payload 3.24.0 → 3.25.0-canary.9728d80
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/collections/operations/local/count.d.ts +31 -1
- package/dist/collections/operations/local/count.d.ts.map +1 -1
- package/dist/collections/operations/local/count.js.map +1 -1
- package/dist/collections/operations/local/countVersions.d.ts +31 -1
- package/dist/collections/operations/local/countVersions.d.ts.map +1 -1
- package/dist/collections/operations/local/countVersions.js.map +1 -1
- package/dist/collections/operations/local/create.d.ts +66 -1
- package/dist/collections/operations/local/create.d.ts.map +1 -1
- package/dist/collections/operations/local/create.js.map +1 -1
- package/dist/collections/operations/local/delete.d.ts +58 -1
- package/dist/collections/operations/local/delete.d.ts.map +1 -1
- package/dist/collections/operations/local/delete.js.map +1 -1
- package/dist/collections/operations/local/duplicate.d.ts +51 -1
- package/dist/collections/operations/local/duplicate.d.ts.map +1 -1
- package/dist/collections/operations/local/duplicate.js.map +1 -1
- package/dist/collections/operations/local/find.d.ts +76 -1
- package/dist/collections/operations/local/find.d.ts.map +1 -1
- package/dist/collections/operations/local/find.js.map +1 -1
- package/dist/collections/operations/local/findByID.d.ts +59 -1
- package/dist/collections/operations/local/findByID.d.ts.map +1 -1
- package/dist/collections/operations/local/findByID.js.map +1 -1
- package/dist/collections/operations/local/findVersionByID.d.ts +48 -1
- package/dist/collections/operations/local/findVersionByID.d.ts.map +1 -1
- package/dist/collections/operations/local/findVersionByID.js.map +1 -1
- package/dist/collections/operations/local/findVersions.d.ts +58 -1
- package/dist/collections/operations/local/findVersions.d.ts.map +1 -1
- package/dist/collections/operations/local/findVersions.js.map +1 -1
- package/dist/collections/operations/local/restoreVersion.d.ts +44 -1
- package/dist/collections/operations/local/restoreVersion.d.ts.map +1 -1
- package/dist/collections/operations/local/restoreVersion.js.map +1 -1
- package/dist/collections/operations/local/update.d.ts +88 -1
- package/dist/collections/operations/local/update.d.ts.map +1 -1
- package/dist/collections/operations/local/update.js.map +1 -1
- package/dist/fields/config/client.d.ts.map +1 -1
- package/dist/fields/config/client.js +8 -4
- package/dist/fields/config/client.js.map +1 -1
- package/dist/fields/config/types.d.ts +2 -1
- package/dist/fields/config/types.d.ts.map +1 -1
- package/dist/fields/config/types.js.map +1 -1
- package/dist/fields/validations.js +2 -2
- package/dist/fields/validations.js.map +1 -1
- package/dist/globals/operations/local/countGlobalVersions.d.ts +31 -1
- package/dist/globals/operations/local/countGlobalVersions.d.ts.map +1 -1
- package/dist/globals/operations/local/countGlobalVersions.js.map +1 -1
- package/dist/globals/operations/local/findOne.d.ts +46 -0
- package/dist/globals/operations/local/findOne.d.ts.map +1 -1
- package/dist/globals/operations/local/findOne.js.map +1 -1
- package/dist/globals/operations/local/findVersionByID.d.ts +47 -0
- package/dist/globals/operations/local/findVersionByID.d.ts.map +1 -1
- package/dist/globals/operations/local/findVersionByID.js.map +1 -1
- package/dist/globals/operations/local/findVersions.d.ts +57 -0
- package/dist/globals/operations/local/findVersions.d.ts.map +1 -1
- package/dist/globals/operations/local/findVersions.js.map +1 -1
- package/dist/globals/operations/local/restoreVersion.d.ts +40 -0
- package/dist/globals/operations/local/restoreVersion.d.ts.map +1 -1
- package/dist/globals/operations/local/restoreVersion.js.map +1 -1
- package/dist/globals/operations/local/update.d.ts +54 -0
- package/dist/globals/operations/local/update.d.ts.map +1 -1
- package/dist/globals/operations/local/update.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/uploads/endpoints/getFile.d.ts.map +1 -1
- package/dist/uploads/endpoints/getFile.js +24 -1
- package/dist/uploads/endpoints/getFile.js.map +1 -1
- package/dist/utilities/checkDocumentLockStatus.js +2 -2
- package/dist/utilities/checkDocumentLockStatus.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,17 +1,47 @@
|
|
|
1
1
|
import type { CollectionSlug, Payload, RequestContext, TypedLocale } from '../../../index.js';
|
|
2
2
|
import type { Document, PayloadRequest, Where } from '../../../types/index.js';
|
|
3
3
|
export type Options<TSlug extends CollectionSlug> = {
|
|
4
|
+
/**
|
|
5
|
+
* the Collection slug to operate against.
|
|
6
|
+
*/
|
|
4
7
|
collection: TSlug;
|
|
5
8
|
/**
|
|
6
|
-
* context, which will then be passed to req.context
|
|
9
|
+
* [Context](https://payloadcms.com/docs/hooks/context), which will then be passed to `context` and `req.context`,
|
|
10
|
+
* which can be read by hooks. Useful if you want to pass additional information to the hooks which
|
|
11
|
+
* shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook
|
|
12
|
+
* to determine if it should run or not.
|
|
7
13
|
*/
|
|
8
14
|
context?: RequestContext;
|
|
15
|
+
/**
|
|
16
|
+
* [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.
|
|
17
|
+
*/
|
|
9
18
|
depth?: number;
|
|
19
|
+
/**
|
|
20
|
+
* When set to `true`, errors will not be thrown.
|
|
21
|
+
*/
|
|
10
22
|
disableErrors?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.
|
|
25
|
+
*/
|
|
11
26
|
locale?: TypedLocale;
|
|
27
|
+
/**
|
|
28
|
+
* Skip access control.
|
|
29
|
+
* Set to `false` if you want to respect Access Control for the operation, for example when fetching data for the fron-end.
|
|
30
|
+
* @default true
|
|
31
|
+
*/
|
|
12
32
|
overrideAccess?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* The `PayloadRequest` object. You can pass it to thread the current [transaction](https://payloadcms.com/docs/database/transactions), user and locale to the operation.
|
|
35
|
+
* Recommended to pass when using the Local API from hooks, as usually you want to execute the operation within the current transaction.
|
|
36
|
+
*/
|
|
13
37
|
req?: Partial<PayloadRequest>;
|
|
38
|
+
/**
|
|
39
|
+
* If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.
|
|
40
|
+
*/
|
|
14
41
|
user?: Document;
|
|
42
|
+
/**
|
|
43
|
+
* A filter [query](https://payloadcms.com/docs/queries/overview)
|
|
44
|
+
*/
|
|
15
45
|
where?: Where;
|
|
16
46
|
};
|
|
17
47
|
export default function countLocal<TSlug extends CollectionSlug>(payload: Payload, options: Options<TSlug>): Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"count.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/count.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC7F,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAM9E,MAAM,MAAM,OAAO,CAAC,KAAK,SAAS,cAAc,IAAI;IAClD,UAAU,EAAE,KAAK,CAAA;IACjB
|
|
1
|
+
{"version":3,"file":"count.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/count.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC7F,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAM9E,MAAM,MAAM,OAAO,CAAC,KAAK,SAAS,cAAc,IAAI;IAClD;;OAEG;IACH,UAAU,EAAE,KAAK,CAAA;IACjB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;IAC7B;;OAEG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAA;IACf;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAA;AAGD,wBAA8B,UAAU,CAAC,KAAK,SAAS,cAAc,EACnE,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,GACtB,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAkBhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/collections/operations/local/count.ts"],"sourcesContent":["// @ts-strict-ignore\nimport type { CollectionSlug, Payload, RequestContext, TypedLocale } from '../../../index.js'\nimport type { Document, PayloadRequest, Where } from '../../../types/index.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { countOperation } from '../count.js'\n\nexport type Options<TSlug extends CollectionSlug> = {\n collection: TSlug\n /**\n * context, which will then be passed to req.context
|
|
1
|
+
{"version":3,"sources":["../../../../src/collections/operations/local/count.ts"],"sourcesContent":["// @ts-strict-ignore\nimport type { CollectionSlug, Payload, RequestContext, TypedLocale } from '../../../index.js'\nimport type { Document, PayloadRequest, Where } from '../../../types/index.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { countOperation } from '../count.js'\n\nexport type Options<TSlug extends CollectionSlug> = {\n /**\n * the Collection slug to operate against.\n */\n collection: TSlug\n /**\n * [Context](https://payloadcms.com/docs/hooks/context), which will then be passed to `context` and `req.context`,\n * which can be read by hooks. Useful if you want to pass additional information to the hooks which\n * shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook\n * to determine if it should run or not.\n */\n context?: RequestContext\n /**\n * [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.\n */\n depth?: number\n /**\n * When set to `true`, errors will not be thrown.\n */\n disableErrors?: boolean\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: TypedLocale\n /**\n * Skip access control.\n * Set to `false` if you want to respect Access Control for the operation, for example when fetching data for the fron-end.\n * @default true\n */\n overrideAccess?: boolean\n /**\n * The `PayloadRequest` object. You can pass it to thread the current [transaction](https://payloadcms.com/docs/database/transactions), user and locale to the operation.\n * Recommended to pass when using the Local API from hooks, as usually you want to execute the operation within the current transaction.\n */\n req?: Partial<PayloadRequest>\n /**\n * If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.\n */\n user?: Document\n /**\n * A filter [query](https://payloadcms.com/docs/queries/overview)\n */\n where?: Where\n}\n\n// eslint-disable-next-line no-restricted-exports\nexport default async function countLocal<TSlug extends CollectionSlug>(\n payload: Payload,\n options: Options<TSlug>,\n): Promise<{ totalDocs: number }> {\n const { collection: collectionSlug, disableErrors, overrideAccess = true, where } = options\n\n const collection = payload.collections[collectionSlug]\n\n if (!collection) {\n throw new APIError(\n `The collection with slug ${String(collectionSlug)} can't be found. Count Operation.`,\n )\n }\n\n return countOperation<TSlug>({\n collection,\n disableErrors,\n overrideAccess,\n req: await createLocalReq(options, payload),\n where,\n })\n}\n"],"names":["APIError","createLocalReq","countOperation","countLocal","payload","options","collection","collectionSlug","disableErrors","overrideAccess","where","collections","String","req"],"mappings":"AAAA,oBAAoB;AAIpB,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,cAAc,QAAQ,cAAa;AA+C5C,iDAAiD;AACjD,eAAe,eAAeC,WAC5BC,OAAgB,EAChBC,OAAuB;IAEvB,MAAM,EAAEC,YAAYC,cAAc,EAAEC,aAAa,EAAEC,iBAAiB,IAAI,EAAEC,KAAK,EAAE,GAAGL;IAEpF,MAAMC,aAAaF,QAAQO,WAAW,CAACJ,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIN,SACR,CAAC,yBAAyB,EAAEY,OAAOL,gBAAgB,iCAAiC,CAAC;IAEzF;IAEA,OAAOL,eAAsB;QAC3BI;QACAE;QACAC;QACAI,KAAK,MAAMZ,eAAeI,SAASD;QACnCM;IACF;AACF"}
|
|
@@ -1,17 +1,47 @@
|
|
|
1
1
|
import type { CollectionSlug, Payload, RequestContext, TypedLocale } from '../../../index.js';
|
|
2
2
|
import type { Document, PayloadRequest, Where } from '../../../types/index.js';
|
|
3
3
|
export type Options<TSlug extends CollectionSlug> = {
|
|
4
|
+
/**
|
|
5
|
+
* the Collection slug to operate against.
|
|
6
|
+
*/
|
|
4
7
|
collection: TSlug;
|
|
5
8
|
/**
|
|
6
|
-
* context, which will then be passed to req.context
|
|
9
|
+
* [Context](https://payloadcms.com/docs/hooks/context), which will then be passed to `context` and `req.context`,
|
|
10
|
+
* which can be read by hooks. Useful if you want to pass additional information to the hooks which
|
|
11
|
+
* shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook
|
|
12
|
+
* to determine if it should run or not.
|
|
7
13
|
*/
|
|
8
14
|
context?: RequestContext;
|
|
15
|
+
/**
|
|
16
|
+
* [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.
|
|
17
|
+
*/
|
|
9
18
|
depth?: number;
|
|
19
|
+
/**
|
|
20
|
+
* When set to `true`, errors will not be thrown.
|
|
21
|
+
*/
|
|
10
22
|
disableErrors?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.
|
|
25
|
+
*/
|
|
11
26
|
locale?: TypedLocale;
|
|
27
|
+
/**
|
|
28
|
+
* Skip access control.
|
|
29
|
+
* Set to `false` if you want to respect Access Control for the operation, for example when fetching data for the fron-end.
|
|
30
|
+
* @default true
|
|
31
|
+
*/
|
|
12
32
|
overrideAccess?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* The `PayloadRequest` object. You can pass it to thread the current [transaction](https://payloadcms.com/docs/database/transactions), user and locale to the operation.
|
|
35
|
+
* Recommended to pass when using the Local API from hooks, as usually you want to execute the operation within the current transaction.
|
|
36
|
+
*/
|
|
13
37
|
req?: Partial<PayloadRequest>;
|
|
38
|
+
/**
|
|
39
|
+
* If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.
|
|
40
|
+
*/
|
|
14
41
|
user?: Document;
|
|
42
|
+
/**
|
|
43
|
+
* A filter [query](https://payloadcms.com/docs/queries/overview)
|
|
44
|
+
*/
|
|
15
45
|
where?: Where;
|
|
16
46
|
};
|
|
17
47
|
export default function countVersionsLocal<TSlug extends CollectionSlug>(payload: Payload, options: Options<TSlug>): Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"countVersions.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/countVersions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC7F,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAM9E,MAAM,MAAM,OAAO,CAAC,KAAK,SAAS,cAAc,IAAI;IAClD,UAAU,EAAE,KAAK,CAAA;IACjB
|
|
1
|
+
{"version":3,"file":"countVersions.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/countVersions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC7F,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAM9E,MAAM,MAAM,OAAO,CAAC,KAAK,SAAS,cAAc,IAAI;IAClD;;OAEG;IACH,UAAU,EAAE,KAAK,CAAA;IACjB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;IAC7B;;OAEG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAA;IACf;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAA;AAGD,wBAA8B,kBAAkB,CAAC,KAAK,SAAS,cAAc,EAC3E,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,GACtB,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAkBhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/collections/operations/local/countVersions.ts"],"sourcesContent":["// @ts-strict-ignore\nimport type { CollectionSlug, Payload, RequestContext, TypedLocale } from '../../../index.js'\nimport type { Document, PayloadRequest, Where } from '../../../types/index.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { countVersionsOperation } from '../countVersions.js'\n\nexport type Options<TSlug extends CollectionSlug> = {\n collection: TSlug\n /**\n * context, which will then be passed to req.context
|
|
1
|
+
{"version":3,"sources":["../../../../src/collections/operations/local/countVersions.ts"],"sourcesContent":["// @ts-strict-ignore\nimport type { CollectionSlug, Payload, RequestContext, TypedLocale } from '../../../index.js'\nimport type { Document, PayloadRequest, Where } from '../../../types/index.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { countVersionsOperation } from '../countVersions.js'\n\nexport type Options<TSlug extends CollectionSlug> = {\n /**\n * the Collection slug to operate against.\n */\n collection: TSlug\n /**\n * [Context](https://payloadcms.com/docs/hooks/context), which will then be passed to `context` and `req.context`,\n * which can be read by hooks. Useful if you want to pass additional information to the hooks which\n * shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook\n * to determine if it should run or not.\n */\n context?: RequestContext\n /**\n * [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.\n */\n depth?: number\n /**\n * When set to `true`, errors will not be thrown.\n */\n disableErrors?: boolean\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: TypedLocale\n /**\n * Skip access control.\n * Set to `false` if you want to respect Access Control for the operation, for example when fetching data for the fron-end.\n * @default true\n */\n overrideAccess?: boolean\n /**\n * The `PayloadRequest` object. You can pass it to thread the current [transaction](https://payloadcms.com/docs/database/transactions), user and locale to the operation.\n * Recommended to pass when using the Local API from hooks, as usually you want to execute the operation within the current transaction.\n */\n req?: Partial<PayloadRequest>\n /**\n * If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.\n */\n user?: Document\n /**\n * A filter [query](https://payloadcms.com/docs/queries/overview)\n */\n where?: Where\n}\n\n// eslint-disable-next-line no-restricted-exports\nexport default async function countVersionsLocal<TSlug extends CollectionSlug>(\n payload: Payload,\n options: Options<TSlug>,\n): Promise<{ totalDocs: number }> {\n const { collection: collectionSlug, disableErrors, overrideAccess = true, where } = options\n\n const collection = payload.collections[collectionSlug]\n\n if (!collection) {\n throw new APIError(\n `The collection with slug ${String(collectionSlug)} can't be found. Count Versions Operation.`,\n )\n }\n\n return countVersionsOperation<TSlug>({\n collection,\n disableErrors,\n overrideAccess,\n req: await createLocalReq(options, payload),\n where,\n })\n}\n"],"names":["APIError","createLocalReq","countVersionsOperation","countVersionsLocal","payload","options","collection","collectionSlug","disableErrors","overrideAccess","where","collections","String","req"],"mappings":"AAAA,oBAAoB;AAIpB,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,sBAAsB,QAAQ,sBAAqB;AA+C5D,iDAAiD;AACjD,eAAe,eAAeC,mBAC5BC,OAAgB,EAChBC,OAAuB;IAEvB,MAAM,EAAEC,YAAYC,cAAc,EAAEC,aAAa,EAAEC,iBAAiB,IAAI,EAAEC,KAAK,EAAE,GAAGL;IAEpF,MAAMC,aAAaF,QAAQO,WAAW,CAACJ,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIN,SACR,CAAC,yBAAyB,EAAEY,OAAOL,gBAAgB,0CAA0C,CAAC;IAElG;IAEA,OAAOL,uBAA8B;QACnCI;QACAE;QACAC;QACAI,KAAK,MAAMZ,eAAeI,SAASD;QACnCM;IACF;AACF"}
|
|
@@ -3,27 +3,92 @@ import type { File } from '../../../uploads/types.js';
|
|
|
3
3
|
import type { DataFromCollectionSlug, RequiredDataFromCollectionSlug, SelectFromCollectionSlug } from '../../config/types.js';
|
|
4
4
|
import { type CollectionSlug, type Payload, type RequestContext, type TypedLocale } from '../../../index.js';
|
|
5
5
|
export type Options<TSlug extends CollectionSlug, TSelect extends SelectType> = {
|
|
6
|
+
/**
|
|
7
|
+
* the Collection slug to operate against.
|
|
8
|
+
*/
|
|
6
9
|
collection: TSlug;
|
|
7
10
|
/**
|
|
8
|
-
* context, which will then be passed to req.context
|
|
11
|
+
* [Context](https://payloadcms.com/docs/hooks/context), which will then be passed to `context` and `req.context`,
|
|
12
|
+
* which can be read by hooks. Useful if you want to pass additional information to the hooks which
|
|
13
|
+
* shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook
|
|
14
|
+
* to determine if it should run or not.
|
|
9
15
|
*/
|
|
10
16
|
context?: RequestContext;
|
|
17
|
+
/**
|
|
18
|
+
* The data for the document to create.
|
|
19
|
+
*/
|
|
11
20
|
data: RequiredDataFromCollectionSlug<TSlug>;
|
|
21
|
+
/**
|
|
22
|
+
* [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.
|
|
23
|
+
*/
|
|
12
24
|
depth?: number;
|
|
25
|
+
/**
|
|
26
|
+
* When set to `true`, a [database transactions](https://payloadcms.com/docs/database/transactions) will not be initialized.
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
13
29
|
disableTransaction?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* If creating verification-enabled auth doc,
|
|
32
|
+
* you can disable the email that is auto-sent
|
|
33
|
+
*/
|
|
14
34
|
disableVerificationEmail?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Create a **draft** document. [More](https://payloadcms.com/docs/versions/drafts#draft-api)
|
|
37
|
+
*/
|
|
15
38
|
draft?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* If you want to create a document that is a duplicate of another document
|
|
41
|
+
*/
|
|
16
42
|
duplicateFromID?: DataFromCollectionSlug<TSlug>['id'];
|
|
43
|
+
/**
|
|
44
|
+
* Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.
|
|
45
|
+
*/
|
|
17
46
|
fallbackLocale?: false | TypedLocale;
|
|
47
|
+
/**
|
|
48
|
+
* A `File` object when creating a collection with `upload: true`.
|
|
49
|
+
*/
|
|
18
50
|
file?: File;
|
|
51
|
+
/**
|
|
52
|
+
* A file path when creating a collection with `upload: true`.
|
|
53
|
+
*/
|
|
19
54
|
filePath?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.
|
|
57
|
+
*/
|
|
20
58
|
locale?: TypedLocale;
|
|
59
|
+
/**
|
|
60
|
+
* Skip access control.
|
|
61
|
+
* Set to `false` if you want to respect Access Control for the operation, for example when fetching data for the fron-end.
|
|
62
|
+
* @default true
|
|
63
|
+
*/
|
|
21
64
|
overrideAccess?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* If you are uploading a file and would like to replace
|
|
67
|
+
* the existing file instead of generating a new filename,
|
|
68
|
+
* you can set the following property to `true`
|
|
69
|
+
*/
|
|
22
70
|
overwriteExistingFiles?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.
|
|
73
|
+
*/
|
|
23
74
|
populate?: PopulateType;
|
|
75
|
+
/**
|
|
76
|
+
* The `PayloadRequest` object. You can pass it to thread the current [transaction](https://payloadcms.com/docs/database/transactions), user and locale to the operation.
|
|
77
|
+
* Recommended to pass when using the Local API from hooks, as usually you want to execute the operation within the current transaction.
|
|
78
|
+
*/
|
|
24
79
|
req?: Partial<PayloadRequest>;
|
|
80
|
+
/**
|
|
81
|
+
* Specify [select](https://payloadcms.com/docs/queries/select) to control which fields to include to the result.
|
|
82
|
+
*/
|
|
25
83
|
select?: TSelect;
|
|
84
|
+
/**
|
|
85
|
+
* Opt-in to receiving hidden fields. By default, they are hidden from returned documents in accordance to your config.
|
|
86
|
+
* @default false
|
|
87
|
+
*/
|
|
26
88
|
showHiddenFields?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.
|
|
91
|
+
*/
|
|
27
92
|
user?: Document;
|
|
28
93
|
};
|
|
29
94
|
export default function createLocal<TSlug extends CollectionSlug, TSelect extends SelectFromCollectionSlug<TSlug>>(payload: Payload, options: Options<TSlug, TSelect>): Promise<TransformCollectionWithSelect<TSlug, TSelect>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/create.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,UAAU,EACV,6BAA6B,EAC9B,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,KAAK,EACV,sBAAsB,EACtB,8BAA8B,EAC9B,wBAAwB,EACzB,MAAM,uBAAuB,CAAA;AAG9B,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,WAAW,EACjB,MAAM,mBAAmB,CAAA;AAK1B,MAAM,MAAM,OAAO,CAAC,KAAK,SAAS,cAAc,EAAE,OAAO,SAAS,UAAU,IAAI;IAC9E,UAAU,EAAE,KAAK,CAAA;IACjB
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/create.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,UAAU,EACV,6BAA6B,EAC9B,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,KAAK,EACV,sBAAsB,EACtB,8BAA8B,EAC9B,wBAAwB,EACzB,MAAM,uBAAuB,CAAA;AAG9B,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,WAAW,EACjB,MAAM,mBAAmB,CAAA;AAK1B,MAAM,MAAM,OAAO,CAAC,KAAK,SAAS,cAAc,EAAE,OAAO,SAAS,UAAU,IAAI;IAC9E;;OAEG;IACH,UAAU,EAAE,KAAK,CAAA;IACjB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB;;OAEG;IACH,IAAI,EAAE,8BAA8B,CAAC,KAAK,CAAC,CAAA;IAC3C;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B;;;OAGG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;;OAEG;IACH,eAAe,CAAC,EAAE,sBAAsB,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAA;IACrD;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IACpC;;OAEG;IACH,IAAI,CAAC,EAAE,IAAI,CAAA;IACX;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC;;OAEG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;IAC7B;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B;;OAEG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAA;CAChB,CAAA;AAGD,wBAA8B,WAAW,CACvC,KAAK,SAAS,cAAc,EAC5B,OAAO,SAAS,wBAAwB,CAAC,KAAK,CAAC,EAE/C,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,6BAA6B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CA2CxD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/collections/operations/local/create.ts"],"sourcesContent":["// @ts-strict-ignore\nimport type {\n Document,\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformCollectionWithSelect,\n} from '../../../types/index.js'\nimport type { File } from '../../../uploads/types.js'\nimport type {\n DataFromCollectionSlug,\n RequiredDataFromCollectionSlug,\n SelectFromCollectionSlug,\n} from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport {\n type CollectionSlug,\n deepCopyObjectSimple,\n type Payload,\n type RequestContext,\n type TypedLocale,\n} from '../../../index.js'\nimport { getFileByPath } from '../../../uploads/getFileByPath.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { createOperation } from '../create.js'\n\nexport type Options<TSlug extends CollectionSlug, TSelect extends SelectType> = {\n collection: TSlug\n /**\n * context, which will then be passed to req.context
|
|
1
|
+
{"version":3,"sources":["../../../../src/collections/operations/local/create.ts"],"sourcesContent":["// @ts-strict-ignore\nimport type {\n Document,\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformCollectionWithSelect,\n} from '../../../types/index.js'\nimport type { File } from '../../../uploads/types.js'\nimport type {\n DataFromCollectionSlug,\n RequiredDataFromCollectionSlug,\n SelectFromCollectionSlug,\n} from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport {\n type CollectionSlug,\n deepCopyObjectSimple,\n type Payload,\n type RequestContext,\n type TypedLocale,\n} from '../../../index.js'\nimport { getFileByPath } from '../../../uploads/getFileByPath.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { createOperation } from '../create.js'\n\nexport type Options<TSlug extends CollectionSlug, TSelect extends SelectType> = {\n /**\n * the Collection slug to operate against.\n */\n collection: TSlug\n /**\n * [Context](https://payloadcms.com/docs/hooks/context), which will then be passed to `context` and `req.context`,\n * which can be read by hooks. Useful if you want to pass additional information to the hooks which\n * shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook\n * to determine if it should run or not.\n */\n context?: RequestContext\n /**\n * The data for the document to create.\n */\n data: RequiredDataFromCollectionSlug<TSlug>\n /**\n * [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.\n */\n depth?: number\n /**\n * When set to `true`, a [database transactions](https://payloadcms.com/docs/database/transactions) will not be initialized.\n * @default false\n */\n disableTransaction?: boolean\n /**\n * If creating verification-enabled auth doc,\n * you can disable the email that is auto-sent\n */\n disableVerificationEmail?: boolean\n /**\n * Create a **draft** document. [More](https://payloadcms.com/docs/versions/drafts#draft-api)\n */\n draft?: boolean\n /**\n * If you want to create a document that is a duplicate of another document\n */\n duplicateFromID?: DataFromCollectionSlug<TSlug>['id']\n /**\n * Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.\n */\n fallbackLocale?: false | TypedLocale\n /**\n * A `File` object when creating a collection with `upload: true`.\n */\n file?: File\n /**\n * A file path when creating a collection with `upload: true`.\n */\n filePath?: string\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: TypedLocale\n /**\n * Skip access control.\n * Set to `false` if you want to respect Access Control for the operation, for example when fetching data for the fron-end.\n * @default true\n */\n overrideAccess?: boolean\n /**\n * If you are uploading a file and would like to replace\n * the existing file instead of generating a new filename,\n * you can set the following property to `true`\n */\n overwriteExistingFiles?: boolean\n /**\n * Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.\n */\n populate?: PopulateType\n /**\n * The `PayloadRequest` object. You can pass it to thread the current [transaction](https://payloadcms.com/docs/database/transactions), user and locale to the operation.\n * Recommended to pass when using the Local API from hooks, as usually you want to execute the operation within the current transaction.\n */\n req?: Partial<PayloadRequest>\n /**\n * Specify [select](https://payloadcms.com/docs/queries/select) to control which fields to include to the result.\n */\n select?: TSelect\n /**\n * Opt-in to receiving hidden fields. By default, they are hidden from returned documents in accordance to your config.\n * @default false\n */\n showHiddenFields?: boolean\n /**\n * If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.\n */\n user?: Document\n}\n\n// eslint-disable-next-line no-restricted-exports\nexport default async function createLocal<\n TSlug extends CollectionSlug,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n>(\n payload: Payload,\n options: Options<TSlug, TSelect>,\n): Promise<TransformCollectionWithSelect<TSlug, TSelect>> {\n const {\n collection: collectionSlug,\n data,\n depth,\n disableTransaction,\n disableVerificationEmail,\n draft,\n duplicateFromID,\n file,\n filePath,\n overrideAccess = true,\n overwriteExistingFiles = false,\n populate,\n select,\n showHiddenFields,\n } = options\n const collection = payload.collections[collectionSlug]\n\n if (!collection) {\n throw new APIError(\n `The collection with slug ${String(collectionSlug)} can't be found. Create Operation.`,\n )\n }\n\n const req = await createLocalReq(options, payload)\n req.file = file ?? (await getFileByPath(filePath))\n\n return createOperation<TSlug, TSelect>({\n collection,\n data: deepCopyObjectSimple(data), // Ensure mutation of data in create operation hooks doesn't affect the original data\n depth,\n disableTransaction,\n disableVerificationEmail,\n draft,\n duplicateFromID,\n overrideAccess,\n overwriteExistingFiles,\n populate,\n req,\n select,\n showHiddenFields,\n })\n}\n"],"names":["APIError","deepCopyObjectSimple","getFileByPath","createLocalReq","createOperation","createLocal","payload","options","collection","collectionSlug","data","depth","disableTransaction","disableVerificationEmail","draft","duplicateFromID","file","filePath","overrideAccess","overwriteExistingFiles","populate","select","showHiddenFields","collections","String","req"],"mappings":"AAAA,oBAAoB;AAepB,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAEEC,oBAAoB,QAIf,oBAAmB;AAC1B,SAASC,aAAa,QAAQ,oCAAmC;AACjE,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,eAAe,QAAQ,eAAc;AA4F9C,iDAAiD;AACjD,eAAe,eAAeC,YAI5BC,OAAgB,EAChBC,OAAgC;IAEhC,MAAM,EACJC,YAAYC,cAAc,EAC1BC,IAAI,EACJC,KAAK,EACLC,kBAAkB,EAClBC,wBAAwB,EACxBC,KAAK,EACLC,eAAe,EACfC,IAAI,EACJC,QAAQ,EACRC,iBAAiB,IAAI,EACrBC,yBAAyB,KAAK,EAC9BC,QAAQ,EACRC,MAAM,EACNC,gBAAgB,EACjB,GAAGf;IACJ,MAAMC,aAAaF,QAAQiB,WAAW,CAACd,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIR,SACR,CAAC,yBAAyB,EAAEwB,OAAOf,gBAAgB,kCAAkC,CAAC;IAE1F;IAEA,MAAMgB,MAAM,MAAMtB,eAAeI,SAASD;IAC1CmB,IAAIT,IAAI,GAAGA,QAAS,MAAMd,cAAce;IAExC,OAAOb,gBAAgC;QACrCI;QACAE,MAAMT,qBAAqBS;QAC3BC;QACAC;QACAC;QACAC;QACAC;QACAG;QACAC;QACAC;QACAK;QACAJ;QACAC;IACF;AACF"}
|
|
@@ -2,29 +2,86 @@ import type { CollectionSlug, Payload, RequestContext, TypedLocale } from '../..
|
|
|
2
2
|
import type { Document, PayloadRequest, PopulateType, SelectType, TransformCollectionWithSelect, Where } from '../../../types/index.js';
|
|
3
3
|
import type { BulkOperationResult, SelectFromCollectionSlug } from '../../config/types.js';
|
|
4
4
|
export type BaseOptions<TSlug extends CollectionSlug, TSelect extends SelectType> = {
|
|
5
|
+
/**
|
|
6
|
+
* the Collection slug to operate against.
|
|
7
|
+
*/
|
|
5
8
|
collection: TSlug;
|
|
6
9
|
/**
|
|
7
|
-
* context, which will then be passed to req.context
|
|
10
|
+
* [Context](https://payloadcms.com/docs/hooks/context), which will then be passed to `context` and `req.context`,
|
|
11
|
+
* which can be read by hooks. Useful if you want to pass additional information to the hooks which
|
|
12
|
+
* shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook
|
|
13
|
+
* to determine if it should run or not.
|
|
8
14
|
*/
|
|
9
15
|
context?: RequestContext;
|
|
16
|
+
/**
|
|
17
|
+
* [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.
|
|
18
|
+
*/
|
|
10
19
|
depth?: number;
|
|
20
|
+
/**
|
|
21
|
+
* When set to `true`, a [database transactions](https://payloadcms.com/docs/database/transactions) will not be initialized.
|
|
22
|
+
* @default false
|
|
23
|
+
*/
|
|
11
24
|
disableTransaction?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.
|
|
27
|
+
*/
|
|
12
28
|
fallbackLocale?: false | TypedLocale;
|
|
29
|
+
/**
|
|
30
|
+
* Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.
|
|
31
|
+
*/
|
|
13
32
|
locale?: TypedLocale;
|
|
33
|
+
/**
|
|
34
|
+
* Skip access control.
|
|
35
|
+
* Set to `false` if you want to respect Access Control for the operation, for example when fetching data for the fron-end.
|
|
36
|
+
* @default true
|
|
37
|
+
*/
|
|
14
38
|
overrideAccess?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* By default, document locks are ignored (`true`). Set to `false` to enforce locks and prevent operations when a document is locked by another user. [More details](https://payloadcms.com/docs/admin/locked-documents).
|
|
41
|
+
* @default true
|
|
42
|
+
*/
|
|
15
43
|
overrideLock?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.
|
|
46
|
+
*/
|
|
16
47
|
populate?: PopulateType;
|
|
48
|
+
/**
|
|
49
|
+
* The `PayloadRequest` object. You can pass it to thread the current [transaction](https://payloadcms.com/docs/database/transactions), user and locale to the operation.
|
|
50
|
+
* Recommended to pass when using the Local API from hooks, as usually you want to execute the operation within the current transaction.
|
|
51
|
+
*/
|
|
17
52
|
req?: Partial<PayloadRequest>;
|
|
53
|
+
/**
|
|
54
|
+
* Specify [select](https://payloadcms.com/docs/queries/select) to control which fields to include to the result.
|
|
55
|
+
*/
|
|
18
56
|
select?: TSelect;
|
|
57
|
+
/**
|
|
58
|
+
* Opt-in to receiving hidden fields. By default, they are hidden from returned documents in accordance to your config.
|
|
59
|
+
* @default false
|
|
60
|
+
*/
|
|
19
61
|
showHiddenFields?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.
|
|
64
|
+
*/
|
|
20
65
|
user?: Document;
|
|
21
66
|
};
|
|
22
67
|
export type ByIDOptions<TSlug extends CollectionSlug, TSelect extends SelectFromCollectionSlug<TSlug>> = {
|
|
68
|
+
/**
|
|
69
|
+
* The ID of the document to delete.
|
|
70
|
+
*/
|
|
23
71
|
id: number | string;
|
|
72
|
+
/**
|
|
73
|
+
* A filter [query](https://payloadcms.com/docs/queries/overview)
|
|
74
|
+
*/
|
|
24
75
|
where?: never;
|
|
25
76
|
} & BaseOptions<TSlug, TSelect>;
|
|
26
77
|
export type ManyOptions<TSlug extends CollectionSlug, TSelect extends SelectFromCollectionSlug<TSlug>> = {
|
|
78
|
+
/**
|
|
79
|
+
* The ID of the document to delete.
|
|
80
|
+
*/
|
|
27
81
|
id?: never;
|
|
82
|
+
/**
|
|
83
|
+
* A filter [query](https://payloadcms.com/docs/queries/overview)
|
|
84
|
+
*/
|
|
28
85
|
where: Where;
|
|
29
86
|
} & BaseOptions<TSlug, TSelect>;
|
|
30
87
|
export type Options<TSlug extends CollectionSlug, TSelect extends SelectFromCollectionSlug<TSlug>> = ByIDOptions<TSlug, TSelect> | ManyOptions<TSlug, TSelect>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/delete.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC7F,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,UAAU,EACV,6BAA6B,EAC7B,KAAK,EACN,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAO1F,MAAM,MAAM,WAAW,CAAC,KAAK,SAAS,cAAc,EAAE,OAAO,SAAS,UAAU,IAAI;IAClF,UAAU,EAAE,KAAK,CAAA;IACjB
|
|
1
|
+
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/delete.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC7F,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,UAAU,EACV,6BAA6B,EAC7B,KAAK,EACN,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAO1F,MAAM,MAAM,WAAW,CAAC,KAAK,SAAS,cAAc,EAAE,OAAO,SAAS,UAAU,IAAI;IAClF;;OAEG;IACH,UAAU,EAAE,KAAK,CAAA;IACjB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IACpC;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;OAEG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;IAC7B;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B;;OAEG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,WAAW,CACrB,KAAK,SAAS,cAAc,EAC5B,OAAO,SAAS,wBAAwB,CAAC,KAAK,CAAC,IAC7C;IACF;;OAEG;IACH,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,GAAG,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;AAE/B,MAAM,MAAM,WAAW,CACrB,KAAK,SAAS,cAAc,EAC5B,OAAO,SAAS,wBAAwB,CAAC,KAAK,CAAC,IAC7C;IACF;;OAEG;IACH,EAAE,CAAC,EAAE,KAAK,CAAA;IACV;;OAEG;IACH,KAAK,EAAE,KAAK,CAAA;CACb,GAAG,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;AAE/B,MAAM,MAAM,OAAO,CACjB,KAAK,SAAS,cAAc,EAC5B,OAAO,SAAS,wBAAwB,CAAC,KAAK,CAAC,IAC7C,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;AAE7D,iBAAe,WAAW,CACxB,KAAK,SAAS,cAAc,EAC5B,OAAO,SAAS,wBAAwB,CAAC,KAAK,CAAC,EAE/C,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,GACnC,OAAO,CAAC,6BAA6B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAA;AACzD,iBAAe,WAAW,CACxB,KAAK,SAAS,cAAc,EAC5B,OAAO,SAAS,wBAAwB,CAAC,KAAK,CAAC,EAE/C,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,GACnC,OAAO,CAAC,mBAAmB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAA;AAC/C,iBAAe,WAAW,CACxB,KAAK,SAAS,cAAc,EAC5B,OAAO,SAAS,wBAAwB,CAAC,KAAK,CAAC,EAE/C,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,mBAAmB,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,6BAA6B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAA;AAiD/F,eAAe,WAAW,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/collections/operations/local/delete.ts"],"sourcesContent":["// @ts-strict-ignore\nimport type { CollectionSlug, Payload, RequestContext, TypedLocale } from '../../../index.js'\nimport type {\n Document,\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformCollectionWithSelect,\n Where,\n} from '../../../types/index.js'\nimport type { BulkOperationResult, SelectFromCollectionSlug } from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { deleteOperation } from '../delete.js'\nimport { deleteByIDOperation } from '../deleteByID.js'\n\nexport type BaseOptions<TSlug extends CollectionSlug, TSelect extends SelectType> = {\n collection: TSlug\n /**\n * context, which will then be passed to req.context
|
|
1
|
+
{"version":3,"sources":["../../../../src/collections/operations/local/delete.ts"],"sourcesContent":["// @ts-strict-ignore\nimport type { CollectionSlug, Payload, RequestContext, TypedLocale } from '../../../index.js'\nimport type {\n Document,\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformCollectionWithSelect,\n Where,\n} from '../../../types/index.js'\nimport type { BulkOperationResult, SelectFromCollectionSlug } from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { deleteOperation } from '../delete.js'\nimport { deleteByIDOperation } from '../deleteByID.js'\n\nexport type BaseOptions<TSlug extends CollectionSlug, TSelect extends SelectType> = {\n /**\n * the Collection slug to operate against.\n */\n collection: TSlug\n /**\n * [Context](https://payloadcms.com/docs/hooks/context), which will then be passed to `context` and `req.context`,\n * which can be read by hooks. Useful if you want to pass additional information to the hooks which\n * shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook\n * to determine if it should run or not.\n */\n context?: RequestContext\n /**\n * [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.\n */\n depth?: number\n /**\n * When set to `true`, a [database transactions](https://payloadcms.com/docs/database/transactions) will not be initialized.\n * @default false\n */\n disableTransaction?: boolean\n /**\n * Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.\n */\n fallbackLocale?: false | TypedLocale\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: TypedLocale\n /**\n * Skip access control.\n * Set to `false` if you want to respect Access Control for the operation, for example when fetching data for the fron-end.\n * @default true\n */\n overrideAccess?: boolean\n /**\n * By default, document locks are ignored (`true`). Set to `false` to enforce locks and prevent operations when a document is locked by another user. [More details](https://payloadcms.com/docs/admin/locked-documents).\n * @default true\n */\n overrideLock?: boolean\n /**\n * Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.\n */\n populate?: PopulateType\n /**\n * The `PayloadRequest` object. You can pass it to thread the current [transaction](https://payloadcms.com/docs/database/transactions), user and locale to the operation.\n * Recommended to pass when using the Local API from hooks, as usually you want to execute the operation within the current transaction.\n */\n req?: Partial<PayloadRequest>\n /**\n * Specify [select](https://payloadcms.com/docs/queries/select) to control which fields to include to the result.\n */\n select?: TSelect\n /**\n * Opt-in to receiving hidden fields. By default, they are hidden from returned documents in accordance to your config.\n * @default false\n */\n showHiddenFields?: boolean\n /**\n * If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.\n */\n user?: Document\n}\n\nexport type ByIDOptions<\n TSlug extends CollectionSlug,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n> = {\n /**\n * The ID of the document to delete.\n */\n id: number | string\n /**\n * A filter [query](https://payloadcms.com/docs/queries/overview)\n */\n where?: never\n} & BaseOptions<TSlug, TSelect>\n\nexport type ManyOptions<\n TSlug extends CollectionSlug,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n> = {\n /**\n * The ID of the document to delete.\n */\n id?: never\n /**\n * A filter [query](https://payloadcms.com/docs/queries/overview)\n */\n where: Where\n} & BaseOptions<TSlug, TSelect>\n\nexport type Options<\n TSlug extends CollectionSlug,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n> = ByIDOptions<TSlug, TSelect> | ManyOptions<TSlug, TSelect>\n\nasync function deleteLocal<\n TSlug extends CollectionSlug,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n>(\n payload: Payload,\n options: ByIDOptions<TSlug, TSelect>,\n): Promise<TransformCollectionWithSelect<TSlug, TSelect>>\nasync function deleteLocal<\n TSlug extends CollectionSlug,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n>(\n payload: Payload,\n options: ManyOptions<TSlug, TSelect>,\n): Promise<BulkOperationResult<TSlug, TSelect>>\nasync function deleteLocal<\n TSlug extends CollectionSlug,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n>(\n payload: Payload,\n options: Options<TSlug, TSelect>,\n): Promise<BulkOperationResult<TSlug, TSelect> | TransformCollectionWithSelect<TSlug, TSelect>>\nasync function deleteLocal<\n TSlug extends CollectionSlug,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n>(\n payload: Payload,\n options: Options<TSlug, TSelect>,\n): Promise<BulkOperationResult<TSlug, TSelect> | TransformCollectionWithSelect<TSlug, TSelect>> {\n const {\n id,\n collection: collectionSlug,\n depth,\n disableTransaction,\n overrideAccess = true,\n overrideLock,\n populate,\n select,\n showHiddenFields,\n where,\n } = options\n\n const collection = payload.collections[collectionSlug]\n\n if (!collection) {\n throw new APIError(\n `The collection with slug ${String(collectionSlug)} can't be found. Delete Operation.`,\n )\n }\n\n const args = {\n id,\n collection,\n depth,\n disableTransaction,\n overrideAccess,\n overrideLock,\n populate,\n req: await createLocalReq(options, payload),\n select,\n showHiddenFields,\n where,\n }\n\n if (options.id) {\n return deleteByIDOperation<TSlug, TSelect>(args)\n }\n return deleteOperation<TSlug, TSelect>(args)\n}\n\nexport default deleteLocal\n"],"names":["APIError","createLocalReq","deleteOperation","deleteByIDOperation","deleteLocal","payload","options","id","collection","collectionSlug","depth","disableTransaction","overrideAccess","overrideLock","populate","select","showHiddenFields","where","collections","String","args","req"],"mappings":"AAAA,oBAAoB;AAYpB,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,eAAe,QAAQ,eAAc;AAC9C,SAASC,mBAAmB,QAAQ,mBAAkB;AAwHtD,eAAeC,YAIbC,OAAgB,EAChBC,OAAgC;IAEhC,MAAM,EACJC,EAAE,EACFC,YAAYC,cAAc,EAC1BC,KAAK,EACLC,kBAAkB,EAClBC,iBAAiB,IAAI,EACrBC,YAAY,EACZC,QAAQ,EACRC,MAAM,EACNC,gBAAgB,EAChBC,KAAK,EACN,GAAGX;IAEJ,MAAME,aAAaH,QAAQa,WAAW,CAACT,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIR,SACR,CAAC,yBAAyB,EAAEmB,OAAOV,gBAAgB,kCAAkC,CAAC;IAE1F;IAEA,MAAMW,OAAO;QACXb;QACAC;QACAE;QACAC;QACAC;QACAC;QACAC;QACAO,KAAK,MAAMpB,eAAeK,SAASD;QACnCU;QACAC;QACAC;IACF;IAEA,IAAIX,QAAQC,EAAE,EAAE;QACd,OAAOJ,oBAAoCiB;IAC7C;IACA,OAAOlB,gBAAgCkB;AACzC;AAEA,eAAehB,YAAW"}
|
|
@@ -4,23 +4,73 @@ import type { Payload, RequestContext } from '../../../index.js';
|
|
|
4
4
|
import type { Document, PayloadRequest, PopulateType, SelectType, TransformCollectionWithSelect } from '../../../types/index.js';
|
|
5
5
|
import type { RequiredDataFromCollectionSlug, SelectFromCollectionSlug } from '../../config/types.js';
|
|
6
6
|
export type Options<TSlug extends CollectionSlug, TSelect extends SelectType> = {
|
|
7
|
+
/**
|
|
8
|
+
* the Collection slug to operate against.
|
|
9
|
+
*/
|
|
7
10
|
collection: TSlug;
|
|
8
11
|
/**
|
|
9
|
-
* context, which will then be passed to req.context
|
|
12
|
+
* [Context](https://payloadcms.com/docs/hooks/context), which will then be passed to `context` and `req.context`,
|
|
13
|
+
* which can be read by hooks. Useful if you want to pass additional information to the hooks which
|
|
14
|
+
* shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook
|
|
15
|
+
* to determine if it should run or not.
|
|
10
16
|
*/
|
|
11
17
|
context?: RequestContext;
|
|
18
|
+
/**
|
|
19
|
+
* Override the data for the document to duplicate.
|
|
20
|
+
*/
|
|
12
21
|
data?: DeepPartial<RequiredDataFromCollectionSlug<TSlug>>;
|
|
22
|
+
/**
|
|
23
|
+
* [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.
|
|
24
|
+
*/
|
|
13
25
|
depth?: number;
|
|
26
|
+
/**
|
|
27
|
+
* When set to `true`, a [database transactions](https://payloadcms.com/docs/database/transactions) will not be initialized.
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
14
30
|
disableTransaction?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Create a **draft** document. [More](https://payloadcms.com/docs/versions/drafts#draft-api)
|
|
33
|
+
*/
|
|
15
34
|
draft?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.
|
|
37
|
+
*/
|
|
16
38
|
fallbackLocale?: false | TypedLocale;
|
|
39
|
+
/**
|
|
40
|
+
* The ID of the document to duplicate from.
|
|
41
|
+
*/
|
|
17
42
|
id: number | string;
|
|
43
|
+
/**
|
|
44
|
+
* Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.
|
|
45
|
+
*/
|
|
18
46
|
locale?: TypedLocale;
|
|
47
|
+
/**
|
|
48
|
+
* Skip access control.
|
|
49
|
+
* Set to `false` if you want to respect Access Control for the operation, for example when fetching data for the fron-end.
|
|
50
|
+
* @default true
|
|
51
|
+
*/
|
|
19
52
|
overrideAccess?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.
|
|
55
|
+
*/
|
|
20
56
|
populate?: PopulateType;
|
|
57
|
+
/**
|
|
58
|
+
* The `PayloadRequest` object. You can pass it to thread the current [transaction](https://payloadcms.com/docs/database/transactions), user and locale to the operation.
|
|
59
|
+
* Recommended to pass when using the Local API from hooks, as usually you want to execute the operation within the current transaction.
|
|
60
|
+
*/
|
|
21
61
|
req?: Partial<PayloadRequest>;
|
|
62
|
+
/**
|
|
63
|
+
* Specify [select](https://payloadcms.com/docs/queries/select) to control which fields to include to the result.
|
|
64
|
+
*/
|
|
22
65
|
select?: TSelect;
|
|
66
|
+
/**
|
|
67
|
+
* Opt-in to receiving hidden fields. By default, they are hidden from returned documents in accordance to your config.
|
|
68
|
+
* @default false
|
|
69
|
+
*/
|
|
23
70
|
showHiddenFields?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.
|
|
73
|
+
*/
|
|
24
74
|
user?: Document;
|
|
25
75
|
};
|
|
26
76
|
export declare function duplicate<TSlug extends CollectionSlug, TSelect extends SelectFromCollectionSlug<TSlug>>(payload: Payload, options: Options<TSlug, TSelect>): Promise<TransformCollectionWithSelect<TSlug, TSelect>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"duplicate.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/duplicate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAEhD,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACrE,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,UAAU,EACV,6BAA6B,EAC9B,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EACV,8BAA8B,EAC9B,wBAAwB,EACzB,MAAM,uBAAuB,CAAA;AAM9B,MAAM,MAAM,OAAO,CAAC,KAAK,SAAS,cAAc,EAAE,OAAO,SAAS,UAAU,IAAI;IAC9E,UAAU,EAAE,KAAK,CAAA;IACjB
|
|
1
|
+
{"version":3,"file":"duplicate.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/duplicate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAEhD,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACrE,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,UAAU,EACV,6BAA6B,EAC9B,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EACV,8BAA8B,EAC9B,wBAAwB,EACzB,MAAM,uBAAuB,CAAA;AAM9B,MAAM,MAAM,OAAO,CAAC,KAAK,SAAS,cAAc,EAAE,OAAO,SAAS,UAAU,IAAI;IAC9E;;OAEG;IACH,UAAU,EAAE,KAAK,CAAA;IACjB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB;;OAEG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC,8BAA8B,CAAC,KAAK,CAAC,CAAC,CAAA;IACzD;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IACpC;;OAEG;IACH,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;OAEG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;IAC7B;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B;;OAEG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAA;CAChB,CAAA;AAED,wBAAsB,SAAS,CAC7B,KAAK,SAAS,cAAc,EAC5B,OAAO,SAAS,wBAAwB,CAAC,KAAK,CAAC,EAE/C,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,6BAA6B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CA2CxD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/collections/operations/local/duplicate.ts"],"sourcesContent":["// @ts-strict-ignore\nimport type { DeepPartial } from 'ts-essentials'\n\nimport type { CollectionSlug, TypedLocale } from '../../..//index.js'\nimport type { Payload, RequestContext } from '../../../index.js'\nimport type {\n Document,\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformCollectionWithSelect,\n} from '../../../types/index.js'\nimport type {\n RequiredDataFromCollectionSlug,\n SelectFromCollectionSlug,\n} from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { duplicateOperation } from '../duplicate.js'\n\nexport type Options<TSlug extends CollectionSlug, TSelect extends SelectType> = {\n collection: TSlug\n /**\n * context, which will then be passed to req.context
|
|
1
|
+
{"version":3,"sources":["../../../../src/collections/operations/local/duplicate.ts"],"sourcesContent":["// @ts-strict-ignore\nimport type { DeepPartial } from 'ts-essentials'\n\nimport type { CollectionSlug, TypedLocale } from '../../..//index.js'\nimport type { Payload, RequestContext } from '../../../index.js'\nimport type {\n Document,\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformCollectionWithSelect,\n} from '../../../types/index.js'\nimport type {\n RequiredDataFromCollectionSlug,\n SelectFromCollectionSlug,\n} from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { duplicateOperation } from '../duplicate.js'\n\nexport type Options<TSlug extends CollectionSlug, TSelect extends SelectType> = {\n /**\n * the Collection slug to operate against.\n */\n collection: TSlug\n /**\n * [Context](https://payloadcms.com/docs/hooks/context), which will then be passed to `context` and `req.context`,\n * which can be read by hooks. Useful if you want to pass additional information to the hooks which\n * shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook\n * to determine if it should run or not.\n */\n context?: RequestContext\n /**\n * Override the data for the document to duplicate.\n */\n data?: DeepPartial<RequiredDataFromCollectionSlug<TSlug>>\n /**\n * [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.\n */\n depth?: number\n /**\n * When set to `true`, a [database transactions](https://payloadcms.com/docs/database/transactions) will not be initialized.\n * @default false\n */\n disableTransaction?: boolean\n /**\n * Create a **draft** document. [More](https://payloadcms.com/docs/versions/drafts#draft-api)\n */\n draft?: boolean\n /**\n * Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.\n */\n fallbackLocale?: false | TypedLocale\n /**\n * The ID of the document to duplicate from.\n */\n id: number | string\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: TypedLocale\n /**\n * Skip access control.\n * Set to `false` if you want to respect Access Control for the operation, for example when fetching data for the fron-end.\n * @default true\n */\n overrideAccess?: boolean\n /**\n * Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.\n */\n populate?: PopulateType\n /**\n * The `PayloadRequest` object. You can pass it to thread the current [transaction](https://payloadcms.com/docs/database/transactions), user and locale to the operation.\n * Recommended to pass when using the Local API from hooks, as usually you want to execute the operation within the current transaction.\n */\n req?: Partial<PayloadRequest>\n /**\n * Specify [select](https://payloadcms.com/docs/queries/select) to control which fields to include to the result.\n */\n select?: TSelect\n /**\n * Opt-in to receiving hidden fields. By default, they are hidden from returned documents in accordance to your config.\n * @default false\n */\n showHiddenFields?: boolean\n /**\n * If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.\n */\n user?: Document\n}\n\nexport async function duplicate<\n TSlug extends CollectionSlug,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n>(\n payload: Payload,\n options: Options<TSlug, TSelect>,\n): Promise<TransformCollectionWithSelect<TSlug, TSelect>> {\n const {\n id,\n collection: collectionSlug,\n data,\n depth,\n disableTransaction,\n draft,\n overrideAccess = true,\n populate,\n select,\n showHiddenFields,\n } = options\n const collection = payload.collections[collectionSlug]\n\n if (!collection) {\n throw new APIError(\n `The collection with slug ${String(collectionSlug)} can't be found. Duplicate Operation.`,\n )\n }\n\n if (collection.config.disableDuplicate === true) {\n throw new APIError(\n `The collection with slug ${String(collectionSlug)} cannot be duplicated.`,\n 400,\n )\n }\n\n const req = await createLocalReq(options, payload)\n\n return duplicateOperation<TSlug, TSelect>({\n id,\n collection,\n data,\n depth,\n disableTransaction,\n draft,\n overrideAccess,\n populate,\n req,\n select,\n showHiddenFields,\n })\n}\n"],"names":["APIError","createLocalReq","duplicateOperation","duplicate","payload","options","id","collection","collectionSlug","data","depth","disableTransaction","draft","overrideAccess","populate","select","showHiddenFields","collections","String","config","disableDuplicate","req"],"mappings":"AAAA,oBAAoB;AAiBpB,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,kBAAkB,QAAQ,kBAAiB;AAyEpD,OAAO,eAAeC,UAIpBC,OAAgB,EAChBC,OAAgC;IAEhC,MAAM,EACJC,EAAE,EACFC,YAAYC,cAAc,EAC1BC,IAAI,EACJC,KAAK,EACLC,kBAAkB,EAClBC,KAAK,EACLC,iBAAiB,IAAI,EACrBC,QAAQ,EACRC,MAAM,EACNC,gBAAgB,EACjB,GAAGX;IACJ,MAAME,aAAaH,QAAQa,WAAW,CAACT,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIP,SACR,CAAC,yBAAyB,EAAEkB,OAAOV,gBAAgB,qCAAqC,CAAC;IAE7F;IAEA,IAAID,WAAWY,MAAM,CAACC,gBAAgB,KAAK,MAAM;QAC/C,MAAM,IAAIpB,SACR,CAAC,yBAAyB,EAAEkB,OAAOV,gBAAgB,sBAAsB,CAAC,EAC1E;IAEJ;IAEA,MAAMa,MAAM,MAAMpB,eAAeI,SAASD;IAE1C,OAAOF,mBAAmC;QACxCI;QACAC;QACAE;QACAC;QACAC;QACAC;QACAC;QACAC;QACAO;QACAN;QACAC;IACF;AACF"}
|