payload 4.0.0-beta.3 → 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/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/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/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/hooks/afterChange/promise.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/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 +12 -3
- package/dist/queues/operations/runJobs/runJob/getRunTaskFunction.js +1 -1
- package/dist/queues/operations/runJobs/runJob/getRunTaskFunction.js.map +1 -1
- package/dist/uploads/fileVersioning/archive.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/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/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/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/featureInfo/getFeatureInfo.js.map +1 -1
- package/dist/versions/allLocalesPublicationStatus.js.map +1 -1
- package/package.json +11 -9
- package/skills/payload/reference/PLUGIN-DEVELOPMENT.md +1 -1
|
@@ -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;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,gBAAgBG,eAAe,IAAIF;QAC3D,MAAMG,8BAA8BD,oBAAoBF;QACxD,MAAMI,qBAAqBL,gBAAgBK,kBAAkB;QAC7D,MAAMC,gBAAgBD,qBAAqBA,mBAAmBE,SAAS,GAAGC;QAC1E,MAAMC,eAAeT,gBAAgBS,YAAY,IAAI;QAErD,4EAA4E;QAC5E,MAAMC,8BAAmF,CAAC;QAE1F,MAAMC,kBAAkBZ,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,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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C,UAAU,CAACwB,IAAI;IAElD,oCAAoC;IACpCzG,OAAO4C,KAAK,GAAG5C,OAAO4C,KAAK,IAAI,CAAC;IAChC5C,OAAO4C,KAAK,CAACqC,UAAU,GAAGjF,OAAO4C,KAAK,CAACqC,UAAU,IAAI,CAAC;IACtDjF,OAAO4C,KAAK,CAACqC,UAAU,CAACyB,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 +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,KAA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;;;;GAWG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA0dtF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hierarchy/utils/computePaths.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../collections/config/types.js'\nimport type { Document, PayloadRequest } from '../../types/index.js'\n\nimport { slugify as payloadSlugify } from '../../utilities/slugify.js'\nimport { HIERARCHY_SLUG_PATH_FIELD, HIERARCHY_TITLE_PATH_FIELD } from '../constants.js'\nimport { buildLocalizedHierarchyPaths } from './buildLocalizedHierarchyPaths.js'\nimport { findFieldByName, findUseAsTitleField } from './findUseAsTitle.js'\nimport { getLocalizedValue } from './getLocalizedValue.js'\n\ntype ComputePathsArgs = {\n collection: SanitizedCollectionConfig\n doc: Document\n draft?: boolean\n locale?: string\n parentFieldName: string\n req: PayloadRequest\n slugPathFieldName?: string\n titlePathFieldName?: string\n}\n\ntype ComputePathsResult = {\n slugPath: Record<string, string> | string\n titlePath: Record<string, string> | string\n}\n\n// Helper to get title value - returns string for single locale, object for 'all' locales\nconst getTitleValue = ({\n document,\n isTitleLocalized = false,\n locale,\n req,\n titleFieldName,\n}: {\n document: Document\n isTitleLocalized?: boolean\n locale?: string\n req: PayloadRequest\n titleFieldName: string\n}): Record<string, string> | string => {\n const titleValue = document[titleFieldName]\n\n if (!titleValue) {\n return document.id?.toString() || 'untitled'\n }\n\n // If field is localized and we want all locales, return the full object\n if (isTitleLocalized && locale === 'all' && typeof titleValue === 'object') {\n return titleValue\n }\n\n // Single locale - use getLocalizedValue to handle fallback\n if (isTitleLocalized && typeof titleValue === 'object') {\n const localizedValue = getLocalizedValue({\n fallbackLocale: req.fallbackLocale,\n fieldType: 'text',\n locale: locale || req.locale || 'en',\n value: titleValue,\n })\n return localizedValue || document.id?.toString() || 'untitled'\n }\n\n return titleValue\n}\n\n// Helper to get slug value from a dedicated slug field\nconst getSlugFieldValue = ({\n document,\n isSlugLocalized = false,\n locale,\n req,\n slugFieldName,\n}: {\n document: Document\n isSlugLocalized?: boolean\n locale?: string\n req: PayloadRequest\n slugFieldName: string\n}): Record<string, string> | string | undefined => {\n const slugValue = document[slugFieldName]\n\n if (!slugValue) {\n return undefined\n }\n\n // If field is localized and we want all locales, return the full object\n if (isSlugLocalized && locale === 'all' && typeof slugValue === 'object') {\n return slugValue\n }\n\n // Single locale - use getLocalizedValue to handle fallback\n if (isSlugLocalized && typeof slugValue === 'object') {\n const localizedValue = getLocalizedValue({\n fallbackLocale: req.fallbackLocale,\n fieldType: 'text',\n locale: locale || req.locale || 'en',\n value: slugValue,\n })\n return localizedValue || undefined\n }\n\n return slugValue\n}\n\n/**\n * Computes both slug and title breadcrumb paths for a document by walking up the parent chain.\n * More efficient than computing them separately since it only walks the chain once.\n *\n * Note: Ancestor fetches always use `overrideAccess: true` to ensure paths are complete.\n * If a user can read a document, they should see its full breadcrumb path even if they\n * cannot read all ancestor documents. This prevents broken breadcrumbs and provides\n * better UX at the cost of minimal information leakage (ancestor titles in paths).\n *\n * @param args - Configuration for path computation\n * @returns Object with slugPath and titlePath\n */\nexport async function computePaths(args: ComputePathsArgs): Promise<ComputePathsResult> {\n const {\n collection,\n doc,\n draft = false,\n locale,\n parentFieldName,\n req,\n slugPathFieldName = HIERARCHY_SLUG_PATH_FIELD,\n titlePathFieldName = HIERARCHY_TITLE_PATH_FIELD,\n } = args\n\n const slugify =\n (collection.hierarchy !== false && collection.hierarchy.slugify) ||\n ((text: string) => payloadSlugify(text) || '')\n const { localized: isTitleLocalized, titleFieldName } = findUseAsTitleField(collection)\n\n // Check for dedicated slug field\n const slugFieldName = collection.hierarchy !== false ? collection.hierarchy.slugField : undefined\n const slugFieldInfo = slugFieldName ? findFieldByName(collection, slugFieldName) : undefined\n const isSlugFieldLocalized = slugFieldInfo?.localized ?? false\n\n // Initialize cache if it doesn't exist\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const context = req.context as any\n if (!context.hierarchyAncestorCache) {\n context.hierarchyAncestorCache = {}\n }\n if (!context.hierarchyAncestorCache[collection.slug]) {\n context.hierarchyAncestorCache[collection.slug] = {}\n }\n\n // Initialize cache stats if debug is enabled\n if (req.payload.config.debug && !context.hierarchyCacheStats) {\n context.hierarchyCacheStats = {\n hits: 0,\n misses: 0,\n queries: 0,\n }\n }\n\n const parentValue = doc[parentFieldName]\n let parentID: number | string | undefined\n\n if (!parentValue) {\n // No parent - root document\n parentID = undefined\n } else {\n // Extract ID from parent value\n // Parent can be:\n // - Plain ID (string/number)\n // - Populated object with { id: ... }\n if (typeof parentValue === 'object' && 'id' in parentValue) {\n parentID = parentValue.id\n } else {\n parentID = parentValue as number | string\n }\n }\n\n if (parentID) {\n // Parent is always from the same collection (self-referential)\n const parentCollectionConfig = collection\n const parentHierarchyConfig = parentCollectionConfig.hierarchy\n\n // If parent collection doesn't have hierarchy, we can't compute paths through it\n if (!parentHierarchyConfig || !parentCollectionConfig) {\n const titleValue = getTitleValue({\n document: doc,\n isTitleLocalized,\n locale,\n req,\n titleFieldName,\n })\n\n const slugValue = slugFieldName\n ? getSlugFieldValue({\n document: doc,\n isSlugLocalized: isSlugFieldLocalized,\n locale,\n req,\n slugFieldName,\n })\n : undefined\n\n if (isTitleLocalized && locale === 'all') {\n return buildLocalizedHierarchyPaths({\n req,\n slugify,\n slugValue: slugValue as Record<string, string> | undefined,\n titleValue: titleValue as Record<string, string>,\n })\n }\n\n return {\n slugPath: slugValue !== undefined ? (slugValue as string) : slugify(titleValue as string),\n titlePath: titleValue as string,\n }\n }\n\n // Initialize cache for parent collection if needed\n if (!context.hierarchyAncestorCache[collection.slug]) {\n context.hierarchyAncestorCache[collection.slug] = {}\n }\n\n const cache = context.hierarchyAncestorCache[collection.slug]\n const cacheKey = `${parentID}_${locale || 'default'}`\n\n // Check cache first\n let parent = cache[cacheKey]\n\n if (parent) {\n // Cache hit\n if (context.hierarchyCacheStats) {\n context.hierarchyCacheStats.hits += 1\n }\n } else {\n // Cache miss - fetch parent\n if (context.hierarchyCacheStats) {\n context.hierarchyCacheStats.misses += 1\n context.hierarchyCacheStats.queries += 1\n }\n\n const parentTitleField = findUseAsTitleField(parentCollectionConfig).titleFieldName\n\n // parentID is guaranteed to be defined here (we're inside if (parentID))\n const validParentID = parentID\n\n // Create new context with computeHierarchyPaths enabled to trigger recursive path computation\n const parentReq = {\n ...req,\n context: {\n ...req.context,\n computeHierarchyPaths: true,\n },\n }\n\n // Fetch parent\n // When locale === 'all', we need special handling because Payload doesn't support\n // fetching all locales of a draft document (drafts are stored per-locale).\n // Strategy: Try published first, fallback to fetching each locale separately for drafts.\n const fetchParent = async () => {\n if (locale === 'all') {\n try {\n // First try to fetch published version with all locales\n return await req.payload.findByID({\n id: validParentID,\n collection: collection.slug,\n depth: 0,\n locale,\n overrideAccess: true,\n req: parentReq,\n select: {\n [parentHierarchyConfig.parentFieldName]: true,\n [parentHierarchyConfig.slugPathFieldName]: true,\n [parentHierarchyConfig.titlePathFieldName]: true,\n [parentTitleField]: true,\n ...(slugFieldName ? { [slugFieldName]: true } : {}),\n },\n user: req.user,\n })\n } catch (_error) {\n // Published version not found, must be a draft\n // Payload doesn't support fetching all locales of a draft with a single query\n // So we need to fetch each locale separately and combine the path data\n const locales = req.payload.config.localization\n ? req.payload.config.localization.localeCodes\n : []\n const parentPathsByLocale: Record<\n string,\n { slugPath?: string; title?: string; titlePath?: string }\n > = {}\n\n // Get parent collection's slugify function (may differ from child's)\n const parentSlugify =\n (parentCollectionConfig.hierarchy !== false &&\n parentCollectionConfig.hierarchy.slugify) ||\n ((text: string) => payloadSlugify(text) || '')\n\n // Fetch parent for each locale to get paths\n for (const loc of locales) {\n // Create a new request with this specific locale but keep computeHierarchyPaths flag\n const localeReq = {\n ...req,\n context: {\n ...req.context,\n computeHierarchyPaths: true,\n },\n locale: loc,\n }\n\n try {\n const parentForLocale = await req.payload.findByID({\n id: validParentID,\n collection: collection.slug,\n depth: 0,\n draft: true,\n locale: loc,\n overrideAccess: true,\n req: localeReq,\n user: req.user,\n })\n\n // Extract the path fields and title from the parent\n // If paths weren't computed (undefined), compute them manually for root documents\n let parentSlugPath = parentForLocale[parentHierarchyConfig.slugPathFieldName]\n let parentTitlePath = parentForLocale[parentHierarchyConfig.titlePathFieldName]\n const parentTitle = parentForLocale[parentTitleField]\n\n // If paths are undefined, this might be a root document - compute paths from title\n if (!parentSlugPath && parentTitle) {\n parentSlugPath = parentSlugify(parentTitle)\n }\n if (!parentTitlePath && parentTitle) {\n parentTitlePath = parentTitle\n }\n\n parentPathsByLocale[loc] = {\n slugPath: parentSlugPath,\n title: parentTitle,\n titlePath: parentTitlePath,\n }\n } catch (_localeError) {\n // This locale doesn't exist, skip it\n }\n }\n\n // Combine the path data from all locales into a single parent object\n const combinedSlugPaths: Record<string, string | undefined> = {}\n const combinedTitlePaths: Record<string, string | undefined> = {}\n const combinedTitles: Record<string, string | undefined> = {}\n\n for (const loc of locales) {\n if (parentPathsByLocale[loc]) {\n combinedSlugPaths[loc] = parentPathsByLocale[loc].slugPath\n combinedTitlePaths[loc] = parentPathsByLocale[loc].titlePath\n combinedTitles[loc] = parentPathsByLocale[loc].title\n }\n }\n\n // Return a parent object with only the hierarchy fields we need\n // (all properly formatted as multi-locale objects)\n return {\n id: validParentID,\n [parentHierarchyConfig.slugPathFieldName]: combinedSlugPaths,\n [parentHierarchyConfig.titlePathFieldName]: combinedTitlePaths,\n [parentTitleField]: combinedTitles,\n }\n }\n } else {\n // Normal case: single locale, can pass draft parameter\n return await req.payload.findByID({\n id: validParentID,\n collection: collection.slug,\n depth: 0,\n draft,\n locale,\n overrideAccess: true,\n req: parentReq,\n select: {\n [parentHierarchyConfig.parentFieldName]: true,\n [parentHierarchyConfig.slugPathFieldName]: true,\n [parentHierarchyConfig.titlePathFieldName]: true,\n [parentTitleField]: true,\n ...(slugFieldName ? { [slugFieldName]: true } : {}),\n },\n user: req.user,\n })\n }\n }\n\n try {\n parent = await fetchParent()\n\n // Store in cache\n cache[cacheKey] = parent\n } catch {\n // If we can't fetch the parent at all (even with fallbacks), treat this as a root document\n // This can happen with complex draft/locale combinations\n parentID = undefined\n }\n }\n\n // If parent fetch failed, treat as root document\n if (!parentID || !parent) {\n const titleValue = getTitleValue({\n document: doc,\n isTitleLocalized,\n locale,\n req,\n titleFieldName,\n })\n\n const slugValue = slugFieldName\n ? getSlugFieldValue({\n document: doc,\n isSlugLocalized: isSlugFieldLocalized,\n locale,\n req,\n slugFieldName,\n })\n : undefined\n\n if (isTitleLocalized && locale === 'all') {\n return buildLocalizedHierarchyPaths({\n req,\n slugify,\n slugValue: slugValue as Record<string, string> | undefined,\n titleValue: titleValue as Record<string, string>,\n })\n }\n\n return {\n slugPath: slugValue !== undefined ? (slugValue as string) : slugify(titleValue as string),\n titlePath: titleValue as string,\n }\n }\n\n const docTitle = getTitleValue({ document: doc, isTitleLocalized, locale, req, titleFieldName })\n\n // Cache the current document (in its own collection's cache)\n const currentDocCacheKey = `${doc.id}_${locale || 'default'}`\n if (!context.hierarchyAncestorCache[collection.slug]) {\n context.hierarchyAncestorCache[collection.slug] = {}\n }\n context.hierarchyAncestorCache[collection.slug][currentDocCacheKey] = {\n [parentFieldName]: parentID,\n [slugPathFieldName]: undefined, // Will be set below\n [titleFieldName]: docTitle,\n [titlePathFieldName]: undefined, // Will be set below\n }\n\n // Get parent's path field names from hierarchy config\n const parentSlugPathFieldName =\n parentCollectionConfig.hierarchy !== false\n ? parentCollectionConfig.hierarchy.slugPathFieldName\n : HIERARCHY_SLUG_PATH_FIELD\n const parentTitlePathFieldName =\n parentCollectionConfig.hierarchy !== false\n ? parentCollectionConfig.hierarchy.titlePathFieldName\n : HIERARCHY_TITLE_PATH_FIELD\n\n // Handle localized case (locale === 'all' with localized title field)\n if (isTitleLocalized && locale === 'all') {\n // Parent might have non-localized title field, resulting in string paths instead of objects\n // Convert parent paths to objects if they're strings (use same value for all locales)\n let parentSlugPathObj: Record<string, string> | undefined = parent[\n parentSlugPathFieldName\n ] as Record<string, string> | undefined\n let parentTitlePathObj: Record<string, string> | undefined = parent[\n parentTitlePathFieldName\n ] as Record<string, string> | undefined\n\n // If parent paths are strings (non-localized parent), convert to objects for all locales\n if (typeof parentSlugPathObj === 'string') {\n const locales = req.payload.config.localization\n ? req.payload.config.localization.localeCodes\n : []\n const slugValue = parentSlugPathObj\n parentSlugPathObj = {}\n for (const loc of locales) {\n parentSlugPathObj[loc] = slugValue\n }\n }\n\n if (typeof parentTitlePathObj === 'string') {\n const locales = req.payload.config.localization\n ? req.payload.config.localization.localeCodes\n : []\n const titleValue = parentTitlePathObj\n parentTitlePathObj = {}\n for (const loc of locales) {\n parentTitlePathObj[loc] = titleValue\n }\n }\n\n // Get slug value if slugField is configured\n const docSlugValue = slugFieldName\n ? getSlugFieldValue({\n document: doc,\n isSlugLocalized: isSlugFieldLocalized,\n locale,\n req,\n slugFieldName,\n })\n : undefined\n\n // If parent paths are undefined (parent fetch failed or paths not computed),\n // buildLocalizedHierarchyPaths will handle it by using just the child's title\n const result = buildLocalizedHierarchyPaths({\n parentSlugPath: parentSlugPathObj,\n parentTitlePath: parentTitlePathObj,\n req,\n slugify,\n slugValue: docSlugValue as Record<string, string> | undefined,\n titleValue: docTitle as Record<string, string>,\n })\n\n // Update cache with computed paths\n context.hierarchyAncestorCache[collection.slug][currentDocCacheKey][slugPathFieldName] =\n result.slugPath\n context.hierarchyAncestorCache[collection.slug][currentDocCacheKey][titlePathFieldName] =\n result.titlePath\n\n return result\n }\n\n // Single locale case - get slug value if slugField is configured\n const singleLocaleSlugValue = slugFieldName\n ? getSlugFieldValue({\n document: doc,\n isSlugLocalized: isSlugFieldLocalized,\n locale,\n req,\n slugFieldName,\n })\n : undefined\n\n const slugSegment =\n singleLocaleSlugValue !== undefined\n ? (singleLocaleSlugValue as string)\n : slugify(docTitle as string)\n\n const result = {\n slugPath: (parent[parentSlugPathFieldName] as string) + '/' + slugSegment,\n titlePath: (parent[parentTitlePathFieldName] as string) + '/' + (docTitle as string),\n }\n\n // Update cache with computed paths\n context.hierarchyAncestorCache[collection.slug][currentDocCacheKey][slugPathFieldName] =\n result.slugPath\n context.hierarchyAncestorCache[collection.slug][currentDocCacheKey][titlePathFieldName] =\n result.titlePath\n\n return result\n } else {\n // Root document (no parent)\n const titleValue = getTitleValue({\n document: doc,\n isTitleLocalized,\n locale,\n req,\n titleFieldName,\n })\n context.hierarchyAncestorCache[collection.slug][doc.id] = {\n [parentFieldName]: null,\n [titleFieldName]: titleValue,\n }\n\n const rootSlugValue = slugFieldName\n ? getSlugFieldValue({\n document: doc,\n isSlugLocalized: isSlugFieldLocalized,\n locale,\n req,\n slugFieldName,\n })\n : undefined\n\n // Handle localized case (locale === 'all' with localized title field)\n if (isTitleLocalized && locale === 'all') {\n return buildLocalizedHierarchyPaths({\n req,\n slugify,\n slugValue: rootSlugValue as Record<string, string> | undefined,\n titleValue: titleValue as Record<string, string>,\n })\n }\n\n // Single locale case\n return {\n slugPath:\n rootSlugValue !== undefined ? (rootSlugValue as string) : slugify(titleValue as string),\n titlePath: titleValue as string,\n }\n }\n}\n"],"names":["slugify","payloadSlugify","HIERARCHY_SLUG_PATH_FIELD","HIERARCHY_TITLE_PATH_FIELD","buildLocalizedHierarchyPaths","findFieldByName","findUseAsTitleField","getLocalizedValue","getTitleValue","document","isTitleLocalized","locale","req","titleFieldName","titleValue","id","toString","localizedValue","fallbackLocale","fieldType","value","getSlugFieldValue","isSlugLocalized","slugFieldName","slugValue","undefined","computePaths","args","collection","doc","draft","parentFieldName","slugPathFieldName","titlePathFieldName","hierarchy","text","localized","slugField","slugFieldInfo","isSlugFieldLocalized","context","hierarchyAncestorCache","slug","payload","config","debug","hierarchyCacheStats","hits","misses","queries","parentValue","parentID","parentCollectionConfig","parentHierarchyConfig","slugPath","titlePath","cache","cacheKey","parent","parentTitleField","validParentID","parentReq","computeHierarchyPaths","fetchParent","findByID","depth","overrideAccess","select","user","_error","locales","localization","localeCodes","parentPathsByLocale","parentSlugify","loc","localeReq","parentForLocale","parentSlugPath","parentTitlePath","parentTitle","title","_localeError","combinedSlugPaths","combinedTitlePaths","combinedTitles","docTitle","currentDocCacheKey","parentSlugPathFieldName","parentTitlePathFieldName","parentSlugPathObj","parentTitlePathObj","docSlugValue","result","singleLocaleSlugValue","slugSegment","rootSlugValue"],"mappings":"AAGA,SAASA,WAAWC,cAAc,QAAQ,6BAA4B;AACtE,SAASC,yBAAyB,EAAEC,0BAA0B,QAAQ,kBAAiB;AACvF,SAASC,4BAA4B,QAAQ,oCAAmC;AAChF,SAASC,eAAe,EAAEC,mBAAmB,QAAQ,sBAAqB;AAC1E,SAASC,iBAAiB,QAAQ,yBAAwB;AAkB1D,yFAAyF;AACzF,MAAMC,gBAAgB,CAAC,EACrBC,QAAQ,EACRC,mBAAmB,KAAK,EACxBC,MAAM,EACNC,GAAG,EACHC,cAAc,EAOf;IACC,MAAMC,aAAaL,QAAQ,CAACI,eAAe;IAE3C,IAAI,CAACC,YAAY;QACf,OAAOL,SAASM,EAAE,EAAEC,cAAc;IACpC;IAEA,wEAAwE;IACxE,IAAIN,oBAAoBC,WAAW,SAAS,OAAOG,eAAe,UAAU;QAC1E,OAAOA;IACT;IAEA,2DAA2D;IAC3D,IAAIJ,oBAAoB,OAAOI,eAAe,UAAU;QACtD,MAAMG,iBAAiBV,kBAAkB;YACvCW,gBAAgBN,IAAIM,cAAc;YAClCC,WAAW;YACXR,QAAQA,UAAUC,IAAID,MAAM,IAAI;YAChCS,OAAON;QACT;QACA,OAAOG,kBAAkBR,SAASM,EAAE,EAAEC,cAAc;IACtD;IAEA,OAAOF;AACT;AAEA,uDAAuD;AACvD,MAAMO,oBAAoB,CAAC,EACzBZ,QAAQ,EACRa,kBAAkB,KAAK,EACvBX,MAAM,EACNC,GAAG,EACHW,aAAa,EAOd;IACC,MAAMC,YAAYf,QAAQ,CAACc,cAAc;IAEzC,IAAI,CAACC,WAAW;QACd,OAAOC;IACT;IAEA,wEAAwE;IACxE,IAAI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ACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/hierarchy/utils/computePaths.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../collections/config/types.js'\nimport type { Document, PayloadRequest } from '../../types/index.js'\n\nimport { slugify as payloadSlugify } from '../../utilities/slugify.js'\nimport { HIERARCHY_SLUG_PATH_FIELD, HIERARCHY_TITLE_PATH_FIELD } from '../constants.js'\nimport { buildLocalizedHierarchyPaths } from './buildLocalizedHierarchyPaths.js'\nimport { findFieldByName, findUseAsTitleField } from './findUseAsTitle.js'\nimport { getLocalizedValue } from './getLocalizedValue.js'\n\ntype ComputePathsArgs = {\n collection: SanitizedCollectionConfig\n doc: Document\n draft?: boolean\n locale?: string\n parentFieldName: string\n req: PayloadRequest\n slugPathFieldName?: string\n titlePathFieldName?: string\n}\n\ntype ComputePathsResult = {\n slugPath: Record<string, string> | string\n titlePath: Record<string, string> | string\n}\n\n// Helper to get title value - returns string for single locale, object for 'all' locales\nconst getTitleValue = ({\n document,\n isTitleLocalized = false,\n locale,\n req,\n titleFieldName,\n}: {\n document: Document\n isTitleLocalized?: boolean\n locale?: string\n req: PayloadRequest\n titleFieldName: string\n}): Record<string, string> | string => {\n const titleValue = document[titleFieldName]\n\n if (!titleValue) {\n return document.id?.toString() || 'untitled'\n }\n\n // If field is localized and we want all locales, return the full object\n if (isTitleLocalized && locale === 'all' && typeof titleValue === 'object') {\n return titleValue\n }\n\n // Single locale - use getLocalizedValue to handle fallback\n if (isTitleLocalized && typeof titleValue === 'object') {\n const localizedValue = getLocalizedValue({\n fallbackLocale: req.fallbackLocale,\n fieldType: 'text',\n locale: locale || req.locale || 'en',\n value: titleValue,\n })\n return localizedValue || document.id?.toString() || 'untitled'\n }\n\n return titleValue\n}\n\n// Helper to get slug value from a dedicated slug field\nconst getSlugFieldValue = ({\n document,\n isSlugLocalized = false,\n locale,\n req,\n slugFieldName,\n}: {\n document: Document\n isSlugLocalized?: boolean\n locale?: string\n req: PayloadRequest\n slugFieldName: string\n}): Record<string, string> | string | undefined => {\n const slugValue = document[slugFieldName]\n\n if (!slugValue) {\n return undefined\n }\n\n // If field is localized and we want all locales, return the full object\n if (isSlugLocalized && locale === 'all' && typeof slugValue === 'object') {\n return slugValue\n }\n\n // Single locale - use getLocalizedValue to handle fallback\n if (isSlugLocalized && typeof slugValue === 'object') {\n const localizedValue = getLocalizedValue({\n fallbackLocale: req.fallbackLocale,\n fieldType: 'text',\n locale: locale || req.locale || 'en',\n value: slugValue,\n })\n return localizedValue || undefined\n }\n\n return slugValue\n}\n\n/**\n * Computes both slug and title breadcrumb paths for a document by walking up the parent chain.\n * More efficient than computing them separately since it only walks the chain once.\n *\n * Note: Ancestor fetches always use `overrideAccess: true` to ensure paths are complete.\n * If a user can read a document, they should see its full breadcrumb path even if they\n * cannot read all ancestor documents. This prevents broken breadcrumbs and provides\n * better UX at the cost of minimal information leakage (ancestor titles in paths).\n *\n * @param args - Configuration for path computation\n * @returns Object with slugPath and titlePath\n */\nexport async function computePaths(args: ComputePathsArgs): Promise<ComputePathsResult> {\n const {\n collection,\n doc,\n draft = false,\n locale,\n parentFieldName,\n req,\n slugPathFieldName = HIERARCHY_SLUG_PATH_FIELD,\n titlePathFieldName = HIERARCHY_TITLE_PATH_FIELD,\n } = args\n\n const slugify =\n (collection.hierarchy !== false && collection.hierarchy.slugify) ||\n ((text: string) => payloadSlugify(text) || '')\n const { localized: isTitleLocalized, titleFieldName } = findUseAsTitleField(collection)\n\n // Check for dedicated slug field\n const slugFieldName = collection.hierarchy !== false ? collection.hierarchy.slugField : undefined\n const slugFieldInfo = slugFieldName ? findFieldByName(collection, slugFieldName) : undefined\n const isSlugFieldLocalized = slugFieldInfo?.localized ?? false\n\n // Initialize cache if it doesn't exist\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const context = req.context as any\n if (!context.hierarchyAncestorCache) {\n context.hierarchyAncestorCache = {}\n }\n if (!context.hierarchyAncestorCache[collection.slug]) {\n context.hierarchyAncestorCache[collection.slug] = {}\n }\n\n // Initialize cache stats if debug is enabled\n if (req.payload.config.debug && !context.hierarchyCacheStats) {\n context.hierarchyCacheStats = {\n hits: 0,\n misses: 0,\n queries: 0,\n }\n }\n\n const parentValue = doc[parentFieldName]\n let parentID: number | string | undefined\n\n if (!parentValue) {\n // No parent - root document\n parentID = undefined\n } else {\n // Extract ID from parent value\n // Parent can be:\n // - Plain ID (string/number)\n // - Populated object with { id: ... }\n if (typeof parentValue === 'object' && 'id' in parentValue) {\n parentID = parentValue.id\n } else {\n parentID = parentValue as number | string\n }\n }\n\n if (parentID) {\n // Parent is always from the same collection (self-referential)\n const parentCollectionConfig = collection\n const parentHierarchyConfig = parentCollectionConfig.hierarchy\n\n // If parent collection doesn't have hierarchy, we can't compute paths through it\n if (!parentHierarchyConfig || !parentCollectionConfig) {\n const titleValue = getTitleValue({\n document: doc,\n isTitleLocalized,\n locale,\n req,\n titleFieldName,\n })\n\n const slugValue = slugFieldName\n ? getSlugFieldValue({\n document: doc,\n isSlugLocalized: isSlugFieldLocalized,\n locale,\n req,\n slugFieldName,\n })\n : undefined\n\n if (isTitleLocalized && locale === 'all') {\n return buildLocalizedHierarchyPaths({\n req,\n slugify,\n slugValue: slugValue as Record<string, string> | undefined,\n titleValue: titleValue as Record<string, string>,\n })\n }\n\n return {\n slugPath: slugValue !== undefined ? slugValue : slugify(titleValue as string),\n titlePath: titleValue as string,\n }\n }\n\n // Initialize cache for parent collection if needed\n if (!context.hierarchyAncestorCache[collection.slug]) {\n context.hierarchyAncestorCache[collection.slug] = {}\n }\n\n const cache = context.hierarchyAncestorCache[collection.slug]\n const cacheKey = `${parentID}_${locale || 'default'}`\n\n // Check cache first\n let parent = cache[cacheKey]\n\n if (parent) {\n // Cache hit\n if (context.hierarchyCacheStats) {\n context.hierarchyCacheStats.hits += 1\n }\n } else {\n // Cache miss - fetch parent\n if (context.hierarchyCacheStats) {\n context.hierarchyCacheStats.misses += 1\n context.hierarchyCacheStats.queries += 1\n }\n\n const parentTitleField = findUseAsTitleField(parentCollectionConfig).titleFieldName\n\n // parentID is guaranteed to be defined here (we're inside if (parentID))\n const validParentID = parentID\n\n // Create new context with computeHierarchyPaths enabled to trigger recursive path computation\n const parentReq = {\n ...req,\n context: {\n ...req.context,\n computeHierarchyPaths: true,\n },\n }\n\n // Fetch parent\n // When locale === 'all', we need special handling because Payload doesn't support\n // fetching all locales of a draft document (drafts are stored per-locale).\n // Strategy: Try published first, fallback to fetching each locale separately for drafts.\n const fetchParent = async () => {\n if (locale === 'all') {\n try {\n // First try to fetch published version with all locales\n return await req.payload.findByID({\n id: validParentID,\n collection: collection.slug,\n depth: 0,\n locale,\n overrideAccess: true,\n req: parentReq,\n select: {\n [parentHierarchyConfig.parentFieldName]: true,\n [parentHierarchyConfig.slugPathFieldName]: true,\n [parentHierarchyConfig.titlePathFieldName]: true,\n [parentTitleField]: true,\n ...(slugFieldName ? { [slugFieldName]: true } : {}),\n },\n user: req.user,\n })\n } catch (_error) {\n // Published version not found, must be a draft\n // Payload doesn't support fetching all locales of a draft with a single query\n // So we need to fetch each locale separately and combine the path data\n const locales = req.payload.config.localization\n ? req.payload.config.localization.localeCodes\n : []\n const parentPathsByLocale: Record<\n string,\n { slugPath?: string; title?: string; titlePath?: string }\n > = {}\n\n // Get parent collection's slugify function (may differ from child's)\n const parentSlugify =\n (parentCollectionConfig.hierarchy !== false &&\n parentCollectionConfig.hierarchy.slugify) ||\n ((text: string) => payloadSlugify(text) || '')\n\n // Fetch parent for each locale to get paths\n for (const loc of locales) {\n // Create a new request with this specific locale but keep computeHierarchyPaths flag\n const localeReq = {\n ...req,\n context: {\n ...req.context,\n computeHierarchyPaths: true,\n },\n locale: loc,\n }\n\n try {\n const parentForLocale = await req.payload.findByID({\n id: validParentID,\n collection: collection.slug,\n depth: 0,\n draft: true,\n locale: loc,\n overrideAccess: true,\n req: localeReq,\n user: req.user,\n })\n\n // Extract the path fields and title from the parent\n // If paths weren't computed (undefined), compute them manually for root documents\n let parentSlugPath = parentForLocale[parentHierarchyConfig.slugPathFieldName]\n let parentTitlePath = parentForLocale[parentHierarchyConfig.titlePathFieldName]\n const parentTitle = parentForLocale[parentTitleField]\n\n // If paths are undefined, this might be a root document - compute paths from title\n if (!parentSlugPath && parentTitle) {\n parentSlugPath = parentSlugify(parentTitle)\n }\n if (!parentTitlePath && parentTitle) {\n parentTitlePath = parentTitle\n }\n\n parentPathsByLocale[loc] = {\n slugPath: parentSlugPath,\n title: parentTitle,\n titlePath: parentTitlePath,\n }\n } catch (_localeError) {\n // This locale doesn't exist, skip it\n }\n }\n\n // Combine the path data from all locales into a single parent object\n const combinedSlugPaths: Record<string, string | undefined> = {}\n const combinedTitlePaths: Record<string, string | undefined> = {}\n const combinedTitles: Record<string, string | undefined> = {}\n\n for (const loc of locales) {\n if (parentPathsByLocale[loc]) {\n combinedSlugPaths[loc] = parentPathsByLocale[loc].slugPath\n combinedTitlePaths[loc] = parentPathsByLocale[loc].titlePath\n combinedTitles[loc] = parentPathsByLocale[loc].title\n }\n }\n\n // Return a parent object with only the hierarchy fields we need\n // (all properly formatted as multi-locale objects)\n return {\n id: validParentID,\n [parentHierarchyConfig.slugPathFieldName]: combinedSlugPaths,\n [parentHierarchyConfig.titlePathFieldName]: combinedTitlePaths,\n [parentTitleField]: combinedTitles,\n }\n }\n } else {\n // Normal case: single locale, can pass draft parameter\n return await req.payload.findByID({\n id: validParentID,\n collection: collection.slug,\n depth: 0,\n draft,\n locale,\n overrideAccess: true,\n req: parentReq,\n select: {\n [parentHierarchyConfig.parentFieldName]: true,\n [parentHierarchyConfig.slugPathFieldName]: true,\n [parentHierarchyConfig.titlePathFieldName]: true,\n [parentTitleField]: true,\n ...(slugFieldName ? { [slugFieldName]: true } : {}),\n },\n user: req.user,\n })\n }\n }\n\n try {\n parent = await fetchParent()\n\n // Store in cache\n cache[cacheKey] = parent\n } catch {\n // If we can't fetch the parent at all (even with fallbacks), treat this as a root document\n // This can happen with complex draft/locale combinations\n parentID = undefined\n }\n }\n\n // If parent fetch failed, treat as root document\n if (!parentID || !parent) {\n const titleValue = getTitleValue({\n document: doc,\n isTitleLocalized,\n locale,\n req,\n titleFieldName,\n })\n\n const slugValue = slugFieldName\n ? getSlugFieldValue({\n document: doc,\n isSlugLocalized: isSlugFieldLocalized,\n locale,\n req,\n slugFieldName,\n })\n : undefined\n\n if (isTitleLocalized && locale === 'all') {\n return buildLocalizedHierarchyPaths({\n req,\n slugify,\n slugValue: slugValue as Record<string, string> | undefined,\n titleValue: titleValue as Record<string, string>,\n })\n }\n\n return {\n slugPath: slugValue !== undefined ? slugValue : slugify(titleValue as string),\n titlePath: titleValue as string,\n }\n }\n\n const docTitle = getTitleValue({ document: doc, isTitleLocalized, locale, req, titleFieldName })\n\n // Cache the current document (in its own collection's cache)\n const currentDocCacheKey = `${doc.id}_${locale || 'default'}`\n if (!context.hierarchyAncestorCache[collection.slug]) {\n context.hierarchyAncestorCache[collection.slug] = {}\n }\n context.hierarchyAncestorCache[collection.slug][currentDocCacheKey] = {\n [parentFieldName]: parentID,\n [slugPathFieldName]: undefined, // Will be set below\n [titleFieldName]: docTitle,\n [titlePathFieldName]: undefined, // Will be set below\n }\n\n // Get parent's path field names from hierarchy config\n const parentSlugPathFieldName =\n parentCollectionConfig.hierarchy !== false\n ? parentCollectionConfig.hierarchy.slugPathFieldName\n : HIERARCHY_SLUG_PATH_FIELD\n const parentTitlePathFieldName =\n parentCollectionConfig.hierarchy !== false\n ? parentCollectionConfig.hierarchy.titlePathFieldName\n : HIERARCHY_TITLE_PATH_FIELD\n\n // Handle localized case (locale === 'all' with localized title field)\n if (isTitleLocalized && locale === 'all') {\n // Parent might have non-localized title field, resulting in string paths instead of objects\n // Convert parent paths to objects if they're strings (use same value for all locales)\n let parentSlugPathObj: Record<string, string> | undefined = parent[\n parentSlugPathFieldName\n ] as Record<string, string> | undefined\n let parentTitlePathObj: Record<string, string> | undefined = parent[\n parentTitlePathFieldName\n ] as Record<string, string> | undefined\n\n // If parent paths are strings (non-localized parent), convert to objects for all locales\n if (typeof parentSlugPathObj === 'string') {\n const locales = req.payload.config.localization\n ? req.payload.config.localization.localeCodes\n : []\n const slugValue = parentSlugPathObj\n parentSlugPathObj = {}\n for (const loc of locales) {\n parentSlugPathObj[loc] = slugValue\n }\n }\n\n if (typeof parentTitlePathObj === 'string') {\n const locales = req.payload.config.localization\n ? req.payload.config.localization.localeCodes\n : []\n const titleValue = parentTitlePathObj\n parentTitlePathObj = {}\n for (const loc of locales) {\n parentTitlePathObj[loc] = titleValue\n }\n }\n\n // Get slug value if slugField is configured\n const docSlugValue = slugFieldName\n ? getSlugFieldValue({\n document: doc,\n isSlugLocalized: isSlugFieldLocalized,\n locale,\n req,\n slugFieldName,\n })\n : undefined\n\n // If parent paths are undefined (parent fetch failed or paths not computed),\n // buildLocalizedHierarchyPaths will handle it by using just the child's title\n const result = buildLocalizedHierarchyPaths({\n parentSlugPath: parentSlugPathObj,\n parentTitlePath: parentTitlePathObj,\n req,\n slugify,\n slugValue: docSlugValue as Record<string, string> | undefined,\n titleValue: docTitle as Record<string, string>,\n })\n\n // Update cache with computed paths\n context.hierarchyAncestorCache[collection.slug][currentDocCacheKey][slugPathFieldName] =\n result.slugPath\n context.hierarchyAncestorCache[collection.slug][currentDocCacheKey][titlePathFieldName] =\n result.titlePath\n\n return result\n }\n\n // Single locale case - get slug value if slugField is configured\n const singleLocaleSlugValue = slugFieldName\n ? getSlugFieldValue({\n document: doc,\n isSlugLocalized: isSlugFieldLocalized,\n locale,\n req,\n slugFieldName,\n })\n : undefined\n\n const slugSegment =\n singleLocaleSlugValue !== undefined\n ? (singleLocaleSlugValue as string)\n : slugify(docTitle as string)\n\n const result = {\n slugPath: (parent[parentSlugPathFieldName] as string) + '/' + slugSegment,\n titlePath: (parent[parentTitlePathFieldName] as string) + '/' + (docTitle as string),\n }\n\n // Update cache with computed paths\n context.hierarchyAncestorCache[collection.slug][currentDocCacheKey][slugPathFieldName] =\n result.slugPath\n context.hierarchyAncestorCache[collection.slug][currentDocCacheKey][titlePathFieldName] =\n result.titlePath\n\n return result\n } else {\n // Root document (no parent)\n const titleValue = getTitleValue({\n document: doc,\n isTitleLocalized,\n locale,\n req,\n titleFieldName,\n })\n context.hierarchyAncestorCache[collection.slug][doc.id] = {\n [parentFieldName]: null,\n [titleFieldName]: titleValue,\n }\n\n const rootSlugValue = slugFieldName\n ? getSlugFieldValue({\n document: doc,\n isSlugLocalized: isSlugFieldLocalized,\n locale,\n req,\n slugFieldName,\n })\n : undefined\n\n // Handle localized case (locale === 'all' with localized title field)\n if (isTitleLocalized && locale === 'all') {\n return buildLocalizedHierarchyPaths({\n req,\n slugify,\n slugValue: rootSlugValue as Record<string, string> | undefined,\n titleValue: titleValue as Record<string, string>,\n })\n }\n\n // Single locale case\n return {\n slugPath: rootSlugValue !== undefined ? rootSlugValue : slugify(titleValue as string),\n titlePath: titleValue as string,\n }\n }\n}\n"],"names":["slugify","payloadSlugify","HIERARCHY_SLUG_PATH_FIELD","HIERARCHY_TITLE_PATH_FIELD","buildLocalizedHierarchyPaths","findFieldByName","findUseAsTitleField","getLocalizedValue","getTitleValue","document","isTitleLocalized","locale","req","titleFieldName","titleValue","id","toString","localizedValue","fallbackLocale","fieldType","value","getSlugFieldValue","isSlugLocalized","slugFieldName","slugValue","undefined","computePaths","args","collection","doc","draft","parentFieldName","slugPathFieldName","titlePathFieldName","hierarchy","text","localized","slugField","slugFieldInfo","isSlugFieldLocalized","context","hierarchyAncestorCache","slug","payload","config","debug","hierarchyCacheStats","hits","misses","queries","parentValue","parentID","parentCollectionConfig","parentHierarchyConfig","slugPath","titlePath","cache","cacheKey","parent","parentTitleField","validParentID","parentReq","computeHierarchyPaths","fetchParent","findByID","depth","overrideAccess","select","user","_error","locales","localization","localeCodes","parentPathsByLocale","parentSlugify","loc","localeReq","parentForLocale","parentSlugPath","parentTitlePath","parentTitle","title","_localeError","combinedSlugPaths","combinedTitlePaths","combinedTitles","docTitle","currentDocCacheKey","parentSlugPathFieldName","parentTitlePathFieldName","parentSlugPathObj","parentTitlePathObj","docSlugValue","result","singleLocaleSlugValue","slugSegment","rootSlugValue"],"mappings":"AAGA,SAASA,WAAWC,cAAc,QAAQ,6BAA4B;AACtE,SAASC,yBAAyB,EAAEC,0BAA0B,QAAQ,kBAAiB;AACvF,SAASC,4BAA4B,QAAQ,oCAAmC;AAChF,SAASC,eAAe,EAAEC,mBAAmB,QAAQ,sBAAqB;AAC1E,SAASC,iBAAiB,QAAQ,yBAAwB;AAkB1D,yFAAyF;AACzF,MAAMC,gBAAgB,CAAC,EACrBC,QAAQ,EACRC,mBAAmB,KAAK,EACxBC,MAAM,EACNC,GAAG,EACHC,cAAc,EAOf;IACC,MAAMC,aAAaL,QAAQ,CAACI,eAAe;IAE3C,IAAI,CAACC,YAAY;QACf,OAAOL,SAASM,EAAE,EAAEC,cAAc;IACpC;IAEA,wEAAwE;IACxE,IAAIN,oBAAoBC,WAAW,SAAS,OAAOG,eAAe,UAAU;QAC1E,OAAOA;IACT;IAEA,2DAA2D;IAC3D,IAAIJ,oBAAoB,OAAOI,eAAe,UAAU;QACtD,MAAMG,iBAAiBV,kBAAkB;YACvCW,gBAAgBN,IAAIM,cAAc;YAClCC,WAAW;YACXR,QAAQA,UAAUC,IAAID,MAAM,IAAI;YAChCS,OAAON;QACT;QACA,OAAOG,kBAAkBR,SAASM,EAAE,EAAEC,cAAc;IACtD;IAEA,OAAOF;AACT;AAEA,uDAAuD;AACvD,MAAMO,oBAAoB,CAAC,EACzBZ,QAAQ,EACRa,kBAAkB,KAAK,EACvBX,MAAM,EACNC,GAAG,EACHW,aAAa,EAOd;IACC,MAAMC,YAAYf,QAAQ,CAACc,cAAc;IAEzC,IAAI,CAACC,WAAW;QACd,OAAOC;IACT;IAEA,wEAAwE;IACxE,IAAIH,mBAAmBX,WAAW,SAAS,OAAOa,cAAc,UAAU;QACxE,OAAOA;IACT;IAEA,2DAA2D;IAC3D,IAAIF,mBAAmB,OAAOE,cAAc,UAAU;QACpD,MAAMP,i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AC1BF,kBAAkB;YAChBZ,UAAUoB;YACVP,iBAAiBiB;YACjB5B;YACAC;YACAW;QACF,KACAE;QAEJ,MAAMsE,cACJD,0BAA0BrE,YACrBqE,wBACD9F,QAAQsF;QAEd,MAAMO,SAAS;YACbvC,UAAU,AAACI,MAAM,CAAC8B,wBAAwB,GAAc,MAAMO;YAC9DxC,WAAW,AAACG,MAAM,CAAC+B,yBAAyB,GAAc,MAAOH;QACnE;QAEA,mCAAmC;QACnC9C,QAAQC,sBAAsB,CAACb,WAAWc,IAAI,CAAC,CAAC6C,mBAAmB,CAACvD,kBAAkB,GACpF6D,OAAOvC,QAAQ;QACjBd,QAAQC,sBAAsB,CAACb,WAAWc,IAAI,CAAC,CAAC6C,mBAAmB,CAACtD,mBAAmB,GACrF4D,OAAOtC,SAAS;QAElB,OAAOsC;IACT,OAAO;QACL,4BAA4B;QAC5B,MAAM/E,aAAaN,cAAc;YAC/BC,UAAUoB;YACVnB;YACAC;YACAC;YACAC;QACF;QACA2B,QAAQC,sBAAsB,CAACb,WAAWc,IAAI,CAAC,CAACb,IAAId,EAAE,CAAC,GAAG;YACxD,CAACgB,gBAAgB,EAAE;YACnB,CAAClB,eAAe,EAAEC;QACpB;QAEA,MAAMkF,gBAAgBzE,gBAClBF,kBAAkB;YAChBZ,UAAUoB;YACVP,iBAAiBiB;YACjB5B;YACAC;YACAW;QACF,KACAE;QAEJ,sEAAsE;QACtE,IAAIf,oBAAoBC,WAAW,OAAO;YACxC,OAAOP,6BAA6B;gBAClCQ;gBACAZ;gBACAwB,WAAWwE;gBACXlF,YAAYA;YACd;QACF;QAEA,qBAAqB;QACrB,OAAO;YACLwC,UAAU0C,kBAAkBvE,YAAYuE,gBAAgBhG,QAAQc;YAChEyC,WAAWzC;QACb;IACF;AACF"}
|
package/dist/index.bundled.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export { default as deepMerge } from 'deepmerge';
|
|
|
21
21
|
import { PinoPretty } from 'pino-pretty';
|
|
22
22
|
import { DatePickerProps } from 'react-datepicker';
|
|
23
23
|
|
|
24
|
-
declare const clientTranslationKeys: ("error:autosaving" | "error:correctInvalidFields" | "error:deletingTitle" | "error:documentNotFound" | "error:emailOrPasswordIncorrect" | "error:failedToResetLayout" | "error:failedToSaveLayout" | "error:fileFetchFailed" | "error:insufficientClipboardPermissions" | "error:invalidClipboardData" | "error:invalidFileType" | "error:invalidRequestArgs" | "error:loadingDocument" | "error:logoutFailed" | "error:noFileFoundInClipboard" | "error:noMatchedField" | "error:notAllowedToAccessPage" | "error:notAllowedToPerformAction" | "error:previewing" | "error:problemUploadingFile" | "error:restoringTitle" | "error:revertingDocument" | "error:tokenNotProvided" | "error:unableToCopy" | "error:unableToDeleteCount" | "error:unableToReadClipboard" | "error:unableToReindexCollection" | "error:unableToUpdateCount" | "error:unauthorized" | "error:unauthorizedAdmin" | "error:unknown" | "error:unPublishingDocument" | "error:unspecific" | "error:unverifiedEmail" | "error:urlNotAllowed" | "error:userEmailAlreadyRegistered" | "error:usernameAlreadyRegistered" | "error:usernameOrPasswordIncorrect" | "error:followingFieldsInvalid" | "fields:blocks" | "fields:addLabel" | "fields:addLink" | "fields:addNew" | "fields:addNewLabel" | "fields:addRelationship" | "fields:addUpload" | "fields:block" | "fields:blockName" | "fields:blockType" | "fields:chooseBetweenCustomTextOrDocument" | "fields:chooseDocumentToLink" | "fields:chooseFromExisting" | "fields:collapseAll" | "fields:customURL" | "fields:editLink" | "fields:editRelationship" | "fields:enterURL" | "fields:hidePassword" | "fields:internalLink" | "fields:itemsAndMore" | "fields:labelRelationship" | "fields:latitude" | "fields:linkedTo" | "fields:linkType" | "fields:longitude" | "fields:openInNewTab" | "fields:passwordsDoNotMatch" | "fields:removeRelationship" | "fields:removeUpload" | "fields:saveChanges" | "fields:searchForBlock" | "fields:searchForLanguage" | "fields:selectFieldsToEdit" | "fields:showAll" | "fields:showPassword" | "fields:swapRelationship" | "fields:swapUpload" | "fields:textToDisplay" | "fields:toggleBlock" | "fields:uploadNewLabel" | "localization:cannotCopySameLocale" | "localization:copyFrom" | "localization:copyFromTo" | "localization:copyTo" | "localization:copyToLocale" | "localization:localeToPublish" | "localization:selectedLocales" | "localization:selectLocaleToCopy" | "localization:selectLocaleToDuplicate" | "upload:addFile" | "upload:addFiles" | "upload:bulkUpload" | "upload:copyLinkToFile" | "upload:copyURL" | "upload:crop" | "upload:cropBottom" | "upload:cropBottomLeft" | "upload:cropBottomRight" | "upload:cropLeft" | "upload:cropRight" | "upload:cropToolDescription" | "upload:cropTop" | "upload:cropTopLeft" | "upload:cropTopRight" | "upload:download" | "upload:dragAndDrop" | "upload:editImage" | "upload:fileName" | "upload:fileSize" | "upload:filesToUpload" | "upload:fileToUpload" | "upload:focalPoint" | "upload:focalPointDescription" | "upload:fromURL" | "upload:height" | "upload:linkToFile" | "upload:noFile" | "upload:pasteFromClipboard" | "upload:pasteURL" | "upload:previewSizes" | "upload:renameFile" | "upload:replaceFile" | "upload:selectCollectionToBrowse" | "upload:selectFile" | "upload:setCropArea" | "upload:setFocalPoint" | "upload:sizes" | "upload:sizesFor" | "upload:width" | "llmInstructions:additionalInstructions" | "llmInstructions:collectionDescription" | "llmInstructions:collectionSystemDescription" | "llmInstructions:editInstructions" | "llmInstructions:global" | "llmInstructions:globalDescription" | "llmInstructions:globalSystemDescription" | "llmInstructions:instructions" | "llmInstructions:systemInstructions" | "llmInstructions:title" | "authentication:forgotPassword" | "authentication:verify" | "authentication:account" | "authentication:accountOfCurrentUser" | "authentication:accountVerified" | "authentication:alreadyActivated" | "authentication:alreadyLoggedIn" | "authentication:apiKey" | "authentication:authenticated" | "authentication:backToLogin" | "authentication:beginCreateFirstUser" | "authentication:changePassword" | "authentication:checkYourEmailForPasswordReset" | "authentication:confirmGeneration" | "authentication:confirmPassword" | "authentication:createFirstUser" | "authentication:createUser" | "authentication:emailNotValid" | "authentication:emailOrUsername" | "authentication:emailSent" | "authentication:emailVerified" | "authentication:emailVerifiedRedirecting" | "authentication:enableAPIKey" | "authentication:failedToUnlock" | "authentication:forceUnlock" | "authentication:forgotPasswordEmailInstructions" | "authentication:forgotPasswordUsernameInstructions" | "authentication:usernameNotValid" | "authentication:forgotPasswordQuestion" | "authentication:generate" | "authentication:generateNewAPIKey" | "authentication:generatingNewAPIKeyWillInvalidate" | "authentication:logBackIn" | "authentication:loggedIn" | "authentication:loggedInChangePassword" | "authentication:loggedOutInactivity" | "authentication:loggedOutSuccessfully" | "authentication:loggingOut" | "authentication:login" | "authentication:logOut" | "authentication:logout" | "authentication:logoutSuccessful" | "authentication:logoutUser" | "authentication:newAPIKeyGenerated" | "authentication:newPassword" | "authentication:notRedirected" | "authentication:passed" | "authentication:passwordResetSuccessfully" | "authentication:resend" | "authentication:resetPassword" | "authentication:stayLoggedIn" | "authentication:successfullyRegisteredFirstUser" | "authentication:successfullyUnlocked" | "authentication:tokenRefreshSuccessful" | "authentication:unableToVerify" | "authentication:username" | "authentication:verified" | "authentication:verifiedSuccessfully" | "authentication:verifyUser" | "authentication:youAreInactive" | "commandPalette:title" | "commandPalette:createNew" | "commandPalette:hintClose" | "commandPalette:hintCreate" | "commandPalette:hintNavigate" | "commandPalette:hintSelect" | "commandPalette:noResults" | "commandPalette:placeholder" | "dashboard:addButton" | "dashboard:addWidget" | "dashboard:deleteWidget" | "dashboard:discardConfirmLabel" | "dashboard:discardMessage" | "dashboard:discardTitle" | "dashboard:editDashboard" | "dashboard:editingDashboard" | "dashboard:noItems" | "dashboard:resetLayout" | "dashboard:resizeWidget" | "dashboard:searchWidgets" | "dashboard:widgetAddPin" | "dashboard:widgetCollectionRequired" | "dashboard:widgetConfigurationError" | "dashboard:widgetDropFilesToUpload" | "dashboard:widgetInvalidCollection" | "dashboard:widgetInvalidFilterField" | "dashboard:widgetInvalidSortField" | "dashboard:widgetLimitLabel" | "dashboard:widgetNonSortableSortField" | "dashboard:widgetPageCount" | "dashboard:widgetPagination" | "dashboard:widgetPinned" | "dashboard:widgetPinnedEmpty" | "dashboard:widgetPinnedEmptyDescription" | "dashboard:widgetPinnedSaveError" | "dashboard:widgetQueryError" | "dashboard:widgetRecentlyViewedEmpty" | "dashboard:widgetRecentlyViewedEmptyDescription" | "dashboard:widgetRecentlyViewedFilterDescription" | "dashboard:widgetRecentlyViewedTitle" | "dashboard:widgetRecentsAndPinned" | "dashboard:widgetRemovePin" | "dashboard:widgetSelectCollectionFirst" | "dashboard:widgetSelectSortField" | "dashboard:widgetSortDirectionLabel" | "dashboard:widgetSortFieldLabel" | "dashboard:widgetTitleFallback" | "dashboard:widgetTitleLabel" | "dashboard:widgetUploadDropzoneDescription" | "dashboard:widgetUploadFiles" | "general:collections" | "general:globals" | "general:false" | "general:none" | "general:locale" | "general:select" | "general:user" | "general:createdAt" | "general:error" | "general:updatedAt" | "general:access" | "general:custom" | "general:name" | "general:depth" | "general:collection" | "general:email" | "general:items" | "general:of" | "general:dashboard" | "general:notFound" | "general:unauthorized" | "general:newLabel" | "general:saveChanges" | "general:username" | "general:createNew" | "general:noResults" | "general:aboutToDelete" | "general:aboutToPermanentlyDelete" | "general:aboutToPermanentlyDeleteTrash" | "general:aboutToRestore" | "general:aboutToRestoreAsDraft" | "general:aboutToRestoreAsDraftCount" | "general:aboutToRestoreCount" | "general:aboutToTrash" | "general:aboutToTrashCount" | "general:accepts" | "general:addBelow" | "general:addFilter" | "general:adminTheme" | "general:all" | "general:allCollections" | "general:allLocales" | "general:allowedTypes" | "general:and" | "general:anotherUser" | "general:anotherUserTakenOver" | "general:applyChanges" | "general:ascending" | "general:auto" | "general:automatic" | "general:backToDashboard" | "general:breadcrumb" | "general:by" | "general:cancel" | "general:changesNotSaved" | "general:checked" | "general:clear" | "general:clearAll" | "general:clearSearch" | "general:close" | "general:collapse" | "general:columns" | "general:columnToSort" | "general:confirm" | "general:confirmCopy" | "general:confirmDeletion" | "general:confirmDuplication" | "general:confirmMove" | "general:confirmReindex" | "general:confirmReindexAll" | "general:confirmReindexDescription" | "general:confirmReindexDescriptionAll" | "general:confirmRestoration" | "general:copied" | "general:copy" | "general:copyField" | "general:copying" | "general:copyRow" | "general:copyWarning" | "general:create" | "general:created" | "general:createdBy" | "general:createNewLabel" | "general:creating" | "general:creatingNewLabel" | "general:currentlyEditing" | "general:dark" | "general:decrement" | "general:delete" | "general:deleted" | "general:deletedAgo" | "general:deletedAt" | "general:deletedCountSuccessfully" | "general:deletedSuccessfully" | "general:deleteLabel" | "general:deletePermanently" | "general:deleting" | "general:descending" | "general:deselectAllRows" | "general:document" | "general:documentIsTrashed" | "general:documentLocked" | "general:documentModified" | "general:documentOutOfDate" | "general:documents" | "general:dragToReorder" | "general:duplicate" | "general:duplicateWithoutSaving" | "general:edit" | "general:editAll" | "general:editColumns" | "general:editedSince" | "general:editing" | "general:editingTakenOver" | "general:editLabel" | "general:emailAddress" | "general:emptyTrash" | "general:emptyTrashLabel" | "general:enhancedContrastMode" | "general:enterANumber" | "general:enterAValue" | "general:errors" | "general:exitLivePreview" | "general:expand" | "general:export" | "general:fallbackToDefaultLocale" | "general:field" | "general:filter" | "general:filters" | "general:filterWhere" | "general:goBack" | "general:goToPage" | "general:gridLayout" | "general:groupByLabel" | "general:hideSidebar" | "general:import" | "general:increment" | "general:isEditing" | "general:item" | "general:language" | "general:lastModified" | "general:layout" | "general:leaveAnyway" | "general:leaveWithoutSaving" | "general:light" | "general:livePreview" | "general:loading" | "general:loadMore" | "general:locales" | "general:lock" | "general:manageLabel" | "general:menu" | "general:moreOptions" | "general:move" | "general:moveConfirm" | "general:moveCount" | "general:moveDown" | "general:moveUp" | "general:moving" | "general:movingCount" | "general:next" | "general:nextPage" | "general:no" | "general:noDateSelected" | "general:noFiltersSet" | "general:noLabel" | "general:noMatchesFound" | "general:noOptions" | "general:noResultsDescription" | "general:noResultsFound" | "general:nothingFound" | "general:noTrashResults" | "general:notSelectedDocument" | "general:notShownInTable" | "general:noUpcomingEventsScheduled" | "general:noValue" | "general:only" | "general:open" | "general:openInNewWindow" | "general:or" | "general:order" | "general:original" | "general:overwriteExistingData" | "general:pageNotFound" | "general:pageNumberRange" | "general:password" | "general:pasteBelow" | "general:pasteField" | "general:pasteRow" | "general:payloadSettings" | "general:permanentlyDelete" | "general:permanentlyDeletedCountSuccessfully" | "general:perPage" | "general:perPageLabel" | "general:presets" | "general:previous" | "general:previousPage" | "general:reindex" | "general:reindexingAll" | "general:reloadDocument" | "general:remove" | "general:rename" | "general:replaceRow" | "general:requiredFields" | "general:reset" | "general:resetPreferences" | "general:resetPreferencesDescription" | "general:resettingPreferences" | "general:restore" | "general:restoreAsPublished" | "general:restoredCountSuccessfully" | "general:restoring" | "general:retry" | "general:row" | "general:rows" | "general:save" | "general:saving" | "general:schedulePublishFor" | "general:searchAutomatically" | "general:searchBy" | "general:searchCleared" | "general:searchColumns" | "general:searchGroups" | "general:searchResults" | "general:selectAll" | "general:selectAllRows" | "general:selectedCount" | "general:selectedDocument" | "general:selectLabel" | "general:selectValue" | "general:settings" | "general:showAllLabel" | "general:shownInTable" | "general:showSidebar" | "general:skipToContent" | "general:sorryNotFound" | "general:sort" | "general:sortByLabelDirection" | "general:sortByOrderToReorder" | "general:stayOnThisPage" | "general:submissionSuccessful" | "general:submit" | "general:submitting" | "general:success" | "general:successfullyCreated" | "general:successfullyDuplicated" | "general:successfullyReindexed" | "general:tableLayout" | "general:takeOver" | "general:theme" | "general:thisLanguage" | "general:time" | "general:timezone" | "general:titleDeleted" | "general:titleRestored" | "general:titleTrashed" | "general:toggle" | "general:trash" | "general:trashedCountSuccessfully" | "general:true" | "general:unchecked" | "general:unlock" | "general:unsavedChanges" | "general:unsavedChangesDuplicate" | "general:untitled" | "general:upcomingEvents" | "general:updatedAgo" | "general:updatedBy" | "general:updatedCountSuccessfully" | "general:updatedLabelSuccessfully" | "general:updatedSuccessfully" | "general:updateForEveryone" | "general:updating" | "general:uploading" | "general:uploadingBulk" | "general:users" | "general:value" | "general:viewing" | "general:viewReadOnly" | "general:welcome" | "general:where" | "general:yes" | "general:aboutToDeleteCount" | "general:editingLabel" | "hierarchy:noResults" | "hierarchy:searchResults" | "hierarchy:goTo" | "hierarchy:itemsMovedTo" | "hierarchy:itemsMovedToRoot" | "hierarchy:moveTo" | "hierarchy:moveToRoot" | "hierarchy:noParent" | "hierarchy:removeFrom" | "hierarchy:searchLabel" | "operators:contains" | "operators:equals" | "operators:exists" | "operators:intersects" | "operators:near" | "operators:within" | "operators:isGreaterThan" | "operators:isGreaterThanOrEqualTo" | "operators:isIn" | "operators:isLessThan" | "operators:isLessThanOrEqualTo" | "operators:isLike" | "operators:isNotEqualTo" | "operators:isNotIn" | "operators:isNotLike" | "validation:required" | "validation:username" | "validation:emailAddress" | "validation:enterNumber" | "validation:fieldHasNo" | "validation:greaterThanMax" | "validation:invalidBlock" | "validation:invalidBlocks" | "validation:invalidInput" | "validation:invalidSelection" | "validation:invalidSelections" | "validation:latitudeOutOfBounds" | "validation:lessThanMin" | "validation:limitReached" | "validation:longerThanMin" | "validation:longitudeOutOfBounds" | "validation:notValidDate" | "validation:requiresAtLeast" | "validation:requiresNoMoreThan" | "validation:requiresTwoNumbers" | "validation:shorterThanMax" | "validation:timezoneRequired" | "validation:trueOrFalse" | "validation:validUploadID" | "version:type" | "version:version" | "version:aboutToRestore" | "version:restoring" | "version:aboutToPublishSelection" | "version:aboutToRestoreGlobal" | "version:aboutToRevertToPublished" | "version:aboutToUnpublish" | "version:aboutToUnpublishIn" | "version:aboutToUnpublishSelection" | "version:autosave" | "version:autosavedSuccessfully" | "version:autosavedVersion" | "version:changed" | "version:compareVersions" | "version:comparingAgainst" | "version:confirmPublish" | "version:confirmRevertToSaved" | "version:confirmUnpublish" | "version:confirmVersionRestoration" | "version:currentDraft" | "version:currentlyPublished" | "version:currentlyViewing" | "version:currentPublishedVersion" | "version:draft" | "version:draftHasPublishedVersion" | "version:draftSavedSuccessfully" | "version:lastSavedAgo" | "version:modifiedOnly" | "version:moreVersions" | "version:noFurtherVersionsFound" | "version:noLabelGroup" | "version:noRowsFound" | "version:noRowsSelected" | "version:preview" | "version:previouslyDraft" | "version:previouslyPublished" | "version:previousVersion" | "version:problemRestoringVersion" | "version:publish" | "version:publishAllLocales" | "version:publishChanges" | "version:published" | "version:publishIn" | "version:publishing" | "version:restoreAsDraft" | "version:restoredSuccessfully" | "version:restoreThisVersion" | "version:reverting" | "version:revertToPublished" | "version:revertUnsuccessful" | "version:saveDraft" | "version:scheduledSuccessfully" | "version:schedulePublish" | "version:selectLocales" | "version:selectVersionToCompare" | "version:showLocales" | "version:specificVersion" | "version:status" | "version:unpublish" | "version:unpublished" | "version:unpublishedSuccessfully" | "version:unpublishIn" | "version:unpublishing" | "version:versionAgo" | "version:versionID" | "version:versions" | "version:viewingVersion" | "version:viewingVersionGlobal" | "version:viewingVersions" | "version:viewingVersionsGlobal" | "version:changedFieldsCount")[];
|
|
24
|
+
declare const clientTranslationKeys: ("error:autosaving" | "error:correctInvalidFields" | "error:deletingTitle" | "error:documentNotFound" | "error:emailOrPasswordIncorrect" | "error:failedToResetLayout" | "error:failedToSaveLayout" | "error:fileFetchFailed" | "error:insufficientClipboardPermissions" | "error:invalidClipboardData" | "error:invalidFileType" | "error:invalidRequestArgs" | "error:loadingDocument" | "error:logoutFailed" | "error:noFileFoundInClipboard" | "error:noMatchedField" | "error:notAllowedToAccessPage" | "error:notAllowedToPerformAction" | "error:previewing" | "error:problemUploadingFile" | "error:restoringTitle" | "error:revertingDocument" | "error:tokenNotProvided" | "error:unableToCopy" | "error:unableToDeleteCount" | "error:unableToReadClipboard" | "error:unableToReindexCollection" | "error:unableToUpdateCount" | "error:unauthorized" | "error:unauthorizedAdmin" | "error:unknown" | "error:unPublishingDocument" | "error:unspecific" | "error:unverifiedEmail" | "error:urlNotAllowed" | "error:userEmailAlreadyRegistered" | "error:usernameAlreadyRegistered" | "error:usernameOrPasswordIncorrect" | "error:followingFieldsInvalid" | "fields:blocks" | "fields:addLabel" | "fields:addLink" | "fields:addNew" | "fields:addNewLabel" | "fields:addRelationship" | "fields:addUpload" | "fields:block" | "fields:blockName" | "fields:blockType" | "fields:chooseBetweenCustomTextOrDocument" | "fields:chooseDocumentToLink" | "fields:chooseFromExisting" | "fields:collapseAll" | "fields:customURL" | "fields:editLink" | "fields:editRelationship" | "fields:enterURL" | "fields:hidePassword" | "fields:internalLink" | "fields:itemsAndMore" | "fields:labelRelationship" | "fields:latitude" | "fields:linkedTo" | "fields:linkType" | "fields:longitude" | "fields:openInNewTab" | "fields:passwordsDoNotMatch" | "fields:removeRelationship" | "fields:removeUpload" | "fields:saveChanges" | "fields:searchForBlock" | "fields:searchForLanguage" | "fields:selectFieldsToEdit" | "fields:showAll" | "fields:showPassword" | "fields:swapRelationship" | "fields:swapUpload" | "fields:textToDisplay" | "fields:toggleBlock" | "fields:uploadNewLabel" | "localization:cannotCopySameLocale" | "localization:copyFrom" | "localization:copyFromTo" | "localization:copyTo" | "localization:copyToLocale" | "localization:localeToPublish" | "localization:selectedLocales" | "localization:selectLocaleToCopy" | "localization:selectLocaleToDuplicate" | "upload:addFile" | "upload:addFiles" | "upload:bulkUpload" | "upload:copyLinkToFile" | "upload:copyURL" | "upload:crop" | "upload:cropBottom" | "upload:cropBottomLeft" | "upload:cropBottomRight" | "upload:cropLeft" | "upload:cropRight" | "upload:cropToolDescription" | "upload:cropTop" | "upload:cropTopLeft" | "upload:cropTopRight" | "upload:download" | "upload:dragAndDrop" | "upload:editImage" | "upload:fileName" | "upload:fileSize" | "upload:filesToUpload" | "upload:fileToUpload" | "upload:focalPoint" | "upload:focalPointDescription" | "upload:fromURL" | "upload:height" | "upload:linkToFile" | "upload:noFile" | "upload:pasteFromClipboard" | "upload:pasteURL" | "upload:previewSizes" | "upload:renameFile" | "upload:replaceFile" | "upload:selectCollectionToBrowse" | "upload:selectFile" | "upload:setCropArea" | "upload:setFocalPoint" | "upload:sizes" | "upload:sizesFor" | "upload:width" | "llmInstructions:additionalInstructions" | "llmInstructions:collectionDescription" | "llmInstructions:collectionSystemDescription" | "llmInstructions:editInstructions" | "llmInstructions:global" | "llmInstructions:globalDescription" | "llmInstructions:globalSystemDescription" | "llmInstructions:instructions" | "llmInstructions:systemInstructions" | "llmInstructions:title" | "authentication:forgotPassword" | "authentication:verify" | "authentication:account" | "authentication:accountOfCurrentUser" | "authentication:accountVerified" | "authentication:alreadyActivated" | "authentication:alreadyLoggedIn" | "authentication:apiKey" | "authentication:authenticated" | "authentication:backToLogin" | "authentication:beginCreateFirstUser" | "authentication:changePassword" | "authentication:checkYourEmailForPasswordReset" | "authentication:confirmGeneration" | "authentication:confirmPassword" | "authentication:createFirstUser" | "authentication:createUser" | "authentication:emailNotValid" | "authentication:emailOrUsername" | "authentication:emailSent" | "authentication:emailVerified" | "authentication:emailVerifiedRedirecting" | "authentication:enableAPIKey" | "authentication:failedToUnlock" | "authentication:forceUnlock" | "authentication:forgotPasswordEmailInstructions" | "authentication:forgotPasswordUsernameInstructions" | "authentication:usernameNotValid" | "authentication:forgotPasswordQuestion" | "authentication:generate" | "authentication:generateNewAPIKey" | "authentication:generatingNewAPIKeyWillInvalidate" | "authentication:logBackIn" | "authentication:loggedIn" | "authentication:loggedInChangePassword" | "authentication:loggedOutInactivity" | "authentication:loggedOutSuccessfully" | "authentication:loggingOut" | "authentication:login" | "authentication:logOut" | "authentication:logout" | "authentication:logoutSuccessful" | "authentication:logoutUser" | "authentication:newAPIKeyGenerated" | "authentication:newPassword" | "authentication:notRedirected" | "authentication:passed" | "authentication:passwordResetSuccessfully" | "authentication:resend" | "authentication:resetPassword" | "authentication:stayLoggedIn" | "authentication:successfullyRegisteredFirstUser" | "authentication:successfullyUnlocked" | "authentication:tokenRefreshSuccessful" | "authentication:unableToVerify" | "authentication:username" | "authentication:verified" | "authentication:verifiedSuccessfully" | "authentication:verifyUser" | "authentication:youAreInactive" | "commandPalette:title" | "commandPalette:createNew" | "commandPalette:hintClose" | "commandPalette:hintCreate" | "commandPalette:hintNavigate" | "commandPalette:hintSelect" | "commandPalette:noResults" | "commandPalette:placeholder" | "dashboard:addButton" | "dashboard:addWidget" | "dashboard:deleteWidget" | "dashboard:discardConfirmLabel" | "dashboard:discardMessage" | "dashboard:discardTitle" | "dashboard:editDashboard" | "dashboard:editingDashboard" | "dashboard:noItems" | "dashboard:resetLayout" | "dashboard:resizeWidget" | "dashboard:searchWidgets" | "dashboard:widgetAddPin" | "dashboard:widgetCollectionRequired" | "dashboard:widgetConfigurationError" | "dashboard:widgetDropFilesToUpload" | "dashboard:widgetInvalidCollection" | "dashboard:widgetInvalidFilterField" | "dashboard:widgetInvalidSortField" | "dashboard:widgetLimitLabel" | "dashboard:widgetNonSortableSortField" | "dashboard:widgetPageCount" | "dashboard:widgetPagination" | "dashboard:widgetPinned" | "dashboard:widgetPinnedEmpty" | "dashboard:widgetPinnedEmptyDescription" | "dashboard:widgetPinnedSaveError" | "dashboard:widgetQueryError" | "dashboard:widgetRecentlyViewedEmpty" | "dashboard:widgetRecentlyViewedEmptyDescription" | "dashboard:widgetRecentlyViewedFilterDescription" | "dashboard:widgetRecentlyViewedTitle" | "dashboard:widgetRecentsAndPinned" | "dashboard:widgetRemovePin" | "dashboard:widgetSelectCollectionFirst" | "dashboard:widgetSelectSortField" | "dashboard:widgetSortDirectionLabel" | "dashboard:widgetSortFieldLabel" | "dashboard:widgetTitleFallback" | "dashboard:widgetTitleLabel" | "dashboard:widgetUploadDropzoneDescription" | "dashboard:widgetUploadFiles" | "general:collections" | "general:globals" | "general:false" | "general:none" | "general:locale" | "general:select" | "general:user" | "general:createdAt" | "general:error" | "general:updatedAt" | "general:access" | "general:custom" | "general:name" | "general:depth" | "general:collection" | "general:email" | "general:items" | "general:of" | "general:dashboard" | "general:notFound" | "general:unauthorized" | "general:newLabel" | "general:saveChanges" | "general:username" | "general:createNew" | "general:noResults" | "general:aboutToDelete" | "general:aboutToPermanentlyDelete" | "general:aboutToPermanentlyDeleteTrash" | "general:aboutToRestore" | "general:aboutToRestoreAsDraft" | "general:aboutToRestoreAsDraftCount" | "general:aboutToRestoreCount" | "general:aboutToTrash" | "general:aboutToTrashCount" | "general:accepts" | "general:addBelow" | "general:addFilter" | "general:adminTheme" | "general:all" | "general:allCollections" | "general:allLocales" | "general:allowedTypes" | "general:and" | "general:anotherUser" | "general:anotherUserTakenOver" | "general:apiResponse" | "general:applyChanges" | "general:ascending" | "general:auto" | "general:automatic" | "general:backToDashboard" | "general:breadcrumb" | "general:by" | "general:cancel" | "general:changesNotSaved" | "general:checked" | "general:clear" | "general:clearAll" | "general:clearSearch" | "general:close" | "general:collapse" | "general:columns" | "general:columnToSort" | "general:confirm" | "general:confirmCopy" | "general:confirmDeletion" | "general:confirmDuplication" | "general:confirmMove" | "general:confirmReindex" | "general:confirmReindexAll" | "general:confirmReindexDescription" | "general:confirmReindexDescriptionAll" | "general:confirmRestoration" | "general:copied" | "general:copy" | "general:copyField" | "general:copying" | "general:copyRow" | "general:copyWarning" | "general:create" | "general:created" | "general:createdBy" | "general:createNewLabel" | "general:creating" | "general:creatingNewLabel" | "general:currentlyEditing" | "general:dark" | "general:decrement" | "general:delete" | "general:deleted" | "general:deletedAgo" | "general:deletedAt" | "general:deletedCountSuccessfully" | "general:deletedSuccessfully" | "general:deleteLabel" | "general:deletePermanently" | "general:deleting" | "general:descending" | "general:deselectAllRows" | "general:document" | "general:documentIsTrashed" | "general:documentLocked" | "general:documentModified" | "general:documentOutOfDate" | "general:documents" | "general:dragCancelled" | "general:dragDropped" | "general:dragInstructions" | "general:dragMoved" | "general:dragPickedUp" | "general:dragToMove" | "general:dragToReorder" | "general:duplicate" | "general:duplicateWithoutSaving" | "general:edit" | "general:editAll" | "general:editColumns" | "general:editedSince" | "general:editing" | "general:editingTakenOver" | "general:editLabel" | "general:emailAddress" | "general:emptyTrash" | "general:emptyTrashLabel" | "general:enhancedContrastMode" | "general:enterANumber" | "general:enterAValue" | "general:errors" | "general:exitLivePreview" | "general:expand" | "general:export" | "general:fallbackToDefaultLocale" | "general:field" | "general:filter" | "general:filters" | "general:filterWhere" | "general:goBack" | "general:goToPage" | "general:gridLayout" | "general:groupByLabel" | "general:hideSidebar" | "general:import" | "general:increment" | "general:isEditing" | "general:item" | "general:language" | "general:lastModified" | "general:layout" | "general:leaveAnyway" | "general:leaveWithoutSaving" | "general:light" | "general:livePreview" | "general:loading" | "general:loadMore" | "general:locales" | "general:lock" | "general:manageLabel" | "general:menu" | "general:moreOptions" | "general:move" | "general:moveConfirm" | "general:moveCount" | "general:moveDown" | "general:moveUp" | "general:moving" | "general:movingCount" | "general:next" | "general:nextPage" | "general:no" | "general:noDateSelected" | "general:noFiltersSet" | "general:noLabel" | "general:noMatchesFound" | "general:noOptions" | "general:noResultsDescription" | "general:noResultsFound" | "general:nothingFound" | "general:noTrashResults" | "general:notSelectedDocument" | "general:notShownInTable" | "general:noUpcomingEventsScheduled" | "general:noValue" | "general:only" | "general:open" | "general:openInNewWindow" | "general:or" | "general:order" | "general:original" | "general:overwriteExistingData" | "general:pageNotFound" | "general:pageNumberRange" | "general:password" | "general:pasteBelow" | "general:pasteField" | "general:pasteRow" | "general:payloadSettings" | "general:permanentlyDelete" | "general:permanentlyDeletedCountSuccessfully" | "general:perPage" | "general:perPageLabel" | "general:presets" | "general:previous" | "general:previousPage" | "general:reindex" | "general:reindexingAll" | "general:reloadDocument" | "general:remove" | "general:removeFilter" | "general:rename" | "general:replaceRow" | "general:requiredFields" | "general:reset" | "general:resetPreferences" | "general:resetPreferencesDescription" | "general:resettingPreferences" | "general:restore" | "general:restoreAsPublished" | "general:restoredCountSuccessfully" | "general:restoring" | "general:retry" | "general:row" | "general:rows" | "general:save" | "general:saving" | "general:schedulePublishFor" | "general:searchAutomatically" | "general:searchBy" | "general:searchCleared" | "general:searchColumns" | "general:searchGroups" | "general:searchResults" | "general:selectAll" | "general:selectAllRows" | "general:selectedCount" | "general:selectedDocument" | "general:selectLabel" | "general:selectValue" | "general:settings" | "general:showAllLabel" | "general:shownInTable" | "general:showSidebar" | "general:skipToContent" | "general:sorryNotFound" | "general:sort" | "general:sortByLabelDirection" | "general:sortByOrderToReorder" | "general:stayOnThisPage" | "general:submissionSuccessful" | "general:submit" | "general:submitting" | "general:success" | "general:successfullyCreated" | "general:successfullyDuplicated" | "general:successfullyReindexed" | "general:tableLayout" | "general:takeOver" | "general:theme" | "general:thisLanguage" | "general:time" | "general:timezone" | "general:titleDeleted" | "general:titleRestored" | "general:titleTrashed" | "general:toggle" | "general:trash" | "general:trashedCountSuccessfully" | "general:true" | "general:unchecked" | "general:unlock" | "general:unsavedChanges" | "general:unsavedChangesDuplicate" | "general:untitled" | "general:upcomingEvents" | "general:updatedAgo" | "general:updatedBy" | "general:updatedCountSuccessfully" | "general:updatedLabelSuccessfully" | "general:updatedSuccessfully" | "general:updateForEveryone" | "general:updating" | "general:uploading" | "general:uploadingBulk" | "general:users" | "general:value" | "general:viewing" | "general:viewReadOnly" | "general:welcome" | "general:where" | "general:yes" | "general:aboutToDeleteCount" | "general:editingLabel" | "hierarchy:noResults" | "hierarchy:searchResults" | "hierarchy:folderLocation" | "hierarchy:goTo" | "hierarchy:itemsMovedTo" | "hierarchy:itemsMovedToRoot" | "hierarchy:moveTo" | "hierarchy:moveToRoot" | "hierarchy:noParent" | "hierarchy:removeFrom" | "hierarchy:searchLabel" | "operators:contains" | "operators:equals" | "operators:exists" | "operators:intersects" | "operators:near" | "operators:within" | "operators:isGreaterThan" | "operators:isGreaterThanOrEqualTo" | "operators:isIn" | "operators:isLessThan" | "operators:isLessThanOrEqualTo" | "operators:isLike" | "operators:isNotEqualTo" | "operators:isNotIn" | "operators:isNotLike" | "validation:required" | "validation:username" | "validation:emailAddress" | "validation:enterNumber" | "validation:fieldHasNo" | "validation:greaterThanMax" | "validation:invalidBlock" | "validation:invalidBlocks" | "validation:invalidInput" | "validation:invalidSelection" | "validation:invalidSelections" | "validation:latitudeOutOfBounds" | "validation:lessThanMin" | "validation:limitReached" | "validation:longerThanMin" | "validation:longitudeOutOfBounds" | "validation:notValidDate" | "validation:requiresAtLeast" | "validation:requiresNoMoreThan" | "validation:requiresTwoNumbers" | "validation:shorterThanMax" | "validation:timezoneRequired" | "validation:trueOrFalse" | "validation:validUploadID" | "version:type" | "version:version" | "version:aboutToRestore" | "version:restoring" | "version:aboutToPublishSelection" | "version:aboutToRestoreGlobal" | "version:aboutToRevertToPublished" | "version:aboutToUnpublish" | "version:aboutToUnpublishIn" | "version:aboutToUnpublishSelection" | "version:autosave" | "version:autosavedSuccessfully" | "version:autosavedVersion" | "version:changed" | "version:compareVersions" | "version:comparingAgainst" | "version:confirmPublish" | "version:confirmRevertToSaved" | "version:confirmUnpublish" | "version:confirmVersionRestoration" | "version:currentDraft" | "version:currentlyPublished" | "version:currentlyViewing" | "version:currentPublishedVersion" | "version:draft" | "version:draftHasPublishedVersion" | "version:draftSavedSuccessfully" | "version:lastSavedAgo" | "version:modifiedOnly" | "version:moreVersions" | "version:noFurtherVersionsFound" | "version:noLabelGroup" | "version:noRowsFound" | "version:noRowsSelected" | "version:preview" | "version:previouslyDraft" | "version:previouslyPublished" | "version:previousVersion" | "version:problemRestoringVersion" | "version:publish" | "version:publishAllLocales" | "version:publishChanges" | "version:published" | "version:publishIn" | "version:publishing" | "version:restoreAsDraft" | "version:restoredSuccessfully" | "version:restoreThisVersion" | "version:reverting" | "version:revertToPublished" | "version:revertUnsuccessful" | "version:saveDraft" | "version:scheduledSuccessfully" | "version:schedulePublish" | "version:selectLocales" | "version:selectVersionToCompare" | "version:showLocales" | "version:specificVersion" | "version:status" | "version:unpublish" | "version:unpublished" | "version:unpublishedSuccessfully" | "version:unpublishIn" | "version:unpublishing" | "version:versionAgo" | "version:versionID" | "version:versions" | "version:viewingVersion" | "version:viewingVersionGlobal" | "version:viewingVersions" | "version:viewingVersionsGlobal" | "version:changedFieldsCount")[];
|
|
25
25
|
|
|
26
26
|
declare const enTranslations: {
|
|
27
27
|
authentication: {
|
|
@@ -292,6 +292,7 @@ declare const enTranslations: {
|
|
|
292
292
|
and: string;
|
|
293
293
|
anotherUser: string;
|
|
294
294
|
anotherUserTakenOver: string;
|
|
295
|
+
apiResponse: string;
|
|
295
296
|
applyChanges: string;
|
|
296
297
|
ascending: string;
|
|
297
298
|
auto: string;
|
|
@@ -358,6 +359,12 @@ declare const enTranslations: {
|
|
|
358
359
|
documentModified: string;
|
|
359
360
|
documentOutOfDate: string;
|
|
360
361
|
documents: string;
|
|
362
|
+
dragCancelled: string;
|
|
363
|
+
dragDropped: string;
|
|
364
|
+
dragInstructions: string;
|
|
365
|
+
dragMoved: string;
|
|
366
|
+
dragPickedUp: string;
|
|
367
|
+
dragToMove: string;
|
|
361
368
|
dragToReorder: string;
|
|
362
369
|
duplicate: string;
|
|
363
370
|
duplicateWithoutSaving: string;
|
|
@@ -469,6 +476,7 @@ declare const enTranslations: {
|
|
|
469
476
|
reindexingAll: string;
|
|
470
477
|
reloadDocument: string;
|
|
471
478
|
remove: string;
|
|
479
|
+
removeFilter: string;
|
|
472
480
|
rename: string;
|
|
473
481
|
replaceRow: string;
|
|
474
482
|
requiredFields: string;
|
|
@@ -558,6 +566,7 @@ declare const enTranslations: {
|
|
|
558
566
|
yes: string;
|
|
559
567
|
};
|
|
560
568
|
hierarchy: {
|
|
569
|
+
folderLocation: string;
|
|
561
570
|
goTo: string;
|
|
562
571
|
itemsMovedTo: string;
|
|
563
572
|
itemsMovedToRoot: string;
|
|
@@ -12223,7 +12232,7 @@ type RouterAdapterRouter = {
|
|
|
12223
12232
|
*/
|
|
12224
12233
|
replace: (path: string, options?: {
|
|
12225
12234
|
scroll?: boolean;
|
|
12226
|
-
}) => void;
|
|
12235
|
+
}) => Promise<void> | void;
|
|
12227
12236
|
/**
|
|
12228
12237
|
* Use this property to standardize behaviors across different router implementations.
|
|
12229
12238
|
* Set it up to sync client state to the URL without triggering a second server load.
|
|
@@ -15260,7 +15269,7 @@ type Arguments = {
|
|
|
15260
15269
|
req?: PayloadRequest;
|
|
15261
15270
|
showHiddenFields?: boolean;
|
|
15262
15271
|
};
|
|
15263
|
-
declare const restoreVersionOperation: <T extends
|
|
15272
|
+
declare const restoreVersionOperation: <T extends JsonObject = any>(args: Arguments) => Promise<T>;
|
|
15264
15273
|
|
|
15265
15274
|
type Args$8<TSlug extends GlobalSlug> = {
|
|
15266
15275
|
autosave?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/queues/operations/runJobs/runJob/getRunTaskFunction.ts"],"sourcesContent":["import ObjectIdImport from 'bson-objectid'\n\nimport type { Job } from '../../../../index.js'\nimport type { PayloadRequest } from '../../../../types/index.js'\nimport type {\n RetryConfig,\n RunInlineTaskFunction,\n RunTaskFunction,\n RunTaskFunctions,\n TaskConfig,\n TaskHandler,\n TaskHandlerResult,\n TaskSlug,\n} from '../../../config/types/taskTypes.js'\nimport type {\n JobLog,\n SingleTaskStatus,\n WorkflowConfig,\n WorkflowSlug,\n} from '../../../config/types/workflowTypes.js'\nimport type { UpdateJobFunction } from './getUpdateJobFunction.js'\n\nimport { JobCancelledError, JobRunAbortedError, TaskError } from '../../../errors/index.js'\nimport { getCurrentDate } from '../../../utilities/getCurrentDate.js'\nimport { getTaskHandlerFromConfig } from './importHandlerPath.js'\n\nconst ObjectId = 'default' in ObjectIdImport ? ObjectIdImport.default : ObjectIdImport\n\nexport type TaskParent = {\n taskID: string\n taskSlug: string\n}\n\nexport const getRunTaskFunction = <TIsInline extends boolean>(\n job: Job,\n workflowConfig: WorkflowConfig,\n req: PayloadRequest,\n isInline: TIsInline,\n updateJob: UpdateJobFunction,\n parent?: TaskParent,\n): TIsInline extends true ? RunInlineTaskFunction : RunTaskFunctions => {\n const jobConfig = req.payload.config.jobs\n\n const runTask: <TTaskSlug extends string>(\n taskSlug: TTaskSlug,\n ) => TTaskSlug extends 'inline' ? RunInlineTaskFunction : RunTaskFunction<TTaskSlug> = (\n taskSlug,\n ) =>\n (async (\n taskID: Parameters<RunInlineTaskFunction>[0],\n {\n input,\n retries,\n // Only available for inline tasks:\n task,\n }: Parameters<RunInlineTaskFunction>[1] & Parameters<RunTaskFunction<string>>[1],\n ) => {\n const executedAt = getCurrentDate()\n\n let taskConfig: TaskConfig | undefined\n if (!isInline) {\n taskConfig = (jobConfig.tasks?.length &&\n jobConfig.tasks.find((t) => t.slug === taskSlug)) as TaskConfig<string>\n\n if (!taskConfig) {\n throw new Error(`Task ${taskSlug} not found in workflow ${job.workflowSlug}`)\n }\n }\n\n const retriesConfigFromPropsNormalized =\n retries == undefined || retries == null\n ? {}\n : typeof retries === 'number'\n ? { attempts: retries }\n : retries\n const retriesConfigFromTaskConfigNormalized = taskConfig\n ? typeof taskConfig.retries === 'number'\n ? { attempts: taskConfig.retries }\n : taskConfig.retries\n : {}\n\n const finalRetriesConfig: RetryConfig = {\n ...retriesConfigFromTaskConfigNormalized,\n ...retriesConfigFromPropsNormalized, // Retry config from props takes precedence\n }\n\n const taskStatus: null | SingleTaskStatus<string> = job?.taskStatus?.[taskSlug]\n ? job.taskStatus[taskSlug][taskID]!\n : null\n\n // Handle restoration of task if it succeeded in a previous run\n if (taskStatus && taskStatus.complete === true) {\n let shouldRestore = true\n if (finalRetriesConfig?.shouldRestore === false) {\n shouldRestore = false\n } else if (typeof finalRetriesConfig?.shouldRestore === 'function') {\n shouldRestore = await finalRetriesConfig.shouldRestore({\n input,\n job,\n req,\n taskStatus,\n })\n }\n if (shouldRestore) {\n return taskStatus.output\n }\n }\n\n const runner = isInline\n ? (task as TaskHandler<TaskSlug>)\n : await getTaskHandlerFromConfig(taskConfig)\n\n if (!runner || typeof runner !== 'function') {\n throw new TaskError({\n executedAt,\n input,\n job,\n message: isInline\n ? `Inline task with ID ${taskID} does not have a valid handler.`\n : `Task with slug ${taskSlug} in workflow ${job.workflowSlug} does not have a valid handler.`,\n parent,\n retriesConfig: finalRetriesConfig,\n taskConfig,\n taskID,\n taskSlug,\n taskStatus,\n workflowConfig,\n })\n }\n\n let output: TaskHandlerResult<string>['output']\n\n try {\n output = (\n await runner({\n inlineTask: getRunTaskFunction(job, workflowConfig, req, true, updateJob, {\n taskID,\n taskSlug,\n }),\n input,\n job: job as unknown as Job<WorkflowSlug>,\n req,\n tasks: getRunTaskFunction(job, workflowConfig, req, false, updateJob, {\n taskID,\n taskSlug,\n }),\n })\n )?.output\n } catch (err: any) {\n if (err instanceof JobCancelledError || err instanceof JobRunAbortedError) {\n // Job run aborts are handled by the top-level runner.\n throw err\n }\n throw new TaskError({\n executedAt,\n input: input!,\n job,\n message: err.message || 'Task handler threw an error',\n output,\n parent,\n retriesConfig: finalRetriesConfig,\n taskConfig,\n taskID,\n taskSlug,\n taskStatus,\n workflowConfig,\n })\n }\n\n if (taskConfig?.onSuccess) {\n await taskConfig.onSuccess({\n input,\n job,\n req,\n taskStatus,\n })\n }\n\n const newLogItem: JobLog = {\n id: new ObjectId().toHexString(),\n completedAt: getCurrentDate().toISOString(),\n executedAt: executedAt.toISOString(),\n input: input ?? {},\n output,\n parent,\n state: 'succeeded',\n taskID,\n taskSlug,\n }\n\n await updateJob({\n log: {\n $push: newLogItem,\n } as any,\n // Set to null to skip main row update on postgres. 2 => 1 db round trips\n updatedAt: null as any,\n })\n\n return output\n }) as any\n\n if (isInline) {\n return runTask('inline') as TIsInline extends true ? RunInlineTaskFunction : RunTaskFunctions\n } else {\n const tasks: RunTaskFunctions = {}\n for (const task of jobConfig.tasks ?? []) {\n tasks[task.slug] = runTask(task.slug) as RunTaskFunction<string>\n }\n return tasks as TIsInline extends true ? RunInlineTaskFunction : RunTaskFunctions\n }\n}\n"],"names":["ObjectIdImport","JobCancelledError","JobRunAbortedError","TaskError","getCurrentDate","getTaskHandlerFromConfig","ObjectId","default","getRunTaskFunction","job","workflowConfig","req","isInline","updateJob","parent","jobConfig","payload","config","jobs","runTask","taskSlug","taskID","input","retries","task","executedAt","taskConfig","tasks","length","find","t","slug","Error","workflowSlug","retriesConfigFromPropsNormalized","undefined","attempts","retriesConfigFromTaskConfigNormalized","finalRetriesConfig","taskStatus","complete","shouldRestore","output","runner","message","retriesConfig","inlineTask","err","onSuccess","newLogItem","id","toHexString","completedAt","toISOString","state","log","$push","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;YAEA,IAAIgB,YAAYsB,WAAW;gBACzB,MAAMtB,WAAWsB,SAAS,CAAC;oBACzB1B;oBACAb;oBACAE;oBACA4B;gBACF;YACF;YAEA,MAAMU,aAAqB;gBACzBC,IAAI,IAAI5C,WAAW6C,WAAW;gBAC9BC,aAAahD,iBAAiBiD,WAAW;gBACzC5B,YAAYA,WAAW4B,WAAW;gBAClC/B,OAAOA,SAAS,CAAC;gBACjBoB;gBACA5B;gBACAwC,OAAO;gBACPjC;gBACAD;YACF;YAEA,MAAMP,UAAU;gBACd0C,KAAK;oBACHC,OAAOP;gBACT;gBACA,yEAAyE;gBACzEQ,WAAW;YACb;YAEA,OAAOf;QACT;IAEF,IAAI9B,UAAU;QACZ,OAAOO,QAAQ;IACjB,OAAO;QACL,MAAMQ,QAA0B,CAAC;QACjC,KAAK,MAAMH,QAAQT,UAAUY,KAAK,IAAI,EAAE,CAAE;YACxCA,KAAK,CAACH,KAAKO,IAAI,CAAC,GAAGZ,QAAQK,KAAKO,IAAI;QACtC;QACA,OAAOJ;IACT;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/queues/operations/runJobs/runJob/getRunTaskFunction.ts"],"sourcesContent":["import ObjectIdImport from 'bson-objectid'\n\nimport type { Job } from '../../../../index.js'\nimport type { PayloadRequest } from '../../../../types/index.js'\nimport type {\n RetryConfig,\n RunInlineTaskFunction,\n RunTaskFunction,\n RunTaskFunctions,\n TaskConfig,\n TaskHandler,\n TaskHandlerResult,\n TaskSlug,\n} from '../../../config/types/taskTypes.js'\nimport type {\n JobLog,\n SingleTaskStatus,\n WorkflowConfig,\n WorkflowSlug,\n} from '../../../config/types/workflowTypes.js'\nimport type { UpdateJobFunction } from './getUpdateJobFunction.js'\n\nimport { JobCancelledError, JobRunAbortedError, TaskError } from '../../../errors/index.js'\nimport { getCurrentDate } from '../../../utilities/getCurrentDate.js'\nimport { getTaskHandlerFromConfig } from './importHandlerPath.js'\n\nconst ObjectId = 'default' in ObjectIdImport ? ObjectIdImport.default : ObjectIdImport\n\nexport type TaskParent = {\n taskID: string\n taskSlug: string\n}\n\nexport const getRunTaskFunction = <TIsInline extends boolean>(\n job: Job,\n workflowConfig: WorkflowConfig,\n req: PayloadRequest,\n isInline: TIsInline,\n updateJob: UpdateJobFunction,\n parent?: TaskParent,\n): TIsInline extends true ? RunInlineTaskFunction : RunTaskFunctions => {\n const jobConfig = req.payload.config.jobs\n\n const runTask: <TTaskSlug extends string>(\n taskSlug: TTaskSlug,\n ) => TTaskSlug extends 'inline' ? RunInlineTaskFunction : RunTaskFunction<TTaskSlug> = (\n taskSlug,\n ) =>\n (async (\n taskID: Parameters<RunInlineTaskFunction>[0],\n {\n input,\n retries,\n // Only available for inline tasks:\n task,\n }: Parameters<RunInlineTaskFunction>[1] & Parameters<RunTaskFunction<string>>[1],\n ) => {\n const executedAt = getCurrentDate()\n\n let taskConfig: TaskConfig | undefined\n if (!isInline) {\n taskConfig = (jobConfig.tasks?.length &&\n jobConfig.tasks.find((t) => t.slug === taskSlug)) as TaskConfig<string>\n\n if (!taskConfig) {\n throw new Error(`Task ${taskSlug} not found in workflow ${job.workflowSlug}`)\n }\n }\n\n const retriesConfigFromPropsNormalized =\n retries == undefined || retries == null\n ? {}\n : typeof retries === 'number'\n ? { attempts: retries }\n : retries\n const retriesConfigFromTaskConfigNormalized = taskConfig\n ? typeof taskConfig.retries === 'number'\n ? { attempts: taskConfig.retries }\n : taskConfig.retries\n : {}\n\n const finalRetriesConfig: RetryConfig = {\n ...retriesConfigFromTaskConfigNormalized,\n ...retriesConfigFromPropsNormalized, // Retry config from props takes precedence\n }\n\n const taskStatus: null | SingleTaskStatus<string> = job?.taskStatus?.[taskSlug]\n ? job.taskStatus[taskSlug][taskID]!\n : null\n\n // Handle restoration of task if it succeeded in a previous run\n if (taskStatus && taskStatus.complete === true) {\n let shouldRestore = true\n if (finalRetriesConfig?.shouldRestore === false) {\n shouldRestore = false\n } else if (typeof finalRetriesConfig?.shouldRestore === 'function') {\n shouldRestore = await finalRetriesConfig.shouldRestore({\n input,\n job,\n req,\n taskStatus,\n })\n }\n if (shouldRestore) {\n return taskStatus.output\n }\n }\n\n const runner = isInline\n ? (task as TaskHandler<TaskSlug>)\n : await getTaskHandlerFromConfig(taskConfig)\n\n if (!runner || typeof runner !== 'function') {\n throw new TaskError({\n executedAt,\n input,\n job,\n message: isInline\n ? `Inline task with ID ${taskID} does not have a valid handler.`\n : `Task with slug ${taskSlug} in workflow ${job.workflowSlug} does not have a valid handler.`,\n parent,\n retriesConfig: finalRetriesConfig,\n taskConfig,\n taskID,\n taskSlug,\n taskStatus,\n workflowConfig,\n })\n }\n\n let output: TaskHandlerResult<string>['output']\n\n try {\n output = (\n await runner({\n inlineTask: getRunTaskFunction(job, workflowConfig, req, true, updateJob, {\n taskID,\n taskSlug,\n }),\n input,\n job,\n req,\n tasks: getRunTaskFunction(job, workflowConfig, req, false, updateJob, {\n taskID,\n taskSlug,\n }),\n })\n )?.output\n } catch (err: any) {\n if (err instanceof JobCancelledError || err instanceof JobRunAbortedError) {\n // Job run aborts are handled by the top-level runner.\n throw err\n }\n throw new TaskError({\n executedAt,\n input: input!,\n job,\n message: err.message || 'Task handler threw an error',\n output,\n parent,\n retriesConfig: finalRetriesConfig,\n taskConfig,\n taskID,\n taskSlug,\n taskStatus,\n workflowConfig,\n })\n }\n\n if (taskConfig?.onSuccess) {\n await taskConfig.onSuccess({\n input,\n job,\n req,\n taskStatus,\n })\n }\n\n const newLogItem: JobLog = {\n id: new ObjectId().toHexString(),\n completedAt: getCurrentDate().toISOString(),\n executedAt: executedAt.toISOString(),\n input: input ?? {},\n output,\n parent,\n state: 'succeeded',\n taskID,\n taskSlug,\n }\n\n await updateJob({\n log: {\n $push: newLogItem,\n } as any,\n // Set to null to skip main row update on postgres. 2 => 1 db round trips\n updatedAt: null as any,\n })\n\n return output\n }) as any\n\n if (isInline) {\n return runTask('inline') as TIsInline extends true ? RunInlineTaskFunction : RunTaskFunctions\n } else {\n const tasks: RunTaskFunctions = {}\n for (const task of jobConfig.tasks ?? []) {\n tasks[task.slug] = runTask(task.slug) as RunTaskFunction<string>\n }\n return tasks as TIsInline extends true ? RunInlineTaskFunction : RunTaskFunctions\n }\n}\n"],"names":["ObjectIdImport","JobCancelledError","JobRunAbortedError","TaskError","getCurrentDate","getTaskHandlerFromConfig","ObjectId","default","getRunTaskFunction","job","workflowConfig","req","isInline","updateJob","parent","jobConfig","payload","config","jobs","runTask","taskSlug","taskID","input","retries","task","executedAt","taskConfig","tasks","length","find","t","slug","Error","workflowSlug","retriesConfigFromPropsNormalized","undefined","attempts","retriesConfigFromTaskConfigNormalized","finalRetriesConfig","taskStatus","complete","shouldRestore","output","runner","message","retriesConfig","inlineTask","err","onSuccess","newLogItem","id","toHexString","completedAt","toISOString","state","log","$push","updatedAt"],"mappings":"AAAA,OAAOA,oBAAoB,gBAAe;AAsB1C,SAASC,iBAAiB,EAAEC,kBAAkB,EAAEC,SAAS,QAAQ,2BAA0B;AAC3F,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,wBAAwB,QAAQ,yBAAwB;AAEjE,MAAMC,WAAW,aAAaN,iBAAiBA,eAAeO,OAAO,GAAGP;AAOxE,OAAO,MAAMQ,qBAAqB,CAChCC,KACAC,gBACAC,KACAC,UACAC,WACAC;IAEA,MAAMC,YAAYJ,IAAIK,OAAO,CAACC,MAAM,CAACC,IAAI;IAEzC,MAAMC,UAEiF,CACrFC,WAEC,OACCC,QACA,EACEC,KAAK,EACLC,OAAO,EACP,mCAAmC;QACnCC,IAAI,EAC0E;YAEhF,MAAMC,aAAarB;YAEnB,IAAIsB;YACJ,IAAI,CAACd,UAAU;gBACbc,aAAcX,UAAUY,KAAK,EAAEC,UAC7Bb,UAAUY,KAAK,CAACE,IAAI,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAKX;gBAEzC,IAAI,CAACM,YAAY;oBACf,MAAM,IAAIM,MAAM,CAAC,KAAK,EAAEZ,SAAS,uBAAuB,EA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