payload 4.0.0-internal.2fddfc0 → 4.0.0-internal.3aa3d85

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 (262) hide show
  1. package/LICENSE.md +1 -1
  2. package/bin.js +11 -0
  3. package/dist/admin/RichText.d.ts +1 -21
  4. package/dist/admin/RichText.d.ts.map +1 -1
  5. package/dist/admin/RichText.js.map +1 -1
  6. package/dist/admin/forms/Field.d.ts +2 -2
  7. package/dist/admin/forms/Field.d.ts.map +1 -1
  8. package/dist/admin/forms/Field.js.map +1 -1
  9. package/dist/admin/forms/Form.d.ts +0 -29
  10. package/dist/admin/forms/Form.d.ts.map +1 -1
  11. package/dist/admin/forms/Form.js.map +1 -1
  12. package/dist/admin/functions/index.d.ts +1 -1
  13. package/dist/admin/functions/index.js.map +1 -1
  14. package/dist/admin/types.d.ts +1 -0
  15. package/dist/admin/types.d.ts.map +1 -1
  16. package/dist/admin/types.js.map +1 -1
  17. package/dist/auth/operations/auth.d.ts +2 -2
  18. package/dist/auth/operations/auth.d.ts.map +1 -1
  19. package/dist/auth/operations/auth.js.map +1 -1
  20. package/dist/auth/operations/login.d.ts +2 -1
  21. package/dist/auth/operations/login.d.ts.map +1 -1
  22. package/dist/auth/operations/login.js.map +1 -1
  23. package/dist/auth/operations/me.js.map +1 -1
  24. package/dist/auth/operations/refresh.d.ts.map +1 -1
  25. package/dist/auth/operations/refresh.js +9 -3
  26. package/dist/auth/operations/refresh.js.map +1 -1
  27. package/dist/auth/operations/resetPassword.d.ts.map +1 -1
  28. package/dist/auth/operations/resetPassword.js.map +1 -1
  29. package/dist/auth/sendVerificationEmail.d.ts +2 -2
  30. package/dist/auth/sendVerificationEmail.d.ts.map +1 -1
  31. package/dist/auth/sendVerificationEmail.js +1 -1
  32. package/dist/auth/sendVerificationEmail.js.map +1 -1
  33. package/dist/auth/sessions.d.ts +4 -5
  34. package/dist/auth/sessions.d.ts.map +1 -1
  35. package/dist/auth/sessions.js +5 -3
  36. package/dist/auth/sessions.js.map +1 -1
  37. package/dist/auth/strategies/apiKey.js.map +1 -1
  38. package/dist/auth/strategies/local/incrementLoginAttempts.d.ts +2 -2
  39. package/dist/auth/strategies/local/incrementLoginAttempts.d.ts.map +1 -1
  40. package/dist/auth/strategies/local/incrementLoginAttempts.js +1 -1
  41. package/dist/auth/strategies/local/incrementLoginAttempts.js.map +1 -1
  42. package/dist/auth/types.d.ts +28 -21
  43. package/dist/auth/types.d.ts.map +1 -1
  44. package/dist/auth/types.js.map +1 -1
  45. package/dist/bin/generateImportMap/iterateCollections.d.ts.map +1 -1
  46. package/dist/bin/generateImportMap/iterateCollections.js +10 -0
  47. package/dist/bin/generateImportMap/iterateCollections.js.map +1 -1
  48. package/dist/bin/generateImportMap/utilities/resolveImportMapFilePath.d.ts.map +1 -1
  49. package/dist/bin/generateImportMap/utilities/resolveImportMapFilePath.js +11 -3
  50. package/dist/bin/generateImportMap/utilities/resolveImportMapFilePath.js.map +1 -1
  51. package/dist/collections/config/client.d.ts +1 -1
  52. package/dist/collections/config/client.d.ts.map +1 -1
  53. package/dist/collections/config/client.js +1 -0
  54. package/dist/collections/config/client.js.map +1 -1
  55. package/dist/collections/config/defaults.d.ts +0 -4
  56. package/dist/collections/config/defaults.d.ts.map +1 -1
  57. package/dist/collections/config/defaults.js +0 -15
  58. package/dist/collections/config/defaults.js.map +1 -1
  59. package/dist/collections/config/types.d.ts +6 -0
  60. package/dist/collections/config/types.d.ts.map +1 -1
  61. package/dist/collections/config/types.js.map +1 -1
  62. package/dist/collections/operations/findDistinct.d.ts.map +1 -1
  63. package/dist/collections/operations/findDistinct.js +1 -0
  64. package/dist/collections/operations/findDistinct.js.map +1 -1
  65. package/dist/collections/operations/local/count.d.ts +3 -3
  66. package/dist/collections/operations/local/count.d.ts.map +1 -1
  67. package/dist/collections/operations/local/count.js.map +1 -1
  68. package/dist/collections/operations/local/countVersions.d.ts +3 -3
  69. package/dist/collections/operations/local/countVersions.d.ts.map +1 -1
  70. package/dist/collections/operations/local/countVersions.js.map +1 -1
  71. package/dist/collections/operations/local/create.d.ts +3 -3
  72. package/dist/collections/operations/local/create.d.ts.map +1 -1
  73. package/dist/collections/operations/local/create.js.map +1 -1
  74. package/dist/collections/operations/local/delete.d.ts +3 -3
  75. package/dist/collections/operations/local/delete.d.ts.map +1 -1
  76. package/dist/collections/operations/local/delete.js.map +1 -1
  77. package/dist/collections/operations/local/duplicate.d.ts +3 -3
  78. package/dist/collections/operations/local/duplicate.d.ts.map +1 -1
  79. package/dist/collections/operations/local/duplicate.js.map +1 -1
  80. package/dist/collections/operations/local/find.d.ts +3 -3
  81. package/dist/collections/operations/local/find.d.ts.map +1 -1
  82. package/dist/collections/operations/local/find.js.map +1 -1
  83. package/dist/collections/operations/local/findByID.d.ts +3 -3
  84. package/dist/collections/operations/local/findByID.d.ts.map +1 -1
  85. package/dist/collections/operations/local/findByID.js.map +1 -1
  86. package/dist/collections/operations/local/findDistinct.d.ts +2 -2
  87. package/dist/collections/operations/local/findDistinct.d.ts.map +1 -1
  88. package/dist/collections/operations/local/findDistinct.js.map +1 -1
  89. package/dist/collections/operations/local/findVersionByID.d.ts +3 -3
  90. package/dist/collections/operations/local/findVersionByID.d.ts.map +1 -1
  91. package/dist/collections/operations/local/findVersionByID.js.map +1 -1
  92. package/dist/collections/operations/local/findVersions.d.ts +3 -3
  93. package/dist/collections/operations/local/findVersions.d.ts.map +1 -1
  94. package/dist/collections/operations/local/findVersions.js.map +1 -1
  95. package/dist/collections/operations/local/restoreVersion.d.ts +3 -3
  96. package/dist/collections/operations/local/restoreVersion.d.ts.map +1 -1
  97. package/dist/collections/operations/local/restoreVersion.js.map +1 -1
  98. package/dist/collections/operations/local/update.d.ts +3 -3
  99. package/dist/collections/operations/local/update.d.ts.map +1 -1
  100. package/dist/collections/operations/local/update.js.map +1 -1
  101. package/dist/collections/operations/utilities/types.d.ts +0 -9
  102. package/dist/collections/operations/utilities/types.d.ts.map +1 -1
  103. package/dist/collections/operations/utilities/types.js.map +1 -1
  104. package/dist/config/client.d.ts +2 -2
  105. package/dist/config/client.d.ts.map +1 -1
  106. package/dist/config/client.js.map +1 -1
  107. package/dist/config/defaults.d.ts +0 -4
  108. package/dist/config/defaults.d.ts.map +1 -1
  109. package/dist/config/defaults.js +0 -78
  110. package/dist/config/defaults.js.map +1 -1
  111. package/dist/config/definePlugin.d.ts +10 -10
  112. package/dist/config/definePlugin.d.ts.map +1 -1
  113. package/dist/config/definePlugin.js +7 -11
  114. package/dist/config/definePlugin.js.map +1 -1
  115. package/dist/config/sanitize.d.ts.map +1 -1
  116. package/dist/config/sanitize.js +137 -13
  117. package/dist/config/sanitize.js.map +1 -1
  118. package/dist/config/types.d.ts +35 -3
  119. package/dist/config/types.d.ts.map +1 -1
  120. package/dist/config/types.js.map +1 -1
  121. package/dist/exports/internal.d.ts +1 -0
  122. package/dist/exports/internal.d.ts.map +1 -1
  123. package/dist/exports/internal.js +1 -0
  124. package/dist/exports/internal.js.map +1 -1
  125. package/dist/exports/shared.d.ts +3 -2
  126. package/dist/exports/shared.d.ts.map +1 -1
  127. package/dist/exports/shared.js +2 -1
  128. package/dist/exports/shared.js.map +1 -1
  129. package/dist/fields/baseFields/slug/countVersions.d.ts.map +1 -1
  130. package/dist/fields/baseFields/slug/countVersions.js +6 -8
  131. package/dist/fields/baseFields/slug/countVersions.js.map +1 -1
  132. package/dist/fields/baseFields/slug/generateSlug.d.ts +14 -7
  133. package/dist/fields/baseFields/slug/generateSlug.d.ts.map +1 -1
  134. package/dist/fields/baseFields/slug/generateSlug.js +53 -73
  135. package/dist/fields/baseFields/slug/generateSlug.js.map +1 -1
  136. package/dist/fields/baseFields/slug/types.d.ts +14 -0
  137. package/dist/fields/baseFields/slug/types.d.ts.map +1 -0
  138. package/dist/fields/baseFields/slug/types.js +6 -0
  139. package/dist/fields/baseFields/slug/types.js.map +1 -0
  140. package/dist/fields/config/client.d.ts +1 -1
  141. package/dist/fields/config/client.d.ts.map +1 -1
  142. package/dist/fields/config/client.js +2 -1
  143. package/dist/fields/config/client.js.map +1 -1
  144. package/dist/fields/config/sanitize.d.ts.map +1 -1
  145. package/dist/fields/config/sanitize.js +39 -0
  146. package/dist/fields/config/sanitize.js.map +1 -1
  147. package/dist/fields/config/types.d.ts +44 -8
  148. package/dist/fields/config/types.d.ts.map +1 -1
  149. package/dist/fields/config/types.js.map +1 -1
  150. package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
  151. package/dist/fields/hooks/afterRead/promise.js +11 -1
  152. package/dist/fields/hooks/afterRead/promise.js.map +1 -1
  153. package/dist/fields/hooks/beforeValidate/promise.d.ts.map +1 -1
  154. package/dist/fields/hooks/beforeValidate/promise.js +10 -1
  155. package/dist/fields/hooks/beforeValidate/promise.js.map +1 -1
  156. package/dist/fields/setDefaultBeforeDuplicate.js +1 -0
  157. package/dist/fields/setDefaultBeforeDuplicate.js.map +1 -1
  158. package/dist/fields/sortableFieldTypes.d.ts.map +1 -1
  159. package/dist/fields/sortableFieldTypes.js +1 -0
  160. package/dist/fields/sortableFieldTypes.js.map +1 -1
  161. package/dist/fields/validations.d.ts +4 -1
  162. package/dist/fields/validations.d.ts.map +1 -1
  163. package/dist/fields/validations.js +7 -0
  164. package/dist/fields/validations.js.map +1 -1
  165. package/dist/globals/operations/local/countVersions.d.ts +3 -3
  166. package/dist/globals/operations/local/countVersions.d.ts.map +1 -1
  167. package/dist/globals/operations/local/countVersions.js.map +1 -1
  168. package/dist/globals/operations/local/findOne.d.ts +3 -3
  169. package/dist/globals/operations/local/findOne.d.ts.map +1 -1
  170. package/dist/globals/operations/local/findOne.js.map +1 -1
  171. package/dist/globals/operations/local/findVersionByID.d.ts +3 -3
  172. package/dist/globals/operations/local/findVersionByID.d.ts.map +1 -1
  173. package/dist/globals/operations/local/findVersionByID.js.map +1 -1
  174. package/dist/globals/operations/local/findVersions.d.ts +3 -3
  175. package/dist/globals/operations/local/findVersions.d.ts.map +1 -1
  176. package/dist/globals/operations/local/findVersions.js.map +1 -1
  177. package/dist/globals/operations/local/restoreVersion.d.ts +3 -3
  178. package/dist/globals/operations/local/restoreVersion.d.ts.map +1 -1
  179. package/dist/globals/operations/local/restoreVersion.js.map +1 -1
  180. package/dist/globals/operations/local/update.d.ts +3 -3
  181. package/dist/globals/operations/local/update.d.ts.map +1 -1
  182. package/dist/globals/operations/local/update.js.map +1 -1
  183. package/dist/index.bundled.d.ts +365 -300
  184. package/dist/index.d.ts +59 -15
  185. package/dist/index.d.ts.map +1 -1
  186. package/dist/index.js +1 -2
  187. package/dist/index.js.map +1 -1
  188. package/dist/preferences/keys.d.ts +4 -0
  189. package/dist/preferences/keys.d.ts.map +1 -1
  190. package/dist/preferences/keys.js +4 -1
  191. package/dist/preferences/keys.js.map +1 -1
  192. package/dist/preferences/types.d.ts +15 -0
  193. package/dist/preferences/types.d.ts.map +1 -1
  194. package/dist/preferences/types.js +3 -1
  195. package/dist/preferences/types.js.map +1 -1
  196. package/dist/types/index.d.ts +8 -3
  197. package/dist/types/index.d.ts.map +1 -1
  198. package/dist/types/index.js.map +1 -1
  199. package/dist/uploads/fetchAPI-multipart/processMultipart.d.ts.map +1 -1
  200. package/dist/uploads/fetchAPI-multipart/processMultipart.js +1 -14
  201. package/dist/uploads/fetchAPI-multipart/processMultipart.js.map +1 -1
  202. package/dist/uploads/matchMimeType.d.ts +8 -0
  203. package/dist/uploads/matchMimeType.d.ts.map +1 -0
  204. package/dist/uploads/matchMimeType.js +19 -0
  205. package/dist/uploads/matchMimeType.js.map +1 -0
  206. package/dist/uploads/matchMimeType.spec.js +66 -0
  207. package/dist/uploads/matchMimeType.spec.js.map +1 -0
  208. package/dist/uploads/types.d.ts +21 -0
  209. package/dist/uploads/types.d.ts.map +1 -1
  210. package/dist/uploads/types.js.map +1 -1
  211. package/dist/utilities/addDataAndFileToRequest.d.ts.map +1 -1
  212. package/dist/utilities/addDataAndFileToRequest.js +6 -0
  213. package/dist/utilities/addDataAndFileToRequest.js.map +1 -1
  214. package/dist/utilities/configToJSONSchema.d.ts +13 -4
  215. package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
  216. package/dist/utilities/configToJSONSchema.js +139 -61
  217. package/dist/utilities/configToJSONSchema.js.map +1 -1
  218. package/dist/utilities/configToJSONSchema.spec.js +319 -0
  219. package/dist/utilities/configToJSONSchema.spec.js.map +1 -1
  220. package/dist/utilities/createLocalReq.d.ts +2 -2
  221. package/dist/utilities/createLocalReq.d.ts.map +1 -1
  222. package/dist/utilities/createLocalReq.js.map +1 -1
  223. package/dist/utilities/createPayloadRequest.d.ts.map +1 -1
  224. package/dist/utilities/createPayloadRequest.js +1 -0
  225. package/dist/utilities/createPayloadRequest.js.map +1 -1
  226. package/dist/utilities/getEntityPermissions/getEntityPermissions.d.ts.map +1 -1
  227. package/dist/utilities/getEntityPermissions/getEntityPermissions.js +2 -0
  228. package/dist/utilities/getEntityPermissions/getEntityPermissions.js.map +1 -1
  229. package/dist/utilities/getEntityPermissions/populateFieldPermissions.d.ts +7 -1
  230. package/dist/utilities/getEntityPermissions/populateFieldPermissions.d.ts.map +1 -1
  231. package/dist/utilities/getEntityPermissions/populateFieldPermissions.js +19 -2
  232. package/dist/utilities/getEntityPermissions/populateFieldPermissions.js.map +1 -1
  233. package/dist/utilities/isURLAllowed.d.ts.map +1 -1
  234. package/dist/utilities/isURLAllowed.js +9 -3
  235. package/dist/utilities/isURLAllowed.js.map +1 -1
  236. package/dist/utilities/isURLAllowed.spec.js +78 -0
  237. package/dist/utilities/isURLAllowed.spec.js.map +1 -0
  238. package/dist/utilities/telemetry/conf/envPaths.d.ts.map +1 -1
  239. package/dist/utilities/telemetry/conf/envPaths.js +40 -31
  240. package/dist/utilities/telemetry/conf/envPaths.js.map +1 -1
  241. package/dist/utilities/telemetry/events/adminInit.d.ts.map +1 -1
  242. package/dist/utilities/telemetry/events/adminInit.js +2 -3
  243. package/dist/utilities/telemetry/events/adminInit.js.map +1 -1
  244. package/dist/utilities/telemetry/events/serverInit.d.ts.map +1 -1
  245. package/dist/utilities/telemetry/events/serverInit.js +2 -3
  246. package/dist/utilities/telemetry/events/serverInit.js.map +1 -1
  247. package/dist/utilities/telemetry/index.d.ts +14 -3
  248. package/dist/utilities/telemetry/index.d.ts.map +1 -1
  249. package/dist/utilities/telemetry/index.js +6 -1
  250. package/dist/utilities/telemetry/index.js.map +1 -1
  251. package/dist/utilities/telemetry/index.spec.js +43 -0
  252. package/dist/utilities/telemetry/index.spec.js.map +1 -0
  253. package/dist/versions/schedule/job.js.map +1 -1
  254. package/package.json +3 -3
  255. package/dist/fields/baseFields/slug/index.d.ts +0 -89
  256. package/dist/fields/baseFields/slug/index.d.ts.map +0 -1
  257. package/dist/fields/baseFields/slug/index.js +0 -81
  258. package/dist/fields/baseFields/slug/index.js.map +0 -1
  259. package/dist/utilities/isRSCEnabled.d.ts +0 -12
  260. package/dist/utilities/isRSCEnabled.d.ts.map +0 -1
  261. package/dist/utilities/isRSCEnabled.js +0 -14
  262. package/dist/utilities/isRSCEnabled.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/preferences/types.ts"],"sourcesContent":["import type { DefaultDocumentIDType } from '../index.js'\nimport type { PayloadRequest } from '../types/index.js'\n\nexport type PreferenceRequest = {\n key: string\n overrideAccess?: boolean\n req: PayloadRequest\n user: PayloadRequest['user']\n}\n\nexport type PreferenceUpdateRequest = { value: unknown } & PreferenceRequest\n\nexport type CollapsedPreferences = string[]\n\nexport type TabsPreferences = Array<{\n [path: string]: number\n}>\n\nexport type InsideFieldsPreferences = {\n collapsed: CollapsedPreferences\n tabIndex: number\n}\n\nexport type FieldsPreferences = {\n [key: string]: InsideFieldsPreferences\n}\n\nexport type DocumentPreferences = {\n fields: FieldsPreferences\n}\n\nexport type ColumnPreference = {\n accessor: string\n active: boolean\n}\n\nexport type CollectionPreferences = {\n columns?: ColumnPreference[]\n editViewType?: 'default' | 'live-preview'\n groupBy?: string\n limit?: number\n listViewType?: 'hierarchy' | 'list'\n preset?: DefaultDocumentIDType\n sort?: string\n}\n"],"names":[],"mappings":"AAoCA,WAQC"}
1
+ {"version":3,"sources":["../../src/preferences/types.ts"],"sourcesContent":["import type { DefaultDocumentIDType } from '../index.js'\nimport type { PayloadRequest } from '../types/index.js'\n\nexport type PreferenceRequest = {\n key: string\n overrideAccess?: boolean\n req: PayloadRequest\n user: PayloadRequest['user']\n}\n\nexport type PreferenceUpdateRequest = { value: unknown } & PreferenceRequest\n\nexport type CollapsedPreferences = string[]\n\nexport type TabsPreferences = Array<{\n [path: string]: number\n}>\n\nexport type InsideFieldsPreferences = {\n collapsed: CollapsedPreferences\n tabIndex: number\n}\n\nexport type FieldsPreferences = {\n [key: string]: InsideFieldsPreferences\n}\n\nexport type DocumentPreferences = {\n fields: FieldsPreferences\n}\n\nexport type ColumnPreference = {\n accessor: string\n active: boolean\n}\n\nexport type CollectionPreferences = {\n columns?: ColumnPreference[]\n editViewType?: 'default' | 'live-preview'\n groupBy?: string\n limit?: number\n listViewType?: 'hierarchy' | 'list'\n preset?: DefaultDocumentIDType\n sort?: string\n}\n\n/**\n * A single document the user has viewed in the admin. Only identity and timestamp are stored;\n * display fields (title, thumbnail, etc.) are computed at render time from the live document.\n */\nexport type RecentlyViewedItem = {\n collectionSlug: string\n id: DefaultDocumentIDType\n viewedAt: string\n}\n\n/**\n * The `recently-viewed` preference value: the user's recently viewed documents, most recent first.\n */\nexport type RecentlyViewedPreferences = {\n items: RecentlyViewedItem[]\n}\n"],"names":[],"mappings":"AAwDA;;CAEC,GACD,WAEC"}
@@ -5,11 +5,16 @@ import type { URL } from 'url';
5
5
  import type { ServerAdapter } from '../admin/adapters/server.js';
6
6
  import type { DataFromCollectionSlug, QueryDraftDataFromCollectionSlug, TypeWithID, TypeWithTimestamps } from '../collections/config/types.js';
7
7
  import type payload from '../index.js';
8
- import type { CollectionSlug, DataFromGlobalSlug, GlobalSlug, Payload, RequestContext, TypedCollectionJoins, TypedCollectionSelect, TypedFallbackLocale, TypedLocale, TypedUser } from '../index.js';
8
+ import type { AuthenticatedUser, CollectionSlug, DataFromGlobalSlug, GlobalSlug, Payload, RequestContext, TypedCollectionJoins, TypedCollectionSelect, TypedFallbackLocale, TypedLocale } from '../index.js';
9
9
  import type { File } from '../uploads/types.js';
10
10
  import type { Operator } from './constants.js';
11
11
  export type { TypeWithID } from '../collections/config/types.js';
12
12
  export type { Payload } from '../index.js';
13
+ export interface PayloadRequestAPI {
14
+ GraphQL: true;
15
+ local: true;
16
+ REST: true;
17
+ }
13
18
  export type CustomPayloadRequestProperties = {
14
19
  context: RequestContext;
15
20
  /** The locale that should be used for a field when it is not translated to the requested locale */
@@ -29,7 +34,7 @@ export type CustomPayloadRequestProperties = {
29
34
  /**
30
35
  * The context in which the request is being made
31
36
  */
32
- payloadAPI: 'GraphQL' | 'local' | 'REST';
37
+ payloadAPI: keyof PayloadRequestAPI;
33
38
  /** Optimized document loader */
34
39
  payloadDataLoader: {
35
40
  /**
@@ -73,7 +78,7 @@ export type CustomPayloadRequestProperties = {
73
78
  */
74
79
  transactionID?: number | Promise<number | string> | string;
75
80
  /** The signed-in user */
76
- user: null | TypedUser;
81
+ user: AuthenticatedUser | null;
77
82
  } & Pick<URL, 'hash' | 'host' | 'href' | 'origin' | 'pathname' | 'port' | 'protocol' | 'search' | 'searchParams'>;
78
83
  type PayloadRequestData = {
79
84
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,KAAK,UAAU,MAAM,YAAY,CAAA;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC/D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAE9B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAChE,OAAO,KA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CACrC,GACC,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAEtC,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["import type { I18n, TFunction } from '@payloadcms/translations'\nimport type DataLoader from 'dataloader'\nimport type { OptionalKeys, RequiredKeys } from 'ts-essentials'\nimport type { URL } from 'url'\n\nimport type { ServerAdapter } from '../admin/adapters/server.js'\nimport type {\n DataFromCollectionSlug,\n QueryDraftDataFromCollectionSlug,\n TypeWithID,\n TypeWithTimestamps,\n} from '../collections/config/types.js'\nimport type payload from '../index.js'\nimport type {\n CollectionSlug,\n DataFromGlobalSlug,\n GlobalSlug,\n Payload,\n RequestContext,\n TypedCollectionJoins,\n TypedCollectionSelect,\n TypedFallbackLocale,\n TypedLocale,\n TypedUser,\n} from '../index.js'\nimport type { File } from '../uploads/types.js'\nimport type { Operator } from './constants.js'\nexport type { TypeWithID } from '../collections/config/types.js'\nexport type { Payload } from '../index.js'\n\nexport type CustomPayloadRequestProperties = {\n context: RequestContext\n /** The locale that should be used for a field when it is not translated to the requested locale */\n fallbackLocale?: TypedFallbackLocale\n i18n: I18n\n /**\n * The requested locale if specified\n * Only available for localized collections\n *\n * Suppressing warning below as it is a valid use case - won't be an issue if generated types exist\n */\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n locale?: 'all' | TypedLocale\n /**\n * The payload object\n */\n payload: typeof payload\n /**\n * The context in which the request is being made\n */\n payloadAPI: 'GraphQL' | 'local' | 'REST'\n /** Optimized document loader */\n payloadDataLoader: {\n /**\n * Wraps `payload.find` with a cache to deduplicate requests\n * @experimental This is may be replaced by a more robust cache strategy in future versions\n * By calling this method with the same arguments many times in one request, it will only be handled one time\n * const result = await req.payloadDataLoader.find({\n * collection,\n * req,\n * where: findWhere,\n * })\n */\n find: Payload['find']\n } & DataLoader<string, TypeWithID>\n /** Resized versions of the image that was uploaded during this request */\n payloadUploadSizes?: Record<string, Buffer>\n /** Query params on the request */\n query: Record<string, unknown>\n /** Any response headers that are required to be set when a response is sent */\n responseHeaders?: Headers\n /** The route parameters\n * @example\n * /:collection/:id -> /posts/123\n * { collection: 'posts', id: '123' }\n */\n routeParams?: Record<string, unknown>\n /**\n * Framework abstraction for server-only navigation, cookies, and headers APIs.\n * Populated by the framework adapter (e.g. `@payloadcms/next`). Plugins that\n * have access to `req` should call methods here (`req.server.unauthorized()`,\n * `req.server.redirect(...)`) instead of importing from `next/navigation` or\n * `next/headers` directly. Optional because non-framework contexts (jobs,\n * scripts, tests) construct requests without a server adapter.\n */\n server?: ServerAdapter\n /** Translate function - duplicate of i18n.t */\n t: TFunction\n /**\n * Identifier for the database transaction for interactions in a single, all-or-nothing operation.\n * Can also be used to ensure consistency when multiple operations try to create a transaction concurrently on the same request.\n */\n transactionID?: number | Promise<number | string> | string\n /** The signed-in user */\n user: null | TypedUser\n} & Pick<\n URL,\n 'hash' | 'host' | 'href' | 'origin' | 'pathname' | 'port' | 'protocol' | 'search' | 'searchParams'\n>\ntype PayloadRequestData = {\n /**\n * Data from the request body\n *\n * Within Payload operations, i.e. hooks, data will be there\n * BUT in custom endpoints it will not be, you will need to\n * use either:\n * 1. `const data = await req.json()`\n *\n * 2. import { addDataAndFileToRequest } from 'payload'\n * `await addDataAndFileToRequest(req)`\n *\n * You should not expect this object to be the document data. It is the request data.\n * */\n data?: JsonObject\n /** The file on the request, same rules apply as the `data` property */\n file?: {\n /**\n * Context of the file when it was uploaded via client side.\n */\n clientUploadContext?: unknown\n } & File\n /** All files from multipart form data, keyed by field name */\n files?: Record<string, File | File[]>\n}\nexport interface PayloadRequest\n extends CustomPayloadRequestProperties,\n Partial<Request>,\n PayloadRequestData {\n headers: Request['headers']\n}\n\nexport type { Operator }\n\n// Makes it so things like passing new Date() will error\nexport type JsonValue = JsonArray | JsonObject | unknown //Date | JsonArray | JsonObject | boolean | null | number | string // TODO: Evaluate proper, strong type for this\n\nexport type JsonArray = Array<JsonValue>\n\nexport interface JsonObject {\n [key: string]: any\n}\n\nexport type WhereField = {\n // any json-serializable value\n [key in Operator]?: JsonValue\n}\n\nexport type Where = {\n [key: string]: Where[] | WhereField\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n and?: Where[]\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n or?: Where[]\n}\n\nexport type Sort = Array<string> | string\n\ntype SerializableValue = boolean | number | object | string\nexport type DefaultValue =\n | ((args: {\n locale?: TypedLocale\n req: PayloadRequest\n user: PayloadRequest['user']\n }) => SerializableValue)\n | SerializableValue\n\n/**\n * Applies pagination for join fields for including collection relationships\n */\nexport type JoinQuery<TSlug extends CollectionSlug = string> =\n TypedCollectionJoins[TSlug] extends Record<string, string>\n ?\n | false\n | Partial<{\n [K in keyof TypedCollectionJoins[TSlug]]:\n | {\n count?: boolean\n limit?: number\n page?: number\n sort?: string\n where?: Where\n }\n | false\n }>\n : never\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type Document = any\n\nexport type Operation = 'create' | 'delete' | 'read' | 'update'\nexport type VersionOperations = 'readVersions'\nexport type AuthOperations = 'unlock'\nexport type AllOperations = AuthOperations | Operation | VersionOperations\n\nexport function docHasTimestamps(doc: any): doc is TypeWithTimestamps {\n return doc?.createdAt && doc?.updatedAt\n}\n\nexport type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N // This is a commonly used trick to detect 'any'\nexport type IsAny<T> = IfAny<T, true, false>\nexport type ReplaceAny<T, DefaultType> = IsAny<T> extends true ? DefaultType : T\n\nexport type SelectIncludeType = {\n [k: string]: SelectIncludeType | true\n}\n\nexport type SelectExcludeType = {\n [k: string]: false | SelectExcludeType\n}\n\nexport type SelectMode = 'exclude' | 'include'\n\nexport type SelectType = SelectExcludeType | SelectIncludeType\n\n/**\n * Operations that invoke an entity-level `select` function.\n *\n * Narrower than `HookOperationType`: `select` runs only for read- and\n * write-path operations that materialize a document (`create`, `delete`,\n * `read`, `restoreVersion`, `update`). Operations like `autosave`, `count`,\n * `countVersions`, `forgotPassword`, `login`, `readDistinct`, `refresh`, and\n * `resetPassword` do not invoke `select` and are intentionally excluded.\n */\nexport type SelectFnOperation = 'create' | 'delete' | 'read' | 'restoreVersion' | 'update'\n\nexport type SelectFnArgs = {\n operation: SelectFnOperation\n req: PayloadRequest\n /** The caller's `select` arg, or `undefined` if not provided. */\n select?: SelectType\n}\n\nexport type SelectFn<TSelect extends SelectType = SelectType> = (\n args: SelectFnArgs,\n) => TSelect | undefined\n\n/**\n * Shared shape for the entity-level `select` config used by Collections and Globals.\n * The JSDoc on the `select` property is the single source of truth — pick from this\n * type when defining the config:\n *\n * & Pick<WithSelectFn<...>, 'select'>\n */\nexport type WithSelectFn<TSelect extends SelectType = SelectType> = {\n /**\n * Entity-level Select API configuration.\n *\n * A function that receives the current request context (`operation`, `req`,\n * the caller's `select`) and returns the final `select` to apply, replacing\n * the caller's. Return `undefined` to leave the caller's `select` unchanged.\n *\n * Useful to dynamically modify the caller's selection based on the request context:\n * - Forcing a field to be populated for reference within hooks / access control.\n * - Differentiating between API requests and admin panel requests, to optimize\n * the amount of data being queried in each case.\n *\n * Note: per-document data is not available — this runs before the read.\n *\n * @see https://payloadcms.com/docs/queries/select\n */\n select?: SelectFn<TSelect>\n}\n\nexport type ApplyDisableErrors<T, DisableErrors = false> = false extends DisableErrors\n ? T\n : null | T\n\nexport type TransformDataWithSelect<\n Data extends Record<string, any>,\n Select extends SelectType,\n> = Select extends never\n ? Data\n : string extends keyof Select\n ? Data\n : // START Handle types when they aren't generated\n // For example in any package in this repository outside of tests / plugins\n // This stil gives us autocomplete when using include select mode, i.e select: {title :true} returns type {title: any, id: string | number}\n string extends keyof Omit<Data, 'id'>\n ? Select extends SelectIncludeType\n ? {\n [K in Data extends TypeWithID ? 'id' | keyof Select : keyof Select]: K extends 'id'\n ? number | string\n : unknown\n }\n : Data\n : // END Handle types when they aren't generated\n // Handle include mode\n Select extends SelectIncludeType\n ? {\n [K in keyof Data as K extends keyof Select\n ? Select[K] extends object | true\n ? K\n : never\n : // select 'id' always\n K extends 'id'\n ? K\n : never]: Data[K]\n }\n : // Handle exclude mode\n {\n [K in keyof Data as K extends keyof Select\n ? Select[K] extends object | undefined\n ? K\n : never\n : K]: Data[K]\n }\n\nexport type TransformCollectionWithSelect<\n TSlug extends CollectionSlug,\n TSelect extends SelectType,\n> = TSelect extends SelectType\n ? TransformDataWithSelect<DataFromCollectionSlug<TSlug>, TSelect>\n : DataFromCollectionSlug<TSlug>\n\nexport type DraftTransformCollectionWithSelect<\n TSlug extends CollectionSlug,\n TSelect extends SelectType,\n> = TSelect extends SelectType\n ? TransformDataWithSelect<QueryDraftDataFromCollectionSlug<TSlug>, TSelect>\n : QueryDraftDataFromCollectionSlug<TSlug>\n\nexport type TransformGlobalWithSelect<\n TSlug extends GlobalSlug,\n TSelect extends SelectType,\n> = TSelect extends SelectType\n ? TransformDataWithSelect<DataFromGlobalSlug<TSlug>, TSelect>\n : DataFromGlobalSlug<TSlug>\n\nexport type PopulateType = Partial<TypedCollectionSelect>\n\nexport type ResolvedFilterOptions = { [collection: string]: Where }\n\nexport type PickPreserveOptional<T, K extends keyof T> = Partial<\n Pick<T, Extract<K, OptionalKeys<T>>>\n> &\n Pick<T, Extract<K, RequiredKeys<T>>>\n\nexport type MaybePromise<T> = Promise<T> | T\n"],"names":["docHasTimestamps","doc","createdAt","updatedAt"],"mappings":"AAkMA,OAAO,SAASA,iBAAiBC,GAAQ;IACvC,OAAOA,KAAKC,aAAaD,KAAKE;AAChC"}
1
+ {"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["import type { I18n, TFunction } from '@payloadcms/translations'\nimport type DataLoader from 'dataloader'\nimport type { OptionalKeys, RequiredKeys } from 'ts-essentials'\nimport type { URL } from 'url'\n\nimport type { ServerAdapter } from '../admin/adapters/server.js'\nimport type {\n DataFromCollectionSlug,\n QueryDraftDataFromCollectionSlug,\n TypeWithID,\n TypeWithTimestamps,\n} from '../collections/config/types.js'\nimport type payload from '../index.js'\nimport type {\n AuthenticatedUser,\n CollectionSlug,\n DataFromGlobalSlug,\n GlobalSlug,\n Payload,\n RequestContext,\n TypedCollectionJoins,\n TypedCollectionSelect,\n TypedFallbackLocale,\n TypedLocale,\n} from '../index.js'\nimport type { File } from '../uploads/types.js'\nimport type { Operator } from './constants.js'\nexport type { TypeWithID } from '../collections/config/types.js'\nexport type { Payload } from '../index.js'\n\nexport interface PayloadRequestAPI {\n GraphQL: true\n local: true\n REST: true\n}\n\nexport type CustomPayloadRequestProperties = {\n context: RequestContext\n /** The locale that should be used for a field when it is not translated to the requested locale */\n fallbackLocale?: TypedFallbackLocale\n i18n: I18n\n /**\n * The requested locale if specified\n * Only available for localized collections\n *\n * Suppressing warning below as it is a valid use case - won't be an issue if generated types exist\n */\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\n locale?: 'all' | TypedLocale\n /**\n * The payload object\n */\n payload: typeof payload\n /**\n * The context in which the request is being made\n */\n payloadAPI: keyof PayloadRequestAPI\n /** Optimized document loader */\n payloadDataLoader: {\n /**\n * Wraps `payload.find` with a cache to deduplicate requests\n * @experimental This is may be replaced by a more robust cache strategy in future versions\n * By calling this method with the same arguments many times in one request, it will only be handled one time\n * const result = await req.payloadDataLoader.find({\n * collection,\n * req,\n * where: findWhere,\n * })\n */\n find: Payload['find']\n } & DataLoader<string, TypeWithID>\n /** Resized versions of the image that was uploaded during this request */\n payloadUploadSizes?: Record<string, Buffer>\n /** Query params on the request */\n query: Record<string, unknown>\n /** Any response headers that are required to be set when a response is sent */\n responseHeaders?: Headers\n /** The route parameters\n * @example\n * /:collection/:id -> /posts/123\n * { collection: 'posts', id: '123' }\n */\n routeParams?: Record<string, unknown>\n /**\n * Framework abstraction for server-only navigation, cookies, and headers APIs.\n * Populated by the framework adapter (e.g. `@payloadcms/next`). Plugins that\n * have access to `req` should call methods here (`req.server.unauthorized()`,\n * `req.server.redirect(...)`) instead of importing from `next/navigation` or\n * `next/headers` directly. Optional because non-framework contexts (jobs,\n * scripts, tests) construct requests without a server adapter.\n */\n server?: ServerAdapter\n /** Translate function - duplicate of i18n.t */\n t: TFunction\n /**\n * Identifier for the database transaction for interactions in a single, all-or-nothing operation.\n * Can also be used to ensure consistency when multiple operations try to create a transaction concurrently on the same request.\n */\n transactionID?: number | Promise<number | string> | string\n /** The signed-in user */\n user: AuthenticatedUser | null\n} & Pick<\n URL,\n 'hash' | 'host' | 'href' | 'origin' | 'pathname' | 'port' | 'protocol' | 'search' | 'searchParams'\n>\ntype PayloadRequestData = {\n /**\n * Data from the request body\n *\n * Within Payload operations, i.e. hooks, data will be there\n * BUT in custom endpoints it will not be, you will need to\n * use either:\n * 1. `const data = await req.json()`\n *\n * 2. import { addDataAndFileToRequest } from 'payload'\n * `await addDataAndFileToRequest(req)`\n *\n * You should not expect this object to be the document data. It is the request data.\n * */\n data?: JsonObject\n /** The file on the request, same rules apply as the `data` property */\n file?: {\n /**\n * Context of the file when it was uploaded via client side.\n */\n clientUploadContext?: unknown\n } & File\n /** All files from multipart form data, keyed by field name */\n files?: Record<string, File | File[]>\n}\nexport interface PayloadRequest\n extends CustomPayloadRequestProperties,\n Partial<Request>,\n PayloadRequestData {\n headers: Request['headers']\n}\n\nexport type { Operator }\n\n// Makes it so things like passing new Date() will error\nexport type JsonValue = JsonArray | JsonObject | unknown //Date | JsonArray | JsonObject | boolean | null | number | string // TODO: Evaluate proper, strong type for this\n\nexport type JsonArray = Array<JsonValue>\n\nexport interface JsonObject {\n [key: string]: any\n}\n\nexport type WhereField = {\n // any json-serializable value\n [key in Operator]?: JsonValue\n}\n\nexport type Where = {\n [key: string]: Where[] | WhereField\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n and?: Where[]\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n or?: Where[]\n}\n\nexport type Sort = Array<string> | string\n\ntype SerializableValue = boolean | number | object | string\nexport type DefaultValue =\n | ((args: {\n locale?: TypedLocale\n req: PayloadRequest\n user: PayloadRequest['user']\n }) => SerializableValue)\n | SerializableValue\n\n/**\n * Applies pagination for join fields for including collection relationships\n */\nexport type JoinQuery<TSlug extends CollectionSlug = string> =\n TypedCollectionJoins[TSlug] extends Record<string, string>\n ?\n | false\n | Partial<{\n [K in keyof TypedCollectionJoins[TSlug]]:\n | {\n count?: boolean\n limit?: number\n page?: number\n sort?: string\n where?: Where\n }\n | false\n }>\n : never\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type Document = any\n\nexport type Operation = 'create' | 'delete' | 'read' | 'update'\nexport type VersionOperations = 'readVersions'\nexport type AuthOperations = 'unlock'\nexport type AllOperations = AuthOperations | Operation | VersionOperations\n\nexport function docHasTimestamps(doc: any): doc is TypeWithTimestamps {\n return doc?.createdAt && doc?.updatedAt\n}\n\nexport type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N // This is a commonly used trick to detect 'any'\nexport type IsAny<T> = IfAny<T, true, false>\nexport type ReplaceAny<T, DefaultType> = IsAny<T> extends true ? DefaultType : T\n\nexport type SelectIncludeType = {\n [k: string]: SelectIncludeType | true\n}\n\nexport type SelectExcludeType = {\n [k: string]: false | SelectExcludeType\n}\n\nexport type SelectMode = 'exclude' | 'include'\n\nexport type SelectType = SelectExcludeType | SelectIncludeType\n\n/**\n * Operations that invoke an entity-level `select` function.\n *\n * Narrower than `HookOperationType`: `select` runs only for read- and\n * write-path operations that materialize a document (`create`, `delete`,\n * `read`, `restoreVersion`, `update`). Operations like `autosave`, `count`,\n * `countVersions`, `forgotPassword`, `login`, `readDistinct`, `refresh`, and\n * `resetPassword` do not invoke `select` and are intentionally excluded.\n */\nexport type SelectFnOperation = 'create' | 'delete' | 'read' | 'restoreVersion' | 'update'\n\nexport type SelectFnArgs = {\n operation: SelectFnOperation\n req: PayloadRequest\n /** The caller's `select` arg, or `undefined` if not provided. */\n select?: SelectType\n}\n\nexport type SelectFn<TSelect extends SelectType = SelectType> = (\n args: SelectFnArgs,\n) => TSelect | undefined\n\n/**\n * Shared shape for the entity-level `select` config used by Collections and Globals.\n * The JSDoc on the `select` property is the single source of truth — pick from this\n * type when defining the config:\n *\n * & Pick<WithSelectFn<...>, 'select'>\n */\nexport type WithSelectFn<TSelect extends SelectType = SelectType> = {\n /**\n * Entity-level Select API configuration.\n *\n * A function that receives the current request context (`operation`, `req`,\n * the caller's `select`) and returns the final `select` to apply, replacing\n * the caller's. Return `undefined` to leave the caller's `select` unchanged.\n *\n * Useful to dynamically modify the caller's selection based on the request context:\n * - Forcing a field to be populated for reference within hooks / access control.\n * - Differentiating between API requests and admin panel requests, to optimize\n * the amount of data being queried in each case.\n *\n * Note: per-document data is not available — this runs before the read.\n *\n * @see https://payloadcms.com/docs/queries/select\n */\n select?: SelectFn<TSelect>\n}\n\nexport type ApplyDisableErrors<T, DisableErrors = false> = false extends DisableErrors\n ? T\n : null | T\n\nexport type TransformDataWithSelect<\n Data extends Record<string, any>,\n Select extends SelectType,\n> = Select extends never\n ? Data\n : string extends keyof Select\n ? Data\n : // START Handle types when they aren't generated\n // For example in any package in this repository outside of tests / plugins\n // This stil gives us autocomplete when using include select mode, i.e select: {title :true} returns type {title: any, id: string | number}\n string extends keyof Omit<Data, 'id'>\n ? Select extends SelectIncludeType\n ? {\n [K in Data extends TypeWithID ? 'id' | keyof Select : keyof Select]: K extends 'id'\n ? number | string\n : unknown\n }\n : Data\n : // END Handle types when they aren't generated\n // Handle include mode\n Select extends SelectIncludeType\n ? {\n [K in keyof Data as K extends keyof Select\n ? Select[K] extends object | true\n ? K\n : never\n : // select 'id' always\n K extends 'id'\n ? K\n : never]: Data[K]\n }\n : // Handle exclude mode\n {\n [K in keyof Data as K extends keyof Select\n ? Select[K] extends object | undefined\n ? K\n : never\n : K]: Data[K]\n }\n\nexport type TransformCollectionWithSelect<\n TSlug extends CollectionSlug,\n TSelect extends SelectType,\n> = TSelect extends SelectType\n ? TransformDataWithSelect<DataFromCollectionSlug<TSlug>, TSelect>\n : DataFromCollectionSlug<TSlug>\n\nexport type DraftTransformCollectionWithSelect<\n TSlug extends CollectionSlug,\n TSelect extends SelectType,\n> = TSelect extends SelectType\n ? TransformDataWithSelect<QueryDraftDataFromCollectionSlug<TSlug>, TSelect>\n : QueryDraftDataFromCollectionSlug<TSlug>\n\nexport type TransformGlobalWithSelect<\n TSlug extends GlobalSlug,\n TSelect extends SelectType,\n> = TSelect extends SelectType\n ? TransformDataWithSelect<DataFromGlobalSlug<TSlug>, TSelect>\n : DataFromGlobalSlug<TSlug>\n\nexport type PopulateType = Partial<TypedCollectionSelect>\n\nexport type ResolvedFilterOptions = { [collection: string]: Where }\n\nexport type PickPreserveOptional<T, K extends keyof T> = Partial<\n Pick<T, Extract<K, OptionalKeys<T>>>\n> &\n Pick<T, Extract<K, RequiredKeys<T>>>\n\nexport type MaybePromise<T> = Promise<T> | T\n"],"names":["docHasTimestamps","doc","createdAt","updatedAt"],"mappings":"AAwMA,OAAO,SAASA,iBAAiBC,GAAQ;IACvC,OAAOA,KAAKC,aAAaD,KAAKE;AAChC"}
@@ -1 +1 @@
1
- {"version":3,"file":"processMultipart.d.ts","sourceRoot":"","sources":["../../../src/uploads/fetchAPI-multipart/processMultipart.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAA;AACtE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAA;AAS5D,QAAA,MAAM,iBAAiB,eAAuC,CAAA;AAE9D,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,OAAO;QACf,CAAC,iBAAiB,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAA;KACrC;CACF;AAED,KAAK,gBAAgB,GAAG,CAAC,IAAI,EAAE;IAC7B,OAAO,EAAE,yBAAyB,CAAA;IAClC,OAAO,EAAE,OAAO,CAAA;CACjB,KAAK,OAAO,CAAC,0BAA0B,CAAC,CAAA;AACzC,eAAO,MAAM,gBAAgB,EAAE,gBAgO9B,CAAA"}
1
+ {"version":3,"file":"processMultipart.d.ts","sourceRoot":"","sources":["../../../src/uploads/fetchAPI-multipart/processMultipart.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAA;AACtE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAA;AAS5D,QAAA,MAAM,iBAAiB,eAAuC,CAAA;AAE9D,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,OAAO;QACf,CAAC,iBAAiB,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAA;KACrC;CACF;AAED,KAAK,gBAAgB,GAAG,CAAC,IAAI,EAAE;IAC7B,OAAO,EAAE,yBAAyB,CAAA;IAClC,OAAO,EAAE,OAAO,CAAA;CACjB,KAAK,OAAO,CAAC,0BAA0B,CAAC,CAAA;AACzC,eAAO,MAAM,gBAAgB,EAAE,gBAuN9B,CAAA"}
@@ -20,17 +20,10 @@ export const processMultipart = async ({ options, request })=>{
20
20
  allFilesHaveResolved = res;
21
21
  failedResolvingFiles = rej;
22
22
  });
23
- // Attach a no-op catch handler immediately to prevent Node.js from treating this as
24
- // an unhandled rejection if failedResolvingFiles() is called while the read loop is
25
- // still suspended at `await reader.read()`. The real error is rethrown below.
26
- allFilesComplete.catch(()=>{});
27
23
  const busboyFinished = new Promise((resolve, reject)=>{
28
24
  busboyFinishedResolve = resolve;
29
25
  busboyFinishedReject = reject;
30
26
  });
31
- // Prevent unhandled rejection when abortOnLimit rejects allFilesComplete
32
- // (which throws at line ~241) before execution reaches `await busboyFinished`.
33
- busboyFinished.catch(()=>{});
34
27
  const result = {
35
28
  fields: undefined,
36
29
  files: undefined
@@ -48,9 +41,6 @@ export const processMultipart = async ({ options, request })=>{
48
41
  file.destroy();
49
42
  shouldAbortProccessing = true;
50
43
  failedResolvingFiles(err);
51
- // Cancel the reader so the while loop exits immediately rather than draining
52
- // the rest of the request body after an abort.
53
- void reader?.cancel();
54
44
  }
55
45
  // Build multipart req.body fields
56
46
  busboy.on('field', (field, val)=>{
@@ -154,12 +144,9 @@ export const processMultipart = async ({ options, request })=>{
154
144
  }
155
145
  busboyFinishedResolve();
156
146
  });
157
- busboy.on('error', (err)=>{
147
+ busboy.on('error', (err = new APIError('Busboy error parsing multipart request', httpStatus.BAD_REQUEST))=>{
158
148
  debugLog(options, `Busboy error`);
159
- shouldAbortProccessing = true;
160
149
  const busboyError = err instanceof Error ? err : new APIError('Busboy error parsing multipart request', httpStatus.BAD_REQUEST);
161
- // Reject both promises so neither hangs regardless of whether files were in-flight.
162
- failedResolvingFiles(busboyError);
163
150
  busboyFinishedReject(busboyError);
164
151
  });
165
152
  while(parsingRequest){
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/uploads/fetchAPI-multipart/processMultipart.ts"],"sourcesContent":["import type { Readable } from 'stream'\n\nimport Busboy from 'busboy'\nimport { status as httpStatus } from 'http-status'\n\nimport type { FetchAPIFileUploadOptions } from '../../config/types.js'\nimport type { FetchAPIFileUploadResponse } from './index.js'\n\nimport { APIError } from '../../errors/APIError.js'\nimport { fileFactory } from './fileFactory.js'\nimport { memHandler, tempFileHandler } from './handlers.js'\nimport { processNested } from './processNested.js'\nimport { createUploadTimer } from './uploadTimer.js'\nimport { buildFields, debugLog, isFunc, parseFileName } from './utilities.js'\n\nconst waitFlushProperty = Symbol('wait flush property symbol')\n\ndeclare global {\n interface Request {\n [waitFlushProperty]?: Promise<any>[]\n }\n}\n\ntype ProcessMultipart = (args: {\n options: FetchAPIFileUploadOptions\n request: Request\n}) => Promise<FetchAPIFileUploadResponse>\nexport const processMultipart: ProcessMultipart = async ({ options, request }) => {\n let parsingRequest = true\n\n let shouldAbortProccessing = false\n let fileCount = 0\n let filesCompleted = 0\n let allFilesHaveResolved: (value?: unknown) => void\n let failedResolvingFiles: (err: Error) => void\n let busboyFinishedResolve: () => void\n let busboyFinishedReject: (err: Error) => void\n\n const allFilesComplete = new Promise((res, rej) => {\n allFilesHaveResolved = res\n failedResolvingFiles = rej\n })\n // Attach a no-op catch handler immediately to prevent Node.js from treating this as\n // an unhandled rejection if failedResolvingFiles() is called while the read loop is\n // still suspended at `await reader.read()`. The real error is rethrown below.\n allFilesComplete.catch(() => {})\n\n const busboyFinished = new Promise<void>((resolve, reject) => {\n busboyFinishedResolve = resolve\n busboyFinishedReject = reject\n })\n // Prevent unhandled rejection when abortOnLimit rejects allFilesComplete\n // (which throws at line ~241) before execution reaches `await busboyFinished`.\n busboyFinished.catch(() => {})\n\n const result: FetchAPIFileUploadResponse = {\n fields: undefined!,\n files: undefined!,\n }\n\n const headersObject: Record<string, string> = {}\n request.headers.forEach((value, name) => {\n headersObject[name] = value\n })\n\n const reader = request.body?.getReader()\n\n const busboy = Busboy({ ...options, headers: headersObject })\n\n function abortAndDestroyFile(file: Readable, err: APIError) {\n file.destroy()\n shouldAbortProccessing = true\n failedResolvingFiles(err)\n // Cancel the reader so the while loop exits immediately rather than draining\n // the rest of the request body after an abort.\n void reader?.cancel()\n }\n\n // Build multipart req.body fields\n busboy.on('field', (field, val) => {\n result.fields = buildFields(result.fields, field, val)\n })\n\n // Build req.files fields\n busboy.on('file', (field, file, info) => {\n fileCount += 1\n // Parse file name(cutting huge names, decoding, etc..).\n const { encoding, filename: name, mimeType: mime } = info\n const filename = parseFileName(options, name)\n\n const inferredMimeType =\n (filename && filename.endsWith('.glb') && 'model/gltf-binary') ||\n (filename && filename.endsWith('.gltf') && 'model/gltf+json') ||\n mime\n\n // Define methods and handlers for upload process.\n const { cleanup, complete, dataHandler, getFilePath, getFileSize, getHash, getWritePromise } =\n options.useTempFiles\n ? tempFileHandler(options, field, filename) // Upload into temporary file.\n : memHandler(options, field, filename) // Upload into RAM.\n\n const writePromise = options.useTempFiles\n ? getWritePromise().catch(() => {\n busboy.end()\n cleanup()\n })\n : getWritePromise()\n\n const uploadTimer = createUploadTimer(options.uploadTimeout, () => {\n return abortAndDestroyFile(\n file,\n new APIError(`Upload timeout for ${field}->${filename}, bytes:${getFileSize()}`),\n )\n })\n\n file.on('limit', () => {\n debugLog(options, `Size limit reached for ${field}->${filename}, bytes:${getFileSize()}`)\n uploadTimer.clear()\n\n if (isFunc(options.limitHandler)) {\n options.limitHandler({ request, size: getFileSize() })\n }\n\n // Return error and cleanup files if abortOnLimit set.\n if (options.abortOnLimit) {\n debugLog(options, `Upload file size limit reached ${field}->${filename}.`)\n cleanup()\n abortAndDestroyFile(\n file,\n new APIError(options.responseOnLimit!, httpStatus.REQUEST_ENTITY_TOO_LARGE, {\n size: getFileSize(),\n }),\n )\n }\n })\n\n file.on('data', (data) => {\n uploadTimer.set()\n dataHandler(data)\n })\n\n file.on('end', () => {\n const size = getFileSize()\n debugLog(options, `Upload finished ${field}->${filename}, bytes:${size}`)\n uploadTimer.clear()\n\n if (!name && size === 0) {\n fileCount -= 1\n if (options.useTempFiles) {\n cleanup()\n debugLog(options, `Removing the empty file ${field}->${filename}`)\n }\n return debugLog(options, `Don't add file instance if original name and size are empty`)\n }\n\n filesCompleted += 1\n\n result.files = buildFields(\n result.files,\n field,\n fileFactory(\n {\n name: filename,\n buffer: complete(),\n encoding,\n hash: getHash(),\n mimetype: inferredMimeType,\n size,\n tempFilePath: getFilePath(),\n truncated: Boolean('truncated' in file && file.truncated) || false,\n },\n options,\n ),\n )\n\n if (!request[waitFlushProperty]) {\n request[waitFlushProperty] = []\n }\n request[waitFlushProperty].push(writePromise)\n\n if (filesCompleted === fileCount) {\n allFilesHaveResolved()\n }\n })\n\n file.on('error', (err) => {\n uploadTimer.clear()\n debugLog(options, `File Error: ${err.message}`)\n cleanup()\n failedResolvingFiles(err)\n })\n\n // Start upload process.\n debugLog(options, `New upload started ${field}->${filename}, bytes:${getFileSize()}`)\n uploadTimer.set()\n })\n\n busboy.on('finish', async () => {\n debugLog(options, `Busboy finished parsing request.`)\n if (options.parseNested) {\n result.fields = processNested(result.fields)\n result.files = processNested(result.files)\n }\n\n if (request[waitFlushProperty]) {\n try {\n await Promise.all(request[waitFlushProperty]).then(() => {\n delete request[waitFlushProperty]\n })\n } catch (err) {\n debugLog(options, `Error waiting for file write promises: ${err}`)\n }\n }\n\n busboyFinishedResolve()\n })\n\n busboy.on('error', (err?: Error) => {\n debugLog(options, `Busboy error`)\n shouldAbortProccessing = true\n const busboyError =\n err instanceof Error\n ? err\n : new APIError('Busboy error parsing multipart request', httpStatus.BAD_REQUEST)\n // Reject both promises so neither hangs regardless of whether files were in-flight.\n failedResolvingFiles(busboyError)\n busboyFinishedReject(busboyError)\n })\n\n while (parsingRequest) {\n const { done, value } = await reader!.read()\n\n if (done) {\n parsingRequest = false\n busboy.end()\n }\n\n if (value && !shouldAbortProccessing) {\n busboy.write(value)\n }\n }\n\n if (fileCount !== 0) {\n await allFilesComplete.catch((e) => {\n throw e\n })\n }\n\n await busboyFinished\n\n return result\n}\n"],"names":["Busboy","status","httpStatus","APIError","fileFactory","memHandler","tempFileHandler","processNested","createUploadTimer","buildFields","debugLog","isFunc","parseFileName","waitFlushProperty","Symbol","processMultipart","options","request","parsingRequest","shouldAbortProccessing","fileCount","filesCompleted","allFilesHaveResolved","failedResolvingFiles","busboyFinishedResolve","busboyFinishedReject","allFilesComplete","Promise","res","rej","catch","busboyFinished","resolve","reject","result","fields","undefined","files","headersObject","headers","forEach","value","name","reader","body","getReader","busboy","abortAndDestroyFile","file","err","destroy","cancel","on","field","val","info","encoding","filename","mimeType","mime","inferredMimeType","endsWith","cleanup","complete","dataHandler","getFilePath","getFileSize","getHash","getWritePromise","useTempFiles","writePromise","end","uploadTimer","uploadTimeout","clear","limitHandler","size","abortOnLimit","responseOnLimit","REQUEST_ENTITY_TOO_LARGE","data","set","buffer","hash","mimetype","tempFilePath","truncated","Boolean","push","message","parseNested","all","then","busboyError","Error","BAD_REQUEST","done","read","write","e"],"mappings":"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EA,IAAI9B,SAAS,CAACtB,wBAAwB;YACpC2B,OAAOoD,KAAK,CAACzD;QACf;IACF;IAEA,IAAIrB,cAAc,GAAG;QACnB,MAAMM,iBAAiBI,KAAK,CAAC,CAACqE;YAC5B,MAAMA;QACR;IACF;IAEA,MAAMpE;IAEN,OAAOG;AACT,EAAC"}
1
+ {"version":3,"sources":["../../../src/uploads/fetchAPI-multipart/processMultipart.ts"],"sourcesContent":["import type { Readable } from 'stream'\n\nimport Busboy from 'busboy'\nimport { status as httpStatus } from 'http-status'\n\nimport type { FetchAPIFileUploadOptions } from '../../config/types.js'\nimport type { FetchAPIFileUploadResponse } from './index.js'\n\nimport { APIError } from '../../errors/APIError.js'\nimport { fileFactory } from './fileFactory.js'\nimport { memHandler, tempFileHandler } from './handlers.js'\nimport { processNested } from './processNested.js'\nimport { createUploadTimer } from './uploadTimer.js'\nimport { buildFields, debugLog, isFunc, parseFileName } from './utilities.js'\n\nconst waitFlushProperty = Symbol('wait flush property symbol')\n\ndeclare global {\n interface Request {\n [waitFlushProperty]?: Promise<any>[]\n }\n}\n\ntype ProcessMultipart = (args: {\n options: FetchAPIFileUploadOptions\n request: Request\n}) => Promise<FetchAPIFileUploadResponse>\nexport const processMultipart: ProcessMultipart = async ({ options, request }) => {\n let parsingRequest = true\n\n let shouldAbortProccessing = false\n let fileCount = 0\n let filesCompleted = 0\n let allFilesHaveResolved: (value?: unknown) => void\n let failedResolvingFiles: (err: Error) => void\n let busboyFinishedResolve: () => void\n let busboyFinishedReject: (err: Error) => void\n\n const allFilesComplete = new Promise((res, rej) => {\n allFilesHaveResolved = res\n failedResolvingFiles = rej\n })\n\n const busboyFinished = new Promise<void>((resolve, reject) => {\n busboyFinishedResolve = resolve\n busboyFinishedReject = reject\n })\n\n const result: FetchAPIFileUploadResponse = {\n fields: undefined!,\n files: undefined!,\n }\n\n const headersObject: Record<string, string> = {}\n request.headers.forEach((value, name) => {\n headersObject[name] = value\n })\n\n const reader = request.body?.getReader()\n\n const busboy = Busboy({ ...options, headers: headersObject })\n\n function abortAndDestroyFile(file: Readable, err: APIError) {\n file.destroy()\n shouldAbortProccessing = true\n failedResolvingFiles(err)\n }\n\n // Build multipart req.body fields\n busboy.on('field', (field, val) => {\n result.fields = buildFields(result.fields, field, val)\n })\n\n // Build req.files fields\n busboy.on('file', (field, file, info) => {\n fileCount += 1\n // Parse file name(cutting huge names, decoding, etc..).\n const { encoding, filename: name, mimeType: mime } = info\n const filename = parseFileName(options, name)\n\n const inferredMimeType =\n (filename && filename.endsWith('.glb') && 'model/gltf-binary') ||\n (filename && filename.endsWith('.gltf') && 'model/gltf+json') ||\n mime\n\n // Define methods and handlers for upload process.\n const { cleanup, complete, dataHandler, getFilePath, getFileSize, getHash, getWritePromise } =\n options.useTempFiles\n ? tempFileHandler(options, field, filename) // Upload into temporary file.\n : memHandler(options, field, filename) // Upload into RAM.\n\n const writePromise = options.useTempFiles\n ? getWritePromise().catch(() => {\n busboy.end()\n cleanup()\n })\n : getWritePromise()\n\n const uploadTimer = createUploadTimer(options.uploadTimeout, () => {\n return abortAndDestroyFile(\n file,\n new APIError(`Upload timeout for ${field}->${filename}, bytes:${getFileSize()}`),\n )\n })\n\n file.on('limit', () => {\n debugLog(options, `Size limit reached for ${field}->${filename}, bytes:${getFileSize()}`)\n uploadTimer.clear()\n\n if (isFunc(options.limitHandler)) {\n options.limitHandler({ request, size: getFileSize() })\n }\n\n // Return error and cleanup files if abortOnLimit set.\n if (options.abortOnLimit) {\n debugLog(options, `Upload file size limit reached ${field}->${filename}.`)\n cleanup()\n abortAndDestroyFile(\n file,\n new APIError(options.responseOnLimit!, httpStatus.REQUEST_ENTITY_TOO_LARGE, {\n size: getFileSize(),\n }),\n )\n }\n })\n\n file.on('data', (data) => {\n uploadTimer.set()\n dataHandler(data)\n })\n\n file.on('end', () => {\n const size = getFileSize()\n debugLog(options, `Upload finished ${field}->${filename}, bytes:${size}`)\n uploadTimer.clear()\n\n if (!name && size === 0) {\n fileCount -= 1\n if (options.useTempFiles) {\n cleanup()\n debugLog(options, `Removing the empty file ${field}->${filename}`)\n }\n return debugLog(options, `Don't add file instance if original name and size are empty`)\n }\n\n filesCompleted += 1\n\n result.files = buildFields(\n result.files,\n field,\n fileFactory(\n {\n name: filename,\n buffer: complete(),\n encoding,\n hash: getHash(),\n mimetype: inferredMimeType,\n size,\n tempFilePath: getFilePath(),\n truncated: Boolean('truncated' in file && file.truncated) || false,\n },\n options,\n ),\n )\n\n if (!request[waitFlushProperty]) {\n request[waitFlushProperty] = []\n }\n request[waitFlushProperty].push(writePromise)\n\n if (filesCompleted === fileCount) {\n allFilesHaveResolved()\n }\n })\n\n file.on('error', (err) => {\n uploadTimer.clear()\n debugLog(options, `File Error: ${err.message}`)\n cleanup()\n failedResolvingFiles(err)\n })\n\n // Start upload process.\n debugLog(options, `New upload started ${field}->${filename}, bytes:${getFileSize()}`)\n uploadTimer.set()\n })\n\n busboy.on('finish', async () => {\n debugLog(options, `Busboy finished parsing request.`)\n if (options.parseNested) {\n result.fields = processNested(result.fields)\n result.files = processNested(result.files)\n }\n\n if (request[waitFlushProperty]) {\n try {\n await Promise.all(request[waitFlushProperty]).then(() => {\n delete request[waitFlushProperty]\n })\n } catch (err) {\n debugLog(options, `Error waiting for file write promises: ${err}`)\n }\n }\n\n busboyFinishedResolve()\n })\n\n busboy.on(\n 'error',\n (err = new APIError('Busboy error parsing multipart request', httpStatus.BAD_REQUEST)) => {\n debugLog(options, `Busboy error`)\n const busboyError =\n err instanceof Error\n ? err\n : new APIError('Busboy error parsing multipart request', httpStatus.BAD_REQUEST)\n\n busboyFinishedReject(busboyError)\n },\n )\n\n while (parsingRequest) {\n const { done, value } = await reader!.read()\n\n if (done) {\n parsingRequest = false\n busboy.end()\n }\n\n if (value && !shouldAbortProccessing) {\n busboy.write(value)\n }\n }\n\n if (fileCount !== 0) {\n await allFilesComplete.catch((e) => {\n throw e\n })\n }\n\n await busboyFinished\n\n return result\n}\n"],"names":["Busboy","status","httpStatus","APIError","fileFactory","memHandler","tempFileHandler","processNested","createUploadTimer","buildFields","debugLog","isFunc","parseFileName","waitFlushProperty","Symbol","processMultipart","options","request","parsingRequest","shouldAbortProccessing","fileCount","filesCompleted","allFilesHaveResolved","failedResolvingFiles","busboyFinishedResolve","busboyFinishedReject","allFilesComplete","Promise","res","rej","busboyFinished","resolve","reject","result","fields","undefined","files","headersObject","headers","forEach","value","name","reader","body","getReader","busboy","abortAndDestroyFile","file","err","destroy","on","field","val","info","encoding","filename","mimeType","mime","inferredMimeType","endsWith","cleanup","complete","dataHandler","getFilePath","getFileSize","getHash","getWritePromise","useTempFiles","writePromise","catch","end","uploadTimer","uploadTimeout","clear","limitHandler","size","abortOnLimit","responseOnLimit","REQUEST_ENTITY_TOO_LARGE","data","set","buffer","hash","mimetype","tempFilePath","truncated","Boolean","push","message","parseNested","all","then","BAD_REQUEST","busboyError","Error","done","read","write","e"],"mappings":"AAEA,OAAOA,YAAY,SAAQ;AAC3B,SAASC,UAAUC,UAAU,QAAQ,cAAa;AAKlD,SAASC,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,WAAW,QAAQ,mBAAkB;AAC9C,SAASC,UAAU,EAAEC,eAAe,QAAQ,gBAAe;AAC3D,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,iBAAiB,QAAQ,mBAAkB;AACpD,SAASC,WAAW,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,aAAa,QAAQ,iBAAgB;AAE7E,MAAMC,oBAAoBC,OAAO;AAYjC,OAAO,MAAMC,mBAAqC,OAAO,EAAEC,OAAO,EAAEC,OAAO,EAAE;IAC3E,IAAIC,iBAAiB;IAErB,IAAIC,yBAAyB;IAC7B,IAAIC,YAAY;IAChB,IAAIC,iBAAiB;IACrB,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IAEJ,MAAMC,mBAAmB,IAAIC,QAAQ,CAACC,KAAKC;QACzCP,uBAAuBM;QACvBL,uBAAuBM;IACzB;IAEA,MA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AAM,IAAI7C,SAAS,0CAA0CD,WAAW0F,WAAW,CAAC;QACnFlF,SAASM,SAAS,CAAC,YAAY,CAAC;QAChC,MAAM6E,cACJ7C,eAAe8C,QACX9C,MACA,IAAI7C,SAAS,0CAA0CD,WAAW0F,WAAW;QAEnFnE,qBAAqBoE;IACvB;IAGF,MAAO3E,eAAgB;QACrB,MAAM,EAAE6E,IAAI,EAAEvD,KAAK,EAAE,GAAG,MAAME,OAAQsD,IAAI;QAE1C,IAAID,MAAM;YACR7E,iBAAiB;YACjB2B,OAAOyB,GAAG;QACZ;QAEA,IAAI9B,SAAS,CAACrB,wBAAwB;YACpC0B,OAAOoD,KAAK,CAACzD;QACf;IACF;IAEA,IAAIpB,cAAc,GAAG;QACnB,MAAMM,iBAAiB2C,KAAK,CAAC,CAAC6B;YAC5B,MAAMA;QACR;IACF;IAEA,MAAMpE;IAEN,OAAOG;AACT,EAAC"}
@@ -0,0 +1,8 @@
1
+ import type { PayloadComponent } from '../config/types.js';
2
+ /**
3
+ * Resolves a PayloadComponent from a MIME-type keyed map.
4
+ *
5
+ * Priority: exact match → category wildcard (e.g. `video/*`) → universal fallback (`*`).
6
+ */
7
+ export declare function matchMimeType(map: Record<string, PayloadComponent>, mimeType: string): PayloadComponent | undefined;
8
+ //# sourceMappingURL=matchMimeType.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matchMimeType.d.ts","sourceRoot":"","sources":["../../src/uploads/matchMimeType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAE1D;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,EACrC,QAAQ,EAAE,MAAM,GACf,gBAAgB,GAAG,SAAS,CAY9B"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Resolves a PayloadComponent from a MIME-type keyed map.
3
+ *
4
+ * Priority: exact match → category wildcard (e.g. `video/*`) → universal fallback (`*`).
5
+ */ export function matchMimeType(map, mimeType) {
6
+ if (mimeType in map) {
7
+ return map[mimeType];
8
+ }
9
+ const category = mimeType.split('/')[0];
10
+ if (`${category}/*` in map) {
11
+ return map[`${category}/*`];
12
+ }
13
+ if ('*' in map) {
14
+ return map['*'];
15
+ }
16
+ return undefined;
17
+ }
18
+
19
+ //# sourceMappingURL=matchMimeType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/uploads/matchMimeType.ts"],"sourcesContent":["import type { PayloadComponent } from '../config/types.js'\n\n/**\n * Resolves a PayloadComponent from a MIME-type keyed map.\n *\n * Priority: exact match → category wildcard (e.g. `video/*`) → universal fallback (`*`).\n */\nexport function matchMimeType(\n map: Record<string, PayloadComponent>,\n mimeType: string,\n): PayloadComponent | undefined {\n if (mimeType in map) {\n return map[mimeType]\n }\n const category = mimeType.split('/')[0]\n if (`${category}/*` in map) {\n return map[`${category}/*`]\n }\n if ('*' in map) {\n return map['*']\n }\n return undefined\n}\n"],"names":["matchMimeType","map","mimeType","category","split","undefined"],"mappings":"AAEA;;;;CAIC,GACD,OAAO,SAASA,cACdC,GAAqC,EACrCC,QAAgB;IAEhB,IAAIA,YAAYD,KAAK;QACnB,OAAOA,GAAG,CAACC,SAAS;IACtB;IACA,MAAMC,WAAWD,SAASE,KAAK,CAAC,IAAI,CAAC,EAAE;IACvC,IAAI,GAAGD,SAAS,EAAE,CAAC,IAAIF,KAAK;QAC1B,OAAOA,GAAG,CAAC,GAAGE,SAAS,EAAE,CAAC,CAAC;IAC7B;IACA,IAAI,OAAOF,KAAK;QACd,OAAOA,GAAG,CAAC,IAAI;IACjB;IACA,OAAOI;AACT"}
@@ -0,0 +1,66 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { matchMimeType } from './matchMimeType.js';
3
+ describe('matchMimeType', ()=>{
4
+ it('should return the exact match when present', ()=>{
5
+ const map = {
6
+ 'image/png': 'PngComponent',
7
+ '*': 'FallbackComponent'
8
+ };
9
+ expect(matchMimeType(map, 'image/png')).toBe('PngComponent');
10
+ });
11
+ it('should fall back to the category wildcard when no exact match exists', ()=>{
12
+ const map = {
13
+ 'image/*': 'ImageComponent',
14
+ '*': 'FallbackComponent'
15
+ };
16
+ expect(matchMimeType(map, 'image/png')).toBe('ImageComponent');
17
+ });
18
+ it('should fall back to the universal wildcard when no exact or category match exists', ()=>{
19
+ const map = {
20
+ 'video/*': 'VideoComponent',
21
+ '*': 'FallbackComponent'
22
+ };
23
+ expect(matchMimeType(map, 'image/png')).toBe('FallbackComponent');
24
+ });
25
+ it('should return undefined when no entry matches', ()=>{
26
+ const map = {
27
+ 'video/*': 'VideoComponent'
28
+ };
29
+ expect(matchMimeType(map, 'image/png')).toBeUndefined();
30
+ });
31
+ it('should honor an explicit `false` exact match and not fall through to the wildcard', ()=>{
32
+ const map = {
33
+ 'image/png': false,
34
+ '*': 'FallbackComponent'
35
+ };
36
+ expect(matchMimeType(map, 'image/png')).toBe(false);
37
+ });
38
+ it('should honor an explicit `false` category wildcard and not fall through to the universal wildcard', ()=>{
39
+ const map = {
40
+ 'image/*': false,
41
+ '*': 'FallbackComponent'
42
+ };
43
+ expect(matchMimeType(map, 'image/png')).toBe(false);
44
+ });
45
+ it('should handle an empty-string mime type by falling back to the universal wildcard', ()=>{
46
+ const map = {
47
+ '*': 'FallbackComponent'
48
+ };
49
+ expect(matchMimeType(map, '')).toBe('FallbackComponent');
50
+ });
51
+ it('should handle a mime type without a slash', ()=>{
52
+ const map = {
53
+ 'image/*': 'ImageComponent',
54
+ '*': 'FallbackComponent'
55
+ };
56
+ expect(matchMimeType(map, 'notamimetype')).toBe('FallbackComponent');
57
+ });
58
+ it('should match case-sensitively', ()=>{
59
+ const map = {
60
+ 'image/png': 'PngComponent'
61
+ };
62
+ expect(matchMimeType(map, 'IMAGE/PNG')).toBeUndefined();
63
+ });
64
+ });
65
+
66
+ //# sourceMappingURL=matchMimeType.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/uploads/matchMimeType.spec.ts"],"sourcesContent":["import { describe, expect, it } from 'vitest'\n\nimport { matchMimeType } from './matchMimeType.js'\n\ndescribe('matchMimeType', () => {\n it('should return the exact match when present', () => {\n const map = { 'image/png': 'PngComponent', '*': 'FallbackComponent' }\n expect(matchMimeType(map, 'image/png')).toBe('PngComponent')\n })\n\n it('should fall back to the category wildcard when no exact match exists', () => {\n const map = { 'image/*': 'ImageComponent', '*': 'FallbackComponent' }\n expect(matchMimeType(map, 'image/png')).toBe('ImageComponent')\n })\n\n it('should fall back to the universal wildcard when no exact or category match exists', () => {\n const map = { 'video/*': 'VideoComponent', '*': 'FallbackComponent' }\n expect(matchMimeType(map, 'image/png')).toBe('FallbackComponent')\n })\n\n it('should return undefined when no entry matches', () => {\n const map = { 'video/*': 'VideoComponent' }\n expect(matchMimeType(map, 'image/png')).toBeUndefined()\n })\n\n it('should honor an explicit `false` exact match and not fall through to the wildcard', () => {\n const map = { 'image/png': false as const, '*': 'FallbackComponent' }\n expect(matchMimeType(map, 'image/png')).toBe(false)\n })\n\n it('should honor an explicit `false` category wildcard and not fall through to the universal wildcard', () => {\n const map = { 'image/*': false as const, '*': 'FallbackComponent' }\n expect(matchMimeType(map, 'image/png')).toBe(false)\n })\n\n it('should handle an empty-string mime type by falling back to the universal wildcard', () => {\n const map = { '*': 'FallbackComponent' }\n expect(matchMimeType(map, '')).toBe('FallbackComponent')\n })\n\n it('should handle a mime type without a slash', () => {\n const map = { 'image/*': 'ImageComponent', '*': 'FallbackComponent' }\n expect(matchMimeType(map, 'notamimetype')).toBe('FallbackComponent')\n })\n\n it('should match case-sensitively', () => {\n const map = { 'image/png': 'PngComponent' }\n expect(matchMimeType(map, 'IMAGE/PNG')).toBeUndefined()\n })\n})\n"],"names":["describe","expect","it","matchMimeType","map","toBe","toBeUndefined"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,SAAQ;AAE7C,SAASC,aAAa,QAAQ,qBAAoB;AAElDH,SAAS,iBAAiB;IACxBE,GAAG,8CAA8C;QAC/C,MAAME,MAAM;YAAE,aAAa;YAAgB,KAAK;QAAoB;QACpEH,OAAOE,cAAcC,KAAK,cAAcC,IAAI,CAAC;IAC/C;IAEAH,GAAG,wEAAwE;QACzE,MAAME,MAAM;YAAE,WAAW;YAAkB,KAAK;QAAoB;QACpEH,OAAOE,cAAcC,KAAK,cAAcC,IAAI,CAAC;IAC/C;IAEAH,GAAG,qFAAqF;QACtF,MAAME,MAAM;YAAE,WAAW;YAAkB,KAAK;QAAoB;QACpEH,OAAOE,cAAcC,KAAK,cAAcC,IAAI,CAAC;IAC/C;IAEAH,GAAG,iDAAiD;QAClD,MAAME,MAAM;YAAE,WAAW;QAAiB;QAC1CH,OAAOE,cAAcC,KAAK,cAAcE,aAAa;IACvD;IAEAJ,GAAG,qFAAqF;QACtF,MAAME,MAAM;YAAE,aAAa;YAAgB,KAAK;QAAoB;QACpEH,OAAOE,cAAcC,KAAK,cAAcC,IAAI,CAAC;IAC/C;IAEAH,GAAG,qGAAqG;QACtG,MAAME,MAAM;YAAE,WAAW;YAAgB,KAAK;QAAoB;QAClEH,OAAOE,cAAcC,KAAK,cAAcC,IAAI,CAAC;IAC/C;IAEAH,GAAG,qFAAqF;QACtF,MAAME,MAAM;YAAE,KAAK;QAAoB;QACvCH,OAAOE,cAAcC,KAAK,KAAKC,IAAI,CAAC;IACtC;IAEAH,GAAG,6CAA6C;QAC9C,MAAME,MAAM;YAAE,WAAW;YAAkB,KAAK;QAAoB;QACpEH,OAAOE,cAAcC,KAAK,iBAAiBC,IAAI,CAAC;IAClD;IAEAH,GAAG,iCAAiC;QAClC,MAAME,MAAM;YAAE,aAAa;QAAe;QAC1CH,OAAOE,cAAcC,KAAK,cAAcE,aAAa;IACvD;AACF"}
@@ -105,12 +105,33 @@ export type FileAllowList = Array<{
105
105
  extensions: string[];
106
106
  mimeType: string;
107
107
  }>;
108
+ export type UploadFilePreviewClientProps = {
109
+ filename: string;
110
+ filesize: number;
111
+ /** Resolved URL of the file (data.url). */
112
+ fileSrc: string;
113
+ height?: number;
114
+ mimeType: string;
115
+ width?: number;
116
+ };
117
+ type UploadFilePreviewMap = {
118
+ [mimeTypePattern: string]: PayloadComponent;
119
+ };
108
120
  type Admin = {
109
121
  components?: {
110
122
  /**
111
123
  * The Controls component to extend the upload controls in the admin panel.
112
124
  */
113
125
  controls?: PayloadComponent[];
126
+ /**
127
+ * A custom component to render in place of the default Thumbnail in the upload side panel.
128
+ *
129
+ * Can be a single PayloadComponent (renders for all MIME types) or a Record keyed by
130
+ * MIME type patterns. Pattern resolution priority: exact match → category wildcard
131
+ * (e.g. `video/*`) → universal fallback (`*`). Falls back to the default Thumbnail
132
+ * when nothing matches.
133
+ */
134
+ filePreview?: PayloadComponent | UploadFilePreviewMap;
114
135
  };
115
136
  };
116
137
  export type UploadConfig = {
@@ -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,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,IA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AG;IACxC,UAAU,EAAE,gBAAgB,CAAA;IAC5B,IAAI,EAAE,IAAI,CAAA;IACV,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,SAAS,EAAE,YAAY,CAAC,WAAW,CAAC,CAAA;CACrC,GAAG,YAAY,CAAA;AAEhB,MAAM,MAAM,IAAI,GAAG;IACjB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,MAAM,MAAM,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 { 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\ntype Admin = {\n components?: {\n /**\n * The Controls component to extend the upload controls in the admin panel.\n */\n controls?: PayloadComponent[]\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 clientUploadContext?: unknown\n collection: string\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 * 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}\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":"AAkWA,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 { 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 clientUploadContext?: unknown\n collection: string\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 * 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}\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":"AAyXA,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,uBAwGrC,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;AAKvD,KAAK,uBAAuB,GAAG,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;AAErE;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,uBA+GrC,CAAA"}
@@ -87,6 +87,12 @@ import { processMultipartFormdata } from '../uploads/fetchAPI-multipart/index.js
87
87
  }
88
88
  throw new APIError('Expected response from the upload handler.');
89
89
  }
90
+ if (response.status >= 300 && response.status < 400) {
91
+ const redirectUrl = response.headers.get('Location');
92
+ if (redirectUrl) {
93
+ response = await fetch(redirectUrl);
94
+ }
95
+ }
90
96
  req.file = {
91
97
  name: filename,
92
98
  clientUploadContext,
@@ -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 clientUploadContext, collectionSlug, filename, mimeType, size\n try {\n ;({ clientUploadContext, collectionSlug, filename, mimeType, size } = JSON.parse(\n fields.file,\n ))\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 clientUploadContext, // Pass additional specific to adapters context returned from UploadHandler, then staticHandler can use them.\n collection: collectionSlug,\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 req.file = {\n name: filename,\n clientUploadContext,\n data: Buffer.from(await response.arrayBuffer()),\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","clientUploadContext","collectionSlug","filename","mimeType","size","uploadConfig","collections","handlers","response","handler","result","doc","params","collection","err","name","Buffer","from","arrayBuffer","mimetype"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,wBAAuB;AAChD,SAASC,wBAAwB,QAAQ,yCAAwC;AAIjF;;CAEC,GACD,OAAO,MAAMC,0BAAmD,OAAOC;IACrE,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,MAAM,EAAEC,OAAO,EAAE,GAAGJ;IAE3C,IAAIG,UAAU;QAAC;QAAS;QAAQ;KAAM,CAACE,QAAQ,CAACF,OAAOG,WAAW,OAAOL,MAAM;QAC7E,MAAM,CAACM,YAAY,GAAG,AAACL,CAAAA,QAAQM,GAAG,CAAC,mBAAmB,EAAC,EAAGC,KAAK,CAAC,KAAK;QACrE,MAAMC,eAAeC,SAASX,IAAIE,OAAO,CAACM,GAAG,CAAC,qBAAqB,KAAK;QACxE,MAAMI,gBAAgBZ,IAAIC,IAAI,KAAK;QAEnC,IAAIM,gBAAgB,oBAAoB;YACtC,IAAI;gBACF,MAAMM,OAAO,MAAMb,IAAIa,IAAI;gBAC3B,MAAMC,OAAOD,OAAOE,KAAKC,KAAK,CAACH,QAAQ,CAAC;gBACxCb,IAAIc,IAAI,GAAGA;gBACX,iD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CAC9EO,OAAOQ,IAAI,CACb;gBACF,EAAE,OAAM;oBACN,MAAM,IAAIlC,SAAS,4BAA4B;gBACjD;gBACA,MAAM2C,eAAexC,IAAII,OAAO,CAACqC,WAAW,CAACL,eAAe,CAAEV,MAAM,CAACE,MAAM;gBAE3E,IAAI,CAACY,aAAaE,QAAQ,EAAE;oBAC1B,MAAM,IAAI7C,SAAS,8CAA8CuC;gBACnE;gBAEA,IAAIO,WAA4B;gBAChC,IAAIvB;gBAEJ,KAAK,MAAMwB,WAAWJ,aAAaE,QAAQ,CAAE;oBAC3C,IAAI;wBACF,MAAMG,SAAS,MAAMD,QAAQ5C,KAAK;4BAChC8C,KAAK;4BACLC,QAAQ;gCACNZ;gCACAa,YAAYZ;gCACZC;4BACF;wBACF;wBACA,IAAIQ,QAAQ;4BACVF,WAAWE;wBACb;oBACA,+EAA+E;oBACjF,EAAE,OAAOI,KAAK;wBACZ7B,QAAQ6B;oBACV;gBACF;gBAEA,IAAI,CAACN,UAAU;oBACb,IAAIvB,OAAO;wBACThB,QAAQkB,MAAM,CAACF,KAAK,CAACA;oBACvB;oBAEA,MAAM,IAAIvB,SAAS;gBACrB;gBAEAG,IAAI+B,IAAI,GAAG;oBACTmB,MAAMb;oBACNF;oBACArB,MAAMqC,OAAOC,IAAI,CAAC,MAAMT,SAASU,WAAW;oBAC5CC,UAAUX,SAASzC,OAAO,CAACM,GAAG,CAAC,mBAAmB8B;oBAClDC;gBACF;YACF;QACF;IACF;AACF,EAAC"}
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 clientUploadContext, collectionSlug, filename, mimeType, size\n try {\n ;({ clientUploadContext, collectionSlug, filename, mimeType, size } = JSON.parse(\n fields.file,\n ))\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 clientUploadContext, // Pass additional specific to adapters context returned from UploadHandler, then staticHandler can use them.\n collection: collectionSlug,\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 clientUploadContext,\n data: Buffer.from(await response.arrayBuffer()),\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","clientUploadContext","collectionSlug","filename","mimeType","size","uploadConfig","collections","handlers","response","handler","result","doc","params","collection","err","status","redirectUrl","fetch","name","Buffer","from","arrayBuffer","mimetype"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,wBAAuB;AAChD,SAASC,wBAAwB,QAAQ,yCAAwC;AAIjF;;CAEC,GACD,OAAO,MAAMC,0BAAmD,OAAOC;IACrE,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,MAAM,EAAEC,OAAO,EAAE,GAAGJ;IAE3C,IAAIG,UAAU;QAAC;QAAS;QAAQ;KAAM,CAACE,QAAQ,CAACF,OAAOG,WAAW,OAAOL,MAAM;QAC7E,MAAM,CAACM,YAAY,GAAG,AAACL,CAAAA,QAAQM,GAAG,CAAC,mBAAmB,EAAC,EAAGC,KAAK,CAAC,KAAK;QACrE,MAAMC,eAAeC,SAASX,IAAIE,OAAO,CAACM,GAAG,CAAC,qBAAqB,KAAK;QACxE,MAAMI,gBAAgBZ,IAAIC,IAAI,KAAK;QAEnC,IAAIM,gBAAgB,oBAAoB;YACtC,IAAI;gBACF,MAAMM,OAAO,MAAMb,IAAIa,IAAI;gBAC3B,MAAMC,OAAOD,OAAOE,KAAKC,KAAK,CAACH,QAAQ,C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