payload 4.0.0-internal.40de3ec → 4.0.0-internal.45cfa3d

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 (381) 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/fields/Row.d.ts +2 -2
  7. package/dist/admin/fields/Row.d.ts.map +1 -1
  8. package/dist/admin/fields/Row.js.map +1 -1
  9. package/dist/admin/forms/Description.d.ts +2 -2
  10. package/dist/admin/forms/Description.d.ts.map +1 -1
  11. package/dist/admin/forms/Description.js.map +1 -1
  12. package/dist/admin/forms/Field.d.ts +3 -5
  13. package/dist/admin/forms/Field.d.ts.map +1 -1
  14. package/dist/admin/forms/Field.js.map +1 -1
  15. package/dist/admin/forms/Form.d.ts +0 -29
  16. package/dist/admin/forms/Form.d.ts.map +1 -1
  17. package/dist/admin/forms/Form.js.map +1 -1
  18. package/dist/admin/types.d.ts +2 -1
  19. package/dist/admin/types.d.ts.map +1 -1
  20. package/dist/admin/types.js.map +1 -1
  21. package/dist/admin/views/document.d.ts +0 -4
  22. package/dist/admin/views/document.d.ts.map +1 -1
  23. package/dist/admin/views/document.js.map +1 -1
  24. package/dist/admin/views/list.d.ts +5 -0
  25. package/dist/admin/views/list.d.ts.map +1 -1
  26. package/dist/admin/views/list.js.map +1 -1
  27. package/dist/auth/baseFields/apiKey.d.ts +10 -2
  28. package/dist/auth/baseFields/apiKey.d.ts.map +1 -1
  29. package/dist/auth/baseFields/apiKey.js +35 -24
  30. package/dist/auth/baseFields/apiKey.js.map +1 -1
  31. package/dist/auth/getAuthFields.js +2 -2
  32. package/dist/auth/getAuthFields.js.map +1 -1
  33. package/dist/auth/operations/auth.d.ts +2 -2
  34. package/dist/auth/operations/auth.d.ts.map +1 -1
  35. package/dist/auth/operations/auth.js.map +1 -1
  36. package/dist/auth/operations/login.d.ts +2 -1
  37. package/dist/auth/operations/login.d.ts.map +1 -1
  38. package/dist/auth/operations/login.js.map +1 -1
  39. package/dist/auth/operations/me.js.map +1 -1
  40. package/dist/auth/operations/refresh.d.ts.map +1 -1
  41. package/dist/auth/operations/refresh.js +9 -3
  42. package/dist/auth/operations/refresh.js.map +1 -1
  43. package/dist/auth/operations/resetPassword.d.ts.map +1 -1
  44. package/dist/auth/operations/resetPassword.js.map +1 -1
  45. package/dist/auth/sendVerificationEmail.d.ts +2 -2
  46. package/dist/auth/sendVerificationEmail.d.ts.map +1 -1
  47. package/dist/auth/sendVerificationEmail.js +1 -1
  48. package/dist/auth/sendVerificationEmail.js.map +1 -1
  49. package/dist/auth/sessions.d.ts +4 -5
  50. package/dist/auth/sessions.d.ts.map +1 -1
  51. package/dist/auth/sessions.js +5 -3
  52. package/dist/auth/sessions.js.map +1 -1
  53. package/dist/auth/strategies/apiKey.js.map +1 -1
  54. package/dist/auth/strategies/local/incrementLoginAttempts.d.ts +2 -2
  55. package/dist/auth/strategies/local/incrementLoginAttempts.d.ts.map +1 -1
  56. package/dist/auth/strategies/local/incrementLoginAttempts.js +1 -1
  57. package/dist/auth/strategies/local/incrementLoginAttempts.js.map +1 -1
  58. package/dist/auth/types.d.ts +28 -21
  59. package/dist/auth/types.d.ts.map +1 -1
  60. package/dist/auth/types.js.map +1 -1
  61. package/dist/bin/generateImportMap/iterateCollections.d.ts.map +1 -1
  62. package/dist/bin/generateImportMap/iterateCollections.js +11 -0
  63. package/dist/bin/generateImportMap/iterateCollections.js.map +1 -1
  64. package/dist/bin/generateImportMap/iterateConfig.d.ts.map +1 -1
  65. package/dist/bin/generateImportMap/iterateConfig.js +12 -0
  66. package/dist/bin/generateImportMap/iterateConfig.js.map +1 -1
  67. package/dist/bin/generateImportMap/utilities/resolveImportMapFilePath.d.ts.map +1 -1
  68. package/dist/bin/generateImportMap/utilities/resolveImportMapFilePath.js +11 -3
  69. package/dist/bin/generateImportMap/utilities/resolveImportMapFilePath.js.map +1 -1
  70. package/dist/collections/config/client.d.ts +1 -1
  71. package/dist/collections/config/client.d.ts.map +1 -1
  72. package/dist/collections/config/client.js +1 -0
  73. package/dist/collections/config/client.js.map +1 -1
  74. package/dist/collections/config/defaults.d.ts +0 -4
  75. package/dist/collections/config/defaults.d.ts.map +1 -1
  76. package/dist/collections/config/defaults.js +0 -15
  77. package/dist/collections/config/defaults.js.map +1 -1
  78. package/dist/collections/config/sanitize.d.ts.map +1 -1
  79. package/dist/collections/config/sanitize.js +1 -11
  80. package/dist/collections/config/sanitize.js.map +1 -1
  81. package/dist/collections/config/types.d.ts +7 -0
  82. package/dist/collections/config/types.d.ts.map +1 -1
  83. package/dist/collections/config/types.js.map +1 -1
  84. package/dist/collections/endpoints/create.d.ts.map +1 -1
  85. package/dist/collections/endpoints/create.js +0 -2
  86. package/dist/collections/endpoints/create.js.map +1 -1
  87. package/dist/collections/endpoints/updateByID.d.ts.map +1 -1
  88. package/dist/collections/endpoints/updateByID.js +1 -2
  89. package/dist/collections/endpoints/updateByID.js.map +1 -1
  90. package/dist/collections/operations/count.d.ts.map +1 -1
  91. package/dist/collections/operations/count.js +1 -0
  92. package/dist/collections/operations/count.js.map +1 -1
  93. package/dist/collections/operations/create.d.ts +0 -1
  94. package/dist/collections/operations/create.d.ts.map +1 -1
  95. package/dist/collections/operations/create.js +14 -6
  96. package/dist/collections/operations/create.js.map +1 -1
  97. package/dist/collections/operations/findDistinct.d.ts.map +1 -1
  98. package/dist/collections/operations/findDistinct.js +1 -0
  99. package/dist/collections/operations/findDistinct.js.map +1 -1
  100. package/dist/collections/operations/local/count.d.ts +3 -3
  101. package/dist/collections/operations/local/count.d.ts.map +1 -1
  102. package/dist/collections/operations/local/count.js.map +1 -1
  103. package/dist/collections/operations/local/countVersions.d.ts +3 -3
  104. package/dist/collections/operations/local/countVersions.d.ts.map +1 -1
  105. package/dist/collections/operations/local/countVersions.js.map +1 -1
  106. package/dist/collections/operations/local/create.d.ts +3 -3
  107. package/dist/collections/operations/local/create.d.ts.map +1 -1
  108. package/dist/collections/operations/local/create.js.map +1 -1
  109. package/dist/collections/operations/local/delete.d.ts +3 -3
  110. package/dist/collections/operations/local/delete.d.ts.map +1 -1
  111. package/dist/collections/operations/local/delete.js.map +1 -1
  112. package/dist/collections/operations/local/duplicate.d.ts +3 -3
  113. package/dist/collections/operations/local/duplicate.d.ts.map +1 -1
  114. package/dist/collections/operations/local/duplicate.js.map +1 -1
  115. package/dist/collections/operations/local/find.d.ts +3 -3
  116. package/dist/collections/operations/local/find.d.ts.map +1 -1
  117. package/dist/collections/operations/local/find.js.map +1 -1
  118. package/dist/collections/operations/local/findByID.d.ts +3 -3
  119. package/dist/collections/operations/local/findByID.d.ts.map +1 -1
  120. package/dist/collections/operations/local/findByID.js.map +1 -1
  121. package/dist/collections/operations/local/findDistinct.d.ts +2 -2
  122. package/dist/collections/operations/local/findDistinct.d.ts.map +1 -1
  123. package/dist/collections/operations/local/findDistinct.js.map +1 -1
  124. package/dist/collections/operations/local/findVersionByID.d.ts +3 -3
  125. package/dist/collections/operations/local/findVersionByID.d.ts.map +1 -1
  126. package/dist/collections/operations/local/findVersionByID.js.map +1 -1
  127. package/dist/collections/operations/local/findVersions.d.ts +3 -3
  128. package/dist/collections/operations/local/findVersions.d.ts.map +1 -1
  129. package/dist/collections/operations/local/findVersions.js.map +1 -1
  130. package/dist/collections/operations/local/restoreVersion.d.ts +3 -3
  131. package/dist/collections/operations/local/restoreVersion.d.ts.map +1 -1
  132. package/dist/collections/operations/local/restoreVersion.js.map +1 -1
  133. package/dist/collections/operations/local/update.d.ts +7 -11
  134. package/dist/collections/operations/local/update.d.ts.map +1 -1
  135. package/dist/collections/operations/local/update.js +1 -2
  136. package/dist/collections/operations/local/update.js.map +1 -1
  137. package/dist/collections/operations/update.d.ts +0 -1
  138. package/dist/collections/operations/update.d.ts.map +1 -1
  139. package/dist/collections/operations/update.js +8 -4
  140. package/dist/collections/operations/update.js.map +1 -1
  141. package/dist/collections/operations/updateByID.d.ts +0 -1
  142. package/dist/collections/operations/updateByID.d.ts.map +1 -1
  143. package/dist/collections/operations/updateByID.js +1 -5
  144. package/dist/collections/operations/updateByID.js.map +1 -1
  145. package/dist/collections/operations/utilities/copyDataWithFreshRowIDs.d.ts +9 -0
  146. package/dist/collections/operations/utilities/copyDataWithFreshRowIDs.d.ts.map +1 -0
  147. package/dist/collections/operations/utilities/copyDataWithFreshRowIDs.js +170 -0
  148. package/dist/collections/operations/utilities/copyDataWithFreshRowIDs.js.map +1 -0
  149. package/dist/collections/operations/utilities/types.d.ts +0 -9
  150. package/dist/collections/operations/utilities/types.d.ts.map +1 -1
  151. package/dist/collections/operations/utilities/types.js.map +1 -1
  152. package/dist/collections/operations/utilities/update.d.ts +1 -2
  153. package/dist/collections/operations/utilities/update.d.ts.map +1 -1
  154. package/dist/collections/operations/utilities/update.js +48 -57
  155. package/dist/collections/operations/utilities/update.js.map +1 -1
  156. package/dist/config/client.d.ts +2 -2
  157. package/dist/config/client.d.ts.map +1 -1
  158. package/dist/config/client.js.map +1 -1
  159. package/dist/config/defaults.d.ts +0 -4
  160. package/dist/config/defaults.d.ts.map +1 -1
  161. package/dist/config/defaults.js +0 -78
  162. package/dist/config/defaults.js.map +1 -1
  163. package/dist/config/definePlugin.d.ts +10 -10
  164. package/dist/config/definePlugin.d.ts.map +1 -1
  165. package/dist/config/definePlugin.js +7 -11
  166. package/dist/config/definePlugin.js.map +1 -1
  167. package/dist/config/orderable/index.d.ts.map +1 -1
  168. package/dist/config/orderable/index.js +23 -0
  169. package/dist/config/orderable/index.js.map +1 -1
  170. package/dist/config/sanitize.d.ts.map +1 -1
  171. package/dist/config/sanitize.js +137 -13
  172. package/dist/config/sanitize.js.map +1 -1
  173. package/dist/config/types.d.ts +49 -20
  174. package/dist/config/types.d.ts.map +1 -1
  175. package/dist/config/types.js +1 -0
  176. package/dist/config/types.js.map +1 -1
  177. package/dist/errors/ValidationError.d.ts +1 -0
  178. package/dist/errors/ValidationError.d.ts.map +1 -1
  179. package/dist/errors/ValidationError.js.map +1 -1
  180. package/dist/exports/migrations.d.ts +5 -13
  181. package/dist/exports/migrations.d.ts.map +1 -1
  182. package/dist/exports/migrations.js +5 -13
  183. package/dist/exports/migrations.js.map +1 -1
  184. package/dist/exports/shared.d.ts +3 -2
  185. package/dist/exports/shared.d.ts.map +1 -1
  186. package/dist/exports/shared.js +3 -2
  187. package/dist/exports/shared.js.map +1 -1
  188. package/dist/fields/config/client.d.ts.map +1 -1
  189. package/dist/fields/config/client.js +10 -3
  190. package/dist/fields/config/client.js.map +1 -1
  191. package/dist/fields/config/types.d.ts +13 -1
  192. package/dist/fields/config/types.d.ts.map +1 -1
  193. package/dist/fields/config/types.js.map +1 -1
  194. package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
  195. package/dist/fields/hooks/afterRead/promise.js +10 -1
  196. package/dist/fields/hooks/afterRead/promise.js.map +1 -1
  197. package/dist/fields/hooks/beforeChange/promise.d.ts.map +1 -1
  198. package/dist/fields/hooks/beforeChange/promise.js.map +1 -1
  199. package/dist/fields/hooks/beforeValidate/promise.d.ts.map +1 -1
  200. package/dist/fields/hooks/beforeValidate/promise.js +10 -1
  201. package/dist/fields/hooks/beforeValidate/promise.js.map +1 -1
  202. package/dist/globals/config/sanitize.d.ts.map +1 -1
  203. package/dist/globals/config/sanitize.js +1 -6
  204. package/dist/globals/config/sanitize.js.map +1 -1
  205. package/dist/globals/endpoints/update.d.ts.map +1 -1
  206. package/dist/globals/endpoints/update.js +0 -2
  207. package/dist/globals/endpoints/update.js.map +1 -1
  208. package/dist/globals/operations/local/countVersions.d.ts +3 -3
  209. package/dist/globals/operations/local/countVersions.d.ts.map +1 -1
  210. package/dist/globals/operations/local/countVersions.js.map +1 -1
  211. package/dist/globals/operations/local/findOne.d.ts +3 -3
  212. package/dist/globals/operations/local/findOne.d.ts.map +1 -1
  213. package/dist/globals/operations/local/findOne.js.map +1 -1
  214. package/dist/globals/operations/local/findVersionByID.d.ts +3 -3
  215. package/dist/globals/operations/local/findVersionByID.d.ts.map +1 -1
  216. package/dist/globals/operations/local/findVersionByID.js.map +1 -1
  217. package/dist/globals/operations/local/findVersions.d.ts +3 -3
  218. package/dist/globals/operations/local/findVersions.d.ts.map +1 -1
  219. package/dist/globals/operations/local/findVersions.js.map +1 -1
  220. package/dist/globals/operations/local/restoreVersion.d.ts +3 -3
  221. package/dist/globals/operations/local/restoreVersion.d.ts.map +1 -1
  222. package/dist/globals/operations/local/restoreVersion.js.map +1 -1
  223. package/dist/globals/operations/local/update.d.ts +7 -9
  224. package/dist/globals/operations/local/update.d.ts.map +1 -1
  225. package/dist/globals/operations/local/update.js +1 -2
  226. package/dist/globals/operations/local/update.js.map +1 -1
  227. package/dist/globals/operations/update.d.ts +0 -1
  228. package/dist/globals/operations/update.d.ts.map +1 -1
  229. package/dist/globals/operations/update.js +52 -58
  230. package/dist/globals/operations/update.js.map +1 -1
  231. package/dist/index.bundled.d.ts +441 -311
  232. package/dist/index.d.ts +62 -15
  233. package/dist/index.d.ts.map +1 -1
  234. package/dist/index.js +4 -3
  235. package/dist/index.js.map +1 -1
  236. package/dist/preferences/keys.d.ts +4 -0
  237. package/dist/preferences/keys.d.ts.map +1 -1
  238. package/dist/preferences/keys.js +4 -1
  239. package/dist/preferences/keys.js.map +1 -1
  240. package/dist/preferences/types.d.ts +15 -0
  241. package/dist/preferences/types.d.ts.map +1 -1
  242. package/dist/preferences/types.js +3 -1
  243. package/dist/preferences/types.js.map +1 -1
  244. package/dist/query-presets/config.d.ts.map +1 -1
  245. package/dist/query-presets/config.js +73 -34
  246. package/dist/query-presets/config.js.map +1 -1
  247. package/dist/query-presets/constraints.d.ts.map +1 -1
  248. package/dist/query-presets/constraints.js +2 -1
  249. package/dist/query-presets/constraints.js.map +1 -1
  250. package/dist/types/index.d.ts +8 -3
  251. package/dist/types/index.d.ts.map +1 -1
  252. package/dist/types/index.js.map +1 -1
  253. package/dist/uploads/fetchAPI-multipart/processMultipart.d.ts.map +1 -1
  254. package/dist/uploads/fetchAPI-multipart/processMultipart.js +1 -14
  255. package/dist/uploads/fetchAPI-multipart/processMultipart.js.map +1 -1
  256. package/dist/uploads/matchMimeType.d.ts +8 -0
  257. package/dist/uploads/matchMimeType.d.ts.map +1 -0
  258. package/dist/uploads/matchMimeType.js +19 -0
  259. package/dist/uploads/matchMimeType.js.map +1 -0
  260. package/dist/uploads/matchMimeType.spec.js +66 -0
  261. package/dist/uploads/matchMimeType.spec.js.map +1 -0
  262. package/dist/uploads/types.d.ts +21 -0
  263. package/dist/uploads/types.d.ts.map +1 -1
  264. package/dist/uploads/types.js.map +1 -1
  265. package/dist/utilities/addDataAndFileToRequest.d.ts.map +1 -1
  266. package/dist/utilities/addDataAndFileToRequest.js +6 -0
  267. package/dist/utilities/addDataAndFileToRequest.js.map +1 -1
  268. package/dist/utilities/configToJSONSchema.d.ts +13 -4
  269. package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
  270. package/dist/utilities/configToJSONSchema.js +138 -61
  271. package/dist/utilities/configToJSONSchema.js.map +1 -1
  272. package/dist/utilities/configToJSONSchema.spec.js +319 -0
  273. package/dist/utilities/configToJSONSchema.spec.js.map +1 -1
  274. package/dist/utilities/createLocalReq.d.ts +2 -2
  275. package/dist/utilities/createLocalReq.d.ts.map +1 -1
  276. package/dist/utilities/createLocalReq.js.map +1 -1
  277. package/dist/utilities/createPayloadRequest.d.ts.map +1 -1
  278. package/dist/utilities/createPayloadRequest.js +1 -0
  279. package/dist/utilities/createPayloadRequest.js.map +1 -1
  280. package/dist/utilities/deepCopyObject.d.ts.map +1 -1
  281. package/dist/utilities/deepCopyObject.js +8 -0
  282. package/dist/utilities/deepCopyObject.js.map +1 -1
  283. package/dist/utilities/getEntityPermissions/getEntityPermissions.d.ts.map +1 -1
  284. package/dist/utilities/getEntityPermissions/getEntityPermissions.js +2 -0
  285. package/dist/utilities/getEntityPermissions/getEntityPermissions.js.map +1 -1
  286. package/dist/utilities/getEntityPermissions/populateFieldPermissions.d.ts +7 -1
  287. package/dist/utilities/getEntityPermissions/populateFieldPermissions.d.ts.map +1 -1
  288. package/dist/utilities/getEntityPermissions/populateFieldPermissions.js +19 -2
  289. package/dist/utilities/getEntityPermissions/populateFieldPermissions.js.map +1 -1
  290. package/dist/utilities/getFieldByPath.d.ts.map +1 -1
  291. package/dist/utilities/getFieldByPath.js.map +1 -1
  292. package/dist/utilities/getVersionsConfig.js.map +1 -1
  293. package/dist/utilities/mergeLocalizedData.d.ts +14 -4
  294. package/dist/utilities/mergeLocalizedData.d.ts.map +1 -1
  295. package/dist/utilities/mergeLocalizedData.js +49 -34
  296. package/dist/utilities/mergeLocalizedData.js.map +1 -1
  297. package/dist/utilities/mergeLocalizedData.spec.js +23 -23
  298. package/dist/utilities/mergeLocalizedData.spec.js.map +1 -1
  299. package/dist/utilities/parseParams/index.d.ts +2 -5
  300. package/dist/utilities/parseParams/index.d.ts.map +1 -1
  301. package/dist/utilities/parseParams/index.js.map +1 -1
  302. package/dist/utilities/parseParams/index.spec.js +0 -9
  303. package/dist/utilities/parseParams/index.spec.js.map +1 -1
  304. package/dist/utilities/telemetry/conf/envPaths.d.ts.map +1 -1
  305. package/dist/utilities/telemetry/conf/envPaths.js +40 -31
  306. package/dist/utilities/telemetry/conf/envPaths.js.map +1 -1
  307. package/dist/utilities/traverseFields.d.ts.map +1 -1
  308. package/dist/utilities/traverseFields.js.map +1 -1
  309. package/dist/versions/baseFields.d.ts +1 -2
  310. package/dist/versions/baseFields.d.ts.map +1 -1
  311. package/dist/versions/baseFields.js +0 -13
  312. package/dist/versions/baseFields.js.map +1 -1
  313. package/dist/versions/buildCollectionFields.d.ts.map +1 -1
  314. package/dist/versions/buildCollectionFields.js +0 -2
  315. package/dist/versions/buildCollectionFields.js.map +1 -1
  316. package/dist/versions/buildGlobalFields.d.ts.map +1 -1
  317. package/dist/versions/buildGlobalFields.js +0 -2
  318. package/dist/versions/buildGlobalFields.js.map +1 -1
  319. package/dist/versions/buildSingleLocalePublishData.d.ts +32 -0
  320. package/dist/versions/buildSingleLocalePublishData.d.ts.map +1 -0
  321. package/dist/versions/buildSingleLocalePublishData.js +37 -0
  322. package/dist/versions/buildSingleLocalePublishData.js.map +1 -0
  323. package/dist/versions/saveVersion.d.ts +0 -2
  324. package/dist/versions/saveVersion.d.ts.map +1 -1
  325. package/dist/versions/saveVersion.js +12 -17
  326. package/dist/versions/saveVersion.js.map +1 -1
  327. package/dist/versions/schedule/job.d.ts.map +1 -1
  328. package/dist/versions/schedule/job.js +2 -9
  329. package/dist/versions/schedule/job.js.map +1 -1
  330. package/dist/versions/types.d.ts +2 -15
  331. package/dist/versions/types.d.ts.map +1 -1
  332. package/dist/versions/types.js.map +1 -1
  333. package/package.json +3 -3
  334. package/dist/database/migrations/templates/localizeStatus.d.ts +0 -10
  335. package/dist/database/migrations/templates/localizeStatus.d.ts.map +0 -1
  336. package/dist/database/migrations/templates/localizeStatus.js +0 -54
  337. package/dist/database/migrations/templates/localizeStatus.js.map +0 -1
  338. package/dist/utilities/isRSCEnabled.d.ts +0 -12
  339. package/dist/utilities/isRSCEnabled.d.ts.map +0 -1
  340. package/dist/utilities/isRSCEnabled.js +0 -14
  341. package/dist/utilities/isRSCEnabled.js.map +0 -1
  342. package/dist/versions/migrations/localizeStatus/index.d.ts +0 -12
  343. package/dist/versions/migrations/localizeStatus/index.d.ts.map +0 -1
  344. package/dist/versions/migrations/localizeStatus/index.js +0 -33
  345. package/dist/versions/migrations/localizeStatus/index.js.map +0 -1
  346. package/dist/versions/migrations/localizeStatus/mongo/down.d.ts +0 -9
  347. package/dist/versions/migrations/localizeStatus/mongo/down.d.ts.map +0 -1
  348. package/dist/versions/migrations/localizeStatus/mongo/down.js +0 -112
  349. package/dist/versions/migrations/localizeStatus/mongo/down.js.map +0 -1
  350. package/dist/versions/migrations/localizeStatus/mongo/index.d.ts +0 -8
  351. package/dist/versions/migrations/localizeStatus/mongo/index.d.ts.map +0 -1
  352. package/dist/versions/migrations/localizeStatus/mongo/index.js +0 -8
  353. package/dist/versions/migrations/localizeStatus/mongo/index.js.map +0 -1
  354. package/dist/versions/migrations/localizeStatus/mongo/up.d.ts +0 -9
  355. package/dist/versions/migrations/localizeStatus/mongo/up.d.ts.map +0 -1
  356. package/dist/versions/migrations/localizeStatus/mongo/up.js +0 -220
  357. package/dist/versions/migrations/localizeStatus/mongo/up.js.map +0 -1
  358. package/dist/versions/migrations/localizeStatus/sql/down.d.ts +0 -11
  359. package/dist/versions/migrations/localizeStatus/sql/down.d.ts.map +0 -1
  360. package/dist/versions/migrations/localizeStatus/sql/down.js +0 -213
  361. package/dist/versions/migrations/localizeStatus/sql/down.js.map +0 -1
  362. package/dist/versions/migrations/localizeStatus/sql/index.d.ts +0 -8
  363. package/dist/versions/migrations/localizeStatus/sql/index.d.ts.map +0 -1
  364. package/dist/versions/migrations/localizeStatus/sql/index.js +0 -8
  365. package/dist/versions/migrations/localizeStatus/sql/index.js.map +0 -1
  366. package/dist/versions/migrations/localizeStatus/sql/migrateMainCollection.d.ts +0 -13
  367. package/dist/versions/migrations/localizeStatus/sql/migrateMainCollection.d.ts.map +0 -1
  368. package/dist/versions/migrations/localizeStatus/sql/migrateMainCollection.js +0 -51
  369. package/dist/versions/migrations/localizeStatus/sql/migrateMainCollection.js.map +0 -1
  370. package/dist/versions/migrations/localizeStatus/sql/migrateMainGlobal.d.ts +0 -13
  371. package/dist/versions/migrations/localizeStatus/sql/migrateMainGlobal.d.ts.map +0 -1
  372. package/dist/versions/migrations/localizeStatus/sql/migrateMainGlobal.js +0 -54
  373. package/dist/versions/migrations/localizeStatus/sql/migrateMainGlobal.js.map +0 -1
  374. package/dist/versions/migrations/localizeStatus/sql/up.d.ts +0 -11
  375. package/dist/versions/migrations/localizeStatus/sql/up.d.ts.map +0 -1
  376. package/dist/versions/migrations/localizeStatus/sql/up.js +0 -277
  377. package/dist/versions/migrations/localizeStatus/sql/up.js.map +0 -1
  378. package/dist/versions/saveSnapshot.d.ts +0 -18
  379. package/dist/versions/saveSnapshot.d.ts.map +0 -1
  380. package/dist/versions/saveSnapshot.js +0 -38
  381. package/dist/versions/saveSnapshot.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"}
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/query-presets/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAShD,eAAO,MAAM,0BAA0B,0BAA0B,CAAA;AAEjE,eAAO,MAAM,qBAAqB,GAAI,QAAQ,MAAM,KAAG,gBA8KrD,CAAA"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/query-presets/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAShD,eAAO,MAAM,0BAA0B,0BAA0B,CAAA;AAEjE,eAAO,MAAM,qBAAqB,GAAI,QAAQ,MAAM,KAAG,gBAqNrD,CAAA"}
@@ -23,25 +23,64 @@ export const getQueryPresetsConfig = (config)=>({
23
23
  {
24
24
  name: 'title',
25
25
  type: 'text',
26
+ admin: {
27
+ className: 'query-preset-title'
28
+ },
26
29
  required: true
27
30
  },
28
31
  {
29
- name: 'isShared',
30
- type: 'checkbox',
31
- defaultValue: false,
32
- validate: (isShared, { data })=>{
33
- const typedData = data;
34
- // ensure the `isShared` is only true if all constraints are 'onlyMe'
35
- if (typedData?.access) {
36
- const someOperationsAreShared = Object.values(typedData.access).some((operation)=>operation.constraint !== 'onlyMe');
37
- if (!isShared && someOperationsAreShared) {
38
- return 'If any constraint is not "onlyMe", the preset must be shared';
32
+ type: 'row',
33
+ admin: {
34
+ className: 'query-preset-controls-row'
35
+ },
36
+ fields: [
37
+ {
38
+ name: 'presetsHeading',
39
+ type: 'ui',
40
+ admin: {
41
+ components: {
42
+ Field: {
43
+ clientProps: {
44
+ i18nKey: 'general:presets'
45
+ },
46
+ path: '@payloadcms/ui#QueryPresetsHeading'
47
+ }
48
+ }
49
+ }
50
+ },
51
+ {
52
+ name: 'groupBy',
53
+ type: 'text',
54
+ admin: {
55
+ components: {
56
+ Cell: '@payloadcms/ui#QueryPresetsGroupByCell',
57
+ Field: '@payloadcms/ui#QueryPresetsGroupByField'
58
+ }
59
+ },
60
+ label: 'Group By'
61
+ },
62
+ {
63
+ name: 'columns',
64
+ type: 'json',
65
+ admin: {
66
+ components: {
67
+ Cell: '@payloadcms/ui#QueryPresetsColumnsCell',
68
+ Field: '@payloadcms/ui#QueryPresetsColumnField'
69
+ }
70
+ },
71
+ validate: (value)=>{
72
+ if (value) {
73
+ try {
74
+ JSON.parse(JSON.stringify(value));
75
+ } catch {
76
+ return 'Invalid JSON';
77
+ }
78
+ }
79
+ return true;
39
80
  }
40
81
  }
41
- return true;
42
- }
82
+ ]
43
83
  },
44
- getConstraints(config),
45
84
  {
46
85
  name: 'where',
47
86
  type: 'json',
@@ -69,36 +108,36 @@ export const getQueryPresetsConfig = (config)=>({
69
108
  label: 'Filters'
70
109
  },
71
110
  {
72
- name: 'columns',
73
- type: 'json',
111
+ name: 'accessHeading',
112
+ type: 'ui',
74
113
  admin: {
75
114
  components: {
76
- Cell: '@payloadcms/ui#QueryPresetsColumnsCell',
77
- Field: '@payloadcms/ui#QueryPresetsColumnField'
78
- }
79
- },
80
- validate: (value)=>{
81
- if (value) {
82
- try {
83
- JSON.parse(JSON.stringify(value));
84
- } catch {
85
- return 'Invalid JSON';
115
+ Field: {
116
+ clientProps: {
117
+ i18nKey: 'general:access'
118
+ },
119
+ path: '@payloadcms/ui#QueryPresetsHeading'
86
120
  }
87
121
  }
88
- return true;
89
122
  }
90
123
  },
91
124
  {
92
- name: 'groupBy',
93
- type: 'text',
94
- admin: {
95
- components: {
96
- Cell: '@payloadcms/ui#QueryPresetsGroupByCell',
97
- Field: '@payloadcms/ui#QueryPresetsGroupByField'
125
+ name: 'isShared',
126
+ type: 'checkbox',
127
+ defaultValue: false,
128
+ validate: (isShared, { data })=>{
129
+ const typedData = data;
130
+ // ensure the `isShared` is only true if all constraints are 'onlyMe'
131
+ if (typedData?.access) {
132
+ const someOperationsAreShared = Object.values(typedData.access).some((operation)=>operation.constraint !== 'onlyMe');
133
+ if (!isShared && someOperationsAreShared) {
134
+ return 'If any constraint is not "onlyMe", the preset must be shared';
135
+ }
98
136
  }
99
- },
100
- label: 'Group By'
137
+ return true;
138
+ }
101
139
  },
140
+ getConstraints(config),
102
141
  {
103
142
  name: 'relatedCollection',
104
143
  type: 'select',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/query-presets/config.ts"],"sourcesContent":["import type { CollectionConfig } from '../collections/config/types.js'\nimport type { Config } from '../config/types.js'\nimport type { Option } from '../fields/config/types.js'\n\nimport { transformWhereQuery } from '../utilities/transformWhereQuery.js'\nimport { validateWhereQuery } from '../utilities/validateWhereQuery.js'\nimport { getAccess } from './access.js'\nimport { getConstraints } from './constraints.js'\nimport { operations, type QueryPreset } from './types.js'\n\nexport const queryPresetsCollectionSlug = 'payload-query-presets'\n\nexport const getQueryPresetsConfig = (config: Config): CollectionConfig => ({\n slug: queryPresetsCollectionSlug,\n access: getAccess(config),\n admin: {\n defaultColumns: ['title', 'isShared', 'access', 'where', 'columns', 'groupBy'],\n hidden: true,\n useAsTitle: 'title',\n },\n fields: [\n {\n name: 'title',\n type: 'text',\n required: true,\n },\n {\n name: 'isShared',\n type: 'checkbox',\n defaultValue: false,\n validate: (isShared, { data }) => {\n const typedData = data as QueryPreset\n\n // ensure the `isShared` is only true if all constraints are 'onlyMe'\n if (typedData?.access) {\n const someOperationsAreShared = Object.values(typedData.access).some(\n (operation) => operation.constraint !== 'onlyMe',\n )\n\n if (!isShared && someOperationsAreShared) {\n return 'If any constraint is not \"onlyMe\", the preset must be shared'\n }\n }\n\n return true\n },\n },\n getConstraints(config),\n {\n name: 'where',\n type: 'json',\n admin: {\n components: {\n Cell: '@payloadcms/ui#QueryPresetsWhereCell',\n Field: '@payloadcms/ui#QueryPresetsWhereField',\n },\n },\n hooks: {\n beforeValidate: [\n ({ data }) => {\n // transform the \"where\" query here so that the client-side doesn't have to\n if (data?.where) {\n if (validateWhereQuery(data.where)) {\n return data.where\n } else {\n return transformWhereQuery(data.where)\n }\n }\n\n return data?.where\n },\n ],\n },\n label: 'Filters',\n },\n {\n name: 'columns',\n type: 'json',\n admin: {\n components: {\n Cell: '@payloadcms/ui#QueryPresetsColumnsCell',\n Field: '@payloadcms/ui#QueryPresetsColumnField',\n },\n },\n validate: (value) => {\n if (value) {\n try {\n JSON.parse(JSON.stringify(value))\n } catch {\n return 'Invalid JSON'\n }\n }\n\n return true\n },\n },\n {\n name: 'groupBy',\n type: 'text',\n admin: {\n components: {\n Cell: '@payloadcms/ui#QueryPresetsGroupByCell',\n Field: '@payloadcms/ui#QueryPresetsGroupByField',\n },\n },\n label: 'Group By',\n },\n {\n name: 'relatedCollection',\n type: 'select',\n admin: {\n hidden: true,\n },\n options: config.collections\n ? config.collections.reduce((acc, collection) => {\n if (collection.enableQueryPresets) {\n acc.push({\n label: collection.labels?.plural || collection.slug,\n value: collection.slug,\n })\n }\n return acc\n }, [] as Option[])\n : [],\n required: true,\n },\n {\n name: 'isTemp',\n type: 'checkbox',\n admin: {\n description:\n \"This is a temporary field used to determine if updating the preset would remove the user's access to it. When `true`, this record will be deleted after running the preset's `validate` function.\",\n disabled: true,\n hidden: true,\n },\n },\n ],\n hooks: {\n beforeValidate: [\n ({ data, operation }) => {\n // TODO: type this\n const typedData = data as any\n\n if (operation === 'create' || operation === 'update') {\n // Ensure all operations have a constraint\n operations.forEach((operation) => {\n if (!typedData.access) {\n typedData.access = {}\n }\n\n if (!typedData.access?.[operation]) {\n typedData[operation] = {}\n }\n\n // Ensure all operations have a constraint\n if (!typedData.access[operation]?.constraint) {\n typedData.access[operation] = {\n ...typedData.access[operation],\n constraint: 'onlyMe',\n }\n }\n })\n\n // If at least one constraint is not `onlyMe` then `isShared` must be true\n if (typedData?.access) {\n const someOperationsAreShared = Object.values(typedData.access).some(\n // TODO: remove the `any` here\n (operation: any) => operation.constraint !== 'onlyMe',\n )\n\n typedData.isShared = someOperationsAreShared\n }\n }\n\n return typedData\n },\n ],\n },\n labels: {\n plural: 'Presets',\n singular: 'Preset',\n ...(config.queryPresets?.labels || {}),\n },\n lockDocuments: false,\n select: ({ select }) => (select ? { ...select, relatedCollection: true } : undefined),\n versions: false,\n})\n"],"names":["transformWhereQuery","validateWhereQuery","getAccess","getConstraints","operations","queryPresetsCollectionSlug","getQueryPresetsConfig","config","slug","access","admin","defaultColumns","hidden","useAsTitle","fields","name","type","required","defaultValue","validate","isShared","data","typedData","someOperationsAreShared","Object","values","some","operation","constraint","components","Cell","Field","hooks","beforeValidate","where","label","value","JSON","parse","stringify","options","collections","reduce","acc","collection","enableQueryPresets","push","labels","plural","description","disabled","forEach","singular","queryPresets","lockDocuments","select","relatedCollection","undefined","versions"],"mappings":"AAIA,SAASA,mBAAmB,QAAQ,sCAAqC;AACzE,SAASC,kBAAkB,QAAQ,qCAAoC;AACvE,SAASC,SAAS,QAAQ,cAAa;AACvC,SAASC,cAAc,QAAQ,mBAAkB;AACjD,SAASC,UAAU,QAA0B,aAAY;AAEzD,OAAO,MAAMC,6BAA6B,wBAAuB;AAEjE,OAAO,MAAMC,wBAAwB,CA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IN,WAAWb,QAAQ;4BACrB,MAAMc,0BAA0BC,OAAOC,MAAM,CAACH,UAAUb,MAAM,EAAEiB,IAAI,CAClE,8BAA8B;4BAC9B,CAACC,YAAmBA,UAAUC,UAAU,KAAK;4BAG/CN,UAAUF,QAAQ,GAAGG;wBACvB;oBACF;oBAEA,OAAOD;gBACT;aACD;QACH;QACAyB,QAAQ;YACNC,QAAQ;YACRI,UAAU;YACV,GAAI7C,OAAO8C,YAAY,EAAEN,UAAU,CAAC,CAAC;QACvC;QACAO,eAAe;QACfC,QAAQ,CAAC,EAAEA,MAAM,EAAE,GAAMA,SAAS;gBAAE,GAAGA,MAAM;gBAAEC,mBAAmB;YAAK,IAAIC;QAC3EC,UAAU;IACZ,CAAA,EAAE"}
1
+ {"version":3,"sources":["../../src/query-presets/config.ts"],"sourcesContent":["import type { CollectionConfig } from '../collections/config/types.js'\nimport type { Config } from '../config/types.js'\nimport type { Option } from '../fields/config/types.js'\n\nimport { transformWhereQuery } from '../utilities/transformWhereQuery.js'\nimport { validateWhereQuery } from '../utilities/validateWhereQuery.js'\nimport { getAccess } from './access.js'\nimport { getConstraints } from './constraints.js'\nimport { operations, type QueryPreset } from './types.js'\n\nexport const queryPresetsCollectionSlug = 'payload-query-presets'\n\nexport const getQueryPresetsConfig = (config: Config): CollectionConfig => ({\n slug: queryPresetsCollectionSlug,\n access: getAccess(config),\n admin: {\n defaultColumns: ['title', 'isShared', 'access', 'where', 'columns', 'groupBy'],\n hidden: true,\n useAsTitle: 'title',\n },\n fields: [\n {\n name: 'title',\n type: 'text',\n admin: {\n className: 'query-preset-title',\n },\n required: true,\n },\n {\n type: 'row',\n admin: {\n className: 'query-preset-controls-row',\n },\n fields: [\n {\n name: 'presetsHeading',\n type: 'ui',\n admin: {\n components: {\n Field: {\n clientProps: {\n i18nKey: 'general:presets',\n },\n path: '@payloadcms/ui#QueryPresetsHeading',\n },\n },\n },\n },\n {\n name: 'groupBy',\n type: 'text',\n admin: {\n components: {\n Cell: '@payloadcms/ui#QueryPresetsGroupByCell',\n Field: '@payloadcms/ui#QueryPresetsGroupByField',\n },\n },\n label: 'Group By',\n },\n {\n name: 'columns',\n type: 'json',\n admin: {\n components: {\n Cell: '@payloadcms/ui#QueryPresetsColumnsCell',\n Field: '@payloadcms/ui#QueryPresetsColumnField',\n },\n },\n validate: (value) => {\n if (value) {\n try {\n JSON.parse(JSON.stringify(value))\n } catch {\n return 'Invalid JSON'\n }\n }\n\n return true\n },\n },\n ],\n },\n {\n name: 'where',\n type: 'json',\n admin: {\n components: {\n Cell: '@payloadcms/ui#QueryPresetsWhereCell',\n Field: '@payloadcms/ui#QueryPresetsWhereField',\n },\n },\n hooks: {\n beforeValidate: [\n ({ data }) => {\n // transform the \"where\" query here so that the client-side doesn't have to\n if (data?.where) {\n if (validateWhereQuery(data.where)) {\n return data.where\n } else {\n return transformWhereQuery(data.where)\n }\n }\n\n return data?.where\n },\n ],\n },\n label: 'Filters',\n },\n {\n name: 'accessHeading',\n type: 'ui',\n admin: {\n components: {\n Field: {\n clientProps: {\n i18nKey: 'general:access',\n },\n path: '@payloadcms/ui#QueryPresetsHeading',\n },\n },\n },\n },\n {\n name: 'isShared',\n type: 'checkbox',\n defaultValue: false,\n validate: (isShared, { data }) => {\n const typedData = data as QueryPreset\n\n // ensure the `isShared` is only true if all constraints are 'onlyMe'\n if (typedData?.access) {\n const someOperationsAreShared = Object.values(typedData.access).some(\n (operation) => operation.constraint !== 'onlyMe',\n )\n\n if (!isShared && someOperationsAreShared) {\n return 'If any constraint is not \"onlyMe\", the preset must be shared'\n }\n }\n\n return true\n },\n },\n getConstraints(config),\n {\n name: 'relatedCollection',\n type: 'select',\n admin: {\n hidden: true,\n },\n options: config.collections\n ? config.collections.reduce((acc, collection) => {\n if (collection.enableQueryPresets) {\n acc.push({\n label: collection.labels?.plural || collection.slug,\n value: collection.slug,\n })\n }\n return acc\n }, [] as Option[])\n : [],\n required: true,\n },\n {\n name: 'isTemp',\n type: 'checkbox',\n admin: {\n description:\n \"This is a temporary field used to determine if updating the preset would remove the user's access to it. When `true`, this record will be deleted after running the preset's `validate` function.\",\n disabled: true,\n hidden: true,\n },\n },\n ],\n hooks: {\n beforeValidate: [\n ({ data, operation }) => {\n // TODO: type this\n const typedData = data as any\n\n if (operation === 'create' || operation === 'update') {\n // Ensure all operations have a constraint\n operations.forEach((operation) => {\n if (!typedData.access) {\n typedData.access = {}\n }\n\n if (!typedData.access?.[operation]) {\n typedData[operation] = {}\n }\n\n // Ensure all operations have a constraint\n if (!typedData.access[operation]?.constraint) {\n typedData.access[operation] = {\n ...typedData.access[operation],\n constraint: 'onlyMe',\n }\n }\n })\n\n // If at least one constraint is not `onlyMe` then `isShared` must be true\n if (typedData?.access) {\n const someOperationsAreShared = Object.values(typedData.access).some(\n // TODO: remove the `any` here\n (operation: any) => operation.constraint !== 'onlyMe',\n )\n\n typedData.isShared = someOperationsAreShared\n }\n }\n\n return typedData\n },\n ],\n },\n labels: {\n plural: 'Presets',\n singular: 'Preset',\n ...(config.queryPresets?.labels || {}),\n },\n lockDocuments: false,\n select: ({ select }) => (select ? { ...select, relatedCollection: true } : undefined),\n versions: false,\n})\n"],"names":["transformWhereQuery","validateWhereQuery","getAccess","getConstraints","operations","queryPresetsCollectionSlug","getQueryPresetsConfig","config","slug","access","admin","defaultColumns","hidden","useAsTitle","fields","name","type","className","required","components","Field","clientProps","i18nKey","path","Cell","label","validate","value","JSON","parse","stringify","hooks","beforeValidate","data","where","defaultValue","isShared","typedData","someOperationsAreShared","Object","values","some","operation","constraint","options","collections","reduce","acc","collection","enableQueryPresets","push","labels","plural","description","disabled","forEach","singular","queryPresets","lockDocuments","select","relatedCollection","undefined","versions"],"mappings":"AAIA,SAASA,mBAAmB,QAAQ,sCAAqC;AACzE,SAASC,kBAAkB,QAAQ,qCAAoC;AACvE,SAASC,SAAS,QAAQ,cAAa;AACvC,SAASC,cAAc,QAAQ,mBAAkB;AACjD,SAASC,UAAU,QAA0B,aAAY;AAEzD,OAA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0CAA0C;wBAC1CtC,WAAWmD,OAAO,CAAC,CAACb;4BAClB,IAAI,CAACL,UAAU5B,MAAM,EAAE;gCACrB4B,UAAU5B,MAAM,GAAG,CAAC;4BACtB;4BAEA,IAAI,CAAC4B,UAAU5B,MAAM,EAAE,CAACiC,UAAU,EAAE;gCAClCL,SAAS,CAACK,UAAU,GAAG,CAAC;4BAC1B;4BAEA,0CAA0C;4BAC1C,IAAI,CAACL,UAAU5B,MAAM,CAACiC,UAAU,EAAEC,YAAY;gCAC5CN,UAAU5B,MAAM,CAACiC,UAAU,GAAG;oCAC5B,GAAGL,UAAU5B,MAAM,CAACiC,UAAU;oCAC9BC,YAAY;gCACd;4BACF;wBACF;wBAEA,0EAA0E;wBAC1E,IAAIN,WAAW5B,QAAQ;4BACrB,MAAM6B,0BAA0BC,OAAOC,MAAM,CAACH,UAAU5B,MAAM,EAAEgC,IAAI,CAClE,8BAA8B;4BAC9B,CAACC,YAAmBA,UAAUC,UAAU,KAAK;4BAG/CN,UAAUD,QAAQ,GAAGE;wBACvB;oBACF;oBAEA,OAAOD;gBACT;aACD;QACH;QACAc,QAAQ;YACNC,QAAQ;YACRI,UAAU;YACV,GAAIjD,OAAOkD,YAAY,EAAEN,UAAU,CAAC,CAAC;QACvC;QACAO,eAAe;QACfC,QAAQ,CAAC,EAAEA,MAAM,EAAE,GAAMA,SAAS;gBAAE,GAAGA,MAAM;gBAAEC,mBAAmB;YAAK,IAAIC;QAC3EC,UAAU;IACZ,CAAA,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"constraints.d.ts","sourceRoot":"","sources":["../../src/query-presets/constraints.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,KAAK,EAAE,KAAK,EAAU,MAAM,2BAA2B,CAAA;AAuB9D,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,KAAG,KA2F9C,CAAA"}
1
+ {"version":3,"file":"constraints.d.ts","sourceRoot":"","sources":["../../src/query-presets/constraints.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,KAAK,EAAE,KAAK,EAAU,MAAM,2BAA2B,CAAA;AAuB9D,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,KAAG,KA4F9C,CAAA"}
@@ -21,6 +21,7 @@ export const getConstraints = (config)=>({
21
21
  name: 'access',
22
22
  type: 'group',
23
23
  admin: {
24
+ className: 'query-preset-access-group',
24
25
  components: {
25
26
  Cell: '@payloadcms/ui#QueryPresetsAccessCell'
26
27
  },
@@ -96,7 +97,7 @@ export const getConstraints = (config)=>({
96
97
  ],
97
98
  label: ()=>toWords(constraintOperation)
98
99
  })),
99
- label: 'Sharing settings',
100
+ label: false,
100
101
  validate: preventLockout
101
102
  });
102
103
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/query-presets/constraints.ts"],"sourcesContent":["import { getTranslation } from '@payloadcms/translations'\n\nimport type { Config } from '../config/types.js'\nimport type { Field, Option } from '../fields/config/types.js'\nimport type { QueryPresetConstraint } from './types.js'\n\nimport { fieldAffectsData } from '../fields/config/types.js'\nimport { toWords } from '../utilities/formatLabels.js'\nimport { preventLockout } from './preventLockout.js'\nimport { operations } from './types.js'\n\nconst defaultConstraintOptions: Option[] = [\n {\n label: 'Everyone',\n value: 'everyone',\n },\n {\n label: 'Only Me',\n value: 'onlyMe',\n },\n {\n label: 'Specific Users',\n value: 'specificUsers',\n },\n]\n\nexport const getConstraints = (config: Config): Field => ({\n name: 'access',\n type: 'group',\n admin: {\n components: {\n Cell: '@payloadcms/ui#QueryPresetsAccessCell',\n },\n condition: (data) => Boolean(data?.isShared),\n },\n fields: operations.map((constraintOperation) => ({\n type: 'collapsible',\n fields: [\n {\n name: constraintOperation,\n type: 'group',\n admin: {\n hideGutter: true,\n },\n fields: [\n {\n name: 'constraint',\n type: 'select',\n defaultValue: 'onlyMe',\n filterOptions: (args) =>\n typeof config?.queryPresets?.filterConstraints === 'function'\n ? config.queryPresets.filterConstraints(args)\n : args.options,\n label: ({ i18n }) =>\n `Specify who can ${constraintOperation} this ${getTranslation(config.queryPresets?.labels?.singular || 'Preset', i18n)}`,\n options: [\n ...defaultConstraintOptions,\n ...(config?.queryPresets?.constraints?.[constraintOperation]?.map(\n (option: QueryPresetConstraint) => ({\n label: option.label,\n value: option.value,\n }),\n ) || []),\n ],\n },\n {\n name: 'users',\n type: 'relationship',\n admin: {\n condition: (data) =>\n Boolean(data?.access?.[constraintOperation]?.constraint === 'specificUsers'),\n },\n hasMany: true,\n hooks: {\n beforeChange: [\n ({ data, req }) => {\n if (data?.access?.[constraintOperation]?.constraint === 'onlyMe' && req.user) {\n return [req.user.id]\n }\n\n if (\n data?.access?.[constraintOperation]?.constraint === 'specificUsers' &&\n req.user\n ) {\n return [...(data?.access?.[constraintOperation]?.users || []), req.user.id]\n }\n },\n ],\n },\n relationTo: config.admin?.user ?? 'users', // TODO: remove this fallback when the args are properly typed as `SanitizedConfig`\n },\n ...(config?.queryPresets?.constraints?.[constraintOperation]?.reduce(\n (acc: Field[], option: QueryPresetConstraint) => {\n option.fields?.forEach((field, index) => {\n acc.push({ ...field })\n\n if (fieldAffectsData(field)) {\n acc[index]!.admin = {\n ...(acc[index]?.admin || {}),\n condition: (data) =>\n Boolean(data?.access?.[constraintOperation]?.constraint === option.value),\n }\n }\n })\n\n return acc\n },\n [] as Field[],\n ) || []),\n ],\n label: false,\n },\n ],\n label: () => toWords(constraintOperation),\n })),\n label: 'Sharing settings',\n validate: preventLockout,\n})\n"],"names":["getTranslation","fieldAffectsData","toWords","preventLockout","operations","defaultConstraintOptions","label","value","getConstraints","config","name","type","admin","components","Cell","condition","data","Boolean","isShared","fields","map","constraintOperation","hideGutter","defaultValue","filterOptions","args","queryPresets","filterConstraints","options","i18n","labels","singular","constraints","option","access","constraint","hasMany","hooks","beforeChange","req","user","id","users","relationTo","reduce","acc","forEach","field","index","push","validate"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CAACb,oBAAoB,EAAEc,eAAe;gCAChE;gCACAC,SAAS;gCACTC,OAAO;oCACLC,cAAc;wCACZ,CAAC,EAAEtB,IAAI,EAAEuB,GAAG,EAAE;4CACZ,IAAIvB,MAAMkB,QAAQ,CAACb,oBAAoB,EAAEc,eAAe,YAAYI,IAAIC,IAAI,EAAE;gDAC5E,OAAO;oDAACD,IAAIC,IAAI,CAACC,EAAE;iDAAC;4CACtB;4CAEA,IACEzB,MAAMkB,QAAQ,CAACb,oBAAoB,EAAEc,eAAe,mBACpDI,IAAIC,IAAI,EACR;gDACA,OAAO;uDAAKxB,MAAMkB,QAAQ,CAACb,oBAAoB,EAAEqB,SAAS,EAAE;oDAAGH,IAAIC,IAAI,CAACC,EAAE;iDAAC;4CAC7E;wCACF;qCACD;gCACH;gCACAE,YAAYlC,OAAOG,KAAK,EAAE4B,QAAQ;4BACpC;+BACI/B,QAAQiB,cAAcM,aAAa,CAACX,oBAAoB,EAAEuB,OAC5D,CAACC,KAAcZ;gCACbA,OAAOd,MAAM,EAAE2B,QAAQ,CAACC,OAAOC;oCAC7BH,IAAII,IAAI,CAAC;wCAAE,GAAGF,KAAK;oCAAC;oCAEpB,IAAI9C,iBAAiB8C,QAAQ;wCAC3BF,GAAG,CAACG,MAAM,CAAEpC,KAAK,GAAG;4CAClB,GAAIiC,GAAG,CAACG,MAAM,EAAEpC,SAAS,CAAC,CAAC;4CAC3BG,WAAW,CAACC,OACVC,QAAQD,MAAMkB,QAAQ,CAACb,oBAAoB,EAAEc,eAAeF,OAAO1B,KAAK;wCAC5E;oCACF;gCACF;gCAEA,OAAOsC;4BACT,GACA,EAAE,KACC,EAAE;yBACR;wBACDvC,OAAO;oBACT;iBACD;gBACDA,OAAO,IAAMJ,QAAQmB;YACvB,CAAA;QACAf,OAAO;QACP4C,UAAU/C;IACZ,CAAA,EAAE"}
1
+ {"version":3,"sources":["../../src/query-presets/constraints.ts"],"sourcesContent":["import { getTranslation } from '@payloadcms/translations'\n\nimport type { Config } from '../config/types.js'\nimport type { Field, Option } from '../fields/config/types.js'\nimport type { QueryPresetConstraint } from './types.js'\n\nimport { fieldAffectsData } from '../fields/config/types.js'\nimport { toWords } from '../utilities/formatLabels.js'\nimport { preventLockout } from './preventLockout.js'\nimport { operations } from './types.js'\n\nconst defaultConstraintOptions: Option[] = [\n {\n label: 'Everyone',\n value: 'everyone',\n },\n {\n label: 'Only Me',\n value: 'onlyMe',\n },\n {\n label: 'Specific Users',\n value: 'specificUsers',\n },\n]\n\nexport const getConstraints = (config: Config): Field => ({\n name: 'access',\n type: 'group',\n admin: {\n className: 'query-preset-access-group',\n components: {\n Cell: '@payloadcms/ui#QueryPresetsAccessCell',\n },\n condition: (data) => Boolean(data?.isShared),\n },\n fields: operations.map((constraintOperation) => ({\n type: 'collapsible',\n fields: [\n {\n name: constraintOperation,\n type: 'group',\n admin: {\n hideGutter: true,\n },\n fields: [\n {\n name: 'constraint',\n type: 'select',\n defaultValue: 'onlyMe',\n filterOptions: (args) =>\n typeof config?.queryPresets?.filterConstraints === 'function'\n ? config.queryPresets.filterConstraints(args)\n : args.options,\n label: ({ i18n }) =>\n `Specify who can ${constraintOperation} this ${getTranslation(config.queryPresets?.labels?.singular || 'Preset', i18n)}`,\n options: [\n ...defaultConstraintOptions,\n ...(config?.queryPresets?.constraints?.[constraintOperation]?.map(\n (option: QueryPresetConstraint) => ({\n label: option.label,\n value: option.value,\n }),\n ) || []),\n ],\n },\n {\n name: 'users',\n type: 'relationship',\n admin: {\n condition: (data) =>\n Boolean(data?.access?.[constraintOperation]?.constraint === 'specificUsers'),\n },\n hasMany: true,\n hooks: {\n beforeChange: [\n ({ data, req }) => {\n if (data?.access?.[constraintOperation]?.constraint === 'onlyMe' && req.user) {\n return [req.user.id]\n }\n\n if (\n data?.access?.[constraintOperation]?.constraint === 'specificUsers' &&\n req.user\n ) {\n return [...(data?.access?.[constraintOperation]?.users || []), req.user.id]\n }\n },\n ],\n },\n relationTo: config.admin?.user ?? 'users', // TODO: remove this fallback when the args are properly typed as `SanitizedConfig`\n },\n ...(config?.queryPresets?.constraints?.[constraintOperation]?.reduce(\n (acc: Field[], option: QueryPresetConstraint) => {\n option.fields?.forEach((field, index) => {\n acc.push({ ...field })\n\n if (fieldAffectsData(field)) {\n acc[index]!.admin = {\n ...(acc[index]?.admin || {}),\n condition: (data) =>\n Boolean(data?.access?.[constraintOperation]?.constraint === option.value),\n }\n }\n })\n\n return acc\n },\n [] as Field[],\n ) || []),\n ],\n label: false,\n },\n ],\n label: () => toWords(constraintOperation),\n })),\n label: false,\n validate: preventLockout,\n})\n"],"names":["getTranslation","fieldAffectsData","toWords","preventLockout","operations","defaultConstraintOptions","label","value","getConstraints","config","name","type","admin","className","components","Cell","condition","data","Boolean","isShared","fields","map","constraintOperation","hideGutter","defaultValue","filterOptions","args","queryPresets","filterConstraints","options","i18n","labels","singular","constraints","option","access","constraint","hasMany","hooks","beforeChange","req","user","id","users","relationTo","reduce","acc","forEach","field","index","push","validate"],"mappings":"AAAA,SAASA,cAAc,QAAQ,2BAA0B;AAMzD,SAASC,gBAAgB,QAAQ,4BAA2B;AAC5D,SAASC,OAAO,QAAQ,+BAA8B;AACtD,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,UAAU,QAAQ,aAAY;AAEvC,MAAMC,2BAAqC;IACzC;QACEC,OAAO;QACPC,OAAO;IACT;IACA;QACED,OAAO;QACPC,OAAO;IACT;IACA;QACED,OAAO;QACPC,OAAO;IACT;CACD;AAED,OAAO,MAAMC,iBAAiB,CAACC,SAA2B,CAAA;QACxDC,MAAM;QACNC,MAAM;QACNC,OAAO;YACLC,WAAW;YACXC,YAAY;gBACVC,MAAM;YACR;YACAC,WAAW,CAACC,OAASC,QAAQD,MAAME;QACrC;QACAC,QAAQhB,WAAWiB,GAAG,CAAC,CAACC,sBAAyB,CAAA;gBAC/CX,MAAM;gBACNS,QAAQ;oBACN;wBACEV,MAAMY;wBACNX,MAAM;wBACNC,OAAO;4BACLW,YAAY;w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AACC,KAAcZ;gCACbA,OAAOd,MAAM,EAAE2B,QAAQ,CAACC,OAAOC;oCAC7BH,IAAII,IAAI,CAAC;wCAAE,GAAGF,KAAK;oCAAC;oCAEpB,IAAI/C,iBAAiB+C,QAAQ;wCAC3BF,GAAG,CAACG,MAAM,CAAErC,KAAK,GAAG;4CAClB,GAAIkC,GAAG,CAACG,MAAM,EAAErC,SAAS,CAAC,CAAC;4CAC3BI,WAAW,CAACC,OACVC,QAAQD,MAAMkB,QAAQ,CAACb,oBAAoB,EAAEc,eAAeF,OAAO3B,KAAK;wCAC5E;oCACF;gCACF;gCAEA,OAAOuC;4BACT,GACA,EAAE,KACC,EAAE;yBACR;wBACDxC,OAAO;oBACT;iBACD;gBACDA,OAAO,IAAMJ,QAAQoB;YACvB,CAAA;QACAhB,OAAO;QACP6C,UAAUhD;IACZ,CAAA,EAAE"}
@@ -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,KAAK,EACV,sBAAsB,EACtB,gCAAgC,EAChC,UAAU,EACV,kBAAkB,EACnB,MAAM,gCAAgC,CAAA;AACvC,OAAO,KAAK,OAAO,MAAM,aAAa,CAAA;AACtC,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,OAAO,EACP,cAAc,EACd,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,WAAW,EACX,SAAS,EACV,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,YAAY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C,KAAK,CAAC,EAAE,OAAO,CAAC,GAC/D,sBAAsB,CAAC,KAAK,CAAC,CAAA;AAEjC,MAAM,MAAM,kCAAkC,CAC5C,KAAK,SAAS,cAAc,EAC5B,OAAO,SAAS,UAAU,IACxB,OAAO,SAAS,UAAU,GAC1B,uBAAuB,CAAC,gCAAgC,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,GACzE,gCAAgC,CAAC,KAAK,CAAC,CAAA;AAE3C,MAAM,MAAM,yBAAyB,CACnC,KAAK,SAAS,UAAU,EACxB,OAAO,SAAS,UAAU,IACxB,OAAO,SAAS,UAAU,GAC1B,uBAAuB,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,GAC3D,kBAAkB,CAAC,KAAK,CAAC,CAAA;AAE7B,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAA;AAEzD,MAAM,MAAM,qBAAqB,GAAG;IAAE,CAAC,UAAU,EAAE,MAAM,GAAG,KAAK,CAAA;CAAE,CAAA;AAEnE,MAAM,MAAM,oBAAoB,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,OAAO,CAC9D,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,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":"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,OA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pD,IAAIA,QAAQ0E,WAAW,EAAE;YACvBxD,OAAOC,MAAM,GAAG5B,cAAc2B,OAAOC,MAAM;YAC3CD,OAAOG,KAAK,GAAG9B,cAAc2B,OAAOG,KAAK;QAC3C;QAEA,IAAIpB,OAAO,CAACJ,kBAAkB,EAAE;YAC9B,IAAI;gBACF,MAAMc,QAAQgE,GAAG,CAAC1E,OAAO,CAACJ,kBAAkB,EAAE+E,IAAI,CAAC;oBACjD,OAAO3E,OAAO,CAACJ,kBAAkB;gBACnC;YACF,EAAE,OAAOoC,KAAK;gBACZvC,SAASM,SAAS,CAAC,uCAAuC,EAAEiC,KAAK;YACnE;QACF;QAEAzB;IACF;IAEAsB,OAAOM,EAAE,CAAC,SAAS,CAACH;QAClBvC,SAASM,SAAS,CAAC,YAAY,CAAC;QAChCG,yBAAyB;QACzB,MAAM0E,cACJ5C,eAAe6C,QACX7C,MACA,IAAI9C,SAAS,0CAA0CD,WAAW6F,WAAW;QACnF,oFAAoF;QACpFxE,qBAAqBsE;QACrBpE,qBAAqBoE;IACvB;IAEA,MAAO3E,eAAgB;QACrB,MAAM,EAAE8E,IAAI,EAAEvD,KAAK,EAAE,GAAG,MAAME,OAAQsD,IAAI;QAE1C,IAAID,MAAM;YACR9E,iBAAiB;YACjB4B,OAAOyB,GAAG;QACZ;QAEA,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,MAAMC,iBAAiB,IAAIH,QAAc,CAACI,SAASC;QACjDR,wBAAwBO;QACxBN,uBAAuBO;IACzB;IAEA,MAAMC,SAAqC;QACzCC,QAAQC;QACRC,OAAOD;IACT;IAEA,MAAME,gBAAwC,CAAC;IAC/CpB,QAAQqB,OAAO,CAACC,OAAO,CAAC,CAACC,OAAOC;QAC9BJ,aAAa,CAACI,KAAK,GAAGD;IACxB;IAEA,MAAME,SAASzB,QAAQ0B,IAAI,EAAEC;IAE7B,MAAMC,SAAS7C,OAAO;QAAE,GAAGgB,OAAO;QAAEsB,SAASD;IAAc;IAE3D,SAASS,oBAAoBC,IAAc,EAAEC,GAAa;QACxDD,K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ACzD;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"}