payload 3.74.0-internal.b78b222 → 3.74.0
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/admin/functions/index.d.ts +5 -12
- package/dist/admin/functions/index.d.ts.map +1 -1
- package/dist/admin/functions/index.js.map +1 -1
- package/dist/admin/types.d.ts +1 -1
- package/dist/admin/types.d.ts.map +1 -1
- package/dist/admin/types.js.map +1 -1
- package/dist/admin/views/dashboard.d.ts +3 -2
- package/dist/admin/views/dashboard.d.ts.map +1 -1
- package/dist/admin/views/dashboard.js.map +1 -1
- package/dist/auth/operations/forgotPassword.d.ts +3 -3
- package/dist/auth/operations/forgotPassword.d.ts.map +1 -1
- package/dist/auth/operations/forgotPassword.js.map +1 -1
- package/dist/auth/operations/local/forgotPassword.d.ts +4 -4
- package/dist/auth/operations/local/forgotPassword.d.ts.map +1 -1
- package/dist/auth/operations/local/forgotPassword.js.map +1 -1
- package/dist/auth/operations/local/login.d.ts +6 -4
- package/dist/auth/operations/local/login.d.ts.map +1 -1
- package/dist/auth/operations/local/login.js.map +1 -1
- package/dist/auth/operations/local/resetPassword.d.ts +4 -4
- package/dist/auth/operations/local/resetPassword.d.ts.map +1 -1
- package/dist/auth/operations/local/resetPassword.js.map +1 -1
- package/dist/auth/operations/local/unlock.d.ts +3 -3
- package/dist/auth/operations/local/unlock.d.ts.map +1 -1
- package/dist/auth/operations/local/unlock.js.map +1 -1
- package/dist/auth/operations/local/verifyEmail.d.ts +4 -4
- package/dist/auth/operations/local/verifyEmail.d.ts.map +1 -1
- package/dist/auth/operations/local/verifyEmail.js.map +1 -1
- package/dist/auth/operations/login.d.ts +10 -8
- package/dist/auth/operations/login.d.ts.map +1 -1
- package/dist/auth/operations/login.js.map +1 -1
- package/dist/auth/operations/registerFirstUser.d.ts +3 -3
- package/dist/auth/operations/registerFirstUser.d.ts.map +1 -1
- package/dist/auth/operations/registerFirstUser.js.map +1 -1
- package/dist/auth/operations/resetPassword.d.ts +2 -2
- package/dist/auth/operations/resetPassword.d.ts.map +1 -1
- package/dist/auth/operations/resetPassword.js.map +1 -1
- package/dist/auth/operations/unlock.d.ts +3 -3
- package/dist/auth/operations/unlock.d.ts.map +1 -1
- package/dist/auth/operations/unlock.js.map +1 -1
- package/dist/collections/config/types.d.ts +2 -2
- package/dist/collections/config/types.d.ts.map +1 -1
- package/dist/collections/config/types.js.map +1 -1
- package/dist/collections/operations/create.d.ts.map +1 -1
- package/dist/collections/operations/create.js +0 -9
- package/dist/collections/operations/create.js.map +1 -1
- package/dist/collections/operations/delete.d.ts.map +1 -1
- package/dist/collections/operations/delete.js +0 -9
- package/dist/collections/operations/delete.js.map +1 -1
- package/dist/collections/operations/deleteByID.d.ts.map +1 -1
- package/dist/collections/operations/deleteByID.js +0 -9
- package/dist/collections/operations/deleteByID.js.map +1 -1
- package/dist/collections/operations/find.d.ts.map +1 -1
- package/dist/collections/operations/find.js +0 -9
- package/dist/collections/operations/find.js.map +1 -1
- package/dist/collections/operations/findByID.d.ts.map +1 -1
- package/dist/collections/operations/findByID.js +0 -9
- package/dist/collections/operations/findByID.js.map +1 -1
- 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.map +1 -1
- package/dist/collections/operations/local/countVersions.js.map +1 -1
- 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.map +1 -1
- package/dist/collections/operations/local/delete.js.map +1 -1
- 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.map +1 -1
- package/dist/collections/operations/local/find.js.map +1 -1
- 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.map +1 -1
- package/dist/collections/operations/local/findDistinct.js.map +1 -1
- 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.map +1 -1
- package/dist/collections/operations/local/findVersions.js.map +1 -1
- 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.map +1 -1
- package/dist/collections/operations/local/update.js.map +1 -1
- package/dist/collections/operations/update.d.ts.map +1 -1
- package/dist/collections/operations/update.js +1 -10
- package/dist/collections/operations/update.js.map +1 -1
- package/dist/collections/operations/updateByID.d.ts.map +1 -1
- package/dist/collections/operations/updateByID.js +0 -9
- package/dist/collections/operations/updateByID.js.map +1 -1
- 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.map +1 -1
- package/dist/globals/operations/local/findOne.js.map +1 -1
- 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.map +1 -1
- 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.map +1 -1
- 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 +41 -46
- package/dist/index.d.ts +6 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/preferences/config.d.ts.map +1 -1
- package/dist/preferences/config.js +13 -2
- package/dist/preferences/config.js.map +1 -1
- package/dist/utilities/addSelectGenericsToGeneratedTypes.spec.js +6 -4
- package/dist/utilities/addSelectGenericsToGeneratedTypes.spec.js.map +1 -1
- package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
- package/dist/utilities/configToJSONSchema.js +21 -20
- package/dist/utilities/configToJSONSchema.js.map +1 -1
- package/dist/utilities/createLocalReq.d.ts.map +1 -1
- package/dist/utilities/createLocalReq.js +0 -8
- package/dist/utilities/createLocalReq.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/addSelectGenericsToGeneratedTypes.spec.ts"],"sourcesContent":["import { describe, it, expect } from 'vitest'\nimport { addSelectGenericsToGeneratedTypes } from './addSelectGenericsToGeneretedTypes.js'\n\nconst INPUT_AND_OUTPUT = [\n {\n input: `\n/* tslint:disable */\n/* eslint-disable */\n/**\n * This file was automatically generated by Payload.\n * DO NOT MODIFY IT BY HAND. Instead, modify your source Payload config,\n * and re-run \\`payload generate:types\\` to regenerate this file.\n */\n\nexport interface Config {\n auth: {\n users: UserAuthOperations;\n };\n collections: {\n posts: Post;\n users: User;\n 'payload-locked-documents': PayloadLockedDocument;\n 'payload-preferences': PayloadPreference;\n 'payload-migrations': PayloadMigration;\n };\n collectionsSelect: {\n posts: PostsSelect;\n users: UsersSelect;\n 'payload-locked-documents': PayloadLockedDocumentsSelect;\n 'payload-preferences': PayloadPreferencesSelect;\n 'payload-migrations': PayloadMigrationsSelect;\n };\n db: {\n defaultIDType: string;\n };\n globals: {};\n globalsSelect: {};\n locale: null;\n user: User;\n}\nexport interface UserAuthOperations {\n forgotPassword: {\n email: string;\n password: string;\n };\n login: {\n email: string;\n password: string;\n };\n registerFirstUser: {\n email: string;\n password: string;\n };\n unlock: {\n email: string;\n password: string;\n };\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"posts\".\n */\nexport interface Post {\n id: string;\n text?: string | null;\n number?: number | null;\n group?: {\n text?: string | null;\n number?: number | null;\n };\n array?:\n | {\n text?: string | null;\n number?: number | null;\n id?: string | null;\n }[]\n | null;\n blocks?:\n | (\n | {\n text?: string | null;\n introText?: string | null;\n id?: string | null;\n blockName?: string | null;\n blockType: 'intro';\n }\n | {\n text?: string | null;\n ctaText?: string | null;\n id?: string | null;\n blockName?: string | null;\n blockType: 'cta';\n }\n )[]\n | null;\n updatedAt: string;\n createdAt: string;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"users\".\n */\nexport interface User {\n id: string;\n updatedAt: string;\n createdAt: string;\n email: string;\n resetPasswordToken?: string | null;\n resetPasswordExpiration?: string | null;\n salt?: string | null;\n hash?: string | null;\n loginAttempts?: number | null;\n lockUntil?: string | null;\n password?: string | null;\n collection: 'users';\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"payload-locked-documents\".\n */\nexport interface PayloadLockedDocument {\n id: string;\n document?:\n | ({\n relationTo: 'posts';\n value: string | Post;\n } | null)\n | ({\n relationTo: 'users';\n value: string | User;\n } | null);\n globalSlug?: string | null;\n user: {\n relationTo: 'users';\n value: string | User;\n };\n updatedAt: string;\n createdAt: string;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"payload-preferences\".\n */\nexport interface PayloadPreference {\n id: string;\n user: {\n relationTo: 'users';\n value: string | User;\n };\n key?: string | null;\n value?:\n | {\n [k: string]: unknown;\n }\n | unknown[]\n | string\n | number\n | boolean\n | null;\n updatedAt: string;\n createdAt: string;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"payload-migrations\".\n */\nexport interface PayloadMigration {\n id: string;\n name?: string | null;\n batch?: number | null;\n updatedAt: string;\n createdAt: string;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"posts_select\".\n */\nexport interface PostsSelect {\n text?: boolean;\n number?: boolean;\n sharedGroup?: boolean | SharedGroup;\n group?:\n | boolean\n | {\n text?: boolean;\n number?: boolean;\n };\n array?:\n | boolean\n | {\n text?: boolean;\n number?: boolean;\n id?: boolean;\n };\n blocks?:\n | boolean\n | {\n intro?:\n | boolean\n | {\n text?: boolean;\n introText?: boolean;\n id?: boolean;\n blockName?: boolean;\n };\n cta?:\n | boolean\n | {\n text?: boolean;\n ctaText?: boolean;\n id?: boolean;\n blockName?: boolean;\n };\n };\n updatedAt?: boolean;\n createdAt?: boolean;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"users_select\".\n */\nexport interface UsersSelect {\n updatedAt?: boolean;\n createdAt?: boolean;\n email?: boolean;\n resetPasswordToken?: boolean;\n resetPasswordExpiration?: boolean;\n salt?: boolean;\n hash?: boolean;\n loginAttempts?: boolean;\n lockUntil?: boolean;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"payload-locked-documents_select\".\n */\nexport interface PayloadLockedDocumentsSelect {\n document?: boolean;\n globalSlug?: boolean;\n user?: boolean;\n updatedAt?: boolean;\n createdAt?: boolean;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"payload-preferences_select\".\n */\nexport interface PayloadPreferencesSelect {\n user?: boolean;\n key?: boolean;\n value?: boolean;\n updatedAt?: boolean;\n createdAt?: boolean;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"payload-migrations_select\".\n */\nexport interface PayloadMigrationsSelect {\n name?: boolean;\n batch?: boolean;\n updatedAt?: boolean;\n createdAt?: boolean;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"auth\".\n */\nexport interface Auth {\n [k: string]: unknown;\n}\n\n\ndeclare module 'payload' {\n // @ts-ignore\n export interface GeneratedTypes extends Config {}\n}\n`,\n output: `\n/* tslint:disable */\n/* eslint-disable */\n/**\n * This file was automatically generated by Payload.\n * DO NOT MODIFY IT BY HAND. Instead, modify your source Payload config,\n * and re-run \\`payload generate:types\\` to regenerate this file.\n */\n\nexport interface Config {\n auth: {\n users: UserAuthOperations;\n };\n collections: {\n posts: Post;\n users: User;\n 'payload-locked-documents': PayloadLockedDocument;\n 'payload-preferences': PayloadPreference;\n 'payload-migrations': PayloadMigration;\n };\n collectionsSelect: {\n posts: PostsSelect<false> | PostsSelect<true>;\n users: UsersSelect<false> | UsersSelect<true>;\n 'payload-locked-documents': PayloadLockedDocumentsSelect<false> | PayloadLockedDocumentsSelect<true>;\n 'payload-preferences': PayloadPreferencesSelect<false> | PayloadPreferencesSelect<true>;\n 'payload-migrations': PayloadMigrationsSelect<false> | PayloadMigrationsSelect<true>;\n };\n db: {\n defaultIDType: string;\n };\n globals: {};\n globalsSelect: {};\n locale: null;\n user: User;\n}\nexport interface UserAuthOperations {\n forgotPassword: {\n email: string;\n password: string;\n };\n login: {\n email: string;\n password: string;\n };\n registerFirstUser: {\n email: string;\n password: string;\n };\n unlock: {\n email: string;\n password: string;\n };\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"posts\".\n */\nexport interface Post {\n id: string;\n text?: string | null;\n number?: number | null;\n group?: {\n text?: string | null;\n number?: number | null;\n };\n array?:\n | {\n text?: string | null;\n number?: number | null;\n id?: string | null;\n }[]\n | null;\n blocks?:\n | (\n | {\n text?: string | null;\n introText?: string | null;\n id?: string | null;\n blockName?: string | null;\n blockType: 'intro';\n }\n | {\n text?: string | null;\n ctaText?: string | null;\n id?: string | null;\n blockName?: string | null;\n blockType: 'cta';\n }\n )[]\n | null;\n updatedAt: string;\n createdAt: string;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"users\".\n */\nexport interface User {\n id: string;\n updatedAt: string;\n createdAt: string;\n email: string;\n resetPasswordToken?: string | null;\n resetPasswordExpiration?: string | null;\n salt?: string | null;\n hash?: string | null;\n loginAttempts?: number | null;\n lockUntil?: string | null;\n password?: string | null;\n collection: 'users';\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"payload-locked-documents\".\n */\nexport interface PayloadLockedDocument {\n id: string;\n document?:\n | ({\n relationTo: 'posts';\n value: string | Post;\n } | null)\n | ({\n relationTo: 'users';\n value: string | User;\n } | null);\n globalSlug?: string | null;\n user: {\n relationTo: 'users';\n value: string | User;\n };\n updatedAt: string;\n createdAt: string;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"payload-preferences\".\n */\nexport interface PayloadPreference {\n id: string;\n user: {\n relationTo: 'users';\n value: string | User;\n };\n key?: string | null;\n value?:\n | {\n [k: string]: unknown;\n }\n | unknown[]\n | string\n | number\n | boolean\n | null;\n updatedAt: string;\n createdAt: string;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"payload-migrations\".\n */\nexport interface PayloadMigration {\n id: string;\n name?: string | null;\n batch?: number | null;\n updatedAt: string;\n createdAt: string;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"posts_select\".\n */\nexport interface PostsSelect<T extends boolean = true> {\n text?: T;\n number?: T;\n sharedGroup?: T | SharedGroup<T>;\n group?:\n | T\n | {\n text?: T;\n number?: T;\n };\n array?:\n | T\n | {\n text?: T;\n number?: T;\n id?: T;\n };\n blocks?:\n | T\n | {\n intro?:\n | T\n | {\n text?: T;\n introText?: T;\n id?: T;\n blockName?: T;\n };\n cta?:\n | T\n | {\n text?: T;\n ctaText?: T;\n id?: T;\n blockName?: T;\n };\n };\n updatedAt?: T;\n createdAt?: T;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"users_select\".\n */\nexport interface UsersSelect<T extends boolean = true> {\n updatedAt?: T;\n createdAt?: T;\n email?: T;\n resetPasswordToken?: T;\n resetPasswordExpiration?: T;\n salt?: T;\n hash?: T;\n loginAttempts?: T;\n lockUntil?: T;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"payload-locked-documents_select\".\n */\nexport interface PayloadLockedDocumentsSelect<T extends boolean = true> {\n document?: T;\n globalSlug?: T;\n user?: T;\n updatedAt?: T;\n createdAt?: T;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"payload-preferences_select\".\n */\nexport interface PayloadPreferencesSelect<T extends boolean = true> {\n user?: T;\n key?: T;\n value?: T;\n updatedAt?: T;\n createdAt?: T;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"payload-migrations_select\".\n */\nexport interface PayloadMigrationsSelect<T extends boolean = true> {\n name?: T;\n batch?: T;\n updatedAt?: T;\n createdAt?: T;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"auth\".\n */\nexport interface Auth {\n [k: string]: unknown;\n}\n\n\ndeclare module 'payload' {\n // @ts-ignore\n export interface GeneratedTypes extends Config {}\n}\n`,\n },\n]\n\ndescribe('addSelectGenericsToGeneratedTypes', () => {\n it('should match return of given input with output', () => {\n for (const { input, output } of INPUT_AND_OUTPUT) {\n expect(\n addSelectGenericsToGeneratedTypes({\n compiledGeneratedTypes: input,\n }),\n ).toStrictEqual(output)\n }\n })\n})\n"],"names":["describe","it","expect","addSelectGenericsToGeneratedTypes","INPUT_AND_OUTPUT","input","output","compiledGeneratedTypes","toStrictEqual"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,EAAE,EAAEC,MAAM,QAAQ,SAAQ;AAC7C,SAASC,iCAAiC,QAAQ,yCAAwC;AAE1F,MAAMC,mBAAmB;IACvB;QACEC,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgRZ,CAAC;QACGC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgRb,CAAC;IACC;CACD;AAEDN,SAAS,qCAAqC;IAC5CC,GAAG,kDAAkD;QACnD,KAAK,MAAM,EAAEI,KAAK,EAAEC,MAAM,EAAE,IAAIF,iBAAkB;YAChDF,OACEC,kCAAkC;gBAChCI,wBAAwBF;YAC1B,IACAG,aAAa,CAACF;QAClB;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/addSelectGenericsToGeneratedTypes.spec.ts"],"sourcesContent":["import { describe, it, expect } from 'vitest'\nimport { addSelectGenericsToGeneratedTypes } from './addSelectGenericsToGeneretedTypes.js'\n\nconst INPUT_AND_OUTPUT = [\n {\n input: `\n/* tslint:disable */\n/* eslint-disable */\n/**\n * This file was automatically generated by Payload.\n * DO NOT MODIFY IT BY HAND. Instead, modify your source Payload config,\n * and re-run \\`payload generate:types\\` to regenerate this file.\n */\n\nexport interface Config {\n auth: {\n users: UserAuthOperations;\n };\n collections: {\n posts: Post;\n users: User;\n 'payload-locked-documents': PayloadLockedDocument;\n 'payload-preferences': PayloadPreference;\n 'payload-migrations': PayloadMigration;\n };\n collectionsSelect: {\n posts: PostsSelect;\n users: UsersSelect;\n 'payload-locked-documents': PayloadLockedDocumentsSelect;\n 'payload-preferences': PayloadPreferencesSelect;\n 'payload-migrations': PayloadMigrationsSelect;\n };\n db: {\n defaultIDType: string;\n };\n globals: {};\n globalsSelect: {};\n locale: null;\n user: User & {\n collection: 'users';\n };\n}\nexport interface UserAuthOperations {\n forgotPassword: {\n email: string;\n password: string;\n };\n login: {\n email: string;\n password: string;\n };\n registerFirstUser: {\n email: string;\n password: string;\n };\n unlock: {\n email: string;\n password: string;\n };\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"posts\".\n */\nexport interface Post {\n id: string;\n text?: string | null;\n number?: number | null;\n group?: {\n text?: string | null;\n number?: number | null;\n };\n array?:\n | {\n text?: string | null;\n number?: number | null;\n id?: string | null;\n }[]\n | null;\n blocks?:\n | (\n | {\n text?: string | null;\n introText?: string | null;\n id?: string | null;\n blockName?: string | null;\n blockType: 'intro';\n }\n | {\n text?: string | null;\n ctaText?: string | null;\n id?: string | null;\n blockName?: string | null;\n blockType: 'cta';\n }\n )[]\n | null;\n updatedAt: string;\n createdAt: string;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"users\".\n */\nexport interface User {\n id: string;\n updatedAt: string;\n createdAt: string;\n email: string;\n resetPasswordToken?: string | null;\n resetPasswordExpiration?: string | null;\n salt?: string | null;\n hash?: string | null;\n loginAttempts?: number | null;\n lockUntil?: string | null;\n password?: string | null;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"payload-locked-documents\".\n */\nexport interface PayloadLockedDocument {\n id: string;\n document?:\n | ({\n relationTo: 'posts';\n value: string | Post;\n } | null)\n | ({\n relationTo: 'users';\n value: string | User;\n } | null);\n globalSlug?: string | null;\n user: {\n relationTo: 'users';\n value: string | User;\n };\n updatedAt: string;\n createdAt: string;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"payload-preferences\".\n */\nexport interface PayloadPreference {\n id: string;\n user: {\n relationTo: 'users';\n value: string | User;\n };\n key?: string | null;\n value?:\n | {\n [k: string]: unknown;\n }\n | unknown[]\n | string\n | number\n | boolean\n | null;\n updatedAt: string;\n createdAt: string;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"payload-migrations\".\n */\nexport interface PayloadMigration {\n id: string;\n name?: string | null;\n batch?: number | null;\n updatedAt: string;\n createdAt: string;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"posts_select\".\n */\nexport interface PostsSelect {\n text?: boolean;\n number?: boolean;\n sharedGroup?: boolean | SharedGroup;\n group?:\n | boolean\n | {\n text?: boolean;\n number?: boolean;\n };\n array?:\n | boolean\n | {\n text?: boolean;\n number?: boolean;\n id?: boolean;\n };\n blocks?:\n | boolean\n | {\n intro?:\n | boolean\n | {\n text?: boolean;\n introText?: boolean;\n id?: boolean;\n blockName?: boolean;\n };\n cta?:\n | boolean\n | {\n text?: boolean;\n ctaText?: boolean;\n id?: boolean;\n blockName?: boolean;\n };\n };\n updatedAt?: boolean;\n createdAt?: boolean;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"users_select\".\n */\nexport interface UsersSelect {\n updatedAt?: boolean;\n createdAt?: boolean;\n email?: boolean;\n resetPasswordToken?: boolean;\n resetPasswordExpiration?: boolean;\n salt?: boolean;\n hash?: boolean;\n loginAttempts?: boolean;\n lockUntil?: boolean;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"payload-locked-documents_select\".\n */\nexport interface PayloadLockedDocumentsSelect {\n document?: boolean;\n globalSlug?: boolean;\n user?: boolean;\n updatedAt?: boolean;\n createdAt?: boolean;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"payload-preferences_select\".\n */\nexport interface PayloadPreferencesSelect {\n user?: boolean;\n key?: boolean;\n value?: boolean;\n updatedAt?: boolean;\n createdAt?: boolean;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"payload-migrations_select\".\n */\nexport interface PayloadMigrationsSelect {\n name?: boolean;\n batch?: boolean;\n updatedAt?: boolean;\n createdAt?: boolean;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"auth\".\n */\nexport interface Auth {\n [k: string]: unknown;\n}\n\n\ndeclare module 'payload' {\n // @ts-ignore\n export interface GeneratedTypes extends Config {}\n}\n`,\n output: `\n/* tslint:disable */\n/* eslint-disable */\n/**\n * This file was automatically generated by Payload.\n * DO NOT MODIFY IT BY HAND. Instead, modify your source Payload config,\n * and re-run \\`payload generate:types\\` to regenerate this file.\n */\n\nexport interface Config {\n auth: {\n users: UserAuthOperations;\n };\n collections: {\n posts: Post;\n users: User;\n 'payload-locked-documents': PayloadLockedDocument;\n 'payload-preferences': PayloadPreference;\n 'payload-migrations': PayloadMigration;\n };\n collectionsSelect: {\n posts: PostsSelect<false> | PostsSelect<true>;\n users: UsersSelect<false> | UsersSelect<true>;\n 'payload-locked-documents': PayloadLockedDocumentsSelect<false> | PayloadLockedDocumentsSelect<true>;\n 'payload-preferences': PayloadPreferencesSelect<false> | PayloadPreferencesSelect<true>;\n 'payload-migrations': PayloadMigrationsSelect<false> | PayloadMigrationsSelect<true>;\n };\n db: {\n defaultIDType: string;\n };\n globals: {};\n globalsSelect: {};\n locale: null;\n user: User & {\n collection: 'users';\n };\n}\nexport interface UserAuthOperations {\n forgotPassword: {\n email: string;\n password: string;\n };\n login: {\n email: string;\n password: string;\n };\n registerFirstUser: {\n email: string;\n password: string;\n };\n unlock: {\n email: string;\n password: string;\n };\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"posts\".\n */\nexport interface Post {\n id: string;\n text?: string | null;\n number?: number | null;\n group?: {\n text?: string | null;\n number?: number | null;\n };\n array?:\n | {\n text?: string | null;\n number?: number | null;\n id?: string | null;\n }[]\n | null;\n blocks?:\n | (\n | {\n text?: string | null;\n introText?: string | null;\n id?: string | null;\n blockName?: string | null;\n blockType: 'intro';\n }\n | {\n text?: string | null;\n ctaText?: string | null;\n id?: string | null;\n blockName?: string | null;\n blockType: 'cta';\n }\n )[]\n | null;\n updatedAt: string;\n createdAt: string;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"users\".\n */\nexport interface User {\n id: string;\n updatedAt: string;\n createdAt: string;\n email: string;\n resetPasswordToken?: string | null;\n resetPasswordExpiration?: string | null;\n salt?: string | null;\n hash?: string | null;\n loginAttempts?: number | null;\n lockUntil?: string | null;\n password?: string | null;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"payload-locked-documents\".\n */\nexport interface PayloadLockedDocument {\n id: string;\n document?:\n | ({\n relationTo: 'posts';\n value: string | Post;\n } | null)\n | ({\n relationTo: 'users';\n value: string | User;\n } | null);\n globalSlug?: string | null;\n user: {\n relationTo: 'users';\n value: string | User;\n };\n updatedAt: string;\n createdAt: string;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"payload-preferences\".\n */\nexport interface PayloadPreference {\n id: string;\n user: {\n relationTo: 'users';\n value: string | User;\n };\n key?: string | null;\n value?:\n | {\n [k: string]: unknown;\n }\n | unknown[]\n | string\n | number\n | boolean\n | null;\n updatedAt: string;\n createdAt: string;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"payload-migrations\".\n */\nexport interface PayloadMigration {\n id: string;\n name?: string | null;\n batch?: number | null;\n updatedAt: string;\n createdAt: string;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"posts_select\".\n */\nexport interface PostsSelect<T extends boolean = true> {\n text?: T;\n number?: T;\n sharedGroup?: T | SharedGroup<T>;\n group?:\n | T\n | {\n text?: T;\n number?: T;\n };\n array?:\n | T\n | {\n text?: T;\n number?: T;\n id?: T;\n };\n blocks?:\n | T\n | {\n intro?:\n | T\n | {\n text?: T;\n introText?: T;\n id?: T;\n blockName?: T;\n };\n cta?:\n | T\n | {\n text?: T;\n ctaText?: T;\n id?: T;\n blockName?: T;\n };\n };\n updatedAt?: T;\n createdAt?: T;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"users_select\".\n */\nexport interface UsersSelect<T extends boolean = true> {\n updatedAt?: T;\n createdAt?: T;\n email?: T;\n resetPasswordToken?: T;\n resetPasswordExpiration?: T;\n salt?: T;\n hash?: T;\n loginAttempts?: T;\n lockUntil?: T;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"payload-locked-documents_select\".\n */\nexport interface PayloadLockedDocumentsSelect<T extends boolean = true> {\n document?: T;\n globalSlug?: T;\n user?: T;\n updatedAt?: T;\n createdAt?: T;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"payload-preferences_select\".\n */\nexport interface PayloadPreferencesSelect<T extends boolean = true> {\n user?: T;\n key?: T;\n value?: T;\n updatedAt?: T;\n createdAt?: T;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"payload-migrations_select\".\n */\nexport interface PayloadMigrationsSelect<T extends boolean = true> {\n name?: T;\n batch?: T;\n updatedAt?: T;\n createdAt?: T;\n}\n/**\n * This interface was referenced by \\`Config\\`'s JSON-Schema\n * via the \\`definition\\` \"auth\".\n */\nexport interface Auth {\n [k: string]: unknown;\n}\n\n\ndeclare module 'payload' {\n // @ts-ignore\n export interface GeneratedTypes extends Config {}\n}\n`,\n },\n]\n\ndescribe('addSelectGenericsToGeneratedTypes', () => {\n it('should match return of given input with output', () => {\n for (const { input, output } of INPUT_AND_OUTPUT) {\n expect(\n addSelectGenericsToGeneratedTypes({\n compiledGeneratedTypes: input,\n }),\n ).toStrictEqual(output)\n }\n })\n})\n"],"names":["describe","it","expect","addSelectGenericsToGeneratedTypes","INPUT_AND_OUTPUT","input","output","compiledGeneratedTypes","toStrictEqual"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,EAAE,EAAEC,MAAM,QAAQ,SAAQ;AAC7C,SAASC,iCAAiC,QAAQ,yCAAwC;AAE1F,MAAMC,mBAAmB;IACvB;QACEC,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiRZ,CAAC;QACGC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiRb,CAAC;IACC;CACD;AAEDN,SAAS,qCAAqC;IAC5CC,GAAG,kDAAkD;QACnD,KAAK,MAAM,EAAEI,KAAK,EAAEC,MAAM,EAAE,IAAIF,iBAAkB;YAChDF,OACEC,kCAAkC;gBAChCI,wBAAwBF;YAC1B,IACAG,aAAa,CAACF;QAClB;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configToJSONSchema.d.ts","sourceRoot":"","sources":["../../src/utilities/configToJSONSchema.ts"],"names":[],"mappings":"AAAA,O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V;IACD,UAAU,EAAE;QACV,CAAC,CAAC,EAAE,MAAM,GAAG,WAAW,CAAA;KACzB,CAAA;IACD,QAAQ,EAAE,MAAM,EAAE,CAAA;CACnB,CA4eA;AAGD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,yBAAyB,GAAG,qBAAqB,EACzD,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,EAC/D,IAAI,CAAC,EAAE,IAAI,GACV,WAAW,CAwEb;AAED,wBAAgB,wBAAwB,CAAC,EACvC,MAAM,EACN,MAAM,EACN,wBAAwB,GACzB,EAAE;IACD,MAAM,EAAE,eAAe,CAAA;IACvB,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,wBAAwB,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;CACnD,GAAG,WAAW,CAgGd;AAgHD,wBAAgB,oCAAoC,CAClD,MAAM,EAAE,yBAAyB,GAChC,WAAW,CA0Bb;AAGD,wBAAgB,qBAAqB,CACnC,kBAAkB,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,CAAC,oBAAoB,CAAC,GAC9E,WAAW,CAOb;AAuBD;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,eAAe,EACvB,aAAa,CAAC,EAAE,QAAQ,GAAG,MAAM,EACjC,IAAI,CAAC,EAAE,IAAI,GACV,WAAW,CA2Lb"}
|
|
@@ -167,7 +167,26 @@ function generateAuthEntitySchemas(entities) {
|
|
|
167
167
|
...entities
|
|
168
168
|
].filter(({ auth })=>Boolean(auth)).map(({ slug })=>{
|
|
169
169
|
return {
|
|
170
|
-
|
|
170
|
+
allOf: [
|
|
171
|
+
{
|
|
172
|
+
$ref: `#/definitions/${slug}`
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
type: 'object',
|
|
176
|
+
additionalProperties: false,
|
|
177
|
+
properties: {
|
|
178
|
+
collection: {
|
|
179
|
+
type: 'string',
|
|
180
|
+
enum: [
|
|
181
|
+
slug
|
|
182
|
+
]
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
required: [
|
|
186
|
+
'collection'
|
|
187
|
+
]
|
|
188
|
+
}
|
|
189
|
+
]
|
|
171
190
|
};
|
|
172
191
|
}, {});
|
|
173
192
|
return {
|
|
@@ -753,29 +772,11 @@ export function entityToJSONSchema(config, entity, interfaceNameDefinitions, def
|
|
|
753
772
|
type: 'text'
|
|
754
773
|
});
|
|
755
774
|
}
|
|
756
|
-
const isAuthCollection = 'auth' in entity && entity.auth;
|
|
757
|
-
const fieldsSchema = fieldsToJSONSchema(collectionIDFieldTypes, mutableFields, interfaceNameDefinitions, config, i18n);
|
|
758
|
-
// Add collection property to auth collections
|
|
759
|
-
if (isAuthCollection) {
|
|
760
|
-
fieldsSchema.properties = {
|
|
761
|
-
...fieldsSchema.properties,
|
|
762
|
-
collection: {
|
|
763
|
-
type: 'string',
|
|
764
|
-
enum: [
|
|
765
|
-
entity.slug
|
|
766
|
-
]
|
|
767
|
-
}
|
|
768
|
-
};
|
|
769
|
-
fieldsSchema.required = [
|
|
770
|
-
...fieldsSchema.required || [],
|
|
771
|
-
'collection'
|
|
772
|
-
];
|
|
773
|
-
}
|
|
774
775
|
const jsonSchema = {
|
|
775
776
|
type: 'object',
|
|
776
777
|
additionalProperties: false,
|
|
777
778
|
title,
|
|
778
|
-
...
|
|
779
|
+
...fieldsToJSONSchema(collectionIDFieldTypes, mutableFields, interfaceNameDefinitions, config, i18n)
|
|
779
780
|
};
|
|
780
781
|
const entityDescription = entityOrFieldToJsDocs({
|
|
781
782
|
entity,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/configToJSONSchema.ts"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { JSONSchema4, JSONSchema4TypeName } from 'json-schema'\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 { FieldAffectingData, FlattenedField, Option } from '../fields/config/types.js'\nimport type { SanitizedGlobalConfig } from '../globals/config/types.js'\n\nimport { MissingEditorProp } from '../errors/MissingEditorProp.js'\nimport { fieldAffectsData } from '../fields/config/types.js'\nimport { generateJobsJSONSchemas } from '../queues/config/generateJobsJSONSchemas.js'\nimport { formatNames } from './formatLabels.js'\nimport { getCollectionIDFieldTypes } from './getCollectionIDFieldTypes.js'\nimport { optionsAreEqual } from './optionsAreEqual.js'\n\nconst fieldIsRequired = (field: FlattenedField): boolean => {\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.flattenedFields.some((subField) => fieldIsRequired(subField))\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(\n (acc, { slug }) => {\n acc[slug] = {\n $ref: `#/definitions/${slug}`,\n }\n\n return acc\n },\n {} as Record<string, JSONSchema4>,\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(\n (acc, { slug }) => {\n acc[slug] = {\n $ref: `#/definitions/${slug}_select`,\n }\n\n return acc\n },\n {} as Record<string, JSONSchema4>,\n )\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n }\n}\n\nfunction generateCollectionJoinsSchemas(collections: SanitizedCollectionConfig[]): JSONSchema4 {\n const properties = [...collections].reduce<Record<string, JSONSchema4>>(\n (acc, { slug, joins, polymorphicJoins }) => {\n const schema = {\n type: 'object',\n additionalProperties: false,\n properties: {},\n required: [] as string[],\n } satisfies JSONSchema4\n\n for (const collectionSlug in joins) {\n for (const join of joins[collectionSlug]!) {\n ;(schema.properties as any)[join.joinPath] = {\n type: 'string',\n enum: [collectionSlug],\n }\n schema.required.push(join.joinPath)\n }\n }\n\n for (const join of polymorphicJoins) {\n ;(schema.properties as any)[join.joinPath] = {\n type: 'string',\n enum: join.field.collection,\n }\n schema.required.push(join.joinPath)\n }\n\n if (Object.keys(schema.properties).length > 0) {\n acc[slug] = schema\n }\n\n return acc\n },\n {},\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 generateFallbackLocaleEntitySchemas(\n localization: SanitizedConfig['localization'],\n): JSONSchema4 {\n if (localization && 'localeCodes' in localization && localization?.localeCodes) {\n const localeCodes = [...localization.localeCodes].map((localeCode) => {\n return localeCode\n }, [])\n\n return {\n oneOf: [\n { type: 'string', enum: ['false', 'none', 'null'] },\n { type: 'boolean', enum: [false] },\n { type: 'null' },\n { type: 'string', enum: localeCodes },\n { type: 'array', items: { type: 'string', enum: localeCodes } },\n ],\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 { $ref: `#/definitions/${slug}` }\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\nfunction entityOrFieldToJsDocs({\n entity,\n i18n,\n}: {\n entity: FlattenedField | SanitizedCollectionConfig | SanitizedGlobalConfig\n i18n?: I18n\n}): string | undefined {\n let description: string | undefined = undefined\n if (entity?.admin?.description) {\n if (typeof entity?.admin?.description === 'string') {\n description = entity?.admin?.description\n } else if (typeof entity?.admin?.description === 'object') {\n if (entity?.admin?.description?.en) {\n description = entity?.admin?.description?.en\n } else if (entity?.admin?.description?.[i18n!.language]) {\n description = entity?.admin?.description?.[i18n!.language]\n }\n } else if (typeof entity?.admin?.description === 'function' && i18n) {\n // do not evaluate description functions for generating JSDocs. The output of\n // those can differ depending on where and when they are called, creating\n // inconsistencies in the generated JSDocs.\n }\n }\n return description\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: FlattenedField[],\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 i18n?: I18n,\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, index) => {\n const isRequired = fieldAffectsData(field) && fieldIsRequired(field)\n\n const fieldDescription = entityOrFieldToJsDocs({ entity: field, i18n })\n const baseFieldSchema: JSONSchema4 = {}\n if (fieldDescription) {\n baseFieldSchema.description = fieldDescription\n }\n\n let fieldSchema: JSONSchema4\n\n switch (field.type) {\n case 'array': {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'object',\n additionalProperties: false,\n ...fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.flattenedFields,\n interfaceNameDefinitions,\n config,\n i18n,\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 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(\n field.blockReferences ? field.blockReferences.length : field.blocks.length,\n )\n\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: hasBlocks\n ? {\n oneOf: (field.blockReferences ?? field.blocks).map((block) => {\n if (typeof block === 'string') {\n const resolvedBlock = config?.blocks?.find((b) => b.slug === block)\n return {\n $ref: `#/definitions/${resolvedBlock!.interfaceName ?? resolvedBlock!.slug}`,\n }\n }\n const blockFieldSchemas = fieldsToJSONSchema(\n collectionIDFieldTypes,\n block.flattenedFields,\n interfaceNameDefinitions,\n config,\n i18n,\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 case 'checkbox': {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('boolean', isRequired),\n }\n break\n }\n case 'code':\n case 'date':\n case 'email':\n case 'textarea': {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('string', isRequired),\n }\n break\n }\n\n case 'group': {\n if (fieldAffectsData(field)) {\n fieldSchema = {\n ...baseFieldSchema,\n type: 'object',\n additionalProperties: false,\n ...fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.flattenedFields,\n interfaceNameDefinitions,\n config,\n i18n,\n ),\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = { $ref: `#/definitions/${field.interfaceName}` }\n }\n }\n break\n }\n\n case 'join': {\n let items: JSONSchema4\n\n if (Array.isArray(field.collection)) {\n items = {\n oneOf: field.collection.map((collection) => ({\n type: 'object',\n additionalProperties: false,\n properties: {\n relationTo: {\n const: collection,\n },\n value: {\n oneOf: [\n {\n type: collectionIDFieldTypes[collection],\n },\n {\n $ref: `#/definitions/${collection}`,\n },\n ],\n },\n },\n required: ['collectionSlug', 'value'],\n })),\n }\n } else {\n items = {\n oneOf: [\n {\n type: collectionIDFieldTypes[field.collection],\n },\n {\n $ref: `#/definitions/${field.collection}`,\n },\n ],\n }\n }\n\n fieldSchema = {\n ...baseFieldSchema,\n type: 'object',\n additionalProperties: false,\n properties: {\n docs: {\n type: 'array',\n items,\n },\n hasNextPage: { type: 'boolean' },\n totalDocs: { type: 'number' },\n },\n }\n break\n }\n\n case 'json': {\n fieldSchema = field.jsonSchema?.schema || {\n ...baseFieldSchema,\n type: ['object', 'array', 'string', 'number', 'boolean', 'null'],\n }\n break\n }\n\n case 'number': {\n if (field.hasMany === true) {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: { type: 'number' },\n }\n } else {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('number', isRequired),\n }\n }\n break\n }\n\n case 'point': {\n fieldSchema = {\n ...baseFieldSchema,\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 'radio': {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('string', isRequired),\n enum: buildOptionEnums(field.options),\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = {\n $ref: `#/definitions/${field.interfaceName}`,\n }\n }\n\n break\n }\n case 'relationship':\n case 'upload': {\n if (Array.isArray(field.relationTo)) {\n if (field.hasMany) {\n fieldSchema = {\n ...baseFieldSchema,\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 ...baseFieldSchema,\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 ...baseFieldSchema,\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 ...baseFieldSchema,\n oneOf: [\n {\n type: withNullableJSONSchemaType(\n collectionIDFieldTypes[field.relationTo]!,\n isRequired,\n ),\n },\n { $ref: `#/definitions/${field.relationTo}` },\n ],\n }\n }\n\n break\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 = {\n ...baseFieldSchema,\n ...field.editor.outputSchema({\n collectionIDFieldTypes,\n config,\n field,\n i18n,\n interfaceNameDefinitions,\n isRequired,\n }),\n }\n } else {\n // Maintain backwards compatibility with existing rich text editors\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'object',\n },\n }\n }\n\n break\n }\n\n case 'select': {\n const optionEnums = buildOptionEnums(field.options)\n // We get the previous field to check for a date in the case of a timezone select\n // This works because timezone selects are always inserted right after a date with 'timezone: true'\n const previousField = fields?.[index - 1]\n const isTimezoneField =\n previousField?.type === 'date' && previousField.timezone && field.name.includes('_tz')\n\n // Check if the timezone field's options match the global config's supported timezones\n const hasMatchingGlobalTimezones =\n isTimezoneField &&\n config &&\n optionsAreEqual(field.options, config.admin?.timezones?.supportedTimezones)\n\n // Timezone selects should reference the supportedTimezones definition\n // only if the field's options match the global config\n if (isTimezoneField && hasMatchingGlobalTimezones) {\n fieldSchema = {\n $ref: `#/definitions/supportedTimezones`,\n }\n } else {\n if (field.hasMany) {\n fieldSchema = {\n ...baseFieldSchema,\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 ...baseFieldSchema,\n type: withNullableJSONSchemaType('string', isRequired),\n }\n if (optionEnums?.length) {\n fieldSchema.enum = optionEnums\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 break\n }\n case 'tab': {\n fieldSchema = {\n ...baseFieldSchema,\n type: 'object',\n additionalProperties: false,\n ...fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.flattenedFields,\n interfaceNameDefinitions,\n config,\n i18n,\n ),\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = { $ref: `#/definitions/${field.interfaceName}` }\n }\n break\n }\n\n case 'text':\n if (field.hasMany === true) {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: { type: 'string' },\n }\n } else {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('string', isRequired),\n }\n }\n break\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 if (isRequired && fieldSchema.required !== false) {\n requiredFieldNames.add(field.name)\n }\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 entity: SanitizedCollectionConfig | SanitizedGlobalConfig,\n interfaceNameDefinitions: Map<string, JSONSchema4>,\n defaultIDType: 'number' | 'text',\n collectionIDFieldTypes?: { [key: string]: 'number' | 'string' },\n i18n?: I18n,\n): JSONSchema4 {\n if (!collectionIDFieldTypes) {\n collectionIDFieldTypes = getCollectionIDFieldTypes({ config, defaultIDType })\n }\n\n const title = entity.typescript?.interface\n ? entity.typescript.interface\n : formatNames(entity.slug).singular\n\n let mutableFields = [...entity.flattenedFields]\n\n const idField: FieldAffectingData = { name: 'id', type: defaultIDType as 'text', required: true }\n const customIdField = mutableFields.find((field) => field.name === 'id') as FieldAffectingData\n\n if (customIdField && customIdField.type !== 'group' && customIdField.type !== 'tab') {\n mutableFields = mutableFields.map((field) => {\n if (field === customIdField) {\n return { ...field, required: true }\n }\n\n return field\n })\n } else {\n mutableFields.unshift(idField)\n }\n\n // mark timestamp fields required\n if ('timestamps' in entity && entity.timestamps !== false) {\n mutableFields = mutableFields.map((field) => {\n if (field.name === 'createdAt' || field.name === 'updatedAt') {\n return {\n ...field,\n required: true,\n }\n }\n return field\n })\n }\n\n if (\n 'auth' in entity &&\n entity.auth &&\n (!entity.auth?.disableLocalStrategy ||\n (typeof entity.auth?.disableLocalStrategy === 'object' &&\n entity.auth.disableLocalStrategy.enableFields))\n ) {\n mutableFields.push({\n name: 'password',\n type: 'text',\n })\n }\n\n const isAuthCollection = 'auth' in entity && entity.auth\n\n const fieldsSchema = fieldsToJSONSchema(\n collectionIDFieldTypes,\n mutableFields,\n interfaceNameDefinitions,\n config,\n i18n,\n )\n\n // Add collection property to auth collections\n if (isAuthCollection) {\n fieldsSchema.properties = {\n ...fieldsSchema.properties,\n collection: { type: 'string', enum: [entity.slug] },\n }\n fieldsSchema.required = [...(fieldsSchema.required || []), 'collection']\n }\n\n const jsonSchema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n title,\n ...fieldsSchema,\n }\n\n const entityDescription = entityOrFieldToJsDocs({ entity, i18n })\n\n if (entityDescription) {\n jsonSchema.description = entityDescription\n }\n\n return jsonSchema\n}\n\nexport function fieldsToSelectJSONSchema({\n config,\n fields,\n interfaceNameDefinitions,\n}: {\n config: SanitizedConfig\n fields: FlattenedField[]\n interfaceNameDefinitions: Map<string, JSONSchema4>\n}): 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 'array':\n case 'group':\n case 'tab': {\n let fieldSchema: JSONSchema4 = fieldsToSelectJSONSchema({\n config,\n fields: field.flattenedFields,\n interfaceNameDefinitions,\n })\n\n if (field.interfaceName) {\n const definition = `${field.interfaceName}_select`\n interfaceNameDefinitions.set(definition, fieldSchema)\n\n fieldSchema = {\n $ref: `#/definitions/${definition}`,\n }\n }\n\n schema.properties![field.name] = {\n oneOf: [\n {\n type: 'boolean',\n },\n fieldSchema,\n ],\n }\n\n break\n }\n\n case 'blocks': {\n const blocksSchema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n properties: {},\n }\n\n for (const block of field.blockReferences ?? field.blocks) {\n if (typeof block === 'string') {\n continue // TODO\n }\n\n let blockSchema = fieldsToSelectJSONSchema({\n config,\n fields: block.flattenedFields,\n interfaceNameDefinitions,\n })\n\n if (block.interfaceName) {\n const definition = `${block.interfaceName}_select`\n interfaceNameDefinitions.set(definition, blockSchema)\n blockSchema = {\n $ref: `#/definitions/${definition}`,\n }\n }\n\n blocksSchema.properties![block.slug] = {\n oneOf: [\n {\n type: 'boolean',\n },\n blockSchema,\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 '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 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 }\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: `${formatNames(config.slug).singular}AuthOperations`,\n }\n}\n\n// Generates the JSON Schema for supported timezones\nexport function timezonesToJSONSchema(\n supportedTimezones: SanitizedConfig['admin']['timezones']['supportedTimezones'],\n): JSONSchema4 {\n return {\n description: 'Supported timezones in IANA format.',\n enum: supportedTimezones.map((timezone) =>\n typeof timezone === 'string' ? timezone : timezone.value,\n ),\n }\n}\n\nfunction generateAuthOperationSchemas(collections: SanitizedCollectionConfig[]): JSONSchema4 {\n const properties = collections.reduce(\n (acc, collection) => {\n if (collection.auth) {\n acc[collection.slug] = {\n $ref: `#/definitions/auth/${collection.slug}`,\n }\n }\n return acc\n },\n {} as Record<string, JSONSchema4>,\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 i18n?: I18n,\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({\n config,\n defaultIDType: defaultIDType!,\n })\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 i18n,\n )\n const select = fieldsToSelectJSONSchema({\n config,\n fields: entity.flattenedFields,\n interfaceNameDefinitions,\n })\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 {} as Record<string, JSONSchema4>,\n )\n\n const timezoneDefinitions = timezonesToJSONSchema(config.admin.timezones.supportedTimezones)\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: {} as Record<string, JSONSchema4> },\n )\n\n const jobsSchemas = config.jobs\n ? generateJobsJSONSchemas(\n config,\n config.jobs,\n interfaceNameDefinitions,\n collectionIDFieldTypes,\n i18n,\n )\n : {}\n\n const blocksDefinition: JSONSchema4 | undefined = {\n type: 'object',\n additionalProperties: false,\n properties: {},\n required: [],\n }\n if (config?.blocks?.length) {\n for (const block of config.blocks) {\n const blockFieldSchemas = fieldsToJSONSchema(\n collectionIDFieldTypes,\n block.flattenedFields,\n interfaceNameDefinitions,\n config,\n i18n,\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 const interfaceName = block.interfaceName ?? block.slug\n interfaceNameDefinitions.set(interfaceName, blockSchema)\n\n blocksDefinition.properties![block.slug] = {\n $ref: `#/definitions/${interfaceName}`,\n }\n ;(blocksDefinition.required as string[]).push(block.slug)\n }\n }\n\n let jsonSchema: JSONSchema4 = {\n additionalProperties: false,\n definitions: {\n supportedTimezones: timezoneDefinitions,\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 blocks: blocksDefinition,\n collections: generateEntitySchemas(config.collections || []),\n collectionsJoins: generateCollectionJoinsSchemas(config.collections || []),\n collectionsSelect: generateEntitySelectSchemas(config.collections || []),\n db: generateDbEntitySchema(config),\n fallbackLocale: generateFallbackLocaleEntitySchemas(config.localization),\n globals: generateEntitySchemas(config.globals || []),\n globalsSelect: generateEntitySelectSchemas(config.globals || []),\n locale: generateLocaleEntitySchemas(config.localization),\n ...(config.typescript?.strictDraftTypes\n ? {\n strictDraftTypes: {\n type: 'boolean',\n const: true,\n },\n }\n : {}),\n user: generateAuthEntitySchemas(config.collections),\n },\n required: [\n 'user',\n 'locale',\n 'fallbackLocale',\n 'collections',\n 'collectionsSelect',\n 'collectionsJoins',\n 'globalsSelect',\n ...(config.typescript?.strictDraftTypes ? ['strictDraftTypes'] : []),\n 'globals',\n 'auth',\n 'db',\n 'jobs',\n 'blocks',\n ],\n title: 'Config',\n }\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', 'workflows'],\n }\n }\n\n if (config?.typescript?.schema?.length) {\n for (const schema of config.typescript.schema) {\n jsonSchema = schema({ collectionIDFieldTypes, config, i18n: i18n!, jsonSchema })\n }\n }\n\n return jsonSchema\n}\n"],"names":["MissingEditorProp","fieldAffectsData","generateJobsJSONSchemas","formatNames","getCollectionIDFieldTypes","optionsAreEqual","fieldIsRequired","field","isConditional","Boolean","admin","condition","isMarkedRequired","required","type","flattenedFields","some","subField","buildOptionEnums","options","map","option","value","generateEntitySchemas","entities","properties","reduce","acc","slug","$ref","additionalProperties","Object","keys","generateEntitySelectSchemas","generateCollectionJoinsSchemas","collections","joins","polymorphicJoins","schema","collectionSlug","join","joinPath","enum","push","collection","length","generateLocaleEntitySchemas","localization","locales","localesFromConfig","locale","code","generateFallbackLocaleEntitySchemas","localeCodes","localeCode","oneOf","items","generateAuthEntitySchemas","filter","auth","generateDbEntitySchema","config","defaultIDType","db","withNullableJSONSchemaType","fieldType","isRequired","fieldTypes","entityOrFieldToJsDocs","entity","i18n","description","undefined","en","language","fieldsToJSONSchema","collectionIDFieldTypes","fields","interfaceNameDefinitions","requiredFieldNames","Set","fromEntries","fieldSchemas","index","fieldDescription","baseFieldSchema","fieldSchema","interfaceName","set","hasBlocks","blockReferences","blocks","block","resolvedBlock","find","b","blockFieldSchemas","blockSchema","blockType","const","Array","isArray","relationTo","docs","hasNextPage","totalDocs","jsonSchema","hasMany","maxItems","minItems","relation","editor","Error","outputSchema","optionEnums","previousField","isTimezoneField","timezone","name","includes","hasMatchingGlobalTimezones","timezones","supportedTimezones","typescriptSchema","add","Map","from","entityToJSONSchema","title","typescript","interface","singular","mutableFields","idField","customIdField","unshift","timestamps","disableLocalStrategy","enableFields","isAuthCollection","fieldsSchema","entityDescription","fieldsToSelectJSONSchema","definition","blocksSchema","generateAuthFieldTypes","loginWithUsername","allowEmailLogin","email","username","password","requiredFields","requireEmail","requireUsername","authCollectionToOperationsJSONSchema","loginUserFields","forgotOrUnlockUserFields","registerUserFields","forgotPassword","login","registerFirstUser","unlock","timezonesToJSONSchema","generateAuthOperationSchemas","configToJSONSchema","globals","global","entityDefinitions","select","globalType","timezoneDefinitions","authOperationDefinitions","authCollection","jobsSchemas","jobs","blocksDefinition","definitions","collectionsJoins","collectionsSelect","fallbackLocale","globalsSelect","strictDraftTypes","user","size","key"],"mappings":"AASA,SAASA,iBAAiB,QAAQ,iCAAgC;AAClE,SAASC,gBAAgB,QAAQ,4BAA2B;AAC5D,SAASC,uBAAuB,QAAQ,8CAA6C;AACrF,SAASC,WAAW,QAAQ,oBAAmB;AAC/C,SAASC,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,"sources":["../../src/utilities/configToJSONSchema.ts"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { JSONSchema4, JSONSchema4TypeName } from 'json-schema'\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 { FieldAffectingData, FlattenedField, Option } from '../fields/config/types.js'\nimport type { SanitizedGlobalConfig } from '../globals/config/types.js'\n\nimport { MissingEditorProp } from '../errors/MissingEditorProp.js'\nimport { fieldAffectsData } from '../fields/config/types.js'\nimport { generateJobsJSONSchemas } from '../queues/config/generateJobsJSONSchemas.js'\nimport { formatNames } from './formatLabels.js'\nimport { getCollectionIDFieldTypes } from './getCollectionIDFieldTypes.js'\nimport { optionsAreEqual } from './optionsAreEqual.js'\n\nconst fieldIsRequired = (field: FlattenedField): boolean => {\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.flattenedFields.some((subField) => fieldIsRequired(subField))\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(\n (acc, { slug }) => {\n acc[slug] = {\n $ref: `#/definitions/${slug}`,\n }\n\n return acc\n },\n {} as Record<string, JSONSchema4>,\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(\n (acc, { slug }) => {\n acc[slug] = {\n $ref: `#/definitions/${slug}_select`,\n }\n\n return acc\n },\n {} as Record<string, JSONSchema4>,\n )\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n }\n}\n\nfunction generateCollectionJoinsSchemas(collections: SanitizedCollectionConfig[]): JSONSchema4 {\n const properties = [...collections].reduce<Record<string, JSONSchema4>>(\n (acc, { slug, joins, polymorphicJoins }) => {\n const schema = {\n type: 'object',\n additionalProperties: false,\n properties: {},\n required: [] as string[],\n } satisfies JSONSchema4\n\n for (const collectionSlug in joins) {\n for (const join of joins[collectionSlug]!) {\n ;(schema.properties as any)[join.joinPath] = {\n type: 'string',\n enum: [collectionSlug],\n }\n schema.required.push(join.joinPath)\n }\n }\n\n for (const join of polymorphicJoins) {\n ;(schema.properties as any)[join.joinPath] = {\n type: 'string',\n enum: join.field.collection,\n }\n schema.required.push(join.joinPath)\n }\n\n if (Object.keys(schema.properties).length > 0) {\n acc[slug] = schema\n }\n\n return acc\n },\n {},\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 generateFallbackLocaleEntitySchemas(\n localization: SanitizedConfig['localization'],\n): JSONSchema4 {\n if (localization && 'localeCodes' in localization && localization?.localeCodes) {\n const localeCodes = [...localization.localeCodes].map((localeCode) => {\n return localeCode\n }, [])\n\n return {\n oneOf: [\n { type: 'string', enum: ['false', 'none', 'null'] },\n { type: 'boolean', enum: [false] },\n { type: 'null' },\n { type: 'string', enum: localeCodes },\n { type: 'array', items: { type: 'string', enum: localeCodes } },\n ],\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\nfunction entityOrFieldToJsDocs({\n entity,\n i18n,\n}: {\n entity: FlattenedField | SanitizedCollectionConfig | SanitizedGlobalConfig\n i18n?: I18n\n}): string | undefined {\n let description: string | undefined = undefined\n if (entity?.admin?.description) {\n if (typeof entity?.admin?.description === 'string') {\n description = entity?.admin?.description\n } else if (typeof entity?.admin?.description === 'object') {\n if (entity?.admin?.description?.en) {\n description = entity?.admin?.description?.en\n } else if (entity?.admin?.description?.[i18n!.language]) {\n description = entity?.admin?.description?.[i18n!.language]\n }\n } else if (typeof entity?.admin?.description === 'function' && i18n) {\n // do not evaluate description functions for generating JSDocs. The output of\n // those can differ depending on where and when they are called, creating\n // inconsistencies in the generated JSDocs.\n }\n }\n return description\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: FlattenedField[],\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 i18n?: I18n,\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, index) => {\n const isRequired = fieldAffectsData(field) && fieldIsRequired(field)\n\n const fieldDescription = entityOrFieldToJsDocs({ entity: field, i18n })\n const baseFieldSchema: JSONSchema4 = {}\n if (fieldDescription) {\n baseFieldSchema.description = fieldDescription\n }\n\n let fieldSchema: JSONSchema4\n\n switch (field.type) {\n case 'array': {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'object',\n additionalProperties: false,\n ...fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.flattenedFields,\n interfaceNameDefinitions,\n config,\n i18n,\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 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(\n field.blockReferences ? field.blockReferences.length : field.blocks.length,\n )\n\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: hasBlocks\n ? {\n oneOf: (field.blockReferences ?? field.blocks).map((block) => {\n if (typeof block === 'string') {\n const resolvedBlock = config?.blocks?.find((b) => b.slug === block)\n return {\n $ref: `#/definitions/${resolvedBlock!.interfaceName ?? resolvedBlock!.slug}`,\n }\n }\n const blockFieldSchemas = fieldsToJSONSchema(\n collectionIDFieldTypes,\n block.flattenedFields,\n interfaceNameDefinitions,\n config,\n i18n,\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 case 'checkbox': {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('boolean', isRequired),\n }\n break\n }\n case 'code':\n case 'date':\n case 'email':\n case 'textarea': {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('string', isRequired),\n }\n break\n }\n\n case 'group': {\n if (fieldAffectsData(field)) {\n fieldSchema = {\n ...baseFieldSchema,\n type: 'object',\n additionalProperties: false,\n ...fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.flattenedFields,\n interfaceNameDefinitions,\n config,\n i18n,\n ),\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = { $ref: `#/definitions/${field.interfaceName}` }\n }\n }\n break\n }\n\n case 'join': {\n let items: JSONSchema4\n\n if (Array.isArray(field.collection)) {\n items = {\n oneOf: field.collection.map((collection) => ({\n type: 'object',\n additionalProperties: false,\n properties: {\n relationTo: {\n const: collection,\n },\n value: {\n oneOf: [\n {\n type: collectionIDFieldTypes[collection],\n },\n {\n $ref: `#/definitions/${collection}`,\n },\n ],\n },\n },\n required: ['collectionSlug', 'value'],\n })),\n }\n } else {\n items = {\n oneOf: [\n {\n type: collectionIDFieldTypes[field.collection],\n },\n {\n $ref: `#/definitions/${field.collection}`,\n },\n ],\n }\n }\n\n fieldSchema = {\n ...baseFieldSchema,\n type: 'object',\n additionalProperties: false,\n properties: {\n docs: {\n type: 'array',\n items,\n },\n hasNextPage: { type: 'boolean' },\n totalDocs: { type: 'number' },\n },\n }\n break\n }\n\n case 'json': {\n fieldSchema = field.jsonSchema?.schema || {\n ...baseFieldSchema,\n type: ['object', 'array', 'string', 'number', 'boolean', 'null'],\n }\n break\n }\n\n case 'number': {\n if (field.hasMany === true) {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: { type: 'number' },\n }\n } else {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('number', isRequired),\n }\n }\n break\n }\n\n case 'point': {\n fieldSchema = {\n ...baseFieldSchema,\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 'radio': {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('string', isRequired),\n enum: buildOptionEnums(field.options),\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = {\n $ref: `#/definitions/${field.interfaceName}`,\n }\n }\n\n break\n }\n case 'relationship':\n case 'upload': {\n if (Array.isArray(field.relationTo)) {\n if (field.hasMany) {\n fieldSchema = {\n ...baseFieldSchema,\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 ...baseFieldSchema,\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 ...baseFieldSchema,\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 ...baseFieldSchema,\n oneOf: [\n {\n type: withNullableJSONSchemaType(\n collectionIDFieldTypes[field.relationTo]!,\n isRequired,\n ),\n },\n { $ref: `#/definitions/${field.relationTo}` },\n ],\n }\n }\n\n break\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 = {\n ...baseFieldSchema,\n ...field.editor.outputSchema({\n collectionIDFieldTypes,\n config,\n field,\n i18n,\n interfaceNameDefinitions,\n isRequired,\n }),\n }\n } else {\n // Maintain backwards compatibility with existing rich text editors\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'object',\n },\n }\n }\n\n break\n }\n\n case 'select': {\n const optionEnums = buildOptionEnums(field.options)\n // We get the previous field to check for a date in the case of a timezone select\n // This works because timezone selects are always inserted right after a date with 'timezone: true'\n const previousField = fields?.[index - 1]\n const isTimezoneField =\n previousField?.type === 'date' && previousField.timezone && field.name.includes('_tz')\n\n // Check if the timezone field's options match the global config's supported timezones\n const hasMatchingGlobalTimezones =\n isTimezoneField &&\n config &&\n optionsAreEqual(field.options, config.admin?.timezones?.supportedTimezones)\n\n // Timezone selects should reference the supportedTimezones definition\n // only if the field's options match the global config\n if (isTimezoneField && hasMatchingGlobalTimezones) {\n fieldSchema = {\n $ref: `#/definitions/supportedTimezones`,\n }\n } else {\n if (field.hasMany) {\n fieldSchema = {\n ...baseFieldSchema,\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 ...baseFieldSchema,\n type: withNullableJSONSchemaType('string', isRequired),\n }\n if (optionEnums?.length) {\n fieldSchema.enum = optionEnums\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 break\n }\n case 'tab': {\n fieldSchema = {\n ...baseFieldSchema,\n type: 'object',\n additionalProperties: false,\n ...fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.flattenedFields,\n interfaceNameDefinitions,\n config,\n i18n,\n ),\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = { $ref: `#/definitions/${field.interfaceName}` }\n }\n break\n }\n\n case 'text':\n if (field.hasMany === true) {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: { type: 'string' },\n }\n } else {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('string', isRequired),\n }\n }\n break\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 if (isRequired && fieldSchema.required !== false) {\n requiredFieldNames.add(field.name)\n }\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 entity: SanitizedCollectionConfig | SanitizedGlobalConfig,\n interfaceNameDefinitions: Map<string, JSONSchema4>,\n defaultIDType: 'number' | 'text',\n collectionIDFieldTypes?: { [key: string]: 'number' | 'string' },\n i18n?: I18n,\n): JSONSchema4 {\n if (!collectionIDFieldTypes) {\n collectionIDFieldTypes = getCollectionIDFieldTypes({ config, defaultIDType })\n }\n\n const title = entity.typescript?.interface\n ? entity.typescript.interface\n : formatNames(entity.slug).singular\n\n let mutableFields = [...entity.flattenedFields]\n\n const idField: FieldAffectingData = { name: 'id', type: defaultIDType as 'text', required: true }\n const customIdField = mutableFields.find((field) => field.name === 'id') as FieldAffectingData\n\n if (customIdField && customIdField.type !== 'group' && customIdField.type !== 'tab') {\n mutableFields = mutableFields.map((field) => {\n if (field === customIdField) {\n return { ...field, required: true }\n }\n\n return field\n })\n } else {\n mutableFields.unshift(idField)\n }\n\n // mark timestamp fields required\n if ('timestamps' in entity && entity.timestamps !== false) {\n mutableFields = mutableFields.map((field) => {\n if (field.name === 'createdAt' || field.name === 'updatedAt') {\n return {\n ...field,\n required: true,\n }\n }\n return field\n })\n }\n\n if (\n 'auth' in entity &&\n entity.auth &&\n (!entity.auth?.disableLocalStrategy ||\n (typeof entity.auth?.disableLocalStrategy === 'object' &&\n entity.auth.disableLocalStrategy.enableFields))\n ) {\n mutableFields.push({\n name: 'password',\n type: 'text',\n })\n }\n\n const jsonSchema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n title,\n ...fieldsToJSONSchema(\n collectionIDFieldTypes,\n mutableFields,\n interfaceNameDefinitions,\n config,\n i18n,\n ),\n }\n\n const entityDescription = entityOrFieldToJsDocs({ entity, i18n })\n\n if (entityDescription) {\n jsonSchema.description = entityDescription\n }\n\n return jsonSchema\n}\n\nexport function fieldsToSelectJSONSchema({\n config,\n fields,\n interfaceNameDefinitions,\n}: {\n config: SanitizedConfig\n fields: FlattenedField[]\n interfaceNameDefinitions: Map<string, JSONSchema4>\n}): 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 'array':\n case 'group':\n case 'tab': {\n let fieldSchema: JSONSchema4 = fieldsToSelectJSONSchema({\n config,\n fields: field.flattenedFields,\n interfaceNameDefinitions,\n })\n\n if (field.interfaceName) {\n const definition = `${field.interfaceName}_select`\n interfaceNameDefinitions.set(definition, fieldSchema)\n\n fieldSchema = {\n $ref: `#/definitions/${definition}`,\n }\n }\n\n schema.properties![field.name] = {\n oneOf: [\n {\n type: 'boolean',\n },\n fieldSchema,\n ],\n }\n\n break\n }\n\n case 'blocks': {\n const blocksSchema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n properties: {},\n }\n\n for (const block of field.blockReferences ?? field.blocks) {\n if (typeof block === 'string') {\n continue // TODO\n }\n\n let blockSchema = fieldsToSelectJSONSchema({\n config,\n fields: block.flattenedFields,\n interfaceNameDefinitions,\n })\n\n if (block.interfaceName) {\n const definition = `${block.interfaceName}_select`\n interfaceNameDefinitions.set(definition, blockSchema)\n blockSchema = {\n $ref: `#/definitions/${definition}`,\n }\n }\n\n blocksSchema.properties![block.slug] = {\n oneOf: [\n {\n type: 'boolean',\n },\n blockSchema,\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 '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 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 }\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: `${formatNames(config.slug).singular}AuthOperations`,\n }\n}\n\n// Generates the JSON Schema for supported timezones\nexport function timezonesToJSONSchema(\n supportedTimezones: SanitizedConfig['admin']['timezones']['supportedTimezones'],\n): JSONSchema4 {\n return {\n description: 'Supported timezones in IANA format.',\n enum: supportedTimezones.map((timezone) =>\n typeof timezone === 'string' ? timezone : timezone.value,\n ),\n }\n}\n\nfunction generateAuthOperationSchemas(collections: SanitizedCollectionConfig[]): JSONSchema4 {\n const properties = collections.reduce(\n (acc, collection) => {\n if (collection.auth) {\n acc[collection.slug] = {\n $ref: `#/definitions/auth/${collection.slug}`,\n }\n }\n return acc\n },\n {} as Record<string, JSONSchema4>,\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 i18n?: I18n,\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({\n config,\n defaultIDType: defaultIDType!,\n })\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 i18n,\n )\n const select = fieldsToSelectJSONSchema({\n config,\n fields: entity.flattenedFields,\n interfaceNameDefinitions,\n })\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 {} as Record<string, JSONSchema4>,\n )\n\n const timezoneDefinitions = timezonesToJSONSchema(config.admin.timezones.supportedTimezones)\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: {} as Record<string, JSONSchema4> },\n )\n\n const jobsSchemas = config.jobs\n ? generateJobsJSONSchemas(\n config,\n config.jobs,\n interfaceNameDefinitions,\n collectionIDFieldTypes,\n i18n,\n )\n : {}\n\n const blocksDefinition: JSONSchema4 | undefined = {\n type: 'object',\n additionalProperties: false,\n properties: {},\n required: [],\n }\n if (config?.blocks?.length) {\n for (const block of config.blocks) {\n const blockFieldSchemas = fieldsToJSONSchema(\n collectionIDFieldTypes,\n block.flattenedFields,\n interfaceNameDefinitions,\n config,\n i18n,\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 const interfaceName = block.interfaceName ?? block.slug\n interfaceNameDefinitions.set(interfaceName, blockSchema)\n\n blocksDefinition.properties![block.slug] = {\n $ref: `#/definitions/${interfaceName}`,\n }\n ;(blocksDefinition.required as string[]).push(block.slug)\n }\n }\n\n let jsonSchema: JSONSchema4 = {\n additionalProperties: false,\n definitions: {\n supportedTimezones: timezoneDefinitions,\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 blocks: blocksDefinition,\n collections: generateEntitySchemas(config.collections || []),\n collectionsJoins: generateCollectionJoinsSchemas(config.collections || []),\n collectionsSelect: generateEntitySelectSchemas(config.collections || []),\n db: generateDbEntitySchema(config),\n fallbackLocale: generateFallbackLocaleEntitySchemas(config.localization),\n globals: generateEntitySchemas(config.globals || []),\n globalsSelect: generateEntitySelectSchemas(config.globals || []),\n locale: generateLocaleEntitySchemas(config.localization),\n ...(config.typescript?.strictDraftTypes\n ? {\n strictDraftTypes: {\n type: 'boolean',\n const: true,\n },\n }\n : {}),\n user: generateAuthEntitySchemas(config.collections),\n },\n required: [\n 'user',\n 'locale',\n 'fallbackLocale',\n 'collections',\n 'collectionsSelect',\n 'collectionsJoins',\n 'globalsSelect',\n ...(config.typescript?.strictDraftTypes ? ['strictDraftTypes'] : []),\n 'globals',\n 'auth',\n 'db',\n 'jobs',\n 'blocks',\n ],\n title: 'Config',\n }\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', 'workflows'],\n }\n }\n\n if (config?.typescript?.schema?.length) {\n for (const schema of config.typescript.schema) {\n jsonSchema = schema({ collectionIDFieldTypes, config, i18n: i18n!, jsonSchema })\n }\n }\n\n return jsonSchema\n}\n"],"names":["MissingEditorProp","fieldAffectsData","generateJobsJSONSchemas","formatNames","getCollectionIDFieldTypes","optionsAreEqual","fieldIsRequired","field","isConditional","Boolean","admin","condition","isMarkedRequired","required","type","flattenedFields","some","subField","buildOptionEnums","options","map","option","value","generateEntitySchemas","entities","properties","reduce","acc","slug","$ref","additionalProperties","Object","keys","generateEntitySelectSchemas","generateCollectionJoinsSchemas","collections","joins","polymorphicJoins","schema","collectionSlug","join","joinPath","enum","push","collection","length","generateLocaleEntitySchemas","localization","locales","localesFromConfig","locale","code","generateFallbackLocaleEntitySchemas","localeCodes","localeCode","oneOf","items","generateAuthEntitySchemas","filter","auth","allOf","generateDbEntitySchema","config","defaultIDType","db","withNullableJSONSchemaType","fieldType","isRequired","fieldTypes","entityOrFieldToJsDocs","entity","i18n","description","undefined","en","language","fieldsToJSONSchema","collectionIDFieldTypes","fields","interfaceNameDefinitions","requiredFieldNames","Set","fromEntries","fieldSchemas","index","fieldDescription","baseFieldSchema","fieldSchema","interfaceName","set","hasBlocks","blockReferences","blocks","block","resolvedBlock","find","b","blockFieldSchemas","blockSchema","blockType","const","Array","isArray","relationTo","docs","hasNextPage","totalDocs","jsonSchema","hasMany","maxItems","minItems","relation","editor","Error","outputSchema","optionEnums","previousField","isTimezoneField","timezone","name","includes","hasMatchingGlobalTimezones","timezones","supportedTimezones","typescriptSchema","add","Map","from","entityToJSONSchema","title","typescript","interface","singular","mutableFields","idField","customIdField","unshift","timestamps","disableLocalStrategy","enableFields","entityDescription","fieldsToSelectJSONSchema","definition","blocksSchema","generateAuthFieldTypes","loginWithUsername","allowEmailLogin","email","username","password","requiredFields","requireEmail","requireUsername","authCollectionToOperationsJSONSchema","loginUserFields","forgotOrUnlockUserFields","registerUserFields","forgotPassword","login","registerFirstUser","unlock","timezonesToJSONSchema","generateAuthOperationSchemas","configToJSONSchema","globals","global","entityDefinitions","select","globalType","timezoneDefinitions","authOperationDefinitions","authCollection","jobsSchemas","jobs","blocksDefinition","definitions","collectionsJoins","collectionsSelect","fallbackLocale","globalsSelect","strictDraftTypes","user","size","key"],"mappings":"AASA,SAASA,iBAAiB,QAAQ,iCAAgC;AAClE,SAASC,gBAAgB,QAAQ,4BAA2B;AAC5D,SAASC,uBAAuB,QAAQ,8CAA6C;AACrF,SAASC,WAAW,QAAQ,oBAAmB;AAC/C,SAASC,yBAAyB,QAAQ,iCAAgC;AAC1E,SAASC,eAAe,QAAQ,uBAAsB;AAEtD,MAAMC,k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O,IAAI,EAAE;YACnDe,eAAelJ,4BAA4B6B,OAAOsG,OAAO,IAAI,EAAE;YAC/DlH,QAAQJ,4BAA4BgB,OAAOf,YAAY;YACvD,GAAIe,OAAOoE,UAAU,EAAEkD,mBACnB;gBACEA,kBAAkB;oBAChBtK,MAAM;oBACNsF,OAAO;gBACT;YACF,IACA,CAAC,CAAC;YACNiF,MAAM5H,0BAA0BK,OAAO3B,WAAW;QACpD;QACAtB,UAAU;YACR;YACA;YACA;YACA;YACA;YACA;YACA;eACIiD,OAAOoE,UAAU,EAAEkD,mBAAmB;gBAAC;aAAmB,GAAG,EAAE;YACnE;YACA;YACA;YACA;YACA;SACD;QACDnD,OAAO;IACT;IAEA,IAAI2C,YAAYG,WAAW,EAAEO,MAAM;QACjC,KAAK,MAAM,CAACC,KAAKjK,MAAM,IAAIsJ,YAAYG,WAAW,CAAE;YAClDpE,WAAWoE,WAAW,AAAC,CAACQ,IAAI,GAAGjK;QACjC;IACF;IACA,IAAIsJ,YAAYnJ,UAAU,EAAE;QAC1BkF,WAAWlF,UAAU,CAAEoJ,IAAI,GAAG;YAC5B/J,MAAM;YACNgB,sBAAsB;YACtBL,YAAYmJ,YAAYnJ,UAAU;YAClCZ,UAAU;gBAAC;gBAAS;aAAY;QAClC;IACF;IAEA,IAAIiD,QAAQoE,YAAY5F,QAAQO,QAAQ;QACtC,KAAK,MAAMP,UAAUwB,OAAOoE,UAAU,CAAC5F,MAAM,CAAE;YAC7CqE,aAAarE,OAAO;gBAAEuC;gBAAwBf;gBAAQS,MAAMA;gBAAOoC;YAAW;QAChF;IACF;IAEA,OAAOA;AACT"}
|
|
@@ -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,SAAS,EAAE,MAAM,aAAa,CAAA;AAClF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAsFvD,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,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,SAAS,CAAA;CACjB,CAAA;AAED,KAAK,cAAc,GAAG,CAAC,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,cAAc,CAAC,CAAA;AAEnG,eAAO,MAAM,cAAc,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,SAAS,EAAE,MAAM,aAAa,CAAA;AAClF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAsFvD,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,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,SAAS,CAAA;CACjB,CAAA;AAED,KAAK,cAAc,GAAG,CAAC,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,cAAc,CAAC,CAAA;AAEnG,eAAO,MAAM,cAAc,EAAE,cA4C5B,CAAA"}
|
|
@@ -89,14 +89,6 @@ export const createLocalReq = async ({ context, fallbackLocale, locale: localeAr
|
|
|
89
89
|
req.i18n = i18n;
|
|
90
90
|
req.t = i18n.t;
|
|
91
91
|
req.user = user || req?.user || null;
|
|
92
|
-
// Ensure user.collection is set for auth-related access control
|
|
93
|
-
// TODO (4.0): Instead of silently falling back, throw an error if user.collection is missing
|
|
94
|
-
if (req.user && !req.user.collection) {
|
|
95
|
-
req.user = {
|
|
96
|
-
...req.user,
|
|
97
|
-
collection: payload.config.admin.user
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
92
|
req.payloadDataLoader = req?.payloadDataLoader || getDataLoader(req);
|
|
101
93
|
req.routeParams = req?.routeParams || {};
|
|
102
94
|
req.query = req?.query || {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/createLocalReq.ts"],"sourcesContent":["import type { Payload, RequestContext, TypedLocale, TypedUser } 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 fallbackLocale?: false | TypedLocale\n locale?: string\n req?: Partial<PayloadRequest>\n urlSuffix?: string\n user?: TypedUser\n}\n\ntype CreateLocalReq = (options: CreateLocalReqOptions, payload: Payload) => Promise<PayloadRequest>\n\nexport const createLocalReq: CreateLocalReq = async (\n { context, fallbackLocale, locale: localeArg, req = {} as PayloadRequest, urlSuffix, user },\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
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/createLocalReq.ts"],"sourcesContent":["import type { Payload, RequestContext, TypedLocale, TypedUser } 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 fallbackLocale?: false | TypedLocale\n locale?: string\n req?: Partial<PayloadRequest>\n urlSuffix?: string\n user?: TypedUser\n}\n\ntype CreateLocalReq = (options: CreateLocalReqOptions, payload: Payload) => Promise<PayloadRequest>\n\nexport const createLocalReq: CreateLocalReq = async (\n { context, fallbackLocale, locale: localeArg, req = {} as PayloadRequest, urlSuffix, user },\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 req.payloadDataLoader = req?.payloadDataLoader || getDataLoader(req as PayloadRequest)\n req.routeParams = req?.routeParams || {}\n req.query = req?.query || {}\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","fallbackLocale","locale","localeArg","user","localization","defaultLocale","localeCandidate","query","sanitizedFallback","i18n","language","fallbackLanguage","headers","Headers","payloadAPI","t","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;AAEA,MAAMI,0BAA0B,CAACL,KAA8BM;IAC7D;;;;;;GAMC,GACD,IAAIC;IAEJ,SAASC;QACP,IAAID,WAAW;YACb,OAAOA;QACT;QAEA,MAAME,cAAc,CAAC,OAAO,EAAET,IAAIU,IAAI,IAAI,cAAcJ,aAAa,IAAI;QAEzE,MAAMK,WACJX,KAAKY,OACJZ,CAAAA,IAAIa,OAAO,EAAEC,QAAQC,YAClB,GAAGf,IAAIa,OAAO,EAAEC,OAAOC,YAAYT,aAAa,IAAI,GACpDG,WAAU;QAEhB,IAAI;YACFF,YAAY,IAAIS,IAAIL;QACtB,EAAE,OAAOM,MAAM;YACbjB,IAAIa,OAAO,EAAEK,OAAOC,MAClB,CAAC,sCAAsC,EAAER,SAAS,kBAAkB,EAAEF,aAAa;YAGrFF,YAAY,IAAIS,IAAIP;QACtB;QAEA,OAAOF;IACT;IAEA,IAAI,CAACP,IAAIU,IAAI,EAAE;QACbV,IAAIU,IAAI,GAAGF,eAAeE,IAAI;IAChC;IAEA,IAAI,CAACV,IAAIoB,QAAQ,EAA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;IACpB;IAEAvC,IAAIC,OAAO,GAAGF,kBAAkBC,KAAKC;IACrCD,IAAIwC,UAAU,GAAGxC,KAAKwC,cAAc;IACpCxC,IAAIa,OAAO,GAAGA;IACdb,IAAImC,IAAI,GAAGA;IACXnC,IAAIyC,CAAC,GAAGN,KAAKM,CAAC;IACdzC,IAAI6B,IAAI,GAAGA,QAAQ7B,KAAK6B,QAAQ;IAChC7B,IAAI0C,iBAAiB,GAAG1C,KAAK0C,qBAAqB9C,cAAcI;IAChEA,IAAI2C,WAAW,GAAG3C,KAAK2C,eAAe,CAAC;IACvC3C,IAAIiC,KAAK,GAAGjC,KAAKiC,SAAS,CAAC;IAE3B5B,wBAAwBL,KAAKM;IAE7B,OAAON;AACT,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payload",
|
|
3
|
-
"version": "3.74.0
|
|
3
|
+
"version": "3.74.0",
|
|
4
4
|
"description": "Node, React, Headless CMS and Application Framework built on Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"admin panel",
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
"undici": "7.18.2",
|
|
116
116
|
"uuid": "10.0.0",
|
|
117
117
|
"ws": "^8.16.0",
|
|
118
|
-
"@payloadcms/translations": "3.74.0
|
|
118
|
+
"@payloadcms/translations": "3.74.0"
|
|
119
119
|
},
|
|
120
120
|
"devDependencies": {
|
|
121
121
|
"@hyrious/esbuild-plugin-commonjs": "0.2.6",
|