payload 4.0.0-internal.cd69eef → 4.0.0-internal.d1cc1d3

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 (279) hide show
  1. package/dist/admin/RichText.d.ts +1 -1
  2. package/dist/admin/RichText.d.ts.map +1 -1
  3. package/dist/admin/RichText.js.map +1 -1
  4. package/dist/admin/functions/index.d.ts +10 -8
  5. package/dist/admin/functions/index.d.ts.map +1 -1
  6. package/dist/admin/functions/index.js.map +1 -1
  7. package/dist/admin/types.d.ts +2 -2
  8. package/dist/admin/types.d.ts.map +1 -1
  9. package/dist/admin/types.js.map +1 -1
  10. package/dist/auth/endpoints/login.d.ts.map +1 -1
  11. package/dist/auth/endpoints/login.js +2 -11
  12. package/dist/auth/endpoints/login.js.map +1 -1
  13. package/dist/auth/loginWithCookie.d.ts +33 -0
  14. package/dist/auth/loginWithCookie.d.ts.map +1 -0
  15. package/dist/auth/loginWithCookie.js +34 -0
  16. package/dist/auth/loginWithCookie.js.map +1 -0
  17. package/dist/auth/serverFunctions/cookies.d.ts +47 -0
  18. package/dist/auth/serverFunctions/cookies.d.ts.map +1 -0
  19. package/dist/auth/serverFunctions/cookies.js +52 -0
  20. package/dist/auth/serverFunctions/cookies.js.map +1 -0
  21. package/dist/auth/serverFunctions/login.d.ts +29 -0
  22. package/dist/auth/serverFunctions/login.d.ts.map +1 -0
  23. package/dist/auth/serverFunctions/login.js +63 -0
  24. package/dist/auth/serverFunctions/login.js.map +1 -0
  25. package/dist/auth/serverFunctions/logout.d.ts +17 -0
  26. package/dist/auth/serverFunctions/logout.d.ts.map +1 -0
  27. package/dist/auth/serverFunctions/logout.js +58 -0
  28. package/dist/auth/serverFunctions/logout.js.map +1 -0
  29. package/dist/auth/serverFunctions/refresh.d.ts +17 -0
  30. package/dist/auth/serverFunctions/refresh.d.ts.map +1 -0
  31. package/dist/auth/serverFunctions/refresh.js +61 -0
  32. package/dist/auth/serverFunctions/refresh.js.map +1 -0
  33. package/dist/collections/config/client.d.ts +2 -3
  34. package/dist/collections/config/client.d.ts.map +1 -1
  35. package/dist/collections/config/client.js +5 -7
  36. package/dist/collections/config/client.js.map +1 -1
  37. package/dist/collections/config/defaults.d.ts.map +1 -1
  38. package/dist/collections/config/defaults.js +1 -0
  39. package/dist/collections/config/defaults.js.map +1 -1
  40. package/dist/collections/config/sanitize.d.ts +3 -8
  41. package/dist/collections/config/sanitize.d.ts.map +1 -1
  42. package/dist/collections/config/sanitize.js +2 -6
  43. package/dist/collections/config/sanitize.js.map +1 -1
  44. package/dist/collections/config/types.d.ts +1 -1
  45. package/dist/collections/config/types.d.ts.map +1 -1
  46. package/dist/collections/config/types.js.map +1 -1
  47. package/dist/collections/config/useAsTitle.spec.js +27 -27
  48. package/dist/collections/config/useAsTitle.spec.js.map +1 -1
  49. package/dist/collections/operations/create.d.ts.map +1 -1
  50. package/dist/collections/operations/create.js +10 -0
  51. package/dist/collections/operations/create.js.map +1 -1
  52. package/dist/collections/operations/restoreVersion.d.ts.map +1 -1
  53. package/dist/collections/operations/restoreVersion.js +7 -4
  54. package/dist/collections/operations/restoreVersion.js.map +1 -1
  55. package/dist/collections/operations/updateByID.js +1 -0
  56. package/dist/collections/operations/updateByID.js.map +1 -1
  57. package/dist/config/build.js +1 -1
  58. package/dist/config/build.js.map +1 -1
  59. package/dist/config/defaults.d.ts.map +1 -1
  60. package/dist/config/defaults.js +5 -2
  61. package/dist/config/defaults.js.map +1 -1
  62. package/dist/config/orderable/index.d.ts +1 -1
  63. package/dist/config/orderable/index.d.ts.map +1 -1
  64. package/dist/config/orderable/index.js +2 -2
  65. package/dist/config/orderable/index.js.map +1 -1
  66. package/dist/config/sanitize.d.ts +1 -1
  67. package/dist/config/sanitize.d.ts.map +1 -1
  68. package/dist/config/sanitize.js +33 -40
  69. package/dist/config/sanitize.js.map +1 -1
  70. package/dist/config/types.d.ts +1 -1
  71. package/dist/config/types.js.map +1 -1
  72. package/dist/database/createDatabaseAdapter.d.ts +1 -1
  73. package/dist/database/createDatabaseAdapter.d.ts.map +1 -1
  74. package/dist/database/createDatabaseAdapter.js +0 -2
  75. package/dist/database/createDatabaseAdapter.js.map +1 -1
  76. package/dist/database/types.d.ts +6 -0
  77. package/dist/database/types.d.ts.map +1 -1
  78. package/dist/database/types.js.map +1 -1
  79. package/dist/exports/auth.d.ts +5 -0
  80. package/dist/exports/auth.d.ts.map +1 -0
  81. package/dist/exports/auth.js +6 -0
  82. package/dist/exports/auth.js.map +1 -0
  83. package/dist/exports/internal.d.ts +2 -0
  84. package/dist/exports/internal.d.ts.map +1 -1
  85. package/dist/exports/internal.js +3 -1
  86. package/dist/exports/internal.js.map +1 -1
  87. package/dist/fields/baseFields/slug/duplicateContext.d.ts +11 -0
  88. package/dist/fields/baseFields/slug/duplicateContext.d.ts.map +1 -0
  89. package/dist/fields/baseFields/slug/duplicateContext.js +21 -0
  90. package/dist/fields/baseFields/slug/duplicateContext.js.map +1 -0
  91. package/dist/fields/baseFields/slug/fillEmptyLocalizedSlugs.d.ts +22 -0
  92. package/dist/fields/baseFields/slug/fillEmptyLocalizedSlugs.d.ts.map +1 -0
  93. package/dist/fields/baseFields/slug/fillEmptyLocalizedSlugs.js +63 -0
  94. package/dist/fields/baseFields/slug/fillEmptyLocalizedSlugs.js.map +1 -0
  95. package/dist/fields/baseFields/slug/generateSlug.d.ts +13 -8
  96. package/dist/fields/baseFields/slug/generateSlug.d.ts.map +1 -1
  97. package/dist/fields/baseFields/slug/generateSlug.js +98 -45
  98. package/dist/fields/baseFields/slug/generateSlug.js.map +1 -1
  99. package/dist/fields/baseFields/slug/generateSlugBeforeDuplicate.d.ts +18 -0
  100. package/dist/fields/baseFields/slug/generateSlugBeforeDuplicate.d.ts.map +1 -0
  101. package/dist/fields/baseFields/slug/generateSlugBeforeDuplicate.js +20 -0
  102. package/dist/fields/baseFields/slug/generateSlugBeforeDuplicate.js.map +1 -0
  103. package/dist/fields/baseFields/slug/getSlugFallbackValue.d.ts +22 -0
  104. package/dist/fields/baseFields/slug/getSlugFallbackValue.d.ts.map +1 -0
  105. package/dist/fields/baseFields/slug/getSlugFallbackValue.js +23 -0
  106. package/dist/fields/baseFields/slug/getSlugFallbackValue.js.map +1 -0
  107. package/dist/fields/baseFields/slug/hasValue.d.ts +3 -0
  108. package/dist/fields/baseFields/slug/hasValue.d.ts.map +1 -0
  109. package/dist/fields/baseFields/slug/hasValue.js +3 -0
  110. package/dist/fields/baseFields/slug/hasValue.js.map +1 -0
  111. package/dist/fields/config/reservedFieldNames.spec.js +18 -18
  112. package/dist/fields/config/reservedFieldNames.spec.js.map +1 -1
  113. package/dist/fields/config/sanitize.d.ts +3 -9
  114. package/dist/fields/config/sanitize.d.ts.map +1 -1
  115. package/dist/fields/config/sanitize.js +33 -34
  116. package/dist/fields/config/sanitize.js.map +1 -1
  117. package/dist/fields/config/sanitize.spec.js +128 -105
  118. package/dist/fields/config/sanitize.spec.js.map +1 -1
  119. package/dist/fields/config/types.d.ts +4 -3
  120. package/dist/fields/config/types.d.ts.map +1 -1
  121. package/dist/fields/config/types.js.map +1 -1
  122. package/dist/fields/hooks/beforeValidate/promise.d.ts.map +1 -1
  123. package/dist/fields/hooks/beforeValidate/promise.js +5 -3
  124. package/dist/fields/hooks/beforeValidate/promise.js.map +1 -1
  125. package/dist/fields/hooks/beforeValidate/stripNullRows.d.ts +10 -0
  126. package/dist/fields/hooks/beforeValidate/stripNullRows.d.ts.map +1 -0
  127. package/dist/fields/hooks/beforeValidate/stripNullRows.js +18 -0
  128. package/dist/fields/hooks/beforeValidate/stripNullRows.js.map +1 -0
  129. package/dist/fields/validations.d.ts.map +1 -1
  130. package/dist/fields/validations.js +7 -8
  131. package/dist/fields/validations.js.map +1 -1
  132. package/dist/fields/validations.spec.js +61 -37
  133. package/dist/fields/validations.spec.js.map +1 -1
  134. package/dist/globals/config/sanitize.d.ts +2 -7
  135. package/dist/globals/config/sanitize.d.ts.map +1 -1
  136. package/dist/globals/config/sanitize.js +2 -6
  137. package/dist/globals/config/sanitize.js.map +1 -1
  138. package/dist/globals/config/sanitize.spec.js +6 -6
  139. package/dist/globals/config/sanitize.spec.js.map +1 -1
  140. package/dist/globals/operations/countGlobalVersions.d.ts.map +1 -1
  141. package/dist/globals/operations/countGlobalVersions.js +1 -0
  142. package/dist/globals/operations/countGlobalVersions.js.map +1 -1
  143. package/dist/index.bundled.d.ts +247 -178
  144. package/dist/index.d.ts +49 -17
  145. package/dist/index.d.ts.map +1 -1
  146. package/dist/index.js +3 -0
  147. package/dist/index.js.map +1 -1
  148. package/dist/query-presets/constraints.js +1 -1
  149. package/dist/query-presets/constraints.js.map +1 -1
  150. package/dist/queues/config/collection.d.ts.map +1 -1
  151. package/dist/queues/config/collection.js +37 -43
  152. package/dist/queues/config/collection.js.map +1 -1
  153. package/dist/queues/config/global.d.ts +5 -6
  154. package/dist/queues/config/global.d.ts.map +1 -1
  155. package/dist/queues/config/global.js +1 -1
  156. package/dist/queues/config/global.js.map +1 -1
  157. package/dist/queues/config/types/index.d.ts +29 -24
  158. package/dist/queues/config/types/index.d.ts.map +1 -1
  159. package/dist/queues/config/types/index.js.map +1 -1
  160. package/dist/queues/config/types/taskTypes.d.ts +4 -7
  161. package/dist/queues/config/types/taskTypes.d.ts.map +1 -1
  162. package/dist/queues/config/types/taskTypes.js.map +1 -1
  163. package/dist/queues/config/types/workflowJSONTypes.d.ts +10 -9
  164. package/dist/queues/config/types/workflowJSONTypes.d.ts.map +1 -1
  165. package/dist/queues/config/types/workflowJSONTypes.js.map +1 -1
  166. package/dist/queues/config/types/workflowTypes.d.ts +11 -58
  167. package/dist/queues/config/types/workflowTypes.d.ts.map +1 -1
  168. package/dist/queues/config/types/workflowTypes.js.map +1 -1
  169. package/dist/queues/endpoints/handleSchedules.js +1 -1
  170. package/dist/queues/endpoints/handleSchedules.js.map +1 -1
  171. package/dist/queues/errors/handleTaskError.js +4 -4
  172. package/dist/queues/errors/handleTaskError.js.map +1 -1
  173. package/dist/queues/errors/handleWorkflowError.js +1 -1
  174. package/dist/queues/errors/handleWorkflowError.js.map +1 -1
  175. package/dist/queues/errors/index.d.ts +6 -0
  176. package/dist/queues/errors/index.d.ts.map +1 -1
  177. package/dist/queues/errors/index.js +5 -0
  178. package/dist/queues/errors/index.js.map +1 -1
  179. package/dist/queues/localAPI.d.ts +4 -4
  180. package/dist/queues/localAPI.d.ts.map +1 -1
  181. package/dist/queues/localAPI.js +63 -66
  182. package/dist/queues/localAPI.js.map +1 -1
  183. package/dist/queues/operations/handleSchedules/countRunnableOrActiveJobsForQueue.d.ts +4 -4
  184. package/dist/queues/operations/handleSchedules/countRunnableOrActiveJobsForQueue.d.ts.map +1 -1
  185. package/dist/queues/operations/handleSchedules/countRunnableOrActiveJobsForQueue.js.map +1 -1
  186. package/dist/queues/operations/handleSchedules/index.d.ts +1 -1
  187. package/dist/queues/operations/handleSchedules/index.d.ts.map +1 -1
  188. package/dist/queues/operations/handleSchedules/index.js +1 -1
  189. package/dist/queues/operations/handleSchedules/index.js.map +1 -1
  190. package/dist/queues/operations/runJobs/heartbeat.d.ts +13 -0
  191. package/dist/queues/operations/runJobs/heartbeat.d.ts.map +1 -0
  192. package/dist/queues/operations/runJobs/heartbeat.js +66 -0
  193. package/dist/queues/operations/runJobs/heartbeat.js.map +1 -0
  194. package/dist/queues/operations/runJobs/index.d.ts.map +1 -1
  195. package/dist/queues/operations/runJobs/index.js +133 -84
  196. package/dist/queues/operations/runJobs/index.js.map +1 -1
  197. package/dist/queues/operations/runJobs/runJSONJob/index.d.ts.map +1 -1
  198. package/dist/queues/operations/runJobs/runJSONJob/index.js +6 -3
  199. package/dist/queues/operations/runJobs/runJSONJob/index.js.map +1 -1
  200. package/dist/queues/operations/runJobs/runJob/getRunTaskFunction.js +5 -5
  201. package/dist/queues/operations/runJobs/runJob/getRunTaskFunction.js.map +1 -1
  202. package/dist/queues/operations/runJobs/runJob/getUpdateJobFunction.d.ts +2 -1
  203. package/dist/queues/operations/runJobs/runJob/getUpdateJobFunction.d.ts.map +1 -1
  204. package/dist/queues/operations/runJobs/runJob/getUpdateJobFunction.js +39 -8
  205. package/dist/queues/operations/runJobs/runJob/getUpdateJobFunction.js.map +1 -1
  206. package/dist/queues/operations/runJobs/runJob/importHandlerPath.js.map +1 -1
  207. package/dist/queues/operations/runJobs/runJob/index.d.ts.map +1 -1
  208. package/dist/queues/operations/runJobs/runJob/index.js +4 -4
  209. package/dist/queues/operations/runJobs/runJob/index.js.map +1 -1
  210. package/dist/queues/utilities/updateJob.d.ts.map +1 -1
  211. package/dist/queues/utilities/updateJob.js +3 -0
  212. package/dist/queues/utilities/updateJob.js.map +1 -1
  213. package/dist/types/index.d.ts +2 -2
  214. package/dist/types/index.d.ts.map +1 -1
  215. package/dist/types/index.js.map +1 -1
  216. package/dist/uploads/checkFileRestrictions.d.ts +1 -1
  217. package/dist/uploads/checkFileRestrictions.d.ts.map +1 -1
  218. package/dist/uploads/checkFileRestrictions.js +15 -1
  219. package/dist/uploads/checkFileRestrictions.js.map +1 -1
  220. package/dist/uploads/endpoints/uploadInstructions.d.ts +12 -0
  221. package/dist/uploads/endpoints/uploadInstructions.d.ts.map +1 -1
  222. package/dist/uploads/endpoints/uploadInstructions.js +66 -20
  223. package/dist/uploads/endpoints/uploadInstructions.js.map +1 -1
  224. package/dist/uploads/generateFileData.js +4 -1
  225. package/dist/uploads/generateFileData.js.map +1 -1
  226. package/dist/uploads/getFileFromUploadInstructions.d.ts +8 -0
  227. package/dist/uploads/getFileFromUploadInstructions.d.ts.map +1 -0
  228. package/dist/uploads/getFileFromUploadInstructions.js +62 -0
  229. package/dist/uploads/getFileFromUploadInstructions.js.map +1 -0
  230. package/dist/uploads/getImageSize.d.ts +12 -1
  231. package/dist/uploads/getImageSize.d.ts.map +1 -1
  232. package/dist/uploads/getImageSize.js +20 -18
  233. package/dist/uploads/getImageSize.js.map +1 -1
  234. package/dist/uploads/getImageSize.spec.js +298 -0
  235. package/dist/uploads/getImageSize.spec.js.map +1 -0
  236. package/dist/uploads/probeImageSize.d.ts +39 -0
  237. package/dist/uploads/probeImageSize.d.ts.map +1 -0
  238. package/dist/uploads/probeImageSize.js +374 -0
  239. package/dist/uploads/probeImageSize.js.map +1 -0
  240. package/dist/uploads/probeImageSize.spec.js +366 -0
  241. package/dist/uploads/probeImageSize.spec.js.map +1 -0
  242. package/dist/uploads/stagedUpload.d.ts +27 -0
  243. package/dist/uploads/stagedUpload.d.ts.map +1 -0
  244. package/dist/uploads/stagedUpload.js +197 -0
  245. package/dist/uploads/stagedUpload.js.map +1 -0
  246. package/dist/uploads/types.d.ts +41 -13
  247. package/dist/uploads/types.d.ts.map +1 -1
  248. package/dist/uploads/types.js.map +1 -1
  249. package/dist/utilities/addDataAndFileToRequest.d.ts.map +1 -1
  250. package/dist/utilities/addDataAndFileToRequest.js +12 -46
  251. package/dist/utilities/addDataAndFileToRequest.js.map +1 -1
  252. package/dist/utilities/configToJSONSchema.spec.js +33 -33
  253. package/dist/utilities/configToJSONSchema.spec.js.map +1 -1
  254. package/dist/utilities/fieldValueExists.d.ts +29 -0
  255. package/dist/utilities/fieldValueExists.d.ts.map +1 -0
  256. package/dist/utilities/fieldValueExists.js +27 -0
  257. package/dist/utilities/fieldValueExists.js.map +1 -0
  258. package/dist/utilities/getUniqueFieldValue.d.ts +27 -0
  259. package/dist/utilities/getUniqueFieldValue.d.ts.map +1 -0
  260. package/dist/utilities/getUniqueFieldValue.js +26 -0
  261. package/dist/utilities/getUniqueFieldValue.js.map +1 -0
  262. package/dist/versions/deleteScheduledPublishJobs.js +2 -2
  263. package/dist/versions/deleteScheduledPublishJobs.js.map +1 -1
  264. package/dist/versions/payloadPackageList.d.ts.map +1 -1
  265. package/dist/versions/payloadPackageList.js +0 -1
  266. package/dist/versions/payloadPackageList.js.map +1 -1
  267. package/package.json +8 -3
  268. package/dist/database/defaultUpdateJobs.d.ts +0 -3
  269. package/dist/database/defaultUpdateJobs.d.ts.map +0 -1
  270. package/dist/database/defaultUpdateJobs.js +0 -41
  271. package/dist/database/defaultUpdateJobs.js.map +0 -1
  272. package/dist/fields/baseFields/slug/countVersions.d.ts +0 -13
  273. package/dist/fields/baseFields/slug/countVersions.d.ts.map +0 -1
  274. package/dist/fields/baseFields/slug/countVersions.js +0 -27
  275. package/dist/fields/baseFields/slug/countVersions.js.map +0 -1
  276. package/dist/uploads/tempFile.d.ts +0 -7
  277. package/dist/uploads/tempFile.d.ts.map +0 -1
  278. package/dist/uploads/tempFile.js +0 -39
  279. package/dist/uploads/tempFile.js.map +0 -1
@@ -51,7 +51,7 @@ export type GenerateImageName = (args: {
51
51
  sizeName: string;
52
52
  width: number;
53
53
  }) => string;
54
- export type ImageSize = {
54
+ type ImageSizeBase = {
55
55
  /**
56
56
  * Admin UI options that control how this image size appears in list views.
57
57
  */
@@ -70,16 +70,21 @@ export type ImageSize = {
70
70
  groupBy?: boolean;
71
71
  };
72
72
  };
73
- /**
74
- * @deprecated prefer position
75
- */
76
- crop?: string;
77
- formatOptions?: ImageUploadFormatOptions;
78
73
  /**
79
74
  * Generate a custom name for the file of this image size.
80
75
  */
81
76
  generateImageName?: GenerateImageName;
82
77
  name: string;
78
+ };
79
+ /**
80
+ * Image size options implemented by Payload's default Sharp image processor.
81
+ */
82
+ export type SharpImageSizeOptions = {
83
+ /**
84
+ * @deprecated prefer position
85
+ */
86
+ crop?: string;
87
+ formatOptions?: ImageUploadFormatOptions;
83
88
  trimOptions?: ImageUploadTrimOptions;
84
89
  /**
85
90
  * When an uploaded image is smaller than the defined image size, we have 3 options:
@@ -92,6 +97,23 @@ export type ImageSize = {
92
97
  */
93
98
  withoutEnlargement?: ResizeOptions['withoutEnlargement'];
94
99
  } & Omit<ResizeOptions, 'withoutEnlargement'>;
100
+ /**
101
+ * Interface to be module-augmented by image processing providers.
102
+ *
103
+ * When no provider is registered, ImageSize uses SharpImageSizeOptions.
104
+ * When providers are registered, ImageSize uses their registered options instead.
105
+ *
106
+ * @example
107
+ * declare module 'payload' {
108
+ * interface RegisteredImageSizeOptions {
109
+ * myProvider: MyProviderImageSizeOptions
110
+ * }
111
+ * }
112
+ */
113
+ export interface RegisteredImageSizeOptions {
114
+ }
115
+ type ImageSizeOptions = keyof RegisteredImageSizeOptions extends never ? SharpImageSizeOptions : RegisteredImageSizeOptions[keyof RegisteredImageSizeOptions];
116
+ export type ImageSize = ImageSizeBase & ImageSizeOptions;
95
117
  export type GetAdminThumbnail = (args: {
96
118
  doc: Record<string, unknown>;
97
119
  }) => false | null | string;
@@ -236,9 +258,9 @@ export type UploadConfig = {
236
258
  headers?: Headers;
237
259
  params: {
238
260
  collection: string;
239
- directUpload?: unknown;
240
261
  filename: string;
241
262
  prefix?: string;
263
+ uploadReference?: unknown;
242
264
  };
243
265
  }) => Promise<Response> | Promise<void> | Response | void)[];
244
266
  /**
@@ -291,8 +313,7 @@ export type UploadConfig = {
291
313
  staticDir?: string;
292
314
  trimOptions?: ImageUploadTrimOptions;
293
315
  /**
294
- * Adapter-provided upload instructions. Client config exposes this as a `true` marker without
295
- * the server-only access and generate functions.
316
+ * Adapter-provided upload instructions.
296
317
  * @internal
297
318
  */
298
319
  uploadInstructions?: UploadInstructionsCapability;
@@ -321,10 +342,11 @@ export type UploadInstructionsRequest = {
321
342
  };
322
343
  export type UploadInstructions = {
323
344
  file: {
324
- directUpload: Record<string, unknown>;
345
+ collectionSlug?: UploadCollectionSlug;
325
346
  filename: string;
326
347
  mimeType: string;
327
348
  size: number;
349
+ uploadReference: Record<string, unknown>;
328
350
  };
329
351
  } & ({
330
352
  data?: unknown;
@@ -339,15 +361,21 @@ export type UploadInstructions = {
339
361
  type: 'http';
340
362
  });
341
363
  export type GenerateUploadInstructions = (args: {
364
+ overrideAccess?: boolean;
342
365
  req: PayloadRequest;
343
366
  } & UploadInstructionsRequest) => Promise<UploadInstructions> | UploadInstructions;
344
367
  export type UploadInstructionsCapability = {
345
- /** Controls access to generating upload instructions. */
346
- access?: UploadInstructionsAccess;
347
- /** Generates instructions for uploading a file. */
368
+ /** Generates upload instructions. The generator or supporting endpoint must check access. */
348
369
  generate: GenerateUploadInstructions;
370
+ /**
371
+ * Whether the Admin panel should use these instructions before saving a document.
372
+ * This can still be useful when upload chunks pass through Payload.
373
+ */
374
+ useInAdmin: boolean;
349
375
  };
350
376
  export type checkFileRestrictionsParams = {
377
+ /** Set to false when the file bytes have not been uploaded yet. */
378
+ checkFileContents?: boolean;
351
379
  collection: CollectionConfig;
352
380
  file: File;
353
381
  req: PayloadRequest;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/uploads/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAE/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAClF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAEjE,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,EAAE,IAAI,GAAG,MAAM,CAAA;IACvB,QAAQ,EAAE,IAAI,GAAG,MAAM,CAAA;IACvB,MAAM,EAAE,IAAI,GAAG,MAAM,CAAA;IACrB,QAAQ,EAAE,IAAI,GAAG,MAAM,CAAA;IACvB,GAAG,EAAE,IAAI,GAAG,MAAM,CAAA;IAClB,KAAK,EAAE,IAAI,GAAG,MAAM,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,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,UAAU,GAAG;IACvB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,KAAK,IAAI,GAAG;IACV,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,GAAG,GAAG,IAAI,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV,CAAA;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/uploads/types.ts"],"sourcesContent":["import type { ResizeOptions, Sharp, SharpOptions } from 'sharp'\n\nimport type { CollectionConfig, TypeWithID } from '../collections/config/types.js'\nimport type { PayloadComponent } from '../config/types.js'\nimport type { UploadCollectionSlug } from '../index.js'\nimport type { PayloadRequest } from '../types/index.js'\nimport type { WithMetadata } from './optionallyAppendMetadata.js'\n\nexport type FileSize = {\n filename: null | string\n filesize: null | number\n height: null | number\n mimeType: null | string\n url: null | string\n width: null | number\n}\n\nexport type FileSizes = {\n [size: string]: FileSize\n}\n\nexport type FileData = {\n filename: string\n filesize: number\n focalX?: number\n focalY?: number\n height: number\n mimeType: string\n sizes: FileSizes\n tempFilePath?: string\n url?: string\n width: number\n}\n\nexport type ProbedImageSize = {\n height: number\n width: number\n}\n\n/**\n * Params sent to the sharp `toFormat()` function\n * @link https://sharp.pixelplumbing.com/api-output#toformat\n */\nexport type ImageUploadFormatOptions = {\n format: Parameters<Sharp['toFormat']>[0]\n options?: Parameters<Sharp['toFormat']>[1]\n}\n\n/**\n * Params sent to the sharp trim() function\n * @link https://sharp.pixelplumbing.com/api-resize#trim\n */\nexport type ImageUploadTrimOptions = Parameters<Sharp['trim']>[0]\n\nexport type GenerateImageName = (args: {\n extension: string\n height: number\n originalName: string\n sizeName: string\n width: number\n}) => string\n\nexport type ImageSize = {\n /**\n * Admin UI options that control how this image size appears in list views.\n */\n admin?: {\n /**\n * Controls visibility of this image size in the collection list view.\n * Defaults to hiding the image size from columns, filters, and group-by to reduce noise.\n *\n * - `column` — whether to hide this size from selectable list columns. @default false\n * - `filter` — whether to hide this size from filter options. @default false\n * - `groupBy` — whether to hide this size from group-by options. @default false\n */\n disabled?: {\n column?: boolean\n filter?: boolean\n groupBy?: boolean\n }\n }\n /**\n * @deprecated prefer position\n */\n crop?: string // comes from sharp package\n formatOptions?: ImageUploadFormatOptions\n /**\n * Generate a custom name for the file of this image size.\n */\n generateImageName?: GenerateImageName\n name: string\n trimOptions?: ImageUploadTrimOptions\n /**\n * When an uploaded image is smaller than the defined image size, we have 3 options:\n *\n * `undefined | false | true`\n *\n * 1. `undefined` [default]: uploading images with smaller width AND height than the image size will return null\n * 2. `false`: always enlarge images to the image size\n * 3. `true`: if the image is smaller than the image size, return the original image\n */\n withoutEnlargement?: ResizeOptions['withoutEnlargement']\n} & Omit<ResizeOptions, 'withoutEnlargement'>\n\nexport type GetAdminThumbnail = (args: { doc: Record<string, unknown> }) => false | null | string\n\nexport type AllowList = Array<{\n hostname: string\n pathname?: string\n port?: string\n protocol?: 'http' | 'https'\n search?: string\n}>\n\nexport type FileAllowList = Array<{\n extensions: string[]\n mimeType: string\n}>\n\nexport type UploadFilePreviewClientProps = {\n filename: string\n filesize: number\n /** Resolved URL of the file (data.url). */\n fileSrc: string\n height?: number\n mimeType: string\n width?: number\n}\n\ntype UploadFilePreviewMap = {\n [mimeTypePattern: string]: PayloadComponent\n}\n\ntype Admin = {\n components?: {\n /**\n * The Controls component to extend the upload controls in the admin panel.\n */\n controls?: PayloadComponent[]\n /**\n * A custom component to render in place of the default Thumbnail in the upload side panel.\n *\n * Can be a single PayloadComponent (renders for all MIME types) or a Record keyed by\n * MIME type patterns. Pattern resolution priority: exact match → category wildcard\n * (e.g. `video/*`) → universal fallback (`*`). Falls back to the default Thumbnail\n * when nothing matches.\n */\n filePreview?: PayloadComponent | UploadFilePreviewMap\n }\n}\n\nexport type UploadConfig = {\n /**\n * The adapter name to use for uploads. Used for storage adapter telemetry.\n * @default undefined\n */\n adapter?: string\n /**\n * The admin configuration for the upload field.\n */\n admin?: Admin\n /**\n * Represents an admin thumbnail, which can be either a React component or a string.\n * - If a string, it should be one of the image size names.\n * - A function that generates a fully qualified URL for the thumbnail, receives the doc as the only argument.\n **/\n adminThumbnail?: GetAdminThumbnail | string\n /**\n * Allow restricted file types known to be problematic.\n * - If set to `true`, it will allow all file types.\n * - If set to `false`, it will not allow file types and extensions known to be problematic.\n * - This setting is overriden by the `mimeTypes` option.\n * @default false\n */\n allowRestrictedFileTypes?: boolean\n /**\n * Enables bulk upload of files from the list view.\n * @default true\n */\n bulkUpload?: boolean\n /**\n * Appends a cache tag to the image URL when fetching the thumbnail in the admin panel. It may be desirable to disable this when hosting via CDNs with strict parameters.\n *\n * @default true\n */\n cacheTags?: boolean\n /**\n * Sharp constructor options to be passed to the uploaded file.\n * @link https://sharp.pixelplumbing.com/api-constructor/#sharp\n */\n constructorOptions?: SharpOptions\n /**\n * Enables cropping of images.\n * @default true\n */\n crop?: boolean\n /**\n * Disable the ability to save files to disk.\n * @default false\n */\n disableLocalStorage?: boolean\n /**\n * Enable displaying preview of the uploaded file in Upload fields related to this Collection.\n * Can be locally overridden by `displayPreview` option in Upload field.\n * @default false\n */\n displayPreview?: boolean\n /**\n *\n * Accepts existing headers and returns the headers after filtering or modifying.\n * If using this option, you should handle the removal of any sensitive cookies\n * (like payload-prefixed cookies) to prevent leaking session information to external\n * services. By default, Payload automatically filters out payload-prefixed cookies\n * when this option is NOT defined.\n *\n * Useful for adding custom headers to fetch from external providers.\n * @default undefined\n */\n externalFileHeaderFilter?: (headers: Record<string, string>) => Record<string, string>\n /**\n * Field slugs to use for a compound index instead of the default filename index.\n */\n filenameCompoundIndex?: string[]\n /**\n * Require files to be uploaded when creating a document.\n * @default true\n */\n filesRequiredOnCreate?: boolean\n /**\n * Enables focal point positioning for image manipulation.\n * @default true\n */\n focalPoint?: boolean\n /**\n * Format options for the uploaded file. Formatting image sizes needs to be done within each formatOptions individually.\n */\n formatOptions?: ImageUploadFormatOptions\n /**\n * Custom handlers to run when a file is fetched.\n *\n * - If a handler returns a Response, the response will be sent to the client and no further handlers will be run.\n * - If a handler returns null, the next handler will be run.\n * - If no handlers return a response the file will be returned by default.\n *\n * @link https://sharp.pixelplumbing.com/api-output/#toformat\n * @default undefined\n */\n handlers?: ((\n req: PayloadRequest,\n args: {\n doc: TypeWithID\n headers?: Headers\n params: {\n collection: string\n directUpload?: unknown\n filename: string\n prefix?: string\n }\n },\n ) => Promise<Response> | Promise<void> | Response | void)[]\n /**\n * Set to `true` to prevent the admin UI from showing file inputs during document creation, useful for programmatic file generation.\n */\n hideFileInputOnCreate?: boolean\n /**\n * Set to `true` to prevent the admin UI having a way to remove an existing file while editing.\n */\n hideRemoveFile?: boolean\n imageSizes?: ImageSize[]\n /**\n * Restrict mimeTypes in the file picker. Array of valid mime types or mimetype wildcards\n * @example ['image/*', 'application/pdf']\n * @default undefined\n */\n mimeTypes?: string[]\n /**\n * Ability to modify the response headers fetching a file.\n * @default undefined\n */\n modifyResponseHeaders?: ({ headers }: { headers: Headers }) => Headers | void\n /**\n * Controls the behavior of pasting/uploading files from URLs.\n * If set to `false`, fetching from remote URLs is disabled.\n * If an `allowList` is provided, server-side fetching will be enabled for specified URLs.\n *\n * @default true (client-side fetching enabled)\n */\n pasteURL?:\n | {\n allowList: AllowList\n }\n | false\n /**\n * Sharp resize options for the original image.\n * @link https://sharp.pixelplumbing.com/api-resize#resize\n * @default undefined\n */\n resizeOptions?: ResizeOptions\n /**\n * Skip safe fetch when using server-side fetching for external files from these URLs.\n * @default false\n */\n skipSafeFetch?: AllowList | boolean\n /**\n * The directory to serve static files from. Defaults to collection slug.\n * @default undefined\n */\n staticDir?: string\n trimOptions?: ImageUploadTrimOptions\n /**\n * Adapter-provided upload instructions. Client config exposes this as a `true` marker without\n * the server-only access and generate functions.\n * @internal\n */\n uploadInstructions?: UploadInstructionsCapability\n /**\n * Optionally append metadata to the image during processing.\n *\n * Can be a boolean or a function.\n *\n * If true, metadata will be appended to the image.\n * If false, no metadata will be appended.\n * If a function, it will receive an object containing the metadata and should return a boolean indicating whether to append the metadata.\n * @default false\n */\n withMetadata?: WithMetadata\n}\n\nexport type UploadInstructionsAccess = (args: {\n collectionSlug: UploadCollectionSlug\n req: PayloadRequest\n}) => boolean | Promise<boolean>\n\nexport type UploadInstructionsRequest = {\n collectionSlug: UploadCollectionSlug\n docPrefix?: string\n filename: string\n filesize: number\n mimeType: string\n}\n\nexport type UploadInstructions = {\n file: {\n directUpload: Record<string, unknown>\n filename: string\n mimeType: string\n size: number\n }\n} & (\n | {\n data?: unknown\n name: string\n type: 'dispatch'\n }\n | {\n request: {\n headers?: Record<string, string>\n method: 'POST' | 'PUT'\n url: string\n }\n type: 'http'\n }\n)\n\nexport type GenerateUploadInstructions = (\n args: { req: PayloadRequest } & UploadInstructionsRequest,\n) => Promise<UploadInstructions> | UploadInstructions\n\nexport type UploadInstructionsCapability = {\n /** Controls access to generating upload instructions. */\n access?: UploadInstructionsAccess\n /** Generates instructions for uploading a file. */\n generate: GenerateUploadInstructions\n}\nexport type checkFileRestrictionsParams = {\n collection: CollectionConfig\n file: File\n req: PayloadRequest\n}\n\nexport type SanitizedUploadConfig = {\n staticDir: UploadConfig['staticDir']\n} & UploadConfig\n\nexport type File = {\n /**\n * The buffer of the file.\n */\n data: Buffer\n /**\n * The mimetype of the file.\n */\n mimetype: string\n /**\n * The name of the file.\n */\n name: string\n /**\n * The size of the file in bytes.\n */\n size: number\n /**\n * Path to the temp file on disk when useTempFiles is enabled. In this case file.data will be an empty buffer.\n */\n tempFilePath?: string\n}\n\nexport type FileToSave = {\n /**\n * The buffer of the file.\n */\n buffer: Buffer\n /**\n * The path to save the file.\n */\n path: string\n}\n\ntype Crop = {\n height: number\n unit: '%' | 'px'\n width: number\n x: number\n y: number\n}\n\nexport type FocalPoint = {\n x: number\n y: number\n}\n\nexport type UploadEdits = {\n crop?: Crop\n focalPoint?: FocalPoint\n heightInPixels?: number\n widthInPixels?: number\n}\n"],"names":[],"mappings":"AA+aA,WAKC"}
1
+ {"version":3,"sources":["../../src/uploads/types.ts"],"sourcesContent":["import type { ResizeOptions, Sharp, SharpOptions } from 'sharp'\n\nimport type { CollectionConfig, TypeWithID } from '../collections/config/types.js'\nimport type { PayloadComponent } from '../config/types.js'\nimport type { UploadCollectionSlug } from '../index.js'\nimport type { PayloadRequest } from '../types/index.js'\nimport type { WithMetadata } from './optionallyAppendMetadata.js'\n\nexport type FileSize = {\n filename: null | string\n filesize: null | number\n height: null | number\n mimeType: null | string\n url: null | string\n width: null | number\n}\n\nexport type FileSizes = {\n [size: string]: FileSize\n}\n\nexport type FileData = {\n filename: string\n filesize: number\n focalX?: number\n focalY?: number\n height: number\n mimeType: string\n sizes: FileSizes\n tempFilePath?: string\n url?: string\n width: number\n}\n\nexport type ProbedImageSize = {\n height: number\n width: number\n}\n\n/**\n * Params sent to the sharp `toFormat()` function\n * @link https://sharp.pixelplumbing.com/api-output#toformat\n */\nexport type ImageUploadFormatOptions = {\n format: Parameters<Sharp['toFormat']>[0]\n options?: Parameters<Sharp['toFormat']>[1]\n}\n\n/**\n * Params sent to the sharp trim() function\n * @link https://sharp.pixelplumbing.com/api-resize#trim\n */\nexport type ImageUploadTrimOptions = Parameters<Sharp['trim']>[0]\n\nexport type GenerateImageName = (args: {\n extension: string\n height: number\n originalName: string\n sizeName: string\n width: number\n}) => string\n\ntype ImageSizeBase = {\n /**\n * Admin UI options that control how this image size appears in list views.\n */\n admin?: {\n /**\n * Controls visibility of this image size in the collection list view.\n * Defaults to hiding the image size from columns, filters, and group-by to reduce noise.\n *\n * - `column` — whether to hide this size from selectable list columns. @default false\n * - `filter` — whether to hide this size from filter options. @default false\n * - `groupBy` — whether to hide this size from group-by options. @default false\n */\n disabled?: {\n column?: boolean\n filter?: boolean\n groupBy?: boolean\n }\n }\n /**\n * Generate a custom name for the file of this image size.\n */\n generateImageName?: GenerateImageName\n name: string\n}\n\n/**\n * Image size options implemented by Payload's default Sharp image processor.\n */\nexport type SharpImageSizeOptions = {\n /**\n * @deprecated prefer position\n */\n crop?: string // comes from sharp package\n formatOptions?: ImageUploadFormatOptions\n trimOptions?: ImageUploadTrimOptions\n /**\n * When an uploaded image is smaller than the defined image size, we have 3 options:\n *\n * `undefined | false | true`\n *\n * 1. `undefined` [default]: uploading images with smaller width AND height than the image size will return null\n * 2. `false`: always enlarge images to the image size\n * 3. `true`: if the image is smaller than the image size, return the original image\n */\n withoutEnlargement?: ResizeOptions['withoutEnlargement']\n} & Omit<ResizeOptions, 'withoutEnlargement'>\n\n/**\n * Interface to be module-augmented by image processing providers.\n *\n * When no provider is registered, ImageSize uses SharpImageSizeOptions.\n * When providers are registered, ImageSize uses their registered options instead.\n *\n * @example\n * declare module 'payload' {\n * interface RegisteredImageSizeOptions {\n * myProvider: MyProviderImageSizeOptions\n * }\n * }\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type -- Intentionally empty so image processing providers can augment it.\nexport interface RegisteredImageSizeOptions {}\n\ntype ImageSizeOptions = keyof RegisteredImageSizeOptions extends never\n ? SharpImageSizeOptions\n : RegisteredImageSizeOptions[keyof RegisteredImageSizeOptions]\n\nexport type ImageSize = ImageSizeBase & ImageSizeOptions\n\nexport type GetAdminThumbnail = (args: { doc: Record<string, unknown> }) => false | null | string\n\nexport type AllowList = Array<{\n hostname: string\n pathname?: string\n port?: string\n protocol?: 'http' | 'https'\n search?: string\n}>\n\nexport type FileAllowList = Array<{\n extensions: string[]\n mimeType: string\n}>\n\nexport type UploadFilePreviewClientProps = {\n filename: string\n filesize: number\n /** Resolved URL of the file (data.url). */\n fileSrc: string\n height?: number\n mimeType: string\n width?: number\n}\n\ntype UploadFilePreviewMap = {\n [mimeTypePattern: string]: PayloadComponent\n}\n\ntype Admin = {\n components?: {\n /**\n * The Controls component to extend the upload controls in the admin panel.\n */\n controls?: PayloadComponent[]\n /**\n * A custom component to render in place of the default Thumbnail in the upload side panel.\n *\n * Can be a single PayloadComponent (renders for all MIME types) or a Record keyed by\n * MIME type patterns. Pattern resolution priority: exact match → category wildcard\n * (e.g. `video/*`) → universal fallback (`*`). Falls back to the default Thumbnail\n * when nothing matches.\n */\n filePreview?: PayloadComponent | UploadFilePreviewMap\n }\n}\n\nexport type UploadConfig = {\n /**\n * The adapter name to use for uploads. Used for storage adapter telemetry.\n * @default undefined\n */\n adapter?: string\n /**\n * The admin configuration for the upload field.\n */\n admin?: Admin\n /**\n * Represents an admin thumbnail, which can be either a React component or a string.\n * - If a string, it should be one of the image size names.\n * - A function that generates a fully qualified URL for the thumbnail, receives the doc as the only argument.\n **/\n adminThumbnail?: GetAdminThumbnail | string\n /**\n * Allow restricted file types known to be problematic.\n * - If set to `true`, it will allow all file types.\n * - If set to `false`, it will not allow file types and extensions known to be problematic.\n * - This setting is overriden by the `mimeTypes` option.\n * @default false\n */\n allowRestrictedFileTypes?: boolean\n /**\n * Enables bulk upload of files from the list view.\n * @default true\n */\n bulkUpload?: boolean\n /**\n * Appends a cache tag to the image URL when fetching the thumbnail in the admin panel. It may be desirable to disable this when hosting via CDNs with strict parameters.\n *\n * @default true\n */\n cacheTags?: boolean\n /**\n * Sharp constructor options to be passed to the uploaded file.\n * @link https://sharp.pixelplumbing.com/api-constructor/#sharp\n */\n constructorOptions?: SharpOptions\n /**\n * Enables cropping of images.\n * @default true\n */\n crop?: boolean\n /**\n * Disable the ability to save files to disk.\n * @default false\n */\n disableLocalStorage?: boolean\n /**\n * Enable displaying preview of the uploaded file in Upload fields related to this Collection.\n * Can be locally overridden by `displayPreview` option in Upload field.\n * @default false\n */\n displayPreview?: boolean\n /**\n *\n * Accepts existing headers and returns the headers after filtering or modifying.\n * If using this option, you should handle the removal of any sensitive cookies\n * (like payload-prefixed cookies) to prevent leaking session information to external\n * services. By default, Payload automatically filters out payload-prefixed cookies\n * when this option is NOT defined.\n *\n * Useful for adding custom headers to fetch from external providers.\n * @default undefined\n */\n externalFileHeaderFilter?: (headers: Record<string, string>) => Record<string, string>\n /**\n * Field slugs to use for a compound index instead of the default filename index.\n */\n filenameCompoundIndex?: string[]\n /**\n * Require files to be uploaded when creating a document.\n * @default true\n */\n filesRequiredOnCreate?: boolean\n /**\n * Enables focal point positioning for image manipulation.\n * @default true\n */\n focalPoint?: boolean\n /**\n * Format options for the uploaded file. Formatting image sizes needs to be done within each formatOptions individually.\n */\n formatOptions?: ImageUploadFormatOptions\n /**\n * Custom handlers to run when a file is fetched.\n *\n * - If a handler returns a Response, the response will be sent to the client and no further handlers will be run.\n * - If a handler returns null, the next handler will be run.\n * - If no handlers return a response the file will be returned by default.\n *\n * @link https://sharp.pixelplumbing.com/api-output/#toformat\n * @default undefined\n */\n handlers?: ((\n req: PayloadRequest,\n args: {\n doc: TypeWithID\n headers?: Headers\n params: {\n collection: string\n filename: string\n prefix?: string\n uploadReference?: unknown\n }\n },\n ) => Promise<Response> | Promise<void> | Response | void)[]\n /**\n * Set to `true` to prevent the admin UI from showing file inputs during document creation, useful for programmatic file generation.\n */\n hideFileInputOnCreate?: boolean\n /**\n * Set to `true` to prevent the admin UI having a way to remove an existing file while editing.\n */\n hideRemoveFile?: boolean\n imageSizes?: ImageSize[]\n /**\n * Restrict mimeTypes in the file picker. Array of valid mime types or mimetype wildcards\n * @example ['image/*', 'application/pdf']\n * @default undefined\n */\n mimeTypes?: string[]\n /**\n * Ability to modify the response headers fetching a file.\n * @default undefined\n */\n modifyResponseHeaders?: ({ headers }: { headers: Headers }) => Headers | void\n /**\n * Controls the behavior of pasting/uploading files from URLs.\n * If set to `false`, fetching from remote URLs is disabled.\n * If an `allowList` is provided, server-side fetching will be enabled for specified URLs.\n *\n * @default true (client-side fetching enabled)\n */\n pasteURL?:\n | {\n allowList: AllowList\n }\n | false\n /**\n * Sharp resize options for the original image.\n * @link https://sharp.pixelplumbing.com/api-resize#resize\n * @default undefined\n */\n resizeOptions?: ResizeOptions\n /**\n * Skip safe fetch when using server-side fetching for external files from these URLs.\n * @default false\n */\n skipSafeFetch?: AllowList | boolean\n /**\n * The directory to serve static files from. Defaults to collection slug.\n * @default undefined\n */\n staticDir?: string\n trimOptions?: ImageUploadTrimOptions\n /**\n * Adapter-provided upload instructions.\n * @internal\n */\n uploadInstructions?: UploadInstructionsCapability\n /**\n * Optionally append metadata to the image during processing.\n *\n * Can be a boolean or a function.\n *\n * If true, metadata will be appended to the image.\n * If false, no metadata will be appended.\n * If a function, it will receive an object containing the metadata and should return a boolean indicating whether to append the metadata.\n * @default false\n */\n withMetadata?: WithMetadata\n}\n\nexport type UploadInstructionsAccess = (args: {\n collectionSlug: UploadCollectionSlug\n req: PayloadRequest\n}) => boolean | Promise<boolean>\n\nexport type UploadInstructionsRequest = {\n collectionSlug: UploadCollectionSlug\n docPrefix?: string\n filename: string\n filesize: number\n mimeType: string\n}\n\nexport type UploadInstructions = {\n file: {\n collectionSlug?: UploadCollectionSlug\n filename: string\n mimeType: string\n size: number\n uploadReference: Record<string, unknown>\n }\n} & (\n | {\n data?: unknown\n name: string\n type: 'dispatch'\n }\n | {\n request: {\n headers?: Record<string, string>\n method: 'POST' | 'PUT'\n url: string\n }\n type: 'http'\n }\n)\n\nexport type GenerateUploadInstructions = (\n args: { overrideAccess?: boolean; req: PayloadRequest } & UploadInstructionsRequest,\n) => Promise<UploadInstructions> | UploadInstructions\n\nexport type UploadInstructionsCapability = {\n /** Generates upload instructions. The generator or supporting endpoint must check access. */\n generate: GenerateUploadInstructions\n /**\n * Whether the Admin panel should use these instructions before saving a document.\n * This can still be useful when upload chunks pass through Payload.\n */\n useInAdmin: boolean\n}\nexport type checkFileRestrictionsParams = {\n /** Set to false when the file bytes have not been uploaded yet. */\n checkFileContents?: boolean\n collection: CollectionConfig\n file: File\n req: PayloadRequest\n}\n\nexport type SanitizedUploadConfig = {\n staticDir: UploadConfig['staticDir']\n} & UploadConfig\n\nexport type File = {\n /**\n * The buffer of the file.\n */\n data: Buffer\n /**\n * The mimetype of the file.\n */\n mimetype: string\n /**\n * The name of the file.\n */\n name: string\n /**\n * The size of the file in bytes.\n */\n size: number\n /**\n * Path to the temp file on disk when useTempFiles is enabled. In this case file.data will be an empty buffer.\n */\n tempFilePath?: string\n}\n\nexport type FileToSave = {\n /**\n * The buffer of the file.\n */\n buffer: Buffer\n /**\n * The path to save the file.\n */\n path: string\n}\n\ntype Crop = {\n height: number\n unit: '%' | 'px'\n width: number\n x: number\n y: number\n}\n\nexport type FocalPoint = {\n x: number\n y: number\n}\n\nexport type UploadEdits = {\n crop?: Crop\n focalPoint?: FocalPoint\n heightInPixels?: number\n widthInPixels?: number\n}\n"],"names":[],"mappings":"AAgdA,WAKC"}
@@ -1 +1 @@
1
- {"version":3,"file":"addDataAndFileToRequest.d.ts","sourceRoot":"","sources":["../../src/utilities/addDataAndFileToRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAKvD,KAAK,uBAAuB,GAAG,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;AAErE;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,uBA8GrC,CAAA"}
1
+ {"version":3,"file":"addDataAndFileToRequest.d.ts","sourceRoot":"","sources":["../../src/utilities/addDataAndFileToRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAOvD,KAAK,uBAAuB,GAAG,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;AAErE;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,uBA4ErC,CAAA"}
@@ -1,5 +1,6 @@
1
1
  import { APIError } from '../errors/APIError.js';
2
2
  import { processMultipartFormdata } from '../uploads/fetchAPI-multipart/index.js';
3
+ import { getFileFromUploadInstructions } from '../uploads/getFileFromUploadInstructions.js';
3
4
  /**
4
5
  * Mutates the Request, appending 'data' and 'file' if found
5
6
  */ export const addDataAndFileToRequest = async (req)=>{
@@ -50,57 +51,22 @@ import { processMultipartFormdata } from '../uploads/fetchAPI-multipart/index.js
50
51
  req.data = JSON.parse(fields._payload);
51
52
  }
52
53
  if (!req.file && fields?.file && typeof fields?.file === 'string') {
53
- let directUpload, filename, mimeType, size;
54
- const collectionSlug = req.routeParams?.collection;
54
+ let uploadedFile;
55
55
  try {
56
- ;
57
- ({ directUpload, filename, mimeType, size } = JSON.parse(fields.file));
56
+ uploadedFile = JSON.parse(fields.file);
58
57
  } catch {
59
58
  throw new APIError('A file name is required.', 400);
60
59
  }
61
- const uploadConfig = req.payload.collections[collectionSlug].config.upload;
62
- if (!uploadConfig.handlers) {
63
- throw new APIError('uploadConfig.handlers is not present for ' + collectionSlug);
60
+ const collectionSlug = typeof req.routeParams?.collection === 'string' ? req.routeParams.collection : uploadedFile.collectionSlug;
61
+ const uploadConfig = collectionSlug ? req.payload.collections[collectionSlug]?.config.upload : undefined;
62
+ if (!collectionSlug || !uploadConfig) {
63
+ throw new APIError('Invalid upload collection.', 400);
64
64
  }
65
- let response = null;
66
- let error;
67
- for (const handler of uploadConfig.handlers){
68
- try {
69
- const result = await handler(req, {
70
- doc: null,
71
- params: {
72
- collection: collectionSlug,
73
- directUpload,
74
- filename
75
- }
76
- });
77
- if (result) {
78
- response = result;
79
- }
80
- // If we couldn't get the file from that handler, save the error and try other.
81
- } catch (err) {
82
- error = err;
83
- }
84
- }
85
- if (!response) {
86
- if (error) {
87
- payload.logger.error(error);
88
- }
89
- throw new APIError('Expected response from the upload handler.');
90
- }
91
- if (response.status >= 300 && response.status < 400) {
92
- const redirectUrl = response.headers.get('Location');
93
- if (redirectUrl) {
94
- response = await fetch(redirectUrl);
95
- }
96
- }
97
- req.file = {
98
- name: filename,
99
- data: Buffer.from(await response.arrayBuffer()),
100
- directUpload,
101
- mimetype: response.headers.get('Content-Type') || mimeType,
102
- size
103
- };
65
+ req.file = await getFileFromUploadInstructions({
66
+ collectionSlug,
67
+ file: uploadedFile,
68
+ req
69
+ });
104
70
  }
105
71
  }
106
72
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/addDataAndFileToRequest.ts"],"sourcesContent":["import type { PayloadRequest } from '../types/index.js'\n\nimport { APIError } from '../errors/APIError.js'\nimport { processMultipartFormdata } from '../uploads/fetchAPI-multipart/index.js'\n\ntype AddDataAndFileToRequest = (req: PayloadRequest) => Promise<void>\n\n/**\n * Mutates the Request, appending 'data' and 'file' if found\n */\nexport const addDataAndFileToRequest: AddDataAndFileToRequest = async (req) => {\n const { body, headers, method, payload } = req\n\n if (method && ['PATCH', 'POST', 'PUT'].includes(method.toUpperCase()) && body) {\n const [contentType] = (headers.get('Content-Type') || '').split(';', 1)\n const bodyByteSize = parseInt(req.headers.get('Content-Length') || '0', 10)\n const hasBodyStream = req.body !== null\n\n if (contentType === 'application/json') {\n try {\n const text = await req.text?.()\n const data = text ? JSON.parse(text) : {}\n req.data = data\n // @ts-expect-error attach json method to request\n req.json = () => Promise.resolve(data)\n } catch (error) {\n if (error instanceof SyntaxError) {\n throw new APIError('Invalid JSON', 400)\n }\n req.payload.logger.error(error)\n throw error\n }\n } else if ((bodyByteSize || hasBodyStream) && contentType?.includes('multipart/')) {\n const { error, fields, files } = await processMultipartFormdata({\n options: {\n ...(payload.config.bodyParser || {}),\n ...(payload.config.upload || {}),\n },\n request: req as Request,\n })\n\n if (error) {\n throw new APIError(error.message)\n }\n\n // Set all files on req.files for access by hooks\n if (files) {\n req.files = files\n // Backwards compatibility: set req.file for standard upload collections\n // Guard: if multiple files share the field name \"file\", files.file is an array — skip\n if (files.file && !Array.isArray(files.file)) {\n req.file = files.file\n }\n }\n\n if (fields?._payload && typeof fields._payload === 'string') {\n req.data = JSON.parse(fields._payload)\n }\n\n if (!req.file && fields?.file && typeof fields?.file === 'string') {\n let directUpload, filename, mimeType, size\n const collectionSlug = req.routeParams?.collection as string\n try {\n ;({ directUpload, filename, mimeType, size } = JSON.parse(fields.file))\n } catch {\n throw new APIError('A file name is required.', 400)\n }\n const uploadConfig = req.payload.collections[collectionSlug]!.config.upload\n\n if (!uploadConfig.handlers) {\n throw new APIError('uploadConfig.handlers is not present for ' + collectionSlug)\n }\n\n let response: null | Response = null\n let error: unknown\n\n for (const handler of uploadConfig.handlers) {\n try {\n const result = await handler(req, {\n doc: null!,\n params: {\n collection: collectionSlug,\n directUpload,\n filename,\n },\n })\n if (result) {\n response = result\n }\n // If we couldn't get the file from that handler, save the error and try other.\n } catch (err) {\n error = err\n }\n }\n\n if (!response) {\n if (error) {\n payload.logger.error(error)\n }\n\n throw new APIError('Expected response from the upload handler.')\n }\n\n if (response.status >= 300 && response.status < 400) {\n const redirectUrl = response.headers.get('Location')\n if (redirectUrl) {\n response = await fetch(redirectUrl)\n }\n }\n\n req.file = {\n name: filename,\n data: Buffer.from(await response.arrayBuffer()),\n directUpload,\n mimetype: response.headers.get('Content-Type') || mimeType,\n size,\n }\n }\n }\n }\n}\n"],"names":["APIError","processMultipartFormdata","addDataAndFileToRequest","req","body","headers","method","payload","includes","toUpperCase","contentType","get","split","bodyByteSize","parseInt","hasBodyStream","text","data","JSON","parse","json","Promise","resolve","error","SyntaxError","logger","fields","files","options","config","bodyParser","upload","request","message","file","Array","isArray","_payload","directUpload","filename","mimeType","size","collectionSlug","routeParams","collection","uploadConfig","collections","handlers","response","handler","result","doc","params","err","status","redirectUrl","fetch","name","Buffer","from","arrayBuffer","mimetype"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,wBAAuB;AAChD,SAASC,wBAAwB,QAAQ,yCAAwC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gBAEA,IAAI,CAACL,UAAU;oBACb,IAAIzB,OAAO;wBACThB,QAAQkB,MAAM,CAACF,KAAK,CAACA;oBACvB;oBAEA,MAAM,IAAIvB,SAAS;gBACrB;gBAEA,IAAIgD,SAASM,MAAM,IAAI,OAAON,SAASM,MAAM,GAAG,KAAK;oBACnD,MAAMC,cAAcP,SAAS3C,OAAO,CAACM,GAAG,CAAC;oBACzC,IAAI4C,aAAa;wBACfP,WAAW,MAAMQ,MAAMD;oBACzB;gBACF;gBAEApD,IAAI+B,IAAI,GAAG;oBACTuB,MAAMlB;oBACNtB,MAAMyC,OAAOC,IAAI,CAAC,MAAMX,SAASY,WAAW;oBAC5CtB;oBACAuB,UAAUb,SAAS3C,OAAO,CAACM,GAAG,CAAC,mBAAmB6B;oBAClDC;gBACF;YACF;QACF;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../src/utilities/addDataAndFileToRequest.ts"],"sourcesContent":["import type { PayloadRequest } from '../types/index.js'\nimport type { UploadInstructions } from '../uploads/types.js'\n\nimport { APIError } from '../errors/APIError.js'\nimport { processMultipartFormdata } from '../uploads/fetchAPI-multipart/index.js'\nimport { getFileFromUploadInstructions } from '../uploads/getFileFromUploadInstructions.js'\n\ntype AddDataAndFileToRequest = (req: PayloadRequest) => Promise<void>\n\n/**\n * Mutates the Request, appending 'data' and 'file' if found\n */\nexport const addDataAndFileToRequest: AddDataAndFileToRequest = async (req) => {\n const { body, headers, method, payload } = req\n\n if (method && ['PATCH', 'POST', 'PUT'].includes(method.toUpperCase()) && body) {\n const [contentType] = (headers.get('Content-Type') || '').split(';', 1)\n const bodyByteSize = parseInt(req.headers.get('Content-Length') || '0', 10)\n const hasBodyStream = req.body !== null\n\n if (contentType === 'application/json') {\n try {\n const text = await req.text?.()\n const data = text ? JSON.parse(text) : {}\n req.data = data\n // @ts-expect-error attach json method to request\n req.json = () => Promise.resolve(data)\n } catch (error) {\n if (error instanceof SyntaxError) {\n throw new APIError('Invalid JSON', 400)\n }\n req.payload.logger.error(error)\n throw error\n }\n } else if ((bodyByteSize || hasBodyStream) && contentType?.includes('multipart/')) {\n const { error, fields, files } = await processMultipartFormdata({\n options: {\n ...(payload.config.bodyParser || {}),\n ...(payload.config.upload || {}),\n },\n request: req as Request,\n })\n\n if (error) {\n throw new APIError(error.message)\n }\n\n // Set all files on req.files for access by hooks\n if (files) {\n req.files = files\n // Backwards compatibility: set req.file for standard upload collections\n // Guard: if multiple files share the field name \"file\", files.file is an array — skip\n if (files.file && !Array.isArray(files.file)) {\n req.file = files.file\n }\n }\n\n if (fields?._payload && typeof fields._payload === 'string') {\n req.data = JSON.parse(fields._payload)\n }\n\n if (!req.file && fields?.file && typeof fields?.file === 'string') {\n let uploadedFile: UploadInstructions['file']\n try {\n uploadedFile = JSON.parse(fields.file)\n } catch {\n throw new APIError('A file name is required.', 400)\n }\n const collectionSlug =\n typeof req.routeParams?.collection === 'string'\n ? req.routeParams.collection\n : uploadedFile.collectionSlug\n const uploadConfig = collectionSlug\n ? req.payload.collections[collectionSlug]?.config.upload\n : undefined\n\n if (!collectionSlug || !uploadConfig) {\n throw new APIError('Invalid upload collection.', 400)\n }\n\n req.file = await getFileFromUploadInstructions({\n collectionSlug,\n file: uploadedFile,\n req,\n })\n }\n }\n }\n}\n"],"names":["APIError","processMultipartFormdata","getFileFromUploadInstructions","addDataAndFileToRequest","req","body","headers","method","payload","includes","toUpperCase","contentType","get","split","bodyByteSize","parseInt","hasBodyStream","text","data","JSON","parse","json","Promise","resolve","error","SyntaxError","logger","fields","files","options","config","bodyParser","upload","request","message","file","Array","isArray","_payload","uploadedFile","collectionSlug","routeParams","collection","uploadConfig","collections","undefined"],"mappings":"AAGA,SAASA,QAAQ,QAAQ,wBAAuB;AAChD,SAASC,wBAAwB,QAAQ,yCAAwC;AACjF,SAASC,6BAA6B,QAAQ,8CAA6C;AAI3F;;CAEC,GACD,OAAO,MAAMC,0BAAmD,OAAOC;IACrE,MAAM,EAAEC,IAAI,EAAEC,OAAO,EA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AAsF;gBACtF,IAAIA,MAAMO,IAAI,IAAI,CAACC,MAAMC,OAAO,CAACT,MAAMO,IAAI,GAAG;oBAC5C/B,IAAI+B,IAAI,GAAGP,MAAMO,IAAI;gBACvB;YACF;YAEA,IAAIR,QAAQW,YAAY,OAAOX,OAAOW,QAAQ,KAAK,UAAU;gBAC3DlC,IAAIc,IAAI,GAAGC,KAAKC,KAAK,CAACO,OAAOW,QAAQ;YACvC;YAEA,IAAI,CAAClC,IAAI+B,IAAI,IAAIR,QAAQQ,QAAQ,OAAOR,QAAQQ,SAAS,UAAU;gBACjE,IAAII;gBACJ,IAAI;oBACFA,eAAepB,KAAKC,KAAK,CAACO,OAAOQ,IAAI;gBACvC,EAAE,OAAM;oBACN,MAAM,IAAInC,SAAS,4BAA4B;gBACjD;gBACA,MAAMwC,iBACJ,OAAOpC,IAAIqC,WAAW,EAAEC,eAAe,WACnCtC,IAAIqC,WAAW,CAACC,UAAU,GAC1BH,aAAaC,cAAc;gBACjC,MAAMG,eAAeH,iBACjBpC,IAAII,OAAO,CAACoC,WAAW,CAACJ,eAAe,EAAEV,OAAOE,SAChDa;gBAEJ,IAAI,CAACL,kBAAkB,CAACG,cAAc;oBACpC,MAAM,IAAI3C,SAAS,8BAA8B;gBACnD;gBAEAI,IAAI+B,IAAI,GAAG,MAAMjC,8BAA8B;oBAC7CsC;oBACAL,MAAMI;oBACNnC;gBACF;YACF;QACF;IACF;AACF,EAAC"}
@@ -2,7 +2,7 @@ import { describe, it, expect } from 'vitest';
2
2
  import { sanitizeConfig } from '../config/sanitize.js';
3
3
  import { configToJSONSchema, entityToStandaloneJSONSchema } from './configToJSONSchema.js';
4
4
  describe('configToJSONSchema', ()=>{
5
- it('should handle optional arrays with required fields', async ()=>{
5
+ it('should handle optional arrays with required fields', ()=>{
6
6
  // @ts-expect-error
7
7
  const config = {
8
8
  collections: [
@@ -26,7 +26,7 @@ describe('configToJSONSchema', ()=>{
26
26
  }
27
27
  ]
28
28
  };
29
- const sanitizedConfig = await sanitizeConfig(config);
29
+ const sanitizedConfig = sanitizeConfig(config);
30
30
  const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text');
31
31
  expect(schema?.$defs?.test).toStrictEqual({
32
32
  type: 'object',
@@ -66,7 +66,7 @@ describe('configToJSONSchema', ()=>{
66
66
  title: 'Test'
67
67
  });
68
68
  });
69
- it('should generate separate input types when generateInputTypes is enabled', async ()=>{
69
+ it('should generate separate input types when generateInputTypes is enabled', ()=>{
70
70
  // @ts-expect-error partial config
71
71
  const config = {
72
72
  collections: [
@@ -124,7 +124,7 @@ describe('configToJSONSchema', ()=>{
124
124
  generateInputTypes: true
125
125
  }
126
126
  };
127
- const sanitizedConfig = await sanitizeConfig(config);
127
+ const sanitizedConfig = sanitizeConfig(config);
128
128
  const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text');
129
129
  // Output (read) shape is unchanged: relationships may be populated, managed fields are present,
130
130
  // and a required field with a defaultValue stays required.
@@ -212,7 +212,7 @@ describe('configToJSONSchema', ()=>{
212
212
  $ref: '#/$defs/posts_input'
213
213
  });
214
214
  });
215
- it('should keep _status in the input schema for draft-enabled entities', async ()=>{
215
+ it('should keep _status in the input schema for draft-enabled entities', ()=>{
216
216
  // @ts-expect-error partial config
217
217
  const config = {
218
218
  collections: [
@@ -231,7 +231,7 @@ describe('configToJSONSchema', ()=>{
231
231
  }
232
232
  ]
233
233
  };
234
- const sanitizedConfig = await sanitizeConfig(config);
234
+ const sanitizedConfig = sanitizeConfig(config);
235
235
  const entity = sanitizedConfig.collections[0];
236
236
  const schema = entityToStandaloneJSONSchema({
237
237
  config: sanitizedConfig,
@@ -249,7 +249,7 @@ describe('configToJSONSchema', ()=>{
249
249
  expect(schema.properties?.createdAt).toBeUndefined();
250
250
  expect(schema.properties?.updatedAt).toBeUndefined();
251
251
  });
252
- it('should skip input types by default and generate them when enabled', async ()=>{
252
+ it('should skip input types by default and generate them when enabled', ()=>{
253
253
  // @ts-expect-error partial config
254
254
  const offByDefault = {
255
255
  collections: [
@@ -264,7 +264,7 @@ describe('configToJSONSchema', ()=>{
264
264
  }
265
265
  ]
266
266
  };
267
- const { jsonSchema: defaultSchema } = configToJSONSchema(await sanitizeConfig(offByDefault), 'text');
267
+ const { jsonSchema: defaultSchema } = configToJSONSchema(sanitizeConfig(offByDefault), 'text');
268
268
  expect(defaultSchema?.$defs?.posts_input).toBeUndefined();
269
269
  expect(defaultSchema?.properties?.collectionsInput).toBeUndefined();
270
270
  // @ts-expect-error partial config
@@ -284,11 +284,11 @@ describe('configToJSONSchema', ()=>{
284
284
  generateInputTypes: true
285
285
  }
286
286
  };
287
- const { jsonSchema: enabledSchema } = configToJSONSchema(await sanitizeConfig(enabled), 'text');
287
+ const { jsonSchema: enabledSchema } = configToJSONSchema(sanitizeConfig(enabled), 'text');
288
288
  expect(enabledSchema?.$defs?.posts_input).toBeDefined();
289
289
  expect(enabledSchema?.properties?.collectionsInput).toBeDefined();
290
290
  });
291
- it('should generate Input-suffixed definitions for named interfaces and blocks', async ()=>{
291
+ it('should generate Input-suffixed definitions for named interfaces and blocks', ()=>{
292
292
  // @ts-expect-error partial config
293
293
  const config = {
294
294
  collections: [
@@ -344,7 +344,7 @@ describe('configToJSONSchema', ()=>{
344
344
  generateInputTypes: true
345
345
  }
346
346
  };
347
- const sanitizedConfig = await sanitizeConfig(config);
347
+ const sanitizedConfig = sanitizeConfig(config);
348
348
  const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text');
349
349
  // Read-shaped named interface keeps the populated-doc union...
350
350
  expect((schema?.$defs?.Meta).properties.author).toStrictEqual({
@@ -393,7 +393,7 @@ describe('configToJSONSchema', ()=>{
393
393
  ]
394
394
  });
395
395
  });
396
- it('passes the variant to field-level jsonSchema transforms', async ()=>{
396
+ it('passes the variant to field-level jsonSchema transforms', ()=>{
397
397
  // @ts-expect-error partial config
398
398
  const config = {
399
399
  collections: [
@@ -417,12 +417,12 @@ describe('configToJSONSchema', ()=>{
417
417
  generateInputTypes: true
418
418
  }
419
419
  };
420
- const sanitizedConfig = await sanitizeConfig(config);
420
+ const sanitizedConfig = sanitizeConfig(config);
421
421
  const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text');
422
422
  expect((schema?.$defs?.posts).properties.custom.description).toBe('output');
423
423
  expect((schema?.$defs?.posts_input).properties.custom.description).toBe('input');
424
424
  });
425
- it('should handle block fields with no blocks', async ()=>{
425
+ it('should handle block fields with no blocks', ()=>{
426
426
  // @ts-expect-error
427
427
  const config = {
428
428
  collections: [
@@ -477,7 +477,7 @@ describe('configToJSONSchema', ()=>{
477
477
  }
478
478
  ]
479
479
  };
480
- const sanitizedConfig = await sanitizeConfig(config);
480
+ const sanitizedConfig = sanitizeConfig(config);
481
481
  const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text');
482
482
  expect(schema?.$defs?.test).toStrictEqual({
483
483
  type: 'object',
@@ -531,7 +531,7 @@ describe('configToJSONSchema', ()=>{
531
531
  title: 'Test'
532
532
  });
533
533
  });
534
- it('keeps the first block interface name clean and content-hashes the colliding one', async ()=>{
534
+ it('keeps the first block interface name clean and content-hashes the colliding one', ()=>{
535
535
  // @ts-expect-error - partial config for testing
536
536
  const config = {
537
537
  collections: [
@@ -591,7 +591,7 @@ describe('configToJSONSchema', ()=>{
591
591
  }
592
592
  ]
593
593
  };
594
- const sanitizedConfig = await sanitizeConfig(config);
594
+ const sanitizedConfig = sanitizeConfig(config);
595
595
  const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text');
596
596
  const defs = schema.$defs;
597
597
  // The first `hero` keeps the clean name; the unique block is unaffected.
@@ -614,7 +614,7 @@ describe('configToJSONSchema', ()=>{
614
614
  const { jsonSchema: schema2 } = configToJSONSchema(sanitizedConfig, 'text');
615
615
  expect(Object.keys(schema2.$defs).filter((k)=>/^Hero/.test(k)).sort()).toStrictEqual(Object.keys(defs).filter((k)=>/^Hero/.test(k)).sort());
616
616
  });
617
- it('should handle tabs and named tabs with required fields', async ()=>{
617
+ it('should handle tabs and named tabs with required fields', ()=>{
618
618
  // @ts-expect-error
619
619
  const config = {
620
620
  collections: [
@@ -662,7 +662,7 @@ describe('configToJSONSchema', ()=>{
662
662
  }
663
663
  ]
664
664
  };
665
- const sanitizedConfig = await sanitizeConfig(config);
665
+ const sanitizedConfig = sanitizeConfig(config);
666
666
  const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text');
667
667
  expect(schema?.$defs?.test).toStrictEqual({
668
668
  type: 'object',
@@ -710,7 +710,7 @@ describe('configToJSONSchema', ()=>{
710
710
  title: 'Test'
711
711
  });
712
712
  });
713
- it('should handle custom typescript schema and JSON field schema', async ()=>{
713
+ it('should handle custom typescript schema and JSON field schema', ()=>{
714
714
  const customSchema = {
715
715
  type: 'object',
716
716
  properties: {
@@ -751,7 +751,7 @@ describe('configToJSONSchema', ()=>{
751
751
  }
752
752
  ]
753
753
  };
754
- const sanitizedConfig = await sanitizeConfig(config);
754
+ const sanitizedConfig = sanitizeConfig(config);
755
755
  const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text');
756
756
  expect(schema?.$defs?.test).toStrictEqual({
757
757
  type: 'object',
@@ -769,7 +769,7 @@ describe('configToJSONSchema', ()=>{
769
769
  title: 'Test'
770
770
  });
771
771
  });
772
- it('should handle same block object being referenced in both collection and config.blocks', async ()=>{
772
+ it('should handle same block object being referenced in both collection and config.blocks', ()=>{
773
773
  const sharedBlock = {
774
774
  slug: 'sharedBlock',
775
775
  interfaceName: 'SharedBlock',
@@ -811,7 +811,7 @@ describe('configToJSONSchema', ()=>{
811
811
  ]
812
812
  };
813
813
  // Ensure both rich text editor are sanitized
814
- const sanitizedConfig = await sanitizeConfig(config);
814
+ const sanitizedConfig = sanitizeConfig(config);
815
815
  expect(typeof sanitizedConfig?.blocks?.[0]?.fields?.[0]?.editor).toBe('object');
816
816
  expect(typeof sanitizedConfig.collections[0].fields[0]?.blocks?.[0]?.fields?.[0]?.editor).toBe('object');
817
817
  const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text');
@@ -877,7 +877,7 @@ describe('configToJSONSchema', ()=>{
877
877
  // The definition should still be registered for TypeScript type generation
878
878
  expect(schema?.$defs?.SharedBlock).toStrictEqual(expectedBlockSchema);
879
879
  });
880
- it('content-hashes a colliding explicit interfaceName instead of overwriting it', async ()=>{
880
+ it('content-hashes a colliding explicit interfaceName instead of overwriting it', ()=>{
881
881
  // Two different blocks both set `interfaceName: 'Hero'` - each must keep its own definition.
882
882
  const config = {
883
883
  collections: [
@@ -916,7 +916,7 @@ describe('configToJSONSchema', ()=>{
916
916
  }
917
917
  ]
918
918
  };
919
- const sanitizedConfig = await sanitizeConfig(config);
919
+ const sanitizedConfig = sanitizeConfig(config);
920
920
  const { jsonSchema } = configToJSONSchema(sanitizedConfig, 'text');
921
921
  const defs = jsonSchema.$defs;
922
922
  // Each differently-shaped block keeps its own interface (one clean, one hash-suffixed).
@@ -926,7 +926,7 @@ describe('configToJSONSchema', ()=>{
926
926
  const shapeOf = (name)=>Object.keys(defs[name].properties).sort().join(',');
927
927
  expect(shapeOf(heroNames[0])).not.toBe(shapeOf(heroNames[1]));
928
928
  });
929
- it('reuses one definition when the same block is registered more than once', async ()=>{
929
+ it('reuses one definition when the same block is registered more than once', ()=>{
930
930
  // Reusing one block across fields registers an identical schema each time, so it dedupes.
931
931
  const heroBlock = {
932
932
  slug: 'hero',
@@ -963,14 +963,14 @@ describe('configToJSONSchema', ()=>{
963
963
  }
964
964
  ]
965
965
  };
966
- const sanitizedConfig = await sanitizeConfig(config);
966
+ const sanitizedConfig = sanitizeConfig(config);
967
967
  const { jsonSchema } = configToJSONSchema(sanitizedConfig, 'text');
968
968
  const heroNames = Object.keys(jsonSchema.$defs).filter((k)=>/^Hero(_[0-9A-F]{8})?$/.test(k));
969
969
  expect(heroNames).toEqual([
970
970
  'Hero'
971
971
  ]);
972
972
  });
973
- it('should allow overriding required to false', async ()=>{
973
+ it('should allow overriding required to false', ()=>{
974
974
  // @ts-expect-error
975
975
  const config = {
976
976
  collections: [
@@ -995,12 +995,12 @@ describe('configToJSONSchema', ()=>{
995
995
  }
996
996
  ]
997
997
  };
998
- const sanitizedConfig = await sanitizeConfig(config);
998
+ const sanitizedConfig = sanitizeConfig(config);
999
999
  const { jsonSchema: schema } = configToJSONSchema(sanitizedConfig, 'text');
1000
1000
  // @ts-expect-error
1001
1001
  expect(schema.$defs.test.properties.title.required).toStrictEqual(false);
1002
1002
  });
1003
- it('should propagate forceInlineBlocks to nested fields (array, group, tab)', async ()=>{
1003
+ it('should propagate forceInlineBlocks to nested fields (array, group, tab)', ()=>{
1004
1004
  const namedBlock = {
1005
1005
  slug: 'myBlock',
1006
1006
  interfaceName: 'MyBlock',
@@ -1049,7 +1049,7 @@ describe('configToJSONSchema', ()=>{
1049
1049
  }
1050
1050
  ]
1051
1051
  };
1052
- const sanitizedConfig = await sanitizeConfig(config);
1052
+ const sanitizedConfig = sanitizeConfig(config);
1053
1053
  // Without forceInlineBlocks: blocks field uses $ref
1054
1054
  const { jsonSchema: schemaDefault } = configToJSONSchema(sanitizedConfig, 'text');
1055
1055
  const arrItemsDefault = schemaDefault.$defs.test.properties.arr.items;
@@ -1073,7 +1073,7 @@ describe('configToJSONSchema', ()=>{
1073
1073
  const: 'myBlock'
1074
1074
  });
1075
1075
  });
1076
- it('entityToStandaloneJSONSchema bundles only the definitions an entity references', async ()=>{
1076
+ it('entityToStandaloneJSONSchema bundles only the definitions an entity references', ()=>{
1077
1077
  const sharedBlock = {
1078
1078
  slug: 'sharedBlock',
1079
1079
  interfaceName: 'SharedBlock',
@@ -1136,7 +1136,7 @@ describe('configToJSONSchema', ()=>{
1136
1136
  }
1137
1137
  ]
1138
1138
  };
1139
- const sanitizedConfig = await sanitizeConfig(config);
1139
+ const sanitizedConfig = sanitizeConfig(config);
1140
1140
  const entity = sanitizedConfig.collections.find((collection)=>collection.slug === 'with-refs');
1141
1141
  const schema = entityToStandaloneJSONSchema({
1142
1142
  config: sanitizedConfig,