Skip to content

Commit

Permalink
add changeset for types, and remove unused types
Browse files Browse the repository at this point in the history
  • Loading branch information
dcousens committed Apr 8, 2024
1 parent 4fc6857 commit c174127
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 44 deletions.
5 changes: 5 additions & 0 deletions .changeset/less-config-types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystone-6/core': major
---

Removes `AdminUIConfig`, `DatabaseConfig`, `GraphQLConfig` and `ServerConfig` from `@keystone-6/core/types`, and some unused types - instead use `KeystoneConfig['ui']`, `KeystoneConfig['db']` and so on
50 changes: 8 additions & 42 deletions packages/core/src/types/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type express from 'express'
import type { GraphQLSchema } from 'graphql'
import type { Options as BodyParserOptions } from 'body-parser'

import type { AssetMode, BaseKeystoneTypeInfo, KeystoneContext, DatabaseProvider } from '..'
import type { BaseKeystoneTypeInfo, KeystoneContext, DatabaseProvider } from '..'
import type { SessionStrategy } from '../session'
import type { MaybePromise } from '../utils'
import {
Expand Down Expand Up @@ -90,6 +90,13 @@ export type StorageConfig = (
}
) & FileOrImage

// copy of the Prisma's LogLevel types from `src/runtime/getLogLevel.ts`, as we dont have them
type PrismaLogLevel = 'info' | 'query' | 'warn' | 'error'
type PrismaLogDefinition = {
level: PrismaLogLevel
emit: 'stdout' | 'event'
}

export type KeystoneConfig<TypeInfo extends BaseKeystoneTypeInfo = BaseKeystoneTypeInfo> = {
types?: {
path: string
Expand Down Expand Up @@ -267,51 +274,10 @@ export type __ResolvedKeystoneConfig<TypeInfo extends BaseKeystoneTypeInfo = Bas

export type { ListConfig, BaseFields, MaybeSessionFunction, MaybeItemFunction }

// Copy of the Prisma's LogLevel types from `src/runtime/getLogLevel.ts`,
// because they are not exported by Prisma.
type PrismaLogLevel = 'info' | 'query' | 'warn' | 'error'
type PrismaLogDefinition = {
level: PrismaLogLevel
emit: 'stdout' | 'event'
}

export type AdminFileToWrite =
| { mode: 'write', src: string, outputPath: string }
| { mode: 'copy', inputPath: string, outputPath: string }

export type FilesConfig = {
upload: AssetMode
transformFilename?: (str: string) => string
local?: {
/**
* The path local files are uploaded to.
* @default 'public/files'
*/
storagePath?: string
/**
* The base of the URL local files will be served from, outside of keystone.
* @default '/files'
*/
baseUrl?: string
}
}

export type ImagesConfig = {
upload: AssetMode
local?: {
/**
* The path local images are uploaded to.
* @default 'public/images'
*/
storagePath?: string
/**
* The base of the URL local images will be served from, outside of keystone.
* @default '/images'
*/
baseUrl?: string
}
}

export type { ListHooks, ListAccessControl, FieldHooks, FieldAccessControl }
export type {
FieldCreateItemAccessArgs,
Expand Down
2 changes: 0 additions & 2 deletions packages/core/src/types/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ type GraphQLExecutionArguments<TData, TVariables> = {

// Files API

export type AssetMode = 'local' | 's3'

export type FileMetadata = {
filename: string
filesize: number
Expand Down

0 comments on commit c174127

Please sign in to comment.