@payloadcms/next 3.0.0-beta.10 → 3.0.0-beta.12

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 (185) hide show
  1. package/dist/exports/routes.d.ts +1 -1
  2. package/dist/exports/routes.d.ts.map +1 -1
  3. package/dist/exports/routes.js +1 -1
  4. package/dist/exports/routes.js.map +1 -1
  5. package/dist/exports/utilities.d.ts +3 -0
  6. package/dist/exports/utilities.d.ts.map +1 -1
  7. package/dist/exports/utilities.js +3 -0
  8. package/dist/exports/utilities.js.map +1 -1
  9. package/dist/next-fileupload/handlers.js.map +1 -1
  10. package/dist/next-fileupload/isEligibleRequest.js +1 -1
  11. package/dist/next-fileupload/isEligibleRequest.js.map +1 -1
  12. package/dist/next-fileupload/processMultipart.d.ts.map +1 -1
  13. package/dist/next-fileupload/processMultipart.js +29 -6
  14. package/dist/next-fileupload/processMultipart.js.map +1 -1
  15. package/dist/next-fileupload/utilities.d.ts.map +1 -1
  16. package/dist/next-fileupload/utilities.js +4 -4
  17. package/dist/next-fileupload/utilities.js.map +1 -1
  18. package/dist/routes/graphql/handler.d.ts.map +1 -1
  19. package/dist/routes/graphql/handler.js +8 -3
  20. package/dist/routes/graphql/handler.js.map +1 -1
  21. package/dist/routes/rest/auth/access.d.ts.map +1 -1
  22. package/dist/routes/rest/auth/access.js +5 -0
  23. package/dist/routes/rest/auth/access.js.map +1 -1
  24. package/dist/routes/rest/auth/forgotPassword.d.ts.map +1 -1
  25. package/dist/routes/rest/auth/forgotPassword.js +7 -2
  26. package/dist/routes/rest/auth/forgotPassword.js.map +1 -1
  27. package/dist/routes/rest/auth/init.d.ts.map +1 -1
  28. package/dist/routes/rest/auth/init.js +6 -0
  29. package/dist/routes/rest/auth/init.js.map +1 -1
  30. package/dist/routes/rest/auth/login.d.ts.map +1 -1
  31. package/dist/routes/rest/auth/login.js +8 -5
  32. package/dist/routes/rest/auth/login.js.map +1 -1
  33. package/dist/routes/rest/auth/logout.d.ts.map +1 -1
  34. package/dist/routes/rest/auth/logout.js +11 -6
  35. package/dist/routes/rest/auth/logout.js.map +1 -1
  36. package/dist/routes/rest/auth/me.d.ts.map +1 -1
  37. package/dist/routes/rest/auth/me.js +5 -0
  38. package/dist/routes/rest/auth/me.js.map +1 -1
  39. package/dist/routes/rest/auth/refresh.d.ts.map +1 -1
  40. package/dist/routes/rest/auth/refresh.js +11 -7
  41. package/dist/routes/rest/auth/refresh.js.map +1 -1
  42. package/dist/routes/rest/auth/registerFirstUser.d.ts.map +1 -1
  43. package/dist/routes/rest/auth/registerFirstUser.js +17 -5
  44. package/dist/routes/rest/auth/registerFirstUser.js.map +1 -1
  45. package/dist/routes/rest/auth/resetPassword.d.ts.map +1 -1
  46. package/dist/routes/rest/auth/resetPassword.js +8 -5
  47. package/dist/routes/rest/auth/resetPassword.js.map +1 -1
  48. package/dist/routes/rest/auth/unlock.d.ts.map +1 -1
  49. package/dist/routes/rest/auth/unlock.js +7 -2
  50. package/dist/routes/rest/auth/unlock.js.map +1 -1
  51. package/dist/routes/rest/auth/verifyEmail.d.ts.map +1 -1
  52. package/dist/routes/rest/auth/verifyEmail.js +7 -2
  53. package/dist/routes/rest/auth/verifyEmail.js.map +1 -1
  54. package/dist/routes/rest/buildFormState.d.ts.map +1 -1
  55. package/dist/routes/rest/buildFormState.js +15 -0
  56. package/dist/routes/rest/buildFormState.js.map +1 -1
  57. package/dist/routes/rest/collections/count.d.ts +3 -0
  58. package/dist/routes/rest/collections/count.d.ts.map +1 -0
  59. package/dist/routes/rest/collections/count.js +15 -0
  60. package/dist/routes/rest/collections/count.js.map +1 -0
  61. package/dist/routes/rest/collections/create.d.ts.map +1 -1
  62. package/dist/routes/rest/collections/create.js +5 -0
  63. package/dist/routes/rest/collections/create.js.map +1 -1
  64. package/dist/routes/rest/collections/delete.d.ts.map +1 -1
  65. package/dist/routes/rest/collections/delete.js +7 -0
  66. package/dist/routes/rest/collections/delete.js.map +1 -1
  67. package/dist/routes/rest/collections/deleteByID.d.ts.map +1 -1
  68. package/dist/routes/rest/collections/deleteByID.js +7 -0
  69. package/dist/routes/rest/collections/deleteByID.js.map +1 -1
  70. package/dist/routes/rest/collections/docAccess.d.ts.map +1 -1
  71. package/dist/routes/rest/collections/docAccess.js +5 -0
  72. package/dist/routes/rest/collections/docAccess.js.map +1 -1
  73. package/dist/routes/rest/collections/duplicate.d.ts.map +1 -1
  74. package/dist/routes/rest/collections/duplicate.js +5 -0
  75. package/dist/routes/rest/collections/duplicate.js.map +1 -1
  76. package/dist/routes/rest/collections/find.d.ts.map +1 -1
  77. package/dist/routes/rest/collections/find.js +5 -0
  78. package/dist/routes/rest/collections/find.js.map +1 -1
  79. package/dist/routes/rest/collections/findByID.d.ts.map +1 -1
  80. package/dist/routes/rest/collections/findByID.js +5 -0
  81. package/dist/routes/rest/collections/findByID.js.map +1 -1
  82. package/dist/routes/rest/collections/findVersionByID.d.ts.map +1 -1
  83. package/dist/routes/rest/collections/findVersionByID.js +5 -0
  84. package/dist/routes/rest/collections/findVersionByID.js.map +1 -1
  85. package/dist/routes/rest/collections/findVersions.d.ts.map +1 -1
  86. package/dist/routes/rest/collections/findVersions.js +5 -0
  87. package/dist/routes/rest/collections/findVersions.js.map +1 -1
  88. package/dist/routes/rest/collections/preview.d.ts.map +1 -1
  89. package/dist/routes/rest/collections/preview.js +7 -1
  90. package/dist/routes/rest/collections/preview.js.map +1 -1
  91. package/dist/routes/rest/collections/restoreVersion.d.ts.map +1 -1
  92. package/dist/routes/rest/collections/restoreVersion.js +5 -0
  93. package/dist/routes/rest/collections/restoreVersion.js.map +1 -1
  94. package/dist/routes/rest/collections/update.d.ts.map +1 -1
  95. package/dist/routes/rest/collections/update.js +7 -0
  96. package/dist/routes/rest/collections/update.js.map +1 -1
  97. package/dist/routes/rest/collections/updateByID.d.ts.map +1 -1
  98. package/dist/routes/rest/collections/updateByID.js +5 -0
  99. package/dist/routes/rest/collections/updateByID.js.map +1 -1
  100. package/dist/routes/rest/files/getFile.d.ts.map +1 -1
  101. package/dist/routes/rest/files/getFile.js +15 -8
  102. package/dist/routes/rest/files/getFile.js.map +1 -1
  103. package/dist/routes/rest/files/getFileTypeFallback.d.ts +7 -0
  104. package/dist/routes/rest/files/getFileTypeFallback.d.ts.map +1 -0
  105. package/dist/routes/rest/files/getFileTypeFallback.js +21 -0
  106. package/dist/routes/rest/files/getFileTypeFallback.js.map +1 -0
  107. package/dist/routes/rest/globals/docAccess.d.ts.map +1 -1
  108. package/dist/routes/rest/globals/docAccess.js +5 -0
  109. package/dist/routes/rest/globals/docAccess.js.map +1 -1
  110. package/dist/routes/rest/globals/findOne.d.ts.map +1 -1
  111. package/dist/routes/rest/globals/findOne.js +5 -0
  112. package/dist/routes/rest/globals/findOne.js.map +1 -1
  113. package/dist/routes/rest/globals/findVersionByID.d.ts.map +1 -1
  114. package/dist/routes/rest/globals/findVersionByID.js +5 -0
  115. package/dist/routes/rest/globals/findVersionByID.js.map +1 -1
  116. package/dist/routes/rest/globals/findVersions.d.ts.map +1 -1
  117. package/dist/routes/rest/globals/findVersions.js +5 -0
  118. package/dist/routes/rest/globals/findVersions.js.map +1 -1
  119. package/dist/routes/rest/globals/preview.d.ts.map +1 -1
  120. package/dist/routes/rest/globals/preview.js +7 -1
  121. package/dist/routes/rest/globals/preview.js.map +1 -1
  122. package/dist/routes/rest/globals/restoreVersion.d.ts.map +1 -1
  123. package/dist/routes/rest/globals/restoreVersion.js +5 -0
  124. package/dist/routes/rest/globals/restoreVersion.js.map +1 -1
  125. package/dist/routes/rest/globals/update.d.ts.map +1 -1
  126. package/dist/routes/rest/globals/update.js +5 -0
  127. package/dist/routes/rest/globals/update.js.map +1 -1
  128. package/dist/routes/rest/index.d.ts +1 -0
  129. package/dist/routes/rest/index.d.ts.map +1 -1
  130. package/dist/routes/rest/index.js +55 -9
  131. package/dist/routes/rest/index.js.map +1 -1
  132. package/dist/routes/rest/routeError.d.ts +5 -4
  133. package/dist/routes/rest/routeError.d.ts.map +1 -1
  134. package/dist/routes/rest/routeError.js +25 -11
  135. package/dist/routes/rest/routeError.js.map +1 -1
  136. package/dist/utilities/getDataAndFile.d.ts.map +1 -1
  137. package/dist/utilities/getDataAndFile.js +26 -46
  138. package/dist/utilities/getDataAndFile.js.map +1 -1
  139. package/dist/utilities/headersWithCors.d.ts +8 -0
  140. package/dist/utilities/headersWithCors.d.ts.map +1 -0
  141. package/dist/utilities/headersWithCors.js +17 -0
  142. package/dist/utilities/headersWithCors.js.map +1 -0
  143. package/dist/utilities/initPage.d.ts.map +1 -1
  144. package/dist/utilities/initPage.js +15 -2
  145. package/dist/utilities/initPage.js.map +1 -1
  146. package/dist/views/API/index.client.js +2 -2
  147. package/dist/views/API/index.client.js.map +1 -1
  148. package/dist/views/CreateFirstUser/index.client.js +2 -2
  149. package/dist/views/CreateFirstUser/index.client.js.map +1 -1
  150. package/dist/views/CreateFirstUser/index.d.ts.map +1 -1
  151. package/dist/views/CreateFirstUser/index.js +17 -0
  152. package/dist/views/CreateFirstUser/index.js.map +1 -1
  153. package/dist/views/Edit/Default/{SetStepNav → SetDocumentStepNav}/index.d.ts +1 -1
  154. package/dist/views/Edit/Default/SetDocumentStepNav/index.d.ts.map +1 -0
  155. package/dist/views/Edit/Default/{SetStepNav → SetDocumentStepNav}/index.js +12 -5
  156. package/dist/views/Edit/Default/SetDocumentStepNav/index.js.map +1 -0
  157. package/dist/views/Edit/Default/index.d.ts.map +1 -1
  158. package/dist/views/Edit/Default/index.js +5 -4
  159. package/dist/views/Edit/Default/index.js.map +1 -1
  160. package/dist/views/ForgotPassword/ForgotPasswordForm/index.d.ts +3 -0
  161. package/dist/views/ForgotPassword/ForgotPasswordForm/index.d.ts.map +1 -0
  162. package/dist/views/ForgotPassword/ForgotPasswordForm/index.js +55 -0
  163. package/dist/views/ForgotPassword/ForgotPasswordForm/index.js.map +1 -0
  164. package/dist/views/ForgotPassword/index.d.ts.map +1 -1
  165. package/dist/views/ForgotPassword/index.js +3 -39
  166. package/dist/views/ForgotPassword/index.js.map +1 -1
  167. package/dist/views/List/index.js +2 -2
  168. package/dist/views/List/index.js.map +1 -1
  169. package/dist/views/LivePreview/Toolbar/Controls/index.d.ts.map +1 -1
  170. package/dist/views/LivePreview/Toolbar/Controls/index.js +6 -4
  171. package/dist/views/LivePreview/Toolbar/Controls/index.js.map +1 -1
  172. package/dist/views/LivePreview/index.client.js +2 -2
  173. package/dist/views/LivePreview/index.client.js.map +1 -1
  174. package/dist/views/Login/LoginForm/index.d.ts.map +1 -1
  175. package/dist/views/Login/LoginForm/index.js +26 -2
  176. package/dist/views/Login/LoginForm/index.js.map +1 -1
  177. package/dist/views/Logout/LogoutClient.d.ts.map +1 -1
  178. package/dist/views/Logout/LogoutClient.js +1 -2
  179. package/dist/views/Logout/LogoutClient.js.map +1 -1
  180. package/dist/views/Versions/index.js +2 -2
  181. package/dist/views/Versions/index.js.map +1 -1
  182. package/package.json +10 -8
  183. package/dist/views/Edit/Default/SetStepNav/index.d.ts.map +0 -1
  184. package/dist/views/Edit/Default/SetStepNav/index.js.map +0 -1
  185. package/src/index.js +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/routes/rest/collections/create.ts"],"sourcesContent":["import { getTranslation } from '@payloadcms/translations'\nimport httpStatus from 'http-status'\nimport { createOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nexport const create: CollectionRouteHandler = async ({ collection, req }) => {\n const { searchParams } = req\n const autosave = searchParams.get('autosave') === 'true'\n const draft = searchParams.get('draft') === 'true'\n const depth = searchParams.get('depth')\n\n const doc = await createOperation({\n autosave,\n collection,\n data: req.data,\n depth: isNumber(depth) ? depth : undefined,\n draft,\n req,\n })\n\n return Response.json(\n {\n doc,\n message: req.t('general:successfullyCreated', {\n label: getTranslation(collection.config.labels.singular, req.i18n),\n }),\n },\n {\n status: httpStatus.CREATED,\n },\n )\n}\n"],"names":["getTranslation","httpStatus","createOperation","isNumber","create","collection","req","searchParams","autosave","get","draft","depth","doc","data","undefined","Response","json","message","t","label","config","labels","singular","i18n","status","CREATED"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,gBAAgB,cAAa;AACpC,SAASC,eAAe,QAAQ,qBAAoB;AACpD,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,OAAO,MAAMC,SAAiC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACtE,MAAM,EAAEC,YAAY,EAAE,GAAGD;IACzB,MAAME,WAAWD,aAAaE,GAAG,CAAC,gBAAgB;IAClD,MAAMC,QAAQH,aAAaE,GAAG,CAAC,aAAa;IAC5C,MAAME,QAAQJ,aAAaE,GAAG,CAAC;IAE/B,MAAMG,MAAM,MAAMV,gBAAgB;QAChCM;QACAH;QACAQ,MAAMP,IAAIO,IAAI;QACdF,OAAOR,SAASQ,SAASA,QAAQG;QACjCJ;QACAJ;IACF;IAEA,OAAOS,SAASC,IAAI,CAClB;QACEJ;QACAK,SAASX,IAAIY,CAAC,CAAC,+BAA+B;YAC5CC,OAAOnB,eAAeK,WAAWe,MAAM,CAACC,MAAM,CAACC,QAAQ,EAAEhB,IAAIiB,IAAI;QACnE;IACF,GACA;QACEC,QAAQvB,WAAWwB,OAAO;IAC5B;AAEJ,EAAC"}
1
+ {"version":3,"sources":["../../../../src/routes/rest/collections/create.ts"],"sourcesContent":["import { getTranslation } from '@payloadcms/translations'\nimport httpStatus from 'http-status'\nimport { createOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const create: CollectionRouteHandler = async ({ collection, req }) => {\n const { searchParams } = req\n const autosave = searchParams.get('autosave') === 'true'\n const draft = searchParams.get('draft') === 'true'\n const depth = searchParams.get('depth')\n\n const doc = await createOperation({\n autosave,\n collection,\n data: req.data,\n depth: isNumber(depth) ? depth : undefined,\n draft,\n req,\n })\n\n return Response.json(\n {\n doc,\n message: req.t('general:successfullyCreated', {\n label: getTranslation(collection.config.labels.singular, req.i18n),\n }),\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.CREATED,\n },\n )\n}\n"],"names":["getTranslation","httpStatus","createOperation","isNumber","headersWithCors","create","collection","req","searchParams","autosave","get","draft","depth","doc","data","undefined","Response","json","message","t","label","config","labels","singular","i18n","headers","Headers","status","CREATED"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,gBAAgB,cAAa;AACpC,SAASC,eAAe,QAAQ,qBAAoB;AACpD,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,SAAiC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACtE,MAAM,EAAEC,YAAY,EAAE,GAAGD;IACzB,MAAME,WAAWD,aAAaE,GAAG,CAAC,gBAAgB;IAClD,MAAMC,QAAQH,aAAaE,GAAG,CAAC,aAAa;IAC5C,MAAME,QAAQJ,aAAaE,GAAG,CAAC;IAE/B,MAAMG,MAAM,MAAMX,gBAAgB;QAChCO;QACAH;QACAQ,MAAMP,IAAIO,IAAI;QACdF,OAAOT,SAASS,SAASA,QAAQG;QACjCJ;QACAJ;IACF;IAEA,OAAOS,SAASC,IAAI,CAClB;QACEJ;QACAK,SAASX,IAAIY,CAAC,CAAC,+BAA+B;YAC5CC,OAAOpB,eAAeM,WAAWe,MAAM,CAACC,MAAM,CAACC,QAAQ,EAAEhB,IAAIiB,IAAI;QACnE;IACF,GACA;QACEC,SAASrB,gBAAgB;YACvBqB,SAAS,IAAIC;YACbnB;QACF;QACAoB,QAAQ1B,WAAW2B,OAAO;IAC5B;AAEJ,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/delete.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAEzD,eAAO,MAAM,SAAS,EAAE,sBAkDvB,CAAA"}
1
+ {"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/delete.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,SAAS,EAAE,sBAyDvB,CAAA"}
@@ -2,6 +2,7 @@ import { getTranslation } from '@payloadcms/translations';
2
2
  import httpStatus from 'http-status';
3
3
  import { deleteOperation } from 'payload/operations';
4
4
  import { isNumber } from 'payload/utilities';
5
+ import { headersWithCors } from '../../../utilities/headersWithCors.js';
5
6
  export const deleteDoc = async ({ collection, req })=>{
6
7
  const { depth, where } = req.query;
7
8
  const result = await deleteOperation({
@@ -10,6 +11,10 @@ export const deleteDoc = async ({ collection, req })=>{
10
11
  req,
11
12
  where
12
13
  });
14
+ const headers = headersWithCors({
15
+ headers: new Headers(),
16
+ req
17
+ });
13
18
  if (result.errors.length === 0) {
14
19
  const message = req.t('general:deletedCountSuccessfully', {
15
20
  count: result.docs.length,
@@ -19,6 +24,7 @@ export const deleteDoc = async ({ collection, req })=>{
19
24
  ...result,
20
25
  message
21
26
  }, {
27
+ headers,
22
28
  status: httpStatus.OK
23
29
  });
24
30
  }
@@ -32,6 +38,7 @@ export const deleteDoc = async ({ collection, req })=>{
32
38
  ...result,
33
39
  message
34
40
  }, {
41
+ headers,
35
42
  status: httpStatus.BAD_REQUEST
36
43
  });
37
44
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/routes/rest/collections/delete.ts"],"sourcesContent":["import type { Where } from 'payload/types'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport httpStatus from 'http-status'\nimport { deleteOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nexport const deleteDoc: CollectionRouteHandler = async ({ collection, req }) => {\n const { depth, where } = req.query as {\n depth?: string\n where?: Where\n }\n\n const result = await deleteOperation({\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n req,\n where,\n })\n\n if (result.errors.length === 0) {\n const message = req.t('general:deletedCountSuccessfully', {\n count: result.docs.length,\n label: getTranslation(\n collection.config.labels[result.docs.length > 1 ? 'plural' : 'singular'],\n req.i18n,\n ),\n })\n\n return Response.json(\n {\n ...result,\n message,\n },\n {\n status: httpStatus.OK,\n },\n )\n }\n\n const total = result.docs.length + result.errors.length\n\n const message = req.t('error:unableToDeleteCount', {\n count: result.errors.length,\n label: getTranslation(collection.config.labels[total > 1 ? 'plural' : 'singular'], req.i18n),\n total,\n })\n\n return Response.json(\n {\n ...result,\n message,\n },\n {\n status: httpStatus.BAD_REQUEST,\n },\n )\n}\n"],"names":["getTranslation","httpStatus","deleteOperation","isNumber","deleteDoc","collection","req","depth","where","query","result","Number","undefined","errors","length","message","t","count","docs","label","config","labels","i18n","Response","json","status","OK","total","BAD_REQUEST"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,gBAAgB,cAAa;AACpC,SAASC,eAAe,QAAQ,qBAAoB;AACpD,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,OAAO,MAAMC,YAAoC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACzE,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGF,IAAIG,KAAK;IAKlC,MAAMC,SAAS,MAAMR,gBAAgB;QACnCG;QACAE,OAAOJ,SAASI,SAASI,OAAOJ,SAASK;QACzCN;QACAE;IACF;IAEA,IAAIE,OAAOG,MAAM,CAACC,MAAM,KAAK,GAAG;QAC9B,MAAMC,UAAUT,IAAIU,CAAC,CAAC,oCAAoC;YACxDC,OAAOP,OAAOQ,IAAI,CAACJ,MAAM;YACzBK,OAAOnB,eACLK,WAAWe,MAAM,CAACC,MAAM,CAACX,OAAOQ,IAAI,CAACJ,MAAM,GAAG,IAAI,WAAW,WAAW,EACxER,IAAIgB,IAAI;QAEZ;QAEA,OAAOC,SAASC,IAAI,CAClB;YACE,GAAGd,MAAM;YACTK;QACF,GACA;YACEU,QAAQxB,WAAWyB,EAAE;QACvB;IAEJ;IAEA,MAAMC,QAAQjB,OAAOQ,IAAI,CAACJ,MAAM,GAAGJ,OAAOG,MAAM,CAACC,MAAM;IAEvD,MAAMC,UAAUT,IAAIU,CAAC,CAAC,6BAA6B;QACjDC,OAAOP,OAAOG,MAAM,CAACC,MAAM;QAC3BK,OAAOnB,eAAeK,WAAWe,MAAM,CAACC,MAAM,CAACM,QAAQ,IAAI,WAAW,WAAW,EAAErB,IAAIgB,IAAI;QAC3FK;IACF;IAEA,OAAOJ,SAASC,IAAI,CAClB;QACE,GAAGd,MAAM;QACTK;IACF,GACA;QACEU,QAAQxB,WAAW2B,WAAW;IAChC;AAEJ,EAAC"}
1
+ {"version":3,"sources":["../../../../src/routes/rest/collections/delete.ts"],"sourcesContent":["import type { Where } from 'payload/types'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport httpStatus from 'http-status'\nimport { deleteOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const deleteDoc: CollectionRouteHandler = async ({ collection, req }) => {\n const { depth, where } = req.query as {\n depth?: string\n where?: Where\n }\n\n const result = await deleteOperation({\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n req,\n where,\n })\n\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n if (result.errors.length === 0) {\n const message = req.t('general:deletedCountSuccessfully', {\n count: result.docs.length,\n label: getTranslation(\n collection.config.labels[result.docs.length > 1 ? 'plural' : 'singular'],\n req.i18n,\n ),\n })\n\n return Response.json(\n {\n ...result,\n message,\n },\n {\n headers,\n status: httpStatus.OK,\n },\n )\n }\n\n const total = result.docs.length + result.errors.length\n\n const message = req.t('error:unableToDeleteCount', {\n count: result.errors.length,\n label: getTranslation(collection.config.labels[total > 1 ? 'plural' : 'singular'], req.i18n),\n total,\n })\n\n return Response.json(\n {\n ...result,\n message,\n },\n {\n headers,\n status: httpStatus.BAD_REQUEST,\n },\n )\n}\n"],"names":["getTranslation","httpStatus","deleteOperation","isNumber","headersWithCors","deleteDoc","collection","req","depth","where","query","result","Number","undefined","headers","Headers","errors","length","message","t","count","docs","label","config","labels","i18n","Response","json","status","OK","total","BAD_REQUEST"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,gBAAgB,cAAa;AACpC,SAASC,eAAe,QAAQ,qBAAoB;AACpD,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,YAAoC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACzE,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGF,IAAIG,KAAK;IAKlC,MAAMC,SAAS,MAAMT,gBAAgB;QACnCI;QACAE,OAAOL,SAASK,SAASI,OAAOJ,SAASK;QACzCN;QACAE;IACF;IAEA,MAAMK,UAAUV,gBAAgB;QAC9BU,SAAS,IAAIC;QACbR;IACF;IAEA,IAAII,OAAOK,MAAM,CAACC,MAAM,KAAK,GAAG;QAC9B,MAAMC,UAAUX,IAAIY,CAAC,CAAC,oCAAoC;YACxDC,OAAOT,OAAOU,IAAI,CAACJ,MAAM;YACzBK,OAAOtB,eACLM,WAAWiB,MAAM,CAACC,MAAM,CAACb,OAAOU,IAAI,CAACJ,MAAM,GAAG,IAAI,WAAW,WAAW,EACxEV,IAAIkB,IAAI;QAEZ;QAEA,OAAOC,SAASC,IAAI,CAClB;YACE,GAAGhB,MAAM;YACTO;QACF,GACA;YACEJ;YACAc,QAAQ3B,WAAW4B,EAAE;QACvB;IAEJ;IAEA,MAAMC,QAAQnB,OAAOU,IAAI,CAACJ,MAAM,GAAGN,OAAOK,MAAM,CAACC,MAAM;IAEvD,MAAMC,UAAUX,IAAIY,CAAC,CAAC,6BAA6B;QACjDC,OAAOT,OAAOK,MAAM,CAACC,MAAM;QAC3BK,OAAOtB,eAAeM,WAAWiB,MAAM,CAACC,MAAM,CAACM,QAAQ,IAAI,WAAW,WAAW,EAAEvB,IAAIkB,IAAI;QAC3FK;IACF;IAEA,OAAOJ,SAASC,IAAI,CAClB;QACE,GAAGhB,MAAM;QACTO;IACF,GACA;QACEJ;QACAc,QAAQ3B,WAAW8B,WAAW;IAChC;AAEJ,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"deleteByID.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/deleteByID.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAI/D,eAAO,MAAM,UAAU,EAAE,4BAyCxB,CAAA"}
1
+ {"version":3,"file":"deleteByID.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/deleteByID.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAK/D,eAAO,MAAM,UAAU,EAAE,4BAgDxB,CAAA"}
@@ -1,6 +1,7 @@
1
1
  import httpStatus from 'http-status';
2
2
  import { deleteByIDOperation } from 'payload/operations';
3
3
  import { isNumber } from 'payload/utilities';
4
+ import { headersWithCors } from '../../../utilities/headersWithCors.js';
4
5
  import { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js';
5
6
  export const deleteByID = async ({ id: incomingID, collection, req })=>{
6
7
  const { searchParams } = req;
@@ -16,10 +17,15 @@ export const deleteByID = async ({ id: incomingID, collection, req })=>{
16
17
  depth: isNumber(depth) ? depth : undefined,
17
18
  req
18
19
  });
20
+ const headers = headersWithCors({
21
+ headers: new Headers(),
22
+ req
23
+ });
19
24
  if (!doc) {
20
25
  return Response.json({
21
26
  message: req.t('general:notFound')
22
27
  }, {
28
+ headers,
23
29
  status: httpStatus.NOT_FOUND
24
30
  });
25
31
  }
@@ -27,6 +33,7 @@ export const deleteByID = async ({ id: incomingID, collection, req })=>{
27
33
  doc,
28
34
  message: req.t('general:deletedSuccessfully')
29
35
  }, {
36
+ headers,
30
37
  status: httpStatus.OK
31
38
  });
32
39
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/routes/rest/collections/deleteByID.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { deleteByIDOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nimport { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js'\n\nexport const deleteByID: CollectionRouteHandlerWithID = async ({\n id: incomingID,\n collection,\n req,\n}) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n\n const id = sanitizeCollectionID({\n id: incomingID,\n collectionSlug: collection.config.slug,\n payload: req.payload,\n })\n\n const doc = await deleteByIDOperation({\n id,\n collection,\n depth: isNumber(depth) ? depth : undefined,\n req,\n })\n\n if (!doc) {\n return Response.json(\n {\n message: req.t('general:notFound'),\n },\n {\n status: httpStatus.NOT_FOUND,\n },\n )\n }\n\n return Response.json(\n {\n doc,\n message: req.t('general:deletedSuccessfully'),\n },\n {\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","deleteByIDOperation","isNumber","sanitizeCollectionID","deleteByID","id","incomingID","collection","req","searchParams","depth","get","collectionSlug","config","slug","payload","doc","undefined","Response","json","message","t","status","NOT_FOUND","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,mBAAmB,QAAQ,qBAAoB;AACxD,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,SAASC,oBAAoB,QAAQ,uCAAsC;AAE3E,OAAO,MAAMC,aAA2C,OAAO,EAC7DC,IAAIC,UAAU,EACdC,UAAU,EACVC,GAAG,EACJ;IACC,MAAM,EAAEC,YAAY,EAAE,GAAGD;IACzB,MAAME,QAAQD,aAAaE,GAAG,CAAC;IAE/B,MAAMN,KAAKF,qBAAqB;QAC9BE,IAAIC;QACJM,gBAAgBL,WAAWM,MAAM,CAACC,IAAI;QACtCC,SAASP,IAAIO,OAAO;IACtB;IAEA,MAAMC,MAAM,MAAMf,oBAAoB;QACpCI;QACAE;QACAG,OAAOR,SAASQ,SAASA,QAAQO;QACjCT;IACF;IAEA,IAAI,CAACQ,KAAK;QACR,OAAOE,SAASC,IAAI,CAClB;YACEC,SAASZ,IAAIa,CAAC,CAAC;QACjB,GACA;YACEC,QAAQtB,WAAWuB,SAAS;QAC9B;IAEJ;IAEA,OAAOL,SAASC,IAAI,CAClB;QACEH;QACAI,SAASZ,IAAIa,CAAC,CAAC;IACjB,GACA;QACEC,QAAQtB,WAAWwB,EAAE;IACvB;AAEJ,EAAC"}
1
+ {"version":3,"sources":["../../../../src/routes/rest/collections/deleteByID.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { deleteByIDOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js'\n\nexport const deleteByID: CollectionRouteHandlerWithID = async ({\n id: incomingID,\n collection,\n req,\n}) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n\n const id = sanitizeCollectionID({\n id: incomingID,\n collectionSlug: collection.config.slug,\n payload: req.payload,\n })\n\n const doc = await deleteByIDOperation({\n id,\n collection,\n depth: isNumber(depth) ? depth : undefined,\n req,\n })\n\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n if (!doc) {\n return Response.json(\n {\n message: req.t('general:notFound'),\n },\n {\n headers,\n status: httpStatus.NOT_FOUND,\n },\n )\n }\n\n return Response.json(\n {\n doc,\n message: req.t('general:deletedSuccessfully'),\n },\n {\n headers,\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","deleteByIDOperation","isNumber","headersWithCors","sanitizeCollectionID","deleteByID","id","incomingID","collection","req","searchParams","depth","get","collectionSlug","config","slug","payload","doc","undefined","headers","Headers","Response","json","message","t","status","NOT_FOUND","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,mBAAmB,QAAQ,qBAAoB;AACxD,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,oBAAoB,QAAQ,uCAAsC;AAE3E,OAAO,MAAMC,aAA2C,OAAO,EAC7DC,IAAIC,UAAU,EACdC,UAAU,EACVC,GAAG,EACJ;IACC,MAAM,EAAEC,YAAY,EAAE,GAAGD;IACzB,MAAME,QAAQD,aAAaE,GAAG,CAAC;IAE/B,MAAMN,KAAKF,qBAAqB;QAC9BE,IAAIC;QACJM,gBAAgBL,WAAWM,MAAM,CAACC,IAAI;QACtCC,SAASP,IAAIO,OAAO;IACtB;IAEA,MAAMC,MAAM,MAAMhB,oBAAoB;QACpCK;QACAE;QACAG,OAAOT,SAASS,SAASA,QAAQO;QACjCT;IACF;IAEA,MAAMU,UAAUhB,gBAAgB;QAC9BgB,SAAS,IAAIC;QACbX;IACF;IAEA,IAAI,CAACQ,KAAK;QACR,OAAOI,SAASC,IAAI,CAClB;YACEC,SAASd,IAAIe,CAAC,CAAC;QACjB,GACA;YACEL;YACAM,QAAQzB,WAAW0B,SAAS;QAC9B;IAEJ;IAEA,OAAOL,SAASC,IAAI,CAClB;QACEL;QACAM,SAASd,IAAIe,CAAC,CAAC;IACjB,GACA;QACEL;QACAM,QAAQzB,WAAW2B,EAAE;IACvB;AAEJ,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"docAccess.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/docAccess.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAE/D,eAAO,MAAM,SAAS,EAAE,4BAUvB,CAAA"}
1
+ {"version":3,"file":"docAccess.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/docAccess.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAI/D,eAAO,MAAM,SAAS,EAAE,4BAcvB,CAAA"}
@@ -1,5 +1,6 @@
1
1
  import httpStatus from 'http-status';
2
2
  import { docAccessOperation } from 'payload/operations';
3
+ import { headersWithCors } from '../../../utilities/headersWithCors.js';
3
4
  export const docAccess = async ({ id, collection, req })=>{
4
5
  const result = await docAccessOperation({
5
6
  id,
@@ -7,6 +8,10 @@ export const docAccess = async ({ id, collection, req })=>{
7
8
  req
8
9
  });
9
10
  return Response.json(result, {
11
+ headers: headersWithCors({
12
+ headers: new Headers(),
13
+ req
14
+ }),
10
15
  status: httpStatus.OK
11
16
  });
12
17
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/routes/rest/collections/docAccess.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { docAccessOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nexport const docAccess: CollectionRouteHandlerWithID = async ({ id, collection, req }) => {\n const result = await docAccessOperation({\n id,\n collection,\n req,\n })\n\n return Response.json(result, {\n status: httpStatus.OK,\n })\n}\n"],"names":["httpStatus","docAccessOperation","docAccess","id","collection","req","result","Response","json","status","OK"],"rangeMappings":";;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,kBAAkB,QAAQ,qBAAoB;AAIvD,OAAO,MAAMC,YAA0C,OAAO,EAAEC,EAAE,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACnF,MAAMC,SAAS,MAAML,mBAAmB;QACtCE;QACAC;QACAC;IACF;IAEA,OAAOE,SAASC,IAAI,CAACF,QAAQ;QAC3BG,QAAQT,WAAWU,EAAE;IACvB;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/routes/rest/collections/docAccess.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { docAccessOperation } from 'payload/operations'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const docAccess: CollectionRouteHandlerWithID = async ({ id, collection, req }) => {\n const result = await docAccessOperation({\n id,\n collection,\n req,\n })\n\n return Response.json(result, {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n })\n}\n"],"names":["httpStatus","docAccessOperation","headersWithCors","docAccess","id","collection","req","result","Response","json","headers","Headers","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,kBAAkB,QAAQ,qBAAoB;AAIvD,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,YAA0C,OAAO,EAAEC,EAAE,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACnF,MAAMC,SAAS,MAAMN,mBAAmB;QACtCG;QACAC;QACAC;IACF;IAEA,OAAOE,SAASC,IAAI,CAACF,QAAQ;QAC3BG,SAASR,gBAAgB;YACvBQ,SAAS,IAAIC;YACbL;QACF;QACAM,QAAQZ,WAAWa,EAAE;IACvB;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"duplicate.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/duplicate.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAI/D,eAAO,MAAM,SAAS,EAAE,4BAqCvB,CAAA"}
1
+ {"version":3,"file":"duplicate.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/duplicate.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAK/D,eAAO,MAAM,SAAS,EAAE,4BAyCvB,CAAA"}
@@ -2,6 +2,7 @@ import { getTranslation } from '@payloadcms/translations';
2
2
  import httpStatus from 'http-status';
3
3
  import { duplicateOperation } from 'payload/operations';
4
4
  import { isNumber } from 'payload/utilities';
5
+ import { headersWithCors } from '../../../utilities/headersWithCors.js';
5
6
  import { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js';
6
7
  export const duplicate = async ({ id: incomingID, collection, req })=>{
7
8
  const { searchParams } = req;
@@ -27,6 +28,10 @@ export const duplicate = async ({ id: incomingID, collection, req })=>{
27
28
  doc,
28
29
  message
29
30
  }, {
31
+ headers: headersWithCors({
32
+ headers: new Headers(),
33
+ req
34
+ }),
30
35
  status: httpStatus.OK
31
36
  });
32
37
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/routes/rest/collections/duplicate.ts"],"sourcesContent":["import { getTranslation } from '@payloadcms/translations'\nimport httpStatus from 'http-status'\nimport { duplicateOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nimport { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js'\n\nexport const duplicate: CollectionRouteHandlerWithID = async ({\n id: incomingID,\n collection,\n req,\n}) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n // draft defaults to true, unless explicitly set requested as false to prevent the newly duplicated document from being published\n const draft = searchParams.get('draft') !== 'false'\n\n const id = sanitizeCollectionID({\n id: incomingID,\n collectionSlug: collection.config.slug,\n payload: req.payload,\n })\n\n const doc = await duplicateOperation({\n id,\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft,\n req,\n })\n\n const message = req.t('general:successfullyDuplicated', {\n label: getTranslation(collection.config.labels.singular, req.i18n),\n })\n\n return Response.json(\n {\n doc,\n message,\n },\n {\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["getTranslation","httpStatus","duplicateOperation","isNumber","sanitizeCollectionID","duplicate","id","incomingID","collection","req","searchParams","depth","get","draft","collectionSlug","config","slug","payload","doc","Number","undefined","message","t","label","labels","singular","i18n","Response","json","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,gBAAgB,cAAa;AACpC,SAASC,kBAAkB,QAAQ,qBAAoB;AACvD,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,SAASC,oBAAoB,QAAQ,uCAAsC;AAE3E,OAAO,MAAMC,YAA0C,OAAO,EAC5DC,IAAIC,UAAU,EACdC,UAAU,EACVC,GAAG,EACJ;IACC,MAAM,EAAEC,YAAY,EAAE,GAAGD;IACzB,MAAME,QAAQD,aAAaE,GAAG,CAAC;IAC/B,iIAAiI;IACjI,MAAMC,QAAQH,aAAaE,GAAG,CAAC,aAAa;IAE5C,MAAMN,KAAKF,qBAAqB;QAC9BE,IAAIC;QACJO,gBAAgBN,WAAWO,MAAM,CAACC,IAAI;QACtCC,SAASR,IAAIQ,OAAO;IACtB;IAEA,MAAMC,MAAM,MAAMhB,mBAAmB;QACnCI;QACAE;QACAG,OAAOR,SAASQ,SAASQ,OAAOR,SAASS;QACzCP;QACAJ;IACF;IAEA,MAAMY,UAAUZ,IAAIa,CAAC,CAAC,kCAAkC;QACtDC,OAAOvB,eAAeQ,WAAWO,MAAM,CAACS,MAAM,CAACC,QAAQ,EAAEhB,IAAIiB,IAAI;IACnE;IAEA,OAAOC,SAASC,IAAI,CAClB;QACEV;QACAG;IACF,GACA;QACEQ,QAAQ5B,WAAW6B,EAAE;IACvB;AAEJ,EAAC"}
1
+ {"version":3,"sources":["../../../../src/routes/rest/collections/duplicate.ts"],"sourcesContent":["import { getTranslation } from '@payloadcms/translations'\nimport httpStatus from 'http-status'\nimport { duplicateOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js'\n\nexport const duplicate: CollectionRouteHandlerWithID = async ({\n id: incomingID,\n collection,\n req,\n}) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n // draft defaults to true, unless explicitly set requested as false to prevent the newly duplicated document from being published\n const draft = searchParams.get('draft') !== 'false'\n\n const id = sanitizeCollectionID({\n id: incomingID,\n collectionSlug: collection.config.slug,\n payload: req.payload,\n })\n\n const doc = await duplicateOperation({\n id,\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft,\n req,\n })\n\n const message = req.t('general:successfullyDuplicated', {\n label: getTranslation(collection.config.labels.singular, req.i18n),\n })\n\n return Response.json(\n {\n doc,\n message,\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["getTranslation","httpStatus","duplicateOperation","isNumber","headersWithCors","sanitizeCollectionID","duplicate","id","incomingID","collection","req","searchParams","depth","get","draft","collectionSlug","config","slug","payload","doc","Number","undefined","message","t","label","labels","singular","i18n","Response","json","headers","Headers","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,gBAAgB,cAAa;AACpC,SAASC,kBAAkB,QAAQ,qBAAoB;AACvD,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,oBAAoB,QAAQ,uCAAsC;AAE3E,OAAO,MAAMC,YAA0C,OAAO,EAC5DC,IAAIC,UAAU,EACdC,UAAU,EACVC,GAAG,EACJ;IACC,MAAM,EAAEC,YAAY,EAAE,GAAGD;IACzB,MAAME,QAAQD,aAAaE,GAAG,CAAC;IAC/B,iIAAiI;IACjI,MAAMC,QAAQH,aAAaE,GAAG,CAAC,aAAa;IAE5C,MAAMN,KAAKF,qBAAqB;QAC9BE,IAAIC;QACJO,gBAAgBN,WAAWO,MAAM,CAACC,IAAI;QACtCC,SAASR,IAAIQ,OAAO;IACtB;IAEA,MAAMC,MAAM,MAAMjB,mBAAmB;QACnCK;QACAE;QACAG,OAAOT,SAASS,SAASQ,OAAOR,SAASS;QACzCP;QACAJ;IACF;IAEA,MAAMY,UAAUZ,IAAIa,CAAC,CAAC,kCAAkC;QACtDC,OAAOxB,eAAeS,WAAWO,MAAM,CAACS,MAAM,CAACC,QAAQ,EAAEhB,IAAIiB,IAAI;IACnE;IAEA,OAAOC,SAASC,IAAI,CAClB;QACEV;QACAG;IACF,GACA;QACEQ,SAAS1B,gBAAgB;YACvB0B,SAAS,IAAIC;YACbrB;QACF;QACAsB,QAAQ/B,WAAWgC,EAAE;IACvB;AAEJ,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/find.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAEzD,eAAO,MAAM,IAAI,EAAE,sBAwBlB,CAAA"}
1
+ {"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/find.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,IAAI,EAAE,sBA4BlB,CAAA"}
@@ -1,6 +1,7 @@
1
1
  import httpStatus from 'http-status';
2
2
  import { findOperation } from 'payload/operations';
3
3
  import { isNumber } from 'payload/utilities';
4
+ import { headersWithCors } from '../../../utilities/headersWithCors.js';
4
5
  export const find = async ({ collection, req })=>{
5
6
  const { depth, draft, limit, page, sort, where } = req.query;
6
7
  const result = await findOperation({
@@ -14,6 +15,10 @@ export const find = async ({ collection, req })=>{
14
15
  where
15
16
  });
16
17
  return Response.json(result, {
18
+ headers: headersWithCors({
19
+ headers: new Headers(),
20
+ req
21
+ }),
17
22
  status: httpStatus.OK
18
23
  });
19
24
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/routes/rest/collections/find.ts"],"sourcesContent":["import type { Where } from 'payload/types'\n\nimport httpStatus from 'http-status'\nimport { findOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nexport const find: CollectionRouteHandler = async ({ collection, req }) => {\n const { depth, draft, limit, page, sort, where } = req.query as {\n depth?: string\n draft?: string\n limit?: string\n page?: string\n sort?: string\n where?: Where\n }\n\n const result = await findOperation({\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft: draft === 'true',\n limit: isNumber(limit) ? Number(limit) : undefined,\n page: isNumber(page) ? Number(page) : undefined,\n req,\n sort,\n where,\n })\n\n return Response.json(result, {\n status: httpStatus.OK,\n })\n}\n"],"names":["httpStatus","findOperation","isNumber","find","collection","req","depth","draft","limit","page","sort","where","query","result","Number","undefined","Response","json","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;","mappings":"AAEA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,OAAO,MAAMC,OAA+B,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACpE,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAEC,KAAK,EAAEC,IAAI,EAAEC,IAAI,EAAEC,KAAK,EAAE,GAAGN,IAAIO,KAAK;IAS5D,MAAMC,SAAS,MAAMZ,cAAc;QACjCG;QACAE,OAAOJ,SAASI,SAASQ,OAAOR,SAASS;QACzCR,OAAOA,UAAU;QACjBC,OAAON,SAASM,SAASM,OAAON,SAASO;QACzCN,MAAMP,SAASO,QAAQK,OAAOL,QAAQM;QACtCV;QACAK;QACAC;IACF;IAEA,OAAOK,SAASC,IAAI,CAACJ,QAAQ;QAC3BK,QAAQlB,WAAWmB,EAAE;IACvB;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/routes/rest/collections/find.ts"],"sourcesContent":["import type { Where } from 'payload/types'\n\nimport httpStatus from 'http-status'\nimport { findOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const find: CollectionRouteHandler = async ({ collection, req }) => {\n const { depth, draft, limit, page, sort, where } = req.query as {\n depth?: string\n draft?: string\n limit?: string\n page?: string\n sort?: string\n where?: Where\n }\n\n const result = await findOperation({\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft: draft === 'true',\n limit: isNumber(limit) ? Number(limit) : undefined,\n page: isNumber(page) ? Number(page) : undefined,\n req,\n sort,\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"],"names":["httpStatus","findOperation","isNumber","headersWithCors","find","collection","req","depth","draft","limit","page","sort","where","query","result","Number","undefined","Response","json","headers","Headers","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,OAA+B,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACpE,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAEC,KAAK,EAAEC,IAAI,EAAEC,IAAI,EAAEC,KAAK,EAAE,GAAGN,IAAIO,KAAK;IAS5D,MAAMC,SAAS,MAAMb,cAAc;QACjCI;QACAE,OAAOL,SAASK,SAASQ,OAAOR,SAASS;QACzCR,OAAOA,UAAU;QACjBC,OAAOP,SAASO,SAASM,OAAON,SAASO;QACzCN,MAAMR,SAASQ,QAAQK,OAAOL,QAAQM;QACtCV;QACAK;QACAC;IACF;IAEA,OAAOK,SAASC,IAAI,CAACJ,QAAQ;QAC3BK,SAAShB,gBAAgB;YACvBgB,SAAS,IAAIC;YACbd;QACF;QACAe,QAAQrB,WAAWsB,EAAE;IACvB;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"findByID.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/findByID.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAI/D,eAAO,MAAM,QAAQ,EAAE,4BAyBtB,CAAA"}
1
+ {"version":3,"file":"findByID.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/findByID.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAK/D,eAAO,MAAM,QAAQ,EAAE,4BA6BtB,CAAA"}
@@ -1,6 +1,7 @@
1
1
  import httpStatus from 'http-status';
2
2
  import { findByIDOperation } from 'payload/operations';
3
3
  import { isNumber } from 'payload/utilities';
4
+ import { headersWithCors } from '../../../utilities/headersWithCors.js';
4
5
  import { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js';
5
6
  export const findByID = async ({ id: incomingID, collection, req })=>{
6
7
  const { searchParams } = req;
@@ -18,6 +19,10 @@ export const findByID = async ({ id: incomingID, collection, req })=>{
18
19
  req
19
20
  });
20
21
  return Response.json(result, {
22
+ headers: headersWithCors({
23
+ headers: new Headers(),
24
+ req
25
+ }),
21
26
  status: httpStatus.OK
22
27
  });
23
28
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/routes/rest/collections/findByID.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { findByIDOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nimport { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js'\n\nexport const findByID: CollectionRouteHandlerWithID = async ({\n id: incomingID,\n collection,\n req,\n}) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n\n const id = sanitizeCollectionID({\n id: incomingID,\n collectionSlug: collection.config.slug,\n payload: req.payload,\n })\n\n const result = await findByIDOperation({\n id,\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft: searchParams.get('draft') === 'true',\n req,\n })\n\n return Response.json(result, {\n status: httpStatus.OK,\n })\n}\n"],"names":["httpStatus","findByIDOperation","isNumber","sanitizeCollectionID","findByID","id","incomingID","collection","req","searchParams","depth","get","collectionSlug","config","slug","payload","result","Number","undefined","draft","Response","json","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,iBAAiB,QAAQ,qBAAoB;AACtD,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,SAASC,oBAAoB,QAAQ,uCAAsC;AAE3E,OAAO,MAAMC,WAAyC,OAAO,EAC3DC,IAAIC,UAAU,EACdC,UAAU,EACVC,GAAG,EACJ;IACC,MAAM,EAAEC,YAAY,EAAE,GAAGD;IACzB,MAAME,QAAQD,aAAaE,GAAG,CAAC;IAE/B,MAAMN,KAAKF,qBAAqB;QAC9BE,IAAIC;QACJM,gBAAgBL,WAAWM,MAAM,CAACC,IAAI;QACtCC,SAASP,IAAIO,OAAO;IACtB;IAEA,MAAMC,SAAS,MAAMf,kBAAkB;QACrCI;QACAE;QACAG,OAAOR,SAASQ,SAASO,OAAOP,SAASQ;QACzCC,OAAOV,aAAaE,GAAG,CAAC,aAAa;QACrCH;IACF;IAEA,OAAOY,SAASC,IAAI,CAACL,QAAQ;QAC3BM,QAAQtB,WAAWuB,EAAE;IACvB;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/routes/rest/collections/findByID.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { findByIDOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js'\n\nexport const findByID: CollectionRouteHandlerWithID = async ({\n id: incomingID,\n collection,\n req,\n}) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n\n const id = sanitizeCollectionID({\n id: incomingID,\n collectionSlug: collection.config.slug,\n payload: req.payload,\n })\n\n const result = await findByIDOperation({\n id,\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft: searchParams.get('draft') === 'true',\n req,\n })\n\n return Response.json(result, {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n })\n}\n"],"names":["httpStatus","findByIDOperation","isNumber","headersWithCors","sanitizeCollectionID","findByID","id","incomingID","collection","req","searchParams","depth","get","collectionSlug","config","slug","payload","result","Number","undefined","draft","Response","json","headers","Headers","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,iBAAiB,QAAQ,qBAAoB;AACtD,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,oBAAoB,QAAQ,uCAAsC;AAE3E,OAAO,MAAMC,WAAyC,OAAO,EAC3DC,IAAIC,UAAU,EACdC,UAAU,EACVC,GAAG,EACJ;IACC,MAAM,EAAEC,YAAY,EAAE,GAAGD;IACzB,MAAME,QAAQD,aAAaE,GAAG,CAAC;IAE/B,MAAMN,KAAKF,qBAAqB;QAC9BE,IAAIC;QACJM,gBAAgBL,WAAWM,MAAM,CAACC,IAAI;QACtCC,SAASP,IAAIO,OAAO;IACtB;IAEA,MAAMC,SAAS,MAAMhB,kBAAkB;QACrCK;QACAE;QACAG,OAAOT,SAASS,SAASO,OAAOP,SAASQ;QACzCC,OAAOV,aAAaE,GAAG,CAAC,aAAa;QACrCH;IACF;IAEA,OAAOY,SAASC,IAAI,CAACL,QAAQ;QAC3BM,SAASpB,gBAAgB;YACvBoB,SAAS,IAAIC;YACbf;QACF;QACAgB,QAAQzB,WAAW0B,EAAE;IACvB;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"findVersionByID.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/findVersionByID.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAI/D,eAAO,MAAM,eAAe,EAAE,4BAwB7B,CAAA"}
1
+ {"version":3,"file":"findVersionByID.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/findVersionByID.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAK/D,eAAO,MAAM,eAAe,EAAE,4BA4B7B,CAAA"}
@@ -1,6 +1,7 @@
1
1
  import httpStatus from 'http-status';
2
2
  import { findVersionByIDOperation } from 'payload/operations';
3
3
  import { isNumber } from 'payload/utilities';
4
+ import { headersWithCors } from '../../../utilities/headersWithCors.js';
4
5
  import { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js';
5
6
  export const findVersionByID = async ({ id: incomingID, collection, req })=>{
6
7
  const { searchParams } = req;
@@ -17,6 +18,10 @@ export const findVersionByID = async ({ id: incomingID, collection, req })=>{
17
18
  req
18
19
  });
19
20
  return Response.json(result, {
21
+ headers: headersWithCors({
22
+ headers: new Headers(),
23
+ req
24
+ }),
20
25
  status: httpStatus.OK
21
26
  });
22
27
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/routes/rest/collections/findVersionByID.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { findVersionByIDOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nimport { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js'\n\nexport const findVersionByID: CollectionRouteHandlerWithID = async ({\n id: incomingID,\n collection,\n req,\n}) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n\n const id = sanitizeCollectionID({\n id: incomingID,\n collectionSlug: collection.config.slug,\n payload: req.payload,\n })\n\n const result = await findVersionByIDOperation({\n id,\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n req,\n })\n\n return Response.json(result, {\n status: httpStatus.OK,\n })\n}\n"],"names":["httpStatus","findVersionByIDOperation","isNumber","sanitizeCollectionID","findVersionByID","id","incomingID","collection","req","searchParams","depth","get","collectionSlug","config","slug","payload","result","Number","undefined","Response","json","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,wBAAwB,QAAQ,qBAAoB;AAC7D,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,SAASC,oBAAoB,QAAQ,uCAAsC;AAE3E,OAAO,MAAMC,kBAAgD,OAAO,EAClEC,IAAIC,UAAU,EACdC,UAAU,EACVC,GAAG,EACJ;IACC,MAAM,EAAEC,YAAY,EAAE,GAAGD;IACzB,MAAME,QAAQD,aAAaE,GAAG,CAAC;IAE/B,MAAMN,KAAKF,qBAAqB;QAC9BE,IAAIC;QACJM,gBAAgBL,WAAWM,MAAM,CAACC,IAAI;QACtCC,SAASP,IAAIO,OAAO;IACtB;IAEA,MAAMC,SAAS,MAAMf,yBAAyB;QAC5CI;QACAE;QACAG,OAAOR,SAASQ,SAASO,OAAOP,SAASQ;QACzCV;IACF;IAEA,OAAOW,SAASC,IAAI,CAACJ,QAAQ;QAC3BK,QAAQrB,WAAWsB,EAAE;IACvB;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/routes/rest/collections/findVersionByID.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { findVersionByIDOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js'\n\nexport const findVersionByID: CollectionRouteHandlerWithID = async ({\n id: incomingID,\n collection,\n req,\n}) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n\n const id = sanitizeCollectionID({\n id: incomingID,\n collectionSlug: collection.config.slug,\n payload: req.payload,\n })\n\n const result = await findVersionByIDOperation({\n id,\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n req,\n })\n\n return Response.json(result, {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n })\n}\n"],"names":["httpStatus","findVersionByIDOperation","isNumber","headersWithCors","sanitizeCollectionID","findVersionByID","id","incomingID","collection","req","searchParams","depth","get","collectionSlug","config","slug","payload","result","Number","undefined","Response","json","headers","Headers","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,wBAAwB,QAAQ,qBAAoB;AAC7D,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,oBAAoB,QAAQ,uCAAsC;AAE3E,OAAO,MAAMC,kBAAgD,OAAO,EAClEC,IAAIC,UAAU,EACdC,UAAU,EACVC,GAAG,EACJ;IACC,MAAM,EAAEC,YAAY,EAAE,GAAGD;IACzB,MAAME,QAAQD,aAAaE,GAAG,CAAC;IAE/B,MAAMN,KAAKF,qBAAqB;QAC9BE,IAAIC;QACJM,gBAAgBL,WAAWM,MAAM,CAACC,IAAI;QACtCC,SAASP,IAAIO,OAAO;IACtB;IAEA,MAAMC,SAAS,MAAMhB,yBAAyB;QAC5CK;QACAE;QACAG,OAAOT,SAASS,SAASO,OAAOP,SAASQ;QACzCV;IACF;IAEA,OAAOW,SAASC,IAAI,CAACJ,QAAQ;QAC3BK,SAASnB,gBAAgB;YACvBmB,SAAS,IAAIC;YACbd;QACF;QACAe,QAAQxB,WAAWyB,EAAE;IACvB;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"findVersions.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/findVersions.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAEzD,eAAO,MAAM,YAAY,EAAE,sBAsB1B,CAAA"}
1
+ {"version":3,"file":"findVersions.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/findVersions.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,YAAY,EAAE,sBA0B1B,CAAA"}
@@ -1,6 +1,7 @@
1
1
  import httpStatus from 'http-status';
2
2
  import { findVersionsOperation } from 'payload/operations';
3
3
  import { isNumber } from 'payload/utilities';
4
+ import { headersWithCors } from '../../../utilities/headersWithCors.js';
4
5
  export const findVersions = async ({ collection, req })=>{
5
6
  const { depth, limit, page, sort, where } = req.query;
6
7
  const result = await findVersionsOperation({
@@ -13,6 +14,10 @@ export const findVersions = async ({ collection, req })=>{
13
14
  where
14
15
  });
15
16
  return Response.json(result, {
17
+ headers: headersWithCors({
18
+ headers: new Headers(),
19
+ req
20
+ }),
16
21
  status: httpStatus.OK
17
22
  });
18
23
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/routes/rest/collections/findVersions.ts"],"sourcesContent":["import type { Where } from 'payload/types'\n\nimport httpStatus from 'http-status'\nimport { findVersionsOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nexport const findVersions: CollectionRouteHandler = async ({ collection, req }) => {\n const { depth, limit, page, sort, where } = req.query as {\n depth?: string\n limit?: string\n page?: string\n sort?: string\n where?: Where\n }\n\n const result = await findVersionsOperation({\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n limit: isNumber(limit) ? Number(limit) : undefined,\n page: isNumber(page) ? Number(page) : undefined,\n req,\n sort,\n where,\n })\n\n return Response.json(result, {\n status: httpStatus.OK,\n })\n}\n"],"names":["httpStatus","findVersionsOperation","isNumber","findVersions","collection","req","depth","limit","page","sort","where","query","result","Number","undefined","Response","json","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;","mappings":"AAEA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,qBAAqB,QAAQ,qBAAoB;AAC1D,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,OAAO,MAAMC,eAAuC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IAC5E,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAEC,IAAI,EAAEC,IAAI,EAAEC,KAAK,EAAE,GAAGL,IAAIM,KAAK;IAQrD,MAAMC,SAAS,MAAMX,sBAAsB;QACzCG;QACAE,OAAOJ,SAASI,SAASO,OAAOP,SAASQ;QACzCP,OAAOL,SAASK,SAASM,OAAON,SAASO;QACzCN,MAAMN,SAASM,QAAQK,OAAOL,QAAQM;QACtCT;QACAI;QACAC;IACF;IAEA,OAAOK,SAASC,IAAI,CAACJ,QAAQ;QAC3BK,QAAQjB,WAAWkB,EAAE;IACvB;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/routes/rest/collections/findVersions.ts"],"sourcesContent":["import type { Where } from 'payload/types'\n\nimport httpStatus from 'http-status'\nimport { findVersionsOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const findVersions: CollectionRouteHandler = async ({ collection, req }) => {\n const { depth, limit, page, sort, where } = req.query as {\n depth?: string\n limit?: string\n page?: string\n sort?: string\n where?: Where\n }\n\n const result = await findVersionsOperation({\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n limit: isNumber(limit) ? Number(limit) : undefined,\n page: isNumber(page) ? Number(page) : undefined,\n req,\n sort,\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"],"names":["httpStatus","findVersionsOperation","isNumber","headersWithCors","findVersions","collection","req","depth","limit","page","sort","where","query","result","Number","undefined","Response","json","headers","Headers","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,qBAAqB,QAAQ,qBAAoB;AAC1D,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,eAAuC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IAC5E,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAEC,IAAI,EAAEC,IAAI,EAAEC,KAAK,EAAE,GAAGL,IAAIM,KAAK;IAQrD,MAAMC,SAAS,MAAMZ,sBAAsB;QACzCI;QACAE,OAAOL,SAASK,SAASO,OAAOP,SAASQ;QACzCP,OAAON,SAASM,SAASM,OAAON,SAASO;QACzCN,MAAMP,SAASO,QAAQK,OAAOL,QAAQM;QACtCT;QACAI;QACAC;IACF;IAEA,OAAOK,SAASC,IAAI,CAACJ,QAAQ;QAC3BK,SAASf,gBAAgB;YACvBe,SAAS,IAAIC;YACbb;QACF;QACAc,QAAQpB,WAAWqB,EAAE;IACvB;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/preview.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAI/D,eAAO,MAAM,OAAO,EAAE,4BAuCrB,CAAA"}
1
+ {"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/preview.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAK/D,eAAO,MAAM,OAAO,EAAE,4BA4CrB,CAAA"}
@@ -2,6 +2,7 @@ import httpStatus from 'http-status';
2
2
  import { extractJWT } from 'payload/auth';
3
3
  import { findByIDOperation } from 'payload/operations';
4
4
  import { isNumber } from 'payload/utilities';
5
+ import { headersWithCors } from '../../../utilities/headersWithCors.js';
5
6
  import { routeError } from '../routeError.js';
6
7
  export const preview = async ({ id, collection, req })=>{
7
8
  const { searchParams } = req;
@@ -24,14 +25,19 @@ export const preview = async ({ id, collection, req })=>{
24
25
  token
25
26
  });
26
27
  } catch (err) {
27
- routeError({
28
+ return routeError({
28
29
  collection,
30
+ config: req.payload.config,
29
31
  err,
30
32
  req
31
33
  });
32
34
  }
33
35
  }
34
36
  return Response.json(previewURL, {
37
+ headers: headersWithCors({
38
+ headers: new Headers(),
39
+ req
40
+ }),
35
41
  status: httpStatus.OK
36
42
  });
37
43
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/routes/rest/collections/preview.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { extractJWT } from 'payload/auth'\nimport { findByIDOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nimport { routeError } from '../routeError.js'\n\nexport const preview: CollectionRouteHandlerWithID = async ({ id, collection, req }) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n\n const result = await findByIDOperation({\n id,\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft: searchParams.get('draft') === 'true',\n req,\n })\n\n let previewURL: string\n\n const generatePreviewURL = req.payload.config.collections.find(\n (config) => config.slug === collection.config.slug,\n )?.admin?.preview\n\n const token = extractJWT(req)\n\n if (typeof generatePreviewURL === 'function') {\n try {\n previewURL = await generatePreviewURL(result, {\n locale: req.locale,\n req,\n token,\n })\n } catch (err) {\n routeError({\n collection,\n err,\n req,\n })\n }\n }\n\n return Response.json(previewURL, {\n status: httpStatus.OK,\n })\n}\n"],"names":["httpStatus","extractJWT","findByIDOperation","isNumber","routeError","preview","id","collection","req","searchParams","depth","get","result","Number","undefined","draft","previewURL","generatePreviewURL","payload","config","collections","find","slug","admin","token","locale","err","Response","json","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,UAAU,QAAQ,eAAc;AACzC,SAASC,iBAAiB,QAAQ,qBAAoB;AACtD,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,SAASC,UAAU,QAAQ,mBAAkB;AAE7C,OAAO,MAAMC,UAAwC,OAAO,EAAEC,EAAE,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACjF,MAAM,EAAEC,YAAY,EAAE,GAAGD;IACzB,MAAME,QAAQD,aAAaE,GAAG,CAAC;IAE/B,MAAMC,SAAS,MAAMV,kBAAkB;QACrCI;QACAC;QACAG,OAAOP,SAASO,SAASG,OAAOH,SAASI;QACzCC,OAAON,aAAaE,GAAG,CAAC,aAAa;QACrCH;IACF;IAEA,IAAIQ;IAEJ,MAAMC,qBAAqBT,IAAIU,OAAO,CAACC,MAAM,CAACC,WAAW,CAACC,IAAI,CAC5D,CAACF,SAAWA,OAAOG,IAAI,KAAKf,WAAWY,MAAM,CAACG,IAAI,GACjDC,OAAOlB;IAEV,MAAMmB,QAAQvB,WAAWO;IAEzB,IAAI,OAAOS,uBAAuB,YAAY;QAC5C,IAAI;YACFD,aAAa,MAAMC,mBAAmBL,QAAQ;gBAC5Ca,QAAQjB,IAAIiB,MAAM;gBAClBjB;gBACAgB;YACF;QACF,EAAE,OAAOE,KAAK;YACZtB,WAAW;gBACTG;gBACAmB;gBACAlB;YACF;QACF;IACF;IAEA,OAAOmB,SAASC,IAAI,CAACZ,YAAY;QAC/Ba,QAAQ7B,WAAW8B,EAAE;IACvB;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/routes/rest/collections/preview.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { extractJWT } from 'payload/auth'\nimport { findByIDOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { routeError } from '../routeError.js'\n\nexport const preview: CollectionRouteHandlerWithID = async ({ id, collection, req }) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n\n const result = await findByIDOperation({\n id,\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft: searchParams.get('draft') === 'true',\n req,\n })\n\n let previewURL: string\n\n const generatePreviewURL = req.payload.config.collections.find(\n (config) => config.slug === collection.config.slug,\n )?.admin?.preview\n\n const token = extractJWT(req)\n\n if (typeof generatePreviewURL === 'function') {\n try {\n previewURL = await generatePreviewURL(result, {\n locale: req.locale,\n req,\n token,\n })\n } catch (err) {\n return routeError({\n collection,\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"],"names":["httpStatus","extractJWT","findByIDOperation","isNumber","headersWithCors","routeError","preview","id","collection","req","searchParams","depth","get","result","Number","undefined","draft","previewURL","generatePreviewURL","payload","config","collections","find","slug","admin","token","locale","err","Response","json","headers","Headers","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,UAAU,QAAQ,eAAc;AACzC,SAASC,iBAAiB,QAAQ,qBAAoB;AACtD,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,UAAU,QAAQ,mBAAkB;AAE7C,OAAO,MAAMC,UAAwC,OAAO,EAAEC,EAAE,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACjF,MAAM,EAAEC,YAAY,EAAE,GAAGD;IACzB,MAAME,QAAQD,aAAaE,GAAG,CAAC;IAE/B,MAAMC,SAAS,MAAMX,kBAAkB;QACrCK;QACAC;QACAG,OAAOR,SAASQ,SAASG,OAAOH,SAASI;QACzCC,OAAON,aAAaE,GAAG,CAAC,aAAa;QACrCH;IACF;IAEA,IAAIQ;IAEJ,MAAMC,qBAAqBT,IAAIU,OAAO,CAACC,MAAM,CAACC,WAAW,CAACC,IAAI,CAC5D,CAACF,SAAWA,OAAOG,IAAI,KAAKf,WAAWY,MAAM,CAACG,IAAI,GACjDC,OAAOlB;IAEV,MAAMmB,QAAQxB,WAAWQ;IAEzB,IAAI,OAAOS,uBAAuB,YAAY;QAC5C,IAAI;YACFD,aAAa,MAAMC,mBAAmBL,QAAQ;gBAC5Ca,QAAQjB,IAAIiB,MAAM;gBAClBjB;gBACAgB;YACF;QACF,EAAE,OAAOE,KAAK;YACZ,OAAOtB,WAAW;gBAChBG;gBACAY,QAAQX,IAAIU,OAAO,CAACC,MAAM;gBAC1BO;gBACAlB;YACF;QACF;IACF;IAEA,OAAOmB,SAASC,IAAI,CAACZ,YAAY;QAC/Ba,SAAS1B,gBAAgB;YACvB0B,SAAS,IAAIC;YACbtB;QACF;QACAuB,QAAQhC,WAAWiC,EAAE;IACvB;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"restoreVersion.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/restoreVersion.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAI/D,eAAO,MAAM,cAAc,EAAE,4BA8B5B,CAAA"}
1
+ {"version":3,"file":"restoreVersion.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/restoreVersion.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAK/D,eAAO,MAAM,cAAc,EAAE,4BAkC5B,CAAA"}
@@ -1,6 +1,7 @@
1
1
  import httpStatus from 'http-status';
2
2
  import { restoreVersionOperation } from 'payload/operations';
3
3
  import { isNumber } from 'payload/utilities';
4
+ import { headersWithCors } from '../../../utilities/headersWithCors.js';
4
5
  import { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js';
5
6
  export const restoreVersion = async ({ id: incomingID, collection, req })=>{
6
7
  const { searchParams } = req;
@@ -20,6 +21,10 @@ export const restoreVersion = async ({ id: incomingID, collection, req })=>{
20
21
  ...result,
21
22
  message: req.t('version:restoredSuccessfully')
22
23
  }, {
24
+ headers: headersWithCors({
25
+ headers: new Headers(),
26
+ req
27
+ }),
23
28
  status: httpStatus.OK
24
29
  });
25
30
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/routes/rest/collections/restoreVersion.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { restoreVersionOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nimport { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js'\n\nexport const restoreVersion: CollectionRouteHandlerWithID = async ({\n id: incomingID,\n collection,\n req,\n}) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n\n const id = sanitizeCollectionID({\n id: incomingID,\n collectionSlug: collection.config.slug,\n payload: req.payload,\n })\n\n const result = await restoreVersionOperation({\n id,\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n req,\n })\n\n return Response.json(\n {\n ...result,\n message: req.t('version:restoredSuccessfully'),\n },\n {\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","restoreVersionOperation","isNumber","sanitizeCollectionID","restoreVersion","id","incomingID","collection","req","searchParams","depth","get","collectionSlug","config","slug","payload","result","Number","undefined","Response","json","message","t","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,uBAAuB,QAAQ,qBAAoB;AAC5D,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,SAASC,oBAAoB,QAAQ,uCAAsC;AAE3E,OAAO,MAAMC,iBAA+C,OAAO,EACjEC,IAAIC,UAAU,EACdC,UAAU,EACVC,GAAG,EACJ;IACC,MAAM,EAAEC,YAAY,EAAE,GAAGD;IACzB,MAAME,QAAQD,aAAaE,GAAG,CAAC;IAE/B,MAAMN,KAAKF,qBAAqB;QAC9BE,IAAIC;QACJM,gBAAgBL,WAAWM,MAAM,CAACC,IAAI;QACtCC,SAASP,IAAIO,OAAO;IACtB;IAEA,MAAMC,SAAS,MAAMf,wBAAwB;QAC3CI;QACAE;QACAG,OAAOR,SAASQ,SAASO,OAAOP,SAASQ;QACzCV;IACF;IAEA,OAAOW,SAASC,IAAI,CAClB;QACE,GAAGJ,MAAM;QACTK,SAASb,IAAIc,CAAC,CAAC;IACjB,GACA;QACEC,QAAQvB,WAAWwB,EAAE;IACvB;AAEJ,EAAC"}
1
+ {"version":3,"sources":["../../../../src/routes/rest/collections/restoreVersion.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { restoreVersionOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js'\n\nexport const restoreVersion: CollectionRouteHandlerWithID = async ({\n id: incomingID,\n collection,\n req,\n}) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n\n const id = sanitizeCollectionID({\n id: incomingID,\n collectionSlug: collection.config.slug,\n payload: req.payload,\n })\n\n const result = await restoreVersionOperation({\n id,\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n req,\n })\n\n return Response.json(\n {\n ...result,\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"],"names":["httpStatus","restoreVersionOperation","isNumber","headersWithCors","sanitizeCollectionID","restoreVersion","id","incomingID","collection","req","searchParams","depth","get","collectionSlug","config","slug","payload","result","Number","undefined","Response","json","message","t","headers","Headers","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,uBAAuB,QAAQ,qBAAoB;AAC5D,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,oBAAoB,QAAQ,uCAAsC;AAE3E,OAAO,MAAMC,iBAA+C,OAAO,EACjEC,IAAIC,UAAU,EACdC,UAAU,EACVC,GAAG,EACJ;IACC,MAAM,EAAEC,YAAY,EAAE,GAAGD;IACzB,MAAME,QAAQD,aAAaE,GAAG,CAAC;IAE/B,MAAMN,KAAKF,qBAAqB;QAC9BE,IAAIC;QACJM,gBAAgBL,WAAWM,MAAM,CAACC,IAAI;QACtCC,SAASP,IAAIO,OAAO;IACtB;IAEA,MAAMC,SAAS,MAAMhB,wBAAwB;QAC3CK;QACAE;QACAG,OAAOT,SAASS,SAASO,OAAOP,SAASQ;QACzCV;IACF;IAEA,OAAOW,SAASC,IAAI,CAClB;QACE,GAAGJ,MAAM;QACTK,SAASb,IAAIc,CAAC,CAAC;IACjB,GACA;QACEC,SAASrB,gBAAgB;YACvBqB,SAAS,IAAIC;YACbhB;QACF;QACAiB,QAAQ1B,WAAW2B,EAAE;IACvB;AAEJ,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/update.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAEzD,eAAO,MAAM,MAAM,EAAE,sBAoDpB,CAAA"}
1
+ {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/update.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,MAAM,EAAE,sBA2DpB,CAAA"}
@@ -2,6 +2,7 @@ import { getTranslation } from '@payloadcms/translations';
2
2
  import httpStatus from 'http-status';
3
3
  import { updateOperation } from 'payload/operations';
4
4
  import { isNumber } from 'payload/utilities';
5
+ import { headersWithCors } from '../../../utilities/headersWithCors.js';
5
6
  export const update = async ({ collection, req })=>{
6
7
  const { depth, draft, where } = req.query;
7
8
  const result = await updateOperation({
@@ -12,6 +13,10 @@ export const update = async ({ collection, req })=>{
12
13
  req,
13
14
  where
14
15
  });
16
+ const headers = headersWithCors({
17
+ headers: new Headers(),
18
+ req
19
+ });
15
20
  if (result.errors.length === 0) {
16
21
  const message = req.t('general:updatedCountSuccessfully', {
17
22
  count: result.docs.length,
@@ -21,6 +26,7 @@ export const update = async ({ collection, req })=>{
21
26
  ...result,
22
27
  message
23
28
  }, {
29
+ headers,
24
30
  status: httpStatus.OK
25
31
  });
26
32
  }
@@ -34,6 +40,7 @@ export const update = async ({ collection, req })=>{
34
40
  ...result,
35
41
  message
36
42
  }, {
43
+ headers,
37
44
  status: httpStatus.BAD_REQUEST
38
45
  });
39
46
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/routes/rest/collections/update.ts"],"sourcesContent":["import type { Where } from 'payload/types'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport httpStatus from 'http-status'\nimport { updateOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nexport const update: CollectionRouteHandler = async ({ collection, req }) => {\n const { depth, draft, where } = req.query as {\n depth?: string\n draft?: string\n where?: Where\n }\n\n const result = await updateOperation({\n collection,\n data: req.data,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft: draft === 'true',\n req,\n where,\n })\n\n if (result.errors.length === 0) {\n const message = req.t('general:updatedCountSuccessfully', {\n count: result.docs.length,\n label: getTranslation(\n collection.config.labels[result.docs.length > 1 ? 'plural' : 'singular'],\n req.i18n,\n ),\n })\n\n return Response.json(\n {\n ...result,\n message,\n },\n {\n status: httpStatus.OK,\n },\n )\n }\n\n const total = result.docs.length + result.errors.length\n const message = req.t('error:unableToUpdateCount', {\n count: result.errors.length,\n label: getTranslation(collection.config.labels[total > 1 ? 'plural' : 'singular'], req.i18n),\n total,\n })\n\n return Response.json(\n {\n ...result,\n message,\n },\n {\n status: httpStatus.BAD_REQUEST,\n },\n )\n}\n"],"names":["getTranslation","httpStatus","updateOperation","isNumber","update","collection","req","depth","draft","where","query","result","data","Number","undefined","errors","length","message","t","count","docs","label","config","labels","i18n","Response","json","status","OK","total","BAD_REQUEST"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,gBAAgB,cAAa;AACpC,SAASC,eAAe,QAAQ,qBAAoB;AACpD,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,OAAO,MAAMC,SAAiC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACtE,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGH,IAAII,KAAK;IAMzC,MAAMC,SAAS,MAAMT,gBAAgB;QACnCG;QACAO,MAAMN,IAAIM,IAAI;QACdL,OAAOJ,SAASI,SAASM,OAAON,SAASO;QACzCN,OAAOA,UAAU;QACjBF;QACAG;IACF;IAEA,IAAIE,OAAOI,MAAM,CAACC,MAAM,KAAK,GAAG;QAC9B,MAAMC,UAAUX,IAAIY,CAAC,CAAC,oCAAoC;YACxDC,OAAOR,OAAOS,IAAI,CAACJ,MAAM;YACzBK,OAAOrB,eACLK,WAAWiB,MAAM,CAACC,MAAM,CAACZ,OAAOS,IAAI,CAACJ,MAAM,GAAG,IAAI,WAAW,WAAW,EACxEV,IAAIkB,IAAI;QAEZ;QAEA,OAAOC,SAASC,IAAI,CAClB;YACE,GAAGf,MAAM;YACTM;QACF,GACA;YACEU,QAAQ1B,WAAW2B,EAAE;QACvB;IAEJ;IAEA,MAAMC,QAAQlB,OAAOS,IAAI,CAACJ,MAAM,GAAGL,OAAOI,MAAM,CAACC,MAAM;IACvD,MAAMC,UAAUX,IAAIY,CAAC,CAAC,6BAA6B;QACjDC,OAAOR,OAAOI,MAAM,CAACC,MAAM;QAC3BK,OAAOrB,eAAeK,WAAWiB,MAAM,CAACC,MAAM,CAACM,QAAQ,IAAI,WAAW,WAAW,EAAEvB,IAAIkB,IAAI;QAC3FK;IACF;IAEA,OAAOJ,SAASC,IAAI,CAClB;QACE,GAAGf,MAAM;QACTM;IACF,GACA;QACEU,QAAQ1B,WAAW6B,WAAW;IAChC;AAEJ,EAAC"}
1
+ {"version":3,"sources":["../../../../src/routes/rest/collections/update.ts"],"sourcesContent":["import type { Where } from 'payload/types'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport httpStatus from 'http-status'\nimport { updateOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\n\nexport const update: CollectionRouteHandler = async ({ collection, req }) => {\n const { depth, draft, where } = req.query as {\n depth?: string\n draft?: string\n where?: Where\n }\n\n const result = await updateOperation({\n collection,\n data: req.data,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft: draft === 'true',\n req,\n where,\n })\n\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n if (result.errors.length === 0) {\n const message = req.t('general:updatedCountSuccessfully', {\n count: result.docs.length,\n label: getTranslation(\n collection.config.labels[result.docs.length > 1 ? 'plural' : 'singular'],\n req.i18n,\n ),\n })\n\n return Response.json(\n {\n ...result,\n message,\n },\n {\n headers,\n status: httpStatus.OK,\n },\n )\n }\n\n const total = result.docs.length + result.errors.length\n const message = req.t('error:unableToUpdateCount', {\n count: result.errors.length,\n label: getTranslation(collection.config.labels[total > 1 ? 'plural' : 'singular'], req.i18n),\n total,\n })\n\n return Response.json(\n {\n ...result,\n message,\n },\n {\n headers,\n status: httpStatus.BAD_REQUEST,\n },\n )\n}\n"],"names":["getTranslation","httpStatus","updateOperation","isNumber","headersWithCors","update","collection","req","depth","draft","where","query","result","data","Number","undefined","headers","Headers","errors","length","message","t","count","docs","label","config","labels","i18n","Response","json","status","OK","total","BAD_REQUEST"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,gBAAgB,cAAa;AACpC,SAASC,eAAe,QAAQ,qBAAoB;AACpD,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,SAASC,eAAe,QAAQ,wCAAuC;AAEvE,OAAO,MAAMC,SAAiC,OAAO,EAAEC,UAAU,EAAEC,GAAG,EAAE;IACtE,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGH,IAAII,KAAK;IAMzC,MAAMC,SAAS,MAAMV,gBAAgB;QACnCI;QACAO,MAAMN,IAAIM,IAAI;QACdL,OAAOL,SAASK,SAASM,OAAON,SAASO;QACzCN,OAAOA,UAAU;QACjBF;QACAG;IACF;IAEA,MAAMM,UAAUZ,gBAAgB;QAC9BY,SAAS,IAAIC;QACbV;IACF;IAEA,IAAIK,OAAOM,MAAM,CAACC,MAAM,KAAK,GAAG;QAC9B,MAAMC,UAAUb,IAAIc,CAAC,CAAC,oCAAoC;YACxDC,OAAOV,OAAOW,IAAI,CAACJ,MAAM;YACzBK,OAAOxB,eACLM,WAAWmB,MAAM,CAACC,MAAM,CAACd,OAAOW,IAAI,CAACJ,MAAM,GAAG,IAAI,WAAW,WAAW,EACxEZ,IAAIoB,IAAI;QAEZ;QAEA,OAAOC,SAASC,IAAI,CAClB;YACE,GAAGjB,MAAM;YACTQ;QACF,GACA;YACEJ;YACAc,QAAQ7B,WAAW8B,EAAE;QACvB;IAEJ;IAEA,MAAMC,QAAQpB,OAAOW,IAAI,CAACJ,MAAM,GAAGP,OAAOM,MAAM,CAACC,MAAM;IACvD,MAAMC,UAAUb,IAAIc,CAAC,CAAC,6BAA6B;QACjDC,OAAOV,OAAOM,MAAM,CAACC,MAAM;QAC3BK,OAAOxB,eAAeM,WAAWmB,MAAM,CAACC,MAAM,CAACM,QAAQ,IAAI,WAAW,WAAW,EAAEzB,IAAIoB,IAAI;QAC3FK;IACF;IAEA,OAAOJ,SAASC,IAAI,CAClB;QACE,GAAGjB,MAAM;QACTQ;IACF,GACA;QACEJ;QACAc,QAAQ7B,WAAWgC,WAAW;IAChC;AAEJ,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"updateByID.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/updateByID.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAI/D,eAAO,MAAM,UAAU,EAAE,4BAwCxB,CAAA"}
1
+ {"version":3,"file":"updateByID.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/updateByID.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAK/D,eAAO,MAAM,UAAU,EAAE,4BA4CxB,CAAA"}
@@ -1,6 +1,7 @@
1
1
  import httpStatus from 'http-status';
2
2
  import { updateByIDOperation } from 'payload/operations';
3
3
  import { isNumber } from 'payload/utilities';
4
+ import { headersWithCors } from '../../../utilities/headersWithCors.js';
4
5
  import { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js';
5
6
  export const updateByID = async ({ id: incomingID, collection, req })=>{
6
7
  const { searchParams } = req;
@@ -28,6 +29,10 @@ export const updateByID = async ({ id: incomingID, collection, req })=>{
28
29
  doc,
29
30
  message
30
31
  }, {
32
+ headers: headersWithCors({
33
+ headers: new Headers(),
34
+ req
35
+ }),
31
36
  status: httpStatus.OK
32
37
  });
33
38
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/routes/rest/collections/updateByID.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { updateByIDOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nimport { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js'\n\nexport const updateByID: CollectionRouteHandlerWithID = async ({\n id: incomingID,\n collection,\n req,\n}) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n const autosave = searchParams.get('autosave') === 'true'\n const draft = searchParams.get('draft') === 'true'\n\n const id = sanitizeCollectionID({\n id: incomingID,\n collectionSlug: collection.config.slug,\n payload: req.payload,\n })\n\n const doc = await updateByIDOperation({\n id,\n autosave,\n collection,\n data: req.data,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft,\n req,\n })\n\n let message = req.t('general:updatedSuccessfully')\n\n if (draft) message = req.t('version:draftSavedSuccessfully')\n if (autosave) message = req.t('version:autosavedSuccessfully')\n\n return Response.json(\n {\n doc,\n message,\n },\n {\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","updateByIDOperation","isNumber","sanitizeCollectionID","updateByID","id","incomingID","collection","req","searchParams","depth","get","autosave","draft","collectionSlug","config","slug","payload","doc","data","Number","undefined","message","t","Response","json","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,mBAAmB,QAAQ,qBAAoB;AACxD,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,SAASC,oBAAoB,QAAQ,uCAAsC;AAE3E,OAAO,MAAMC,aAA2C,OAAO,EAC7DC,IAAIC,UAAU,EACdC,UAAU,EACVC,GAAG,EACJ;IACC,MAAM,EAAEC,YAAY,EAAE,GAAGD;IACzB,MAAME,QAAQD,aAAaE,GAAG,CAAC;IAC/B,MAAMC,WAAWH,aAAaE,GAAG,CAAC,gBAAgB;IAClD,MAAME,QAAQJ,aAAaE,GAAG,CAAC,aAAa;IAE5C,MAAMN,KAAKF,qBAAqB;QAC9BE,IAAIC;QACJQ,gBAAgBP,WAAWQ,MAAM,CAACC,IAAI;QACtCC,SAAST,IAAIS,OAAO;IACtB;IAEA,MAAMC,MAAM,MAAMjB,oBAAoB;QACpCI;QACAO;QACAL;QACAY,MAAMX,IAAIW,IAAI;QACdT,OAAOR,SAASQ,SAASU,OAAOV,SAASW;QACzCR;QACAL;IACF;IAEA,IAAIc,UAAUd,IAAIe,CAAC,CAAC;IAEpB,IAAIV,OAAOS,UAAUd,IAAIe,CAAC,CAAC;IAC3B,IAAIX,UAAUU,UAAUd,IAAIe,CAAC,CAAC;IAE9B,OAAOC,SAASC,IAAI,CAClB;QACEP;QACAI;IACF,GACA;QACEI,QAAQ1B,WAAW2B,EAAE;IACvB;AAEJ,EAAC"}
1
+ {"version":3,"sources":["../../../../src/routes/rest/collections/updateByID.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { updateByIDOperation } from 'payload/operations'\nimport { isNumber } from 'payload/utilities'\n\nimport type { CollectionRouteHandlerWithID } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js'\n\nexport const updateByID: CollectionRouteHandlerWithID = async ({\n id: incomingID,\n collection,\n req,\n}) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n const autosave = searchParams.get('autosave') === 'true'\n const draft = searchParams.get('draft') === 'true'\n\n const id = sanitizeCollectionID({\n id: incomingID,\n collectionSlug: collection.config.slug,\n payload: req.payload,\n })\n\n const doc = await updateByIDOperation({\n id,\n autosave,\n collection,\n data: req.data,\n depth: isNumber(depth) ? Number(depth) : undefined,\n draft,\n req,\n })\n\n let message = req.t('general:updatedSuccessfully')\n\n if (draft) message = req.t('version:draftSavedSuccessfully')\n if (autosave) message = req.t('version:autosavedSuccessfully')\n\n return Response.json(\n {\n doc,\n message,\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","updateByIDOperation","isNumber","headersWithCors","sanitizeCollectionID","updateByID","id","incomingID","collection","req","searchParams","depth","get","autosave","draft","collectionSlug","config","slug","payload","doc","data","Number","undefined","message","t","Response","json","headers","Headers","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AACpC,SAASC,mBAAmB,QAAQ,qBAAoB;AACxD,SAASC,QAAQ,QAAQ,oBAAmB;AAI5C,SAASC,eAAe,QAAQ,wCAAuC;AACvE,SAASC,oBAAoB,QAAQ,uCAAsC;AAE3E,OAAO,MAAMC,aAA2C,OAAO,EAC7DC,IAAIC,UAAU,EACdC,UAAU,EACVC,GAAG,EACJ;IACC,MAAM,EAAEC,YAAY,EAAE,GAAGD;IACzB,MAAME,QAAQD,aAAaE,GAAG,CAAC;IAC/B,MAAMC,WAAWH,aAAaE,GAAG,CAAC,gBAAgB;IAClD,MAAME,QAAQJ,aAAaE,GAAG,CAAC,aAAa;IAE5C,MAAMN,KAAKF,qBAAqB;QAC9BE,IAAIC;QACJQ,gBAAgBP,WAAWQ,MAAM,CAACC,IAAI;QACtCC,SAAST,IAAIS,OAAO;IACtB;IAEA,MAAMC,MAAM,MAAMlB,oBAAoB;QACpCK;QACAO;QACAL;QACAY,MAAMX,IAAIW,IAAI;QACdT,OAAOT,SAASS,SAASU,OAAOV,SAASW;QACzCR;QACAL;IACF;IAEA,IAAIc,UAAUd,IAAIe,CAAC,CAAC;IAEpB,IAAIV,OAAOS,UAAUd,IAAIe,CAAC,CAAC;IAC3B,IAAIX,UAAUU,UAAUd,IAAIe,CAAC,CAAC;IAE9B,OAAOC,SAASC,IAAI,CAClB;QACEP;QACAI;IACF,GACA;QACEI,SAASxB,gBAAgB;YACvBwB,SAAS,IAAIC;YACbnB;QACF;QACAoB,QAAQ7B,WAAW8B,EAAE;IACvB;AAEJ,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"getFile.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/files/getFile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAY/D,KAAK,IAAI,GAAG;IACV,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,EAAE,MAAM,CAAA;IAChB,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AACD,eAAO,MAAM,OAAO,kCAAyC,IAAI,KAAG,QAAQ,QAAQ,CAuDnF,CAAA"}
1
+ {"version":3,"file":"getFile.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/files/getFile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAe/D,KAAK,IAAI,GAAG;IACV,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,EAAE,MAAM,CAAA;IAChB,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AACD,eAAO,MAAM,OAAO,kCAAyC,IAAI,KAAG,QAAQ,QAAQ,CA0DnF,CAAA"}