Skip to content

Commit 908dc13

Browse files
committed
return resolved Config
1 parent eddc0ff commit 908dc13

32 files changed

+147
-77
lines changed

.changeset/blue-balloons-turn.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@keystone-6/core": minor
3+
---
4+
5+
Renamed `__ResolvedKeystoneConfig` to `ResolvedKeystoneConfig`.
6+
Changed `config` function to return config with defaults instead of just type casting. This now returns `ResolvedKeystoneConfig` instead of `KeystoneConfig`

.changeset/shaggy-beds-know.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@keystone-6/auth": minor
3+
---
4+
5+
Changed type of `withAuth` input to `ResolvedKeystoneConfig` instead of `KeystoneConfig`

packages/auth/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import type {
22
AdminFileToWrite,
33
BaseListTypeInfo,
4-
KeystoneConfig,
54
KeystoneContext,
65
SessionStrategy,
76
BaseKeystoneTypeInfo,
7+
ResolvedKeystoneConfig,
88
} from '@keystone-6/core/types'
99
import { password, timestamp } from '@keystone-6/core/fields'
1010

@@ -134,7 +134,7 @@ export function createAuth<ListTypeInfo extends BaseListTypeInfo> ({
134134
})
135135

136136
function throwIfInvalidConfig<TypeInfo extends BaseKeystoneTypeInfo> (
137-
config: KeystoneConfig<TypeInfo>
137+
config: ResolvedKeystoneConfig<TypeInfo>
138138
) {
139139
if (!(listKey in config.lists)) {
140140
throw new Error(`withAuth cannot find the list "${listKey}"`)
@@ -247,8 +247,8 @@ export function createAuth<ListTypeInfo extends BaseListTypeInfo> ({
247247
* Automatically extends your configuration with a prescriptive implementation.
248248
*/
249249
function withAuth<TypeInfo extends BaseKeystoneTypeInfo> (
250-
config: KeystoneConfig<TypeInfo>
251-
): KeystoneConfig<TypeInfo> {
250+
config: ResolvedKeystoneConfig<TypeInfo>
251+
): ResolvedKeystoneConfig<TypeInfo> {
252252
throwIfInvalidConfig(config)
253253
let { ui } = config
254254
if (!ui?.isDisabled) {

packages/core/src/admin-ui/system/generateAdminUI.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { type GraphQLSchema } from 'graphql'
77
import { type Entry, walk as _walk } from '@nodelib/fs.walk'
88
import {
99
type AdminFileToWrite,
10-
type __ResolvedKeystoneConfig
10+
type ResolvedKeystoneConfig
1111
} from '../../types'
1212
import { writeAdminFiles } from '../templates'
1313
import { type AdminMetaRootVal } from '../../lib/create-admin-meta'
@@ -66,7 +66,7 @@ export async function writeAdminFile (file: AdminFileToWrite, projectAdminPath:
6666
const pageExtensions = new Set(['.js', '.jsx', '.ts', '.tsx'])
6767

6868
export async function generateAdminUI (
69-
config: __ResolvedKeystoneConfig,
69+
config: ResolvedKeystoneConfig,
7070
graphQLSchema: GraphQLSchema,
7171
adminMeta: AdminMetaRootVal,
7272
projectAdminPath: string,

packages/core/src/admin-ui/templates/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import * as Path from 'path'
22
import { type GraphQLSchema } from 'graphql'
3-
import {
4-
type __ResolvedKeystoneConfig
5-
} from '../../types'
3+
import { type ResolvedKeystoneConfig } from '../../types'
64
import { type AdminMetaRootVal } from '../../lib/create-admin-meta'
75
import { appTemplate } from './app'
86
import { homeTemplate } from './home'
@@ -14,7 +12,8 @@ import { nextConfigTemplate } from './next-config'
1412

1513
const pkgDir = Path.dirname(require.resolve('@keystone-6/core/package.json'))
1614

17-
export function writeAdminFiles (config: __ResolvedKeystoneConfig,
15+
export function writeAdminFiles (
16+
config: ResolvedKeystoneConfig,
1817
graphQLSchema: GraphQLSchema,
1918
adminMeta: AdminMetaRootVal,
2019
configFileExists: boolean

packages/core/src/artifacts.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { type ChildProcess } from 'node:child_process'
55
import { printSchema } from 'graphql'
66
import { getGenerators, formatSchema } from '@prisma/internals'
77
import { ExitError } from './scripts/utils'
8-
import { type __ResolvedKeystoneConfig } from './types'
98
import { initialiseLists } from './lib/core/initialise-lists'
109
import {
1110
type System,

packages/core/src/context.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import {
22
type BaseKeystoneTypeInfo,
3-
type KeystoneConfig,
3+
type ResolvedKeystoneConfig,
44
type KeystoneContext
55
} from './types'
66
import { createSystem } from './lib/createSystem'
77

88
export function getContext<TypeInfo extends BaseKeystoneTypeInfo> (
9-
config: KeystoneConfig<TypeInfo>,
9+
config: ResolvedKeystoneConfig<TypeInfo>,
1010
PrismaModule: unknown
1111
): KeystoneContext<TypeInfo> {
1212
const system = createSystem(config)

packages/core/src/fields/types/relationship/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export type RelationshipFieldConfig<ListTypeInfo extends BaseListTypeInfo> =
107107
} & (OneDbConfig | ManyDbConfig) &
108108
(SelectDisplayConfig | CardsDisplayConfig | CountDisplayConfig)
109109

110-
export function relationship <ListTypeInfo extends BaseListTypeInfo>({
110+
export function relationship <ListTypeInfo extends BaseListTypeInfo> ({
111111
ref,
112112
...config
113113
}: RelationshipFieldConfig<ListTypeInfo>): FieldTypeFunc<ListTypeInfo> {

packages/core/src/lib/assets/createFilesContext.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { randomBytes } from 'node:crypto'
22

33
import {
44
type FilesContext,
5-
type __ResolvedKeystoneConfig,
5+
type ResolvedKeystoneConfig,
66
} from '../../types'
77
import { localFileAssetsAPI } from './local'
88
import { s3FileAssetsAPI } from './s3'
@@ -21,7 +21,7 @@ function defaultTransformName (path: string) {
2121
return `${urlSafeName}-${id}`
2222
}
2323

24-
export function createFilesContext (config: __ResolvedKeystoneConfig): FilesContext {
24+
export function createFilesContext (config: ResolvedKeystoneConfig): FilesContext {
2525
const adaptersMap = new Map<string, FileAdapter>()
2626

2727
for (const [storageKey, storageConfig] of Object.entries(config.storage || {})) {

packages/core/src/lib/assets/createImagesContext.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import imageSize from 'image-size'
33

44
import {
55
type ImagesContext,
6-
type __ResolvedKeystoneConfig,
6+
type ResolvedKeystoneConfig,
77
} from '../../types'
88
import type { ImageAdapter } from './types'
99
import { localImageAssetsAPI } from './local'
@@ -33,7 +33,7 @@ async function getImageMetadataFromBuffer (buffer: Buffer) {
3333
return { width, height, filesize: buffer.length, extension }
3434
}
3535

36-
export function createImagesContext (config: __ResolvedKeystoneConfig): ImagesContext {
36+
export function createImagesContext (config: ResolvedKeystoneConfig): ImagesContext {
3737
const imageAssetsAPIs = new Map<string, ImageAdapter>()
3838
for (const [storageKey, storageConfig] of Object.entries(config.storage || {})) {
3939
if (storageConfig.type === 'image') {

0 commit comments

Comments
 (0)