payload 3.0.0-beta.123 → 3.0.0-beta.125
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 +2 -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/find.d.ts.map +1 -1
- package/dist/collections/operations/find.js +9 -2
- package/dist/collections/operations/find.js.map +1 -1
- package/dist/collections/operations/findByID.d.ts.map +1 -1
- package/dist/collections/operations/findByID.js +21 -6
- package/dist/collections/operations/findByID.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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- package/dist/collections/operations/local/update.d.ts.map +1 -1
- package/dist/collections/operations/local/update.js.map +1 -1
- package/dist/database/queryValidation/validateSearchParams.d.ts.map +1 -1
- package/dist/database/queryValidation/validateSearchParams.js +7 -0
- package/dist/database/queryValidation/validateSearchParams.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 +2 -1
- package/dist/fields/hooks/afterRead/index.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/index.js.map +1 -1
- package/dist/fields/hooks/afterRead/promise.d.ts +2 -1
- package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/promise.js.map +1 -1
- package/dist/fields/hooks/afterRead/traverseFields.d.ts +2 -1
- package/dist/fields/hooks/afterRead/traverseFields.d.ts.map +1 -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/types/index.d.ts +2 -5
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utilities/addSelectGenericsToGeneratedTyoes.spec.js +4 -4
- package/dist/utilities/addSelectGenericsToGeneratedTyoes.spec.js.map +1 -1
- package/dist/utilities/addSelectGenericsToGeneretedTypes.js +1 -1
- package/dist/utilities/addSelectGenericsToGeneretedTypes.js.map +1 -1
- package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
- package/dist/utilities/configToJSONSchema.js +2 -0
- package/dist/utilities/configToJSONSchema.js.map +1 -1
- package/dist/utilities/telemetry/index.d.ts +1 -0
- package/dist/utilities/telemetry/index.d.ts.map +1 -1
- package/dist/utilities/telemetry/index.js +29 -3
- package/dist/utilities/telemetry/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/create.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/create.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC7F,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,UAAU,EACV,6BAA6B,EAC9B,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,KAAK,EACV,8BAA8B,EAC9B,wBAAwB,EACzB,MAAM,uBAAuB,CAAA;AAO9B,MAAM,MAAM,OAAO,CAAC,KAAK,SAAS,cAAc,EAAE,OAAO,SAAS,UAAU,IAAI;IAC9E,UAAU,EAAE,KAAK,CAAA;IACjB;;OAEG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,IAAI,EAAE,8BAA8B,CAAC,KAAK,CAAC,CAAA;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,cAAc,CAAC,EAAE,WAAW,CAAA;IAC5B,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC,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;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,CAuCxD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/collections/operations/local/create.ts"],"sourcesContent":["import type { CollectionSlug, Payload, TypedLocale } from '../../../index.js'\nimport type {\n Document,\n PayloadRequest,\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/collections/operations/local/create.ts"],"sourcesContent":["import type { CollectionSlug, Payload, RequestContext, TypedLocale } from '../../../index.js'\nimport type {\n Document,\n PayloadRequest,\n SelectType,\n TransformCollectionWithSelect,\n} from '../../../types/index.js'\nimport type { File } from '../../../uploads/types.js'\nimport type {\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 { 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, which can be read by hooks\n */\n context?: RequestContext\n data: RequiredDataFromCollectionSlug<TSlug>\n depth?: number\n disableTransaction?: boolean\n disableVerificationEmail?: boolean\n draft?: boolean\n fallbackLocale?: TypedLocale\n file?: File\n filePath?: string\n locale?: TypedLocale\n overrideAccess?: boolean\n overwriteExistingFiles?: boolean\n req?: PayloadRequest\n select?: TSelect\n showHiddenFields?: boolean\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 file,\n filePath,\n overrideAccess = true,\n overwriteExistingFiles = false,\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,\n depth,\n disableTransaction,\n disableVerificationEmail,\n draft,\n overrideAccess,\n overwriteExistingFiles,\n req,\n select,\n showHiddenFields,\n })\n}\n"],"names":["APIError","getFileByPath","createLocalReq","createOperation","createLocal","payload","options","collection","collectionSlug","data","depth","disableTransaction","disableVerificationEmail","draft","file","filePath","overrideAccess","overwriteExistingFiles","select","showHiddenFields","collections","String","req"],"mappings":"AAaA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,aAAa,QAAQ,oCAAmC;AACjE,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,eAAe,QAAQ,eAAc;AAyB9C,iDAAiD;AACjD,eAAe,eAAeC,YAI5BC,OAAgB,EAChBC,OAAgC;IAEhC,MAAM,EACJC,YAAYC,cAAc,EAC1BC,IAAI,EACJC,KAAK,EACLC,kBAAkB,EAClBC,wBAAwB,EACxBC,KAAK,EACLC,IAAI,EACJC,QAAQ,EACRC,iBAAiB,IAAI,EACrBC,yBAAyB,KAAK,EAC9BC,MAAM,EACNC,gBAAgB,EACjB,GAAGb;IACJ,MAAMC,aAAaF,QAAQe,WAAW,CAACZ,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIP,SACR,CAAC,yBAAyB,EAAEqB,OAAOb,gBAAgB,kCAAkC,CAAC;IAE1F;IAEA,MAAMc,MAAM,MAAMpB,eAAeI,SAASD;IAC1CiB,IAAIR,IAAI,GAAGA,QAAS,MAAMb,cAAcc;IAExC,OAAOZ,gBAAgC;QACrCI;QACAE;QACAC;QACAC;QACAC;QACAC;QACAG;QACAC;QACAK;QACAJ;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, 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
5
|
collection: TSlug;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/delete.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,E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":["import type { CollectionSlug, Payload, TypedLocale } from '../../../index.js'\nimport type {\n Document,\n PayloadRequest,\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/collections/operations/local/delete.ts"],"sourcesContent":["import type { CollectionSlug, Payload, RequestContext, TypedLocale } from '../../../index.js'\nimport type {\n Document,\n PayloadRequest,\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, which can be read by hooks\n */\n context?: RequestContext\n depth?: number\n disableTransaction?: boolean\n fallbackLocale?: TypedLocale\n locale?: TypedLocale\n overrideAccess?: boolean\n overrideLock?: boolean\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 where?: never\n} & BaseOptions<TSlug, TSelect>\n\nexport type ManyOptions<\n TSlug extends CollectionSlug,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n> = {\n id?: never\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 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 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","select","showHiddenFields","where","collections","String","args","req"],"mappings":"AAUA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,eAAe,QAAQ,eAAc;AAC9C,SAASC,mBAAmB,QAAQ,mBAAkB;AA8DtD,eAAeC,YAIbC,OAAgB,EAChBC,OAAgC;IAEhC,MAAM,EACJC,EAAE,EACFC,YAAYC,cAAc,EAC1BC,KAAK,EACLC,kBAAkB,EAClBC,iBAAiB,IAAI,EACrBC,YAAY,EACZC,MAAM,EACNC,gBAAgB,EAChBC,KAAK,EACN,GAAGV;IAEJ,MAAME,aAAaH,QAAQY,WAAW,CAACR,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIR,SACR,CAAC,yBAAyB,EAAEkB,OAAOT,gBAAgB,kCAAkC,CAAC;IAE1F;IAEA,MAAMU,OAAO;QACXZ;QACAC;QACAE;QACAC;QACAC;QACAC;QACAO,KAAK,MAAMnB,eAAeK,SAASD;QACnCS;QACAC;QACAC;IACF;IAEA,IAAIV,QAAQC,EAAE,EAAE;QACd,OAAOJ,oBAAoCgB;IAC7C;IACA,OAAOjB,gBAAgCiB;AACzC;AAEA,eAAef,YAAW"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CollectionSlug, TypedLocale } from '../../..//index.js';
|
|
2
|
-
import type { Payload } from '../../../index.js';
|
|
3
|
-
import type { Document, PayloadRequest,
|
|
2
|
+
import type { Payload, RequestContext } from '../../../index.js';
|
|
3
|
+
import type { Document, PayloadRequest, SelectType, TransformCollectionWithSelect } from '../../../types/index.js';
|
|
4
4
|
import type { SelectFromCollectionSlug } from '../../config/types.js';
|
|
5
5
|
export type Options<TSlug extends CollectionSlug, TSelect extends SelectType> = {
|
|
6
6
|
collection: TSlug;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"duplicate.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/duplicate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"duplicate.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/duplicate.ts"],"names":[],"mappings":"AAAA,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,UAAU,EACV,6BAA6B,EAC9B,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAMrE,MAAM,MAAM,OAAO,CAAC,KAAK,SAAS,cAAc,EAAE,OAAO,SAAS,UAAU,IAAI;IAC9E,UAAU,EAAE,KAAK,CAAA;IACjB;;OAEG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,cAAc,CAAC,EAAE,WAAW,CAAA;IAC5B,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,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,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,CAuCxD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/collections/operations/local/duplicate.ts"],"sourcesContent":["import type { CollectionSlug, TypedLocale } from '../../..//index.js'\nimport type { Payload } from '../../../index.js'\nimport type {\n Document,\n PayloadRequest,\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/collections/operations/local/duplicate.ts"],"sourcesContent":["import type { CollectionSlug, TypedLocale } from '../../..//index.js'\nimport type { Payload, RequestContext } from '../../../index.js'\nimport type {\n Document,\n PayloadRequest,\n SelectType,\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 { 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, which can be read by hooks\n */\n context?: RequestContext\n depth?: number\n disableTransaction?: boolean\n draft?: boolean\n fallbackLocale?: TypedLocale\n id: number | string\n locale?: TypedLocale\n overrideAccess?: boolean\n req?: PayloadRequest\n select?: TSelect\n showHiddenFields?: boolean\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 depth,\n disableTransaction,\n draft,\n overrideAccess = true,\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 depth,\n disableTransaction,\n draft,\n overrideAccess,\n req,\n select,\n showHiddenFields,\n })\n}\n"],"names":["APIError","createLocalReq","duplicateOperation","duplicate","payload","options","id","collection","collectionSlug","depth","disableTransaction","draft","overrideAccess","select","showHiddenFields","collections","String","config","disableDuplicate","req"],"mappings":"AAUA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,kBAAkB,QAAQ,kBAAiB;AAqBpD,OAAO,eAAeC,UAIpBC,OAAgB,EAChBC,OAAgC;IAEhC,MAAM,EACJC,EAAE,EACFC,YAAYC,cAAc,EAC1BC,KAAK,EACLC,kBAAkB,EAClBC,KAAK,EACLC,iBAAiB,IAAI,EACrBC,MAAM,EACNC,gBAAgB,EACjB,GAAGT;IACJ,MAAME,aAAaH,QAAQW,WAAW,CAACP,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIP,SACR,CAAC,yBAAyB,EAAEgB,OAAOR,gBAAgB,qCAAqC,CAAC;IAE7F;IAEA,IAAID,WAAWU,MAAM,CAACC,gBAAgB,KAAK,MAAM;QAC/C,MAAM,IAAIlB,SACR,CAAC,yBAAyB,EAAEgB,OAAOR,gBAAgB,sBAAsB,CAAC,EAC1E;IAEJ;IAEA,MAAMW,MAAM,MAAMlB,eAAeI,SAASD;IAE1C,OAAOF,mBAAmC;QACxCI;QACAC;QACAE;QACAC;QACAC;QACAC;QACAO;QACAN;QACAC;IACF;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PaginatedDocs } from '../../../database/types.js';
|
|
2
|
-
import type { CollectionSlug, JoinQuery, Payload, TypedLocale } from '../../../index.js';
|
|
3
|
-
import type { Document, PayloadRequest,
|
|
2
|
+
import type { CollectionSlug, JoinQuery, Payload, RequestContext, TypedLocale } from '../../../index.js';
|
|
3
|
+
import type { Document, PayloadRequest, SelectType, Sort, TransformCollectionWithSelect, Where } from '../../../types/index.js';
|
|
4
4
|
import type { SelectFromCollectionSlug } from '../../config/types.js';
|
|
5
5
|
export type Options<TSlug extends CollectionSlug, TSelect extends SelectType> = {
|
|
6
6
|
collection: TSlug;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/find.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,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Q,CAAA;IACf,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,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,aAAa,CAAC,6BAA6B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,CA8CvE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/collections/operations/local/find.ts"],"sourcesContent":["import type { PaginatedDocs } from '../../../database/types.js'\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../../src/collections/operations/local/find.ts"],"sourcesContent":["import type { PaginatedDocs } from '../../../database/types.js'\nimport type {\n CollectionSlug,\n JoinQuery,\n Payload,\n RequestContext,\n TypedLocale,\n} from '../../../index.js'\nimport type {\n Document,\n PayloadRequest,\n SelectType,\n Sort,\n TransformCollectionWithSelect,\n Where,\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 { findOperation } from '../find.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, which can be read by hooks\n */\n context?: RequestContext\n currentDepth?: number\n depth?: number\n disableErrors?: boolean\n draft?: boolean\n fallbackLocale?: TypedLocale\n includeLockStatus?: boolean\n joins?: JoinQuery\n limit?: number\n locale?: 'all' | TypedLocale\n overrideAccess?: boolean\n page?: number\n pagination?: boolean\n req?: PayloadRequest\n select?: TSelect\n showHiddenFields?: boolean\n sort?: Sort\n user?: Document\n where?: Where\n}\n\nexport async function findLocal<\n TSlug extends CollectionSlug,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n>(\n payload: Payload,\n options: Options<TSlug, TSelect>,\n): Promise<PaginatedDocs<TransformCollectionWithSelect<TSlug, TSelect>>> {\n const {\n collection: collectionSlug,\n currentDepth,\n depth,\n disableErrors,\n draft = false,\n includeLockStatus,\n joins,\n limit,\n overrideAccess = true,\n page,\n pagination = true,\n select,\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 Operation.`,\n )\n }\n\n return findOperation<TSlug, TSelect>({\n collection,\n currentDepth,\n depth,\n disableErrors,\n draft,\n includeLockStatus,\n joins,\n limit,\n overrideAccess,\n page,\n pagination,\n req: await createLocalReq(options, payload),\n select,\n showHiddenFields,\n sort,\n where,\n })\n}\n"],"names":["APIError","createLocalReq","findOperation","findLocal","payload","options","collection","collectionSlug","currentDepth","depth","disableErrors","draft","includeLockStatus","joins","limit","overrideAccess","page","pagination","select","showHiddenFields","sort","where","collections","String","req"],"mappings":"AAkBA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,aAAa,QAAQ,aAAY;AA4B1C,OAAO,eAAeC,UAIpBC,OAAgB,EAChBC,OAAgC;IAEhC,MAAM,EACJC,YAAYC,cAAc,EAC1BC,YAAY,EACZC,KAAK,EACLC,aAAa,EACbC,QAAQ,KAAK,EACbC,iBAAiB,EACjBC,KAAK,EACLC,KAAK,EACLC,iBAAiB,IAAI,EACrBC,IAAI,EACJC,aAAa,IAAI,EACjBC,MAAM,EACN,UAAU;IACVC,gBAAgB,EAChBC,IAAI,EACJC,KAAK,EACN,GAAGhB;IAEJ,MAAMC,aAAaF,QAAQkB,WAAW,CAACf,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIN,SACR,CAAC,yBAAyB,EAAEuB,OAAOhB,gBAAgB,gCAAgC,CAAC;IAExF;IAEA,OAAOL,cAA8B;QACnCI;QACAE;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAO,KAAK,MAAMvB,eAAeI,SAASD;QACnCc;QACAC;QACAC;QACAC;IACF;AACF"}
|
|
@@ -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, 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;
|
|
@@ -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,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,CAAA;IACjB,MAAM,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IAC5B,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,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,CAqC5F"}
|
|
@@ -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 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\n locale?: 'all' | TypedLocale\n overrideAccess?: boolean\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 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 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","select","showHiddenFields","collections","String","req"],"mappings":"AAAA,wCAAwC,GAiBxC,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,iBAAiB,QAAQ,iBAAgB;AA4BlD,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,MAAM,EACNC,gBAAgB,EACjB,GAAGZ;IAEJ,MAAME,aAAaH,QAAQc,WAAW,CAACV,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIP,SACR,CAAC,yBAAyB,EAAEmB,OAAOX,gBAAgB,sCAAsC,CAAC;IAE9F;IAEA,OAAON,kBAAkD;QACvDI;QACAC;QACAE;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAK,KAAK,MAAMnB,eAAeI,SAASD;QACnCY;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, 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> = {
|
|
@@ -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,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACnF,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,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,CA+BzD"}
|
|
@@ -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, 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 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 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 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","select","showHiddenFields","collections","String","req"],"mappings":"AAKA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,wBAAwB,QAAQ,wBAAuB;AAqBhE,eAAe,eAAeC,qBAC5BC,OAAgB,EAChBC,OAAuB;IAEvB,MAAM,EACJC,EAAE,EACFC,YAAYC,cAAc,EAC1BC,KAAK,EACLC,gBAAgB,KAAK,EACrBC,iBAAiB,IAAI,EACrBC,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,8CAA8C,CAAC;IAErD;IAEA,OAAON,yBAAyB;QAC9BI;QACAC;QACAE;QACAC;QACAC;QACAK,KAAK,MAAMf,eAAeI,SAASD;QACnCQ;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, 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> = {
|
|
@@ -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,EAAE,QAAQ,EAAE,cAAc,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAChG,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,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,CAiCxE"}
|
|
@@ -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 {
|
|
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 { Document, PayloadRequest, SelectType, Sort, Where } 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 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 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 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","select","showHiddenFields","sort","where","collections","String","req"],"mappings":"AAMA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,qBAAqB,QAAQ,qBAAoB;AAuB1D,eAAe,eAAeC,kBAC5BC,OAAgB,EAChBC,OAAuB;IAEvB,MAAM,EACJC,YAAYC,cAAc,EAC1BC,KAAK,EACLC,KAAK,EACLC,iBAAiB,IAAI,EACrBC,IAAI,EACJC,MAAM,EACNC,gBAAgB,EAChBC,IAAI,EACJC,KAAK,EACN,GAAGV;IAEJ,MAAMC,aAAaF,QAAQY,WAAW,CAACT,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIN,SACR,CAAC,yBAAyB,EAAEiB,OAAOV,gBAAgB,yCAAyC,CAAC;IAEjG;IAEA,OAAOL,sBAAsB;QAC3BI;QACAE;QACAC;QACAC;QACAC;QACAO,KAAK,MAAMjB,eAAeI,SAASD;QACnCQ;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, 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;
|
|
@@ -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,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACnF,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,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,CAgCxC"}
|
|
@@ -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, 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 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 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 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","select","showHiddenFields","collections","String","args","req"],"mappings":"AAIA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,uBAAuB,QAAQ,uBAAsB;AAoB9D,eAAe,eAAeC,oBAC5BC,OAAgB,EAChBC,OAAuB;IAEvB,MAAM,EACJC,EAAE,EACFC,YAAYC,cAAc,EAC1BC,KAAK,EACLC,iBAAiB,IAAI,EACrBC,MAAM,EACNC,gBAAgB,EACjB,GAAGP;IAEJ,MAAME,aAAaH,QAAQS,WAAW,CAACL,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIP,SACR,CAAC,yBAAyB,EAAEc,OAC1BN,gBACA,2CAA2C,CAAC;IAElD;IAEA,MAAMO,OAAO;QACXT;QACAC;QACAE;QACAC;QACAN;QACAY,KAAK,MAAMf,eAAeI,SAASD;QACnCO;QACAC;IACF;IAEA,OAAOV,wBAAwBa;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, 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> = {
|
|
@@ -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,QAAQ,EACR,cAAc,EACd,UAAU,EACV,6BAA6B,EAC7B,KAAK,EACN,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,KAAK,EACV,mBAAmB,EACnB,8BAA8B,EAC9B,wBAAwB,EACzB,MAAM,uBAAuB,CAAA;AAQ9B,MAAM,MAAM,WAAW,CAAC,KAAK,SAAS,cAAc,EAAE,OAAO,SAAS,UAAU,IAAI;IAClF,QAAQ,CAAC,EAAE,OAAO,CAAA;I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AE/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;AAiE/F,eAAe,WAAW,CAAA"}
|
|
@@ -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 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 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 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 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","publishSpecificLocale","select","showHiddenFields","where","collections","String","req","args"],"mappings":"AAiBA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,aAAa,QAAQ,oCAAmC;AACjE,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,eAAe,QAAQ,eAAc;AAC9C,SAASC,mBAAmB,QAAQ,mBAAkB;AAuEtD,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,qBAAqB,EACrBC,MAAM,EACNC,gBAAgB,EAChBC,KAAK,EACN,GAAGlB;IAEJ,MAAMG,aAAaJ,QAAQoB,WAAW,CAACf,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIV,SACR,CAAC,yBAAyB,EAAE2B,OAAOhB,gBAAgB,kCAAkC,CAAC;IAE1F;IAEA,MAAMiB,MAAM,MAAM1B,eAAeK,SAASD;IAC1CsB,IAAIZ,IAAI,GAAGA,QAAS,MAAMf,cAAcgB;IAExC,MAAMY,OAAO;QACXrB;QACAC;QACAC;QACAE;QACAC;QACAC;QACAC;QACAG;QACAC;QACAC;QACAC;QACAf;QACAgB;QACAM;QACAL;QACAC;QACAC;IACF;IAEA,IAAIlB,QAAQC,EAAE,EAAE;QACd,OAAOJ,oBAAoCyB;IAC7C;IACA,OAAO1B,gBAAgC0B;AACzC;AAEA,eAAexB,YAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateSearchParams.d.ts","sourceRoot":"","sources":["../../../src/database/queryValidation/validateSearchParams.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAA;AAClF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;AACzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AAC1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAe,MAAM,YAAY,CAAA;AAQ7D,KAAK,IAAI,GAAG;IACV,gBAAgB,CAAC,EAAE,yBAAyB,CAAA;IAC5C,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IAC1B,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,YAAY,CAAC,EAAE,qBAAqB,CAAA;IACpC,QAAQ,EAAE,MAAM,CAAA;IAChB,cAAc,EAAE,OAAO,CAAA;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,cAAc,CAAA;IACxB,GAAG,EAAE,cAAc,CAAA;IACnB,GAAG,EAAE,OAAO,CAAA;IACZ,aAAa,CAAC,EAAE,KAAK,EAAE,CAAA;CACxB,CAAA;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,EACxC,gBAAgB,EAChB,MAAM,EACN,MAAM,EACN,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,IAAI,EAAE,YAAY,EAClB,QAAQ,EACR,GAAG,EACH,GAAG,EACH,aAAa,GACd,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"validateSearchParams.d.ts","sourceRoot":"","sources":["../../../src/database/queryValidation/validateSearchParams.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAA;AAClF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;AACzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AAC1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAe,MAAM,YAAY,CAAA;AAQ7D,KAAK,IAAI,GAAG;IACV,gBAAgB,CAAC,EAAE,yBAAyB,CAAA;IAC5C,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IAC1B,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,YAAY,CAAC,EAAE,qBAAqB,CAAA;IACpC,QAAQ,EAAE,MAAM,CAAA;IAChB,cAAc,EAAE,OAAO,CAAA;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,cAAc,CAAA;IACxB,GAAG,EAAE,cAAc,CAAA;IACnB,GAAG,EAAE,OAAO,CAAA;IACZ,aAAa,CAAC,EAAE,KAAK,EAAE,CAAA;CACxB,CAAA;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,EACxC,gBAAgB,EAChB,MAAM,EACN,MAAM,EACN,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,IAAI,EAAE,YAAY,EAClB,QAAQ,EACR,GAAG,EACH,GAAG,EACH,aAAa,GACd,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAyJtB"}
|
|
@@ -38,6 +38,13 @@ import { validateQueryPaths } from './validateQueryPaths.js';
|
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
const promises = [];
|
|
41
|
+
// Sanitize relation.otherRelation.id to relation.otherRelation
|
|
42
|
+
if (paths.at(-1)?.path === 'id') {
|
|
43
|
+
const previousField = paths.at(-2)?.field;
|
|
44
|
+
if (previousField && (previousField.type === 'relationship' || previousField.type === 'upload') && typeof previousField.relationTo === 'string') {
|
|
45
|
+
paths.pop();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
41
48
|
promises.push(...paths.map(async ({ collectionSlug, field, invalid, path }, i)=>{
|
|
42
49
|
if (invalid) {
|
|
43
50
|
errors.push({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/database/queryValidation/validateSearchParams.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../collections/config/types.js'\nimport type { Field } from '../../fields/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../globals/config/types.js'\nimport type { PayloadRequest } from '../../types/index.js'\nimport type { EntityPolicies, PathToQuery } from './types.js'\n\nimport { fieldAffectsData, fieldIsVirtual } from '../../fields/config/types.js'\nimport { getEntityPolicies } from '../../utilities/getEntityPolicies.js'\nimport isolateObjectProperty from '../../utilities/isolateObjectProperty.js'\nimport { getLocalizedPaths } from '../getLocalizedPaths.js'\nimport { validateQueryPaths } from './validateQueryPaths.js'\n\ntype Args = {\n collectionConfig?: SanitizedCollectionConfig\n errors: { path: string }[]\n fields: Field[]\n globalConfig?: SanitizedGlobalConfig\n operator: string\n overrideAccess: boolean\n path: string\n policies: EntityPolicies\n req: PayloadRequest\n val: unknown\n versionFields?: Field[]\n}\n\n/**\n * Validate the Payload key / value / operator\n */\nexport async function validateSearchParam({\n collectionConfig,\n errors,\n fields,\n globalConfig,\n operator,\n overrideAccess,\n path: incomingPath,\n policies,\n req,\n val,\n versionFields,\n}: Args): Promise<void> {\n // Replace GraphQL nested field double underscore formatting\n let sanitizedPath\n if (incomingPath === '_id') {\n sanitizedPath = 'id'\n } else {\n sanitizedPath = incomingPath.replace(/__/g, '.')\n }\n let paths: PathToQuery[] = []\n const { slug } = collectionConfig || globalConfig\n\n if (globalConfig && !policies.globals[slug]) {\n globalConfig.fields = fields\n\n policies.globals[slug] = await getEntityPolicies({\n type: 'global',\n entity: globalConfig,\n operations: ['read'],\n req,\n })\n }\n\n if (sanitizedPath !== 'id') {\n paths = await getLocalizedPaths({\n collectionSlug: collectionConfig?.slug,\n fields,\n globalSlug: globalConfig?.slug,\n incomingPath: sanitizedPath,\n locale: req.locale,\n overrideAccess,\n payload: req.payload,\n })\n }\n const promises = []\n promises.push(\n ...paths.map(async ({ collectionSlug, field, invalid, path }, i) => {\n if (invalid) {\n errors.push({ path })\n return\n }\n\n if (fieldIsVirtual(field)) {\n errors.push({ path })\n }\n\n if (!overrideAccess && fieldAffectsData(field)) {\n if (collectionSlug) {\n if (!policies.collections[collectionSlug]) {\n policies.collections[collectionSlug] = await getEntityPolicies({\n type: 'collection',\n entity: req.payload.collections[collectionSlug].config,\n operations: ['read'],\n req: isolateObjectProperty(req, 'transactionID'),\n })\n }\n\n if (\n ['hash', 'salt'].includes(incomingPath) &&\n collectionConfig.auth &&\n !collectionConfig.auth?.disableLocalStrategy\n ) {\n errors.push({ path: incomingPath })\n }\n }\n let fieldPath = path\n // remove locale from end of path\n if (path.endsWith(`.${req.locale}`)) {\n fieldPath = path.slice(0, -(req.locale.length + 1))\n }\n // remove \".value\" from ends of polymorphic relationship paths\n if (\n (field.type === 'relationship' || field.type === 'upload') &&\n Array.isArray(field.relationTo)\n ) {\n fieldPath = fieldPath.replace('.value', '')\n }\n const entityType: 'collections' | 'globals' = globalConfig ? 'globals' : 'collections'\n const entitySlug = collectionSlug || globalConfig.slug\n const segments = fieldPath.split('.')\n\n let fieldAccess\n if (versionFields) {\n fieldAccess = policies[entityType][entitySlug]\n if (segments[0] === 'parent' || segments[0] === 'version') {\n segments.shift()\n }\n } else {\n fieldAccess = policies[entityType][entitySlug].fields\n }\n\n segments.forEach((segment) => {\n if (fieldAccess[segment]) {\n if ('fields' in fieldAccess[segment]) {\n fieldAccess = fieldAccess[segment].fields\n } else if ('blocks' in fieldAccess[segment]) {\n fieldAccess = fieldAccess[segment]\n } else {\n fieldAccess = fieldAccess[segment]\n }\n }\n })\n\n if (!fieldAccess?.read?.permission) {\n errors.push({ path: fieldPath })\n }\n }\n\n if (i > 1) {\n // Remove top collection and reverse array\n // to work backwards from top\n const pathsToQuery = paths.slice(1).reverse()\n\n pathsToQuery.forEach(\n ({ collectionSlug: pathCollectionSlug, path: subPath }, pathToQueryIndex) => {\n // On the \"deepest\" collection,\n // validate query of the relationship\n if (pathToQueryIndex === 0) {\n promises.push(\n validateQueryPaths({\n collectionConfig: req.payload.collections[pathCollectionSlug].config,\n errors,\n globalConfig: undefined,\n overrideAccess,\n policies,\n req,\n where: {\n [subPath]: {\n [operator]: val,\n },\n },\n }),\n )\n }\n },\n )\n }\n }),\n )\n await Promise.all(promises)\n}\n"],"names":["fieldAffectsData","fieldIsVirtual","getEntityPolicies","isolateObjectProperty","getLocalizedPaths","validateQueryPaths","validateSearchParam","collectionConfig","errors","fields","globalConfig","operator","overrideAccess","path","incomingPath","policies","req","val","versionFields","sanitizedPath","replace","paths","slug","globals","type","entity","operations","collectionSlug","globalSlug","locale","payload","promises","push","map","field","invalid","i","collections","config","includes","auth","disableLocalStrategy","fieldPath","endsWith","slice","length","Array","isArray","relationTo","entityType","entitySlug","segments","split","fieldAccess","shift","forEach","segment","read","permission","pathsToQuery","reverse","pathCollectionSlug","subPath","pathToQueryIndex","undefined","where","Promise","all"],"mappings":"AAMA,SAASA,gBAAgB,EAAEC,cAAc,QAAQ,+BAA8B;AAC/E,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,OAAOC,2BAA2B,2CAA0C;AAC5E,SAASC,iBAAiB,QAAQ,0BAAyB;AAC3D,SAASC,kBAAkB,QAAQ,0BAAyB;AAgB5D;;CAEC,GACD,OAAO,eAAeC,oBAAoB,EACxCC,gBAAgB,EAChBC,MAAM,EACNC,MAAM,EACNC,YAAY,EACZC,QAAQ,EACRC,cAAc,EACdC,MAAMC,YAAY,EAClBC,QAAQ,EACRC,GAAG,EACHC,GAAG,EACHC,aAAa,EACR;IACL,4DAA4D;IAC5D,IAAIC;IACJ,IAAIL,iBAAiB,OAAO;QAC1BK,gBAAgB;IAClB,OAAO;QACLA,gBAAgBL,aAAaM,OAAO,CAAC,OAAO;IAC9C;IACA,IAAIC,QAAuB,EAAE;IAC7B,MAAM,EAAEC,IAAI,EAAE,GAAGf,oBAAoBG;IAErC,IAAIA,gBAAgB,CAACK,SAASQ,OAAO,CAACD,KAAK,EAAE;QAC3CZ,aAAaD,MAAM,GAAGA;QAEtBM,SAASQ,OAAO,CAACD,KAAK,GAAG,MAAMpB,kBAAkB;YAC/CsB,MAAM;YAC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E5B,gBAAgBkC,kBAAkB,EAAEhD,MAAMiD,OAAO,EAAE,EAAEC;gBACtD,+BAA+B;gBAC/B,qCAAqC;gBACrC,IAAIA,qBAAqB,GAAG;oBAC1BhC,SAASC,IAAI,CACX3B,mBAAmB;wBACjBE,kBAAkBS,IAAIc,OAAO,CAACO,WAAW,CAACwB,mBAAmB,CAACvB,MAAM;wBACpE9B;wBACAE,cAAcsD;wBACdpD;wBACAG;wBACAC;wBACAiD,OAAO;4BACL,CAACH,QAAQ,EAAE;gCACT,CAACnD,SAAS,EAAEM;4BACd;wBACF;oBACF;gBAEJ;YACF;QAEJ;IACF;IAEF,MAAMiD,QAAQC,GAAG,CAACpC;AACpB"}
|
|
1
|
+
{"version":3,"sources":["../../../src/database/queryValidation/validateSearchParams.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../collections/config/types.js'\nimport type { Field } from '../../fields/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../globals/config/types.js'\nimport type { PayloadRequest } from '../../types/index.js'\nimport type { EntityPolicies, PathToQuery } from './types.js'\n\nimport { fieldAffectsData, fieldIsVirtual } from '../../fields/config/types.js'\nimport { getEntityPolicies } from '../../utilities/getEntityPolicies.js'\nimport isolateObjectProperty from '../../utilities/isolateObjectProperty.js'\nimport { getLocalizedPaths } from '../getLocalizedPaths.js'\nimport { validateQueryPaths } from './validateQueryPaths.js'\n\ntype Args = {\n collectionConfig?: SanitizedCollectionConfig\n errors: { path: string }[]\n fields: Field[]\n globalConfig?: SanitizedGlobalConfig\n operator: string\n overrideAccess: boolean\n path: string\n policies: EntityPolicies\n req: PayloadRequest\n val: unknown\n versionFields?: Field[]\n}\n\n/**\n * Validate the Payload key / value / operator\n */\nexport async function validateSearchParam({\n collectionConfig,\n errors,\n fields,\n globalConfig,\n operator,\n overrideAccess,\n path: incomingPath,\n policies,\n req,\n val,\n versionFields,\n}: Args): Promise<void> {\n // Replace GraphQL nested field double underscore formatting\n let sanitizedPath\n if (incomingPath === '_id') {\n sanitizedPath = 'id'\n } else {\n sanitizedPath = incomingPath.replace(/__/g, '.')\n }\n let paths: PathToQuery[] = []\n const { slug } = collectionConfig || globalConfig\n\n if (globalConfig && !policies.globals[slug]) {\n globalConfig.fields = fields\n\n policies.globals[slug] = await getEntityPolicies({\n type: 'global',\n entity: globalConfig,\n operations: ['read'],\n req,\n })\n }\n\n if (sanitizedPath !== 'id') {\n paths = await getLocalizedPaths({\n collectionSlug: collectionConfig?.slug,\n fields,\n globalSlug: globalConfig?.slug,\n incomingPath: sanitizedPath,\n locale: req.locale,\n overrideAccess,\n payload: req.payload,\n })\n }\n const promises = []\n\n // Sanitize relation.otherRelation.id to relation.otherRelation\n if (paths.at(-1)?.path === 'id') {\n const previousField = paths.at(-2)?.field\n if (\n previousField &&\n (previousField.type === 'relationship' || previousField.type === 'upload') &&\n typeof previousField.relationTo === 'string'\n ) {\n paths.pop()\n }\n }\n\n promises.push(\n ...paths.map(async ({ collectionSlug, field, invalid, path }, i) => {\n if (invalid) {\n errors.push({ path })\n return\n }\n\n if (fieldIsVirtual(field)) {\n errors.push({ path })\n }\n\n if (!overrideAccess && fieldAffectsData(field)) {\n if (collectionSlug) {\n if (!policies.collections[collectionSlug]) {\n policies.collections[collectionSlug] = await getEntityPolicies({\n type: 'collection',\n entity: req.payload.collections[collectionSlug].config,\n operations: ['read'],\n req: isolateObjectProperty(req, 'transactionID'),\n })\n }\n\n if (\n ['hash', 'salt'].includes(incomingPath) &&\n collectionConfig.auth &&\n !collectionConfig.auth?.disableLocalStrategy\n ) {\n errors.push({ path: incomingPath })\n }\n }\n let fieldPath = path\n // remove locale from end of path\n if (path.endsWith(`.${req.locale}`)) {\n fieldPath = path.slice(0, -(req.locale.length + 1))\n }\n // remove \".value\" from ends of polymorphic relationship paths\n if (\n (field.type === 'relationship' || field.type === 'upload') &&\n Array.isArray(field.relationTo)\n ) {\n fieldPath = fieldPath.replace('.value', '')\n }\n\n const entityType: 'collections' | 'globals' = globalConfig ? 'globals' : 'collections'\n const entitySlug = collectionSlug || globalConfig.slug\n const segments = fieldPath.split('.')\n\n let fieldAccess\n if (versionFields) {\n fieldAccess = policies[entityType][entitySlug]\n if (segments[0] === 'parent' || segments[0] === 'version') {\n segments.shift()\n }\n } else {\n fieldAccess = policies[entityType][entitySlug].fields\n }\n\n segments.forEach((segment) => {\n if (fieldAccess[segment]) {\n if ('fields' in fieldAccess[segment]) {\n fieldAccess = fieldAccess[segment].fields\n } else if ('blocks' in fieldAccess[segment]) {\n fieldAccess = fieldAccess[segment]\n } else {\n fieldAccess = fieldAccess[segment]\n }\n }\n })\n\n if (!fieldAccess?.read?.permission) {\n errors.push({ path: fieldPath })\n }\n }\n\n if (i > 1) {\n // Remove top collection and reverse array\n // to work backwards from top\n const pathsToQuery = paths.slice(1).reverse()\n\n pathsToQuery.forEach(\n ({ collectionSlug: pathCollectionSlug, path: subPath }, pathToQueryIndex) => {\n // On the \"deepest\" collection,\n // validate query of the relationship\n if (pathToQueryIndex === 0) {\n promises.push(\n validateQueryPaths({\n collectionConfig: req.payload.collections[pathCollectionSlug].config,\n errors,\n globalConfig: undefined,\n overrideAccess,\n policies,\n req,\n where: {\n [subPath]: {\n [operator]: val,\n },\n },\n }),\n )\n }\n },\n )\n }\n }),\n )\n await Promise.all(promises)\n}\n"],"names":["fieldAffectsData","fieldIsVirtual","getEntityPolicies","isolateObjectProperty","getLocalizedPaths","validateQueryPaths","validateSearchParam","collectionConfig","errors","fields","globalConfig","operator","overrideAccess","path","incomingPath","policies","req","val","versionFields","sanitizedPath","replace","paths","slug","globals","type","entity","operations","collectionSlug","globalSlug","locale","payload","promises","at","previousField","field","relationTo","pop","push","map","invalid","i","collections","config","includes","auth","disableLocalStrategy","fieldPath","endsWith","slice","length","Array","isArray","entityType","entitySlug","segments","split","fieldAccess","shift","forEach","segment","read","permission","pathsToQuery","reverse","pathCollectionSlug","subPath","pathToQueryIndex","undefined","where","Promise","all"],"mappings":"AAMA,SAASA,gBAAgB,EAAEC,cAAc,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AACtB,MAAM;wBACpElC;wBACAE,cAAcyD;wBACdvD;wBACAG;wBACAC;wBACAoD,OAAO;4BACL,CAACH,QAAQ,EAAE;gCACT,CAACtD,SAAS,EAAEM;4BACd;wBACF;oBACF;gBAEJ;YACF;QAEJ;IACF;IAEF,MAAMoD,QAAQC,GAAG,CAACvC;AACpB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { SanitizedCollectionConfig } from '../collections/config/types.js';
|
|
2
|
+
import type { JoinQuery, PayloadRequest } from '../types/index.js';
|
|
3
|
+
type Args = {
|
|
4
|
+
collectionConfig: SanitizedCollectionConfig;
|
|
5
|
+
joins?: JoinQuery;
|
|
6
|
+
overrideAccess: boolean;
|
|
7
|
+
req: PayloadRequest;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* * Validates `where` for each join
|
|
11
|
+
* * Combines the access result for joined collection
|
|
12
|
+
* * Combines the default join's `where`
|
|
13
|
+
*/
|
|
14
|
+
export declare const sanitizeJoinQuery: ({ collectionConfig, joins: joinsQuery, overrideAccess, req, }: Args) => Promise<false | {
|
|
15
|
+
[schemaPath: string]: false | {
|
|
16
|
+
limit?: number;
|
|
17
|
+
sort?: string;
|
|
18
|
+
where?: import("../types/index.js").Where;
|
|
19
|
+
};
|
|
20
|
+
}>;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=sanitizeJoinQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sanitizeJoinQuery.d.ts","sourceRoot":"","sources":["../../src/database/sanitizeJoinQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAC/E,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAOlE,KAAK,IAAI,GAAG;IACV,gBAAgB,EAAE,yBAAyB,CAAA;IAC3C,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,cAAc,EAAE,OAAO,CAAA;IACvB,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,kEAK3B,IAAI;;;;;;EAkEN,CAAA"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import executeAccess from '../auth/executeAccess.js';
|
|
2
|
+
import { QueryError } from '../errors/QueryError.js';
|
|
3
|
+
import { combineQueries } from './combineQueries.js';
|
|
4
|
+
import { validateQueryPaths } from './queryValidation/validateQueryPaths.js';
|
|
5
|
+
/**
|
|
6
|
+
* * Validates `where` for each join
|
|
7
|
+
* * Combines the access result for joined collection
|
|
8
|
+
* * Combines the default join's `where`
|
|
9
|
+
*/ export const sanitizeJoinQuery = async ({ collectionConfig, joins: joinsQuery, overrideAccess, req })=>{
|
|
10
|
+
if (joinsQuery === false) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
if (!joinsQuery) {
|
|
14
|
+
joinsQuery = {};
|
|
15
|
+
}
|
|
16
|
+
const errors = [];
|
|
17
|
+
const promises = [];
|
|
18
|
+
for(const collectionSlug in collectionConfig.joins){
|
|
19
|
+
for (const { field, schemaPath } of collectionConfig.joins[collectionSlug]){
|
|
20
|
+
if (joinsQuery[schemaPath] === false) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
const joinCollectionConfig = req.payload.collections[collectionSlug].config;
|
|
24
|
+
const accessResult = !overrideAccess ? await executeAccess({
|
|
25
|
+
disableErrors: true,
|
|
26
|
+
req
|
|
27
|
+
}, joinCollectionConfig.access.read) : true;
|
|
28
|
+
if (accessResult === false) {
|
|
29
|
+
joinsQuery[schemaPath] = false;
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (!joinsQuery[schemaPath]) {
|
|
33
|
+
joinsQuery[schemaPath] = {};
|
|
34
|
+
}
|
|
35
|
+
const joinQuery = joinsQuery[schemaPath];
|
|
36
|
+
if (!joinQuery.where) {
|
|
37
|
+
joinQuery.where = {};
|
|
38
|
+
}
|
|
39
|
+
if (field.where) {
|
|
40
|
+
joinQuery.where = combineQueries(joinQuery.where, field.where);
|
|
41
|
+
}
|
|
42
|
+
if (typeof accessResult === 'object') {
|
|
43
|
+
joinQuery.where = combineQueries(joinQuery.where, accessResult);
|
|
44
|
+
}
|
|
45
|
+
promises.push(validateQueryPaths({
|
|
46
|
+
collectionConfig: joinCollectionConfig,
|
|
47
|
+
errors,
|
|
48
|
+
overrideAccess,
|
|
49
|
+
req,
|
|
50
|
+
where: joinQuery.where
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
await Promise.all(promises);
|
|
55
|
+
if (errors.length > 0) {
|
|
56
|
+
throw new QueryError(errors);
|
|
57
|
+
}
|
|
58
|
+
return joinsQuery;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=sanitizeJoinQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/database/sanitizeJoinQuery.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../collections/config/types.js'\nimport type { JoinQuery, PayloadRequest } from '../types/index.js'\n\nimport executeAccess from '../auth/executeAccess.js'\nimport { QueryError } from '../errors/QueryError.js'\nimport { combineQueries } from './combineQueries.js'\nimport { validateQueryPaths } from './queryValidation/validateQueryPaths.js'\n\ntype Args = {\n collectionConfig: SanitizedCollectionConfig\n joins?: JoinQuery\n overrideAccess: boolean\n req: PayloadRequest\n}\n\n/**\n * * Validates `where` for each join\n * * Combines the access result for joined collection\n * * Combines the default join's `where`\n */\nexport const sanitizeJoinQuery = async ({\n collectionConfig,\n joins: joinsQuery,\n overrideAccess,\n req,\n}: Args) => {\n if (joinsQuery === false) {\n return false\n }\n\n if (!joinsQuery) {\n joinsQuery = {}\n }\n\n const errors: { path: string }[] = []\n const promises: Promise<void>[] = []\n\n for (const collectionSlug in collectionConfig.joins) {\n for (const { field, schemaPath } of collectionConfig.joins[collectionSlug]) {\n if (joinsQuery[schemaPath] === false) {\n continue\n }\n\n const joinCollectionConfig = req.payload.collections[collectionSlug].config\n\n const accessResult = !overrideAccess\n ? await executeAccess({ disableErrors: true, req }, joinCollectionConfig.access.read)\n : true\n\n if (accessResult === false) {\n joinsQuery[schemaPath] = false\n continue\n }\n\n if (!joinsQuery[schemaPath]) {\n joinsQuery[schemaPath] = {}\n }\n\n const joinQuery = joinsQuery[schemaPath]\n\n if (!joinQuery.where) {\n joinQuery.where = {}\n }\n\n if (field.where) {\n joinQuery.where = combineQueries(joinQuery.where, field.where)\n }\n\n if (typeof accessResult === 'object') {\n joinQuery.where = combineQueries(joinQuery.where, accessResult)\n }\n\n promises.push(\n validateQueryPaths({\n collectionConfig: joinCollectionConfig,\n errors,\n overrideAccess,\n req,\n where: joinQuery.where,\n }),\n )\n }\n }\n\n await Promise.all(promises)\n\n if (errors.length > 0) {\n throw new QueryError(errors)\n }\n\n return joinsQuery\n}\n"],"names":["executeAccess","QueryError","combineQueries","validateQueryPaths","sanitizeJoinQuery","collectionConfig","joins","joinsQuery","overrideAccess","req","errors","promises","collectionSlug","field","schemaPath","joinCollectionConfig","payload","collections","config","accessResult","disableErrors","access","read","joinQuery","where","push","Promise","all","length"],"mappings":"AAGA,OAAOA,mBAAmB,2BAA0B;AACpD,SAASC,UAAU,QAAQ,0BAAyB;AACpD,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,kBAAkB,QAAQ,0CAAyC;AAS5E;;;;CAIC,GACD,OAAO,MAAMC,oBAAoB,OAAO,EACtCC,gBAAgB,EAChBC,OAAOC,UAAU,EACjBC,cAAc,EACdC,GAAG,EACE;IACL,IAAIF,eAAe,OAAO;QACxB,OAAO;IACT;IAEA,IAAI,CAACA,YAAY;QACfA,aAAa,CAAC;IAChB;IAEA,MAAMG,SAA6B,EAAE;IACrC,MAAMC,WAA4B,EAAE;IAEpC,IAAK,MAAMC,kBAAkBP,iBAAiBC,KAAK,CAAE;QACnD,KAAK,MAAM,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