payload 3.0.0-beta.120 → 3.0.0-beta.121
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/dist/auth/operations/registerFirstUser.d.ts.map +1 -1
- package/dist/auth/operations/registerFirstUser.js.map +1 -1
- package/dist/auth/strategies/local/register.d.ts +3 -2
- package/dist/auth/strategies/local/register.d.ts.map +1 -1
- package/dist/auth/strategies/local/register.js +3 -2
- package/dist/auth/strategies/local/register.js.map +1 -1
- package/dist/bin/generateTypes.d.ts.map +1 -1
- package/dist/bin/generateTypes.js +4 -0
- package/dist/bin/generateTypes.js.map +1 -1
- package/dist/bin/index.d.ts +1 -1
- package/dist/bin/index.d.ts.map +1 -1
- package/dist/bin/index.js +25 -0
- package/dist/bin/index.js.map +1 -1
- package/dist/collections/config/types.d.ts +7 -5
- package/dist/collections/config/types.d.ts.map +1 -1
- package/dist/collections/config/types.js.map +1 -1
- package/dist/collections/dataloader.d.ts +3 -2
- package/dist/collections/dataloader.d.ts.map +1 -1
- package/dist/collections/dataloader.js +9 -5
- package/dist/collections/dataloader.js.map +1 -1
- package/dist/collections/operations/create.d.ts +4 -3
- package/dist/collections/operations/create.d.ts.map +1 -1
- package/dist/collections/operations/create.js +6 -3
- package/dist/collections/operations/create.js.map +1 -1
- package/dist/collections/operations/delete.d.ts +4 -9
- package/dist/collections/operations/delete.d.ts.map +1 -1
- package/dist/collections/operations/delete.js +3 -1
- package/dist/collections/operations/delete.js.map +1 -1
- package/dist/collections/operations/deleteByID.d.ts +4 -3
- package/dist/collections/operations/deleteByID.d.ts.map +1 -1
- package/dist/collections/operations/deleteByID.js +3 -1
- package/dist/collections/operations/deleteByID.js.map +1 -1
- package/dist/collections/operations/duplicate.d.ts +4 -3
- package/dist/collections/operations/duplicate.d.ts.map +1 -1
- package/dist/collections/operations/duplicate.js +7 -3
- package/dist/collections/operations/duplicate.js.map +1 -1
- package/dist/collections/operations/find.d.ts +4 -3
- package/dist/collections/operations/find.d.ts.map +1 -1
- package/dist/collections/operations/find.js +7 -1
- package/dist/collections/operations/find.js.map +1 -1
- package/dist/collections/operations/findByID.d.ts +4 -3
- package/dist/collections/operations/findByID.d.ts.map +1 -1
- package/dist/collections/operations/findByID.js +5 -2
- package/dist/collections/operations/findByID.js.map +1 -1
- package/dist/collections/operations/findVersionByID.d.ts +2 -1
- package/dist/collections/operations/findVersionByID.d.ts.map +1 -1
- package/dist/collections/operations/findVersionByID.js +3 -1
- package/dist/collections/operations/findVersionByID.js.map +1 -1
- package/dist/collections/operations/findVersions.d.ts +2 -1
- package/dist/collections/operations/findVersions.d.ts.map +1 -1
- package/dist/collections/operations/findVersions.js +3 -1
- package/dist/collections/operations/findVersions.js.map +1 -1
- package/dist/collections/operations/local/create.d.ts +5 -4
- package/dist/collections/operations/local/create.d.ts.map +1 -1
- package/dist/collections/operations/local/create.js +2 -1
- package/dist/collections/operations/local/create.js.map +1 -1
- package/dist/collections/operations/local/delete.d.ts +12 -11
- package/dist/collections/operations/local/delete.d.ts.map +1 -1
- package/dist/collections/operations/local/delete.js +2 -1
- package/dist/collections/operations/local/delete.js.map +1 -1
- package/dist/collections/operations/local/duplicate.d.ts +5 -4
- package/dist/collections/operations/local/duplicate.d.ts.map +1 -1
- package/dist/collections/operations/local/duplicate.js +2 -1
- package/dist/collections/operations/local/duplicate.js.map +1 -1
- package/dist/collections/operations/local/find.d.ts +5 -4
- package/dist/collections/operations/local/find.d.ts.map +1 -1
- package/dist/collections/operations/local/find.js +3 -1
- package/dist/collections/operations/local/find.js.map +1 -1
- package/dist/collections/operations/local/findByID.d.ts +7 -6
- package/dist/collections/operations/local/findByID.d.ts.map +1 -1
- package/dist/collections/operations/local/findByID.js +3 -2
- package/dist/collections/operations/local/findByID.js.map +1 -1
- package/dist/collections/operations/local/findVersionByID.d.ts +2 -1
- package/dist/collections/operations/local/findVersionByID.d.ts.map +1 -1
- package/dist/collections/operations/local/findVersionByID.js +2 -1
- package/dist/collections/operations/local/findVersionByID.js.map +1 -1
- package/dist/collections/operations/local/findVersions.d.ts +2 -1
- package/dist/collections/operations/local/findVersions.d.ts.map +1 -1
- package/dist/collections/operations/local/findVersions.js +2 -1
- package/dist/collections/operations/local/findVersions.js.map +1 -1
- package/dist/collections/operations/local/index.d.ts.map +1 -1
- package/dist/collections/operations/local/index.js +1 -1
- package/dist/collections/operations/local/index.js.map +1 -1
- package/dist/collections/operations/local/restoreVersion.d.ts +2 -1
- package/dist/collections/operations/local/restoreVersion.d.ts.map +1 -1
- package/dist/collections/operations/local/restoreVersion.js +2 -1
- package/dist/collections/operations/local/restoreVersion.js.map +1 -1
- package/dist/collections/operations/local/update.d.ts +12 -11
- package/dist/collections/operations/local/update.d.ts.map +1 -1
- package/dist/collections/operations/local/update.js +2 -1
- package/dist/collections/operations/local/update.js.map +1 -1
- package/dist/collections/operations/restoreVersion.d.ts +2 -1
- package/dist/collections/operations/restoreVersion.d.ts.map +1 -1
- package/dist/collections/operations/restoreVersion.js +4 -2
- package/dist/collections/operations/restoreVersion.js.map +1 -1
- package/dist/collections/operations/update.d.ts +4 -3
- package/dist/collections/operations/update.d.ts.map +1 -1
- package/dist/collections/operations/update.js +6 -3
- package/dist/collections/operations/update.js.map +1 -1
- package/dist/collections/operations/updateByID.d.ts +4 -3
- package/dist/collections/operations/updateByID.d.ts.map +1 -1
- package/dist/collections/operations/updateByID.js +5 -2
- package/dist/collections/operations/updateByID.js.map +1 -1
- package/dist/collections/operations/utils.d.ts +8 -8
- package/dist/collections/operations/utils.d.ts.map +1 -1
- package/dist/collections/operations/utils.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 +1 -0
- package/dist/config/client.js.map +1 -1
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +8 -0
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/sanitize.d.ts.map +1 -1
- package/dist/config/sanitize.js +21 -0
- package/dist/config/sanitize.js.map +1 -1
- package/dist/config/types.d.ts +6 -1
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js.map +1 -1
- package/dist/database/types.d.ts +15 -1
- package/dist/database/types.d.ts.map +1 -1
- package/dist/database/types.js.map +1 -1
- package/dist/exports/shared.d.ts +1 -0
- package/dist/exports/shared.d.ts.map +1 -1
- package/dist/exports/shared.js +1 -0
- package/dist/exports/shared.js.map +1 -1
- package/dist/fields/config/types.d.ts +2 -0
- package/dist/fields/config/types.d.ts.map +1 -1
- package/dist/fields/config/types.js.map +1 -1
- package/dist/fields/hooks/afterRead/index.d.ts +2 -1
- package/dist/fields/hooks/afterRead/index.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/index.js +4 -1
- package/dist/fields/hooks/afterRead/index.js.map +1 -1
- package/dist/fields/hooks/afterRead/promise.d.ts +4 -2
- package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/promise.js +59 -1
- package/dist/fields/hooks/afterRead/promise.js.map +1 -1
- package/dist/fields/hooks/afterRead/relationshipPopulationPromise.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/relationshipPopulationPromise.js +1 -0
- package/dist/fields/hooks/afterRead/relationshipPopulationPromise.js.map +1 -1
- package/dist/fields/hooks/afterRead/traverseFields.d.ts +4 -2
- package/dist/fields/hooks/afterRead/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/traverseFields.js +3 -1
- package/dist/fields/hooks/afterRead/traverseFields.js.map +1 -1
- package/dist/globals/config/types.d.ts +2 -1
- package/dist/globals/config/types.d.ts.map +1 -1
- package/dist/globals/config/types.js.map +1 -1
- package/dist/globals/operations/findOne.d.ts +2 -1
- package/dist/globals/operations/findOne.d.ts.map +1 -1
- package/dist/globals/operations/findOne.js +15 -2
- package/dist/globals/operations/findOne.js.map +1 -1
- package/dist/globals/operations/findVersionByID.d.ts +2 -1
- package/dist/globals/operations/findVersionByID.d.ts.map +1 -1
- package/dist/globals/operations/findVersionByID.js +3 -1
- package/dist/globals/operations/findVersionByID.js.map +1 -1
- package/dist/globals/operations/findVersions.d.ts +2 -1
- package/dist/globals/operations/findVersions.d.ts.map +1 -1
- package/dist/globals/operations/findVersions.js +7 -3
- package/dist/globals/operations/findVersions.js.map +1 -1
- package/dist/globals/operations/local/findOne.d.ts +5 -4
- package/dist/globals/operations/local/findOne.d.ts.map +1 -1
- package/dist/globals/operations/local/findOne.js +2 -1
- package/dist/globals/operations/local/findOne.js.map +1 -1
- package/dist/globals/operations/local/findVersionByID.d.ts +2 -1
- package/dist/globals/operations/local/findVersionByID.d.ts.map +1 -1
- package/dist/globals/operations/local/findVersionByID.js +2 -1
- package/dist/globals/operations/local/findVersionByID.js.map +1 -1
- package/dist/globals/operations/local/findVersions.d.ts +2 -1
- package/dist/globals/operations/local/findVersions.d.ts.map +1 -1
- package/dist/globals/operations/local/findVersions.js +3 -2
- package/dist/globals/operations/local/findVersions.js.map +1 -1
- package/dist/globals/operations/local/restoreVersion.d.ts.map +1 -1
- package/dist/globals/operations/local/restoreVersion.js +1 -1
- package/dist/globals/operations/local/restoreVersion.js.map +1 -1
- package/dist/globals/operations/local/update.d.ts +5 -4
- package/dist/globals/operations/local/update.d.ts.map +1 -1
- package/dist/globals/operations/local/update.js +2 -1
- package/dist/globals/operations/local/update.js.map +1 -1
- package/dist/globals/operations/update.d.ts +4 -3
- package/dist/globals/operations/update.d.ts.map +1 -1
- package/dist/globals/operations/update.js +15 -2
- package/dist/globals/operations/update.js.map +1 -1
- package/dist/index.d.ts +61 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/queues/config/generateJobsJSONSchemas.d.ts +18 -0
- package/dist/queues/config/generateJobsJSONSchemas.d.ts.map +1 -0
- package/dist/queues/config/generateJobsJSONSchemas.js +125 -0
- package/dist/queues/config/generateJobsJSONSchemas.js.map +1 -0
- package/dist/queues/config/jobsCollection.d.ts +4 -0
- package/dist/queues/config/jobsCollection.d.ts.map +1 -0
- package/dist/queues/config/jobsCollection.js +211 -0
- package/dist/queues/config/jobsCollection.js.map +1 -0
- package/dist/queues/config/types/index.d.ts +45 -0
- package/dist/queues/config/types/index.d.ts.map +1 -0
- package/dist/queues/config/types/index.js +3 -0
- package/dist/queues/config/types/index.js.map +1 -0
- package/dist/queues/config/types/taskTypes.d.ts +134 -0
- package/dist/queues/config/types/taskTypes.d.ts.map +1 -0
- package/dist/queues/config/types/taskTypes.js +3 -0
- package/dist/queues/config/types/taskTypes.js.map +1 -0
- package/dist/queues/config/types/workflowJSONTypes.d.ts +29 -0
- package/dist/queues/config/types/workflowJSONTypes.d.ts.map +1 -0
- package/dist/queues/config/types/workflowJSONTypes.js +3 -0
- package/dist/queues/config/types/workflowJSONTypes.js.map +1 -0
- package/dist/queues/config/types/workflowTypes.d.ts +98 -0
- package/dist/queues/config/types/workflowTypes.d.ts.map +1 -0
- package/dist/queues/config/types/workflowTypes.js +3 -0
- package/dist/queues/config/types/workflowTypes.js.map +1 -0
- package/dist/queues/localAPI.d.ts +23 -0
- package/dist/queues/localAPI.d.ts.map +1 -0
- package/dist/queues/localAPI.js +28 -0
- package/dist/queues/localAPI.js.map +1 -0
- package/dist/queues/operations/runJobs/index.d.ts +21 -0
- package/dist/queues/operations/runJobs/index.d.ts.map +1 -0
- package/dist/queues/operations/runJobs/index.js +180 -0
- package/dist/queues/operations/runJobs/index.js.map +1 -0
- package/dist/queues/operations/runJobs/runJSONJob/index.d.ts +18 -0
- package/dist/queues/operations/runJobs/runJSONJob/index.d.ts.map +1 -0
- package/dist/queues/operations/runJobs/runJSONJob/index.js +125 -0
- package/dist/queues/operations/runJobs/runJSONJob/index.js.map +1 -0
- package/dist/queues/operations/runJobs/runJob/calculateBackoffWaitUntil.d.ts +6 -0
- package/dist/queues/operations/runJobs/runJob/calculateBackoffWaitUntil.d.ts.map +1 -0
- package/dist/queues/operations/runJobs/runJob/calculateBackoffWaitUntil.js +26 -0
- package/dist/queues/operations/runJobs/runJob/calculateBackoffWaitUntil.js.map +1 -0
- package/dist/queues/operations/runJobs/runJob/getRunTaskFunction.d.ts +26 -0
- package/dist/queues/operations/runJobs/runJob/getRunTaskFunction.d.ts.map +1 -0
- package/dist/queues/operations/runJobs/runJob/getRunTaskFunction.js +204 -0
- package/dist/queues/operations/runJobs/runJob/getRunTaskFunction.js.map +1 -0
- package/dist/queues/operations/runJobs/runJob/getUpdateJobFunction.d.ts +5 -0
- package/dist/queues/operations/runJobs/runJob/getUpdateJobFunction.d.ts.map +1 -0
- package/dist/queues/operations/runJobs/runJob/getUpdateJobFunction.js +18 -0
- package/dist/queues/operations/runJobs/runJob/getUpdateJobFunction.js.map +1 -0
- package/dist/queues/operations/runJobs/runJob/handleWorkflowError.d.ts +17 -0
- package/dist/queues/operations/runJobs/runJob/handleWorkflowError.d.ts.map +1 -0
- package/dist/queues/operations/runJobs/runJob/handleWorkflowError.js +43 -0
- package/dist/queues/operations/runJobs/runJob/handleWorkflowError.js.map +1 -0
- package/dist/queues/operations/runJobs/runJob/importHandlerPath.d.ts +2 -0
- package/dist/queues/operations/runJobs/runJob/importHandlerPath.d.ts.map +1 -0
- package/dist/queues/operations/runJobs/runJob/importHandlerPath.js +21 -0
- package/dist/queues/operations/runJobs/runJob/importHandlerPath.js.map +1 -0
- package/dist/queues/operations/runJobs/runJob/index.d.ts +17 -0
- package/dist/queues/operations/runJobs/runJob/index.d.ts.map +1 -0
- package/dist/queues/operations/runJobs/runJob/index.js +48 -0
- package/dist/queues/operations/runJobs/runJob/index.js.map +1 -0
- package/dist/queues/restEndpointRun.d.ts +3 -0
- package/dist/queues/restEndpointRun.d.ts.map +1 -0
- package/dist/queues/restEndpointRun.js +66 -0
- package/dist/queues/restEndpointRun.js.map +1 -0
- package/dist/queues/utilities/getJobTaskStatus.d.ts +9 -0
- package/dist/queues/utilities/getJobTaskStatus.d.ts.map +1 -0
- package/dist/queues/utilities/getJobTaskStatus.js +29 -0
- package/dist/queues/utilities/getJobTaskStatus.js.map +1 -0
- package/dist/types/index.d.ts +20 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utilities/addSelectGenericsToGeneratedTyoes.spec.js +562 -0
- package/dist/utilities/addSelectGenericsToGeneratedTyoes.spec.js.map +1 -0
- package/dist/utilities/addSelectGenericsToGeneretedTypes.d.ts +4 -0
- package/dist/utilities/addSelectGenericsToGeneretedTypes.d.ts.map +1 -0
- package/dist/utilities/addSelectGenericsToGeneretedTypes.js +41 -0
- package/dist/utilities/addSelectGenericsToGeneretedTypes.js.map +1 -0
- package/dist/utilities/configToJSONSchema.d.ts +6 -1
- package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
- package/dist/utilities/configToJSONSchema.js +171 -15
- package/dist/utilities/configToJSONSchema.js.map +1 -1
- package/dist/utilities/getSelectMode.d.ts +3 -0
- package/dist/utilities/getSelectMode.d.ts.map +1 -0
- package/dist/utilities/getSelectMode.js +14 -0
- package/dist/utilities/getSelectMode.js.map +1 -0
- package/dist/utilities/traverseFields.d.ts.map +1 -1
- package/dist/utilities/traverseFields.js +51 -8
- package/dist/utilities/traverseFields.js.map +1 -1
- package/dist/versions/drafts/getQueryDraftsSelect.d.ts +5 -0
- package/dist/versions/drafts/getQueryDraftsSelect.d.ts.map +1 -0
- package/dist/versions/drafts/getQueryDraftsSelect.js +18 -0
- package/dist/versions/drafts/getQueryDraftsSelect.js.map +1 -0
- package/dist/versions/drafts/replaceWithDraftIfAvailable.d.ts +3 -2
- package/dist/versions/drafts/replaceWithDraftIfAvailable.d.ts.map +1 -1
- package/dist/versions/drafts/replaceWithDraftIfAvailable.js +11 -7
- package/dist/versions/drafts/replaceWithDraftIfAvailable.js.map +1 -1
- package/dist/versions/saveVersion.d.ts +3 -2
- package/dist/versions/saveVersion.d.ts.map +1 -1
- package/dist/versions/saveVersion.js +5 -1
- package/dist/versions/saveVersion.js.map +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const addSelectGenericsToGeneratedTypes = ({ compiledGeneratedTypes })=>{
|
|
2
|
+
const modifiedLines = [];
|
|
3
|
+
let isCollectionsSelectToken = false;
|
|
4
|
+
let isSelectTypeToken = false;
|
|
5
|
+
for (const line of compiledGeneratedTypes.split('\n')){
|
|
6
|
+
let newLine = line;
|
|
7
|
+
if (line === ` collectionsSelect?: {` || line === ` globalsSelect?: {`) {
|
|
8
|
+
isCollectionsSelectToken = true;
|
|
9
|
+
}
|
|
10
|
+
if (isCollectionsSelectToken) {
|
|
11
|
+
if (line === ' };') {
|
|
12
|
+
isCollectionsSelectToken = false;
|
|
13
|
+
} else {
|
|
14
|
+
// replace <posts: PostsSelect;> with <posts: PostsSelect<true> | PostsSelect<false;>
|
|
15
|
+
newLine = line.replace(/(['"]?\w+['"]?):\s*(\w+);/g, (_, variable, type)=>{
|
|
16
|
+
return `${variable}: ${type}<false> | ${type}<true>;`;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
// eslint-disable-next-line regexp/no-unused-capturing-group
|
|
21
|
+
if (line.match(/via the `definition` "([\w-]+_select)"/g)) {
|
|
22
|
+
isSelectTypeToken = true;
|
|
23
|
+
}
|
|
24
|
+
if (isSelectTypeToken) {
|
|
25
|
+
if (line.startsWith('export interface')) {
|
|
26
|
+
// add generic to the interface
|
|
27
|
+
newLine = line.replace(/(export interface\s+\w+)(\s*\{)/g, '$1<T extends boolean = true>$2');
|
|
28
|
+
} else {
|
|
29
|
+
// replace booleans with T on the line
|
|
30
|
+
newLine = line.replace(/(?<!\?)\bboolean\b/g, 'T');
|
|
31
|
+
if (line === '}') {
|
|
32
|
+
isSelectTypeToken = false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
modifiedLines.push(newLine);
|
|
37
|
+
}
|
|
38
|
+
return modifiedLines.join('\n');
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=addSelectGenericsToGeneretedTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/addSelectGenericsToGeneretedTypes.ts"],"sourcesContent":["export const addSelectGenericsToGeneratedTypes = ({\n compiledGeneratedTypes,\n}: {\n compiledGeneratedTypes: string\n}) => {\n const modifiedLines = []\n\n let isCollectionsSelectToken = false\n let isSelectTypeToken = false\n\n for (const line of compiledGeneratedTypes.split('\\n')) {\n let newLine = line\n if (line === ` collectionsSelect?: {` || line === ` globalsSelect?: {`) {\n isCollectionsSelectToken = true\n }\n\n if (isCollectionsSelectToken) {\n if (line === ' };') {\n isCollectionsSelectToken = false\n } else {\n // replace <posts: PostsSelect;> with <posts: PostsSelect<true> | PostsSelect<false;>\n newLine = line.replace(/(['\"]?\\w+['\"]?):\\s*(\\w+);/g, (_, variable, type) => {\n return `${variable}: ${type}<false> | ${type}<true>;`\n })\n }\n }\n\n // eslint-disable-next-line regexp/no-unused-capturing-group\n if (line.match(/via the `definition` \"([\\w-]+_select)\"/g)) {\n isSelectTypeToken = true\n }\n\n if (isSelectTypeToken) {\n if (line.startsWith('export interface')) {\n // add generic to the interface\n newLine = line.replace(/(export interface\\s+\\w+)(\\s*\\{)/g, '$1<T extends boolean = true>$2')\n } else {\n // replace booleans with T on the line\n newLine = line.replace(/(?<!\\?)\\bboolean\\b/g, 'T')\n\n if (line === '}') {\n isSelectTypeToken = false\n }\n }\n }\n\n modifiedLines.push(newLine)\n }\n\n return modifiedLines.join('\\n')\n}\n"],"names":["addSelectGenericsToGeneratedTypes","compiledGeneratedTypes","modifiedLines","isCollectionsSelectToken","isSelectTypeToken","line","split","newLine","replace","_","variable","type","match","startsWith","push","join"],"mappings":"AAAA,OAAO,MAAMA,oCAAoC,CAAC,EAChDC,sBAAsB,EAGvB;IACC,MAAMC,gBAAgB,EAAE;IAExB,IAAIC,2BAA2B;IAC/B,IAAIC,oBAAoB;IAExB,KAAK,MAAMC,QAAQJ,uBAAuBK,KAAK,CAAC,MAAO;QACrD,IAAIC,UAAUF;QACd,IAAIA,SAAS,CAAC,uBAAuB,CAAC,IAAIA,SAAS,CAAC,mBAAmB,CAAC,EAAE;YACxEF,2BAA2B;QAC7B;QAEA,IAAIA,0BAA0B;YAC5B,IAAIE,SAAS,QAAQ;gBACnBF,2BAA2B;YAC7B,OAAO;gBACL,qFAAqF;gBACrFI,UAAUF,KAAKG,OAAO,CAAC,8BAA8B,CAACC,GAAGC,UAAUC;oBACjE,OAAO,CAAC,EAAED,SAAS,EAAE,EAAEC,KAAK,UAAU,EAAEA,KAAK,OAAO,CAAC;gBACvD;YACF;QACF;QAEA,4DAA4D;QAC5D,IAAIN,KAAKO,KAAK,CAAC,4CAA4C;YACzDR,oBAAoB;QACtB;QAEA,IAAIA,mBAAmB;YACrB,IAAIC,KAAKQ,UAAU,CAAC,qBAAqB;gBACvC,+BAA+B;gBAC/BN,UAAUF,KAAKG,OAAO,CAAC,oCAAoC;YAC7D,OAAO;gBACL,sCAAsC;gBACtCD,UAAUF,KAAKG,OAAO,CAAC,uBAAuB;gBAE9C,IAAIH,SAAS,KAAK;oBAChBD,oBAAoB;gBACtB;YACF;QACF;QAEAF,cAAcY,IAAI,CAACP;IACrB;IAEA,OAAOL,cAAca,IAAI,CAAC;AAC5B,EAAC"}
|
|
@@ -25,7 +25,12 @@ interfaceNameDefinitions: Map<string, JSONSchema4>, config?: SanitizedConfig): {
|
|
|
25
25
|
};
|
|
26
26
|
required: string[];
|
|
27
27
|
};
|
|
28
|
-
export declare function entityToJSONSchema(config: SanitizedConfig, incomingEntity: SanitizedCollectionConfig | SanitizedGlobalConfig, interfaceNameDefinitions: Map<string, JSONSchema4>, defaultIDType: 'number' | 'text'
|
|
28
|
+
export declare function entityToJSONSchema(config: SanitizedConfig, incomingEntity: SanitizedCollectionConfig | SanitizedGlobalConfig, interfaceNameDefinitions: Map<string, JSONSchema4>, defaultIDType: 'number' | 'text', collectionIDFieldTypes?: {
|
|
29
|
+
[key: string]: 'number' | 'string';
|
|
30
|
+
}): JSONSchema4;
|
|
31
|
+
export declare function fieldsToSelectJSONSchema({ fields }: {
|
|
32
|
+
fields: Field[];
|
|
33
|
+
}): JSONSchema4;
|
|
29
34
|
export declare function authCollectionToOperationsJSONSchema(config: SanitizedCollectionConfig): JSONSchema4;
|
|
30
35
|
/**
|
|
31
36
|
* This is used for generating the TypeScript types (payload-types.ts) with the payload generate:types command.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configToJSONSchema.d.ts","sourceRoot":"","sources":["../../src/utilities/configToJSONSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAMnE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAC/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,KAAK,EAAE,KAAK,EAA8B,MAAM,2BAA2B,CAAA;AAClF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"configToJSONSchema.d.ts","sourceRoot":"","sources":["../../src/utilities/configToJSONSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAMnE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAC/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,KAAK,EAAE,KAAK,EAA8B,MAAM,2BAA2B,CAAA;AAClF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAoJvE;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,mBAAmB,EAC9B,UAAU,EAAE,OAAO,GAClB,mBAAmB,GAAG,mBAAmB,EAAE,CAO7C;AAED,wBAAgB,kBAAkB;AAChC;;;;GAIG;AACH,sBAAsB,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAA;CAAE,EAC9D,MAAM,EAAE,KAAK,EAAE;AACf;;GAEG;AACH,wBAAwB,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,EAClD,MAAM,CAAC,EAAE,eAAe,GACvB;IACD,UAAU,EAAE;QACV,CAAC,CAAC,EAAE,MAAM,GAAG,WAAW,CAAA;KACzB,CAAA;IACD,QAAQ,EAAE,MAAM,EAAE,CAAA;CACnB,CA6ZA;AAGD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,eAAe,EACvB,cAAc,EAAE,yBAAyB,GAAG,qBAAqB,EACjE,wBAAwB,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,EAClD,aAAa,EAAE,QAAQ,GAAG,MAAM,EAChC,sBAAsB,CAAC,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAA;CAAE,GAC9D,WAAW,CA8Cb;AAED,wBAAgB,wBAAwB,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,KAAK,EAAE,CAAA;CAAE,GAAG,WAAW,CA0FrF;AAgHD,wBAAgB,oCAAoC,CAClD,MAAM,EAAE,yBAAyB,GAChC,WAAW,CA0Bb;AAoBD;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,eAAe,EACvB,aAAa,CAAC,EAAE,QAAQ,GAAG,MAAM,GAChC,WAAW,CA0Gb"}
|
|
@@ -2,6 +2,7 @@ import pluralize from 'pluralize';
|
|
|
2
2
|
const { singular } = pluralize;
|
|
3
3
|
import { MissingEditorProp } from '../errors/MissingEditorProp.js';
|
|
4
4
|
import { fieldAffectsData, tabHasName } from '../fields/config/types.js';
|
|
5
|
+
import { generateJobsJSONSchemas } from '../queues/config/generateJobsJSONSchemas.js';
|
|
5
6
|
import { deepCopyObject } from './deepCopyObject.js';
|
|
6
7
|
import { toWords } from './formatLabels.js';
|
|
7
8
|
import { getCollectionIDFieldTypes } from './getCollectionIDFieldTypes.js';
|
|
@@ -53,6 +54,22 @@ function generateEntitySchemas(entities) {
|
|
|
53
54
|
required: Object.keys(properties)
|
|
54
55
|
};
|
|
55
56
|
}
|
|
57
|
+
function generateEntitySelectSchemas(entities) {
|
|
58
|
+
const properties = [
|
|
59
|
+
...entities
|
|
60
|
+
].reduce((acc, { slug })=>{
|
|
61
|
+
acc[slug] = {
|
|
62
|
+
$ref: `#/definitions/${slug}_select`
|
|
63
|
+
};
|
|
64
|
+
return acc;
|
|
65
|
+
}, {});
|
|
66
|
+
return {
|
|
67
|
+
type: 'object',
|
|
68
|
+
additionalProperties: false,
|
|
69
|
+
properties,
|
|
70
|
+
required: Object.keys(properties)
|
|
71
|
+
};
|
|
72
|
+
}
|
|
56
73
|
function generateLocaleEntitySchemas(localization) {
|
|
57
74
|
if (localization && 'locales' in localization && localization?.locales) {
|
|
58
75
|
const localesFromConfig = localization?.locales;
|
|
@@ -254,15 +271,19 @@ export function fieldsToJSONSchema(/**
|
|
|
254
271
|
fieldSchema = {
|
|
255
272
|
type: withNullableJSONSchemaType('array', isRequired),
|
|
256
273
|
items: {
|
|
257
|
-
type: 'string'
|
|
258
|
-
enum: optionEnums
|
|
274
|
+
type: 'string'
|
|
259
275
|
}
|
|
260
276
|
};
|
|
277
|
+
if (optionEnums?.length) {
|
|
278
|
+
fieldSchema.items.enum = optionEnums;
|
|
279
|
+
}
|
|
261
280
|
} else {
|
|
262
281
|
fieldSchema = {
|
|
263
|
-
type: withNullableJSONSchemaType('string', isRequired)
|
|
264
|
-
enum: optionEnums
|
|
282
|
+
type: withNullableJSONSchemaType('string', isRequired)
|
|
265
283
|
};
|
|
284
|
+
if (optionEnums?.length) {
|
|
285
|
+
fieldSchema.enum = optionEnums;
|
|
286
|
+
}
|
|
266
287
|
}
|
|
267
288
|
break;
|
|
268
289
|
}
|
|
@@ -531,7 +552,13 @@ export function fieldsToJSONSchema(/**
|
|
|
531
552
|
};
|
|
532
553
|
}
|
|
533
554
|
// This function is part of the public API and is exported through payload/utilities
|
|
534
|
-
export function entityToJSONSchema(config, incomingEntity, interfaceNameDefinitions, defaultIDType) {
|
|
555
|
+
export function entityToJSONSchema(config, incomingEntity, interfaceNameDefinitions, defaultIDType, collectionIDFieldTypes) {
|
|
556
|
+
if (!collectionIDFieldTypes) {
|
|
557
|
+
collectionIDFieldTypes = getCollectionIDFieldTypes({
|
|
558
|
+
config,
|
|
559
|
+
defaultIDType
|
|
560
|
+
});
|
|
561
|
+
}
|
|
535
562
|
const entity = deepCopyObject(incomingEntity);
|
|
536
563
|
const title = entity.typescript?.interface ? entity.typescript.interface : singular(toWords(entity.slug, true));
|
|
537
564
|
const idField = {
|
|
@@ -563,11 +590,6 @@ export function entityToJSONSchema(config, incomingEntity, interfaceNameDefiniti
|
|
|
563
590
|
type: 'text'
|
|
564
591
|
});
|
|
565
592
|
}
|
|
566
|
-
// Used for relationship fields, to determine whether to use a string or number type for the ID.
|
|
567
|
-
const collectionIDFieldTypes = getCollectionIDFieldTypes({
|
|
568
|
-
config,
|
|
569
|
-
defaultIDType
|
|
570
|
-
});
|
|
571
593
|
return {
|
|
572
594
|
type: 'object',
|
|
573
595
|
additionalProperties: false,
|
|
@@ -575,6 +597,97 @@ export function entityToJSONSchema(config, incomingEntity, interfaceNameDefiniti
|
|
|
575
597
|
...fieldsToJSONSchema(collectionIDFieldTypes, entity.fields, interfaceNameDefinitions, config)
|
|
576
598
|
};
|
|
577
599
|
}
|
|
600
|
+
export function fieldsToSelectJSONSchema({ fields }) {
|
|
601
|
+
const schema = {
|
|
602
|
+
type: 'object',
|
|
603
|
+
additionalProperties: false,
|
|
604
|
+
properties: {}
|
|
605
|
+
};
|
|
606
|
+
for (const field of fields){
|
|
607
|
+
switch(field.type){
|
|
608
|
+
case 'row':
|
|
609
|
+
case 'collapsible':
|
|
610
|
+
schema.properties = {
|
|
611
|
+
...schema.properties,
|
|
612
|
+
...fieldsToSelectJSONSchema({
|
|
613
|
+
fields: field.fields
|
|
614
|
+
}).properties
|
|
615
|
+
};
|
|
616
|
+
break;
|
|
617
|
+
case 'array':
|
|
618
|
+
case 'group':
|
|
619
|
+
schema.properties[field.name] = {
|
|
620
|
+
oneOf: [
|
|
621
|
+
{
|
|
622
|
+
type: 'boolean'
|
|
623
|
+
},
|
|
624
|
+
fieldsToSelectJSONSchema({
|
|
625
|
+
fields: field.fields
|
|
626
|
+
})
|
|
627
|
+
]
|
|
628
|
+
};
|
|
629
|
+
break;
|
|
630
|
+
case 'tabs':
|
|
631
|
+
for (const tab of field.tabs){
|
|
632
|
+
if (tabHasName(tab)) {
|
|
633
|
+
schema.properties[tab.name] = {
|
|
634
|
+
oneOf: [
|
|
635
|
+
{
|
|
636
|
+
type: 'boolean'
|
|
637
|
+
},
|
|
638
|
+
fieldsToSelectJSONSchema({
|
|
639
|
+
fields: tab.fields
|
|
640
|
+
})
|
|
641
|
+
]
|
|
642
|
+
};
|
|
643
|
+
continue;
|
|
644
|
+
}
|
|
645
|
+
schema.properties = {
|
|
646
|
+
...schema.properties,
|
|
647
|
+
...fieldsToSelectJSONSchema({
|
|
648
|
+
fields: tab.fields
|
|
649
|
+
}).properties
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
break;
|
|
653
|
+
case 'blocks':
|
|
654
|
+
{
|
|
655
|
+
const blocksSchema = {
|
|
656
|
+
type: 'object',
|
|
657
|
+
additionalProperties: false,
|
|
658
|
+
properties: {}
|
|
659
|
+
};
|
|
660
|
+
for (const block of field.blocks){
|
|
661
|
+
blocksSchema.properties[block.slug] = {
|
|
662
|
+
oneOf: [
|
|
663
|
+
{
|
|
664
|
+
type: 'boolean'
|
|
665
|
+
},
|
|
666
|
+
fieldsToSelectJSONSchema({
|
|
667
|
+
fields: block.fields
|
|
668
|
+
})
|
|
669
|
+
]
|
|
670
|
+
};
|
|
671
|
+
}
|
|
672
|
+
schema.properties[field.name] = {
|
|
673
|
+
oneOf: [
|
|
674
|
+
{
|
|
675
|
+
type: 'boolean'
|
|
676
|
+
},
|
|
677
|
+
blocksSchema
|
|
678
|
+
]
|
|
679
|
+
};
|
|
680
|
+
break;
|
|
681
|
+
}
|
|
682
|
+
default:
|
|
683
|
+
schema.properties[field.name] = {
|
|
684
|
+
type: 'boolean'
|
|
685
|
+
};
|
|
686
|
+
break;
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
return schema;
|
|
690
|
+
}
|
|
578
691
|
const fieldType = {
|
|
579
692
|
type: 'string',
|
|
580
693
|
required: false
|
|
@@ -756,13 +869,38 @@ function generateAuthOperationSchemas(collections) {
|
|
|
756
869
|
*/ export function configToJSONSchema(config, defaultIDType) {
|
|
757
870
|
// a mutable Map to store custom top-level `interfaceName` types. Fields with an `interfaceName` property will be moved to the top-level definitions here
|
|
758
871
|
const interfaceNameDefinitions = new Map();
|
|
872
|
+
// Used for relationship fields, to determine whether to use a string or number type for the ID.
|
|
873
|
+
const collectionIDFieldTypes = getCollectionIDFieldTypes({
|
|
874
|
+
config,
|
|
875
|
+
defaultIDType
|
|
876
|
+
});
|
|
759
877
|
// Collections and Globals have to be moved to the top-level definitions as well. Reason: The top-level type will be the `Config` type - we don't want all collection and global
|
|
760
878
|
// types to be inlined inside the `Config` type
|
|
761
|
-
const
|
|
762
|
-
...config.globals
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
879
|
+
const entities = [
|
|
880
|
+
...config.globals.map((global)=>({
|
|
881
|
+
type: 'global',
|
|
882
|
+
entity: global
|
|
883
|
+
})),
|
|
884
|
+
...config.collections.map((collection)=>({
|
|
885
|
+
type: 'collection',
|
|
886
|
+
entity: collection
|
|
887
|
+
}))
|
|
888
|
+
];
|
|
889
|
+
const entityDefinitions = entities.reduce((acc, { type, entity })=>{
|
|
890
|
+
acc[entity.slug] = entityToJSONSchema(config, entity, interfaceNameDefinitions, defaultIDType, collectionIDFieldTypes);
|
|
891
|
+
const select = fieldsToSelectJSONSchema({
|
|
892
|
+
fields: entity.fields
|
|
893
|
+
});
|
|
894
|
+
if (type === 'global') {
|
|
895
|
+
select.properties.globalType = {
|
|
896
|
+
type: 'boolean'
|
|
897
|
+
};
|
|
898
|
+
}
|
|
899
|
+
acc[`${entity.slug}_select`] = {
|
|
900
|
+
type: 'object',
|
|
901
|
+
additionalProperties: false,
|
|
902
|
+
...select
|
|
903
|
+
};
|
|
766
904
|
return acc;
|
|
767
905
|
}, {});
|
|
768
906
|
const authOperationDefinitions = [
|
|
@@ -773,6 +911,7 @@ function generateAuthOperationSchemas(collections) {
|
|
|
773
911
|
}, {
|
|
774
912
|
auth: {}
|
|
775
913
|
});
|
|
914
|
+
const jobsSchemas = config.jobs ? generateJobsJSONSchemas(config, config.jobs, interfaceNameDefinitions, collectionIDFieldTypes) : {};
|
|
776
915
|
let jsonSchema = {
|
|
777
916
|
additionalProperties: false,
|
|
778
917
|
definitions: {
|
|
@@ -785,8 +924,10 @@ function generateAuthOperationSchemas(collections) {
|
|
|
785
924
|
properties: {
|
|
786
925
|
auth: generateAuthOperationSchemas(config.collections),
|
|
787
926
|
collections: generateEntitySchemas(config.collections || []),
|
|
927
|
+
collectionsSelect: generateEntitySelectSchemas(config.collections || []),
|
|
788
928
|
db: generateDbEntitySchema(config),
|
|
789
929
|
globals: generateEntitySchemas(config.globals || []),
|
|
930
|
+
globalsSelect: generateEntitySelectSchemas(config.globals || []),
|
|
790
931
|
locale: generateLocaleEntitySchemas(config.localization),
|
|
791
932
|
user: generateAuthEntitySchemas(config.collections)
|
|
792
933
|
},
|
|
@@ -800,6 +941,21 @@ function generateAuthOperationSchemas(collections) {
|
|
|
800
941
|
],
|
|
801
942
|
title: 'Config'
|
|
802
943
|
};
|
|
944
|
+
if (jobsSchemas.definitions?.size) {
|
|
945
|
+
for (const [key, value] of jobsSchemas.definitions){
|
|
946
|
+
jsonSchema.definitions[key] = value;
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
if (jobsSchemas.properties) {
|
|
950
|
+
jsonSchema.properties.jobs = {
|
|
951
|
+
type: 'object',
|
|
952
|
+
additionalProperties: false,
|
|
953
|
+
properties: jobsSchemas.properties,
|
|
954
|
+
required: [
|
|
955
|
+
'tasks'
|
|
956
|
+
]
|
|
957
|
+
};
|
|
958
|
+
}
|
|
803
959
|
if (config?.typescript?.schema?.length) {
|
|
804
960
|
for (const schema of config.typescript.schema){
|
|
805
961
|
jsonSchema = schema({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/configToJSONSchema.ts"],"sourcesContent":["import type { JSONSchema4, JSONSchema4TypeName } from 'json-schema'\n\nimport pluralize from 'pluralize'\nconst { singular } = pluralize\n\nimport type { Auth } from '../auth/types.js'\nimport type { SanitizedCollectionConfig } from '../collections/config/types.js'\nimport type { SanitizedConfig } from '../config/types.js'\nimport type { Field, FieldAffectingData, Option } from '../fields/config/types.js'\nimport type { SanitizedGlobalConfig } from '../globals/config/types.js'\n\nimport { MissingEditorProp } from '../errors/MissingEditorProp.js'\nimport { fieldAffectsData, tabHasName } from '../fields/config/types.js'\nimport { deepCopyObject } from './deepCopyObject.js'\nimport { toWords } from './formatLabels.js'\nimport { getCollectionIDFieldTypes } from './getCollectionIDFieldTypes.js'\n\nconst fieldIsRequired = (field: Field) => {\n const isConditional = Boolean(field?.admin && field?.admin?.condition)\n if (isConditional) {\n return false\n }\n\n const isMarkedRequired = 'required' in field && field.required === true\n if (fieldAffectsData(field) && isMarkedRequired) {\n return true\n }\n\n // if any subfields are required, this field is required\n if ('fields' in field && field.type !== 'array') {\n return field.fields.some((subField) => fieldIsRequired(subField))\n }\n\n // if any tab subfields have required fields, this field is required\n if (field.type === 'tabs') {\n return field.tabs.some((tab) => {\n if ('name' in tab) {\n return tab.fields.some((subField) => fieldIsRequired(subField))\n }\n return false\n })\n }\n\n return false\n}\n\nfunction buildOptionEnums(options: Option[]): string[] {\n return options.map((option) => {\n if (typeof option === 'object' && 'value' in option) {\n return option.value\n }\n\n return option\n })\n}\n\nfunction generateEntitySchemas(\n entities: (SanitizedCollectionConfig | SanitizedGlobalConfig)[],\n): JSONSchema4 {\n const properties = [...entities].reduce((acc, { slug }) => {\n acc[slug] = {\n $ref: `#/definitions/${slug}`,\n }\n\n return acc\n }, {})\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n }\n}\n\nfunction generateLocaleEntitySchemas(localization: SanitizedConfig['localization']): JSONSchema4 {\n if (localization && 'locales' in localization && localization?.locales) {\n const localesFromConfig = localization?.locales\n\n const locales = [...localesFromConfig].map((locale) => {\n return locale.code\n }, [])\n\n return {\n type: 'string',\n enum: locales,\n }\n }\n\n return {\n type: 'null',\n }\n}\n\nfunction generateAuthEntitySchemas(entities: SanitizedCollectionConfig[]): JSONSchema4 {\n const properties: JSONSchema4[] = [...entities]\n .filter(({ auth }) => Boolean(auth))\n .map(({ slug }) => {\n return {\n allOf: [\n { $ref: `#/definitions/${slug}` },\n {\n type: 'object',\n additionalProperties: false,\n properties: {\n collection: { type: 'string', enum: [slug] },\n },\n required: ['collection'],\n },\n ],\n }\n }, {})\n\n return {\n oneOf: properties,\n }\n}\n\n/**\n * Generates the JSON Schema for database configuration\n *\n * @example { db: idType: string }\n */\nfunction generateDbEntitySchema(config: SanitizedConfig): JSONSchema4 {\n const defaultIDType: JSONSchema4 =\n config.db?.defaultIDType === 'number' ? { type: 'number' } : { type: 'string' }\n\n return {\n type: 'object',\n additionalProperties: false,\n properties: {\n defaultIDType,\n },\n required: ['defaultIDType'],\n }\n}\n\n/**\n * Returns a JSON Schema Type with 'null' added if the field is not required.\n */\nexport function withNullableJSONSchemaType(\n fieldType: JSONSchema4TypeName,\n isRequired: boolean,\n): JSONSchema4TypeName | JSONSchema4TypeName[] {\n const fieldTypes = [fieldType]\n if (isRequired) {\n return fieldType\n }\n fieldTypes.push('null')\n return fieldTypes\n}\n\nexport function fieldsToJSONSchema(\n /**\n * Used for relationship fields, to determine whether to use a string or number type for the ID.\n * While there is a default ID field type set by the db adapter, they can differ on a collection-level\n * if they have custom ID fields.\n */\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' },\n fields: Field[],\n /**\n * Allows you to define new top-level interfaces that can be re-used in the output schema.\n */\n interfaceNameDefinitions: Map<string, JSONSchema4>,\n config?: SanitizedConfig,\n): {\n properties: {\n [k: string]: JSONSchema4\n }\n required: string[]\n} {\n const requiredFieldNames = new Set<string>()\n\n return {\n properties: Object.fromEntries(\n fields.reduce((fieldSchemas, field) => {\n const isRequired = fieldAffectsData(field) && fieldIsRequired(field)\n if (isRequired) {\n requiredFieldNames.add(field.name)\n }\n\n let fieldSchema: JSONSchema4\n\n switch (field.type) {\n case 'text':\n if (field.hasMany === true) {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: { type: 'string' },\n }\n } else {\n fieldSchema = { type: withNullableJSONSchemaType('string', isRequired) }\n }\n break\n case 'textarea':\n case 'code':\n case 'email':\n case 'date': {\n fieldSchema = { type: withNullableJSONSchemaType('string', isRequired) }\n break\n }\n\n case 'number': {\n if (field.hasMany === true) {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: { type: 'number' },\n }\n } else {\n fieldSchema = { type: withNullableJSONSchemaType('number', isRequired) }\n }\n break\n }\n\n case 'checkbox': {\n fieldSchema = { type: withNullableJSONSchemaType('boolean', isRequired) }\n break\n }\n\n case 'json': {\n fieldSchema = field.jsonSchema?.schema || {\n type: ['object', 'array', 'string', 'number', 'boolean', 'null'],\n }\n break\n }\n\n case 'richText': {\n if (!field?.editor) {\n throw new MissingEditorProp(field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n if (typeof field.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n if (field.editor.outputSchema) {\n fieldSchema = field.editor.outputSchema({\n collectionIDFieldTypes,\n config,\n field,\n interfaceNameDefinitions,\n isRequired,\n })\n } else {\n // Maintain backwards compatibility with existing rich text editors\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'object',\n },\n }\n }\n\n break\n }\n\n case 'radio': {\n fieldSchema = {\n type: withNullableJSONSchemaType('string', isRequired),\n enum: buildOptionEnums(field.options),\n }\n\n break\n }\n\n case 'select': {\n const optionEnums = buildOptionEnums(field.options)\n\n if (field.hasMany) {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'string',\n enum: optionEnums,\n },\n }\n } else {\n fieldSchema = {\n type: withNullableJSONSchemaType('string', isRequired),\n enum: optionEnums,\n }\n }\n\n break\n }\n\n case 'point': {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: [\n {\n type: 'number',\n },\n {\n type: 'number',\n },\n ],\n maxItems: 2,\n minItems: 2,\n }\n break\n }\n\n case 'join': {\n fieldSchema = {\n type: withNullableJSONSchemaType('object', false),\n additionalProperties: false,\n properties: {\n docs: {\n type: withNullableJSONSchemaType('array', false),\n items: {\n oneOf: [\n {\n type: collectionIDFieldTypes[field.collection],\n },\n {\n $ref: `#/definitions/${field.collection}`,\n },\n ],\n },\n },\n hasNextPage: { type: withNullableJSONSchemaType('boolean', false) },\n },\n }\n break\n }\n\n case 'upload':\n case 'relationship': {\n if (Array.isArray(field.relationTo)) {\n if (field.hasMany) {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n oneOf: field.relationTo.map((relation) => {\n return {\n type: 'object',\n additionalProperties: false,\n properties: {\n relationTo: {\n const: relation,\n },\n value: {\n oneOf: [\n {\n type: collectionIDFieldTypes[relation],\n },\n {\n $ref: `#/definitions/${relation}`,\n },\n ],\n },\n },\n required: ['value', 'relationTo'],\n }\n }),\n },\n }\n } else {\n fieldSchema = {\n oneOf: field.relationTo.map((relation) => {\n return {\n type: withNullableJSONSchemaType('object', isRequired),\n additionalProperties: false,\n properties: {\n relationTo: {\n const: relation,\n },\n value: {\n oneOf: [\n {\n type: collectionIDFieldTypes[relation],\n },\n {\n $ref: `#/definitions/${relation}`,\n },\n ],\n },\n },\n required: ['value', 'relationTo'],\n }\n }),\n }\n }\n } else if (field.hasMany) {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n oneOf: [\n {\n type: collectionIDFieldTypes[field.relationTo],\n },\n {\n $ref: `#/definitions/${field.relationTo}`,\n },\n ],\n },\n }\n } else {\n fieldSchema = {\n oneOf: [\n {\n type: withNullableJSONSchemaType(\n collectionIDFieldTypes[field.relationTo],\n isRequired,\n ),\n },\n {\n $ref: `#/definitions/${field.relationTo}`,\n },\n ],\n }\n }\n\n break\n }\n\n case 'blocks': {\n // Check for a case where no blocks are provided.\n // We need to generate an empty array for this case, note that JSON schema 4 doesn't support empty arrays\n // so the best we can get is `unknown[]`\n const hasBlocks = Boolean(field.blocks.length)\n\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: hasBlocks\n ? {\n oneOf: field.blocks.map((block) => {\n const blockFieldSchemas = fieldsToJSONSchema(\n collectionIDFieldTypes,\n block.fields,\n interfaceNameDefinitions,\n config,\n )\n\n const blockSchema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n properties: {\n ...blockFieldSchemas.properties,\n blockType: {\n const: block.slug,\n },\n },\n required: ['blockType', ...blockFieldSchemas.required],\n }\n\n if (block.interfaceName) {\n interfaceNameDefinitions.set(block.interfaceName, blockSchema)\n\n return {\n $ref: `#/definitions/${block.interfaceName}`,\n }\n }\n\n return blockSchema\n }),\n }\n : {},\n }\n break\n }\n\n case 'array': {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'object',\n additionalProperties: false,\n ...fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.fields,\n interfaceNameDefinitions,\n config,\n ),\n },\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = {\n $ref: `#/definitions/${field.interfaceName}`,\n }\n }\n break\n }\n\n case 'row':\n case 'collapsible': {\n const childSchema = fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.fields,\n interfaceNameDefinitions,\n config,\n )\n Object.entries(childSchema.properties).forEach(([propName, propSchema]) => {\n fieldSchemas.set(propName, propSchema)\n })\n childSchema.required.forEach((propName) => {\n requiredFieldNames.add(propName)\n })\n break\n }\n\n case 'tabs': {\n field.tabs.forEach((tab) => {\n const childSchema = fieldsToJSONSchema(\n collectionIDFieldTypes,\n tab.fields,\n interfaceNameDefinitions,\n config,\n )\n if (tabHasName(tab)) {\n // could have interface\n fieldSchemas.set(tab.name, {\n type: 'object',\n additionalProperties: false,\n ...childSchema,\n })\n\n // If the named tab has any required fields then we mark this as required otherwise it should be optional\n const hasRequiredFields = tab.fields.some((subField) => fieldIsRequired(subField))\n\n if (hasRequiredFields) {\n requiredFieldNames.add(tab.name)\n }\n } else {\n Object.entries(childSchema.properties).forEach(([propName, propSchema]) => {\n fieldSchemas.set(propName, propSchema)\n })\n childSchema.required.forEach((propName) => {\n requiredFieldNames.add(propName)\n })\n }\n })\n break\n }\n\n case 'group': {\n fieldSchema = {\n type: 'object',\n additionalProperties: false,\n ...fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.fields,\n interfaceNameDefinitions,\n config,\n ),\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = {\n $ref: `#/definitions/${field.interfaceName}`,\n }\n }\n break\n }\n\n default: {\n break\n }\n }\n\n if ('typescriptSchema' in field && field?.typescriptSchema?.length) {\n for (const schema of field.typescriptSchema) {\n fieldSchema = schema({ jsonSchema: fieldSchema })\n }\n }\n\n if (fieldSchema && fieldAffectsData(field)) {\n fieldSchemas.set(field.name, fieldSchema)\n }\n\n return fieldSchemas\n }, new Map<string, JSONSchema4>()),\n ),\n required: Array.from(requiredFieldNames),\n }\n}\n\n// This function is part of the public API and is exported through payload/utilities\nexport function entityToJSONSchema(\n config: SanitizedConfig,\n incomingEntity: SanitizedCollectionConfig | SanitizedGlobalConfig,\n interfaceNameDefinitions: Map<string, JSONSchema4>,\n defaultIDType: 'number' | 'text',\n): JSONSchema4 {\n const entity: SanitizedCollectionConfig | SanitizedGlobalConfig = deepCopyObject(incomingEntity)\n const title = entity.typescript?.interface\n ? entity.typescript.interface\n : singular(toWords(entity.slug, true))\n\n const idField: FieldAffectingData = { name: 'id', type: defaultIDType as 'text', required: true }\n const customIdField = entity.fields.find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n ) as FieldAffectingData\n\n if (customIdField && customIdField.type !== 'group' && customIdField.type !== 'tab') {\n customIdField.required = true\n } else {\n entity.fields.unshift(idField)\n }\n\n // mark timestamp fields required\n if ('timestamps' in entity && entity.timestamps !== false) {\n entity.fields = entity.fields.map((field) => {\n if (fieldAffectsData(field) && (field.name === 'createdAt' || field.name === 'updatedAt')) {\n return {\n ...field,\n required: true,\n }\n }\n return field\n })\n }\n\n if ('auth' in entity && entity.auth && !entity.auth?.disableLocalStrategy) {\n entity.fields.push({\n name: 'password',\n type: 'text',\n })\n }\n\n // Used for relationship fields, to determine whether to use a string or number type for the ID.\n const collectionIDFieldTypes = getCollectionIDFieldTypes({ config, defaultIDType })\n\n return {\n type: 'object',\n additionalProperties: false,\n title,\n ...fieldsToJSONSchema(collectionIDFieldTypes, entity.fields, interfaceNameDefinitions, config),\n }\n}\n\nconst fieldType: JSONSchema4 = {\n type: 'string',\n required: false,\n}\nconst generateAuthFieldTypes = ({\n type,\n loginWithUsername,\n}: {\n loginWithUsername: Auth['loginWithUsername']\n type: 'forgotOrUnlock' | 'login' | 'register'\n}): JSONSchema4 => {\n if (loginWithUsername) {\n switch (type) {\n case 'login': {\n if (loginWithUsername.allowEmailLogin) {\n // allow username or email and require password for login\n return {\n additionalProperties: false,\n oneOf: [\n {\n additionalProperties: false,\n properties: { email: fieldType, password: fieldType },\n required: ['email', 'password'],\n },\n {\n additionalProperties: false,\n properties: { password: fieldType, username: fieldType },\n required: ['username', 'password'],\n },\n ],\n }\n } else {\n // allow only username and password for login\n return {\n additionalProperties: false,\n properties: {\n password: fieldType,\n username: fieldType,\n },\n required: ['username', 'password'],\n }\n }\n }\n\n case 'register': {\n const requiredFields: ('email' | 'password' | 'username')[] = ['password']\n const properties: {\n email?: JSONSchema4['properties']\n password?: JSONSchema4['properties']\n username?: JSONSchema4['properties']\n } = {\n password: fieldType,\n username: fieldType,\n }\n\n if (loginWithUsername.requireEmail) {\n requiredFields.push('email')\n }\n if (loginWithUsername.requireUsername) {\n requiredFields.push('username')\n }\n if (loginWithUsername.requireEmail || loginWithUsername.allowEmailLogin) {\n properties.email = fieldType\n }\n\n return {\n additionalProperties: false,\n properties,\n required: requiredFields,\n }\n }\n\n case 'forgotOrUnlock': {\n if (loginWithUsername.allowEmailLogin) {\n // allow email or username for unlock/forgot-password\n return {\n additionalProperties: false,\n oneOf: [\n {\n additionalProperties: false,\n properties: { email: fieldType },\n required: ['email'],\n },\n {\n additionalProperties: false,\n properties: { username: fieldType },\n required: ['username'],\n },\n ],\n }\n } else {\n // allow only username for unlock/forgot-password\n return {\n additionalProperties: false,\n properties: { username: fieldType },\n required: ['username'],\n }\n }\n }\n }\n }\n\n // default email (and password for login/register)\n return {\n additionalProperties: false,\n properties: { email: fieldType, password: fieldType },\n required: ['email', 'password'],\n }\n}\n\nexport function authCollectionToOperationsJSONSchema(\n config: SanitizedCollectionConfig,\n): JSONSchema4 {\n const loginWithUsername = config.auth?.loginWithUsername\n const loginUserFields: JSONSchema4 = generateAuthFieldTypes({ type: 'login', loginWithUsername })\n const forgotOrUnlockUserFields: JSONSchema4 = generateAuthFieldTypes({\n type: 'forgotOrUnlock',\n loginWithUsername,\n })\n const registerUserFields: JSONSchema4 = generateAuthFieldTypes({\n type: 'register',\n loginWithUsername,\n })\n\n const properties: JSONSchema4['properties'] = {\n forgotPassword: forgotOrUnlockUserFields,\n login: loginUserFields,\n registerFirstUser: registerUserFields,\n unlock: forgotOrUnlockUserFields,\n }\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n title: `${singular(toWords(`${config.slug}`, true))}AuthOperations`,\n }\n}\n\nfunction generateAuthOperationSchemas(collections: SanitizedCollectionConfig[]): JSONSchema4 {\n const properties = collections.reduce((acc, collection) => {\n if (collection.auth) {\n acc[collection.slug] = {\n $ref: `#/definitions/auth/${collection.slug}`,\n }\n }\n return acc\n }, {})\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n }\n}\n\n/**\n * This is used for generating the TypeScript types (payload-types.ts) with the payload generate:types command.\n */\nexport function configToJSONSchema(\n config: SanitizedConfig,\n defaultIDType?: 'number' | 'text',\n): JSONSchema4 {\n // a mutable Map to store custom top-level `interfaceName` types. Fields with an `interfaceName` property will be moved to the top-level definitions here\n const interfaceNameDefinitions: Map<string, JSONSchema4> = new Map()\n\n // Collections and Globals have to be moved to the top-level definitions as well. Reason: The top-level type will be the `Config` type - we don't want all collection and global\n // types to be inlined inside the `Config` type\n const entityDefinitions: { [k: string]: JSONSchema4 } = [\n ...config.globals,\n ...config.collections,\n ].reduce((acc, entity) => {\n acc[entity.slug] = entityToJSONSchema(config, entity, interfaceNameDefinitions, defaultIDType)\n return acc\n }, {})\n\n const authOperationDefinitions = [...config.collections]\n .filter(({ auth }) => Boolean(auth))\n .reduce(\n (acc, authCollection) => {\n acc.auth[authCollection.slug] = authCollectionToOperationsJSONSchema(authCollection)\n return acc\n },\n { auth: {} },\n )\n\n let jsonSchema: JSONSchema4 = {\n additionalProperties: false,\n definitions: {\n ...entityDefinitions,\n ...Object.fromEntries(interfaceNameDefinitions),\n ...authOperationDefinitions,\n },\n // These properties here will be very simple, as all the complexity is in the definitions. These are just the properties for the top-level `Config` type\n type: 'object',\n properties: {\n auth: generateAuthOperationSchemas(config.collections),\n collections: generateEntitySchemas(config.collections || []),\n db: generateDbEntitySchema(config),\n globals: generateEntitySchemas(config.globals || []),\n locale: generateLocaleEntitySchemas(config.localization),\n user: generateAuthEntitySchemas(config.collections),\n },\n required: ['user', 'locale', 'collections', 'globals', 'auth', 'db'],\n title: 'Config',\n }\n\n if (config?.typescript?.schema?.length) {\n for (const schema of config.typescript.schema) {\n jsonSchema = schema({ jsonSchema })\n }\n }\n\n return jsonSchema\n}\n"],"names":["pluralize","singular","MissingEditorProp","fieldAffectsData","tabHasName","deepCopyObject","toWords","getCollectionIDFieldTypes","fieldIsRequired","field","isConditional","Boolean","admin","condition","isMarkedRequired","required","type","fields","some","subField","tabs","tab","buildOptionEnums","options","map","option","value","generateEntitySchemas","entities","properties","reduce","acc","slug","$ref","additionalProperties","Object","keys","generateLocaleEntitySchemas","localization","locales","localesFromConfig","locale","code","enum","generateAuthEntitySchemas","filter","auth","allOf","collection","oneOf","generateDbEntitySchema","config","defaultIDType","db","withNullableJSONSchemaType","fieldType","isRequired","fieldTypes","push","fieldsToJSONSchema","collectionIDFieldTypes","interfaceNameDefinitions","requiredFieldNames","Set","fromEntries","fieldSchemas","add","name","fieldSchema","hasMany","items","jsonSchema","schema","editor","Error","outputSchema","optionEnums","maxItems","minItems","docs","hasNextPage","Array","isArray","relationTo","relation","const","hasBlocks","blocks","length","block","blockFieldSchemas","blockSchema","blockType","interfaceName","set","childSchema","entries","forEach","propName","propSchema","hasRequiredFields","typescriptSchema","Map","from","entityToJSONSchema","incomingEntity","entity","title","typescript","interface","idField","customIdField","find","unshift","timestamps","disableLocalStrategy","generateAuthFieldTypes","loginWithUsername","allowEmailLogin","email","password","username","requiredFields","requireEmail","requireUsername","authCollectionToOperationsJSONSchema","loginUserFields","forgotOrUnlockUserFields","registerUserFields","forgotPassword","login","registerFirstUser","unlock","generateAuthOperationSchemas","collections","configToJSONSchema","entityDefinitions","globals","authOperationDefinitions","authCollection","definitions","user"],"mappings":"AAEA,OAAOA,eAAe,YAAW;AACjC,MAAM,EAAEC,QAAQ,EAAE,GAAGD;AAQrB,SAASE,iBAAiB,QAAQ,iCAAgC;AAClE,SAASC,gBAAgB,EAAEC,UAAU,QAAQ,4BAA2B;A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AAOyD,UAAU,CAACpC,MAAM,CAAE;YAC7CD,aAAaC,OAAO;gBAAED;YAAW;QACnC;IACF;IAEA,OAAOA;AACT"}
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/configToJSONSchema.ts"],"sourcesContent":["import type { JSONSchema4, JSONSchema4TypeName } from 'json-schema'\n\nimport pluralize from 'pluralize'\nconst { singular } = pluralize\n\nimport type { Auth } from '../auth/types.js'\nimport type { SanitizedCollectionConfig } from '../collections/config/types.js'\nimport type { SanitizedConfig } from '../config/types.js'\nimport type { Field, FieldAffectingData, Option } from '../fields/config/types.js'\nimport type { SanitizedGlobalConfig } from '../globals/config/types.js'\n\nimport { MissingEditorProp } from '../errors/MissingEditorProp.js'\nimport { fieldAffectsData, tabHasName } from '../fields/config/types.js'\nimport { generateJobsJSONSchemas } from '../queues/config/generateJobsJSONSchemas.js'\nimport { deepCopyObject } from './deepCopyObject.js'\nimport { toWords } from './formatLabels.js'\nimport { getCollectionIDFieldTypes } from './getCollectionIDFieldTypes.js'\n\nconst fieldIsRequired = (field: Field) => {\n const isConditional = Boolean(field?.admin && field?.admin?.condition)\n if (isConditional) {\n return false\n }\n\n const isMarkedRequired = 'required' in field && field.required === true\n if (fieldAffectsData(field) && isMarkedRequired) {\n return true\n }\n\n // if any subfields are required, this field is required\n if ('fields' in field && field.type !== 'array') {\n return field.fields.some((subField) => fieldIsRequired(subField))\n }\n\n // if any tab subfields have required fields, this field is required\n if (field.type === 'tabs') {\n return field.tabs.some((tab) => {\n if ('name' in tab) {\n return tab.fields.some((subField) => fieldIsRequired(subField))\n }\n return false\n })\n }\n\n return false\n}\n\nfunction buildOptionEnums(options: Option[]): string[] {\n return options.map((option) => {\n if (typeof option === 'object' && 'value' in option) {\n return option.value\n }\n\n return option\n })\n}\n\nfunction generateEntitySchemas(\n entities: (SanitizedCollectionConfig | SanitizedGlobalConfig)[],\n): JSONSchema4 {\n const properties = [...entities].reduce((acc, { slug }) => {\n acc[slug] = {\n $ref: `#/definitions/${slug}`,\n }\n\n return acc\n }, {})\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n }\n}\n\nfunction generateEntitySelectSchemas(\n entities: (SanitizedCollectionConfig | SanitizedGlobalConfig)[],\n): JSONSchema4 {\n const properties = [...entities].reduce((acc, { slug }) => {\n acc[slug] = {\n $ref: `#/definitions/${slug}_select`,\n }\n\n return acc\n }, {})\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n }\n}\n\nfunction generateLocaleEntitySchemas(localization: SanitizedConfig['localization']): JSONSchema4 {\n if (localization && 'locales' in localization && localization?.locales) {\n const localesFromConfig = localization?.locales\n\n const locales = [...localesFromConfig].map((locale) => {\n return locale.code\n }, [])\n\n return {\n type: 'string',\n enum: locales,\n }\n }\n\n return {\n type: 'null',\n }\n}\n\nfunction generateAuthEntitySchemas(entities: SanitizedCollectionConfig[]): JSONSchema4 {\n const properties: JSONSchema4[] = [...entities]\n .filter(({ auth }) => Boolean(auth))\n .map(({ slug }) => {\n return {\n allOf: [\n { $ref: `#/definitions/${slug}` },\n {\n type: 'object',\n additionalProperties: false,\n properties: {\n collection: { type: 'string', enum: [slug] },\n },\n required: ['collection'],\n },\n ],\n }\n }, {})\n\n return {\n oneOf: properties,\n }\n}\n\n/**\n * Generates the JSON Schema for database configuration\n *\n * @example { db: idType: string }\n */\nfunction generateDbEntitySchema(config: SanitizedConfig): JSONSchema4 {\n const defaultIDType: JSONSchema4 =\n config.db?.defaultIDType === 'number' ? { type: 'number' } : { type: 'string' }\n\n return {\n type: 'object',\n additionalProperties: false,\n properties: {\n defaultIDType,\n },\n required: ['defaultIDType'],\n }\n}\n\n/**\n * Returns a JSON Schema Type with 'null' added if the field is not required.\n */\nexport function withNullableJSONSchemaType(\n fieldType: JSONSchema4TypeName,\n isRequired: boolean,\n): JSONSchema4TypeName | JSONSchema4TypeName[] {\n const fieldTypes = [fieldType]\n if (isRequired) {\n return fieldType\n }\n fieldTypes.push('null')\n return fieldTypes\n}\n\nexport function fieldsToJSONSchema(\n /**\n * Used for relationship fields, to determine whether to use a string or number type for the ID.\n * While there is a default ID field type set by the db adapter, they can differ on a collection-level\n * if they have custom ID fields.\n */\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' },\n fields: Field[],\n /**\n * Allows you to define new top-level interfaces that can be re-used in the output schema.\n */\n interfaceNameDefinitions: Map<string, JSONSchema4>,\n config?: SanitizedConfig,\n): {\n properties: {\n [k: string]: JSONSchema4\n }\n required: string[]\n} {\n const requiredFieldNames = new Set<string>()\n\n return {\n properties: Object.fromEntries(\n fields.reduce((fieldSchemas, field) => {\n const isRequired = fieldAffectsData(field) && fieldIsRequired(field)\n if (isRequired) {\n requiredFieldNames.add(field.name)\n }\n\n let fieldSchema: JSONSchema4\n\n switch (field.type) {\n case 'text':\n if (field.hasMany === true) {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: { type: 'string' },\n }\n } else {\n fieldSchema = { type: withNullableJSONSchemaType('string', isRequired) }\n }\n break\n case 'textarea':\n case 'code':\n case 'email':\n case 'date': {\n fieldSchema = { type: withNullableJSONSchemaType('string', isRequired) }\n break\n }\n\n case 'number': {\n if (field.hasMany === true) {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: { type: 'number' },\n }\n } else {\n fieldSchema = { type: withNullableJSONSchemaType('number', isRequired) }\n }\n break\n }\n\n case 'checkbox': {\n fieldSchema = { type: withNullableJSONSchemaType('boolean', isRequired) }\n break\n }\n\n case 'json': {\n fieldSchema = field.jsonSchema?.schema || {\n type: ['object', 'array', 'string', 'number', 'boolean', 'null'],\n }\n break\n }\n\n case 'richText': {\n if (!field?.editor) {\n throw new MissingEditorProp(field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n if (typeof field.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n if (field.editor.outputSchema) {\n fieldSchema = field.editor.outputSchema({\n collectionIDFieldTypes,\n config,\n field,\n interfaceNameDefinitions,\n isRequired,\n })\n } else {\n // Maintain backwards compatibility with existing rich text editors\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'object',\n },\n }\n }\n\n break\n }\n\n case 'radio': {\n fieldSchema = {\n type: withNullableJSONSchemaType('string', isRequired),\n enum: buildOptionEnums(field.options),\n }\n\n break\n }\n\n case 'select': {\n const optionEnums = buildOptionEnums(field.options)\n\n if (field.hasMany) {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'string',\n },\n }\n if (optionEnums?.length) {\n ;(fieldSchema.items as JSONSchema4).enum = optionEnums\n }\n } else {\n fieldSchema = {\n type: withNullableJSONSchemaType('string', isRequired),\n }\n if (optionEnums?.length) {\n fieldSchema.enum = optionEnums\n }\n }\n\n break\n }\n\n case 'point': {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: [\n {\n type: 'number',\n },\n {\n type: 'number',\n },\n ],\n maxItems: 2,\n minItems: 2,\n }\n break\n }\n\n case 'join': {\n fieldSchema = {\n type: withNullableJSONSchemaType('object', false),\n additionalProperties: false,\n properties: {\n docs: {\n type: withNullableJSONSchemaType('array', false),\n items: {\n oneOf: [\n {\n type: collectionIDFieldTypes[field.collection],\n },\n {\n $ref: `#/definitions/${field.collection}`,\n },\n ],\n },\n },\n hasNextPage: { type: withNullableJSONSchemaType('boolean', false) },\n },\n }\n break\n }\n\n case 'upload':\n case 'relationship': {\n if (Array.isArray(field.relationTo)) {\n if (field.hasMany) {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n oneOf: field.relationTo.map((relation) => {\n return {\n type: 'object',\n additionalProperties: false,\n properties: {\n relationTo: {\n const: relation,\n },\n value: {\n oneOf: [\n {\n type: collectionIDFieldTypes[relation],\n },\n {\n $ref: `#/definitions/${relation}`,\n },\n ],\n },\n },\n required: ['value', 'relationTo'],\n }\n }),\n },\n }\n } else {\n fieldSchema = {\n oneOf: field.relationTo.map((relation) => {\n return {\n type: withNullableJSONSchemaType('object', isRequired),\n additionalProperties: false,\n properties: {\n relationTo: {\n const: relation,\n },\n value: {\n oneOf: [\n {\n type: collectionIDFieldTypes[relation],\n },\n {\n $ref: `#/definitions/${relation}`,\n },\n ],\n },\n },\n required: ['value', 'relationTo'],\n }\n }),\n }\n }\n } else if (field.hasMany) {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n oneOf: [\n {\n type: collectionIDFieldTypes[field.relationTo],\n },\n {\n $ref: `#/definitions/${field.relationTo}`,\n },\n ],\n },\n }\n } else {\n fieldSchema = {\n oneOf: [\n {\n type: withNullableJSONSchemaType(\n collectionIDFieldTypes[field.relationTo],\n isRequired,\n ),\n },\n {\n $ref: `#/definitions/${field.relationTo}`,\n },\n ],\n }\n }\n\n break\n }\n\n case 'blocks': {\n // Check for a case where no blocks are provided.\n // We need to generate an empty array for this case, note that JSON schema 4 doesn't support empty arrays\n // so the best we can get is `unknown[]`\n const hasBlocks = Boolean(field.blocks.length)\n\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: hasBlocks\n ? {\n oneOf: field.blocks.map((block) => {\n const blockFieldSchemas = fieldsToJSONSchema(\n collectionIDFieldTypes,\n block.fields,\n interfaceNameDefinitions,\n config,\n )\n\n const blockSchema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n properties: {\n ...blockFieldSchemas.properties,\n blockType: {\n const: block.slug,\n },\n },\n required: ['blockType', ...blockFieldSchemas.required],\n }\n\n if (block.interfaceName) {\n interfaceNameDefinitions.set(block.interfaceName, blockSchema)\n\n return {\n $ref: `#/definitions/${block.interfaceName}`,\n }\n }\n\n return blockSchema\n }),\n }\n : {},\n }\n break\n }\n\n case 'array': {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'object',\n additionalProperties: false,\n ...fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.fields,\n interfaceNameDefinitions,\n config,\n ),\n },\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = {\n $ref: `#/definitions/${field.interfaceName}`,\n }\n }\n break\n }\n\n case 'row':\n case 'collapsible': {\n const childSchema = fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.fields,\n interfaceNameDefinitions,\n config,\n )\n Object.entries(childSchema.properties).forEach(([propName, propSchema]) => {\n fieldSchemas.set(propName, propSchema)\n })\n childSchema.required.forEach((propName) => {\n requiredFieldNames.add(propName)\n })\n break\n }\n\n case 'tabs': {\n field.tabs.forEach((tab) => {\n const childSchema = fieldsToJSONSchema(\n collectionIDFieldTypes,\n tab.fields,\n interfaceNameDefinitions,\n config,\n )\n if (tabHasName(tab)) {\n // could have interface\n fieldSchemas.set(tab.name, {\n type: 'object',\n additionalProperties: false,\n ...childSchema,\n })\n\n // If the named tab has any required fields then we mark this as required otherwise it should be optional\n const hasRequiredFields = tab.fields.some((subField) => fieldIsRequired(subField))\n\n if (hasRequiredFields) {\n requiredFieldNames.add(tab.name)\n }\n } else {\n Object.entries(childSchema.properties).forEach(([propName, propSchema]) => {\n fieldSchemas.set(propName, propSchema)\n })\n childSchema.required.forEach((propName) => {\n requiredFieldNames.add(propName)\n })\n }\n })\n break\n }\n\n case 'group': {\n fieldSchema = {\n type: 'object',\n additionalProperties: false,\n ...fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.fields,\n interfaceNameDefinitions,\n config,\n ),\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = {\n $ref: `#/definitions/${field.interfaceName}`,\n }\n }\n break\n }\n\n default: {\n break\n }\n }\n\n if ('typescriptSchema' in field && field?.typescriptSchema?.length) {\n for (const schema of field.typescriptSchema) {\n fieldSchema = schema({ jsonSchema: fieldSchema })\n }\n }\n\n if (fieldSchema && fieldAffectsData(field)) {\n fieldSchemas.set(field.name, fieldSchema)\n }\n\n return fieldSchemas\n }, new Map<string, JSONSchema4>()),\n ),\n required: Array.from(requiredFieldNames),\n }\n}\n\n// This function is part of the public API and is exported through payload/utilities\nexport function entityToJSONSchema(\n config: SanitizedConfig,\n incomingEntity: SanitizedCollectionConfig | SanitizedGlobalConfig,\n interfaceNameDefinitions: Map<string, JSONSchema4>,\n defaultIDType: 'number' | 'text',\n collectionIDFieldTypes?: { [key: string]: 'number' | 'string' },\n): JSONSchema4 {\n if (!collectionIDFieldTypes) {\n collectionIDFieldTypes = getCollectionIDFieldTypes({ config, defaultIDType })\n }\n const entity: SanitizedCollectionConfig | SanitizedGlobalConfig = deepCopyObject(incomingEntity)\n const title = entity.typescript?.interface\n ? entity.typescript.interface\n : singular(toWords(entity.slug, true))\n\n const idField: FieldAffectingData = { name: 'id', type: defaultIDType as 'text', required: true }\n const customIdField = entity.fields.find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n ) as FieldAffectingData\n\n if (customIdField && customIdField.type !== 'group' && customIdField.type !== 'tab') {\n customIdField.required = true\n } else {\n entity.fields.unshift(idField)\n }\n\n // mark timestamp fields required\n if ('timestamps' in entity && entity.timestamps !== false) {\n entity.fields = entity.fields.map((field) => {\n if (fieldAffectsData(field) && (field.name === 'createdAt' || field.name === 'updatedAt')) {\n return {\n ...field,\n required: true,\n }\n }\n return field\n })\n }\n\n if ('auth' in entity && entity.auth && !entity.auth?.disableLocalStrategy) {\n entity.fields.push({\n name: 'password',\n type: 'text',\n })\n }\n\n return {\n type: 'object',\n additionalProperties: false,\n title,\n ...fieldsToJSONSchema(collectionIDFieldTypes, entity.fields, interfaceNameDefinitions, config),\n }\n}\n\nexport function fieldsToSelectJSONSchema({ fields }: { fields: Field[] }): JSONSchema4 {\n const schema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n properties: {},\n }\n\n for (const field of fields) {\n switch (field.type) {\n case 'row':\n case 'collapsible':\n schema.properties = {\n ...schema.properties,\n ...fieldsToSelectJSONSchema({ fields: field.fields }).properties,\n }\n\n break\n\n case 'array':\n case 'group':\n schema.properties[field.name] = {\n oneOf: [\n {\n type: 'boolean',\n },\n fieldsToSelectJSONSchema({ fields: field.fields }),\n ],\n }\n break\n\n case 'tabs':\n for (const tab of field.tabs) {\n if (tabHasName(tab)) {\n schema.properties[tab.name] = {\n oneOf: [\n {\n type: 'boolean',\n },\n fieldsToSelectJSONSchema({ fields: tab.fields }),\n ],\n }\n continue\n }\n\n schema.properties = {\n ...schema.properties,\n ...fieldsToSelectJSONSchema({ fields: tab.fields }).properties,\n }\n }\n break\n\n case 'blocks': {\n const blocksSchema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n properties: {},\n }\n\n for (const block of field.blocks) {\n blocksSchema.properties[block.slug] = {\n oneOf: [\n {\n type: 'boolean',\n },\n fieldsToSelectJSONSchema({ fields: block.fields }),\n ],\n }\n }\n\n schema.properties[field.name] = {\n oneOf: [\n {\n type: 'boolean',\n },\n blocksSchema,\n ],\n }\n\n break\n }\n\n default:\n schema.properties[field.name] = {\n type: 'boolean',\n }\n break\n }\n }\n\n return schema\n}\n\nconst fieldType: JSONSchema4 = {\n type: 'string',\n required: false,\n}\nconst generateAuthFieldTypes = ({\n type,\n loginWithUsername,\n}: {\n loginWithUsername: Auth['loginWithUsername']\n type: 'forgotOrUnlock' | 'login' | 'register'\n}): JSONSchema4 => {\n if (loginWithUsername) {\n switch (type) {\n case 'login': {\n if (loginWithUsername.allowEmailLogin) {\n // allow username or email and require password for login\n return {\n additionalProperties: false,\n oneOf: [\n {\n additionalProperties: false,\n properties: { email: fieldType, password: fieldType },\n required: ['email', 'password'],\n },\n {\n additionalProperties: false,\n properties: { password: fieldType, username: fieldType },\n required: ['username', 'password'],\n },\n ],\n }\n } else {\n // allow only username and password for login\n return {\n additionalProperties: false,\n properties: {\n password: fieldType,\n username: fieldType,\n },\n required: ['username', 'password'],\n }\n }\n }\n\n case 'register': {\n const requiredFields: ('email' | 'password' | 'username')[] = ['password']\n const properties: {\n email?: JSONSchema4['properties']\n password?: JSONSchema4['properties']\n username?: JSONSchema4['properties']\n } = {\n password: fieldType,\n username: fieldType,\n }\n\n if (loginWithUsername.requireEmail) {\n requiredFields.push('email')\n }\n if (loginWithUsername.requireUsername) {\n requiredFields.push('username')\n }\n if (loginWithUsername.requireEmail || loginWithUsername.allowEmailLogin) {\n properties.email = fieldType\n }\n\n return {\n additionalProperties: false,\n properties,\n required: requiredFields,\n }\n }\n\n case 'forgotOrUnlock': {\n if (loginWithUsername.allowEmailLogin) {\n // allow email or username for unlock/forgot-password\n return {\n additionalProperties: false,\n oneOf: [\n {\n additionalProperties: false,\n properties: { email: fieldType },\n required: ['email'],\n },\n {\n additionalProperties: false,\n properties: { username: fieldType },\n required: ['username'],\n },\n ],\n }\n } else {\n // allow only username for unlock/forgot-password\n return {\n additionalProperties: false,\n properties: { username: fieldType },\n required: ['username'],\n }\n }\n }\n }\n }\n\n // default email (and password for login/register)\n return {\n additionalProperties: false,\n properties: { email: fieldType, password: fieldType },\n required: ['email', 'password'],\n }\n}\n\nexport function authCollectionToOperationsJSONSchema(\n config: SanitizedCollectionConfig,\n): JSONSchema4 {\n const loginWithUsername = config.auth?.loginWithUsername\n const loginUserFields: JSONSchema4 = generateAuthFieldTypes({ type: 'login', loginWithUsername })\n const forgotOrUnlockUserFields: JSONSchema4 = generateAuthFieldTypes({\n type: 'forgotOrUnlock',\n loginWithUsername,\n })\n const registerUserFields: JSONSchema4 = generateAuthFieldTypes({\n type: 'register',\n loginWithUsername,\n })\n\n const properties: JSONSchema4['properties'] = {\n forgotPassword: forgotOrUnlockUserFields,\n login: loginUserFields,\n registerFirstUser: registerUserFields,\n unlock: forgotOrUnlockUserFields,\n }\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n title: `${singular(toWords(`${config.slug}`, true))}AuthOperations`,\n }\n}\n\nfunction generateAuthOperationSchemas(collections: SanitizedCollectionConfig[]): JSONSchema4 {\n const properties = collections.reduce((acc, collection) => {\n if (collection.auth) {\n acc[collection.slug] = {\n $ref: `#/definitions/auth/${collection.slug}`,\n }\n }\n return acc\n }, {})\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n }\n}\n\n/**\n * This is used for generating the TypeScript types (payload-types.ts) with the payload generate:types command.\n */\nexport function configToJSONSchema(\n config: SanitizedConfig,\n defaultIDType?: 'number' | 'text',\n): JSONSchema4 {\n // a mutable Map to store custom top-level `interfaceName` types. Fields with an `interfaceName` property will be moved to the top-level definitions here\n const interfaceNameDefinitions: Map<string, JSONSchema4> = new Map()\n\n // Used for relationship fields, to determine whether to use a string or number type for the ID.\n const collectionIDFieldTypes = getCollectionIDFieldTypes({ config, defaultIDType })\n\n // Collections and Globals have to be moved to the top-level definitions as well. Reason: The top-level type will be the `Config` type - we don't want all collection and global\n // types to be inlined inside the `Config` type\n\n const entities: {\n entity: SanitizedCollectionConfig | SanitizedGlobalConfig\n type: 'collection' | 'global'\n }[] = [\n ...config.globals.map((global) => ({ type: 'global' as const, entity: global })),\n ...config.collections.map((collection) => ({\n type: 'collection' as const,\n entity: collection,\n })),\n ]\n\n const entityDefinitions: { [k: string]: JSONSchema4 } = entities.reduce(\n (acc, { type, entity }) => {\n acc[entity.slug] = entityToJSONSchema(\n config,\n entity,\n interfaceNameDefinitions,\n defaultIDType,\n collectionIDFieldTypes,\n )\n const select = fieldsToSelectJSONSchema({ fields: entity.fields })\n\n if (type === 'global') {\n select.properties.globalType = {\n type: 'boolean',\n }\n }\n\n acc[`${entity.slug}_select`] = {\n type: 'object',\n additionalProperties: false,\n ...select,\n }\n\n return acc\n },\n {},\n )\n\n const authOperationDefinitions = [...config.collections]\n .filter(({ auth }) => Boolean(auth))\n .reduce(\n (acc, authCollection) => {\n acc.auth[authCollection.slug] = authCollectionToOperationsJSONSchema(authCollection)\n return acc\n },\n { auth: {} },\n )\n\n const jobsSchemas = config.jobs\n ? generateJobsJSONSchemas(config, config.jobs, interfaceNameDefinitions, collectionIDFieldTypes)\n : {}\n\n let jsonSchema: JSONSchema4 = {\n additionalProperties: false,\n definitions: {\n ...entityDefinitions,\n ...Object.fromEntries(interfaceNameDefinitions),\n ...authOperationDefinitions,\n },\n // These properties here will be very simple, as all the complexity is in the definitions. These are just the properties for the top-level `Config` type\n type: 'object',\n properties: {\n auth: generateAuthOperationSchemas(config.collections),\n collections: generateEntitySchemas(config.collections || []),\n collectionsSelect: generateEntitySelectSchemas(config.collections || []),\n db: generateDbEntitySchema(config),\n globals: generateEntitySchemas(config.globals || []),\n globalsSelect: generateEntitySelectSchemas(config.globals || []),\n locale: generateLocaleEntitySchemas(config.localization),\n user: generateAuthEntitySchemas(config.collections),\n },\n required: ['user', 'locale', 'collections', 'globals', 'auth', 'db'],\n title: 'Config',\n }\n if (jobsSchemas.definitions?.size) {\n for (const [key, value] of jobsSchemas.definitions) {\n jsonSchema.definitions[key] = value\n }\n }\n if (jobsSchemas.properties) {\n jsonSchema.properties.jobs = {\n type: 'object',\n additionalProperties: false,\n properties: jobsSchemas.properties,\n required: ['tasks'],\n }\n }\n\n if (config?.typescript?.schema?.length) {\n for (const schema of config.typescript.schema) {\n jsonSchema = schema({ jsonSchema })\n }\n }\n\n return jsonSchema\n}\n"],"names":["pluralize","singular","MissingEditorProp","fieldAffectsData","tabHasName","generateJobsJSONSchemas","deepCopyObject","toWords","getCollectionIDFieldTypes","fieldIsRequired","field","isConditional","Boolean","admin","condition","isMarkedRequired","required","type","fields","some","subField","tabs","tab","buildOptionEnums","options","map","option","value","generateEntitySchemas","entities","properties","reduce","acc","slug","$ref","additionalProperties","Object","keys","generateEntitySelectSchemas","generateLocaleEntitySchemas","localization","locales","localesFromConfig","locale","code","enum","generateAuthEntitySchemas","filter","auth","allOf","collection","oneOf","generateDbEntitySchema","config","defaultIDType","db","withNullableJSONSchemaType","fieldType","isRequired","fieldTypes","push","fieldsToJSONSchema","collectionIDFieldTypes","interfaceNameDefinitions","requiredFieldNames","Set","fromEntries","fieldSchemas","add","name","fieldSchema","hasMany","items","jsonSchema","schema","editor","Error","outputSchema","optionEnums","length","maxItems","minItems","docs","hasNextPage","Array","isArray","relationTo","relation","const","hasBlocks","blocks","block","blockFieldSchemas","blockSchema","blockType","interfaceName","set","childSchema","entries","forEach","propName","propSchema","hasRequiredFields","typescriptSchema","Map","from","entityToJSONSchema","incomingEntity","entity","title","typescript","interface","idField","customIdField","find","unshift","timestamps","disableLocalStrategy","fieldsToSelectJSONSchema","blocksSchema","generateAuthFieldTypes","loginWithUsername","allowEmailLogin","email","password","username","requiredFields","requireEmail","requireUsername","authCollectionToOperationsJSONSchema","loginUserFields","forgotOrUnlockUserFields","registerUserFields","forgotPassword","login","registerFirstUser","unlock","generateAuthOperationSchemas","collections","configToJSONSchema","globals","global","entityDefinitions","select","globalType","authOperationDefinitions","authCollection","jobsSchemas","jobs","definitions","collectionsSelect","globalsSelect","user","size","key"],"mappings":"AAEA,OAAOA,eAAe,YAAW;AACjC,MAAM,EAAEC,QAAQ,EAAE,GAAGD;AAQrB,SAASE,iBAAiB,QAAQ,iCAAgC;AAClE,SAASC,gBAAgB,EAAEC,UAAU,QAAQ,4BAA2B;AACxE,SAASC,uBAAuB,QAAQ,8CAA6C;AACrF,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,OAAO,QAAQ,oBAAmB;AAC3C,SAASC,yBAAyB,QAAQ,iCAAgC;AAE1E,MAAMC,kBAAkB,CAACC;IACvB,MAAMC,gBAAgBC,QAAQF,OAAOG,SAASH,OAAOG,OAAOC;IAC5D,IAAIH,eAAe;QACjB,OAAO;IACT;IAEA,MAAMI,mBAAmB,cAAcL,SAASA,MAAMM,QAAQ,KAAK;IACnE,IAAIb,iBAAiBO,UAAUK,kBAAkB;QAC/C,OAAO;IACT;IAEA,wDAAwD;IACxD,IAAI,YAAYL,SAASA,MAAMO,IAAI,KAAK,SAAS;QAC/C,OAAOP,MAAMQ,MAAM,CAACC,IAAI,CAAC,CAACC,WAAaX,gBAAgBW;IACzD;IAEA,oEAAoE;IACpE,IAAIV,M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AAG;YAC3BnI,MAAM;YACNkB,sBAAsB;YACtBL,YAAYqH,YAAYrH,UAAU;YAClCd,UAAU;gBAAC;aAAQ;QACrB;IACF;IAEA,IAAIqC,QAAQyD,YAAYpC,QAAQK,QAAQ;QACtC,KAAK,MAAML,UAAUrB,OAAOyD,UAAU,CAACpC,MAAM,CAAE;YAC7CD,aAAaC,OAAO;gBAAED;YAAW;QACnC;IACF;IAEA,OAAOA;AACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSelectMode.d.ts","sourceRoot":"","sources":["../../src/utilities/getSelectMode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAE/D,eAAO,MAAM,aAAa,WAAY,UAAU,KAAG,UAalD,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const getSelectMode = (select)=>{
|
|
2
|
+
for(const key in select){
|
|
3
|
+
const selectValue = select[key];
|
|
4
|
+
if (selectValue === false) {
|
|
5
|
+
return 'exclude';
|
|
6
|
+
}
|
|
7
|
+
if (typeof selectValue === 'object') {
|
|
8
|
+
return getSelectMode(selectValue);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return 'include';
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=getSelectMode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/getSelectMode.ts"],"sourcesContent":["import type { SelectMode, SelectType } from '../types/index.js'\n\nexport const getSelectMode = (select: SelectType): SelectMode => {\n for (const key in select) {\n const selectValue = select[key]\n if (selectValue === false) {\n return 'exclude'\n }\n\n if (typeof selectValue === 'object') {\n return getSelectMode(selectValue)\n }\n }\n\n return 'include'\n}\n"],"names":["getSelectMode","select","key","selectValue"],"mappings":"AAEA,OAAO,MAAMA,gBAAgB,CAACC;IAC5B,IAAK,MAAMC,OAAOD,OAAQ;QACxB,MAAME,cAAcF,MAAM,CAACC,IAAI;QAC/B,IAAIC,gBAAgB,OAAO;YACzB,OAAO;QACT;QAEA,IAAI,OAAOA,gBAAgB,UAAU;YACnC,OAAOH,cAAcG;QACvB;IACF;IAEA,OAAO;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../src/utilities/traverseFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../src/utilities/traverseFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA2B,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AA8B3F,MAAM,MAAM,sBAAsB,GAAG,CAAC,IAAI,EAAE;IAC1C;;OAEG;IACH,KAAK,EAAE,KAAK,GAAG,UAAU,CAAA;IACzB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,IAAI,CAAA;IACjB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAA;IAC7C;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAA;CACxC,KAAK,OAAO,GAAG,IAAI,CAAA;AAEpB,KAAK,kBAAkB,GAAG;IACxB,QAAQ,EAAE,sBAAsB,CAAA;IAChC,MAAM,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,EAAE,CAAA;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAA;IAC7C,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAA;CACxC,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,0CAKxB,kBAAkB,KAAG,IAyEvB,CAAA"}
|