payload 4.0.0-beta.8 → 4.0.0-beta.9

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 (196) hide show
  1. package/dist/auth/baseFields/sessions.d.ts.map +1 -1
  2. package/dist/auth/baseFields/sessions.js +12 -0
  3. package/dist/auth/baseFields/sessions.js.map +1 -1
  4. package/dist/auth/createAuthToken.d.ts +3 -3
  5. package/dist/auth/createAuthToken.d.ts.map +1 -1
  6. package/dist/auth/createAuthToken.js +4 -1
  7. package/dist/auth/createAuthToken.js.map +1 -1
  8. package/dist/auth/getUserAgentLabel.d.ts +8 -0
  9. package/dist/auth/getUserAgentLabel.d.ts.map +1 -0
  10. package/dist/auth/getUserAgentLabel.js +70 -0
  11. package/dist/auth/getUserAgentLabel.js.map +1 -0
  12. package/dist/auth/operations/login.d.ts.map +1 -1
  13. package/dist/auth/operations/login.js +5 -0
  14. package/dist/auth/operations/login.js.map +1 -1
  15. package/dist/auth/operations/resetPassword.d.ts.map +1 -1
  16. package/dist/auth/operations/resetPassword.js +5 -0
  17. package/dist/auth/operations/resetPassword.js.map +1 -1
  18. package/dist/auth/sessions.d.ts +2 -2
  19. package/dist/auth/sessions.d.ts.map +1 -1
  20. package/dist/auth/sessions.js +5 -2
  21. package/dist/auth/sessions.js.map +1 -1
  22. package/dist/auth/types.d.ts +9 -0
  23. package/dist/auth/types.d.ts.map +1 -1
  24. package/dist/auth/types.js.map +1 -1
  25. package/dist/cli/commands/generateImportMap/utilities/resolveImportMapFilePath.d.ts.map +1 -1
  26. package/dist/cli/commands/generateImportMap/utilities/resolveImportMapFilePath.js +7 -3
  27. package/dist/cli/commands/generateImportMap/utilities/resolveImportMapFilePath.js.map +1 -1
  28. package/dist/collections/operations/create.js +1 -1
  29. package/dist/collections/operations/create.js.map +1 -1
  30. package/dist/collections/operations/findByID.d.ts.map +1 -1
  31. package/dist/collections/operations/findByID.js +1 -3
  32. package/dist/collections/operations/findByID.js.map +1 -1
  33. package/dist/collections/operations/local/restoreVersion.d.ts.map +1 -1
  34. package/dist/collections/operations/local/restoreVersion.js +2 -1
  35. package/dist/collections/operations/local/restoreVersion.js.map +1 -1
  36. package/dist/collections/operations/restoreVersion.d.ts.map +1 -1
  37. package/dist/collections/operations/restoreVersion.js +22 -6
  38. package/dist/collections/operations/restoreVersion.js.map +1 -1
  39. package/dist/collections/operations/update.js +1 -1
  40. package/dist/collections/operations/update.js.map +1 -1
  41. package/dist/collections/operations/updateByID.js +1 -1
  42. package/dist/collections/operations/updateByID.js.map +1 -1
  43. package/dist/exports/internal.d.ts +1 -1
  44. package/dist/exports/internal.d.ts.map +1 -1
  45. package/dist/exports/internal.js.map +1 -1
  46. package/dist/index.bundled.d.ts +48 -63
  47. package/dist/index.d.ts +0 -2
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +0 -2
  50. package/dist/index.js.map +1 -1
  51. package/dist/uploads/checkFileAccess.d.ts.map +1 -1
  52. package/dist/uploads/checkFileAccess.js +1 -0
  53. package/dist/uploads/checkFileAccess.js.map +1 -1
  54. package/dist/uploads/endpoints/getFile.d.ts.map +1 -1
  55. package/dist/uploads/endpoints/getFile.js +17 -5
  56. package/dist/uploads/endpoints/getFile.js.map +1 -1
  57. package/dist/uploads/fileSelectionParams.d.ts +10 -0
  58. package/dist/uploads/fileSelectionParams.d.ts.map +1 -0
  59. package/dist/uploads/fileSelectionParams.js +10 -0
  60. package/dist/uploads/fileSelectionParams.js.map +1 -0
  61. package/dist/uploads/fileVersioning/cloudStorage.d.ts +7 -0
  62. package/dist/uploads/fileVersioning/cloudStorage.d.ts.map +1 -1
  63. package/dist/uploads/fileVersioning/cloudStorage.js +43 -19
  64. package/dist/uploads/fileVersioning/cloudStorage.js.map +1 -1
  65. package/dist/uploads/fileVersioning/resolveHistoricalFile.d.ts +18 -4
  66. package/dist/uploads/fileVersioning/resolveHistoricalFile.d.ts.map +1 -1
  67. package/dist/uploads/fileVersioning/resolveHistoricalFile.js +73 -30
  68. package/dist/uploads/fileVersioning/resolveHistoricalFile.js.map +1 -1
  69. package/dist/uploads/fileVersioning/restore.d.ts +17 -3
  70. package/dist/uploads/fileVersioning/restore.d.ts.map +1 -1
  71. package/dist/uploads/fileVersioning/restore.js +42 -1
  72. package/dist/uploads/fileVersioning/restore.js.map +1 -1
  73. package/dist/uploads/fileVersioning/restoreRequestTime.d.ts +15 -0
  74. package/dist/uploads/fileVersioning/restoreRequestTime.d.ts.map +1 -0
  75. package/dist/uploads/fileVersioning/restoreRequestTime.js +176 -0
  76. package/dist/uploads/fileVersioning/restoreRequestTime.js.map +1 -0
  77. package/dist/uploads/fileVersioning/storedFiles.d.ts +4 -0
  78. package/dist/uploads/fileVersioning/storedFiles.d.ts.map +1 -1
  79. package/dist/uploads/fileVersioning/storedFiles.js +10 -1
  80. package/dist/uploads/fileVersioning/storedFiles.js.map +1 -1
  81. package/dist/uploads/generateFileData/edits/legacyUploadEdits.d.ts +122 -0
  82. package/dist/uploads/generateFileData/edits/legacyUploadEdits.d.ts.map +1 -0
  83. package/dist/uploads/generateFileData/edits/legacyUploadEdits.js +261 -0
  84. package/dist/uploads/generateFileData/edits/legacyUploadEdits.js.map +1 -0
  85. package/dist/uploads/generateFileData/edits/resolveUploadEdits.d.ts +30 -0
  86. package/dist/uploads/generateFileData/edits/resolveUploadEdits.d.ts.map +1 -0
  87. package/dist/uploads/generateFileData/edits/resolveUploadEdits.js +131 -0
  88. package/dist/uploads/generateFileData/edits/resolveUploadEdits.js.map +1 -0
  89. package/dist/uploads/generateFileData/index.d.ts +47 -0
  90. package/dist/uploads/generateFileData/index.d.ts.map +1 -0
  91. package/dist/uploads/generateFileData/index.js +365 -0
  92. package/dist/uploads/generateFileData/index.js.map +1 -0
  93. package/dist/uploads/generateFileData/output/buildUploadOutput.d.ts +52 -0
  94. package/dist/uploads/generateFileData/output/buildUploadOutput.d.ts.map +1 -0
  95. package/dist/uploads/generateFileData/output/buildUploadOutput.js +394 -0
  96. package/dist/uploads/generateFileData/output/buildUploadOutput.js.map +1 -0
  97. package/dist/uploads/generateFileData/output/buildVariantOutputs.d.ts +33 -0
  98. package/dist/uploads/generateFileData/output/buildVariantOutputs.d.ts.map +1 -0
  99. package/dist/uploads/generateFileData/output/buildVariantOutputs.js +100 -0
  100. package/dist/uploads/generateFileData/output/buildVariantOutputs.js.map +1 -0
  101. package/dist/uploads/generateFileData/output/resolveTempFileHandling.d.ts +20 -0
  102. package/dist/uploads/generateFileData/output/resolveTempFileHandling.d.ts.map +1 -0
  103. package/dist/uploads/generateFileData/output/resolveTempFileHandling.js +20 -0
  104. package/dist/uploads/generateFileData/output/resolveTempFileHandling.js.map +1 -0
  105. package/dist/uploads/generateFileData/plan/planSourceRebuild.d.ts +35 -0
  106. package/dist/uploads/generateFileData/plan/planSourceRebuild.d.ts.map +1 -0
  107. package/dist/uploads/generateFileData/plan/planSourceRebuild.js +54 -0
  108. package/dist/uploads/generateFileData/plan/planSourceRebuild.js.map +1 -0
  109. package/dist/uploads/generateFileData/plan/planUploadStages.d.ts +44 -0
  110. package/dist/uploads/generateFileData/plan/planUploadStages.d.ts.map +1 -0
  111. package/dist/uploads/generateFileData/plan/planUploadStages.js +63 -0
  112. package/dist/uploads/generateFileData/plan/planUploadStages.js.map +1 -0
  113. package/dist/uploads/generateFileData/runUploadTransformers.d.ts +46 -0
  114. package/dist/uploads/generateFileData/runUploadTransformers.d.ts.map +1 -0
  115. package/dist/uploads/generateFileData/runUploadTransformers.js +93 -0
  116. package/dist/uploads/generateFileData/runUploadTransformers.js.map +1 -0
  117. package/dist/uploads/generateFileData/source/downloadClientUpload.d.ts +32 -0
  118. package/dist/uploads/generateFileData/source/downloadClientUpload.d.ts.map +1 -0
  119. package/dist/uploads/generateFileData/source/downloadClientUpload.js +43 -0
  120. package/dist/uploads/generateFileData/source/downloadClientUpload.js.map +1 -0
  121. package/dist/uploads/generateFileData/source/readUploadSource.d.ts +27 -0
  122. package/dist/uploads/generateFileData/source/readUploadSource.d.ts.map +1 -0
  123. package/dist/uploads/generateFileData/source/readUploadSource.js +97 -0
  124. package/dist/uploads/generateFileData/source/readUploadSource.js.map +1 -0
  125. package/dist/uploads/generateFileData/source/selectUploadSource.d.ts +50 -0
  126. package/dist/uploads/generateFileData/source/selectUploadSource.d.ts.map +1 -0
  127. package/dist/uploads/generateFileData/source/selectUploadSource.js +42 -0
  128. package/dist/uploads/generateFileData/source/selectUploadSource.js.map +1 -0
  129. package/dist/uploads/generateFileData/utils/checkFileAndUseDetectedType.d.ts +9 -0
  130. package/dist/uploads/generateFileData/utils/checkFileAndUseDetectedType.d.ts.map +1 -0
  131. package/dist/uploads/generateFileData/utils/checkFileAndUseDetectedType.js +19 -0
  132. package/dist/uploads/generateFileData/utils/checkFileAndUseDetectedType.js.map +1 -0
  133. package/dist/uploads/generateFileData/utils/generateImageSizeFilename.d.ts.map +1 -0
  134. package/dist/uploads/generateFileData/utils/generateImageSizeFilename.js.map +1 -0
  135. package/dist/uploads/generateFileData/utils/getUploadStorage.d.ts +27 -0
  136. package/dist/uploads/generateFileData/utils/getUploadStorage.d.ts.map +1 -0
  137. package/dist/uploads/generateFileData/utils/getUploadStorage.js +22 -0
  138. package/dist/uploads/generateFileData/utils/getUploadStorage.js.map +1 -0
  139. package/dist/uploads/generateFileData/utils/toFileUploadError.d.ts +11 -0
  140. package/dist/uploads/generateFileData/utils/toFileUploadError.d.ts.map +1 -0
  141. package/dist/uploads/generateFileData/utils/toFileUploadError.js +15 -0
  142. package/dist/uploads/generateFileData/utils/toFileUploadError.js.map +1 -0
  143. package/dist/uploads/getFileFromUploadInstructions.js +2 -2
  144. package/dist/uploads/getFileFromUploadInstructions.js.map +1 -1
  145. package/dist/uploads/requestTimeFileData.d.ts +36 -0
  146. package/dist/uploads/requestTimeFileData.d.ts.map +1 -0
  147. package/dist/uploads/requestTimeFileData.js +56 -0
  148. package/dist/uploads/requestTimeFileData.js.map +1 -0
  149. package/dist/uploads/transformState/planUpload.d.ts +27 -2
  150. package/dist/uploads/transformState/planUpload.d.ts.map +1 -1
  151. package/dist/uploads/transformState/planUpload.js +27 -4
  152. package/dist/uploads/transformState/planUpload.js.map +1 -1
  153. package/dist/uploads/transformState/transformStateInput.d.ts +52 -0
  154. package/dist/uploads/transformState/transformStateInput.d.ts.map +1 -0
  155. package/dist/uploads/transformState/transformStateInput.js +113 -0
  156. package/dist/uploads/transformState/transformStateInput.js.map +1 -0
  157. package/dist/uploads/transformers/handleDynamicFileRequest.d.ts +7 -1
  158. package/dist/uploads/transformers/handleDynamicFileRequest.d.ts.map +1 -1
  159. package/dist/uploads/transformers/handleDynamicFileRequest.js +40 -10
  160. package/dist/uploads/transformers/handleDynamicFileRequest.js.map +1 -1
  161. package/dist/uploads/transformers/transformUploadFile.js +1 -1
  162. package/dist/uploads/transformers/transformUploadFile.js.map +1 -1
  163. package/dist/uploads/transformers/uploadTransformerBridge.d.ts +16 -6
  164. package/dist/uploads/transformers/uploadTransformerBridge.d.ts.map +1 -1
  165. package/dist/uploads/transformers/uploadTransformerBridge.js +3 -1
  166. package/dist/uploads/transformers/uploadTransformerBridge.js.map +1 -1
  167. package/dist/utilities/initTransaction.d.ts.map +1 -1
  168. package/dist/utilities/initTransaction.js +35 -7
  169. package/dist/utilities/initTransaction.js.map +1 -1
  170. package/dist/versions/getLatestCollectionVersion.d.ts +1 -2
  171. package/dist/versions/getLatestCollectionVersion.d.ts.map +1 -1
  172. package/dist/versions/getLatestCollectionVersion.js +7 -23
  173. package/dist/versions/getLatestCollectionVersion.js.map +1 -1
  174. package/dist/versions/getLatestGlobalVersion.d.ts +1 -2
  175. package/dist/versions/getLatestGlobalVersion.d.ts.map +1 -1
  176. package/dist/versions/getLatestGlobalVersion.js +2 -6
  177. package/dist/versions/getLatestGlobalVersion.js.map +1 -1
  178. package/package.json +3 -3
  179. package/skills/payload/SKILL.md +12 -9
  180. package/skills/payload/reference/ADAPTERS.md +21 -27
  181. package/skills/payload/reference/FIELDS.md +1 -1
  182. package/skills/payload/reference/HOOKS.md +1 -1
  183. package/skills/payload/reference/PLUGIN-DEVELOPMENT.md +1 -1
  184. package/skills/payload/reference/QUERIES.md +6 -6
  185. package/dist/uploads/generateFileData.d.ts +0 -60
  186. package/dist/uploads/generateFileData.d.ts.map +0 -1
  187. package/dist/uploads/generateFileData.js +0 -1022
  188. package/dist/uploads/generateFileData.js.map +0 -1
  189. package/dist/uploads/generateImageSizeFilename.d.ts.map +0 -1
  190. package/dist/uploads/generateImageSizeFilename.js.map +0 -1
  191. package/dist/uploads/transformState/resolveUploadEdits.d.ts +0 -91
  192. package/dist/uploads/transformState/resolveUploadEdits.d.ts.map +0 -1
  193. package/dist/uploads/transformState/resolveUploadEdits.js +0 -397
  194. package/dist/uploads/transformState/resolveUploadEdits.js.map +0 -1
  195. /package/dist/uploads/{generateImageSizeFilename.d.ts → generateFileData/utils/generateImageSizeFilename.d.ts} +0 -0
  196. /package/dist/uploads/{generateImageSizeFilename.js → generateFileData/utils/generateImageSizeFilename.js} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/auth/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAE9D;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,UAAU,EAAE,OAAO,CAAA;IACnB,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,CAAA;CACtC,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,UAAU,CAAA;IAClB,MAAM,EAAE,iBAAiB,CAAA;IACzB,IAAI,EAAE,UAAU,CAAA;IAChB,MAAM,EAAE,UAAU,C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AAED,MAAM,WAAW,IACf,SACE,IAAI,CACF,gBAAgB,EACd,SAAS,GACT,gBAAgB,GAChB,UAAU,GACV,mBAAmB,GACnB,kBAAkB,GAClB,eAAe,GACf,YAAY,GACZ,iBAAiB,GACjB,aAAa,GACb,QAAQ,CACX,EACD,QAAQ,CACN,IAAI,CACF,gBAAgB,EACd,gBAAgB,GAChB,UAAU,GACV,kBAAkB,GAClB,YAAY,GACZ,iBAAiB,GACjB,aAAa,GACb,QAAQ,CACX,CACF;IACH,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,GAAG,QAAQ,CAAC,CAAC,CAAA;IACzF,iBAAiB,EAAE,KAAK,GAAG,QAAQ,CAAC,wBAAwB,CAAC,CAAA;IAC7D,aAAa,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,KAAK,CAAA;CAC9C;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,KAAK,GAAG,MAAM,IAAI,KAAK,CAE7E"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/auth/types.ts"],"sourcesContent":["import type { CollectionSlug, GlobalSlug, Payload, User } from '../index.js'\nimport type { PayloadRequest, Where } from '../types/index.js'\n\n/**\n * A permission object that can be used to determine if a user has access to a specific operation.\n */\nexport type Permission = {\n permission: boolean\n where?: Where\n}\n\nexport type FieldsPermissions = {\n [fieldName: string]: FieldPermissions\n}\n\nexport type BlockPermissions = {\n create: Permission\n fields: FieldsPermissions\n read: Permission\n update: Permission\n /** Permission to validate candidate block data without saving. */\n validate: Permission\n}\n\nexport type SanitizedBlockPermissions =\n | {\n fields: SanitizedFieldsPermissions\n }\n | true\n\nexport type BlocksPermissions = {\n [blockSlug: string]: BlockPermissions\n}\n\nexport type SanitizedBlocksPermissions =\n | {\n [blockSlug: string]: SanitizedBlockPermissions\n }\n | true\n\nexport type FieldPermissions = {\n blocks?: BlocksPermissions\n create?: Permission\n fields?: FieldsPermissions\n read?: Permission\n update?: Permission\n /** Permission to validate candidate field data without saving. */\n validate?: Permission\n}\n\nexport type SanitizedFieldPermissions =\n | {\n blocks?: SanitizedBlocksPermissions\n create: true\n fields?: SanitizedFieldsPermissions\n read: true\n update: true\n validate: true\n }\n | true\n\nexport type SanitizedFieldsPermissions =\n | {\n [fieldName: string]: SanitizedFieldPermissions\n }\n | true\n\nexport type CollectionPermission = {\n create?: Permission\n delete?: Permission\n fields: FieldsPermissions\n read?: Permission\n readVersions?: Permission\n // Auth-enabled Collections only\n unlock?: Permission\n update?: Permission\n /** Permission to validate collection candidate data without saving. */\n validate?: Permission\n}\n\nexport type SanitizedCollectionPermission = {\n create?: true\n delete?: true\n fields: SanitizedFieldsPermissions\n read?: true\n readVersions?: true\n // Auth-enabled Collections only\n unlock?: true\n update?: true\n validate?: true\n}\n\nexport type GlobalPermission = {\n fields: FieldsPermissions\n read?: Permission\n readVersions?: Permission\n update?: Permission\n /** Permission to validate global candidate data without saving. */\n validate?: Permission\n}\n\nexport type SanitizedGlobalPermission = {\n fields: SanitizedFieldsPermissions\n read?: true\n readVersions?: true\n update?: true\n validate?: true\n}\n\nexport type DocumentPermissions = CollectionPermission | GlobalPermission\n\nexport type SanitizedDocumentPermissions = SanitizedCollectionPermission | SanitizedGlobalPermission\n\nexport type Permissions = {\n canAccessAdmin: boolean\n collections?: Record<CollectionSlug, CollectionPermission>\n globals?: Record<GlobalSlug, GlobalPermission>\n}\n\nexport type SanitizedPermissions = {\n canAccessAdmin?: boolean\n collections?: {\n [collectionSlug: string]: SanitizedCollectionPermission\n }\n globals?: {\n [globalSlug: string]: SanitizedGlobalPermission\n }\n}\n\n/**\n * Fields injected onto a user at authentication time. They are never stored in the database and\n * never present on a plain document read (e.g. `payload.findByID`) - only on the authenticated\n * user (`req.user`, login/auth/me results, auth strategies).\n */\nexport type AuthRuntimeFields = {\n /**\n * The session ID of the current request. May be present on request-authenticated users when\n * sessions are enabled.\n */\n _sid?: string\n /**\n * The name of the auth strategy that authenticated the request (e.g. `local-jwt`).\n */\n _strategy?: string\n}\n\n/**\n * Note: AuthenticatedUser still carries the write-only `password` from `User` (always `undefined` at runtime).\n * Stripping it cleanly isn't possible, because auth operations build the authenticated user\n * from a read `User` doc, so a `never`-typed `password` would break those assignments\n */\n/**\n * The signed-in user: the read user plus the runtime auth markers (`_strategy`, `_sid`).\n * Server authentication APIs may retain complete fields, while response boundaries apply read access.\n */\nexport type AuthenticatedUser = AuthRuntimeFields & User\n\nexport type UserSession = {\n createdAt?: Date | null | string\n expiresAt: Date | string\n id: string\n /**\n * How many times the session was refreshed with a refresh token. Refresh tokens remember it, so\n * the latest one can be told apart from older ones.\n */\n refreshCount?: null | number\n /** When the session was last refreshed with a refresh token. */\n refreshedAt?: Date | null | string\n}\ntype GenerateVerifyEmailHTML<TUser = any> = (args: {\n req: PayloadRequest\n token: string\n user: TUser\n}) => Promise<string> | string\n\ntype GenerateVerifyEmailSubject<TUser = any> = (args: {\n req: PayloadRequest\n token: string\n user: TUser\n}) => Promise<string> | string\n\ntype GenerateForgotPasswordEmailHTML<TUser = any> = (args?: {\n req?: PayloadRequest\n token?: string\n user?: TUser\n}) => Promise<string> | string\n\ntype GenerateForgotPasswordEmailSubject<TUser = any> = (args?: {\n req?: PayloadRequest\n token?: string\n user?: TUser\n}) => Promise<string> | string\n\nexport type AuthStrategyFunctionArgs = {\n /**\n * Specifies whether or not response headers can be set from this strategy.\n */\n canSetHeaders?: boolean\n headers: Request['headers']\n isGraphQL?: boolean\n payload: Payload\n /** The request that initiated authentication, when available. */\n req?: PayloadRequest\n /**\n * The AuthStrategy name property from the payload config.\n */\n strategyName?: string\n}\n\nexport type AuthStrategyResult = {\n responseHeaders?: Headers\n user: AuthenticatedUser | null\n}\n\nexport type AuthStrategyFunction = (\n args: AuthStrategyFunctionArgs,\n) => AuthStrategyResult | Promise<AuthStrategyResult>\nexport type AuthStrategy = {\n authenticate: AuthStrategyFunction\n name: string\n}\n\nexport type LoginWithUsernameOptions =\n | {\n allowEmailLogin?: false\n requireEmail?: boolean\n // If `allowEmailLogin` is false, `requireUsername` must be true (default: true)\n requireUsername?: true\n }\n | {\n allowEmailLogin?: true\n requireEmail?: boolean\n requireUsername?: boolean\n }\n\ntype AuthCookies = {\n domain?: string\n sameSite?: 'Lax' | 'None' | 'Strict' | boolean\n secure?: boolean\n}\n\nexport interface IncomingAuthType {\n /**\n * Set cookie options, including secure, sameSite, and domain. For advanced users.\n */\n cookies?: AuthCookies\n /**\n * How many levels deep a user document should be populated when creating the JWT and binding the user to the req. Defaults to 0 and should only be modified if absolutely necessary, as this will affect performance.\n * @default 0\n */\n depth?: number\n /**\n * Controls whether Payload's built-in local auth strategy is disabled. Set to `true` to disable\n * local authentication or `false` to keep it enabled.\n *\n * Pass an object to disable local authentication while configuring how its fields are retained.\n * Only disable local authentication if you have replaced Payload's auth mechanisms with your own.\n * @default false\n */\n disableLocalStrategy?:\n | {\n /**\n * Include auth fields on the collection even though the local strategy is disabled.\n * Useful when you do not want the database or types to vary depending on the auth configuration.\n */\n enableFields?: true\n /**\n * When auth fields are retained, make the password field optional.\n */\n optionalPassword?: true\n }\n | boolean\n /**\n * Customize the way that the forgotPassword operation functions.\n * @link https://payloadcms.com/docs/authentication/email#forgot-password\n */\n forgotPassword?: {\n /**\n * The number of milliseconds that the forgot password token should be valid for.\n * @default 3600000 // 1 hour\n */\n expiration?: number\n generateEmailHTML?: GenerateForgotPasswordEmailHTML\n generateEmailSubject?: GenerateForgotPasswordEmailSubject\n /**\n * The minimum number of milliseconds between password reset emails for the same user.\n * @default 15000\n * Set to 0 to disable.\n */\n minRequestInterval?: number\n }\n /**\n * Set the time (in milliseconds) that a user should be locked out if they fail authentication more times than maxLoginAttempts allows for.\n */\n lockTime?: number\n /**\n * Ability to allow users to login with username/password.\n *\n * @link https://payloadcms.com/docs/authentication/overview#login-with-username\n */\n loginWithUsername?: boolean | LoginWithUsernameOptions\n /**\n * Only allow a user to attempt logging in X amount of times. Automatically locks out a user from authenticating if this limit is passed. Set to 0 to disable.\n */\n maxLoginAttempts?: number\n /**\n * Lets clients stay logged in after their token expires. Logins also return a refresh token,\n * which the refresh operation trades for a new token and a new refresh token. Each refresh token\n * is meant to be used once. The one from right before still works for 30 seconds after a refresh,\n * for clients that refresh twice at once. When a used one comes back otherwise, its session is\n * logged out. Requires `useSessions`.\n *\n * Refresh tokens don't expire on their own. They work as long as their login session, which lasts\n * `expiration` from the last refresh instead of `tokenExpiration`.\n *\n * @default false\n * @link https://payloadcms.com/docs/authentication/overview#refresh-tokens\n */\n refreshTokens?:\n | {\n /**\n * How many seconds a login session with a refresh token lasts without a refresh, which is\n * how long its refresh token can be used. Every refresh starts this time again. The token\n * itself still expires after `tokenExpiration`.\n *\n * @default 2592000 (30 days)\n */\n expiration?: number\n }\n | boolean\n /***\n * Set to true if you want to remove the token from the returned authentication API responses such as login or refresh.\n */\n removeTokenFromResponses?: true\n /**\n * Advanced - an array of custom authentification strategies to extend this collection's authentication with.\n * @link https://payloadcms.com/docs/authentication/custom-strategies\n */\n strategies?: AuthStrategy[]\n /**\n * Controls how many seconds the token will be valid for. Default is 2 hours.\n * @default 7200\n * @link https://payloadcms.com/docs/authentication/overview#config-options\n */\n tokenExpiration?: number\n /**\n * Payload Authentication provides for API keys to be set on each user within an Authentication-enabled Collection.\n * @default false\n * @link https://payloadcms.com/docs/authentication/api-keys\n */\n useAPIKey?:\n | {\n /**\n * Allows administrators to reveal stored API keys from the Admin Panel.\n * @default false\n */\n reveal?: boolean\n }\n | boolean\n\n /**\n * Use sessions for authentication. Enabled by default.\n * @default true\n */\n useSessions?: boolean\n\n /**\n * Set to true or pass an object with verification options to require users to verify by email before they are allowed to log into your app.\n * @link https://payloadcms.com/docs/authentication/email#email-verification\n */\n verify?:\n | {\n generateEmailHTML?: GenerateVerifyEmailHTML\n generateEmailSubject?: GenerateVerifyEmailSubject\n }\n | boolean\n}\n\nexport type VerifyConfig = {\n generateEmailHTML?: GenerateVerifyEmailHTML\n generateEmailSubject?: GenerateVerifyEmailSubject\n}\n\nexport interface Auth\n extends\n Omit<\n IncomingAuthType,\n | 'cookies'\n | 'forgotPassword'\n | 'lockTime'\n | 'loginWithUsername'\n | 'maxLoginAttempts'\n | 'refreshTokens'\n | 'strategies'\n | 'tokenExpiration'\n | 'useSessions'\n | 'verify'\n >,\n Required<\n Pick<\n IncomingAuthType,\n | 'forgotPassword'\n | 'lockTime'\n | 'maxLoginAttempts'\n | 'strategies'\n | 'tokenExpiration'\n | 'useSessions'\n | 'verify'\n >\n > {\n cookies: Pick<AuthCookies, 'domain'> & Required<Pick<AuthCookies, 'sameSite' | 'secure'>>\n loginWithUsername: false | Required<LoginWithUsernameOptions>\n refreshTokens: { expiration: number } | false\n}\n\nexport function hasWhereAccessResult(result: boolean | Where): result is Where {\n return result && typeof result === 'object'\n}\n"],"names":["hasWhereAccessResult","result"],"mappings":"AA+ZA,OAAO,SAASA,qBAAqBC,MAAuB;IAC1D,OAAOA,UAAU,OAAOA,WAAW;AACrC"}
1
+ {"version":3,"sources":["../../src/auth/types.ts"],"sourcesContent":["import type { CollectionSlug, GlobalSlug, Payload, User } from '../index.js'\nimport type { PayloadRequest, Where } from '../types/index.js'\n\n/**\n * A permission object that can be used to determine if a user has access to a specific operation.\n */\nexport type Permission = {\n permission: boolean\n where?: Where\n}\n\nexport type FieldsPermissions = {\n [fieldName: string]: FieldPermissions\n}\n\nexport type BlockPermissions = {\n create: Permission\n fields: FieldsPermissions\n read: Permission\n update: Permission\n /** Permission to validate candidate block data without saving. */\n validate: Permission\n}\n\nexport type SanitizedBlockPermissions =\n | {\n fields: SanitizedFieldsPermissions\n }\n | true\n\nexport type BlocksPermissions = {\n [blockSlug: string]: BlockPermissions\n}\n\nexport type SanitizedBlocksPermissions =\n | {\n [blockSlug: string]: SanitizedBlockPermissions\n }\n | true\n\nexport type FieldPermissions = {\n blocks?: BlocksPermissions\n create?: Permission\n fields?: FieldsPermissions\n read?: Permission\n update?: Permission\n /** Permission to validate candidate field data without saving. */\n validate?: Permission\n}\n\nexport type SanitizedFieldPermissions =\n | {\n blocks?: SanitizedBlocksPermissions\n create: true\n fields?: SanitizedFieldsPermissions\n read: true\n update: true\n validate: true\n }\n | true\n\nexport type SanitizedFieldsPermissions =\n | {\n [fieldName: string]: SanitizedFieldPermissions\n }\n | true\n\nexport type CollectionPermission = {\n create?: Permission\n delete?: Permission\n fields: FieldsPermissions\n read?: Permission\n readVersions?: Permission\n // Auth-enabled Collections only\n unlock?: Permission\n update?: Permission\n /** Permission to validate collection candidate data without saving. */\n validate?: Permission\n}\n\nexport type SanitizedCollectionPermission = {\n create?: true\n delete?: true\n fields: SanitizedFieldsPermissions\n read?: true\n readVersions?: true\n // Auth-enabled Collections only\n unlock?: true\n update?: true\n validate?: true\n}\n\nexport type GlobalPermission = {\n fields: FieldsPermissions\n read?: Permission\n readVersions?: Permission\n update?: Permission\n /** Permission to validate global candidate data without saving. */\n validate?: Permission\n}\n\nexport type SanitizedGlobalPermission = {\n fields: SanitizedFieldsPermissions\n read?: true\n readVersions?: true\n update?: true\n validate?: true\n}\n\nexport type DocumentPermissions = CollectionPermission | GlobalPermission\n\nexport type SanitizedDocumentPermissions = SanitizedCollectionPermission | SanitizedGlobalPermission\n\nexport type Permissions = {\n canAccessAdmin: boolean\n collections?: Record<CollectionSlug, CollectionPermission>\n globals?: Record<GlobalSlug, GlobalPermission>\n}\n\nexport type SanitizedPermissions = {\n canAccessAdmin?: boolean\n collections?: {\n [collectionSlug: string]: SanitizedCollectionPermission\n }\n globals?: {\n [globalSlug: string]: SanitizedGlobalPermission\n }\n}\n\n/**\n * Fields injected onto a user at authentication time. They are never stored in the database and\n * never present on a plain document read (e.g. `payload.findByID`) - only on the authenticated\n * user (`req.user`, login/auth/me results, auth strategies).\n */\nexport type AuthRuntimeFields = {\n /**\n * The session ID of the current request. May be present on request-authenticated users when\n * sessions are enabled.\n */\n _sid?: string\n /**\n * The name of the auth strategy that authenticated the request (e.g. `local-jwt`).\n */\n _strategy?: string\n}\n\n/**\n * Note: AuthenticatedUser still carries the write-only `password` from `User` (always `undefined` at runtime).\n * Stripping it cleanly isn't possible, because auth operations build the authenticated user\n * from a read `User` doc, so a `never`-typed `password` would break those assignments\n */\n/**\n * The signed-in user: the read user plus the runtime auth markers (`_strategy`, `_sid`).\n * Server authentication APIs may retain complete fields, while response boundaries apply read access.\n */\nexport type AuthenticatedUser = AuthRuntimeFields & User\n\nexport type UserSession = {\n createdAt?: Date | null | string\n expiresAt: Date | string\n id: string\n /** What the session is, for people to read, e.g. \"Claude Code\" or \"Chrome on macOS\". */\n label?: null | string\n /** More to show next to the label, e.g. `{ redirectHost: 'claude.ai' }`. Never anything secret. */\n metadata?: null | Record<string, unknown>\n /**\n * How many times the session was refreshed with a refresh token. Refresh tokens remember it, so\n * the latest one can be told apart from older ones.\n */\n refreshCount?: null | number\n /** When the session was last refreshed with a refresh token. */\n refreshedAt?: Date | null | string\n /**\n * How the session was created: `'login'` for a sign-in, or e.g. `'mcp'` for an MCP client the\n * user allowed. Plugins can use their own values.\n */\n type?: null | string\n}\ntype GenerateVerifyEmailHTML<TUser = any> = (args: {\n req: PayloadRequest\n token: string\n user: TUser\n}) => Promise<string> | string\n\ntype GenerateVerifyEmailSubject<TUser = any> = (args: {\n req: PayloadRequest\n token: string\n user: TUser\n}) => Promise<string> | string\n\ntype GenerateForgotPasswordEmailHTML<TUser = any> = (args?: {\n req?: PayloadRequest\n token?: string\n user?: TUser\n}) => Promise<string> | string\n\ntype GenerateForgotPasswordEmailSubject<TUser = any> = (args?: {\n req?: PayloadRequest\n token?: string\n user?: TUser\n}) => Promise<string> | string\n\nexport type AuthStrategyFunctionArgs = {\n /**\n * Specifies whether or not response headers can be set from this strategy.\n */\n canSetHeaders?: boolean\n headers: Request['headers']\n isGraphQL?: boolean\n payload: Payload\n /** The request that initiated authentication, when available. */\n req?: PayloadRequest\n /**\n * The AuthStrategy name property from the payload config.\n */\n strategyName?: string\n}\n\nexport type AuthStrategyResult = {\n responseHeaders?: Headers\n user: AuthenticatedUser | null\n}\n\nexport type AuthStrategyFunction = (\n args: AuthStrategyFunctionArgs,\n) => AuthStrategyResult | Promise<AuthStrategyResult>\nexport type AuthStrategy = {\n authenticate: AuthStrategyFunction\n name: string\n}\n\nexport type LoginWithUsernameOptions =\n | {\n allowEmailLogin?: false\n requireEmail?: boolean\n // If `allowEmailLogin` is false, `requireUsername` must be true (default: true)\n requireUsername?: true\n }\n | {\n allowEmailLogin?: true\n requireEmail?: boolean\n requireUsername?: boolean\n }\n\ntype AuthCookies = {\n domain?: string\n sameSite?: 'Lax' | 'None' | 'Strict' | boolean\n secure?: boolean\n}\n\nexport interface IncomingAuthType {\n /**\n * Set cookie options, including secure, sameSite, and domain. For advanced users.\n */\n cookies?: AuthCookies\n /**\n * How many levels deep a user document should be populated when creating the JWT and binding the user to the req. Defaults to 0 and should only be modified if absolutely necessary, as this will affect performance.\n * @default 0\n */\n depth?: number\n /**\n * Controls whether Payload's built-in local auth strategy is disabled. Set to `true` to disable\n * local authentication or `false` to keep it enabled.\n *\n * Pass an object to disable local authentication while configuring how its fields are retained.\n * Only disable local authentication if you have replaced Payload's auth mechanisms with your own.\n * @default false\n */\n disableLocalStrategy?:\n | {\n /**\n * Include auth fields on the collection even though the local strategy is disabled.\n * Useful when you do not want the database or types to vary depending on the auth configuration.\n */\n enableFields?: true\n /**\n * When auth fields are retained, make the password field optional.\n */\n optionalPassword?: true\n }\n | boolean\n /**\n * Customize the way that the forgotPassword operation functions.\n * @link https://payloadcms.com/docs/authentication/email#forgot-password\n */\n forgotPassword?: {\n /**\n * The number of milliseconds that the forgot password token should be valid for.\n * @default 3600000 // 1 hour\n */\n expiration?: number\n generateEmailHTML?: GenerateForgotPasswordEmailHTML\n generateEmailSubject?: GenerateForgotPasswordEmailSubject\n /**\n * The minimum number of milliseconds between password reset emails for the same user.\n * @default 15000\n * Set to 0 to disable.\n */\n minRequestInterval?: number\n }\n /**\n * Set the time (in milliseconds) that a user should be locked out if they fail authentication more times than maxLoginAttempts allows for.\n */\n lockTime?: number\n /**\n * Ability to allow users to login with username/password.\n *\n * @link https://payloadcms.com/docs/authentication/overview#login-with-username\n */\n loginWithUsername?: boolean | LoginWithUsernameOptions\n /**\n * Only allow a user to attempt logging in X amount of times. Automatically locks out a user from authenticating if this limit is passed. Set to 0 to disable.\n */\n maxLoginAttempts?: number\n /**\n * Lets clients stay logged in after their token expires. Logins also return a refresh token,\n * which the refresh operation trades for a new token and a new refresh token. Each refresh token\n * is meant to be used once. The one from right before still works for 30 seconds after a refresh,\n * for clients that refresh twice at once. When a used one comes back otherwise, its session is\n * logged out. Requires `useSessions`.\n *\n * Refresh tokens don't expire on their own. They work as long as their login session, which lasts\n * `expiration` from the last refresh instead of `tokenExpiration`.\n *\n * @default false\n * @link https://payloadcms.com/docs/authentication/overview#refresh-tokens\n */\n refreshTokens?:\n | {\n /**\n * How many seconds a login session with a refresh token lasts without a refresh, which is\n * how long its refresh token can be used. Every refresh starts this time again. The token\n * itself still expires after `tokenExpiration`.\n *\n * @default 2592000 (30 days)\n */\n expiration?: number\n }\n | boolean\n /***\n * Set to true if you want to remove the token from the returned authentication API responses such as login or refresh.\n */\n removeTokenFromResponses?: true\n /**\n * Advanced - an array of custom authentification strategies to extend this collection's authentication with.\n * @link https://payloadcms.com/docs/authentication/custom-strategies\n */\n strategies?: AuthStrategy[]\n /**\n * Controls how many seconds the token will be valid for. Default is 2 hours.\n * @default 7200\n * @link https://payloadcms.com/docs/authentication/overview#config-options\n */\n tokenExpiration?: number\n /**\n * Payload Authentication provides for API keys to be set on each user within an Authentication-enabled Collection.\n * @default false\n * @link https://payloadcms.com/docs/authentication/api-keys\n */\n useAPIKey?:\n | {\n /**\n * Allows administrators to reveal stored API keys from the Admin Panel.\n * @default false\n */\n reveal?: boolean\n }\n | boolean\n\n /**\n * Use sessions for authentication. Enabled by default.\n * @default true\n */\n useSessions?: boolean\n\n /**\n * Set to true or pass an object with verification options to require users to verify by email before they are allowed to log into your app.\n * @link https://payloadcms.com/docs/authentication/email#email-verification\n */\n verify?:\n | {\n generateEmailHTML?: GenerateVerifyEmailHTML\n generateEmailSubject?: GenerateVerifyEmailSubject\n }\n | boolean\n}\n\nexport type VerifyConfig = {\n generateEmailHTML?: GenerateVerifyEmailHTML\n generateEmailSubject?: GenerateVerifyEmailSubject\n}\n\nexport interface Auth\n extends\n Omit<\n IncomingAuthType,\n | 'cookies'\n | 'forgotPassword'\n | 'lockTime'\n | 'loginWithUsername'\n | 'maxLoginAttempts'\n | 'refreshTokens'\n | 'strategies'\n | 'tokenExpiration'\n | 'useSessions'\n | 'verify'\n >,\n Required<\n Pick<\n IncomingAuthType,\n | 'forgotPassword'\n | 'lockTime'\n | 'maxLoginAttempts'\n | 'strategies'\n | 'tokenExpiration'\n | 'useSessions'\n | 'verify'\n >\n > {\n cookies: Pick<AuthCookies, 'domain'> & Required<Pick<AuthCookies, 'sameSite' | 'secure'>>\n loginWithUsername: false | Required<LoginWithUsernameOptions>\n refreshTokens: { expiration: number } | false\n}\n\nexport function hasWhereAccessResult(result: boolean | Where): result is Where {\n return result && typeof result === 'object'\n}\n"],"names":["hasWhereAccessResult","result"],"mappings":"AAwaA,OAAO,SAASA,qBAAqBC,MAAuB;IAC1D,OAAOA,UAAU,OAAOA,WAAW;AACrC"}
@@ -1 +1 @@
1
- {"version":3,"file":"resolveImportMapFilePath.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/generateImportMap/utilities/resolveImportMapFilePath.ts"],"names":[],"mappings":"AA+BA;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAAC,EAC7C,UAAqB,EACrB,oBAAoB,EACpB,aAAa,EACb,OAAO,GACR,EAAE;IACD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC/B,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,OAAO,EAAE,MAAM,CAAA;CAChB,GAAG,OAAO,CAAC,KAAK,GAAG,MAAM,CAAC,CAkC1B"}
1
+ {"version":3,"file":"resolveImportMapFilePath.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/generateImportMap/utilities/resolveImportMapFilePath.ts"],"names":[],"mappings":"AAoCA;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAAC,EAC7C,UAAqB,EACrB,oBAAoB,EACpB,aAAa,EACb,OAAO,GACR,EAAE;IACD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC/B,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,OAAO,EAAE,MAAM,CAAA;CAChB,GAAG,OAAO,CAAC,KAAK,GAAG,MAAM,CAAC,CAkC1B"}
@@ -16,14 +16,18 @@ async function pathOrFileExists(path) {
16
16
  * never matches the TanStack patterns and vice versa.
17
17
  *
18
18
  * Adapters with a bespoke layout can still bypass this via `candidateDirectories`.
19
- */ const defaultCandidateDirectories = (rootDir, adminRoute)=>[
19
+ */ const defaultCandidateDirectories = (rootDir, adminRoute)=>{
20
+ // Next.js uses %5F for routable segments that begin with an underscore.
21
+ const adminFolder = adminRoute.replace(/(^|\/)_/g, '$1%5F');
22
+ return [
20
23
  // Next.js App Router: `(payload)` route group nested under the admin route
21
- path.resolve(rootDir, `app/${NEXT_PAYLOAD_ROUTE_GROUP}${adminRoute}/`),
22
- path.resolve(rootDir, `src/app/${NEXT_PAYLOAD_ROUTE_GROUP}${adminRoute}/`),
24
+ path.resolve(rootDir, `app/${NEXT_PAYLOAD_ROUTE_GROUP}${adminFolder}/`),
25
+ path.resolve(rootDir, `src/app/${NEXT_PAYLOAD_ROUTE_GROUP}${adminFolder}/`),
23
26
  // TanStack Start: `_payload` pathless route folder at the app root
24
27
  path.resolve(rootDir, `app/${TANSTACK_PAYLOAD_DIR}/`),
25
28
  path.resolve(rootDir, `src/app/${TANSTACK_PAYLOAD_DIR}/`)
26
29
  ];
30
+ };
27
31
  /**
28
32
  * Returns the path to the import map file. If the import map file is not found, it throws an error.
29
33
  *
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/cli/commands/generateImportMap/utilities/resolveImportMapFilePath.ts"],"sourcesContent":["import fs from 'fs/promises'\nimport path from 'path'\n\nimport { NEXT_PAYLOAD_ROUTE_GROUP, TANSTACK_PAYLOAD_DIR } from '../frameworkConventions.js'\n\nasync function pathOrFileExists(path: string): Promise<boolean> {\n try {\n await fs.access(path)\n return true\n } catch {\n return false\n }\n}\n\n/**\n * Default directory patterns for import map resolution, covering the supported\n * framework conventions. Directories are probed in order and the first existing\n * one wins; the conventions are mutually exclusive in practice, so a Next.js app\n * never matches the TanStack patterns and vice versa.\n *\n * Adapters with a bespoke layout can still bypass this via `candidateDirectories`.\n */\nconst defaultCandidateDirectories = (rootDir: string, adminRoute: string): string[] => [\n // Next.js App Router: `(payload)` route group nested under the admin route\n path.resolve(rootDir, `app/${NEXT_PAYLOAD_ROUTE_GROUP}${adminRoute}/`),\n path.resolve(rootDir, `src/app/${NEXT_PAYLOAD_ROUTE_GROUP}${adminRoute}/`),\n // TanStack Start: `_payload` pathless route folder at the app root\n path.resolve(rootDir, `app/${TANSTACK_PAYLOAD_DIR}/`),\n path.resolve(rootDir, `src/app/${TANSTACK_PAYLOAD_DIR}/`),\n]\n\n/**\n * Returns the path to the import map file. If the import map file is not found, it throws an error.\n *\n * @param candidateDirectories - Optional array of directory paths to search for the import map.\n * Defaults to Next.js app directory convention. Framework adapters can provide their own.\n */\nexport async function resolveImportMapFilePath({\n adminRoute = '/admin',\n candidateDirectories,\n importMapFile,\n rootDir,\n}: {\n adminRoute?: string\n candidateDirectories?: string[]\n importMapFile?: string\n rootDir: string\n}): Promise<Error | string> {\n let importMapFilePath: string | undefined = undefined\n\n if (importMapFile?.length) {\n if (!(await pathOrFileExists(importMapFile))) {\n try {\n await fs.writeFile(importMapFile, '', { flag: 'wx' })\n } catch (err) {\n return new Error(\n `Could not find the import map file at ${importMapFile}${err instanceof Error && err?.message ? `: ${err.message}` : ''}`,\n )\n }\n }\n importMapFilePath = importMapFile\n } else {\n const directories = candidateDirectories ?? defaultCandidateDirectories(rootDir, adminRoute)\n\n for (const dir of directories) {\n if (await pathOrFileExists(dir)) {\n importMapFilePath = path.resolve(dir, 'importMap.js')\n if (!(await pathOrFileExists(importMapFilePath))) {\n await fs.writeFile(importMapFilePath, '', { flag: 'wx' })\n }\n break\n }\n }\n\n if (!importMapFilePath) {\n return new Error(\n `Could not find Payload import map folder. Looked in ${directories.join(' and ')}`,\n )\n }\n }\n return importMapFilePath\n}\n"],"names":["fs","path","NEXT_PAYLOAD_ROUTE_GROUP","TANSTACK_PAYLOAD_DIR","pathOrFileExists","access","defaultCandidateDirectories","rootDir","adminRoute","resolve","resolveImportMapFilePath","candidateDirectories","importMapFile","importMapFilePath","undefined","length","writeFile","flag","err","Error","message","directories","dir","join"],"mappings":"AAAA,OAAOA,QAAQ,cAAa;AAC5B,OAAOC,UAAU,OAAM;AAEvB,SAASC,wBAAwB,EAAEC,oBAAoB,QAAQ,6BAA4B;AAE3F,eAAeC,iBAAiBH,IAAY;IAC1C,IAAI;QACF,MAAMD,GAAGK,MAAM,CAACJ;QAChB,OAAO;IACT,EAAE,OAAM;QACN,OAAO;IACT;AACF;AAEA;;;;;;;CAOC,GACD,MAAMK,8BAA8B,CAACC,SAAiBC,aAAiC;QACrF,2EAA2E;QAC3EP,KAAKQ,OAAO,CAACF,SAAS,CAAC,IAAI,EAAEL,2BAA2BM,WAAW,CAAC,CAAC;QACrEP,KAAKQ,OAAO,CAACF,SAAS,CAAC,QAAQ,EAAEL,2BAA2BM,WAAW,CAAC,CAAC;QACzE,mEAAmE;QACnEP,KAAKQ,OAAO,CAACF,SAAS,CAAC,IAAI,EAAEJ,qBAAqB,CAAC,CAAC;QACpDF,KAAKQ,OAAO,CAACF,SAAS,CAAC,QAAQ,EAAEJ,qBAAqB,CAAC,CAAC;KACzD;AAED;;;;;CAKC,GACD,OAAO,eAAeO,yBAAyB,EAC7CF,aAAa,QAAQ,EACrBG,oBAAoB,EACpBC,aAAa,EACbL,OAAO,EAMR;IACC,IAAIM,oBAAwCC;IAE5C,IAAIF,eAAeG,QAAQ;QACzB,IAAI,CAAE,MAAMX,iBAAiBQ,gBAAiB;YAC5C,IAAI;gBACF,MAAMZ,GAAGgB,SAAS,CAACJ,eAAe,IAAI;oBAAEK,MAAM;gBAAK;YACrD,EAAE,OAAOC,KAAK;gBACZ,OAAO,IAAIC,MACT,CAAC,sCAAsC,EAAEP,gBAAgBM,eAAeC,SAASD,KAAKE,UAAU,CAAC,EAAE,EAAEF,IAAIE,OAAO,EAAE,GAAG,IAAI;YAE7H;QACF;QACAP,oBAAoBD;IACtB,OAAO;QACL,MAAMS,cAAcV,wBAAwBL,4BAA4BC,SAASC;QAEjF,KAAK,MAAMc,OAAOD,YAAa;YAC7B,IAAI,MAAMjB,iBAAiBkB,MAAM;gBAC/BT,oBAAoBZ,KAAKQ,OAAO,CAACa,KAAK;gBACtC,IAAI,CAAE,MAAMlB,iBAAiBS,oBAAqB;oBAChD,MAAMb,GAAGgB,SAAS,CAACH,mBAAmB,IAAI;wBAAEI,MAAM;oBAAK;gBACzD;gBACA;YACF;QACF;QAEA,IAAI,CAACJ,mBAAmB;YACtB,OAAO,IAAIM,MACT,CAAC,oDAAoD,EAAEE,YAAYE,IAAI,CAAC,UAAU;QAEtF;IACF;IACA,OAAOV;AACT"}
1
+ {"version":3,"sources":["../../../../../src/cli/commands/generateImportMap/utilities/resolveImportMapFilePath.ts"],"sourcesContent":["import fs from 'fs/promises'\nimport path from 'path'\n\nimport { NEXT_PAYLOAD_ROUTE_GROUP, TANSTACK_PAYLOAD_DIR } from '../frameworkConventions.js'\n\nasync function pathOrFileExists(path: string): Promise<boolean> {\n try {\n await fs.access(path)\n return true\n } catch {\n return false\n }\n}\n\n/**\n * Default directory patterns for import map resolution, covering the supported\n * framework conventions. Directories are probed in order and the first existing\n * one wins; the conventions are mutually exclusive in practice, so a Next.js app\n * never matches the TanStack patterns and vice versa.\n *\n * Adapters with a bespoke layout can still bypass this via `candidateDirectories`.\n */\nconst defaultCandidateDirectories = (rootDir: string, adminRoute: string): string[] => {\n // Next.js uses %5F for routable segments that begin with an underscore.\n const adminFolder = adminRoute.replace(/(^|\\/)_/g, '$1%5F')\n\n return [\n // Next.js App Router: `(payload)` route group nested under the admin route\n path.resolve(rootDir, `app/${NEXT_PAYLOAD_ROUTE_GROUP}${adminFolder}/`),\n path.resolve(rootDir, `src/app/${NEXT_PAYLOAD_ROUTE_GROUP}${adminFolder}/`),\n // TanStack Start: `_payload` pathless route folder at the app root\n path.resolve(rootDir, `app/${TANSTACK_PAYLOAD_DIR}/`),\n path.resolve(rootDir, `src/app/${TANSTACK_PAYLOAD_DIR}/`),\n ]\n}\n\n/**\n * Returns the path to the import map file. If the import map file is not found, it throws an error.\n *\n * @param candidateDirectories - Optional array of directory paths to search for the import map.\n * Defaults to Next.js app directory convention. Framework adapters can provide their own.\n */\nexport async function resolveImportMapFilePath({\n adminRoute = '/admin',\n candidateDirectories,\n importMapFile,\n rootDir,\n}: {\n adminRoute?: string\n candidateDirectories?: string[]\n importMapFile?: string\n rootDir: string\n}): Promise<Error | string> {\n let importMapFilePath: string | undefined = undefined\n\n if (importMapFile?.length) {\n if (!(await pathOrFileExists(importMapFile))) {\n try {\n await fs.writeFile(importMapFile, '', { flag: 'wx' })\n } catch (err) {\n return new Error(\n `Could not find the import map file at ${importMapFile}${err instanceof Error && err?.message ? `: ${err.message}` : ''}`,\n )\n }\n }\n importMapFilePath = importMapFile\n } else {\n const directories = candidateDirectories ?? defaultCandidateDirectories(rootDir, adminRoute)\n\n for (const dir of directories) {\n if (await pathOrFileExists(dir)) {\n importMapFilePath = path.resolve(dir, 'importMap.js')\n if (!(await pathOrFileExists(importMapFilePath))) {\n await fs.writeFile(importMapFilePath, '', { flag: 'wx' })\n }\n break\n }\n }\n\n if (!importMapFilePath) {\n return new Error(\n `Could not find Payload import map folder. Looked in ${directories.join(' and ')}`,\n )\n }\n }\n return importMapFilePath\n}\n"],"names":["fs","path","NEXT_PAYLOAD_ROUTE_GROUP","TANSTACK_PAYLOAD_DIR","pathOrFileExists","access","defaultCandidateDirectories","rootDir","adminRoute","adminFolder","replace","resolve","resolveImportMapFilePath","candidateDirectories","importMapFile","importMapFilePath","undefined","length","writeFile","flag","err","Error","message","directories","dir","join"],"mappings":"AAAA,OAAOA,QAAQ,cAAa;AAC5B,OAAOC,UAAU,OAAM;AAEvB,SAASC,wBAAwB,EAAEC,oBAAoB,QAAQ,6BAA4B;AAE3F,eAAeC,iBAAiBH,IAAY;IAC1C,IAAI;QACF,MAAMD,GAAGK,MAAM,CAACJ;QAChB,OAAO;IACT,EAAE,OAAM;QACN,OAAO;IACT;AACF;AAEA;;;;;;;CAOC,GACD,MAAMK,8BAA8B,CAACC,SAAiBC;IACpD,wEAAwE;IACxE,MAAMC,cAAcD,WAAWE,OAAO,CAAC,YAAY;IAEnD,OAAO;QACL,2EAA2E;QAC3ET,KAAKU,OAAO,CAACJ,SAAS,CAAC,IAAI,EAAEL,2BAA2BO,YAAY,CAAC,CAAC;QACtER,KAAKU,OAAO,CAACJ,SAAS,CAAC,QAAQ,EAAEL,2BAA2BO,YAAY,CAAC,CAAC;QAC1E,mEAAmE;QACnER,KAAKU,OAAO,CAACJ,SAAS,CAAC,IAAI,EAAEJ,qBAAqB,CAAC,CAAC;QACpDF,KAAKU,OAAO,CAACJ,SAAS,CAAC,QAAQ,EAAEJ,qBAAqB,CAAC,CAAC;KACzD;AACH;AAEA;;;;;CAKC,GACD,OAAO,eAAeS,yBAAyB,EAC7CJ,aAAa,QAAQ,EACrBK,oBAAoB,EACpBC,aAAa,EACbP,OAAO,EAMR;IACC,IAAIQ,oBAAwCC;IAE5C,IAAIF,eAAeG,QAAQ;QACzB,IAAI,CAAE,MAAMb,iBAAiBU,gBAAiB;YAC5C,IAAI;gBACF,MAAMd,GAAGkB,SAAS,CAACJ,eAAe,IAAI;oBAAEK,MAAM;gBAAK;YACrD,EAAE,OAAOC,KAAK;gBACZ,OAAO,IAAIC,MACT,CAAC,sCAAsC,EAAEP,gBAAgBM,eAAeC,SAASD,KAAKE,UAAU,CAAC,EAAE,EAAEF,IAAIE,OAAO,EAAE,GAAG,IAAI;YAE7H;QACF;QACAP,oBAAoBD;IACtB,OAAO;QACL,MAAMS,cAAcV,wBAAwBP,4BAA4BC,SAASC;QAEjF,KAAK,MAAMgB,OAAOD,YAAa;YAC7B,IAAI,MAAMnB,iBAAiBoB,MAAM;gBAC/BT,oBAAoBd,KAAKU,OAAO,CAACa,KAAK;gBACtC,IAAI,CAAE,MAAMpB,iBAAiBW,oBAAqB;oBAChD,MAAMf,GAAGkB,SAAS,CAACH,mBAAmB,IAAI;wBAAEI,MAAM;oBAAK;gBACzD;gBACA;YACF;QACF;QAEA,IAAI,CAACJ,mBAAmB;YACtB,OAAO,IAAIM,MACT,CAAC,oDAAoD,EAAEE,YAAYE,IAAI,CAAC,UAAU;QAEtF;IACF;IACA,OAAOV;AACT"}
@@ -14,7 +14,7 @@ import { saveVersion } from '../../index.js';
14
14
  import { removeUnreferencedStagedObjects } from '../../uploads/fileVersioning/cleanup.js';
15
15
  import { captureCloudHookState, runCloudFileCreation } from '../../uploads/fileVersioning/cloudStorage.js';
16
16
  import { abortFileOperationScope, beginFileOperationScope, completeFileOperationScope, runFileCreationPlan, stageLocalUploadFiles } from '../../uploads/fileVersioning/fileOperationManager.js';
17
- import { generateFileData } from '../../uploads/generateFileData.js';
17
+ import { generateFileData } from '../../uploads/generateFileData/index.js';
18
18
  import { getExternalUploadSource, getUploadDestination, sanitizeUploadData } from '../../uploads/sanitizeUploadData.js';
19
19
  import { unlinkTempFiles } from '../../uploads/unlinkTempFiles.js';
20
20
  import { uploadFiles } from '../../uploads/uploadFiles.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/collections/operations/create.ts"],"sourcesContent":["import crypto from 'crypto'\n\nimport type { CollectionSlug, FindOptions, JsonObject } from '../../index.js'\nimport type {\n Document,\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformCollectionWithSelect,\n} from '../../types/index.js'\nimport type {\n Collection,\n DataFromCollectionSlug,\n RequiredDataFromCollectionSlug,\n SelectFromCollectionSlug,\n} from '../config/types.js'\n\nimport { ensureUsernameOrEmail } from '../../auth/ensureUsernameOrEmail.js'\nimport { executeAccess } from '../../auth/executeAccess.js'\nimport { sendVerificationEmail } from '../../auth/sendVerificationEmail.js'\nimport { registerLocalStrategy } from '../../auth/strategies/local/register.js'\nimport { getDuplicateDocumentData } from '../../duplicateDocument/index.js'\nimport { APIError, ValidationError } from '../../errors/index.js'\nimport { fillEmptyLocalizedSlugs } from '../../fields/baseFields/slug/fillEmptyLocalizedSlugs.js'\nimport { afterChange } from '../../fields/hooks/afterChange/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { beforeChange } from '../../fields/hooks/beforeChange/index.js'\nimport { beforeValidate } from '../../fields/hooks/beforeValidate/index.js'\nimport { saveVersion } from '../../index.js'\nimport { removeUnreferencedStagedObjects } from '../../uploads/fileVersioning/cleanup.js'\nimport {\n captureCloudHookState,\n runCloudFileCreation,\n} from '../../uploads/fileVersioning/cloudStorage.js'\nimport {\n abortFileOperationScope,\n beginFileOperationScope,\n completeFileOperationScope,\n runFileCreationPlan,\n stageLocalUploadFiles,\n} from '../../uploads/fileVersioning/fileOperationManager.js'\nimport { generateFileData } from '../../uploads/generateFileData.js'\nimport {\n getExternalUploadSource,\n getUploadDestination,\n sanitizeUploadData,\n} from '../../uploads/sanitizeUploadData.js'\nimport { unlinkTempFiles } from '../../uploads/unlinkTempFiles.js'\nimport { uploadFiles } from '../../uploads/uploadFiles.js'\nimport { assertNoValidationWrite } from '../../utilities/assertNoValidationWrite.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport {\n hasDraftsEnabled,\n hasDraftValidationEnabled,\n hasLocalizeStatusEnabled,\n} from '../../utilities/getVersionsConfig.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { resolvePublishAllLocales } from '../../utilities/resolvePublishAllLocales.js'\nimport { resolveSelect } from '../../utilities/resolveSelect.js'\nimport { sanitizeInternalFields } from '../../utilities/sanitizeInternalFields.js'\nimport { sanitizeSelect } from '../../utilities/sanitizeSelect.js'\nimport {\n buildAllLocalesPublicationHookDoc,\n canApplyAllLocalesStatusChange,\n getAllLocalesPublicationStatus,\n normalizeAllLocalesPublicationStatus,\n reconcileAllLocalesPublicationStatus,\n} from '../../versions/allLocalesPublicationStatus.js'\nimport { validateLocalWithLocaleKeyedData } from './local/validate.js'\nimport { buildAfterOperation } from './utilities/buildAfterOperation.js'\nimport { buildBeforeOperation } from './utilities/buildBeforeOperation.js'\n\nexport type Arguments<TSlug extends CollectionSlug> = {\n autosave?: boolean\n collection: Collection\n data: RequiredDataFromCollectionSlug<TSlug>\n depth?: number\n disableTransaction?: boolean\n disableVerificationEmail?: boolean\n draft?: boolean\n duplicateFromID?: DataFromCollectionSlug<TSlug>['id']\n overrideAccess?: boolean\n overwriteExistingFiles?: boolean\n populate?: PopulateType\n publishAllLocales?: boolean\n req: PayloadRequest\n selectedLocales?: string[]\n showHiddenFields?: boolean\n} & Pick<FindOptions<TSlug, SelectType>, 'select'>\n\nexport const createOperation = async <\n TSlug extends CollectionSlug,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n>(\n incomingArgs: Arguments<TSlug>,\n): Promise<TransformCollectionWithSelect<TSlug, TSelect>> => {\n let args = incomingArgs\n let externalUploadSource: ReturnType<typeof getExternalUploadSource>\n let restoreCloudHookState: (() => void) | undefined\n const hasFileOperationScope = Boolean(args.collection.config.upload)\n\n if (hasFileOperationScope) {\n beginFileOperationScope({ req: args.req })\n }\n\n assertNoValidationWrite(args.req)\n\n try {\n const shouldCommit = !args.disableTransaction && (await initTransaction(args.req))\n\n // Keep a remote URL only as an ephemeral file source, then strip all submitted generated\n // identity before untrusted create hooks run. The fetched file receives new server-owned\n // identity before persistence.\n if (args.collection.config.upload && !args.overrideAccess) {\n externalUploadSource = getExternalUploadSource(args.data)\n const { objectKey, prefix } = getUploadDestination({ data: args.data, file: args.req.file })\n const sanitizedData = sanitizeUploadData(args.data, 'create')\n\n args = {\n ...args,\n data:\n typeof sanitizedData === 'object' && sanitizedData !== null\n ? {\n ...sanitizedData,\n ...(prefix !== undefined ? { prefix } : {}),\n ...(objectKey !== undefined ? { _objectKey: objectKey } : {}),\n }\n : sanitizedData,\n }\n }\n\n const initialCollectionConfig = args.collection.config\n const initialPublishAllLocales = resolvePublishAllLocales({\n draft: args.draft,\n hasLocalizeStatusEnabled: hasLocalizeStatusEnabled(initialCollectionConfig),\n publishAllLocalesArg: args.publishAllLocales,\n })\n const initialAllLocalesPublicationStatus = getAllLocalesPublicationStatus({\n hasLocalizedStatus: Boolean(\n args.req.payload.config.localization && hasLocalizeStatusEnabled(initialCollectionConfig),\n ),\n publishAllLocales: initialPublishAllLocales,\n unpublishAllLocales: false,\n })\n\n const initialAllLocalesPublicationIntent = normalizeAllLocalesPublicationStatus({\n data: args.data,\n status: initialAllLocalesPublicationStatus,\n })\n ensureUsernameOrEmail<TSlug>({\n authOptions: args.collection.config.auth,\n collectionSlug: args.collection.config.slug,\n data: args.data,\n operation: 'create',\n req: args.req,\n })\n\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n args = await buildBeforeOperation({\n args,\n collection: args.collection.config,\n operation: 'create',\n overrideAccess: args.overrideAccess!,\n })\n\n const {\n autosave = false,\n collection: { config: collectionConfig },\n collection,\n depth,\n disableVerificationEmail,\n draft = false,\n duplicateFromID,\n overrideAccess,\n overwriteExistingFiles = false,\n populate,\n publishAllLocales: publishAllLocalesArg,\n req: {\n fallbackLocale,\n locale,\n payload,\n payload: { config },\n },\n req,\n select: incomingSelect,\n selectedLocales,\n showHiddenFields,\n } = args\n\n let { data } = args\n\n // For creates there is no existing doc — always publish all locales when not a draft.\n let publishAllLocales = resolvePublishAllLocales({\n draft,\n hasLocalizeStatusEnabled: hasLocalizeStatusEnabled(collectionConfig),\n publishAllLocalesArg,\n })\n const requestedAllLocalesPublicationStatus = getAllLocalesPublicationStatus({\n hasLocalizedStatus: Boolean(\n config.localization && hasLocalizeStatusEnabled(collectionConfig),\n ),\n publishAllLocales,\n unpublishAllLocales: false,\n })\n const allLocalesPublicationStatus = reconcileAllLocalesPublicationStatus({\n data,\n intent: initialAllLocalesPublicationIntent,\n status: requestedAllLocalesPublicationStatus,\n })\n\n if (requestedAllLocalesPublicationStatus && !allLocalesPublicationStatus) {\n publishAllLocales = false\n }\n const isSavingDraft = Boolean(draft && hasDraftsEnabled(collectionConfig) && !publishAllLocales)\n\n if (isSavingDraft) {\n data._status = 'draft'\n }\n\n const isDuplicating = duplicateFromID !== undefined && duplicateFromID !== null\n\n if (isDuplicating && collectionConfig.disableDuplicate === true) {\n throw new APIError(\n `The collection with slug ${String(collectionConfig.slug)} cannot be duplicated.`,\n 400,\n )\n }\n\n let duplicatedFromDocWithLocales: JsonObject = {}\n let duplicatedFromDoc: JsonObject = {}\n\n if (isDuplicating) {\n const duplicateResult = await getDuplicateDocumentData({\n id: duplicateFromID,\n collectionConfig,\n draftArg: isSavingDraft,\n overrideAccess,\n req,\n selectedLocales,\n })\n\n duplicatedFromDoc = duplicateResult.duplicatedFromDoc\n duplicatedFromDocWithLocales = duplicateResult.duplicatedFromDocWithLocales\n }\n\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n if (!overrideAccess) {\n await executeAccess(\n { slug: collectionConfig.slug, data, req },\n collectionConfig.access.create,\n )\n }\n\n // /////////////////////////////////////\n // Generate data for all files and sizes\n // /////////////////////////////////////\n\n const { data: newFileData, files: filesToUpload } = await generateFileData({\n collection,\n config,\n data,\n draft: isSavingDraft,\n externalUploadSource,\n isDuplicating,\n operation: 'create',\n originalDoc: duplicatedFromDoc,\n overwriteExistingFiles,\n req,\n throwOnMissingFile:\n !isSavingDraft && collection.config.upload.filesRequiredOnCreate !== false,\n })\n\n data = newFileData\n\n // /////////////////////////////////////\n // beforeValidate - Fields\n // /////////////////////////////////////\n\n let statusFieldAccess = false\n const publicationFieldPolicyDoc = buildAllLocalesPublicationHookDoc({\n doc: duplicatedFromDoc,\n docWithLocales: duplicatedFromDocWithLocales,\n status:\n data._status === allLocalesPublicationStatus ? allLocalesPublicationStatus : undefined,\n })\n\n data = await beforeValidate({\n collection: collectionConfig,\n context: req.context,\n data,\n doc: duplicatedFromDoc,\n docForHooks: publicationFieldPolicyDoc,\n global: null,\n onFieldAccess: ({ accessResult, path }) => {\n if (path === '_status') {\n statusFieldAccess = accessResult\n }\n },\n operation: 'create',\n overrideAccess: overrideAccess!,\n req,\n })\n\n const publicationHookDoc = buildAllLocalesPublicationHookDoc({\n doc: duplicatedFromDoc,\n docWithLocales: duplicatedFromDocWithLocales,\n status:\n statusFieldAccess && data._status === allLocalesPublicationStatus\n ? allLocalesPublicationStatus\n : undefined,\n })\n\n // /////////////////////////////////////\n // beforeValidate - Collections\n // /////////////////////////////////////\n\n if (collectionConfig.hooks.beforeValidate?.length) {\n for (const hook of collectionConfig.hooks.beforeValidate) {\n data =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n data,\n operation: 'create',\n originalDoc: publicationHookDoc,\n req,\n })) || data\n }\n }\n\n // /////////////////////////////////////\n // beforeChange - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.beforeChange?.length) {\n for (const hook of collectionConfig.hooks.beforeChange) {\n data =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n data,\n operation: 'create',\n originalDoc: publicationHookDoc,\n req,\n })) || data\n }\n }\n\n const publicationData = { ...data }\n\n // /////////////////////////////////////\n // beforeChange - Fields\n // /////////////////////////////////////\n\n let statusFieldValue: unknown\n const docWithLocalesForFields = !statusFieldAccess\n ? { ...duplicatedFromDocWithLocales, _status: {} }\n : duplicatedFromDocWithLocales\n\n const dataWithLocales = await beforeChange<JsonObject>({\n collection: collectionConfig,\n context: req.context,\n data,\n doc: publicationHookDoc,\n docWithLocales: docWithLocalesForFields,\n global: null,\n onDataProcessed: (processedData) => {\n statusFieldValue = processedData._status\n },\n operation: 'create',\n overrideAccess,\n req,\n skipValidation: isSavingDraft && !hasDraftValidationEnabled(collectionConfig),\n })\n\n const shouldApplyAllLocalesStatusChange = canApplyAllLocalesStatusChange({\n canUpdateStatus: statusFieldAccess,\n requestedStatus: allLocalesPublicationStatus,\n statusAfterDocumentHooks: publicationData._status,\n statusAfterFieldHooks: statusFieldValue,\n })\n\n if (\n allLocalesPublicationStatus &&\n !shouldApplyAllLocalesStatusChange &&\n statusFieldAccess &&\n typeof statusFieldValue === 'undefined' &&\n typeof duplicatedFromDocWithLocales._status === 'object' &&\n duplicatedFromDocWithLocales._status !== null\n ) {\n dataWithLocales._status = { ...duplicatedFromDocWithLocales._status }\n }\n\n // When locale='all' or when beforeChange doesn't convert the string (e.g. no locale hook ran),\n // the localized _status remains a plain string. Expand it to a per-locale object so MongoDB\n // doesn't reject the write. This covers both draft and non-draft operations.\n if (\n config.localization &&\n hasLocalizeStatusEnabled(collectionConfig) &&\n typeof dataWithLocales._status === 'string'\n ) {\n const statusStr = dataWithLocales._status\n\n if (\n shouldApplyAllLocalesStatusChange &&\n typeof duplicatedFromDocWithLocales._status === 'object' &&\n duplicatedFromDocWithLocales._status !== null\n ) {\n dataWithLocales._status = { ...duplicatedFromDocWithLocales._status }\n } else {\n dataWithLocales._status = {}\n }\n\n if (!shouldApplyAllLocalesStatusChange) {\n for (const localeCode of config.localization.localeCodes) {\n ;(dataWithLocales._status as Record<string, unknown>)[localeCode] = statusStr\n }\n }\n }\n\n if (\n config.localization &&\n hasLocalizeStatusEnabled(collectionConfig) &&\n shouldApplyAllLocalesStatusChange\n ) {\n let accessibleLocaleCodes = config.localization.localeCodes\n\n if (config.localization.filterAvailableLocales) {\n const filteredLocales = await config.localization.filterAvailableLocales({\n locales: config.localization.locales,\n req,\n })\n accessibleLocaleCodes = filteredLocales.map((locale) =>\n typeof locale === 'string' ? locale : locale.code,\n )\n }\n\n if (typeof dataWithLocales._status !== 'object' || dataWithLocales._status === null) {\n dataWithLocales._status = {}\n }\n\n for (const localeCode of accessibleLocaleCodes) {\n dataWithLocales._status[localeCode] = 'published'\n }\n }\n\n // Fill every locale of a localized slug so switching locales never lands on an empty slug. The\n // slug field hook only sees the active locale, so the rest are seeded here on create.\n if (config.localization) {\n await fillEmptyLocalizedSlugs({\n collection: collectionConfig,\n data: dataWithLocales,\n overrideAccess,\n req,\n })\n }\n\n if (\n config.localization &&\n hasDraftsEnabled(collectionConfig) &&\n publishAllLocales &&\n (!hasLocalizeStatusEnabled(collectionConfig) || shouldApplyAllLocalesStatusChange)\n ) {\n const validationResult = await validateLocalWithLocaleKeyedData({\n operation: 'create',\n options: {\n collection: collectionConfig.slug,\n data: dataWithLocales,\n locale: 'all',\n overrideAccess,\n req,\n },\n payload,\n })\n\n if (!validationResult.valid) {\n throw new ValidationError(\n {\n collection: collectionConfig.slug,\n errors: validationResult.errors,\n req,\n },\n req.t,\n )\n }\n }\n\n // /////////////////////////////////////\n // Write files to local storage\n // /////////////////////////////////////\n\n // /////////////////////////////////////\n // Create\n // /////////////////////////////////////\n\n const select = sanitizeSelect({\n fields: collectionConfig.flattenedFields,\n select: resolveSelect({\n config: collectionConfig.select,\n operation: 'create',\n req,\n select: incomingSelect,\n }),\n })\n\n const writeDocument = async () => {\n if (collectionConfig.auth && !collectionConfig.auth.disableLocalStrategy) {\n if (collectionConfig.auth.verify) {\n dataWithLocales._verified = Boolean(dataWithLocales._verified) || false\n dataWithLocales._verificationToken = crypto.randomBytes(20).toString('hex')\n }\n\n return registerLocalStrategy({\n collection: collectionConfig,\n doc: dataWithLocales,\n password: data.password as string,\n payload: req.payload,\n req,\n })\n }\n\n return payload.db.create({\n collection: collectionConfig.slug,\n data: dataWithLocales,\n req,\n })\n }\n\n const hasManagedLocalUpload =\n !collectionConfig.upload.disableLocalStorage &&\n filesToUpload.length > 0 &&\n Boolean(dataWithLocales.original)\n let doc\n\n if (\n collectionConfig.upload.fileOperations &&\n (filesToUpload.length > 0 || req.context?._payloadVerifiedProviderOriginal)\n ) {\n restoreCloudHookState = captureCloudHookState({ req })\n doc = await runCloudFileCreation({\n collection: collectionConfig,\n data: dataWithLocales,\n files: filesToUpload,\n req,\n write: writeDocument,\n })\n } else if (hasManagedLocalUpload) {\n doc = await runFileCreationPlan({\n cleanupStagedAfterWriteFailure: (objects) =>\n removeUnreferencedStagedObjects({ collection: collectionConfig, objects, req }),\n req,\n stage: ({ trackStagedObject }) =>\n stageLocalUploadFiles({\n files: filesToUpload,\n staticDir: collectionConfig.upload.staticDir!,\n trackStagedObject,\n }),\n write: writeDocument,\n })\n } else {\n if (!collectionConfig.upload.disableLocalStorage) {\n await uploadFiles(payload, filesToUpload, req)\n }\n doc = await writeDocument()\n }\n\n const verificationToken = doc._verificationToken\n let resultWithLocales: Document = sanitizeInternalFields(doc)\n\n // /////////////////////////////////////\n // Add collection property for auth collections\n // /////////////////////////////////////\n\n if (collectionConfig.auth) {\n resultWithLocales = { ...resultWithLocales, collection: collectionConfig.slug }\n }\n\n // /////////////////////////////////////\n // Create version\n // /////////////////////////////////////\n\n if (collectionConfig.versions) {\n await saveVersion({\n id: resultWithLocales.id,\n autosave,\n collection: collectionConfig,\n docWithLocales: resultWithLocales,\n operation: 'create',\n payload,\n req,\n returning: false,\n })\n }\n\n // /////////////////////////////////////\n // Send verification email if applicable\n // /////////////////////////////////////\n\n if (collectionConfig.auth && collectionConfig.auth.verify && resultWithLocales.email) {\n await sendVerificationEmail({\n collection: { config: collectionConfig },\n config: payload.config,\n disableEmail: disableVerificationEmail!,\n email: payload.email,\n req,\n token: verificationToken,\n user: resultWithLocales,\n })\n }\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n let result: Document = await afterRead({\n collection: collectionConfig,\n context: req.context,\n depth: depth!,\n doc: resultWithLocales,\n draft,\n fallbackLocale: fallbackLocale!,\n global: null,\n locale: locale!,\n overrideAccess: overrideAccess!,\n populate,\n req,\n select,\n showHiddenFields: showHiddenFields!,\n })\n\n // /////////////////////////////////////\n // afterRead - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.afterRead?.length) {\n for (const hook of collectionConfig.hooks.afterRead) {\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: result,\n overrideAccess,\n req,\n })) || result\n }\n }\n\n // /////////////////////////////////////\n // afterChange - Fields\n // /////////////////////////////////////\n\n result = await afterChange({\n collection: collectionConfig,\n context: req.context,\n data,\n doc: result,\n global: null,\n operation: 'create',\n previousDoc: {},\n req,\n })\n\n // /////////////////////////////////////\n // afterChange - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.afterChange?.length) {\n for (const hook of collectionConfig.hooks.afterChange) {\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n data,\n doc: result,\n operation: 'create',\n overrideAccess,\n previousDoc: {},\n req: args.req,\n select,\n })) || result\n }\n }\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n result = await buildAfterOperation<TSlug>({\n args,\n collection: collectionConfig,\n operation: 'create',\n overrideAccess: args.overrideAccess!,\n result,\n })\n\n await unlinkTempFiles({ collectionConfig, config, req }).catch((unlinkError) => {\n req.payload.logger.error({ err: unlinkError, msg: 'Failed to remove temp file' })\n })\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n if (shouldCommit) {\n await commitTransaction(req)\n }\n\n if (hasFileOperationScope) {\n await completeFileOperationScope({ req })\n }\n\n return result\n } catch (error: unknown) {\n await unlinkTempFiles({\n collectionConfig: args.collection.config,\n config: args.req.payload.config,\n req: args.req,\n }).catch((unlinkError) => {\n args.req.payload.logger.error({ err: unlinkError, msg: 'Failed to remove temp file' })\n })\n await killTransaction(args.req)\n if (hasFileOperationScope) {\n await abortFileOperationScope({ req: args.req })\n }\n throw error\n } finally {\n restoreCloudHookState?.()\n }\n}\n"],"names":["crypto","ensureUsernameOrEmail","executeAccess","sendVerificationEmail","registerLocalStrategy","getDuplicateDocumentData","APIError","ValidationError","fillEmptyLocalizedSlugs","afterChange","afterRead","beforeChange","beforeValidate","saveVersion","removeUnreferencedStagedObjects","captureCloudHookState","runCloudFileCreation","abortFileOperationScope","beginFileOperationScope","completeFileOperationScope","runFileCreationPlan","stageLocalUploadFiles","generateFileData","getExternalUploadSource","getUploadDestination","sanitizeUploadData","unlinkTempFiles","uploadFiles","assertNoValidationWrite","commitTransaction","hasDraftsEnabled","hasDraftValidationEnabled","hasLocalizeStatusEnabled","initTransaction","killTransaction","resolvePublishAllLocales","resolveSelect","sanitizeInternalFields","sanitizeSelect","buildAllLocalesPublicationHookDoc","canApplyAllLocalesStatusChange","getAllLocalesPublicationStatus","normalizeAllLocalesPublicationStatus","reconcileAllLocalesPublicationStatus","validateLocalWithLocaleKeyedData","buildAfterOperation","buildBeforeOperation","createOperation","incomingArgs","args","externalUploadSource","restoreCloudHookState","hasFileOperationScope","Boolean","collection","config","upload","req","shouldCommit","disableTransaction","overrideAccess","data","objectKey","prefix","file","sanitizedData","undefined","_objectKey","initialCollectionConfig","initialPublishAllLocales","draft","publishAllLocalesArg","publishAllLocales","initialAllLocalesPublicationStatus","hasLocalizedStatus","payload","localization","unpublishAllLocales","initialAllLocalesPublicationIntent","status","authOptions","auth","collectionSlug","slug","operation","autosave","collectionConfig","depth","disableVerificationEmail","duplicateFromID","overwriteExistingFiles","populate","fallbackLocale","locale","select","incomingSelect","selectedLocales","showHiddenFields","requestedAllLocalesPublicationStatus","allLocalesPublicationStatus","intent","isSavingDraft","_status","isDuplicating","disableDuplicate","String","duplicatedFromDocWithLocales","duplicatedFromDoc","duplicateResult","id","draftArg","access","create","newFileData","files","filesToUpload","originalDoc","throwOnMissingFile","filesRequiredOnCreate","statusFieldAccess","publicationFieldPolicyDoc","doc","docWithLocales","context","docForHooks","global","onFieldAccess","accessResult","path","publicationHookDoc","hooks","length","hook","publicationData","statusFieldValue","docWithLocalesForFields","dataWithLocales","onDataProcessed","processedData","skipValidation","shouldApplyAllLocalesStatusChange","canUpdateStatus","requestedStatus","statusAfterDocumentHooks","statusAfterFieldHooks","statusStr","localeCode","localeCodes","accessibleLocaleCodes","filterAvailableLocales","filteredLocales","locales","map","code","validationResult","options","valid","errors","t","fields","flattenedFields","writeDocument","disableLocalStrategy","verify","_verified","_verificationToken","randomBytes","toString","password","db","hasManagedLocalUpload","disableLocalStorage","original","fileOperations","_payloadVerifiedProviderOriginal","write","cleanupStagedAfterWriteFailure","objects","stage","trackStagedObject","staticDir","verificationToken","resultWithLocales","versions","returning","email","disableEmail","token","user","result","previousDoc","catch","unlinkError","logger","error","err","msg"],"mappings":"AAAA,OAAOA,YAAY,SAAQ;AAiB3B,SAASC,qBAAqB,QAAQ,sCAAqC;AAC3E,SAASC,aAAa,QAAQ,8BAA6B;AAC3D,SAASC,qBAAqB,QAAQ,sCAAqC;AAC3E,SAASC,qBAAqB,QAAQ,0CAAyC;AAC/E,SAASC,wBAAwB,QAAQ,mCAAkC;AAC3E,SAASC,QAAQ,EAAEC,eAAe,QAAQ,wBAAuB;AACjE,SAASC,uBAAuB,QAAQ,0DAAyD;AACjG,SAASC,WAAW,QAAQ,0CAAyC;AACrE,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,YAAY,QAAQ,2CAA0C;AACvE,SAASC,cAAc,QAAQ,6CAA4C;AAC3E,SAASC,WAAW,QAAQ,iBAAgB;AAC5C,SAASC,+BAA+B,QAAQ,0CAAyC;AACzF,SACEC,qBAAqB,EACrBC,oBAAoB,QACf,+CAA8C;AACrD,SACEC,uBAAuB,EACvBC,uBAAuB,EACvBC,0BAA0B,EAC1BC,mBAAmB,EACnBC,qBAAqB,QAChB,uDAAsD;AAC7D,SAASC,gBAAgB,QAAQ,oCAAmC;AACpE,SACEC,uBAAuB,EACvBC,oBAAoB,EACpBC,kBAAkB,QACb,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B;gBAAEsC;YAAI;QACzC;QAEA,OAAOoI;IACT,EAAE,OAAOK,OAAgB;QACvB,MAAMxK,gBAAgB;YACpB4D,kBAAkBrC,KAAKK,UAAU,CAACC,MAAM;YACxCA,QAAQN,KAAKQ,GAAG,CAACkB,OAAO,CAACpB,MAAM;YAC/BE,KAAKR,KAAKQ,GAAG;QACf,GAAGsI,KAAK,CAAC,CAACC;YACR/I,KAAKQ,GAAG,CAACkB,OAAO,CAACsH,MAAM,CAACC,KAAK,CAAC;gBAAEC,KAAKH;gBAAaI,KAAK;YAA6B;QACtF;QACA,MAAMlK,gBAAgBe,KAAKQ,GAAG;QAC9B,IAAIL,uBAAuB;YACzB,MAAMnC,wBAAwB;gBAAEwC,KAAKR,KAAKQ,GAAG;YAAC;QAChD;QACA,MAAMyI;IACR,SAAU;QACR/I;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/collections/operations/create.ts"],"sourcesContent":["import crypto from 'crypto'\n\nimport type { CollectionSlug, FindOptions, JsonObject } from '../../index.js'\nimport type {\n Document,\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformCollectionWithSelect,\n} from '../../types/index.js'\nimport type {\n Collection,\n DataFromCollectionSlug,\n RequiredDataFromCollectionSlug,\n SelectFromCollectionSlug,\n} from '../config/types.js'\n\nimport { ensureUsernameOrEmail } from '../../auth/ensureUsernameOrEmail.js'\nimport { executeAccess } from '../../auth/executeAccess.js'\nimport { sendVerificationEmail } from '../../auth/sendVerificationEmail.js'\nimport { registerLocalStrategy } from '../../auth/strategies/local/register.js'\nimport { getDuplicateDocumentData } from '../../duplicateDocument/index.js'\nimport { APIError, ValidationError } from '../../errors/index.js'\nimport { fillEmptyLocalizedSlugs } from '../../fields/baseFields/slug/fillEmptyLocalizedSlugs.js'\nimport { afterChange } from '../../fields/hooks/afterChange/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { beforeChange } from '../../fields/hooks/beforeChange/index.js'\nimport { beforeValidate } from '../../fields/hooks/beforeValidate/index.js'\nimport { saveVersion } from '../../index.js'\nimport { removeUnreferencedStagedObjects } from '../../uploads/fileVersioning/cleanup.js'\nimport {\n captureCloudHookState,\n runCloudFileCreation,\n} from '../../uploads/fileVersioning/cloudStorage.js'\nimport {\n abortFileOperationScope,\n beginFileOperationScope,\n completeFileOperationScope,\n runFileCreationPlan,\n stageLocalUploadFiles,\n} from '../../uploads/fileVersioning/fileOperationManager.js'\nimport { generateFileData } from '../../uploads/generateFileData/index.js'\nimport {\n getExternalUploadSource,\n getUploadDestination,\n sanitizeUploadData,\n} from '../../uploads/sanitizeUploadData.js'\nimport { unlinkTempFiles } from '../../uploads/unlinkTempFiles.js'\nimport { uploadFiles } from '../../uploads/uploadFiles.js'\nimport { assertNoValidationWrite } from '../../utilities/assertNoValidationWrite.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport {\n hasDraftsEnabled,\n hasDraftValidationEnabled,\n hasLocalizeStatusEnabled,\n} from '../../utilities/getVersionsConfig.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { resolvePublishAllLocales } from '../../utilities/resolvePublishAllLocales.js'\nimport { resolveSelect } from '../../utilities/resolveSelect.js'\nimport { sanitizeInternalFields } from '../../utilities/sanitizeInternalFields.js'\nimport { sanitizeSelect } from '../../utilities/sanitizeSelect.js'\nimport {\n buildAllLocalesPublicationHookDoc,\n canApplyAllLocalesStatusChange,\n getAllLocalesPublicationStatus,\n normalizeAllLocalesPublicationStatus,\n reconcileAllLocalesPublicationStatus,\n} from '../../versions/allLocalesPublicationStatus.js'\nimport { validateLocalWithLocaleKeyedData } from './local/validate.js'\nimport { buildAfterOperation } from './utilities/buildAfterOperation.js'\nimport { buildBeforeOperation } from './utilities/buildBeforeOperation.js'\n\nexport type Arguments<TSlug extends CollectionSlug> = {\n autosave?: boolean\n collection: Collection\n data: RequiredDataFromCollectionSlug<TSlug>\n depth?: number\n disableTransaction?: boolean\n disableVerificationEmail?: boolean\n draft?: boolean\n duplicateFromID?: DataFromCollectionSlug<TSlug>['id']\n overrideAccess?: boolean\n overwriteExistingFiles?: boolean\n populate?: PopulateType\n publishAllLocales?: boolean\n req: PayloadRequest\n selectedLocales?: string[]\n showHiddenFields?: boolean\n} & Pick<FindOptions<TSlug, SelectType>, 'select'>\n\nexport const createOperation = async <\n TSlug extends CollectionSlug,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n>(\n incomingArgs: Arguments<TSlug>,\n): Promise<TransformCollectionWithSelect<TSlug, TSelect>> => {\n let args = incomingArgs\n let externalUploadSource: ReturnType<typeof getExternalUploadSource>\n let restoreCloudHookState: (() => void) | undefined\n const hasFileOperationScope = Boolean(args.collection.config.upload)\n\n if (hasFileOperationScope) {\n beginFileOperationScope({ req: args.req })\n }\n\n assertNoValidationWrite(args.req)\n\n try {\n const shouldCommit = !args.disableTransaction && (await initTransaction(args.req))\n\n // Keep a remote URL only as an ephemeral file source, then strip all submitted generated\n // identity before untrusted create hooks run. The fetched file receives new server-owned\n // identity before persistence.\n if (args.collection.config.upload && !args.overrideAccess) {\n externalUploadSource = getExternalUploadSource(args.data)\n const { objectKey, prefix } = getUploadDestination({ data: args.data, file: args.req.file })\n const sanitizedData = sanitizeUploadData(args.data, 'create')\n\n args = {\n ...args,\n data:\n typeof sanitizedData === 'object' && sanitizedData !== null\n ? {\n ...sanitizedData,\n ...(prefix !== undefined ? { prefix } : {}),\n ...(objectKey !== undefined ? { _objectKey: objectKey } : {}),\n }\n : sanitizedData,\n }\n }\n\n const initialCollectionConfig = args.collection.config\n const initialPublishAllLocales = resolvePublishAllLocales({\n draft: args.draft,\n hasLocalizeStatusEnabled: hasLocalizeStatusEnabled(initialCollectionConfig),\n publishAllLocalesArg: args.publishAllLocales,\n })\n const initialAllLocalesPublicationStatus = getAllLocalesPublicationStatus({\n hasLocalizedStatus: Boolean(\n args.req.payload.config.localization && hasLocalizeStatusEnabled(initialCollectionConfig),\n ),\n publishAllLocales: initialPublishAllLocales,\n unpublishAllLocales: false,\n })\n\n const initialAllLocalesPublicationIntent = normalizeAllLocalesPublicationStatus({\n data: args.data,\n status: initialAllLocalesPublicationStatus,\n })\n ensureUsernameOrEmail<TSlug>({\n authOptions: args.collection.config.auth,\n collectionSlug: args.collection.config.slug,\n data: args.data,\n operation: 'create',\n req: args.req,\n })\n\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n args = await buildBeforeOperation({\n args,\n collection: args.collection.config,\n operation: 'create',\n overrideAccess: args.overrideAccess!,\n })\n\n const {\n autosave = false,\n collection: { config: collectionConfig },\n collection,\n depth,\n disableVerificationEmail,\n draft = false,\n duplicateFromID,\n overrideAccess,\n overwriteExistingFiles = false,\n populate,\n publishAllLocales: publishAllLocalesArg,\n req: {\n fallbackLocale,\n locale,\n payload,\n payload: { config },\n },\n req,\n select: incomingSelect,\n selectedLocales,\n showHiddenFields,\n } = args\n\n let { data } = args\n\n // For creates there is no existing doc — always publish all locales when not a draft.\n let publishAllLocales = resolvePublishAllLocales({\n draft,\n hasLocalizeStatusEnabled: hasLocalizeStatusEnabled(collectionConfig),\n publishAllLocalesArg,\n })\n const requestedAllLocalesPublicationStatus = getAllLocalesPublicationStatus({\n hasLocalizedStatus: Boolean(\n config.localization && hasLocalizeStatusEnabled(collectionConfig),\n ),\n publishAllLocales,\n unpublishAllLocales: false,\n })\n const allLocalesPublicationStatus = reconcileAllLocalesPublicationStatus({\n data,\n intent: initialAllLocalesPublicationIntent,\n status: requestedAllLocalesPublicationStatus,\n })\n\n if (requestedAllLocalesPublicationStatus && !allLocalesPublicationStatus) {\n publishAllLocales = false\n }\n const isSavingDraft = Boolean(draft && hasDraftsEnabled(collectionConfig) && !publishAllLocales)\n\n if (isSavingDraft) {\n data._status = 'draft'\n }\n\n const isDuplicating = duplicateFromID !== undefined && duplicateFromID !== null\n\n if (isDuplicating && collectionConfig.disableDuplicate === true) {\n throw new APIError(\n `The collection with slug ${String(collectionConfig.slug)} cannot be duplicated.`,\n 400,\n )\n }\n\n let duplicatedFromDocWithLocales: JsonObject = {}\n let duplicatedFromDoc: JsonObject = {}\n\n if (isDuplicating) {\n const duplicateResult = await getDuplicateDocumentData({\n id: duplicateFromID,\n collectionConfig,\n draftArg: isSavingDraft,\n overrideAccess,\n req,\n selectedLocales,\n })\n\n duplicatedFromDoc = duplicateResult.duplicatedFromDoc\n duplicatedFromDocWithLocales = duplicateResult.duplicatedFromDocWithLocales\n }\n\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n if (!overrideAccess) {\n await executeAccess(\n { slug: collectionConfig.slug, data, req },\n collectionConfig.access.create,\n )\n }\n\n // /////////////////////////////////////\n // Generate data for all files and sizes\n // /////////////////////////////////////\n\n const { data: newFileData, files: filesToUpload } = await generateFileData({\n collection,\n config,\n data,\n draft: isSavingDraft,\n externalUploadSource,\n isDuplicating,\n operation: 'create',\n originalDoc: duplicatedFromDoc,\n overwriteExistingFiles,\n req,\n throwOnMissingFile:\n !isSavingDraft && collection.config.upload.filesRequiredOnCreate !== false,\n })\n\n data = newFileData\n\n // /////////////////////////////////////\n // beforeValidate - Fields\n // /////////////////////////////////////\n\n let statusFieldAccess = false\n const publicationFieldPolicyDoc = buildAllLocalesPublicationHookDoc({\n doc: duplicatedFromDoc,\n docWithLocales: duplicatedFromDocWithLocales,\n status:\n data._status === allLocalesPublicationStatus ? allLocalesPublicationStatus : undefined,\n })\n\n data = await beforeValidate({\n collection: collectionConfig,\n context: req.context,\n data,\n doc: duplicatedFromDoc,\n docForHooks: publicationFieldPolicyDoc,\n global: null,\n onFieldAccess: ({ accessResult, path }) => {\n if (path === '_status') {\n statusFieldAccess = accessResult\n }\n },\n operation: 'create',\n overrideAccess: overrideAccess!,\n req,\n })\n\n const publicationHookDoc = buildAllLocalesPublicationHookDoc({\n doc: duplicatedFromDoc,\n docWithLocales: duplicatedFromDocWithLocales,\n status:\n statusFieldAccess && data._status === allLocalesPublicationStatus\n ? allLocalesPublicationStatus\n : undefined,\n })\n\n // /////////////////////////////////////\n // beforeValidate - Collections\n // /////////////////////////////////////\n\n if (collectionConfig.hooks.beforeValidate?.length) {\n for (const hook of collectionConfig.hooks.beforeValidate) {\n data =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n data,\n operation: 'create',\n originalDoc: publicationHookDoc,\n req,\n })) || data\n }\n }\n\n // /////////////////////////////////////\n // beforeChange - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.beforeChange?.length) {\n for (const hook of collectionConfig.hooks.beforeChange) {\n data =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n data,\n operation: 'create',\n originalDoc: publicationHookDoc,\n req,\n })) || data\n }\n }\n\n const publicationData = { ...data }\n\n // /////////////////////////////////////\n // beforeChange - Fields\n // /////////////////////////////////////\n\n let statusFieldValue: unknown\n const docWithLocalesForFields = !statusFieldAccess\n ? { ...duplicatedFromDocWithLocales, _status: {} }\n : duplicatedFromDocWithLocales\n\n const dataWithLocales = await beforeChange<JsonObject>({\n collection: collectionConfig,\n context: req.context,\n data,\n doc: publicationHookDoc,\n docWithLocales: docWithLocalesForFields,\n global: null,\n onDataProcessed: (processedData) => {\n statusFieldValue = processedData._status\n },\n operation: 'create',\n overrideAccess,\n req,\n skipValidation: isSavingDraft && !hasDraftValidationEnabled(collectionConfig),\n })\n\n const shouldApplyAllLocalesStatusChange = canApplyAllLocalesStatusChange({\n canUpdateStatus: statusFieldAccess,\n requestedStatus: allLocalesPublicationStatus,\n statusAfterDocumentHooks: publicationData._status,\n statusAfterFieldHooks: statusFieldValue,\n })\n\n if (\n allLocalesPublicationStatus &&\n !shouldApplyAllLocalesStatusChange &&\n statusFieldAccess &&\n typeof statusFieldValue === 'undefined' &&\n typeof duplicatedFromDocWithLocales._status === 'object' &&\n duplicatedFromDocWithLocales._status !== null\n ) {\n dataWithLocales._status = { ...duplicatedFromDocWithLocales._status }\n }\n\n // When locale='all' or when beforeChange doesn't convert the string (e.g. no locale hook ran),\n // the localized _status remains a plain string. Expand it to a per-locale object so MongoDB\n // doesn't reject the write. This covers both draft and non-draft operations.\n if (\n config.localization &&\n hasLocalizeStatusEnabled(collectionConfig) &&\n typeof dataWithLocales._status === 'string'\n ) {\n const statusStr = dataWithLocales._status\n\n if (\n shouldApplyAllLocalesStatusChange &&\n typeof duplicatedFromDocWithLocales._status === 'object' &&\n duplicatedFromDocWithLocales._status !== null\n ) {\n dataWithLocales._status = { ...duplicatedFromDocWithLocales._status }\n } else {\n dataWithLocales._status = {}\n }\n\n if (!shouldApplyAllLocalesStatusChange) {\n for (const localeCode of config.localization.localeCodes) {\n ;(dataWithLocales._status as Record<string, unknown>)[localeCode] = statusStr\n }\n }\n }\n\n if (\n config.localization &&\n hasLocalizeStatusEnabled(collectionConfig) &&\n shouldApplyAllLocalesStatusChange\n ) {\n let accessibleLocaleCodes = config.localization.localeCodes\n\n if (config.localization.filterAvailableLocales) {\n const filteredLocales = await config.localization.filterAvailableLocales({\n locales: config.localization.locales,\n req,\n })\n accessibleLocaleCodes = filteredLocales.map((locale) =>\n typeof locale === 'string' ? locale : locale.code,\n )\n }\n\n if (typeof dataWithLocales._status !== 'object' || dataWithLocales._status === null) {\n dataWithLocales._status = {}\n }\n\n for (const localeCode of accessibleLocaleCodes) {\n dataWithLocales._status[localeCode] = 'published'\n }\n }\n\n // Fill every locale of a localized slug so switching locales never lands on an empty slug. The\n // slug field hook only sees the active locale, so the rest are seeded here on create.\n if (config.localization) {\n await fillEmptyLocalizedSlugs({\n collection: collectionConfig,\n data: dataWithLocales,\n overrideAccess,\n req,\n })\n }\n\n if (\n config.localization &&\n hasDraftsEnabled(collectionConfig) &&\n publishAllLocales &&\n (!hasLocalizeStatusEnabled(collectionConfig) || shouldApplyAllLocalesStatusChange)\n ) {\n const validationResult = await validateLocalWithLocaleKeyedData({\n operation: 'create',\n options: {\n collection: collectionConfig.slug,\n data: dataWithLocales,\n locale: 'all',\n overrideAccess,\n req,\n },\n payload,\n })\n\n if (!validationResult.valid) {\n throw new ValidationError(\n {\n collection: collectionConfig.slug,\n errors: validationResult.errors,\n req,\n },\n req.t,\n )\n }\n }\n\n // /////////////////////////////////////\n // Write files to local storage\n // /////////////////////////////////////\n\n // /////////////////////////////////////\n // Create\n // /////////////////////////////////////\n\n const select = sanitizeSelect({\n fields: collectionConfig.flattenedFields,\n select: resolveSelect({\n config: collectionConfig.select,\n operation: 'create',\n req,\n select: incomingSelect,\n }),\n })\n\n const writeDocument = async () => {\n if (collectionConfig.auth && !collectionConfig.auth.disableLocalStrategy) {\n if (collectionConfig.auth.verify) {\n dataWithLocales._verified = Boolean(dataWithLocales._verified) || false\n dataWithLocales._verificationToken = crypto.randomBytes(20).toString('hex')\n }\n\n return registerLocalStrategy({\n collection: collectionConfig,\n doc: dataWithLocales,\n password: data.password as string,\n payload: req.payload,\n req,\n })\n }\n\n return payload.db.create({\n collection: collectionConfig.slug,\n data: dataWithLocales,\n req,\n })\n }\n\n const hasManagedLocalUpload =\n !collectionConfig.upload.disableLocalStorage &&\n filesToUpload.length > 0 &&\n Boolean(dataWithLocales.original)\n let doc\n\n if (\n collectionConfig.upload.fileOperations &&\n (filesToUpload.length > 0 || req.context?._payloadVerifiedProviderOriginal)\n ) {\n restoreCloudHookState = captureCloudHookState({ req })\n doc = await runCloudFileCreation({\n collection: collectionConfig,\n data: dataWithLocales,\n files: filesToUpload,\n req,\n write: writeDocument,\n })\n } else if (hasManagedLocalUpload) {\n doc = await runFileCreationPlan({\n cleanupStagedAfterWriteFailure: (objects) =>\n removeUnreferencedStagedObjects({ collection: collectionConfig, objects, req }),\n req,\n stage: ({ trackStagedObject }) =>\n stageLocalUploadFiles({\n files: filesToUpload,\n staticDir: collectionConfig.upload.staticDir!,\n trackStagedObject,\n }),\n write: writeDocument,\n })\n } else {\n if (!collectionConfig.upload.disableLocalStorage) {\n await uploadFiles(payload, filesToUpload, req)\n }\n doc = await writeDocument()\n }\n\n const verificationToken = doc._verificationToken\n let resultWithLocales: Document = sanitizeInternalFields(doc)\n\n // /////////////////////////////////////\n // Add collection property for auth collections\n // /////////////////////////////////////\n\n if (collectionConfig.auth) {\n resultWithLocales = { ...resultWithLocales, collection: collectionConfig.slug }\n }\n\n // /////////////////////////////////////\n // Create version\n // /////////////////////////////////////\n\n if (collectionConfig.versions) {\n await saveVersion({\n id: resultWithLocales.id,\n autosave,\n collection: collectionConfig,\n docWithLocales: resultWithLocales,\n operation: 'create',\n payload,\n req,\n returning: false,\n })\n }\n\n // /////////////////////////////////////\n // Send verification email if applicable\n // /////////////////////////////////////\n\n if (collectionConfig.auth && collectionConfig.auth.verify && resultWithLocales.email) {\n await sendVerificationEmail({\n collection: { config: collectionConfig },\n config: payload.config,\n disableEmail: disableVerificationEmail!,\n email: payload.email,\n req,\n token: verificationToken,\n user: resultWithLocales,\n })\n }\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n let result: Document = await afterRead({\n collection: collectionConfig,\n context: req.context,\n depth: depth!,\n doc: resultWithLocales,\n draft,\n fallbackLocale: fallbackLocale!,\n global: null,\n locale: locale!,\n overrideAccess: overrideAccess!,\n populate,\n req,\n select,\n showHiddenFields: showHiddenFields!,\n })\n\n // /////////////////////////////////////\n // afterRead - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.afterRead?.length) {\n for (const hook of collectionConfig.hooks.afterRead) {\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: result,\n overrideAccess,\n req,\n })) || result\n }\n }\n\n // /////////////////////////////////////\n // afterChange - Fields\n // /////////////////////////////////////\n\n result = await afterChange({\n collection: collectionConfig,\n context: req.context,\n data,\n doc: result,\n global: null,\n operation: 'create',\n previousDoc: {},\n req,\n })\n\n // /////////////////////////////////////\n // afterChange - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.afterChange?.length) {\n for (const hook of collectionConfig.hooks.afterChange) {\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n data,\n doc: result,\n operation: 'create',\n overrideAccess,\n previousDoc: {},\n req: args.req,\n select,\n })) || result\n }\n }\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n result = await buildAfterOperation<TSlug>({\n args,\n collection: collectionConfig,\n operation: 'create',\n overrideAccess: args.overrideAccess!,\n result,\n })\n\n await unlinkTempFiles({ collectionConfig, config, req }).catch((unlinkError) => {\n req.payload.logger.error({ err: unlinkError, msg: 'Failed to remove temp file' })\n })\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n if (shouldCommit) {\n await commitTransaction(req)\n }\n\n if (hasFileOperationScope) {\n await completeFileOperationScope({ req })\n }\n\n return result\n } catch (error: unknown) {\n await unlinkTempFiles({\n collectionConfig: args.collection.config,\n config: args.req.payload.config,\n req: args.req,\n }).catch((unlinkError) => {\n args.req.payload.logger.error({ err: unlinkError, msg: 'Failed to remove temp file' })\n })\n await killTransaction(args.req)\n if (hasFileOperationScope) {\n await abortFileOperationScope({ req: args.req })\n }\n throw error\n } finally {\n restoreCloudHookState?.()\n }\n}\n"],"names":["crypto","ensureUsernameOrEmail","executeAccess","sendVerificationEmail","registerLocalStrategy","getDuplicateDocumentData","APIError","ValidationError","fillEmptyLocalizedSlugs","afterChange","afterRead","beforeChange","beforeValidate","saveVersion","removeUnreferencedStagedObjects","captureCloudHookState","runCloudFileCreation","abortFileOperationScope","beginFileOperationScope","completeFileOperationScope","runFileCreationPlan","stageLocalUploadFiles","generateFileData","getExternalUploadSource","getUploadDestination","sanitizeUploadData","unlinkTempFiles","uploadFiles","assertNoValidationWrite","commitTransaction","hasDraftsEnabled","hasDraftValidationEnabled","hasLocalizeStatusEnabled","initTransaction","killTransaction","resolvePublishAllLocales","resolveSelect","sanitizeInternalFields","sanitizeSelect","buildAllLocalesPublicationHookDoc","canApplyAllLocalesStatusChange","getAllLocalesPublicationStatus","normalizeAllLocalesPublicationStatus","reconcileAllLocalesPublicationStatus","validateLocalWithLocaleKeyedData","buildAfterOperation","buildBeforeOperation","createOperation","incomingArgs","args","externalUploadSource","restoreCloudHookState","hasFileOperationScope","Boolean","collection","config","upload","req","shouldCommit","disableTransaction","overrideAccess","data","objectKey","prefix","file","sanitizedData","undefined","_objectKey","initialCollectionConfig","initialPublishAllLocales","draft","publishAllLocalesArg","publishAllLocales","initialAllLocalesPublicationStatus","hasLocalizedStatus","payload","localization","unpublishAllLocales","initialAllLocalesPublicationIntent","status","authOptions","auth","collectionSlug","slug","operation","autosave","collectionConfig","depth","disableVerificationEmail","duplicateFromID","overwriteExistingFiles","populate","fallbackLocale","locale","select","incomingSelect","selectedLocales","showHiddenFields","requestedAllLocalesPublicationStatus","allLocalesPublicationStatus","intent","isSavingDraft","_status","isDuplicating","disableDuplicate","String","duplicatedFromDocWithLocales","duplicatedFromDoc","duplicateResult","id","draftArg","access","create","newFileData","files","filesToUpload","originalDoc","throwOnMissingFile","filesRequiredOnCreate","statusFieldAccess","publicationFieldPolicyDoc","doc","docWithLocales","context","docForHooks","global","onFieldAccess","accessResult","path","publicationHookDoc","hooks","length","hook","publicationData","statusFieldValue","docWithLocalesForFields","dataWithLocales","onDataProcessed","processedData","skipValidation","shouldApplyAllLocalesStatusChange","canUpdateStatus","requestedStatus","statusAfterDocumentHooks","statusAfterFieldHooks","statusStr","localeCode","localeCodes","accessibleLocaleCodes","filterAvailableLocales","filteredLocales","locales","map","code","validationResult","options","valid","errors","t","fields","flattenedFields","writeDocument","disableLocalStrategy","verify","_verified","_verificationToken","randomBytes","toString","password","db","hasManagedLocalUpload","disableLocalStorage","original","fileOperations","_payloadVerifiedProviderOriginal","write","cleanupStagedAfterWriteFailure","objects","stage","trackStagedObject","staticDir","verificationToken","resultWithLocales","versions","returning","email","disableEmail","token","user","result","previousDoc","catch","unlinkError","logger","error","err","msg"],"mappings":"AAAA,OAAOA,YAAY,SAAQ;AAiB3B,SAASC,qBAAqB,QAAQ,sCAAqC;AAC3E,SAASC,aAAa,QAAQ,8BAA6B;AAC3D,SAASC,qBAAqB,QAAQ,sCAAqC;A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OAAO;oBACpB9D;oBACA4D,KAAKoE;oBACLzG,WAAW;oBACXxB;oBACAkI,aAAa,CAAC;oBACdrI,KAAKR,KAAKQ,GAAG;oBACbqC;gBACF,MAAO+F;YACX;QACF;QAEA,wCAAwC;QACxC,8BAA8B;QAC9B,wCAAwC;QAExCA,SAAS,MAAMhJ,oBAA2B;YACxCI;YACAK,YAAYgC;YACZF,WAAW;YACXxB,gBAAgBX,KAAKW,cAAc;YACnCiI;QACF;QAEA,MAAMnK,gBAAgB;YAAE4D;YAAkB/B;YAAQE;QAAI,GAAGsI,KAAK,CAAC,CAACC;YAC9DvI,IAAIkB,OAAO,CAACsH,MAAM,CAACC,KAAK,CAAC;gBAAEC,KAAKH;gBAAaI,KAAK;YAA6B;QACjF;QAEA,wCAAwC;QACxC,iBAAiB;QACjB,wCAAwC;QAExC,IAAI1I,cAAc;YAChB,MAAM7B,kBAAkB4B;QAC1B;QAEA,IAAIL,uBAAuB;YACzB,MAAMjC,2BAA2B;gBAAEsC;YAAI;QACzC;QAEA,OAAOoI;IACT,EAAE,OAAOK,OAAgB;QACvB,MAAMxK,gBAAgB;YACpB4D,kBAAkBrC,KAAKK,UAAU,CAACC,MAAM;YACxCA,QAAQN,KAAKQ,GAAG,CAACkB,OAAO,CAACpB,MAAM;YAC/BE,KAAKR,KAAKQ,GAAG;QACf,GAAGsI,KAAK,CAAC,CAACC;YACR/I,KAAKQ,GAAG,CAACkB,OAAO,CAACsH,MAAM,CAACC,KAAK,CAAC;gBAAEC,KAAKH;gBAAaI,KAAK;YAA6B;QACtF;QACA,MAAMlK,gBAAgBe,KAAKQ,GAAG;QAC9B,IAAIL,uBAAuB;YACzB,MAAMnC,wBAAwB;gBAAEwC,KAAKR,KAAKQ,GAAG;YAAC;QAChD;QACA,MAAMyI;IACR,SAAU;QACR/I;IACF;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"findByID.d.ts","sourceRoot":"","sources":["../../../src/collections/operations/findByID.ts"],"names":[],"mappings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B,GAC5B,KAAK,SAAS,cAAc,EAC5B,cAAc,SAAS,OAAO,EAC9B,OAAO,SAAS,wBAAwB,CAAC,KAAK,CAAC,gBAEjC,YAAY,KACzB,OAAO,CAAC,kBAAkB,CAAC,6BAA6B,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,cAAc,CAAC,CAoV3F,CAAA"}
@@ -107,9 +107,7 @@ export const findByIDOperation = async (incomingArgs)=>{
107
107
  draftsEnabled: replaceWithVersion,
108
108
  joins: req.payloadAPI === 'GraphQL' ? false : sanitizedJoins,
109
109
  locale: locale,
110
- req: {
111
- transactionID: req.transactionID
112
- },
110
+ req,
113
111
  select: dbSelect,
114
112
  where: fullWhere
115
113
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/collections/operations/findByID.ts"],"sourcesContent":["import type { FindOneArgs } from '../../database/types.js'\nimport type { CollectionSlug, FindOptions, JoinQuery } from '../../index.js'\nimport type {\n ApplyDisableErrors,\n JsonObject,\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformCollectionWithSelect,\n} from '../../types/index.js'\nimport type {\n Collection,\n DataFromCollectionSlug,\n SelectFromCollectionSlug,\n TypeWithID,\n} from '../config/types.js'\n\nimport { executeAccess } from '../../auth/executeAccess.js'\nimport { combineQueries } from '../../database/combineQueries.js'\nimport { sanitizeJoinQuery } from '../../database/sanitizeJoinQuery.js'\nimport { sanitizeWhereQuery } from '../../database/sanitizeWhereQuery.js'\nimport { NotFound } from '../../errors/index.js'\nimport { afterRead, type AfterReadArgs } from '../../fields/hooks/afterRead/index.js'\nimport { validateQueryPaths } from '../../index.js'\nimport { lockedDocumentsCollectionSlug } from '../../locked-documents/config.js'\nimport { appendNonTrashedFilter } from '../../utilities/appendNonTrashedFilter.js'\nimport { getSelectMode } from '../../utilities/getSelectMode.js'\nimport { hasDraftsEnabled } from '../../utilities/getVersionsConfig.js'\nimport { resolveSelect } from '../../utilities/resolveSelect.js'\nimport { sanitizeSelect } from '../../utilities/sanitizeSelect.js'\nimport { buildVersionCollectionFields } from '../../versions/buildCollectionFields.js'\nimport { appendVersionToQueryKey } from '../../versions/drafts/appendVersionToQueryKey.js'\nimport { getQueryDraftsSelect } from '../../versions/drafts/getQueryDraftsSelect.js'\nimport { replaceWithDraftIfAvailable } from '../../versions/drafts/replaceWithDraftIfAvailable.js'\nimport { buildAfterOperation } from './utilities/buildAfterOperation.js'\nimport { buildBeforeOperation } from './utilities/buildBeforeOperation.js'\n\nexport type FindByIDArgs = {\n collection: Collection\n currentDepth?: number\n /**\n * You may pass the document data directly which will skip the `db.findOne` database query.\n * This is useful if you want to use this endpoint solely for running hooks and populating data.\n */\n data?: Record<string, unknown>\n depth?: number\n disableErrors?: boolean\n draft?: boolean\n id: number | string\n includeLockStatus?: boolean\n joins?: JoinQuery\n overrideAccess?: boolean\n populate?: PopulateType\n req: PayloadRequest\n showHiddenFields?: boolean\n trash?: boolean\n} & Pick<AfterReadArgs<JsonObject>, 'flattenLocales'> &\n Pick<FindOptions<string, SelectType>, 'select'>\n\nexport const findByIDOperation = async <\n TSlug extends CollectionSlug,\n TDisableErrors extends boolean,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n>(\n incomingArgs: FindByIDArgs,\n): Promise<ApplyDisableErrors<TransformCollectionWithSelect<TSlug, TSelect>, TDisableErrors>> => {\n let args = incomingArgs\n\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n args = await buildBeforeOperation({\n args,\n collection: args.collection.config,\n operation: 'read',\n overrideAccess: args.overrideAccess!,\n })\n\n const {\n id,\n collection: { config: collectionConfig },\n currentDepth,\n depth,\n disableErrors,\n draft: replaceWithVersion = false,\n flattenLocales,\n includeLockStatus: includeLockStatusFromArgs,\n joins,\n overrideAccess = false,\n populate,\n req: { fallbackLocale, locale, t },\n req,\n select: incomingSelect,\n showHiddenFields,\n trash = false,\n } = args\n\n const includeLockStatus =\n includeLockStatusFromArgs && req.payload.collections?.[lockedDocumentsCollectionSlug]\n\n const select = sanitizeSelect({\n fields: collectionConfig.flattenedFields,\n select: resolveSelect({\n config: collectionConfig.select,\n operation: 'read',\n req,\n select: incomingSelect,\n }),\n })\n\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n const accessResult = !overrideAccess\n ? await executeAccess(\n { id, slug: collectionConfig.slug, disableErrors, req },\n collectionConfig.access.read,\n )\n : true\n\n // If errors are disabled, and access returns false, return null\n if (accessResult === false) {\n return null!\n }\n\n const isValidID =\n (typeof id === 'string' && id.length > 0) || (typeof id === 'number' && Number.isFinite(id))\n\n if (!isValidID) {\n throw new NotFound(t)\n }\n\n const where = { id: { equals: id } }\n\n let fullWhere = combineQueries(where, accessResult)\n\n // Exclude trashed documents when trash: false\n fullWhere = appendNonTrashedFilter({\n enableTrash: collectionConfig.trash,\n trash,\n where: fullWhere,\n })\n\n sanitizeWhereQuery({\n fields: collectionConfig.flattenedFields,\n payload: args.req.payload,\n where: fullWhere,\n })\n\n const sanitizedJoins = await sanitizeJoinQuery({\n collectionConfig,\n joins,\n overrideAccess,\n req,\n })\n\n // execute only if there's a custom ID and potentially overwriten access on id\n if (req.payload.collections[collectionConfig.slug]!.customIDType) {\n await validateQueryPaths({\n collectionConfig,\n overrideAccess,\n req,\n where,\n })\n }\n\n // /////////////////////////////////////\n // Find by ID\n // /////////////////////////////////////\n\n const shouldQueryDrafts = !args.data && replaceWithVersion && hasDraftsEnabled(collectionConfig)\n let docWithLocales: DataFromCollectionSlug<TSlug> | null | undefined\n let query = fullWhere\n\n let dbSelect = select\n\n if (\n collectionConfig.versions?.drafts &&\n replaceWithVersion &&\n select &&\n getSelectMode(select) === 'include'\n ) {\n dbSelect = { ...select, createdAt: true, updatedAt: true }\n }\n\n const findOneArgs: FindOneArgs = {\n collection: collectionConfig.slug,\n draftsEnabled: replaceWithVersion,\n joins: req.payloadAPI === 'GraphQL' ? false : sanitizedJoins,\n locale: locale!,\n req: {\n transactionID: req.transactionID,\n },\n select: dbSelect,\n where: fullWhere,\n }\n\n if (shouldQueryDrafts) {\n query = appendVersionToQueryKey(fullWhere)\n\n await validateQueryPaths({\n collectionConfig,\n overrideAccess,\n req,\n versionFields: buildVersionCollectionFields(req.payload.config, collectionConfig, true),\n where: appendVersionToQueryKey(where),\n })\n\n const { docs } = await req.payload.db.queryDrafts<DataFromCollectionSlug<TSlug>>({\n collection: collectionConfig.slug,\n joins: req.payloadAPI === 'GraphQL' ? false : sanitizedJoins,\n limit: 1,\n locale: locale!,\n pagination: false,\n req,\n select: getQueryDraftsSelect({ select }),\n where: query,\n })\n\n docWithLocales = docs[0]\n\n if (!docWithLocales) {\n const { docs: existingVersions } = await req.payload.db.queryDrafts({\n collection: collectionConfig.slug,\n limit: 1,\n locale: locale!,\n pagination: false,\n req,\n select: { parent: true },\n where: appendVersionToQueryKey(where),\n })\n\n if (!existingVersions[0]) {\n query = fullWhere\n docWithLocales = await req.payload.db.findOne(findOneArgs)\n }\n }\n } else {\n docWithLocales = await req.payload.db.findOne(findOneArgs)\n }\n\n if (!docWithLocales && !args.data) {\n if (!disableErrors) {\n throw new NotFound(req.t)\n }\n return null!\n }\n\n let result: DataFromCollectionSlug<TSlug> =\n (args.data as DataFromCollectionSlug<TSlug>) ?? docWithLocales!\n\n // /////////////////////////////////////\n // Add collection property for auth collections\n // /////////////////////////////////////\n\n if (collectionConfig.auth) {\n result = { ...result, collection: collectionConfig.slug }\n }\n\n // /////////////////////////////////////\n // Include Lock Status if required\n // /////////////////////////////////////\n\n if (includeLockStatus && id) {\n let lockStatus: (JsonObject & TypeWithID) | null = null\n\n try {\n const lockDocumentsProp = collectionConfig?.lockDocuments\n\n const lockDurationDefault = 300 // Default 5 minutes in seconds\n const lockDuration =\n typeof lockDocumentsProp === 'object' ? lockDocumentsProp.duration : lockDurationDefault\n const lockDurationInMilliseconds = lockDuration * 1000\n\n const lockedDocument = await req.payload.find({\n collection: lockedDocumentsCollectionSlug,\n depth: 1,\n limit: 1,\n overrideAccess: false,\n pagination: false,\n req,\n where: {\n and: [\n {\n 'document.relationTo': {\n equals: collectionConfig.slug,\n },\n },\n {\n 'document.value': {\n equals: id,\n },\n },\n // Query where the lock is newer than the current time minus lock time\n {\n updatedAt: {\n greater_than: new Date(new Date().getTime() - lockDurationInMilliseconds),\n },\n },\n ],\n },\n })\n\n if (lockedDocument && lockedDocument.docs.length > 0) {\n lockStatus = lockedDocument.docs[0]!\n }\n } catch {\n // swallow error\n }\n\n result._isLocked = !!lockStatus\n result._userEditing = lockStatus?.user?.value ?? null\n }\n\n // /////////////////////////////////////\n // Replace document with draft if available\n // /////////////////////////////////////\n\n if (!shouldQueryDrafts && replaceWithVersion && hasDraftsEnabled(collectionConfig)) {\n result = await replaceWithDraftIfAvailable({\n accessResult,\n doc: result,\n entity: collectionConfig,\n entityType: 'collection',\n overrideAccess,\n req,\n select,\n })\n }\n\n // /////////////////////////////////////\n // beforeRead - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.beforeRead?.length) {\n for (const hook of collectionConfig.hooks.beforeRead) {\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: result,\n overrideAccess,\n query,\n req,\n })) || result\n }\n }\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n result = await afterRead({\n collection: collectionConfig,\n context: req.context,\n currentDepth,\n depth: depth!,\n doc: result,\n draft: replaceWithVersion,\n fallbackLocale: fallbackLocale!,\n flattenLocales,\n global: null,\n locale: locale!,\n overrideAccess,\n populate,\n req,\n select,\n showHiddenFields: showHiddenFields!,\n })\n\n // /////////////////////////////////////\n // afterRead - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.afterRead?.length) {\n for (const hook of collectionConfig.hooks.afterRead) {\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: result,\n overrideAccess,\n query,\n req,\n })) || result\n }\n }\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n result = await buildAfterOperation({\n args,\n collection: collectionConfig,\n operation: 'findByID',\n overrideAccess,\n result,\n })\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n return result as ApplyDisableErrors<TransformCollectionWithSelect<TSlug, TSelect>, TDisableErrors>\n}\n"],"names":["executeAccess","combineQueries","sanitizeJoinQuery","sanitizeWhereQuery","NotFound","afterRead","validateQueryPaths","lockedDocumentsCollectionSlug","appendNonTrashedFilter","getSelectMode","hasDraftsEnabled","resolveSelect","sanitizeSelect","buildVersionCollectionFields","appendVersionToQueryKey","getQueryDraftsSelect","replaceWithDraftIfAvailable","buildAfterOperation","buildBeforeOperation","findByIDOperation","incomingArgs","args","collection","config","operation","overrideAccess","id","collectionConfig","currentDepth","depth","disableErrors","draft","replaceWithVersion","flattenLocales","includeLockStatus","includeLockStatusFromArgs","joins","populate","req","fallbackLocale","locale","t","select","incomingSelect","showHiddenFields","trash","payload","collections","fields","flattenedFields","accessResult","slug","access","read","isValidID","length","Number","isFinite","where","equals","fullWhere","enableTrash","sanitizedJoins","customIDType","shouldQueryDrafts","data","docWithLocales","query","dbSelect","versions","drafts","createdAt","updatedAt","findOneArgs","draftsEnabled","payloadAPI","transactionID","versionFields","docs","db","queryDrafts","limit","pagination","existingVersions","parent","findOne","result","auth","lockStatus","lockDocumentsProp","lockDocuments","lockDurationDefault","lockDuration","duration","lockDurationInMilliseconds","lockedDocument","find","and","greater_than","Date","getTime","_isLocked","_userEditing","user","value","doc","entity","entityType","hooks","beforeRead","hook","context","global"],"mappings":"AAiBA,SAASA,aAAa,QAAQ,8BAA6B;AAC3D,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,iBAAiB,QAAQ,sCAAqC;AACvE,SAASC,kBAAkB,QAAQ,uCAAsC;AACzE,SAASC,QAAQ,QAAQ,wBAAuB;AAChD,SAASC,SAAS,QAA4B,wCAAuC;AACrF,SAASC,kBAAkB,QAAQ,iBAAgB;AACnD,SAASC,6BAA6B,QAAQ,mCAAkC;AAChF,SAASC,sBAAsB,QAAQ,4CAA2C;AAClF,SAASC,aAA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AC9B,wCAAwC;IAExCA,SAAS,MAAMrE,oBAAoB;QACjCI;QACAC,YAAYK;QACZH,WAAW;QACXC;QACA6D;IACF;IAEA,wCAAwC;IACxC,iBAAiB;IACjB,wCAAwC;IAExC,OAAOA;AACT,EAAC"}
1
+ {"version":3,"sources":["../../../src/collections/operations/findByID.ts"],"sourcesContent":["import type { FindOneArgs } from '../../database/types.js'\nimport type { CollectionSlug, FindOptions, JoinQuery } from '../../index.js'\nimport type {\n ApplyDisableErrors,\n JsonObject,\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformCollectionWithSelect,\n} from '../../types/index.js'\nimport type {\n Collection,\n DataFromCollectionSlug,\n SelectFromCollectionSlug,\n TypeWithID,\n} from '../config/types.js'\n\nimport { executeAccess } from '../../auth/executeAccess.js'\nimport { combineQueries } from '../../database/combineQueries.js'\nimport { sanitizeJoinQuery } from '../../database/sanitizeJoinQuery.js'\nimport { sanitizeWhereQuery } from '../../database/sanitizeWhereQuery.js'\nimport { NotFound } from '../../errors/index.js'\nimport { afterRead, type AfterReadArgs } from '../../fields/hooks/afterRead/index.js'\nimport { validateQueryPaths } from '../../index.js'\nimport { lockedDocumentsCollectionSlug } from '../../locked-documents/config.js'\nimport { appendNonTrashedFilter } from '../../utilities/appendNonTrashedFilter.js'\nimport { getSelectMode } from '../../utilities/getSelectMode.js'\nimport { hasDraftsEnabled } from '../../utilities/getVersionsConfig.js'\nimport { resolveSelect } from '../../utilities/resolveSelect.js'\nimport { sanitizeSelect } from '../../utilities/sanitizeSelect.js'\nimport { buildVersionCollectionFields } from '../../versions/buildCollectionFields.js'\nimport { appendVersionToQueryKey } from '../../versions/drafts/appendVersionToQueryKey.js'\nimport { getQueryDraftsSelect } from '../../versions/drafts/getQueryDraftsSelect.js'\nimport { replaceWithDraftIfAvailable } from '../../versions/drafts/replaceWithDraftIfAvailable.js'\nimport { buildAfterOperation } from './utilities/buildAfterOperation.js'\nimport { buildBeforeOperation } from './utilities/buildBeforeOperation.js'\n\nexport type FindByIDArgs = {\n collection: Collection\n currentDepth?: number\n /**\n * You may pass the document data directly which will skip the `db.findOne` database query.\n * This is useful if you want to use this endpoint solely for running hooks and populating data.\n */\n data?: Record<string, unknown>\n depth?: number\n disableErrors?: boolean\n draft?: boolean\n id: number | string\n includeLockStatus?: boolean\n joins?: JoinQuery\n overrideAccess?: boolean\n populate?: PopulateType\n req: PayloadRequest\n showHiddenFields?: boolean\n trash?: boolean\n} & Pick<AfterReadArgs<JsonObject>, 'flattenLocales'> &\n Pick<FindOptions<string, SelectType>, 'select'>\n\nexport const findByIDOperation = async <\n TSlug extends CollectionSlug,\n TDisableErrors extends boolean,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n>(\n incomingArgs: FindByIDArgs,\n): Promise<ApplyDisableErrors<TransformCollectionWithSelect<TSlug, TSelect>, TDisableErrors>> => {\n let args = incomingArgs\n\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n args = await buildBeforeOperation({\n args,\n collection: args.collection.config,\n operation: 'read',\n overrideAccess: args.overrideAccess!,\n })\n\n const {\n id,\n collection: { config: collectionConfig },\n currentDepth,\n depth,\n disableErrors,\n draft: replaceWithVersion = false,\n flattenLocales,\n includeLockStatus: includeLockStatusFromArgs,\n joins,\n overrideAccess = false,\n populate,\n req: { fallbackLocale, locale, t },\n req,\n select: incomingSelect,\n showHiddenFields,\n trash = false,\n } = args\n\n const includeLockStatus =\n includeLockStatusFromArgs && req.payload.collections?.[lockedDocumentsCollectionSlug]\n\n const select = sanitizeSelect({\n fields: collectionConfig.flattenedFields,\n select: resolveSelect({\n config: collectionConfig.select,\n operation: 'read',\n req,\n select: incomingSelect,\n }),\n })\n\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n const accessResult = !overrideAccess\n ? await executeAccess(\n { id, slug: collectionConfig.slug, disableErrors, req },\n collectionConfig.access.read,\n )\n : true\n\n // If errors are disabled, and access returns false, return null\n if (accessResult === false) {\n return null!\n }\n\n const isValidID =\n (typeof id === 'string' && id.length > 0) || (typeof id === 'number' && Number.isFinite(id))\n\n if (!isValidID) {\n throw new NotFound(t)\n }\n\n const where = { id: { equals: id } }\n\n let fullWhere = combineQueries(where, accessResult)\n\n // Exclude trashed documents when trash: false\n fullWhere = appendNonTrashedFilter({\n enableTrash: collectionConfig.trash,\n trash,\n where: fullWhere,\n })\n\n sanitizeWhereQuery({\n fields: collectionConfig.flattenedFields,\n payload: args.req.payload,\n where: fullWhere,\n })\n\n const sanitizedJoins = await sanitizeJoinQuery({\n collectionConfig,\n joins,\n overrideAccess,\n req,\n })\n\n // execute only if there's a custom ID and potentially overwriten access on id\n if (req.payload.collections[collectionConfig.slug]!.customIDType) {\n await validateQueryPaths({\n collectionConfig,\n overrideAccess,\n req,\n where,\n })\n }\n\n // /////////////////////////////////////\n // Find by ID\n // /////////////////////////////////////\n\n const shouldQueryDrafts = !args.data && replaceWithVersion && hasDraftsEnabled(collectionConfig)\n let docWithLocales: DataFromCollectionSlug<TSlug> | null | undefined\n let query = fullWhere\n\n let dbSelect = select\n\n if (\n collectionConfig.versions?.drafts &&\n replaceWithVersion &&\n select &&\n getSelectMode(select) === 'include'\n ) {\n dbSelect = { ...select, createdAt: true, updatedAt: true }\n }\n\n const findOneArgs: FindOneArgs = {\n collection: collectionConfig.slug,\n draftsEnabled: replaceWithVersion,\n joins: req.payloadAPI === 'GraphQL' ? false : sanitizedJoins,\n locale: locale!,\n req,\n select: dbSelect,\n where: fullWhere,\n }\n\n if (shouldQueryDrafts) {\n query = appendVersionToQueryKey(fullWhere)\n\n await validateQueryPaths({\n collectionConfig,\n overrideAccess,\n req,\n versionFields: buildVersionCollectionFields(req.payload.config, collectionConfig, true),\n where: appendVersionToQueryKey(where),\n })\n\n const { docs } = await req.payload.db.queryDrafts<DataFromCollectionSlug<TSlug>>({\n collection: collectionConfig.slug,\n joins: req.payloadAPI === 'GraphQL' ? false : sanitizedJoins,\n limit: 1,\n locale: locale!,\n pagination: false,\n req,\n select: getQueryDraftsSelect({ select }),\n where: query,\n })\n\n docWithLocales = docs[0]\n\n if (!docWithLocales) {\n const { docs: existingVersions } = await req.payload.db.queryDrafts({\n collection: collectionConfig.slug,\n limit: 1,\n locale: locale!,\n pagination: false,\n req,\n select: { parent: true },\n where: appendVersionToQueryKey(where),\n })\n\n if (!existingVersions[0]) {\n query = fullWhere\n docWithLocales = await req.payload.db.findOne(findOneArgs)\n }\n }\n } else {\n docWithLocales = await req.payload.db.findOne(findOneArgs)\n }\n\n if (!docWithLocales && !args.data) {\n if (!disableErrors) {\n throw new NotFound(req.t)\n }\n return null!\n }\n\n let result: DataFromCollectionSlug<TSlug> =\n (args.data as DataFromCollectionSlug<TSlug>) ?? docWithLocales!\n\n // /////////////////////////////////////\n // Add collection property for auth collections\n // /////////////////////////////////////\n\n if (collectionConfig.auth) {\n result = { ...result, collection: collectionConfig.slug }\n }\n\n // /////////////////////////////////////\n // Include Lock Status if required\n // /////////////////////////////////////\n\n if (includeLockStatus && id) {\n let lockStatus: (JsonObject & TypeWithID) | null = null\n\n try {\n const lockDocumentsProp = collectionConfig?.lockDocuments\n\n const lockDurationDefault = 300 // Default 5 minutes in seconds\n const lockDuration =\n typeof lockDocumentsProp === 'object' ? lockDocumentsProp.duration : lockDurationDefault\n const lockDurationInMilliseconds = lockDuration * 1000\n\n const lockedDocument = await req.payload.find({\n collection: lockedDocumentsCollectionSlug,\n depth: 1,\n limit: 1,\n overrideAccess: false,\n pagination: false,\n req,\n where: {\n and: [\n {\n 'document.relationTo': {\n equals: collectionConfig.slug,\n },\n },\n {\n 'document.value': {\n equals: id,\n },\n },\n // Query where the lock is newer than the current time minus lock time\n {\n updatedAt: {\n greater_than: new Date(new Date().getTime() - lockDurationInMilliseconds),\n },\n },\n ],\n },\n })\n\n if (lockedDocument && lockedDocument.docs.length > 0) {\n lockStatus = lockedDocument.docs[0]!\n }\n } catch {\n // swallow error\n }\n\n result._isLocked = !!lockStatus\n result._userEditing = lockStatus?.user?.value ?? null\n }\n\n // /////////////////////////////////////\n // Replace document with draft if available\n // /////////////////////////////////////\n\n if (!shouldQueryDrafts && replaceWithVersion && hasDraftsEnabled(collectionConfig)) {\n result = await replaceWithDraftIfAvailable({\n accessResult,\n doc: result,\n entity: collectionConfig,\n entityType: 'collection',\n overrideAccess,\n req,\n select,\n })\n }\n\n // /////////////////////////////////////\n // beforeRead - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.beforeRead?.length) {\n for (const hook of collectionConfig.hooks.beforeRead) {\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: result,\n overrideAccess,\n query,\n req,\n })) || result\n }\n }\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n result = await afterRead({\n collection: collectionConfig,\n context: req.context,\n currentDepth,\n depth: depth!,\n doc: result,\n draft: replaceWithVersion,\n fallbackLocale: fallbackLocale!,\n flattenLocales,\n global: null,\n locale: locale!,\n overrideAccess,\n populate,\n req,\n select,\n showHiddenFields: showHiddenFields!,\n })\n\n // /////////////////////////////////////\n // afterRead - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.afterRead?.length) {\n for (const hook of collectionConfig.hooks.afterRead) {\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: result,\n overrideAccess,\n query,\n req,\n })) || result\n }\n }\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n result = await buildAfterOperation({\n args,\n collection: collectionConfig,\n operation: 'findByID',\n overrideAccess,\n result,\n })\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n return result as ApplyDisableErrors<TransformCollectionWithSelect<TSlug, TSelect>, TDisableErrors>\n}\n"],"names":["executeAccess","combineQueries","sanitizeJoinQuery","sanitizeWhereQuery","NotFound","afterRead","validateQueryPaths","lockedDocumentsCollectionSlug","appendNonTrashedFilter","getSelectMode","hasDraftsEnabled","resolveSelect","sanitizeSelect","buildVersionCollectionFields","appendVersionToQueryKey","getQueryDraftsSelect","replaceWithDraftIfAvailable","buildAfterOperation","buildBeforeOperation","findByIDOperation","incomingArgs","args","collection","config","operation","overrideAccess","id","collectionConfig","currentDepth","depth","disableErrors","draft","replaceWithVersion","flattenLocales","includeLockStatus","includeLockStatusFromArgs","joins","populate","req","fallbackLocale","locale","t","select","incomingSelect","showHiddenFields","trash","payload","collections","fields","flattenedFields","accessResult","slug","access","read","isValidID","length","Number","isFinite","where","equals","fullWhere","enableTrash","sanitizedJoins","customIDType","shouldQueryDrafts","data","docWithLocales","query","dbSelect","versions","drafts","createdAt","updatedAt","findOneArgs","draftsEnabled","payloadAPI","versionFields","docs","db","queryDrafts","limit","pagination","existingVersions","parent","findOne","result","auth","lockStatus","lockDocumentsProp","lockDocuments","lockDurationDefault","lockDuration","duration","lockDurationInMilliseconds","lockedDocument","find","and","greater_than","Date","getTime","_isLocked","_userEditing","user","value","doc","entity","entityType","hooks","beforeRead","hook","context","global"],"mappings":"AAiBA,SAASA,aAAa,QAAQ,8BAA6B;AAC3D,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,iBAAiB,QAAQ,sCAAqC;AACvE,SAASC,kBAAkB,QAAQ,uCAAsC;AACzE,SAASC,QAAQ,QAAQ,wBAAuB;AAChD,SAASC,SAAS,QAA4B,wCAAuC;AACrF,SAASC,kBAAkB,QAAQ,iBAAgB;AACnD,SAASC,6BAA6B,QAAQ,mCAAkC;AAChF,SAASC,sBAAsB,QAAQ,4CAA2C;AAClF,SAASC,aAAa,QAAQ,mCAAkC;AAChE,SAASC,gBAAgB,QAAQ,uCAAsC;AACvE,SAASC,aAAa,QAAQ,mCAAkC;AAChE,SAASC,cAAc,QAAQ,oCAAmC;AAClE,SAASC,4BAA4B,QAAQ,0CAAyC;AACtF,SAASC,uBAAuB,QAAQ,mDAAkD;AAC1F,SAASC,oBAAoB,QAAQ,gDAA+C;AACpF,SAASC,2BAA2B,QAAQ,uDAAsD;AAClG,SAASC,mBAAmB,QAAQ,qCAAoC;AACxE,SAAS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wCAAwC;IAExC,IAAIf,iBAAiBgF,KAAK,EAAEC,YAAYrD,QAAQ;QAC9C,KAAK,MAAMsD,QAAQlF,iBAAiBgF,KAAK,CAACC,UAAU,CAAE;YACpDvB,SACE,AAAC,MAAMwB,KAAK;gBACVvF,YAAYK;gBACZmF,SAASxE,IAAIwE,OAAO;gBACpBN,KAAKnB;gBACL5D;gBACA0C;gBACA7B;YACF,MAAO+C;QACX;IACF;IAEA,wCAAwC;IACxC,qBAAqB;IACrB,wCAAwC;IAExCA,SAAS,MAAMhF,UAAU;QACvBiB,YAAYK;QACZmF,SAASxE,IAAIwE,OAAO;QACpBlF;QACAC,OAAOA;QACP2E,KAAKnB;QACLtD,OAAOC;QACPO,gBAAgBA;QAChBN;QACA8E,QAAQ;QACRvE,QAAQA;QACRf;QACAY;QACAC;QACAI;QACAE,kBAAkBA;IACpB;IAEA,wCAAwC;IACxC,yBAAyB;IACzB,wCAAwC;IAExC,IAAIjB,iBAAiBgF,KAAK,EAAEtG,WAAWkD,QAAQ;QAC7C,KAAK,MAAMsD,QAAQlF,iBAAiBgF,KAAK,CAACtG,SAAS,CAAE;YACnDgF,SACE,AAAC,MAAMwB,KAAK;gBACVvF,YAAYK;gBACZmF,SAASxE,IAAIwE,OAAO;gBACpBN,KAAKnB;gBACL5D;gBACA0C;gBACA7B;YACF,MAAO+C;QACX;IACF;IAEA,wCAAwC;IACxC,8BAA8B;IAC9B,wCAAwC;IAExCA,SAAS,MAAMpE,oBAAoB;QACjCI;QACAC,YAAYK;QACZH,WAAW;QACXC;QACA4D;IACF;IAEA,wCAAwC;IACxC,iBAAiB;IACjB,wCAAwC;IAExC,OAAOA;AACT,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"restoreVersion.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/restoreVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,WAAW,EACX,OAAO,EACP,cAAc,EACd,WAAW,EACX,IAAI,EACL,M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1
+ {"version":3,"file":"restoreVersion.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/restoreVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,WAAW,EACX,OAAO,EACP,cAAc,EACd,WAAW,EACX,IAAI,EACL,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACvF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AAEzE,OAAO,KAAK,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAA;AAMhG,KAAK,WAAW,CAAC,KAAK,SAAS,cAAc,IAAI;IAC/C;;OAEG;IACH,UAAU,EAAE,KAAK,CAAA;IACjB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IACpC;;OAEG;IACH,EAAE,EAAE,MAAM,CAAA;IACV;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB;;OAEG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;IAC7B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B;;OAEG;IACH,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;CACnB,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE,QAAQ,CAAC,GAChD,IAAI,CAAC,qBAAqB,EAAE,gBAAgB,CAAC,CAAA;AAE/C,MAAM,MAAM,OAAO,CAAC,KAAK,SAAS,cAAc,IAAI,WAAW,CAAC,KAAK,CAAC,GACpE,2BAA2B,CAAC,KAAK,CAAC,CAAA;AAEpC,wBAAsB,mBAAmB,CAAC,KAAK,SAAS,cAAc,EACpE,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,GACtB,OAAO,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAuCxC"}
@@ -2,7 +2,7 @@ import { APIError } from '../../../errors/index.js';
2
2
  import { createPayloadRequest } from '../../../utilities/createPayloadRequest.js';
3
3
  import { restoreVersionOperation } from '../restoreVersion.js';
4
4
  export async function restoreVersionLocal(payload, options) {
5
- const { id, collection: collectionSlug, depth, overrideAccess = false, populate, select, showHiddenFields } = options;
5
+ const { id, collection: collectionSlug, depth, draft, overrideAccess = false, populate, select, showHiddenFields } = options;
6
6
  const collection = payload.collections[collectionSlug];
7
7
  if (!collection) {
8
8
  throw new APIError(`The collection with slug ${String(collectionSlug)} can't be found. Restore Version Operation.`);
@@ -11,6 +11,7 @@ export async function restoreVersionLocal(payload, options) {
11
11
  id,
12
12
  collection,
13
13
  depth,
14
+ draft,
14
15
  overrideAccess,
15
16
  payload,
16
17
  populate,