payload 4.0.0-internal.2fddfc0 → 4.0.0-internal.3aa3d85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/bin.js +11 -0
- package/dist/admin/RichText.d.ts +1 -21
- package/dist/admin/RichText.d.ts.map +1 -1
- package/dist/admin/RichText.js.map +1 -1
- package/dist/admin/forms/Field.d.ts +2 -2
- package/dist/admin/forms/Field.d.ts.map +1 -1
- package/dist/admin/forms/Field.js.map +1 -1
- package/dist/admin/forms/Form.d.ts +0 -29
- package/dist/admin/forms/Form.d.ts.map +1 -1
- package/dist/admin/forms/Form.js.map +1 -1
- package/dist/admin/functions/index.d.ts +1 -1
- package/dist/admin/functions/index.js.map +1 -1
- package/dist/admin/types.d.ts +1 -0
- package/dist/admin/types.d.ts.map +1 -1
- package/dist/admin/types.js.map +1 -1
- package/dist/auth/operations/auth.d.ts +2 -2
- package/dist/auth/operations/auth.d.ts.map +1 -1
- package/dist/auth/operations/auth.js.map +1 -1
- package/dist/auth/operations/login.d.ts +2 -1
- package/dist/auth/operations/login.d.ts.map +1 -1
- package/dist/auth/operations/login.js.map +1 -1
- package/dist/auth/operations/me.js.map +1 -1
- package/dist/auth/operations/refresh.d.ts.map +1 -1
- package/dist/auth/operations/refresh.js +9 -3
- package/dist/auth/operations/refresh.js.map +1 -1
- package/dist/auth/operations/resetPassword.d.ts.map +1 -1
- package/dist/auth/operations/resetPassword.js.map +1 -1
- package/dist/auth/sendVerificationEmail.d.ts +2 -2
- package/dist/auth/sendVerificationEmail.d.ts.map +1 -1
- package/dist/auth/sendVerificationEmail.js +1 -1
- package/dist/auth/sendVerificationEmail.js.map +1 -1
- package/dist/auth/sessions.d.ts +4 -5
- package/dist/auth/sessions.d.ts.map +1 -1
- package/dist/auth/sessions.js +5 -3
- package/dist/auth/sessions.js.map +1 -1
- package/dist/auth/strategies/apiKey.js.map +1 -1
- package/dist/auth/strategies/local/incrementLoginAttempts.d.ts +2 -2
- package/dist/auth/strategies/local/incrementLoginAttempts.d.ts.map +1 -1
- package/dist/auth/strategies/local/incrementLoginAttempts.js +1 -1
- package/dist/auth/strategies/local/incrementLoginAttempts.js.map +1 -1
- package/dist/auth/types.d.ts +28 -21
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/auth/types.js.map +1 -1
- package/dist/bin/generateImportMap/iterateCollections.d.ts.map +1 -1
- package/dist/bin/generateImportMap/iterateCollections.js +10 -0
- package/dist/bin/generateImportMap/iterateCollections.js.map +1 -1
- package/dist/bin/generateImportMap/utilities/resolveImportMapFilePath.d.ts.map +1 -1
- package/dist/bin/generateImportMap/utilities/resolveImportMapFilePath.js +11 -3
- package/dist/bin/generateImportMap/utilities/resolveImportMapFilePath.js.map +1 -1
- package/dist/collections/config/client.d.ts +1 -1
- package/dist/collections/config/client.d.ts.map +1 -1
- package/dist/collections/config/client.js +1 -0
- package/dist/collections/config/client.js.map +1 -1
- package/dist/collections/config/defaults.d.ts +0 -4
- package/dist/collections/config/defaults.d.ts.map +1 -1
- package/dist/collections/config/defaults.js +0 -15
- package/dist/collections/config/defaults.js.map +1 -1
- package/dist/collections/config/types.d.ts +6 -0
- package/dist/collections/config/types.d.ts.map +1 -1
- package/dist/collections/config/types.js.map +1 -1
- package/dist/collections/operations/findDistinct.d.ts.map +1 -1
- package/dist/collections/operations/findDistinct.js +1 -0
- package/dist/collections/operations/findDistinct.js.map +1 -1
- package/dist/collections/operations/local/count.d.ts +3 -3
- package/dist/collections/operations/local/count.d.ts.map +1 -1
- package/dist/collections/operations/local/count.js.map +1 -1
- package/dist/collections/operations/local/countVersions.d.ts +3 -3
- package/dist/collections/operations/local/countVersions.d.ts.map +1 -1
- package/dist/collections/operations/local/countVersions.js.map +1 -1
- package/dist/collections/operations/local/create.d.ts +3 -3
- package/dist/collections/operations/local/create.d.ts.map +1 -1
- package/dist/collections/operations/local/create.js.map +1 -1
- package/dist/collections/operations/local/delete.d.ts +3 -3
- package/dist/collections/operations/local/delete.d.ts.map +1 -1
- package/dist/collections/operations/local/delete.js.map +1 -1
- package/dist/collections/operations/local/duplicate.d.ts +3 -3
- package/dist/collections/operations/local/duplicate.d.ts.map +1 -1
- package/dist/collections/operations/local/duplicate.js.map +1 -1
- package/dist/collections/operations/local/find.d.ts +3 -3
- package/dist/collections/operations/local/find.d.ts.map +1 -1
- package/dist/collections/operations/local/find.js.map +1 -1
- package/dist/collections/operations/local/findByID.d.ts +3 -3
- package/dist/collections/operations/local/findByID.d.ts.map +1 -1
- package/dist/collections/operations/local/findByID.js.map +1 -1
- package/dist/collections/operations/local/findDistinct.d.ts +2 -2
- package/dist/collections/operations/local/findDistinct.d.ts.map +1 -1
- package/dist/collections/operations/local/findDistinct.js.map +1 -1
- package/dist/collections/operations/local/findVersionByID.d.ts +3 -3
- package/dist/collections/operations/local/findVersionByID.d.ts.map +1 -1
- package/dist/collections/operations/local/findVersionByID.js.map +1 -1
- package/dist/collections/operations/local/findVersions.d.ts +3 -3
- package/dist/collections/operations/local/findVersions.d.ts.map +1 -1
- package/dist/collections/operations/local/findVersions.js.map +1 -1
- package/dist/collections/operations/local/restoreVersion.d.ts +3 -3
- package/dist/collections/operations/local/restoreVersion.d.ts.map +1 -1
- package/dist/collections/operations/local/restoreVersion.js.map +1 -1
- package/dist/collections/operations/local/update.d.ts +3 -3
- package/dist/collections/operations/local/update.d.ts.map +1 -1
- package/dist/collections/operations/local/update.js.map +1 -1
- package/dist/collections/operations/utilities/types.d.ts +0 -9
- package/dist/collections/operations/utilities/types.d.ts.map +1 -1
- package/dist/collections/operations/utilities/types.js.map +1 -1
- package/dist/config/client.d.ts +2 -2
- package/dist/config/client.d.ts.map +1 -1
- package/dist/config/client.js.map +1 -1
- package/dist/config/defaults.d.ts +0 -4
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +0 -78
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/definePlugin.d.ts +10 -10
- package/dist/config/definePlugin.d.ts.map +1 -1
- package/dist/config/definePlugin.js +7 -11
- package/dist/config/definePlugin.js.map +1 -1
- package/dist/config/sanitize.d.ts.map +1 -1
- package/dist/config/sanitize.js +137 -13
- package/dist/config/sanitize.js.map +1 -1
- package/dist/config/types.d.ts +35 -3
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js.map +1 -1
- package/dist/exports/internal.d.ts +1 -0
- package/dist/exports/internal.d.ts.map +1 -1
- package/dist/exports/internal.js +1 -0
- package/dist/exports/internal.js.map +1 -1
- package/dist/exports/shared.d.ts +3 -2
- package/dist/exports/shared.d.ts.map +1 -1
- package/dist/exports/shared.js +2 -1
- package/dist/exports/shared.js.map +1 -1
- package/dist/fields/baseFields/slug/countVersions.d.ts.map +1 -1
- package/dist/fields/baseFields/slug/countVersions.js +6 -8
- package/dist/fields/baseFields/slug/countVersions.js.map +1 -1
- package/dist/fields/baseFields/slug/generateSlug.d.ts +14 -7
- package/dist/fields/baseFields/slug/generateSlug.d.ts.map +1 -1
- package/dist/fields/baseFields/slug/generateSlug.js +53 -73
- package/dist/fields/baseFields/slug/generateSlug.js.map +1 -1
- package/dist/fields/baseFields/slug/types.d.ts +14 -0
- package/dist/fields/baseFields/slug/types.d.ts.map +1 -0
- package/dist/fields/baseFields/slug/types.js +6 -0
- package/dist/fields/baseFields/slug/types.js.map +1 -0
- package/dist/fields/config/client.d.ts +1 -1
- package/dist/fields/config/client.d.ts.map +1 -1
- package/dist/fields/config/client.js +2 -1
- package/dist/fields/config/client.js.map +1 -1
- package/dist/fields/config/sanitize.d.ts.map +1 -1
- package/dist/fields/config/sanitize.js +39 -0
- package/dist/fields/config/sanitize.js.map +1 -1
- package/dist/fields/config/types.d.ts +44 -8
- package/dist/fields/config/types.d.ts.map +1 -1
- package/dist/fields/config/types.js.map +1 -1
- package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/promise.js +11 -1
- package/dist/fields/hooks/afterRead/promise.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/promise.js +10 -1
- package/dist/fields/hooks/beforeValidate/promise.js.map +1 -1
- package/dist/fields/setDefaultBeforeDuplicate.js +1 -0
- package/dist/fields/setDefaultBeforeDuplicate.js.map +1 -1
- package/dist/fields/sortableFieldTypes.d.ts.map +1 -1
- package/dist/fields/sortableFieldTypes.js +1 -0
- package/dist/fields/sortableFieldTypes.js.map +1 -1
- package/dist/fields/validations.d.ts +4 -1
- package/dist/fields/validations.d.ts.map +1 -1
- package/dist/fields/validations.js +7 -0
- package/dist/fields/validations.js.map +1 -1
- package/dist/globals/operations/local/countVersions.d.ts +3 -3
- package/dist/globals/operations/local/countVersions.d.ts.map +1 -1
- package/dist/globals/operations/local/countVersions.js.map +1 -1
- package/dist/globals/operations/local/findOne.d.ts +3 -3
- package/dist/globals/operations/local/findOne.d.ts.map +1 -1
- package/dist/globals/operations/local/findOne.js.map +1 -1
- package/dist/globals/operations/local/findVersionByID.d.ts +3 -3
- package/dist/globals/operations/local/findVersionByID.d.ts.map +1 -1
- package/dist/globals/operations/local/findVersionByID.js.map +1 -1
- package/dist/globals/operations/local/findVersions.d.ts +3 -3
- package/dist/globals/operations/local/findVersions.d.ts.map +1 -1
- package/dist/globals/operations/local/findVersions.js.map +1 -1
- package/dist/globals/operations/local/restoreVersion.d.ts +3 -3
- package/dist/globals/operations/local/restoreVersion.d.ts.map +1 -1
- package/dist/globals/operations/local/restoreVersion.js.map +1 -1
- package/dist/globals/operations/local/update.d.ts +3 -3
- package/dist/globals/operations/local/update.d.ts.map +1 -1
- package/dist/globals/operations/local/update.js.map +1 -1
- package/dist/index.bundled.d.ts +365 -300
- package/dist/index.d.ts +59 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/preferences/keys.d.ts +4 -0
- package/dist/preferences/keys.d.ts.map +1 -1
- package/dist/preferences/keys.js +4 -1
- package/dist/preferences/keys.js.map +1 -1
- package/dist/preferences/types.d.ts +15 -0
- package/dist/preferences/types.d.ts.map +1 -1
- package/dist/preferences/types.js +3 -1
- package/dist/preferences/types.js.map +1 -1
- package/dist/types/index.d.ts +8 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/uploads/fetchAPI-multipart/processMultipart.d.ts.map +1 -1
- package/dist/uploads/fetchAPI-multipart/processMultipart.js +1 -14
- package/dist/uploads/fetchAPI-multipart/processMultipart.js.map +1 -1
- package/dist/uploads/matchMimeType.d.ts +8 -0
- package/dist/uploads/matchMimeType.d.ts.map +1 -0
- package/dist/uploads/matchMimeType.js +19 -0
- package/dist/uploads/matchMimeType.js.map +1 -0
- package/dist/uploads/matchMimeType.spec.js +66 -0
- package/dist/uploads/matchMimeType.spec.js.map +1 -0
- package/dist/uploads/types.d.ts +21 -0
- package/dist/uploads/types.d.ts.map +1 -1
- package/dist/uploads/types.js.map +1 -1
- package/dist/utilities/addDataAndFileToRequest.d.ts.map +1 -1
- package/dist/utilities/addDataAndFileToRequest.js +6 -0
- package/dist/utilities/addDataAndFileToRequest.js.map +1 -1
- package/dist/utilities/configToJSONSchema.d.ts +13 -4
- package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
- package/dist/utilities/configToJSONSchema.js +139 -61
- package/dist/utilities/configToJSONSchema.js.map +1 -1
- package/dist/utilities/configToJSONSchema.spec.js +319 -0
- package/dist/utilities/configToJSONSchema.spec.js.map +1 -1
- package/dist/utilities/createLocalReq.d.ts +2 -2
- package/dist/utilities/createLocalReq.d.ts.map +1 -1
- package/dist/utilities/createLocalReq.js.map +1 -1
- package/dist/utilities/createPayloadRequest.d.ts.map +1 -1
- package/dist/utilities/createPayloadRequest.js +1 -0
- package/dist/utilities/createPayloadRequest.js.map +1 -1
- package/dist/utilities/getEntityPermissions/getEntityPermissions.d.ts.map +1 -1
- package/dist/utilities/getEntityPermissions/getEntityPermissions.js +2 -0
- package/dist/utilities/getEntityPermissions/getEntityPermissions.js.map +1 -1
- package/dist/utilities/getEntityPermissions/populateFieldPermissions.d.ts +7 -1
- package/dist/utilities/getEntityPermissions/populateFieldPermissions.d.ts.map +1 -1
- package/dist/utilities/getEntityPermissions/populateFieldPermissions.js +19 -2
- package/dist/utilities/getEntityPermissions/populateFieldPermissions.js.map +1 -1
- package/dist/utilities/isURLAllowed.d.ts.map +1 -1
- package/dist/utilities/isURLAllowed.js +9 -3
- package/dist/utilities/isURLAllowed.js.map +1 -1
- package/dist/utilities/isURLAllowed.spec.js +78 -0
- package/dist/utilities/isURLAllowed.spec.js.map +1 -0
- package/dist/utilities/telemetry/conf/envPaths.d.ts.map +1 -1
- package/dist/utilities/telemetry/conf/envPaths.js +40 -31
- package/dist/utilities/telemetry/conf/envPaths.js.map +1 -1
- package/dist/utilities/telemetry/events/adminInit.d.ts.map +1 -1
- package/dist/utilities/telemetry/events/adminInit.js +2 -3
- package/dist/utilities/telemetry/events/adminInit.js.map +1 -1
- package/dist/utilities/telemetry/events/serverInit.d.ts.map +1 -1
- package/dist/utilities/telemetry/events/serverInit.js +2 -3
- package/dist/utilities/telemetry/events/serverInit.js.map +1 -1
- package/dist/utilities/telemetry/index.d.ts +14 -3
- package/dist/utilities/telemetry/index.d.ts.map +1 -1
- package/dist/utilities/telemetry/index.js +6 -1
- package/dist/utilities/telemetry/index.js.map +1 -1
- package/dist/utilities/telemetry/index.spec.js +43 -0
- package/dist/utilities/telemetry/index.spec.js.map +1 -0
- package/dist/versions/schedule/job.js.map +1 -1
- package/package.json +3 -3
- package/dist/fields/baseFields/slug/index.d.ts +0 -89
- package/dist/fields/baseFields/slug/index.d.ts.map +0 -1
- package/dist/fields/baseFields/slug/index.js +0 -81
- package/dist/fields/baseFields/slug/index.js.map +0 -1
- package/dist/utilities/isRSCEnabled.d.ts +0 -12
- package/dist/utilities/isRSCEnabled.d.ts.map +0 -1
- package/dist/utilities/isRSCEnabled.js +0 -14
- package/dist/utilities/isRSCEnabled.js.map +0 -1
|
@@ -66,6 +66,325 @@ describe('configToJSONSchema', ()=>{
|
|
|
66
66
|
title: 'Test'
|
|
67
67
|
});
|
|
68
68
|
});
|
|
69
|
+
it('should generate separate input types when generateInputTypes is enabled', async ()=>{
|
|
70
|
+
// @ts-expect-error partial config
|
|
71
|
+
const config = {
|
|
72
|
+
collections: [
|
|
73
|
+
{
|
|
74
|
+
slug: 'authors',
|
|
75
|
+
fields: [
|
|
76
|
+
{
|
|
77
|
+
name: 'name',
|
|
78
|
+
type: 'text'
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
slug: 'categories',
|
|
84
|
+
fields: [
|
|
85
|
+
{
|
|
86
|
+
name: 'title',
|
|
87
|
+
type: 'text'
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
slug: 'posts',
|
|
93
|
+
fields: [
|
|
94
|
+
{
|
|
95
|
+
name: 'title',
|
|
96
|
+
type: 'text',
|
|
97
|
+
required: true
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: 'status',
|
|
101
|
+
type: 'select',
|
|
102
|
+
defaultValue: 'draft',
|
|
103
|
+
options: [
|
|
104
|
+
'draft',
|
|
105
|
+
'published'
|
|
106
|
+
],
|
|
107
|
+
required: true
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: 'author',
|
|
111
|
+
type: 'relationship',
|
|
112
|
+
relationTo: 'authors'
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: 'categories',
|
|
116
|
+
type: 'relationship',
|
|
117
|
+
hasMany: true,
|
|
118
|
+
relationTo: 'categories'
|
|
119
|
+
}
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
],
|
|
123
|
+
typescript: {
|
|
124
|
+
generateInputTypes: true
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
const sanitizedConfig = await sanitizeConfig(config);
|
|
128
|
+
const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text');
|
|
129
|
+
// Output (read) shape is unchanged: relationships may be populated, managed fields are present,
|
|
130
|
+
// and a required field with a defaultValue stays required.
|
|
131
|
+
const postsOutput = schema?.$defs?.posts;
|
|
132
|
+
expect(postsOutput.title).toBe('Post');
|
|
133
|
+
expect(postsOutput.properties.author).toStrictEqual({
|
|
134
|
+
oneOf: [
|
|
135
|
+
{
|
|
136
|
+
type: [
|
|
137
|
+
'string',
|
|
138
|
+
'null'
|
|
139
|
+
]
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
$ref: '#/$defs/authors'
|
|
143
|
+
}
|
|
144
|
+
]
|
|
145
|
+
});
|
|
146
|
+
expect(postsOutput.properties.categories).toStrictEqual({
|
|
147
|
+
type: [
|
|
148
|
+
'array',
|
|
149
|
+
'null'
|
|
150
|
+
],
|
|
151
|
+
items: {
|
|
152
|
+
oneOf: [
|
|
153
|
+
{
|
|
154
|
+
type: 'string'
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
$ref: '#/$defs/categories'
|
|
158
|
+
}
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
expect(postsOutput.required).toStrictEqual([
|
|
163
|
+
'id',
|
|
164
|
+
'title',
|
|
165
|
+
'status',
|
|
166
|
+
'updatedAt',
|
|
167
|
+
'createdAt'
|
|
168
|
+
]);
|
|
169
|
+
// Input (write) shape: relationships are ID-only, the defaultValue field is optional, `id` is
|
|
170
|
+
// optional, and createdAt/updatedAt are dropped. `id` and the defaulted `status` are optional
|
|
171
|
+
// but NOT nullable - nullability follows the read shape, where they're non-null.
|
|
172
|
+
expect(schema?.$defs?.posts_input).toStrictEqual({
|
|
173
|
+
type: 'object',
|
|
174
|
+
additionalProperties: false,
|
|
175
|
+
properties: {
|
|
176
|
+
id: {
|
|
177
|
+
type: 'string'
|
|
178
|
+
},
|
|
179
|
+
title: {
|
|
180
|
+
type: 'string'
|
|
181
|
+
},
|
|
182
|
+
status: {
|
|
183
|
+
type: 'string',
|
|
184
|
+
enum: [
|
|
185
|
+
'draft',
|
|
186
|
+
'published'
|
|
187
|
+
]
|
|
188
|
+
},
|
|
189
|
+
author: {
|
|
190
|
+
type: [
|
|
191
|
+
'string',
|
|
192
|
+
'null'
|
|
193
|
+
]
|
|
194
|
+
},
|
|
195
|
+
categories: {
|
|
196
|
+
type: [
|
|
197
|
+
'array',
|
|
198
|
+
'null'
|
|
199
|
+
],
|
|
200
|
+
items: {
|
|
201
|
+
type: 'string'
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
required: [
|
|
206
|
+
'title'
|
|
207
|
+
],
|
|
208
|
+
title: 'PostInput'
|
|
209
|
+
});
|
|
210
|
+
// The Config type exposes input shapes under `collectionsInput`.
|
|
211
|
+
expect(schema?.properties?.collectionsInput?.properties?.posts).toStrictEqual({
|
|
212
|
+
$ref: '#/$defs/posts_input'
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
it('should skip input types by default and generate them when enabled', async ()=>{
|
|
216
|
+
// @ts-expect-error partial config
|
|
217
|
+
const offByDefault = {
|
|
218
|
+
collections: [
|
|
219
|
+
{
|
|
220
|
+
slug: 'posts',
|
|
221
|
+
fields: [
|
|
222
|
+
{
|
|
223
|
+
name: 'title',
|
|
224
|
+
type: 'text'
|
|
225
|
+
}
|
|
226
|
+
]
|
|
227
|
+
}
|
|
228
|
+
]
|
|
229
|
+
};
|
|
230
|
+
const { jsonSchema: defaultSchema } = configToJSONSchema(await sanitizeConfig(offByDefault), 'text');
|
|
231
|
+
expect(defaultSchema?.$defs?.posts_input).toBeUndefined();
|
|
232
|
+
expect(defaultSchema?.properties?.collectionsInput).toBeUndefined();
|
|
233
|
+
// @ts-expect-error partial config
|
|
234
|
+
const enabled = {
|
|
235
|
+
collections: [
|
|
236
|
+
{
|
|
237
|
+
slug: 'posts',
|
|
238
|
+
fields: [
|
|
239
|
+
{
|
|
240
|
+
name: 'title',
|
|
241
|
+
type: 'text'
|
|
242
|
+
}
|
|
243
|
+
]
|
|
244
|
+
}
|
|
245
|
+
],
|
|
246
|
+
typescript: {
|
|
247
|
+
generateInputTypes: true
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
const { jsonSchema: enabledSchema } = configToJSONSchema(await sanitizeConfig(enabled), 'text');
|
|
251
|
+
expect(enabledSchema?.$defs?.posts_input).toBeDefined();
|
|
252
|
+
expect(enabledSchema?.properties?.collectionsInput).toBeDefined();
|
|
253
|
+
});
|
|
254
|
+
it('should generate Input-suffixed definitions for named interfaces and blocks', async ()=>{
|
|
255
|
+
// @ts-expect-error partial config
|
|
256
|
+
const config = {
|
|
257
|
+
collections: [
|
|
258
|
+
{
|
|
259
|
+
slug: 'authors',
|
|
260
|
+
fields: [
|
|
261
|
+
{
|
|
262
|
+
name: 'name',
|
|
263
|
+
type: 'text'
|
|
264
|
+
}
|
|
265
|
+
]
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
slug: 'pages',
|
|
269
|
+
fields: [
|
|
270
|
+
{
|
|
271
|
+
name: 'meta',
|
|
272
|
+
type: 'group',
|
|
273
|
+
interfaceName: 'Meta',
|
|
274
|
+
fields: [
|
|
275
|
+
{
|
|
276
|
+
name: 'author',
|
|
277
|
+
type: 'relationship',
|
|
278
|
+
relationTo: 'authors'
|
|
279
|
+
}
|
|
280
|
+
]
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
name: 'layout',
|
|
284
|
+
type: 'blocks',
|
|
285
|
+
blocks: [
|
|
286
|
+
{
|
|
287
|
+
slug: 'hero',
|
|
288
|
+
fields: [
|
|
289
|
+
{
|
|
290
|
+
name: 'heading',
|
|
291
|
+
type: 'text',
|
|
292
|
+
required: true
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
name: 'cta',
|
|
296
|
+
type: 'relationship',
|
|
297
|
+
relationTo: 'authors'
|
|
298
|
+
}
|
|
299
|
+
]
|
|
300
|
+
}
|
|
301
|
+
]
|
|
302
|
+
}
|
|
303
|
+
]
|
|
304
|
+
}
|
|
305
|
+
],
|
|
306
|
+
typescript: {
|
|
307
|
+
generateInputTypes: true
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
const sanitizedConfig = await sanitizeConfig(config);
|
|
311
|
+
const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text');
|
|
312
|
+
// Read-shaped named interface keeps the populated-doc union...
|
|
313
|
+
expect((schema?.$defs?.Meta).properties.author).toStrictEqual({
|
|
314
|
+
oneOf: [
|
|
315
|
+
{
|
|
316
|
+
type: [
|
|
317
|
+
'string',
|
|
318
|
+
'null'
|
|
319
|
+
]
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
$ref: '#/$defs/authors'
|
|
323
|
+
}
|
|
324
|
+
]
|
|
325
|
+
});
|
|
326
|
+
// ...and a separate `Input` definition is ID-only, so the two don't collide.
|
|
327
|
+
expect((schema?.$defs?.MetaInput).properties.author).toStrictEqual({
|
|
328
|
+
type: [
|
|
329
|
+
'string',
|
|
330
|
+
'null'
|
|
331
|
+
]
|
|
332
|
+
});
|
|
333
|
+
// Blocks get the same treatment: read-shaped `Hero`, write-shaped `HeroInput`.
|
|
334
|
+
const heroInput = schema?.$defs?.HeroInput;
|
|
335
|
+
expect(heroInput.properties.cta).toStrictEqual({
|
|
336
|
+
type: [
|
|
337
|
+
'string',
|
|
338
|
+
'null'
|
|
339
|
+
]
|
|
340
|
+
});
|
|
341
|
+
expect(heroInput.required).toStrictEqual([
|
|
342
|
+
'blockType',
|
|
343
|
+
'heading'
|
|
344
|
+
]);
|
|
345
|
+
expect((schema?.$defs?.Hero).properties.cta).toStrictEqual({
|
|
346
|
+
oneOf: [
|
|
347
|
+
{
|
|
348
|
+
type: [
|
|
349
|
+
'string',
|
|
350
|
+
'null'
|
|
351
|
+
]
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
$ref: '#/$defs/authors'
|
|
355
|
+
}
|
|
356
|
+
]
|
|
357
|
+
});
|
|
358
|
+
});
|
|
359
|
+
it('passes the variant to field-level jsonSchema transforms', async ()=>{
|
|
360
|
+
// @ts-expect-error partial config
|
|
361
|
+
const config = {
|
|
362
|
+
collections: [
|
|
363
|
+
{
|
|
364
|
+
slug: 'posts',
|
|
365
|
+
fields: [
|
|
366
|
+
{
|
|
367
|
+
name: 'custom',
|
|
368
|
+
type: 'text',
|
|
369
|
+
jsonSchema: [
|
|
370
|
+
({ jsonSchema, variant })=>({
|
|
371
|
+
...jsonSchema,
|
|
372
|
+
description: variant
|
|
373
|
+
})
|
|
374
|
+
]
|
|
375
|
+
}
|
|
376
|
+
]
|
|
377
|
+
}
|
|
378
|
+
],
|
|
379
|
+
typescript: {
|
|
380
|
+
generateInputTypes: true
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
const sanitizedConfig = await sanitizeConfig(config);
|
|
384
|
+
const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text');
|
|
385
|
+
expect((schema?.$defs?.posts).properties.custom.description).toBe('output');
|
|
386
|
+
expect((schema?.$defs?.posts_input).properties.custom.description).toBe('input');
|
|
387
|
+
});
|
|
69
388
|
it('should handle block fields with no blocks', async ()=>{
|
|
70
389
|
// @ts-expect-error
|
|
71
390
|
const config = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/configToJSONSchema.spec.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\nimport { describe, it, expect } from 'vitest'\n\nimport type { Config } from '../config/types.js'\n\nimport { sanitizeConfig } from '../config/sanitize.js'\nimport { configToJSONSchema, entityToStandaloneJSONSchema } from './configToJSONSchema.js'\nimport type { Block, BlocksField, RichTextField } from '../fields/config/types.js'\n\ndescribe('configToJSONSchema', () => {\n it('should handle optional arrays with required fields', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'someRequiredField',\n type: 'array',\n fields: [\n {\n name: 'someRequiredField',\n type: 'text',\n required: true,\n },\n ],\n },\n ],\n timestamps: false,\n versions: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.$defs?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n someRequiredField: {\n type: ['array', 'null'],\n items: {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: ['string', 'null'],\n },\n someRequiredField: {\n type: 'string',\n },\n },\n required: ['someRequiredField'],\n },\n },\n },\n required: ['id'],\n title: 'Test',\n })\n })\n\n it('should handle block fields with no blocks', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'blockField',\n type: 'blocks',\n blocks: [],\n },\n {\n name: 'blockFieldRequired',\n type: 'blocks',\n blocks: [],\n required: true,\n },\n {\n name: 'blockFieldWithFields',\n type: 'blocks',\n blocks: [\n {\n slug: 'test',\n fields: [\n {\n name: 'field',\n type: 'text',\n },\n ],\n },\n ],\n },\n {\n name: 'blockFieldWithFieldsRequired',\n type: 'blocks',\n blocks: [\n {\n slug: 'testRequired',\n fields: [\n {\n name: 'field',\n type: 'text',\n required: true,\n },\n ],\n },\n ],\n },\n ],\n timestamps: false,\n versions: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.$defs?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n blockField: {\n type: ['array', 'null'],\n items: {},\n },\n blockFieldRequired: {\n type: 'array',\n items: {},\n },\n blockFieldWithFields: {\n type: ['array', 'null'],\n items: {\n oneOf: [{ $ref: '#/$defs/Test' }],\n },\n },\n blockFieldWithFieldsRequired: {\n type: ['array', 'null'],\n items: {\n oneOf: [{ $ref: '#/$defs/TestRequired' }],\n },\n },\n },\n required: ['id', 'blockFieldRequired'],\n title: 'Test',\n })\n })\n\n it('keeps the first block interface name clean and content-hashes the colliding one', async () => {\n // @ts-expect-error - partial config for testing\n const config: Config = {\n collections: [\n {\n slug: 'pages',\n fields: [\n {\n name: 'layout',\n type: 'blocks',\n blocks: [\n { slug: 'hero', fields: [{ name: 'title', type: 'text' }] },\n { slug: 'cta', fields: [{ name: 'label', type: 'text' }] },\n ],\n },\n ],\n timestamps: false,\n versions: false,\n },\n {\n slug: 'posts',\n fields: [\n {\n name: 'layout',\n type: 'blocks',\n // Same slug `hero`, DIFFERENT fields → name collision with pages' hero.\n blocks: [{ slug: 'hero', fields: [{ name: 'heading', type: 'text' }] }],\n },\n ],\n timestamps: false,\n versions: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text')\n const defs = schema.$defs!\n\n // The first `hero` keeps the clean name; the unique block is unaffected.\n expect(defs.Hero).toBeDefined()\n expect(defs.Cta).toBeDefined()\n\n // Only the second, differently-shaped `hero` is disambiguated with a content hash.\n const hashedHeroNames = Object.keys(defs).filter((k) => /^Hero_[0-9A-F]{8}$/.test(k))\n expect(hashedHeroNames).toHaveLength(1)\n\n // The disambiguated interface carries the explanatory JSDoc note; the clean one does not.\n expect((defs[hashedHeroNames[0]!] as { description?: string }).description).toContain(\n 'content hash',\n )\n expect((defs.Hero as { description?: string }).description).toBeUndefined()\n\n // Each collection's block field references its own block's interface.\n const refsOf = (slug: string): string[] =>\n (\n defs[slug] as { properties: { layout: { items: { oneOf: Array<{ $ref: string }> } } } }\n ).properties.layout.items.oneOf.map((r) => r.$ref)\n expect(refsOf('pages')).toContain('#/$defs/Hero')\n expect(refsOf('pages')).toContain('#/$defs/Cta')\n expect(refsOf('posts')).toStrictEqual([`#/$defs/${hashedHeroNames[0]}`])\n\n // Hashing is deterministic: regenerating yields identical names.\n const { jsonSchema: schema2 } = configToJSONSchema(sanitizedConfig, 'text')\n expect(\n Object.keys(schema2.$defs!)\n .filter((k) => /^Hero/.test(k))\n .sort(),\n ).toStrictEqual(\n Object.keys(defs)\n .filter((k) => /^Hero/.test(k))\n .sort(),\n )\n })\n\n it('should handle tabs and named tabs with required fields', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n type: 'tabs',\n tabs: [\n {\n fields: [\n {\n name: 'fieldInUnnamedTab',\n type: 'text',\n },\n ],\n label: 'unnamedTab',\n },\n {\n name: 'namedTab',\n fields: [\n {\n name: 'fieldInNamedTab',\n type: 'text',\n },\n ],\n label: 'namedTab',\n },\n {\n name: 'namedTabWithRequired',\n fields: [\n {\n name: 'fieldInNamedTab',\n type: 'text',\n required: true,\n },\n ],\n label: 'namedTabWithRequired',\n },\n ],\n },\n ],\n timestamps: false,\n versions: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.$defs?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n fieldInUnnamedTab: {\n type: ['string', 'null'],\n },\n namedTab: {\n type: 'object',\n additionalProperties: false,\n properties: {\n fieldInNamedTab: {\n type: ['string', 'null'],\n },\n },\n required: [],\n },\n namedTabWithRequired: {\n type: 'object',\n additionalProperties: false,\n properties: {\n fieldInNamedTab: {\n type: 'string',\n },\n },\n required: ['fieldInNamedTab'],\n },\n },\n required: ['id', 'namedTabWithRequired'],\n title: 'Test',\n })\n })\n\n it('should handle custom typescript schema and JSON field schema', async () => {\n const customSchema: JSONSchema4 = {\n type: 'object',\n properties: {\n id: {\n type: 'number',\n },\n required: ['id'],\n },\n }\n\n const config: Partial<Config> = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'withCustom',\n type: 'text',\n jsonSchema: [() => customSchema],\n },\n {\n name: 'jsonWithSchema',\n type: 'json',\n jsonSchema: {\n fileMatch: ['a://b/foo.json'],\n schema: customSchema,\n uri: 'a://b/foo.json',\n },\n },\n ],\n timestamps: false,\n versions: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config as Config)\n const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.$defs?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n jsonWithSchema: customSchema,\n withCustom: customSchema,\n },\n required: ['id'],\n title: 'Test',\n })\n })\n\n it('should handle same block object being referenced in both collection and config.blocks', async () => {\n const sharedBlock: Block = {\n slug: 'sharedBlock',\n interfaceName: 'SharedBlock',\n fields: [\n {\n name: 'richText',\n type: 'richText',\n editor: () => {\n // stub rich text editor\n return {\n CellComponent: '',\n FieldComponent: '',\n validate: () => true,\n }\n },\n },\n ],\n }\n\n // @ts-expect-error\n const config: Config = {\n blocks: [sharedBlock],\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'someBlockField',\n type: 'blocks',\n blocks: [sharedBlock],\n },\n ],\n timestamps: false,\n versions: false,\n },\n ],\n }\n\n // Ensure both rich text editor are sanitized\n const sanitizedConfig = await sanitizeConfig(config)\n expect(typeof (sanitizedConfig?.blocks?.[0]?.fields?.[0] as RichTextField)?.editor).toBe(\n 'object',\n )\n expect(\n typeof (\n (sanitizedConfig.collections[0].fields[0] as BlocksField)?.blocks?.[0]\n ?.fields?.[0] as RichTextField\n )?.editor,\n ).toBe('object')\n\n const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text')\n\n const expectedBlockSchema = {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: { type: ['string', 'null'] },\n blockName: { type: ['string', 'null'] },\n blockType: { const: 'sharedBlock' },\n richText: { type: ['array', 'null'], items: { type: 'object' } },\n },\n required: ['blockType'],\n }\n\n expect(schema?.$defs?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n title: 'Test',\n properties: {\n id: {\n type: 'string',\n },\n someBlockField: {\n type: ['array', 'null'],\n items: {\n oneOf: [\n {\n $ref: '#/$defs/SharedBlock',\n },\n ],\n },\n },\n },\n required: ['id'],\n })\n\n // The definition should still be registered for TypeScript type generation\n expect(schema?.$defs?.SharedBlock).toStrictEqual(expectedBlockSchema)\n })\n\n it('content-hashes a colliding explicit interfaceName instead of overwriting it', async () => {\n // Two different blocks both set `interfaceName: 'Hero'` - each must keep its own definition.\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'blocksField',\n type: 'blocks',\n blocks: [\n {\n slug: 'blockA',\n fields: [{ name: 'title', type: 'text' }],\n interfaceName: 'Hero',\n },\n {\n slug: 'blockB',\n fields: [{ name: 'subtitle', type: 'number' }],\n interfaceName: 'Hero',\n },\n ],\n },\n ],\n timestamps: false,\n versions: false,\n },\n ],\n } as unknown as Config\n\n const sanitizedConfig = await sanitizeConfig(config)\n const { jsonSchema } = configToJSONSchema(sanitizedConfig, 'text')\n const defs = jsonSchema.$defs!\n\n // Each differently-shaped block keeps its own interface (one clean, one hash-suffixed).\n const heroNames = Object.keys(defs).filter((k) => /^Hero(_[0-9A-F]{8})?$/.test(k))\n expect(heroNames).toHaveLength(2)\n\n // ...and they carry distinct field shapes (not a silent overwrite).\n const shapeOf = (name: string): string =>\n Object.keys((defs[name] as { properties: Record<string, unknown> }).properties)\n .sort()\n .join(',')\n expect(shapeOf(heroNames[0]!)).not.toBe(shapeOf(heroNames[1]!))\n })\n\n it('reuses one definition when the same block is registered more than once', async () => {\n // Reusing one block across fields registers an identical schema each time, so it dedupes.\n const heroBlock = {\n slug: 'hero',\n fields: [{ name: 'title', type: 'text' }],\n interfaceName: 'Hero',\n }\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n { name: 'a', type: 'blocks', blocks: [heroBlock] },\n { name: 'b', type: 'blocks', blocks: [heroBlock] },\n ],\n timestamps: false,\n versions: false,\n },\n ],\n } as unknown as Config\n\n const sanitizedConfig = await sanitizeConfig(config)\n const { jsonSchema } = configToJSONSchema(sanitizedConfig, 'text')\n\n const heroNames = Object.keys(jsonSchema.$defs!).filter((k) => /^Hero(_[0-9A-F]{8})?$/.test(k))\n expect(heroNames).toEqual(['Hero'])\n })\n\n it('should allow overriding required to false', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'title',\n type: 'text',\n required: true,\n defaultValue: 'test',\n jsonSchema: [\n () => ({\n type: 'string',\n required: false,\n }),\n ],\n },\n ],\n timestamps: false,\n versions: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text')\n\n // @ts-expect-error\n expect(schema.$defs.test.properties.title.required).toStrictEqual(false)\n })\n\n it('should propagate forceInlineBlocks to nested fields (array, group, tab)', async () => {\n const namedBlock: Block = {\n slug: 'myBlock',\n interfaceName: 'MyBlock',\n fields: [{ name: 'text', type: 'text' }],\n }\n\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'arr',\n type: 'array',\n fields: [{ name: 'blocks', type: 'blocks', blocks: [namedBlock] }],\n },\n {\n name: 'grp',\n type: 'group',\n fields: [{ name: 'blocks', type: 'blocks', blocks: [namedBlock] }],\n },\n ],\n timestamps: false,\n versions: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n\n // Without forceInlineBlocks: blocks field uses $ref\n const { jsonSchema: schemaDefault } = configToJSONSchema(sanitizedConfig, 'text')\n const arrItemsDefault = schemaDefault.$defs!.test.properties!.arr.items as JSONSchema4\n const arrBlocksDefault = (arrItemsDefault.properties!.blocks.items as JSONSchema4).oneOf![0]\n expect(arrBlocksDefault).toStrictEqual({ $ref: '#/$defs/MyBlock' })\n\n // With forceInlineBlocks: blocks field is inlined, no $ref\n const { jsonSchema: schemaInline } = configToJSONSchema(sanitizedConfig, 'text', undefined, {\n forceInlineBlocks: true,\n })\n const arrItemsInline = schemaInline.$defs!.test.properties!.arr.items as JSONSchema4\n const arrBlocksInline = (arrItemsInline.properties!.blocks.items as JSONSchema4).oneOf![0]\n expect(arrBlocksInline).not.toHaveProperty('$ref')\n expect(arrBlocksInline.properties?.blockType).toStrictEqual({ const: 'myBlock' })\n\n const grpBlocksInline = (\n schemaInline.$defs!.test.properties!.grp.properties!.blocks.items as JSONSchema4\n ).oneOf![0]\n expect(grpBlocksInline).not.toHaveProperty('$ref')\n expect(grpBlocksInline.properties?.blockType).toStrictEqual({ const: 'myBlock' })\n })\n\n it('entityToStandaloneJSONSchema bundles only the definitions an entity references', async () => {\n const sharedBlock: Block = {\n slug: 'sharedBlock',\n interfaceName: 'SharedBlock',\n fields: [{ name: 'title', type: 'text' }],\n }\n\n // @ts-expect-error partial config\n const config: Config = {\n admin: {\n timezones: {\n supportedTimezones: [\n { label: 'UTC', value: 'UTC' },\n { label: 'New York', value: 'America/New_York' },\n ],\n },\n },\n blocks: [sharedBlock],\n collections: [\n {\n slug: 'with-refs',\n fields: [\n { name: 'layout', type: 'blocks', blocks: ['sharedBlock'] },\n { name: 'when', type: 'date', timezone: true },\n ],\n timestamps: false,\n versions: false,\n },\n {\n slug: 'other',\n fields: [{ name: 'title', type: 'text' }],\n timestamps: false,\n versions: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const entity = sanitizedConfig.collections.find(\n (collection) => collection.slug === 'with-refs',\n )!\n\n const schema = entityToStandaloneJSONSchema({\n config: sanitizedConfig,\n defaultIDType: 'text',\n entity,\n })\n\n // Has its own $schema, so it resolves on its own.\n expect(schema.$schema).toBe('https://json-schema.org/draft/2020-12/schema')\n\n // The block reference is resolved inline, so it can't dangle.\n const layoutItems = (schema.properties?.layout as JSONSchema4)?.items as JSONSchema4\n const inlinedBlock = (layoutItems?.oneOf?.[0] ?? {}) as JSONSchema4\n expect(inlinedBlock.properties?.blockType).toStrictEqual({ const: 'sharedBlock' })\n expect(inlinedBlock.properties?.title).toBeDefined()\n\n // A timezone field pulls in supportedTimezones from the root config.\n expect(schema.$defs?.supportedTimezones).toBeDefined()\n\n // Doesn't pull in unrelated collections.\n expect(schema.$defs?.other).toBeUndefined()\n })\n})\n"],"names":["describe","it","expect","sanitizeConfig","configToJSONSchema","entityToStandaloneJSONSchema","config","collections","slug","fields","name","type","required","timestamps","versions","sanitizedConfig","jsonSchema","schema","$defs","test","toStrictEqual","additionalProperties","properties","id","someRequiredField","items","title","blocks","blockField","blockFieldRequired","blockFieldWithFields","oneOf","$ref","blockFieldWithFieldsRequired","defs","Hero","toBeDefined","Cta","hashedHeroNames","Object","keys","filter","k","toHaveLength","description","toContain","toBeUndefined","refsOf","layout","map","r","schema2","sort","tabs","label","fieldInUnnamedTab","namedTab","fieldInNamedTab","namedTabWithRequired","customSchema","fileMatch","uri","jsonWithSchema","withCustom","sharedBlock","interfaceName","editor","CellComponent","FieldComponent","validate","toBe","expectedBlockSchema","blockName","blockType","const","richText","someBlockField","SharedBlock","heroNames","shapeOf","join","not","heroBlock","toEqual","defaultValue","namedBlock","schemaDefault","arrItemsDefault","arr","arrBlocksDefault","schemaInline","undefined","forceInlineBlocks","arrItemsInline","arrBlocksInline","toHaveProperty","grpBlocksInline","grp","admin","timezones","supportedTimezones","value","timezone","entity","find","collection","defaultIDType","$schema","layoutItems","inlinedBlock","other"],"mappings":"AACA,SAASA,QAAQ,EAAEC,EAAE,EAAEC,MAAM,QAAQ,SAAQ;AAI7C,SAASC,cAAc,QAAQ,wBAAuB;AACtD,SAASC,kBAAkB,EAAEC,4BAA4B,QAAQ,0BAAyB;AAG1FL,SAAS,sBAAsB;IAC7BC,GAAG,sDAAsD;QACvD,mBAAmB;QACnB,MAAMK,SAAiB;YACrBC,aAAa;gBACX;oBACEC,MAAM;oBACNC,QAAQ;wBACN;4BACEC,MAAM;4BACNC,MAAM;4BACNF,QAAQ;gCACN;oCACEC,MAAM;oCACNC,MAAM;oCACNC,UAAU;gCACZ;6BACD;wBACH;qBACD;oBACDC,YAAY;oBACZC,U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EAAqE;QACrElC,OAAOe,OAAOC,KAAK,EAAEkF,oBAAoBhE,WAAW;QAEpD,yCAAyC;QACzClC,OAAOe,OAAOC,KAAK,EAAE4F,OAAOhE,aAAa;IAC3C;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/configToJSONSchema.spec.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\nimport { describe, it, expect } from 'vitest'\n\nimport type { Config } from '../config/types.js'\n\nimport { sanitizeConfig } from '../config/sanitize.js'\nimport { configToJSONSchema, entityToStandaloneJSONSchema } from './configToJSONSchema.js'\nimport type { Block, BlocksField, RichTextField } from '../fields/config/types.js'\n\ndescribe('configToJSONSchema', () => {\n it('should handle optional arrays with required fields', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'someRequiredField',\n type: 'array',\n fields: [\n {\n name: 'someRequiredField',\n type: 'text',\n required: true,\n },\n ],\n },\n ],\n timestamps: false,\n versions: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.$defs?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n someRequiredField: {\n type: ['array', 'null'],\n items: {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: ['string', 'null'],\n },\n someRequiredField: {\n type: 'string',\n },\n },\n required: ['someRequiredField'],\n },\n },\n },\n required: ['id'],\n title: 'Test',\n })\n })\n\n it('should generate separate input types when generateInputTypes is enabled', async () => {\n // @ts-expect-error partial config\n const config: Config = {\n collections: [\n { slug: 'authors', fields: [{ name: 'name', type: 'text' }] },\n { slug: 'categories', fields: [{ name: 'title', type: 'text' }] },\n {\n slug: 'posts',\n fields: [\n { name: 'title', type: 'text', required: true },\n {\n name: 'status',\n type: 'select',\n defaultValue: 'draft',\n options: ['draft', 'published'],\n required: true,\n },\n { name: 'author', type: 'relationship', relationTo: 'authors' },\n { name: 'categories', type: 'relationship', hasMany: true, relationTo: 'categories' },\n ],\n },\n ],\n typescript: { generateInputTypes: true },\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text')\n\n // Output (read) shape is unchanged: relationships may be populated, managed fields are present,\n // and a required field with a defaultValue stays required.\n const postsOutput = schema?.$defs?.posts as JSONSchema4\n expect(postsOutput.title).toBe('Post')\n expect(postsOutput.properties!.author).toStrictEqual({\n oneOf: [{ type: ['string', 'null'] }, { $ref: '#/$defs/authors' }],\n })\n expect(postsOutput.properties!.categories).toStrictEqual({\n type: ['array', 'null'],\n items: { oneOf: [{ type: 'string' }, { $ref: '#/$defs/categories' }] },\n })\n expect(postsOutput.required).toStrictEqual(['id', 'title', 'status', 'updatedAt', 'createdAt'])\n\n // Input (write) shape: relationships are ID-only, the defaultValue field is optional, `id` is\n // optional, and createdAt/updatedAt are dropped. `id` and the defaulted `status` are optional\n // but NOT nullable - nullability follows the read shape, where they're non-null.\n expect(schema?.$defs?.posts_input).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: { type: 'string' },\n title: { type: 'string' },\n status: { type: 'string', enum: ['draft', 'published'] },\n author: { type: ['string', 'null'] },\n categories: { type: ['array', 'null'], items: { type: 'string' } },\n },\n required: ['title'],\n title: 'PostInput',\n })\n\n // The Config type exposes input shapes under `collectionsInput`.\n expect((schema?.properties?.collectionsInput as JSONSchema4)?.properties?.posts).toStrictEqual({\n $ref: '#/$defs/posts_input',\n })\n })\n\n it('should skip input types by default and generate them when enabled', async () => {\n // @ts-expect-error partial config\n const offByDefault: Config = {\n collections: [{ slug: 'posts', fields: [{ name: 'title', type: 'text' }] }],\n }\n const { jsonSchema: defaultSchema } = configToJSONSchema(\n await sanitizeConfig(offByDefault),\n 'text',\n )\n expect(defaultSchema?.$defs?.posts_input).toBeUndefined()\n expect(defaultSchema?.properties?.collectionsInput).toBeUndefined()\n\n // @ts-expect-error partial config\n const enabled: Config = {\n collections: [{ slug: 'posts', fields: [{ name: 'title', type: 'text' }] }],\n typescript: { generateInputTypes: true },\n }\n const { jsonSchema: enabledSchema } = configToJSONSchema(\n await sanitizeConfig(enabled),\n 'text',\n )\n expect(enabledSchema?.$defs?.posts_input).toBeDefined()\n expect(enabledSchema?.properties?.collectionsInput).toBeDefined()\n })\n\n it('should generate Input-suffixed definitions for named interfaces and blocks', async () => {\n // @ts-expect-error partial config\n const config: Config = {\n collections: [\n { slug: 'authors', fields: [{ name: 'name', type: 'text' }] },\n {\n slug: 'pages',\n fields: [\n {\n name: 'meta',\n type: 'group',\n interfaceName: 'Meta',\n fields: [{ name: 'author', type: 'relationship', relationTo: 'authors' }],\n },\n {\n name: 'layout',\n type: 'blocks',\n blocks: [\n {\n slug: 'hero',\n fields: [\n { name: 'heading', type: 'text', required: true },\n { name: 'cta', type: 'relationship', relationTo: 'authors' },\n ],\n },\n ],\n },\n ],\n },\n ],\n typescript: { generateInputTypes: true },\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text')\n\n // Read-shaped named interface keeps the populated-doc union...\n expect((schema?.$defs?.Meta as JSONSchema4).properties!.author).toStrictEqual({\n oneOf: [{ type: ['string', 'null'] }, { $ref: '#/$defs/authors' }],\n })\n // ...and a separate `Input` definition is ID-only, so the two don't collide.\n expect((schema?.$defs?.MetaInput as JSONSchema4).properties!.author).toStrictEqual({\n type: ['string', 'null'],\n })\n\n // Blocks get the same treatment: read-shaped `Hero`, write-shaped `HeroInput`.\n const heroInput = schema?.$defs?.HeroInput as JSONSchema4\n expect(heroInput.properties!.cta).toStrictEqual({ type: ['string', 'null'] })\n expect(heroInput.required).toStrictEqual(['blockType', 'heading'])\n expect((schema?.$defs?.Hero as JSONSchema4).properties!.cta).toStrictEqual({\n oneOf: [{ type: ['string', 'null'] }, { $ref: '#/$defs/authors' }],\n })\n })\n\n it('passes the variant to field-level jsonSchema transforms', async () => {\n // @ts-expect-error partial config\n const config: Config = {\n collections: [\n {\n slug: 'posts',\n fields: [\n {\n name: 'custom',\n type: 'text',\n jsonSchema: [({ jsonSchema, variant }) => ({ ...jsonSchema, description: variant })],\n },\n ],\n },\n ],\n typescript: { generateInputTypes: true },\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text')\n\n expect((schema?.$defs?.posts as JSONSchema4).properties!.custom.description).toBe('output')\n expect((schema?.$defs?.posts_input as JSONSchema4).properties!.custom.description).toBe('input')\n })\n\n it('should handle block fields with no blocks', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'blockField',\n type: 'blocks',\n blocks: [],\n },\n {\n name: 'blockFieldRequired',\n type: 'blocks',\n blocks: [],\n required: true,\n },\n {\n name: 'blockFieldWithFields',\n type: 'blocks',\n blocks: [\n {\n slug: 'test',\n fields: [\n {\n name: 'field',\n type: 'text',\n },\n ],\n },\n ],\n },\n {\n name: 'blockFieldWithFieldsRequired',\n type: 'blocks',\n blocks: [\n {\n slug: 'testRequired',\n fields: [\n {\n name: 'field',\n type: 'text',\n required: true,\n },\n ],\n },\n ],\n },\n ],\n timestamps: false,\n versions: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.$defs?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n blockField: {\n type: ['array', 'null'],\n items: {},\n },\n blockFieldRequired: {\n type: 'array',\n items: {},\n },\n blockFieldWithFields: {\n type: ['array', 'null'],\n items: {\n oneOf: [{ $ref: '#/$defs/Test' }],\n },\n },\n blockFieldWithFieldsRequired: {\n type: ['array', 'null'],\n items: {\n oneOf: [{ $ref: '#/$defs/TestRequired' }],\n },\n },\n },\n required: ['id', 'blockFieldRequired'],\n title: 'Test',\n })\n })\n\n it('keeps the first block interface name clean and content-hashes the colliding one', async () => {\n // @ts-expect-error - partial config for testing\n const config: Config = {\n collections: [\n {\n slug: 'pages',\n fields: [\n {\n name: 'layout',\n type: 'blocks',\n blocks: [\n { slug: 'hero', fields: [{ name: 'title', type: 'text' }] },\n { slug: 'cta', fields: [{ name: 'label', type: 'text' }] },\n ],\n },\n ],\n timestamps: false,\n versions: false,\n },\n {\n slug: 'posts',\n fields: [\n {\n name: 'layout',\n type: 'blocks',\n // Same slug `hero`, DIFFERENT fields → name collision with pages' hero.\n blocks: [{ slug: 'hero', fields: [{ name: 'heading', type: 'text' }] }],\n },\n ],\n timestamps: false,\n versions: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text')\n const defs = schema.$defs!\n\n // The first `hero` keeps the clean name; the unique block is unaffected.\n expect(defs.Hero).toBeDefined()\n expect(defs.Cta).toBeDefined()\n\n // Only the second, differently-shaped `hero` is disambiguated with a content hash.\n const hashedHeroNames = Object.keys(defs).filter((k) => /^Hero_[0-9A-F]{8}$/.test(k))\n expect(hashedHeroNames).toHaveLength(1)\n\n // The disambiguated interface carries the explanatory JSDoc note; the clean one does not.\n expect((defs[hashedHeroNames[0]!] as { description?: string }).description).toContain(\n 'content hash',\n )\n expect((defs.Hero as { description?: string }).description).toBeUndefined()\n\n // Each collection's block field references its own block's interface.\n const refsOf = (slug: string): string[] =>\n (\n defs[slug] as { properties: { layout: { items: { oneOf: Array<{ $ref: string }> } } } }\n ).properties.layout.items.oneOf.map((r) => r.$ref)\n expect(refsOf('pages')).toContain('#/$defs/Hero')\n expect(refsOf('pages')).toContain('#/$defs/Cta')\n expect(refsOf('posts')).toStrictEqual([`#/$defs/${hashedHeroNames[0]}`])\n\n // Hashing is deterministic: regenerating yields identical names.\n const { jsonSchema: schema2 } = configToJSONSchema(sanitizedConfig, 'text')\n expect(\n Object.keys(schema2.$defs!)\n .filter((k) => /^Hero/.test(k))\n .sort(),\n ).toStrictEqual(\n Object.keys(defs)\n .filter((k) => /^Hero/.test(k))\n .sort(),\n )\n })\n\n it('should handle tabs and named tabs with required fields', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n type: 'tabs',\n tabs: [\n {\n fields: [\n {\n name: 'fieldInUnnamedTab',\n type: 'text',\n },\n ],\n label: 'unnamedTab',\n },\n {\n name: 'namedTab',\n fields: [\n {\n name: 'fieldInNamedTab',\n type: 'text',\n },\n ],\n label: 'namedTab',\n },\n {\n name: 'namedTabWithRequired',\n fields: [\n {\n name: 'fieldInNamedTab',\n type: 'text',\n required: true,\n },\n ],\n label: 'namedTabWithRequired',\n },\n ],\n },\n ],\n timestamps: false,\n versions: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.$defs?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n fieldInUnnamedTab: {\n type: ['string', 'null'],\n },\n namedTab: {\n type: 'object',\n additionalProperties: false,\n properties: {\n fieldInNamedTab: {\n type: ['string', 'null'],\n },\n },\n required: [],\n },\n namedTabWithRequired: {\n type: 'object',\n additionalProperties: false,\n properties: {\n fieldInNamedTab: {\n type: 'string',\n },\n },\n required: ['fieldInNamedTab'],\n },\n },\n required: ['id', 'namedTabWithRequired'],\n title: 'Test',\n })\n })\n\n it('should handle custom typescript schema and JSON field schema', async () => {\n const customSchema: JSONSchema4 = {\n type: 'object',\n properties: {\n id: {\n type: 'number',\n },\n required: ['id'],\n },\n }\n\n const config: Partial<Config> = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'withCustom',\n type: 'text',\n jsonSchema: [() => customSchema],\n },\n {\n name: 'jsonWithSchema',\n type: 'json',\n jsonSchema: {\n fileMatch: ['a://b/foo.json'],\n schema: customSchema,\n uri: 'a://b/foo.json',\n },\n },\n ],\n timestamps: false,\n versions: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config as Config)\n const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.$defs?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n jsonWithSchema: customSchema,\n withCustom: customSchema,\n },\n required: ['id'],\n title: 'Test',\n })\n })\n\n it('should handle same block object being referenced in both collection and config.blocks', async () => {\n const sharedBlock: Block = {\n slug: 'sharedBlock',\n interfaceName: 'SharedBlock',\n fields: [\n {\n name: 'richText',\n type: 'richText',\n editor: () => {\n // stub rich text editor\n return {\n CellComponent: '',\n FieldComponent: '',\n validate: () => true,\n }\n },\n },\n ],\n }\n\n // @ts-expect-error\n const config: Config = {\n blocks: [sharedBlock],\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'someBlockField',\n type: 'blocks',\n blocks: [sharedBlock],\n },\n ],\n timestamps: false,\n versions: false,\n },\n ],\n }\n\n // Ensure both rich text editor are sanitized\n const sanitizedConfig = await sanitizeConfig(config)\n expect(typeof (sanitizedConfig?.blocks?.[0]?.fields?.[0] as RichTextField)?.editor).toBe(\n 'object',\n )\n expect(\n typeof (\n (sanitizedConfig.collections[0].fields[0] as BlocksField)?.blocks?.[0]\n ?.fields?.[0] as RichTextField\n )?.editor,\n ).toBe('object')\n\n const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text')\n\n const expectedBlockSchema = {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: { type: ['string', 'null'] },\n blockName: { type: ['string', 'null'] },\n blockType: { const: 'sharedBlock' },\n richText: { type: ['array', 'null'], items: { type: 'object' } },\n },\n required: ['blockType'],\n }\n\n expect(schema?.$defs?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n title: 'Test',\n properties: {\n id: {\n type: 'string',\n },\n someBlockField: {\n type: ['array', 'null'],\n items: {\n oneOf: [\n {\n $ref: '#/$defs/SharedBlock',\n },\n ],\n },\n },\n },\n required: ['id'],\n })\n\n // The definition should still be registered for TypeScript type generation\n expect(schema?.$defs?.SharedBlock).toStrictEqual(expectedBlockSchema)\n })\n\n it('content-hashes a colliding explicit interfaceName instead of overwriting it', async () => {\n // Two different blocks both set `interfaceName: 'Hero'` - each must keep its own definition.\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'blocksField',\n type: 'blocks',\n blocks: [\n {\n slug: 'blockA',\n fields: [{ name: 'title', type: 'text' }],\n interfaceName: 'Hero',\n },\n {\n slug: 'blockB',\n fields: [{ name: 'subtitle', type: 'number' }],\n interfaceName: 'Hero',\n },\n ],\n },\n ],\n timestamps: false,\n versions: false,\n },\n ],\n } as unknown as Config\n\n const sanitizedConfig = await sanitizeConfig(config)\n const { jsonSchema } = configToJSONSchema(sanitizedConfig, 'text')\n const defs = jsonSchema.$defs!\n\n // Each differently-shaped block keeps its own interface (one clean, one hash-suffixed).\n const heroNames = Object.keys(defs).filter((k) => /^Hero(_[0-9A-F]{8})?$/.test(k))\n expect(heroNames).toHaveLength(2)\n\n // ...and they carry distinct field shapes (not a silent overwrite).\n const shapeOf = (name: string): string =>\n Object.keys((defs[name] as { properties: Record<string, unknown> }).properties)\n .sort()\n .join(',')\n expect(shapeOf(heroNames[0]!)).not.toBe(shapeOf(heroNames[1]!))\n })\n\n it('reuses one definition when the same block is registered more than once', async () => {\n // Reusing one block across fields registers an identical schema each time, so it dedupes.\n const heroBlock = {\n slug: 'hero',\n fields: [{ name: 'title', type: 'text' }],\n interfaceName: 'Hero',\n }\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n { name: 'a', type: 'blocks', blocks: [heroBlock] },\n { name: 'b', type: 'blocks', blocks: [heroBlock] },\n ],\n timestamps: false,\n versions: false,\n },\n ],\n } as unknown as Config\n\n const sanitizedConfig = await sanitizeConfig(config)\n const { jsonSchema } = configToJSONSchema(sanitizedConfig, 'text')\n\n const heroNames = Object.keys(jsonSchema.$defs!).filter((k) => /^Hero(_[0-9A-F]{8})?$/.test(k))\n expect(heroNames).toEqual(['Hero'])\n })\n\n it('should allow overriding required to false', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'title',\n type: 'text',\n required: true,\n defaultValue: 'test',\n jsonSchema: [\n () => ({\n type: 'string',\n required: false,\n }),\n ],\n },\n ],\n timestamps: false,\n versions: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text')\n\n // @ts-expect-error\n expect(schema.$defs.test.properties.title.required).toStrictEqual(false)\n })\n\n it('should propagate forceInlineBlocks to nested fields (array, group, tab)', async () => {\n const namedBlock: Block = {\n slug: 'myBlock',\n interfaceName: 'MyBlock',\n fields: [{ name: 'text', type: 'text' }],\n }\n\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'arr',\n type: 'array',\n fields: [{ name: 'blocks', type: 'blocks', blocks: [namedBlock] }],\n },\n {\n name: 'grp',\n type: 'group',\n fields: [{ name: 'blocks', type: 'blocks', blocks: [namedBlock] }],\n },\n ],\n timestamps: false,\n versions: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n\n // Without forceInlineBlocks: blocks field uses $ref\n const { jsonSchema: schemaDefault } = configToJSONSchema(sanitizedConfig, 'text')\n const arrItemsDefault = schemaDefault.$defs!.test.properties!.arr.items as JSONSchema4\n const arrBlocksDefault = (arrItemsDefault.properties!.blocks.items as JSONSchema4).oneOf![0]\n expect(arrBlocksDefault).toStrictEqual({ $ref: '#/$defs/MyBlock' })\n\n // With forceInlineBlocks: blocks field is inlined, no $ref\n const { jsonSchema: schemaInline } = configToJSONSchema(sanitizedConfig, 'text', undefined, {\n forceInlineBlocks: true,\n })\n const arrItemsInline = schemaInline.$defs!.test.properties!.arr.items as JSONSchema4\n const arrBlocksInline = (arrItemsInline.properties!.blocks.items as JSONSchema4).oneOf![0]\n expect(arrBlocksInline).not.toHaveProperty('$ref')\n expect(arrBlocksInline.properties?.blockType).toStrictEqual({ const: 'myBlock' })\n\n const grpBlocksInline = (\n schemaInline.$defs!.test.properties!.grp.properties!.blocks.items as JSONSchema4\n ).oneOf![0]\n expect(grpBlocksInline).not.toHaveProperty('$ref')\n expect(grpBlocksInline.properties?.blockType).toStrictEqual({ const: 'myBlock' })\n })\n\n it('entityToStandaloneJSONSchema bundles only the definitions an entity references', async () => {\n const sharedBlock: Block = {\n slug: 'sharedBlock',\n interfaceName: 'SharedBlock',\n fields: [{ name: 'title', type: 'text' }],\n }\n\n // @ts-expect-error partial config\n const config: Config = {\n admin: {\n timezones: {\n supportedTimezones: [\n { label: 'UTC', value: 'UTC' },\n { label: 'New York', value: 'America/New_York' },\n ],\n },\n },\n blocks: [sharedBlock],\n collections: [\n {\n slug: 'with-refs',\n fields: [\n { name: 'layout', type: 'blocks', blocks: ['sharedBlock'] },\n { name: 'when', type: 'date', timezone: true },\n ],\n timestamps: false,\n versions: false,\n },\n {\n slug: 'other',\n fields: [{ name: 'title', type: 'text' }],\n timestamps: false,\n versions: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const entity = sanitizedConfig.collections.find(\n (collection) => collection.slug === 'with-refs',\n )!\n\n const schema = entityToStandaloneJSONSchema({\n config: sanitizedConfig,\n defaultIDType: 'text',\n entity,\n })\n\n // Has its own $schema, so it resolves on its own.\n expect(schema.$schema).toBe('https://json-schema.org/draft/2020-12/schema')\n\n // The block reference is resolved inline, so it can't dangle.\n const layoutItems = (schema.properties?.layout as JSONSchema4)?.items as JSONSchema4\n const inlinedBlock = (layoutItems?.oneOf?.[0] ?? {}) as JSONSchema4\n expect(inlinedBlock.properties?.blockType).toStrictEqual({ const: 'sharedBlock' })\n expect(inlinedBlock.properties?.title).toBeDefined()\n\n // A timezone field pulls in supportedTimezones from the root config.\n expect(schema.$defs?.supportedTimezones).toBeDefined()\n\n // Doesn't pull in unrelated collections.\n expect(schema.$defs?.other).toBeUndefined()\n })\n})\n"],"names":["describe","it","expect","sanitizeConfig","configToJSONSchema","entityToStandaloneJSONSchema","config","collections","slug","fields","name","type","required","timestamps","versions","sanitizedConfig","jsonSchema","schema","$defs","test","toStrictEqual","additionalProperties","properties","id","someRequiredField","items","title","defaultValue","options","relationTo","hasMany","typescript","generateInputTypes","postsOutput","posts","toBe","author","oneOf","$ref","categories","posts_input","status","enum","collectionsInput","offByDefault","defaultSchema","toBeUndefined","enabled","enabledSchema","toBeDefined","interfaceName","blocks","Meta","MetaInput","heroInput","HeroInput","cta","Hero","variant","description","custom","blockField","blockFieldRequired","blockFieldWithFields","blockFieldWithFieldsRequired","defs","Cta","hashedHeroNames","Object","keys","filter","k","toHaveLength","toContain","refsOf","layout","map","r","schema2","sort","tabs","label","fieldInUnnamedTab","namedTab","fieldInNamedTab","namedTabWithRequired","customSchema","fileMatch","uri","jsonWithSchema","withCustom","sharedBlock","editor","CellComponent","FieldComponent","validate","expectedBlockSchema","blockName","blockType","const","richText","someBlockField","SharedBlock","heroNames","shapeOf","join","not","heroBlock","toEqual","namedBlock","schemaDefault","arrItemsDefault","arr","arrBlocksDefault","schemaInline","undefined","forceInlineBlocks","arrItemsInline","arrBlocksInline","toHaveProperty","grpBlocksInline","grp","admin","timezones","supportedTimezones","value","timezone","entity","find","collection","defaultIDType","$schema","layoutItems","inlinedBlock","other"],"mappings":"AACA,SAASA,QAAQ,EAAEC,EAAE,EAAEC,MAAM,QAAQ,SAAQ;AAI7C,SAASC,cAAc,QAAQ,wBAAuB;AACtD,SAASC,kBAAkB,EAAEC,4BAA4B,QAAQ,0BAAyB;AAG1FL,SAAS,sBAAsB;IAC7BC,GAAG,sDAAsD;QACvD,mBAAmB;QACnB,MAAMK,SAAiB;YACrBC,aAAa;gBACX;oBACEC,MAAM;oBACNC,QAAQ;wBACN;4BACEC,MAAM;4BACNC,MAAM;4BACNF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AAW9E,aAAa,CAAC;YAAE+E,OAAO;QAAc;QAChFjG,OAAOmI,aAAa/G,UAAU,EAAEI,OAAOuB,WAAW;QAElD,qEAAqE;QACrE/C,OAAOe,OAAOC,KAAK,EAAE0G,oBAAoB3E,WAAW;QAEpD,yCAAyC;QACzC/C,OAAOe,OAAOC,KAAK,EAAEoH,OAAOxF,aAAa;IAC3C;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Payload, RequestContext, TypedLocale,
|
|
1
|
+
import type { Payload, RequestContext, TypedLocale, User } from '../index.js';
|
|
2
2
|
import type { PayloadRequest } from '../types/index.js';
|
|
3
3
|
export type CreateLocalReqOptions = {
|
|
4
4
|
context?: RequestContext;
|
|
@@ -7,7 +7,7 @@ export type CreateLocalReqOptions = {
|
|
|
7
7
|
locale?: string;
|
|
8
8
|
req?: Partial<PayloadRequest>;
|
|
9
9
|
urlSuffix?: string;
|
|
10
|
-
user?:
|
|
10
|
+
user?: User;
|
|
11
11
|
};
|
|
12
12
|
type CreateLocalReq = (options: CreateLocalReqOptions, payload: Payload) => Promise<PayloadRequest>;
|
|
13
13
|
export declare const createLocalReq: CreateLocalReq;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createLocalReq.d.ts","sourceRoot":"","sources":["../../src/utilities/createLocalReq.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"createLocalReq.d.ts","sourceRoot":"","sources":["../../src/utilities/createLocalReq.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAsFvD,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IACpC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,IAAI,CAAA;CACZ,CAAA;AAED,KAAK,cAAc,GAAG,CAAC,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,cAAc,CAAC,CAAA;AAEnG,eAAO,MAAM,cAAc,EAAE,cA+D5B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/createLocalReq.ts"],"sourcesContent":["import type { Payload, RequestContext, TypedLocale,
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/createLocalReq.ts"],"sourcesContent":["import type { Payload, RequestContext, TypedLocale, User } from '../index.js'\nimport type { PayloadRequest } from '../types/index.js'\n\nimport { getDataLoader } from '../collections/dataloader.js'\nimport { getLocalI18n } from '../translations/getLocalI18n.js'\nimport { sanitizeFallbackLocale } from '../utilities/sanitizeFallbackLocale.js'\n\nfunction getRequestContext(\n req: Partial<PayloadRequest> = { context: null } as unknown as PayloadRequest,\n context: RequestContext = {},\n): RequestContext {\n if (req.context) {\n if (Object.keys(req.context).length === 0 && req.context.constructor === Object) {\n // if req.context is `{}` avoid unnecessary spread\n return context\n } else {\n return { ...req.context, ...context }\n }\n } else {\n return context\n }\n}\n\nconst attachFakeURLProperties = (req: Partial<PayloadRequest>, urlSuffix?: string) => {\n /**\n * *NOTE*\n * If no URL is provided, the local API was called outside\n * the context of a request. Therefore we create a fake URL object.\n * `ts-expect-error` is used below for properties that are 'read-only'.\n * Since they do not exist yet we can safely ignore the error.\n */\n let urlObject: undefined | URL\n\n function getURLObject() {\n if (urlObject) {\n return urlObject\n }\n\n const fallbackURL = `http://${req.host || 'localhost'}${urlSuffix || ''}`\n\n const urlToUse =\n req?.url ||\n (req.payload?.config?.serverURL\n ? `${req.payload?.config.serverURL}${urlSuffix || ''}`\n : fallbackURL)\n\n try {\n urlObject = new URL(urlToUse)\n } catch (_err) {\n req.payload?.logger.error(\n `Failed to create URL object from URL: ${urlToUse}, falling back to ${fallbackURL}`,\n )\n\n urlObject = new URL(fallbackURL)\n }\n\n return urlObject\n }\n\n if (!req.host) {\n req.host = getURLObject().host\n }\n\n if (!req.protocol) {\n req.protocol = getURLObject().protocol\n }\n\n if (!req.pathname) {\n req.pathname = getURLObject().pathname\n }\n\n if (!req.searchParams) {\n // @ts-expect-error eslint-disable-next-line no-param-reassign\n req.searchParams = getURLObject().searchParams\n }\n\n if (!req.origin) {\n // @ts-expect-error eslint-disable-next-line no-param-reassign\n req.origin = getURLObject().origin\n }\n\n if (!req?.url) {\n // @ts-expect-error eslint-disable-next-line no-param-reassign\n req.url = getURLObject().href\n }\n}\n\nexport type CreateLocalReqOptions = {\n context?: RequestContext\n depth?: number\n fallbackLocale?: false | TypedLocale\n locale?: string\n req?: Partial<PayloadRequest>\n urlSuffix?: string\n user?: User\n}\n\ntype CreateLocalReq = (options: CreateLocalReqOptions, payload: Payload) => Promise<PayloadRequest>\n\nexport const createLocalReq: CreateLocalReq = async (\n {\n context,\n depth,\n fallbackLocale,\n locale: localeArg,\n req = {} as PayloadRequest,\n urlSuffix,\n user,\n },\n payload,\n): Promise<PayloadRequest> => {\n const localization = payload.config?.localization\n\n if (localization) {\n const locale = localeArg === '*' ? 'all' : localeArg\n const defaultLocale = localization.defaultLocale\n const localeCandidate = locale || req?.locale || req?.query?.locale\n\n req.locale =\n localeCandidate && typeof localeCandidate === 'string' ? localeCandidate : defaultLocale\n\n const sanitizedFallback = sanitizeFallbackLocale({\n fallbackLocale: fallbackLocale!,\n locale: req.locale,\n localization,\n })\n\n req.fallbackLocale = sanitizedFallback!\n }\n\n const i18n =\n req?.i18n ||\n (await getLocalI18n({ config: payload.config, language: payload.config.i18n.fallbackLanguage }))\n\n if (!req.headers) {\n req.headers = new Headers()\n }\n\n req.context = getRequestContext(req, context)\n req.payloadAPI = req?.payloadAPI || 'local'\n req.payload = payload\n req.i18n = i18n\n req.t = i18n.t\n req.user = user || req?.user || null\n\n // Ensure user.collection is set for auth-related access control\n // TODO (4.0): Instead of silently falling back, throw an error if user.collection is missing\n if (req.user && !req.user.collection) {\n req.user = { ...req.user, collection: payload.config.admin.user }\n }\n\n req.payloadDataLoader = req?.payloadDataLoader || getDataLoader(req as PayloadRequest)\n req.routeParams = req?.routeParams || {}\n req.query = req?.query || {}\n\n if (typeof depth !== 'undefined') {\n req.query.depth = depth\n }\n\n attachFakeURLProperties(req, urlSuffix)\n\n return req as PayloadRequest\n}\n"],"names":["getDataLoader","getLocalI18n","sanitizeFallbackLocale","getRequestContext","req","context","Object","keys","length","attachFakeURLProperties","urlSuffix","urlObject","getURLObject","fallbackURL","host","urlToUse","url","payload","config","serverURL","URL","_err","logger","error","protocol","pathname","searchParams","origin","href","createLocalReq","depth","fallbackLocale","locale","localeArg","user","localization","defaultLocale","localeCandidate","query","sanitizedFallback","i18n","language","fallbackLanguage","headers","Headers","payloadAPI","t","collection","admin","payloadDataLoader","routeParams"],"mappings":"AAGA,SAASA,aAAa,QAAQ,+BAA8B;AAC5D,SAASC,YAAY,QAAQ,kCAAiC;AAC9D,SAASC,sBAAsB,QAAQ,yCAAwC;AAE/E,SAASC,kBACPC,MAA+B;IAAEC,SAAS;AAAK,CAA8B,EAC7EA,UAA0B,CAAC,CAAC;IAE5B,IAAID,IAAIC,OAAO,EAAE;QACf,IAAIC,OAAOC,IAAI,CAACH,IAAIC,OAAO,EAAEG,MAAM,KAAK,KAAKJ,IAAIC,OAAO,CAAC,WAAW,KAAKC,QAAQ;YAC/E,kDAAkD;YAClD,OAAOD;QACT,OAAO;YACL,OAAO;gBAAE,GAAGD,IAAIC,OAAO;gBAAE,GAAGA,OAAO;YAAC;QACtC;IACF,OAAO;QACL,OAAOA;IACT;AACF;AA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9C,KAAK8C,eAAe,CAAC;IACvC9C,IAAIkC,KAAK,GAAGlC,KAAKkC,SAAS,CAAC;IAE3B,IAAI,OAAOR,UAAU,aAAa;QAChC1B,IAAIkC,KAAK,CAACR,KAAK,GAAGA;IACpB;IAEArB,wBAAwBL,KAAKM;IAE7B,OAAON;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPayloadRequest.d.ts","sourceRoot":"","sources":["../../src/utilities/createPayloadRequest.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEzD,OAAO,KAAK,EAAkC,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAUvF,KAAK,IAAI,GAAG;IACV,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAA;IAClD,MAAM,CAAC,EAAE;QACP,UAAU,EAAE,MAAM,CAAA;KACnB,CAAA;IACD,uBAAuB,CAAC,EAAE,MAAM,CAAA;IAChC,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAU,qFAMxC,IAAI,KAAG,OAAO,CAAC,cAAc,
|
|
1
|
+
{"version":3,"file":"createPayloadRequest.d.ts","sourceRoot":"","sources":["../../src/utilities/createPayloadRequest.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEzD,OAAO,KAAK,EAAkC,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAUvF,KAAK,IAAI,GAAG;IACV,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAA;IAClD,MAAM,CAAC,EAAE;QACP,UAAU,EAAE,MAAM,CAAA;KACnB,CAAA;IACD,uBAAuB,CAAC,EAAE,MAAM,CAAA;IAChC,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAU,qFAMxC,IAAI,KAAG,OAAO,CAAC,cAAc,CA2G/B,CAAA"}
|
|
@@ -35,6 +35,7 @@ export const createPayloadRequest = async ({ canSetHeaders, config: configPromis
|
|
|
35
35
|
let locale = searchParams.get('locale');
|
|
36
36
|
const { search: queryToParse } = urlProperties;
|
|
37
37
|
const query = queryToParse ? qs.parse(queryToParse, {
|
|
38
|
+
allowEmptyArrays: true,
|
|
38
39
|
arrayLimit: 1000,
|
|
39
40
|
depth: 10,
|
|
40
41
|
ignoreQueryPrefix: true
|