@payloadcms/next 3.15.2-canary.64ffcd8 → 3.15.2-canary.8d5d2d1

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 (266) hide show
  1. package/dist/exports/utilities.d.ts +65 -5
  2. package/dist/exports/utilities.d.ts.map +1 -1
  3. package/dist/exports/utilities.js +49 -5
  4. package/dist/exports/utilities.js.map +1 -1
  5. package/dist/layouts/Root/index.d.ts.map +1 -1
  6. package/dist/layouts/Root/index.js +1 -2
  7. package/dist/layouts/Root/index.js.map +1 -1
  8. package/dist/routes/graphql/handler.d.ts.map +1 -1
  9. package/dist/routes/graphql/handler.js +1 -6
  10. package/dist/routes/graphql/handler.js.map +1 -1
  11. package/dist/routes/graphql/playground.d.ts +1 -1
  12. package/dist/routes/graphql/playground.d.ts.map +1 -1
  13. package/dist/routes/graphql/playground.js +1 -1
  14. package/dist/routes/graphql/playground.js.map +1 -1
  15. package/dist/routes/rest/index.d.ts +6 -26
  16. package/dist/routes/rest/index.d.ts.map +1 -1
  17. package/dist/routes/rest/index.js +25 -820
  18. package/dist/routes/rest/index.js.map +1 -1
  19. package/dist/routes/rest/og/index.d.ts +2 -8
  20. package/dist/routes/rest/og/index.d.ts.map +1 -1
  21. package/dist/routes/rest/og/index.js +3 -6
  22. package/dist/routes/rest/og/index.js.map +1 -1
  23. package/dist/templates/Default/index.d.ts +0 -4
  24. package/dist/templates/Default/index.d.ts.map +1 -1
  25. package/dist/templates/Default/index.js +1 -9
  26. package/dist/templates/Default/index.js.map +1 -1
  27. package/dist/utilities/getNextRequestI18n.d.ts +1 -1
  28. package/dist/utilities/getNextRequestI18n.d.ts.map +1 -1
  29. package/dist/utilities/getNextRequestI18n.js +1 -1
  30. package/dist/utilities/getNextRequestI18n.js.map +1 -1
  31. package/dist/utilities/getPayloadHMR.d.ts +8 -0
  32. package/dist/utilities/getPayloadHMR.d.ts.map +1 -1
  33. package/dist/utilities/getPayloadHMR.js +8 -0
  34. package/dist/utilities/getPayloadHMR.js.map +1 -1
  35. package/dist/utilities/initReq.d.ts.map +1 -1
  36. package/dist/utilities/initReq.js +1 -2
  37. package/dist/utilities/initReq.js.map +1 -1
  38. package/dist/views/List/handleServerFunction.d.ts +1 -2
  39. package/dist/views/List/handleServerFunction.d.ts.map +1 -1
  40. package/dist/views/List/handleServerFunction.js.map +1 -1
  41. package/dist/views/List/index.d.ts.map +1 -1
  42. package/dist/views/List/index.js.map +1 -1
  43. package/dist/views/Root/getViewFromConfig.d.ts +0 -1
  44. package/dist/views/Root/getViewFromConfig.d.ts.map +1 -1
  45. package/dist/views/Root/getViewFromConfig.js +0 -2
  46. package/dist/views/Root/getViewFromConfig.js.map +1 -1
  47. package/dist/views/Root/index.d.ts.map +1 -1
  48. package/dist/views/Root/index.js +0 -5
  49. package/dist/views/Root/index.js.map +1 -1
  50. package/package.json +6 -6
  51. package/dist/fetchAPI-multipart/fileFactory.d.ts +0 -16
  52. package/dist/fetchAPI-multipart/fileFactory.d.ts.map +0 -1
  53. package/dist/fetchAPI-multipart/fileFactory.js +0 -44
  54. package/dist/fetchAPI-multipart/fileFactory.js.map +0 -1
  55. package/dist/fetchAPI-multipart/handlers.d.ts +0 -14
  56. package/dist/fetchAPI-multipart/handlers.d.ts.map +0 -1
  57. package/dist/fetchAPI-multipart/handlers.js +0 -87
  58. package/dist/fetchAPI-multipart/handlers.js.map +0 -1
  59. package/dist/fetchAPI-multipart/index.d.ts +0 -32
  60. package/dist/fetchAPI-multipart/index.d.ts.map +0 -1
  61. package/dist/fetchAPI-multipart/index.js +0 -43
  62. package/dist/fetchAPI-multipart/index.js.map +0 -1
  63. package/dist/fetchAPI-multipart/isEligibleRequest.d.ts +0 -2
  64. package/dist/fetchAPI-multipart/isEligibleRequest.d.ts.map +0 -1
  65. package/dist/fetchAPI-multipart/isEligibleRequest.js +0 -18
  66. package/dist/fetchAPI-multipart/isEligibleRequest.js.map +0 -1
  67. package/dist/fetchAPI-multipart/processMultipart.d.ts +0 -9
  68. package/dist/fetchAPI-multipart/processMultipart.d.ts.map +0 -1
  69. package/dist/fetchAPI-multipart/processMultipart.js +0 -178
  70. package/dist/fetchAPI-multipart/processMultipart.js.map +0 -1
  71. package/dist/fetchAPI-multipart/processNested.d.ts +0 -2
  72. package/dist/fetchAPI-multipart/processNested.d.ts.map +0 -1
  73. package/dist/fetchAPI-multipart/processNested.js +0 -31
  74. package/dist/fetchAPI-multipart/processNested.js.map +0 -1
  75. package/dist/fetchAPI-multipart/uploadTimer.d.ts +0 -7
  76. package/dist/fetchAPI-multipart/uploadTimer.d.ts.map +0 -1
  77. package/dist/fetchAPI-multipart/uploadTimer.js +0 -20
  78. package/dist/fetchAPI-multipart/uploadTimer.js.map +0 -1
  79. package/dist/fetchAPI-multipart/utilities.d.ts +0 -65
  80. package/dist/fetchAPI-multipart/utilities.d.ts.map +0 -1
  81. package/dist/fetchAPI-multipart/utilities.js +0 -227
  82. package/dist/fetchAPI-multipart/utilities.js.map +0 -1
  83. package/dist/fetchAPI-stream-file/index.d.ts +0 -5
  84. package/dist/fetchAPI-stream-file/index.d.ts.map +0 -1
  85. package/dist/fetchAPI-stream-file/index.js +0 -27
  86. package/dist/fetchAPI-stream-file/index.js.map +0 -1
  87. package/dist/routes/rest/auth/access.d.ts +0 -3
  88. package/dist/routes/rest/auth/access.d.ts.map +0 -1
  89. package/dist/routes/rest/auth/access.js +0 -28
  90. package/dist/routes/rest/auth/access.js.map +0 -1
  91. package/dist/routes/rest/auth/forgotPassword.d.ts +0 -3
  92. package/dist/routes/rest/auth/forgotPassword.d.ts.map +0 -1
  93. package/dist/routes/rest/auth/forgotPassword.js +0 -34
  94. package/dist/routes/rest/auth/forgotPassword.js.map +0 -1
  95. package/dist/routes/rest/auth/init.d.ts +0 -3
  96. package/dist/routes/rest/auth/init.d.ts.map +0 -1
  97. package/dist/routes/rest/auth/init.js +0 -20
  98. package/dist/routes/rest/auth/init.js.map +0 -1
  99. package/dist/routes/rest/auth/login.d.ts +0 -3
  100. package/dist/routes/rest/auth/login.d.ts.map +0 -1
  101. package/dist/routes/rest/auth/login.js +0 -49
  102. package/dist/routes/rest/auth/login.js.map +0 -1
  103. package/dist/routes/rest/auth/logout.d.ts +0 -3
  104. package/dist/routes/rest/auth/logout.d.ts.map +0 -1
  105. package/dist/routes/rest/auth/logout.js +0 -40
  106. package/dist/routes/rest/auth/logout.js.map +0 -1
  107. package/dist/routes/rest/auth/me.d.ts +0 -3
  108. package/dist/routes/rest/auth/me.d.ts.map +0 -1
  109. package/dist/routes/rest/auth/me.js +0 -28
  110. package/dist/routes/rest/auth/me.js.map +0 -1
  111. package/dist/routes/rest/auth/refresh.d.ts +0 -3
  112. package/dist/routes/rest/auth/refresh.d.ts.map +0 -1
  113. package/dist/routes/rest/auth/refresh.js +0 -38
  114. package/dist/routes/rest/auth/refresh.js.map +0 -1
  115. package/dist/routes/rest/auth/registerFirstUser.d.ts +0 -3
  116. package/dist/routes/rest/auth/registerFirstUser.d.ts.map +0 -1
  117. package/dist/routes/rest/auth/registerFirstUser.js +0 -48
  118. package/dist/routes/rest/auth/registerFirstUser.js.map +0 -1
  119. package/dist/routes/rest/auth/resetPassword.d.ts +0 -3
  120. package/dist/routes/rest/auth/resetPassword.d.ts.map +0 -1
  121. package/dist/routes/rest/auth/resetPassword.js +0 -43
  122. package/dist/routes/rest/auth/resetPassword.js.map +0 -1
  123. package/dist/routes/rest/auth/unlock.d.ts +0 -3
  124. package/dist/routes/rest/auth/unlock.d.ts.map +0 -1
  125. package/dist/routes/rest/auth/unlock.js +0 -32
  126. package/dist/routes/rest/auth/unlock.js.map +0 -1
  127. package/dist/routes/rest/auth/verifyEmail.d.ts +0 -3
  128. package/dist/routes/rest/auth/verifyEmail.d.ts.map +0 -1
  129. package/dist/routes/rest/auth/verifyEmail.js +0 -27
  130. package/dist/routes/rest/auth/verifyEmail.js.map +0 -1
  131. package/dist/routes/rest/checkEndpoints.d.ts +0 -5
  132. package/dist/routes/rest/checkEndpoints.d.ts.map +0 -1
  133. package/dist/routes/rest/checkEndpoints.js +0 -14
  134. package/dist/routes/rest/checkEndpoints.js.map +0 -1
  135. package/dist/routes/rest/collections/count.d.ts +0 -3
  136. package/dist/routes/rest/collections/count.d.ts.map +0 -1
  137. package/dist/routes/rest/collections/count.js +0 -19
  138. package/dist/routes/rest/collections/count.js.map +0 -1
  139. package/dist/routes/rest/collections/create.d.ts +0 -3
  140. package/dist/routes/rest/collections/create.d.ts.map +0 -1
  141. package/dist/routes/rest/collections/create.js +0 -39
  142. package/dist/routes/rest/collections/create.js.map +0 -1
  143. package/dist/routes/rest/collections/delete.d.ts +0 -3
  144. package/dist/routes/rest/collections/delete.d.ts.map +0 -1
  145. package/dist/routes/rest/collections/delete.js +0 -57
  146. package/dist/routes/rest/collections/delete.js.map +0 -1
  147. package/dist/routes/rest/collections/deleteByID.d.ts +0 -3
  148. package/dist/routes/rest/collections/deleteByID.d.ts.map +0 -1
  149. package/dist/routes/rest/collections/deleteByID.js +0 -50
  150. package/dist/routes/rest/collections/deleteByID.js.map +0 -1
  151. package/dist/routes/rest/collections/docAccess.d.ts +0 -3
  152. package/dist/routes/rest/collections/docAccess.d.ts.map +0 -1
  153. package/dist/routes/rest/collections/docAccess.js +0 -22
  154. package/dist/routes/rest/collections/docAccess.js.map +0 -1
  155. package/dist/routes/rest/collections/duplicate.d.ts +0 -3
  156. package/dist/routes/rest/collections/duplicate.d.ts.map +0 -1
  157. package/dist/routes/rest/collections/duplicate.js +0 -47
  158. package/dist/routes/rest/collections/duplicate.js.map +0 -1
  159. package/dist/routes/rest/collections/find.d.ts +0 -3
  160. package/dist/routes/rest/collections/find.d.ts.map +0 -1
  161. package/dist/routes/rest/collections/find.js +0 -43
  162. package/dist/routes/rest/collections/find.js.map +0 -1
  163. package/dist/routes/rest/collections/findByID.d.ts +0 -3
  164. package/dist/routes/rest/collections/findByID.d.ts.map +0 -1
  165. package/dist/routes/rest/collections/findByID.js +0 -38
  166. package/dist/routes/rest/collections/findByID.js.map +0 -1
  167. package/dist/routes/rest/collections/findVersionByID.d.ts +0 -3
  168. package/dist/routes/rest/collections/findVersionByID.d.ts.map +0 -1
  169. package/dist/routes/rest/collections/findVersionByID.js +0 -36
  170. package/dist/routes/rest/collections/findVersionByID.js.map +0 -1
  171. package/dist/routes/rest/collections/findVersions.d.ts +0 -3
  172. package/dist/routes/rest/collections/findVersions.d.ts.map +0 -1
  173. package/dist/routes/rest/collections/findVersions.js +0 -39
  174. package/dist/routes/rest/collections/findVersions.js.map +0 -1
  175. package/dist/routes/rest/collections/preview.d.ts +0 -3
  176. package/dist/routes/rest/collections/preview.d.ts.map +0 -1
  177. package/dist/routes/rest/collections/preview.js +0 -49
  178. package/dist/routes/rest/collections/preview.js.map +0 -1
  179. package/dist/routes/rest/collections/restoreVersion.d.ts +0 -3
  180. package/dist/routes/rest/collections/restoreVersion.d.ts.map +0 -1
  181. package/dist/routes/rest/collections/restoreVersion.js +0 -40
  182. package/dist/routes/rest/collections/restoreVersion.js.map +0 -1
  183. package/dist/routes/rest/collections/update.d.ts +0 -3
  184. package/dist/routes/rest/collections/update.d.ts.map +0 -1
  185. package/dist/routes/rest/collections/update.js +0 -62
  186. package/dist/routes/rest/collections/update.js.map +0 -1
  187. package/dist/routes/rest/collections/updateByID.d.ts +0 -3
  188. package/dist/routes/rest/collections/updateByID.d.ts.map +0 -1
  189. package/dist/routes/rest/collections/updateByID.js +0 -55
  190. package/dist/routes/rest/collections/updateByID.js.map +0 -1
  191. package/dist/routes/rest/files/checkFileAccess.d.ts +0 -7
  192. package/dist/routes/rest/files/checkFileAccess.d.ts.map +0 -1
  193. package/dist/routes/rest/files/checkFileAccess.js +0 -57
  194. package/dist/routes/rest/files/checkFileAccess.js.map +0 -1
  195. package/dist/routes/rest/files/getFile.d.ts +0 -9
  196. package/dist/routes/rest/files/getFile.d.ts.map +0 -1
  197. package/dist/routes/rest/files/getFile.js +0 -70
  198. package/dist/routes/rest/files/getFile.js.map +0 -1
  199. package/dist/routes/rest/files/getFileTypeFallback.d.ts +0 -7
  200. package/dist/routes/rest/files/getFileTypeFallback.d.ts.map +0 -1
  201. package/dist/routes/rest/files/getFileTypeFallback.js +0 -20
  202. package/dist/routes/rest/files/getFileTypeFallback.js.map +0 -1
  203. package/dist/routes/rest/globals/docAccess.d.ts +0 -3
  204. package/dist/routes/rest/globals/docAccess.d.ts.map +0 -1
  205. package/dist/routes/rest/globals/docAccess.js +0 -20
  206. package/dist/routes/rest/globals/docAccess.js.map +0 -1
  207. package/dist/routes/rest/globals/findOne.d.ts +0 -3
  208. package/dist/routes/rest/globals/findOne.d.ts.map +0 -1
  209. package/dist/routes/rest/globals/findOne.js +0 -30
  210. package/dist/routes/rest/globals/findOne.js.map +0 -1
  211. package/dist/routes/rest/globals/findVersionByID.d.ts +0 -3
  212. package/dist/routes/rest/globals/findVersionByID.d.ts.map +0 -1
  213. package/dist/routes/rest/globals/findVersionByID.js +0 -30
  214. package/dist/routes/rest/globals/findVersionByID.js.map +0 -1
  215. package/dist/routes/rest/globals/findVersions.d.ts +0 -3
  216. package/dist/routes/rest/globals/findVersions.d.ts.map +0 -1
  217. package/dist/routes/rest/globals/findVersions.js +0 -39
  218. package/dist/routes/rest/globals/findVersions.js.map +0 -1
  219. package/dist/routes/rest/globals/preview.d.ts +0 -3
  220. package/dist/routes/rest/globals/preview.d.ts.map +0 -1
  221. package/dist/routes/rest/globals/preview.js +0 -47
  222. package/dist/routes/rest/globals/preview.js.map +0 -1
  223. package/dist/routes/rest/globals/restoreVersion.d.ts +0 -3
  224. package/dist/routes/rest/globals/restoreVersion.d.ts.map +0 -1
  225. package/dist/routes/rest/globals/restoreVersion.js +0 -34
  226. package/dist/routes/rest/globals/restoreVersion.js.map +0 -1
  227. package/dist/routes/rest/globals/update.d.ts +0 -3
  228. package/dist/routes/rest/globals/update.d.ts.map +0 -1
  229. package/dist/routes/rest/globals/update.js +0 -46
  230. package/dist/routes/rest/globals/update.js.map +0 -1
  231. package/dist/routes/rest/routeError.d.ts +0 -9
  232. package/dist/routes/rest/routeError.d.ts.map +0 -1
  233. package/dist/routes/rest/routeError.js +0 -83
  234. package/dist/routes/rest/routeError.js.map +0 -1
  235. package/dist/routes/rest/types.d.ts +0 -23
  236. package/dist/routes/rest/types.d.ts.map +0 -1
  237. package/dist/routes/rest/types.js +0 -2
  238. package/dist/routes/rest/types.js.map +0 -1
  239. package/dist/routes/rest/utilities/sanitizeCollectionID.d.ts +0 -9
  240. package/dist/routes/rest/utilities/sanitizeCollectionID.d.ts.map +0 -1
  241. package/dist/routes/rest/utilities/sanitizeCollectionID.js +0 -20
  242. package/dist/routes/rest/utilities/sanitizeCollectionID.js.map +0 -1
  243. package/dist/utilities/addDataAndFileToRequest.d.ts +0 -8
  244. package/dist/utilities/addDataAndFileToRequest.d.ts.map +0 -1
  245. package/dist/utilities/addDataAndFileToRequest.js +0 -47
  246. package/dist/utilities/addDataAndFileToRequest.js.map +0 -1
  247. package/dist/utilities/addLocalesToRequest.d.ts +0 -17
  248. package/dist/utilities/addLocalesToRequest.d.ts.map +0 -1
  249. package/dist/utilities/addLocalesToRequest.js +0 -65
  250. package/dist/utilities/addLocalesToRequest.js.map +0 -1
  251. package/dist/utilities/createPayloadRequest.d.ts +0 -11
  252. package/dist/utilities/createPayloadRequest.d.ts.map +0 -1
  253. package/dist/utilities/createPayloadRequest.js +0 -103
  254. package/dist/utilities/createPayloadRequest.js.map +0 -1
  255. package/dist/utilities/getRequestLanguage.d.ts +0 -12
  256. package/dist/utilities/getRequestLanguage.d.ts.map +0 -1
  257. package/dist/utilities/getRequestLanguage.js +0 -19
  258. package/dist/utilities/getRequestLanguage.js.map +0 -1
  259. package/dist/utilities/headersWithCors.d.ts +0 -8
  260. package/dist/utilities/headersWithCors.d.ts.map +0 -1
  261. package/dist/utilities/headersWithCors.js +0 -24
  262. package/dist/utilities/headersWithCors.js.map +0 -1
  263. package/dist/utilities/mergeHeaders.d.ts +0 -2
  264. package/dist/utilities/mergeHeaders.d.ts.map +0 -1
  265. package/dist/utilities/mergeHeaders.js +0 -10
  266. package/dist/utilities/mergeHeaders.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"findVersions.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/globals/findVersions.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAIrD,eAAO,MAAM,YAAY,EAAE,kBAgC1B,CAAA"}
@@ -1,39 +0,0 @@
1
- import httpStatus from 'http-status';
2
- import { findVersionsOperationGlobal, sanitizePopulateParam, sanitizeSelectParam } from 'payload';
3
- import { isNumber } from 'payload/shared';
4
- import { headersWithCors } from '../../../utilities/headersWithCors.js';
5
- export const findVersions = async ({
6
- globalConfig,
7
- req
8
- }) => {
9
- const {
10
- depth,
11
- limit,
12
- page,
13
- pagination,
14
- populate,
15
- select,
16
- sort,
17
- where
18
- } = req.query;
19
- const result = await findVersionsOperationGlobal({
20
- depth: isNumber(depth) ? Number(depth) : undefined,
21
- globalConfig,
22
- limit: isNumber(limit) ? Number(limit) : undefined,
23
- page: isNumber(page) ? Number(page) : undefined,
24
- pagination: pagination === 'false' ? false : undefined,
25
- populate: sanitizePopulateParam(populate),
26
- req,
27
- select: sanitizeSelectParam(select),
28
- sort: typeof sort === 'string' ? sort.split(',') : undefined,
29
- where
30
- });
31
- return Response.json(result, {
32
- headers: headersWithCors({
33
- headers: new Headers(),
34
- req
35
- }),
36
- status: httpStatus.OK
37
- });
38
- };
39
- //# sourceMappingURL=findVersions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"findVersions.js","names":["httpStatus","findVersionsOperationGlobal","sanitizePopulateParam","sanitizeSelectParam","isNumber","headersWithCors","findVersions","globalConfig","req","depth","limit","page","pagination","populate","select","sort","where","query","result","Number","undefined","split","Response","json","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/globals/findVersions.ts"],"sourcesContent":["import type { Where } from 'payload'\n\nimport httpStatus from 'http-status'\nimport { findVersionsOperationGlobal, sanitizePopulateParam, sanitizeSelectParam } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { GlobalRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const findVersions: GlobalRouteHandler = async ({ globalConfig, req }) => {\n const { depth, limit, page, pagination, populate, select, sort, where } = req.query as {\n depth?: string\n limit?: string\n page?: string\n pagination?: string\n populate?: Record<string, unknown>\n select?: Record<string, unknown>\n sort?: string\n where?: Where\n }\n\n const result = await findVersionsOperationGlobal({\n depth: isNumber(depth) ? Number(depth) : undefined,\n globalConfig,\n limit: isNumber(limit) ? Number(limit) : undefined,\n page: isNumber(page) ? Number(page) : undefined,\n pagination: pagination === 'false' ? false : undefined,\n populate: sanitizePopulateParam(populate),\n req,\n select: sanitizeSelectParam(select),\n sort: typeof sort === 'string' ? sort.split(',') : undefined,\n where,\n })\n\n return Response.json(result, {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n })\n}\n"],"mappings":"AAEA,OAAOA,UAAA,MAAgB;AACvB,SAASC,2BAA2B,EAAEC,qBAAqB,EAAEC,mBAAmB,QAAQ;AACxF,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAEhC,OAAO,MAAMC,YAAA,GAAmC,MAAAA,CAAO;EAAEC,YAAY;EAAEC;AAAG,CAAE;EAC1E,MAAM;IAAEC,KAAK;IAAEC,KAAK;IAAEC,IAAI;IAAEC,UAAU;IAAEC,QAAQ;IAAEC,MAAM;IAAEC,IAAI;IAAEC;EAAK,CAAE,GAAGR,GAAA,CAAIS,KAAK;EAWnF,MAAMC,MAAA,GAAS,MAAMjB,2BAAA,CAA4B;IAC/CQ,KAAA,EAAOL,QAAA,CAASK,KAAA,IAASU,MAAA,CAAOV,KAAA,IAASW,SAAA;IACzCb,YAAA;IACAG,KAAA,EAAON,QAAA,CAASM,KAAA,IAASS,MAAA,CAAOT,KAAA,IAASU,SAAA;IACzCT,IAAA,EAAMP,QAAA,CAASO,IAAA,IAAQQ,MAAA,CAAOR,IAAA,IAAQS,SAAA;IACtCR,UAAA,EAAYA,UAAA,KAAe,UAAU,QAAQQ,SAAA;IAC7CP,QAAA,EAAUX,qBAAA,CAAsBW,QAAA;IAChCL,GAAA;IACAM,MAAA,EAAQX,mBAAA,CAAoBW,MAAA;IAC5BC,IAAA,EAAM,OAAOA,IAAA,KAAS,WAAWA,IAAA,CAAKM,KAAK,CAAC,OAAOD,SAAA;IACnDJ;EACF;EAEA,OAAOM,QAAA,CAASC,IAAI,CAACL,MAAA,EAAQ;IAC3BM,OAAA,EAASnB,eAAA,CAAgB;MACvBmB,OAAA,EAAS,IAAIC,OAAA;MACbjB;IACF;IACAkB,MAAA,EAAQ1B,UAAA,CAAW2B;EACrB;AACF","ignoreList":[]}
@@ -1,3 +0,0 @@
1
- import type { GlobalRouteHandler } from '../types.js';
2
- export declare const preview: GlobalRouteHandler;
3
- //# sourceMappingURL=preview.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/globals/preview.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAKrD,eAAO,MAAM,OAAO,EAAE,kBA2CrB,CAAA"}
@@ -1,47 +0,0 @@
1
- import httpStatus from 'http-status';
2
- import { extractJWT, findOneOperation } from 'payload';
3
- import { isNumber } from 'payload/shared';
4
- import { headersWithCors } from '../../../utilities/headersWithCors.js';
5
- import { routeError } from '../routeError.js';
6
- export const preview = async ({
7
- globalConfig,
8
- req
9
- }) => {
10
- const {
11
- searchParams
12
- } = req;
13
- const depth = searchParams.get('depth');
14
- const doc = await findOneOperation({
15
- slug: globalConfig.slug,
16
- depth: isNumber(depth) ? Number(depth) : undefined,
17
- draft: searchParams.get('draft') === 'true',
18
- globalConfig,
19
- req
20
- });
21
- let previewURL;
22
- const generatePreviewURL = req.payload.config.globals.find(config => config.slug === globalConfig.slug)?.admin?.preview;
23
- const token = extractJWT(req);
24
- if (typeof generatePreviewURL === 'function') {
25
- try {
26
- previewURL = await generatePreviewURL(doc, {
27
- locale: req.locale,
28
- req,
29
- token
30
- });
31
- } catch (err) {
32
- return routeError({
33
- config: req.payload.config,
34
- err,
35
- req
36
- });
37
- }
38
- }
39
- return Response.json(previewURL, {
40
- headers: headersWithCors({
41
- headers: new Headers(),
42
- req
43
- }),
44
- status: httpStatus.OK
45
- });
46
- };
47
- //# sourceMappingURL=preview.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"preview.js","names":["httpStatus","extractJWT","findOneOperation","isNumber","headersWithCors","routeError","preview","globalConfig","req","searchParams","depth","get","doc","slug","Number","undefined","draft","previewURL","generatePreviewURL","payload","config","globals","find","admin","token","locale","err","Response","json","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/globals/preview.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { extractJWT, findOneOperation } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { GlobalRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { routeError } from '../routeError.js'\n\nexport const preview: GlobalRouteHandler = async ({ globalConfig, req }) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n\n const doc = await findOneOperation({\n slug: globalConfig.slug,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft: searchParams.get('draft') === 'true',\n globalConfig,\n req,\n })\n\n let previewURL: string\n\n const generatePreviewURL = req.payload.config.globals.find(\n (config) => config.slug === globalConfig.slug,\n )?.admin?.preview\n\n const token = extractJWT(req)\n\n if (typeof generatePreviewURL === 'function') {\n try {\n previewURL = await generatePreviewURL(doc, {\n locale: req.locale,\n req,\n token,\n })\n } catch (err) {\n return routeError({\n config: req.payload.config,\n err,\n req,\n })\n }\n }\n\n return Response.json(previewURL, {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n })\n}\n"],"mappings":"AAAA,OAAOA,UAAA,MAAgB;AACvB,SAASC,UAAU,EAAEC,gBAAgB,QAAQ;AAC7C,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,UAAU,QAAQ;AAE3B,OAAO,MAAMC,OAAA,GAA8B,MAAAA,CAAO;EAAEC,YAAY;EAAEC;AAAG,CAAE;EACrE,MAAM;IAAEC;EAAY,CAAE,GAAGD,GAAA;EACzB,MAAME,KAAA,GAAQD,YAAA,CAAaE,GAAG,CAAC;EAE/B,MAAMC,GAAA,GAAM,MAAMV,gBAAA,CAAiB;IACjCW,IAAA,EAAMN,YAAA,CAAaM,IAAI;IACvBH,KAAA,EAAOP,QAAA,CAASO,KAAA,IAASI,MAAA,CAAOJ,KAAA,IAASK,SAAA;IACzCC,KAAA,EAAOP,YAAA,CAAaE,GAAG,CAAC,aAAa;IACrCJ,YAAA;IACAC;EACF;EAEA,IAAIS,UAAA;EAEJ,MAAMC,kBAAA,GAAqBV,GAAA,CAAIW,OAAO,CAACC,MAAM,CAACC,OAAO,CAACC,IAAI,CACvDF,MAAA,IAAWA,MAAA,CAAOP,IAAI,KAAKN,YAAA,CAAaM,IAAI,GAC5CU,KAAA,EAAOjB,OAAA;EAEV,MAAMkB,KAAA,GAAQvB,UAAA,CAAWO,GAAA;EAEzB,IAAI,OAAOU,kBAAA,KAAuB,YAAY;IAC5C,IAAI;MACFD,UAAA,GAAa,MAAMC,kBAAA,CAAmBN,GAAA,EAAK;QACzCa,MAAA,EAAQjB,GAAA,CAAIiB,MAAM;QAClBjB,GAAA;QACAgB;MACF;IACF,EAAE,OAAOE,GAAA,EAAK;MACZ,OAAOrB,UAAA,CAAW;QAChBe,MAAA,EAAQZ,GAAA,CAAIW,OAAO,CAACC,MAAM;QAC1BM,GAAA;QACAlB;MACF;IACF;EACF;EAEA,OAAOmB,QAAA,CAASC,IAAI,CAACX,UAAA,EAAY;IAC/BY,OAAA,EAASzB,eAAA,CAAgB;MACvByB,OAAA,EAAS,IAAIC,OAAA;MACbtB;IACF;IACAuB,MAAA,EAAQ/B,UAAA,CAAWgC;EACrB;AACF","ignoreList":[]}
@@ -1,3 +0,0 @@
1
- import type { GlobalRouteHandlerWithID } from '../types.js';
2
- export declare const restoreVersion: GlobalRouteHandlerWithID;
3
- //# sourceMappingURL=restoreVersion.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"restoreVersion.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/globals/restoreVersion.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAI3D,eAAO,MAAM,cAAc,EAAE,wBA2B5B,CAAA"}
@@ -1,34 +0,0 @@
1
- import httpStatus from 'http-status';
2
- import { restoreVersionOperationGlobal, sanitizePopulateParam } from 'payload';
3
- import { isNumber } from 'payload/shared';
4
- import { headersWithCors } from '../../../utilities/headersWithCors.js';
5
- export const restoreVersion = async ({
6
- id,
7
- globalConfig,
8
- req
9
- }) => {
10
- const {
11
- searchParams
12
- } = req;
13
- const depth = searchParams.get('depth');
14
- const draft = searchParams.get('draft');
15
- const doc = await restoreVersionOperationGlobal({
16
- id,
17
- depth: isNumber(depth) ? Number(depth) : undefined,
18
- draft: draft === 'true' ? true : undefined,
19
- globalConfig,
20
- populate: sanitizePopulateParam(req.query.populate),
21
- req
22
- });
23
- return Response.json({
24
- doc,
25
- message: req.t('version:restoredSuccessfully')
26
- }, {
27
- headers: headersWithCors({
28
- headers: new Headers(),
29
- req
30
- }),
31
- status: httpStatus.OK
32
- });
33
- };
34
- //# sourceMappingURL=restoreVersion.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"restoreVersion.js","names":["httpStatus","restoreVersionOperationGlobal","sanitizePopulateParam","isNumber","headersWithCors","restoreVersion","id","globalConfig","req","searchParams","depth","get","draft","doc","Number","undefined","populate","query","Response","json","message","t","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/globals/restoreVersion.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { restoreVersionOperationGlobal, sanitizePopulateParam } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { GlobalRouteHandlerWithID } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const restoreVersion: GlobalRouteHandlerWithID = async ({ id, globalConfig, req }) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n const draft = searchParams.get('draft')\n\n const doc = await restoreVersionOperationGlobal({\n id,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft: draft === 'true' ? true : undefined,\n globalConfig,\n populate: sanitizePopulateParam(req.query.populate),\n req,\n })\n\n return Response.json(\n {\n doc,\n message: req.t('version:restoredSuccessfully'),\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"mappings":"AAAA,OAAOA,UAAA,MAAgB;AACvB,SAASC,6BAA6B,EAAEC,qBAAqB,QAAQ;AACrE,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAEhC,OAAO,MAAMC,cAAA,GAA2C,MAAAA,CAAO;EAAEC,EAAE;EAAEC,YAAY;EAAEC;AAAG,CAAE;EACtF,MAAM;IAAEC;EAAY,CAAE,GAAGD,GAAA;EACzB,MAAME,KAAA,GAAQD,YAAA,CAAaE,GAAG,CAAC;EAC/B,MAAMC,KAAA,GAAQH,YAAA,CAAaE,GAAG,CAAC;EAE/B,MAAME,GAAA,GAAM,MAAMZ,6BAAA,CAA8B;IAC9CK,EAAA;IACAI,KAAA,EAAOP,QAAA,CAASO,KAAA,IAASI,MAAA,CAAOJ,KAAA,IAASK,SAAA;IACzCH,KAAA,EAAOA,KAAA,KAAU,SAAS,OAAOG,SAAA;IACjCR,YAAA;IACAS,QAAA,EAAUd,qBAAA,CAAsBM,GAAA,CAAIS,KAAK,CAACD,QAAQ;IAClDR;EACF;EAEA,OAAOU,QAAA,CAASC,IAAI,CAClB;IACEN,GAAA;IACAO,OAAA,EAASZ,GAAA,CAAIa,CAAC,CAAC;EACjB,GACA;IACEC,OAAA,EAASlB,eAAA,CAAgB;MACvBkB,OAAA,EAAS,IAAIC,OAAA;MACbf;IACF;IACAgB,MAAA,EAAQxB,UAAA,CAAWyB;EACrB;AAEJ","ignoreList":[]}
@@ -1,3 +0,0 @@
1
- import type { GlobalRouteHandler } from '../types.js';
2
- export declare const update: GlobalRouteHandler;
3
- //# sourceMappingURL=update.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/globals/update.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAIrD,eAAO,MAAM,MAAM,EAAE,kBA0CpB,CAAA"}
@@ -1,46 +0,0 @@
1
- import httpStatus from 'http-status';
2
- import { sanitizePopulateParam, sanitizeSelectParam, updateOperationGlobal } from 'payload';
3
- import { isNumber } from 'payload/shared';
4
- import { headersWithCors } from '../../../utilities/headersWithCors.js';
5
- export const update = async ({
6
- globalConfig,
7
- req
8
- }) => {
9
- const {
10
- searchParams
11
- } = req;
12
- const depth = searchParams.get('depth');
13
- const draft = searchParams.get('draft') === 'true';
14
- const autosave = searchParams.get('autosave') === 'true';
15
- const publishSpecificLocale = req.query.publishSpecificLocale;
16
- const result = await updateOperationGlobal({
17
- slug: globalConfig.slug,
18
- autosave,
19
- data: req.data,
20
- depth: isNumber(depth) ? Number(depth) : undefined,
21
- draft,
22
- globalConfig,
23
- populate: sanitizePopulateParam(req.query.populate),
24
- publishSpecificLocale,
25
- req,
26
- select: sanitizeSelectParam(req.query.select)
27
- });
28
- let message = req.t('general:updatedSuccessfully');
29
- if (draft) {
30
- message = req.t('version:draftSavedSuccessfully');
31
- }
32
- if (autosave) {
33
- message = req.t('version:autosavedSuccessfully');
34
- }
35
- return Response.json({
36
- message,
37
- result
38
- }, {
39
- headers: headersWithCors({
40
- headers: new Headers(),
41
- req
42
- }),
43
- status: httpStatus.OK
44
- });
45
- };
46
- //# sourceMappingURL=update.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"update.js","names":["httpStatus","sanitizePopulateParam","sanitizeSelectParam","updateOperationGlobal","isNumber","headersWithCors","update","globalConfig","req","searchParams","depth","get","draft","autosave","publishSpecificLocale","query","result","slug","data","Number","undefined","populate","select","message","t","Response","json","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/globals/update.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { sanitizePopulateParam, sanitizeSelectParam, updateOperationGlobal } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { GlobalRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const update: GlobalRouteHandler = async ({ globalConfig, req }) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n const draft = searchParams.get('draft') === 'true'\n const autosave = searchParams.get('autosave') === 'true'\n const publishSpecificLocale = req.query.publishSpecificLocale as string | undefined\n\n const result = await updateOperationGlobal({\n slug: globalConfig.slug,\n autosave,\n data: req.data,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft,\n globalConfig,\n populate: sanitizePopulateParam(req.query.populate),\n publishSpecificLocale,\n req,\n select: sanitizeSelectParam(req.query.select),\n })\n\n let message = req.t('general:updatedSuccessfully')\n\n if (draft) {\n message = req.t('version:draftSavedSuccessfully')\n }\n if (autosave) {\n message = req.t('version:autosavedSuccessfully')\n }\n\n return Response.json(\n {\n message,\n result,\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"mappings":"AAAA,OAAOA,UAAA,MAAgB;AACvB,SAASC,qBAAqB,EAAEC,mBAAmB,EAAEC,qBAAqB,QAAQ;AAClF,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAEhC,OAAO,MAAMC,MAAA,GAA6B,MAAAA,CAAO;EAAEC,YAAY;EAAEC;AAAG,CAAE;EACpE,MAAM;IAAEC;EAAY,CAAE,GAAGD,GAAA;EACzB,MAAME,KAAA,GAAQD,YAAA,CAAaE,GAAG,CAAC;EAC/B,MAAMC,KAAA,GAAQH,YAAA,CAAaE,GAAG,CAAC,aAAa;EAC5C,MAAME,QAAA,GAAWJ,YAAA,CAAaE,GAAG,CAAC,gBAAgB;EAClD,MAAMG,qBAAA,GAAwBN,GAAA,CAAIO,KAAK,CAACD,qBAAqB;EAE7D,MAAME,MAAA,GAAS,MAAMb,qBAAA,CAAsB;IACzCc,IAAA,EAAMV,YAAA,CAAaU,IAAI;IACvBJ,QAAA;IACAK,IAAA,EAAMV,GAAA,CAAIU,IAAI;IACdR,KAAA,EAAON,QAAA,CAASM,KAAA,IAASS,MAAA,CAAOT,KAAA,IAASU,SAAA;IACzCR,KAAA;IACAL,YAAA;IACAc,QAAA,EAAUpB,qBAAA,CAAsBO,GAAA,CAAIO,KAAK,CAACM,QAAQ;IAClDP,qBAAA;IACAN,GAAA;IACAc,MAAA,EAAQpB,mBAAA,CAAoBM,GAAA,CAAIO,KAAK,CAACO,MAAM;EAC9C;EAEA,IAAIC,OAAA,GAAUf,GAAA,CAAIgB,CAAC,CAAC;EAEpB,IAAIZ,KAAA,EAAO;IACTW,OAAA,GAAUf,GAAA,CAAIgB,CAAC,CAAC;EAClB;EACA,IAAIX,QAAA,EAAU;IACZU,OAAA,GAAUf,GAAA,CAAIgB,CAAC,CAAC;EAClB;EAEA,OAAOC,QAAA,CAASC,IAAI,CAClB;IACEH,OAAA;IACAP;EACF,GACA;IACEW,OAAA,EAAStB,eAAA,CAAgB;MACvBsB,OAAA,EAAS,IAAIC,OAAA;MACbpB;IACF;IACAqB,MAAA,EAAQ7B,UAAA,CAAW8B;EACrB;AAEJ","ignoreList":[]}
@@ -1,9 +0,0 @@
1
- import type { Collection, PayloadRequest, SanitizedConfig } from 'payload';
2
- import { APIError } from 'payload';
3
- export declare const routeError: ({ collection, config: configArg, err, req: incomingReq, }: {
4
- collection?: Collection;
5
- config: Promise<SanitizedConfig> | SanitizedConfig;
6
- err: APIError;
7
- req: PayloadRequest | Request;
8
- }) => Promise<Response>;
9
- //# sourceMappingURL=routeError.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"routeError.d.ts","sourceRoot":"","sources":["../../../src/routes/rest/routeError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAe,cAAc,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAGvF,OAAO,EAAE,QAAQ,EAAsC,MAAM,SAAS,CAAA;AAKtE,eAAO,MAAM,UAAU,8DAKpB;IACD,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAA;IAClD,GAAG,EAAE,QAAQ,CAAA;IACb,GAAG,EAAE,cAAc,GAAG,OAAO,CAAA;CAC9B,sBAkFA,CAAA"}
@@ -1,83 +0,0 @@
1
- import httpStatus from 'http-status';
2
- import { APIError, formatErrors, getPayload, logError } from 'payload';
3
- import { headersWithCors } from '../../utilities/headersWithCors.js';
4
- import { mergeHeaders } from '../../utilities/mergeHeaders.js';
5
- export const routeError = async ({
6
- collection,
7
- config: configArg,
8
- err,
9
- req: incomingReq
10
- }) => {
11
- let payload = 'payload' in incomingReq && incomingReq?.payload;
12
- if (!payload) {
13
- try {
14
- payload = await getPayload({
15
- config: configArg
16
- });
17
- } catch (e) {
18
- return Response.json({
19
- message: 'There was an error initializing Payload'
20
- }, {
21
- status: httpStatus.INTERNAL_SERVER_ERROR
22
- });
23
- }
24
- }
25
- const req = incomingReq;
26
- req.payload = payload;
27
- const headers = headersWithCors({
28
- headers: new Headers(),
29
- req
30
- });
31
- const {
32
- config
33
- } = payload;
34
- let response = formatErrors(err);
35
- let status = err.status || httpStatus.INTERNAL_SERVER_ERROR;
36
- logError({
37
- err,
38
- payload
39
- });
40
- // Internal server errors can contain anything, including potentially sensitive data.
41
- // Therefore, error details will be hidden from the response unless `config.debug` is `true`
42
- if (!config.debug && status === httpStatus.INTERNAL_SERVER_ERROR) {
43
- response = formatErrors(new APIError('Something went wrong.'));
44
- }
45
- if (config.debug && config.debug === true) {
46
- response.stack = err.stack;
47
- }
48
- if (collection) {
49
- await collection.config.hooks.afterError?.reduce(async (promise, hook) => {
50
- await promise;
51
- const result = await hook({
52
- collection: collection.config,
53
- context: req.context,
54
- error: err,
55
- req,
56
- result: response
57
- });
58
- if (result) {
59
- response = result.response || response;
60
- status = result.status || status;
61
- }
62
- }, Promise.resolve());
63
- }
64
- await config.hooks.afterError?.reduce(async (promise, hook) => {
65
- await promise;
66
- const result = await hook({
67
- collection: collection?.config,
68
- context: req.context,
69
- error: err,
70
- req,
71
- result: response
72
- });
73
- if (result) {
74
- response = result.response || response;
75
- status = result.status || status;
76
- }
77
- }, Promise.resolve());
78
- return Response.json(response, {
79
- headers: req.responseHeaders ? mergeHeaders(req.responseHeaders, headers) : headers,
80
- status
81
- });
82
- };
83
- //# sourceMappingURL=routeError.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"routeError.js","names":["httpStatus","APIError","formatErrors","getPayload","logError","headersWithCors","mergeHeaders","routeError","collection","config","configArg","err","req","incomingReq","payload","e","Response","json","message","status","INTERNAL_SERVER_ERROR","headers","Headers","response","debug","stack","hooks","afterError","reduce","promise","hook","result","context","error","Promise","resolve","responseHeaders"],"sources":["../../../src/routes/rest/routeError.ts"],"sourcesContent":["import type { Collection, ErrorResult, PayloadRequest, SanitizedConfig } from 'payload'\n\nimport httpStatus from 'http-status'\nimport { APIError, formatErrors, getPayload, logError } from 'payload'\n\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { mergeHeaders } from '../../utilities/mergeHeaders.js'\n\nexport const routeError = async ({\n collection,\n config: configArg,\n err,\n req: incomingReq,\n}: {\n collection?: Collection\n config: Promise<SanitizedConfig> | SanitizedConfig\n err: APIError\n req: PayloadRequest | Request\n}) => {\n let payload = 'payload' in incomingReq && incomingReq?.payload\n\n if (!payload) {\n try {\n payload = await getPayload({ config: configArg })\n } catch (e) {\n return Response.json(\n {\n message: 'There was an error initializing Payload',\n },\n { status: httpStatus.INTERNAL_SERVER_ERROR },\n )\n }\n }\n\n const req = incomingReq as PayloadRequest\n\n req.payload = payload\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n const { config } = payload\n\n let response = formatErrors(err)\n\n let status = err.status || httpStatus.INTERNAL_SERVER_ERROR\n\n logError({ err, payload })\n\n // Internal server errors can contain anything, including potentially sensitive data.\n // Therefore, error details will be hidden from the response unless `config.debug` is `true`\n if (!config.debug && status === httpStatus.INTERNAL_SERVER_ERROR) {\n response = formatErrors(new APIError('Something went wrong.'))\n }\n\n if (config.debug && config.debug === true) {\n response.stack = err.stack\n }\n\n if (collection) {\n await collection.config.hooks.afterError?.reduce(async (promise, hook) => {\n await promise\n\n const result = await hook({\n collection: collection.config,\n context: req.context,\n error: err,\n req,\n result: response,\n })\n\n if (result) {\n response = (result.response as ErrorResult) || response\n status = result.status || status\n }\n }, Promise.resolve())\n }\n\n await config.hooks.afterError?.reduce(async (promise, hook) => {\n await promise\n\n const result = await hook({\n collection: collection?.config,\n context: req.context,\n error: err,\n req,\n result: response,\n })\n\n if (result) {\n response = (result.response as ErrorResult) || response\n status = result.status || status\n }\n }, Promise.resolve())\n\n return Response.json(response, {\n headers: req.responseHeaders ? mergeHeaders(req.responseHeaders, headers) : headers,\n status,\n })\n}\n"],"mappings":"AAEA,OAAOA,UAAA,MAAgB;AACvB,SAASC,QAAQ,EAAEC,YAAY,EAAEC,UAAU,EAAEC,QAAQ,QAAQ;AAE7D,SAASC,eAAe,QAAQ;AAChC,SAASC,YAAY,QAAQ;AAE7B,OAAO,MAAMC,UAAA,GAAa,MAAAA,CAAO;EAC/BC,UAAU;EACVC,MAAA,EAAQC,SAAS;EACjBC,GAAG;EACHC,GAAA,EAAKC;AAAW,CAMjB;EACC,IAAIC,OAAA,GAAU,aAAaD,WAAA,IAAeA,WAAA,EAAaC,OAAA;EAEvD,IAAI,CAACA,OAAA,EAAS;IACZ,IAAI;MACFA,OAAA,GAAU,MAAMX,UAAA,CAAW;QAAEM,MAAA,EAAQC;MAAU;IACjD,EAAE,OAAOK,CAAA,EAAG;MACV,OAAOC,QAAA,CAASC,IAAI,CAClB;QACEC,OAAA,EAAS;MACX,GACA;QAAEC,MAAA,EAAQnB,UAAA,CAAWoB;MAAsB;IAE/C;EACF;EAEA,MAAMR,GAAA,GAAMC,WAAA;EAEZD,GAAA,CAAIE,OAAO,GAAGA,OAAA;EACd,MAAMO,OAAA,GAAUhB,eAAA,CAAgB;IAC9BgB,OAAA,EAAS,IAAIC,OAAA;IACbV;EACF;EAEA,MAAM;IAAEH;EAAM,CAAE,GAAGK,OAAA;EAEnB,IAAIS,QAAA,GAAWrB,YAAA,CAAaS,GAAA;EAE5B,IAAIQ,MAAA,GAASR,GAAA,CAAIQ,MAAM,IAAInB,UAAA,CAAWoB,qBAAqB;EAE3DhB,QAAA,CAAS;IAAEO,GAAA;IAAKG;EAAQ;EAExB;EACA;EACA,IAAI,CAACL,MAAA,CAAOe,KAAK,IAAIL,MAAA,KAAWnB,UAAA,CAAWoB,qBAAqB,EAAE;IAChEG,QAAA,GAAWrB,YAAA,CAAa,IAAID,QAAA,CAAS;EACvC;EAEA,IAAIQ,MAAA,CAAOe,KAAK,IAAIf,MAAA,CAAOe,KAAK,KAAK,MAAM;IACzCD,QAAA,CAASE,KAAK,GAAGd,GAAA,CAAIc,KAAK;EAC5B;EAEA,IAAIjB,UAAA,EAAY;IACd,MAAMA,UAAA,CAAWC,MAAM,CAACiB,KAAK,CAACC,UAAU,EAAEC,MAAA,CAAO,OAAOC,OAAA,EAASC,IAAA;MAC/D,MAAMD,OAAA;MAEN,MAAME,MAAA,GAAS,MAAMD,IAAA,CAAK;QACxBtB,UAAA,EAAYA,UAAA,CAAWC,MAAM;QAC7BuB,OAAA,EAASpB,GAAA,CAAIoB,OAAO;QACpBC,KAAA,EAAOtB,GAAA;QACPC,GAAA;QACAmB,MAAA,EAAQR;MACV;MAEA,IAAIQ,MAAA,EAAQ;QACVR,QAAA,GAAWQ,MAAC,CAAOR,QAAQ,IAAoBA,QAAA;QAC/CJ,MAAA,GAASY,MAAA,CAAOZ,MAAM,IAAIA,MAAA;MAC5B;IACF,GAAGe,OAAA,CAAQC,OAAO;EACpB;EAEA,MAAM1B,MAAA,CAAOiB,KAAK,CAACC,UAAU,EAAEC,MAAA,CAAO,OAAOC,OAAA,EAASC,IAAA;IACpD,MAAMD,OAAA;IAEN,MAAME,MAAA,GAAS,MAAMD,IAAA,CAAK;MACxBtB,UAAA,EAAYA,UAAA,EAAYC,MAAA;MACxBuB,OAAA,EAASpB,GAAA,CAAIoB,OAAO;MACpBC,KAAA,EAAOtB,GAAA;MACPC,GAAA;MACAmB,MAAA,EAAQR;IACV;IAEA,IAAIQ,MAAA,EAAQ;MACVR,QAAA,GAAWQ,MAAC,CAAOR,QAAQ,IAAoBA,QAAA;MAC/CJ,MAAA,GAASY,MAAA,CAAOZ,MAAM,IAAIA,MAAA;IAC5B;EACF,GAAGe,OAAA,CAAQC,OAAO;EAElB,OAAOnB,QAAA,CAASC,IAAI,CAACM,QAAA,EAAU;IAC7BF,OAAA,EAAST,GAAA,CAAIwB,eAAe,GAAG9B,YAAA,CAAaM,GAAA,CAAIwB,eAAe,EAAEf,OAAA,IAAWA,OAAA;IAC5EF;EACF;AACF","ignoreList":[]}
@@ -1,23 +0,0 @@
1
- import type { Collection, PayloadRequest, SanitizedGlobalConfig } from 'payload';
2
- export type BaseRouteHandler = ({ req }: {
3
- req: PayloadRequest;
4
- }) => Promise<Response> | Response;
5
- export type CollectionRouteHandler = ({ collection, req, }: {
6
- collection: Collection;
7
- req: PayloadRequest;
8
- }) => Promise<Response> | Response;
9
- export type CollectionRouteHandlerWithID = ({ id, collection, req, }: {
10
- collection: Collection;
11
- id: string;
12
- req: PayloadRequest;
13
- }) => Promise<Response> | Response;
14
- export type GlobalRouteHandler = ({ globalConfig, req, }: {
15
- globalConfig: SanitizedGlobalConfig;
16
- req: PayloadRequest;
17
- }) => Promise<Response> | Response;
18
- export type GlobalRouteHandlerWithID = ({ id, globalConfig, req, }: {
19
- globalConfig: SanitizedGlobalConfig;
20
- id: string;
21
- req: PayloadRequest;
22
- }) => Promise<Response> | Response;
23
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/routes/rest/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEhF,MAAM,MAAM,gBAAgB,GAAG,CAAC,EAAE,GAAG,EAAE,EAAE;IAAE,GAAG,EAAE,cAAc,CAAA;CAAE,KAAK,OAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAA;AAEjG,MAAM,MAAM,sBAAsB,GAAG,CAAC,EACpC,UAAU,EACV,GAAG,GACJ,EAAE;IACD,UAAU,EAAE,UAAU,CAAA;IACtB,GAAG,EAAE,cAAc,CAAA;CACpB,KAAK,OAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAA;AAElC,MAAM,MAAM,4BAA4B,GAAG,CAAC,EAC1C,EAAE,EACF,UAAU,EACV,GAAG,GACJ,EAAE;IACD,UAAU,EAAE,UAAU,CAAA;IACtB,EAAE,EAAE,MAAM,CAAA;IACV,GAAG,EAAE,cAAc,CAAA;CACpB,KAAK,OAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAA;AAElC,MAAM,MAAM,kBAAkB,GAAG,CAAC,EAChC,YAAY,EACZ,GAAG,GACJ,EAAE;IACD,YAAY,EAAE,qBAAqB,CAAA;IACnC,GAAG,EAAE,cAAc,CAAA;CACpB,KAAK,OAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAA;AAElC,MAAM,MAAM,wBAAwB,GAAG,CAAC,EACtC,EAAE,EACF,YAAY,EACZ,GAAG,GACJ,EAAE;IACD,YAAY,EAAE,qBAAqB,CAAA;IACnC,EAAE,EAAE,MAAM,CAAA;IACV,GAAG,EAAE,cAAc,CAAA;CACpB,KAAK,OAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../src/routes/rest/types.ts"],"sourcesContent":["import type { Collection, PayloadRequest, SanitizedGlobalConfig } from 'payload'\n\nexport type BaseRouteHandler = ({ req }: { req: PayloadRequest }) => Promise<Response> | Response\n\nexport type CollectionRouteHandler = ({\n collection,\n req,\n}: {\n collection: Collection\n req: PayloadRequest\n}) => Promise<Response> | Response\n\nexport type CollectionRouteHandlerWithID = ({\n id,\n collection,\n req,\n}: {\n collection: Collection\n id: string\n req: PayloadRequest\n}) => Promise<Response> | Response\n\nexport type GlobalRouteHandler = ({\n globalConfig,\n req,\n}: {\n globalConfig: SanitizedGlobalConfig\n req: PayloadRequest\n}) => Promise<Response> | Response\n\nexport type GlobalRouteHandlerWithID = ({\n id,\n globalConfig,\n req,\n}: {\n globalConfig: SanitizedGlobalConfig\n id: string\n req: PayloadRequest\n}) => Promise<Response> | Response\n"],"mappings":"AA8BA","ignoreList":[]}
@@ -1,9 +0,0 @@
1
- import type { Payload } from 'payload';
2
- type Args = {
3
- collectionSlug: string;
4
- id: string;
5
- payload: Payload;
6
- };
7
- export declare const sanitizeCollectionID: ({ id, collectionSlug, payload }: Args) => number | string;
8
- export {};
9
- //# sourceMappingURL=sanitizeCollectionID.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sanitizeCollectionID.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/utilities/sanitizeCollectionID.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEtC,KAAK,IAAI,GAAG;IACV,cAAc,EAAE,MAAM,CAAA;IACtB,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,oBAAoB,oCAAqC,IAAI,KAAG,MAAM,GAAG,MAkBrF,CAAA"}
@@ -1,20 +0,0 @@
1
- export const sanitizeCollectionID = ({
2
- id,
3
- collectionSlug,
4
- payload
5
- }) => {
6
- let sanitizedID = id;
7
- const collection = payload.collections[collectionSlug];
8
- // If default db ID type is a number, we should sanitize
9
- let shouldSanitize = Boolean(payload.db.defaultIDType === 'number');
10
- // UNLESS the customIDType for this collection is text.... then we leave it
11
- if (shouldSanitize && collection.customIDType === 'text') {
12
- shouldSanitize = false;
13
- }
14
- // If we still should sanitize, parse float
15
- if (shouldSanitize) {
16
- sanitizedID = parseFloat(sanitizedID);
17
- }
18
- return sanitizedID;
19
- };
20
- //# sourceMappingURL=sanitizeCollectionID.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sanitizeCollectionID.js","names":["sanitizeCollectionID","id","collectionSlug","payload","sanitizedID","collection","collections","shouldSanitize","Boolean","db","defaultIDType","customIDType","parseFloat"],"sources":["../../../../src/routes/rest/utilities/sanitizeCollectionID.ts"],"sourcesContent":["import type { Payload } from 'payload'\n\ntype Args = {\n collectionSlug: string\n id: string\n payload: Payload\n}\n\nexport const sanitizeCollectionID = ({ id, collectionSlug, payload }: Args): number | string => {\n let sanitizedID: number | string = id\n const collection = payload.collections[collectionSlug]\n\n // If default db ID type is a number, we should sanitize\n let shouldSanitize = Boolean(payload.db.defaultIDType === 'number')\n\n // UNLESS the customIDType for this collection is text.... then we leave it\n if (shouldSanitize && collection.customIDType === 'text') {\n shouldSanitize = false\n }\n\n // If we still should sanitize, parse float\n if (shouldSanitize) {\n sanitizedID = parseFloat(sanitizedID)\n }\n\n return sanitizedID\n}\n"],"mappings":"AAQA,OAAO,MAAMA,oBAAA,GAAuBA,CAAC;EAAEC,EAAE;EAAEC,cAAc;EAAEC;AAAO,CAAQ;EACxE,IAAIC,WAAA,GAA+BH,EAAA;EACnC,MAAMI,UAAA,GAAaF,OAAA,CAAQG,WAAW,CAACJ,cAAA,CAAe;EAEtD;EACA,IAAIK,cAAA,GAAiBC,OAAA,CAAQL,OAAA,CAAQM,EAAE,CAACC,aAAa,KAAK;EAE1D;EACA,IAAIH,cAAA,IAAkBF,UAAA,CAAWM,YAAY,KAAK,QAAQ;IACxDJ,cAAA,GAAiB;EACnB;EAEA;EACA,IAAIA,cAAA,EAAgB;IAClBH,WAAA,GAAcQ,UAAA,CAAWR,WAAA;EAC3B;EAEA,OAAOA,WAAA;AACT","ignoreList":[]}
@@ -1,8 +0,0 @@
1
- import type { PayloadRequest } from 'payload';
2
- type AddDataAndFileToRequest = (req: PayloadRequest) => Promise<void>;
3
- /**
4
- * Mutates the Request, appending 'data' and 'file' if found
5
- */
6
- export declare const addDataAndFileToRequest: AddDataAndFileToRequest;
7
- export {};
8
- //# sourceMappingURL=addDataAndFileToRequest.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"addDataAndFileToRequest.d.ts","sourceRoot":"","sources":["../../src/utilities/addDataAndFileToRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAM7C,KAAK,uBAAuB,GAAG,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;AAErE;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,uBAoCrC,CAAA"}
@@ -1,47 +0,0 @@
1
- import { APIError } from 'payload';
2
- import { fetchAPIFileUpload } from '../fetchAPI-multipart/index.js';
3
- /**
4
- * Mutates the Request, appending 'data' and 'file' if found
5
- */
6
- export const addDataAndFileToRequest = async req => {
7
- const {
8
- body,
9
- headers,
10
- method,
11
- payload
12
- } = req;
13
- if (method && ['PATCH', 'POST', 'PUT'].includes(method.toUpperCase()) && body) {
14
- const [contentType] = (headers.get('Content-Type') || '').split(';');
15
- const bodyByteSize = parseInt(req.headers.get('Content-Length') || '0', 10);
16
- if (contentType === 'application/json') {
17
- let data = {};
18
- try {
19
- data = await req.json();
20
- } catch (error) {
21
- req.payload.logger.error(error);
22
- } finally {
23
- req.data = data;
24
- req.json = () => Promise.resolve(data);
25
- }
26
- } else if (bodyByteSize && contentType.includes('multipart/')) {
27
- const {
28
- error,
29
- fields,
30
- files
31
- } = await fetchAPIFileUpload({
32
- options: payload.config.upload,
33
- request: req
34
- });
35
- if (error) {
36
- throw new APIError(error.message);
37
- }
38
- if (files?.file) {
39
- req.file = files.file;
40
- }
41
- if (fields?._payload && typeof fields._payload === 'string') {
42
- req.data = JSON.parse(fields._payload);
43
- }
44
- }
45
- }
46
- };
47
- //# sourceMappingURL=addDataAndFileToRequest.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"addDataAndFileToRequest.js","names":["APIError","fetchAPIFileUpload","addDataAndFileToRequest","req","body","headers","method","payload","includes","toUpperCase","contentType","get","split","bodyByteSize","parseInt","data","json","error","logger","Promise","resolve","fields","files","options","config","upload","request","message","file","_payload","JSON","parse"],"sources":["../../src/utilities/addDataAndFileToRequest.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\n\nimport { APIError } from 'payload'\n\nimport { fetchAPIFileUpload } from '../fetchAPI-multipart/index.js'\n\ntype AddDataAndFileToRequest = (req: PayloadRequest) => Promise<void>\n\n/**\n * Mutates the Request, appending 'data' and 'file' if found\n */\nexport const addDataAndFileToRequest: AddDataAndFileToRequest = async (req) => {\n const { body, headers, method, payload } = req\n\n if (method && ['PATCH', 'POST', 'PUT'].includes(method.toUpperCase()) && body) {\n const [contentType] = (headers.get('Content-Type') || '').split(';')\n const bodyByteSize = parseInt(req.headers.get('Content-Length') || '0', 10)\n\n if (contentType === 'application/json') {\n let data = {}\n try {\n data = await req.json()\n } catch (error) {\n req.payload.logger.error(error)\n } finally {\n req.data = data\n req.json = () => Promise.resolve(data)\n }\n } else if (bodyByteSize && contentType.includes('multipart/')) {\n const { error, fields, files } = await fetchAPIFileUpload({\n options: payload.config.upload,\n request: req as Request,\n })\n\n if (error) {\n throw new APIError(error.message)\n }\n\n if (files?.file) {\n req.file = files.file\n }\n\n if (fields?._payload && typeof fields._payload === 'string') {\n req.data = JSON.parse(fields._payload)\n }\n }\n }\n}\n"],"mappings":"AAEA,SAASA,QAAQ,QAAQ;AAEzB,SAASC,kBAAkB,QAAQ;AAInC;;;AAGA,OAAO,MAAMC,uBAAA,GAAmD,MAAOC,GAAA;EACrE,MAAM;IAAEC,IAAI;IAAEC,OAAO;IAAEC,MAAM;IAAEC;EAAO,CAAE,GAAGJ,GAAA;EAE3C,IAAIG,MAAA,IAAU,CAAC,SAAS,QAAQ,MAAM,CAACE,QAAQ,CAACF,MAAA,CAAOG,WAAW,OAAOL,IAAA,EAAM;IAC7E,MAAM,CAACM,WAAA,CAAY,GAAG,CAACL,OAAA,CAAQM,GAAG,CAAC,mBAAmB,EAAC,EAAGC,KAAK,CAAC;IAChE,MAAMC,YAAA,GAAeC,QAAA,CAASX,GAAA,CAAIE,OAAO,CAACM,GAAG,CAAC,qBAAqB,KAAK;IAExE,IAAID,WAAA,KAAgB,oBAAoB;MACtC,IAAIK,IAAA,GAAO,CAAC;MACZ,IAAI;QACFA,IAAA,GAAO,MAAMZ,GAAA,CAAIa,IAAI;MACvB,EAAE,OAAOC,KAAA,EAAO;QACdd,GAAA,CAAII,OAAO,CAACW,MAAM,CAACD,KAAK,CAACA,KAAA;MAC3B,UAAU;QACRd,GAAA,CAAIY,IAAI,GAAGA,IAAA;QACXZ,GAAA,CAAIa,IAAI,GAAG,MAAMG,OAAA,CAAQC,OAAO,CAACL,IAAA;MACnC;IACF,OAAO,IAAIF,YAAA,IAAgBH,WAAA,CAAYF,QAAQ,CAAC,eAAe;MAC7D,MAAM;QAAES,KAAK;QAAEI,MAAM;QAAEC;MAAK,CAAE,GAAG,MAAMrB,kBAAA,CAAmB;QACxDsB,OAAA,EAAShB,OAAA,CAAQiB,MAAM,CAACC,MAAM;QAC9BC,OAAA,EAASvB;MACX;MAEA,IAAIc,KAAA,EAAO;QACT,MAAM,IAAIjB,QAAA,CAASiB,KAAA,CAAMU,OAAO;MAClC;MAEA,IAAIL,KAAA,EAAOM,IAAA,EAAM;QACfzB,GAAA,CAAIyB,IAAI,GAAGN,KAAA,CAAMM,IAAI;MACvB;MAEA,IAAIP,MAAA,EAAQQ,QAAA,IAAY,OAAOR,MAAA,CAAOQ,QAAQ,KAAK,UAAU;QAC3D1B,GAAA,CAAIY,IAAI,GAAGe,IAAA,CAAKC,KAAK,CAACV,MAAA,CAAOQ,QAAQ;MACvC;IACF;EACF;AACF","ignoreList":[]}
@@ -1,17 +0,0 @@
1
- import type { PayloadRequest, SanitizedConfig } from 'payload';
2
- /**
3
- * Mutates the Request to contain 'locale' and 'fallbackLocale' based on data or searchParams
4
- */
5
- export declare function addLocalesToRequestFromData(req: PayloadRequest): void;
6
- type SanitizeLocalesArgs = {
7
- fallbackLocale: string;
8
- locale: string;
9
- localization: SanitizedConfig['localization'];
10
- };
11
- type SanitizeLocalesReturn = {
12
- fallbackLocale?: string;
13
- locale?: string;
14
- };
15
- export declare const sanitizeLocales: ({ fallbackLocale, locale, localization, }: SanitizeLocalesArgs) => SanitizeLocalesReturn;
16
- export {};
17
- //# sourceMappingURL=addLocalesToRequest.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"addLocalesToRequest.d.ts","sourceRoot":"","sources":["../../src/utilities/addLocalesToRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAG9D;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,cAAc,GAAG,IAAI,CAqCrE;AAED,KAAK,mBAAmB,GAAG;IACzB,cAAc,EAAE,MAAM,CAAA;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,EAAE,eAAe,CAAC,cAAc,CAAC,CAAA;CAC9C,CAAA;AACD,KAAK,qBAAqB,GAAG;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AACD,eAAO,MAAM,eAAe,8CAIzB,mBAAmB,KAAG,qBAqBxB,CAAA"}
@@ -1,65 +0,0 @@
1
- import { sanitizeFallbackLocale } from 'payload';
2
- /**
3
- * Mutates the Request to contain 'locale' and 'fallbackLocale' based on data or searchParams
4
- */
5
- export function addLocalesToRequestFromData(req) {
6
- const {
7
- data,
8
- payload: {
9
- config
10
- }
11
- } = req;
12
- if (data) {
13
- let localeOnReq = req.locale;
14
- let fallbackLocaleOnReq = req.fallbackLocale;
15
- if (!localeOnReq && data?.locale && typeof data.locale === 'string') {
16
- localeOnReq = data.locale;
17
- }
18
- if (!fallbackLocaleOnReq) {
19
- if (data?.['fallback-locale'] && typeof data?.['fallback-locale'] === 'string') {
20
- fallbackLocaleOnReq = data['fallback-locale'];
21
- }
22
- if (data?.['fallbackLocale'] && typeof data?.['fallbackLocale'] === 'string') {
23
- fallbackLocaleOnReq = data['fallbackLocale'];
24
- }
25
- }
26
- const {
27
- fallbackLocale,
28
- locale
29
- } = sanitizeLocales({
30
- fallbackLocale: fallbackLocaleOnReq,
31
- locale: localeOnReq,
32
- localization: config.localization
33
- });
34
- if (locale) {
35
- req.locale = locale;
36
- }
37
- if (fallbackLocale) {
38
- req.fallbackLocale = fallbackLocale;
39
- }
40
- }
41
- }
42
- export const sanitizeLocales = ({
43
- fallbackLocale,
44
- locale,
45
- localization
46
- }) => {
47
- // Check if localization has fallback enabled or if a fallback locale is provided
48
- if (localization) {
49
- fallbackLocale = sanitizeFallbackLocale({
50
- fallbackLocale,
51
- locale,
52
- localization
53
- });
54
- }
55
- if (locale === '*') {
56
- locale = 'all';
57
- } else if (localization && !localization.localeCodes.includes(locale) && localization.fallback) {
58
- locale = localization.defaultLocale;
59
- }
60
- return {
61
- fallbackLocale,
62
- locale
63
- };
64
- };
65
- //# sourceMappingURL=addLocalesToRequest.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"addLocalesToRequest.js","names":["sanitizeFallbackLocale","addLocalesToRequestFromData","req","data","payload","config","localeOnReq","locale","fallbackLocaleOnReq","fallbackLocale","sanitizeLocales","localization","localeCodes","includes","fallback","defaultLocale"],"sources":["../../src/utilities/addLocalesToRequest.ts"],"sourcesContent":["import type { PayloadRequest, SanitizedConfig } from 'payload'\n\nimport { sanitizeFallbackLocale } from 'payload'\n/**\n * Mutates the Request to contain 'locale' and 'fallbackLocale' based on data or searchParams\n */\nexport function addLocalesToRequestFromData(req: PayloadRequest): void {\n const {\n data,\n payload: { config },\n } = req\n\n if (data) {\n let localeOnReq = req.locale\n let fallbackLocaleOnReq = req.fallbackLocale\n\n if (!localeOnReq && data?.locale && typeof data.locale === 'string') {\n localeOnReq = data.locale\n }\n\n if (!fallbackLocaleOnReq) {\n if (data?.['fallback-locale'] && typeof data?.['fallback-locale'] === 'string') {\n fallbackLocaleOnReq = data['fallback-locale']\n }\n\n if (data?.['fallbackLocale'] && typeof data?.['fallbackLocale'] === 'string') {\n fallbackLocaleOnReq = data['fallbackLocale']\n }\n }\n\n const { fallbackLocale, locale } = sanitizeLocales({\n fallbackLocale: fallbackLocaleOnReq,\n locale: localeOnReq,\n localization: config.localization,\n })\n\n if (locale) {\n req.locale = locale\n }\n if (fallbackLocale) {\n req.fallbackLocale = fallbackLocale\n }\n }\n}\n\ntype SanitizeLocalesArgs = {\n fallbackLocale: string\n locale: string\n localization: SanitizedConfig['localization']\n}\ntype SanitizeLocalesReturn = {\n fallbackLocale?: string\n locale?: string\n}\nexport const sanitizeLocales = ({\n fallbackLocale,\n locale,\n localization,\n}: SanitizeLocalesArgs): SanitizeLocalesReturn => {\n // Check if localization has fallback enabled or if a fallback locale is provided\n\n if (localization) {\n fallbackLocale = sanitizeFallbackLocale({\n fallbackLocale,\n locale,\n localization,\n })\n }\n\n if (locale === '*') {\n locale = 'all'\n } else if (localization && !localization.localeCodes.includes(locale) && localization.fallback) {\n locale = localization.defaultLocale\n }\n\n return {\n fallbackLocale,\n locale,\n }\n}\n"],"mappings":"AAEA,SAASA,sBAAsB,QAAQ;AACvC;;;AAGA,OAAO,SAASC,4BAA4BC,GAAmB;EAC7D,MAAM;IACJC,IAAI;IACJC,OAAA,EAAS;MAAEC;IAAM;EAAE,CACpB,GAAGH,GAAA;EAEJ,IAAIC,IAAA,EAAM;IACR,IAAIG,WAAA,GAAcJ,GAAA,CAAIK,MAAM;IAC5B,IAAIC,mBAAA,GAAsBN,GAAA,CAAIO,cAAc;IAE5C,IAAI,CAACH,WAAA,IAAeH,IAAA,EAAMI,MAAA,IAAU,OAAOJ,IAAA,CAAKI,MAAM,KAAK,UAAU;MACnED,WAAA,GAAcH,IAAA,CAAKI,MAAM;IAC3B;IAEA,IAAI,CAACC,mBAAA,EAAqB;MACxB,IAAIL,IAAA,GAAO,kBAAkB,IAAI,OAAOA,IAAA,GAAO,kBAAkB,KAAK,UAAU;QAC9EK,mBAAA,GAAsBL,IAAI,CAAC,kBAAkB;MAC/C;MAEA,IAAIA,IAAA,GAAO,iBAAiB,IAAI,OAAOA,IAAA,GAAO,iBAAiB,KAAK,UAAU;QAC5EK,mBAAA,GAAsBL,IAAI,CAAC,iBAAiB;MAC9C;IACF;IAEA,MAAM;MAAEM,cAAc;MAAEF;IAAM,CAAE,GAAGG,eAAA,CAAgB;MACjDD,cAAA,EAAgBD,mBAAA;MAChBD,MAAA,EAAQD,WAAA;MACRK,YAAA,EAAcN,MAAA,CAAOM;IACvB;IAEA,IAAIJ,MAAA,EAAQ;MACVL,GAAA,CAAIK,MAAM,GAAGA,MAAA;IACf;IACA,IAAIE,cAAA,EAAgB;MAClBP,GAAA,CAAIO,cAAc,GAAGA,cAAA;IACvB;EACF;AACF;AAWA,OAAO,MAAMC,eAAA,GAAkBA,CAAC;EAC9BD,cAAc;EACdF,MAAM;EACNI;AAAY,CACQ;EACpB;EAEA,IAAIA,YAAA,EAAc;IAChBF,cAAA,GAAiBT,sBAAA,CAAuB;MACtCS,cAAA;MACAF,MAAA;MACAI;IACF;EACF;EAEA,IAAIJ,MAAA,KAAW,KAAK;IAClBA,MAAA,GAAS;EACX,OAAO,IAAII,YAAA,IAAgB,CAACA,YAAA,CAAaC,WAAW,CAACC,QAAQ,CAACN,MAAA,KAAWI,YAAA,CAAaG,QAAQ,EAAE;IAC9FP,MAAA,GAASI,YAAA,CAAaI,aAAa;EACrC;EAEA,OAAO;IACLN,cAAA;IACAF;EACF;AACF","ignoreList":[]}
@@ -1,11 +0,0 @@
1
- import type { PayloadRequest, SanitizedConfig } from 'payload';
2
- type Args = {
3
- config: Promise<SanitizedConfig> | SanitizedConfig;
4
- params?: {
5
- collection: string;
6
- };
7
- request: Request;
8
- };
9
- export declare const createPayloadRequest: ({ config: configPromise, params, request, }: Args) => Promise<PayloadRequest>;
10
- export {};
11
- //# sourceMappingURL=createPayloadRequest.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createPayloadRequest.d.ts","sourceRoot":"","sources":["../../src/utilities/createPayloadRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkC,cAAc,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAgB9F,KAAK,IAAI,GAAG;IACV,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAA;IAClD,MAAM,CAAC,EAAE;QACP,UAAU,EAAE,MAAM,CAAA;KACnB,CAAA;IACD,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,oBAAoB,gDAI9B,IAAI,KAAG,OAAO,CAAC,cAAc,CAwG/B,CAAA"}