@payloadcms/next 3.4.1-canary.b6681a9 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/prod/styles.css +1 -1
- package/dist/routes/rest/collections/create.d.ts.map +1 -1
- package/dist/routes/rest/collections/create.js +3 -5
- package/dist/routes/rest/collections/create.js.map +1 -1
- package/dist/routes/rest/collections/delete.d.ts.map +1 -1
- package/dist/routes/rest/collections/delete.js +3 -5
- package/dist/routes/rest/collections/delete.js.map +1 -1
- package/dist/routes/rest/collections/deleteByID.d.ts.map +1 -1
- package/dist/routes/rest/collections/deleteByID.js +3 -5
- package/dist/routes/rest/collections/deleteByID.js.map +1 -1
- package/dist/routes/rest/collections/duplicate.d.ts.map +1 -1
- package/dist/routes/rest/collections/duplicate.js +3 -5
- package/dist/routes/rest/collections/duplicate.js.map +1 -1
- package/dist/routes/rest/collections/find.d.ts.map +1 -1
- package/dist/routes/rest/collections/find.js +3 -6
- package/dist/routes/rest/collections/find.js.map +1 -1
- package/dist/routes/rest/collections/findByID.d.ts.map +1 -1
- package/dist/routes/rest/collections/findByID.js +3 -6
- package/dist/routes/rest/collections/findByID.js.map +1 -1
- package/dist/routes/rest/collections/findVersionByID.d.ts.map +1 -1
- package/dist/routes/rest/collections/findVersionByID.js +3 -5
- package/dist/routes/rest/collections/findVersionByID.js.map +1 -1
- package/dist/routes/rest/collections/findVersions.d.ts.map +1 -1
- package/dist/routes/rest/collections/findVersions.js +3 -5
- package/dist/routes/rest/collections/findVersions.js.map +1 -1
- package/dist/routes/rest/collections/restoreVersion.d.ts.map +1 -1
- package/dist/routes/rest/collections/restoreVersion.js +2 -3
- package/dist/routes/rest/collections/restoreVersion.js.map +1 -1
- package/dist/routes/rest/collections/update.d.ts.map +1 -1
- package/dist/routes/rest/collections/update.js +3 -5
- package/dist/routes/rest/collections/update.js.map +1 -1
- package/dist/routes/rest/collections/updateByID.d.ts.map +1 -1
- package/dist/routes/rest/collections/updateByID.js +3 -5
- package/dist/routes/rest/collections/updateByID.js.map +1 -1
- package/dist/routes/rest/globals/findOne.d.ts.map +1 -1
- package/dist/routes/rest/globals/findOne.js +3 -5
- package/dist/routes/rest/globals/findOne.js.map +1 -1
- package/dist/routes/rest/globals/findVersionByID.d.ts.map +1 -1
- package/dist/routes/rest/globals/findVersionByID.js +3 -5
- package/dist/routes/rest/globals/findVersionByID.js.map +1 -1
- package/dist/routes/rest/globals/findVersions.d.ts.map +1 -1
- package/dist/routes/rest/globals/findVersions.js +3 -5
- package/dist/routes/rest/globals/findVersions.js.map +1 -1
- package/dist/routes/rest/globals/restoreVersion.d.ts.map +1 -1
- package/dist/routes/rest/globals/restoreVersion.js +2 -3
- package/dist/routes/rest/globals/restoreVersion.js.map +1 -1
- package/dist/routes/rest/globals/update.d.ts.map +1 -1
- package/dist/routes/rest/globals/update.js +3 -5
- package/dist/routes/rest/globals/update.js.map +1 -1
- package/package.json +10 -14
- package/dist/routes/rest/utilities/sanitizeJoinParams.d.ts +0 -13
- package/dist/routes/rest/utilities/sanitizeJoinParams.d.ts.map +0 -1
- package/dist/routes/rest/utilities/sanitizeJoinParams.js +0 -21
- package/dist/routes/rest/utilities/sanitizeJoinParams.js.map +0 -1
- package/dist/routes/rest/utilities/sanitizePopulate.d.ts +0 -3
- package/dist/routes/rest/utilities/sanitizePopulate.d.ts.map +0 -1
- package/dist/routes/rest/utilities/sanitizePopulate.js +0 -11
- package/dist/routes/rest/utilities/sanitizePopulate.js.map +0 -1
- package/dist/routes/rest/utilities/sanitizeSelect.d.ts +0 -6
- package/dist/routes/rest/utilities/sanitizeSelect.d.ts.map +0 -1
- package/dist/routes/rest/utilities/sanitizeSelect.js +0 -17
- package/dist/routes/rest/utilities/sanitizeSelect.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/create.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/create.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIzD,eAAO,MAAM,MAAM,EAAE,sBAgCpB,CAAA"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { getTranslation } from '@payloadcms/translations';
|
|
2
2
|
import httpStatus from 'http-status';
|
|
3
|
-
import { createOperation } from 'payload';
|
|
3
|
+
import { createOperation, sanitizePopulateParam, sanitizeSelectParam } from 'payload';
|
|
4
4
|
import { isNumber } from 'payload/shared';
|
|
5
5
|
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
6
|
-
import { sanitizePopulate } from '../utilities/sanitizePopulate.js';
|
|
7
|
-
import { sanitizeSelect } from '../utilities/sanitizeSelect.js';
|
|
8
6
|
export const create = async ({
|
|
9
7
|
collection,
|
|
10
8
|
req
|
|
@@ -21,9 +19,9 @@ export const create = async ({
|
|
|
21
19
|
data: req.data,
|
|
22
20
|
depth: isNumber(depth) ? depth : undefined,
|
|
23
21
|
draft,
|
|
24
|
-
populate:
|
|
22
|
+
populate: sanitizePopulateParam(req.query.populate),
|
|
25
23
|
req,
|
|
26
|
-
select:
|
|
24
|
+
select: sanitizeSelectParam(req.query.select)
|
|
27
25
|
});
|
|
28
26
|
return Response.json({
|
|
29
27
|
doc,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","names":["getTranslation","httpStatus","createOperation","
|
|
1
|
+
{"version":3,"file":"create.js","names":["getTranslation","httpStatus","createOperation","sanitizePopulateParam","sanitizeSelectParam","isNumber","headersWithCors","create","collection","req","searchParams","autosave","get","draft","depth","doc","data","undefined","populate","query","select","Response","json","message","t","label","config","labels","singular","i18n","headers","Headers","status","CREATED"],"sources":["../../../../src/routes/rest/collections/create.ts"],"sourcesContent":["import { getTranslation } from '@payloadcms/translations'\nimport httpStatus from 'http-status'\nimport { createOperation, sanitizePopulateParam, sanitizeSelectParam } from 'payload'\nimport { isNumber } from 'payload/shared'\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 populate: sanitizePopulateParam(req.query.populate),\n req,\n select: sanitizeSelectParam(req.query.select),\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"],"mappings":"AAAA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,UAAA,MAAgB;AACvB,SAASC,eAAe,EAAEC,qBAAqB,EAAEC,mBAAmB,QAAQ;AAC5E,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAEhC,OAAO,MAAMC,MAAA,GAAiC,MAAAA,CAAO;EAAEC,UAAU;EAAEC;AAAG,CAAE;EACtE,MAAM;IAAEC;EAAY,CAAE,GAAGD,GAAA;EACzB,MAAME,QAAA,GAAWD,YAAA,CAAaE,GAAG,CAAC,gBAAgB;EAClD,MAAMC,KAAA,GAAQH,YAAA,CAAaE,GAAG,CAAC,aAAa;EAC5C,MAAME,KAAA,GAAQJ,YAAA,CAAaE,GAAG,CAAC;EAE/B,MAAMG,GAAA,GAAM,MAAMb,eAAA,CAAgB;IAChCS,QAAA;IACAH,UAAA;IACAQ,IAAA,EAAMP,GAAA,CAAIO,IAAI;IACdF,KAAA,EAAOT,QAAA,CAASS,KAAA,IAASA,KAAA,GAAQG,SAAA;IACjCJ,KAAA;IACAK,QAAA,EAAUf,qBAAA,CAAsBM,GAAA,CAAIU,KAAK,CAACD,QAAQ;IAClDT,GAAA;IACAW,MAAA,EAAQhB,mBAAA,CAAoBK,GAAA,CAAIU,KAAK,CAACC,MAAM;EAC9C;EAEA,OAAOC,QAAA,CAASC,IAAI,CAClB;IACEP,GAAA;IACAQ,OAAA,EAASd,GAAA,CAAIe,CAAC,CAAC,+BAA+B;MAC5CC,KAAA,EAAOzB,cAAA,CAAeQ,UAAA,CAAWkB,MAAM,CAACC,MAAM,CAACC,QAAQ,EAAEnB,GAAA,CAAIoB,IAAI;IACnE;EACF,GACA;IACEC,OAAA,EAASxB,eAAA,CAAgB;MACvBwB,OAAA,EAAS,IAAIC,OAAA;MACbtB;IACF;IACAuB,MAAA,EAAQ/B,UAAA,CAAWgC;EACrB;AAEJ","ignoreList":[]}
|
|
@@ -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;
|
|
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,sBA+DvB,CAAA"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { getTranslation } from '@payloadcms/translations';
|
|
2
2
|
import httpStatus from 'http-status';
|
|
3
|
-
import { deleteOperation } from 'payload';
|
|
3
|
+
import { deleteOperation, sanitizePopulateParam, sanitizeSelectParam } from 'payload';
|
|
4
4
|
import { isNumber } from 'payload/shared';
|
|
5
5
|
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
6
|
-
import { sanitizePopulate } from '../utilities/sanitizePopulate.js';
|
|
7
|
-
import { sanitizeSelect } from '../utilities/sanitizeSelect.js';
|
|
8
6
|
export const deleteDoc = async ({
|
|
9
7
|
collection,
|
|
10
8
|
req
|
|
@@ -20,9 +18,9 @@ export const deleteDoc = async ({
|
|
|
20
18
|
collection,
|
|
21
19
|
depth: isNumber(depth) ? Number(depth) : undefined,
|
|
22
20
|
overrideLock: Boolean(overrideLock === 'true'),
|
|
23
|
-
populate:
|
|
21
|
+
populate: sanitizePopulateParam(populate),
|
|
24
22
|
req,
|
|
25
|
-
select:
|
|
23
|
+
select: sanitizeSelectParam(select),
|
|
26
24
|
where
|
|
27
25
|
});
|
|
28
26
|
const headers = headersWithCors({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete.js","names":["getTranslation","httpStatus","deleteOperation","
|
|
1
|
+
{"version":3,"file":"delete.js","names":["getTranslation","httpStatus","deleteOperation","sanitizePopulateParam","sanitizeSelectParam","isNumber","headersWithCors","deleteDoc","collection","req","depth","overrideLock","populate","select","where","query","result","Number","undefined","Boolean","headers","Headers","errors","length","message","t","count","docs","label","config","labels","i18n","Response","json","status","OK","total","BAD_REQUEST"],"sources":["../../../../src/routes/rest/collections/delete.ts"],"sourcesContent":["import type { Where } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport httpStatus from 'http-status'\nimport { deleteOperation, sanitizePopulateParam, sanitizeSelectParam } from 'payload'\nimport { isNumber } from 'payload/shared'\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, overrideLock, populate, select, where } = req.query as {\n depth?: string\n overrideLock?: string\n populate?: Record<string, unknown>\n select?: Record<string, unknown>\n where?: Where\n }\n\n const result = await deleteOperation({\n collection,\n depth: isNumber(depth) ? Number(depth) : undefined,\n overrideLock: Boolean(overrideLock === 'true'),\n populate: sanitizePopulateParam(populate),\n req,\n select: sanitizeSelectParam(select),\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"],"mappings":"AAEA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,UAAA,MAAgB;AACvB,SAASC,eAAe,EAAEC,qBAAqB,EAAEC,mBAAmB,QAAQ;AAC5E,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAEhC,OAAO,MAAMC,SAAA,GAAoC,MAAAA,CAAO;EAAEC,UAAU;EAAEC;AAAG,CAAE;EACzE,MAAM;IAAEC,KAAK;IAAEC,YAAY;IAAEC,QAAQ;IAAEC,MAAM;IAAEC;EAAK,CAAE,GAAGL,GAAA,CAAIM,KAAK;EAQlE,MAAMC,MAAA,GAAS,MAAMd,eAAA,CAAgB;IACnCM,UAAA;IACAE,KAAA,EAAOL,QAAA,CAASK,KAAA,IAASO,MAAA,CAAOP,KAAA,IAASQ,SAAA;IACzCP,YAAA,EAAcQ,OAAA,CAAQR,YAAA,KAAiB;IACvCC,QAAA,EAAUT,qBAAA,CAAsBS,QAAA;IAChCH,GAAA;IACAI,MAAA,EAAQT,mBAAA,CAAoBS,MAAA;IAC5BC;EACF;EAEA,MAAMM,OAAA,GAAUd,eAAA,CAAgB;IAC9Bc,OAAA,EAAS,IAAIC,OAAA;IACbZ;EACF;EAEA,IAAIO,MAAA,CAAOM,MAAM,CAACC,MAAM,KAAK,GAAG;IAC9B,MAAMC,OAAA,GAAUf,GAAA,CAAIgB,CAAC,CAAC,oCAAoC;MACxDC,KAAA,EAAOV,MAAA,CAAOW,IAAI,CAACJ,MAAM;MACzBK,KAAA,EAAO5B,cAAA,CACLQ,UAAA,CAAWqB,MAAM,CAACC,MAAM,CAACd,MAAA,CAAOW,IAAI,CAACJ,MAAM,GAAG,IAAI,WAAW,WAAW,EACxEd,GAAA,CAAIsB,IAAI;IAEZ;IAEA,OAAOC,QAAA,CAASC,IAAI,CAClB;MACE,GAAGjB,MAAM;MACTQ;IACF,GACA;MACEJ,OAAA;MACAc,MAAA,EAAQjC,UAAA,CAAWkC;IACrB;EAEJ;EAEA,MAAMC,KAAA,GAAQpB,MAAA,CAAOW,IAAI,CAACJ,MAAM,GAAGP,MAAA,CAAOM,MAAM,CAACC,MAAM;EAEvD,MAAMC,OAAA,GAAUf,GAAA,CAAIgB,CAAC,CAAC,6BAA6B;IACjDC,KAAA,EAAOV,MAAA,CAAOM,MAAM,CAACC,MAAM;IAC3BK,KAAA,EAAO5B,cAAA,CAAeQ,UAAA,CAAWqB,MAAM,CAACC,MAAM,CAACM,KAAA,GAAQ,IAAI,WAAW,WAAW,EAAE3B,GAAA,CAAIsB,IAAI;IAC3FK;EACF;EAEA,OAAOJ,QAAA,CAASC,IAAI,CAClB;IACE,GAAGjB,MAAM;IACTQ;EACF,GACA;IACEJ,OAAA;IACAc,MAAA,EAAQjC,UAAA,CAAWoC;EACrB;AAEJ","ignoreList":[]}
|
|
@@ -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;
|
|
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,4BAoDxB,CAAA"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import httpStatus from 'http-status';
|
|
2
|
-
import { deleteByIDOperation } from 'payload';
|
|
2
|
+
import { deleteByIDOperation, sanitizePopulateParam, sanitizeSelectParam } from 'payload';
|
|
3
3
|
import { isNumber } from 'payload/shared';
|
|
4
4
|
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
5
5
|
import { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js';
|
|
6
|
-
import { sanitizePopulate } from '../utilities/sanitizePopulate.js';
|
|
7
|
-
import { sanitizeSelect } from '../utilities/sanitizeSelect.js';
|
|
8
6
|
export const deleteByID = async ({
|
|
9
7
|
id: incomingID,
|
|
10
8
|
collection,
|
|
@@ -25,9 +23,9 @@ export const deleteByID = async ({
|
|
|
25
23
|
collection,
|
|
26
24
|
depth: isNumber(depth) ? depth : undefined,
|
|
27
25
|
overrideLock: Boolean(overrideLock === 'true'),
|
|
28
|
-
populate:
|
|
26
|
+
populate: sanitizePopulateParam(req.query.populate),
|
|
29
27
|
req,
|
|
30
|
-
select:
|
|
28
|
+
select: sanitizeSelectParam(req.query.select)
|
|
31
29
|
});
|
|
32
30
|
const headers = headersWithCors({
|
|
33
31
|
headers: new Headers(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deleteByID.js","names":["httpStatus","deleteByIDOperation","
|
|
1
|
+
{"version":3,"file":"deleteByID.js","names":["httpStatus","deleteByIDOperation","sanitizePopulateParam","sanitizeSelectParam","isNumber","headersWithCors","sanitizeCollectionID","deleteByID","id","incomingID","collection","req","searchParams","depth","get","overrideLock","collectionSlug","config","slug","payload","doc","undefined","Boolean","populate","query","select","headers","Headers","Response","json","message","t","status","NOT_FOUND","OK"],"sources":["../../../../src/routes/rest/collections/deleteByID.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { deleteByIDOperation, sanitizePopulateParam, sanitizeSelectParam } from 'payload'\nimport { isNumber } from 'payload/shared'\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 const overrideLock = searchParams.get('overrideLock')\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 overrideLock: Boolean(overrideLock === 'true'),\n populate: sanitizePopulateParam(req.query.populate),\n req,\n select: sanitizeSelectParam(req.query.select),\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"],"mappings":"AAAA,OAAOA,UAAA,MAAgB;AACvB,SAASC,mBAAmB,EAAEC,qBAAqB,EAAEC,mBAAmB,QAAQ;AAChF,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,oBAAoB,QAAQ;AAErC,OAAO,MAAMC,UAAA,GAA2C,MAAAA,CAAO;EAC7DC,EAAA,EAAIC,UAAU;EACdC,UAAU;EACVC;AAAG,CACJ;EACC,MAAM;IAAEC;EAAY,CAAE,GAAGD,GAAA;EACzB,MAAME,KAAA,GAAQD,YAAA,CAAaE,GAAG,CAAC;EAC/B,MAAMC,YAAA,GAAeH,YAAA,CAAaE,GAAG,CAAC;EAEtC,MAAMN,EAAA,GAAKF,oBAAA,CAAqB;IAC9BE,EAAA,EAAIC,UAAA;IACJO,cAAA,EAAgBN,UAAA,CAAWO,MAAM,CAACC,IAAI;IACtCC,OAAA,EAASR,GAAA,CAAIQ;EACf;EAEA,MAAMC,GAAA,GAAM,MAAMnB,mBAAA,CAAoB;IACpCO,EAAA;IACAE,UAAA;IACAG,KAAA,EAAOT,QAAA,CAASS,KAAA,IAASA,KAAA,GAAQQ,SAAA;IACjCN,YAAA,EAAcO,OAAA,CAAQP,YAAA,KAAiB;IACvCQ,QAAA,EAAUrB,qBAAA,CAAsBS,GAAA,CAAIa,KAAK,CAACD,QAAQ;IAClDZ,GAAA;IACAc,MAAA,EAAQtB,mBAAA,CAAoBQ,GAAA,CAAIa,KAAK,CAACC,MAAM;EAC9C;EAEA,MAAMC,OAAA,GAAUrB,eAAA,CAAgB;IAC9BqB,OAAA,EAAS,IAAIC,OAAA;IACbhB;EACF;EAEA,IAAI,CAACS,GAAA,EAAK;IACR,OAAOQ,QAAA,CAASC,IAAI,CAClB;MACEC,OAAA,EAASnB,GAAA,CAAIoB,CAAC,CAAC;IACjB,GACA;MACEL,OAAA;MACAM,MAAA,EAAQhC,UAAA,CAAWiC;IACrB;EAEJ;EAEA,OAAOL,QAAA,CAASC,IAAI,CAClB;IACET,GAAA;IACAU,OAAA,EAASnB,GAAA,CAAIoB,CAAC,CAAC;EACjB,GACA;IACEL,OAAA;IACAM,MAAA,EAAQhC,UAAA,CAAWkC;EACrB;AAEJ","ignoreList":[]}
|
|
@@ -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;
|
|
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,4BA2CvB,CAAA"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { getTranslation } from '@payloadcms/translations';
|
|
2
2
|
import httpStatus from 'http-status';
|
|
3
|
-
import { duplicateOperation } from 'payload';
|
|
3
|
+
import { duplicateOperation, sanitizePopulateParam, sanitizeSelectParam } from 'payload';
|
|
4
4
|
import { isNumber } from 'payload/shared';
|
|
5
5
|
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
6
6
|
import { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js';
|
|
7
|
-
import { sanitizePopulate } from '../utilities/sanitizePopulate.js';
|
|
8
|
-
import { sanitizeSelect } from '../utilities/sanitizeSelect.js';
|
|
9
7
|
export const duplicate = async ({
|
|
10
8
|
id: incomingID,
|
|
11
9
|
collection,
|
|
@@ -27,9 +25,9 @@ export const duplicate = async ({
|
|
|
27
25
|
collection,
|
|
28
26
|
depth: isNumber(depth) ? Number(depth) : undefined,
|
|
29
27
|
draft,
|
|
30
|
-
populate:
|
|
28
|
+
populate: sanitizePopulateParam(req.query.populate),
|
|
31
29
|
req,
|
|
32
|
-
select:
|
|
30
|
+
select: sanitizeSelectParam(req.query.select)
|
|
33
31
|
});
|
|
34
32
|
const message = req.t('general:successfullyDuplicated', {
|
|
35
33
|
label: getTranslation(collection.config.labels.singular, req.i18n)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"duplicate.js","names":["getTranslation","httpStatus","duplicateOperation","
|
|
1
|
+
{"version":3,"file":"duplicate.js","names":["getTranslation","httpStatus","duplicateOperation","sanitizePopulateParam","sanitizeSelectParam","isNumber","headersWithCors","sanitizeCollectionID","duplicate","id","incomingID","collection","req","searchParams","depth","get","draft","collectionSlug","config","slug","payload","doc","Number","undefined","populate","query","select","message","t","label","labels","singular","i18n","Response","json","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/collections/duplicate.ts"],"sourcesContent":["import { getTranslation } from '@payloadcms/translations'\nimport httpStatus from 'http-status'\nimport { duplicateOperation, sanitizePopulateParam, sanitizeSelectParam } from 'payload'\nimport { isNumber } from 'payload/shared'\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 populate: sanitizePopulateParam(req.query.populate),\n req,\n select: sanitizeSelectParam(req.query.select),\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"],"mappings":"AAAA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,UAAA,MAAgB;AACvB,SAASC,kBAAkB,EAAEC,qBAAqB,EAAEC,mBAAmB,QAAQ;AAC/E,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,oBAAoB,QAAQ;AAErC,OAAO,MAAMC,SAAA,GAA0C,MAAAA,CAAO;EAC5DC,EAAA,EAAIC,UAAU;EACdC,UAAU;EACVC;AAAG,CACJ;EACC,MAAM;IAAEC;EAAY,CAAE,GAAGD,GAAA;EACzB,MAAME,KAAA,GAAQD,YAAA,CAAaE,GAAG,CAAC;EAC/B;EACA,MAAMC,KAAA,GAAQH,YAAA,CAAaE,GAAG,CAAC,aAAa;EAE5C,MAAMN,EAAA,GAAKF,oBAAA,CAAqB;IAC9BE,EAAA,EAAIC,UAAA;IACJO,cAAA,EAAgBN,UAAA,CAAWO,MAAM,CAACC,IAAI;IACtCC,OAAA,EAASR,GAAA,CAAIQ;EACf;EAEA,MAAMC,GAAA,GAAM,MAAMnB,kBAAA,CAAmB;IACnCO,EAAA;IACAE,UAAA;IACAG,KAAA,EAAOT,QAAA,CAASS,KAAA,IAASQ,MAAA,CAAOR,KAAA,IAASS,SAAA;IACzCP,KAAA;IACAQ,QAAA,EAAUrB,qBAAA,CAAsBS,GAAA,CAAIa,KAAK,CAACD,QAAQ;IAClDZ,GAAA;IACAc,MAAA,EAAQtB,mBAAA,CAAoBQ,GAAA,CAAIa,KAAK,CAACC,MAAM;EAC9C;EAEA,MAAMC,OAAA,GAAUf,GAAA,CAAIgB,CAAC,CAAC,kCAAkC;IACtDC,KAAA,EAAO7B,cAAA,CAAeW,UAAA,CAAWO,MAAM,CAACY,MAAM,CAACC,QAAQ,EAAEnB,GAAA,CAAIoB,IAAI;EACnE;EAEA,OAAOC,QAAA,CAASC,IAAI,CAClB;IACEb,GAAA;IACAM;EACF,GACA;IACEQ,OAAA,EAAS7B,eAAA,CAAgB;MACvB6B,OAAA,EAAS,IAAIC,OAAA;MACbxB;IACF;IACAyB,MAAA,EAAQpC,UAAA,CAAWqC;EACrB;AAEJ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/find.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/find.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAGzD,eAAO,MAAM,IAAI,EAAE,sBAkClB,CAAA"}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import httpStatus from 'http-status';
|
|
2
|
-
import { findOperation } from 'payload';
|
|
2
|
+
import { findOperation, sanitizeJoinParams, sanitizePopulateParam, sanitizeSelectParam } from 'payload';
|
|
3
3
|
import { isNumber } from 'payload/shared';
|
|
4
4
|
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
5
|
-
import { sanitizeJoinParams } from '../utilities/sanitizeJoinParams.js';
|
|
6
|
-
import { sanitizePopulate } from '../utilities/sanitizePopulate.js';
|
|
7
|
-
import { sanitizeSelect } from '../utilities/sanitizeSelect.js';
|
|
8
5
|
export const find = async ({
|
|
9
6
|
collection,
|
|
10
7
|
req
|
|
@@ -27,9 +24,9 @@ export const find = async ({
|
|
|
27
24
|
joins: sanitizeJoinParams(joins),
|
|
28
25
|
limit: isNumber(limit) ? Number(limit) : undefined,
|
|
29
26
|
page: isNumber(page) ? Number(page) : undefined,
|
|
30
|
-
populate:
|
|
27
|
+
populate: sanitizePopulateParam(populate),
|
|
31
28
|
req,
|
|
32
|
-
select:
|
|
29
|
+
select: sanitizeSelectParam(select),
|
|
33
30
|
sort: typeof sort === 'string' ? sort.split(',') : undefined,
|
|
34
31
|
where
|
|
35
32
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find.js","names":["httpStatus","findOperation","
|
|
1
|
+
{"version":3,"file":"find.js","names":["httpStatus","findOperation","sanitizeJoinParams","sanitizePopulateParam","sanitizeSelectParam","isNumber","headersWithCors","find","collection","req","depth","draft","joins","limit","page","populate","select","sort","where","query","result","Number","undefined","split","Response","json","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/collections/find.ts"],"sourcesContent":["import type { JoinQuery, Where } from 'payload'\n\nimport httpStatus from 'http-status'\nimport {\n findOperation,\n sanitizeJoinParams,\n sanitizePopulateParam,\n sanitizeSelectParam,\n} from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nexport const find: CollectionRouteHandler = async ({ collection, req }) => {\n const { depth, draft, joins, limit, page, populate, select, sort, where } = req.query as {\n depth?: string\n draft?: string\n joins?: JoinQuery\n limit?: string\n page?: string\n populate?: Record<string, unknown>\n select?: Record<string, unknown>\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 joins: sanitizeJoinParams(joins),\n limit: isNumber(limit) ? Number(limit) : undefined,\n page: isNumber(page) ? Number(page) : 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,SACEC,aAAa,EACbC,kBAAkB,EAClBC,qBAAqB,EACrBC,mBAAmB,QACd;AACP,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,OAAO,MAAMC,IAAA,GAA+B,MAAAA,CAAO;EAAEC,UAAU;EAAEC;AAAG,CAAE;EACpE,MAAM;IAAEC,KAAK;IAAEC,KAAK;IAAEC,KAAK;IAAEC,KAAK;IAAEC,IAAI;IAAEC,QAAQ;IAAEC,MAAM;IAAEC,IAAI;IAAEC;EAAK,CAAE,GAAGT,GAAA,CAAIU,KAAK;EAYrF,MAAMC,MAAA,GAAS,MAAMnB,aAAA,CAAc;IACjCO,UAAA;IACAE,KAAA,EAAOL,QAAA,CAASK,KAAA,IAASW,MAAA,CAAOX,KAAA,IAASY,SAAA;IACzCX,KAAA,EAAOA,KAAA,KAAU;IACjBC,KAAA,EAAOV,kBAAA,CAAmBU,KAAA;IAC1BC,KAAA,EAAOR,QAAA,CAASQ,KAAA,IAASQ,MAAA,CAAOR,KAAA,IAASS,SAAA;IACzCR,IAAA,EAAMT,QAAA,CAASS,IAAA,IAAQO,MAAA,CAAOP,IAAA,IAAQQ,SAAA;IACtCP,QAAA,EAAUZ,qBAAA,CAAsBY,QAAA;IAChCN,GAAA;IACAO,MAAA,EAAQZ,mBAAA,CAAoBY,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,EAASpB,eAAA,CAAgB;MACvBoB,OAAA,EAAS,IAAIC,OAAA;MACblB;IACF;IACAmB,MAAA,EAAQ5B,UAAA,CAAW6B;EACrB;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findByID.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/findByID.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"findByID.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/findByID.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAK/D,eAAO,MAAM,QAAQ,EAAE,4BAgCtB,CAAA"}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import httpStatus from 'http-status';
|
|
2
|
-
import { findByIDOperation } from 'payload';
|
|
2
|
+
import { findByIDOperation, sanitizeJoinParams, sanitizePopulateParam, sanitizeSelectParam } from 'payload';
|
|
3
3
|
import { isNumber } from 'payload/shared';
|
|
4
4
|
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
5
5
|
import { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js';
|
|
6
|
-
import { sanitizeJoinParams } from '../utilities/sanitizeJoinParams.js';
|
|
7
|
-
import { sanitizePopulate } from '../utilities/sanitizePopulate.js';
|
|
8
|
-
import { sanitizeSelect } from '../utilities/sanitizeSelect.js';
|
|
9
6
|
export const findByID = async ({
|
|
10
7
|
id: incomingID,
|
|
11
8
|
collection,
|
|
@@ -26,9 +23,9 @@ export const findByID = async ({
|
|
|
26
23
|
depth: isNumber(depth) ? Number(depth) : undefined,
|
|
27
24
|
draft: searchParams.get('draft') === 'true',
|
|
28
25
|
joins: sanitizeJoinParams(req.query.joins),
|
|
29
|
-
populate:
|
|
26
|
+
populate: sanitizePopulateParam(req.query.populate),
|
|
30
27
|
req,
|
|
31
|
-
select:
|
|
28
|
+
select: sanitizeSelectParam(req.query.select)
|
|
32
29
|
});
|
|
33
30
|
return Response.json(result, {
|
|
34
31
|
headers: headersWithCors({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findByID.js","names":["httpStatus","findByIDOperation","
|
|
1
|
+
{"version":3,"file":"findByID.js","names":["httpStatus","findByIDOperation","sanitizeJoinParams","sanitizePopulateParam","sanitizeSelectParam","isNumber","headersWithCors","sanitizeCollectionID","findByID","id","incomingID","collection","req","searchParams","depth","get","collectionSlug","config","slug","payload","result","Number","undefined","draft","joins","query","populate","select","Response","json","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/collections/findByID.ts"],"sourcesContent":["import type { JoinQuery } from 'payload'\n\nimport httpStatus from 'http-status'\nimport {\n findByIDOperation,\n sanitizeJoinParams,\n sanitizePopulateParam,\n sanitizeSelectParam,\n} from 'payload'\nimport { isNumber } from 'payload/shared'\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 joins: sanitizeJoinParams(req.query.joins as JoinQuery),\n populate: sanitizePopulateParam(req.query.populate),\n req,\n select: sanitizeSelectParam(req.query.select),\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,SACEC,iBAAiB,EACjBC,kBAAkB,EAClBC,qBAAqB,EACrBC,mBAAmB,QACd;AACP,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,oBAAoB,QAAQ;AAErC,OAAO,MAAMC,QAAA,GAAyC,MAAAA,CAAO;EAC3DC,EAAA,EAAIC,UAAU;EACdC,UAAU;EACVC;AAAG,CACJ;EACC,MAAM;IAAEC;EAAY,CAAE,GAAGD,GAAA;EACzB,MAAME,KAAA,GAAQD,YAAA,CAAaE,GAAG,CAAC;EAE/B,MAAMN,EAAA,GAAKF,oBAAA,CAAqB;IAC9BE,EAAA,EAAIC,UAAA;IACJM,cAAA,EAAgBL,UAAA,CAAWM,MAAM,CAACC,IAAI;IACtCC,OAAA,EAASP,GAAA,CAAIO;EACf;EAEA,MAAMC,MAAA,GAAS,MAAMnB,iBAAA,CAAkB;IACrCQ,EAAA;IACAE,UAAA;IACAG,KAAA,EAAOT,QAAA,CAASS,KAAA,IAASO,MAAA,CAAOP,KAAA,IAASQ,SAAA;IACzCC,KAAA,EAAOV,YAAA,CAAaE,GAAG,CAAC,aAAa;IACrCS,KAAA,EAAOtB,kBAAA,CAAmBU,GAAA,CAAIa,KAAK,CAACD,KAAK;IACzCE,QAAA,EAAUvB,qBAAA,CAAsBS,GAAA,CAAIa,KAAK,CAACC,QAAQ;IAClDd,GAAA;IACAe,MAAA,EAAQvB,mBAAA,CAAoBQ,GAAA,CAAIa,KAAK,CAACE,MAAM;EAC9C;EAEA,OAAOC,QAAA,CAASC,IAAI,CAACT,MAAA,EAAQ;IAC3BU,OAAA,EAASxB,eAAA,CAAgB;MACvBwB,OAAA,EAAS,IAAIC,OAAA;MACbnB;IACF;IACAoB,MAAA,EAAQhC,UAAA,CAAWiC;EACrB;AACF","ignoreList":[]}
|
|
@@ -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;
|
|
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,4BA8B7B,CAAA"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import httpStatus from 'http-status';
|
|
2
|
-
import { findVersionByIDOperation } from 'payload';
|
|
2
|
+
import { findVersionByIDOperation, sanitizePopulateParam, sanitizeSelectParam } from 'payload';
|
|
3
3
|
import { isNumber } from 'payload/shared';
|
|
4
4
|
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
5
5
|
import { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js';
|
|
6
|
-
import { sanitizePopulate } from '../utilities/sanitizePopulate.js';
|
|
7
|
-
import { sanitizeSelect } from '../utilities/sanitizeSelect.js';
|
|
8
6
|
export const findVersionByID = async ({
|
|
9
7
|
id: incomingID,
|
|
10
8
|
collection,
|
|
@@ -23,9 +21,9 @@ export const findVersionByID = async ({
|
|
|
23
21
|
id,
|
|
24
22
|
collection,
|
|
25
23
|
depth: isNumber(depth) ? Number(depth) : undefined,
|
|
26
|
-
populate:
|
|
24
|
+
populate: sanitizePopulateParam(req.query.populate),
|
|
27
25
|
req,
|
|
28
|
-
select:
|
|
26
|
+
select: sanitizeSelectParam(req.query.select)
|
|
29
27
|
});
|
|
30
28
|
return Response.json(result, {
|
|
31
29
|
headers: headersWithCors({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findVersionByID.js","names":["httpStatus","findVersionByIDOperation","
|
|
1
|
+
{"version":3,"file":"findVersionByID.js","names":["httpStatus","findVersionByIDOperation","sanitizePopulateParam","sanitizeSelectParam","isNumber","headersWithCors","sanitizeCollectionID","findVersionByID","id","incomingID","collection","req","searchParams","depth","get","collectionSlug","config","slug","payload","result","Number","undefined","populate","query","select","Response","json","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/collections/findVersionByID.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { findVersionByIDOperation, sanitizePopulateParam, sanitizeSelectParam } from 'payload'\nimport { isNumber } from 'payload/shared'\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 populate: sanitizePopulateParam(req.query.populate),\n req,\n select: sanitizeSelectParam(req.query.select),\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":"AAAA,OAAOA,UAAA,MAAgB;AACvB,SAASC,wBAAwB,EAAEC,qBAAqB,EAAEC,mBAAmB,QAAQ;AACrF,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,oBAAoB,QAAQ;AAErC,OAAO,MAAMC,eAAA,GAAgD,MAAAA,CAAO;EAClEC,EAAA,EAAIC,UAAU;EACdC,UAAU;EACVC;AAAG,CACJ;EACC,MAAM;IAAEC;EAAY,CAAE,GAAGD,GAAA;EACzB,MAAME,KAAA,GAAQD,YAAA,CAAaE,GAAG,CAAC;EAE/B,MAAMN,EAAA,GAAKF,oBAAA,CAAqB;IAC9BE,EAAA,EAAIC,UAAA;IACJM,cAAA,EAAgBL,UAAA,CAAWM,MAAM,CAACC,IAAI;IACtCC,OAAA,EAASP,GAAA,CAAIO;EACf;EAEA,MAAMC,MAAA,GAAS,MAAMlB,wBAAA,CAAyB;IAC5CO,EAAA;IACAE,UAAA;IACAG,KAAA,EAAOT,QAAA,CAASS,KAAA,IAASO,MAAA,CAAOP,KAAA,IAASQ,SAAA;IACzCC,QAAA,EAAUpB,qBAAA,CAAsBS,GAAA,CAAIY,KAAK,CAACD,QAAQ;IAClDX,GAAA;IACAa,MAAA,EAAQrB,mBAAA,CAAoBQ,GAAA,CAAIY,KAAK,CAACC,MAAM;EAC9C;EAEA,OAAOC,QAAA,CAASC,IAAI,CAACP,MAAA,EAAQ;IAC3BQ,OAAA,EAAStB,eAAA,CAAgB;MACvBsB,OAAA,EAAS,IAAIC,OAAA;MACbjB;IACF;IACAkB,MAAA,EAAQ7B,UAAA,CAAW8B;EACrB;AACF","ignoreList":[]}
|
|
@@ -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;
|
|
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,sBA8B1B,CAAA"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import httpStatus from 'http-status';
|
|
2
|
-
import { findVersionsOperation } from 'payload';
|
|
2
|
+
import { findVersionsOperation, sanitizePopulateParam, sanitizeSelectParam } from 'payload';
|
|
3
3
|
import { isNumber } from 'payload/shared';
|
|
4
4
|
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
5
|
-
import { sanitizePopulate } from '../utilities/sanitizePopulate.js';
|
|
6
|
-
import { sanitizeSelect } from '../utilities/sanitizeSelect.js';
|
|
7
5
|
export const findVersions = async ({
|
|
8
6
|
collection,
|
|
9
7
|
req
|
|
@@ -22,9 +20,9 @@ export const findVersions = async ({
|
|
|
22
20
|
depth: isNumber(depth) ? Number(depth) : undefined,
|
|
23
21
|
limit: isNumber(limit) ? Number(limit) : undefined,
|
|
24
22
|
page: isNumber(page) ? Number(page) : undefined,
|
|
25
|
-
populate:
|
|
23
|
+
populate: sanitizePopulateParam(populate),
|
|
26
24
|
req,
|
|
27
|
-
select:
|
|
25
|
+
select: sanitizeSelectParam(select),
|
|
28
26
|
sort: typeof sort === 'string' ? sort.split(',') : undefined,
|
|
29
27
|
where
|
|
30
28
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findVersions.js","names":["httpStatus","findVersionsOperation","
|
|
1
|
+
{"version":3,"file":"findVersions.js","names":["httpStatus","findVersionsOperation","sanitizePopulateParam","sanitizeSelectParam","isNumber","headersWithCors","findVersions","collection","req","depth","limit","page","populate","select","sort","where","query","result","Number","undefined","split","Response","json","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/collections/findVersions.ts"],"sourcesContent":["import type { Where } from 'payload'\n\nimport httpStatus from 'http-status'\nimport { findVersionsOperation, sanitizePopulateParam, sanitizeSelectParam } from 'payload'\nimport { isNumber } from 'payload/shared'\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, populate, select, sort, where } = req.query as {\n depth?: string\n limit?: string\n page?: string\n populate?: Record<string, unknown>\n select?: Record<string, unknown>\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 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,qBAAqB,EAAEC,qBAAqB,EAAEC,mBAAmB,QAAQ;AAClF,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAEhC,OAAO,MAAMC,YAAA,GAAuC,MAAAA,CAAO;EAAEC,UAAU;EAAEC;AAAG,CAAE;EAC5E,MAAM;IAAEC,KAAK;IAAEC,KAAK;IAAEC,IAAI;IAAEC,QAAQ;IAAEC,MAAM;IAAEC,IAAI;IAAEC;EAAK,CAAE,GAAGP,GAAA,CAAIQ,KAAK;EAUvE,MAAMC,MAAA,GAAS,MAAMhB,qBAAA,CAAsB;IACzCM,UAAA;IACAE,KAAA,EAAOL,QAAA,CAASK,KAAA,IAASS,MAAA,CAAOT,KAAA,IAASU,SAAA;IACzCT,KAAA,EAAON,QAAA,CAASM,KAAA,IAASQ,MAAA,CAAOR,KAAA,IAASS,SAAA;IACzCR,IAAA,EAAMP,QAAA,CAASO,IAAA,IAAQO,MAAA,CAAOP,IAAA,IAAQQ,SAAA;IACtCP,QAAA,EAAUV,qBAAA,CAAsBU,QAAA;IAChCJ,GAAA;IACAK,MAAA,EAAQV,mBAAA,CAAoBU,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,EAASlB,eAAA,CAAgB;MACvBkB,OAAA,EAAS,IAAIC,OAAA;MACbhB;IACF;IACAiB,MAAA,EAAQzB,UAAA,CAAW0B;EACrB;AACF","ignoreList":[]}
|
|
@@ -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;
|
|
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,4BAqC5B,CAAA"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import httpStatus from 'http-status';
|
|
2
|
-
import { restoreVersionOperation } from 'payload';
|
|
2
|
+
import { restoreVersionOperation, sanitizePopulateParam } from 'payload';
|
|
3
3
|
import { isNumber } from 'payload/shared';
|
|
4
4
|
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
5
5
|
import { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js';
|
|
6
|
-
import { sanitizePopulate } from '../utilities/sanitizePopulate.js';
|
|
7
6
|
export const restoreVersion = async ({
|
|
8
7
|
id: incomingID,
|
|
9
8
|
collection,
|
|
@@ -24,7 +23,7 @@ export const restoreVersion = async ({
|
|
|
24
23
|
collection,
|
|
25
24
|
depth: isNumber(depth) ? Number(depth) : undefined,
|
|
26
25
|
draft: draft === 'true' ? true : undefined,
|
|
27
|
-
populate:
|
|
26
|
+
populate: sanitizePopulateParam(req.query.populate),
|
|
28
27
|
req
|
|
29
28
|
});
|
|
30
29
|
return Response.json({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restoreVersion.js","names":["httpStatus","restoreVersionOperation","isNumber","headersWithCors","sanitizeCollectionID","
|
|
1
|
+
{"version":3,"file":"restoreVersion.js","names":["httpStatus","restoreVersionOperation","sanitizePopulateParam","isNumber","headersWithCors","sanitizeCollectionID","restoreVersion","id","incomingID","collection","req","searchParams","depth","get","draft","collectionSlug","config","slug","payload","result","Number","undefined","populate","query","Response","json","message","t","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/collections/restoreVersion.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { restoreVersionOperation, sanitizePopulateParam } from 'payload'\nimport { isNumber } from 'payload/shared'\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 const draft = searchParams.get('draft')\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 draft: draft === 'true' ? true : undefined,\n populate: sanitizePopulateParam(req.query.populate),\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"],"mappings":"AAAA,OAAOA,UAAA,MAAgB;AACvB,SAASC,uBAAuB,EAAEC,qBAAqB,QAAQ;AAC/D,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,oBAAoB,QAAQ;AAErC,OAAO,MAAMC,cAAA,GAA+C,MAAAA,CAAO;EACjEC,EAAA,EAAIC,UAAU;EACdC,UAAU;EACVC;AAAG,CACJ;EACC,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,MAAMN,EAAA,GAAKF,oBAAA,CAAqB;IAC9BE,EAAA,EAAIC,UAAA;IACJO,cAAA,EAAgBN,UAAA,CAAWO,MAAM,CAACC,IAAI;IACtCC,OAAA,EAASR,GAAA,CAAIQ;EACf;EAEA,MAAMC,MAAA,GAAS,MAAMlB,uBAAA,CAAwB;IAC3CM,EAAA;IACAE,UAAA;IACAG,KAAA,EAAOT,QAAA,CAASS,KAAA,IAASQ,MAAA,CAAOR,KAAA,IAASS,SAAA;IACzCP,KAAA,EAAOA,KAAA,KAAU,SAAS,OAAOO,SAAA;IACjCC,QAAA,EAAUpB,qBAAA,CAAsBQ,GAAA,CAAIa,KAAK,CAACD,QAAQ;IAClDZ;EACF;EAEA,OAAOc,QAAA,CAASC,IAAI,CAClB;IACE,GAAGN,MAAM;IACTO,OAAA,EAAShB,GAAA,CAAIiB,CAAC,CAAC;EACjB,GACA;IACEC,OAAA,EAASxB,eAAA,CAAgB;MACvBwB,OAAA,EAAS,IAAIC,OAAA;MACbnB;IACF;IACAoB,MAAA,EAAQ9B,UAAA,CAAW+B;EACrB;AAEJ","ignoreList":[]}
|
|
@@ -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;
|
|
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,sBAmEpB,CAAA"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { getTranslation } from '@payloadcms/translations';
|
|
2
2
|
import httpStatus from 'http-status';
|
|
3
|
-
import { updateOperation } from 'payload';
|
|
3
|
+
import { sanitizePopulateParam, sanitizeSelectParam, updateOperation } from 'payload';
|
|
4
4
|
import { isNumber } from 'payload/shared';
|
|
5
5
|
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
6
|
-
import { sanitizePopulate } from '../utilities/sanitizePopulate.js';
|
|
7
|
-
import { sanitizeSelect } from '../utilities/sanitizeSelect.js';
|
|
8
6
|
export const update = async ({
|
|
9
7
|
collection,
|
|
10
8
|
req
|
|
@@ -25,9 +23,9 @@ export const update = async ({
|
|
|
25
23
|
draft: draft === 'true',
|
|
26
24
|
limit: isNumber(limit) ? Number(limit) : undefined,
|
|
27
25
|
overrideLock: Boolean(overrideLock === 'true'),
|
|
28
|
-
populate:
|
|
26
|
+
populate: sanitizePopulateParam(populate),
|
|
29
27
|
req,
|
|
30
|
-
select:
|
|
28
|
+
select: sanitizeSelectParam(select),
|
|
31
29
|
where
|
|
32
30
|
});
|
|
33
31
|
const headers = headersWithCors({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","names":["getTranslation","httpStatus","
|
|
1
|
+
{"version":3,"file":"update.js","names":["getTranslation","httpStatus","sanitizePopulateParam","sanitizeSelectParam","updateOperation","isNumber","headersWithCors","update","collection","req","depth","draft","limit","overrideLock","populate","select","where","query","result","data","Number","undefined","Boolean","headers","Headers","errors","length","message","t","count","docs","label","config","labels","i18n","Response","json","status","OK","total","BAD_REQUEST"],"sources":["../../../../src/routes/rest/collections/update.ts"],"sourcesContent":["import type { Where } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport httpStatus from 'http-status'\nimport { sanitizePopulateParam, sanitizeSelectParam, updateOperation } from 'payload'\nimport { isNumber } from 'payload/shared'\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, limit, overrideLock, populate, select, where } = req.query as {\n depth?: string\n draft?: string\n limit?: string\n overrideLock?: string\n populate?: Record<string, unknown>\n select?: Record<string, unknown>\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 limit: isNumber(limit) ? Number(limit) : undefined,\n overrideLock: Boolean(overrideLock === 'true'),\n populate: sanitizePopulateParam(populate),\n req,\n select: sanitizeSelectParam(select),\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"],"mappings":"AAEA,SAASA,cAAc,QAAQ;AAC/B,OAAOC,UAAA,MAAgB;AACvB,SAASC,qBAAqB,EAAEC,mBAAmB,EAAEC,eAAe,QAAQ;AAC5E,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAEhC,OAAO,MAAMC,MAAA,GAAiC,MAAAA,CAAO;EAAEC,UAAU;EAAEC;AAAG,CAAE;EACtE,MAAM;IAAEC,KAAK;IAAEC,KAAK;IAAEC,KAAK;IAAEC,YAAY;IAAEC,QAAQ;IAAEC,MAAM;IAAEC;EAAK,CAAE,GAAGP,GAAA,CAAIQ,KAAK;EAUhF,MAAMC,MAAA,GAAS,MAAMd,eAAA,CAAgB;IACnCI,UAAA;IACAW,IAAA,EAAMV,GAAA,CAAIU,IAAI;IACdT,KAAA,EAAOL,QAAA,CAASK,KAAA,IAASU,MAAA,CAAOV,KAAA,IAASW,SAAA;IACzCV,KAAA,EAAOA,KAAA,KAAU;IACjBC,KAAA,EAAOP,QAAA,CAASO,KAAA,IAASQ,MAAA,CAAOR,KAAA,IAASS,SAAA;IACzCR,YAAA,EAAcS,OAAA,CAAQT,YAAA,KAAiB;IACvCC,QAAA,EAAUZ,qBAAA,CAAsBY,QAAA;IAChCL,GAAA;IACAM,MAAA,EAAQZ,mBAAA,CAAoBY,MAAA;IAC5BC;EACF;EAEA,MAAMO,OAAA,GAAUjB,eAAA,CAAgB;IAC9BiB,OAAA,EAAS,IAAIC,OAAA;IACbf;EACF;EAEA,IAAIS,MAAA,CAAOO,MAAM,CAACC,MAAM,KAAK,GAAG;IAC9B,MAAMC,OAAA,GAAUlB,GAAA,CAAImB,CAAC,CAAC,oCAAoC;MACxDC,KAAA,EAAOX,MAAA,CAAOY,IAAI,CAACJ,MAAM;MACzBK,KAAA,EAAO/B,cAAA,CACLQ,UAAA,CAAWwB,MAAM,CAACC,MAAM,CAACf,MAAA,CAAOY,IAAI,CAACJ,MAAM,GAAG,IAAI,WAAW,WAAW,EACxEjB,GAAA,CAAIyB,IAAI;IAEZ;IAEA,OAAOC,QAAA,CAASC,IAAI,CAClB;MACE,GAAGlB,MAAM;MACTS;IACF,GACA;MACEJ,OAAA;MACAc,MAAA,EAAQpC,UAAA,CAAWqC;IACrB;EAEJ;EAEA,MAAMC,KAAA,GAAQrB,MAAA,CAAOY,IAAI,CAACJ,MAAM,GAAGR,MAAA,CAAOO,MAAM,CAACC,MAAM;EACvD,MAAMC,OAAA,GAAUlB,GAAA,CAAImB,CAAC,CAAC,6BAA6B;IACjDC,KAAA,EAAOX,MAAA,CAAOO,MAAM,CAACC,MAAM;IAC3BK,KAAA,EAAO/B,cAAA,CAAeQ,UAAA,CAAWwB,MAAM,CAACC,MAAM,CAACM,KAAA,GAAQ,IAAI,WAAW,WAAW,EAAE9B,GAAA,CAAIyB,IAAI;IAC3FK;EACF;EAEA,OAAOJ,QAAA,CAASC,IAAI,CAClB;IACE,GAAGlB,MAAM;IACTS;EACF,GACA;IACEJ,OAAA;IACAc,MAAA,EAAQpC,UAAA,CAAWuC;EACrB;AAEJ","ignoreList":[]}
|
|
@@ -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;
|
|
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,4BAsDxB,CAAA"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import httpStatus from 'http-status';
|
|
2
|
-
import { updateByIDOperation } from 'payload';
|
|
2
|
+
import { sanitizePopulateParam, sanitizeSelectParam, updateByIDOperation } from 'payload';
|
|
3
3
|
import { isNumber } from 'payload/shared';
|
|
4
4
|
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
5
5
|
import { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js';
|
|
6
|
-
import { sanitizePopulate } from '../utilities/sanitizePopulate.js';
|
|
7
|
-
import { sanitizeSelect } from '../utilities/sanitizeSelect.js';
|
|
8
6
|
export const updateByID = async ({
|
|
9
7
|
id: incomingID,
|
|
10
8
|
collection,
|
|
@@ -31,10 +29,10 @@ export const updateByID = async ({
|
|
|
31
29
|
depth: isNumber(depth) ? Number(depth) : undefined,
|
|
32
30
|
draft,
|
|
33
31
|
overrideLock: Boolean(overrideLock === 'true'),
|
|
34
|
-
populate:
|
|
32
|
+
populate: sanitizePopulateParam(req.query.populate),
|
|
35
33
|
publishSpecificLocale,
|
|
36
34
|
req,
|
|
37
|
-
select:
|
|
35
|
+
select: sanitizeSelectParam(req.query.select)
|
|
38
36
|
});
|
|
39
37
|
let message = req.t('general:updatedSuccessfully');
|
|
40
38
|
if (draft) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateByID.js","names":["httpStatus","
|
|
1
|
+
{"version":3,"file":"updateByID.js","names":["httpStatus","sanitizePopulateParam","sanitizeSelectParam","updateByIDOperation","isNumber","headersWithCors","sanitizeCollectionID","updateByID","id","incomingID","collection","req","searchParams","depth","get","autosave","draft","overrideLock","publishSpecificLocale","query","collectionSlug","config","slug","payload","doc","data","Number","undefined","Boolean","populate","select","message","t","Response","json","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/collections/updateByID.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { sanitizePopulateParam, sanitizeSelectParam, updateByIDOperation } from 'payload'\nimport { isNumber } from 'payload/shared'\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 const overrideLock = searchParams.get('overrideLock')\n const publishSpecificLocale = req.query.publishSpecificLocale as string | undefined\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 overrideLock: Boolean(overrideLock === 'true'),\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 doc,\n message,\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,mBAAmB,QAAQ;AAChF,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,oBAAoB,QAAQ;AAErC,OAAO,MAAMC,UAAA,GAA2C,MAAAA,CAAO;EAC7DC,EAAA,EAAIC,UAAU;EACdC,UAAU;EACVC;AAAG,CACJ;EACC,MAAM;IAAEC;EAAY,CAAE,GAAGD,GAAA;EACzB,MAAME,KAAA,GAAQD,YAAA,CAAaE,GAAG,CAAC;EAC/B,MAAMC,QAAA,GAAWH,YAAA,CAAaE,GAAG,CAAC,gBAAgB;EAClD,MAAME,KAAA,GAAQJ,YAAA,CAAaE,GAAG,CAAC,aAAa;EAC5C,MAAMG,YAAA,GAAeL,YAAA,CAAaE,GAAG,CAAC;EACtC,MAAMI,qBAAA,GAAwBP,GAAA,CAAIQ,KAAK,CAACD,qBAAqB;EAE7D,MAAMV,EAAA,GAAKF,oBAAA,CAAqB;IAC9BE,EAAA,EAAIC,UAAA;IACJW,cAAA,EAAgBV,UAAA,CAAWW,MAAM,CAACC,IAAI;IACtCC,OAAA,EAASZ,GAAA,CAAIY;EACf;EAEA,MAAMC,GAAA,GAAM,MAAMrB,mBAAA,CAAoB;IACpCK,EAAA;IACAO,QAAA;IACAL,UAAA;IACAe,IAAA,EAAMd,GAAA,CAAIc,IAAI;IACdZ,KAAA,EAAOT,QAAA,CAASS,KAAA,IAASa,MAAA,CAAOb,KAAA,IAASc,SAAA;IACzCX,KAAA;IACAC,YAAA,EAAcW,OAAA,CAAQX,YAAA,KAAiB;IACvCY,QAAA,EAAU5B,qBAAA,CAAsBU,GAAA,CAAIQ,KAAK,CAACU,QAAQ;IAClDX,qBAAA;IACAP,GAAA;IACAmB,MAAA,EAAQ5B,mBAAA,CAAoBS,GAAA,CAAIQ,KAAK,CAACW,MAAM;EAC9C;EAEA,IAAIC,OAAA,GAAUpB,GAAA,CAAIqB,CAAC,CAAC;EAEpB,IAAIhB,KAAA,EAAO;IACTe,OAAA,GAAUpB,GAAA,CAAIqB,CAAC,CAAC;EAClB;EACA,IAAIjB,QAAA,EAAU;IACZgB,OAAA,GAAUpB,GAAA,CAAIqB,CAAC,CAAC;EAClB;EAEA,OAAOC,QAAA,CAASC,IAAI,CAClB;IACEV,GAAA;IACAO;EACF,GACA;IACEI,OAAA,EAAS9B,eAAA,CAAgB;MACvB8B,OAAA,EAAS,IAAIC,OAAA;MACbzB;IACF;IACA0B,MAAA,EAAQrC,UAAA,CAAWsC;EACrB;AAEJ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findOne.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/globals/findOne.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"findOne.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/globals/findOne.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAIrD,eAAO,MAAM,OAAO,EAAE,kBAqBrB,CAAA"}
|