payload 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/admin/RichText.d.ts +4 -1
- package/dist/admin/RichText.d.ts.map +1 -1
- package/dist/admin/RichText.js.map +1 -1
- package/dist/collections/config/types.d.ts +2 -2
- package/dist/collections/config/types.d.ts.map +1 -1
- package/dist/collections/config/types.js.map +1 -1
- package/dist/collections/operations/create.d.ts +2 -1
- package/dist/collections/operations/create.d.ts.map +1 -1
- package/dist/collections/operations/create.js +2 -1
- package/dist/collections/operations/create.js.map +1 -1
- package/dist/collections/operations/delete.d.ts +2 -1
- package/dist/collections/operations/delete.d.ts.map +1 -1
- package/dist/collections/operations/delete.js +2 -1
- package/dist/collections/operations/delete.js.map +1 -1
- package/dist/collections/operations/deleteByID.d.ts +2 -1
- package/dist/collections/operations/deleteByID.d.ts.map +1 -1
- package/dist/collections/operations/deleteByID.js +2 -1
- package/dist/collections/operations/deleteByID.js.map +1 -1
- package/dist/collections/operations/duplicate.d.ts +2 -1
- package/dist/collections/operations/duplicate.d.ts.map +1 -1
- package/dist/collections/operations/duplicate.js +2 -1
- package/dist/collections/operations/duplicate.js.map +1 -1
- package/dist/collections/operations/find.d.ts +2 -1
- package/dist/collections/operations/find.d.ts.map +1 -1
- package/dist/collections/operations/find.js +11 -3
- package/dist/collections/operations/find.js.map +1 -1
- package/dist/collections/operations/findByID.d.ts +2 -1
- package/dist/collections/operations/findByID.d.ts.map +1 -1
- package/dist/collections/operations/findByID.js +23 -7
- package/dist/collections/operations/findByID.js.map +1 -1
- package/dist/collections/operations/findVersionByID.d.ts +2 -1
- package/dist/collections/operations/findVersionByID.d.ts.map +1 -1
- package/dist/collections/operations/findVersionByID.js +2 -1
- package/dist/collections/operations/findVersionByID.js.map +1 -1
- package/dist/collections/operations/findVersions.d.ts +2 -1
- package/dist/collections/operations/findVersions.d.ts.map +1 -1
- package/dist/collections/operations/findVersions.js +2 -1
- package/dist/collections/operations/findVersions.js.map +1 -1
- package/dist/collections/operations/local/count.d.ts +2 -2
- 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/create.d.ts +3 -2
- package/dist/collections/operations/local/create.d.ts.map +1 -1
- package/dist/collections/operations/local/create.js +2 -1
- package/dist/collections/operations/local/create.js.map +1 -1
- package/dist/collections/operations/local/delete.d.ts +3 -2
- package/dist/collections/operations/local/delete.d.ts.map +1 -1
- package/dist/collections/operations/local/delete.js +2 -1
- package/dist/collections/operations/local/delete.js.map +1 -1
- package/dist/collections/operations/local/duplicate.d.ts +3 -2
- package/dist/collections/operations/local/duplicate.d.ts.map +1 -1
- package/dist/collections/operations/local/duplicate.js +2 -1
- package/dist/collections/operations/local/duplicate.js.map +1 -1
- package/dist/collections/operations/local/find.d.ts +4 -3
- 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 +4 -3
- package/dist/collections/operations/local/findByID.d.ts.map +1 -1
- package/dist/collections/operations/local/findByID.js +2 -1
- package/dist/collections/operations/local/findByID.js.map +1 -1
- package/dist/collections/operations/local/findVersionByID.d.ts +3 -2
- package/dist/collections/operations/local/findVersionByID.d.ts.map +1 -1
- package/dist/collections/operations/local/findVersionByID.js +2 -1
- package/dist/collections/operations/local/findVersionByID.js.map +1 -1
- package/dist/collections/operations/local/findVersions.d.ts +3 -2
- package/dist/collections/operations/local/findVersions.d.ts.map +1 -1
- package/dist/collections/operations/local/findVersions.js +2 -1
- package/dist/collections/operations/local/findVersions.js.map +1 -1
- package/dist/collections/operations/local/restoreVersion.d.ts +3 -2
- package/dist/collections/operations/local/restoreVersion.d.ts.map +1 -1
- package/dist/collections/operations/local/restoreVersion.js +2 -1
- package/dist/collections/operations/local/restoreVersion.js.map +1 -1
- package/dist/collections/operations/local/update.d.ts +3 -2
- package/dist/collections/operations/local/update.d.ts.map +1 -1
- package/dist/collections/operations/local/update.js +2 -1
- package/dist/collections/operations/local/update.js.map +1 -1
- package/dist/collections/operations/restoreVersion.d.ts +2 -1
- package/dist/collections/operations/restoreVersion.d.ts.map +1 -1
- package/dist/collections/operations/restoreVersion.js +2 -1
- package/dist/collections/operations/restoreVersion.js.map +1 -1
- package/dist/collections/operations/update.d.ts +2 -1
- package/dist/collections/operations/update.d.ts.map +1 -1
- package/dist/collections/operations/update.js +2 -1
- package/dist/collections/operations/update.js.map +1 -1
- package/dist/collections/operations/updateByID.d.ts +2 -1
- package/dist/collections/operations/updateByID.d.ts.map +1 -1
- package/dist/collections/operations/updateByID.js +8 -6
- package/dist/collections/operations/updateByID.js.map +1 -1
- package/dist/database/sanitizeJoinQuery.d.ts +22 -0
- package/dist/database/sanitizeJoinQuery.d.ts.map +1 -0
- package/dist/database/sanitizeJoinQuery.js +61 -0
- package/dist/database/sanitizeJoinQuery.js.map +1 -0
- package/dist/fields/config/types.d.ts +6 -3
- package/dist/fields/config/types.d.ts.map +1 -1
- package/dist/fields/config/types.js.map +1 -1
- package/dist/fields/hooks/afterChange/index.d.ts +2 -1
- package/dist/fields/hooks/afterChange/index.d.ts.map +1 -1
- package/dist/fields/hooks/afterChange/index.js.map +1 -1
- package/dist/fields/hooks/afterChange/promise.d.ts +2 -1
- package/dist/fields/hooks/afterChange/promise.d.ts.map +1 -1
- package/dist/fields/hooks/afterChange/promise.js.map +1 -1
- package/dist/fields/hooks/afterChange/traverseFields.d.ts +2 -1
- package/dist/fields/hooks/afterChange/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/afterChange/traverseFields.js.map +1 -1
- package/dist/fields/hooks/afterRead/index.d.ts +3 -1
- package/dist/fields/hooks/afterRead/index.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/index.js +2 -1
- package/dist/fields/hooks/afterRead/index.js.map +1 -1
- package/dist/fields/hooks/afterRead/promise.d.ts +4 -2
- package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/promise.js +12 -1
- package/dist/fields/hooks/afterRead/promise.js.map +1 -1
- package/dist/fields/hooks/afterRead/relationshipPopulationPromise.d.ts +3 -2
- package/dist/fields/hooks/afterRead/relationshipPopulationPromise.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/relationshipPopulationPromise.js +7 -3
- package/dist/fields/hooks/afterRead/relationshipPopulationPromise.js.map +1 -1
- package/dist/fields/hooks/afterRead/traverseFields.d.ts +4 -2
- package/dist/fields/hooks/afterRead/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/traverseFields.js +2 -1
- package/dist/fields/hooks/afterRead/traverseFields.js.map +1 -1
- package/dist/fields/hooks/beforeChange/index.d.ts +2 -1
- package/dist/fields/hooks/beforeChange/index.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/index.js.map +1 -1
- package/dist/fields/hooks/beforeChange/promise.d.ts +2 -1
- package/dist/fields/hooks/beforeChange/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/promise.js.map +1 -1
- package/dist/fields/hooks/beforeChange/traverseFields.d.ts +2 -1
- package/dist/fields/hooks/beforeChange/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/traverseFields.js.map +1 -1
- package/dist/fields/hooks/beforeDuplicate/index.d.ts +2 -1
- package/dist/fields/hooks/beforeDuplicate/index.d.ts.map +1 -1
- package/dist/fields/hooks/beforeDuplicate/index.js.map +1 -1
- package/dist/fields/hooks/beforeDuplicate/promise.d.ts +2 -1
- package/dist/fields/hooks/beforeDuplicate/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeDuplicate/promise.js.map +1 -1
- package/dist/fields/hooks/beforeDuplicate/traverseFields.d.ts +2 -1
- package/dist/fields/hooks/beforeDuplicate/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/beforeDuplicate/traverseFields.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/index.d.ts +2 -1
- package/dist/fields/hooks/beforeValidate/index.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/index.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/promise.d.ts +2 -1
- package/dist/fields/hooks/beforeValidate/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/promise.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/traverseFields.d.ts +2 -1
- package/dist/fields/hooks/beforeValidate/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/traverseFields.js.map +1 -1
- package/dist/globals/config/types.d.ts +2 -2
- package/dist/globals/config/types.d.ts.map +1 -1
- package/dist/globals/config/types.js.map +1 -1
- package/dist/globals/operations/findOne.d.ts +2 -1
- package/dist/globals/operations/findOne.d.ts.map +1 -1
- package/dist/globals/operations/findOne.js +2 -1
- package/dist/globals/operations/findOne.js.map +1 -1
- package/dist/globals/operations/findVersionByID.d.ts +2 -1
- package/dist/globals/operations/findVersionByID.d.ts.map +1 -1
- package/dist/globals/operations/findVersionByID.js +2 -1
- package/dist/globals/operations/findVersionByID.js.map +1 -1
- package/dist/globals/operations/findVersions.d.ts +2 -1
- package/dist/globals/operations/findVersions.d.ts.map +1 -1
- package/dist/globals/operations/findVersions.js +2 -1
- package/dist/globals/operations/findVersions.js.map +1 -1
- package/dist/globals/operations/local/findOne.d.ts +2 -1
- package/dist/globals/operations/local/findOne.d.ts.map +1 -1
- package/dist/globals/operations/local/findOne.js +2 -1
- package/dist/globals/operations/local/findOne.js.map +1 -1
- package/dist/globals/operations/local/findVersionByID.d.ts +2 -1
- package/dist/globals/operations/local/findVersionByID.d.ts.map +1 -1
- package/dist/globals/operations/local/findVersionByID.js +2 -1
- package/dist/globals/operations/local/findVersionByID.js.map +1 -1
- package/dist/globals/operations/local/findVersions.d.ts +2 -1
- package/dist/globals/operations/local/findVersions.d.ts.map +1 -1
- package/dist/globals/operations/local/findVersions.js +2 -1
- package/dist/globals/operations/local/findVersions.js.map +1 -1
- package/dist/globals/operations/local/restoreVersion.d.ts +2 -1
- package/dist/globals/operations/local/restoreVersion.d.ts.map +1 -1
- package/dist/globals/operations/local/restoreVersion.js +2 -1
- package/dist/globals/operations/local/restoreVersion.js.map +1 -1
- package/dist/globals/operations/local/update.d.ts +2 -1
- package/dist/globals/operations/local/update.d.ts.map +1 -1
- package/dist/globals/operations/local/update.js +2 -1
- package/dist/globals/operations/local/update.js.map +1 -1
- package/dist/globals/operations/restoreVersion.d.ts +2 -1
- package/dist/globals/operations/restoreVersion.d.ts.map +1 -1
- package/dist/globals/operations/restoreVersion.js +2 -1
- package/dist/globals/operations/restoreVersion.js.map +1 -1
- package/dist/globals/operations/update.d.ts +2 -1
- package/dist/globals/operations/update.d.ts.map +1 -1
- package/dist/globals/operations/update.js +2 -1
- package/dist/globals/operations/update.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/queues/config/jobsCollection.d.ts.map +1 -1
- package/dist/queues/config/jobsCollection.js +15 -13
- package/dist/queues/config/jobsCollection.js.map +1 -1
- package/dist/queues/config/types/index.d.ts +1 -1
- package/dist/queues/config/types/index.d.ts.map +1 -1
- package/dist/queues/config/types/index.js.map +1 -1
- package/dist/queues/operations/runJobs/index.js +1 -1
- package/dist/queues/operations/runJobs/index.js.map +1 -1
- package/dist/types/index.d.ts +6 -8
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
- package/dist/utilities/configToJSONSchema.js +35 -0
- package/dist/utilities/configToJSONSchema.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CollectionSlug, JoinQuery, Payload, SelectType, TypedLocale } from '../../../index.js';
|
|
2
|
-
import type { ApplyDisableErrors, Document, PayloadRequest,
|
|
1
|
+
import type { CollectionSlug, JoinQuery, Payload, RequestContext, SelectType, TypedLocale } from '../../../index.js';
|
|
2
|
+
import type { ApplyDisableErrors, Document, PayloadRequest, PopulateType, TransformCollectionWithSelect } from '../../../types/index.js';
|
|
3
3
|
import type { SelectFromCollectionSlug } from '../../config/types.js';
|
|
4
4
|
export type Options<TSlug extends CollectionSlug, TDisableErrors extends boolean, TSelect extends SelectType> = {
|
|
5
5
|
collection: TSlug;
|
|
@@ -14,9 +14,10 @@ export type Options<TSlug extends CollectionSlug, TDisableErrors extends boolean
|
|
|
14
14
|
fallbackLocale?: TypedLocale;
|
|
15
15
|
id: number | string;
|
|
16
16
|
includeLockStatus?: boolean;
|
|
17
|
-
joins?: JoinQuery
|
|
17
|
+
joins?: JoinQuery<TSlug>;
|
|
18
18
|
locale?: 'all' | TypedLocale;
|
|
19
19
|
overrideAccess?: boolean;
|
|
20
|
+
populate?: PopulateType;
|
|
20
21
|
req?: PayloadRequest;
|
|
21
22
|
select?: TSelect;
|
|
22
23
|
showHiddenFields?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findByID.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/findByID.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"findByID.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/findByID.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EACd,SAAS,EACT,OAAO,EACP,cAAc,EACd,UAAU,EACV,WAAW,EACZ,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EACV,kBAAkB,EAClB,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,6BAA6B,EAC9B,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAMrE,MAAM,MAAM,OAAO,CACjB,KAAK,SAAS,cAAc,EAC5B,cAAc,SAAS,OAAO,EAC9B,OAAO,SAAS,UAAU,IACxB;IACF,UAAU,EAAE,KAAK,CAAA;IACjB;;OAEG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,aAAa,CAAC,EAAE,cAAc,CAAA;IAC9B,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,cAAc,CAAC,EAAE,WAAW,CAAA;IAC5B,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,KAAK,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,CAAA;IACxB,MAAM,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IAC5B,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,GAAG,CAAC,EAAE,cAAc,CAAA;IACpB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,CAAC,EAAE,QAAQ,CAAA;CAChB,CAAA;AAED,wBAA8B,aAAa,CACzC,KAAK,SAAS,cAAc,EAC5B,cAAc,SAAS,OAAO,EAC9B,OAAO,SAAS,wBAAwB,CAAC,KAAK,CAAC,EAE/C,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,CAAC,GAC/C,OAAO,CAAC,kBAAkB,CAAC,6BAA6B,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC,CAuC5F"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { createLocalReq } from '../../../utilities/createLocalReq.js';
|
|
3
3
|
import { findByIDOperation } from '../findByID.js';
|
|
4
4
|
export default async function findByIDLocal(payload, options) {
|
|
5
|
-
const { id, collection: collectionSlug, currentDepth, depth, disableErrors = false, draft = false, includeLockStatus, joins, overrideAccess = true, select, showHiddenFields } = options;
|
|
5
|
+
const { id, collection: collectionSlug, currentDepth, depth, disableErrors = false, draft = false, includeLockStatus, joins, overrideAccess = true, populate, select, showHiddenFields } = options;
|
|
6
6
|
const collection = payload.collections[collectionSlug];
|
|
7
7
|
if (!collection) {
|
|
8
8
|
throw new APIError(`The collection with slug ${String(collectionSlug)} can't be found. Find By ID Operation.`);
|
|
@@ -17,6 +17,7 @@ export default async function findByIDLocal(payload, options) {
|
|
|
17
17
|
includeLockStatus,
|
|
18
18
|
joins,
|
|
19
19
|
overrideAccess,
|
|
20
|
+
populate,
|
|
20
21
|
req: await createLocalReq(options, payload),
|
|
21
22
|
select,
|
|
22
23
|
showHiddenFields
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/collections/operations/local/findByID.ts"],"sourcesContent":["/* eslint-disable no-restricted-exports */\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../../src/collections/operations/local/findByID.ts"],"sourcesContent":["/* eslint-disable no-restricted-exports */\nimport type {\n CollectionSlug,\n JoinQuery,\n Payload,\n RequestContext,\n SelectType,\n TypedLocale,\n} from '../../../index.js'\nimport type {\n ApplyDisableErrors,\n Document,\n PayloadRequest,\n PopulateType,\n TransformCollectionWithSelect,\n} from '../../../types/index.js'\nimport type { SelectFromCollectionSlug } from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { findByIDOperation } from '../findByID.js'\n\nexport type Options<\n TSlug extends CollectionSlug,\n TDisableErrors extends boolean,\n TSelect extends SelectType,\n> = {\n collection: TSlug\n /**\n * context, which will then be passed to req.context, which can be read by hooks\n */\n context?: RequestContext\n currentDepth?: number\n depth?: number\n disableErrors?: TDisableErrors\n draft?: boolean\n fallbackLocale?: TypedLocale\n id: number | string\n includeLockStatus?: boolean\n joins?: JoinQuery<TSlug>\n locale?: 'all' | TypedLocale\n overrideAccess?: boolean\n populate?: PopulateType\n req?: PayloadRequest\n select?: TSelect\n showHiddenFields?: boolean\n user?: Document\n}\n\nexport default async function findByIDLocal<\n TSlug extends CollectionSlug,\n TDisableErrors extends boolean,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n>(\n payload: Payload,\n options: Options<TSlug, TDisableErrors, TSelect>,\n): Promise<ApplyDisableErrors<TransformCollectionWithSelect<TSlug, TSelect>, TDisableErrors>> {\n const {\n id,\n collection: collectionSlug,\n currentDepth,\n depth,\n disableErrors = false,\n draft = false,\n includeLockStatus,\n joins,\n overrideAccess = true,\n populate,\n select,\n showHiddenFields,\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. Find By ID Operation.`,\n )\n }\n\n return findByIDOperation<TSlug, TDisableErrors, TSelect>({\n id,\n collection,\n currentDepth,\n depth,\n disableErrors,\n draft,\n includeLockStatus,\n joins,\n overrideAccess,\n populate,\n req: await createLocalReq(options, payload),\n select,\n showHiddenFields,\n })\n}\n"],"names":["APIError","createLocalReq","findByIDOperation","findByIDLocal","payload","options","id","collection","collectionSlug","currentDepth","depth","disableErrors","draft","includeLockStatus","joins","overrideAccess","populate","select","showHiddenFields","collections","String","req"],"mappings":"AAAA,wCAAwC,GAkBxC,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,iBAAiB,QAAQ,iBAAgB;AA6BlD,eAAe,eAAeC,cAK5BC,OAAgB,EAChBC,OAAgD;IAEhD,MAAM,EACJC,EAAE,EACFC,YAAYC,cAAc,EAC1BC,YAAY,EACZC,KAAK,EACLC,gBAAgB,KAAK,EACrBC,QAAQ,KAAK,EACbC,iBAAiB,EACjBC,KAAK,EACLC,iBAAiB,IAAI,EACrBC,QAAQ,EACRC,MAAM,EACNC,gBAAgB,EACjB,GAAGb;IAEJ,MAAME,aAAaH,QAAQe,WAAW,CAACX,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIP,SACR,CAAC,yBAAyB,EAAEoB,OAAOZ,gBAAgB,sCAAsC,CAAC;IAE9F;IAEA,OAAON,kBAAkD;QACvDI;QACAC;QACAE;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAK,KAAK,MAAMpB,eAAeI,SAASD;QACnCa;QACAC;IACF;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CollectionSlug, Payload, TypedLocale } from '../../../index.js';
|
|
2
|
-
import type { Document, PayloadRequest,
|
|
1
|
+
import type { CollectionSlug, Payload, RequestContext, TypedLocale } from '../../../index.js';
|
|
2
|
+
import type { Document, PayloadRequest, PopulateType, SelectType } from '../../../types/index.js';
|
|
3
3
|
import type { TypeWithVersion } from '../../../versions/types.js';
|
|
4
4
|
import type { DataFromCollectionSlug } from '../../config/types.js';
|
|
5
5
|
export type Options<TSlug extends CollectionSlug> = {
|
|
@@ -15,6 +15,7 @@ export type Options<TSlug extends CollectionSlug> = {
|
|
|
15
15
|
id: string;
|
|
16
16
|
locale?: 'all' | TypedLocale;
|
|
17
17
|
overrideAccess?: boolean;
|
|
18
|
+
populate?: PopulateType;
|
|
18
19
|
req?: PayloadRequest;
|
|
19
20
|
select?: SelectType;
|
|
20
21
|
showHiddenFields?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findVersionByID.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/findVersionByID.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"findVersionByID.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/findVersionByID.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC7F,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACjG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAMnE,MAAM,MAAM,OAAO,CAAC,KAAK,SAAS,cAAc,IAAI;IAClD,UAAU,EAAE,KAAK,CAAA;IACjB;;OAEG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,cAAc,CAAC,EAAE,WAAW,CAAA;IAC5B,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IAC5B,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,GAAG,CAAC,EAAE,cAAc,CAAA;IACpB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,CAAC,EAAE,QAAQ,CAAA;CAChB,CAAA;AAED,wBAA8B,oBAAoB,CAAC,KAAK,SAAS,cAAc,EAC7E,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,GACtB,OAAO,CAAC,eAAe,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC,CAiCzD"}
|
|
@@ -2,7 +2,7 @@ import { APIError } from '../../../errors/index.js';
|
|
|
2
2
|
import { createLocalReq } from '../../../utilities/createLocalReq.js';
|
|
3
3
|
import { findVersionByIDOperation } from '../findVersionByID.js';
|
|
4
4
|
export default async function findVersionByIDLocal(payload, options) {
|
|
5
|
-
const { id, collection: collectionSlug, depth, disableErrors = false, overrideAccess = true, select, showHiddenFields } = options;
|
|
5
|
+
const { id, collection: collectionSlug, depth, disableErrors = false, overrideAccess = true, populate, select, showHiddenFields } = options;
|
|
6
6
|
const collection = payload.collections[collectionSlug];
|
|
7
7
|
if (!collection) {
|
|
8
8
|
throw new APIError(`The collection with slug ${String(collectionSlug)} can't be found. Find Version By ID Operation.`);
|
|
@@ -13,6 +13,7 @@ export default async function findVersionByIDLocal(payload, options) {
|
|
|
13
13
|
depth,
|
|
14
14
|
disableErrors,
|
|
15
15
|
overrideAccess,
|
|
16
|
+
populate,
|
|
16
17
|
req: await createLocalReq(options, payload),
|
|
17
18
|
select,
|
|
18
19
|
showHiddenFields
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/collections/operations/local/findVersionByID.ts"],"sourcesContent":["import type { CollectionSlug, Payload, TypedLocale } from '../../../index.js'\nimport type { Document, PayloadRequest,
|
|
1
|
+
{"version":3,"sources":["../../../../src/collections/operations/local/findVersionByID.ts"],"sourcesContent":["import type { CollectionSlug, Payload, RequestContext, TypedLocale } from '../../../index.js'\nimport type { Document, PayloadRequest, PopulateType, SelectType } from '../../../types/index.js'\nimport type { TypeWithVersion } from '../../../versions/types.js'\nimport type { DataFromCollectionSlug } from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { findVersionByIDOperation } from '../findVersionByID.js'\n\nexport type Options<TSlug extends CollectionSlug> = {\n collection: TSlug\n /**\n * context, which will then be passed to req.context, which can be read by hooks\n */\n context?: RequestContext\n depth?: number\n disableErrors?: boolean\n draft?: boolean\n fallbackLocale?: TypedLocale\n id: string\n locale?: 'all' | TypedLocale\n overrideAccess?: boolean\n populate?: PopulateType\n req?: PayloadRequest\n select?: SelectType\n showHiddenFields?: boolean\n user?: Document\n}\n\nexport default async function findVersionByIDLocal<TSlug extends CollectionSlug>(\n payload: Payload,\n options: Options<TSlug>,\n): Promise<TypeWithVersion<DataFromCollectionSlug<TSlug>>> {\n const {\n id,\n collection: collectionSlug,\n depth,\n disableErrors = false,\n overrideAccess = true,\n populate,\n select,\n showHiddenFields,\n } = options\n\n const collection = payload.collections[collectionSlug]\n\n if (!collection) {\n throw new APIError(\n `The collection with slug ${String(\n collectionSlug,\n )} can't be found. Find Version By ID Operation.`,\n )\n }\n\n return findVersionByIDOperation({\n id,\n collection,\n depth,\n disableErrors,\n overrideAccess,\n populate,\n req: await createLocalReq(options, payload),\n select,\n showHiddenFields,\n })\n}\n"],"names":["APIError","createLocalReq","findVersionByIDOperation","findVersionByIDLocal","payload","options","id","collection","collectionSlug","depth","disableErrors","overrideAccess","populate","select","showHiddenFields","collections","String","req"],"mappings":"AAKA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,wBAAwB,QAAQ,wBAAuB;AAsBhE,eAAe,eAAeC,qBAC5BC,OAAgB,EAChBC,OAAuB;IAEvB,MAAM,EACJC,EAAE,EACFC,YAAYC,cAAc,EAC1BC,KAAK,EACLC,gBAAgB,KAAK,EACrBC,iBAAiB,IAAI,EACrBC,QAAQ,EACRC,MAAM,EACNC,gBAAgB,EACjB,GAAGT;IAEJ,MAAME,aAAaH,QAAQW,WAAW,CAACP,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIP,SACR,CAAC,yBAAyB,EAAEgB,OAC1BR,gBACA,8CAA8C,CAAC;IAErD;IAEA,OAAON,yBAAyB;QAC9BI;QACAC;QACAE;QACAC;QACAC;QACAC;QACAK,KAAK,MAAMhB,eAAeI,SAASD;QACnCS;QACAC;IACF;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PaginatedDocs } from '../../../database/types.js';
|
|
2
|
-
import type { CollectionSlug, Payload, TypedLocale } from '../../../index.js';
|
|
3
|
-
import type { Document, PayloadRequest,
|
|
2
|
+
import type { CollectionSlug, Payload, RequestContext, TypedLocale } from '../../../index.js';
|
|
3
|
+
import type { Document, PayloadRequest, PopulateType, SelectType, Sort, Where } from '../../../types/index.js';
|
|
4
4
|
import type { TypeWithVersion } from '../../../versions/types.js';
|
|
5
5
|
import type { DataFromCollectionSlug } from '../../config/types.js';
|
|
6
6
|
export type Options<TSlug extends CollectionSlug> = {
|
|
@@ -16,6 +16,7 @@ export type Options<TSlug extends CollectionSlug> = {
|
|
|
16
16
|
locale?: 'all' | TypedLocale;
|
|
17
17
|
overrideAccess?: boolean;
|
|
18
18
|
page?: number;
|
|
19
|
+
populate?: PopulateType;
|
|
19
20
|
req?: PayloadRequest;
|
|
20
21
|
select?: SelectType;
|
|
21
22
|
showHiddenFields?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findVersions.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/findVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"findVersions.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/findVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC/D,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,IAAI,EACJ,KAAK,EACN,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAMnE,MAAM,MAAM,OAAO,CAAC,KAAK,SAAS,cAAc,IAAI;IAClD,UAAU,EAAE,KAAK,CAAA;IACjB;;OAEG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,cAAc,CAAC,EAAE,WAAW,CAAA;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IAC5B,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,GAAG,CAAC,EAAE,cAAc,CAAA;IACpB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,IAAI,CAAC,EAAE,QAAQ,CAAA;IACf,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAA;AAED,wBAA8B,iBAAiB,CAAC,KAAK,SAAS,cAAc,EAC1E,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,GACtB,OAAO,CAAC,aAAa,CAAC,eAAe,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAmCxE"}
|
|
@@ -2,7 +2,7 @@ import { APIError } from '../../../errors/index.js';
|
|
|
2
2
|
import { createLocalReq } from '../../../utilities/createLocalReq.js';
|
|
3
3
|
import { findVersionsOperation } from '../findVersions.js';
|
|
4
4
|
export default async function findVersionsLocal(payload, options) {
|
|
5
|
-
const { collection: collectionSlug, depth, limit, overrideAccess = true, page, select, showHiddenFields, sort, where } = options;
|
|
5
|
+
const { collection: collectionSlug, depth, limit, overrideAccess = true, page, populate, select, showHiddenFields, sort, where } = options;
|
|
6
6
|
const collection = payload.collections[collectionSlug];
|
|
7
7
|
if (!collection) {
|
|
8
8
|
throw new APIError(`The collection with slug ${String(collectionSlug)} can't be found. Find Versions Operation.`);
|
|
@@ -13,6 +13,7 @@ export default async function findVersionsLocal(payload, options) {
|
|
|
13
13
|
limit,
|
|
14
14
|
overrideAccess,
|
|
15
15
|
page,
|
|
16
|
+
populate,
|
|
16
17
|
req: await createLocalReq(options, payload),
|
|
17
18
|
select,
|
|
18
19
|
showHiddenFields,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/collections/operations/local/findVersions.ts"],"sourcesContent":["import type { PaginatedDocs } from '../../../database/types.js'\nimport type { CollectionSlug, Payload, TypedLocale } from '../../../index.js'\nimport type {\n Document,\n PayloadRequest,\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/collections/operations/local/findVersions.ts"],"sourcesContent":["import type { PaginatedDocs } from '../../../database/types.js'\nimport type { CollectionSlug, Payload, RequestContext, TypedLocale } from '../../../index.js'\nimport type {\n Document,\n PayloadRequest,\n PopulateType,\n SelectType,\n Sort,\n Where,\n} from '../../../types/index.js'\nimport type { TypeWithVersion } from '../../../versions/types.js'\nimport type { DataFromCollectionSlug } from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { findVersionsOperation } from '../findVersions.js'\n\nexport type Options<TSlug extends CollectionSlug> = {\n collection: TSlug\n /**\n * context, which will then be passed to req.context, which can be read by hooks\n */\n context?: RequestContext\n depth?: number\n draft?: boolean\n fallbackLocale?: TypedLocale\n limit?: number\n locale?: 'all' | TypedLocale\n overrideAccess?: boolean\n page?: number\n populate?: PopulateType\n req?: PayloadRequest\n select?: SelectType\n showHiddenFields?: boolean\n sort?: Sort\n user?: Document\n where?: Where\n}\n\nexport default async function findVersionsLocal<TSlug extends CollectionSlug>(\n payload: Payload,\n options: Options<TSlug>,\n): Promise<PaginatedDocs<TypeWithVersion<DataFromCollectionSlug<TSlug>>>> {\n const {\n collection: collectionSlug,\n depth,\n limit,\n overrideAccess = true,\n page,\n populate,\n select,\n showHiddenFields,\n sort,\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. Find Versions Operation.`,\n )\n }\n\n return findVersionsOperation({\n collection,\n depth,\n limit,\n overrideAccess,\n page,\n populate,\n req: await createLocalReq(options, payload),\n select,\n showHiddenFields,\n sort,\n where,\n })\n}\n"],"names":["APIError","createLocalReq","findVersionsOperation","findVersionsLocal","payload","options","collection","collectionSlug","depth","limit","overrideAccess","page","populate","select","showHiddenFields","sort","where","collections","String","req"],"mappings":"AAaA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,qBAAqB,QAAQ,qBAAoB;AAwB1D,eAAe,eAAeC,kBAC5BC,OAAgB,EAChBC,OAAuB;IAEvB,MAAM,EACJC,YAAYC,cAAc,EAC1BC,KAAK,EACLC,KAAK,EACLC,iBAAiB,IAAI,EACrBC,IAAI,EACJC,QAAQ,EACRC,MAAM,EACNC,gBAAgB,EAChBC,IAAI,EACJC,KAAK,EACN,GAAGX;IAEJ,MAAMC,aAAaF,QAAQa,WAAW,CAACV,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIN,SACR,CAAC,yBAAyB,EAAEkB,OAAOX,gBAAgB,yCAAyC,CAAC;IAEjG;IAEA,OAAOL,sBAAsB;QAC3BI;QACAE;QACAC;QACAC;QACAC;QACAC;QACAO,KAAK,MAAMlB,eAAeI,SAASD;QACnCS;QACAC;QACAC;QACAC;IACF;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CollectionSlug, Payload, TypedLocale } from '../../../index.js';
|
|
2
|
-
import type { Document, PayloadRequest,
|
|
1
|
+
import type { CollectionSlug, Payload, RequestContext, TypedLocale } from '../../../index.js';
|
|
2
|
+
import type { Document, PayloadRequest, PopulateType, SelectType } from '../../../types/index.js';
|
|
3
3
|
import type { DataFromCollectionSlug } from '../../config/types.js';
|
|
4
4
|
export type Options<TSlug extends CollectionSlug> = {
|
|
5
5
|
collection: TSlug;
|
|
@@ -13,6 +13,7 @@ export type Options<TSlug extends CollectionSlug> = {
|
|
|
13
13
|
id: string;
|
|
14
14
|
locale?: TypedLocale;
|
|
15
15
|
overrideAccess?: boolean;
|
|
16
|
+
populate?: PopulateType;
|
|
16
17
|
req?: PayloadRequest;
|
|
17
18
|
select?: SelectType;
|
|
18
19
|
showHiddenFields?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restoreVersion.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/restoreVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"restoreVersion.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/restoreVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC7F,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACjG,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAMnE,MAAM,MAAM,OAAO,CAAC,KAAK,SAAS,cAAc,IAAI;IAClD,UAAU,EAAE,KAAK,CAAA;IACjB;;OAEG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,cAAc,CAAC,EAAE,WAAW,CAAA;IAC5B,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,GAAG,CAAC,EAAE,cAAc,CAAA;IACpB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,CAAC,EAAE,QAAQ,CAAA;CAChB,CAAA;AAED,wBAA8B,mBAAmB,CAAC,KAAK,SAAS,cAAc,EAC5E,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,GACtB,OAAO,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAkCxC"}
|
|
@@ -2,7 +2,7 @@ import { APIError } from '../../../errors/index.js';
|
|
|
2
2
|
import { createLocalReq } from '../../../utilities/createLocalReq.js';
|
|
3
3
|
import { restoreVersionOperation } from '../restoreVersion.js';
|
|
4
4
|
export default async function restoreVersionLocal(payload, options) {
|
|
5
|
-
const { id, collection: collectionSlug, depth, overrideAccess = true, select, showHiddenFields } = options;
|
|
5
|
+
const { id, collection: collectionSlug, depth, overrideAccess = true, populate, select, showHiddenFields } = options;
|
|
6
6
|
const collection = payload.collections[collectionSlug];
|
|
7
7
|
if (!collection) {
|
|
8
8
|
throw new APIError(`The collection with slug ${String(collectionSlug)} can't be found. Restore Version Operation.`);
|
|
@@ -13,6 +13,7 @@ export default async function restoreVersionLocal(payload, options) {
|
|
|
13
13
|
depth,
|
|
14
14
|
overrideAccess,
|
|
15
15
|
payload,
|
|
16
|
+
populate,
|
|
16
17
|
req: await createLocalReq(options, payload),
|
|
17
18
|
select,
|
|
18
19
|
showHiddenFields
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/collections/operations/local/restoreVersion.ts"],"sourcesContent":["import type { CollectionSlug, Payload, TypedLocale } from '../../../index.js'\nimport type { Document, PayloadRequest,
|
|
1
|
+
{"version":3,"sources":["../../../../src/collections/operations/local/restoreVersion.ts"],"sourcesContent":["import type { CollectionSlug, Payload, RequestContext, TypedLocale } from '../../../index.js'\nimport type { Document, PayloadRequest, PopulateType, SelectType } from '../../../types/index.js'\nimport type { DataFromCollectionSlug } from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { restoreVersionOperation } from '../restoreVersion.js'\n\nexport type Options<TSlug extends CollectionSlug> = {\n collection: TSlug\n /**\n * context, which will then be passed to req.context, which can be read by hooks\n */\n context?: RequestContext\n depth?: number\n draft?: boolean\n fallbackLocale?: TypedLocale\n id: string\n locale?: TypedLocale\n overrideAccess?: boolean\n populate?: PopulateType\n req?: PayloadRequest\n select?: SelectType\n showHiddenFields?: boolean\n user?: Document\n}\n\nexport default async function restoreVersionLocal<TSlug extends CollectionSlug>(\n payload: Payload,\n options: Options<TSlug>,\n): Promise<DataFromCollectionSlug<TSlug>> {\n const {\n id,\n collection: collectionSlug,\n depth,\n overrideAccess = true,\n populate,\n select,\n showHiddenFields,\n } = options\n\n const collection = payload.collections[collectionSlug]\n\n if (!collection) {\n throw new APIError(\n `The collection with slug ${String(\n collectionSlug,\n )} can't be found. Restore Version Operation.`,\n )\n }\n\n const args = {\n id,\n collection,\n depth,\n overrideAccess,\n payload,\n populate,\n req: await createLocalReq(options, payload),\n select,\n showHiddenFields,\n }\n\n return restoreVersionOperation(args)\n}\n"],"names":["APIError","createLocalReq","restoreVersionOperation","restoreVersionLocal","payload","options","id","collection","collectionSlug","depth","overrideAccess","populate","select","showHiddenFields","collections","String","args","req"],"mappings":"AAIA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,uBAAuB,QAAQ,uBAAsB;AAqB9D,eAAe,eAAeC,oBAC5BC,OAAgB,EAChBC,OAAuB;IAEvB,MAAM,EACJC,EAAE,EACFC,YAAYC,cAAc,EAC1BC,KAAK,EACLC,iBAAiB,IAAI,EACrBC,QAAQ,EACRC,MAAM,EACNC,gBAAgB,EACjB,GAAGR;IAEJ,MAAME,aAAaH,QAAQU,WAAW,CAACN,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIP,SACR,CAAC,yBAAyB,EAAEe,OAC1BP,gBACA,2CAA2C,CAAC;IAElD;IAEA,MAAMQ,OAAO;QACXV;QACAC;QACAE;QACAC;QACAN;QACAO;QACAM,KAAK,MAAMhB,eAAeI,SAASD;QACnCQ;QACAC;IACF;IAEA,OAAOX,wBAAwBc;AACjC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DeepPartial } from 'ts-essentials';
|
|
2
|
-
import type { CollectionSlug, Payload, TypedLocale } from '../../../index.js';
|
|
3
|
-
import type { Document, PayloadRequest,
|
|
2
|
+
import type { CollectionSlug, Payload, RequestContext, TypedLocale } from '../../../index.js';
|
|
3
|
+
import type { Document, PayloadRequest, PopulateType, SelectType, TransformCollectionWithSelect, Where } from '../../../types/index.js';
|
|
4
4
|
import type { File } from '../../../uploads/types.js';
|
|
5
5
|
import type { BulkOperationResult, RequiredDataFromCollectionSlug, SelectFromCollectionSlug } from '../../config/types.js';
|
|
6
6
|
export type BaseOptions<TSlug extends CollectionSlug, TSelect extends SelectType> = {
|
|
@@ -21,6 +21,7 @@ export type BaseOptions<TSlug extends CollectionSlug, TSelect extends SelectType
|
|
|
21
21
|
overrideAccess?: boolean;
|
|
22
22
|
overrideLock?: boolean;
|
|
23
23
|
overwriteExistingFiles?: boolean;
|
|
24
|
+
populate?: PopulateType;
|
|
24
25
|
publishSpecificLocale?: string;
|
|
25
26
|
req?: PayloadRequest;
|
|
26
27
|
select?: TSelect;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAEhD,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAEhD,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC7F,OAAO,KAAK,EACV,QA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O,CAAC,mBAAmB,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,6BAA6B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAA;AAmE/F,eAAe,WAAW,CAAA"}
|
|
@@ -4,7 +4,7 @@ import { createLocalReq } from '../../../utilities/createLocalReq.js';
|
|
|
4
4
|
import { updateOperation } from '../update.js';
|
|
5
5
|
import { updateByIDOperation } from '../updateByID.js';
|
|
6
6
|
async function updateLocal(payload, options) {
|
|
7
|
-
const { id, autosave, collection: collectionSlug, data, depth, disableTransaction, draft, file, filePath, limit, overrideAccess = true, overrideLock, overwriteExistingFiles = false, publishSpecificLocale, select, showHiddenFields, where } = options;
|
|
7
|
+
const { id, autosave, collection: collectionSlug, data, depth, disableTransaction, draft, file, filePath, limit, overrideAccess = true, overrideLock, overwriteExistingFiles = false, populate, publishSpecificLocale, select, showHiddenFields, where } = options;
|
|
8
8
|
const collection = payload.collections[collectionSlug];
|
|
9
9
|
if (!collection) {
|
|
10
10
|
throw new APIError(`The collection with slug ${String(collectionSlug)} can't be found. Update Operation.`);
|
|
@@ -24,6 +24,7 @@ async function updateLocal(payload, options) {
|
|
|
24
24
|
overrideLock,
|
|
25
25
|
overwriteExistingFiles,
|
|
26
26
|
payload,
|
|
27
|
+
populate,
|
|
27
28
|
publishSpecificLocale,
|
|
28
29
|
req,
|
|
29
30
|
select,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/collections/operations/local/update.ts"],"sourcesContent":["import type { DeepPartial } from 'ts-essentials'\n\nimport type { CollectionSlug, Payload, TypedLocale } from '../../../index.js'\nimport type {\n Document,\n PayloadRequest,\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/collections/operations/local/update.ts"],"sourcesContent":["import type { DeepPartial } from 'ts-essentials'\n\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 { File } from '../../../uploads/types.js'\nimport type {\n BulkOperationResult,\n RequiredDataFromCollectionSlug,\n SelectFromCollectionSlug,\n} from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { getFileByPath } from '../../../uploads/getFileByPath.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { updateOperation } from '../update.js'\nimport { updateByIDOperation } from '../updateByID.js'\n\nexport type BaseOptions<TSlug extends CollectionSlug, TSelect extends SelectType> = {\n autosave?: boolean\n collection: TSlug\n /**\n * context, which will then be passed to req.context, which can be read by hooks\n */\n context?: RequestContext\n data: DeepPartial<RequiredDataFromCollectionSlug<TSlug>>\n depth?: number\n disableTransaction?: boolean\n draft?: boolean\n fallbackLocale?: TypedLocale\n file?: File\n filePath?: string\n locale?: TypedLocale\n overrideAccess?: boolean\n overrideLock?: boolean\n overwriteExistingFiles?: boolean\n populate?: PopulateType\n publishSpecificLocale?: string\n req?: PayloadRequest\n select?: TSelect\n showHiddenFields?: boolean\n user?: Document\n}\n\nexport type ByIDOptions<\n TSlug extends CollectionSlug,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n> = {\n id: number | string\n limit?: never\n where?: never\n} & BaseOptions<TSlug, TSelect>\n\nexport type ManyOptions<\n TSlug extends CollectionSlug,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n> = {\n id?: never\n limit?: number\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 updateLocal<\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 updateLocal<\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 updateLocal<\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 updateLocal<\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 autosave,\n collection: collectionSlug,\n data,\n depth,\n disableTransaction,\n draft,\n file,\n filePath,\n limit,\n overrideAccess = true,\n overrideLock,\n overwriteExistingFiles = false,\n populate,\n publishSpecificLocale,\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. Update Operation.`,\n )\n }\n\n const req = await createLocalReq(options, payload)\n req.file = file ?? (await getFileByPath(filePath))\n\n const args = {\n id,\n autosave,\n collection,\n data,\n depth,\n disableTransaction,\n draft,\n limit,\n overrideAccess,\n overrideLock,\n overwriteExistingFiles,\n payload,\n populate,\n publishSpecificLocale,\n req,\n select,\n showHiddenFields,\n where,\n }\n\n if (options.id) {\n return updateByIDOperation<TSlug, TSelect>(args)\n }\n return updateOperation<TSlug, TSelect>(args)\n}\n\nexport default updateLocal\n"],"names":["APIError","getFileByPath","createLocalReq","updateOperation","updateByIDOperation","updateLocal","payload","options","id","autosave","collection","collectionSlug","data","depth","disableTransaction","draft","file","filePath","limit","overrideAccess","overrideLock","overwriteExistingFiles","populate","publishSpecificLocale","select","showHiddenFields","where","collections","String","req","args"],"mappings":"AAkBA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,aAAa,QAAQ,oCAAmC;AACjE,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,eAAe,QAAQ,eAAc;AAC9C,SAASC,mBAAmB,QAAQ,mBAAkB;AAwEtD,eAAeC,YAIbC,OAAgB,EAChBC,OAAgC;IAEhC,MAAM,EACJC,EAAE,EACFC,QAAQ,EACRC,YAAYC,cAAc,EAC1BC,IAAI,EACJC,KAAK,EACLC,kBAAkB,EAClBC,KAAK,EACLC,IAAI,EACJC,QAAQ,EACRC,KAAK,EACLC,iBAAiB,IAAI,EACrBC,YAAY,EACZC,yBAAyB,KAAK,EAC9BC,QAAQ,EACRC,qBAAqB,EACrBC,MAAM,EACNC,gBAAgB,EAChBC,KAAK,EACN,GAAGnB;IAEJ,MAAMG,aAAaJ,QAAQqB,WAAW,CAAChB,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIV,SACR,CAAC,yBAAyB,EAAE4B,OAAOjB,gBAAgB,kCAAkC,CAAC;IAE1F;IAEA,MAAMkB,MAAM,MAAM3B,eAAeK,SAASD;IAC1CuB,IAAIb,IAAI,GAAGA,QAAS,MAAMf,cAAcgB;IAExC,MAAMa,OAAO;QACXtB;QACAC;QACAC;QACAE;QACAC;QACAC;QACAC;QACAG;QACAC;QACAC;QACAC;QACAf;QACAgB;QACAC;QACAM;QACAL;QACAC;QACAC;IACF;IAEA,IAAInB,QAAQC,EAAE,EAAE;QACd,OAAOJ,oBAAoC0B;IAC7C;IACA,OAAO3B,gBAAgC2B;AACzC;AAEA,eAAezB,YAAW"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PayloadRequest, SelectType } from '../../types/index.js';
|
|
1
|
+
import type { PayloadRequest, PopulateType, SelectType } from '../../types/index.js';
|
|
2
2
|
import type { Collection, TypeWithID } from '../config/types.js';
|
|
3
3
|
export type Arguments = {
|
|
4
4
|
collection: Collection;
|
|
@@ -8,6 +8,7 @@ export type Arguments = {
|
|
|
8
8
|
draft?: boolean;
|
|
9
9
|
id: number | string;
|
|
10
10
|
overrideAccess?: boolean;
|
|
11
|
+
populate?: PopulateType;
|
|
11
12
|
req: PayloadRequest;
|
|
12
13
|
select?: SelectType;
|
|
13
14
|
showHiddenFields?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restoreVersion.d.ts","sourceRoot":"","sources":["../../../src/collections/operations/restoreVersion.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"restoreVersion.d.ts","sourceRoot":"","sources":["../../../src/collections/operations/restoreVersion.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACpF,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAWhE,MAAM,MAAM,SAAS,GAAG;IACtB,UAAU,EAAE,UAAU,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,GAAG,EAAE,cAAc,CAAA;IACnB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,CAAA;AAED,eAAO,MAAM,uBAAuB,GAAU,KAAK,SAAS,UAAU,cAC9D,SAAS,KACd,OAAO,CAAC,KAAK,CAyLf,CAAA"}
|
|
@@ -8,7 +8,7 @@ import { afterRead } from '../../fields/hooks/afterRead/index.js';
|
|
|
8
8
|
import { killTransaction } from '../../utilities/killTransaction.js';
|
|
9
9
|
import { getLatestCollectionVersion } from '../../versions/getLatestCollectionVersion.js';
|
|
10
10
|
export const restoreVersionOperation = async (args)=>{
|
|
11
|
-
const { id, collection: { config: collectionConfig }, depth, draft, overrideAccess = false, req, req: { fallbackLocale, locale, payload }, select, showHiddenFields } = args;
|
|
11
|
+
const { id, collection: { config: collectionConfig }, depth, draft, overrideAccess = false, populate, req, req: { fallbackLocale, locale, payload }, select, showHiddenFields } = args;
|
|
12
12
|
try {
|
|
13
13
|
if (!id) {
|
|
14
14
|
throw new APIError('Missing ID of version to restore.', httpStatus.BAD_REQUEST);
|
|
@@ -113,6 +113,7 @@ export const restoreVersionOperation = async (args)=>{
|
|
|
113
113
|
global: null,
|
|
114
114
|
locale,
|
|
115
115
|
overrideAccess,
|
|
116
|
+
populate,
|
|
116
117
|
req,
|
|
117
118
|
select,
|
|
118
119
|
showHiddenFields
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/operations/restoreVersion.ts"],"sourcesContent":["import httpStatus from 'http-status'\n\nimport type { FindOneArgs } from '../../database/types.js'\nimport type { PayloadRequest, SelectType } from '../../types/index.js'\nimport type { Collection, TypeWithID } from '../config/types.js'\n\nimport executeAccess from '../../auth/executeAccess.js'\nimport { hasWhereAccessResult } from '../../auth/types.js'\nimport { combineQueries } from '../../database/combineQueries.js'\nimport { APIError, Forbidden, NotFound } from '../../errors/index.js'\nimport { afterChange } from '../../fields/hooks/afterChange/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { getLatestCollectionVersion } from '../../versions/getLatestCollectionVersion.js'\n\nexport type Arguments = {\n collection: Collection\n currentDepth?: number\n depth?: number\n disableErrors?: boolean\n draft?: boolean\n id: number | string\n overrideAccess?: boolean\n req: PayloadRequest\n select?: SelectType\n showHiddenFields?: boolean\n}\n\nexport const restoreVersionOperation = async <TData extends TypeWithID = any>(\n args: Arguments,\n): Promise<TData> => {\n const {\n id,\n collection: { config: collectionConfig },\n depth,\n draft,\n overrideAccess = false,\n req,\n req: { fallbackLocale, locale, payload },\n select,\n showHiddenFields,\n } = args\n\n try {\n if (!id) {\n throw new APIError('Missing ID of version to restore.', httpStatus.BAD_REQUEST)\n }\n\n // /////////////////////////////////////\n // Retrieve original raw version\n // /////////////////////////////////////\n\n const { docs: versionDocs } = await req.payload.db.findVersions({\n collection: collectionConfig.slug,\n limit: 1,\n locale,\n pagination: false,\n req,\n where: { id: { equals: id } },\n })\n\n const [rawVersion] = versionDocs\n\n if (!rawVersion) {\n throw new NotFound(req.t)\n }\n\n const parentDocID = rawVersion.parent\n\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n const accessResults = !overrideAccess\n ? await executeAccess({ id: parentDocID, req }, collectionConfig.access.update)\n : true\n const hasWherePolicy = hasWhereAccessResult(accessResults)\n\n // /////////////////////////////////////\n // Retrieve document\n // /////////////////////////////////////\n\n const findOneArgs: FindOneArgs = {\n collection: collectionConfig.slug,\n locale,\n req,\n where: combineQueries({ id: { equals: parentDocID } }, accessResults),\n }\n\n const doc = await req.payload.db.findOne(findOneArgs)\n\n if (!doc && !hasWherePolicy) {\n throw new NotFound(req.t)\n }\n if (!doc && hasWherePolicy) {\n throw new Forbidden(req.t)\n }\n\n // /////////////////////////////////////\n // fetch previousDoc\n // /////////////////////////////////////\n\n const prevDocWithLocales = await getLatestCollectionVersion({\n id: parentDocID,\n config: collectionConfig,\n payload,\n query: findOneArgs,\n req,\n })\n\n // /////////////////////////////////////\n // Update\n // /////////////////////////////////////\n\n let result = await req.payload.db.updateOne({\n id: parentDocID,\n collection: collectionConfig.slug,\n data: rawVersion.version,\n req,\n select,\n })\n\n // /////////////////////////////////////\n // Save `previousDoc` as a version after restoring\n // /////////////////////////////////////\n\n const prevVersion = { ...prevDocWithLocales }\n\n delete prevVersion.id\n\n await payload.db.createVersion({\n autosave: false,\n collectionSlug: collectionConfig.slug,\n createdAt: prevVersion.createdAt,\n parent: parentDocID,\n req,\n updatedAt: new Date().toISOString(),\n versionData: draft ? { ...rawVersion.version, _status: 'draft' } : rawVersion.version,\n })\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n result = await afterRead({\n collection: collectionConfig,\n context: req.context,\n depth,\n doc: result,\n draft: undefined,\n fallbackLocale,\n global: null,\n locale,\n overrideAccess,\n req,\n select,\n showHiddenFields,\n })\n\n // /////////////////////////////////////\n // afterRead - Collection\n // /////////////////////////////////////\n\n await collectionConfig.hooks.afterRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: result,\n req,\n })) || result\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // afterChange - Fields\n // /////////////////////////////////////\n\n result = await afterChange({\n collection: collectionConfig,\n context: req.context,\n data: result,\n doc: result,\n global: null,\n operation: 'update',\n previousDoc: prevDocWithLocales,\n req,\n })\n\n // /////////////////////////////////////\n // afterChange - Collection\n // /////////////////////////////////////\n\n await collectionConfig.hooks.afterChange.reduce(async (priorHook, hook) => {\n await priorHook\n\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: result,\n operation: 'update',\n previousDoc: prevDocWithLocales,\n req,\n })) || result\n }, Promise.resolve())\n\n return result\n } catch (error: unknown) {\n await killTransaction(req)\n throw error\n }\n}\n"],"names":["httpStatus","executeAccess","hasWhereAccessResult","combineQueries","APIError","Forbidden","NotFound","afterChange","afterRead","killTransaction","getLatestCollectionVersion","restoreVersionOperation","args","id","collection","config","collectionConfig","depth","draft","overrideAccess","req","fallbackLocale","locale","payload","select","showHiddenFields","BAD_REQUEST","docs","versionDocs","db","findVersions","slug","limit","pagination","where","equals","rawVersion","t","parentDocID","parent","accessResults","access","update","hasWherePolicy","findOneArgs","doc","findOne","prevDocWithLocales","query","result","updateOne","data","version","prevVersion","createVersion","autosave","collectionSlug","createdAt","updatedAt","Date","toISOString","versionData","_status","context","undefined","global","hooks","reduce","priorHook","hook","Promise","resolve","operation","previousDoc","error"],"mappings":"AAAA,OAAOA,gBAAgB,cA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AAwC;QACxC,qBAAqB;QACrB,wCAAwC;QAExCH,SAAS,MAAMzC,UAAU;YACvBM,YAAYE;YACZ+C,SAAS3C,IAAI2C,OAAO;YACpB9C;YACA4B,KAAKI;YACL/B,OAAO8C;YACP3C;YACA4C,QAAQ;YACR3C;YACAH;YACAC;YACAI;YACAC;QACF;QAEA,wCAAwC;QACxC,yBAAyB;QACzB,wCAAwC;QAExC,MAAMT,iBAAiBkD,KAAK,CAAC1D,SAAS,CAAC2D,MAAM,CAAC,OAAOC,WAAWC;YAC9D,MAAMD;YAENnB,SACE,AAAC,MAAMoB,KAAK;gBACVvD,YAAYE;gBACZ+C,SAAS3C,IAAI2C,OAAO;gBACpBlB,KAAKI;gBACL7B;YACF,MAAO6B;QACX,GAAGqB,QAAQC,OAAO;QAElB,wCAAwC;QACxC,uBAAuB;QACvB,wCAAwC;QAExCtB,SAAS,MAAM1C,YAAY;YACzBO,YAAYE;YACZ+C,SAAS3C,IAAI2C,OAAO;YACpBZ,MAAMF;YACNJ,KAAKI;YACLgB,QAAQ;YACRO,WAAW;YACXC,aAAa1B;YACb3B;QACF;QAEA,wCAAwC;QACxC,2BAA2B;QAC3B,wCAAwC;QAExC,MAAMJ,iBAAiBkD,KAAK,CAAC3D,WAAW,CAAC4D,MAAM,CAAC,OAAOC,WAAWC;YAChE,MAAMD;YAENnB,SACE,AAAC,MAAMoB,KAAK;gBACVvD,YAAYE;gBACZ+C,SAAS3C,IAAI2C,OAAO;gBACpBlB,KAAKI;gBACLuB,WAAW;gBACXC,aAAa1B;gBACb3B;YACF,MAAO6B;QACX,GAAGqB,QAAQC,OAAO;QAElB,OAAOtB;IACT,EAAE,OAAOyB,OAAgB;QACvB,MAAMjE,gBAAgBW;QACtB,MAAMsD;IACR;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/operations/restoreVersion.ts"],"sourcesContent":["import httpStatus from 'http-status'\n\nimport type { FindOneArgs } from '../../database/types.js'\nimport type { PayloadRequest, PopulateType, SelectType } from '../../types/index.js'\nimport type { Collection, TypeWithID } from '../config/types.js'\n\nimport executeAccess from '../../auth/executeAccess.js'\nimport { hasWhereAccessResult } from '../../auth/types.js'\nimport { combineQueries } from '../../database/combineQueries.js'\nimport { APIError, Forbidden, NotFound } from '../../errors/index.js'\nimport { afterChange } from '../../fields/hooks/afterChange/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { getLatestCollectionVersion } from '../../versions/getLatestCollectionVersion.js'\n\nexport type Arguments = {\n collection: Collection\n currentDepth?: number\n depth?: number\n disableErrors?: boolean\n draft?: boolean\n id: number | string\n overrideAccess?: boolean\n populate?: PopulateType\n req: PayloadRequest\n select?: SelectType\n showHiddenFields?: boolean\n}\n\nexport const restoreVersionOperation = async <TData extends TypeWithID = any>(\n args: Arguments,\n): Promise<TData> => {\n const {\n id,\n collection: { config: collectionConfig },\n depth,\n draft,\n overrideAccess = false,\n populate,\n req,\n req: { fallbackLocale, locale, payload },\n select,\n showHiddenFields,\n } = args\n\n try {\n if (!id) {\n throw new APIError('Missing ID of version to restore.', httpStatus.BAD_REQUEST)\n }\n\n // /////////////////////////////////////\n // Retrieve original raw version\n // /////////////////////////////////////\n\n const { docs: versionDocs } = await req.payload.db.findVersions({\n collection: collectionConfig.slug,\n limit: 1,\n locale,\n pagination: false,\n req,\n where: { id: { equals: id } },\n })\n\n const [rawVersion] = versionDocs\n\n if (!rawVersion) {\n throw new NotFound(req.t)\n }\n\n const parentDocID = rawVersion.parent\n\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n const accessResults = !overrideAccess\n ? await executeAccess({ id: parentDocID, req }, collectionConfig.access.update)\n : true\n const hasWherePolicy = hasWhereAccessResult(accessResults)\n\n // /////////////////////////////////////\n // Retrieve document\n // /////////////////////////////////////\n\n const findOneArgs: FindOneArgs = {\n collection: collectionConfig.slug,\n locale,\n req,\n where: combineQueries({ id: { equals: parentDocID } }, accessResults),\n }\n\n const doc = await req.payload.db.findOne(findOneArgs)\n\n if (!doc && !hasWherePolicy) {\n throw new NotFound(req.t)\n }\n if (!doc && hasWherePolicy) {\n throw new Forbidden(req.t)\n }\n\n // /////////////////////////////////////\n // fetch previousDoc\n // /////////////////////////////////////\n\n const prevDocWithLocales = await getLatestCollectionVersion({\n id: parentDocID,\n config: collectionConfig,\n payload,\n query: findOneArgs,\n req,\n })\n\n // /////////////////////////////////////\n // Update\n // /////////////////////////////////////\n\n let result = await req.payload.db.updateOne({\n id: parentDocID,\n collection: collectionConfig.slug,\n data: rawVersion.version,\n req,\n select,\n })\n\n // /////////////////////////////////////\n // Save `previousDoc` as a version after restoring\n // /////////////////////////////////////\n\n const prevVersion = { ...prevDocWithLocales }\n\n delete prevVersion.id\n\n await payload.db.createVersion({\n autosave: false,\n collectionSlug: collectionConfig.slug,\n createdAt: prevVersion.createdAt,\n parent: parentDocID,\n req,\n updatedAt: new Date().toISOString(),\n versionData: draft ? { ...rawVersion.version, _status: 'draft' } : rawVersion.version,\n })\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n result = await afterRead({\n collection: collectionConfig,\n context: req.context,\n depth,\n doc: result,\n draft: undefined,\n fallbackLocale,\n global: null,\n locale,\n overrideAccess,\n populate,\n req,\n select,\n showHiddenFields,\n })\n\n // /////////////////////////////////////\n // afterRead - Collection\n // /////////////////////////////////////\n\n await collectionConfig.hooks.afterRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: result,\n req,\n })) || result\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // afterChange - Fields\n // /////////////////////////////////////\n\n result = await afterChange({\n collection: collectionConfig,\n context: req.context,\n data: result,\n doc: result,\n global: null,\n operation: 'update',\n previousDoc: prevDocWithLocales,\n req,\n })\n\n // /////////////////////////////////////\n // afterChange - Collection\n // /////////////////////////////////////\n\n await collectionConfig.hooks.afterChange.reduce(async (priorHook, hook) => {\n await priorHook\n\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: result,\n operation: 'update',\n previousDoc: prevDocWithLocales,\n req,\n })) || result\n }, Promise.resolve())\n\n return result\n } catch (error: unknown) {\n await killTransaction(req)\n throw error\n }\n}\n"],"names":["httpStatus","executeAccess","hasWhereAccessResult","combineQueries","APIError","Forbidden","NotFound","afterChange","afterRead","killTransaction","getLatestCollectionVersion","restoreVersionOperation","args","id","collection","config","collectionConfig","depth","draft","overrideAccess","populate","req","fallbackLocale","locale","payload","select","showHiddenFields","BAD_REQUEST","docs","versionDocs","db","findVersions","slug","limit","pagination","where","equals","rawVersion","t","parentDocID","parent","accessResults","access","update","hasWherePolicy","findOneArgs","doc","findOne","prevDocWithLocales","query","result","updateOne","data","version","prevVersion","createVersion","autosave","collectionSlug","createdAt","updatedAt","Date","toISOString","versionData","_status","context","undefined","global","hooks","reduce","priorHook","hook","Promise","resolve","operation","previousDoc","error"],"mappings":"AAAA,OAAOA,gBAAgB,cAAa;AAMpC,OAAOC,mBAAmB,8BAA6B;AACvD,SAASC,oBAAoB,QAAQ,sBAAqB;AAC1D,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,QAAQ,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,wBAAuB;AACrE,SAASC,WAAW,QAAQ,0CAAyC;AACrE,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,0BAA0B,QAAQ,+CAA8C;AAgBzF,OAAO,MAAMC,0BAA0B,OACrCC;IAEA,MAAM,EACJC,EAAE,EACFC,YAAY,EAAEC,QAAQC,gBAAgB,EAAE,EACxCC,KAAK,EACLC,KAAK,EACLC,iBAAiB,KAAK,EACtBC,QAAQ,EACRC,GAAG,EACHA,KAAK,EAAEC,cAAc,EAAEC,MAAM,EAAEC,OAAO,EAAE,EACxCC,MAAM,EACNC,gBAAgB,EACjB,GAAGd;IAEJ,IAAI;QACF,IAAI,CAAC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gD,SAAS3C,IAAI2C,OAAO;YACpBZ,MAAMF;YACNJ,KAAKI;YACLgB,QAAQ;YACRO,WAAW;YACXC,aAAa1B;YACb3B;QACF;QAEA,wCAAwC;QACxC,2BAA2B;QAC3B,wCAAwC;QAExC,MAAML,iBAAiBmD,KAAK,CAAC5D,WAAW,CAAC6D,MAAM,CAAC,OAAOC,WAAWC;YAChE,MAAMD;YAENnB,SACE,AAAC,MAAMoB,KAAK;gBACVxD,YAAYE;gBACZgD,SAAS3C,IAAI2C,OAAO;gBACpBlB,KAAKI;gBACLuB,WAAW;gBACXC,aAAa1B;gBACb3B;YACF,MAAO6B;QACX,GAAGqB,QAAQC,OAAO;QAElB,OAAOtB;IACT,EAAE,OAAOyB,OAAgB;QACvB,MAAMlE,gBAAgBY;QACtB,MAAMsD;IACR;AACF,EAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DeepPartial } from 'ts-essentials';
|
|
2
2
|
import type { CollectionSlug } from '../../index.js';
|
|
3
|
-
import type { PayloadRequest, SelectType, Where } from '../../types/index.js';
|
|
3
|
+
import type { PayloadRequest, PopulateType, SelectType, Where } from '../../types/index.js';
|
|
4
4
|
import type { BulkOperationResult, Collection, RequiredDataFromCollectionSlug, SelectFromCollectionSlug } from '../config/types.js';
|
|
5
5
|
export type Arguments<TSlug extends CollectionSlug> = {
|
|
6
6
|
collection: Collection;
|
|
@@ -13,6 +13,7 @@ export type Arguments<TSlug extends CollectionSlug> = {
|
|
|
13
13
|
overrideAccess?: boolean;
|
|
14
14
|
overrideLock?: boolean;
|
|
15
15
|
overwriteExistingFiles?: boolean;
|
|
16
|
+
populate?: PopulateType;
|
|
16
17
|
req: PayloadRequest;
|
|
17
18
|
select?: SelectType;
|
|
18
19
|
showHiddenFields?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/collections/operations/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE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,cAAc,EAC5B,OAAO,SAAS,wBAAwB,CAAC,KAAK,CAAC,gBAEjC,SAAS,CAAC,KAAK,CAAC,KAC7B,OAAO,CAAC,mBAAmB,CAAC,KAAK,EAAE,OAAO,CAAC,CAuZ7C,CAAA"}
|
|
@@ -37,7 +37,7 @@ export const updateOperation = async (incomingArgs)=>{
|
|
|
37
37
|
req: args.req
|
|
38
38
|
}) || args;
|
|
39
39
|
}, Promise.resolve());
|
|
40
|
-
const { collection: { config: collectionConfig }, collection, depth, draft: draftArg = false, limit = 0, overrideAccess, overrideLock, overwriteExistingFiles = false, req: { fallbackLocale, locale, payload: { config }, payload }, req, select, showHiddenFields, where } = args;
|
|
40
|
+
const { collection: { config: collectionConfig }, collection, depth, draft: draftArg = false, limit = 0, overrideAccess, overrideLock, overwriteExistingFiles = false, populate, req: { fallbackLocale, locale, payload: { config }, payload }, req, select, showHiddenFields, where } = args;
|
|
41
41
|
if (!where) {
|
|
42
42
|
throw new APIError("Missing 'where' query of documents to update.", httpStatus.BAD_REQUEST);
|
|
43
43
|
}
|
|
@@ -255,6 +255,7 @@ export const updateOperation = async (incomingArgs)=>{
|
|
|
255
255
|
global: null,
|
|
256
256
|
locale,
|
|
257
257
|
overrideAccess,
|
|
258
|
+
populate,
|
|
258
259
|
req,
|
|
259
260
|
select,
|
|
260
261
|
showHiddenFields
|