payload 3.19.0-canary.edf2c5e → 3.19.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/auth/endpoints/access.d.ts.map +1 -1
- package/dist/auth/endpoints/access.js +7 -0
- package/dist/auth/endpoints/access.js.map +1 -1
- package/dist/auth/endpoints/forgotPassword.d.ts.map +1 -1
- package/dist/auth/endpoints/forgotPassword.js +5 -0
- package/dist/auth/endpoints/forgotPassword.js.map +1 -1
- package/dist/auth/endpoints/init.d.ts.map +1 -1
- package/dist/auth/endpoints/init.js +6 -0
- package/dist/auth/endpoints/init.js.map +1 -1
- package/dist/auth/endpoints/login.d.ts.map +1 -1
- package/dist/auth/endpoints/login.js +6 -2
- package/dist/auth/endpoints/login.js.map +1 -1
- package/dist/auth/endpoints/logout.d.ts.map +1 -1
- package/dist/auth/endpoints/logout.js +7 -3
- package/dist/auth/endpoints/logout.js.map +1 -1
- package/dist/auth/endpoints/me.d.ts.map +1 -1
- package/dist/auth/endpoints/me.js +5 -0
- package/dist/auth/endpoints/me.js.map +1 -1
- package/dist/auth/endpoints/refresh.d.ts.map +1 -1
- package/dist/auth/endpoints/refresh.js +5 -1
- package/dist/auth/endpoints/refresh.js.map +1 -1
- package/dist/auth/endpoints/registerFirstUser.d.ts.map +1 -1
- package/dist/auth/endpoints/registerFirstUser.js +6 -2
- package/dist/auth/endpoints/registerFirstUser.js.map +1 -1
- package/dist/auth/endpoints/resetPassword.d.ts.map +1 -1
- package/dist/auth/endpoints/resetPassword.js +6 -2
- package/dist/auth/endpoints/resetPassword.js.map +1 -1
- package/dist/auth/endpoints/unlock.d.ts.map +1 -1
- package/dist/auth/endpoints/unlock.js +5 -0
- package/dist/auth/endpoints/unlock.js.map +1 -1
- package/dist/auth/endpoints/verifyEmail.d.ts.map +1 -1
- package/dist/auth/endpoints/verifyEmail.js +5 -0
- package/dist/auth/endpoints/verifyEmail.js.map +1 -1
- package/dist/collections/endpoints/create.d.ts.map +1 -1
- package/dist/collections/endpoints/create.js +5 -0
- package/dist/collections/endpoints/create.js.map +1 -1
- package/dist/collections/endpoints/delete.d.ts.map +1 -1
- package/dist/collections/endpoints/delete.js +7 -0
- package/dist/collections/endpoints/delete.js.map +1 -1
- package/dist/collections/endpoints/deleteByID.d.ts.map +1 -1
- package/dist/collections/endpoints/deleteByID.js +7 -0
- package/dist/collections/endpoints/deleteByID.js.map +1 -1
- package/dist/collections/endpoints/docAccess.d.ts.map +1 -1
- package/dist/collections/endpoints/docAccess.js +5 -0
- package/dist/collections/endpoints/docAccess.js.map +1 -1
- package/dist/collections/endpoints/duplicate.d.ts.map +1 -1
- package/dist/collections/endpoints/duplicate.js +5 -0
- package/dist/collections/endpoints/duplicate.js.map +1 -1
- package/dist/collections/endpoints/find.d.ts.map +1 -1
- package/dist/collections/endpoints/find.js +5 -0
- package/dist/collections/endpoints/find.js.map +1 -1
- package/dist/collections/endpoints/findByID.d.ts.map +1 -1
- package/dist/collections/endpoints/findByID.js +5 -0
- package/dist/collections/endpoints/findByID.js.map +1 -1
- package/dist/collections/endpoints/findVersionByID.d.ts.map +1 -1
- package/dist/collections/endpoints/findVersionByID.js +5 -0
- package/dist/collections/endpoints/findVersionByID.js.map +1 -1
- package/dist/collections/endpoints/findVersions.d.ts.map +1 -1
- package/dist/collections/endpoints/findVersions.js +5 -0
- package/dist/collections/endpoints/findVersions.js.map +1 -1
- package/dist/collections/endpoints/getFile.d.ts.map +1 -1
- package/dist/collections/endpoints/getFile.js +5 -1
- package/dist/collections/endpoints/getFile.js.map +1 -1
- package/dist/collections/endpoints/preview.d.ts.map +1 -1
- package/dist/collections/endpoints/preview.js +5 -0
- package/dist/collections/endpoints/preview.js.map +1 -1
- package/dist/collections/endpoints/restoreVersion.d.ts.map +1 -1
- package/dist/collections/endpoints/restoreVersion.js +5 -0
- package/dist/collections/endpoints/restoreVersion.js.map +1 -1
- package/dist/collections/endpoints/update.d.ts.map +1 -1
- package/dist/collections/endpoints/update.js +7 -0
- package/dist/collections/endpoints/update.js.map +1 -1
- package/dist/collections/endpoints/updateByID.d.ts.map +1 -1
- package/dist/collections/endpoints/updateByID.js +5 -0
- package/dist/collections/endpoints/updateByID.js.map +1 -1
- package/dist/fields/config/client.d.ts.map +1 -1
- package/dist/fields/config/client.js +22 -0
- package/dist/fields/config/client.js.map +1 -1
- package/dist/fields/config/types.d.ts +4 -0
- package/dist/fields/config/types.d.ts.map +1 -1
- package/dist/fields/config/types.js.map +1 -1
- package/dist/globals/endpoints/docAccess.d.ts.map +1 -1
- package/dist/globals/endpoints/docAccess.js +5 -0
- package/dist/globals/endpoints/docAccess.js.map +1 -1
- package/dist/globals/endpoints/findOne.d.ts.map +1 -1
- package/dist/globals/endpoints/findOne.js +5 -0
- package/dist/globals/endpoints/findOne.js.map +1 -1
- package/dist/globals/endpoints/findVersionByID.d.ts.map +1 -1
- package/dist/globals/endpoints/findVersionByID.js +5 -0
- package/dist/globals/endpoints/findVersionByID.js.map +1 -1
- package/dist/globals/endpoints/findVersions.d.ts.map +1 -1
- package/dist/globals/endpoints/findVersions.js +5 -0
- package/dist/globals/endpoints/findVersions.js.map +1 -1
- package/dist/globals/endpoints/preview.d.ts.map +1 -1
- package/dist/globals/endpoints/preview.js +5 -0
- package/dist/globals/endpoints/preview.js.map +1 -1
- package/dist/globals/endpoints/restoreVersion.d.ts.map +1 -1
- package/dist/globals/endpoints/restoreVersion.js +5 -0
- package/dist/globals/endpoints/restoreVersion.js.map +1 -1
- package/dist/globals/endpoints/update.d.ts.map +1 -1
- package/dist/globals/endpoints/update.js +5 -0
- package/dist/globals/endpoints/update.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/utilities/handleEndpoints.d.ts +3 -1
- package/dist/utilities/handleEndpoints.d.ts.map +1 -1
- package/dist/utilities/handleEndpoints.js +20 -18
- package/dist/utilities/handleEndpoints.js.map +1 -1
- package/dist/utilities/headersWithCors.d.ts +0 -5
- package/dist/utilities/headersWithCors.d.ts.map +1 -1
- package/dist/utilities/headersWithCors.js +0 -4
- package/dist/utilities/headersWithCors.js.map +1 -1
- package/dist/utilities/routeError.d.ts.map +1 -1
- package/dist/utilities/routeError.js +7 -0
- package/dist/utilities/routeError.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { status as httpStatus } from 'http-status';
|
|
2
2
|
import { getRequestCollectionWithID } from '../../utilities/getRequestEntity.js';
|
|
3
|
+
import { headersWithCors } from '../../utilities/headersWithCors.js';
|
|
3
4
|
import { isNumber } from '../../utilities/isNumber.js';
|
|
4
5
|
import { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js';
|
|
5
6
|
import { sanitizeSelectParam } from '../../utilities/sanitizeSelectParam.js';
|
|
@@ -18,10 +19,15 @@ export const deleteByIDHandler = async (req)=>{
|
|
|
18
19
|
req,
|
|
19
20
|
select: sanitizeSelectParam(req.query.select)
|
|
20
21
|
});
|
|
22
|
+
const headers = headersWithCors({
|
|
23
|
+
headers: new Headers(),
|
|
24
|
+
req
|
|
25
|
+
});
|
|
21
26
|
if (!doc) {
|
|
22
27
|
return Response.json({
|
|
23
28
|
message: req.t('general:notFound')
|
|
24
29
|
}, {
|
|
30
|
+
headers,
|
|
25
31
|
status: httpStatus.NOT_FOUND
|
|
26
32
|
});
|
|
27
33
|
}
|
|
@@ -29,6 +35,7 @@ export const deleteByIDHandler = async (req)=>{
|
|
|
29
35
|
doc,
|
|
30
36
|
message: req.t('general:deletedSuccessfully')
|
|
31
37
|
}, {
|
|
38
|
+
headers,
|
|
32
39
|
status: httpStatus.OK
|
|
33
40
|
});
|
|
34
41
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/endpoints/deleteByID.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollectionWithID } from '../../utilities/getRequestEntity.js'\nimport { isNumber } from '../../utilities/isNumber.js'\nimport { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js'\nimport { sanitizeSelectParam } from '../../utilities/sanitizeSelectParam.js'\nimport { deleteByIDOperation } from '../operations/deleteByID.js'\n\nexport const deleteByIDHandler: PayloadHandler = async (req) => {\n const { id, collection } = getRequestCollectionWithID(req)\n const { searchParams } = req\n const depth = searchParams.get('depth')\n const overrideLock = searchParams.get('overrideLock')\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 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":["status","httpStatus","getRequestCollectionWithID","isNumber","sanitizePopulateParam","sanitizeSelectParam","deleteByIDOperation","deleteByIDHandler","req","id","collection","searchParams","depth","get","overrideLock","doc","undefined","Boolean","populate","query","select","Response","json","message","t","NOT_FOUND","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,0BAA0B,QAAQ,sCAAqC;AAChF,SAASC,QAAQ,QAAQ,8BAA6B;AACtD,SAASC,qBAAqB,QAAQ,2CAA0C;AAChF,SAASC,mBAAmB,QAAQ,yCAAwC;AAC5E,SAASC,mBAAmB,QAAQ,8BAA6B;AAEjE,OAAO,MAAMC,oBAAoC,OAAOC;IACtD,MAAM,EAAEC,EAAE,EAAEC,UAAU,EAAE,
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/endpoints/deleteByID.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollectionWithID } from '../../utilities/getRequestEntity.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { isNumber } from '../../utilities/isNumber.js'\nimport { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js'\nimport { sanitizeSelectParam } from '../../utilities/sanitizeSelectParam.js'\nimport { deleteByIDOperation } from '../operations/deleteByID.js'\n\nexport const deleteByIDHandler: PayloadHandler = async (req) => {\n const { id, collection } = getRequestCollectionWithID(req)\n const { searchParams } = req\n const depth = searchParams.get('depth')\n const overrideLock = searchParams.get('overrideLock')\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"],"names":["status","httpStatus","getRequestCollectionWithID","headersWithCors","isNumber","sanitizePopulateParam","sanitizeSelectParam","deleteByIDOperation","deleteByIDHandler","req","id","collection","searchParams","depth","get","overrideLock","doc","undefined","Boolean","populate","query","select","headers","Headers","Response","json","message","t","NOT_FOUND","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,0BAA0B,QAAQ,sCAAqC;AAChF,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,QAAQ,QAAQ,8BAA6B;AACtD,SAASC,qBAAqB,QAAQ,2CAA0C;AAChF,SAASC,mBAAmB,QAAQ,yCAAwC;AAC5E,SAASC,mBAAmB,QAAQ,8BAA6B;AAEjE,OAAO,MAAMC,oBAAoC,OAAOC;IACtD,MAAM,EAAEC,EAAE,EAAEC,UAAU,EAAE,GAAGT,2BAA2BO;IACtD,MAAM,EAAEG,YAAY,EAAE,GAAGH;IACzB,MAAMI,QAAQD,aAAaE,GAAG,CAAC;IAC/B,MAAMC,eAAeH,aAAaE,GAAG,CAAC;IAEtC,MAAME,MAAM,MAAMT,oBAAoB;QACpCG;QACAC;QACAE,OAAOT,SAASS,SAASA,QAAQI;QACjCF,cAAcG,QAAQH,iBAAiB;QACvCI,UAAUd,sBAAsBI,IAAIW,KAAK,CAACD,QAAQ;QAClDV;QACAY,QAAQf,oBAAoBG,IAAIW,KAAK,CAACC,MAAM;IAC9C;IAEA,MAAMC,UAAUnB,gBAAgB;QAC9BmB,SAAS,IAAIC;QACbd;IACF;IAEA,IAAI,CAACO,KAAK;QACR,OAAOQ,SAASC,IAAI,CAClB;YACEC,SAASjB,IAAIkB,CAAC,CAAC;QACjB,GACA;YACEL;YACAtB,QAAQC,WAAW2B,SAAS;QAC9B;IAEJ;IAEA,OAAOJ,SAASC,IAAI,CAClB;QACET;QACAU,SAASjB,IAAIkB,CAAC,CAAC;IACjB,GACA;QACEL;QACAtB,QAAQC,WAAW4B,EAAE;IACvB;AAEJ,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docAccess.d.ts","sourceRoot":"","sources":["../../../src/collections/endpoints/docAccess.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"docAccess.d.ts","sourceRoot":"","sources":["../../../src/collections/endpoints/docAccess.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAM3D,eAAO,MAAM,gBAAgB,EAAE,cAe9B,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { status as httpStatus } from 'http-status';
|
|
2
2
|
import { getRequestCollectionWithID } from '../../utilities/getRequestEntity.js';
|
|
3
|
+
import { headersWithCors } from '../../utilities/headersWithCors.js';
|
|
3
4
|
import { docAccessOperation } from '../operations/docAccess.js';
|
|
4
5
|
export const docAccessHandler = async (req)=>{
|
|
5
6
|
const { id, collection } = getRequestCollectionWithID(req, {
|
|
@@ -11,6 +12,10 @@ export const docAccessHandler = async (req)=>{
|
|
|
11
12
|
req
|
|
12
13
|
});
|
|
13
14
|
return Response.json(result, {
|
|
15
|
+
headers: headersWithCors({
|
|
16
|
+
headers: new Headers(),
|
|
17
|
+
req
|
|
18
|
+
}),
|
|
14
19
|
status: httpStatus.OK
|
|
15
20
|
});
|
|
16
21
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/endpoints/docAccess.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollectionWithID } from '../../utilities/getRequestEntity.js'\nimport { docAccessOperation } from '../operations/docAccess.js'\n\nexport const docAccessHandler: PayloadHandler = async (req) => {\n const { id, collection } = getRequestCollectionWithID(req, { optionalID: true })\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":["status","httpStatus","getRequestCollectionWithID","docAccessOperation","docAccessHandler","req","id","collection","optionalID","result","Response","json","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,0BAA0B,QAAQ,sCAAqC;AAChF,SAASC,kBAAkB,QAAQ,6BAA4B;AAE/D,OAAO,MAAMC,mBAAmC,OAAOC;IACrD,MAAM,EAAEC,EAAE,EAAEC,UAAU,EAAE,
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/endpoints/docAccess.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollectionWithID } from '../../utilities/getRequestEntity.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { docAccessOperation } from '../operations/docAccess.js'\n\nexport const docAccessHandler: PayloadHandler = async (req) => {\n const { id, collection } = getRequestCollectionWithID(req, { optionalID: true })\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":["status","httpStatus","getRequestCollectionWithID","headersWithCors","docAccessOperation","docAccessHandler","req","id","collection","optionalID","result","Response","json","headers","Headers","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,0BAA0B,QAAQ,sCAAqC;AAChF,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,kBAAkB,QAAQ,6BAA4B;AAE/D,OAAO,MAAMC,mBAAmC,OAAOC;IACrD,MAAM,EAAEC,EAAE,EAAEC,UAAU,EAAE,GAAGN,2BAA2BI,KAAK;QAAEG,YAAY;IAAK;IAC9E,MAAMC,SAAS,MAAMN,mBAAmB;QACtCG;QACAC;QACAF;IACF;IAEA,OAAOK,SAASC,IAAI,CAACF,QAAQ;QAC3BG,SAASV,gBAAgB;YACvBU,SAAS,IAAIC;YACbR;QACF;QACAN,QAAQC,WAAWc,EAAE;IACvB;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"duplicate.d.ts","sourceRoot":"","sources":["../../../src/collections/endpoints/duplicate.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"duplicate.d.ts","sourceRoot":"","sources":["../../../src/collections/endpoints/duplicate.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAS3D,eAAO,MAAM,gBAAgB,EAAE,cAmC9B,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getTranslation } from '@payloadcms/translations';
|
|
2
2
|
import { status as httpStatus } from 'http-status';
|
|
3
3
|
import { getRequestCollectionWithID } from '../../utilities/getRequestEntity.js';
|
|
4
|
+
import { headersWithCors } from '../../utilities/headersWithCors.js';
|
|
4
5
|
import { isNumber } from '../../utilities/isNumber.js';
|
|
5
6
|
import { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js';
|
|
6
7
|
import { sanitizeSelectParam } from '../../utilities/sanitizeSelectParam.js';
|
|
@@ -28,6 +29,10 @@ export const duplicateHandler = async (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/collections/endpoints/duplicate.ts"],"sourcesContent":["import { getTranslation } from '@payloadcms/translations'\nimport { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollectionWithID } from '../../utilities/getRequestEntity.js'\nimport { isNumber } from '../../utilities/isNumber.js'\nimport { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js'\nimport { sanitizeSelectParam } from '../../utilities/sanitizeSelectParam.js'\nimport { duplicateOperation } from '../operations/duplicate.js'\n\nexport const duplicateHandler: PayloadHandler = async (req) => {\n const { id, collection } = getRequestCollectionWithID(req)\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 doc = await duplicateOperation({\n id,\n collection,\n data: req.data,\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 status: httpStatus.OK,\n },\n )\n}\n"],"names":["getTranslation","status","httpStatus","getRequestCollectionWithID","isNumber","sanitizePopulateParam","sanitizeSelectParam","duplicateOperation","duplicateHandler","req","id","collection","searchParams","depth","get","draft","doc","data","Number","undefined","populate","query","select","message","t","label","config","labels","singular","i18n","Response","json","OK"],"mappings":"AAAA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,0BAA0B,QAAQ,sCAAqC;AAChF,SAASC,QAAQ,QAAQ,8BAA6B;AACtD,SAASC,qBAAqB,QAAQ,2CAA0C;AAChF,SAASC,mBAAmB,QAAQ,yCAAwC;AAC5E,SAASC,kBAAkB,QAAQ,6BAA4B;AAE/D,OAAO,MAAMC,mBAAmC,OAAOC;IACrD,MAAM,EAAEC,EAAE,EAAEC,UAAU,EAAE,
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/endpoints/duplicate.ts"],"sourcesContent":["import { getTranslation } from '@payloadcms/translations'\nimport { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollectionWithID } from '../../utilities/getRequestEntity.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { isNumber } from '../../utilities/isNumber.js'\nimport { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js'\nimport { sanitizeSelectParam } from '../../utilities/sanitizeSelectParam.js'\nimport { duplicateOperation } from '../operations/duplicate.js'\n\nexport const duplicateHandler: PayloadHandler = async (req) => {\n const { id, collection } = getRequestCollectionWithID(req)\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 doc = await duplicateOperation({\n id,\n collection,\n data: req.data,\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"],"names":["getTranslation","status","httpStatus","getRequestCollectionWithID","headersWithCors","isNumber","sanitizePopulateParam","sanitizeSelectParam","duplicateOperation","duplicateHandler","req","id","collection","searchParams","depth","get","draft","doc","data","Number","undefined","populate","query","select","message","t","label","config","labels","singular","i18n","Response","json","headers","Headers","OK"],"mappings":"AAAA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,0BAA0B,QAAQ,sCAAqC;AAChF,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,QAAQ,QAAQ,8BAA6B;AACtD,SAASC,qBAAqB,QAAQ,2CAA0C;AAChF,SAASC,mBAAmB,QAAQ,yCAAwC;AAC5E,SAASC,kBAAkB,QAAQ,6BAA4B;AAE/D,OAAO,MAAMC,mBAAmC,OAAOC;IACrD,MAAM,EAAEC,EAAE,EAAEC,UAAU,EAAE,GAAGT,2BAA2BO;IACtD,MAAM,EAAEG,YAAY,EAAE,GAAGH;IACzB,MAAMI,QAAQD,aAAaE,GAAG,CAAC;IAC/B,iIAAiI;IACjI,MAAMC,QAAQH,aAAaE,GAAG,CAAC,aAAa;IAE5C,MAAME,MAAM,MAAMT,mBAAmB;QACnCG;QACAC;QACAM,MAAMR,IAAIQ,IAAI;QACdJ,OAAOT,SAASS,SAASK,OAAOL,SAASM;QACzCJ;QACAK,UAAUf,sBAAsBI,IAAIY,KAAK,CAACD,QAAQ;QAClDX;QACAa,QAAQhB,oBAAoBG,IAAIY,KAAK,CAACC,MAAM;IAC9C;IAEA,MAAMC,UAAUd,IAAIe,CAAC,CAAC,kCAAkC;QACtDC,OAAO1B,eAAeY,WAAWe,MAAM,CAACC,MAAM,CAACC,QAAQ,EAAEnB,IAAIoB,IAAI;IACnE;IAEA,OAAOC,SAASC,IAAI,CAClB;QACEf;QACAO;IACF,GACA;QACES,SAAS7B,gBAAgB;YACvB6B,SAAS,IAAIC;YACbxB;QACF;QACAT,QAAQC,WAAWiC,EAAE;IACvB;AAEJ,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../src/collections/endpoints/find.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../src/collections/endpoints/find.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAW3D,eAAO,MAAM,WAAW,EAAE,cAsCzB,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { status as httpStatus } from 'http-status';
|
|
2
2
|
import { getRequestCollection } from '../../utilities/getRequestEntity.js';
|
|
3
|
+
import { headersWithCors } from '../../utilities/headersWithCors.js';
|
|
3
4
|
import { isNumber } from '../../utilities/isNumber.js';
|
|
4
5
|
import { sanitizeJoinParams } from '../../utilities/sanitizeJoinParams.js';
|
|
5
6
|
import { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js';
|
|
@@ -23,6 +24,10 @@ export const findHandler = async (req)=>{
|
|
|
23
24
|
where
|
|
24
25
|
});
|
|
25
26
|
return Response.json(result, {
|
|
27
|
+
headers: headersWithCors({
|
|
28
|
+
headers: new Headers(),
|
|
29
|
+
req
|
|
30
|
+
}),
|
|
26
31
|
status: httpStatus.OK
|
|
27
32
|
});
|
|
28
33
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/endpoints/find.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\nimport type { JoinQuery, Where } from '../../types/index.js'\n\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { isNumber } from '../../utilities/isNumber.js'\nimport { sanitizeJoinParams } from '../../utilities/sanitizeJoinParams.js'\nimport { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js'\nimport { sanitizeSelectParam } from '../../utilities/sanitizeSelectParam.js'\nimport { findOperation } from '../operations/find.js'\n\nexport const findHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(req)\n const { depth, draft, joins, limit, page, pagination, populate, select, sort, where } =\n req.query as {\n depth?: string\n draft?: string\n joins?: JoinQuery\n limit?: string\n page?: string\n pagination?: string\n populate?: Record<string, unknown>\n select?: Record<string, unknown>\n sort?: string\n where?: Where\n }\n\n const result = await 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 pagination: pagination === 'false' ? false : undefined,\n populate: sanitizePopulateParam(populate),\n req,\n select: sanitizeSelectParam(select),\n sort: typeof sort === 'string' ? sort.split(',') : undefined,\n where,\n })\n\n return Response.json(result, {\n status: httpStatus.OK,\n })\n}\n"],"names":["status","httpStatus","getRequestCollection","isNumber","sanitizeJoinParams","sanitizePopulateParam","sanitizeSelectParam","findOperation","findHandler","req","collection","depth","draft","joins","limit","page","pagination","populate","select","sort","where","query","result","Number","undefined","split","Response","json","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAKlD,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,QAAQ,QAAQ,8BAA6B;AACtD,SAASC,kBAAkB,QAAQ,wCAAuC;AAC1E,SAASC,qBAAqB,QAAQ,2CAA0C;AAChF,SAASC,mBAAmB,QAAQ,yCAAwC;AAC5E,SAASC,aAAa,QAAQ,wBAAuB;AAErD,OAAO,MAAMC,cAA8B,OAAOC;IAChD,MAAMC,
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/endpoints/find.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\nimport type { JoinQuery, Where } from '../../types/index.js'\n\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { isNumber } from '../../utilities/isNumber.js'\nimport { sanitizeJoinParams } from '../../utilities/sanitizeJoinParams.js'\nimport { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js'\nimport { sanitizeSelectParam } from '../../utilities/sanitizeSelectParam.js'\nimport { findOperation } from '../operations/find.js'\n\nexport const findHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(req)\n const { depth, draft, joins, limit, page, pagination, populate, select, sort, where } =\n req.query as {\n depth?: string\n draft?: string\n joins?: JoinQuery\n limit?: string\n page?: string\n pagination?: string\n populate?: Record<string, unknown>\n select?: Record<string, unknown>\n sort?: string\n where?: Where\n }\n\n const result = await 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 pagination: pagination === 'false' ? false : undefined,\n populate: sanitizePopulateParam(populate),\n req,\n select: sanitizeSelectParam(select),\n sort: typeof sort === 'string' ? sort.split(',') : undefined,\n where,\n })\n\n return Response.json(result, {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n })\n}\n"],"names":["status","httpStatus","getRequestCollection","headersWithCors","isNumber","sanitizeJoinParams","sanitizePopulateParam","sanitizeSelectParam","findOperation","findHandler","req","collection","depth","draft","joins","limit","page","pagination","populate","select","sort","where","query","result","Number","undefined","split","Response","json","headers","Headers","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAKlD,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,QAAQ,QAAQ,8BAA6B;AACtD,SAASC,kBAAkB,QAAQ,wCAAuC;AAC1E,SAASC,qBAAqB,QAAQ,2CAA0C;AAChF,SAASC,mBAAmB,QAAQ,yCAAwC;AAC5E,SAASC,aAAa,QAAQ,wBAAuB;AAErD,OAAO,MAAMC,cAA8B,OAAOC;IAChD,MAAMC,aAAaT,qBAAqBQ;IACxC,MAAM,EAAEE,KAAK,EAAEC,KAAK,EAAEC,KAAK,EAAEC,KAAK,EAAEC,IAAI,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAE,GACnFX,IAAIY,KAAK;IAaX,MAAMC,SAAS,MAAMf,cAAc;QACjCG;QACAC,OAAOR,SAASQ,SAASY,OAAOZ,SAASa;QACzCZ,OAAOA,UAAU;QACjBC,OAAOT,mBAAmBS;QAC1BC,OAAOX,SAASW,SAASS,OAAOT,SAASU;QACzCT,MAAMZ,SAASY,QAAQQ,OAAOR,QAAQS;QACtCR,YAAYA,eAAe,UAAU,QAAQQ;QAC7CP,UAAUZ,sBAAsBY;QAChCR;QACAS,QAAQZ,oBAAoBY;QAC5BC,MAAM,OAAOA,SAAS,WAAWA,KAAKM,KAAK,CAAC,OAAOD;QACnDJ;IACF;IAEA,OAAOM,SAASC,IAAI,CAACL,QAAQ;QAC3BM,SAAS1B,gBAAgB;YACvB0B,SAAS,IAAIC;YACbpB;QACF;QACAV,QAAQC,WAAW8B,EAAE;IACvB;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findByID.d.ts","sourceRoot":"","sources":["../../../src/collections/endpoints/findByID.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"findByID.d.ts","sourceRoot":"","sources":["../../../src/collections/endpoints/findByID.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAW3D,eAAO,MAAM,eAAe,EAAE,cAuB7B,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { status as httpStatus } from 'http-status';
|
|
2
2
|
import { getRequestCollectionWithID } from '../../utilities/getRequestEntity.js';
|
|
3
|
+
import { headersWithCors } from '../../utilities/headersWithCors.js';
|
|
3
4
|
import { isNumber } from '../../utilities/isNumber.js';
|
|
4
5
|
import { sanitizeJoinParams } from '../../utilities/sanitizeJoinParams.js';
|
|
5
6
|
import { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js';
|
|
@@ -20,6 +21,10 @@ export const findByIDHandler = async (req)=>{
|
|
|
20
21
|
select: sanitizeSelectParam(req.query.select)
|
|
21
22
|
});
|
|
22
23
|
return Response.json(result, {
|
|
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/collections/endpoints/findByID.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\nimport type { JoinQuery } from '../../types/index.js'\n\nimport { getRequestCollectionWithID } from '../../utilities/getRequestEntity.js'\nimport { isNumber } from '../../utilities/isNumber.js'\nimport { sanitizeJoinParams } from '../../utilities/sanitizeJoinParams.js'\nimport { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js'\nimport { sanitizeSelectParam } from '../../utilities/sanitizeSelectParam.js'\nimport { findByIDOperation } from '../operations/findByID.js'\n\nexport const findByIDHandler: PayloadHandler = async (req) => {\n const { searchParams } = req\n const { id, collection } = getRequestCollectionWithID(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 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 status: httpStatus.OK,\n })\n}\n"],"names":["status","httpStatus","getRequestCollectionWithID","isNumber","sanitizeJoinParams","sanitizePopulateParam","sanitizeSelectParam","findByIDOperation","findByIDHandler","req","searchParams","id","collection","depth","get","result","Number","undefined","draft","joins","query","populate","select","Response","json","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAKlD,SAASC,0BAA0B,QAAQ,sCAAqC;AAChF,SAASC,QAAQ,QAAQ,8BAA6B;AACtD,SAASC,kBAAkB,QAAQ,wCAAuC;AAC1E,SAASC,qBAAqB,QAAQ,2CAA0C;AAChF,SAASC,mBAAmB,QAAQ,yCAAwC;AAC5E,SAASC,iBAAiB,QAAQ,4BAA2B;AAE7D,OAAO,MAAMC,kBAAkC,OAAOC;IACpD,MAAM,EAAEC,YAAY,EAAE,GAAGD;IACzB,MAAM,EAAEE,EAAE,EAAEC,UAAU,EAAE,
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/endpoints/findByID.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\nimport type { JoinQuery } from '../../types/index.js'\n\nimport { getRequestCollectionWithID } from '../../utilities/getRequestEntity.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { isNumber } from '../../utilities/isNumber.js'\nimport { sanitizeJoinParams } from '../../utilities/sanitizeJoinParams.js'\nimport { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js'\nimport { sanitizeSelectParam } from '../../utilities/sanitizeSelectParam.js'\nimport { findByIDOperation } from '../operations/findByID.js'\n\nexport const findByIDHandler: PayloadHandler = async (req) => {\n const { searchParams } = req\n const { id, collection } = getRequestCollectionWithID(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 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"],"names":["status","httpStatus","getRequestCollectionWithID","headersWithCors","isNumber","sanitizeJoinParams","sanitizePopulateParam","sanitizeSelectParam","findByIDOperation","findByIDHandler","req","searchParams","id","collection","depth","get","result","Number","undefined","draft","joins","query","populate","select","Response","json","headers","Headers","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAKlD,SAASC,0BAA0B,QAAQ,sCAAqC;AAChF,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,QAAQ,QAAQ,8BAA6B;AACtD,SAASC,kBAAkB,QAAQ,wCAAuC;AAC1E,SAASC,qBAAqB,QAAQ,2CAA0C;AAChF,SAASC,mBAAmB,QAAQ,yCAAwC;AAC5E,SAASC,iBAAiB,QAAQ,4BAA2B;AAE7D,OAAO,MAAMC,kBAAkC,OAAOC;IACpD,MAAM,EAAEC,YAAY,EAAE,GAAGD;IACzB,MAAM,EAAEE,EAAE,EAAEC,UAAU,EAAE,GAAGX,2BAA2BQ;IACtD,MAAMI,QAAQH,aAAaI,GAAG,CAAC;IAE/B,MAAMC,SAAS,MAAMR,kBAAkB;QACrCI;QACAC;QACAC,OAAOV,SAASU,SAASG,OAAOH,SAASI;QACzCC,OAAOR,aAAaI,GAAG,CAAC,aAAa;QACrCK,OAAOf,mBAAmBK,IAAIW,KAAK,CAACD,KAAK;QACzCE,UAAUhB,sBAAsBI,IAAIW,KAAK,CAACC,QAAQ;QAClDZ;QACAa,QAAQhB,oBAAoBG,IAAIW,KAAK,CAACE,MAAM;IAC9C;IAEA,OAAOC,SAASC,IAAI,CAACT,QAAQ;QAC3BU,SAASvB,gBAAgB;YACvBuB,SAAS,IAAIC;YACbjB;QACF;QACAV,QAAQC,WAAW2B,EAAE;IACvB;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findVersionByID.d.ts","sourceRoot":"","sources":["../../../src/collections/endpoints/findVersionByID.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"findVersionByID.d.ts","sourceRoot":"","sources":["../../../src/collections/endpoints/findVersionByID.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAS3D,eAAO,MAAM,sBAAsB,EAAE,cAsBpC,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { status as httpStatus } from 'http-status';
|
|
2
2
|
import { getRequestCollectionWithID } from '../../utilities/getRequestEntity.js';
|
|
3
|
+
import { headersWithCors } from '../../utilities/headersWithCors.js';
|
|
3
4
|
import { isNumber } from '../../utilities/isNumber.js';
|
|
4
5
|
import { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js';
|
|
5
6
|
import { sanitizeSelectParam } from '../../utilities/sanitizeSelectParam.js';
|
|
@@ -17,6 +18,10 @@ export const findVersionByIDHandler = async (req)=>{
|
|
|
17
18
|
select: sanitizeSelectParam(req.query.select)
|
|
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/collections/endpoints/findVersionByID.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollectionWithID } from '../../utilities/getRequestEntity.js'\nimport { isNumber } from '../../utilities/isNumber.js'\nimport { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js'\nimport { sanitizeSelectParam } from '../../utilities/sanitizeSelectParam.js'\nimport { findVersionByIDOperation } from '../operations/findVersionByID.js'\n\nexport const findVersionByIDHandler: PayloadHandler = async (req) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n\n const { id, collection } = getRequestCollectionWithID(req)\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 status: httpStatus.OK,\n })\n}\n"],"names":["status","httpStatus","getRequestCollectionWithID","isNumber","sanitizePopulateParam","sanitizeSelectParam","findVersionByIDOperation","findVersionByIDHandler","req","searchParams","depth","get","id","collection","result","Number","undefined","populate","query","select","Response","json","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,0BAA0B,QAAQ,sCAAqC;AAChF,SAASC,QAAQ,QAAQ,8BAA6B;AACtD,SAASC,qBAAqB,QAAQ,2CAA0C;AAChF,SAASC,mBAAmB,QAAQ,yCAAwC;AAC5E,SAASC,wBAAwB,QAAQ,mCAAkC;AAE3E,OAAO,MAAMC,yBAAyC,OAAOC;IAC3D,MAAM,EAAEC,YAAY,EAAE,GAAGD;IACzB,MAAME,QAAQD,aAAaE,GAAG,CAAC;IAE/B,MAAM,EAAEC,EAAE,EAAEC,UAAU,EAAE,
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/endpoints/findVersionByID.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollectionWithID } from '../../utilities/getRequestEntity.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { isNumber } from '../../utilities/isNumber.js'\nimport { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js'\nimport { sanitizeSelectParam } from '../../utilities/sanitizeSelectParam.js'\nimport { findVersionByIDOperation } from '../operations/findVersionByID.js'\n\nexport const findVersionByIDHandler: PayloadHandler = async (req) => {\n const { searchParams } = req\n const depth = searchParams.get('depth')\n\n const { id, collection } = getRequestCollectionWithID(req)\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"],"names":["status","httpStatus","getRequestCollectionWithID","headersWithCors","isNumber","sanitizePopulateParam","sanitizeSelectParam","findVersionByIDOperation","findVersionByIDHandler","req","searchParams","depth","get","id","collection","result","Number","undefined","populate","query","select","Response","json","headers","Headers","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,0BAA0B,QAAQ,sCAAqC;AAChF,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,QAAQ,QAAQ,8BAA6B;AACtD,SAASC,qBAAqB,QAAQ,2CAA0C;AAChF,SAASC,mBAAmB,QAAQ,yCAAwC;AAC5E,SAASC,wBAAwB,QAAQ,mCAAkC;AAE3E,OAAO,MAAMC,yBAAyC,OAAOC;IAC3D,MAAM,EAAEC,YAAY,EAAE,GAAGD;IACzB,MAAME,QAAQD,aAAaE,GAAG,CAAC;IAE/B,MAAM,EAAEC,EAAE,EAAEC,UAAU,EAAE,GAAGZ,2BAA2BO;IAEtD,MAAMM,SAAS,MAAMR,yBAAyB;QAC5CM;QACAC;QACAH,OAAOP,SAASO,SAASK,OAAOL,SAASM;QACzCC,UAAUb,sBAAsBI,IAAIU,KAAK,CAACD,QAAQ;QAClDT;QACAW,QAAQd,oBAAoBG,IAAIU,KAAK,CAACC,MAAM;IAC9C;IAEA,OAAOC,SAASC,IAAI,CAACP,QAAQ;QAC3BQ,SAASpB,gBAAgB;YACvBoB,SAAS,IAAIC;YACbf;QACF;QACAT,QAAQC,WAAWwB,EAAE;IACvB;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findVersions.d.ts","sourceRoot":"","sources":["../../../src/collections/endpoints/findVersions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"findVersions.d.ts","sourceRoot":"","sources":["../../../src/collections/endpoints/findVersions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAU3D,eAAO,MAAM,mBAAmB,EAAE,cAiCjC,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { status as httpStatus } from 'http-status';
|
|
2
2
|
import { getRequestCollection } from '../../utilities/getRequestEntity.js';
|
|
3
|
+
import { headersWithCors } from '../../utilities/headersWithCors.js';
|
|
3
4
|
import { isNumber } from '../../utilities/isNumber.js';
|
|
4
5
|
import { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js';
|
|
5
6
|
import { sanitizeSelectParam } from '../../utilities/sanitizeSelectParam.js';
|
|
@@ -20,6 +21,10 @@ export const findVersionsHandler = async (req)=>{
|
|
|
20
21
|
where
|
|
21
22
|
});
|
|
22
23
|
return Response.json(result, {
|
|
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/collections/endpoints/findVersions.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\nimport type { Where } from '../../types/index.js'\n\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { isNumber } from '../../utilities/isNumber.js'\nimport { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js'\nimport { sanitizeSelectParam } from '../../utilities/sanitizeSelectParam.js'\nimport { findVersionsOperation } from '../operations/findVersions.js'\n\nexport const findVersionsHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(req)\n const { depth, limit, page, pagination, populate, select, sort, where } = req.query as {\n depth?: string\n limit?: string\n page?: string\n pagination?: string\n populate?: Record<string, unknown>\n select?: Record<string, unknown>\n sort?: string\n where?: Where\n }\n\n const result = await 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 pagination: pagination === 'false' ? false : undefined,\n populate: sanitizePopulateParam(populate),\n req,\n select: sanitizeSelectParam(select),\n sort: typeof sort === 'string' ? sort.split(',') : undefined,\n where,\n })\n\n return Response.json(result, {\n status: httpStatus.OK,\n })\n}\n"],"names":["status","httpStatus","getRequestCollection","isNumber","sanitizePopulateParam","sanitizeSelectParam","findVersionsOperation","findVersionsHandler","req","collection","depth","limit","page","pagination","populate","select","sort","where","query","result","Number","undefined","split","Response","json","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAKlD,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,QAAQ,QAAQ,8BAA6B;AACtD,SAASC,qBAAqB,QAAQ,2CAA0C;AAChF,SAASC,mBAAmB,QAAQ,yCAAwC;AAC5E,SAASC,qBAAqB,QAAQ,gCAA+B;AAErE,OAAO,MAAMC,sBAAsC,OAAOC;IACxD,MAAMC,
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/endpoints/findVersions.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\nimport type { Where } from '../../types/index.js'\n\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { isNumber } from '../../utilities/isNumber.js'\nimport { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js'\nimport { sanitizeSelectParam } from '../../utilities/sanitizeSelectParam.js'\nimport { findVersionsOperation } from '../operations/findVersions.js'\n\nexport const findVersionsHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(req)\n const { depth, limit, page, pagination, populate, select, sort, where } = req.query as {\n depth?: string\n limit?: string\n page?: string\n pagination?: string\n populate?: Record<string, unknown>\n select?: Record<string, unknown>\n sort?: string\n where?: Where\n }\n\n const result = await 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 pagination: pagination === 'false' ? false : undefined,\n populate: sanitizePopulateParam(populate),\n req,\n select: sanitizeSelectParam(select),\n sort: typeof sort === 'string' ? sort.split(',') : undefined,\n where,\n })\n\n return Response.json(result, {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n })\n}\n"],"names":["status","httpStatus","getRequestCollection","headersWithCors","isNumber","sanitizePopulateParam","sanitizeSelectParam","findVersionsOperation","findVersionsHandler","req","collection","depth","limit","page","pagination","populate","select","sort","where","query","result","Number","undefined","split","Response","json","headers","Headers","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAKlD,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,QAAQ,QAAQ,8BAA6B;AACtD,SAASC,qBAAqB,QAAQ,2CAA0C;AAChF,SAASC,mBAAmB,QAAQ,yCAAwC;AAC5E,SAASC,qBAAqB,QAAQ,gCAA+B;AAErE,OAAO,MAAMC,sBAAsC,OAAOC;IACxD,MAAMC,aAAaR,qBAAqBO;IACxC,MAAM,EAAEE,KAAK,EAAEC,KAAK,EAAEC,IAAI,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAE,GAAGT,IAAIU,KAAK;IAWnF,MAAMC,SAAS,MAAMb,sBAAsB;QACzCG;QACAC,OAAOP,SAASO,SAASU,OAAOV,SAASW;QACzCV,OAAOR,SAASQ,SAASS,OAAOT,SAASU;QACzCT,MAAMT,SAASS,QAAQQ,OAAOR,QAAQS;QACtCR,YAAYA,eAAe,UAAU,QAAQQ;QAC7CP,UAAUV,sBAAsBU;QAChCN;QACAO,QAAQV,oBAAoBU;QAC5BC,MAAM,OAAOA,SAAS,WAAWA,KAAKM,KAAK,CAAC,OAAOD;QACnDJ;IACF;IAEA,OAAOM,SAASC,IAAI,CAACL,QAAQ;QAC3BM,SAASvB,gBAAgB;YACvBuB,SAAS,IAAIC;YACblB;QACF;QACAT,QAAQC,WAAW2B,EAAE;IACvB;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFile.d.ts","sourceRoot":"","sources":["../../../src/collections/endpoints/getFile.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"getFile.d.ts","sourceRoot":"","sources":["../../../src/collections/endpoints/getFile.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAS3D,eAAO,MAAM,cAAc,EAAE,cA2D5B,CAAA"}
|
|
@@ -7,6 +7,7 @@ import { checkFileAccess } from '../../uploads/checkFileAccess.js';
|
|
|
7
7
|
import { streamFile } from '../../uploads/fetchAPI-stream-file/index.js';
|
|
8
8
|
import { getFileTypeFallback } from '../../uploads/getFileTypeFallback.js';
|
|
9
9
|
import { getRequestCollection } from '../../utilities/getRequestEntity.js';
|
|
10
|
+
import { headersWithCors } from '../../utilities/headersWithCors.js';
|
|
10
11
|
export const getFileHandler = async (req)=>{
|
|
11
12
|
const collection = getRequestCollection(req);
|
|
12
13
|
const filename = req.routeParams.filename;
|
|
@@ -48,7 +49,10 @@ export const getFileHandler = async (req)=>{
|
|
|
48
49
|
headers
|
|
49
50
|
}) : headers;
|
|
50
51
|
return new Response(data, {
|
|
51
|
-
headers
|
|
52
|
+
headers: headersWithCors({
|
|
53
|
+
headers,
|
|
54
|
+
req
|
|
55
|
+
}),
|
|
52
56
|
status: httpStatus.OK
|
|
53
57
|
});
|
|
54
58
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/endpoints/getFile.ts"],"sourcesContent":["import { fileTypeFromFile } from 'file-type'\nimport fsPromises from 'fs/promises'\nimport { status as httpStatus } from 'http-status'\nimport path from 'path'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { APIError } from '../../errors/APIError.js'\nimport { checkFileAccess } from '../../uploads/checkFileAccess.js'\nimport { streamFile } from '../../uploads/fetchAPI-stream-file/index.js'\nimport { getFileTypeFallback } from '../../uploads/getFileTypeFallback.js'\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\n\nexport const getFileHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(req)\n\n const filename = req.routeParams.filename as string\n\n if (!collection.config.upload) {\n throw new APIError(\n `This collection is not an upload collection: ${collection.config.slug}`,\n httpStatus.BAD_REQUEST,\n )\n }\n\n const accessResult = await checkFileAccess({\n collection,\n filename,\n req,\n })\n\n if (accessResult instanceof Response) {\n return accessResult\n }\n\n if (collection.config.upload.handlers?.length) {\n let customResponse = null\n for (const handler of collection.config.upload.handlers) {\n customResponse = await handler(req, {\n doc: accessResult,\n params: {\n collection: collection.config.slug,\n filename,\n },\n })\n }\n\n if (customResponse instanceof Response) {\n return customResponse\n }\n }\n\n const fileDir = collection.config.upload?.staticDir || collection.config.slug\n const filePath = path.resolve(`${fileDir}/${filename}`)\n const stats = await fsPromises.stat(filePath)\n const data = streamFile(filePath)\n const fileTypeResult = (await fileTypeFromFile(filePath)) || getFileTypeFallback(filePath)\n\n let headers = new Headers()\n headers.set('Content-Type', fileTypeResult.mime)\n headers.set('Content-Length', stats.size + '')\n headers = collection.config.upload?.modifyResponseHeaders\n ? collection.config.upload.modifyResponseHeaders({ headers })\n : headers\n\n return new Response(data, {\n headers,\n status: httpStatus.OK,\n })\n}\n"],"names":["fileTypeFromFile","fsPromises","status","httpStatus","path","APIError","checkFileAccess","streamFile","getFileTypeFallback","getRequestCollection","getFileHandler","req","collection","filename","routeParams","config","upload","slug","BAD_REQUEST","accessResult","Response","handlers","length","customResponse","handler","doc","params","fileDir","staticDir","filePath","resolve","stats","stat","data","fileTypeResult","headers","Headers","set","mime","size","modifyResponseHeaders","OK"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,YAAW;AAC5C,OAAOC,gBAAgB,cAAa;AACpC,SAASC,UAAUC,UAAU,QAAQ,cAAa;AAClD,OAAOC,UAAU,OAAM;AAIvB,SAASC,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,eAAe,QAAQ,mCAAkC;AAClE,SAASC,UAAU,QAAQ,8CAA6C;AACxE,SAASC,mBAAmB,QAAQ,uCAAsC;AAC1E,SAASC,oBAAoB,QAAQ,sCAAqC;
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/endpoints/getFile.ts"],"sourcesContent":["import { fileTypeFromFile } from 'file-type'\nimport fsPromises from 'fs/promises'\nimport { status as httpStatus } from 'http-status'\nimport path from 'path'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { APIError } from '../../errors/APIError.js'\nimport { checkFileAccess } from '../../uploads/checkFileAccess.js'\nimport { streamFile } from '../../uploads/fetchAPI-stream-file/index.js'\nimport { getFileTypeFallback } from '../../uploads/getFileTypeFallback.js'\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\n\nexport const getFileHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(req)\n\n const filename = req.routeParams.filename as string\n\n if (!collection.config.upload) {\n throw new APIError(\n `This collection is not an upload collection: ${collection.config.slug}`,\n httpStatus.BAD_REQUEST,\n )\n }\n\n const accessResult = await checkFileAccess({\n collection,\n filename,\n req,\n })\n\n if (accessResult instanceof Response) {\n return accessResult\n }\n\n if (collection.config.upload.handlers?.length) {\n let customResponse = null\n for (const handler of collection.config.upload.handlers) {\n customResponse = await handler(req, {\n doc: accessResult,\n params: {\n collection: collection.config.slug,\n filename,\n },\n })\n }\n\n if (customResponse instanceof Response) {\n return customResponse\n }\n }\n\n const fileDir = collection.config.upload?.staticDir || collection.config.slug\n const filePath = path.resolve(`${fileDir}/${filename}`)\n const stats = await fsPromises.stat(filePath)\n const data = streamFile(filePath)\n const fileTypeResult = (await fileTypeFromFile(filePath)) || getFileTypeFallback(filePath)\n\n let headers = new Headers()\n headers.set('Content-Type', fileTypeResult.mime)\n headers.set('Content-Length', stats.size + '')\n headers = collection.config.upload?.modifyResponseHeaders\n ? collection.config.upload.modifyResponseHeaders({ headers })\n : headers\n\n return new Response(data, {\n headers: headersWithCors({\n headers,\n req,\n }),\n status: httpStatus.OK,\n })\n}\n"],"names":["fileTypeFromFile","fsPromises","status","httpStatus","path","APIError","checkFileAccess","streamFile","getFileTypeFallback","getRequestCollection","headersWithCors","getFileHandler","req","collection","filename","routeParams","config","upload","slug","BAD_REQUEST","accessResult","Response","handlers","length","customResponse","handler","doc","params","fileDir","staticDir","filePath","resolve","stats","stat","data","fileTypeResult","headers","Headers","set","mime","size","modifyResponseHeaders","OK"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,YAAW;AAC5C,OAAOC,gBAAgB,cAAa;AACpC,SAASC,UAAUC,UAAU,QAAQ,cAAa;AAClD,OAAOC,UAAU,OAAM;AAIvB,SAASC,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,eAAe,QAAQ,mCAAkC;AAClE,SAASC,UAAU,QAAQ,8CAA6C;AACxE,SAASC,mBAAmB,QAAQ,uCAAsC;AAC1E,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,eAAe,QAAQ,qCAAoC;AAEpE,OAAO,MAAMC,iBAAiC,OAAOC;IACnD,MAAMC,aAAaJ,qBAAqBG;IAExC,MAAME,WAAWF,IAAIG,WAAW,CAACD,QAAQ;IAEzC,IAAI,CAACD,WAAWG,MAAM,CAACC,MAAM,EAAE;QAC7B,MAAM,IAAIZ,SACR,CAAC,6CAA6C,EAAEQ,WAAWG,MAAM,CAACE,IAAI,EAAE,EACxEf,WAAWgB,WAAW;IAE1B;IAEA,MAAMC,eAAe,MAAMd,gBAAgB;QACzCO;QACAC;QACAF;IACF;IAEA,IAAIQ,wBAAwBC,UAAU;QACpC,OAAOD;IACT;IAEA,IAAIP,WAAWG,MAAM,CAACC,MAAM,CAACK,QAAQ,EAAEC,QAAQ;QAC7C,IAAIC,iBAAiB;QACrB,KAAK,MAAMC,WAAWZ,WAAWG,MAAM,CAACC,MAAM,CAACK,QAAQ,CAAE;YACvDE,iBAAiB,MAAMC,QAAQb,KAAK;gBAClCc,KAAKN;gBACLO,QAAQ;oBACNd,YAAYA,WAAWG,MAAM,CAACE,IAAI;oBAClCJ;gBACF;YACF;QACF;QAEA,IAAIU,0BAA0BH,UAAU;YACtC,OAAOG;QACT;IACF;IAEA,MAAMI,UAAUf,WAAWG,MAAM,CAACC,MAAM,EAAEY,aAAahB,WAAWG,MAAM,CAACE,IAAI;IAC7E,MAAMY,WAAW1B,KAAK2B,OAAO,CAAC,GAAGH,QAAQ,CAAC,EAAEd,UAAU;IACtD,MAAMkB,QAAQ,MAAM/B,WAAWgC,IAAI,CAACH;IACpC,MAAMI,OAAO3B,WAAWuB;IACxB,MAAMK,iBAAiB,AAAC,MAAMnC,iBAAiB8B,aAActB,oBAAoBsB;IAEjF,IAAIM,UAAU,IAAIC;IAClBD,QAAQE,GAAG,CAAC,gBAAgBH,eAAeI,IAAI;IAC/CH,QAAQE,GAAG,CAAC,kBAAkBN,MAAMQ,IAAI,GAAG;IAC3CJ,UAAUvB,WAAWG,MAAM,CAACC,MAAM,EAAEwB,wBAChC5B,WAAWG,MAAM,CAACC,MAAM,CAACwB,qBAAqB,CAAC;QAAEL;IAAQ,KACzDA;IAEJ,OAAO,IAAIf,SAASa,MAAM;QACxBE,SAAS1B,gBAAgB;YACvB0B;YACAxB;QACF;QACAV,QAAQC,WAAWuC,EAAE;IACvB;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../src/collections/endpoints/preview.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../src/collections/endpoints/preview.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAQ3D,eAAO,MAAM,cAAc,EAAE,cAmC5B,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { status as httpStatus } from 'http-status';
|
|
2
2
|
import { extractJWT } from '../../auth/extractJWT.js';
|
|
3
3
|
import { getRequestCollectionWithID } from '../../utilities/getRequestEntity.js';
|
|
4
|
+
import { headersWithCors } from '../../utilities/headersWithCors.js';
|
|
4
5
|
import { isNumber } from '../../utilities/isNumber.js';
|
|
5
6
|
import { findByIDOperation } from '../operations/findByID.js';
|
|
6
7
|
export const previewHandler = async (req)=>{
|
|
@@ -25,6 +26,10 @@ export const previewHandler = async (req)=>{
|
|
|
25
26
|
});
|
|
26
27
|
}
|
|
27
28
|
return Response.json(previewURL, {
|
|
29
|
+
headers: headersWithCors({
|
|
30
|
+
headers: new Headers(),
|
|
31
|
+
req
|
|
32
|
+
}),
|
|
28
33
|
status: httpStatus.OK
|
|
29
34
|
});
|
|
30
35
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/endpoints/preview.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { extractJWT } from '../../auth/extractJWT.js'\nimport { getRequestCollectionWithID } from '../../utilities/getRequestEntity.js'\nimport { isNumber } from '../../utilities/isNumber.js'\nimport { findByIDOperation } from '../operations/findByID.js'\n\nexport const previewHandler: PayloadHandler = async (req) => {\n const { id, collection } = getRequestCollectionWithID(req)\n const { searchParams } = req\n const depth = searchParams.get('depth')\n\n const doc = 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 =\n req.payload?.collections?.[collection.config.slug]?.config?.admin?.preview\n\n const token = extractJWT(req)\n\n if (typeof generatePreviewURL === 'function') {\n previewURL = await generatePreviewURL(doc, {\n locale: req.locale,\n req,\n token,\n })\n }\n\n return Response.json(previewURL, {\n status: httpStatus.OK,\n })\n}\n"],"names":["status","httpStatus","extractJWT","getRequestCollectionWithID","isNumber","findByIDOperation","previewHandler","req","id","collection","searchParams","depth","get","doc","Number","undefined","draft","previewURL","generatePreviewURL","payload","collections","config","slug","admin","preview","token","locale","Response","json","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,UAAU,QAAQ,2BAA0B;AACrD,SAASC,0BAA0B,QAAQ,sCAAqC;AAChF,SAASC,QAAQ,QAAQ,8BAA6B;AACtD,SAASC,iBAAiB,QAAQ,4BAA2B;AAE7D,OAAO,MAAMC,iBAAiC,OAAOC;IACnD,MAAM,EAAEC,EAAE,EAAEC,UAAU,EAAE,
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/endpoints/preview.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { extractJWT } from '../../auth/extractJWT.js'\nimport { getRequestCollectionWithID } from '../../utilities/getRequestEntity.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { isNumber } from '../../utilities/isNumber.js'\nimport { findByIDOperation } from '../operations/findByID.js'\n\nexport const previewHandler: PayloadHandler = async (req) => {\n const { id, collection } = getRequestCollectionWithID(req)\n const { searchParams } = req\n const depth = searchParams.get('depth')\n\n const doc = 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 =\n req.payload?.collections?.[collection.config.slug]?.config?.admin?.preview\n\n const token = extractJWT(req)\n\n if (typeof generatePreviewURL === 'function') {\n previewURL = await generatePreviewURL(doc, {\n locale: req.locale,\n req,\n token,\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":["status","httpStatus","extractJWT","getRequestCollectionWithID","headersWithCors","isNumber","findByIDOperation","previewHandler","req","id","collection","searchParams","depth","get","doc","Number","undefined","draft","previewURL","generatePreviewURL","payload","collections","config","slug","admin","preview","token","locale","Response","json","headers","Headers","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,UAAU,QAAQ,2BAA0B;AACrD,SAASC,0BAA0B,QAAQ,sCAAqC;AAChF,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,QAAQ,QAAQ,8BAA6B;AACtD,SAASC,iBAAiB,QAAQ,4BAA2B;AAE7D,OAAO,MAAMC,iBAAiC,OAAOC;IACnD,MAAM,EAAEC,EAAE,EAAEC,UAAU,EAAE,GAAGP,2BAA2BK;IACtD,MAAM,EAAEG,YAAY,EAAE,GAAGH;IACzB,MAAMI,QAAQD,aAAaE,GAAG,CAAC;IAE/B,MAAMC,MAAM,MAAMR,kBAAkB;QAClCG;QACAC;QACAE,OAAOP,SAASO,SAASG,OAAOH,SAASI;QACzCC,OAAON,aAAaE,GAAG,CAAC,aAAa;QACrCL;IACF;IAEA,IAAIU;IAEJ,MAAMC,qBACJX,IAAIY,OAAO,EAAEC,aAAa,CAACX,WAAWY,MAAM,CAACC,IAAI,CAAC,EAAED,QAAQE,OAAOC;IAErE,MAAMC,QAAQxB,WAAWM;IAEzB,IAAI,OAAOW,uBAAuB,YAAY;QAC5CD,aAAa,MAAMC,mBAAmBL,KAAK;YACzCa,QAAQnB,IAAImB,MAAM;YAClBnB;YACAkB;QACF;IACF;IAEA,OAAOE,SAASC,IAAI,CAACX,YAAY;QAC/BY,SAAS1B,gBAAgB;YACvB0B,SAAS,IAAIC;YACbvB;QACF;QACAR,QAAQC,WAAW+B,EAAE;IACvB;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restoreVersion.d.ts","sourceRoot":"","sources":["../../../src/collections/endpoints/restoreVersion.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"restoreVersion.d.ts","sourceRoot":"","sources":["../../../src/collections/endpoints/restoreVersion.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAQ3D,eAAO,MAAM,qBAAqB,EAAE,cA4BnC,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { status as httpStatus } from 'http-status';
|
|
2
2
|
import { getRequestCollectionWithID } from '../../utilities/getRequestEntity.js';
|
|
3
|
+
import { headersWithCors } from '../../utilities/headersWithCors.js';
|
|
3
4
|
import { isNumber } from '../../utilities/isNumber.js';
|
|
4
5
|
import { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js';
|
|
5
6
|
import { restoreVersionOperation } from '../operations/restoreVersion.js';
|
|
@@ -20,6 +21,10 @@ export const restoreVersionHandler = async (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/collections/endpoints/restoreVersion.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollectionWithID } from '../../utilities/getRequestEntity.js'\nimport { isNumber } from '../../utilities/isNumber.js'\nimport { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js'\nimport { restoreVersionOperation } from '../operations/restoreVersion.js'\n\nexport const restoreVersionHandler: PayloadHandler = async (req) => {\n const { id, collection } = getRequestCollectionWithID(req)\n const { searchParams } = req\n const depth = searchParams.get('depth')\n const draft = searchParams.get('draft')\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 status: httpStatus.OK,\n },\n )\n}\n"],"names":["status","httpStatus","getRequestCollectionWithID","isNumber","sanitizePopulateParam","restoreVersionOperation","restoreVersionHandler","req","id","collection","searchParams","depth","get","draft","result","Number","undefined","populate","query","Response","json","message","t","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,0BAA0B,QAAQ,sCAAqC;AAChF,SAASC,QAAQ,QAAQ,8BAA6B;AACtD,SAASC,qBAAqB,QAAQ,2CAA0C;AAChF,SAASC,uBAAuB,QAAQ,kCAAiC;AAEzE,OAAO,MAAMC,wBAAwC,OAAOC;IAC1D,MAAM,EAAEC,EAAE,EAAEC,UAAU,EAAE,
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/endpoints/restoreVersion.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollectionWithID } from '../../utilities/getRequestEntity.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { isNumber } from '../../utilities/isNumber.js'\nimport { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js'\nimport { restoreVersionOperation } from '../operations/restoreVersion.js'\n\nexport const restoreVersionHandler: PayloadHandler = async (req) => {\n const { id, collection } = getRequestCollectionWithID(req)\n const { searchParams } = req\n const depth = searchParams.get('depth')\n const draft = searchParams.get('draft')\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"],"names":["status","httpStatus","getRequestCollectionWithID","headersWithCors","isNumber","sanitizePopulateParam","restoreVersionOperation","restoreVersionHandler","req","id","collection","searchParams","depth","get","draft","result","Number","undefined","populate","query","Response","json","message","t","headers","Headers","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,0BAA0B,QAAQ,sCAAqC;AAChF,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,QAAQ,QAAQ,8BAA6B;AACtD,SAASC,qBAAqB,QAAQ,2CAA0C;AAChF,SAASC,uBAAuB,QAAQ,kCAAiC;AAEzE,OAAO,MAAMC,wBAAwC,OAAOC;IAC1D,MAAM,EAAEC,EAAE,EAAEC,UAAU,EAAE,GAAGR,2BAA2BM;IACtD,MAAM,EAAEG,YAAY,EAAE,GAAGH;IACzB,MAAMI,QAAQD,aAAaE,GAAG,CAAC;IAC/B,MAAMC,QAAQH,aAAaE,GAAG,CAAC;IAE/B,MAAME,SAAS,MAAMT,wBAAwB;QAC3CG;QACAC;QACAE,OAAOR,SAASQ,SAASI,OAAOJ,SAASK;QACzCH,OAAOA,UAAU,SAAS,OAAOG;QACjCC,UAAUb,sBAAsBG,IAAIW,KAAK,CAACD,QAAQ;QAClDV;IACF;IAEA,OAAOY,SAASC,IAAI,CAClB;QACE,GAAGN,MAAM;QACTO,SAASd,IAAIe,CAAC,CAAC;IACjB,GACA;QACEC,SAASrB,gBAAgB;YACvBqB,SAAS,IAAIC;YACbjB;QACF;QACAR,QAAQC,WAAWyB,EAAE;IACvB;AAEJ,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/collections/endpoints/update.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/collections/endpoints/update.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAU3D,eAAO,MAAM,aAAa,EAAE,cAoE3B,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getTranslation } from '@payloadcms/translations';
|
|
2
2
|
import { status as httpStatus } from 'http-status';
|
|
3
3
|
import { getRequestCollection } from '../../utilities/getRequestEntity.js';
|
|
4
|
+
import { headersWithCors } from '../../utilities/headersWithCors.js';
|
|
4
5
|
import { isNumber } from '../../utilities/isNumber.js';
|
|
5
6
|
import { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js';
|
|
6
7
|
import { sanitizeSelectParam } from '../../utilities/sanitizeSelectParam.js';
|
|
@@ -20,6 +21,10 @@ export const updateHandler = async (req)=>{
|
|
|
20
21
|
select: sanitizeSelectParam(select),
|
|
21
22
|
where
|
|
22
23
|
});
|
|
24
|
+
const headers = headersWithCors({
|
|
25
|
+
headers: new Headers(),
|
|
26
|
+
req
|
|
27
|
+
});
|
|
23
28
|
if (result.errors.length === 0) {
|
|
24
29
|
const message = req.t('general:updatedCountSuccessfully', {
|
|
25
30
|
count: result.docs.length,
|
|
@@ -29,6 +34,7 @@ export const updateHandler = async (req)=>{
|
|
|
29
34
|
...result,
|
|
30
35
|
message
|
|
31
36
|
}, {
|
|
37
|
+
headers,
|
|
32
38
|
status: httpStatus.OK
|
|
33
39
|
});
|
|
34
40
|
}
|
|
@@ -42,6 +48,7 @@ export const updateHandler = async (req)=>{
|
|
|
42
48
|
...result,
|
|
43
49
|
message
|
|
44
50
|
}, {
|
|
51
|
+
headers,
|
|
45
52
|
status: httpStatus.BAD_REQUEST
|
|
46
53
|
});
|
|
47
54
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/endpoints/update.ts"],"sourcesContent":["import { getTranslation } from '@payloadcms/translations'\nimport { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\nimport type { Where } from '../../types/index.js'\n\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { isNumber } from '../../utilities/isNumber.js'\nimport { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js'\nimport { sanitizeSelectParam } from '../../utilities/sanitizeSelectParam.js'\nimport { updateOperation } from '../operations/update.js'\n\nexport const updateHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(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 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 ? 'singular' : 'plural'],\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 ? 'singular' : 'plural'], 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","status","httpStatus","getRequestCollection","isNumber","sanitizePopulateParam","sanitizeSelectParam","updateOperation","updateHandler","req","collection","depth","draft","limit","overrideLock","populate","select","where","query","result","data","Number","undefined","Boolean","errors","length","message","t","count","docs","label","config","labels","i18n","Response","json","OK","total","BAD_REQUEST"],"mappings":"AAAA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,UAAUC,UAAU,QAAQ,cAAa;AAKlD,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,QAAQ,QAAQ,8BAA6B;AACtD,SAASC,qBAAqB,QAAQ,2CAA0C;AAChF,SAASC,mBAAmB,QAAQ,yCAAwC;AAC5E,SAASC,eAAe,QAAQ,0BAAyB;AAEzD,OAAO,MAAMC,gBAAgC,OAAOC;IAClD,MAAMC,
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/endpoints/update.ts"],"sourcesContent":["import { getTranslation } from '@payloadcms/translations'\nimport { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\nimport type { Where } from '../../types/index.js'\n\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { isNumber } from '../../utilities/isNumber.js'\nimport { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js'\nimport { sanitizeSelectParam } from '../../utilities/sanitizeSelectParam.js'\nimport { updateOperation } from '../operations/update.js'\n\nexport const updateHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(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 ? 'singular' : 'plural'],\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 ? 'singular' : 'plural'], 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","status","httpStatus","getRequestCollection","headersWithCors","isNumber","sanitizePopulateParam","sanitizeSelectParam","updateOperation","updateHandler","req","collection","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","OK","total","BAD_REQUEST"],"mappings":"AAAA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,UAAUC,UAAU,QAAQ,cAAa;AAKlD,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,QAAQ,QAAQ,8BAA6B;AACtD,SAASC,qBAAqB,QAAQ,2CAA0C;AAChF,SAASC,mBAAmB,QAAQ,yCAAwC;AAC5E,SAASC,eAAe,QAAQ,0BAAyB;AAEzD,OAAO,MAAMC,gBAAgC,OAAOC;IAClD,MAAMC,aAAaR,qBAAqBO;IACxC,MAAM,EAAEE,KAAK,EAAEC,KAAK,EAAEC,KAAK,EAAEC,YAAY,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,KAAK,EAAE,GAAGR,IAAIS,KAAK;IAUhF,MAAMC,SAAS,MAAMZ,gBAAgB;QACnCG;QACAU,MAAMX,IAAIW,IAAI;QACdT,OAAOP,SAASO,SAASU,OAAOV,SAASW;QACzCV,OAAOA,UAAU;QACjBC,OAAOT,SAASS,SAASQ,OAAOR,SAASS;QACzCR,cAAcS,QAAQT,iBAAiB;QACvCC,UAAUV,sBAAsBU;QAChCN;QACAO,QAAQV,oBAAoBU;QAC5BC;IACF;IAEA,MAAMO,UAAUrB,gBAAgB;QAC9BqB,SAAS,IAAIC;QACbhB;IACF;IAEA,IAAIU,OAAOO,MAAM,CAACC,MAAM,KAAK,GAAG;QAC9B,MAAMC,UAAUnB,IAAIoB,CAAC,CAAC,oCAAoC;YACxDC,OAAOX,OAAOY,IAAI,CAACJ,MAAM;YACzBK,OAAOjC,eACLW,WAAWuB,MAAM,CAACC,MAAM,CAACf,OAAOY,IAAI,CAACJ,MAAM,KAAK,IAAI,aAAa,SAAS,EAC1ElB,IAAI0B,IAAI;QAEZ;QAEA,OAAOC,SAASC,IAAI,CAClB;YACE,GAAGlB,MAAM;YACTS;QACF,GACA;YACEJ;YACAxB,QAAQC,WAAWqC,EAAE;QACvB;IAEJ;IAEA,MAAMC,QAAQpB,OAAOY,IAAI,CAACJ,MAAM,GAAGR,OAAOO,MAAM,CAACC,MAAM;IACvD,MAAMC,UAAUnB,IAAIoB,CAAC,CAAC,6BAA6B;QACjDC,OAAOX,OAAOO,MAAM,CAACC,MAAM;QAC3BK,OAAOjC,eAAeW,WAAWuB,MAAM,CAACC,MAAM,CAACK,UAAU,IAAI,aAAa,SAAS,EAAE9B,IAAI0B,IAAI;QAC7FI;IACF;IAEA,OAAOH,SAASC,IAAI,CAClB;QACE,GAAGlB,MAAM;QACTS;IACF,GACA;QACEJ;QACAxB,QAAQC,WAAWuC,WAAW;IAChC;AAEJ,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateByID.d.ts","sourceRoot":"","sources":["../../../src/collections/endpoints/updateByID.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"updateByID.d.ts","sourceRoot":"","sources":["../../../src/collections/endpoints/updateByID.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAS3D,eAAO,MAAM,iBAAiB,EAAE,cA6C/B,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { status as httpStatus } from 'http-status';
|
|
2
2
|
import { getRequestCollectionWithID } from '../../utilities/getRequestEntity.js';
|
|
3
|
+
import { headersWithCors } from '../../utilities/headersWithCors.js';
|
|
3
4
|
import { isNumber } from '../../utilities/isNumber.js';
|
|
4
5
|
import { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js';
|
|
5
6
|
import { sanitizeSelectParam } from '../../utilities/sanitizeSelectParam.js';
|
|
@@ -36,6 +37,10 @@ export const updateByIDHandler = async (req)=>{
|
|
|
36
37
|
doc,
|
|
37
38
|
message
|
|
38
39
|
}, {
|
|
40
|
+
headers: headersWithCors({
|
|
41
|
+
headers: new Headers(),
|
|
42
|
+
req
|
|
43
|
+
}),
|
|
39
44
|
status: httpStatus.OK
|
|
40
45
|
});
|
|
41
46
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/endpoints/updateByID.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollectionWithID } from '../../utilities/getRequestEntity.js'\nimport { isNumber } from '../../utilities/isNumber.js'\nimport { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js'\nimport { sanitizeSelectParam } from '../../utilities/sanitizeSelectParam.js'\nimport { updateByIDOperation } from '../operations/updateByID.js'\n\nexport const updateByIDHandler: PayloadHandler = async (req) => {\n const { id, collection } = getRequestCollectionWithID(req)\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 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 status: httpStatus.OK,\n },\n )\n}\n"],"names":["status","httpStatus","getRequestCollectionWithID","isNumber","sanitizePopulateParam","sanitizeSelectParam","updateByIDOperation","updateByIDHandler","req","id","collection","searchParams","depth","get","autosave","draft","overrideLock","publishSpecificLocale","query","doc","data","Number","undefined","Boolean","populate","select","message","t","Response","json","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,0BAA0B,QAAQ,sCAAqC;AAChF,SAASC,QAAQ,QAAQ,8BAA6B;AACtD,SAASC,qBAAqB,QAAQ,2CAA0C;AAChF,SAASC,mBAAmB,QAAQ,yCAAwC;AAC5E,SAASC,mBAAmB,QAAQ,8BAA6B;AAEjE,OAAO,MAAMC,oBAAoC,OAAOC;IACtD,MAAM,EAAEC,EAAE,EAAEC,UAAU,EAAE,
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/endpoints/updateByID.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollectionWithID } from '../../utilities/getRequestEntity.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { isNumber } from '../../utilities/isNumber.js'\nimport { sanitizePopulateParam } from '../../utilities/sanitizePopulateParam.js'\nimport { sanitizeSelectParam } from '../../utilities/sanitizeSelectParam.js'\nimport { updateByIDOperation } from '../operations/updateByID.js'\n\nexport const updateByIDHandler: PayloadHandler = async (req) => {\n const { id, collection } = getRequestCollectionWithID(req)\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 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"],"names":["status","httpStatus","getRequestCollectionWithID","headersWithCors","isNumber","sanitizePopulateParam","sanitizeSelectParam","updateByIDOperation","updateByIDHandler","req","id","collection","searchParams","depth","get","autosave","draft","overrideLock","publishSpecificLocale","query","doc","data","Number","undefined","Boolean","populate","select","message","t","Response","json","headers","Headers","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,0BAA0B,QAAQ,sCAAqC;AAChF,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,QAAQ,QAAQ,8BAA6B;AACtD,SAASC,qBAAqB,QAAQ,2CAA0C;AAChF,SAASC,mBAAmB,QAAQ,yCAAwC;AAC5E,SAASC,mBAAmB,QAAQ,8BAA6B;AAEjE,OAAO,MAAMC,oBAAoC,OAAOC;IACtD,MAAM,EAAEC,EAAE,EAAEC,UAAU,EAAE,GAAGT,2BAA2BO;IACtD,MAAM,EAAEG,YAAY,EAAE,GAAGH;IACzB,MAAMI,QAAQD,aAAaE,GAAG,CAAC;IAC/B,MAAMC,WAAWH,aAAaE,GAAG,CAAC,gBAAgB;IAClD,MAAME,QAAQJ,aAAaE,GAAG,CAAC,aAAa;IAC5C,MAAMG,eAAeL,aAAaE,GAAG,CAAC;IACtC,MAAMI,wBAAwBT,IAAIU,KAAK,CAACD,qBAAqB;IAE7D,MAAME,MAAM,MAAMb,oBAAoB;QACpCG;QACAK;QACAJ;QACAU,MAAMZ,IAAIY,IAAI;QACdR,OAAOT,SAASS,SAASS,OAAOT,SAASU;QACzCP;QACAC,cAAcO,QAAQP,iBAAiB;QACvCQ,UAAUpB,sBAAsBI,IAAIU,KAAK,CAACM,QAAQ;QAClDP;QACAT;QACAiB,QAAQpB,oBAAoBG,IAAIU,KAAK,CAACO,MAAM;IAC9C;IAEA,IAAIC,UAAUlB,IAAImB,CAAC,CAAC;IAEpB,IAAIZ,OAAO;QACTW,UAAUlB,IAAImB,CAAC,CAAC;IAClB;IACA,IAAIb,UAAU;QACZY,UAAUlB,IAAImB,CAAC,CAAC;IAClB;IAEA,OAAOC,SAASC,IAAI,CAClB;QACEV;QACAO;IACF,GACA;QACEI,SAAS5B,gBAAgB;YACvB4B,SAAS,IAAIC;YACbvB;QACF;QACAT,QAAQC,WAAWgC,EAAE;IACvB;AAEJ,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/fields/config/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAE1D,OAAO,KAAK,EAKV,WAAW,EACX,KAAK,EACL,SAAS,EAOV,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAKnD,OAAO,EAAyB,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAMtE,OAAO,EAAE,WAAW,EAAE,CAAA;AAEtB,MAAM,MAAM,yBAAyB,GACjC,QAAQ,GACR,QAAQ,GACR,UAAU,GACV,eAAe,GACf,SAAS,GACT,OAAO,GACP,kBAAkB,GAClB,UAAU,GACV,MAAM,IAAI,CAAC,SAAS,EAAE,QAAQ,GAAG,QAAQ,GAAG,cAAc,GAAG,OAAO,CAAC,CAAA;AAEzE,MAAM,MAAM,8BAA8B,GAAG,MAAM,IAAI,CACrD,SAAS,CAAC,OAAO,CAAC,EAClB,YAAY,GAAG,WAAW,CAC3B,CAAA;AA6BD,eAAO,MAAM,iBAAiB,8DAK3B;IACD,aAAa,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,CAAA;IACvD,KAAK,EAAE,KAAK,CAAA;IACZ,IAAI,EAAE,UAAU,CAAA;IAChB,SAAS,EAAE,SAAS,CAAA;CACrB,KAAG,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/fields/config/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAE1D,OAAO,KAAK,EAKV,WAAW,EACX,KAAK,EACL,SAAS,EAOV,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAKnD,OAAO,EAAyB,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAMtE,OAAO,EAAE,WAAW,EAAE,CAAA;AAEtB,MAAM,MAAM,yBAAyB,GACjC,QAAQ,GACR,QAAQ,GACR,UAAU,GACV,eAAe,GACf,SAAS,GACT,OAAO,GACP,kBAAkB,GAClB,UAAU,GACV,MAAM,IAAI,CAAC,SAAS,EAAE,QAAQ,GAAG,QAAQ,GAAG,cAAc,GAAG,OAAO,CAAC,CAAA;AAEzE,MAAM,MAAM,8BAA8B,GAAG,MAAM,IAAI,CACrD,SAAS,CAAC,OAAO,CAAC,EAClB,YAAY,GAAG,WAAW,CAC3B,CAAA;AA6BD,eAAO,MAAM,iBAAiB,8DAK3B;IACD,aAAa,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,CAAA;IACvD,KAAK,EAAE,KAAK,CAAA;IACZ,IAAI,EAAE,UAAU,CAAA;IAChB,SAAS,EAAE,SAAS,CAAA;CACrB,KAAG,WA0QH,CAAA;AAED,eAAO,MAAM,kBAAkB,iEAM5B;IACD,aAAa,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,CAAA;IACvD,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,IAAI,EAAE,UAAU,CAAA;IAChB,SAAS,EAAE,SAAS,CAAA;CACrB,KAAG,WAAW,EAkCd,CAAA"}
|
|
@@ -215,6 +215,28 @@ export const createClientField = ({ defaultIDType, field: incomingField, i18n, i
|
|
|
215
215
|
clientTab[key] = tabProp({
|
|
216
216
|
t: i18n.t
|
|
217
217
|
});
|
|
218
|
+
} else if (key === 'admin') {
|
|
219
|
+
clientTab.admin = {};
|
|
220
|
+
for(const adminKey in tab.admin){
|
|
221
|
+
if (serverOnlyFieldAdminProperties.includes(adminKey)) {
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
switch(adminKey){
|
|
225
|
+
case 'description':
|
|
226
|
+
if ('description' in tab.admin) {
|
|
227
|
+
if (typeof tab.admin?.description === 'function') {
|
|
228
|
+
clientTab.admin.description = tab.admin.description({
|
|
229
|
+
t: i18n.t
|
|
230
|
+
});
|
|
231
|
+
} else {
|
|
232
|
+
clientTab.admin.description = tab.admin.description;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
break;
|
|
236
|
+
default:
|
|
237
|
+
clientField.admin[adminKey] = tab.admin[adminKey];
|
|
238
|
+
}
|
|
239
|
+
}
|
|
218
240
|
} else {
|
|
219
241
|
clientTab[key] = tabProp;
|
|
220
242
|
}
|