@payloadcms/next 3.0.0-beta.124 → 3.0.0-beta.126
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/cjs/withPayload.cjs +12 -1
- package/dist/cjs/withPayload.cjs.map +1 -1
- package/dist/exports/routes.d.ts +1 -1
- package/dist/exports/routes.d.ts.map +1 -1
- package/dist/exports/routes.js +1 -1
- package/dist/exports/routes.js.map +1 -1
- package/dist/routes/rest/collections/create.d.ts.map +1 -1
- package/dist/routes/rest/collections/create.js +2 -0
- 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 -0
- 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 +2 -0
- 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 +2 -0
- 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 -0
- 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 +2 -0
- 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 +2 -0
- 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 -0
- 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 -0
- 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 -0
- 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 +2 -0
- 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 +2 -0
- 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 +2 -0
- 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 -0
- 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 -0
- 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 +2 -0
- package/dist/routes/rest/globals/update.js.map +1 -1
- package/dist/routes/rest/index.d.ts +5 -0
- package/dist/routes/rest/index.d.ts.map +1 -1
- package/dist/routes/rest/index.js +73 -0
- package/dist/routes/rest/index.js.map +1 -1
- package/dist/routes/rest/og/index.js +2 -4
- package/dist/routes/rest/og/index.js.map +1 -1
- package/dist/routes/rest/utilities/sanitizeJoinParams.d.ts +1 -1
- package/dist/routes/rest/utilities/sanitizeJoinParams.d.ts.map +1 -1
- package/dist/routes/rest/utilities/sanitizeJoinParams.js +9 -5
- package/dist/routes/rest/utilities/sanitizeJoinParams.js.map +1 -1
- package/dist/routes/rest/utilities/sanitizePopulate.d.ts +3 -0
- package/dist/routes/rest/utilities/sanitizePopulate.d.ts.map +1 -0
- package/dist/routes/rest/utilities/sanitizePopulate.js +11 -0
- package/dist/routes/rest/utilities/sanitizePopulate.js.map +1 -0
- package/dist/views/Document/getDocumentData.js +4 -2
- package/dist/views/Document/getDocumentData.js.map +1 -1
- package/dist/views/Document/getDocumentPermissions.js +2 -4
- package/dist/views/Document/getDocumentPermissions.js.map +1 -1
- package/dist/views/Version/Restore/index.js +1 -1
- package/dist/views/Version/Restore/index.js.map +1 -1
- package/dist/views/Versions/getLatestVersion.js +1 -1
- package/dist/views/Versions/getLatestVersion.js.map +1 -1
- package/dist/views/Versions/index.js +2 -4
- package/dist/views/Versions/index.js.map +1 -1
- package/dist/withPayload.d.ts.map +1 -1
- package/dist/withPayload.js +9 -1
- package/dist/withPayload.js.map +1 -1
- package/package.json +6 -6
package/dist/cjs/withPayload.cjs
CHANGED
|
@@ -26,6 +26,10 @@ const withPayload = (nextConfig = {})=>{
|
|
|
26
26
|
console.warn('Payload detected a non-zero value for the `staleTimes.dynamic` option in your Next.js config. This will slow down page transitions and may cause stale data to load within the Admin panel. To clear this warning, remove the `staleTimes.dynamic` option from your Next.js config or set it to 0. In the future, Next.js may support scoping this option to specific routes.');
|
|
27
27
|
env.NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH = 'true';
|
|
28
28
|
}
|
|
29
|
+
const poweredByHeader = {
|
|
30
|
+
key: 'X-Powered-By',
|
|
31
|
+
value: 'Next.js, Payload'
|
|
32
|
+
};
|
|
29
33
|
/**
|
|
30
34
|
* @type {import('next').NextConfig}
|
|
31
35
|
*/ const toReturn = {
|
|
@@ -56,6 +60,10 @@ const withPayload = (nextConfig = {})=>{
|
|
|
56
60
|
}
|
|
57
61
|
}
|
|
58
62
|
},
|
|
63
|
+
// We disable the poweredByHeader here because we add it manually in the headers function below
|
|
64
|
+
...nextConfig?.poweredByHeader !== false ? {
|
|
65
|
+
poweredByHeader: false
|
|
66
|
+
} : {},
|
|
59
67
|
headers: async ()=>{
|
|
60
68
|
const headersFromConfig = 'headers' in nextConfig ? await nextConfig.headers() : [];
|
|
61
69
|
return [
|
|
@@ -74,7 +82,10 @@ const withPayload = (nextConfig = {})=>{
|
|
|
74
82
|
{
|
|
75
83
|
key: 'Critical-CH',
|
|
76
84
|
value: 'Sec-CH-Prefers-Color-Scheme'
|
|
77
|
-
}
|
|
85
|
+
},
|
|
86
|
+
...nextConfig?.poweredByHeader !== false ? [
|
|
87
|
+
poweredByHeader
|
|
88
|
+
] : []
|
|
78
89
|
]
|
|
79
90
|
}
|
|
80
91
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/withPayload.js"],"names":[],"mappings":"AAAA;;;;GAIG;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../src/withPayload.js"],"names":[],"mappings":"AAAA;;;;GAIG;;;;;;;;;;;IAkIH,OAA0B;eAA1B;;IAjIa,WAAW;eAAX;;;AAAN,MAAM,cAAc,CAAC,aAAa,CAAC,CAAC;IACzC,MAAM,MAAM,YAAY,OAAO,CAAC;IAEhC,IAAI,WAAW,YAAY,EAAE,YAAY,SAAS;QAChD,QAAQ,IAAI,CACV;QAEF,IAAI,uCAAuC,GAAG;IAChD;IAEA,MAAM,kBAAkB;QACtB,KAAK;QACL,OAAO;IACT;IAEA;;GAEC,GACD,MAAM,WAAW;QACf,GAAG,UAAU;QACb;QACA,2BAA2B;YACzB,GAAI,YAAY,6BAA6B,CAAC,CAAC;YAC/C,QAAQ;mBACF,YAAY,2BAA2B,CAAC,OAAO,IAAI,EAAE;gBACzD;gBACA;aACD;QACH;QACA,2BAA2B;YACzB,GAAI,YAAY,6BAA6B,CAAC,CAAC;YAC/C,QAAQ;mBAAK,YAAY,2BAA2B,CAAC,OAAO,IAAI,EAAE;gBAAG;aAAiB;QACxF;QACA,cAAc;YACZ,GAAI,YAAY,gBAAgB,CAAC,CAAC;YAClC,OAAO;gBACL,GAAI,YAAY,cAAc,SAAS,CAAC,CAAC;gBACzC,cAAc;oBACZ,GAAI,YAAY,cAAc,OAAO,gBAAgB,CAAC,CAAC;oBACvD,wBAAwB;gBAC1B;YACF;QACF;QACA,+FAA+F;QAC/F,GAAI,YAAY,oBAAoB,QAAQ;YAAE,iBAAiB;QAAM,IAAI,CAAC,CAAC;QAC3E,SAAS;YACP,MAAM,oBAAoB,aAAa,aAAa,MAAM,WAAW,OAAO,KAAK,EAAE;YAEnF,OAAO;mBACD,qBAAqB,EAAE;gBAC3B;oBACE,QAAQ;oBACR,SAAS;wBACP;4BACE,KAAK;4BACL,OAAO;wBACT;wBACA;4BACE,KAAK;4BACL,OAAO;wBACT;wBACA;4BACE,KAAK;4BACL,OAAO;wBACT;2BACI,YAAY,oBAAoB,QAAQ;4BAAC;yBAAgB,GAAG,EAAE;qBACnE;gBACH;aACD;QACH;QACA,wBAAwB;eAClB,YAAY,0BAA0B,EAAE;YAC5C;YACA;YACA;YACA;YACA;YACA;SACD;QACD,SAAS,CAAC,eAAe;YACvB,MAAM,wBACJ,OAAO,WAAW,OAAO,KAAK,aAC1B,WAAW,OAAO,CAAC,eAAe,kBAClC;YAEN,OAAO;gBACL,GAAG,qBAAqB;gBACxB,WAAW;uBACL,uBAAuB,aAAa,EAAE;oBAC1C;oBACA;oBACA;oBACA;iBACD;gBACD,gBAAgB;uBACV,uBAAuB,kBAAkB,EAAE;oBAC/C;wBAAE,QAAQ;oBAAwC;oBAClD;wBAAE,MAAM;oBAAwC;oBAChD;wBAAE,QAAQ;oBAAuC;oBACjD;wBAAE,MAAM;oBAAuC;iBAChD;gBACD,SAAS;oBACP,GAAI,uBAAuB,WAAW,CAAC,CAAC;oBACxC,OAAO;wBACL,GAAI,uBAAuB,SAAS,SAAS,CAAC,CAAC;oBACjD;oBACA,UAAU;wBACR,GAAI,uBAAuB,SAAS,YAAY,CAAC,CAAC;wBAClD,iCAAiC;wBACjC,oBAAoB;wBACpB,MAAM;wBACN,UAAU;wBACV,6BAA6B;wBAC7B,QAAQ;wBACR,kBAAkB;wBAClB,eAAe;oBACjB;gBACF;YACF;QACF;IACF;IAEA,IAAI,WAAW,QAAQ,EAAE;QACvB,SAAS,GAAG,CAAC,cAAc,GAAG,WAAW,QAAQ;IACnD;IAEA,OAAO;AACT;MAEA,WAAe","file":"withPayload.cjs","sourcesContent":["/**\n * @param {import('next').NextConfig} nextConfig\n *\n * @returns {import('next').NextConfig}\n * */\nexport const withPayload = (nextConfig = {}) => {\n const env = nextConfig?.env || {}\n\n if (nextConfig.experimental?.staleTimes?.dynamic) {\n console.warn(\n 'Payload detected a non-zero value for the `staleTimes.dynamic` option in your Next.js config. This will slow down page transitions and may cause stale data to load within the Admin panel. To clear this warning, remove the `staleTimes.dynamic` option from your Next.js config or set it to 0. In the future, Next.js may support scoping this option to specific routes.',\n )\n env.NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH = 'true'\n }\n\n const poweredByHeader = {\n key: 'X-Powered-By',\n value: 'Next.js, Payload',\n }\n\n /**\n * @type {import('next').NextConfig}\n */\n const toReturn = {\n ...nextConfig,\n env,\n outputFileTracingExcludes: {\n ...(nextConfig?.outputFileTracingExcludes || {}),\n '**/*': [\n ...(nextConfig?.outputFileTracingExcludes?.['**/*'] || []),\n 'drizzle-kit',\n 'drizzle-kit/api',\n ],\n },\n outputFileTracingIncludes: {\n ...(nextConfig?.outputFileTracingIncludes || {}),\n '**/*': [...(nextConfig?.outputFileTracingIncludes?.['**/*'] || []), '@libsql/client'],\n },\n experimental: {\n ...(nextConfig?.experimental || {}),\n turbo: {\n ...(nextConfig?.experimental?.turbo || {}),\n resolveAlias: {\n ...(nextConfig?.experimental?.turbo?.resolveAlias || {}),\n 'payload-mock-package': 'payload-mock-package',\n },\n },\n },\n // We disable the poweredByHeader here because we add it manually in the headers function below\n ...(nextConfig?.poweredByHeader !== false ? { poweredByHeader: false } : {}),\n headers: async () => {\n const headersFromConfig = 'headers' in nextConfig ? await nextConfig.headers() : []\n\n return [\n ...(headersFromConfig || []),\n {\n source: '/:path*',\n headers: [\n {\n key: 'Accept-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Vary',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n {\n key: 'Critical-CH',\n value: 'Sec-CH-Prefers-Color-Scheme',\n },\n ...(nextConfig?.poweredByHeader !== false ? [poweredByHeader] : []),\n ],\n },\n ]\n },\n serverExternalPackages: [\n ...(nextConfig?.serverExternalPackages || []),\n 'drizzle-kit',\n 'drizzle-kit/api',\n 'pino',\n 'libsql',\n 'pino-pretty',\n 'graphql',\n ],\n webpack: (webpackConfig, webpackOptions) => {\n const incomingWebpackConfig =\n typeof nextConfig.webpack === 'function'\n ? nextConfig.webpack(webpackConfig, webpackOptions)\n : webpackConfig\n\n return {\n ...incomingWebpackConfig,\n externals: [\n ...(incomingWebpackConfig?.externals || []),\n 'drizzle-kit',\n 'drizzle-kit/api',\n 'sharp',\n 'libsql',\n ],\n ignoreWarnings: [\n ...(incomingWebpackConfig?.ignoreWarnings || []),\n { module: /node_modules\\/mongodb\\/lib\\/utils\\.js/ },\n { file: /node_modules\\/mongodb\\/lib\\/utils\\.js/ },\n { module: /node_modules\\/mongodb\\/lib\\/bson\\.js/ },\n { file: /node_modules\\/mongodb\\/lib\\/bson\\.js/ },\n ],\n resolve: {\n ...(incomingWebpackConfig?.resolve || {}),\n alias: {\n ...(incomingWebpackConfig?.resolve?.alias || {}),\n },\n fallback: {\n ...(incomingWebpackConfig?.resolve?.fallback || {}),\n '@aws-sdk/credential-providers': false,\n '@mongodb-js/zstd': false,\n aws4: false,\n kerberos: false,\n 'mongodb-client-encryption': false,\n snappy: false,\n 'supports-color': false,\n 'yocto-queue': false,\n },\n },\n }\n },\n }\n\n if (nextConfig.basePath) {\n toReturn.env.NEXT_BASE_PATH = nextConfig.basePath\n }\n\n return toReturn\n}\n\nexport default withPayload\n"]}
|
package/dist/exports/routes.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { GRAPHQL_PLAYGROUND_GET, GRAPHQL_POST } from '../routes/graphql/index.js';
|
|
2
|
-
export { DELETE as REST_DELETE, GET as REST_GET, OPTIONS as REST_OPTIONS, PATCH as REST_PATCH, POST as REST_POST, } from '../routes/rest/index.js';
|
|
2
|
+
export { DELETE as REST_DELETE, GET as REST_GET, OPTIONS as REST_OPTIONS, PATCH as REST_PATCH, POST as REST_POST, PUT as REST_PUT, } from '../routes/rest/index.js';
|
|
3
3
|
//# sourceMappingURL=routes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/exports/routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAEjF,OAAO,EACL,MAAM,IAAI,WAAW,EACrB,GAAG,IAAI,QAAQ,EACf,OAAO,IAAI,YAAY,EACvB,KAAK,IAAI,UAAU,EACnB,IAAI,IAAI,SAAS,
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/exports/routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAEjF,OAAO,EACL,MAAM,IAAI,WAAW,EACrB,GAAG,IAAI,QAAQ,EACf,OAAO,IAAI,YAAY,EACvB,KAAK,IAAI,UAAU,EACnB,IAAI,IAAI,SAAS,EACjB,GAAG,IAAI,QAAQ,GAChB,MAAM,yBAAyB,CAAA"}
|
package/dist/exports/routes.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { GRAPHQL_PLAYGROUND_GET, GRAPHQL_POST } from '../routes/graphql/index.js';
|
|
2
|
-
export { DELETE as REST_DELETE, GET as REST_GET, OPTIONS as REST_OPTIONS, PATCH as REST_PATCH, POST as REST_POST } from '../routes/rest/index.js';
|
|
2
|
+
export { DELETE as REST_DELETE, GET as REST_GET, OPTIONS as REST_OPTIONS, PATCH as REST_PATCH, POST as REST_POST, PUT as REST_PUT } from '../routes/rest/index.js';
|
|
3
3
|
//# sourceMappingURL=routes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.js","names":["GRAPHQL_PLAYGROUND_GET","GRAPHQL_POST","DELETE","REST_DELETE","GET","REST_GET","OPTIONS","REST_OPTIONS","PATCH","REST_PATCH","POST","REST_POST"],"sources":["../../src/exports/routes.ts"],"sourcesContent":["export { GRAPHQL_PLAYGROUND_GET, GRAPHQL_POST } from '../routes/graphql/index.js'\n\nexport {\n DELETE as REST_DELETE,\n GET as REST_GET,\n OPTIONS as REST_OPTIONS,\n PATCH as REST_PATCH,\n POST as REST_POST,\n} from '../routes/rest/index.js'\n"],"mappings":"AAAA,SAASA,sBAAsB,EAAEC,YAAY,QAAQ;AAErD,SACEC,MAAA,IAAUC,WAAW,EACrBC,GAAA,IAAOC,QAAQ,EACfC,OAAA,IAAWC,YAAY,EACvBC,KAAA,IAASC,UAAU,EACnBC,IAAA,IAAQC,SAAS,
|
|
1
|
+
{"version":3,"file":"routes.js","names":["GRAPHQL_PLAYGROUND_GET","GRAPHQL_POST","DELETE","REST_DELETE","GET","REST_GET","OPTIONS","REST_OPTIONS","PATCH","REST_PATCH","POST","REST_POST","PUT","REST_PUT"],"sources":["../../src/exports/routes.ts"],"sourcesContent":["export { GRAPHQL_PLAYGROUND_GET, GRAPHQL_POST } from '../routes/graphql/index.js'\n\nexport {\n DELETE as REST_DELETE,\n GET as REST_GET,\n OPTIONS as REST_OPTIONS,\n PATCH as REST_PATCH,\n POST as REST_POST,\n PUT as REST_PUT,\n} from '../routes/rest/index.js'\n"],"mappings":"AAAA,SAASA,sBAAsB,EAAEC,YAAY,QAAQ;AAErD,SACEC,MAAA,IAAUC,WAAW,EACrBC,GAAA,IAAOC,QAAQ,EACfC,OAAA,IAAWC,YAAY,EACvBC,KAAA,IAASC,UAAU,EACnBC,IAAA,IAAQC,SAAS,EACjBC,GAAA,IAAOC,QAAQ,QACV","ignoreList":[]}
|
|
@@ -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;AAMzD,eAAO,MAAM,MAAM,EAAE,sBAgCpB,CAAA"}
|
|
@@ -3,6 +3,7 @@ import httpStatus from 'http-status';
|
|
|
3
3
|
import { createOperation } from 'payload';
|
|
4
4
|
import { isNumber } from 'payload/shared';
|
|
5
5
|
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
6
|
+
import { sanitizePopulate } from '../utilities/sanitizePopulate.js';
|
|
6
7
|
import { sanitizeSelect } from '../utilities/sanitizeSelect.js';
|
|
7
8
|
export const create = async ({
|
|
8
9
|
collection,
|
|
@@ -20,6 +21,7 @@ export const create = async ({
|
|
|
20
21
|
data: req.data,
|
|
21
22
|
depth: isNumber(depth) ? depth : undefined,
|
|
22
23
|
draft,
|
|
24
|
+
populate: sanitizePopulate(req.query.populate),
|
|
23
25
|
req,
|
|
24
26
|
select: sanitizeSelect(req.query.select)
|
|
25
27
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","names":["getTranslation","httpStatus","createOperation","isNumber","headersWithCors","sanitizeSelect","create","collection","req","searchParams","autosave","get","draft","depth","doc","data","undefined","
|
|
1
|
+
{"version":3,"file":"create.js","names":["getTranslation","httpStatus","createOperation","isNumber","headersWithCors","sanitizePopulate","sanitizeSelect","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 } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { sanitizePopulate } from '../utilities/sanitizePopulate.js'\nimport { sanitizeSelect } from '../utilities/sanitizeSelect.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: sanitizePopulate(req.query.populate),\n req,\n select: sanitizeSelect(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,QAAQ;AAChC,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,cAAc,QAAQ;AAE/B,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,EAAOX,QAAA,CAASW,KAAA,IAASA,KAAA,GAAQG,SAAA;IACjCJ,KAAA;IACAK,QAAA,EAAUb,gBAAA,CAAiBI,GAAA,CAAIU,KAAK,CAACD,QAAQ;IAC7CT,GAAA;IACAW,MAAA,EAAQd,cAAA,CAAeG,GAAA,CAAIU,KAAK,CAACC,MAAM;EACzC;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,EAAS1B,eAAA,CAAgB;MACvB0B,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;AAMzD,eAAO,MAAM,SAAS,EAAE,sBA+DvB,CAAA"}
|
|
@@ -3,6 +3,7 @@ import httpStatus from 'http-status';
|
|
|
3
3
|
import { deleteOperation } from 'payload';
|
|
4
4
|
import { isNumber } from 'payload/shared';
|
|
5
5
|
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
6
|
+
import { sanitizePopulate } from '../utilities/sanitizePopulate.js';
|
|
6
7
|
import { sanitizeSelect } from '../utilities/sanitizeSelect.js';
|
|
7
8
|
export const deleteDoc = async ({
|
|
8
9
|
collection,
|
|
@@ -11,6 +12,7 @@ export const deleteDoc = async ({
|
|
|
11
12
|
const {
|
|
12
13
|
depth,
|
|
13
14
|
overrideLock,
|
|
15
|
+
populate,
|
|
14
16
|
select,
|
|
15
17
|
where
|
|
16
18
|
} = req.query;
|
|
@@ -18,6 +20,7 @@ export const deleteDoc = async ({
|
|
|
18
20
|
collection,
|
|
19
21
|
depth: isNumber(depth) ? Number(depth) : undefined,
|
|
20
22
|
overrideLock: Boolean(overrideLock === 'true'),
|
|
23
|
+
populate: sanitizePopulate(populate),
|
|
21
24
|
req,
|
|
22
25
|
select: sanitizeSelect(select),
|
|
23
26
|
where
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete.js","names":["getTranslation","httpStatus","deleteOperation","isNumber","headersWithCors","sanitizeSelect","deleteDoc","collection","req","depth","overrideLock","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 } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { sanitizeSelect } from '../utilities/sanitizeSelect.js'\n\nexport const deleteDoc: CollectionRouteHandler = async ({ collection, req }) => {\n const { depth, overrideLock, select, where } = req.query as {\n depth?: string\n overrideLock?: string\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 req,\n select: sanitizeSelect(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,QAAQ;AAChC,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,cAAc,QAAQ;AAE/B,OAAO,MAAMC,SAAA,GAAoC,MAAAA,CAAO;EAAEC,UAAU;EAAEC;AAAG,CAAE;EACzE,MAAM;IAAEC,KAAK;IAAEC,YAAY;IAAEC,MAAM;IAAEC;EAAK,CAAE,
|
|
1
|
+
{"version":3,"file":"delete.js","names":["getTranslation","httpStatus","deleteOperation","isNumber","headersWithCors","sanitizePopulate","sanitizeSelect","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 } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { sanitizePopulate } from '../utilities/sanitizePopulate.js'\nimport { sanitizeSelect } from '../utilities/sanitizeSelect.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: sanitizePopulate(populate),\n req,\n select: sanitizeSelect(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,QAAQ;AAChC,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,cAAc,QAAQ;AAE/B,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,EAAOP,QAAA,CAASO,KAAA,IAASO,MAAA,CAAOP,KAAA,IAASQ,SAAA;IACzCP,YAAA,EAAcQ,OAAA,CAAQR,YAAA,KAAiB;IACvCC,QAAA,EAAUP,gBAAA,CAAiBO,QAAA;IAC3BH,GAAA;IACAI,MAAA,EAAQP,cAAA,CAAeO,MAAA;IACvBC;EACF;EAEA,MAAMM,OAAA,GAAUhB,eAAA,CAAgB;IAC9BgB,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;AAO/D,eAAO,MAAM,UAAU,EAAE,4BAoDxB,CAAA"}
|
|
@@ -3,6 +3,7 @@ import { deleteByIDOperation } 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';
|
|
6
7
|
import { sanitizeSelect } from '../utilities/sanitizeSelect.js';
|
|
7
8
|
export const deleteByID = async ({
|
|
8
9
|
id: incomingID,
|
|
@@ -24,6 +25,7 @@ export const deleteByID = async ({
|
|
|
24
25
|
collection,
|
|
25
26
|
depth: isNumber(depth) ? depth : undefined,
|
|
26
27
|
overrideLock: Boolean(overrideLock === 'true'),
|
|
28
|
+
populate: sanitizePopulate(req.query.populate),
|
|
27
29
|
req,
|
|
28
30
|
select: sanitizeSelect(req.query.select)
|
|
29
31
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deleteByID.js","names":["httpStatus","deleteByIDOperation","isNumber","headersWithCors","sanitizeCollectionID","sanitizeSelect","deleteByID","id","incomingID","collection","req","searchParams","depth","get","overrideLock","collectionSlug","config","slug","payload","doc","undefined","Boolean","
|
|
1
|
+
{"version":3,"file":"deleteByID.js","names":["httpStatus","deleteByIDOperation","isNumber","headersWithCors","sanitizeCollectionID","sanitizePopulate","sanitizeSelect","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 } 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'\nimport { sanitizePopulate } from '../utilities/sanitizePopulate.js'\nimport { sanitizeSelect } from '../utilities/sanitizeSelect.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: sanitizePopulate(req.query.populate),\n req,\n select: sanitizeSelect(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,QAAQ;AACpC,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,cAAc,QAAQ;AAE/B,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,GAAKJ,oBAAA,CAAqB;IAC9BI,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,EAAOX,QAAA,CAASW,KAAA,IAASA,KAAA,GAAQQ,SAAA;IACjCN,YAAA,EAAcO,OAAA,CAAQP,YAAA,KAAiB;IACvCQ,QAAA,EAAUlB,gBAAA,CAAiBM,GAAA,CAAIa,KAAK,CAACD,QAAQ;IAC7CZ,GAAA;IACAc,MAAA,EAAQnB,cAAA,CAAeK,GAAA,CAAIa,KAAK,CAACC,MAAM;EACzC;EAEA,MAAMC,OAAA,GAAUvB,eAAA,CAAgB;IAC9BuB,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;AAO/D,eAAO,MAAM,SAAS,EAAE,4BA2CvB,CAAA"}
|
|
@@ -4,6 +4,7 @@ import { duplicateOperation } 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';
|
|
7
8
|
import { sanitizeSelect } from '../utilities/sanitizeSelect.js';
|
|
8
9
|
export const duplicate = async ({
|
|
9
10
|
id: incomingID,
|
|
@@ -26,6 +27,7 @@ export const duplicate = async ({
|
|
|
26
27
|
collection,
|
|
27
28
|
depth: isNumber(depth) ? Number(depth) : undefined,
|
|
28
29
|
draft,
|
|
30
|
+
populate: sanitizePopulate(req.query.populate),
|
|
29
31
|
req,
|
|
30
32
|
select: sanitizeSelect(req.query.select)
|
|
31
33
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"duplicate.js","names":["getTranslation","httpStatus","duplicateOperation","isNumber","headersWithCors","sanitizeCollectionID","sanitizeSelect","duplicate","id","incomingID","collection","req","searchParams","depth","get","draft","collectionSlug","config","slug","payload","doc","Number","undefined","
|
|
1
|
+
{"version":3,"file":"duplicate.js","names":["getTranslation","httpStatus","duplicateOperation","isNumber","headersWithCors","sanitizeCollectionID","sanitizePopulate","sanitizeSelect","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 } 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'\nimport { sanitizePopulate } from '../utilities/sanitizePopulate.js'\nimport { sanitizeSelect } from '../utilities/sanitizeSelect.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: sanitizePopulate(req.query.populate),\n req,\n select: sanitizeSelect(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,QAAQ;AACnC,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,cAAc,QAAQ;AAE/B,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,GAAKJ,oBAAA,CAAqB;IAC9BI,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,EAAOX,QAAA,CAASW,KAAA,IAASQ,MAAA,CAAOR,KAAA,IAASS,SAAA;IACzCP,KAAA;IACAQ,QAAA,EAAUlB,gBAAA,CAAiBM,GAAA,CAAIa,KAAK,CAACD,QAAQ;IAC7CZ,GAAA;IACAc,MAAA,EAAQnB,cAAA,CAAeK,GAAA,CAAIa,KAAK,CAACC,MAAM;EACzC;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,EAAS/B,eAAA,CAAgB;MACvB+B,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":"AAMA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/find.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAOzD,eAAO,MAAM,IAAI,EAAE,sBAkClB,CAAA"}
|
|
@@ -3,6 +3,7 @@ import { findOperation } from 'payload';
|
|
|
3
3
|
import { isNumber } from 'payload/shared';
|
|
4
4
|
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
5
5
|
import { sanitizeJoinParams } from '../utilities/sanitizeJoinParams.js';
|
|
6
|
+
import { sanitizePopulate } from '../utilities/sanitizePopulate.js';
|
|
6
7
|
import { sanitizeSelect } from '../utilities/sanitizeSelect.js';
|
|
7
8
|
export const find = async ({
|
|
8
9
|
collection,
|
|
@@ -14,6 +15,7 @@ export const find = async ({
|
|
|
14
15
|
joins,
|
|
15
16
|
limit,
|
|
16
17
|
page,
|
|
18
|
+
populate,
|
|
17
19
|
select,
|
|
18
20
|
sort,
|
|
19
21
|
where
|
|
@@ -25,6 +27,7 @@ export const find = async ({
|
|
|
25
27
|
joins: sanitizeJoinParams(joins),
|
|
26
28
|
limit: isNumber(limit) ? Number(limit) : undefined,
|
|
27
29
|
page: isNumber(page) ? Number(page) : undefined,
|
|
30
|
+
populate: sanitizePopulate(populate),
|
|
28
31
|
req,
|
|
29
32
|
select: sanitizeSelect(select),
|
|
30
33
|
sort: typeof sort === 'string' ? sort.split(',') : undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find.js","names":["httpStatus","findOperation","isNumber","headersWithCors","sanitizeJoinParams","sanitizeSelect","find","collection","req","depth","draft","joins","limit","page","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 { findOperation } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { sanitizeJoinParams } from '../utilities/sanitizeJoinParams.js'\nimport { sanitizeSelect } from '../utilities/sanitizeSelect.js'\n\nexport const find: CollectionRouteHandler = async ({ collection, req }) => {\n const { depth, draft, joins, limit, page, select, sort, where } = req.query as {\n depth?: string\n draft?: string\n joins?: JoinQuery\n limit?: string\n page?: string\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 req,\n select: sanitizeSelect(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,aAAa,QAAQ;AAC9B,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,cAAc,QAAQ;AAE/B,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,MAAM;IAAEC,IAAI;IAAEC;EAAK,CAAE,
|
|
1
|
+
{"version":3,"file":"find.js","names":["httpStatus","findOperation","isNumber","headersWithCors","sanitizeJoinParams","sanitizePopulate","sanitizeSelect","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 { findOperation } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { sanitizeJoinParams } from '../utilities/sanitizeJoinParams.js'\nimport { sanitizePopulate } from '../utilities/sanitizePopulate.js'\nimport { sanitizeSelect } from '../utilities/sanitizeSelect.js'\n\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: sanitizePopulate(populate),\n req,\n select: sanitizeSelect(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,aAAa,QAAQ;AAC9B,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,cAAc,QAAQ;AAE/B,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,EAAOR,QAAA,CAASQ,KAAA,IAASW,MAAA,CAAOX,KAAA,IAASY,SAAA;IACzCX,KAAA,EAAOA,KAAA,KAAU;IACjBC,KAAA,EAAOR,kBAAA,CAAmBQ,KAAA;IAC1BC,KAAA,EAAOX,QAAA,CAASW,KAAA,IAASQ,MAAA,CAAOR,KAAA,IAASS,SAAA;IACzCR,IAAA,EAAMZ,QAAA,CAASY,IAAA,IAAQO,MAAA,CAAOP,IAAA,IAAQQ,SAAA;IACtCP,QAAA,EAAUV,gBAAA,CAAiBU,QAAA;IAC3BN,GAAA;IACAO,MAAA,EAAQV,cAAA,CAAeU,MAAA;IACvBC,IAAA,EAAM,OAAOA,IAAA,KAAS,WAAWA,IAAA,CAAKM,KAAK,CAAC,OAAOD,SAAA;IACnDJ;EACF;EAEA,OAAOM,QAAA,CAASC,IAAI,CAACL,MAAA,EAAQ;IAC3BM,OAAA,EAASvB,eAAA,CAAgB;MACvBuB,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":"AAMA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"findByID.d.ts","sourceRoot":"","sources":["../../../../src/routes/rest/collections/findByID.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAQ/D,eAAO,MAAM,QAAQ,EAAE,4BAgCtB,CAAA"}
|
|
@@ -4,6 +4,7 @@ import { isNumber } from 'payload/shared';
|
|
|
4
4
|
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
5
5
|
import { sanitizeCollectionID } from '../utilities/sanitizeCollectionID.js';
|
|
6
6
|
import { sanitizeJoinParams } from '../utilities/sanitizeJoinParams.js';
|
|
7
|
+
import { sanitizePopulate } from '../utilities/sanitizePopulate.js';
|
|
7
8
|
import { sanitizeSelect } from '../utilities/sanitizeSelect.js';
|
|
8
9
|
export const findByID = async ({
|
|
9
10
|
id: incomingID,
|
|
@@ -25,6 +26,7 @@ export const findByID = async ({
|
|
|
25
26
|
depth: isNumber(depth) ? Number(depth) : undefined,
|
|
26
27
|
draft: searchParams.get('draft') === 'true',
|
|
27
28
|
joins: sanitizeJoinParams(req.query.joins),
|
|
29
|
+
populate: sanitizePopulate(req.query.populate),
|
|
28
30
|
req,
|
|
29
31
|
select: sanitizeSelect(req.query.select)
|
|
30
32
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findByID.js","names":["httpStatus","findByIDOperation","isNumber","headersWithCors","sanitizeCollectionID","sanitizeJoinParams","sanitizeSelect","findByID","id","incomingID","collection","req","searchParams","depth","get","collectionSlug","config","slug","payload","result","Number","undefined","draft","joins","query","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 { findByIDOperation } 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'\nimport { sanitizeJoinParams } from '../utilities/sanitizeJoinParams.js'\nimport { sanitizeSelect } from '../utilities/sanitizeSelect.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 req,\n select: sanitizeSelect(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,SAASC,iBAAiB,QAAQ;AAClC,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,cAAc,QAAQ;AAE/B,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,
|
|
1
|
+
{"version":3,"file":"findByID.js","names":["httpStatus","findByIDOperation","isNumber","headersWithCors","sanitizeCollectionID","sanitizeJoinParams","sanitizePopulate","sanitizeSelect","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 { findByIDOperation } 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'\nimport { sanitizeJoinParams } from '../utilities/sanitizeJoinParams.js'\nimport { sanitizePopulate } from '../utilities/sanitizePopulate.js'\nimport { sanitizeSelect } from '../utilities/sanitizeSelect.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: sanitizePopulate(req.query.populate),\n req,\n select: sanitizeSelect(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,SAASC,iBAAiB,QAAQ;AAClC,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,cAAc,QAAQ;AAE/B,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,GAAKL,oBAAA,CAAqB;IAC9BK,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,EAAOZ,QAAA,CAASY,KAAA,IAASO,MAAA,CAAOP,KAAA,IAASQ,SAAA;IACzCC,KAAA,EAAOV,YAAA,CAAaE,GAAG,CAAC,aAAa;IACrCS,KAAA,EAAOnB,kBAAA,CAAmBO,GAAA,CAAIa,KAAK,CAACD,KAAK;IACzCE,QAAA,EAAUpB,gBAAA,CAAiBM,GAAA,CAAIa,KAAK,CAACC,QAAQ;IAC7Cd,GAAA;IACAe,MAAA,EAAQpB,cAAA,CAAeK,GAAA,CAAIa,KAAK,CAACE,MAAM;EACzC;EAEA,OAAOC,QAAA,CAASC,IAAI,CAACT,MAAA,EAAQ;IAC3BU,OAAA,EAAS3B,eAAA,CAAgB;MACvB2B,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;AAO/D,eAAO,MAAM,eAAe,EAAE,4BA8B7B,CAAA"}
|
|
@@ -3,6 +3,7 @@ import { findVersionByIDOperation } 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';
|
|
6
7
|
import { sanitizeSelect } from '../utilities/sanitizeSelect.js';
|
|
7
8
|
export const findVersionByID = async ({
|
|
8
9
|
id: incomingID,
|
|
@@ -22,6 +23,7 @@ export const findVersionByID = async ({
|
|
|
22
23
|
id,
|
|
23
24
|
collection,
|
|
24
25
|
depth: isNumber(depth) ? Number(depth) : undefined,
|
|
26
|
+
populate: sanitizePopulate(req.query.populate),
|
|
25
27
|
req,
|
|
26
28
|
select: sanitizeSelect(req.query.select)
|
|
27
29
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findVersionByID.js","names":["httpStatus","findVersionByIDOperation","isNumber","headersWithCors","sanitizeCollectionID","sanitizeSelect","findVersionByID","id","incomingID","collection","req","searchParams","depth","get","collectionSlug","config","slug","payload","result","Number","undefined","
|
|
1
|
+
{"version":3,"file":"findVersionByID.js","names":["httpStatus","findVersionByIDOperation","isNumber","headersWithCors","sanitizeCollectionID","sanitizePopulate","sanitizeSelect","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 } 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'\nimport { sanitizePopulate } from '../utilities/sanitizePopulate.js'\nimport { sanitizeSelect } from '../utilities/sanitizeSelect.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: sanitizePopulate(req.query.populate),\n req,\n select: sanitizeSelect(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,QAAQ;AACzC,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,cAAc,QAAQ;AAE/B,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,GAAKJ,oBAAA,CAAqB;IAC9BI,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,EAAOX,QAAA,CAASW,KAAA,IAASO,MAAA,CAAOP,KAAA,IAASQ,SAAA;IACzCC,QAAA,EAAUjB,gBAAA,CAAiBM,GAAA,CAAIY,KAAK,CAACD,QAAQ;IAC7CX,GAAA;IACAa,MAAA,EAAQlB,cAAA,CAAeK,GAAA,CAAIY,KAAK,CAACC,MAAM;EACzC;EAEA,OAAOC,QAAA,CAASC,IAAI,CAACP,MAAA,EAAQ;IAC3BQ,OAAA,EAASxB,eAAA,CAAgB;MACvBwB,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;AAMzD,eAAO,MAAM,YAAY,EAAE,sBA8B1B,CAAA"}
|
|
@@ -2,6 +2,7 @@ import httpStatus from 'http-status';
|
|
|
2
2
|
import { findVersionsOperation } from 'payload';
|
|
3
3
|
import { isNumber } from 'payload/shared';
|
|
4
4
|
import { headersWithCors } from '../../../utilities/headersWithCors.js';
|
|
5
|
+
import { sanitizePopulate } from '../utilities/sanitizePopulate.js';
|
|
5
6
|
import { sanitizeSelect } from '../utilities/sanitizeSelect.js';
|
|
6
7
|
export const findVersions = async ({
|
|
7
8
|
collection,
|
|
@@ -11,6 +12,7 @@ export const findVersions = async ({
|
|
|
11
12
|
depth,
|
|
12
13
|
limit,
|
|
13
14
|
page,
|
|
15
|
+
populate,
|
|
14
16
|
select,
|
|
15
17
|
sort,
|
|
16
18
|
where
|
|
@@ -20,6 +22,7 @@ export const findVersions = async ({
|
|
|
20
22
|
depth: isNumber(depth) ? Number(depth) : undefined,
|
|
21
23
|
limit: isNumber(limit) ? Number(limit) : undefined,
|
|
22
24
|
page: isNumber(page) ? Number(page) : undefined,
|
|
25
|
+
populate: sanitizePopulate(populate),
|
|
23
26
|
req,
|
|
24
27
|
select: sanitizeSelect(select),
|
|
25
28
|
sort: typeof sort === 'string' ? sort.split(',') : undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findVersions.js","names":["httpStatus","findVersionsOperation","isNumber","headersWithCors","sanitizeSelect","findVersions","collection","req","depth","limit","page","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 } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { sanitizeSelect } from '../utilities/sanitizeSelect.js'\n\nexport const findVersions: CollectionRouteHandler = async ({ collection, req }) => {\n const { depth, limit, page, select, sort, where } = req.query as {\n depth?: string\n limit?: string\n page?: string\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 req,\n select: sanitizeSelect(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,QAAQ;AACtC,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,cAAc,QAAQ;AAE/B,OAAO,MAAMC,YAAA,GAAuC,MAAAA,CAAO;EAAEC,UAAU;EAAEC;AAAG,CAAE;EAC5E,MAAM;IAAEC,KAAK;IAAEC,KAAK;IAAEC,IAAI;IAAEC,MAAM;IAAEC,IAAI;IAAEC;EAAK,CAAE,
|
|
1
|
+
{"version":3,"file":"findVersions.js","names":["httpStatus","findVersionsOperation","isNumber","headersWithCors","sanitizePopulate","sanitizeSelect","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 } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { sanitizePopulate } from '../utilities/sanitizePopulate.js'\nimport { sanitizeSelect } from '../utilities/sanitizeSelect.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: sanitizePopulate(populate),\n req,\n select: sanitizeSelect(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,QAAQ;AACtC,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,cAAc,QAAQ;AAE/B,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,EAAOP,QAAA,CAASO,KAAA,IAASS,MAAA,CAAOT,KAAA,IAASU,SAAA;IACzCT,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,EAAUR,gBAAA,CAAiBQ,QAAA;IAC3BJ,GAAA;IACAK,MAAA,EAAQR,cAAA,CAAeQ,MAAA;IACvBC,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;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;AAM/D,eAAO,MAAM,cAAc,EAAE,4BAqC5B,CAAA"}
|
|
@@ -3,6 +3,7 @@ import { restoreVersionOperation } 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';
|
|
6
7
|
export const restoreVersion = async ({
|
|
7
8
|
id: incomingID,
|
|
8
9
|
collection,
|
|
@@ -23,6 +24,7 @@ export const restoreVersion = async ({
|
|
|
23
24
|
collection,
|
|
24
25
|
depth: isNumber(depth) ? Number(depth) : undefined,
|
|
25
26
|
draft: draft === 'true' ? true : undefined,
|
|
27
|
+
populate: sanitizePopulate(req.query.populate),
|
|
26
28
|
req
|
|
27
29
|
});
|
|
28
30
|
return Response.json({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restoreVersion.js","names":["httpStatus","restoreVersionOperation","isNumber","headersWithCors","sanitizeCollectionID","restoreVersion","id","incomingID","collection","req","searchParams","depth","get","draft","collectionSlug","config","slug","payload","result","Number","undefined","Response","json","message","t","headers","Headers","status","OK"],"sources":["../../../../src/routes/rest/collections/restoreVersion.ts"],"sourcesContent":["import httpStatus from 'http-status'\nimport { restoreVersionOperation } 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 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,QAAQ;AACxC,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,oBAAoB,QAAQ;
|
|
1
|
+
{"version":3,"file":"restoreVersion.js","names":["httpStatus","restoreVersionOperation","isNumber","headersWithCors","sanitizeCollectionID","sanitizePopulate","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 } 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'\nimport { sanitizePopulate } from '../utilities/sanitizePopulate.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: sanitizePopulate(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,QAAQ;AACxC,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,gBAAgB,QAAQ;AAEjC,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,GAAKH,oBAAA,CAAqB;IAC9BG,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,EAAOV,QAAA,CAASU,KAAA,IAASQ,MAAA,CAAOR,KAAA,IAASS,SAAA;IACzCP,KAAA,EAAOA,KAAA,KAAU,SAAS,OAAOO,SAAA;IACjCC,QAAA,EAAUjB,gBAAA,CAAiBK,GAAA,CAAIa,KAAK,CAACD,QAAQ;IAC7CZ;EACF;EAEA,OAAOc,QAAA,CAASC,IAAI,CAClB;IACE,GAAGN,MAAM;IACTO,OAAA,EAAShB,GAAA,CAAIiB,CAAC,CAAC;EACjB,GACA;IACEC,OAAA,EAASzB,eAAA,CAAgB;MACvByB,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;AAMzD,eAAO,MAAM,MAAM,EAAE,sBAmEpB,CAAA"}
|
|
@@ -3,6 +3,7 @@ import httpStatus from 'http-status';
|
|
|
3
3
|
import { 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';
|
|
6
7
|
import { sanitizeSelect } from '../utilities/sanitizeSelect.js';
|
|
7
8
|
export const update = async ({
|
|
8
9
|
collection,
|
|
@@ -13,6 +14,7 @@ export const update = async ({
|
|
|
13
14
|
draft,
|
|
14
15
|
limit,
|
|
15
16
|
overrideLock,
|
|
17
|
+
populate,
|
|
16
18
|
select,
|
|
17
19
|
where
|
|
18
20
|
} = req.query;
|
|
@@ -23,6 +25,7 @@ export const update = async ({
|
|
|
23
25
|
draft: draft === 'true',
|
|
24
26
|
limit: isNumber(limit) ? Number(limit) : undefined,
|
|
25
27
|
overrideLock: Boolean(overrideLock === 'true'),
|
|
28
|
+
populate: sanitizePopulate(populate),
|
|
26
29
|
req,
|
|
27
30
|
select: sanitizeSelect(select),
|
|
28
31
|
where
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","names":["getTranslation","httpStatus","updateOperation","isNumber","headersWithCors","sanitizeSelect","update","collection","req","depth","draft","limit","overrideLock","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 { updateOperation } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { sanitizeSelect } from '../utilities/sanitizeSelect.js'\n\nexport const update: CollectionRouteHandler = async ({ collection, req }) => {\n const { depth, draft, limit, overrideLock, select, where } = req.query as {\n depth?: string\n draft?: string\n limit?: string\n overrideLock?: string\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 req,\n select: sanitizeSelect(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,eAAe,QAAQ;AAChC,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,cAAc,QAAQ;AAE/B,OAAO,MAAMC,MAAA,GAAiC,MAAAA,CAAO;EAAEC,UAAU;EAAEC;AAAG,CAAE;EACtE,MAAM;IAAEC,KAAK;IAAEC,KAAK;IAAEC,KAAK;IAAEC,YAAY;IAAEC,MAAM;IAAEC;EAAK,CAAE,
|
|
1
|
+
{"version":3,"file":"update.js","names":["getTranslation","httpStatus","updateOperation","isNumber","headersWithCors","sanitizePopulate","sanitizeSelect","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 { updateOperation } from 'payload'\nimport { isNumber } from 'payload/shared'\n\nimport type { CollectionRouteHandler } from '../types.js'\n\nimport { headersWithCors } from '../../../utilities/headersWithCors.js'\nimport { sanitizePopulate } from '../utilities/sanitizePopulate.js'\nimport { sanitizeSelect } from '../utilities/sanitizeSelect.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: sanitizePopulate(populate),\n req,\n select: sanitizeSelect(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,eAAe,QAAQ;AAChC,SAASC,QAAQ,QAAQ;AAIzB,SAASC,eAAe,QAAQ;AAChC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,cAAc,QAAQ;AAE/B,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,MAAMhB,eAAA,CAAgB;IACnCM,UAAA;IACAW,IAAA,EAAMV,GAAA,CAAIU,IAAI;IACdT,KAAA,EAAOP,QAAA,CAASO,KAAA,IAASU,MAAA,CAAOV,KAAA,IAASW,SAAA;IACzCV,KAAA,EAAOA,KAAA,KAAU;IACjBC,KAAA,EAAOT,QAAA,CAASS,KAAA,IAASQ,MAAA,CAAOR,KAAA,IAASS,SAAA;IACzCR,YAAA,EAAcS,OAAA,CAAQT,YAAA,KAAiB;IACvCC,QAAA,EAAUT,gBAAA,CAAiBS,QAAA;IAC3BL,GAAA;IACAM,MAAA,EAAQT,cAAA,CAAeS,MAAA;IACvBC;EACF;EAEA,MAAMO,OAAA,GAAUnB,eAAA,CAAgB;IAC9BmB,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;AAO/D,eAAO,MAAM,UAAU,EAAE,4BAsDxB,CAAA"}
|
|
@@ -3,6 +3,7 @@ import { 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';
|
|
6
7
|
import { sanitizeSelect } from '../utilities/sanitizeSelect.js';
|
|
7
8
|
export const updateByID = async ({
|
|
8
9
|
id: incomingID,
|
|
@@ -30,6 +31,7 @@ export const updateByID = async ({
|
|
|
30
31
|
depth: isNumber(depth) ? Number(depth) : undefined,
|
|
31
32
|
draft,
|
|
32
33
|
overrideLock: Boolean(overrideLock === 'true'),
|
|
34
|
+
populate: sanitizePopulate(req.query.populate),
|
|
33
35
|
publishSpecificLocale,
|
|
34
36
|
req,
|
|
35
37
|
select: sanitizeSelect(req.query.select)
|