payload 3.89.0 → 3.90.0

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 (439) hide show
  1. package/dist/admin/forms/Field.d.ts +2 -0
  2. package/dist/admin/forms/Field.d.ts.map +1 -1
  3. package/dist/admin/forms/Field.js.map +1 -1
  4. package/dist/admin/forms/Form.d.ts +2 -0
  5. package/dist/admin/forms/Form.d.ts.map +1 -1
  6. package/dist/admin/forms/Form.js.map +1 -1
  7. package/dist/admin/functions/index.d.ts +3 -1
  8. package/dist/admin/functions/index.d.ts.map +1 -1
  9. package/dist/admin/functions/index.js.map +1 -1
  10. package/dist/admin/views/dashboard.d.ts +1 -1
  11. package/dist/admin/views/dashboard.d.ts.map +1 -1
  12. package/dist/admin/views/dashboard.js.map +1 -1
  13. package/dist/auth/applyUserReadAccess.d.ts +15 -0
  14. package/dist/auth/applyUserReadAccess.d.ts.map +1 -0
  15. package/dist/auth/applyUserReadAccess.js +41 -0
  16. package/dist/auth/applyUserReadAccess.js.map +1 -0
  17. package/dist/auth/baseFields/apiKey/canCreateOrUpdateAPIKey.d.ts +4 -0
  18. package/dist/auth/baseFields/apiKey/canCreateOrUpdateAPIKey.d.ts.map +1 -0
  19. package/dist/auth/baseFields/apiKey/canCreateOrUpdateAPIKey.js +20 -0
  20. package/dist/auth/baseFields/apiKey/canCreateOrUpdateAPIKey.js.map +1 -0
  21. package/dist/auth/baseFields/apiKey/encryptAPIKey.d.ts +4 -0
  22. package/dist/auth/baseFields/apiKey/encryptAPIKey.d.ts.map +1 -0
  23. package/dist/auth/baseFields/apiKey/encryptAPIKey.js +16 -0
  24. package/dist/auth/baseFields/apiKey/encryptAPIKey.js.map +1 -0
  25. package/dist/auth/baseFields/apiKey/index.d.ts +6 -0
  26. package/dist/auth/baseFields/apiKey/index.d.ts.map +1 -0
  27. package/dist/auth/baseFields/apiKey/index.js +112 -0
  28. package/dist/auth/baseFields/apiKey/index.js.map +1 -0
  29. package/dist/auth/baseFields/apiKey/omitAPIKey.d.ts +4 -0
  30. package/dist/auth/baseFields/apiKey/omitAPIKey.d.ts.map +1 -0
  31. package/dist/auth/baseFields/apiKey/omitAPIKey.js +8 -0
  32. package/dist/auth/baseFields/apiKey/omitAPIKey.js.map +1 -0
  33. package/dist/auth/baseFields/apiKey/omitAPIKeyIndex.d.ts +4 -0
  34. package/dist/auth/baseFields/apiKey/omitAPIKeyIndex.d.ts.map +1 -0
  35. package/dist/auth/baseFields/apiKey/omitAPIKeyIndex.js +5 -0
  36. package/dist/auth/baseFields/apiKey/omitAPIKeyIndex.js.map +1 -0
  37. package/dist/auth/baseFields/apiKey/omitEncryptedAPIKey.d.ts +4 -0
  38. package/dist/auth/baseFields/apiKey/omitEncryptedAPIKey.d.ts.map +1 -0
  39. package/dist/auth/baseFields/apiKey/omitEncryptedAPIKey.js +5 -0
  40. package/dist/auth/baseFields/apiKey/omitEncryptedAPIKey.js.map +1 -0
  41. package/dist/auth/baseFields/apiKey/setAPIKeyIndex.d.ts +4 -0
  42. package/dist/auth/baseFields/apiKey/setAPIKeyIndex.d.ts.map +1 -0
  43. package/dist/auth/baseFields/apiKey/setAPIKeyIndex.js +17 -0
  44. package/dist/auth/baseFields/apiKey/setAPIKeyIndex.js.map +1 -0
  45. package/dist/auth/baseFields/auth.d.ts +1 -0
  46. package/dist/auth/baseFields/auth.d.ts.map +1 -1
  47. package/dist/auth/baseFields/auth.js +9 -0
  48. package/dist/auth/baseFields/auth.js.map +1 -1
  49. package/dist/auth/defaultUnlockAccess.d.ts +3 -0
  50. package/dist/auth/defaultUnlockAccess.d.ts.map +1 -0
  51. package/dist/auth/defaultUnlockAccess.js +8 -0
  52. package/dist/auth/defaultUnlockAccess.js.map +1 -0
  53. package/dist/auth/endpoints/index.d.ts +1 -0
  54. package/dist/auth/endpoints/index.d.ts.map +1 -1
  55. package/dist/auth/endpoints/index.js +8 -0
  56. package/dist/auth/endpoints/index.js.map +1 -1
  57. package/dist/auth/endpoints/revealAPIKey.d.ts +7 -0
  58. package/dist/auth/endpoints/revealAPIKey.d.ts.map +1 -0
  59. package/dist/auth/endpoints/revealAPIKey.js +120 -0
  60. package/dist/auth/endpoints/revealAPIKey.js.map +1 -0
  61. package/dist/auth/executeAccess.d.ts +3 -1
  62. package/dist/auth/executeAccess.d.ts.map +1 -1
  63. package/dist/auth/executeAccess.js +2 -1
  64. package/dist/auth/executeAccess.js.map +1 -1
  65. package/dist/auth/getAuthFields.d.ts +1 -1
  66. package/dist/auth/getAuthFields.d.ts.map +1 -1
  67. package/dist/auth/getAuthFields.js +7 -4
  68. package/dist/auth/getAuthFields.js.map +1 -1
  69. package/dist/auth/getFieldsToSign.d.ts.map +1 -1
  70. package/dist/auth/getFieldsToSign.js +17 -10
  71. package/dist/auth/getFieldsToSign.js.map +1 -1
  72. package/dist/auth/getFieldsToSign.spec.js +114 -0
  73. package/dist/auth/getFieldsToSign.spec.js.map +1 -0
  74. package/dist/auth/jwt.d.ts.map +1 -1
  75. package/dist/auth/jwt.js +2 -0
  76. package/dist/auth/jwt.js.map +1 -1
  77. package/dist/auth/jwt.spec.js +24 -0
  78. package/dist/auth/jwt.spec.js.map +1 -0
  79. package/dist/auth/jwtAuth.d.ts +9 -0
  80. package/dist/auth/jwtAuth.d.ts.map +1 -0
  81. package/dist/auth/jwtAuth.js +8 -0
  82. package/dist/auth/jwtAuth.js.map +1 -0
  83. package/dist/auth/operations/auth.d.ts.map +1 -1
  84. package/dist/auth/operations/auth.js +2 -1
  85. package/dist/auth/operations/auth.js.map +1 -1
  86. package/dist/auth/operations/forgotPassword.d.ts.map +1 -1
  87. package/dist/auth/operations/forgotPassword.js +95 -7
  88. package/dist/auth/operations/forgotPassword.js.map +1 -1
  89. package/dist/auth/operations/local/auth.js +3 -1
  90. package/dist/auth/operations/local/auth.js.map +1 -1
  91. package/dist/auth/operations/login.d.ts.map +1 -1
  92. package/dist/auth/operations/login.js +48 -26
  93. package/dist/auth/operations/login.js.map +1 -1
  94. package/dist/auth/operations/refresh.d.ts.map +1 -1
  95. package/dist/auth/operations/refresh.js +32 -9
  96. package/dist/auth/operations/refresh.js.map +1 -1
  97. package/dist/auth/operations/registerFirstUser.d.ts.map +1 -1
  98. package/dist/auth/operations/registerFirstUser.js +3 -4
  99. package/dist/auth/operations/registerFirstUser.js.map +1 -1
  100. package/dist/auth/operations/resetPassword.d.ts.map +1 -1
  101. package/dist/auth/operations/resetPassword.js +31 -22
  102. package/dist/auth/operations/resetPassword.js.map +1 -1
  103. package/dist/auth/operations/unlock.d.ts.map +1 -1
  104. package/dist/auth/operations/unlock.js +1 -0
  105. package/dist/auth/operations/unlock.js.map +1 -1
  106. package/dist/auth/strategies/apiKey.d.ts.map +1 -1
  107. package/dist/auth/strategies/apiKey.js +15 -1
  108. package/dist/auth/strategies/apiKey.js.map +1 -1
  109. package/dist/auth/strategies/jwt.d.ts.map +1 -1
  110. package/dist/auth/strategies/jwt.js +61 -10
  111. package/dist/auth/strategies/jwt.js.map +1 -1
  112. package/dist/auth/strategies/jwt.spec.js +281 -0
  113. package/dist/auth/strategies/jwt.spec.js.map +1 -0
  114. package/dist/auth/strategies/local/authenticate.d.ts +5 -1
  115. package/dist/auth/strategies/local/authenticate.d.ts.map +1 -1
  116. package/dist/auth/strategies/local/authenticate.js +8 -3
  117. package/dist/auth/strategies/local/authenticate.js.map +1 -1
  118. package/dist/auth/strategies/local/authenticate.spec.js +37 -10
  119. package/dist/auth/strategies/local/authenticate.spec.js.map +1 -1
  120. package/dist/auth/strategies/local/generatePasswordSaltHash.d.ts +9 -1
  121. package/dist/auth/strategies/local/generatePasswordSaltHash.d.ts.map +1 -1
  122. package/dist/auth/strategies/local/generatePasswordSaltHash.js +61 -34
  123. package/dist/auth/strategies/local/generatePasswordSaltHash.js.map +1 -1
  124. package/dist/auth/types.d.ts +16 -1
  125. package/dist/auth/types.d.ts.map +1 -1
  126. package/dist/auth/types.js.map +1 -1
  127. package/dist/collections/config/client.d.ts +1 -0
  128. package/dist/collections/config/client.d.ts.map +1 -1
  129. package/dist/collections/config/client.js +3 -0
  130. package/dist/collections/config/client.js.map +1 -1
  131. package/dist/collections/config/defaults.d.ts.map +1 -1
  132. package/dist/collections/config/defaults.js +4 -2
  133. package/dist/collections/config/defaults.js.map +1 -1
  134. package/dist/collections/config/sanitize.d.ts.map +1 -1
  135. package/dist/collections/config/sanitize.js +17 -6
  136. package/dist/collections/config/sanitize.js.map +1 -1
  137. package/dist/collections/endpoints/index.d.ts +1 -0
  138. package/dist/collections/endpoints/index.d.ts.map +1 -1
  139. package/dist/collections/endpoints/index.js +6 -5
  140. package/dist/collections/endpoints/index.js.map +1 -1
  141. package/dist/collections/operations/create.d.ts.map +1 -1
  142. package/dist/collections/operations/create.js +105 -8
  143. package/dist/collections/operations/create.js.map +1 -1
  144. package/dist/collections/operations/deleteByID.js +13 -13
  145. package/dist/collections/operations/deleteByID.js.map +1 -1
  146. package/dist/collections/operations/findDistinct.d.ts.map +1 -1
  147. package/dist/collections/operations/findDistinct.js +96 -18
  148. package/dist/collections/operations/findDistinct.js.map +1 -1
  149. package/dist/collections/operations/restoreVersion.d.ts.map +1 -1
  150. package/dist/collections/operations/restoreVersion.js +47 -13
  151. package/dist/collections/operations/restoreVersion.js.map +1 -1
  152. package/dist/collections/operations/update.d.ts.map +1 -1
  153. package/dist/collections/operations/update.js +118 -18
  154. package/dist/collections/operations/update.js.map +1 -1
  155. package/dist/collections/operations/updateByID.d.ts.map +1 -1
  156. package/dist/collections/operations/updateByID.js +62 -2
  157. package/dist/collections/operations/updateByID.js.map +1 -1
  158. package/dist/collections/operations/utilities/update.d.ts.map +1 -1
  159. package/dist/collections/operations/utilities/update.js +71 -15
  160. package/dist/collections/operations/utilities/update.js.map +1 -1
  161. package/dist/config/orderable/index.d.ts.map +1 -1
  162. package/dist/config/orderable/index.js +67 -14
  163. package/dist/config/orderable/index.js.map +1 -1
  164. package/dist/config/sanitize.d.ts.map +1 -1
  165. package/dist/config/sanitize.js +1 -1
  166. package/dist/config/sanitize.js.map +1 -1
  167. package/dist/config/types.d.ts +13 -1
  168. package/dist/config/types.d.ts.map +1 -1
  169. package/dist/config/types.js.map +1 -1
  170. package/dist/database/getLocalizedPaths.d.ts +2 -1
  171. package/dist/database/getLocalizedPaths.d.ts.map +1 -1
  172. package/dist/database/getLocalizedPaths.js +12 -3
  173. package/dist/database/getLocalizedPaths.js.map +1 -1
  174. package/dist/database/isNestedRelationshipQuery.d.ts +9 -0
  175. package/dist/database/isNestedRelationshipQuery.d.ts.map +1 -0
  176. package/dist/database/isNestedRelationshipQuery.js +14 -0
  177. package/dist/database/isNestedRelationshipQuery.js.map +1 -0
  178. package/dist/database/prefixWherePaths.d.ts +6 -0
  179. package/dist/database/prefixWherePaths.d.ts.map +1 -0
  180. package/dist/database/prefixWherePaths.js +19 -0
  181. package/dist/database/prefixWherePaths.js.map +1 -0
  182. package/dist/database/prefixWherePaths.spec.js +46 -0
  183. package/dist/database/prefixWherePaths.spec.js.map +1 -0
  184. package/dist/database/queryValidation/validateQueryPaths.d.ts +2 -1
  185. package/dist/database/queryValidation/validateQueryPaths.d.ts.map +1 -1
  186. package/dist/database/queryValidation/validateQueryPaths.js +4 -1
  187. package/dist/database/queryValidation/validateQueryPaths.js.map +1 -1
  188. package/dist/database/queryValidation/validateSearchParams.d.ts +2 -1
  189. package/dist/database/queryValidation/validateSearchParams.d.ts.map +1 -1
  190. package/dist/database/queryValidation/validateSearchParams.js +82 -4
  191. package/dist/database/queryValidation/validateSearchParams.js.map +1 -1
  192. package/dist/database/types.d.ts +5 -0
  193. package/dist/database/types.d.ts.map +1 -1
  194. package/dist/database/types.js.map +1 -1
  195. package/dist/email/normalizeSendEmailOptions.js.map +1 -1
  196. package/dist/email/types.d.ts +4 -1
  197. package/dist/email/types.d.ts.map +1 -1
  198. package/dist/email/types.js.map +1 -1
  199. package/dist/exports/internal.d.ts +7 -0
  200. package/dist/exports/internal.d.ts.map +1 -1
  201. package/dist/exports/internal.js +7 -1
  202. package/dist/exports/internal.js.map +1 -1
  203. package/dist/exports/shared.d.ts +3 -0
  204. package/dist/exports/shared.d.ts.map +1 -1
  205. package/dist/exports/shared.js +3 -0
  206. package/dist/exports/shared.js.map +1 -1
  207. package/dist/fields/config/types.d.ts +7 -5
  208. package/dist/fields/config/types.d.ts.map +1 -1
  209. package/dist/fields/config/types.js.map +1 -1
  210. package/dist/fields/hooks/beforeChange/index.d.ts +7 -1
  211. package/dist/fields/hooks/beforeChange/index.d.ts.map +1 -1
  212. package/dist/fields/hooks/beforeChange/index.js +4 -2
  213. package/dist/fields/hooks/beforeChange/index.js.map +1 -1
  214. package/dist/fields/hooks/beforeChange/index.spec.js +206 -0
  215. package/dist/fields/hooks/beforeChange/index.spec.js.map +1 -0
  216. package/dist/fields/hooks/beforeChange/promise.d.ts +2 -1
  217. package/dist/fields/hooks/beforeChange/promise.d.ts.map +1 -1
  218. package/dist/fields/hooks/beforeChange/promise.js +51 -9
  219. package/dist/fields/hooks/beforeChange/promise.js.map +1 -1
  220. package/dist/fields/hooks/beforeChange/traverseFields.d.ts +2 -1
  221. package/dist/fields/hooks/beforeChange/traverseFields.d.ts.map +1 -1
  222. package/dist/fields/hooks/beforeChange/traverseFields.js +3 -2
  223. package/dist/fields/hooks/beforeChange/traverseFields.js.map +1 -1
  224. package/dist/fields/hooks/beforeDuplicate/promise.d.ts.map +1 -1
  225. package/dist/fields/hooks/beforeDuplicate/promise.js +4 -0
  226. package/dist/fields/hooks/beforeDuplicate/promise.js.map +1 -1
  227. package/dist/fields/hooks/beforeValidate/getFallbackValue.d.ts +2 -1
  228. package/dist/fields/hooks/beforeValidate/getFallbackValue.d.ts.map +1 -1
  229. package/dist/fields/hooks/beforeValidate/getFallbackValue.js +2 -2
  230. package/dist/fields/hooks/beforeValidate/getFallbackValue.js.map +1 -1
  231. package/dist/fields/hooks/beforeValidate/index.d.ts +6 -1
  232. package/dist/fields/hooks/beforeValidate/index.d.ts.map +1 -1
  233. package/dist/fields/hooks/beforeValidate/index.js +3 -1
  234. package/dist/fields/hooks/beforeValidate/index.js.map +1 -1
  235. package/dist/fields/hooks/beforeValidate/index.spec.js +90 -0
  236. package/dist/fields/hooks/beforeValidate/index.spec.js.map +1 -0
  237. package/dist/fields/hooks/beforeValidate/promise.d.ts +6 -1
  238. package/dist/fields/hooks/beforeValidate/promise.d.ts.map +1 -1
  239. package/dist/fields/hooks/beforeValidate/promise.js +23 -8
  240. package/dist/fields/hooks/beforeValidate/promise.js.map +1 -1
  241. package/dist/fields/hooks/beforeValidate/traverseFields.d.ts +6 -1
  242. package/dist/fields/hooks/beforeValidate/traverseFields.d.ts.map +1 -1
  243. package/dist/fields/hooks/beforeValidate/traverseFields.js +3 -1
  244. package/dist/fields/hooks/beforeValidate/traverseFields.js.map +1 -1
  245. package/dist/fields/validations.d.ts.map +1 -1
  246. package/dist/fields/validations.js +3 -1
  247. package/dist/fields/validations.js.map +1 -1
  248. package/dist/globals/operations/restoreVersion.d.ts.map +1 -1
  249. package/dist/globals/operations/restoreVersion.js +45 -11
  250. package/dist/globals/operations/restoreVersion.js.map +1 -1
  251. package/dist/globals/operations/update.d.ts.map +1 -1
  252. package/dist/globals/operations/update.js +95 -16
  253. package/dist/globals/operations/update.js.map +1 -1
  254. package/dist/index.bundled.d.ts +102 -24
  255. package/dist/index.d.ts +3 -1
  256. package/dist/index.d.ts.map +1 -1
  257. package/dist/index.js +2 -2
  258. package/dist/index.js.map +1 -1
  259. package/dist/preferences/config.d.ts.map +1 -1
  260. package/dist/preferences/config.js +2 -1
  261. package/dist/preferences/config.js.map +1 -1
  262. package/dist/query-presets/access.d.ts.map +1 -1
  263. package/dist/query-presets/access.js +2 -1
  264. package/dist/query-presets/access.js.map +1 -1
  265. package/dist/queues/config/types/index.d.ts +2 -1
  266. package/dist/queues/config/types/index.d.ts.map +1 -1
  267. package/dist/queues/config/types/index.js.map +1 -1
  268. package/dist/uploads/assertClientUploadAccess.d.ts +7 -0
  269. package/dist/uploads/assertClientUploadAccess.d.ts.map +1 -0
  270. package/dist/uploads/assertClientUploadAccess.js +27 -0
  271. package/dist/uploads/assertClientUploadAccess.js.map +1 -0
  272. package/dist/uploads/assertClientUploadAllowed.d.ts +11 -0
  273. package/dist/uploads/assertClientUploadAllowed.d.ts.map +1 -0
  274. package/dist/uploads/assertClientUploadAllowed.js +46 -0
  275. package/dist/uploads/assertClientUploadAllowed.js.map +1 -0
  276. package/dist/uploads/assertClientUploadAllowed.spec.js +91 -0
  277. package/dist/uploads/assertClientUploadAllowed.spec.js.map +1 -0
  278. package/dist/uploads/checkFileRestrictions.d.ts +4 -1
  279. package/dist/uploads/checkFileRestrictions.d.ts.map +1 -1
  280. package/dist/uploads/checkFileRestrictions.js +66 -26
  281. package/dist/uploads/checkFileRestrictions.js.map +1 -1
  282. package/dist/uploads/clientUploadReceipt.d.ts +23 -0
  283. package/dist/uploads/clientUploadReceipt.d.ts.map +1 -0
  284. package/dist/uploads/clientUploadReceipt.js +55 -0
  285. package/dist/uploads/clientUploadReceipt.js.map +1 -0
  286. package/dist/uploads/deleteAssociatedFiles.d.ts.map +1 -1
  287. package/dist/uploads/deleteAssociatedFiles.js +33 -8
  288. package/dist/uploads/deleteAssociatedFiles.js.map +1 -1
  289. package/dist/uploads/deleteAssociatedFiles.spec.js +124 -0
  290. package/dist/uploads/deleteAssociatedFiles.spec.js.map +1 -0
  291. package/dist/uploads/detectSvgFromXml.d.ts +1 -3
  292. package/dist/uploads/detectSvgFromXml.d.ts.map +1 -1
  293. package/dist/uploads/detectSvgFromXml.js +3 -40
  294. package/dist/uploads/detectSvgFromXml.js.map +1 -1
  295. package/dist/uploads/endpoints/getFile.d.ts.map +1 -1
  296. package/dist/uploads/endpoints/getFile.js +5 -3
  297. package/dist/uploads/endpoints/getFile.js.map +1 -1
  298. package/dist/uploads/fetchAPI-multipart/handlers.d.ts +2 -2
  299. package/dist/uploads/fetchAPI-multipart/handlers.d.ts.map +1 -1
  300. package/dist/uploads/fetchAPI-multipart/handlers.js +18 -5
  301. package/dist/uploads/fetchAPI-multipart/handlers.js.map +1 -1
  302. package/dist/uploads/fetchAPI-multipart/index.d.ts.map +1 -1
  303. package/dist/uploads/fetchAPI-multipart/index.js +24 -2
  304. package/dist/uploads/fetchAPI-multipart/index.js.map +1 -1
  305. package/dist/uploads/fetchAPI-multipart/processMultipart.d.ts +0 -6
  306. package/dist/uploads/fetchAPI-multipart/processMultipart.d.ts.map +1 -1
  307. package/dist/uploads/fetchAPI-multipart/processMultipart.js +146 -126
  308. package/dist/uploads/fetchAPI-multipart/processMultipart.js.map +1 -1
  309. package/dist/uploads/fetchAPI-multipart/processMultipart.spec.js +663 -0
  310. package/dist/uploads/fetchAPI-multipart/processMultipart.spec.js.map +1 -0
  311. package/dist/uploads/generateFileData.d.ts +3 -1
  312. package/dist/uploads/generateFileData.d.ts.map +1 -1
  313. package/dist/uploads/generateFileData.js +29 -16
  314. package/dist/uploads/generateFileData.js.map +1 -1
  315. package/dist/uploads/getBaseFields.d.ts.map +1 -1
  316. package/dist/uploads/getBaseFields.js +3 -1
  317. package/dist/uploads/getBaseFields.js.map +1 -1
  318. package/dist/uploads/getExternalFile.d.ts +1 -1
  319. package/dist/uploads/getExternalFile.d.ts.map +1 -1
  320. package/dist/uploads/getExternalFile.js +60 -15
  321. package/dist/uploads/getExternalFile.js.map +1 -1
  322. package/dist/uploads/getFileTypeFallback.d.ts.map +1 -1
  323. package/dist/uploads/getFileTypeFallback.js +3 -1
  324. package/dist/uploads/getFileTypeFallback.js.map +1 -1
  325. package/dist/uploads/getFileTypeIdentity.d.ts +19 -0
  326. package/dist/uploads/getFileTypeIdentity.d.ts.map +1 -0
  327. package/dist/uploads/getFileTypeIdentity.js +34 -0
  328. package/dist/uploads/getFileTypeIdentity.js.map +1 -0
  329. package/dist/uploads/getFileTypeIdentity.spec.js +43 -0
  330. package/dist/uploads/getFileTypeIdentity.spec.js.map +1 -0
  331. package/dist/uploads/isProcessableImage.d.ts +2 -0
  332. package/dist/uploads/isProcessableImage.d.ts.map +1 -0
  333. package/dist/uploads/isProcessableImage.js +7 -0
  334. package/dist/uploads/isProcessableImage.js.map +1 -0
  335. package/dist/uploads/safeFetch.d.ts.map +1 -1
  336. package/dist/uploads/safeFetch.js +3 -2
  337. package/dist/uploads/safeFetch.js.map +1 -1
  338. package/dist/uploads/sanitizeUploadData.d.ts +26 -0
  339. package/dist/uploads/sanitizeUploadData.d.ts.map +1 -0
  340. package/dist/uploads/sanitizeUploadData.js +159 -0
  341. package/dist/uploads/sanitizeUploadData.js.map +1 -0
  342. package/dist/uploads/sanitizeUploadData.spec.js +255 -0
  343. package/dist/uploads/sanitizeUploadData.spec.js.map +1 -0
  344. package/dist/uploads/types.d.ts +11 -3
  345. package/dist/uploads/types.d.ts.map +1 -1
  346. package/dist/uploads/types.js.map +1 -1
  347. package/dist/uploads/uploadContentSecurityPolicy.d.ts +2 -0
  348. package/dist/uploads/uploadContentSecurityPolicy.d.ts.map +1 -0
  349. package/dist/uploads/uploadContentSecurityPolicy.js +3 -0
  350. package/dist/uploads/uploadContentSecurityPolicy.js.map +1 -0
  351. package/dist/uploads/validateISOBaseMediaFile.d.ts +4 -0
  352. package/dist/uploads/validateISOBaseMediaFile.d.ts.map +1 -0
  353. package/dist/uploads/validateISOBaseMediaFile.js +91 -0
  354. package/dist/uploads/validateISOBaseMediaFile.js.map +1 -0
  355. package/dist/uploads/validateISOBaseMediaFile.spec.js +130 -0
  356. package/dist/uploads/validateISOBaseMediaFile.spec.js.map +1 -0
  357. package/dist/uploads/validateSvg.d.ts +10 -4
  358. package/dist/uploads/validateSvg.d.ts.map +1 -1
  359. package/dist/uploads/validateSvg.js +280 -40
  360. package/dist/uploads/validateSvg.js.map +1 -1
  361. package/dist/uploads/validateSvg.spec.js +123 -0
  362. package/dist/uploads/validateSvg.spec.js.map +1 -0
  363. package/dist/uploads/validateUploadFilename.d.ts +3 -0
  364. package/dist/uploads/validateUploadFilename.d.ts.map +1 -0
  365. package/dist/uploads/validateUploadFilename.js +13 -0
  366. package/dist/uploads/validateUploadFilename.js.map +1 -0
  367. package/dist/uploads/validateUploadFilename.spec.js +24 -0
  368. package/dist/uploads/validateUploadFilename.spec.js.map +1 -0
  369. package/dist/utilities/addDataAndFileToRequest.d.ts.map +1 -1
  370. package/dist/utilities/addDataAndFileToRequest.js +28 -1
  371. package/dist/utilities/addDataAndFileToRequest.js.map +1 -1
  372. package/dist/utilities/addDataAndFileToRequest.spec.js +158 -0
  373. package/dist/utilities/addDataAndFileToRequest.spec.js.map +1 -1
  374. package/dist/utilities/createPayloadRequest.d.ts.map +1 -1
  375. package/dist/utilities/createPayloadRequest.js +2 -1
  376. package/dist/utilities/createPayloadRequest.js.map +1 -1
  377. package/dist/utilities/deepCopyObject.d.ts.map +1 -1
  378. package/dist/utilities/deepCopyObject.js +110 -19
  379. package/dist/utilities/deepCopyObject.js.map +1 -1
  380. package/dist/utilities/deepCopyObject.spec.js +216 -0
  381. package/dist/utilities/deepCopyObject.spec.js.map +1 -0
  382. package/dist/utilities/fieldPath.d.ts +13 -0
  383. package/dist/utilities/fieldPath.d.ts.map +1 -0
  384. package/dist/utilities/fieldPath.js +51 -0
  385. package/dist/utilities/fieldPath.js.map +1 -0
  386. package/dist/utilities/fieldPath.spec.js +155 -0
  387. package/dist/utilities/fieldPath.spec.js.map +1 -0
  388. package/dist/utilities/getEntityPermissions/getEntityPermissions.d.ts.map +1 -1
  389. package/dist/utilities/getEntityPermissions/getEntityPermissions.js +2 -0
  390. package/dist/utilities/getEntityPermissions/getEntityPermissions.js.map +1 -1
  391. package/dist/utilities/getObjectDotNotation.d.ts.map +1 -1
  392. package/dist/utilities/getObjectDotNotation.js +7 -1
  393. package/dist/utilities/getObjectDotNotation.js.map +1 -1
  394. package/dist/utilities/getObjectDotNotation.spec.js +33 -0
  395. package/dist/utilities/getObjectDotNotation.spec.js.map +1 -0
  396. package/dist/utilities/getSafeRedirect.spec.js +14 -0
  397. package/dist/utilities/getSafeRedirect.spec.js.map +1 -1
  398. package/dist/utilities/getTopLevelFieldNames.d.ts +2 -0
  399. package/dist/utilities/getTopLevelFieldNames.d.ts.map +1 -0
  400. package/dist/utilities/getTopLevelFieldNames.js +3 -0
  401. package/dist/utilities/getTopLevelFieldNames.js.map +1 -0
  402. package/dist/utilities/getTopLevelFieldNames.spec.js +18 -0
  403. package/dist/utilities/getTopLevelFieldNames.spec.js.map +1 -0
  404. package/dist/utilities/handleEndpoints.js +1 -1
  405. package/dist/utilities/handleEndpoints.js.map +1 -1
  406. package/dist/utilities/parseParams/index.d.ts.map +1 -1
  407. package/dist/utilities/parseParams/index.js +3 -1
  408. package/dist/utilities/parseParams/index.js.map +1 -1
  409. package/dist/utilities/parseParams/index.spec.js +8 -0
  410. package/dist/utilities/parseParams/index.spec.js.map +1 -1
  411. package/dist/utilities/traverseFields.d.ts.map +1 -1
  412. package/dist/utilities/traverseFields.js +5 -14
  413. package/dist/utilities/traverseFields.js.map +1 -1
  414. package/dist/utilities/unflatten.d.ts.map +1 -1
  415. package/dist/utilities/unflatten.js +21 -9
  416. package/dist/utilities/unflatten.js.map +1 -1
  417. package/dist/utilities/unflatten.spec.js +38 -0
  418. package/dist/utilities/unflatten.spec.js.map +1 -0
  419. package/dist/versions/allLocalesPublicationStatus.d.ts +38 -0
  420. package/dist/versions/allLocalesPublicationStatus.d.ts.map +1 -0
  421. package/dist/versions/allLocalesPublicationStatus.js +57 -0
  422. package/dist/versions/allLocalesPublicationStatus.js.map +1 -0
  423. package/dist/versions/getLatestGlobalVersion.d.ts.map +1 -1
  424. package/dist/versions/getLatestGlobalVersion.js +10 -2
  425. package/dist/versions/getLatestGlobalVersion.js.map +1 -1
  426. package/dist/versions/getRestoredStatusesToAuthorize.d.ts +9 -0
  427. package/dist/versions/getRestoredStatusesToAuthorize.d.ts.map +1 -0
  428. package/dist/versions/getRestoredStatusesToAuthorize.js +22 -0
  429. package/dist/versions/getRestoredStatusesToAuthorize.js.map +1 -0
  430. package/dist/versions/getRestoredStatusesToAuthorize.spec.js +50 -0
  431. package/dist/versions/getRestoredStatusesToAuthorize.spec.js.map +1 -0
  432. package/dist/versions/schedule/job.d.ts +2 -2
  433. package/dist/versions/schedule/job.d.ts.map +1 -1
  434. package/dist/versions/schedule/job.js +11 -7
  435. package/dist/versions/schedule/job.js.map +1 -1
  436. package/dist/versions/schedule/types.d.ts +5 -1
  437. package/dist/versions/schedule/types.d.ts.map +1 -1
  438. package/dist/versions/schedule/types.js.map +1 -1
  439. package/package.json +4 -2
@@ -83,8 +83,10 @@ export type ServerComponentProps = {
83
83
  payload: Payload;
84
84
  permissions: SanitizedFieldPermissions;
85
85
  preferences: DocumentPreferences;
86
+ /** Request object. Use `req.user` (full principal) for access-control checks. */
86
87
  req: PayloadRequest;
87
88
  siblingData: Data;
89
+ /** Authenticated user with field read access applied. Use for values sent to the client; use `req.user` for access checks. */
88
90
  user: TypedUser;
89
91
  value?: unknown;
90
92
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Field.d.ts","sourceRoot":"","sources":["../../../src/admin/forms/Field.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;AACnF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC9E,OAAO,KAAK,EACV,oBAAoB,EACpB,SAAS,EACT,IAAI,EACJ,cAAc,EACd,SAAS,EACT,SAAS,EACT,aAAa,EACd,MAAM,aAAa,CAAA;AAE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2BAA2B,EAC9E,eAAe,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IACvE,KAAK,CAAC,aAAa,CAAC,eAAe,GAAG,eAAe,CAAC,YAAY,CAAC,CAAC,CAAA;AAExE,MAAM,MAAM,oBAAoB,CAC9B,YAAY,SAAS,KAAK,GAAG,KAAK,EAClC,YAAY,SAAS,2BAA2B,GAAG,2BAA2B,EAC9E,eAAe,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IACvE,KAAK,CAAC,aAAa,CAAC,eAAe,GAAG,eAAe,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/admin/forms/Field.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type { MarkOptional } from 'ts-essentials'\n\nimport type { SanitizedFieldPermissions } from '../../auth/types.js'\nimport type { ClientBlock, ClientField, Field } from '../../fields/config/types.js'\nimport type { TypedUser } from '../../index.js'\nimport type { DocumentPreferences } from '../../preferences/types.js'\nimport type { Operation, Payload, PayloadRequest } from '../../types/index.js'\nimport type {\n ClientFieldSchemaMap,\n ClientTab,\n Data,\n FieldSchemaMap,\n FormField,\n FormState,\n RenderedField,\n} from '../types.js'\n\nexport type ClientFieldWithOptionalType = MarkOptional<ClientField, 'type'>\n\nexport type ClientComponentProps = {\n customComponents?: FormField['customComponents']\n field: ClientBlock | ClientField | ClientTab\n /**\n * Controls the rendering behavior of the fields, i.e. defers rendering until they intersect with the viewport using the Intersection Observer API.\n *\n * If true, the fields will be rendered immediately, rather than waiting for them to intersect with the viewport.\n *\n * If a number is provided, will immediately render fields _up to that index_.\n */\n forceRender?: boolean\n permissions?: SanitizedFieldPermissions\n readOnly?: boolean\n renderedBlocks?: RenderedField[]\n /**\n * Used to extract field configs from a schemaMap.\n * Does not include indexes.\n *\n * @default field.name\n **/\n schemaPath?: string\n}\n\n// TODO: maybe we can come up with a better name?\nexport type FieldPaths = {\n /**\n * @default ''\n */\n indexPath?: string\n /**\n * @default ''\n */\n parentPath?: string\n /**\n * The path built up to the point of the field\n * excluding the field name.\n *\n * @default ''\n */\n parentSchemaPath?: string\n /**\n * A built up path to access FieldState in the form state.\n * Nested fields will have a path that includes the parent field names\n * if they are nested within a group, array, block or named tab.\n *\n * Collapsibles, rows and unnamed tabs will have arbitrary paths\n * that look like _index-0, _index-1, etc.\n *\n * @example 'parentGroupField.childTextField'\n *\n * @default field.name\n */\n path: string\n}\n\n/**\n * TODO: This should be renamed to `FieldComponentServerProps` or similar\n */\nexport type ServerComponentProps = {\n clientField: ClientFieldWithOptionalType\n clientFieldSchemaMap: ClientFieldSchemaMap\n collectionSlug: string\n data: Data\n field: Field\n /**\n * The fieldSchemaMap that is created before form state is built is made available here.\n */\n fieldSchemaMap: FieldSchemaMap\n /**\n * Server Components will also have available to the entire form state.\n * We cannot add it to ClientComponentProps as that would blow up the size of the props sent to the client.\n */\n formState: FormState\n i18n: I18nClient\n id?: number | string\n operation: Operation\n payload: Payload\n permissions: SanitizedFieldPermissions\n preferences: DocumentPreferences\n req: PayloadRequest\n siblingData: Data\n user: TypedUser\n value?: unknown\n}\n\nexport type ClientFieldBase<\n TFieldClient extends ClientFieldWithOptionalType = ClientFieldWithOptionalType,\n> = {\n readonly field: TFieldClient\n} & Omit<ClientComponentProps, 'customComponents' | 'field'>\n\nexport type ServerFieldBase<\n TFieldServer extends Field = Field,\n TFieldClient extends ClientFieldWithOptionalType = ClientFieldWithOptionalType,\n> = {\n readonly clientField: TFieldClient\n readonly field: TFieldServer\n} & Omit<ClientComponentProps, 'field'> &\n Omit<ServerComponentProps, 'clientField' | 'field'>\n\nexport type FieldClientComponent<\n TFieldClient extends ClientFieldWithOptionalType = ClientFieldWithOptionalType,\n AdditionalProps extends Record<string, unknown> = Record<string, unknown>,\n> = React.ComponentType<AdditionalProps & ClientFieldBase<TFieldClient>>\n\nexport type FieldServerComponent<\n TFieldServer extends Field = Field,\n TFieldClient extends ClientFieldWithOptionalType = ClientFieldWithOptionalType,\n AdditionalProps extends Record<string, unknown> = Record<string, unknown>,\n> = React.ComponentType<AdditionalProps & ServerFieldBase<TFieldServer, TFieldClient>>\n"],"names":[],"mappings":"AA6HA,WAIsF"}
1
+ {"version":3,"sources":["../../../src/admin/forms/Field.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type { MarkOptional } from 'ts-essentials'\n\nimport type { SanitizedFieldPermissions } from '../../auth/types.js'\nimport type { ClientBlock, ClientField, Field } from '../../fields/config/types.js'\nimport type { TypedUser } from '../../index.js'\nimport type { DocumentPreferences } from '../../preferences/types.js'\nimport type { Operation, Payload, PayloadRequest } from '../../types/index.js'\nimport type {\n ClientFieldSchemaMap,\n ClientTab,\n Data,\n FieldSchemaMap,\n FormField,\n FormState,\n RenderedField,\n} from '../types.js'\n\nexport type ClientFieldWithOptionalType = MarkOptional<ClientField, 'type'>\n\nexport type ClientComponentProps = {\n customComponents?: FormField['customComponents']\n field: ClientBlock | ClientField | ClientTab\n /**\n * Controls the rendering behavior of the fields, i.e. defers rendering until they intersect with the viewport using the Intersection Observer API.\n *\n * If true, the fields will be rendered immediately, rather than waiting for them to intersect with the viewport.\n *\n * If a number is provided, will immediately render fields _up to that index_.\n */\n forceRender?: boolean\n permissions?: SanitizedFieldPermissions\n readOnly?: boolean\n renderedBlocks?: RenderedField[]\n /**\n * Used to extract field configs from a schemaMap.\n * Does not include indexes.\n *\n * @default field.name\n **/\n schemaPath?: string\n}\n\n// TODO: maybe we can come up with a better name?\nexport type FieldPaths = {\n /**\n * @default ''\n */\n indexPath?: string\n /**\n * @default ''\n */\n parentPath?: string\n /**\n * The path built up to the point of the field\n * excluding the field name.\n *\n * @default ''\n */\n parentSchemaPath?: string\n /**\n * A built up path to access FieldState in the form state.\n * Nested fields will have a path that includes the parent field names\n * if they are nested within a group, array, block or named tab.\n *\n * Collapsibles, rows and unnamed tabs will have arbitrary paths\n * that look like _index-0, _index-1, etc.\n *\n * @example 'parentGroupField.childTextField'\n *\n * @default field.name\n */\n path: string\n}\n\n/**\n * TODO: This should be renamed to `FieldComponentServerProps` or similar\n */\nexport type ServerComponentProps = {\n clientField: ClientFieldWithOptionalType\n clientFieldSchemaMap: ClientFieldSchemaMap\n collectionSlug: string\n data: Data\n field: Field\n /**\n * The fieldSchemaMap that is created before form state is built is made available here.\n */\n fieldSchemaMap: FieldSchemaMap\n /**\n * Server Components will also have available to the entire form state.\n * We cannot add it to ClientComponentProps as that would blow up the size of the props sent to the client.\n */\n formState: FormState\n i18n: I18nClient\n id?: number | string\n operation: Operation\n payload: Payload\n permissions: SanitizedFieldPermissions\n preferences: DocumentPreferences\n /** Request object. Use `req.user` (full principal) for access-control checks. */\n req: PayloadRequest\n siblingData: Data\n /** Authenticated user with field read access applied. Use for values sent to the client; use `req.user` for access checks. */\n user: TypedUser\n value?: unknown\n}\n\nexport type ClientFieldBase<\n TFieldClient extends ClientFieldWithOptionalType = ClientFieldWithOptionalType,\n> = {\n readonly field: TFieldClient\n} & Omit<ClientComponentProps, 'customComponents' | 'field'>\n\nexport type ServerFieldBase<\n TFieldServer extends Field = Field,\n TFieldClient extends ClientFieldWithOptionalType = ClientFieldWithOptionalType,\n> = {\n readonly clientField: TFieldClient\n readonly field: TFieldServer\n} & Omit<ClientComponentProps, 'field'> &\n Omit<ServerComponentProps, 'clientField' | 'field'>\n\nexport type FieldClientComponent<\n TFieldClient extends ClientFieldWithOptionalType = ClientFieldWithOptionalType,\n AdditionalProps extends Record<string, unknown> = Record<string, unknown>,\n> = React.ComponentType<AdditionalProps & ClientFieldBase<TFieldClient>>\n\nexport type FieldServerComponent<\n TFieldServer extends Field = Field,\n TFieldClient extends ClientFieldWithOptionalType = ClientFieldWithOptionalType,\n AdditionalProps extends Record<string, unknown> = Record<string, unknown>,\n> = React.ComponentType<AdditionalProps & ServerFieldBase<TFieldServer, TFieldClient>>\n"],"names":[],"mappings":"AA+HA,WAIsF"}
@@ -158,6 +158,8 @@ export type BuildFormStateArgs = {
158
158
  skipClientConfigAuth?: boolean;
159
159
  skipValidation?: boolean;
160
160
  updateLastEdited?: boolean;
161
+ /** The authenticated user after read access for client-facing field components. */
162
+ user?: PayloadRequest['user'];
161
163
  } & ({
162
164
  collectionSlug: string;
163
165
  globalSlug?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../src/admin/forms/Form.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAElE,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAA;AACvE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AACvF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAE7E,MAAM,MAAM,IAAI,GAAG;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,GAAG,GAAG;IAChB,aAAa,CAAC,EAAE,UAAU,CAAC,eAAe,CAAC,CAAA;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,gBAAgB,CAAC,EAAE;QACjB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;KAC3B,CAAA;IACD,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,mBA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C,EAAE,OAAO,CAAA;IAClB,SAAS,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC/B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,GAAG,EAAE,cAAc,CAAA;IACnB;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB;;;;;;OAMG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,mFAAmF;IACnF,IAAI,CAAC,EAAE,cAAc,CAAC,MAAM,CAAC,CAAA;CAC9B,GAAG,CACA;IACE,cAAc,EAAE,MAAM,CAAA;IAGtB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,GACD;IACE,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,GACD;IACE,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;CACnB,CACJ,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/admin/forms/Form.ts"],"sourcesContent":["import { type SupportedLanguages } from '@payloadcms/translations'\n\nimport type { SanitizedDocumentPermissions } from '../../auth/types.js'\nimport type { Field, Option, TabAsField, Validate } from '../../fields/config/types.js'\nimport type { TypedLocale } from '../../index.js'\nimport type { DocumentPreferences } from '../../preferences/types.js'\nimport type { PayloadRequest, SelectType, Where } from '../../types/index.js'\n\nexport type Data = {\n [key: string]: any\n}\n\nexport type Row = {\n addedByServer?: FieldState['addedByServer']\n blockType?: string\n collapsed?: boolean\n customComponents?: {\n RowLabel?: React.ReactNode\n }\n id: string\n isLoading?: boolean\n lastRenderedPath?: string\n}\n\nexport type FilterOptionsResult = {\n [relation: string]: boolean | Where\n}\n\nexport type FieldState = {\n /**\n * This is used to determine if the field was added by the server.\n * This ensures the field is not ignored by the client when merging form state.\n * This can happen because the current local state is treated as the source of truth.\n * See `mergeServerFormState` for more details.\n */\n addedByServer?: boolean\n /**\n * If the field is a `blocks` field, this will contain the slugs of blocks that are allowed, based on the result of `field.filterOptions`.\n * If this is undefined, all blocks are allowed.\n * If this is an empty array, no blocks are allowed.\n */\n blocksFilterOptions?: string[]\n customComponents?: {\n /**\n * This is used by UI fields, as they can have arbitrary components defined if used\n * as a vessel to bring in custom components.\n */\n [key: string]: React.ReactNode | React.ReactNode[] | undefined\n AfterInput?: React.ReactNode\n BeforeInput?: React.ReactNode\n Description?: React.ReactNode\n Error?: React.ReactNode\n Field?: React.ReactNode\n Label?: React.ReactNode\n }\n disableFormData?: boolean\n errorMessage?: string\n errorPaths?: string[]\n /**\n * The fieldSchema may be part of the form state if `includeSchema: true` is passed to buildFormState.\n * This will never be in the form state of the client.\n */\n fieldSchema?: Field | TabAsField\n filterOptions?: FilterOptionsResult\n initialValue?: unknown\n /**\n * Every time a field is changed locally, this flag is set to true. Prevents form state from server from overwriting local changes.\n * After merging server form state, this flag is reset.\n *\n * @experimental This property is experimental and may change in the future. Use at your own risk.\n */\n isModified?: boolean\n /**\n * The path of the field when its custom components were last rendered.\n * This is used to denote if a field has been rendered, and if so,\n * what path it was rendered under last.\n *\n * If this path is undefined, or, if it is different\n * from the current path of a given field, the field's components will be re-rendered.\n */\n lastRenderedPath?: string\n passesCondition?: boolean\n rows?: Row[]\n /**\n * The result of running `field.filterOptions` on select fields.\n */\n selectFilterOptions?: Option[]\n valid?: boolean\n validate?: Validate\n value?: unknown\n}\n\nexport type FieldStateWithoutComponents = Omit<FieldState, 'customComponents'>\n\nexport type FormState = {\n [path: string]: FieldState\n}\n\nexport type FormStateWithoutComponents = {\n [path: string]: FieldStateWithoutComponents\n}\n\nexport type BuildFormStateArgs = {\n /**\n * If true, will check if the document has been modified since it was loaded.\n * This helps detect stale data when multiple users are editing the same document.\n */\n checkForStaleData?: boolean\n data?: Data\n docPermissions: SanitizedDocumentPermissions | undefined\n docPreferences: DocumentPreferences\n /**\n * In case `formState` is not the top-level, document form state, this can be passed to\n * provide the top-level form state.\n */\n documentFormState?: FormState\n fallbackLocale?: false | TypedLocale\n formState?: FormState\n id?: number | string\n initialBlockData?: Data\n initialBlockFormState?: FormState\n /*\n If not i18n was passed, the language can be passed to init i18n\n */\n language?: keyof SupportedLanguages\n locale?: string\n /**\n * If true, will not render RSCs and instead return a simple string in their place.\n * This is useful for environments that lack RSC support, such as Jest.\n * Form state can still be built, but any server components will be omitted.\n * @default false\n */\n mockRSCs?: boolean\n operation?: 'create' | 'update'\n /**\n * The original updatedAt timestamp from when the document was initially loaded.\n * Used with checkForStaleData to detect if the document has been modified.\n */\n originalUpdatedAt?: string\n readOnly?: boolean\n /**\n * If true, will render field components within their state object.\n * Performance optimization: Setting to `false` ensures that only fields that have changed paths will re-render, e.g. new array rows, etc.\n * For example, you only need to render ALL fields on initial render, not on every onChange.\n */\n renderAllFields?: boolean\n req: PayloadRequest\n /**\n * If true, will return a fresh URL for live preview based on the current form state.\n * Note: this will run on every form state event, so if your `livePreview.url` function is long running or expensive,\n * ensure it caches itself as needed.\n */\n returnLivePreviewURL?: boolean\n returnLockStatus?: boolean\n /**\n * If true, will return a fresh URL for preview based on the current form state.\n * Note: this will run on every form state event, so if your `preview` function is long running or expensive,\n * ensure it caches itself as needed.\n */\n returnPreviewURL?: boolean\n schemaPath: string\n select?: SelectType\n /**\n * When true, sets `user: true` when calling `getClientConfig`.\n * This will retrieve the client config in its entirety, even when unauthenticated.\n * For example, the create-first-user view needs the entire config, but there is no user yet.\n *\n * @experimental This property is experimental and may change in the future. Use at your own risk.\n */\n skipClientConfigAuth?: boolean\n skipValidation?: boolean\n updateLastEdited?: boolean\n} & (\n | {\n collectionSlug: string\n // Do not type it as never. This still makes it so that either collectionSlug or globalSlug is required, but makes it easier to provide both collectionSlug and globalSlug if it's\n // unclear which one is actually available.\n globalSlug?: string\n widgetSlug?: string\n }\n | {\n collectionSlug?: string\n globalSlug: string\n widgetSlug?: string\n }\n | {\n collectionSlug?: string\n globalSlug?: string\n widgetSlug: string\n }\n)\n"],"names":[],"mappings":"AAsGA,WAwFC"}
1
+ {"version":3,"sources":["../../../src/admin/forms/Form.ts"],"sourcesContent":["import { type SupportedLanguages } from '@payloadcms/translations'\n\nimport type { SanitizedDocumentPermissions } from '../../auth/types.js'\nimport type { Field, Option, TabAsField, Validate } from '../../fields/config/types.js'\nimport type { TypedLocale } from '../../index.js'\nimport type { DocumentPreferences } from '../../preferences/types.js'\nimport type { PayloadRequest, SelectType, Where } from '../../types/index.js'\n\nexport type Data = {\n [key: string]: any\n}\n\nexport type Row = {\n addedByServer?: FieldState['addedByServer']\n blockType?: string\n collapsed?: boolean\n customComponents?: {\n RowLabel?: React.ReactNode\n }\n id: string\n isLoading?: boolean\n lastRenderedPath?: string\n}\n\nexport type FilterOptionsResult = {\n [relation: string]: boolean | Where\n}\n\nexport type FieldState = {\n /**\n * This is used to determine if the field was added by the server.\n * This ensures the field is not ignored by the client when merging form state.\n * This can happen because the current local state is treated as the source of truth.\n * See `mergeServerFormState` for more details.\n */\n addedByServer?: boolean\n /**\n * If the field is a `blocks` field, this will contain the slugs of blocks that are allowed, based on the result of `field.filterOptions`.\n * If this is undefined, all blocks are allowed.\n * If this is an empty array, no blocks are allowed.\n */\n blocksFilterOptions?: string[]\n customComponents?: {\n /**\n * This is used by UI fields, as they can have arbitrary components defined if used\n * as a vessel to bring in custom components.\n */\n [key: string]: React.ReactNode | React.ReactNode[] | undefined\n AfterInput?: React.ReactNode\n BeforeInput?: React.ReactNode\n Description?: React.ReactNode\n Error?: React.ReactNode\n Field?: React.ReactNode\n Label?: React.ReactNode\n }\n disableFormData?: boolean\n errorMessage?: string\n errorPaths?: string[]\n /**\n * The fieldSchema may be part of the form state if `includeSchema: true` is passed to buildFormState.\n * This will never be in the form state of the client.\n */\n fieldSchema?: Field | TabAsField\n filterOptions?: FilterOptionsResult\n initialValue?: unknown\n /**\n * Every time a field is changed locally, this flag is set to true. Prevents form state from server from overwriting local changes.\n * After merging server form state, this flag is reset.\n *\n * @experimental This property is experimental and may change in the future. Use at your own risk.\n */\n isModified?: boolean\n /**\n * The path of the field when its custom components were last rendered.\n * This is used to denote if a field has been rendered, and if so,\n * what path it was rendered under last.\n *\n * If this path is undefined, or, if it is different\n * from the current path of a given field, the field's components will be re-rendered.\n */\n lastRenderedPath?: string\n passesCondition?: boolean\n rows?: Row[]\n /**\n * The result of running `field.filterOptions` on select fields.\n */\n selectFilterOptions?: Option[]\n valid?: boolean\n validate?: Validate\n value?: unknown\n}\n\nexport type FieldStateWithoutComponents = Omit<FieldState, 'customComponents'>\n\nexport type FormState = {\n [path: string]: FieldState\n}\n\nexport type FormStateWithoutComponents = {\n [path: string]: FieldStateWithoutComponents\n}\n\nexport type BuildFormStateArgs = {\n /**\n * If true, will check if the document has been modified since it was loaded.\n * This helps detect stale data when multiple users are editing the same document.\n */\n checkForStaleData?: boolean\n data?: Data\n docPermissions: SanitizedDocumentPermissions | undefined\n docPreferences: DocumentPreferences\n /**\n * In case `formState` is not the top-level, document form state, this can be passed to\n * provide the top-level form state.\n */\n documentFormState?: FormState\n fallbackLocale?: false | TypedLocale\n formState?: FormState\n id?: number | string\n initialBlockData?: Data\n initialBlockFormState?: FormState\n /*\n If not i18n was passed, the language can be passed to init i18n\n */\n language?: keyof SupportedLanguages\n locale?: string\n /**\n * If true, will not render RSCs and instead return a simple string in their place.\n * This is useful for environments that lack RSC support, such as Jest.\n * Form state can still be built, but any server components will be omitted.\n * @default false\n */\n mockRSCs?: boolean\n operation?: 'create' | 'update'\n /**\n * The original updatedAt timestamp from when the document was initially loaded.\n * Used with checkForStaleData to detect if the document has been modified.\n */\n originalUpdatedAt?: string\n readOnly?: boolean\n /**\n * If true, will render field components within their state object.\n * Performance optimization: Setting to `false` ensures that only fields that have changed paths will re-render, e.g. new array rows, etc.\n * For example, you only need to render ALL fields on initial render, not on every onChange.\n */\n renderAllFields?: boolean\n req: PayloadRequest\n /**\n * If true, will return a fresh URL for live preview based on the current form state.\n * Note: this will run on every form state event, so if your `livePreview.url` function is long running or expensive,\n * ensure it caches itself as needed.\n */\n returnLivePreviewURL?: boolean\n returnLockStatus?: boolean\n /**\n * If true, will return a fresh URL for preview based on the current form state.\n * Note: this will run on every form state event, so if your `preview` function is long running or expensive,\n * ensure it caches itself as needed.\n */\n returnPreviewURL?: boolean\n schemaPath: string\n select?: SelectType\n /**\n * When true, sets `user: true` when calling `getClientConfig`.\n * This will retrieve the client config in its entirety, even when unauthenticated.\n * For example, the create-first-user view needs the entire config, but there is no user yet.\n *\n * @experimental This property is experimental and may change in the future. Use at your own risk.\n */\n skipClientConfigAuth?: boolean\n skipValidation?: boolean\n updateLastEdited?: boolean\n /** The authenticated user after read access for client-facing field components. */\n user?: PayloadRequest['user']\n} & (\n | {\n collectionSlug: string\n // Do not type it as never. This still makes it so that either collectionSlug or globalSlug is required, but makes it easier to provide both collectionSlug and globalSlug if it's\n // unclear which one is actually available.\n globalSlug?: string\n widgetSlug?: string\n }\n | {\n collectionSlug?: string\n globalSlug: string\n widgetSlug?: string\n }\n | {\n collectionSlug?: string\n globalSlug?: string\n widgetSlug: string\n }\n)\n"],"names":[],"mappings":"AAsGA,WA0FC"}
@@ -13,10 +13,12 @@ export type InitReqResult = {
13
13
  locale?: Locale;
14
14
  permissions: SanitizedPermissions;
15
15
  req: PayloadRequest;
16
+ /** The authenticated user after read access for client-facing consumers. */
17
+ user?: PayloadRequest['user'];
16
18
  };
17
19
  export type DefaultServerFunctionArgs = {
18
20
  importMap: ImportMap;
19
- } & Pick<InitReqResult, 'cookies' | 'locale' | 'permissions' | 'req'>;
21
+ } & Pick<InitReqResult, 'cookies' | 'locale' | 'permissions' | 'req' | 'user'>;
20
22
  export type ServerFunctionArgs = {
21
23
  args: Record<string, unknown>;
22
24
  name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/admin/functions/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAEjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAA;AACrE,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uCAAuC,CAAA;AACpE,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,UAAU,EACV,cAAc,EACd,UAAU,EACV,oBAAoB,EACrB,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+CAA+C,CAAA;AAEnF,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAE5B,OAAO,EAAE,OAAO,CAAA;IAEhB,YAAY,EAAE,iBAAiB,CAAA;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,oBAAoB,CAAA;IACjC,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,EAAE,SAAS,CAAA;CACrB,GAAG,IAAI,C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oC,GAAG;IACjD;;;OAGG;IACH,cAAc,EAAE,OAAO,CAAA;IACvB;;;;;;OAMG;IACH,oBAAoB,EAAE,cAAc,EAAE,CAAA;IACtC;;OAEG;IACH,SAAS,EAAE,MAAM,GAAG,MAAM,CAAA;IAC1B;;;;OAIG;IACH,yBAAyB,EAAE,cAAc,EAAE,CAAA;IAC3C;;OAEG;IACH,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;IACrC,GAAG,EAAE,cAAc,CAAA;IACnB;;OAEG;IACH,IAAI,EAAE,cAAc,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC,cAAc,CAAC,EAAE,cAAc,CAAA;IAC/B,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,IAAI,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,CAAA;CAC1B,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/admin/functions/index.ts"],"sourcesContent":["import type { AcceptedLanguages } from '@payloadcms/translations'\n\nimport type { ImportMap } from '../../bin/generateImportMap/index.js'\nimport type { Locale, SanitizedConfig } from '../../config/types.js'\nimport type { PaginatedDocs } from '../../database/types.js'\nimport type { Slugify } from '../../fields/baseFields/slug/index.js'\nimport type {\n CollectionSlug,\n ColumnPreference,\n FieldPaths,\n FolderSortKeys,\n GlobalSlug,\n SanitizedPermissions,\n} from '../../index.js'\nimport type { PayloadRequest, Sort, Where } from '../../types/index.js'\nimport type { ColumnsFromURL } from '../../utilities/transformColumnPreferences.js'\n\nexport type InitReqResult = {\n cookies: Map<string, string>\n // TODO: Remove in 4.0. Duplicative, already available in req.headers\n headers: Headers\n // TODO: Remove in 4.0. Duplicative, already available in req.i18n.language\n languageCode: AcceptedLanguages\n locale?: Locale\n permissions: SanitizedPermissions\n req: PayloadRequest\n}\n\nexport type DefaultServerFunctionArgs = {\n importMap: ImportMap\n} & Pick<InitReqResult, 'cookies' | 'locale' | 'permissions' | 'req'>\n\nexport type ServerFunctionArgs = {\n args: Record<string, unknown>\n name: string\n}\n\nexport type ServerFunctionClientArgs = {\n args: Record<string, unknown>\n name: string\n}\n\nexport type ServerFunctionClient = (args: ServerFunctionClientArgs) => Promise<unknown> | unknown\n\nexport type ServerFunction<\n TArgs extends object = Record<string, unknown>,\n TReturnType = Promise<unknown> | unknown,\n> = (args: DefaultServerFunctionArgs & TArgs) => TReturnType\n\nexport type ServerFunctionConfig = {\n fn: ServerFunction\n name: string\n}\n\nexport type ServerFunctionHandler = (\n args: {\n config: Promise<SanitizedConfig> | SanitizedConfig\n importMap: ImportMap\n /**\n * A map of server function names to their implementations. These are\n * registered alongside the base server functions and can be called\n * using the useServerFunctions() hook.\n *\n * @example\n * const { serverFunction } = useServerFunctions()\n *\n * const callServerFunction = useCallback(() => {\n *\n * async function call() {\n * const result = (await serverFunction({\n * name: 'record-key',\n * args: {\n * // Your args\n * },\n * }))\n *\n * // Do someting with the result\n * }\n *\n * void call()\n * }, [serverFunction])\n */\n serverFunctions?: Record<string, ServerFunction<any, any>>\n } & ServerFunctionClientArgs,\n) => Promise<unknown>\n\nexport type ListQuery = {\n /*\n * This is an of strings, i.e. `['title', '-slug']`\n * Use `transformColumnsToPreferences` and `transformColumnsToSearchParams` to convert it back and forth\n */\n columns?: ColumnsFromURL\n /*\n * A string representing the field to group by, e.g. `category`\n * A leading hyphen represents descending order, e.g. `-category`\n */\n groupBy?: string\n limit?: number\n page?: number\n preset?: number | string\n queryByGroup?: Record<string, ListQuery>\n /*\n When provided, is automatically injected into the `where` object\n */\n search?: string\n sort?: Sort\n where?: Where\n} & Record<string, unknown>\n\nexport type BuildTableStateArgs = {\n /**\n * If an array is provided, the table will be built to support polymorphic collections.\n */\n collectionSlug: string | string[]\n columns?: ColumnPreference[]\n data?: PaginatedDocs\n /**\n * @deprecated Use `data` instead\n */\n docs?: PaginatedDocs['docs']\n enableRowSelections?: boolean\n orderableFieldName: string\n parent?: {\n collectionSlug: CollectionSlug\n id: number | string\n joinPath: string\n }\n query?: ListQuery\n renderRowTypes?: boolean\n tableAppearance?: 'condensed' | 'default'\n}\n\nexport type BuildCollectionFolderViewResult = {\n View: React.ReactNode\n}\n\nexport type GetFolderResultsComponentAndDataArgs = {\n /**\n * If true and no folderID is provided, only folders will be returned.\n * If false, the results will include documents from the active collections.\n */\n browseByFolder: boolean\n /**\n * Used to filter document types to include in the results/display.\n *\n * i.e. ['folders', 'posts'] will only include folders and posts in the results.\n *\n * collectionsToQuery?\n */\n collectionsToDisplay: CollectionSlug[]\n /**\n * Used to determine how the results should be displayed.\n */\n displayAs: 'grid' | 'list'\n /**\n * Used to filter folders by the collections they are assigned to.\n *\n * i.e. ['posts'] will only include folders that are assigned to the posts collections.\n */\n folderAssignedCollections: CollectionSlug[]\n /**\n * The ID of the folder to filter results by.\n */\n folderID: number | string | undefined\n req: PayloadRequest\n /**\n * The sort order for the results.\n */\n sort: FolderSortKeys\n}\n\nexport type SlugifyServerFunctionArgs = {\n collectionSlug?: CollectionSlug\n globalSlug?: GlobalSlug\n path?: FieldPaths['path']\n} & Omit<Parameters<Slugify>[0], 'req'>\n"],"names":[],"mappings":"AA2KA,WAIuC"}
1
+ {"version":3,"sources":["../../../src/admin/functions/index.ts"],"sourcesContent":["import type { AcceptedLanguages } from '@payloadcms/translations'\n\nimport type { ImportMap } from '../../bin/generateImportMap/index.js'\nimport type { Locale, SanitizedConfig } from '../../config/types.js'\nimport type { PaginatedDocs } from '../../database/types.js'\nimport type { Slugify } from '../../fields/baseFields/slug/index.js'\nimport type {\n CollectionSlug,\n ColumnPreference,\n FieldPaths,\n FolderSortKeys,\n GlobalSlug,\n SanitizedPermissions,\n} from '../../index.js'\nimport type { PayloadRequest, Sort, Where } from '../../types/index.js'\nimport type { ColumnsFromURL } from '../../utilities/transformColumnPreferences.js'\n\nexport type InitReqResult = {\n cookies: Map<string, string>\n // TODO: Remove in 4.0. Duplicative, already available in req.headers\n headers: Headers\n // TODO: Remove in 4.0. Duplicative, already available in req.i18n.language\n languageCode: AcceptedLanguages\n locale?: Locale\n permissions: SanitizedPermissions\n req: PayloadRequest\n /** The authenticated user after read access for client-facing consumers. */\n user?: PayloadRequest['user']\n}\n\nexport type DefaultServerFunctionArgs = {\n importMap: ImportMap\n} & Pick<InitReqResult, 'cookies' | 'locale' | 'permissions' | 'req' | 'user'>\n\nexport type ServerFunctionArgs = {\n args: Record<string, unknown>\n name: string\n}\n\nexport type ServerFunctionClientArgs = {\n args: Record<string, unknown>\n name: string\n}\n\nexport type ServerFunctionClient = (args: ServerFunctionClientArgs) => Promise<unknown> | unknown\n\nexport type ServerFunction<\n TArgs extends object = Record<string, unknown>,\n TReturnType = Promise<unknown> | unknown,\n> = (args: DefaultServerFunctionArgs & TArgs) => TReturnType\n\nexport type ServerFunctionConfig = {\n fn: ServerFunction\n name: string\n}\n\nexport type ServerFunctionHandler = (\n args: {\n config: Promise<SanitizedConfig> | SanitizedConfig\n importMap: ImportMap\n /**\n * A map of server function names to their implementations. These are\n * registered alongside the base server functions and can be called\n * using the useServerFunctions() hook.\n *\n * @example\n * const { serverFunction } = useServerFunctions()\n *\n * const callServerFunction = useCallback(() => {\n *\n * async function call() {\n * const result = (await serverFunction({\n * name: 'record-key',\n * args: {\n * // Your args\n * },\n * }))\n *\n * // Do someting with the result\n * }\n *\n * void call()\n * }, [serverFunction])\n */\n serverFunctions?: Record<string, ServerFunction<any, any>>\n } & ServerFunctionClientArgs,\n) => Promise<unknown>\n\nexport type ListQuery = {\n /*\n * This is an of strings, i.e. `['title', '-slug']`\n * Use `transformColumnsToPreferences` and `transformColumnsToSearchParams` to convert it back and forth\n */\n columns?: ColumnsFromURL\n /*\n * A string representing the field to group by, e.g. `category`\n * A leading hyphen represents descending order, e.g. `-category`\n */\n groupBy?: string\n limit?: number\n page?: number\n preset?: number | string\n queryByGroup?: Record<string, ListQuery>\n /*\n When provided, is automatically injected into the `where` object\n */\n search?: string\n sort?: Sort\n where?: Where\n} & Record<string, unknown>\n\nexport type BuildTableStateArgs = {\n /**\n * If an array is provided, the table will be built to support polymorphic collections.\n */\n collectionSlug: string | string[]\n columns?: ColumnPreference[]\n data?: PaginatedDocs\n /**\n * @deprecated Use `data` instead\n */\n docs?: PaginatedDocs['docs']\n enableRowSelections?: boolean\n orderableFieldName: string\n parent?: {\n collectionSlug: CollectionSlug\n id: number | string\n joinPath: string\n }\n query?: ListQuery\n renderRowTypes?: boolean\n tableAppearance?: 'condensed' | 'default'\n}\n\nexport type BuildCollectionFolderViewResult = {\n View: React.ReactNode\n}\n\nexport type GetFolderResultsComponentAndDataArgs = {\n /**\n * If true and no folderID is provided, only folders will be returned.\n * If false, the results will include documents from the active collections.\n */\n browseByFolder: boolean\n /**\n * Used to filter document types to include in the results/display.\n *\n * i.e. ['folders', 'posts'] will only include folders and posts in the results.\n *\n * collectionsToQuery?\n */\n collectionsToDisplay: CollectionSlug[]\n /**\n * Used to determine how the results should be displayed.\n */\n displayAs: 'grid' | 'list'\n /**\n * Used to filter folders by the collections they are assigned to.\n *\n * i.e. ['posts'] will only include folders that are assigned to the posts collections.\n */\n folderAssignedCollections: CollectionSlug[]\n /**\n * The ID of the folder to filter results by.\n */\n folderID: number | string | undefined\n req: PayloadRequest\n /**\n * The sort order for the results.\n */\n sort: FolderSortKeys\n}\n\nexport type SlugifyServerFunctionArgs = {\n collectionSlug?: CollectionSlug\n globalSlug?: GlobalSlug\n path?: FieldPaths['path']\n} & Omit<Parameters<Slugify>[0], 'req'>\n"],"names":[],"mappings":"AA6KA,WAIuC"}
@@ -20,6 +20,6 @@ export type WidgetServerProps<TWidget extends {
20
20
  } & Exclude<TWidget, never>>] extends [never] ? string : WidgetSlugFromWidget<{
21
21
  data?: unknown;
22
22
  } & Exclude<TWidget, never>>;
23
- } & Pick<InitReqResult, 'cookies' | 'locale' | 'permissions' | 'req'>;
23
+ } & Pick<InitReqResult, 'cookies' | 'locale' | 'permissions' | 'req' | 'user'>;
24
24
  export {};
25
25
  //# sourceMappingURL=dashboard.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dashboard.d.ts","sourceRoot":"","sources":["../../../src/admin/views/dashboard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE5E,oBAAY,UAAU;IACpB,UAAU,gBAAgB;IAC1B,MAAM,YAAY;CACnB;AAED,KAAK,oBAAoB,CAAC,OAAO,IAAI,OAAO,SAAS;IACnD,IAAI,CAAC,EAAE,MAAM,KAAK,CAAA;CACnB,GACG,KAAK,GACL,KAAK,CAAA;AAET,KAAK,oBAAoB,CAAC,OAAO,SAAS;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,IAAI;KAC7D,KAAK,IAAI,UAAU,GAAG,WAAW,CAAC,KAAK,CAAC,SAAS,OAAO,GAAG,KAAK,GAAG,KAAK;CAC1E,CAAC,UAAU,CAAC,CAAA;AAEb,MAAM,MAAM,iBAAiB,CAAC,OAAO,SAAS;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,KAAK,GAAG,KAAK,IAAI;IAClF,UAAU,CAAC,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,GAClC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACvB,oBAAoB,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC3E,oBAAoB,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,GAC7C,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,UAAU,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,GACjC,MAAM,GACN,CAAC,oBAAoB,CAAC;QAAE,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,G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E,KAAK,CAAC,CAAC,GAC7C,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,UAAU,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,GACjC,MAAM,GACN,CAAC,oBAAoB,CAAC;QAAE,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAClF,MAAM,GACN,oBAAoB,CAAC;QAAE,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAA;CACzE,GAAG,IAAI,CAAC,aAAa,EAAE,SAAS,GAAG,QAAQ,GAAG,aAAa,GAAG,KAAK,GAAG,MAAM,CAAC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/admin/views/dashboard.ts"],"sourcesContent":["import type { InitReqResult, TypedWidget, WidgetSlug } from '../../index.js'\n\nexport enum EntityType {\n collection = 'collections',\n global = 'globals',\n}\n\ntype WidgetDataFromWidget<TWidget> = TWidget extends {\n data?: infer TData\n}\n ? TData\n : never\n\ntype WidgetSlugFromWidget<TWidget extends { data?: unknown }> = {\n [TSlug in WidgetSlug]: TypedWidget[TSlug] extends TWidget ? TSlug : never\n}[WidgetSlug]\n\nexport type WidgetServerProps<TWidget extends { data?: unknown } | never = never> = {\n widgetData?: [TWidget] extends [never]\n ? Record<string, unknown>\n : WidgetDataFromWidget<Exclude<TWidget, never>> extends Record<string, unknown>\n ? WidgetDataFromWidget<Exclude<TWidget, never>>\n : Record<string, unknown>\n widgetSlug: [TWidget] extends [never]\n ? string\n : [WidgetSlugFromWidget<{ data?: unknown } & Exclude<TWidget, never>>] extends [never]\n ? string\n : WidgetSlugFromWidget<{ data?: unknown } & Exclude<TWidget, never>>\n} & Pick<InitReqResult, 'cookies' | 'locale' | 'permissions' | 'req'>\n"],"names":["EntityType"],"mappings":"AAEA,OAAO,IAAA,AAAKA,oCAAAA;;;WAAAA;MAGX"}
1
+ {"version":3,"sources":["../../../src/admin/views/dashboard.ts"],"sourcesContent":["import type { InitReqResult, TypedWidget, WidgetSlug } from '../../index.js'\n\nexport enum EntityType {\n collection = 'collections',\n global = 'globals',\n}\n\ntype WidgetDataFromWidget<TWidget> = TWidget extends {\n data?: infer TData\n}\n ? TData\n : never\n\ntype WidgetSlugFromWidget<TWidget extends { data?: unknown }> = {\n [TSlug in WidgetSlug]: TypedWidget[TSlug] extends TWidget ? TSlug : never\n}[WidgetSlug]\n\nexport type WidgetServerProps<TWidget extends { data?: unknown } | never = never> = {\n widgetData?: [TWidget] extends [never]\n ? Record<string, unknown>\n : WidgetDataFromWidget<Exclude<TWidget, never>> extends Record<string, unknown>\n ? WidgetDataFromWidget<Exclude<TWidget, never>>\n : Record<string, unknown>\n widgetSlug: [TWidget] extends [never]\n ? string\n : [WidgetSlugFromWidget<{ data?: unknown } & Exclude<TWidget, never>>] extends [never]\n ? string\n : WidgetSlugFromWidget<{ data?: unknown } & Exclude<TWidget, never>>\n} & Pick<InitReqResult, 'cookies' | 'locale' | 'permissions' | 'req' | 'user'>\n"],"names":["EntityType"],"mappings":"AAEA,OAAO,IAAA,AAAKA,oCAAAA;;;WAAAA;MAGX"}
@@ -0,0 +1,15 @@
1
+ import type { SanitizedCollectionConfig } from '../collections/config/types.js';
2
+ import type { PayloadRequest } from '../types/index.js';
3
+ import type { AuthStrategyResult } from './types.js';
4
+ type AuthenticatedUser = NonNullable<AuthStrategyResult['user']>;
5
+ /** Runs an authenticated user through the collection's read pipeline. */
6
+ export declare const applyUserReadAccess: ({ collection, depth, overrideAccess, req, showHiddenFields, user, }: {
7
+ collection: SanitizedCollectionConfig;
8
+ depth?: number;
9
+ overrideAccess: boolean;
10
+ req: PayloadRequest;
11
+ showHiddenFields: boolean;
12
+ user: AuthenticatedUser;
13
+ }) => Promise<AuthenticatedUser>;
14
+ export {};
15
+ //# sourceMappingURL=applyUserReadAccess.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applyUserReadAccess.d.ts","sourceRoot":"","sources":["../../src/auth/applyUserReadAccess.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAC/E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAKpD,KAAK,iBAAiB,GAAG,WAAW,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAA;AAEhE,yEAAyE;AACzE,eAAO,MAAM,mBAAmB,wEAO7B;IACD,UAAU,EAAE,yBAAyB,CAAA;IACrC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,cAAc,EAAE,OAAO,CAAA;IACvB,GAAG,EAAE,cAAc,CAAA;IACnB,gBAAgB,EAAE,OAAO,CAAA;IACzB,IAAI,EAAE,iBAAiB,CAAA;CACxB,KAAG,OAAO,CAAC,iBAAiB,CAsC5B,CAAA"}
@@ -0,0 +1,41 @@
1
+ import { afterRead } from '../fields/hooks/afterRead/index.js';
2
+ import { deepCopyObjectSimple } from '../utilities/deepCopyObject.js';
3
+ /** Runs an authenticated user through the collection's read pipeline. */ export const applyUserReadAccess = async ({ collection, depth, overrideAccess, req, showHiddenFields, user })=>{
4
+ const authenticationMetadata = {
5
+ ...user._sid !== undefined ? {
6
+ _sid: user._sid
7
+ } : {},
8
+ _strategy: user._strategy,
9
+ collection: user.collection
10
+ };
11
+ let userWithReadAccess = await afterRead({
12
+ collection,
13
+ context: req.context,
14
+ depth: depth,
15
+ doc: deepCopyObjectSimple(user),
16
+ draft: false,
17
+ fallbackLocale: req.fallbackLocale,
18
+ global: null,
19
+ locale: req.locale,
20
+ overrideAccess,
21
+ req,
22
+ showHiddenFields
23
+ });
24
+ if (collection.hooks?.afterRead?.length) {
25
+ for (const hook of collection.hooks.afterRead){
26
+ userWithReadAccess = await hook({
27
+ collection,
28
+ context: req.context,
29
+ doc: userWithReadAccess,
30
+ overrideAccess,
31
+ req
32
+ }) || userWithReadAccess;
33
+ }
34
+ }
35
+ return {
36
+ ...userWithReadAccess,
37
+ ...authenticationMetadata
38
+ };
39
+ };
40
+
41
+ //# sourceMappingURL=applyUserReadAccess.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/auth/applyUserReadAccess.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../collections/config/types.js'\nimport type { PayloadRequest } from '../types/index.js'\nimport type { AuthStrategyResult } from './types.js'\n\nimport { afterRead } from '../fields/hooks/afterRead/index.js'\nimport { deepCopyObjectSimple } from '../utilities/deepCopyObject.js'\n\ntype AuthenticatedUser = NonNullable<AuthStrategyResult['user']>\n\n/** Runs an authenticated user through the collection's read pipeline. */\nexport const applyUserReadAccess = async ({\n collection,\n depth,\n overrideAccess,\n req,\n showHiddenFields,\n user,\n}: {\n collection: SanitizedCollectionConfig\n depth?: number\n overrideAccess: boolean\n req: PayloadRequest\n showHiddenFields: boolean\n user: AuthenticatedUser\n}): Promise<AuthenticatedUser> => {\n const authenticationMetadata = {\n ...(user._sid !== undefined ? { _sid: user._sid } : {}),\n _strategy: user._strategy,\n collection: user.collection,\n }\n\n let userWithReadAccess = await afterRead({\n collection,\n context: req.context,\n depth: depth!,\n doc: deepCopyObjectSimple(user),\n draft: false,\n fallbackLocale: req.fallbackLocale!,\n global: null,\n locale: req.locale!,\n overrideAccess,\n req,\n showHiddenFields,\n })\n\n if (collection.hooks?.afterRead?.length) {\n for (const hook of collection.hooks.afterRead) {\n userWithReadAccess =\n (await hook({\n collection,\n context: req.context,\n doc: userWithReadAccess,\n overrideAccess,\n req,\n })) || userWithReadAccess\n }\n }\n\n return {\n ...userWithReadAccess,\n ...authenticationMetadata,\n }\n}\n"],"names":["afterRead","deepCopyObjectSimple","applyUserReadAccess","collection","depth","overrideAccess","req","showHiddenFields","user","authenticationMetadata","_sid","undefined","_strategy","userWithReadAccess","context","doc","draft","fallbackLocale","global","locale","hooks","length","hook"],"mappings":"AAIA,SAASA,SAAS,QAAQ,qCAAoC;AAC9D,SAASC,oBAAoB,QAAQ,iCAAgC;AAIrE,uEAAuE,GACvE,OAAO,MAAMC,sBAAsB,OAAO,EACxCC,UAAU,EACVC,KAAK,EACLC,cAAc,EACdC,GAAG,EACHC,gBAAgB,EAChBC,IAAI,EAQL;IACC,MAAMC,yBAAyB;QAC7B,GAAID,KAAKE,IAAI,KAAKC,YAAY;YAAED,MAAMF,KAAKE,IAAI;QAAC,IAAI,CAAC,CAAC;QACtDE,WAAWJ,KAAKI,SAAS;QACzBT,YAAYK,KAAKL,UAAU;IAC7B;IAEA,IAAIU,qBAAqB,MAAMb,UAAU;QACvCG;QACAW,SAASR,IAAIQ,OAAO;QACpBV,OAAOA;QACPW,KAAKd,qBAAqBO;QAC1BQ,OAAO;QACPC,gBAAgBX,IAAIW,cAAc;QAClCC,QAAQ;QACRC,QAAQb,IAAIa,MAAM;QAClBd;QACAC;QACAC;IACF;IAEA,IAAIJ,WAAWiB,KAAK,EAAEpB,WAAWqB,QAAQ;QACvC,KAAK,MAAMC,QAAQnB,WAAWiB,KAAK,CAACpB,SAAS,CAAE;YAC7Ca,qBACE,AAAC,MAAMS,KAAK;gBACVnB;gBACAW,SAASR,IAAIQ,OAAO;gBACpBC,KAAKF;gBACLR;gBACAC;YACF,MAAOO;QACX;IACF;IAEA,OAAO;QACL,GAAGA,kBAAkB;QACrB,GAAGJ,sBAAsB;IAC3B;AACF,EAAC"}
@@ -0,0 +1,4 @@
1
+ import type { FieldAccess } from '../../../fields/config/types.js';
2
+ /** Allows API key creation and updates only for users with admin access. */
3
+ export declare const canCreateOrUpdateAPIKey: FieldAccess;
4
+ //# sourceMappingURL=canCreateOrUpdateAPIKey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canCreateOrUpdateAPIKey.d.ts","sourceRoot":"","sources":["../../../../src/auth/baseFields/apiKey/canCreateOrUpdateAPIKey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAKlE,4EAA4E;AAC5E,eAAO,MAAM,uBAAuB,EAAE,WAgBrC,CAAA"}
@@ -0,0 +1,20 @@
1
+ import { UnauthorizedError } from '../../../errors/UnauthorizedError.js';
2
+ import { canAccessAdmin } from '../../../utilities/canAccessAdmin.js';
3
+ /** Allows API key creation and updates only for users with admin access. */ export const canCreateOrUpdateAPIKey = async ({ req })=>{
4
+ if (!req.user) {
5
+ return false;
6
+ }
7
+ try {
8
+ await canAccessAdmin({
9
+ req
10
+ });
11
+ } catch (error) {
12
+ if (error instanceof UnauthorizedError) {
13
+ return false;
14
+ }
15
+ throw error;
16
+ }
17
+ return true;
18
+ };
19
+
20
+ //# sourceMappingURL=canCreateOrUpdateAPIKey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/auth/baseFields/apiKey/canCreateOrUpdateAPIKey.ts"],"sourcesContent":["import type { FieldAccess } from '../../../fields/config/types.js'\n\nimport { UnauthorizedError } from '../../../errors/UnauthorizedError.js'\nimport { canAccessAdmin } from '../../../utilities/canAccessAdmin.js'\n\n/** Allows API key creation and updates only for users with admin access. */\nexport const canCreateOrUpdateAPIKey: FieldAccess = async ({ req }) => {\n if (!req.user) {\n return false\n }\n\n try {\n await canAccessAdmin({ req })\n } catch (error) {\n if (error instanceof UnauthorizedError) {\n return false\n }\n\n throw error\n }\n\n return true\n}\n"],"names":["UnauthorizedError","canAccessAdmin","canCreateOrUpdateAPIKey","req","user","error"],"mappings":"AAEA,SAASA,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,cAAc,QAAQ,uCAAsC;AAErE,0EAA0E,GAC1E,OAAO,MAAMC,0BAAuC,OAAO,EAAEC,GAAG,EAAE;IAChE,IAAI,CAACA,IAAIC,IAAI,EAAE;QACb,OAAO;IACT;IAEA,IAAI;QACF,MAAMH,eAAe;YAAEE;QAAI;IAC7B,EAAE,OAAOE,OAAO;QACd,IAAIA,iBAAiBL,mBAAmB;YACtC,OAAO;QACT;QAEA,MAAMK;IACR;IAEA,OAAO;AACT,EAAC"}
@@ -0,0 +1,4 @@
1
+ import type { FieldHook } from '../../../fields/config/types.js';
2
+ /** Encrypts API keys before storage. */
3
+ export declare const encryptAPIKey: FieldHook;
4
+ //# sourceMappingURL=encryptAPIKey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encryptAPIKey.d.ts","sourceRoot":"","sources":["../../../../src/auth/baseFields/apiKey/encryptAPIKey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAA;AAEhE,wCAAwC;AACxC,eAAO,MAAM,aAAa,EAAE,SAsB3B,CAAA"}
@@ -0,0 +1,16 @@
1
+ /** Encrypts API keys before storage. */ export const encryptAPIKey = ({ data, originalDoc, req, value })=>{
2
+ if (data && 'apiKey' in data && typeof data.apiKey !== 'undefined' && !(typeof data.apiKey === 'string' && data.apiKey)) {
3
+ return null;
4
+ }
5
+ // Checking `enableAPIKey` here is for backward compatibility only and will be removed in v4.
6
+ const isDisablingAPIKey = data?.enableAPIKey === false && originalDoc?.enableAPIKey !== false;
7
+ if (isDisablingAPIKey && !(typeof data.apiKey === 'string' && data.apiKey)) {
8
+ return null;
9
+ }
10
+ if (typeof value === 'undefined') {
11
+ return undefined;
12
+ }
13
+ return value ? req.payload.encrypt(value) : null;
14
+ };
15
+
16
+ //# sourceMappingURL=encryptAPIKey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/auth/baseFields/apiKey/encryptAPIKey.ts"],"sourcesContent":["import type { FieldHook } from '../../../fields/config/types.js'\n\n/** Encrypts API keys before storage. */\nexport const encryptAPIKey: FieldHook = ({ data, originalDoc, req, value }) => {\n if (\n data &&\n 'apiKey' in data &&\n typeof data.apiKey !== 'undefined' &&\n !(typeof data.apiKey === 'string' && data.apiKey)\n ) {\n return null\n }\n\n // Checking `enableAPIKey` here is for backward compatibility only and will be removed in v4.\n const isDisablingAPIKey = data?.enableAPIKey === false && originalDoc?.enableAPIKey !== false\n\n if (isDisablingAPIKey && !(typeof data.apiKey === 'string' && data.apiKey)) {\n return null\n }\n\n if (typeof value === 'undefined') {\n return undefined\n }\n\n return value ? req.payload.encrypt(value as string) : null\n}\n"],"names":["encryptAPIKey","data","originalDoc","req","value","apiKey","isDisablingAPIKey","enableAPIKey","undefined","payload","encrypt"],"mappings":"AAEA,sCAAsC,GACtC,OAAO,MAAMA,gBAA2B,CAAC,EAAEC,IAAI,EAAEC,WAAW,EAAEC,GAAG,EAAEC,KAAK,EAAE;IACxE,IACEH,QACA,YAAYA,QACZ,OAAOA,KAAKI,MAAM,KAAK,eACvB,CAAE,CAAA,OAAOJ,KAAKI,MAAM,KAAK,YAAYJ,KAAKI,MAAM,AAAD,GAC/C;QACA,OAAO;IACT;IAEA,6FAA6F;IAC7F,MAAMC,oBAAoBL,MAAMM,iBAAiB,SAASL,aAAaK,iBAAiB;IAExF,IAAID,qBAAqB,CAAE,CAAA,OAAOL,KAAKI,MAAM,KAAK,YAAYJ,KAAKI,MAAM,AAAD,GAAI;QAC1E,OAAO;IACT;IAEA,IAAI,OAAOD,UAAU,aAAa;QAChC,OAAOI;IACT;IAEA,OAAOJ,QAAQD,IAAIM,OAAO,CAACC,OAAO,CAACN,SAAmB;AACxD,EAAC"}
@@ -0,0 +1,6 @@
1
+ import type { Field } from '../../../fields/config/types.js';
2
+ export { omitAPIKey } from './omitAPIKey.js';
3
+ export declare const apiKeyFields: Field[];
4
+ /** Builds API key fields and safely merges custom overrides. */
5
+ export declare const getAPIKeyFields: (fields: Field[]) => Field[];
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/auth/baseFields/apiKey/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAA;AAS5D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,eAAO,MAAM,YAAY,EAiEpB,KAAK,EAAE,CAAA;AAEZ,gEAAgE;AAChE,eAAO,MAAM,eAAe,WAAY,KAAK,EAAE,KAAG,KAAK,EAkCtD,CAAA"}
@@ -0,0 +1,112 @@
1
+ import { fieldAffectsData } from '../../../fields/config/types.js';
2
+ import { canCreateOrUpdateAPIKey } from './canCreateOrUpdateAPIKey.js';
3
+ import { encryptAPIKey } from './encryptAPIKey.js';
4
+ import { omitAPIKeyIndex } from './omitAPIKeyIndex.js';
5
+ import { omitEncryptedAPIKey } from './omitEncryptedAPIKey.js';
6
+ import { setAPIKeyIndex } from './setAPIKeyIndex.js';
7
+ export { omitAPIKey } from './omitAPIKey.js';
8
+ export const apiKeyFields = [
9
+ // The `enableAPIKey` field is for backward compatibility only and will be removed in v4.
10
+ {
11
+ name: 'enableAPIKey',
12
+ type: 'checkbox',
13
+ access: {
14
+ create: canCreateOrUpdateAPIKey,
15
+ update: canCreateOrUpdateAPIKey
16
+ },
17
+ admin: {
18
+ components: {
19
+ Field: false
20
+ }
21
+ },
22
+ label: ({ t })=>t('authentication:enableAPIKey')
23
+ },
24
+ {
25
+ name: 'apiKey',
26
+ type: 'text',
27
+ access: {
28
+ create: canCreateOrUpdateAPIKey,
29
+ read: ()=>false,
30
+ update: canCreateOrUpdateAPIKey
31
+ },
32
+ admin: {
33
+ components: {
34
+ Field: false
35
+ }
36
+ },
37
+ hooks: {
38
+ afterRead: [
39
+ omitEncryptedAPIKey
40
+ ],
41
+ beforeChange: [
42
+ encryptAPIKey
43
+ ]
44
+ },
45
+ label: ({ t })=>t('authentication:apiKey')
46
+ },
47
+ {
48
+ name: 'apiKeyIndex',
49
+ type: 'text',
50
+ access: {
51
+ create: canCreateOrUpdateAPIKey,
52
+ read: ()=>false,
53
+ update: canCreateOrUpdateAPIKey
54
+ },
55
+ admin: {
56
+ disabled: true
57
+ },
58
+ hidden: true,
59
+ hooks: {
60
+ afterRead: [
61
+ omitAPIKeyIndex
62
+ ],
63
+ beforeValidate: [
64
+ setAPIKeyIndex
65
+ ]
66
+ }
67
+ },
68
+ {
69
+ name: 'hasAPIKey',
70
+ type: 'checkbox',
71
+ access: {
72
+ read: canCreateOrUpdateAPIKey
73
+ },
74
+ admin: {
75
+ components: {
76
+ Field: false
77
+ }
78
+ },
79
+ virtual: true
80
+ }
81
+ ];
82
+ /** Builds API key fields and safely merges custom overrides. */ export const getAPIKeyFields = (fields)=>{
83
+ const customAPIKeyField = fields.find((field)=>fieldAffectsData(field) && field.name === 'apiKey');
84
+ const customAccess = customAPIKeyField && 'access' in customAPIKeyField ? customAPIKeyField.access : undefined;
85
+ return apiKeyFields.map((field)=>{
86
+ if (field.type === 'checkbox' && field.name === 'hasAPIKey') {
87
+ return {
88
+ ...field,
89
+ access: {
90
+ ...field.access,
91
+ read: customAccess?.update ?? canCreateOrUpdateAPIKey
92
+ }
93
+ };
94
+ }
95
+ if (field.type !== 'checkbox' && field.type !== 'text' || ![
96
+ 'apiKeyIndex',
97
+ 'enableAPIKey'
98
+ ].includes(field.name)) {
99
+ return field;
100
+ }
101
+ return {
102
+ ...field,
103
+ access: {
104
+ ...field.access,
105
+ create: customAccess?.create ?? canCreateOrUpdateAPIKey,
106
+ update: customAccess?.update ?? canCreateOrUpdateAPIKey
107
+ }
108
+ };
109
+ });
110
+ };
111
+
112
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/auth/baseFields/apiKey/index.ts"],"sourcesContent":["import type { Field } from '../../../fields/config/types.js'\n\nimport { fieldAffectsData } from '../../../fields/config/types.js'\nimport { canCreateOrUpdateAPIKey } from './canCreateOrUpdateAPIKey.js'\nimport { encryptAPIKey } from './encryptAPIKey.js'\nimport { omitAPIKeyIndex } from './omitAPIKeyIndex.js'\nimport { omitEncryptedAPIKey } from './omitEncryptedAPIKey.js'\nimport { setAPIKeyIndex } from './setAPIKeyIndex.js'\n\nexport { omitAPIKey } from './omitAPIKey.js'\n\nexport const apiKeyFields = [\n // The `enableAPIKey` field is for backward compatibility only and will be removed in v4.\n {\n name: 'enableAPIKey',\n type: 'checkbox',\n access: {\n create: canCreateOrUpdateAPIKey,\n update: canCreateOrUpdateAPIKey,\n },\n admin: {\n components: {\n Field: false,\n },\n },\n label: ({ t }) => t('authentication:enableAPIKey'),\n },\n {\n name: 'apiKey',\n type: 'text',\n access: {\n create: canCreateOrUpdateAPIKey,\n read: () => false,\n update: canCreateOrUpdateAPIKey,\n },\n admin: {\n components: {\n Field: false,\n },\n },\n hooks: {\n afterRead: [omitEncryptedAPIKey],\n beforeChange: [encryptAPIKey],\n },\n label: ({ t }) => t('authentication:apiKey'),\n },\n {\n name: 'apiKeyIndex',\n type: 'text',\n access: {\n create: canCreateOrUpdateAPIKey,\n read: () => false,\n update: canCreateOrUpdateAPIKey,\n },\n admin: {\n disabled: true,\n },\n hidden: true,\n hooks: {\n afterRead: [omitAPIKeyIndex],\n beforeValidate: [setAPIKeyIndex],\n },\n },\n {\n name: 'hasAPIKey',\n type: 'checkbox',\n access: {\n read: canCreateOrUpdateAPIKey,\n },\n admin: {\n components: {\n Field: false,\n },\n },\n virtual: true,\n },\n] as Field[]\n\n/** Builds API key fields and safely merges custom overrides. */\nexport const getAPIKeyFields = (fields: Field[]): Field[] => {\n const customAPIKeyField = fields.find(\n (field) => fieldAffectsData(field) && field.name === 'apiKey',\n )\n const customAccess =\n customAPIKeyField && 'access' in customAPIKeyField ? customAPIKeyField.access : undefined\n\n return apiKeyFields.map((field) => {\n if (field.type === 'checkbox' && field.name === 'hasAPIKey') {\n return {\n ...field,\n access: {\n ...field.access,\n read: customAccess?.update ?? canCreateOrUpdateAPIKey,\n },\n }\n }\n\n if (\n (field.type !== 'checkbox' && field.type !== 'text') ||\n !['apiKeyIndex', 'enableAPIKey'].includes(field.name)\n ) {\n return field\n }\n\n return {\n ...field,\n access: {\n ...field.access,\n create: customAccess?.create ?? canCreateOrUpdateAPIKey,\n update: customAccess?.update ?? canCreateOrUpdateAPIKey,\n },\n }\n })\n}\n"],"names":["fieldAffectsData","canCreateOrUpdateAPIKey","encryptAPIKey","omitAPIKeyIndex","omitEncryptedAPIKey","setAPIKeyIndex","omitAPIKey","apiKeyFields","name","type","access","create","update","admin","components","Field","label","t","read","hooks","afterRead","beforeChange","disabled","hidden","beforeValidate","virtual","getAPIKeyFields","fields","customAPIKeyField","find","field","customAccess","undefined","map","includes"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,kCAAiC;AAClE,SAASC,uBAAuB,QAAQ,+BAA8B;AACtE,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,cAAc,QAAQ,sBAAqB;AAEpD,SAASC,UAAU,QAAQ,kBAAiB;AAE5C,OAAO,MAAMC,eAAe;IAC1B,yFAAyF;IACzF;QACEC,MAAM;QACNC,MAAM;QACNC,QAAQ;YACNC,QAAQV;YACRW,QAAQX;QACV;QACAY,OAAO;YACLC,YAAY;gBACVC,OAAO;YACT;QACF;QACAC,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;IACtB;IACA;QACET,MAAM;QACNC,MAAM;QACNC,QAAQ;YACNC,QAAQV;YACRiB,MAAM,IAAM;YACZN,QAAQX;QACV;QACAY,OAAO;YACLC,YAAY;gBACVC,OAAO;YACT;QACF;QACAI,OAAO;YACLC,WAAW;gBAAChB;aAAoB;YAChCiB,cAAc;gBAACnB;aAAc;QAC/B;QACAc,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;IACtB;IACA;QACET,MAAM;QACNC,MAAM;QACNC,QAAQ;YACNC,QAAQV;YACRiB,MAAM,IAAM;YACZN,QAAQX;QACV;QACAY,OAAO;YACLS,UAAU;QACZ;QACAC,QAAQ;QACRJ,OAAO;YACLC,WAAW;gBAACjB;aAAgB;YAC5BqB,gBAAgB;gBAACnB;aAAe;QAClC;IACF;IACA;QACEG,MAAM;QACNC,MAAM;QACNC,QAAQ;YACNQ,MAAMjB;QACR;QACAY,OAAO;YACLC,YAAY;gBACVC,OAAO;YACT;QACF;QACAU,SAAS;IACX;CACD,CAAW;AAEZ,8DAA8D,GAC9D,OAAO,MAAMC,kBAAkB,CAACC;IAC9B,MAAMC,oBAAoBD,OAAOE,IAAI,CACnC,CAACC,QAAU9B,iBAAiB8B,UAAUA,MAAMtB,IAAI,KAAK;IAEvD,MAAMuB,eACJH,qBAAqB,YAAYA,oBAAoBA,kBAAkBlB,MAAM,GAAGsB;IAElF,OAAOzB,aAAa0B,GAAG,CAAC,CAACH;QACvB,IAAIA,MAAMrB,IAAI,KAAK,cAAcqB,MAAMtB,IAAI,KAAK,aAAa;YAC3D,OAAO;gBACL,GAAGsB,KAAK;gBACRpB,QAAQ;oBACN,GAAGoB,MAAMpB,MAAM;oBACfQ,MAAMa,cAAcnB,UAAUX;gBAChC;YACF;QACF;QAEA,IACE,AAAC6B,MAAMrB,IAAI,KAAK,cAAcqB,MAAMrB,IAAI,KAAK,UAC7C,CAAC;YAAC;YAAe;SAAe,CAACyB,QAAQ,CAACJ,MAAMtB,IAAI,GACpD;YACA,OAAOsB;QACT;QAEA,OAAO;YACL,GAAGA,KAAK;YACRpB,QAAQ;gBACN,GAAGoB,MAAMpB,MAAM;gBACfC,QAAQoB,cAAcpB,UAAUV;gBAChCW,QAAQmB,cAAcnB,UAAUX;YAClC;QACF;IACF;AACF,EAAC"}
@@ -0,0 +1,4 @@
1
+ import type { BeforeReadHook } from '../../../collections/config/types.js';
2
+ /** Removes API key secrets before any collection read hooks can observe them. */
3
+ export declare const omitAPIKey: BeforeReadHook;
4
+ //# sourceMappingURL=omitAPIKey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"omitAPIKey.d.ts","sourceRoot":"","sources":["../../../../src/auth/baseFields/apiKey/omitAPIKey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAA;AAE1E,iFAAiF;AACjF,eAAO,MAAM,UAAU,EAAE,cAOxB,CAAA"}
@@ -0,0 +1,8 @@
1
+ /** Removes API key secrets before any collection read hooks can observe them. */ export const omitAPIKey = ({ doc })=>{
2
+ doc.hasAPIKey = Boolean(doc.apiKeyIndex);
3
+ delete doc.apiKey;
4
+ delete doc.apiKeyIndex;
5
+ return doc;
6
+ };
7
+
8
+ //# sourceMappingURL=omitAPIKey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/auth/baseFields/apiKey/omitAPIKey.ts"],"sourcesContent":["import type { BeforeReadHook } from '../../../collections/config/types.js'\n\n/** Removes API key secrets before any collection read hooks can observe them. */\nexport const omitAPIKey: BeforeReadHook = ({ doc }) => {\n doc.hasAPIKey = Boolean(doc.apiKeyIndex)\n\n delete doc.apiKey\n delete doc.apiKeyIndex\n\n return doc\n}\n"],"names":["omitAPIKey","doc","hasAPIKey","Boolean","apiKeyIndex","apiKey"],"mappings":"AAEA,+EAA+E,GAC/E,OAAO,MAAMA,aAA6B,CAAC,EAAEC,GAAG,EAAE;IAChDA,IAAIC,SAAS,GAAGC,QAAQF,IAAIG,WAAW;IAEvC,OAAOH,IAAII,MAAM;IACjB,OAAOJ,IAAIG,WAAW;IAEtB,OAAOH;AACT,EAAC"}
@@ -0,0 +1,4 @@
1
+ import type { FieldHook } from '../../../fields/config/types.js';
2
+ /** Keeps the authentication index out of returned documents. */
3
+ export declare const omitAPIKeyIndex: FieldHook;
4
+ //# sourceMappingURL=omitAPIKeyIndex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"omitAPIKeyIndex.d.ts","sourceRoot":"","sources":["../../../../src/auth/baseFields/apiKey/omitAPIKeyIndex.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAA;AAEhE,gEAAgE;AAChE,eAAO,MAAM,eAAe,EAAE,SAE7B,CAAA"}
@@ -0,0 +1,5 @@
1
+ /** Keeps the authentication index out of returned documents. */ export const omitAPIKeyIndex = ({ siblingData })=>{
2
+ delete siblingData.apiKeyIndex;
3
+ };
4
+
5
+ //# sourceMappingURL=omitAPIKeyIndex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/auth/baseFields/apiKey/omitAPIKeyIndex.ts"],"sourcesContent":["import type { FieldHook } from '../../../fields/config/types.js'\n\n/** Keeps the authentication index out of returned documents. */\nexport const omitAPIKeyIndex: FieldHook = ({ siblingData }) => {\n delete siblingData.apiKeyIndex\n}\n"],"names":["omitAPIKeyIndex","siblingData","apiKeyIndex"],"mappings":"AAEA,8DAA8D,GAC9D,OAAO,MAAMA,kBAA6B,CAAC,EAAEC,WAAW,EAAE;IACxD,OAAOA,YAAYC,WAAW;AAChC,EAAC"}
@@ -0,0 +1,4 @@
1
+ import type { FieldHook } from '../../../fields/config/types.js';
2
+ /** Prevents the encrypted key from surviving field-level reads. */
3
+ export declare const omitEncryptedAPIKey: FieldHook;
4
+ //# sourceMappingURL=omitEncryptedAPIKey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"omitEncryptedAPIKey.d.ts","sourceRoot":"","sources":["../../../../src/auth/baseFields/apiKey/omitEncryptedAPIKey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAA;AAEhE,mEAAmE;AACnE,eAAO,MAAM,mBAAmB,EAAE,SAEjC,CAAA"}
@@ -0,0 +1,5 @@
1
+ /** Prevents the encrypted key from surviving field-level reads. */ export const omitEncryptedAPIKey = ({ siblingData })=>{
2
+ delete siblingData.apiKey;
3
+ };
4
+
5
+ //# sourceMappingURL=omitEncryptedAPIKey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/auth/baseFields/apiKey/omitEncryptedAPIKey.ts"],"sourcesContent":["import type { FieldHook } from '../../../fields/config/types.js'\n\n/** Prevents the encrypted key from surviving field-level reads. */\nexport const omitEncryptedAPIKey: FieldHook = ({ siblingData }) => {\n delete siblingData.apiKey\n}\n"],"names":["omitEncryptedAPIKey","siblingData","apiKey"],"mappings":"AAEA,iEAAiE,GACjE,OAAO,MAAMA,sBAAiC,CAAC,EAAEC,WAAW,EAAE;IAC5D,OAAOA,YAAYC,MAAM;AAC3B,EAAC"}
@@ -0,0 +1,4 @@
1
+ import type { FieldHook } from '../../../fields/config/types.js';
2
+ /** Maintains the API key authentication index. */
3
+ export declare const setAPIKeyIndex: FieldHook;
4
+ //# sourceMappingURL=setAPIKeyIndex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setAPIKeyIndex.d.ts","sourceRoot":"","sources":["../../../../src/auth/baseFields/apiKey/setAPIKeyIndex.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAA;AAEhE,kDAAkD;AAClD,eAAO,MAAM,cAAc,EAAE,SAyB5B,CAAA"}
@@ -0,0 +1,17 @@
1
+ import crypto from 'crypto';
2
+ /** Maintains the API key authentication index. */ export const setAPIKeyIndex = ({ data, originalDoc, req, siblingData })=>{
3
+ if (data && 'apiKey' in data && typeof data.apiKey !== 'undefined' && !(typeof data.apiKey === 'string' && data.apiKey)) {
4
+ return null;
5
+ }
6
+ // Checking `enableAPIKey` here is for backward compatibility only and will be removed in v4.
7
+ const isDisablingAPIKey = data?.enableAPIKey === false && originalDoc?.enableAPIKey !== false;
8
+ if (isDisablingAPIKey && !(typeof data.apiKey === 'string' && data.apiKey)) {
9
+ return null;
10
+ }
11
+ if (data?.apiKey) {
12
+ return crypto.createHmac('sha256', req.payload.secret).update(data.apiKey).digest('hex');
13
+ }
14
+ delete siblingData.apiKeyIndex;
15
+ };
16
+
17
+ //# sourceMappingURL=setAPIKeyIndex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/auth/baseFields/apiKey/setAPIKeyIndex.ts"],"sourcesContent":["import crypto from 'crypto'\n\nimport type { FieldHook } from '../../../fields/config/types.js'\n\n/** Maintains the API key authentication index. */\nexport const setAPIKeyIndex: FieldHook = ({ data, originalDoc, req, siblingData }) => {\n if (\n data &&\n 'apiKey' in data &&\n typeof data.apiKey !== 'undefined' &&\n !(typeof data.apiKey === 'string' && data.apiKey)\n ) {\n return null\n }\n\n // Checking `enableAPIKey` here is for backward compatibility only and will be removed in v4.\n const isDisablingAPIKey = data?.enableAPIKey === false && originalDoc?.enableAPIKey !== false\n\n if (isDisablingAPIKey && !(typeof data.apiKey === 'string' && data.apiKey)) {\n return null\n }\n\n if (data?.apiKey) {\n return crypto\n .createHmac('sha256', req.payload.secret)\n .update(data.apiKey as string)\n .digest('hex')\n }\n\n delete siblingData.apiKeyIndex\n}\n"],"names":["crypto","setAPIKeyIndex","data","originalDoc","req","siblingData","apiKey","isDisablingAPIKey","enableAPIKey","createHmac","payload","secret","update","digest","apiKeyIndex"],"mappings":"AAAA,OAAOA,YAAY,SAAQ;AAI3B,gDAAgD,GAChD,OAAO,MAAMC,iBAA4B,CAAC,EAAEC,IAAI,EAAEC,WAAW,EAAEC,GAAG,EAAEC,WAAW,EAAE;IAC/E,IACEH,QACA,YAAYA,QACZ,OAAOA,KAAKI,MAAM,KAAK,eACvB,CAAE,CAAA,OAAOJ,KAAKI,MAAM,KAAK,YAAYJ,KAAKI,MAAM,AAAD,GAC/C;QACA,OAAO;IACT;IAEA,6FAA6F;IAC7F,MAAMC,oBAAoBL,MAAMM,iBAAiB,SAASL,aAAaK,iBAAiB;IAExF,IAAID,qBAAqB,CAAE,CAAA,OAAOL,KAAKI,MAAM,KAAK,YAAYJ,KAAKI,MAAM,AAAD,GAAI;QAC1E,OAAO;IACT;IAEA,IAAIJ,MAAMI,QAAQ;QAChB,OAAON,OACJS,UAAU,CAAC,UAAUL,IAAIM,OAAO,CAACC,MAAM,EACvCC,MAAM,CAACV,KAAKI,MAAM,EAClBO,MAAM,CAAC;IACZ;IAEA,OAAOR,YAAYS,WAAW;AAChC,EAAC"}