payload 4.0.0-beta.3 → 4.0.0-beta.5

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.
Files changed (96) hide show
  1. package/dist/admin/adapters/router.d.ts +1 -1
  2. package/dist/admin/adapters/router.d.ts.map +1 -1
  3. package/dist/admin/adapters/router.js.map +1 -1
  4. package/dist/admin/initAdminContext.js.map +1 -1
  5. package/dist/auth/getFieldsToSign.js.map +1 -1
  6. package/dist/auth/loginWithCookie.js.map +1 -1
  7. package/dist/auth/operations/resetPassword.d.ts.map +1 -1
  8. package/dist/auth/operations/resetPassword.js +50 -1
  9. package/dist/auth/operations/resetPassword.js.map +1 -1
  10. package/dist/auth/serverFunctions/cookies.js.map +1 -1
  11. package/dist/auth/serverFunctions/login.js.map +1 -1
  12. package/dist/cli/defineCLICommand.js +1 -1
  13. package/dist/cli/defineCLICommand.js.map +1 -1
  14. package/dist/collections/config/client.js.map +1 -1
  15. package/dist/collections/operations/findByID.js.map +1 -1
  16. package/dist/collections/operations/findVersionByID.js.map +1 -1
  17. package/dist/collections/operations/findVersions.js.map +1 -1
  18. package/dist/collections/operations/local/findDistinct.js.map +1 -1
  19. package/dist/collections/operations/renameFile.js +1 -1
  20. package/dist/collections/operations/renameFile.js.map +1 -1
  21. package/dist/collections/operations/utilities/update.js +1 -1
  22. package/dist/collections/operations/utilities/update.js.map +1 -1
  23. package/dist/collections/operations/validate.js +4 -4
  24. package/dist/collections/operations/validate.js.map +1 -1
  25. package/dist/config/definePlugin.js +3 -1
  26. package/dist/config/definePlugin.js.map +1 -1
  27. package/dist/config/sanitize.js +2 -2
  28. package/dist/config/sanitize.js.map +1 -1
  29. package/dist/exports/build-config.d.ts +9 -0
  30. package/dist/exports/build-config.d.ts.map +1 -0
  31. package/dist/exports/build-config.js +38 -0
  32. package/dist/exports/build-config.js.map +1 -0
  33. package/dist/exports/internal.d.ts +1 -1
  34. package/dist/exports/internal.d.ts.map +1 -1
  35. package/dist/exports/internal.js +1 -1
  36. package/dist/exports/internal.js.map +1 -1
  37. package/dist/fields/config/client.js.map +1 -1
  38. package/dist/fields/hooks/afterChange/promise.js.map +1 -1
  39. package/dist/fields/validations.d.ts.map +1 -1
  40. package/dist/fields/validations.js +4 -1
  41. package/dist/fields/validations.js.map +1 -1
  42. package/dist/globals/operations/local/findOne.js.map +1 -1
  43. package/dist/globals/operations/local/update.js.map +1 -1
  44. package/dist/globals/operations/restoreVersion.d.ts +2 -3
  45. package/dist/globals/operations/restoreVersion.d.ts.map +1 -1
  46. package/dist/globals/operations/restoreVersion.js +22 -15
  47. package/dist/globals/operations/restoreVersion.js.map +1 -1
  48. package/dist/globals/operations/validate.js +1 -1
  49. package/dist/globals/operations/validate.js.map +1 -1
  50. package/dist/hierarchy/createFolderField.js.map +1 -1
  51. package/dist/hierarchy/resolveHierarchyCollections.js +2 -2
  52. package/dist/hierarchy/resolveHierarchyCollections.js.map +1 -1
  53. package/dist/hierarchy/utils/computePaths.d.ts.map +1 -1
  54. package/dist/hierarchy/utils/computePaths.js.map +1 -1
  55. package/dist/index.bundled.d.ts +17 -4
  56. package/dist/queues/operations/runJobs/runJob/getRunTaskFunction.js +1 -1
  57. package/dist/queues/operations/runJobs/runJob/getRunTaskFunction.js.map +1 -1
  58. package/dist/uploads/clientUploadReceipt.d.ts +15 -1
  59. package/dist/uploads/clientUploadReceipt.d.ts.map +1 -1
  60. package/dist/uploads/clientUploadReceipt.js +35 -6
  61. package/dist/uploads/clientUploadReceipt.js.map +1 -1
  62. package/dist/uploads/fileVersioning/archive.js.map +1 -1
  63. package/dist/uploads/fileVersioning/resolveHistoricalFile.js.map +1 -1
  64. package/dist/uploads/generateFileData.d.ts.map +1 -1
  65. package/dist/uploads/generateFileData.js.map +1 -1
  66. package/dist/uploads/getFileFromUploadInstructions.d.ts.map +1 -1
  67. package/dist/uploads/getFileFromUploadInstructions.js +42 -0
  68. package/dist/uploads/getFileFromUploadInstructions.js.map +1 -1
  69. package/dist/uploads/safeFetch.js.map +1 -1
  70. package/dist/uploads/stagedUpload.js.map +1 -1
  71. package/dist/uploads/transformers/handleDynamicFileRequest.js +11 -2
  72. package/dist/uploads/transformers/handleDynamicFileRequest.js.map +1 -1
  73. package/dist/uploads/types.d.ts +5 -1
  74. package/dist/uploads/types.d.ts.map +1 -1
  75. package/dist/uploads/types.js.map +1 -1
  76. package/dist/utilities/addSelectGenericsToGeneretedTypes.d.ts.map +1 -1
  77. package/dist/utilities/addSelectGenericsToGeneretedTypes.js +0 -1
  78. package/dist/utilities/addSelectGenericsToGeneretedTypes.js.map +1 -1
  79. package/dist/utilities/appendDateTimezoneSelectFields.js.map +1 -1
  80. package/dist/utilities/cloneValidationRequest.js.map +1 -1
  81. package/dist/utilities/createPayloadRequest.js.map +1 -1
  82. package/dist/utilities/deepCopyObject.js.map +1 -1
  83. package/dist/utilities/documentMatchingWhereExists.js +1 -1
  84. package/dist/utilities/documentMatchingWhereExists.js.map +1 -1
  85. package/dist/utilities/filterDataToSelectedLocales.js.map +1 -1
  86. package/dist/utilities/getEntityPermissions/getEntityPermissions.d.ts.map +1 -1
  87. package/dist/utilities/getEntityPermissions/getEntityPermissions.js +1 -0
  88. package/dist/utilities/getEntityPermissions/getEntityPermissions.js.map +1 -1
  89. package/dist/utilities/getEntityPermissions/populateFieldPermissions.js.map +1 -1
  90. package/dist/utilities/parseParams/index.js.map +1 -1
  91. package/dist/utilities/parseValidationLocale.js.map +1 -1
  92. package/dist/utilities/sanitizePopulateParam.js.map +1 -1
  93. package/dist/utilities/telemetry/featureInfo/getFeatureInfo.js.map +1 -1
  94. package/dist/versions/allLocalesPublicationStatus.js.map +1 -1
  95. package/package.json +11 -9
  96. package/skills/payload/reference/PLUGIN-DEVELOPMENT.md +1 -1
@@ -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;AACt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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,UACE0C,kBAAkBvE,YAAauE,gBAA2BhG,QAAQc;YACpEyC,WAAWzC;QACb;IACF;AACF"}
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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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"}
@@ -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:draft" | "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: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;
@@ -4972,7 +4981,11 @@ type GenerateUploadInstructions = (args: {
4972
4981
  type UploadInstructionsCapability = {
4973
4982
  /** Generates upload instructions. The generator or supporting endpoint must check access. */
4974
4983
  generate: GenerateUploadInstructions;
4975
- /** Require a signed server-issued reference before invoking upload handlers. @internal */
4984
+ /**
4985
+ * Require a receipt signed by `resolveSignedURLKey` before invoking upload handlers. Client
4986
+ * uploads keep an `original` and file history only when a receipt is verified.
4987
+ * @see https://payloadcms.com/docs/upload/storage-adapters#custom-upload-receipts
4988
+ */
4976
4989
  requiresUploadReceipt?: boolean;
4977
4990
  /**
4978
4991
  * Whether the Admin panel should use these instructions before saving a document.
@@ -12223,7 +12236,7 @@ type RouterAdapterRouter = {
12223
12236
  */
12224
12237
  replace: (path: string, options?: {
12225
12238
  scroll?: boolean;
12226
- }) => void;
12239
+ }) => Promise<void> | void;
12227
12240
  /**
12228
12241
  * Use this property to standardize behaviors across different router implementations.
12229
12242
  * Set it up to sync client state to the URL without triggering a second server load.
@@ -15260,7 +15273,7 @@ type Arguments = {
15260
15273
  req?: PayloadRequest;
15261
15274
  showHiddenFields?: boolean;
15262
15275
  };
15263
- declare const restoreVersionOperation: <T extends TypeWithVersion<T> = any>(args: Arguments) => Promise<T>;
15276
+ declare const restoreVersionOperation: <T extends JsonObject = any>(args: Arguments) => Promise<T>;
15264
15277
 
15265
15278
  type Args$8<TSlug extends GlobalSlug> = {
15266
15279
  autosave?: boolean;
@@ -67,7 +67,7 @@ export const getRunTaskFunction = (job, workflowConfig, req, isInline, updateJob
67
67
  taskSlug
68
68
  }),
69
69
  input,
70
- job: job,
70
+ job,
71
71
  req,
72
72
  tasks: getRunTaskFunction(job, workflowConfig, req, false, updateJob, {
73
73
  taskID,
@@ -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","updatedAt"],"mappings":"AAAA,OAAOA,oBAAoB,gBAAe;AAsB1C,SAASC,iBAAiB,EAAEC,kBAAkB,EAAEC,SAAS,QA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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,EAAEX,IAAIwB,YAAY,EAAE;gBAC9E;YACF;YAEA,MAAMC,mCACJX,WAAWY,aAAaZ,WAAW,OAC/B,CAAC,IACD,OAAOA,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ACAgB,OAAOnB,mBAAmBC,KAAKC,gBAAgBC,KAAK,OAAOE,WAAW;wBACpEQ;wBACAD;oBACF;gBACF,EAAC,GACAsB;YACL,EAAE,OAAOK,KAAU;gBACjB,IAAIA,eAAe9C,qBAAqB8C,eAAe7C,oBAAoB;oBACzE,sDAAsD;oBACtD,MAAM6C;gBACR;gBACA,MAAM,IAAI5C,UAAU;oBAClBsB;oBACAH,OAAOA;oBACPb;oBACAmC,SAASG,IAAIH,OAAO,IAAI;oBACxBF;oBACA5B;oBACA+B,eAAeP;oBACfZ;oBACAL;oBACAD;oBACAmB;oBACA7B;gBACF;YACF;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,6 +1,8 @@
1
1
  import type { PayloadRequest } from '../types/index.js';
2
2
  type ClientUploadReceipt = {
3
3
  _objectKey?: string;
4
+ /** Signed data the storage adapter needs back after upload, such as a provider upload ID. */
5
+ adapterData?: Record<string, unknown>;
4
6
  allowOverwrite?: boolean;
5
7
  collectionSlug: string;
6
8
  expiresAt: number;
@@ -10,8 +12,9 @@ type ClientUploadReceipt = {
10
12
  userCollection: null | string;
11
13
  userID: null | number | string;
12
14
  };
13
- export declare const createClientUploadReceipt: ({ _objectKey, allowOverwrite, collectionSlug, filename, filePrefix, req, storageFilePath, }: {
15
+ export declare const createClientUploadReceipt: ({ _objectKey, adapterData, allowOverwrite, collectionSlug, filename, filePrefix, req, storageFilePath, }: {
14
16
  _objectKey?: string;
17
+ adapterData?: Record<string, unknown>;
15
18
  allowOverwrite?: boolean;
16
19
  collectionSlug: string;
17
20
  filename: string;
@@ -19,6 +22,17 @@ export declare const createClientUploadReceipt: ({ _objectKey, allowOverwrite, c
19
22
  req: PayloadRequest;
20
23
  storageFilePath: string;
21
24
  }) => `${string}.${string}`;
25
+ /**
26
+ * Signs a copy of a receipt with more `adapterData`, such as a provider ID that exists only after
27
+ * the upload. Every other field, including the user and expiry, is kept from the original receipt.
28
+ */
29
+ export declare const resignClientUploadReceipt: ({ adapterData, collectionSlug, req, signedReceipt, }: {
30
+ adapterData: Record<string, unknown>;
31
+ /** Rejects a receipt issued for another collection. */
32
+ collectionSlug?: string;
33
+ req: PayloadRequest;
34
+ signedReceipt: unknown;
35
+ }) => `${string}.${string}`;
22
36
  export declare const verifyClientUploadReceipt: ({ collectionSlug, filename, req, signedReceipt, }: {
23
37
  collectionSlug?: string;
24
38
  filename?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"clientUploadReceipt.d.ts","sourceRoot":"","sources":["../../src/uploads/clientUploadReceipt.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAIvD,KAAK,mBAAmB,GAAG;IACzB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,U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M,CAAA;CAC/B,CAAA;AAOD,eAAO,MAAM,yBAAyB,6GASnC;IACD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACrC,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,cAAc,EAAE,MAAM,CAAA;IACtB,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;IAClB,GAAG,EAAE,cAAc,CAAA;IACnB,eAAe,EAAE,MAAM,CAAA;CACxB,KAAG,GAAG,MAAM,IAAI,MAAM,EActB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,yBAAyB,yDAKnC;IACD,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC,uDAAuD;IACvD,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,GAAG,EAAE,cAAc,CAAA;IACnB,aAAa,EAAE,OAAO,CAAA;CACvB,KAAG,GAAG,MAAM,IAAI,MAAM,EAOtB,CAAA;AAED,eAAO,MAAM,yBAAyB,sDAKnC;IACD,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,GAAG,EAAE,cAAc,CAAA;IACnB,aAAa,EAAE,OAAO,CAAA;CACvB,KAAG,mBA+BH,CAAA"}
@@ -4,11 +4,14 @@ import { APIError } from '../errors/APIError.js';
4
4
  const LIFETIME_MS = 6 * 60 * 60 * 1000;
5
5
  // Separates these signatures from any future receipt format.
6
6
  const DOMAIN = 'payload-client-upload-receipt-v1';
7
- export const createClientUploadReceipt = ({ _objectKey, allowOverwrite, collectionSlug, filename, filePrefix, req, storageFilePath })=>{
7
+ export const createClientUploadReceipt = ({ _objectKey, adapterData, allowOverwrite, collectionSlug, filename, filePrefix, req, storageFilePath })=>{
8
8
  const data = {
9
9
  ..._objectKey !== undefined && {
10
10
  _objectKey
11
11
  },
12
+ ...adapterData !== undefined && {
13
+ adapterData
14
+ },
12
15
  ...allowOverwrite && {
13
16
  allowOverwrite: true
14
17
  },
@@ -19,11 +22,30 @@ export const createClientUploadReceipt = ({ _objectKey, allowOverwrite, collecti
19
22
  storageFilePath,
20
23
  ...getUser(req)
21
24
  };
22
- const encodedReceipt = Buffer.from(JSON.stringify(data)).toString('base64url');
23
- return `${encodedReceipt}.${sign({
24
- encodedReceipt,
25
+ return encodeReceipt({
26
+ data,
25
27
  secret: req.payload.secret
26
- })}`;
28
+ });
29
+ };
30
+ /**
31
+ * Signs a copy of a receipt with more `adapterData`, such as a provider ID that exists only after
32
+ * the upload. Every other field, including the user and expiry, is kept from the original receipt.
33
+ */ export const resignClientUploadReceipt = ({ adapterData, collectionSlug, req, signedReceipt })=>{
34
+ const receipt = verifyClientUploadReceipt({
35
+ collectionSlug,
36
+ req,
37
+ signedReceipt
38
+ });
39
+ return encodeReceipt({
40
+ data: {
41
+ ...receipt,
42
+ adapterData: {
43
+ ...receipt.adapterData,
44
+ ...adapterData
45
+ }
46
+ },
47
+ secret: req.payload.secret
48
+ });
27
49
  };
28
50
  export const verifyClientUploadReceipt = ({ collectionSlug, filename, req, signedReceipt })=>{
29
51
  if (typeof signedReceipt !== 'string') {
@@ -59,6 +81,13 @@ const getUser = (req)=>({
59
81
  userCollection: req.user?.collection ?? null,
60
82
  userID: req.user?.id ?? null
61
83
  });
84
+ const encodeReceipt = ({ data, secret })=>{
85
+ const encodedReceipt = Buffer.from(JSON.stringify(data)).toString('base64url');
86
+ return `${encodedReceipt}.${sign({
87
+ encodedReceipt,
88
+ secret
89
+ })}`;
90
+ };
62
91
  const sign = ({ encodedReceipt, secret })=>crypto.createHmac('sha256', `${DOMAIN}:${secret}`).update(encodedReceipt).digest('base64url');
63
92
  const equal = ({ actual, expected })=>{
64
93
  const actualBuffer = Buffer.from(actual);
@@ -70,7 +99,7 @@ const isReceipt = (value)=>{
70
99
  return false;
71
100
  }
72
101
  const data = value;
73
- return (data._objectKey === undefined || typeof data._objectKey === 'string') && (data.allowOverwrite === undefined || typeof data.allowOverwrite === 'boolean') && typeof data.collectionSlug === 'string' && typeof data.expiresAt === 'number' && Number.isFinite(data.expiresAt) && typeof data.storageFilePath === 'string' && typeof data.filePrefix === 'string' && typeof data.filename === 'string' && (data.userCollection === null || typeof data.userCollection === 'string') && (data.userID === null || typeof data.userID === 'string' || typeof data.userID === 'number' && Number.isFinite(data.userID));
102
+ return (data._objectKey === undefined || typeof data._objectKey === 'string') && (data.adapterData === undefined || typeof data.adapterData === 'object' && data.adapterData !== null && !Array.isArray(data.adapterData)) && (data.allowOverwrite === undefined || typeof data.allowOverwrite === 'boolean') && typeof data.collectionSlug === 'string' && typeof data.expiresAt === 'number' && Number.isFinite(data.expiresAt) && typeof data.storageFilePath === 'string' && typeof data.filePrefix === 'string' && typeof data.filename === 'string' && (data.userCollection === null || typeof data.userCollection === 'string') && (data.userID === null || typeof data.userID === 'string' || typeof data.userID === 'number' && Number.isFinite(data.userID));
74
103
  };
75
104
 
76
105
  //# sourceMappingURL=clientUploadReceipt.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/uploads/clientUploadReceipt.ts"],"sourcesContent":["import crypto from 'node:crypto'\n\nimport type { PayloadRequest } from '../types/index.js'\n\nimport { APIError } from '../errors/APIError.js'\n\ntype ClientUploadReceipt = {\n _objectKey?: string\n allowOverwrite?: boolean\n collectionSlug: string\n expiresAt: number\n filename: string\n filePrefix: string\n storageFilePath: string\n userCollection: null | string\n userID: null | number | string\n}\n\n// Longer than the longest provider upload URL (GCS: five hours).\nconst LIFETIME_MS = 6 * 60 * 60 * 1000\n// Separates these signatures from any future receipt format.\nconst DOMAIN = 'payload-client-upload-receipt-v1'\n\nexport const createClientUploadReceipt = ({\n _objectKey,\n allowOverwrite,\n collectionSlug,\n filename,\n filePrefix,\n req,\n storageFilePath,\n}: {\n _objectKey?: string\n allowOverwrite?: boolean\n collectionSlug: string\n filename: string\n filePrefix: string\n req: PayloadRequest\n storageFilePath: string\n}): `${string}.${string}` => {\n const data: ClientUploadReceipt = {\n ...(_objectKey !== undefined && { _objectKey }),\n ...(allowOverwrite && { allowOverwrite: true }),\n collectionSlug,\n expiresAt: Date.now() + LIFETIME_MS,\n filename,\n filePrefix,\n storageFilePath,\n ...getUser(req),\n }\n const encodedReceipt = Buffer.from(JSON.stringify(data)).toString('base64url')\n\n return `${encodedReceipt}.${sign({ encodedReceipt, secret: req.payload.secret })}`\n}\n\nexport const verifyClientUploadReceipt = ({\n collectionSlug,\n filename,\n req,\n signedReceipt,\n}: {\n collectionSlug?: string\n filename?: string\n req: PayloadRequest\n signedReceipt: unknown\n}): ClientUploadReceipt => {\n if (typeof signedReceipt !== 'string') {\n throwInvalidReference()\n }\n const [encodedReceipt, signature, extra] = signedReceipt.split('.')\n const expected = encodedReceipt ? sign({ encodedReceipt, secret: req.payload.secret }) : ''\n\n if (!encodedReceipt || !signature || extra || !equal({ actual: signature, expected })) {\n throwInvalidReference()\n }\n\n let decodedReceipt: unknown\n try {\n decodedReceipt = JSON.parse(Buffer.from(encodedReceipt, 'base64url').toString())\n } catch {\n throwInvalidReference()\n }\n\n const user = getUser(req)\n if (\n !isReceipt(decodedReceipt) ||\n decodedReceipt.expiresAt <= Date.now() ||\n decodedReceipt.userCollection !== user.userCollection ||\n decodedReceipt.userID !== user.userID ||\n (collectionSlug !== undefined && decodedReceipt.collectionSlug !== collectionSlug) ||\n (filename !== undefined && decodedReceipt.filename !== filename)\n ) {\n throwInvalidReference()\n }\n\n return decodedReceipt\n}\n\nfunction throwInvalidReference(): never {\n throw new APIError('Invalid upload reference.', 400)\n}\n\nconst getUser = (req: PayloadRequest) => ({\n userCollection: req.user?.collection ?? null,\n userID: req.user?.id ?? null,\n})\n\nconst sign = ({ encodedReceipt, secret }: { encodedReceipt: string; secret: string }) =>\n crypto.createHmac('sha256', `${DOMAIN}:${secret}`).update(encodedReceipt).digest('base64url')\n\nconst equal = ({ actual, expected }: { actual: string; expected: string }) => {\n const actualBuffer = Buffer.from(actual)\n const expectedBuffer = Buffer.from(expected)\n return (\n actualBuffer.length === expectedBuffer.length &&\n crypto.timingSafeEqual(actualBuffer, expectedBuffer)\n )\n}\n\nconst isReceipt = (value: unknown): value is ClientUploadReceipt => {\n if (!value || typeof value !== 'object') {\n return false\n }\n const data = value as Partial<ClientUploadReceipt>\n return (\n (data._objectKey === undefined || typeof data._objectKey === 'string') &&\n (data.allowOverwrite === undefined || typeof data.allowOverwrite === 'boolean') &&\n typeof data.collectionSlug === 'string' &&\n typeof data.expiresAt === 'number' &&\n Number.isFinite(data.expiresAt) &&\n typeof data.storageFilePath === 'string' &&\n typeof data.filePrefix === 'string' &&\n typeof data.filename === 'string' &&\n (data.userCollection === null || typeof data.userCollection === 'string') &&\n (data.userID === null ||\n typeof data.userID === 'string' ||\n (typeof data.userID === 'number' && Number.isFinite(data.userID)))\n )\n}\n"],"names":["crypto","APIError","LIFETIME_MS","DOMAIN","createClientUploadReceipt","_objectKey","allowOverwrite","collectionSlug","filename","filePrefix","req","storageFilePath","data","undefined","expiresAt","Date","now","getUser","encodedReceipt","Buffer","from","JSON","stringify","toString","sign","secret","payload","verifyClientUploadReceipt","signedReceipt","throwInvalidReference","signature","extra","split","expected","equal","actual","decodedReceipt","parse","user","isReceipt","userCollection","userID","collection","id","createHmac","update","digest","actualBuffer","expectedBuffer","length","timingSafeEqual","value","Number","isFinite"],"mappings":"AAAA,OAAOA,YAAY,cAAa;AAIhC,SAASC,QAAQ,QAAQ,wBAAuB;AAchD,iEAAiE;AACjE,MAAMC,cAAc,IAAI,KAAK,KAAK;AAClC,6DAA6D;AAC7D,MAAMC,SAAS;AAEf,OAAO,MAAMC,4BAA4B,CAAC,EACxCC,UAAU,EACVC,cAAc,EACdC,cAAc,EACdC,QAAQ,EACRC,UAAU,EACVC,GAAG,EACHC,eAAe,EAShB;IACC,MAAMC,OAA4B;QAChC,GAAIP,eAAeQ,aAAa;YAAER;QAAW,CAAC;QAC9C,GAAIC,kBAAkB;YA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,CAACzC,KAAK6B,MAAM,CAAC;AAEtE"}
1
+ {"version":3,"sources":["../../src/uploads/clientUploadReceipt.ts"],"sourcesContent":["import crypto from 'node:crypto'\n\nimport type { PayloadRequest } from '../types/index.js'\n\nimport { APIError } from '../errors/APIError.js'\n\ntype ClientUploadReceipt = {\n _objectKey?: string\n /** Signed data the storage adapter needs back after upload, such as a provider upload ID. */\n adapterData?: Record<string, unknown>\n allowOverwrite?: boolean\n collectionSlug: string\n expiresAt: number\n filename: string\n filePrefix: string\n storageFilePath: string\n userCollection: null | string\n userID: null | number | string\n}\n\n// Longer than the longest provider upload URL (GCS: five hours).\nconst LIFETIME_MS = 6 * 60 * 60 * 1000\n// Separates these signatures from any future receipt format.\nconst DOMAIN = 'payload-client-upload-receipt-v1'\n\nexport const createClientUploadReceipt = ({\n _objectKey,\n adapterData,\n allowOverwrite,\n collectionSlug,\n filename,\n filePrefix,\n req,\n storageFilePath,\n}: {\n _objectKey?: string\n adapterData?: Record<string, unknown>\n allowOverwrite?: boolean\n collectionSlug: string\n filename: string\n filePrefix: string\n req: PayloadRequest\n storageFilePath: string\n}): `${string}.${string}` => {\n const data: ClientUploadReceipt = {\n ...(_objectKey !== undefined && { _objectKey }),\n ...(adapterData !== undefined && { adapterData }),\n ...(allowOverwrite && { allowOverwrite: true }),\n collectionSlug,\n expiresAt: Date.now() + LIFETIME_MS,\n filename,\n filePrefix,\n storageFilePath,\n ...getUser(req),\n }\n\n return encodeReceipt({ data, secret: req.payload.secret })\n}\n\n/**\n * Signs a copy of a receipt with more `adapterData`, such as a provider ID that exists only after\n * the upload. Every other field, including the user and expiry, is kept from the original receipt.\n */\nexport const resignClientUploadReceipt = ({\n adapterData,\n collectionSlug,\n req,\n signedReceipt,\n}: {\n adapterData: Record<string, unknown>\n /** Rejects a receipt issued for another collection. */\n collectionSlug?: string\n req: PayloadRequest\n signedReceipt: unknown\n}): `${string}.${string}` => {\n const receipt = verifyClientUploadReceipt({ collectionSlug, req, signedReceipt })\n\n return encodeReceipt({\n data: { ...receipt, adapterData: { ...receipt.adapterData, ...adapterData } },\n secret: req.payload.secret,\n })\n}\n\nexport const verifyClientUploadReceipt = ({\n collectionSlug,\n filename,\n req,\n signedReceipt,\n}: {\n collectionSlug?: string\n filename?: string\n req: PayloadRequest\n signedReceipt: unknown\n}): ClientUploadReceipt => {\n if (typeof signedReceipt !== 'string') {\n throwInvalidReference()\n }\n const [encodedReceipt, signature, extra] = signedReceipt.split('.')\n const expected = encodedReceipt ? sign({ encodedReceipt, secret: req.payload.secret }) : ''\n\n if (!encodedReceipt || !signature || extra || !equal({ actual: signature, expected })) {\n throwInvalidReference()\n }\n\n let decodedReceipt: unknown\n try {\n decodedReceipt = JSON.parse(Buffer.from(encodedReceipt, 'base64url').toString())\n } catch {\n throwInvalidReference()\n }\n\n const user = getUser(req)\n if (\n !isReceipt(decodedReceipt) ||\n decodedReceipt.expiresAt <= Date.now() ||\n decodedReceipt.userCollection !== user.userCollection ||\n decodedReceipt.userID !== user.userID ||\n (collectionSlug !== undefined && decodedReceipt.collectionSlug !== collectionSlug) ||\n (filename !== undefined && decodedReceipt.filename !== filename)\n ) {\n throwInvalidReference()\n }\n\n return decodedReceipt\n}\n\nfunction throwInvalidReference(): never {\n throw new APIError('Invalid upload reference.', 400)\n}\n\nconst getUser = (req: PayloadRequest) => ({\n userCollection: req.user?.collection ?? null,\n userID: req.user?.id ?? null,\n})\n\nconst encodeReceipt = ({\n data,\n secret,\n}: {\n data: ClientUploadReceipt\n secret: string\n}): `${string}.${string}` => {\n const encodedReceipt = Buffer.from(JSON.stringify(data)).toString('base64url')\n\n return `${encodedReceipt}.${sign({ encodedReceipt, secret })}`\n}\n\nconst sign = ({ encodedReceipt, secret }: { encodedReceipt: string; secret: string }) =>\n crypto.createHmac('sha256', `${DOMAIN}:${secret}`).update(encodedReceipt).digest('base64url')\n\nconst equal = ({ actual, expected }: { actual: string; expected: string }) => {\n const actualBuffer = Buffer.from(actual)\n const expectedBuffer = Buffer.from(expected)\n return (\n actualBuffer.length === expectedBuffer.length &&\n crypto.timingSafeEqual(actualBuffer, expectedBuffer)\n )\n}\n\nconst isReceipt = (value: unknown): value is ClientUploadReceipt => {\n if (!value || typeof value !== 'object') {\n return false\n }\n const data = value as Partial<ClientUploadReceipt>\n return (\n (data._objectKey === undefined || typeof data._objectKey === 'string') &&\n (data.adapterData === undefined ||\n (typeof data.adapterData === 'object' &&\n data.adapterData !== null &&\n !Array.isArray(data.adapterData))) &&\n (data.allowOverwrite === undefined || typeof data.allowOverwrite === 'boolean') &&\n typeof data.collectionSlug === 'string' &&\n typeof data.expiresAt === 'number' &&\n Number.isFinite(data.expiresAt) &&\n typeof data.storageFilePath === 'string' &&\n typeof data.filePrefix === 'string' &&\n typeof data.filename === 'string' &&\n (data.userCollection === null || typeof data.userCollection === 'string') &&\n (data.userID === null ||\n typeof data.userID === 'string' ||\n (typeof data.userID === 'number' && Number.isFinite(data.userID)))\n )\n}\n"],"names":["crypto","APIError","LIFETIME_MS","DOMAIN","createClientUploadReceipt","_objectKey","adapterData","allowOverwrite","collectionSlug","filename","filePrefix","req","storageFilePath","data","undefined","expiresAt","Date","now","getUser","encodeReceipt","secret","payload","resignClientUploadReceipt","signedReceipt","receipt","verifyClientUploadReceipt","throwInvalidReference","encodedReceipt","signature","extra","split","expected","sign","equal","actual","decodedReceipt","JSON","parse","Buffer","from","toString","user","isReceipt","userCollection","userID","collection","id","stringify","createHmac","update","digest","actualBuffer","expectedBuffer","length","timingSafeEqual","value","Array","isArray","Number","isFinite"],"mappings":"AAAA,OAAOA,YAAY,cAAa;AAIhC,SAASC,QAAQ,QAAQ,wBAAuB;AAgBhD,iEAAiE;AACjE,MAAMC,cAAc,IAAI,KAAK,KAAK;AAClC,6DAA6D;AAC7D,MAAMC,SAAS;AAEf,OAAO,MAAMC,4BAA4B,CAAC,EACxCC,UAAU,EACVC,WAAW,EACXC,cAAc,EACdC,cAAc,EACdC,QAAQ,EACRC,UAAU,EACVC,GAAG,EACH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