payload 4.0.0-beta.10 → 4.0.0-beta.12
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/forms/Form.d.ts +0 -7
- package/dist/admin/forms/Form.d.ts.map +1 -1
- package/dist/admin/forms/Form.js.map +1 -1
- package/dist/collections/operations/count.d.ts.map +1 -1
- package/dist/collections/operations/count.js +3 -1
- package/dist/collections/operations/count.js.map +1 -1
- package/dist/collections/operations/countVersions.d.ts.map +1 -1
- package/dist/collections/operations/countVersions.js +3 -1
- package/dist/collections/operations/countVersions.js.map +1 -1
- package/dist/collections/operations/delete.d.ts.map +1 -1
- package/dist/collections/operations/delete.js +9 -7
- package/dist/collections/operations/delete.js.map +1 -1
- package/dist/collections/operations/find.d.ts.map +1 -1
- package/dist/collections/operations/find.js +9 -15
- package/dist/collections/operations/find.js.map +1 -1
- package/dist/collections/operations/findDistinct.d.ts.map +1 -1
- package/dist/collections/operations/findDistinct.js +3 -1
- package/dist/collections/operations/findDistinct.js.map +1 -1
- package/dist/collections/operations/findVersions.d.ts.map +1 -1
- package/dist/collections/operations/findVersions.js +10 -8
- package/dist/collections/operations/findVersions.js.map +1 -1
- package/dist/collections/operations/renameFile.d.ts.map +1 -1
- package/dist/collections/operations/renameFile.js +16 -9
- package/dist/collections/operations/renameFile.js.map +1 -1
- package/dist/collections/operations/update.d.ts.map +1 -1
- package/dist/collections/operations/update.js +9 -15
- package/dist/collections/operations/update.js.map +1 -1
- package/dist/database/cloneWhere.d.ts +10 -0
- package/dist/database/cloneWhere.d.ts.map +1 -0
- package/dist/database/cloneWhere.js +31 -0
- package/dist/database/cloneWhere.js.map +1 -0
- package/dist/database/nestedRelationshipReadConstraint.d.ts +20 -0
- package/dist/database/nestedRelationshipReadConstraint.d.ts.map +1 -0
- package/dist/database/nestedRelationshipReadConstraint.js +33 -0
- package/dist/database/nestedRelationshipReadConstraint.js.map +1 -0
- package/dist/database/queryValidation/validateSearchParams.d.ts.map +1 -1
- package/dist/database/queryValidation/validateSearchParams.js +36 -1
- package/dist/database/queryValidation/validateSearchParams.js.map +1 -1
- package/dist/database/queryValidation/validateSortQuery.d.ts.map +1 -1
- package/dist/database/queryValidation/validateSortQuery.js +4 -2
- package/dist/database/queryValidation/validateSortQuery.js.map +1 -1
- package/dist/database/sanitizeJoinQuery.d.ts +2 -2
- package/dist/database/sanitizeJoinQuery.d.ts.map +1 -1
- package/dist/database/sanitizeJoinQuery.js +26 -1
- package/dist/database/sanitizeJoinQuery.js.map +1 -1
- package/dist/exports/internal.d.ts +1 -0
- package/dist/exports/internal.d.ts.map +1 -1
- package/dist/exports/internal.js +1 -0
- package/dist/exports/internal.js.map +1 -1
- package/dist/fields/hooks/beforeChange/index.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/index.js +6 -0
- package/dist/fields/hooks/beforeChange/index.js.map +1 -1
- package/dist/fields/mergeBaseFields.d.ts.map +1 -1
- package/dist/fields/mergeBaseFields.js +24 -0
- package/dist/fields/mergeBaseFields.js.map +1 -1
- package/dist/globals/operations/countGlobalVersions.d.ts.map +1 -1
- package/dist/globals/operations/countGlobalVersions.js +3 -1
- package/dist/globals/operations/countGlobalVersions.js.map +1 -1
- package/dist/globals/operations/findVersions.d.ts.map +1 -1
- package/dist/globals/operations/findVersions.js +10 -8
- package/dist/globals/operations/findVersions.js.map +1 -1
- package/dist/hierarchy/utils/findUseAsTitle.js +11 -11
- package/dist/hierarchy/utils/findUseAsTitle.js.map +1 -1
- package/dist/index.bundled.d.ts +55 -11
- package/dist/uploads/fileVersioning/archive.d.ts.map +1 -1
- package/dist/uploads/fileVersioning/archive.js +5 -13
- package/dist/uploads/fileVersioning/archive.js.map +1 -1
- package/dist/uploads/fileVersioning/cloudStorage.d.ts.map +1 -1
- package/dist/uploads/fileVersioning/cloudStorage.js +6 -7
- package/dist/uploads/fileVersioning/cloudStorage.js.map +1 -1
- package/dist/uploads/fileVersioning/resolveHistoricalFile.d.ts.map +1 -1
- package/dist/uploads/fileVersioning/resolveHistoricalFile.js +48 -48
- package/dist/uploads/fileVersioning/resolveHistoricalFile.js.map +1 -1
- package/dist/uploads/fileVersioning/restore.d.ts.map +1 -1
- package/dist/uploads/fileVersioning/restore.js +7 -9
- package/dist/uploads/fileVersioning/restore.js.map +1 -1
- package/dist/uploads/fileVersioning/restoreRequestTime.d.ts.map +1 -1
- package/dist/uploads/fileVersioning/restoreRequestTime.js +22 -36
- package/dist/uploads/fileVersioning/restoreRequestTime.js.map +1 -1
- package/dist/uploads/fileVersioning/storedFiles.d.ts +39 -8
- package/dist/uploads/fileVersioning/storedFiles.d.ts.map +1 -1
- package/dist/uploads/fileVersioning/storedFiles.js +150 -93
- package/dist/uploads/fileVersioning/storedFiles.js.map +1 -1
- package/dist/uploads/fileVersioning/types.d.ts +13 -1
- package/dist/uploads/fileVersioning/types.d.ts.map +1 -1
- package/dist/uploads/fileVersioning/types.js.map +1 -1
- package/dist/uploads/generateFileData/plan/planUploadStages.d.ts.map +1 -1
- package/dist/uploads/generateFileData/plan/planUploadStages.js +2 -0
- package/dist/uploads/generateFileData/plan/planUploadStages.js.map +1 -1
- package/dist/uploads/getBaseFields.d.ts.map +1 -1
- package/dist/uploads/getBaseFields.js +4 -1
- package/dist/uploads/getBaseFields.js.map +1 -1
- package/dist/uploads/transformState/planUpload.d.ts +4 -1
- package/dist/uploads/transformState/planUpload.d.ts.map +1 -1
- package/dist/uploads/transformState/planUpload.js +52 -2
- package/dist/uploads/transformState/planUpload.js.map +1 -1
- package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
- package/dist/utilities/configToJSONSchema.js +6 -0
- package/dist/utilities/configToJSONSchema.js.map +1 -1
- package/dist/utilities/deepMerge.d.ts +55 -3
- package/dist/utilities/deepMerge.d.ts.map +1 -1
- package/dist/utilities/deepMerge.js +104 -9
- package/dist/utilities/deepMerge.js.map +1 -1
- package/dist/utilities/sanitizeUpdateData.d.ts +5 -0
- package/dist/utilities/sanitizeUpdateData.d.ts.map +1 -0
- package/dist/utilities/sanitizeUpdateData.js +10 -0
- package/dist/utilities/sanitizeUpdateData.js.map +1 -0
- package/package.json +2 -3
|
@@ -63,13 +63,6 @@ export type FieldState = {
|
|
|
63
63
|
fieldSchema?: Field | TabAsField;
|
|
64
64
|
filterOptions?: FilterOptionsResult;
|
|
65
65
|
initialValue?: unknown;
|
|
66
|
-
/**
|
|
67
|
-
* Every time a field is changed locally, this flag is set to true. Prevents form state from server from overwriting local changes.
|
|
68
|
-
* After merging server form state, this flag is reset.
|
|
69
|
-
*
|
|
70
|
-
* @experimental This property is experimental and may change in the future. Use at your own risk.
|
|
71
|
-
*/
|
|
72
|
-
isModified?: boolean;
|
|
73
66
|
/**
|
|
74
67
|
* The path of the field when its custom components were last rendered.
|
|
75
68
|
* This is used to denote if a field has been rendered, and if so,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../src/admin/forms/Form.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAElE,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAA;AACvE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AACvF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAE7E,MAAM,MAAM,IAAI,GAAG;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,GAAG,GAAG;IAChB,aAAa,CAAC,EAAE,UAAU,CAAC,eAAe,CAAC,CAAA;IAC3C,SAAS,CAAC,EAAE,M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9B,GAAG,CACA;IACE,cAAc,EAAE,MAAM,CAAA;IAGtB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,GACD;IACE,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,GACD;IACE,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;CACnB,CACJ,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/admin/forms/Form.ts"],"sourcesContent":["import { type SupportedLanguages } from '@payloadcms/translations'\n\nimport type { SanitizedDocumentPermissions } from '../../auth/types.js'\nimport type { Field, Option, TabAsField, Validate } from '../../fields/config/types.js'\nimport type { TypedLocale } from '../../index.js'\nimport type { DocumentPreferences } from '../../preferences/types.js'\nimport type { PayloadRequest, SelectType, Where } from '../../types/index.js'\n\nexport type Data = {\n [key: string]: any\n}\n\nexport type Row = {\n addedByServer?: FieldState['addedByServer']\n blockType?: string\n collapsed?: boolean\n customComponents?: {\n RowLabel?: React.ReactNode\n }\n id: string\n isLoading?: boolean\n lastRenderedPath?: string\n}\n\nexport type FilterOptionsResult = {\n [relation: string]: boolean | Where\n}\n\nexport type FieldState = {\n /**\n * This is used to determine if the field was added by the server.\n * This ensures the field is not ignored by the client when merging form state.\n * This can happen because the current local state is treated as the source of truth.\n * See `mergeServerFormState` for more details.\n */\n addedByServer?: boolean\n /**\n * If the field is a `blocks` field, this will contain the slugs of blocks that are allowed, based on the result of `field.filterOptions`.\n * If this is undefined, all blocks are allowed.\n * If this is an empty array, no blocks are allowed.\n */\n blocksFilterOptions?: string[]\n customComponents?: {\n /**\n * This is used by UI fields, as they can have arbitrary components defined if used\n * as a vessel to bring in custom components.\n */\n [key: string]: React.ReactNode | React.ReactNode[] | undefined\n AfterInput?: React.ReactNode\n BeforeInput?: React.ReactNode\n Description?: React.ReactNode\n Error?: React.ReactNode\n Field?: React.ReactNode\n Label?: React.ReactNode\n }\n /**\n * Excludes this field's own value when form state is converted to document data, so the value is not submitted with the form.\n * The value remains available in form state.\n * Descendant fields are serialized independently.\n */\n disableFormData?: boolean\n errorMessage?: string\n errorPaths?: string[]\n /**\n * The fieldSchema may be part of the form state if `includeSchema: true` is passed to buildFormState.\n * This will never be in the form state of the client.\n */\n fieldSchema?: Field | TabAsField\n filterOptions?: FilterOptionsResult\n initialValue?: unknown\n /**\n *
|
|
1
|
+
{"version":3,"sources":["../../../src/admin/forms/Form.ts"],"sourcesContent":["import { type SupportedLanguages } from '@payloadcms/translations'\n\nimport type { SanitizedDocumentPermissions } from '../../auth/types.js'\nimport type { Field, Option, TabAsField, Validate } from '../../fields/config/types.js'\nimport type { TypedLocale } from '../../index.js'\nimport type { DocumentPreferences } from '../../preferences/types.js'\nimport type { PayloadRequest, SelectType, Where } from '../../types/index.js'\n\nexport type Data = {\n [key: string]: any\n}\n\nexport type Row = {\n addedByServer?: FieldState['addedByServer']\n blockType?: string\n collapsed?: boolean\n customComponents?: {\n RowLabel?: React.ReactNode\n }\n id: string\n isLoading?: boolean\n lastRenderedPath?: string\n}\n\nexport type FilterOptionsResult = {\n [relation: string]: boolean | Where\n}\n\nexport type FieldState = {\n /**\n * This is used to determine if the field was added by the server.\n * This ensures the field is not ignored by the client when merging form state.\n * This can happen because the current local state is treated as the source of truth.\n * See `mergeServerFormState` for more details.\n */\n addedByServer?: boolean\n /**\n * If the field is a `blocks` field, this will contain the slugs of blocks that are allowed, based on the result of `field.filterOptions`.\n * If this is undefined, all blocks are allowed.\n * If this is an empty array, no blocks are allowed.\n */\n blocksFilterOptions?: string[]\n customComponents?: {\n /**\n * This is used by UI fields, as they can have arbitrary components defined if used\n * as a vessel to bring in custom components.\n */\n [key: string]: React.ReactNode | React.ReactNode[] | undefined\n AfterInput?: React.ReactNode\n BeforeInput?: React.ReactNode\n Description?: React.ReactNode\n Error?: React.ReactNode\n Field?: React.ReactNode\n Label?: React.ReactNode\n }\n /**\n * Excludes this field's own value when form state is converted to document data, so the value is not submitted with the form.\n * The value remains available in form state.\n * Descendant fields are serialized independently.\n */\n disableFormData?: boolean\n errorMessage?: string\n errorPaths?: string[]\n /**\n * The fieldSchema may be part of the form state if `includeSchema: true` is passed to buildFormState.\n * This will never be in the form state of the client.\n */\n fieldSchema?: Field | TabAsField\n filterOptions?: FilterOptionsResult\n initialValue?: unknown\n /**\n * The path of the field when its custom components were last rendered.\n * This is used to denote if a field has been rendered, and if so,\n * what path it was rendered under last.\n *\n * If this path is undefined, or, if it is different\n * from the current path of a given field, the field's components will be re-rendered.\n */\n lastRenderedPath?: string\n passesCondition?: boolean\n rows?: Row[]\n /**\n * The result of running `field.filterOptions` on select fields.\n */\n selectFilterOptions?: Option[]\n valid?: boolean\n validate?: Validate\n value?: unknown\n}\n\nexport type FieldStateWithoutComponents = Omit<FieldState, 'customComponents'>\n\nexport type FormState = {\n [path: string]: FieldState\n}\n\nexport type FormStateWithoutComponents = {\n [path: string]: FieldStateWithoutComponents\n}\n\nexport type BuildFormStateArgs = {\n /**\n * If true, will check if the document has been modified since it was loaded.\n * This helps detect stale data when multiple users are editing the same document.\n */\n checkForStaleData?: boolean\n data?: Data\n docPermissions: SanitizedDocumentPermissions | undefined\n docPreferences: DocumentPreferences\n /**\n * In case `formState` is not the top-level, document form state, this can be passed to\n * provide the top-level form state.\n */\n documentFormState?: FormState\n fallbackLocale?: false | TypedLocale\n formState?: FormState\n id?: number | string\n initialBlockData?: Data\n initialBlockFormState?: FormState\n /*\n If not i18n was passed, the language can be passed to init i18n\n */\n language?: keyof SupportedLanguages\n locale?: string\n /**\n * If true, will not render RSCs and instead return a simple string in their place.\n * This is useful for environments that lack RSC support, such as Jest.\n * Form state can still be built, but any server components will be omitted.\n * @default false\n */\n mockRSCs?: boolean\n operation?: 'create' | 'update'\n /**\n * The original updatedAt timestamp from when the document was initially loaded.\n * Used with checkForStaleData to detect if the document has been modified.\n */\n originalUpdatedAt?: string\n readOnly?: boolean\n /**\n * If true, will render field components within their state object.\n * Performance optimization: Setting to `false` ensures that only fields that have changed paths will re-render, e.g. new array rows, etc.\n * For example, you only need to render ALL fields on initial render, not on every onChange.\n */\n renderAllFields?: boolean\n req: PayloadRequest\n /**\n * If true, will return a fresh URL for live preview based on the current form state.\n * Note: this will run on every form state event, so if your `livePreview.url` function is long running or expensive,\n * ensure it caches itself as needed.\n */\n returnLivePreviewURL?: boolean\n returnLockStatus?: boolean\n /**\n * If true, will return a fresh URL for preview based on the current form state.\n * Note: this will run on every form state event, so if your `preview` function is long running or expensive,\n * ensure it caches itself as needed.\n */\n returnPreviewURL?: boolean\n schemaPath: string\n select?: SelectType\n /**\n * When true, sets `user: true` when calling `getClientConfig`.\n * This will retrieve the client config in its entirety, even when unauthenticated.\n * For example, the create-first-user view needs the entire config, but there is no user yet.\n *\n * @experimental This property is experimental and may change in the future. Use at your own risk.\n */\n skipClientConfigAuth?: boolean\n skipValidation?: boolean\n updateLastEdited?: boolean\n /** The authenticated user after read access for client-facing field components. */\n user?: PayloadRequest['user']\n} & (\n | {\n collectionSlug: string\n // Do not type it as never. This still makes it so that either collectionSlug or globalSlug is required, but makes it easier to provide both collectionSlug and globalSlug if it's\n // unclear which one is actually available.\n globalSlug?: string\n widgetSlug?: string\n }\n | {\n collectionSlug?: string\n globalSlug: string\n widgetSlug?: string\n }\n | {\n collectionSlug?: string\n globalSlug?: string\n widgetSlug: string\n }\n)\n"],"names":[],"mappings":"AAoGA,WA0FC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"count.d.ts","sourceRoot":"","sources":["../../../src/collections/operations/count.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"count.d.ts","sourceRoot":"","sources":["../../../src/collections/operations/count.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAWpD,MAAM,MAAM,SAAS,GAAG;IACtB,UAAU,EAAE,UAAU,CAAA;IACtB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,GAAG,CAAC,EAAE,cAAc,CAAA;IACpB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAA;AAGD,eAAO,MAAM,cAAc,GAAU,KAAK,SAAS,cAAc,gBACjD,SAAS,KACtB,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CA0F/B,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { executeAccess } from '../../auth/executeAccess.js';
|
|
2
|
+
import { cloneWhere } from '../../database/cloneWhere.js';
|
|
2
3
|
import { combineQueries } from '../../database/combineQueries.js';
|
|
3
4
|
import { validateQueryPaths } from '../../database/queryValidation/validateQueryPaths.js';
|
|
4
5
|
import { sanitizeWhereQuery } from '../../database/sanitizeWhereQuery.js';
|
|
@@ -17,7 +18,8 @@ export const countOperation = async (incomingArgs)=>{
|
|
|
17
18
|
operation: 'count',
|
|
18
19
|
overrideAccess: args.overrideAccess
|
|
19
20
|
});
|
|
20
|
-
const { collection: { config: collectionConfig }, disableErrors, overrideAccess, req, trash = false, where } = args;
|
|
21
|
+
const { collection: { config: collectionConfig }, disableErrors, overrideAccess, req, trash = false, where: incomingWhere } = args;
|
|
22
|
+
const where = cloneWhere(incomingWhere);
|
|
21
23
|
const { payload } = req;
|
|
22
24
|
// /////////////////////////////////////
|
|
23
25
|
// Access
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/operations/count.ts"],"sourcesContent":["import type { AccessResult } from '../../config/types.js'\nimport type { CollectionSlug } from '../../index.js'\nimport type { PayloadRequest, Where } from '../../types/index.js'\nimport type { Collection } from '../config/types.js'\n\nimport { executeAccess } from '../../auth/executeAccess.js'\nimport { combineQueries } from '../../database/combineQueries.js'\nimport { validateQueryPaths } from '../../database/queryValidation/validateQueryPaths.js'\nimport { sanitizeWhereQuery } from '../../database/sanitizeWhereQuery.js'\nimport { appendNonTrashedFilter } from '../../utilities/appendNonTrashedFilter.js'\nimport { buildAfterOperation } from './utilities/buildAfterOperation.js'\nimport { buildBeforeOperation } from './utilities/buildBeforeOperation.js'\n\nexport type Arguments = {\n collection: Collection\n disableErrors?: boolean\n overrideAccess?: boolean\n req?: PayloadRequest\n trash?: boolean\n where?: Where\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport const countOperation = async <TSlug extends CollectionSlug>(\n incomingArgs: Arguments,\n): Promise<{ totalDocs: number }> => {\n let args = incomingArgs\n\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n args = await buildBeforeOperation({\n args,\n collection: args.collection.config,\n operation: 'count',\n overrideAccess: args.overrideAccess!,\n })\n\n const {\n collection: { config: collectionConfig },\n disableErrors,\n overrideAccess,\n req,\n trash = false,\n where,\n } = args\n\n const { payload } = req!\n\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n let accessResult: AccessResult\n\n if (!overrideAccess) {\n accessResult = await executeAccess(\n { slug: collectionConfig.slug, disableErrors, req: req! },\n collectionConfig.access.read,\n )\n\n // If errors are disabled, and access returns false, return empty results\n if (accessResult === false) {\n return {\n totalDocs: 0,\n }\n }\n }\n\n let result: { totalDocs: number }\n\n let fullWhere = combineQueries(where!, accessResult!)\n sanitizeWhereQuery({ fields: collectionConfig.flattenedFields, payload, where: fullWhere })\n\n // Exclude trashed documents when trash: false\n fullWhere = appendNonTrashedFilter({\n enableTrash: collectionConfig.trash,\n trash,\n where: fullWhere,\n })\n\n await validateQueryPaths({\n collectionConfig,\n overrideAccess: overrideAccess!,\n req: req!,\n where: where!,\n })\n\n result = await payload.db.count({\n collection: collectionConfig.slug,\n locale: req?.locale || undefined,\n req,\n where: fullWhere,\n })\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n result = await buildAfterOperation({\n args,\n collection: collectionConfig,\n operation: 'count',\n overrideAccess,\n result,\n })\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n return result\n}\n"],"names":["executeAccess","combineQueries","validateQueryPaths","sanitizeWhereQuery","appendNonTrashedFilter","buildAfterOperation","buildBeforeOperation","countOperation","incomingArgs","args","collection","config","operation","overrideAccess","collectionConfig","disableErrors","req","trash","where","payload","accessResult","slug","access","read","totalDocs","result","fullWhere","fields","flattenedFields","enableTrash","db","count","locale","undefined"],"mappings":"AAKA,SAASA,aAAa,QAAQ,8BAA6B;AAC3D,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,kBAAkB,QAAQ,uDAAsD;AACzF,SAASC,kBAAkB,QAAQ,uCAAsC;AACzE,SAASC,sBAAsB,QAAQ,4CAA2C;AAClF,SAASC,mBAAmB,QAAQ,qCAAoC;AACxE,SAASC,oBAAoB,QAAQ,sCAAqC;AAW1E,6DAA6D;AAC7D,OAAO,MAAMC,iBAAiB,OAC5BC;IAEA,IAAIC,OAAOD;IAEX,wCAAwC;IACxC,+BAA+B;IAC/B,wCAAwC;IAExCC,OAAO,MAAMH,qBAAqB;QAChCG;QACAC,YAAYD,KAAKC,UAAU,CAACC,MAAM;QAClCC,WAAW;QACXC,gBAAgBJ,KAAKI,cAAc;IACrC;IAEA,MAAM,EACJH,YAAY,EAAEC,QAAQG,gBAAgB,EAAE,EACxCC,aAAa,EACbF,cAAc,EACdG,GAAG,EACHC,QAAQ,KAAK,EACbC,
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/operations/count.ts"],"sourcesContent":["import type { AccessResult } from '../../config/types.js'\nimport type { CollectionSlug } from '../../index.js'\nimport type { PayloadRequest, Where } from '../../types/index.js'\nimport type { Collection } from '../config/types.js'\n\nimport { executeAccess } from '../../auth/executeAccess.js'\nimport { cloneWhere } from '../../database/cloneWhere.js'\nimport { combineQueries } from '../../database/combineQueries.js'\nimport { validateQueryPaths } from '../../database/queryValidation/validateQueryPaths.js'\nimport { sanitizeWhereQuery } from '../../database/sanitizeWhereQuery.js'\nimport { appendNonTrashedFilter } from '../../utilities/appendNonTrashedFilter.js'\nimport { buildAfterOperation } from './utilities/buildAfterOperation.js'\nimport { buildBeforeOperation } from './utilities/buildBeforeOperation.js'\n\nexport type Arguments = {\n collection: Collection\n disableErrors?: boolean\n overrideAccess?: boolean\n req?: PayloadRequest\n trash?: boolean\n where?: Where\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport const countOperation = async <TSlug extends CollectionSlug>(\n incomingArgs: Arguments,\n): Promise<{ totalDocs: number }> => {\n let args = incomingArgs\n\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n args = await buildBeforeOperation({\n args,\n collection: args.collection.config,\n operation: 'count',\n overrideAccess: args.overrideAccess!,\n })\n\n const {\n collection: { config: collectionConfig },\n disableErrors,\n overrideAccess,\n req,\n trash = false,\n where: incomingWhere,\n } = args\n\n const where = cloneWhere(incomingWhere)\n\n const { payload } = req!\n\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n let accessResult: AccessResult\n\n if (!overrideAccess) {\n accessResult = await executeAccess(\n { slug: collectionConfig.slug, disableErrors, req: req! },\n collectionConfig.access.read,\n )\n\n // If errors are disabled, and access returns false, return empty results\n if (accessResult === false) {\n return {\n totalDocs: 0,\n }\n }\n }\n\n let result: { totalDocs: number }\n\n let fullWhere = combineQueries(where!, accessResult!)\n sanitizeWhereQuery({ fields: collectionConfig.flattenedFields, payload, where: fullWhere })\n\n // Exclude trashed documents when trash: false\n fullWhere = appendNonTrashedFilter({\n enableTrash: collectionConfig.trash,\n trash,\n where: fullWhere,\n })\n\n await validateQueryPaths({\n collectionConfig,\n overrideAccess: overrideAccess!,\n req: req!,\n where: where!,\n })\n\n result = await payload.db.count({\n collection: collectionConfig.slug,\n locale: req?.locale || undefined,\n req,\n where: fullWhere,\n })\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n result = await buildAfterOperation({\n args,\n collection: collectionConfig,\n operation: 'count',\n overrideAccess,\n result,\n })\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n return result\n}\n"],"names":["executeAccess","cloneWhere","combineQueries","validateQueryPaths","sanitizeWhereQuery","appendNonTrashedFilter","buildAfterOperation","buildBeforeOperation","countOperation","incomingArgs","args","collection","config","operation","overrideAccess","collectionConfig","disableErrors","req","trash","where","incomingWhere","payload","accessResult","slug","access","read","totalDocs","result","fullWhere","fields","flattenedFields","enableTrash","db","count","locale","undefined"],"mappings":"AAKA,SAASA,aAAa,QAAQ,8BAA6B;AAC3D,SAASC,UAAU,QAAQ,+BAA8B;AACzD,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,kBAAkB,QAAQ,uDAAsD;AACzF,SAASC,kBAAkB,QAAQ,uCAAsC;AACzE,SAASC,sBAAsB,QAAQ,4CAA2C;AAClF,SAASC,mBAAmB,QAAQ,qCAAoC;AACxE,SAASC,oBAAoB,QAAQ,sCAAqC;AAW1E,6DAA6D;AAC7D,OAAO,MAAMC,iBAAiB,OAC5BC;IAEA,IAAIC,OAAOD;IAEX,wCAAwC;IACxC,+BAA+B;IAC/B,wCAAwC;IAExCC,OAAO,MAAMH,qBAAqB;QAChCG;QACAC,YAAYD,KAAKC,UAAU,CAACC,MAAM;QAClCC,WAAW;QACXC,gBAAgBJ,KAAKI,cAAc;IACrC;IAEA,MAAM,EACJH,YAAY,EAAEC,QAAQG,gBAAgB,EAAE,EACxCC,aAAa,EACbF,cAAc,EACdG,GAAG,EACHC,QAAQ,KAAK,EACbC,OAAOC,aAAa,EACrB,GAAGV;IAEJ,MAAMS,QAAQlB,WAAWmB;IAEzB,MAAM,EAAEC,OAAO,EAAE,GAAGJ;IAEpB,wCAAwC;IACxC,SAAS;IACT,wCAAwC;IAExC,IAAIK;IAEJ,IAAI,CAACR,gBAAgB;QACnBQ,eAAe,MAAMtB,cACnB;YAAEuB,MAAMR,iBAAiBQ,IAAI;YAAEP;YAAeC,KAAKA;QAAK,GACxDF,iBAAiBS,MAAM,CAACC,IAAI;QAG9B,yEAAyE;QACzE,IAAIH,iBAAiB,OAAO;YAC1B,OAAO;gBACLI,WAAW;YACb;QACF;IACF;IAEA,IAAIC;IAEJ,IAAIC,YAAY1B,eAAeiB,OAAQG;IACvClB,mBAAmB;QAAEyB,QAAQd,iBAAiBe,eAAe;QAAET;QAASF,OAAOS;IAAU;IAEzF,8CAA8C;IAC9CA,YAAYvB,uBAAuB;QACjC0B,aAAahB,iBAAiBG,KAAK;QACnCA;QACAC,OAAOS;IACT;IAEA,MAAMzB,mBAAmB;QACvBY;QACAD,gBAAgBA;QAChBG,KAAKA;QACLE,OAAOA;IACT;IAEAQ,SAAS,MAAMN,QAAQW,EAAE,CAACC,KAAK,CAAC;QAC9BtB,YAAYI,iBAAiBQ,IAAI;QACjCW,QAAQjB,KAAKiB,UAAUC;QACvBlB;QACAE,OAAOS;IACT;IAEA,wCAAwC;IACxC,8BAA8B;IAC9B,wCAAwC;IAExCD,SAAS,MAAMrB,oBAAoB;QACjCI;QACAC,YAAYI;QACZF,WAAW;QACXC;QACAa;IACF;IAEA,wCAAwC;IACxC,iBAAiB;IACjB,wCAAwC;IAExC,OAAOA;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"countVersions.d.ts","sourceRoot":"","sources":["../../../src/collections/operations/countVersions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"countVersions.d.ts","sourceRoot":"","sources":["../../../src/collections/operations/countVersions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAOpD,OAAO,EAAgC,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAIlF,MAAM,MAAM,SAAS,GAAG;IACtB,UAAU,EAAE,UAAU,CAAA;IACtB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,GAAG,CAAC,EAAE,cAAc,CAAA;IACpB,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAA;AAGD,eAAO,MAAM,sBAAsB,GAAU,KAAK,SAAS,cAAc,gBACzD,SAAS,KACtB,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CAsF/B,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { executeAccess } from '../../auth/executeAccess.js';
|
|
2
|
+
import { cloneWhere } from '../../database/cloneWhere.js';
|
|
2
3
|
import { combineQueries } from '../../database/combineQueries.js';
|
|
3
4
|
import { validateQueryPaths } from '../../database/queryValidation/validateQueryPaths.js';
|
|
4
5
|
import { sanitizeWhereQuery } from '../../database/sanitizeWhereQuery.js';
|
|
@@ -17,7 +18,8 @@ export const countVersionsOperation = async (incomingArgs)=>{
|
|
|
17
18
|
operation: 'countVersions',
|
|
18
19
|
overrideAccess: args.overrideAccess
|
|
19
20
|
});
|
|
20
|
-
const { collection: { config: collectionConfig }, disableErrors, overrideAccess, req, where } = args;
|
|
21
|
+
const { collection: { config: collectionConfig }, disableErrors, overrideAccess, req, where: incomingWhere } = args;
|
|
22
|
+
const where = cloneWhere(incomingWhere);
|
|
21
23
|
const { locale, payload } = req;
|
|
22
24
|
// /////////////////////////////////////
|
|
23
25
|
// Access
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/operations/countVersions.ts"],"sourcesContent":["import type { AccessResult } from '../../config/types.js'\nimport type { PayloadRequest, Where } from '../../types/index.js'\nimport type { Collection } from '../config/types.js'\n\nimport { executeAccess } from '../../auth/executeAccess.js'\nimport { combineQueries } from '../../database/combineQueries.js'\nimport { validateQueryPaths } from '../../database/queryValidation/validateQueryPaths.js'\nimport { sanitizeWhereQuery } from '../../database/sanitizeWhereQuery.js'\nimport { buildVersionCollectionFields, type CollectionSlug } from '../../index.js'\nimport { buildAfterOperation } from './utilities/buildAfterOperation.js'\nimport { buildBeforeOperation } from './utilities/buildBeforeOperation.js'\n\nexport type Arguments = {\n collection: Collection\n disableErrors?: boolean\n overrideAccess?: boolean\n req?: PayloadRequest\n where?: Where\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport const countVersionsOperation = async <TSlug extends CollectionSlug>(\n incomingArgs: Arguments,\n): Promise<{ totalDocs: number }> => {\n let args = incomingArgs\n\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n args = await buildBeforeOperation({\n args,\n collection: args.collection.config,\n operation: 'countVersions',\n overrideAccess: args.overrideAccess!,\n })\n\n const {\n collection: { config: collectionConfig },\n disableErrors,\n overrideAccess,\n req,\n where,\n } = args\n\n const { locale, payload } = req!\n\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n let accessResult: AccessResult\n\n if (!overrideAccess) {\n accessResult = await executeAccess(\n { slug: collectionConfig.slug, disableErrors, req: req! },\n collectionConfig.access.readVersions,\n )\n\n // If errors are disabled, and access returns false, return empty results\n if (accessResult === false) {\n return {\n totalDocs: 0,\n }\n }\n }\n\n let result: { totalDocs: number }\n\n const fullWhere = combineQueries(where!, accessResult!)\n\n const versionFields = buildVersionCollectionFields(payload.config, collectionConfig, true)\n\n sanitizeWhereQuery({ fields: versionFields, payload, where: fullWhere })\n\n await validateQueryPaths({\n collectionConfig,\n overrideAccess: overrideAccess!,\n req: req!,\n versionFields,\n where: where!,\n })\n\n result = await payload.db.countVersions({\n collection: collectionConfig.slug,\n locale: locale!,\n req,\n where: fullWhere,\n })\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n result = await buildAfterOperation({\n args,\n collection: collectionConfig,\n operation: 'countVersions',\n overrideAccess,\n result,\n })\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n return result\n}\n"],"names":["executeAccess","combineQueries","validateQueryPaths","sanitizeWhereQuery","buildVersionCollectionFields","buildAfterOperation","buildBeforeOperation","countVersionsOperation","incomingArgs","args","collection","config","operation","overrideAccess","collectionConfig","disableErrors","req","where","locale","payload","accessResult","slug","access","readVersions","totalDocs","result","fullWhere","versionFields","fields","db","countVersions"],"mappings":"AAIA,SAASA,aAAa,QAAQ,8BAA6B;AAC3D,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,kBAAkB,QAAQ,uDAAsD;AACzF,SAASC,kBAAkB,QAAQ,uCAAsC;AACzE,SAASC,4BAA4B,QAA6B,iBAAgB;AAClF,SAASC,mBAAmB,QAAQ,qCAAoC;AACxE,SAASC,oBAAoB,QAAQ,sCAAqC;AAU1E,6DAA6D;AAC7D,OAAO,MAAMC,yBAAyB,OACpCC;IAEA,IAAIC,OAAOD;IAEX,wCAAwC;IACxC,+BAA+B;IAC/B,wCAAwC;IAExCC,OAAO,MAAMH,qBAAqB;QAChCG;QACAC,YAAYD,KAAKC,UAAU,CAACC,MAAM;QAClCC,WAAW;QACXC,gBAAgBJ,KAAKI,cAAc;IACrC;IAEA,MAAM,EACJH,YAAY,EAAEC,QAAQG,gBAAgB,EAAE,EACxCC,aAAa,EACbF,cAAc,EACdG,GAAG,EACHC,
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/operations/countVersions.ts"],"sourcesContent":["import type { AccessResult } from '../../config/types.js'\nimport type { PayloadRequest, Where } from '../../types/index.js'\nimport type { Collection } from '../config/types.js'\n\nimport { executeAccess } from '../../auth/executeAccess.js'\nimport { cloneWhere } from '../../database/cloneWhere.js'\nimport { combineQueries } from '../../database/combineQueries.js'\nimport { validateQueryPaths } from '../../database/queryValidation/validateQueryPaths.js'\nimport { sanitizeWhereQuery } from '../../database/sanitizeWhereQuery.js'\nimport { buildVersionCollectionFields, type CollectionSlug } from '../../index.js'\nimport { buildAfterOperation } from './utilities/buildAfterOperation.js'\nimport { buildBeforeOperation } from './utilities/buildBeforeOperation.js'\n\nexport type Arguments = {\n collection: Collection\n disableErrors?: boolean\n overrideAccess?: boolean\n req?: PayloadRequest\n where?: Where\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport const countVersionsOperation = async <TSlug extends CollectionSlug>(\n incomingArgs: Arguments,\n): Promise<{ totalDocs: number }> => {\n let args = incomingArgs\n\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n args = await buildBeforeOperation({\n args,\n collection: args.collection.config,\n operation: 'countVersions',\n overrideAccess: args.overrideAccess!,\n })\n\n const {\n collection: { config: collectionConfig },\n disableErrors,\n overrideAccess,\n req,\n where: incomingWhere,\n } = args\n\n const where = cloneWhere(incomingWhere)\n\n const { locale, payload } = req!\n\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n let accessResult: AccessResult\n\n if (!overrideAccess) {\n accessResult = await executeAccess(\n { slug: collectionConfig.slug, disableErrors, req: req! },\n collectionConfig.access.readVersions,\n )\n\n // If errors are disabled, and access returns false, return empty results\n if (accessResult === false) {\n return {\n totalDocs: 0,\n }\n }\n }\n\n let result: { totalDocs: number }\n\n const fullWhere = combineQueries(where!, accessResult!)\n\n const versionFields = buildVersionCollectionFields(payload.config, collectionConfig, true)\n\n sanitizeWhereQuery({ fields: versionFields, payload, where: fullWhere })\n\n await validateQueryPaths({\n collectionConfig,\n overrideAccess: overrideAccess!,\n req: req!,\n versionFields,\n where: where!,\n })\n\n result = await payload.db.countVersions({\n collection: collectionConfig.slug,\n locale: locale!,\n req,\n where: fullWhere,\n })\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n result = await buildAfterOperation({\n args,\n collection: collectionConfig,\n operation: 'countVersions',\n overrideAccess,\n result,\n })\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n return result\n}\n"],"names":["executeAccess","cloneWhere","combineQueries","validateQueryPaths","sanitizeWhereQuery","buildVersionCollectionFields","buildAfterOperation","buildBeforeOperation","countVersionsOperation","incomingArgs","args","collection","config","operation","overrideAccess","collectionConfig","disableErrors","req","where","incomingWhere","locale","payload","accessResult","slug","access","readVersions","totalDocs","result","fullWhere","versionFields","fields","db","countVersions"],"mappings":"AAIA,SAASA,aAAa,QAAQ,8BAA6B;AAC3D,SAASC,UAAU,QAAQ,+BAA8B;AACzD,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,kBAAkB,QAAQ,uDAAsD;AACzF,SAASC,kBAAkB,QAAQ,uCAAsC;AACzE,SAASC,4BAA4B,QAA6B,iBAAgB;AAClF,SAASC,mBAAmB,QAAQ,qCAAoC;AACxE,SAASC,oBAAoB,QAAQ,sCAAqC;AAU1E,6DAA6D;AAC7D,OAAO,MAAMC,yBAAyB,OACpCC;IAEA,IAAIC,OAAOD;IAEX,wCAAwC;IACxC,+BAA+B;IAC/B,wCAAwC;IAExCC,OAAO,MAAMH,qBAAqB;QAChCG;QACAC,YAAYD,KAAKC,UAAU,CAACC,MAAM;QAClCC,WAAW;QACXC,gBAAgBJ,KAAKI,cAAc;IACrC;IAEA,MAAM,EACJH,YAAY,EAAEC,QAAQG,gBAAgB,EAAE,EACxCC,aAAa,EACbF,cAAc,EACdG,GAAG,EACHC,OAAOC,aAAa,EACrB,GAAGT;IAEJ,MAAMQ,QAAQjB,WAAWkB;IAEzB,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAE,GAAGJ;IAE5B,wCAAwC;IACxC,SAAS;IACT,wCAAwC;IAExC,IAAIK;IAEJ,IAAI,CAACR,gBAAgB;QACnBQ,eAAe,MAAMtB,cACnB;YAAEuB,MAAMR,iBAAiBQ,IAAI;YAAEP;YAAeC,KAAKA;QAAK,GACxDF,iBAAiBS,MAAM,CAACC,YAAY;QAGtC,yEAAyE;QACzE,IAAIH,iBAAiB,OAAO;YAC1B,OAAO;gBACLI,WAAW;YACb;QACF;IACF;IAEA,IAAIC;IAEJ,MAAMC,YAAY1B,eAAegB,OAAQI;IAEzC,MAAMO,gBAAgBxB,6BAA6BgB,QAAQT,MAAM,EAAEG,kBAAkB;IAErFX,mBAAmB;QAAE0B,QAAQD;QAAeR;QAASH,OAAOU;IAAU;IAEtE,MAAMzB,mBAAmB;QACvBY;QACAD,gBAAgBA;QAChBG,KAAKA;QACLY;QACAX,OAAOA;IACT;IAEAS,SAAS,MAAMN,QAAQU,EAAE,CAACC,aAAa,CAAC;QACtCrB,YAAYI,iBAAiBQ,IAAI;QACjCH,QAAQA;QACRH;QACAC,OAAOU;IACT;IAEA,wCAAwC;IACxC,8BAA8B;IAC9B,wCAAwC;IAExCD,SAAS,MAAMrB,oBAAoB;QACjCI;QACAC,YAAYI;QACZF,WAAW;QACXC;QACAa;IACF;IAEA,wCAAwC;IACxC,iBAAiB;IACjB,wCAAwC;IAExC,OAAOA;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../src/collections/operations/delete.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAE3F,OAAO,KAAK,EACV,mBAAmB,EACnB,UAAU,EAEV,wBAAwB,EACzB,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../src/collections/operations/delete.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAE3F,OAAO,KAAK,EACV,mBAAmB,EACnB,UAAU,EAEV,wBAAwB,EACzB,MAAM,oBAAoB,CAAA;AAyC3B,MAAM,MAAM,SAAS,GAAG;IACtB,UAAU,EAAE,UAAU,CAAA;IACtB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,GAAG,EAAE,cAAc,CAAA;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,KAAK,EAAE,KAAK,CAAA;CACb,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,QAAQ,CAAC,CAAA;AAEnD,eAAO,MAAM,eAAe,GAC1B,KAAK,SAAS,cAAc,EAC5B,OAAO,SAAS,wBAAwB,CAAC,KAAK,CAAC,gBAEjC,SAAS,KACtB,OAAO,CAAC,mBAAmB,CAAC,KAAK,EAAE,OAAO,CAAC,CAsgB7C,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { executeAccess } from '../../auth/executeAccess.js';
|
|
2
|
+
import { cloneWhere } from '../../database/cloneWhere.js';
|
|
2
3
|
import { combineQueries } from '../../database/combineQueries.js';
|
|
3
4
|
import { validateQueryPaths } from '../../database/queryValidation/validateQueryPaths.js';
|
|
4
5
|
import { sanitizeWhereQuery } from '../../database/sanitizeWhereQuery.js';
|
|
@@ -47,7 +48,8 @@ export const deleteOperation = async (incomingArgs)=>{
|
|
|
47
48
|
operation: 'delete',
|
|
48
49
|
overrideAccess: args.overrideAccess
|
|
49
50
|
});
|
|
50
|
-
const { collection: { config: collectionConfig }, depth, overrideAccess, overrideLock, populate, req: { fallbackLocale, locale, payload: { config }, payload }, req, select: incomingSelect, showHiddenFields, trash = false, where } = args;
|
|
51
|
+
const { collection: { config: collectionConfig }, depth, overrideAccess, overrideLock, populate, req: { fallbackLocale, locale, payload: { config }, payload }, req, select: incomingSelect, showHiddenFields, trash = false, where: incomingWhere } = args;
|
|
52
|
+
const where = cloneWhere(incomingWhere);
|
|
51
53
|
if (!where) {
|
|
52
54
|
throw new APIError("Missing 'where' query of documents to delete.", httpStatus.BAD_REQUEST);
|
|
53
55
|
}
|
|
@@ -61,12 +63,6 @@ export const deleteOperation = async (incomingArgs)=>{
|
|
|
61
63
|
req
|
|
62
64
|
}, collectionConfig.access.delete);
|
|
63
65
|
}
|
|
64
|
-
await validateQueryPaths({
|
|
65
|
-
collectionConfig,
|
|
66
|
-
overrideAccess: overrideAccess,
|
|
67
|
-
req,
|
|
68
|
-
where
|
|
69
|
-
});
|
|
70
66
|
let fullWhere = combineQueries(where, accessResult);
|
|
71
67
|
// Exclude trashed documents when trash: false
|
|
72
68
|
fullWhere = appendNonTrashedFilter({
|
|
@@ -79,6 +75,12 @@ export const deleteOperation = async (incomingArgs)=>{
|
|
|
79
75
|
payload,
|
|
80
76
|
where: fullWhere
|
|
81
77
|
});
|
|
78
|
+
await validateQueryPaths({
|
|
79
|
+
collectionConfig,
|
|
80
|
+
overrideAccess: overrideAccess,
|
|
81
|
+
req,
|
|
82
|
+
where
|
|
83
|
+
});
|
|
82
84
|
const select = sanitizeSelect({
|
|
83
85
|
fields: collectionConfig.flattenedFields,
|
|
84
86
|
select: resolveSelect({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/operations/delete.ts"],"sourcesContent":["import type { AccessResult } from '../../config/types.js'\nimport type { CollectionSlug, FindOptions } from '../../index.js'\nimport type { PayloadRequest, PopulateType, SelectType, Where } from '../../types/index.js'\nimport type { StoredFileList } from '../../uploads/fileVersioning/types.js'\nimport type {\n BulkOperationResult,\n Collection,\n DataFromCollectionSlug,\n SelectFromCollectionSlug,\n} from '../config/types.js'\n\nimport { executeAccess } from '../../auth/executeAccess.js'\nimport { combineQueries } from '../../database/combineQueries.js'\nimport { validateQueryPaths } from '../../database/queryValidation/validateQueryPaths.js'\nimport { sanitizeWhereQuery } from '../../database/sanitizeWhereQuery.js'\nimport { APIError, Locked } from '../../errors/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { deleteUserPreferences } from '../../preferences/deleteUserPreferences.js'\nimport { deleteAssociatedFiles } from '../../uploads/deleteAssociatedFiles.js'\nimport {\n collectStoredFiles,\n collectVersionFiles,\n scheduleUnreferencedFileCleanup,\n} from '../../uploads/fileVersioning/cleanup.js'\nimport {\n abortFileOperationScope,\n beginFileOperationScope,\n completeFileOperationScope,\n} from '../../uploads/fileVersioning/fileOperationManager.js'\nimport { appendNonTrashedFilter } from '../../utilities/appendNonTrashedFilter.js'\nimport { assertNoValidationWrite } from '../../utilities/assertNoValidationWrite.js'\nimport {\n checkDocumentLockStatus,\n deleteDocumentLocks,\n getLockedDocumentIds,\n} from '../../utilities/checkDocumentLockStatus.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { hasScheduledPublishEnabled } from '../../utilities/getVersionsConfig.js'\nimport { httpStatus } from '../../utilities/httpStatus.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { isErrorPublic } from '../../utilities/isErrorPublic.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { resolveSelect } from '../../utilities/resolveSelect.js'\nimport { sanitizeSelect } from '../../utilities/sanitizeSelect.js'\nimport { deleteCollectionVersions } from '../../versions/deleteCollectionVersions.js'\nimport { deleteScheduledPublishJobs } from '../../versions/deleteScheduledPublishJobs.js'\nimport { buildAfterOperation } from './utilities/buildAfterOperation.js'\nimport { buildBeforeOperation } from './utilities/buildBeforeOperation.js'\n\nexport type Arguments = {\n collection: Collection\n depth?: number\n disableTransaction?: boolean\n overrideAccess?: boolean\n overrideLock?: boolean\n populate?: PopulateType\n req: PayloadRequest\n showHiddenFields?: boolean\n trash?: boolean\n where: Where\n} & Pick<FindOptions<string, SelectType>, 'select'>\n\nexport const deleteOperation = async <\n TSlug extends CollectionSlug,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n>(\n incomingArgs: Arguments,\n): Promise<BulkOperationResult<TSlug, TSelect>> => {\n let args = incomingArgs\n\n assertNoValidationWrite(args.req)\n\n if (args.collection.config.disableBulkDelete && !args.overrideAccess) {\n throw new APIError(`Collection ${args.collection.config.slug} has disabled bulk delete`, 403)\n }\n\n const hasFileOperationScope =\n Boolean(args.collection.config.upload) && !args.req.payload.db.bulkOperationsSingleTransaction\n const markedManagedDeletes = new Set<string>()\n\n if (hasFileOperationScope) {\n beginFileOperationScope({ req: args.req })\n }\n\n try {\n const shouldCommit =\n !args.disableTransaction &&\n !args.req.payload.db.bulkOperationsSingleTransaction &&\n (await initTransaction(args.req))\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n args = await buildBeforeOperation({\n args,\n collection: args.collection.config,\n operation: 'delete',\n overrideAccess: args.overrideAccess!,\n })\n\n const {\n collection: { config: collectionConfig },\n depth,\n overrideAccess,\n overrideLock,\n populate,\n req: {\n fallbackLocale,\n locale,\n payload: { config },\n payload,\n },\n req,\n select: incomingSelect,\n showHiddenFields,\n trash = false,\n where,\n } = args\n\n if (!where) {\n throw new APIError(\"Missing 'where' query of documents to delete.\", httpStatus.BAD_REQUEST)\n }\n\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n let accessResult: AccessResult\n\n if (!overrideAccess) {\n accessResult = await executeAccess(\n { slug: collectionConfig.slug, req },\n collectionConfig.access.delete,\n )\n }\n\n await validateQueryPaths({\n collectionConfig,\n overrideAccess: overrideAccess!,\n req,\n where,\n })\n\n let fullWhere = combineQueries(where, accessResult!)\n\n // Exclude trashed documents when trash: false\n fullWhere = appendNonTrashedFilter({\n enableTrash: collectionConfig.trash,\n trash,\n where: fullWhere,\n })\n\n sanitizeWhereQuery({ fields: collectionConfig.flattenedFields, payload, where: fullWhere })\n\n const select = sanitizeSelect({\n fields: collectionConfig.flattenedFields,\n select: resolveSelect({\n config: collectionConfig.select,\n operation: 'delete',\n req,\n select: incomingSelect,\n }),\n })\n\n // /////////////////////////////////////\n // Retrieve documents\n // /////////////////////////////////////\n\n const { docs } = await payload.db.find<DataFromCollectionSlug<TSlug>>({\n collection: collectionConfig.slug,\n locale: locale!,\n req,\n // File cleanup needs every stored representation even when the response selects only an ID.\n select: collectionConfig.upload ? undefined : select,\n where: fullWhere,\n })\n\n const errors: BulkOperationResult<TSlug, TSelect>['errors'] = []\n let didBatchDeleteFail = false\n const deletedFilesByID = new Map<number | string, StoredFileList>()\n req.context ??= {}\n const managedDeletedUploads = (req.context._payloadManagedDeletedUploads ??=\n new Set()) as Set<string>\n\n type Doc = DataFromCollectionSlug<TSlug>\n type ResultDoc = BulkOperationResult<TSlug, TSelect>['docs'][number]\n\n const pushError = (id: number | string, error: unknown, message?: string) => {\n errors.push({\n id,\n isPublic: error instanceof Error ? isErrorPublic(error, config) : false,\n message: message ?? (error instanceof Error ? error.message : 'Unknown error'),\n })\n }\n\n // /////////////////////////////////////\n // beforeDelete - Collection, and associated files\n // /////////////////////////////////////\n\n const runBeforeDeleteWork = async (doc: Doc) => {\n if (collectionConfig.hooks?.beforeDelete?.length) {\n for (const hook of collectionConfig.hooks.beforeDelete) {\n await hook({\n id: doc.id,\n collection: collectionConfig,\n context: req.context,\n req,\n })\n }\n }\n\n if (collectionConfig.upload) {\n deletedFilesByID.set(doc.id, [\n ...(await collectStoredFiles({ collection: collectionConfig, doc, req })),\n ...(collectionConfig.versions\n ? await collectVersionFiles({ collection: collectionConfig, parentID: doc.id, req })\n : []),\n ])\n if (deletedFilesByID.get(doc.id)?.length) {\n const identity = JSON.stringify([collectionConfig.slug, String(doc.id)])\n managedDeletedUploads.add(identity)\n markedManagedDeletes.add(identity)\n }\n }\n\n await deleteAssociatedFiles({\n collectionConfig,\n config,\n doc,\n overrideDelete: true,\n req,\n })\n }\n\n // /////////////////////////////////////\n // afterRead - Fields, afterRead - Collection, afterDelete - Collection\n // /////////////////////////////////////\n\n const runAfterDeleteWork = async (doc: Doc): Promise<ResultDoc> => {\n let result = await afterRead({\n collection: collectionConfig,\n context: req.context,\n depth: depth!,\n doc,\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n draft: undefined,\n fallbackLocale: fallbackLocale!,\n global: null,\n locale: locale!,\n overrideAccess: overrideAccess!,\n populate,\n req,\n select,\n showHiddenFields: showHiddenFields!,\n })\n\n // Add collection property for auth collections\n if (collectionConfig.auth) {\n result = { ...result, collection: collectionConfig.slug }\n }\n\n if (collectionConfig.hooks?.afterRead?.length) {\n for (const hook of collectionConfig.hooks.afterRead) {\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: result || doc,\n overrideAccess,\n req,\n })) || result\n }\n }\n\n if (collectionConfig.hooks?.afterDelete?.length) {\n for (const hook of collectionConfig.hooks.afterDelete) {\n result =\n (await hook({\n id: doc.id,\n collection: collectionConfig,\n context: req.context,\n doc: result,\n req,\n })) || result\n }\n }\n\n return result as ResultDoc\n }\n\n /**\n * One transaction and one set of database calls per document. Only used when\n * `bulkOperationsSingleTransaction` is enabled, which requires each document to be committed\n * on its own and therefore cannot share a batched write with the rest of the operation.\n */\n const deleteDocumentIndividually = async (doc: Doc): Promise<null | ResultDoc> => {\n const hasIndividualFileScope = Boolean(collectionConfig.upload)\n\n if (hasIndividualFileScope) {\n beginFileOperationScope({ req })\n }\n\n try {\n const docShouldCommit = await initTransaction(req)\n\n await checkDocumentLockStatus({\n id: doc.id,\n collectionSlug: collectionConfig.slug,\n lockErrorMessage: `Document with ID ${doc.id} is currently locked and cannot be deleted.`,\n overrideLock,\n req,\n })\n\n await runBeforeDeleteWork(doc)\n\n if (collectionConfig.versions) {\n await deleteCollectionVersions({\n id: doc.id,\n slug: collectionConfig.slug,\n payload,\n req,\n })\n }\n\n if (hasScheduledPublishEnabled(collectionConfig)) {\n await deleteScheduledPublishJobs({\n id: doc.id,\n slug: collectionConfig.slug,\n payload,\n req,\n })\n }\n\n await payload.db.deleteOne({\n collection: collectionConfig.slug,\n req,\n returning: false,\n where: {\n id: {\n equals: doc.id,\n },\n },\n })\n\n if (collectionConfig.upload) {\n await scheduleUnreferencedFileCleanup({\n candidates: deletedFilesByID.get(doc.id) ?? [],\n collection: collectionConfig,\n req,\n })\n }\n\n const result = await runAfterDeleteWork(doc)\n\n if (docShouldCommit) {\n await commitTransaction(req)\n }\n\n if (hasIndividualFileScope) {\n await completeFileOperationScope({ req })\n }\n\n return result\n } catch (error) {\n await killTransaction(req)\n if (hasIndividualFileScope) {\n await abortFileOperationScope({ req })\n }\n pushError(doc.id, error)\n\n return null\n }\n }\n\n /**\n * Deletes the whole batch using a constant number of database calls, independent of how many\n * documents matched. Hooks still run per document, they just no longer each carry a write.\n */\n const deleteDocumentsInBulk = async (): Promise<(null | ResultDoc)[]> => {\n const results: (null | ResultDoc)[] = new Array(docs.length).fill(null)\n\n // /////////////////////////////////////\n // Handle potentially locked documents\n // /////////////////////////////////////\n\n const lockedIds = await getLockedDocumentIds({\n collectionSlug: collectionConfig.slug,\n ids: docs.map(({ id }) => id),\n overrideLock,\n req,\n })\n\n const unlocked: { doc: Doc; index: number }[] = []\n\n docs.forEach((doc, index) => {\n if (lockedIds.has(String(doc.id))) {\n pushError(\n doc.id,\n new Locked(`Document with ID ${doc.id} is currently locked and cannot be deleted.`),\n )\n\n return\n }\n\n unlocked.push({ doc, index })\n })\n\n await deleteDocumentLocks({\n collectionSlug: collectionConfig.slug,\n ids: unlocked.map(({ doc }) => doc.id),\n req,\n })\n\n const deletable: { doc: Doc; index: number }[] = []\n\n await Promise.all(\n unlocked.map(async (entry) => {\n try {\n await runBeforeDeleteWork(entry.doc)\n deletable.push(entry)\n } catch (error) {\n pushError(entry.doc.id, error)\n }\n }),\n )\n\n if (!deletable.length) {\n return results\n }\n\n const ids = deletable.map(({ doc }) => doc.id)\n\n // /////////////////////////////////////\n // Delete versions\n // /////////////////////////////////////\n\n if (collectionConfig.versions) {\n await deleteCollectionVersions({\n slug: collectionConfig.slug,\n ids,\n payload,\n req,\n })\n }\n\n // /////////////////////////////////////\n // Delete scheduled posts\n // /////////////////////////////////////\n\n if (hasScheduledPublishEnabled(collectionConfig)) {\n await deleteScheduledPublishJobs({\n slug: collectionConfig.slug,\n ids,\n payload,\n req,\n })\n }\n\n // /////////////////////////////////////\n // Delete documents\n // /////////////////////////////////////\n\n try {\n await payload.db.deleteMany({\n collection: collectionConfig.slug,\n req,\n where: {\n id: {\n in: ids,\n },\n },\n })\n } catch (error) {\n didBatchDeleteFail = true\n\n if (shouldCommit) {\n await killTransaction(req)\n }\n\n // The delete covers the whole batch, so a failure here belongs to the batch rather than to\n // any single document. Say so explicitly, otherwise one batch failure reads as N unrelated\n // per-document failures.\n const message = `Bulk delete failed for this batch of ${deletable.length} documents: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`\n\n for (const { doc } of deletable) {\n pushError(doc.id, error, message)\n }\n\n return results\n }\n\n if (collectionConfig.upload) {\n await scheduleUnreferencedFileCleanup({\n candidates: deletable.flatMap(({ doc }) => deletedFilesByID.get(doc.id) ?? []),\n collection: collectionConfig,\n req,\n })\n }\n\n await Promise.all(\n deletable.map(async (entry) => {\n try {\n results[entry.index] = await runAfterDeleteWork(entry.doc)\n } catch (error) {\n pushError(entry.doc.id, error)\n }\n }),\n )\n\n return results\n }\n\n let awaitedDocs: (null | ResultDoc)[]\n\n if (req.payload.db.bulkOperationsSingleTransaction) {\n // Process sequentially so that each document's transaction is isolated from the next\n awaitedDocs = []\n\n for (const doc of docs) {\n awaitedDocs.push(await deleteDocumentIndividually(doc))\n }\n } else {\n awaitedDocs = await deleteDocumentsInBulk()\n }\n\n // /////////////////////////////////////\n // Delete Preferences\n // /////////////////////////////////////\n\n if (!didBatchDeleteFail) {\n await deleteUserPreferences({\n collectionConfig,\n ids: docs.map(({ id }) => id),\n payload,\n req,\n })\n }\n\n let result = {\n docs: awaitedDocs.filter((doc): doc is ResultDoc => Boolean(doc)),\n errors,\n }\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n result = await buildAfterOperation({\n args,\n collection: collectionConfig,\n operation: 'delete',\n overrideAccess,\n result,\n })\n\n if (shouldCommit && !didBatchDeleteFail) {\n await commitTransaction(req)\n }\n\n if (hasFileOperationScope) {\n await completeFileOperationScope({ req })\n }\n\n return result\n } catch (error: unknown) {\n await killTransaction(args.req)\n if (hasFileOperationScope) {\n await abortFileOperationScope({ req: args.req })\n }\n throw error\n } finally {\n const managedDeletedUploads = args.req.context?._payloadManagedDeletedUploads as\n | Set<string>\n | undefined\n for (const identity of markedManagedDeletes) {\n managedDeletedUploads?.delete(identity)\n }\n if (managedDeletedUploads?.size === 0) {\n delete args.req.context._payloadManagedDeletedUploads\n }\n }\n}\n"],"names":["executeAccess","combineQueries","validateQueryPaths","sanitizeWhereQuery","APIError","Locked","afterRead","deleteUserPreferences","deleteAssociatedFiles","collectStoredFiles","collectVersionFiles","scheduleUnreferencedFileCleanup","abortFileOperationScope","beginFileOperationScope","completeFileOperationScope","appendNonTrashedFilter","assertNoValidationWrite","checkDocumentLockStatus","deleteDocumentLocks","getLockedDocumentIds","commitTransaction","hasScheduledPublishEnabled","httpStatus","initTransaction","isErrorPublic","killTransaction","resolveSelect","sanitizeSelect","deleteCollectionVersions","deleteScheduledPublishJobs","buildAfterOperation","buildBeforeOperation","deleteOperation","incomingArgs","args","req","collection","config","disableBulkDelete","overrideAccess","slug","hasFileOperationScope","Boolean","upload","payload","db","bulkOperationsSingleTransaction","markedManagedDeletes","Set","shouldCommit","disableTransaction","operation","collectionConfig","depth","overrideLock","populate","fallbackLocale","locale","select","incomingSelect","showHiddenFields","trash","where","BAD_REQUEST","accessResult","access","delete","fullWhere","enableTrash","fields","flattenedFields","docs","find","undefined","errors","didBatchDeleteFail","deletedFilesByID","Map","context","managedDeletedUploads","_payloadManagedDeletedUploads","pushError","id","error","message","push","isPublic","Error","runBeforeDeleteWork","doc","hooks","beforeDelete","length","hook","set","versions","parentID","get","identity","JSON","stringify","String","add","overrideDelete","runAfterDeleteWork","result","draft","global","auth","afterDelete","deleteDocumentIndividually","hasIndividualFileScope","docShouldCommit","collectionSlug","lockErrorMessage","deleteOne","returning","equals","candidates","deleteDocumentsInBulk","results","Array","fill","lockedIds","ids","map","unlocked","forEach","index","has","deletable","Promise","all","entry","deleteMany","in","flatMap","awaitedDocs","filter","size"],"mappings":"AAWA,SAASA,aAAa,QAAQ,8BAA6B;AAC3D,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,kBAAkB,QAAQ,uDAAsD;AACzF,SAASC,kBAAkB,QAAQ,uCAAsC;AACzE,SAASC,QAAQ,EAAEC,MAAM,QAAQ,wBAAuB;AACxD,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,qBAAqB,QAAQ,6CAA4C;AAClF,SAASC,qBAAqB,QAAQ,yCAAwC;AAC9E,SACEC,kBAAkB,EAClBC,mBAAmB,EACnBC,+BAA+B,QAC1B,0CAAyC;AAChD,SACEC,uBAAuB,EACvBC,uBAAuB,EACvBC,0BAA0B,QACrB,uDAAsD;AAC7D,SAASC,sBAAsB,QAAQ,4CAA2C;AAClF,SAASC,uBAAuB,QAAQ,6CAA4C;AACpF,SACEC,uBAAuB,EACvBC,mBAAmB,EACnBC,oBAAoB,QACf,6CAA4C;AACnD,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,0BAA0B,QAAQ,uCAA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,uBAAuB;YACzB,MAAM7B,wBAAwB;gBAAEuB,KAAKD,KAAKC,GAAG;YAAC;QAChD;QACA,MAAMgD;IACR,SAAU;QACR,MAAMJ,wBAAwB7C,KAAKC,GAAG,CAAC2C,OAAO,EAAEE;QAGhD,KAAK,MAAMkB,YAAYnD,qBAAsB;YAC3CgC,uBAAuBb,OAAOgC;QAChC;QACA,IAAInB,uBAAuB4D,SAAS,GAAG;YACrC,OAAOzG,KAAKC,GAAG,CAAC2C,OAAO,CAACE,6BAA6B;QACvD;IACF;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/operations/delete.ts"],"sourcesContent":["import type { AccessResult } from '../../config/types.js'\nimport type { CollectionSlug, FindOptions } from '../../index.js'\nimport type { PayloadRequest, PopulateType, SelectType, Where } from '../../types/index.js'\nimport type { StoredFileList } from '../../uploads/fileVersioning/types.js'\nimport type {\n BulkOperationResult,\n Collection,\n DataFromCollectionSlug,\n SelectFromCollectionSlug,\n} from '../config/types.js'\n\nimport { executeAccess } from '../../auth/executeAccess.js'\nimport { cloneWhere } from '../../database/cloneWhere.js'\nimport { combineQueries } from '../../database/combineQueries.js'\nimport { validateQueryPaths } from '../../database/queryValidation/validateQueryPaths.js'\nimport { sanitizeWhereQuery } from '../../database/sanitizeWhereQuery.js'\nimport { APIError, Locked } from '../../errors/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { deleteUserPreferences } from '../../preferences/deleteUserPreferences.js'\nimport { deleteAssociatedFiles } from '../../uploads/deleteAssociatedFiles.js'\nimport {\n collectStoredFiles,\n collectVersionFiles,\n scheduleUnreferencedFileCleanup,\n} from '../../uploads/fileVersioning/cleanup.js'\nimport {\n abortFileOperationScope,\n beginFileOperationScope,\n completeFileOperationScope,\n} from '../../uploads/fileVersioning/fileOperationManager.js'\nimport { appendNonTrashedFilter } from '../../utilities/appendNonTrashedFilter.js'\nimport { assertNoValidationWrite } from '../../utilities/assertNoValidationWrite.js'\nimport {\n checkDocumentLockStatus,\n deleteDocumentLocks,\n getLockedDocumentIds,\n} from '../../utilities/checkDocumentLockStatus.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { hasScheduledPublishEnabled } from '../../utilities/getVersionsConfig.js'\nimport { httpStatus } from '../../utilities/httpStatus.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { isErrorPublic } from '../../utilities/isErrorPublic.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { resolveSelect } from '../../utilities/resolveSelect.js'\nimport { sanitizeSelect } from '../../utilities/sanitizeSelect.js'\nimport { deleteCollectionVersions } from '../../versions/deleteCollectionVersions.js'\nimport { deleteScheduledPublishJobs } from '../../versions/deleteScheduledPublishJobs.js'\nimport { buildAfterOperation } from './utilities/buildAfterOperation.js'\nimport { buildBeforeOperation } from './utilities/buildBeforeOperation.js'\n\nexport type Arguments = {\n collection: Collection\n depth?: number\n disableTransaction?: boolean\n overrideAccess?: boolean\n overrideLock?: boolean\n populate?: PopulateType\n req: PayloadRequest\n showHiddenFields?: boolean\n trash?: boolean\n where: Where\n} & Pick<FindOptions<string, SelectType>, 'select'>\n\nexport const deleteOperation = async <\n TSlug extends CollectionSlug,\n TSelect extends SelectFromCollectionSlug<TSlug>,\n>(\n incomingArgs: Arguments,\n): Promise<BulkOperationResult<TSlug, TSelect>> => {\n let args = incomingArgs\n\n assertNoValidationWrite(args.req)\n\n if (args.collection.config.disableBulkDelete && !args.overrideAccess) {\n throw new APIError(`Collection ${args.collection.config.slug} has disabled bulk delete`, 403)\n }\n\n const hasFileOperationScope =\n Boolean(args.collection.config.upload) && !args.req.payload.db.bulkOperationsSingleTransaction\n const markedManagedDeletes = new Set<string>()\n\n if (hasFileOperationScope) {\n beginFileOperationScope({ req: args.req })\n }\n\n try {\n const shouldCommit =\n !args.disableTransaction &&\n !args.req.payload.db.bulkOperationsSingleTransaction &&\n (await initTransaction(args.req))\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n args = await buildBeforeOperation({\n args,\n collection: args.collection.config,\n operation: 'delete',\n overrideAccess: args.overrideAccess!,\n })\n\n const {\n collection: { config: collectionConfig },\n depth,\n overrideAccess,\n overrideLock,\n populate,\n req: {\n fallbackLocale,\n locale,\n payload: { config },\n payload,\n },\n req,\n select: incomingSelect,\n showHiddenFields,\n trash = false,\n where: incomingWhere,\n } = args\n\n const where = cloneWhere(incomingWhere)\n\n if (!where) {\n throw new APIError(\"Missing 'where' query of documents to delete.\", httpStatus.BAD_REQUEST)\n }\n\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n let accessResult: AccessResult\n\n if (!overrideAccess) {\n accessResult = await executeAccess(\n { slug: collectionConfig.slug, req },\n collectionConfig.access.delete,\n )\n }\n\n let fullWhere = combineQueries(where, accessResult!)\n\n // Exclude trashed documents when trash: false\n fullWhere = appendNonTrashedFilter({\n enableTrash: collectionConfig.trash,\n trash,\n where: fullWhere,\n })\n\n sanitizeWhereQuery({ fields: collectionConfig.flattenedFields, payload, where: fullWhere })\n\n await validateQueryPaths({\n collectionConfig,\n overrideAccess: overrideAccess!,\n req,\n where,\n })\n\n const select = sanitizeSelect({\n fields: collectionConfig.flattenedFields,\n select: resolveSelect({\n config: collectionConfig.select,\n operation: 'delete',\n req,\n select: incomingSelect,\n }),\n })\n\n // /////////////////////////////////////\n // Retrieve documents\n // /////////////////////////////////////\n\n const { docs } = await payload.db.find<DataFromCollectionSlug<TSlug>>({\n collection: collectionConfig.slug,\n locale: locale!,\n req,\n // File cleanup needs every stored representation even when the response selects only an ID.\n select: collectionConfig.upload ? undefined : select,\n where: fullWhere,\n })\n\n const errors: BulkOperationResult<TSlug, TSelect>['errors'] = []\n let didBatchDeleteFail = false\n const deletedFilesByID = new Map<number | string, StoredFileList>()\n req.context ??= {}\n const managedDeletedUploads = (req.context._payloadManagedDeletedUploads ??=\n new Set()) as Set<string>\n\n type Doc = DataFromCollectionSlug<TSlug>\n type ResultDoc = BulkOperationResult<TSlug, TSelect>['docs'][number]\n\n const pushError = (id: number | string, error: unknown, message?: string) => {\n errors.push({\n id,\n isPublic: error instanceof Error ? isErrorPublic(error, config) : false,\n message: message ?? (error instanceof Error ? error.message : 'Unknown error'),\n })\n }\n\n // /////////////////////////////////////\n // beforeDelete - Collection, and associated files\n // /////////////////////////////////////\n\n const runBeforeDeleteWork = async (doc: Doc) => {\n if (collectionConfig.hooks?.beforeDelete?.length) {\n for (const hook of collectionConfig.hooks.beforeDelete) {\n await hook({\n id: doc.id,\n collection: collectionConfig,\n context: req.context,\n req,\n })\n }\n }\n\n if (collectionConfig.upload) {\n deletedFilesByID.set(doc.id, [\n ...(await collectStoredFiles({ collection: collectionConfig, doc, req })),\n ...(collectionConfig.versions\n ? await collectVersionFiles({ collection: collectionConfig, parentID: doc.id, req })\n : []),\n ])\n if (deletedFilesByID.get(doc.id)?.length) {\n const identity = JSON.stringify([collectionConfig.slug, String(doc.id)])\n managedDeletedUploads.add(identity)\n markedManagedDeletes.add(identity)\n }\n }\n\n await deleteAssociatedFiles({\n collectionConfig,\n config,\n doc,\n overrideDelete: true,\n req,\n })\n }\n\n // /////////////////////////////////////\n // afterRead - Fields, afterRead - Collection, afterDelete - Collection\n // /////////////////////////////////////\n\n const runAfterDeleteWork = async (doc: Doc): Promise<ResultDoc> => {\n let result = await afterRead({\n collection: collectionConfig,\n context: req.context,\n depth: depth!,\n doc,\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n draft: undefined,\n fallbackLocale: fallbackLocale!,\n global: null,\n locale: locale!,\n overrideAccess: overrideAccess!,\n populate,\n req,\n select,\n showHiddenFields: showHiddenFields!,\n })\n\n // Add collection property for auth collections\n if (collectionConfig.auth) {\n result = { ...result, collection: collectionConfig.slug }\n }\n\n if (collectionConfig.hooks?.afterRead?.length) {\n for (const hook of collectionConfig.hooks.afterRead) {\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: result || doc,\n overrideAccess,\n req,\n })) || result\n }\n }\n\n if (collectionConfig.hooks?.afterDelete?.length) {\n for (const hook of collectionConfig.hooks.afterDelete) {\n result =\n (await hook({\n id: doc.id,\n collection: collectionConfig,\n context: req.context,\n doc: result,\n req,\n })) || result\n }\n }\n\n return result as ResultDoc\n }\n\n /**\n * One transaction and one set of database calls per document. Only used when\n * `bulkOperationsSingleTransaction` is enabled, which requires each document to be committed\n * on its own and therefore cannot share a batched write with the rest of the operation.\n */\n const deleteDocumentIndividually = async (doc: Doc): Promise<null | ResultDoc> => {\n const hasIndividualFileScope = Boolean(collectionConfig.upload)\n\n if (hasIndividualFileScope) {\n beginFileOperationScope({ req })\n }\n\n try {\n const docShouldCommit = await initTransaction(req)\n\n await checkDocumentLockStatus({\n id: doc.id,\n collectionSlug: collectionConfig.slug,\n lockErrorMessage: `Document with ID ${doc.id} is currently locked and cannot be deleted.`,\n overrideLock,\n req,\n })\n\n await runBeforeDeleteWork(doc)\n\n if (collectionConfig.versions) {\n await deleteCollectionVersions({\n id: doc.id,\n slug: collectionConfig.slug,\n payload,\n req,\n })\n }\n\n if (hasScheduledPublishEnabled(collectionConfig)) {\n await deleteScheduledPublishJobs({\n id: doc.id,\n slug: collectionConfig.slug,\n payload,\n req,\n })\n }\n\n await payload.db.deleteOne({\n collection: collectionConfig.slug,\n req,\n returning: false,\n where: {\n id: {\n equals: doc.id,\n },\n },\n })\n\n if (collectionConfig.upload) {\n await scheduleUnreferencedFileCleanup({\n candidates: deletedFilesByID.get(doc.id) ?? [],\n collection: collectionConfig,\n req,\n })\n }\n\n const result = await runAfterDeleteWork(doc)\n\n if (docShouldCommit) {\n await commitTransaction(req)\n }\n\n if (hasIndividualFileScope) {\n await completeFileOperationScope({ req })\n }\n\n return result\n } catch (error) {\n await killTransaction(req)\n if (hasIndividualFileScope) {\n await abortFileOperationScope({ req })\n }\n pushError(doc.id, error)\n\n return null\n }\n }\n\n /**\n * Deletes the whole batch using a constant number of database calls, independent of how many\n * documents matched. Hooks still run per document, they just no longer each carry a write.\n */\n const deleteDocumentsInBulk = async (): Promise<(null | ResultDoc)[]> => {\n const results: (null | ResultDoc)[] = new Array(docs.length).fill(null)\n\n // /////////////////////////////////////\n // Handle potentially locked documents\n // /////////////////////////////////////\n\n const lockedIds = await getLockedDocumentIds({\n collectionSlug: collectionConfig.slug,\n ids: docs.map(({ id }) => id),\n overrideLock,\n req,\n })\n\n const unlocked: { doc: Doc; index: number }[] = []\n\n docs.forEach((doc, index) => {\n if (lockedIds.has(String(doc.id))) {\n pushError(\n doc.id,\n new Locked(`Document with ID ${doc.id} is currently locked and cannot be deleted.`),\n )\n\n return\n }\n\n unlocked.push({ doc, index })\n })\n\n await deleteDocumentLocks({\n collectionSlug: collectionConfig.slug,\n ids: unlocked.map(({ doc }) => doc.id),\n req,\n })\n\n const deletable: { doc: Doc; index: number }[] = []\n\n await Promise.all(\n unlocked.map(async (entry) => {\n try {\n await runBeforeDeleteWork(entry.doc)\n deletable.push(entry)\n } catch (error) {\n pushError(entry.doc.id, error)\n }\n }),\n )\n\n if (!deletable.length) {\n return results\n }\n\n const ids = deletable.map(({ doc }) => doc.id)\n\n // /////////////////////////////////////\n // Delete versions\n // /////////////////////////////////////\n\n if (collectionConfig.versions) {\n await deleteCollectionVersions({\n slug: collectionConfig.slug,\n ids,\n payload,\n req,\n })\n }\n\n // /////////////////////////////////////\n // Delete scheduled posts\n // /////////////////////////////////////\n\n if (hasScheduledPublishEnabled(collectionConfig)) {\n await deleteScheduledPublishJobs({\n slug: collectionConfig.slug,\n ids,\n payload,\n req,\n })\n }\n\n // /////////////////////////////////////\n // Delete documents\n // /////////////////////////////////////\n\n try {\n await payload.db.deleteMany({\n collection: collectionConfig.slug,\n req,\n where: {\n id: {\n in: ids,\n },\n },\n })\n } catch (error) {\n didBatchDeleteFail = true\n\n if (shouldCommit) {\n await killTransaction(req)\n }\n\n // The delete covers the whole batch, so a failure here belongs to the batch rather than to\n // any single document. Say so explicitly, otherwise one batch failure reads as N unrelated\n // per-document failures.\n const message = `Bulk delete failed for this batch of ${deletable.length} documents: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`\n\n for (const { doc } of deletable) {\n pushError(doc.id, error, message)\n }\n\n return results\n }\n\n if (collectionConfig.upload) {\n await scheduleUnreferencedFileCleanup({\n candidates: deletable.flatMap(({ doc }) => deletedFilesByID.get(doc.id) ?? []),\n collection: collectionConfig,\n req,\n })\n }\n\n await Promise.all(\n deletable.map(async (entry) => {\n try {\n results[entry.index] = await runAfterDeleteWork(entry.doc)\n } catch (error) {\n pushError(entry.doc.id, error)\n }\n }),\n )\n\n return results\n }\n\n let awaitedDocs: (null | ResultDoc)[]\n\n if (req.payload.db.bulkOperationsSingleTransaction) {\n // Process sequentially so that each document's transaction is isolated from the next\n awaitedDocs = []\n\n for (const doc of docs) {\n awaitedDocs.push(await deleteDocumentIndividually(doc))\n }\n } else {\n awaitedDocs = await deleteDocumentsInBulk()\n }\n\n // /////////////////////////////////////\n // Delete Preferences\n // /////////////////////////////////////\n\n if (!didBatchDeleteFail) {\n await deleteUserPreferences({\n collectionConfig,\n ids: docs.map(({ id }) => id),\n payload,\n req,\n })\n }\n\n let result = {\n docs: awaitedDocs.filter((doc): doc is ResultDoc => Boolean(doc)),\n errors,\n }\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n result = await buildAfterOperation({\n args,\n collection: collectionConfig,\n operation: 'delete',\n overrideAccess,\n result,\n })\n\n if (shouldCommit && !didBatchDeleteFail) {\n await commitTransaction(req)\n }\n\n if (hasFileOperationScope) {\n await completeFileOperationScope({ req })\n }\n\n return result\n } catch (error: unknown) {\n await killTransaction(args.req)\n if (hasFileOperationScope) {\n await abortFileOperationScope({ req: args.req })\n }\n throw error\n } finally {\n const managedDeletedUploads = args.req.context?._payloadManagedDeletedUploads as\n | Set<string>\n | undefined\n for (const identity of markedManagedDeletes) {\n managedDeletedUploads?.delete(identity)\n }\n if (managedDeletedUploads?.size === 0) {\n delete args.req.context._payloadManagedDeletedUploads\n }\n }\n}\n"],"names":["executeAccess","cloneWhere","combineQueries","validateQueryPaths","sanitizeWhereQuery","APIError","Locked","afterRead","deleteUserPreferences","deleteAssociatedFiles","collectStoredFiles","collectVersionFiles","scheduleUnreferencedFileCleanup","abortFileOperationScope","beginFileOperationScope","completeFileOperationScope","appendNonTrashedFilter","assertNoValidationWrite","checkDocumentLockStatus","deleteDocumentLocks","getLockedDocumentIds","commitTransaction","hasScheduledPublishEnabled","httpStatus","initTransaction","isErrorPublic","killTransaction","resolveSelect","sanitizeSelect","deleteCollectionVersions","deleteScheduledPublishJobs","buildAfterOperation","buildBeforeOperation","deleteOperation","incomingArgs","args","req","collection","config","disableBulkDelete","overrideAccess","slug","hasFileOperationScope","Boolean","upload","payload","db","bulkOperationsSingleTransaction","markedManagedDeletes","Set","shouldCommit","disableTransaction","operation","collectionConfig","depth","overrideLock","populate","fallbackLocale","locale","select","incomingSelect","showHiddenFields","trash","where","incomingWhere","BAD_REQUEST","accessResult","access","delete","fullWhere","enableTrash","fields","flattenedFields","docs","find","undefined","errors","didBatchDeleteFail","deletedFilesByID","Map","context","managedDeletedUploads","_payloadManagedDeletedUploads","pushError","id","error","message","push","isPublic","Error","runBeforeDeleteWork","doc","hooks","beforeDelete","length","hook","set","versions","parentID","get","identity","JSON","stringify","String","add","overrideDelete","runAfterDeleteWork","result","draft","global","auth","afterDelete","deleteDocumentIndividually","hasIndividualFileScope","docShouldCommit","collectionSlug","lockErrorMessage","deleteOne","returning","equals","candidates","deleteDocumentsInBulk","results","Array","fill","lockedIds","ids","map","unlocked","forEach","index","has","deletable","Promise","all","entry","deleteMany","in","flatMap","awaitedDocs","filter","size"],"mappings":"AAWA,SAASA,aAAa,QAAQ,8BAA6B;AAC3D,SAASC,UAAU,QAAQ,+BAA8B;AACzD,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,kBAAkB,QAAQ,uDAAsD;AACzF,SAASC,kBAAkB,QAAQ,uCAAsC;AACzE,SAASC,QAAQ,EAAEC,MAAM,QA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3C,EAAE,EAAE,GAAKA;gBAC1BvC;gBACAT;YACF;QACF;QAEA,IAAIuE,SAAS;YACXlC,MAAMkE,YAAYC,MAAM,CAAC,CAACjD,MAA0BhD,QAAQgD;YAC5Df;QACF;QAEA,wCAAwC;QACxC,8BAA8B;QAC9B,wCAAwC;QAExC+B,SAAS,MAAM5E,oBAAoB;YACjCI;YACAE,YAAYgB;YACZD,WAAW;YACXZ;YACAmE;QACF;QAEA,IAAIzD,gBAAgB,CAAC2B,oBAAoB;YACvC,MAAMxD,kBAAkBe;QAC1B;QAEA,IAAIM,uBAAuB;YACzB,MAAM3B,2BAA2B;gBAAEqB;YAAI;QACzC;QAEA,OAAOuE;IACT,EAAE,OAAOtB,OAAgB;QACvB,MAAM3D,gBAAgBS,KAAKC,GAAG;QAC9B,IAAIM,uBAAuB;YACzB,MAAM7B,wBAAwB;gBAAEuB,KAAKD,KAAKC,GAAG;YAAC;QAChD;QACA,MAAMiD;IACR,SAAU;QACR,MAAMJ,wBAAwB9C,KAAKC,GAAG,CAAC4C,OAAO,EAAEE;QAGhD,KAAK,MAAMkB,YAAYpD,qBAAsB;YAC3CiC,uBAAuBb,OAAOgC;QAChC;QACA,IAAInB,uBAAuB4D,SAAS,GAAG;YACrC,OAAO1G,KAAKC,GAAG,CAAC4C,OAAO,CAACE,6BAA6B;QACvD;IACF;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../src/collections/operations/find.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC5E,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,UAAU,EACV,IAAI,EACJ,6BAA6B,EAC7B,KAAK,EACN,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EACV,UAA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AI,EACJ,6BAA6B,EAC7B,KAAK,EACN,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EACV,UAAU,EAEV,wBAAwB,EACzB,MAAM,oBAAoB,CAAA;AAsB3B,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,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,GAAG,CAAC,EAAE,cAAc,CAAA;IACpB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,QAAQ,CAAC,CAAA;AAInD,eAAO,MAAM,aAAa,GACxB,KAAK,SAAS,cAAc,EAC5B,OAAO,SAAS,wBAAwB,CAAC,KAAK,CAAC,gBAEjC,SAAS,KACtB,OAAO,CAAC,aAAa,CAAC,6BAA6B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAuUtE,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { executeAccess } from '../../auth/executeAccess.js';
|
|
2
|
+
import { cloneWhere } from '../../database/cloneWhere.js';
|
|
2
3
|
import { combineQueries } from '../../database/combineQueries.js';
|
|
3
4
|
import { validateQueryPaths } from '../../database/queryValidation/validateQueryPaths.js';
|
|
4
5
|
import { validateSortQuery } from '../../database/queryValidation/validateSortQuery.js';
|
|
@@ -10,7 +11,6 @@ import { appendNonTrashedFilter } from '../../utilities/appendNonTrashedFilter.j
|
|
|
10
11
|
import { hasDraftsEnabled } from '../../utilities/getVersionsConfig.js';
|
|
11
12
|
import { resolveSelect } from '../../utilities/resolveSelect.js';
|
|
12
13
|
import { sanitizeSelect } from '../../utilities/sanitizeSelect.js';
|
|
13
|
-
import { buildVersionCollectionFields } from '../../versions/buildCollectionFields.js';
|
|
14
14
|
import { appendVersionToQueryKey } from '../../versions/drafts/appendVersionToQueryKey.js';
|
|
15
15
|
import { getQueryDraftsSelect } from '../../versions/drafts/getQueryDraftsSelect.js';
|
|
16
16
|
import { getQueryDraftsSort } from '../../versions/drafts/getQueryDraftsSort.js';
|
|
@@ -30,7 +30,8 @@ export const findOperation = async (incomingArgs)=>{
|
|
|
30
30
|
operation: 'read',
|
|
31
31
|
overrideAccess: args.overrideAccess
|
|
32
32
|
});
|
|
33
|
-
const { collection: { config: collectionConfig }, collection, currentDepth, depth, disableErrors, draft: draftsEnabled, includeLockStatus: includeLockStatusFromArgs, joins, limit, overrideAccess, page, pagination = true, populate, select: incomingSelect, showHiddenFields, sort: incomingSort, trash = false, where } = args;
|
|
33
|
+
const { collection: { config: collectionConfig }, collection, currentDepth, depth, disableErrors, draft: draftsEnabled, includeLockStatus: includeLockStatusFromArgs, joins, limit, overrideAccess, page, pagination = true, populate, select: incomingSelect, showHiddenFields, sort: incomingSort, trash = false, where: incomingWhere } = args;
|
|
34
|
+
const where = cloneWhere(incomingWhere);
|
|
34
35
|
const req = args.req;
|
|
35
36
|
const includeLockStatus = includeLockStatusFromArgs && req.payload.collections?.[lockedDocumentsCollectionSlug];
|
|
36
37
|
const { fallbackLocale, locale, payload } = req;
|
|
@@ -88,6 +89,12 @@ export const findOperation = async (incomingArgs)=>{
|
|
|
88
89
|
trash,
|
|
89
90
|
where: fullWhere
|
|
90
91
|
});
|
|
92
|
+
await validateQueryPaths({
|
|
93
|
+
collectionConfig,
|
|
94
|
+
overrideAccess: overrideAccess,
|
|
95
|
+
req,
|
|
96
|
+
where: where ?? {}
|
|
97
|
+
});
|
|
91
98
|
const sort = sanitizeSortQuery({
|
|
92
99
|
fields: collection.config.flattenedFields,
|
|
93
100
|
sort: incomingSort || collectionConfig.defaultSort
|
|
@@ -106,13 +113,6 @@ export const findOperation = async (incomingArgs)=>{
|
|
|
106
113
|
});
|
|
107
114
|
if (hasDraftsEnabled(collectionConfig) && draftsEnabled) {
|
|
108
115
|
fullWhere = appendVersionToQueryKey(fullWhere);
|
|
109
|
-
await validateQueryPaths({
|
|
110
|
-
collectionConfig: collection.config,
|
|
111
|
-
overrideAccess: overrideAccess,
|
|
112
|
-
req,
|
|
113
|
-
versionFields: buildVersionCollectionFields(payload.config, collection.config, true),
|
|
114
|
-
where: appendVersionToQueryKey(where)
|
|
115
|
-
});
|
|
116
116
|
result = await payload.db.queryDrafts({
|
|
117
117
|
collection: collectionConfig.slug,
|
|
118
118
|
joins: req.payloadAPI === 'GraphQL' ? false : sanitizedJoins,
|
|
@@ -131,12 +131,6 @@ export const findOperation = async (incomingArgs)=>{
|
|
|
131
131
|
where: fullWhere
|
|
132
132
|
});
|
|
133
133
|
} else {
|
|
134
|
-
await validateQueryPaths({
|
|
135
|
-
collectionConfig,
|
|
136
|
-
overrideAccess: overrideAccess,
|
|
137
|
-
req,
|
|
138
|
-
where: where
|
|
139
|
-
});
|
|
140
134
|
result = await payload.db.find({
|
|
141
135
|
collection: collectionConfig.slug,
|
|
142
136
|
draftsEnabled,
|