payload 4.0.0-beta.2 → 4.0.0-beta.4
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/adapters/router.d.ts +1 -1
- package/dist/admin/adapters/router.d.ts.map +1 -1
- package/dist/admin/adapters/router.js.map +1 -1
- package/dist/admin/initAdminContext.js.map +1 -1
- package/dist/auth/getFieldsToSign.js.map +1 -1
- package/dist/auth/loginWithCookie.js.map +1 -1
- package/dist/auth/serverFunctions/cookies.js.map +1 -1
- package/dist/auth/serverFunctions/login.js.map +1 -1
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/auth/types.js.map +1 -1
- package/dist/cli/commands/data/utilities.d.ts +1 -1
- package/dist/cli/commands/data/utilities.d.ts.map +1 -1
- package/dist/cli/commands/data/utilities.js.map +1 -1
- package/dist/cli/defineCLICommand.js +1 -1
- package/dist/cli/defineCLICommand.js.map +1 -1
- package/dist/collections/config/client.js.map +1 -1
- package/dist/collections/config/types.d.ts.map +1 -1
- package/dist/collections/config/types.js.map +1 -1
- package/dist/collections/operations/findByID.js.map +1 -1
- package/dist/collections/operations/findVersionByID.js.map +1 -1
- package/dist/collections/operations/findVersions.js.map +1 -1
- package/dist/collections/operations/local/findDistinct.js.map +1 -1
- package/dist/collections/operations/renameFile.js +1 -1
- package/dist/collections/operations/renameFile.js.map +1 -1
- package/dist/collections/operations/utilities/update.js +1 -1
- package/dist/collections/operations/utilities/update.js.map +1 -1
- package/dist/collections/operations/validate.js +4 -4
- package/dist/collections/operations/validate.js.map +1 -1
- package/dist/config/definePlugin.js.map +1 -1
- package/dist/config/sanitize.js +2 -2
- package/dist/config/sanitize.js.map +1 -1
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js.map +1 -1
- package/dist/database/types.d.ts +4 -0
- package/dist/database/types.d.ts.map +1 -1
- package/dist/database/types.js.map +1 -1
- package/dist/exports/build-config.d.ts +9 -0
- package/dist/exports/build-config.d.ts.map +1 -0
- package/dist/exports/build-config.js +38 -0
- package/dist/exports/build-config.js.map +1 -0
- package/dist/fields/config/client.js.map +1 -1
- package/dist/fields/config/reservedFieldNames.d.ts.map +1 -1
- package/dist/fields/config/reservedFieldNames.js.map +1 -1
- package/dist/fields/config/types.d.ts.map +1 -1
- package/dist/fields/config/types.js.map +1 -1
- package/dist/fields/hooks/afterChange/promise.js.map +1 -1
- package/dist/fields/hooks/afterRead/promise.js.map +1 -1
- package/dist/fields/hooks/beforeChange/flattenValidationData.d.ts +14 -0
- package/dist/fields/hooks/beforeChange/flattenValidationData.d.ts.map +1 -0
- package/dist/fields/hooks/beforeChange/flattenValidationData.js +36 -0
- package/dist/fields/hooks/beforeChange/flattenValidationData.js.map +1 -0
- package/dist/fields/hooks/beforeChange/promise.d.ts +2 -1
- package/dist/fields/hooks/beforeChange/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/promise.js +96 -22
- package/dist/fields/hooks/beforeChange/promise.js.map +1 -1
- package/dist/fields/hooks/beforeChange/traverseFields.d.ts +2 -1
- package/dist/fields/hooks/beforeChange/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/traverseFields.js +2 -1
- package/dist/fields/hooks/beforeChange/traverseFields.js.map +1 -1
- package/dist/fields/validations.d.ts.map +1 -1
- package/dist/fields/validations.js +4 -1
- package/dist/fields/validations.js.map +1 -1
- package/dist/globals/config/types.d.ts.map +1 -1
- package/dist/globals/config/types.js.map +1 -1
- package/dist/globals/operations/local/findOne.js.map +1 -1
- package/dist/globals/operations/local/update.js.map +1 -1
- package/dist/globals/operations/restoreVersion.d.ts +2 -3
- package/dist/globals/operations/restoreVersion.d.ts.map +1 -1
- package/dist/globals/operations/restoreVersion.js +22 -15
- package/dist/globals/operations/restoreVersion.js.map +1 -1
- package/dist/globals/operations/validate.js +1 -1
- package/dist/globals/operations/validate.js.map +1 -1
- package/dist/hierarchy/createFolderField.js.map +1 -1
- package/dist/hierarchy/resolveHierarchyCollections.js +2 -2
- package/dist/hierarchy/resolveHierarchyCollections.js.map +1 -1
- package/dist/hierarchy/utils/computePaths.d.ts.map +1 -1
- package/dist/hierarchy/utils/computePaths.js.map +1 -1
- package/dist/index.bundled.d.ts +18 -4
- package/dist/queues/operations/runJobs/runJob/getRunTaskFunction.js +1 -1
- package/dist/queues/operations/runJobs/runJob/getRunTaskFunction.js.map +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/uploads/fileVersioning/archive.js.map +1 -1
- package/dist/uploads/fileVersioning/cloudStorage.js.map +1 -1
- package/dist/uploads/fileVersioning/resolveHistoricalFile.js.map +1 -1
- package/dist/uploads/generateFileData.d.ts.map +1 -1
- package/dist/uploads/generateFileData.js.map +1 -1
- package/dist/uploads/getFileContentRequirement.js.map +1 -1
- package/dist/uploads/getFileFromUploadInstructions.js.map +1 -1
- package/dist/uploads/safeFetch.js.map +1 -1
- package/dist/uploads/stagedUpload.js.map +1 -1
- package/dist/uploads/transformers/handleDynamicFileRequest.js +11 -2
- package/dist/uploads/transformers/handleDynamicFileRequest.js.map +1 -1
- package/dist/utilities/addSelectGenericsToGeneretedTypes.d.ts.map +1 -1
- package/dist/utilities/addSelectGenericsToGeneretedTypes.js +0 -1
- package/dist/utilities/addSelectGenericsToGeneretedTypes.js.map +1 -1
- package/dist/utilities/appendDateTimezoneSelectFields.js.map +1 -1
- package/dist/utilities/cloneValidationRequest.js.map +1 -1
- package/dist/utilities/createPayloadRequest.js.map +1 -1
- package/dist/utilities/deepCopyObject.js.map +1 -1
- package/dist/utilities/documentMatchingWhereExists.js +1 -1
- package/dist/utilities/documentMatchingWhereExists.js.map +1 -1
- package/dist/utilities/entityInputSchema/validateEntityData.d.ts.map +1 -1
- package/dist/utilities/entityInputSchema/validateEntityData.js.map +1 -1
- package/dist/utilities/filterDataToSelectedLocales.js.map +1 -1
- package/dist/utilities/getEntityPermissions/getEntityPermissions.d.ts.map +1 -1
- package/dist/utilities/getEntityPermissions/getEntityPermissions.js +1 -0
- package/dist/utilities/getEntityPermissions/getEntityPermissions.js.map +1 -1
- package/dist/utilities/getEntityPermissions/populateFieldPermissions.js.map +1 -1
- package/dist/utilities/getVersionsConfig.js.map +1 -1
- package/dist/utilities/parseParams/index.js.map +1 -1
- package/dist/utilities/parseValidationLocale.js.map +1 -1
- package/dist/utilities/sanitizePopulateParam.js.map +1 -1
- package/dist/utilities/telemetry/conf/index.d.ts +4 -1
- package/dist/utilities/telemetry/conf/index.d.ts.map +1 -1
- package/dist/utilities/telemetry/conf/index.js.map +1 -1
- package/dist/utilities/telemetry/featureInfo/getFeatureInfo.js.map +1 -1
- package/dist/versions/allLocalesPublicationStatus.js.map +1 -1
- package/dist/versions/isInheritedReadVersionsAccess.js.map +1 -1
- package/package.json +29 -27
- package/skills/payload/reference/ENDPOINTS.md +3 -9
- package/skills/payload/reference/PLUGIN-DEVELOPMENT.md +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/globals/config/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAChE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAE1C,OAAO,KAAK,EACV,MAAM,EACN,QAAQ,EACR,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,UAAU,EACV,qBAAqB,EACrB,WAAW,EACZ,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAA;AAClG,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AACzE,OAAO,KAAK,EACV,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,UAAU,EACV,cAAc,EACd,WAAW,E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,aAAa,GAAG,WAAW,CAAA;IACnC,8FAA8F;IAC9F,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;;OAGG;IACH,aAAa,CAAC,EACV;QACE,QAAQ,EAAE,MAAM,CAAA;KACjB,GACD,KAAK,CAAA;IACT,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,UAAU,CAAC,EAAE;QACX;;WAEG;QACH,SAAS,CAAC,EAAE,MAAM,CAAA;KACnB,CAAA;IACD,QAAQ,CAAC,EAAE,OAAO,GAAG,sBAAsB,CAAA;CAC5C,GAAG,IAAI,CACN,YAAY,CACV,KAAK,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,SAAS,IAAI,GAC3C,iBAAiB,GACjB,oBAAoB,CAAC,KAAK,CAAC,CAChC,EACD,QAAQ,CACT,CAAA;AAED,MAAM,WAAW,qBACf,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/globals/config/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAChE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAE1C,OAAO,KAAK,EACV,MAAM,EACN,QAAQ,EACR,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,UAAU,EACV,qBAAqB,EACrB,WAAW,EACZ,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAA;AAClG,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AACzE,OAAO,KAAK,EACV,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,UAAU,EACV,cAAc,EACd,WAAW,EACX,iBAAiB,EAClB,MAAM,gBAAgB,CAAA;AACvB,OAA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MAAM,GAAG;YACd,iBAAiB,EAAE,cAAc,CAAC,GAAG,CAAC,CAAA;YACtC,IAAI,EAAE,iBAAiB,CAAA;YACvB,WAAW,CAAC,EAAE,iBAAiB,CAAA;SAChC,CAAA;KACF,GACD,KAAK,CAAA;CACV,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/globals/config/types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { GraphQLNonNull, GraphQLObjectType } from 'graphql'\nimport type { IsAny } from 'ts-essentials'\n\nimport type {\n Access,\n Endpoint,\n EntityDescription,\n GeneratePreviewURL,\n LabelFunction,\n LivePreviewConfig,\n MetaConfig,\n SharedAdminComponents,\n StaticLabel,\n} from '../../config/types.js'\nimport type { DBIdentifierName } from '../../database/types.js'\nimport type { Authorship, SanitizedAuthorship } from '../../fields/baseFields/authorship/types.js'\nimport type { Field, FlattenedField } from '../../fields/config/types.js'\nimport type {\n GeneratedTypes,\n GlobalAdminCustom,\n GlobalCustom,\n GlobalSlug,\n RequestContext,\n TypedGlobal,\n TypedGlobalSelect,\n} from '../../index.js'\nimport type {\n FieldOperation,\n PayloadRequest,\n SelectIncludeType,\n Where,\n WithSelectFn,\n} from '../../types/index.js'\nimport type { IncomingGlobalVersions, SanitizedGlobalVersions } from '../../versions/types.js'\n\nexport type DataFromGlobalSlug<TSlug extends GlobalSlug> = TypedGlobal[TSlug]\n\nexport type SelectFromGlobalSlug<TSlug extends GlobalSlug> = TypedGlobalSelect[TSlug]\n\nexport type GlobalAccess<TData = any> = {\n read?: Access<TData>\n readVersions?: Access<TData>\n update?: Access<TData>\n /**\n * Controls on-demand validation for this global.\n * Falls back to `update` access when omitted.\n * The access function receives `req.operation === 'validate'`.\n * @see https://payloadcms.com/docs/validation/overview#access-control-and-hooks\n */\n validate?: Access<TData>\n}\n\n/**\n * Global slugs that do not have drafts enabled.\n * Detects globals without drafts by checking for the absence of the `_status` field.\n */\nexport type GlobalsWithoutDrafts = {\n [TSlug in GlobalSlug]: DataFromGlobalSlug<TSlug> extends { _status?: any } ? never : TSlug\n}[GlobalSlug]\n\n/**\n * Conditionally allows or forbids the `draft` property based on global configuration.\n * When `strictDraftTypes` is enabled, the `draft` property is forbidden on globals without drafts.\n */\nexport type DraftFlagFromGlobalSlug<TSlug extends GlobalSlug> = GeneratedTypes extends {\n strictDraftTypes: true\n}\n ? TSlug extends GlobalsWithoutDrafts\n ? {\n /**\n * The `draft` property is not allowed because this global does not have `versions.drafts` enabled.\n */\n draft?: never\n }\n : {\n /**\n * Whether the global should be queried from the versions table/collection or not. [More](https://payloadcms.com/docs/versions/drafts#draft-api)\n */\n draft?: boolean\n }\n : {\n /**\n * Whether the global should be queried from the versions table/collection or not. [More](https://payloadcms.com/docs/versions/drafts#draft-api)\n */\n draft?: boolean\n }\n\ntype GlobalChangeOperation = Extract<FieldOperation, 'update' | 'validate'>\n\nexport type BeforeValidateHook = (args: {\n context: RequestContext\n data?: any\n /** The global which this hook is being run on */\n global: SanitizedGlobalConfig\n /** Hook operation being performed. */\n operation: GlobalChangeOperation\n originalDoc?: any\n /**\n * Whether access control is being overridden for this operation\n */\n overrideAccess?: boolean\n req: PayloadRequest\n}) => any\n\nexport type BeforeChangeHook = (args: {\n context: RequestContext\n data: any\n /** The global which this hook is being run on */\n global: SanitizedGlobalConfig\n /** Hook operation being performed. */\n operation: GlobalChangeOperation\n originalDoc?: any\n /**\n * Whether access control is being overridden for this operation\n */\n overrideAccess?: boolean\n req: PayloadRequest\n}) => any\n\nexport type AfterChangeHook = (args: {\n context: RequestContext\n data: any\n doc: any\n /** The global which this hook is being run on */\n global: SanitizedGlobalConfig\n /** Hook operation being performed. */\n operation: 'update'\n /**\n * Whether access control is being overridden for this operation\n */\n overrideAccess?: boolean\n previousDoc: any\n req: PayloadRequest\n}) => any\n\nexport type BeforeReadHook = (args: {\n context: RequestContext\n doc: any\n /** The global which this hook is being run on */\n global: SanitizedGlobalConfig\n /**\n * Whether access control is being overridden for this operation\n */\n overrideAccess?: boolean\n req: PayloadRequest\n}) => any\n\nexport type AfterReadHook = (args: {\n context: RequestContext\n doc: any\n findMany?: boolean\n /** The global which this hook is being run on */\n global: SanitizedGlobalConfig\n /**\n * Whether access control is being overridden for this operation\n */\n overrideAccess?: boolean\n query?: Where\n req: PayloadRequest\n}) => any\n\nexport type HookOperationType = 'countVersions' | 'read' | 'restoreVersion' | 'update'\n\nexport type BeforeOperationHook = (args: {\n args?: any\n context: RequestContext\n /**\n * The Global which this hook is being run on\n * */\n global: SanitizedGlobalConfig\n /**\n * Hook operation being performed\n */\n operation: HookOperationType\n /**\n * Whether access control is being overridden for this operation\n */\n overrideAccess?: boolean\n req: PayloadRequest\n}) => any\n\nexport type GlobalAdminOptions = {\n /**\n * Custom admin components\n */\n components?: SharedAdminComponents\n /** Extension point to add your custom data. Available in server and client. */\n custom?: GlobalAdminCustom\n /**\n * Custom description for collection\n */\n description?: EntityDescription\n /**\n * Specify a navigational group for globals in the admin sidebar.\n * - Provide a string to place the entity in a custom group.\n * - Provide a record to define localized group names.\n * - Set to `false` to exclude the global from the sidebar, command palette, and dashboard collection cards.\n * This does not disable routes or change access control.\n */\n group?: false | Record<string, string> | string\n /**\n * Exclude the global from the admin nav and routes\n */\n hidden?: ((args: { user: PayloadRequest['user'] }) => boolean) | boolean\n /**\n * Live preview options\n */\n livePreview?: LivePreviewConfig\n meta?: MetaConfig\n /**\n * Function to generate custom preview URL\n */\n preview?: GeneratePreviewURL\n}\n\ntype GlobalHooks = {\n afterChange?: AfterChangeHook[]\n afterRead?: AfterReadHook[]\n beforeChange?: BeforeChangeHook[]\n beforeOperation?: BeforeOperationHook[]\n beforeRead?: BeforeReadHook[]\n beforeValidate?: BeforeValidateHook[]\n}\n\nexport type GlobalConfig<TSlug extends GlobalSlug = any> = {\n /**\n * Do not set this property manually. This is set to true during sanitization, to avoid\n * sanitizing the same global multiple times.\n */\n _sanitized?: boolean\n access?: GlobalAccess\n admin?: GlobalAdminOptions\n /**\n * Automatically track the user that created and last updated this global via\n * polymorphic `createdBy` / `updatedBy` relationship fields to your auth collections.\n *\n * Use `true` (default) to enable both, `false` to disable both, or an object to\n * toggle each field independently, e.g. `{ updatedBy: false }`.\n *\n * @default true\n */\n authorship?: Authorship | boolean\n /** Extension point to add your custom data. Server only. */\n custom?: GlobalCustom\n /**\n * Customize the SQL table name\n */\n dbName?: DBIdentifierName\n endpoints?: false | Omit<Endpoint, 'root'>[]\n fields: Field[]\n graphQL?:\n | {\n disableMutations?: true\n disableQueries?: true\n name?: string\n }\n | false\n hooks?: GlobalHooks\n label?: LabelFunction | StaticLabel\n /** Read-only Markdown instructions included in this global's MCP and CLI schema responses. */\n llmInstructions?: string\n /**\n * Enables / Disables the ability to lock documents while editing\n * @default true\n */\n lockDocuments?:\n | {\n duration: number\n }\n | false\n slug: string\n /**\n * Options used in typescript generation\n */\n typescript?: {\n /**\n * Typescript generation name given to the interface type\n */\n interface?: string\n }\n versions?: boolean | IncomingGlobalVersions\n} & Pick<\n WithSelectFn<\n IsAny<SelectFromGlobalSlug<TSlug>> extends true\n ? SelectIncludeType\n : SelectFromGlobalSlug<TSlug>\n >,\n 'select'\n>\n\nexport interface SanitizedGlobalConfig\n extends
|
|
1
|
+
{"version":3,"sources":["../../../src/globals/config/types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { GraphQLNonNull, GraphQLObjectType } from 'graphql'\nimport type { IsAny } from 'ts-essentials'\n\nimport type {\n Access,\n Endpoint,\n EntityDescription,\n GeneratePreviewURL,\n LabelFunction,\n LivePreviewConfig,\n MetaConfig,\n SharedAdminComponents,\n StaticLabel,\n} from '../../config/types.js'\nimport type { DBIdentifierName } from '../../database/types.js'\nimport type { Authorship, SanitizedAuthorship } from '../../fields/baseFields/authorship/types.js'\nimport type { Field, FlattenedField } from '../../fields/config/types.js'\nimport type {\n GeneratedTypes,\n GlobalAdminCustom,\n GlobalCustom,\n GlobalSlug,\n RequestContext,\n TypedGlobal,\n TypedGlobalSelect,\n} from '../../index.js'\nimport type {\n FieldOperation,\n PayloadRequest,\n SelectIncludeType,\n Where,\n WithSelectFn,\n} from '../../types/index.js'\nimport type { IncomingGlobalVersions, SanitizedGlobalVersions } from '../../versions/types.js'\n\nexport type DataFromGlobalSlug<TSlug extends GlobalSlug> = TypedGlobal[TSlug]\n\nexport type SelectFromGlobalSlug<TSlug extends GlobalSlug> = TypedGlobalSelect[TSlug]\n\nexport type GlobalAccess<TData = any> = {\n read?: Access<TData>\n readVersions?: Access<TData>\n update?: Access<TData>\n /**\n * Controls on-demand validation for this global.\n * Falls back to `update` access when omitted.\n * The access function receives `req.operation === 'validate'`.\n * @see https://payloadcms.com/docs/validation/overview#access-control-and-hooks\n */\n validate?: Access<TData>\n}\n\n/**\n * Global slugs that do not have drafts enabled.\n * Detects globals without drafts by checking for the absence of the `_status` field.\n */\nexport type GlobalsWithoutDrafts = {\n [TSlug in GlobalSlug]: DataFromGlobalSlug<TSlug> extends { _status?: any } ? never : TSlug\n}[GlobalSlug]\n\n/**\n * Conditionally allows or forbids the `draft` property based on global configuration.\n * When `strictDraftTypes` is enabled, the `draft` property is forbidden on globals without drafts.\n */\nexport type DraftFlagFromGlobalSlug<TSlug extends GlobalSlug> = GeneratedTypes extends {\n strictDraftTypes: true\n}\n ? TSlug extends GlobalsWithoutDrafts\n ? {\n /**\n * The `draft` property is not allowed because this global does not have `versions.drafts` enabled.\n */\n draft?: never\n }\n : {\n /**\n * Whether the global should be queried from the versions table/collection or not. [More](https://payloadcms.com/docs/versions/drafts#draft-api)\n */\n draft?: boolean\n }\n : {\n /**\n * Whether the global should be queried from the versions table/collection or not. [More](https://payloadcms.com/docs/versions/drafts#draft-api)\n */\n draft?: boolean\n }\n\ntype GlobalChangeOperation = Extract<FieldOperation, 'update' | 'validate'>\n\nexport type BeforeValidateHook = (args: {\n context: RequestContext\n data?: any\n /** The global which this hook is being run on */\n global: SanitizedGlobalConfig\n /** Hook operation being performed. */\n operation: GlobalChangeOperation\n originalDoc?: any\n /**\n * Whether access control is being overridden for this operation\n */\n overrideAccess?: boolean\n req: PayloadRequest\n}) => any\n\nexport type BeforeChangeHook = (args: {\n context: RequestContext\n data: any\n /** The global which this hook is being run on */\n global: SanitizedGlobalConfig\n /** Hook operation being performed. */\n operation: GlobalChangeOperation\n originalDoc?: any\n /**\n * Whether access control is being overridden for this operation\n */\n overrideAccess?: boolean\n req: PayloadRequest\n}) => any\n\nexport type AfterChangeHook = (args: {\n context: RequestContext\n data: any\n doc: any\n /** The global which this hook is being run on */\n global: SanitizedGlobalConfig\n /** Hook operation being performed. */\n operation: 'update'\n /**\n * Whether access control is being overridden for this operation\n */\n overrideAccess?: boolean\n previousDoc: any\n req: PayloadRequest\n}) => any\n\nexport type BeforeReadHook = (args: {\n context: RequestContext\n doc: any\n /** The global which this hook is being run on */\n global: SanitizedGlobalConfig\n /**\n * Whether access control is being overridden for this operation\n */\n overrideAccess?: boolean\n req: PayloadRequest\n}) => any\n\nexport type AfterReadHook = (args: {\n context: RequestContext\n doc: any\n findMany?: boolean\n /** The global which this hook is being run on */\n global: SanitizedGlobalConfig\n /**\n * Whether access control is being overridden for this operation\n */\n overrideAccess?: boolean\n query?: Where\n req: PayloadRequest\n}) => any\n\nexport type HookOperationType = 'countVersions' | 'read' | 'restoreVersion' | 'update'\n\nexport type BeforeOperationHook = (args: {\n args?: any\n context: RequestContext\n /**\n * The Global which this hook is being run on\n * */\n global: SanitizedGlobalConfig\n /**\n * Hook operation being performed\n */\n operation: HookOperationType\n /**\n * Whether access control is being overridden for this operation\n */\n overrideAccess?: boolean\n req: PayloadRequest\n}) => any\n\nexport type GlobalAdminOptions = {\n /**\n * Custom admin components\n */\n components?: SharedAdminComponents\n /** Extension point to add your custom data. Available in server and client. */\n custom?: GlobalAdminCustom\n /**\n * Custom description for collection\n */\n description?: EntityDescription\n /**\n * Specify a navigational group for globals in the admin sidebar.\n * - Provide a string to place the entity in a custom group.\n * - Provide a record to define localized group names.\n * - Set to `false` to exclude the global from the sidebar, command palette, and dashboard collection cards.\n * This does not disable routes or change access control.\n */\n group?: false | Record<string, string> | string\n /**\n * Exclude the global from the admin nav and routes\n */\n hidden?: ((args: { user: PayloadRequest['user'] }) => boolean) | boolean\n /**\n * Live preview options\n */\n livePreview?: LivePreviewConfig\n meta?: MetaConfig\n /**\n * Function to generate custom preview URL\n */\n preview?: GeneratePreviewURL\n}\n\ntype GlobalHooks = {\n afterChange?: AfterChangeHook[]\n afterRead?: AfterReadHook[]\n beforeChange?: BeforeChangeHook[]\n beforeOperation?: BeforeOperationHook[]\n beforeRead?: BeforeReadHook[]\n beforeValidate?: BeforeValidateHook[]\n}\n\nexport type GlobalConfig<TSlug extends GlobalSlug = any> = {\n /**\n * Do not set this property manually. This is set to true during sanitization, to avoid\n * sanitizing the same global multiple times.\n */\n _sanitized?: boolean\n access?: GlobalAccess\n admin?: GlobalAdminOptions\n /**\n * Automatically track the user that created and last updated this global via\n * polymorphic `createdBy` / `updatedBy` relationship fields to your auth collections.\n *\n * Use `true` (default) to enable both, `false` to disable both, or an object to\n * toggle each field independently, e.g. `{ updatedBy: false }`.\n *\n * @default true\n */\n authorship?: Authorship | boolean\n /** Extension point to add your custom data. Server only. */\n custom?: GlobalCustom\n /**\n * Customize the SQL table name\n */\n dbName?: DBIdentifierName\n endpoints?: false | Omit<Endpoint, 'root'>[]\n fields: Field[]\n graphQL?:\n | {\n disableMutations?: true\n disableQueries?: true\n name?: string\n }\n | false\n hooks?: GlobalHooks\n label?: LabelFunction | StaticLabel\n /** Read-only Markdown instructions included in this global's MCP and CLI schema responses. */\n llmInstructions?: string\n /**\n * Enables / Disables the ability to lock documents while editing\n * @default true\n */\n lockDocuments?:\n | {\n duration: number\n }\n | false\n slug: string\n /**\n * Options used in typescript generation\n */\n typescript?: {\n /**\n * Typescript generation name given to the interface type\n */\n interface?: string\n }\n versions?: boolean | IncomingGlobalVersions\n} & Pick<\n WithSelectFn<\n IsAny<SelectFromGlobalSlug<TSlug>> extends true\n ? SelectIncludeType\n : SelectFromGlobalSlug<TSlug>\n >,\n 'select'\n>\n\nexport interface SanitizedGlobalConfig\n extends\n Omit<\n GlobalConfig,\n | '_sanitized'\n | 'access'\n | 'admin'\n | 'authorship'\n | 'custom'\n | 'endpoints'\n | 'hooks'\n | 'label'\n | 'slug'\n | 'versions'\n >,\n Required<Pick<GlobalConfig, 'admin' | 'custom' | 'label'>> {\n _sanitized: true\n access: Required<Pick<GlobalAccess, 'read' | 'readVersions' | 'update' | 'validate'>>\n authorship: SanitizedAuthorship\n endpoints: Endpoint[] | false\n /**\n * Fields in the database schema structure\n * Rows / collapsible / tabs w/o name `fields` merged to top, UIs are excluded\n */\n flattenedFields: FlattenedField[]\n hooks: Required<GlobalHooks>\n slug: GlobalSlug\n versions?: SanitizedGlobalVersions\n}\n\nexport type Globals = {\n config: SanitizedGlobalConfig[]\n graphQL?:\n | {\n [slug: string]: {\n mutationInputType: GraphQLNonNull<any>\n type: GraphQLObjectType\n versionType?: GraphQLObjectType\n }\n }\n | false\n}\n"],"names":[],"mappings":"AAAA,qDAAqD,GAiUrD,WAWC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/globals/operations/local/findOne.ts"],"sourcesContent":["import type { FindOptions } from '../../../collections/operations/local/find.js'\nimport type {\n GlobalSlug,\n Payload,\n RequestContext,\n TypedFallbackLocale,\n TypedLocale,\n User,\n} from '../../../index.js'\nimport type {\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformGlobalWithSelect,\n} from '../../../types/index.js'\nimport type { SharedLocalAPIOptions } from '../../../types/operations.js'\nimport type { CreatePayloadRequestArgs } from '../../../utilities/createPayloadRequest.js'\nimport type { DraftFlagFromGlobalSlug, SelectFromGlobalSlug } from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createPayloadRequest } from '../../../utilities/createPayloadRequest.js'\nimport { findOneOperation, type GlobalFindOneArgs } from '../findOne.js'\n\ntype BaseFindOneOptions<TSlug extends GlobalSlug, TSelect extends SelectType> = {\n /**\n * [Context](https://payloadcms.com/docs/hooks/context), which will then be passed to `context` and `req.context`,\n * which can be read by hooks. Useful if you want to pass additional information to the hooks which\n * shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook\n * to determine if it should run or not.\n */\n context?: RequestContext\n /**\n * You may pass the document data directly which will skip the `db.findOne` database query.\n * This is useful if you want to use this endpoint solely for running hooks and populating data.\n */\n data?: Record<string, unknown>\n /**\n * [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.\n */\n depth?: number\n /**\n * When set to `true`, errors will not be thrown.\n */\n disableErrors?: boolean\n /**\n * Whether the document should be queried from the versions table/collection or not. [More](https://payloadcms.com/docs/versions/drafts#draft-api)\n */\n draft?: boolean\n /**\n * Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.\n */\n fallbackLocale?: TypedFallbackLocale\n /**\n * Include info about the lock status to the result with fields: `_isLocked` and `_userEditing`\n */\n includeLockStatus?: boolean\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: 'all' | TypedLocale\n /**\n * Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.\n */\n populate?: PopulateType\n /**\n * The `PayloadRequest` object. You can pass it to thread the current [transaction](https://payloadcms.com/docs/database/transactions), user and locale to the operation.\n * Recommended to pass when using the Local API from hooks, as usually you want to execute the operation within the current transaction.\n */\n req?: Partial<PayloadRequest>\n /**\n * Opt-in to receiving hidden fields. By default, they are hidden from returned documents in accordance to your config.\n * @default false\n */\n showHiddenFields?: boolean\n /**\n * the Global slug to operate against.\n */\n slug: TSlug\n /**\n * If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.\n */\n user?: null | User\n} & Pick<FindOptions<string, SelectType>, 'select'> &\n Pick<GlobalFindOneArgs, 'flattenLocales'> &\n Pick<SharedLocalAPIOptions, 'overrideAccess'>\n\nexport type Options<TSlug extends GlobalSlug, TSelect extends SelectType> = BaseFindOneOptions<\n TSlug,\n TSelect\n> &\n DraftFlagFromGlobalSlug<TSlug>\n\nexport async function findOneGlobalLocal<\n TSlug extends GlobalSlug,\n TSelect extends SelectFromGlobalSlug<TSlug>,\n>(\n payload: Payload,\n options: Options<TSlug, TSelect>,\n): Promise<TransformGlobalWithSelect<TSlug, TSelect>> {\n const {\n slug: globalSlug,\n data,\n depth,\n disableErrors,\n draft = false,\n flattenLocales,\n includeLockStatus,\n overrideAccess = false,\n populate,\n select,\n showHiddenFields,\n } = options\n\n const globalConfig = payload.globals.config.find((config) => config.slug === globalSlug)\n\n if (!globalConfig) {\n throw new APIError(`The global with slug ${String(globalSlug)} can't be found.`)\n }\n\n return findOneOperation({\n slug: globalSlug
|
|
1
|
+
{"version":3,"sources":["../../../../src/globals/operations/local/findOne.ts"],"sourcesContent":["import type { FindOptions } from '../../../collections/operations/local/find.js'\nimport type {\n GlobalSlug,\n Payload,\n RequestContext,\n TypedFallbackLocale,\n TypedLocale,\n User,\n} from '../../../index.js'\nimport type {\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformGlobalWithSelect,\n} from '../../../types/index.js'\nimport type { SharedLocalAPIOptions } from '../../../types/operations.js'\nimport type { CreatePayloadRequestArgs } from '../../../utilities/createPayloadRequest.js'\nimport type { DraftFlagFromGlobalSlug, SelectFromGlobalSlug } from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createPayloadRequest } from '../../../utilities/createPayloadRequest.js'\nimport { findOneOperation, type GlobalFindOneArgs } from '../findOne.js'\n\ntype BaseFindOneOptions<TSlug extends GlobalSlug, TSelect extends SelectType> = {\n /**\n * [Context](https://payloadcms.com/docs/hooks/context), which will then be passed to `context` and `req.context`,\n * which can be read by hooks. Useful if you want to pass additional information to the hooks which\n * shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook\n * to determine if it should run or not.\n */\n context?: RequestContext\n /**\n * You may pass the document data directly which will skip the `db.findOne` database query.\n * This is useful if you want to use this endpoint solely for running hooks and populating data.\n */\n data?: Record<string, unknown>\n /**\n * [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.\n */\n depth?: number\n /**\n * When set to `true`, errors will not be thrown.\n */\n disableErrors?: boolean\n /**\n * Whether the document should be queried from the versions table/collection or not. [More](https://payloadcms.com/docs/versions/drafts#draft-api)\n */\n draft?: boolean\n /**\n * Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.\n */\n fallbackLocale?: TypedFallbackLocale\n /**\n * Include info about the lock status to the result with fields: `_isLocked` and `_userEditing`\n */\n includeLockStatus?: boolean\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: 'all' | TypedLocale\n /**\n * Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.\n */\n populate?: PopulateType\n /**\n * The `PayloadRequest` object. You can pass it to thread the current [transaction](https://payloadcms.com/docs/database/transactions), user and locale to the operation.\n * Recommended to pass when using the Local API from hooks, as usually you want to execute the operation within the current transaction.\n */\n req?: Partial<PayloadRequest>\n /**\n * Opt-in to receiving hidden fields. By default, they are hidden from returned documents in accordance to your config.\n * @default false\n */\n showHiddenFields?: boolean\n /**\n * the Global slug to operate against.\n */\n slug: TSlug\n /**\n * If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.\n */\n user?: null | User\n} & Pick<FindOptions<string, SelectType>, 'select'> &\n Pick<GlobalFindOneArgs, 'flattenLocales'> &\n Pick<SharedLocalAPIOptions, 'overrideAccess'>\n\nexport type Options<TSlug extends GlobalSlug, TSelect extends SelectType> = BaseFindOneOptions<\n TSlug,\n TSelect\n> &\n DraftFlagFromGlobalSlug<TSlug>\n\nexport async function findOneGlobalLocal<\n TSlug extends GlobalSlug,\n TSelect extends SelectFromGlobalSlug<TSlug>,\n>(\n payload: Payload,\n options: Options<TSlug, TSelect>,\n): Promise<TransformGlobalWithSelect<TSlug, TSelect>> {\n const {\n slug: globalSlug,\n data,\n depth,\n disableErrors,\n draft = false,\n flattenLocales,\n includeLockStatus,\n overrideAccess = false,\n populate,\n select,\n showHiddenFields,\n } = options\n\n const globalConfig = payload.globals.config.find((config) => config.slug === globalSlug)\n\n if (!globalConfig) {\n throw new APIError(`The global with slug ${String(globalSlug)} can't be found.`)\n }\n\n return findOneOperation({\n slug: globalSlug,\n data,\n depth,\n disableErrors,\n draft,\n flattenLocales,\n globalConfig,\n includeLockStatus,\n overrideAccess,\n populate,\n req: await createPayloadRequest({\n ...(options as Omit<CreatePayloadRequestArgs, 'payload'>),\n payload,\n }),\n select,\n showHiddenFields,\n })\n}\n"],"names":["APIError","createPayloadRequest","findOneOperation","findOneGlobalLocal","payload","options","slug","globalSlug","data","depth","disableErrors","draft","flattenLocales","includeLockStatus","overrideAccess","populate","select","showHiddenFields","globalConfig","globals","config","find","String","req"],"mappings":"AAmBA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,oBAAoB,QAAQ,6CAA4C;AACjF,SAASC,gBAAgB,QAAgC,gBAAe;AAuExE,OAAO,eAAeC,mBAIpBC,OAAgB,EAChBC,OAAgC;IAEhC,MAAM,EACJC,MAAMC,UAAU,EAChBC,IAAI,EACJC,KAAK,EACLC,aAAa,EACbC,QAAQ,KAAK,EACbC,cAAc,EACdC,iBAAiB,EACjBC,iBAAiB,KAAK,EACtBC,QAAQ,EACRC,MAAM,EACNC,gBAAgB,EACjB,GAAGZ;IAEJ,MAAMa,eAAed,QAAQe,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAACD,SAAWA,OAAOd,IAAI,KAAKC;IAE7E,IAAI,CAACW,cAAc;QACjB,MAAM,IAAIlB,SAAS,CAAC,qBAAqB,EAAEsB,OAAOf,YAAY,gBAAgB,CAAC;IACjF;IAEA,OAAOL,iBAAiB;QACtBI,MAAMC;QACNC;QACAC;QACAC;QACAC;QACAC;QACAM;QACAL;QACAC;QACAC;QACAQ,KAAK,MAAMtB,qBAAqB;YAC9B,GAAII,OAAO;YACXD;QACF;QACAY;QACAC;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/globals/operations/local/update.ts"],"sourcesContent":["import type { DeepPartial } from 'ts-essentials'\n\nimport type {\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformGlobalWithSelect,\n} from '../../../types/index.js'\nimport type { SharedLocalAPIOptions } from '../../../types/operations.js'\nimport type { CreatePayloadRequestArgs } from '../../../utilities/createPayloadRequest.js'\nimport type {\n DataFromGlobalSlug,\n DraftFlagFromGlobalSlug,\n SelectFromGlobalSlug,\n} from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport {\n deepCopyObjectSimple,\n type FindOptions,\n type GlobalSlug,\n type Payload,\n type RequestContext,\n type TypedLocale,\n type User,\n} from '../../../index.js'\nimport { createPayloadRequest } from '../../../utilities/createPayloadRequest.js'\nimport { updateOperation } from '../update.js'\n\ntype BaseOptions<TSlug extends GlobalSlug, TSelect extends SelectType> = {\n /**\n * [Context](https://payloadcms.com/docs/hooks/context), which will then be passed to `context` and `req.context`,\n * which can be read by hooks. Useful if you want to pass additional information to the hooks which\n * shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook\n * to determine if it should run or not.\n */\n context?: RequestContext\n /**\n * The global data to update.\n */\n data: DeepPartial<Omit<DataFromGlobalSlug<TSlug>, 'id'>>\n /**\n * [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.\n */\n depth?: number\n /**\n * Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.\n */\n fallbackLocale?: false | TypedLocale\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: 'all' | TypedLocale\n /**\n * If you are uploading a file and would like to replace\n * the existing file instead of generating a new filename,\n * you can set the following property to `true`\n */\n overrideLock?: boolean\n /**\n * Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.\n */\n populate?: PopulateType\n /**\n * Publish the document / documents in all locales. Only applies when localization is enabled\n * and the global has localized fields.\n *\n * @default undefined\n */\n publishAllLocales?: boolean\n /**\n * The `PayloadRequest` object. You can pass it to thread the current [transaction](https://payloadcms.com/docs/database/transactions), user and locale to the operation.\n * Recommended to pass when using the Local API from hooks, as usually you want to execute the operation within the current transaction.\n */\n req?: Partial<PayloadRequest>\n /**\n * Opt-in to receiving hidden fields. By default, they are hidden from returned documents in accordance to your config.\n * @default false\n */\n showHiddenFields?: boolean\n /**\n * the Global slug to operate against.\n */\n slug: TSlug\n /**\n * Unpublish the document / documents in all locales. Only applies when localization is enabled\n * and the global has localized fields.\n */\n unpublishAllLocales?: boolean\n /**\n * If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.\n */\n user?: null | User\n} & Pick<FindOptions<string, SelectType>, 'select'> &\n Pick<SharedLocalAPIOptions, 'overrideAccess'>\n\nexport type Options<TSlug extends GlobalSlug, TSelect extends SelectType> = BaseOptions<\n TSlug,\n TSelect\n> &\n DraftFlagFromGlobalSlug<TSlug>\n\nexport async function updateGlobalLocal<\n TSlug extends GlobalSlug,\n TSelect extends SelectFromGlobalSlug<TSlug>,\n>(\n payload: Payload,\n options: Options<TSlug, TSelect>,\n): Promise<TransformGlobalWithSelect<TSlug, TSelect>> {\n const {\n slug: globalSlug,\n data,\n depth,\n draft,\n overrideAccess = false,\n overrideLock,\n populate,\n publishAllLocales,\n select,\n showHiddenFields,\n unpublishAllLocales,\n } = options\n\n const globalConfig = payload.globals.config.find((config) => config.slug === globalSlug)\n\n if (!globalConfig) {\n throw new APIError(`The global with slug ${String(globalSlug)} can't be found.`)\n }\n\n return updateOperation<TSlug, TSelect>({\n slug: globalSlug
|
|
1
|
+
{"version":3,"sources":["../../../../src/globals/operations/local/update.ts"],"sourcesContent":["import type { DeepPartial } from 'ts-essentials'\n\nimport type {\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformGlobalWithSelect,\n} from '../../../types/index.js'\nimport type { SharedLocalAPIOptions } from '../../../types/operations.js'\nimport type { CreatePayloadRequestArgs } from '../../../utilities/createPayloadRequest.js'\nimport type {\n DataFromGlobalSlug,\n DraftFlagFromGlobalSlug,\n SelectFromGlobalSlug,\n} from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport {\n deepCopyObjectSimple,\n type FindOptions,\n type GlobalSlug,\n type Payload,\n type RequestContext,\n type TypedLocale,\n type User,\n} from '../../../index.js'\nimport { createPayloadRequest } from '../../../utilities/createPayloadRequest.js'\nimport { updateOperation } from '../update.js'\n\ntype BaseOptions<TSlug extends GlobalSlug, TSelect extends SelectType> = {\n /**\n * [Context](https://payloadcms.com/docs/hooks/context), which will then be passed to `context` and `req.context`,\n * which can be read by hooks. Useful if you want to pass additional information to the hooks which\n * shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook\n * to determine if it should run or not.\n */\n context?: RequestContext\n /**\n * The global data to update.\n */\n data: DeepPartial<Omit<DataFromGlobalSlug<TSlug>, 'id'>>\n /**\n * [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.\n */\n depth?: number\n /**\n * Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.\n */\n fallbackLocale?: false | TypedLocale\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: 'all' | TypedLocale\n /**\n * If you are uploading a file and would like to replace\n * the existing file instead of generating a new filename,\n * you can set the following property to `true`\n */\n overrideLock?: boolean\n /**\n * Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.\n */\n populate?: PopulateType\n /**\n * Publish the document / documents in all locales. Only applies when localization is enabled\n * and the global has localized fields.\n *\n * @default undefined\n */\n publishAllLocales?: boolean\n /**\n * The `PayloadRequest` object. You can pass it to thread the current [transaction](https://payloadcms.com/docs/database/transactions), user and locale to the operation.\n * Recommended to pass when using the Local API from hooks, as usually you want to execute the operation within the current transaction.\n */\n req?: Partial<PayloadRequest>\n /**\n * Opt-in to receiving hidden fields. By default, they are hidden from returned documents in accordance to your config.\n * @default false\n */\n showHiddenFields?: boolean\n /**\n * the Global slug to operate against.\n */\n slug: TSlug\n /**\n * Unpublish the document / documents in all locales. Only applies when localization is enabled\n * and the global has localized fields.\n */\n unpublishAllLocales?: boolean\n /**\n * If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.\n */\n user?: null | User\n} & Pick<FindOptions<string, SelectType>, 'select'> &\n Pick<SharedLocalAPIOptions, 'overrideAccess'>\n\nexport type Options<TSlug extends GlobalSlug, TSelect extends SelectType> = BaseOptions<\n TSlug,\n TSelect\n> &\n DraftFlagFromGlobalSlug<TSlug>\n\nexport async function updateGlobalLocal<\n TSlug extends GlobalSlug,\n TSelect extends SelectFromGlobalSlug<TSlug>,\n>(\n payload: Payload,\n options: Options<TSlug, TSelect>,\n): Promise<TransformGlobalWithSelect<TSlug, TSelect>> {\n const {\n slug: globalSlug,\n data,\n depth,\n draft,\n overrideAccess = false,\n overrideLock,\n populate,\n publishAllLocales,\n select,\n showHiddenFields,\n unpublishAllLocales,\n } = options\n\n const globalConfig = payload.globals.config.find((config) => config.slug === globalSlug)\n\n if (!globalConfig) {\n throw new APIError(`The global with slug ${String(globalSlug)} can't be found.`)\n }\n\n return updateOperation<TSlug, TSelect>({\n slug: globalSlug,\n data: deepCopyObjectSimple(data), // Ensure mutation of data in create operation hooks doesn't affect the original data\n depth,\n draft,\n globalConfig,\n overrideAccess,\n overrideLock,\n populate,\n publishAllLocales,\n req: await createPayloadRequest({\n ...(options as Omit<CreatePayloadRequestArgs, 'payload'>),\n payload,\n }),\n select,\n showHiddenFields,\n unpublishAllLocales,\n })\n}\n"],"names":["APIError","deepCopyObjectSimple","createPayloadRequest","updateOperation","updateGlobalLocal","payload","options","slug","globalSlug","data","depth","draft","overrideAccess","overrideLock","populate","publishAllLocales","select","showHiddenFields","unpublishAllLocales","globalConfig","globals","config","find","String","req"],"mappings":"AAgBA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SACEC,oBAAoB,QAOf,oBAAmB;AAC1B,SAASC,oBAAoB,QAAQ,6CAA4C;AACjF,SAASC,eAAe,QAAQ,eAAc;AA2E9C,OAAO,eAAeC,kBAIpBC,OAAgB,EAChBC,OAAgC;IAEhC,MAAM,EACJC,MAAMC,UAAU,EAChBC,IAAI,EACJC,KAAK,EACLC,KAAK,EACLC,iBAAiB,KAAK,EACtBC,YAAY,EACZC,QAAQ,EACRC,iBAAiB,EACjBC,MAAM,EACNC,gBAAgB,EAChBC,mBAAmB,EACpB,GAAGZ;IAEJ,MAAMa,eAAed,QAAQe,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAACD,SAAWA,OAAOd,IAAI,KAAKC;IAE7E,IAAI,CAACW,cAAc;QACjB,MAAM,IAAInB,SAAS,CAAC,qBAAqB,EAAEuB,OAAOf,YAAY,gBAAgB,CAAC;IACjF;IAEA,OAAOL,gBAAgC;QACrCI,MAAMC;QACNC,MAAMR,qBAAqBQ;QAC3BC;QACAC;QACAQ;QACAP;QACAC;QACAC;QACAC;QACAS,KAAK,MAAMtB,qBAAqB;YAC9B,GAAII,OAAO;YACXD;QACF;QACAW;QACAC;QACAC;IACF;AACF"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { PayloadRequest, PopulateType } from '../../types/index.js';
|
|
2
|
-
import type { TypeWithVersion } from '../../versions/types.js';
|
|
1
|
+
import type { JsonObject, PayloadRequest, PopulateType } from '../../types/index.js';
|
|
3
2
|
import type { SanitizedGlobalConfig } from '../config/types.js';
|
|
4
3
|
export type Arguments = {
|
|
5
4
|
depth?: number;
|
|
@@ -11,5 +10,5 @@ export type Arguments = {
|
|
|
11
10
|
req?: PayloadRequest;
|
|
12
11
|
showHiddenFields?: boolean;
|
|
13
12
|
};
|
|
14
|
-
export declare const restoreVersionOperation: <T extends
|
|
13
|
+
export declare const restoreVersionOperation: <T extends JsonObject = any>(args: Arguments) => Promise<T>;
|
|
15
14
|
//# sourceMappingURL=restoreVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restoreVersion.d.ts","sourceRoot":"","sources":["../../../src/globals/operations/restoreVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAS,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"restoreVersion.d.ts","sourceRoot":"","sources":["../../../src/globals/operations/restoreVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,EAAS,MAAM,sBAAsB,CAAA;AAC3F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAiB/D,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,YAAY,EAAE,qBAAqB,CAAA;IACnC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,GAAG,CAAC,EAAE,cAAc,CAAA;IACpB,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,CAAA;AAED,eAAO,MAAM,uBAAuB,GAAU,CAAC,SAAS,UAAU,GAAG,GAAG,QAChE,SAAS,KACd,OAAO,CAAC,CAAC,CAoPX,CAAA"}
|
|
@@ -11,6 +11,7 @@ import { initTransaction } from '../../utilities/initTransaction.js';
|
|
|
11
11
|
import { killTransaction } from '../../utilities/killTransaction.js';
|
|
12
12
|
import { buildVersionGlobalFields } from '../../versions/buildGlobalFields.js';
|
|
13
13
|
import { getRestoredStatusesToAuthorize } from '../../versions/getRestoredStatusesToAuthorize.js';
|
|
14
|
+
import { saveVersion } from '../../versions/saveVersion.js';
|
|
14
15
|
export const restoreVersionOperation = async (args)=>{
|
|
15
16
|
assertNoValidationWrite(args.req);
|
|
16
17
|
const { id, depth, draft, globalConfig, overrideAccess, populate, showHiddenFields } = args;
|
|
@@ -122,23 +123,16 @@ export const restoreVersionOperation = async (args)=>{
|
|
|
122
123
|
req
|
|
123
124
|
});
|
|
124
125
|
let result = rawVersion.version;
|
|
125
|
-
if (global) {
|
|
126
|
+
if (global || draft) {
|
|
126
127
|
// Ensure updatedAt date is always updated
|
|
127
128
|
result.updatedAt = new Date().toISOString();
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
autosave: false,
|
|
136
|
-
createdAt: result.createdAt ? new Date(result.createdAt).toISOString() : now,
|
|
137
|
-
globalSlug: globalConfig.slug,
|
|
138
|
-
req,
|
|
139
|
-
updatedAt: draft ? now : new Date(result.updatedAt).toISOString(),
|
|
140
|
-
versionData: result
|
|
141
|
-
});
|
|
129
|
+
if (!draft) {
|
|
130
|
+
result = await payload.db.updateGlobal({
|
|
131
|
+
slug: globalConfig.slug,
|
|
132
|
+
data: result,
|
|
133
|
+
req
|
|
134
|
+
});
|
|
135
|
+
}
|
|
142
136
|
} else {
|
|
143
137
|
result = await payload.db.createGlobal({
|
|
144
138
|
slug: globalConfig.slug,
|
|
@@ -146,6 +140,19 @@ export const restoreVersionOperation = async (args)=>{
|
|
|
146
140
|
req
|
|
147
141
|
});
|
|
148
142
|
}
|
|
143
|
+
result = await saveVersion({
|
|
144
|
+
autosave: false,
|
|
145
|
+
docWithLocales: result,
|
|
146
|
+
draft,
|
|
147
|
+
global: globalConfig,
|
|
148
|
+
operation: 'restoreVersion',
|
|
149
|
+
payload,
|
|
150
|
+
req
|
|
151
|
+
});
|
|
152
|
+
result = {
|
|
153
|
+
...result,
|
|
154
|
+
globalType: globalConfig.slug
|
|
155
|
+
};
|
|
149
156
|
// /////////////////////////////////////
|
|
150
157
|
// afterRead - Fields
|
|
151
158
|
// /////////////////////////////////////
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/globals/operations/restoreVersion.ts"],"sourcesContent":["import type { PayloadRequest, PopulateType, Where } from '../../types/index.js'\nimport type { TypeWithVersion } from '../../versions/types.js'\nimport type { SanitizedGlobalConfig } from '../config/types.js'\n\nimport { executeAccess } from '../../auth/executeAccess.js'\nimport { hasWhereAccessResult } from '../../auth/types.js'\nimport { combineQueries } from '../../database/combineQueries.js'\nimport { sanitizeWhereQuery } from '../../database/sanitizeWhereQuery.js'\nimport { Forbidden, NotFound } from '../../errors/index.js'\nimport { afterChange } from '../../fields/hooks/afterChange/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { assertNoValidationWrite } from '../../utilities/assertNoValidationWrite.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { buildVersionGlobalFields } from '../../versions/buildGlobalFields.js'\nimport { getRestoredStatusesToAuthorize } from '../../versions/getRestoredStatusesToAuthorize.js'\n\nexport type Arguments = {\n depth?: number\n draft?: boolean\n globalConfig: SanitizedGlobalConfig\n id: number | string\n overrideAccess?: boolean\n populate?: PopulateType\n req?: PayloadRequest\n showHiddenFields?: boolean\n}\n\nexport const restoreVersionOperation = async <T extends TypeWithVersion<T> = any>(\n args: Arguments,\n): Promise<T> => {\n assertNoValidationWrite(args.req)\n\n const { id, depth, draft, globalConfig, overrideAccess, populate, showHiddenFields } = args\n const req = args.req!\n const { fallbackLocale, locale, payload } = req\n\n try {\n const shouldCommit = await initTransaction(req)\n\n // /////////////////////////////////////\n // beforeOperation - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.beforeOperation?.length) {\n for (const hook of globalConfig.hooks.beforeOperation) {\n args =\n (await hook({\n args,\n context: req.context,\n global: globalConfig,\n operation: 'restoreVersion',\n overrideAccess,\n req,\n })) || args\n }\n }\n\n // /////////////////////////////////////\n // Retrieve original raw version\n // /////////////////////////////////////\n\n // The selected version must satisfy read-version access.\n const readVersionsAccessResult = overrideAccess\n ? true\n : await executeAccess({ slug: globalConfig.slug, req }, globalConfig.access.readVersions)\n\n const versionFields = buildVersionGlobalFields(payload.config, globalConfig, true)\n const where = combineQueries({ id: { equals: id } }, readVersionsAccessResult)\n\n sanitizeWhereQuery({ fields: versionFields, payload, where })\n\n const { docs: versionDocs } = await payload.db.findGlobalVersions<any>({\n global: globalConfig.slug,\n limit: 1,\n req,\n where,\n })\n\n if (!versionDocs || versionDocs.length === 0) {\n if (hasWhereAccessResult(readVersionsAccessResult)) {\n throw new Forbidden(req.t)\n }\n throw new NotFound(req.t)\n }\n\n const rawVersion = versionDocs[0]!\n\n // Patch globalType onto version doc\n rawVersion.version.globalType = globalConfig.slug\n\n // Overwrite draft status if draft is true\n if (draft) {\n rawVersion.version._status = 'draft'\n }\n\n // A localized `_status` can publish and unpublish locales in one restore, so authorize every\n // status it writes. executeAccess throws Forbidden on the first denial.\n const restoredStatuses = getRestoredStatusesToAuthorize(rawVersion.version._status)\n\n const updateAccessResults: Array<boolean | Where> = []\n\n if (overrideAccess) {\n updateAccessResults.push(true)\n } else {\n const statusesToAuthorize = restoredStatuses.length > 0 ? restoredStatuses : [undefined]\n\n for (const status of statusesToAuthorize) {\n updateAccessResults.push(\n await executeAccess(\n {\n slug: globalConfig.slug,\n data: { _status: status },\n req,\n },\n globalConfig.access.update,\n ),\n )\n }\n }\n\n // /////////////////////////////////////\n // fetch previousDoc\n // /////////////////////////////////////\n\n const previousDoc = await payload.findGlobal({\n slug: globalConfig.slug,\n depth,\n overrideAccess: true,\n req,\n })\n\n req.context.isRestoringVersion = true\n\n // /////////////////////////////////////\n // Update global\n // /////////////////////////////////////\n\n for (const updateAccessResult of updateAccessResults) {\n if (!hasWhereAccessResult(updateAccessResult)) {\n continue\n }\n\n const constrainedGlobal = await payload.db.findGlobal({\n slug: globalConfig.slug,\n req,\n where: updateAccessResult,\n })\n\n if (!constrainedGlobal || Object.keys(constrainedGlobal).length === 0) {\n throw new Forbidden(req.t)\n }\n }\n\n const global = await payload.db.findGlobal({\n slug: globalConfig.slug,\n req,\n })\n\n let result = rawVersion.version\n\n if (global) {\n // Ensure updatedAt date is always updated\n result.updatedAt = new Date().toISOString()\n result = await payload.db.updateGlobal({\n slug: globalConfig.slug,\n data: result,\n req,\n })\n\n const now = new Date().toISOString()\n\n result = await payload.db.createGlobalVersion({\n autosave: false,\n createdAt: result.createdAt ? new Date(result.createdAt).toISOString() : now,\n globalSlug: globalConfig.slug,\n req,\n updatedAt: draft ? now : new Date(result.updatedAt).toISOString(),\n versionData: result,\n })\n } else {\n result = await payload.db.createGlobal({\n slug: globalConfig.slug,\n data: result,\n req,\n })\n }\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n result = await afterRead({\n collection: null,\n context: req.context,\n depth: depth!,\n doc: result,\n draft: undefined!,\n fallbackLocale: fallbackLocale!,\n global: globalConfig,\n locale: locale!,\n overrideAccess: overrideAccess!,\n populate,\n req,\n showHiddenFields: showHiddenFields!,\n })\n\n // /////////////////////////////////////\n // afterRead - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.afterRead?.length) {\n for (const hook of globalConfig.hooks.afterRead) {\n result =\n (await hook({\n context: req.context,\n doc: result,\n global: globalConfig,\n overrideAccess,\n req,\n })) || result\n }\n }\n\n // /////////////////////////////////////\n // afterChange - Fields\n // /////////////////////////////////////\n\n result = await afterChange({\n collection: null,\n context: req.context,\n data: result,\n doc: result,\n global: globalConfig,\n operation: 'update',\n previousDoc,\n req,\n })\n\n // /////////////////////////////////////\n // afterChange - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.afterChange?.length) {\n for (const hook of globalConfig.hooks.afterChange) {\n result =\n (await hook({\n context: req.context,\n data: result,\n doc: result,\n global: globalConfig,\n operation: 'update',\n overrideAccess,\n previousDoc,\n req,\n })) || result\n }\n }\n\n if (shouldCommit) {\n await commitTransaction(req)\n }\n\n return result\n } catch (error: unknown) {\n await killTransaction(req)\n throw error\n }\n}\n"],"names":["executeAccess","hasWhereAccessResult","combineQueries","sanitizeWhereQuery","Forbidden","NotFound","afterChange","afterRead","assertNoValidationWrite","commitTransaction","initTransaction","killTransaction","buildVersionGlobalFields","getRestoredStatusesToAuthorize","restoreVersionOperation","args","req","id","depth","draft","globalConfig","overrideAccess","populate","showHiddenFields","fallbackLocale","locale","payload","shouldCommit","hooks","beforeOperation","length","hook","context","global","operation","readVersionsAccessResult","slug","access","readVersions","versionFields","config","where","equals","fields","docs","versionDocs","db","findGlobalVersions","limit","t","rawVersion","version","globalType","_status","restoredStatuses","updateAccessResults","push","statusesToAuthorize","undefined","status","data","update","previousDoc","findGlobal","isRestoringVersion","updateAccessResult","constrainedGlobal","Object","keys","result","updatedAt","Date","toISOString","updateGlobal","now","createGlobalVersion","autosave","createdAt","globalSlug","versionData","createGlobal","collection","doc","error"],"mappings":"AAIA,SAASA,aAAa,QAAQ,8BAA6B;AAC3D,SAASC,oBAAoB,QAAQ,sBAAqB;AAC1D,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,kBAAkB,QAAQ,uCAAsC;AACzE,SAASC,SAAS,EAAEC,QAAQ,QAAQ,wBAAuB;AAC3D,SAASC,WAAW,QAAQ,0CAAyC;AACrE,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,uBAAuB,QAAQ,6CAA4C;AACpF,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,wBAAwB,QAAQ,sCAAqC;AAC9E,SAASC,8BAA8B,QAAQ,mDAAkD;AAajG,OAAO,MAAMC,0BAA0B,OACrCC;IAEAP,wBAAwBO,KAAKC,GAAG;IAEhC,MAAM,EAAEC,EAAE,EAAEC,KAAK,EAAEC,KAAK,EAAEC,YAAY,E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,SACE,AAAC,MAAMtC,KAAK;oBACVC,SAAShB,IAAIgB,OAAO;oBACpBkD,KAAKb;oBACLpC,QAAQb;oBACRC;oBACAL;gBACF,MAAOqD;YACX;QACF;QAEA,wCAAwC;QACxC,uBAAuB;QACvB,wCAAwC;QAExCA,SAAS,MAAM/D,YAAY;YACzB2E,YAAY;YACZjD,SAAShB,IAAIgB,OAAO;YACpB4B,MAAMS;YACNa,KAAKb;YACLpC,QAAQb;YACRc,WAAW;YACX4B;YACA9C;QACF;QAEA,wCAAwC;QACxC,uBAAuB;QACvB,wCAAwC;QAExC,IAAII,aAAaQ,KAAK,EAAEtB,aAAawB,QAAQ;YAC3C,KAAK,MAAMC,QAAQX,aAAaQ,KAAK,CAACtB,WAAW,CAAE;gBACjD+D,SACE,AAAC,MAAMtC,KAAK;oBACVC,SAAShB,IAAIgB,OAAO;oBACpB4B,MAAMS;oBACNa,KAAKb;oBACLpC,QAAQb;oBACRc,WAAW;oBACXb;oBACAyC;oBACA9C;gBACF,MAAOqD;YACX;QACF;QAEA,IAAI1C,cAAc;YAChB,MAAMlB,kBAAkBO;QAC1B;QAEA,OAAOqD;IACT,EAAE,OAAOc,OAAgB;QACvB,MAAMxE,gBAAgBK;QACtB,MAAMmE;IACR;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/globals/operations/restoreVersion.ts"],"sourcesContent":["import type { JsonObject, PayloadRequest, PopulateType, Where } from '../../types/index.js'\nimport type { SanitizedGlobalConfig } from '../config/types.js'\n\nimport { executeAccess } from '../../auth/executeAccess.js'\nimport { hasWhereAccessResult } from '../../auth/types.js'\nimport { combineQueries } from '../../database/combineQueries.js'\nimport { sanitizeWhereQuery } from '../../database/sanitizeWhereQuery.js'\nimport { Forbidden, NotFound } from '../../errors/index.js'\nimport { afterChange } from '../../fields/hooks/afterChange/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { assertNoValidationWrite } from '../../utilities/assertNoValidationWrite.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { buildVersionGlobalFields } from '../../versions/buildGlobalFields.js'\nimport { getRestoredStatusesToAuthorize } from '../../versions/getRestoredStatusesToAuthorize.js'\nimport { saveVersion } from '../../versions/saveVersion.js'\n\nexport type Arguments = {\n depth?: number\n draft?: boolean\n globalConfig: SanitizedGlobalConfig\n id: number | string\n overrideAccess?: boolean\n populate?: PopulateType\n req?: PayloadRequest\n showHiddenFields?: boolean\n}\n\nexport const restoreVersionOperation = async <T extends JsonObject = any>(\n args: Arguments,\n): Promise<T> => {\n assertNoValidationWrite(args.req)\n\n const { id, depth, draft, globalConfig, overrideAccess, populate, showHiddenFields } = args\n const req = args.req!\n const { fallbackLocale, locale, payload } = req\n\n try {\n const shouldCommit = await initTransaction(req)\n\n // /////////////////////////////////////\n // beforeOperation - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.beforeOperation?.length) {\n for (const hook of globalConfig.hooks.beforeOperation) {\n args =\n (await hook({\n args,\n context: req.context,\n global: globalConfig,\n operation: 'restoreVersion',\n overrideAccess,\n req,\n })) || args\n }\n }\n\n // /////////////////////////////////////\n // Retrieve original raw version\n // /////////////////////////////////////\n\n // The selected version must satisfy read-version access.\n const readVersionsAccessResult = overrideAccess\n ? true\n : await executeAccess({ slug: globalConfig.slug, req }, globalConfig.access.readVersions)\n\n const versionFields = buildVersionGlobalFields(payload.config, globalConfig, true)\n const where = combineQueries({ id: { equals: id } }, readVersionsAccessResult)\n\n sanitizeWhereQuery({ fields: versionFields, payload, where })\n\n const { docs: versionDocs } = await payload.db.findGlobalVersions<any>({\n global: globalConfig.slug,\n limit: 1,\n req,\n where,\n })\n\n if (!versionDocs || versionDocs.length === 0) {\n if (hasWhereAccessResult(readVersionsAccessResult)) {\n throw new Forbidden(req.t)\n }\n throw new NotFound(req.t)\n }\n\n const rawVersion = versionDocs[0]!\n\n // Patch globalType onto version doc\n rawVersion.version.globalType = globalConfig.slug\n\n // Overwrite draft status if draft is true\n if (draft) {\n rawVersion.version._status = 'draft'\n }\n\n // A localized `_status` can publish and unpublish locales in one restore, so authorize every\n // status it writes. executeAccess throws Forbidden on the first denial.\n const restoredStatuses = getRestoredStatusesToAuthorize(rawVersion.version._status)\n\n const updateAccessResults: Array<boolean | Where> = []\n\n if (overrideAccess) {\n updateAccessResults.push(true)\n } else {\n const statusesToAuthorize = restoredStatuses.length > 0 ? restoredStatuses : [undefined]\n\n for (const status of statusesToAuthorize) {\n updateAccessResults.push(\n await executeAccess(\n {\n slug: globalConfig.slug,\n data: { _status: status },\n req,\n },\n globalConfig.access.update,\n ),\n )\n }\n }\n\n // /////////////////////////////////////\n // fetch previousDoc\n // /////////////////////////////////////\n\n const previousDoc = await payload.findGlobal({\n slug: globalConfig.slug,\n depth,\n overrideAccess: true,\n req,\n })\n\n req.context.isRestoringVersion = true\n\n // /////////////////////////////////////\n // Update global\n // /////////////////////////////////////\n\n for (const updateAccessResult of updateAccessResults) {\n if (!hasWhereAccessResult(updateAccessResult)) {\n continue\n }\n\n const constrainedGlobal = await payload.db.findGlobal({\n slug: globalConfig.slug,\n req,\n where: updateAccessResult,\n })\n\n if (!constrainedGlobal || Object.keys(constrainedGlobal).length === 0) {\n throw new Forbidden(req.t)\n }\n }\n\n const global = await payload.db.findGlobal({\n slug: globalConfig.slug,\n req,\n })\n\n let result = rawVersion.version\n\n if (global || draft) {\n // Ensure updatedAt date is always updated\n result.updatedAt = new Date().toISOString()\n if (!draft) {\n result = await payload.db.updateGlobal({\n slug: globalConfig.slug,\n data: result,\n req,\n })\n }\n } else {\n result = await payload.db.createGlobal({\n slug: globalConfig.slug,\n data: result,\n req,\n })\n }\n\n result = await saveVersion({\n autosave: false,\n docWithLocales: result,\n draft,\n global: globalConfig,\n operation: 'restoreVersion',\n payload,\n req,\n })\n\n result = {\n ...result,\n globalType: globalConfig.slug,\n }\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n result = await afterRead({\n collection: null,\n context: req.context,\n depth: depth!,\n doc: result,\n draft: undefined!,\n fallbackLocale: fallbackLocale!,\n global: globalConfig,\n locale: locale!,\n overrideAccess: overrideAccess!,\n populate,\n req,\n showHiddenFields: showHiddenFields!,\n })\n\n // /////////////////////////////////////\n // afterRead - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.afterRead?.length) {\n for (const hook of globalConfig.hooks.afterRead) {\n result =\n (await hook({\n context: req.context,\n doc: result,\n global: globalConfig,\n overrideAccess,\n req,\n })) || result\n }\n }\n\n // /////////////////////////////////////\n // afterChange - Fields\n // /////////////////////////////////////\n\n result = await afterChange({\n collection: null,\n context: req.context,\n data: result,\n doc: result,\n global: globalConfig,\n operation: 'update',\n previousDoc,\n req,\n })\n\n // /////////////////////////////////////\n // afterChange - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.afterChange?.length) {\n for (const hook of globalConfig.hooks.afterChange) {\n result =\n (await hook({\n context: req.context,\n data: result,\n doc: result,\n global: globalConfig,\n operation: 'update',\n overrideAccess,\n previousDoc,\n req,\n })) || result\n }\n }\n\n if (shouldCommit) {\n await commitTransaction(req)\n }\n\n return result\n } catch (error: unknown) {\n await killTransaction(req)\n throw error\n }\n}\n"],"names":["executeAccess","hasWhereAccessResult","combineQueries","sanitizeWhereQuery","Forbidden","NotFound","afterChange","afterRead","assertNoValidationWrite","commitTransaction","initTransaction","killTransaction","buildVersionGlobalFields","getRestoredStatusesToAuthorize","saveVersion","restoreVersionOperation","args","req","id","depth","draft","globalConfig","overrideAccess","populate","showHiddenFields","fallbackLocale","locale","payload","shouldCommit","hooks","beforeOperation","length","hook","context","global","operation","readVersionsAccessResult","slug","access","readVersions","versionFields","config","where","equals","fields","docs","versionDocs","db","findGlobalVersions","limit","t","rawVersion","version","globalType","_status","restoredStatuses","updateAccessResults","push","statusesToAuthorize","undefined","status","data","update","previousDoc","findGlobal","isRestoringVersion","updateAccessResult","constrainedGlobal","Object","keys","result","updatedAt","Date","toISOString","updateGlobal","createGlobal","autosave","docWithLocales","collection","doc","error"],"mappings":"AAGA,SAASA,aAAa,QAAQ,8BAA6B;AAC3D,SAASC,oBAAoB,QAAQ,sBAAqB;AAC1D,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,kBAAkB,QAAQ,uCAAsC;AACzE,SAASC,SAAS,EAAEC,QAAQ,QAAQ,wBAAuB;AAC3D,SAASC,WAAW,QAAQ,0CAAyC;AACrE,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,uBAAuB,QAAQ,6CAA4C;AACpF,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,wBAAwB,QAAQ,sCAAqC;AAC9E,SAASC,8BAA8B,QAAQ,mDAAkD;AACjG,SAASC,WAAW,QAAQ,gCAA+B;AAa3D,OAAO,MAAMC,0BAA0B,OACrCC;IAEAR,wBAAwBQ,KAAKC,GAAG;IAEhC,MAAM,EAAEC,EAAE,EAAEC,KAAK,EAAEC,KAAK,EAAEC,YAAY,EAAEC,cAAc,EAAEC,QAAQ,EAAEC,gBAAgB,EAAE,GAAGR;IACvF,MAAMC,MAAMD,KAAKC,GAAG;IACpB,MAAM,EAAEQ,cAAc,EAAEC,MAAM,EAAEC,OAAO,EAAE,GAAGV;IAE5C,IAAI;QACF,MAAMW,eAAe,MAAMlB,gBAAgBO;QAE3C,wCAAwC;QACxC,2BAA2B;QAC3B,wCAAwC;QAExC,IAAII,aAAaQ,KAAK,EAAEC,iBAAiBC,QAAQ;YAC/C,KAAK,MAAMC,QAAQX,aAAaQ,KAAK,CAACC,eAAe,CAAE;gBACrDd,OACE,AAAC,MAAMgB,KAAK;oBACVhB;oBACAiB,SAAShB,IAAIgB,OAAO;oBACpBC,QAAQb;oBACRc,WAAW;oBACXb;oBACAL;gBACF,MAAOD;YACX;QACF;QAEA,wCAAwC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,MAAOqD;YACX;QACF;QAEA,IAAI1C,cAAc;YAChB,MAAMnB,kBAAkBQ;QAC1B;QAEA,OAAOqD;IACT,EAAE,OAAOU,OAAgB;QACvB,MAAMrE,gBAAgBM;QACtB,MAAM+D;IACR;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/globals/operations/validate.ts"],"sourcesContent":["import type { DeepPartial } from 'ts-essentials'\n\nimport type { TypeWithID } from '../../collections/config/types.js'\nimport type { AccessResult } from '../../config/types.js'\nimport type { GlobalSlug, JsonObject } from '../../index.js'\nimport type { PayloadRequest } from '../../types/index.js'\nimport type { ValidationResult } from '../../types/validation.js'\nimport type { ValidationSourceData } from '../../utilities/runValidationLifecycle.js'\nimport type { DataFromGlobalSlug, SanitizedGlobalConfig } from '../config/types.js'\n\nimport { executeAccess } from '../../auth/executeAccess.js'\nimport { hasWhereAccessResult } from '../../auth/types.js'\nimport { Forbidden } from '../../errors/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { deepCopyObjectSimple } from '../../utilities/deepCopyObject.js'\nimport { flattenDataByLocale } from '../../utilities/flattenDataByLocale.js'\nimport { runValidationLifecycle } from '../../utilities/runValidationLifecycle.js'\nimport {\n findDraftVersion,\n getDocumentFromDraftVersion,\n} from '../../versions/drafts/replaceWithDraftIfAvailable.js'\n\nexport type Arguments<TSlug extends GlobalSlug> = {\n data?: DeepPartial<Omit<DataFromGlobalSlug<TSlug>, 'id'>>\n draft: boolean\n globalConfig: SanitizedGlobalConfig\n onValidationData?: (data: JsonObject) => void\n overrideAccess: boolean\n req: PayloadRequest\n skipAccessControl?: boolean\n skipMutationHooks?: boolean\n slug: string\n sourceData?: ValidationSourceData\n validationOperation?: 'update' | 'validate'\n}\n\nexport async function validateOperation<TSlug extends GlobalSlug>(\n args: Arguments<TSlug>,\n): Promise<ValidationResult> {\n const previousOperation = args.req.operation\n args.req.operation = args.validationOperation ?? 'validate'\n\n try {\n return await validateOperationWithScopedRequest(args)\n } finally {\n args.req.operation = previousOperation\n }\n}\n\nasync function validateOperationWithScopedRequest<TSlug extends GlobalSlug>({\n slug,\n data: incomingData,\n draft,\n globalConfig,\n onValidationData,\n overrideAccess,\n req,\n skipAccessControl = false,\n skipMutationHooks = false,\n sourceData,\n validationOperation = 'validate',\n}: Arguments<TSlug>): Promise<ValidationResult> {\n const accessResult =\n !skipAccessControl && !overrideAccess\n ? await executeAccess({ slug, data: incomingData, req }, globalConfig.access.validate)\n : true\n const storedGlobal = sourceData\n ? sourceData.docWithLocales\n : await resolveValidationGlobalSource({\n slug,\n accessResult,\n draft,\n globalConfig,\n overrideAccess,\n req,\n })\n\n const docWithLocales: JsonObject = deepCopyObjectSimple(storedGlobal)\n\n if (docWithLocales._id) {\n delete docWithLocales._id\n }\n\n const originalDoc = sourceData\n ? req.locale === sourceData.originalLocale\n ? deepCopyObjectSimple(sourceData.originalDoc)\n : flattenDataByLocale({\n configBlockReferences: req.payload.config.blocks,\n docWithLocales,\n fields: globalConfig.fields,\n locale: req.locale!,\n })\n : await afterRead({\n collection: null,\n context: req.context,\n depth: 0,\n doc: deepCopyObjectSimple(docWithLocales),\n draft,\n fallbackLocale: req.fallbackLocale!,\n global: globalConfig,\n locale: req.locale!,\n overrideAccess: true,\n req,\n showHiddenFields: true,\n })\n\n return runValidationLifecycle({\n collection: null,\n docWithLocales,\n global: globalConfig,\n incomingData
|
|
1
|
+
{"version":3,"sources":["../../../src/globals/operations/validate.ts"],"sourcesContent":["import type { DeepPartial } from 'ts-essentials'\n\nimport type { TypeWithID } from '../../collections/config/types.js'\nimport type { AccessResult } from '../../config/types.js'\nimport type { GlobalSlug, JsonObject } from '../../index.js'\nimport type { PayloadRequest } from '../../types/index.js'\nimport type { ValidationResult } from '../../types/validation.js'\nimport type { ValidationSourceData } from '../../utilities/runValidationLifecycle.js'\nimport type { DataFromGlobalSlug, SanitizedGlobalConfig } from '../config/types.js'\n\nimport { executeAccess } from '../../auth/executeAccess.js'\nimport { hasWhereAccessResult } from '../../auth/types.js'\nimport { Forbidden } from '../../errors/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { deepCopyObjectSimple } from '../../utilities/deepCopyObject.js'\nimport { flattenDataByLocale } from '../../utilities/flattenDataByLocale.js'\nimport { runValidationLifecycle } from '../../utilities/runValidationLifecycle.js'\nimport {\n findDraftVersion,\n getDocumentFromDraftVersion,\n} from '../../versions/drafts/replaceWithDraftIfAvailable.js'\n\nexport type Arguments<TSlug extends GlobalSlug> = {\n data?: DeepPartial<Omit<DataFromGlobalSlug<TSlug>, 'id'>>\n draft: boolean\n globalConfig: SanitizedGlobalConfig\n onValidationData?: (data: JsonObject) => void\n overrideAccess: boolean\n req: PayloadRequest\n skipAccessControl?: boolean\n skipMutationHooks?: boolean\n slug: string\n sourceData?: ValidationSourceData\n validationOperation?: 'update' | 'validate'\n}\n\nexport async function validateOperation<TSlug extends GlobalSlug>(\n args: Arguments<TSlug>,\n): Promise<ValidationResult> {\n const previousOperation = args.req.operation\n args.req.operation = args.validationOperation ?? 'validate'\n\n try {\n return await validateOperationWithScopedRequest(args)\n } finally {\n args.req.operation = previousOperation\n }\n}\n\nasync function validateOperationWithScopedRequest<TSlug extends GlobalSlug>({\n slug,\n data: incomingData,\n draft,\n globalConfig,\n onValidationData,\n overrideAccess,\n req,\n skipAccessControl = false,\n skipMutationHooks = false,\n sourceData,\n validationOperation = 'validate',\n}: Arguments<TSlug>): Promise<ValidationResult> {\n const accessResult =\n !skipAccessControl && !overrideAccess\n ? await executeAccess({ slug, data: incomingData, req }, globalConfig.access.validate)\n : true\n const storedGlobal = sourceData\n ? sourceData.docWithLocales\n : await resolveValidationGlobalSource({\n slug,\n accessResult,\n draft,\n globalConfig,\n overrideAccess,\n req,\n })\n\n const docWithLocales: JsonObject = deepCopyObjectSimple(storedGlobal)\n\n if (docWithLocales._id) {\n delete docWithLocales._id\n }\n\n const originalDoc = sourceData\n ? req.locale === sourceData.originalLocale\n ? deepCopyObjectSimple(sourceData.originalDoc)\n : flattenDataByLocale({\n configBlockReferences: req.payload.config.blocks,\n docWithLocales,\n fields: globalConfig.fields,\n locale: req.locale!,\n })\n : await afterRead({\n collection: null,\n context: req.context,\n depth: 0,\n doc: deepCopyObjectSimple(docWithLocales),\n draft,\n fallbackLocale: req.fallbackLocale!,\n global: globalConfig,\n locale: req.locale!,\n overrideAccess: true,\n req,\n showHiddenFields: true,\n })\n\n return runValidationLifecycle({\n collection: null,\n docWithLocales,\n global: globalConfig,\n incomingData,\n onValidationData,\n originalDoc,\n overrideAccess,\n req,\n skipMutationHooks,\n validationOperation,\n })\n}\n\n/**\n * Selects the newest stored source before it applies a `where` access policy. This prevents an\n * older accessible draft from replacing a newer restricted draft. If no draft exists, the main\n * global remains the validation source.\n */\nasync function resolveValidationGlobalSource({\n slug,\n accessResult,\n draft,\n globalConfig,\n overrideAccess,\n req,\n}: {\n accessResult: AccessResult\n draft: boolean\n globalConfig: SanitizedGlobalConfig\n overrideAccess: boolean\n req: PayloadRequest\n slug: string\n}): Promise<JsonObject> {\n const main = await req.payload.db.findGlobal({\n slug,\n locale: req.locale!,\n req,\n })\n const hasMain = hasGlobalSource(main)\n const base = (hasMain ? main : { globalType: slug }) as JsonObject & TypeWithID\n\n if (draft && globalConfig.versions?.drafts) {\n const newestDraft = await findDraftVersion({\n accessResult: true,\n doc: base,\n entity: globalConfig,\n entityType: 'global',\n overrideAccess: true,\n req,\n })\n\n if (newestDraft) {\n if (hasWhereAccessResult(accessResult)) {\n const accessibleDraft = await findDraftVersion({\n accessResult,\n doc: base,\n draftVersionID: newestDraft.id,\n entity: globalConfig,\n entityType: 'global',\n overrideAccess,\n req,\n })\n\n if (!accessibleDraft) {\n throw new Forbidden(req.t)\n }\n }\n\n return getDocumentFromDraftVersion({\n doc: base,\n draftVersion: newestDraft,\n entityType: 'global',\n })\n }\n }\n\n if (!hasMain) {\n return {}\n }\n\n if (!hasWhereAccessResult(accessResult)) {\n return main\n }\n\n const accessibleMain = await req.payload.db.findGlobal({\n slug,\n locale: req.locale!,\n req,\n where: accessResult,\n })\n\n if (!hasGlobalSource(accessibleMain)) {\n throw new Forbidden(req.t)\n }\n\n return accessibleMain\n}\n\nfunction hasGlobalSource(source: JsonObject | null | undefined): source is JsonObject {\n return Boolean(source && Object.keys(source).length > 0)\n}\n"],"names":["executeAccess","hasWhereAccessResult","Forbidden","afterRead","deepCopyObjectSimple","flattenDataByLocale","runValidationLifecycle","findDraftVersion","getDocumentFromDraftVersion","validateOperation","args","previousOperation","req","operation","validationOperation","validateOperationWithScopedRequest","slug","data","incomingData","draft","globalConfig","onValidationData","overrideAccess","skipAccessControl","skipMutationHooks","sourceData","accessResult","access","validate","storedGlobal","docWithLocales","resolveValidationGlobalSource","_id","originalDoc","locale","originalLocale","configBlockReferences","payload","config","blocks","fields","collection","context","depth","doc","fallbackLocale","global","showHiddenFields","main","db","findGlobal","hasMain","hasGlobalSource","base","globalType","versions","drafts","newestDraft","entity","entityType","accessibleDraft","draftVersionID","id","t","draftVersion","accessibleMain","where","source","Boolean","Object","keys","length"],"mappings":"AAUA,SAASA,aAAa,QAAQ,8BAA6B;AAC3D,SAASC,oBAAoB,QAAQ,sBAAqB;AAC1D,SAASC,SAAS,QAAQ,wBAAuB;AACjD,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,oBAAoB,QAAQ,oCAAmC;AACxE,SAASC,mBAAmB,QAAQ,yCAAwC;AAC5E,SAASC,sBAAsB,QAAQ,4CAA2C;AAClF,SACEC,gBAAgB,EAChBC,2BAA2B,QACtB,uDAAsD;AAgB7D,OAAO,eAAeC,kBACpBC,IAAsB;IAEtB,MAAMC,oBAAoBD,KAAKE,GAAG,CAACC,SAAS;IAC5CH,KAAKE,GAAG,CAACC,SAAS,GAAGH,KAAKI,mBAAmB,IAAI;IAEjD,IAAI;QACF,OAAO,MAAMC,mCAAmCL;IAClD,SAAU;QACRA,KAAKE,GAAG,CAACC,SAAS,GAAGF;IACvB;A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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hierarchy/createFolderField.ts"],"sourcesContent":["import type { RelationshipField, SingleRelationshipField } from '../fields/config/types.js'\n\nimport { getHierarchyFieldName } from './constants.js'\n\n/**\n * Options for creating a folder relationship field.\n * All SingleRelationshipField properties are available except name, type, relationTo, and hasMany\n * which are managed by the folder system.\n */\nexport type CreateFolderFieldOptions = {\n /**\n * The slug of the hierarchy collection this field references (e.g., 'folders')\n */\n relationTo: string\n} & Pick<Partial<SingleRelationshipField>, 'admin' | 'label' | 'required'>\n\n/**\n * Creates a relationship field for folder-style hierarchies (single-select).\n *\n * This field:\n * - Has hasMany:false (single folder selection)\n * - Uses NullField to render nothing in the form (no DOM output)\n * - Injects a header button for folder selection via miller columns UI\n *\n * Use this in your collection's fields array to add a folder relationship.\n * The field name is automatically generated based on the hierarchy slug.\n *\n * @example\n * import { createFolderField } from 'payload'\n *\n * const Posts: CollectionConfig = {\n * slug: 'posts',\n * fields: [\n * { name: 'title', type: 'text' },\n * createFolderField({\n * relationTo: 'folders',\n * label: 'Folder',\n * }),\n * ],\n * }\n */\nexport function createFolderField(options: CreateFolderFieldOptions): RelationshipField {\n const { admin: adminOverrides, label, relationTo, ...restOptions } = options\n const { components: componentOverrides, ...restAdminOverrides } = adminOverrides || {}\n\n return {\n name: getHierarchyFieldName(relationTo),\n type: 'relationship',\n admin: {\n position: 'sidebar',\n ...restAdminOverrides,\n components: {\n // NullField renders nothing - the header button handles the UI\n Field: '@payloadcms/ui#NullField',\n ...componentOverrides,\n },\n },\n custom: {\n hierarchy: {\n injectHeaderButton: true,\n },\n },\n hasMany: false,\n index: true,\n label: label ?? 'Folder',\n relationTo,\n ...restOptions,\n }
|
|
1
|
+
{"version":3,"sources":["../../src/hierarchy/createFolderField.ts"],"sourcesContent":["import type { RelationshipField, SingleRelationshipField } from '../fields/config/types.js'\n\nimport { getHierarchyFieldName } from './constants.js'\n\n/**\n * Options for creating a folder relationship field.\n * All SingleRelationshipField properties are available except name, type, relationTo, and hasMany\n * which are managed by the folder system.\n */\nexport type CreateFolderFieldOptions = {\n /**\n * The slug of the hierarchy collection this field references (e.g., 'folders')\n */\n relationTo: string\n} & Pick<Partial<SingleRelationshipField>, 'admin' | 'label' | 'required'>\n\n/**\n * Creates a relationship field for folder-style hierarchies (single-select).\n *\n * This field:\n * - Has hasMany:false (single folder selection)\n * - Uses NullField to render nothing in the form (no DOM output)\n * - Injects a header button for folder selection via miller columns UI\n *\n * Use this in your collection's fields array to add a folder relationship.\n * The field name is automatically generated based on the hierarchy slug.\n *\n * @example\n * import { createFolderField } from 'payload'\n *\n * const Posts: CollectionConfig = {\n * slug: 'posts',\n * fields: [\n * { name: 'title', type: 'text' },\n * createFolderField({\n * relationTo: 'folders',\n * label: 'Folder',\n * }),\n * ],\n * }\n */\nexport function createFolderField(options: CreateFolderFieldOptions): RelationshipField {\n const { admin: adminOverrides, label, relationTo, ...restOptions } = options\n const { components: componentOverrides, ...restAdminOverrides } = adminOverrides || {}\n\n return {\n name: getHierarchyFieldName(relationTo),\n type: 'relationship',\n admin: {\n position: 'sidebar',\n ...restAdminOverrides,\n components: {\n // NullField renders nothing - the header button handles the UI\n Field: '@payloadcms/ui#NullField',\n ...componentOverrides,\n },\n },\n custom: {\n hierarchy: {\n injectHeaderButton: true,\n },\n },\n hasMany: false,\n index: true,\n label: label ?? 'Folder',\n relationTo,\n ...restOptions,\n }\n}\n"],"names":["getHierarchyFieldName","createFolderField","options","admin","adminOverrides","label","relationTo","restOptions","components","componentOverrides","restAdminOverrides","name","type","position","Field","custom","hierarchy","injectHeaderButton","hasMany","index"],"mappings":"AAEA,SAASA,qBAAqB,QAAQ,iBAAgB;AActD;;;;;;;;;;;;;;;;;;;;;;;;CAwBC,GACD,OAAO,SAASC,kBAAkBC,OAAiC;IACjE,MAAM,EAAEC,OAAOC,cAAc,EAAEC,KAAK,EAAEC,UAAU,EAAE,GAAGC,aAAa,GAAGL;IACrE,MAAM,EAAEM,YAAYC,kBAAkB,EAAE,GAAGC,oBAAoB,GAAGN,kBAAkB,CAAC;IAErF,OAAO;QACLO,MAAMX,sBAAsBM;QAC5BM,MAAM;QACNT,OAAO;YACLU,UAAU;YACV,GAAGH,kBAAkB;YACrBF,YAAY;gBACV,+DAA+D;gBAC/DM,OAAO;gBACP,GAAGL,kBAAkB;YACvB;QACF;QACAM,QAAQ;YACNC,WAAW;gBACTC,oBAAoB;YACtB;QACF;QACAC,SAAS;QACTC,OAAO;QACPd,OAAOA,SAAS;QAChBC;QACA,GAAGC,WAAW;IAChB;AACF"}
|
|
@@ -93,7 +93,7 @@ import { injectHierarchyButton } from './injectHierarchyButton.js';
|
|
|
93
93
|
if (hierarchyConfig.collectionSpecific) {
|
|
94
94
|
injectTypeField({
|
|
95
95
|
config,
|
|
96
|
-
hierarchyCollection
|
|
96
|
+
hierarchyCollection,
|
|
97
97
|
parentFieldName: hierarchyConfig.parentFieldName,
|
|
98
98
|
sanitizedRelatedCollections,
|
|
99
99
|
typeFieldName: hierarchyConfig.collectionSpecific.fieldName
|
|
@@ -116,7 +116,7 @@ import { injectHierarchyButton } from './injectHierarchyButton.js';
|
|
|
116
116
|
// Add afterDelete hook to clear folder references from related documents
|
|
117
117
|
if (Object.keys(sanitizedRelatedCollections).length > 0) {
|
|
118
118
|
injectAfterDeleteHook({
|
|
119
|
-
hierarchyCollection
|
|
119
|
+
hierarchyCollection,
|
|
120
120
|
sanitizedRelatedCollections
|
|
121
121
|
});
|
|
122
122
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hierarchy/resolveHierarchyCollections.ts"],"sourcesContent":["import type { CollectionConfig, SanitizedCollectionConfig } from '../collections/config/types.js'\nimport type { Config } from '../config/types.js'\nimport type {\n JoinField,\n Option,\n RelationshipField,\n SelectField,\n Validate,\n} from '../fields/config/types.js'\nimport type { Document } from '../types/index.js'\nimport type {\n HierarchyJoinFieldConfig,\n SanitizedHierarchyConfig,\n SanitizedHierarchyRelatedCollection,\n} from './types.js'\n\nimport { sanitizeJoinField } from '../fields/config/sanitizeJoinField.js'\nimport { fieldAffectsData } from '../fields/config/types.js'\nimport { extractID } from '../utilities/extractID.js'\nimport { flattenAllFields } from '../utilities/flattenAllFields.js'\nimport { getHierarchyFieldName } from './constants.js'\nimport { hierarchyCollectionAfterDelete } from './hooks/collectionAfterDelete.js'\nimport { injectHierarchyButton } from './injectHierarchyButton.js'\n\n/**\n * Resolves hierarchy relationships across collections.\n *\n * This function runs after individual collection sanitization to establish\n * cross-collection hierarchy relationships. It discovers which collections\n * reference each hierarchy and configures the necessary fields, components,\n * and hooks.\n *\n * @remarks\n * Must be called after all collections are sanitized.\n *\n * **What it does:**\n * - Discovers related collections by scanning for hierarchy relationship fields\n * - Injects `HierarchyButton` component when `custom.hierarchy.injectHeaderButton` is set\n * - Adds `collectionSpecific` validation to ensure hierarchy items accept the document type\n * - Injects the `hierarchyType` select field when `collectionSpecific` is enabled\n * - Injects join field when `joinField` is configured\n * - Adds `afterDelete` hook to clear hierarchy references when items are deleted\n * - Populates `relatedCollections` in the sanitized hierarchy config\n */\nexport const resolveHierarchyCollections = (config: Config): void => {\n const hierarchyCollections =\n config.collections?.filter((col) => col.hierarchy && typeof col.hierarchy === 'object') || []\n\n for (const hierarchyCollection of hierarchyCollections) {\n const hierarchy = hierarchyCollection.hierarchy\n\n // TypeScript guard - hierarchy is guaranteed to be an object by the filter above\n if (!hierarchy || typeof hierarchy !== 'object') {\n continue\n }\n\n const hierarchyConfig = hierarchy as SanitizedHierarchyConfig\n const defaultFieldName = getHierarchyFieldName(hierarchyCollection.slug)\n const parentFieldName = hierarchyConfig.parentFieldName ?? defaultFieldName\n const isParentFieldNameOverridden = parentFieldName !== defaultFieldName\n const collectionSpecific = hierarchyConfig.collectionSpecific\n const typeFieldName = collectionSpecific ? collectionSpecific.fieldName : undefined\n const allowHasMany = hierarchyConfig.allowHasMany ?? true\n\n // Build relatedCollections by scanning all collections for hierarchy fields\n const sanitizedRelatedCollections: Record<string, SanitizedHierarchyRelatedCollection> = {}\n\n const selfParentField = hierarchyCollection.fields.find(\n (field) =>\n fieldAffectsData(field) &&\n field.name === parentFieldName &&\n field.type === 'relationship' &&\n (field as RelationshipField).relationTo === hierarchyCollection.slug,\n ) as RelationshipField | undefined\n\n // Check if the hierarchy collection's own parent field should be replaced with a header button\n if (selfParentField?.custom?.hierarchy?.injectHeaderButton === true) {\n injectHierarchyButton({\n collection: hierarchyCollection,\n fieldName: parentFieldName,\n hierarchyCollectionSlug: hierarchyCollection.slug,\n parentFieldName: hierarchyConfig.parentFieldName,\n })\n }\n\n for (const collection of config.collections || []) {\n // Skip the hierarchy collection itself (handled above)\n if (collection.slug === hierarchyCollection.slug) {\n continue\n }\n\n // Find hierarchy field by the default name (what createFolderField uses)\n const hierarchyField = collection.fields.find(\n (field) =>\n fieldAffectsData(field) &&\n field.name === defaultFieldName &&\n field.type === 'relationship' &&\n (field as RelationshipField).relationTo === hierarchyCollection.slug,\n ) as RelationshipField | undefined\n\n // If parentFieldName is overridden, rename the field to match\n if (hierarchyField && isParentFieldNameOverridden) {\n hierarchyField.name = parentFieldName\n }\n\n if (!hierarchyField) {\n continue\n }\n\n const fieldHasMany = hierarchyField.hasMany ?? allowHasMany\n\n // If collectionSpecific, inject validation to check hierarchy allows this collection type\n if (collectionSpecific) {\n injectCollectionSpecificValidation({\n hierarchyField,\n hierarchySlug: hierarchyCollection.slug,\n typeFieldName: typeFieldName!,\n })\n }\n\n // Store discovered collection with hasMany info\n sanitizedRelatedCollections[collection.slug] = {\n fieldName: parentFieldName,\n hasMany: fieldHasMany,\n }\n\n // Inject HierarchyButton if field requests it\n if (hierarchyField.custom?.hierarchy?.injectHeaderButton === true) {\n injectHierarchyButton({\n collection,\n fieldName: parentFieldName,\n hierarchyCollectionSlug: hierarchyCollection.slug,\n parentFieldName: hierarchyConfig.parentFieldName,\n })\n }\n }\n\n // If collectionSpecific, add type field to hierarchy collection\n if (hierarchyConfig.collectionSpecific) {\n injectTypeField({\n config,\n hierarchyCollection: hierarchyCollection as SanitizedCollectionConfig,\n parentFieldName: hierarchyConfig.parentFieldName,\n sanitizedRelatedCollections,\n typeFieldName: hierarchyConfig.collectionSpecific.fieldName,\n })\n }\n\n // If joinField is configured, add the join field to query children\n if (hierarchyConfig.joinField) {\n injectJoinField({\n config,\n hierarchyCollection: hierarchyCollection as SanitizedCollectionConfig,\n joinFieldConfig: hierarchyConfig.joinField,\n parentFieldName,\n relatedSlugs: Object.keys(sanitizedRelatedCollections),\n })\n }\n\n // Update hierarchy config with sanitized relatedCollections\n if (hierarchyConfig) {\n hierarchyConfig.relatedCollections = sanitizedRelatedCollections\n }\n\n // Add afterDelete hook to clear folder references from related documents\n if (Object.keys(sanitizedRelatedCollections).length > 0) {\n injectAfterDeleteHook({\n hierarchyCollection: hierarchyCollection as SanitizedCollectionConfig,\n sanitizedRelatedCollections,\n })\n }\n\n // Add sidebar tab for this hierarchy collection (unless explicitly disabled)\n if (hierarchyConfig.admin.injectSidebarTab !== false) {\n injectSidebarTab({\n config,\n hierarchyCollection,\n hierarchyConfig,\n })\n\n // Hide from nav when sidebar tab is injected (unless user explicitly set group)\n if (hierarchyCollection.admin?.group === undefined) {\n hierarchyCollection.admin = {\n ...hierarchyCollection.admin,\n group: false,\n }\n }\n }\n }\n}\n\n/**\n * Injects validation for collectionSpecific hierarchy fields.\n * Ensures the selected hierarchy item allows documents of this collection type.\n */\nfunction injectCollectionSpecificValidation({\n hierarchyField,\n hierarchySlug,\n typeFieldName,\n}: {\n hierarchyField: RelationshipField\n hierarchySlug: string\n typeFieldName: string\n}): void {\n const existingValidate = hierarchyField.validate\n\n const validate: Validate<unknown> = async (value, options) => {\n // Run existing validation first if present\n if (existingValidate) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const existingResult = await existingValidate(value as any, options as any)\n if (existingResult !== true) {\n return existingResult\n }\n }\n\n return validateCollectionSpecificHierarchy({\n hierarchySlug,\n options,\n typeFieldName,\n value,\n })\n }\n\n hierarchyField.validate = validate\n}\n\ntype HierarchyValidationOptions = Parameters<Validate<unknown>>[1]\n\nconst validateCollectionSpecificHierarchy = async ({\n hierarchySlug,\n options,\n typeFieldName,\n value,\n}: {\n hierarchySlug: string\n options: HierarchyValidationOptions\n typeFieldName: string\n value: unknown\n}): Promise<string | true> => {\n if (!value || (Array.isArray(value) && value.length === 0)) {\n return true\n }\n\n const { collectionSlug, overrideAccess, previousValue, req } = options\n const newIDs = (Array.isArray(value) ? value : [value]).map((item) => extractID<Document>(item))\n\n const previousIDs = new Set(\n (Array.isArray(previousValue) ? previousValue : previousValue ? [previousValue] : []).map(\n (item) => extractID<Document>(item),\n ),\n )\n\n for (const newID of newIDs) {\n if (previousIDs.has(newID)) {\n continue\n }\n\n let parentItem: Document | null = null\n if (typeof newID === 'string' || typeof newID === 'number') {\n try {\n parentItem = await req.payload.findByID({\n id: newID,\n collection: hierarchySlug,\n depth: 0,\n overrideAccess: overrideAccess ?? false,\n req,\n select: { [typeFieldName]: true },\n })\n } catch {\n return `Hierarchy item with ID ${newID} not found`\n }\n }\n\n if (!parentItem) {\n return `Hierarchy item with ID ${newID} not found`\n }\n\n const allowedTypes: string[] = (parentItem[typeFieldName] as string[]) || []\n\n if (allowedTypes.length === 0 || (collectionSlug && allowedTypes.includes(collectionSlug))) {\n continue\n }\n\n return `Hierarchy item \"${newID}\" does not allow documents of type \"${collectionSlug}\"`\n }\n\n return true\n}\n\n/**\n * Injects the hierarchyType select field into a hierarchy collection.\n */\nfunction injectTypeField({\n config,\n hierarchyCollection,\n parentFieldName,\n sanitizedRelatedCollections,\n typeFieldName,\n}: {\n config: Config\n hierarchyCollection: CollectionConfig | SanitizedCollectionConfig\n parentFieldName: string\n sanitizedRelatedCollections: Record<string, SanitizedHierarchyRelatedCollection>\n typeFieldName: string\n}): void {\n const collectionOptions: Option[] = Object.keys(sanitizedRelatedCollections).map((slug) => {\n const relatedCollection = config.collections?.find((c) => c.slug === slug)\n\n return {\n label: relatedCollection?.labels?.plural || slug,\n value: slug,\n }\n })\n\n const typeField: SelectField = {\n name: typeFieldName,\n type: 'select',\n admin: {\n components: {\n Field: {\n path: '@payloadcms/ui/rsc#HierarchyTypeFieldServer',\n serverProps: {\n collectionOptions,\n parentFieldName,\n },\n },\n },\n position: 'sidebar',\n },\n hasMany: true,\n label: ({ t }) => t('general:allowedTypes'),\n options: collectionOptions,\n }\n\n hierarchyCollection.fields = hierarchyCollection.fields || []\n\n // This can run again on the same `fields` array, so replace the field if it already exists\n const existingTypeFieldIndex = hierarchyCollection.fields.findIndex(\n (field) => fieldAffectsData(field) && field.name === typeFieldName,\n )\n\n if (existingTypeFieldIndex === -1) {\n hierarchyCollection.fields.push(typeField)\n } else {\n hierarchyCollection.fields[existingTypeFieldIndex] = typeField\n }\n\n // Recompute flattenedFields since we added a field after initial sanitization\n // This is required for the field to be queryable\n if ('flattenedFields' in hierarchyCollection) {\n hierarchyCollection.flattenedFields = flattenAllFields({\n fields: hierarchyCollection.fields,\n })\n }\n}\n\n/**\n * Injects a join field to query all children of a hierarchy item.\n */\nfunction injectJoinField({\n config,\n hierarchyCollection,\n joinFieldConfig,\n parentFieldName,\n relatedSlugs,\n}: {\n config: Config\n hierarchyCollection: SanitizedCollectionConfig\n joinFieldConfig: HierarchyJoinFieldConfig\n parentFieldName: string\n relatedSlugs: string[]\n}): void {\n const { name, admin: userAdmin, ...userConfig } = joinFieldConfig\n\n const hasJoinField = hierarchyCollection.fields?.some(\n (field) => 'name' in field && field.name === name,\n )\n\n if (hasJoinField) {\n return\n }\n\n const joinField: JoinField = {\n // User config (spread first so auto-generated values take precedence for required fields)\n ...userConfig,\n // Auto-generated values (these cannot be overridden)\n name,\n type: 'join',\n collection: [hierarchyCollection.slug, ...relatedSlugs],\n hasMany: true,\n on: parentFieldName,\n // Merge admin config\n admin: {\n ...userAdmin,\n },\n }\n\n hierarchyCollection.fields = hierarchyCollection.fields || []\n hierarchyCollection.fields.push(joinField)\n\n // Sanitize the join field to register it properly\n sanitizeJoinField({\n config,\n field: joinField,\n joins: hierarchyCollection.joins,\n parentIsLocalized: false,\n polymorphicJoins: hierarchyCollection.polymorphicJoins,\n })\n\n // Recompute flattenedFields since we added a field after initial sanitization\n hierarchyCollection.flattenedFields = flattenAllFields({\n fields: hierarchyCollection.fields,\n })\n}\n\n/**\n * Injects afterDelete hook to clear hierarchy references from related documents.\n */\nfunction injectAfterDeleteHook({\n hierarchyCollection,\n sanitizedRelatedCollections,\n}: {\n hierarchyCollection: CollectionConfig | SanitizedCollectionConfig\n sanitizedRelatedCollections: Record<string, SanitizedHierarchyRelatedCollection>\n}): void {\n // Build map of collection slugs to their field names\n const relatedCollectionFieldMap: Record<string, string> = {}\n for (const [slug, relatedConfig] of Object.entries(sanitizedRelatedCollections)) {\n relatedCollectionFieldMap[slug] = relatedConfig.fieldName\n }\n\n hierarchyCollection.hooks = hierarchyCollection.hooks || {}\n hierarchyCollection.hooks.afterDelete = [\n ...(hierarchyCollection.hooks.afterDelete || []),\n hierarchyCollectionAfterDelete({ relatedCollections: relatedCollectionFieldMap }),\n ]\n}\n\n/**\n * Injects a sidebar tab for a hierarchy collection.\n */\nfunction injectSidebarTab({\n config,\n hierarchyCollection,\n hierarchyConfig,\n}: {\n config: Config\n hierarchyCollection: CollectionConfig\n hierarchyConfig: SanitizedHierarchyConfig\n}): void {\n const tabSlug = `hierarchy-${hierarchyCollection.slug}`\n const Icon = hierarchyConfig.admin.components.Icon\n\n // Initialize admin config structure\n config.admin = config.admin || {}\n config.admin.components = config.admin.components || {}\n config.admin.components.sidebar = config.admin.components.sidebar || {}\n config.admin.components.sidebar.tabs = config.admin.components.sidebar.tabs || []\n\n // Check if tab already exists\n const hasTab = config.admin.components.sidebar.tabs.some((tab) => tab.slug === tabSlug)\n\n if (!hasTab) {\n config.admin.components.sidebar.tabs.push({\n slug: tabSlug,\n components: {\n Content: {\n clientProps: {\n hierarchyCollectionSlug: hierarchyCollection.slug,\n },\n path: '@payloadcms/ui/rsc#HierarchySidebarTabServer',\n },\n Icon,\n },\n label: hierarchyCollection.labels?.plural || hierarchyCollection.slug,\n })\n }\n}\n"],"names":["sanitizeJoinField","fieldAffectsData","extractID","flattenAllFields","getHierarchyFieldName","hierarchyCollectionAfterDelete","injectHierarchyButton","resolveHierarchyCollections","config","hierarchyCollections","collections","filter","col","hierarchy","hierarchyCollection","hierarchyConfig","defaultFieldName","slug","parentFieldName","isParentFieldNameOverridden","collectionSpecific","typeFieldName","fieldName","undefined","allowHasMany","sanitizedRelatedCollections","selfParentField","fields","find","field","name","type","relationTo","custom","injectHeaderButton","collection","hierarchyCollectionSlug","hierarchyField","fieldHasMany","hasMany","injectCollectionSpecificValidation","hierarchySlug","injectTypeField","joinField","injectJoinField","joinFieldConfig","relatedSlugs","Object","keys","relatedCollections","length","injectAfterDeleteHook","admin","injectSidebarTab","group","existingValidate","validate","value","options","existingResult","validateCollectionSpecificHierarchy","Array","isArray","collectionSlug","overrideAccess","previousValue","req","newIDs","map","item","previousIDs","Set","newID","has","parentItem","payload","findByID","id","depth","select","allowedTypes","includes","collectionOptions","relatedCollection","c","label","labels","plural","typeField","components","Field","path","serverProps","position","t","existingTypeFieldIndex","findIndex","push","flattenedFields","userAdmin","userConfig","hasJoinField","some","on","joins","parentIsLocalized","polymorphicJoins","relatedCollectionFieldMap","relatedConfig","entries","hooks","afterDelete","tabSlug","Icon","sidebar","tabs","hasTab","tab","Content","clientProps"],"mappings":"AAgBA,SAASA,iBAAiB,QAAQ,wCAAuC;AACzE,SAASC,gBAAgB,QAAQ,4BAA2B;AAC5D,SAASC,SAAS,QAAQ,4BAA2B;AACrD,SAASC,gBAAgB,QAAQ,mCAAkC;AACnE,SAASC,qBAAqB,QAAQ,iBAAgB;AACtD,SAASC,8BAA8B,QAAQ,mCAAkC;AACjF,SAASC,qBAAqB,QAAQ,6BAA4B;AAElE;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,MAAMC,8BAA8B,CAACC;IA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ACyB,OAAO,GAAG1G,OAAO4C,KAAK,CAACqC,UAAU,CAACyB,OAAO,IAAI,CAAC;IACtE1G,OAAO4C,KAAK,CAACqC,UAAU,CAACyB,OAAO,CAACC,IAAI,GAAG3G,OAAO4C,KAAK,CAACqC,UAAU,CAACyB,OAAO,CAACC,IAAI,IAAI,EAAE;IAEjF,8BAA8B;IAC9B,MAAMC,SAAS5G,OAAO4C,KAAK,CAACqC,UAAU,CAACyB,OAAO,CAACC,IAAI,CAACb,IAAI,CAAC,CAACe,MAAQA,IAAIpG,IAAI,KAAK+F;IAE/E,IAAI,CAACI,QAAQ;QACX5G,OAAO4C,KAAK,CAACqC,UAAU,CAACyB,OAAO,CAACC,IAAI,CAAClB,IAAI,CAAC;YACxChF,MAAM+F;YACNvB,YAAY;gBACV6B,SAAS;oBACPC,aAAa;wBACXnF,yBAAyBtB,oBAAoBG,IAAI;oBACnD;oBACA0E,MAAM;gBACR;gBACAsB;YACF;YACA5B,OAAOvE,oBAAoBwE,MAAM,EAAEC,UAAUzE,oBAAoBG,IAAI;QACvE;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/hierarchy/resolveHierarchyCollections.ts"],"sourcesContent":["import type { CollectionConfig, SanitizedCollectionConfig } from '../collections/config/types.js'\nimport type { Config } from '../config/types.js'\nimport type {\n JoinField,\n Option,\n RelationshipField,\n SelectField,\n Validate,\n} from '../fields/config/types.js'\nimport type { Document } from '../types/index.js'\nimport type {\n HierarchyJoinFieldConfig,\n SanitizedHierarchyConfig,\n SanitizedHierarchyRelatedCollection,\n} from './types.js'\n\nimport { sanitizeJoinField } from '../fields/config/sanitizeJoinField.js'\nimport { fieldAffectsData } from '../fields/config/types.js'\nimport { extractID } from '../utilities/extractID.js'\nimport { flattenAllFields } from '../utilities/flattenAllFields.js'\nimport { getHierarchyFieldName } from './constants.js'\nimport { hierarchyCollectionAfterDelete } from './hooks/collectionAfterDelete.js'\nimport { injectHierarchyButton } from './injectHierarchyButton.js'\n\n/**\n * Resolves hierarchy relationships across collections.\n *\n * This function runs after individual collection sanitization to establish\n * cross-collection hierarchy relationships. It discovers which collections\n * reference each hierarchy and configures the necessary fields, components,\n * and hooks.\n *\n * @remarks\n * Must be called after all collections are sanitized.\n *\n * **What it does:**\n * - Discovers related collections by scanning for hierarchy relationship fields\n * - Injects `HierarchyButton` component when `custom.hierarchy.injectHeaderButton` is set\n * - Adds `collectionSpecific` validation to ensure hierarchy items accept the document type\n * - Injects the `hierarchyType` select field when `collectionSpecific` is enabled\n * - Injects join field when `joinField` is configured\n * - Adds `afterDelete` hook to clear hierarchy references when items are deleted\n * - Populates `relatedCollections` in the sanitized hierarchy config\n */\nexport const resolveHierarchyCollections = (config: Config): void => {\n const hierarchyCollections =\n config.collections?.filter((col) => col.hierarchy && typeof col.hierarchy === 'object') || []\n\n for (const hierarchyCollection of hierarchyCollections) {\n const hierarchy = hierarchyCollection.hierarchy\n\n // TypeScript guard - hierarchy is guaranteed to be an object by the filter above\n if (!hierarchy || typeof hierarchy !== 'object') {\n continue\n }\n\n const hierarchyConfig = hierarchy as SanitizedHierarchyConfig\n const defaultFieldName = getHierarchyFieldName(hierarchyCollection.slug)\n const parentFieldName = hierarchyConfig.parentFieldName ?? defaultFieldName\n const isParentFieldNameOverridden = parentFieldName !== defaultFieldName\n const collectionSpecific = hierarchyConfig.collectionSpecific\n const typeFieldName = collectionSpecific ? collectionSpecific.fieldName : undefined\n const allowHasMany = hierarchyConfig.allowHasMany ?? true\n\n // Build relatedCollections by scanning all collections for hierarchy fields\n const sanitizedRelatedCollections: Record<string, SanitizedHierarchyRelatedCollection> = {}\n\n const selfParentField = hierarchyCollection.fields.find(\n (field) =>\n fieldAffectsData(field) &&\n field.name === parentFieldName &&\n field.type === 'relationship' &&\n field.relationTo === hierarchyCollection.slug,\n ) as RelationshipField | undefined\n\n // Check if the hierarchy collection's own parent field should be replaced with a header button\n if (selfParentField?.custom?.hierarchy?.injectHeaderButton === true) {\n injectHierarchyButton({\n collection: hierarchyCollection,\n fieldName: parentFieldName,\n hierarchyCollectionSlug: hierarchyCollection.slug,\n parentFieldName: hierarchyConfig.parentFieldName,\n })\n }\n\n for (const collection of config.collections || []) {\n // Skip the hierarchy collection itself (handled above)\n if (collection.slug === hierarchyCollection.slug) {\n continue\n }\n\n // Find hierarchy field by the default name (what createFolderField uses)\n const hierarchyField = collection.fields.find(\n (field) =>\n fieldAffectsData(field) &&\n field.name === defaultFieldName &&\n field.type === 'relationship' &&\n field.relationTo === hierarchyCollection.slug,\n ) as RelationshipField | undefined\n\n // If parentFieldName is overridden, rename the field to match\n if (hierarchyField && isParentFieldNameOverridden) {\n hierarchyField.name = parentFieldName\n }\n\n if (!hierarchyField) {\n continue\n }\n\n const fieldHasMany = hierarchyField.hasMany ?? allowHasMany\n\n // If collectionSpecific, inject validation to check hierarchy allows this collection type\n if (collectionSpecific) {\n injectCollectionSpecificValidation({\n hierarchyField,\n hierarchySlug: hierarchyCollection.slug,\n typeFieldName: typeFieldName!,\n })\n }\n\n // Store discovered collection with hasMany info\n sanitizedRelatedCollections[collection.slug] = {\n fieldName: parentFieldName,\n hasMany: fieldHasMany,\n }\n\n // Inject HierarchyButton if field requests it\n if (hierarchyField.custom?.hierarchy?.injectHeaderButton === true) {\n injectHierarchyButton({\n collection,\n fieldName: parentFieldName,\n hierarchyCollectionSlug: hierarchyCollection.slug,\n parentFieldName: hierarchyConfig.parentFieldName,\n })\n }\n }\n\n // If collectionSpecific, add type field to hierarchy collection\n if (hierarchyConfig.collectionSpecific) {\n injectTypeField({\n config,\n hierarchyCollection,\n parentFieldName: hierarchyConfig.parentFieldName,\n sanitizedRelatedCollections,\n typeFieldName: hierarchyConfig.collectionSpecific.fieldName,\n })\n }\n\n // If joinField is configured, add the join field to query children\n if (hierarchyConfig.joinField) {\n injectJoinField({\n config,\n hierarchyCollection: hierarchyCollection as SanitizedCollectionConfig,\n joinFieldConfig: hierarchyConfig.joinField,\n parentFieldName,\n relatedSlugs: Object.keys(sanitizedRelatedCollections),\n })\n }\n\n // Update hierarchy config with sanitized relatedCollections\n if (hierarchyConfig) {\n hierarchyConfig.relatedCollections = sanitizedRelatedCollections\n }\n\n // Add afterDelete hook to clear folder references from related documents\n if (Object.keys(sanitizedRelatedCollections).length > 0) {\n injectAfterDeleteHook({\n hierarchyCollection,\n sanitizedRelatedCollections,\n })\n }\n\n // Add sidebar tab for this hierarchy collection (unless explicitly disabled)\n if (hierarchyConfig.admin.injectSidebarTab !== false) {\n injectSidebarTab({\n config,\n hierarchyCollection,\n hierarchyConfig,\n })\n\n // Hide from nav when sidebar tab is injected (unless user explicitly set group)\n if (hierarchyCollection.admin?.group === undefined) {\n hierarchyCollection.admin = {\n ...hierarchyCollection.admin,\n group: false,\n }\n }\n }\n }\n}\n\n/**\n * Injects validation for collectionSpecific hierarchy fields.\n * Ensures the selected hierarchy item allows documents of this collection type.\n */\nfunction injectCollectionSpecificValidation({\n hierarchyField,\n hierarchySlug,\n typeFieldName,\n}: {\n hierarchyField: RelationshipField\n hierarchySlug: string\n typeFieldName: string\n}): void {\n const existingValidate = hierarchyField.validate\n\n const validate: Validate<unknown> = async (value, options) => {\n // Run existing validation first if present\n if (existingValidate) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const existingResult = await existingValidate(value as any, options as any)\n if (existingResult !== true) {\n return existingResult\n }\n }\n\n return validateCollectionSpecificHierarchy({\n hierarchySlug,\n options,\n typeFieldName,\n value,\n })\n }\n\n hierarchyField.validate = validate\n}\n\ntype HierarchyValidationOptions = Parameters<Validate<unknown>>[1]\n\nconst validateCollectionSpecificHierarchy = async ({\n hierarchySlug,\n options,\n typeFieldName,\n value,\n}: {\n hierarchySlug: string\n options: HierarchyValidationOptions\n typeFieldName: string\n value: unknown\n}): Promise<string | true> => {\n if (!value || (Array.isArray(value) && value.length === 0)) {\n return true\n }\n\n const { collectionSlug, overrideAccess, previousValue, req } = options\n const newIDs = (Array.isArray(value) ? value : [value]).map((item) => extractID<Document>(item))\n\n const previousIDs = new Set(\n (Array.isArray(previousValue) ? previousValue : previousValue ? [previousValue] : []).map(\n (item) => extractID<Document>(item),\n ),\n )\n\n for (const newID of newIDs) {\n if (previousIDs.has(newID)) {\n continue\n }\n\n let parentItem: Document | null = null\n if (typeof newID === 'string' || typeof newID === 'number') {\n try {\n parentItem = await req.payload.findByID({\n id: newID,\n collection: hierarchySlug,\n depth: 0,\n overrideAccess: overrideAccess ?? false,\n req,\n select: { [typeFieldName]: true },\n })\n } catch {\n return `Hierarchy item with ID ${newID} not found`\n }\n }\n\n if (!parentItem) {\n return `Hierarchy item with ID ${newID} not found`\n }\n\n const allowedTypes: string[] = (parentItem[typeFieldName] as string[]) || []\n\n if (allowedTypes.length === 0 || (collectionSlug && allowedTypes.includes(collectionSlug))) {\n continue\n }\n\n return `Hierarchy item \"${newID}\" does not allow documents of type \"${collectionSlug}\"`\n }\n\n return true\n}\n\n/**\n * Injects the hierarchyType select field into a hierarchy collection.\n */\nfunction injectTypeField({\n config,\n hierarchyCollection,\n parentFieldName,\n sanitizedRelatedCollections,\n typeFieldName,\n}: {\n config: Config\n hierarchyCollection: CollectionConfig | SanitizedCollectionConfig\n parentFieldName: string\n sanitizedRelatedCollections: Record<string, SanitizedHierarchyRelatedCollection>\n typeFieldName: string\n}): void {\n const collectionOptions: Option[] = Object.keys(sanitizedRelatedCollections).map((slug) => {\n const relatedCollection = config.collections?.find((c) => c.slug === slug)\n\n return {\n label: relatedCollection?.labels?.plural || slug,\n value: slug,\n }\n })\n\n const typeField: SelectField = {\n name: typeFieldName,\n type: 'select',\n admin: {\n components: {\n Field: {\n path: '@payloadcms/ui/rsc#HierarchyTypeFieldServer',\n serverProps: {\n collectionOptions,\n parentFieldName,\n },\n },\n },\n position: 'sidebar',\n },\n hasMany: true,\n label: ({ t }) => t('general:allowedTypes'),\n options: collectionOptions,\n }\n\n hierarchyCollection.fields = hierarchyCollection.fields || []\n\n // This can run again on the same `fields` array, so replace the field if it already exists\n const existingTypeFieldIndex = hierarchyCollection.fields.findIndex(\n (field) => fieldAffectsData(field) && field.name === typeFieldName,\n )\n\n if (existingTypeFieldIndex === -1) {\n hierarchyCollection.fields.push(typeField)\n } else {\n hierarchyCollection.fields[existingTypeFieldIndex] = typeField\n }\n\n // Recompute flattenedFields since we added a field after initial sanitization\n // This is required for the field to be queryable\n if ('flattenedFields' in hierarchyCollection) {\n hierarchyCollection.flattenedFields = flattenAllFields({\n fields: hierarchyCollection.fields,\n })\n }\n}\n\n/**\n * Injects a join field to query all children of a hierarchy item.\n */\nfunction injectJoinField({\n config,\n hierarchyCollection,\n joinFieldConfig,\n parentFieldName,\n relatedSlugs,\n}: {\n config: Config\n hierarchyCollection: SanitizedCollectionConfig\n joinFieldConfig: HierarchyJoinFieldConfig\n parentFieldName: string\n relatedSlugs: string[]\n}): void {\n const { name, admin: userAdmin, ...userConfig } = joinFieldConfig\n\n const hasJoinField = hierarchyCollection.fields?.some(\n (field) => 'name' in field && field.name === name,\n )\n\n if (hasJoinField) {\n return\n }\n\n const joinField: JoinField = {\n // User config (spread first so auto-generated values take precedence for required fields)\n ...userConfig,\n // Auto-generated values (these cannot be overridden)\n name,\n type: 'join',\n collection: [hierarchyCollection.slug, ...relatedSlugs],\n hasMany: true,\n on: parentFieldName,\n // Merge admin config\n admin: {\n ...userAdmin,\n },\n }\n\n hierarchyCollection.fields = hierarchyCollection.fields || []\n hierarchyCollection.fields.push(joinField)\n\n // Sanitize the join field to register it properly\n sanitizeJoinField({\n config,\n field: joinField,\n joins: hierarchyCollection.joins,\n parentIsLocalized: false,\n polymorphicJoins: hierarchyCollection.polymorphicJoins,\n })\n\n // Recompute flattenedFields since we added a field after initial sanitization\n hierarchyCollection.flattenedFields = flattenAllFields({\n fields: hierarchyCollection.fields,\n })\n}\n\n/**\n * Injects afterDelete hook to clear hierarchy references from related documents.\n */\nfunction injectAfterDeleteHook({\n hierarchyCollection,\n sanitizedRelatedCollections,\n}: {\n hierarchyCollection: CollectionConfig | SanitizedCollectionConfig\n sanitizedRelatedCollections: Record<string, SanitizedHierarchyRelatedCollection>\n}): void {\n // Build map of collection slugs to their field names\n const relatedCollectionFieldMap: Record<string, string> = {}\n for (const [slug, relatedConfig] of Object.entries(sanitizedRelatedCollections)) {\n relatedCollectionFieldMap[slug] = relatedConfig.fieldName\n }\n\n hierarchyCollection.hooks = hierarchyCollection.hooks || {}\n hierarchyCollection.hooks.afterDelete = [\n ...(hierarchyCollection.hooks.afterDelete || []),\n hierarchyCollectionAfterDelete({ relatedCollections: relatedCollectionFieldMap }),\n ]\n}\n\n/**\n * Injects a sidebar tab for a hierarchy collection.\n */\nfunction injectSidebarTab({\n config,\n hierarchyCollection,\n hierarchyConfig,\n}: {\n config: Config\n hierarchyCollection: CollectionConfig\n hierarchyConfig: SanitizedHierarchyConfig\n}): void {\n const tabSlug = `hierarchy-${hierarchyCollection.slug}`\n const Icon = hierarchyConfig.admin.components.Icon\n\n // Initialize admin config structure\n config.admin = config.admin || {}\n config.admin.components = config.admin.components || {}\n config.admin.components.sidebar = config.admin.components.sidebar || {}\n config.admin.components.sidebar.tabs = config.admin.components.sidebar.tabs || []\n\n // Check if tab already exists\n const hasTab = config.admin.components.sidebar.tabs.some((tab) => tab.slug === tabSlug)\n\n if (!hasTab) {\n config.admin.components.sidebar.tabs.push({\n slug: tabSlug,\n components: {\n Content: {\n clientProps: {\n hierarchyCollectionSlug: hierarchyCollection.slug,\n },\n path: '@payloadcms/ui/rsc#HierarchySidebarTabServer',\n },\n Icon,\n },\n label: hierarchyCollection.labels?.plural || hierarchyCollection.slug,\n })\n }\n}\n"],"names":["sanitizeJoinField","fieldAffectsData","extractID","flattenAllFields","getHierarchyFieldName","hierarchyCollectionAfterDelete","injectHierarchyButton","resolveHierarchyCollections","config","hierarchyCollections","collections","filter","col","hierarchy","hierarchyCollection","hierarchyConfig","defaultFieldName","slug","parentFieldName","isParentFieldNameOverridden","collectionSpecific","typeFieldName","fieldName","undefined","allowHasMany","sanitizedRelatedCollections","selfParentField","fields","find","field","name","type","relationTo","custom","injectHeaderButton","collection","hierarchyCollectionSlug","hierarchyField","fieldHasMany","hasMany","injectCollectionSpecificValidation","hierarchySlug","injectTypeField","joinField","injectJoinField","joinFieldConfig","relatedSlugs","Object","keys","relatedCollections","length","injectAfterDeleteHook","admin","injectSidebarTab","group","existingValidate","validate","value","options","existingResult","validateCollectionSpecificHierarchy","Array","isArray","collectionSlug","overrideAccess","previousValue","req","newIDs","map","item","previousIDs","Set","newID","has","parentItem","payload","findByID","id","depth","select","allowedTypes","includes","collectionOptions","relatedCollection","c","label","labels","plural","typeField","components","Field","path","serverProps","position","t","existingTypeFieldIndex","findIndex","push","flattenedFields","userAdmin","userConfig","hasJoinField","some","on","joins","parentIsLocalized","polymorphicJoins","relatedCollectionFieldMap","relatedConfig","entries","hooks","afterDelete","tabSlug","Icon","sidebar","tabs","hasTab","tab","Content","clientProps"],"mappings":"AAgBA,SAASA,iBAAiB,QAAQ,wCAAuC;AACzE,SAASC,gBAAgB,QAAQ,4BAA2B;AAC5D,SAASC,SAAS,QAAQ,4BAA2B;AACrD,SAASC,gBAAgB,QAAQ,mCAAkC;AACnE,SAASC,qBAAqB,QAAQ,iBAAgB;AACtD,SAASC,8BAA8B,QAAQ,mCAAkC;AACjF,SAASC,qBAAqB,QAAQ,6BAA4B;AAElE;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,MAAMC,8BAA8B,CAACC;IAC1C,MAAMC,uBACJD,OAAOE,WAAW,EAAEC,OAAO,CAACC,MAAQA,IAAIC,SAAS,IAAI,OAAOD,IAAIC,SAAS,KAAK,aAAa,EAAE;IAE/F,KAAK,MAAMC,uBAAuBL,qBAAsB;QACtD,MAAMI,YAAYC,oBAAoBD,SAAS;QAE/C,iFAAiF;QACjF,IAAI,CAACA,aAAa,OAAOA,cAAc,UAAU;YAC/C;QACF;QAEA,MAAME,kBAAkBF;QACxB,MAAMG,mBAAmBZ,sBAAsBU,oBAAoBG,IAAI;QACvE,MAAMC,kBAAkBH,gBA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,KAAK,CAACqC,UAAU,CAACyB,OAAO,CAACC,IAAI,CAAClB,IAAI,CAAC;YACxChF,MAAM+F;YACNvB,YAAY;gBACV6B,SAAS;oBACPC,aAAa;wBACXnF,yBAAyBtB,oBAAoBG,IAAI;oBACnD;oBACA0E,MAAM;gBACR;gBACAsB;YACF;YACA5B,OAAOvE,oBAAoBwE,MAAM,EAAEC,UAAUzE,oBAAoBG,IAAI;QACvE;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computePaths.d.ts","sourceRoot":"","sources":["../../../src/hierarchy/utils/computePaths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAA;AAClF,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAQpE,KAAK,gBAAgB,GAAG;IACtB,UAAU,EAAE,yBAAyB,CAAA;IACrC,GAAG,EAAE,QAAQ,CAAA;IACb,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,eAAe,EAAE,MAAM,CAAA;IACvB,GAAG,EAAE,cAAc,CAAA;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B,CAAA;AAED,KAAK,kBAAkB,GAAG;IACxB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAA;IACzC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAA;CAC3C,CAAA;AAgFD;;;;;;;;;;;GAWG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC,
|
|
1
|
+
{"version":3,"file":"computePaths.d.ts","sourceRoot":"","sources":["../../../src/hierarchy/utils/computePaths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK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