payload 3.65.0-internal.098b771 → 3.65.0-internal.ef3958a
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 -2
- package/dist/admin/RichText.d.ts.map +1 -1
- package/dist/admin/RichText.js.map +1 -1
- package/dist/collections/dataloader.d.ts +2 -2
- package/dist/collections/dataloader.d.ts.map +1 -1
- package/dist/collections/dataloader.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/utilities/update.d.ts +2 -2
- package/dist/collections/operations/utilities/update.d.ts.map +1 -1
- package/dist/collections/operations/utilities/update.js.map +1 -1
- package/dist/fields/hooks/afterRead/index.d.ts +2 -2
- 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 -2
- 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/relationshipPopulationPromise.d.ts +2 -1
- package/dist/fields/hooks/afterRead/relationshipPopulationPromise.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/relationshipPopulationPromise.js.map +1 -1
- package/dist/fields/hooks/afterRead/traverseFields.d.ts +2 -2
- 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/afterRead/virtualFieldPopulationPromise.d.ts +2 -1
- package/dist/fields/hooks/afterRead/virtualFieldPopulationPromise.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/virtualFieldPopulationPromise.js.map +1 -1
- package/dist/globals/operations/local/findOne.d.ts +2 -2
- package/dist/globals/operations/local/findOne.d.ts.map +1 -1
- package/dist/globals/operations/local/findOne.js.map +1 -1
- package/dist/index.bundled.d.ts +17 -14
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utilities/addLocalesToRequest.d.ts +3 -2
- package/dist/utilities/addLocalesToRequest.d.ts.map +1 -1
- package/dist/utilities/addLocalesToRequest.js.map +1 -1
- package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
- package/dist/utilities/configToJSONSchema.js +46 -0
- package/dist/utilities/configToJSONSchema.js.map +1 -1
- package/dist/utilities/createPayloadRequest.d.ts.map +1 -1
- package/dist/utilities/createPayloadRequest.js.map +1 -1
- package/dist/utilities/sanitizeFallbackLocale.d.ts +3 -3
- package/dist/utilities/sanitizeFallbackLocale.d.ts.map +1 -1
- package/dist/utilities/sanitizeFallbackLocale.js +19 -22
- package/dist/utilities/sanitizeFallbackLocale.js.map +1 -1
- package/package.json +2 -2
package/dist/admin/RichText.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { ImportMapGenerators, PayloadComponent, SanitizedConfig } from '../
|
|
|
5
5
|
import type { ValidationFieldError } from '../errors/ValidationError.js';
|
|
6
6
|
import type { FieldAffectingData, RichTextField, RichTextFieldClient, Validate } from '../fields/config/types.js';
|
|
7
7
|
import type { SanitizedGlobalConfig } from '../globals/config/types.js';
|
|
8
|
-
import type { RequestContext } from '../index.js';
|
|
8
|
+
import type { RequestContext, TypedFallbackLocale } from '../index.js';
|
|
9
9
|
import type { JsonObject, PayloadRequest, PopulateType } from '../types/index.js';
|
|
10
10
|
import type { RichTextFieldClientProps, RichTextFieldServerProps } from './fields/RichText.js';
|
|
11
11
|
import type { FieldDiffClientProps, FieldDiffServerProps, FieldSchemaMap } from './types.js';
|
|
@@ -13,7 +13,7 @@ export type AfterReadRichTextHookArgs<TData extends TypeWithID = any, TValue = a
|
|
|
13
13
|
currentDepth?: number;
|
|
14
14
|
depth?: number;
|
|
15
15
|
draft?: boolean;
|
|
16
|
-
fallbackLocale?:
|
|
16
|
+
fallbackLocale?: TypedFallbackLocale;
|
|
17
17
|
fieldPromises?: Promise<void>[];
|
|
18
18
|
/** Boolean to denote if this hook is running against finding one, or finding many within the afterRead hook. */
|
|
19
19
|
findMany?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichText.d.ts","sourceRoot":"","sources":["../../src/admin/RichText.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C,OAAO,KAAK,EAAE,yBAAyB,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAC3F,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAChG,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAA;AACxE,OAAO,KAAK,EACV,kBAAkB,EAClB,aAAa,EACb,mBAAmB,EACnB,QAAQ,EACT,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"RichText.d.ts","sourceRoot":"","sources":["../../src/admin/RichText.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C,OAAO,KAAK,EAAE,yBAAyB,EAAE,UAAU,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,IACvB,CAAC,EACH,MAAM,EACN,MAAM,EACN,iBAAiB,GAClB,EAAE;IACD,MAAM,EAAE,eAAe,CAAA;IACvB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,iBAAiB,EAAE,OAAO,CAAA;CAC3B,KACG,OAAO,CAAC,eAAe,CAAC,KAAK,EAAE,YAAY,EAAE,oBAAoB,CAAC,CAAC,GACnE,eAAe,CAAC,KAAK,EAAE,YAAY,EAAE,oBAAoB,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/admin/RichText.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { GenericLanguages, I18n } from '@payloadcms/translations'\nimport type { JSONSchema4 } from 'json-schema'\n\nimport type { SanitizedCollectionConfig, TypeWithID } from '../collections/config/types.js'\nimport type { ImportMapGenerators, PayloadComponent, SanitizedConfig } from '../config/types.js'\nimport type { ValidationFieldError } from '../errors/ValidationError.js'\nimport type {\n FieldAffectingData,\n RichTextField,\n RichTextFieldClient,\n Validate,\n} from '../fields/config/types.js'\nimport type { SanitizedGlobalConfig } from '../globals/config/types.js'\nimport type { RequestContext } from '../index.js'\nimport type { JsonObject, PayloadRequest, PopulateType } from '../types/index.js'\nimport type { RichTextFieldClientProps, RichTextFieldServerProps } from './fields/RichText.js'\nimport type { FieldDiffClientProps, FieldDiffServerProps, FieldSchemaMap } from './types.js'\n\nexport type AfterReadRichTextHookArgs<\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n TData extends TypeWithID = any,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n TValue = any,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n TSiblingData = any,\n> = {\n currentDepth?: number\n\n depth?: number\n\n draft?: boolean\n\n fallbackLocale?: string | string[]\n fieldPromises?: Promise<void>[]\n\n /** Boolean to denote if this hook is running against finding one, or finding many within the afterRead hook. */\n findMany?: boolean\n\n flattenLocales?: boolean\n\n locale?: string\n\n /** A string relating to which operation the field type is currently executing within. */\n operation?: 'create' | 'delete' | 'read' | 'update'\n\n overrideAccess?: boolean\n\n populate?: PopulateType\n\n populationPromises?: Promise<void>[]\n showHiddenFields?: boolean\n triggerAccessControl?: boolean\n triggerHooks?: boolean\n}\n\nexport type AfterChangeRichTextHookArgs<\n TData extends TypeWithID = any,\n TValue = any,\n TSiblingData = any,\n> = {\n /** A string relating to which operation the field type is currently executing within. */\n operation: 'create' | 'update'\n /** The document before changes were applied. */\n previousDoc?: TData\n /** The sibling data of the document before changes being applied. */\n previousSiblingDoc?: TSiblingData\n /** The previous value of the field, before changes */\n previousValue?: TValue\n}\n\nexport type BeforeValidateRichTextHookArgs<\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n TData extends TypeWithID = any,\n TValue = any,\n TSiblingData = any,\n> = {\n /** A string relating to which operation the field type is currently executing within. */\n operation: 'create' | 'update'\n overrideAccess?: boolean\n /** The sibling data of the document before changes being applied. */\n previousSiblingDoc?: TSiblingData\n /** The previous value of the field, before changes */\n previousValue?: TValue\n}\n\nexport type BeforeChangeRichTextHookArgs<\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n TData extends TypeWithID = any,\n TValue = any,\n TSiblingData = any,\n> = {\n /**\n * The original data with locales (not modified by any hooks). Only available in `beforeChange` and `beforeDuplicate` field hooks.\n */\n docWithLocales?: JsonObject\n\n duplicate?: boolean\n\n errors?: ValidationFieldError[]\n /**\n * Built up field label\n *\n * @example \"Group Field > Tab Field > Rich Text Field\"\n */\n fieldLabelPath: string\n /** Only available in `beforeChange` field hooks */\n mergeLocaleActions?: (() => Promise<void> | void)[]\n /** A string relating to which operation the field type is currently executing within. */\n operation?: 'create' | 'delete' | 'read' | 'update'\n overrideAccess: boolean\n /** The sibling data of the document before changes being applied. */\n previousSiblingDoc?: TSiblingData\n /** The previous value of the field, before changes */\n previousValue?: TValue\n /**\n * The original siblingData with locales (not modified by any hooks).\n */\n siblingDocWithLocales?: JsonObject\n skipValidation?: boolean\n}\n\nexport type BaseRichTextHookArgs<\n TData extends TypeWithID = any,\n TValue = any,\n TSiblingData = any,\n> = {\n /** The collection which the field belongs to. If the field belongs to a global, this will be null. */\n collection: null | SanitizedCollectionConfig\n context: RequestContext\n /** The data passed to update the document within create and update operations, and the full document itself in the afterRead hook. */\n data?: Partial<TData>\n /** The field which the hook is running against. */\n field: FieldAffectingData\n /** The global which the field belongs to. If the field belongs to a collection, this will be null. */\n global: null | SanitizedGlobalConfig\n indexPath: number[]\n /** The full original document in `update` operations. In the `afterChange` hook, this is the resulting document of the operation. */\n originalDoc?: TData\n parentIsLocalized: boolean\n /**\n * The path of the field, e.g. [\"group\", \"myArray\", 1, \"textField\"]. The path is the schemaPath but with indexes and would be used in the context of field data, not field schemas.\n */\n path: (number | string)[]\n /** The Express request object. It is mocked for Local API operations. */\n req: PayloadRequest\n /**\n * The schemaPath of the field, e.g. [\"group\", \"myArray\", \"textField\"]. The schemaPath is the path but without indexes and would be used in the context of field schemas, not field data.\n */\n schemaPath: string[]\n /** The sibling data passed to a field that the hook is running against. */\n siblingData: Partial<TSiblingData>\n /** The value of the field. */\n value?: TValue\n}\n\nexport type AfterReadRichTextHook<\n TData extends TypeWithID = any,\n TValue = any,\n TSiblingData = any,\n> = (\n args: AfterReadRichTextHookArgs<TData, TValue, TSiblingData> &\n BaseRichTextHookArgs<TData, TValue, TSiblingData>,\n) => Promise<TValue> | TValue\n\nexport type AfterChangeRichTextHook<\n TData extends TypeWithID = any,\n TValue = any,\n TSiblingData = any,\n> = (\n args: AfterChangeRichTextHookArgs<TData, TValue, TSiblingData> &\n BaseRichTextHookArgs<TData, TValue, TSiblingData>,\n) => Promise<TValue> | TValue\n\nexport type BeforeChangeRichTextHook<\n TData extends TypeWithID = any,\n TValue = any,\n TSiblingData = any,\n> = (\n args: BaseRichTextHookArgs<TData, TValue, TSiblingData> &\n BeforeChangeRichTextHookArgs<TData, TValue, TSiblingData>,\n) => Promise<TValue> | TValue\n\nexport type BeforeValidateRichTextHook<\n TData extends TypeWithID = any,\n TValue = any,\n TSiblingData = any,\n> = (\n args: BaseRichTextHookArgs<TData, TValue, TSiblingData> &\n BeforeValidateRichTextHookArgs<TData, TValue, TSiblingData>,\n) => Promise<TValue> | TValue\n\nexport type RichTextHooks = {\n afterChange?: AfterChangeRichTextHook[]\n afterRead?: AfterReadRichTextHook[]\n beforeChange?: BeforeChangeRichTextHook[]\n beforeValidate?: BeforeValidateRichTextHook[]\n}\n\ntype RichTextAdapterBase<\n Value extends object = object,\n AdapterProps = any,\n ExtraFieldProperties = {},\n> = {\n /**\n * Provide a function that can be used to add items to the import map. This is useful for\n * making modules available to the client.\n */\n generateImportMap?: ImportMapGenerators[0]\n /**\n * Provide a function that can be used to add items to the schema map. This is useful for\n * richtext sub-fields the server needs to \"know\" about in order to do things like calculate form state.\n *\n * This function is run within `buildFieldSchemaMap`.\n */\n generateSchemaMap?: (args: {\n config: SanitizedConfig\n field: RichTextField\n i18n: I18n<any, any>\n schemaMap: FieldSchemaMap\n schemaPath: string\n }) => FieldSchemaMap\n /**\n * Like an afterRead hook, but runs only for the GraphQL resolver. For populating data, this should be used, as afterRead hooks do not have a depth in graphQL.\n *\n * To populate stuff / resolve field hooks, mutate the incoming populationPromises or fieldPromises array. They will then be awaited in the correct order within payload itself.\n * @param data\n */\n graphQLPopulationPromises?: (data: {\n context: RequestContext\n currentDepth?: number\n depth: number\n draft: boolean\n field: RichTextField<Value, AdapterProps, ExtraFieldProperties>\n fieldPromises: Promise<void>[]\n findMany: boolean\n flattenLocales: boolean\n overrideAccess?: boolean\n parentIsLocalized: boolean\n populateArg?: PopulateType\n populationPromises: Promise<void>[]\n req: PayloadRequest\n showHiddenFields: boolean\n siblingDoc: JsonObject\n }) => void\n hooks?: RichTextHooks\n /**\n * @deprecated - manually merge i18n translations into the config.i18n.translations object within the adapter provider instead.\n * This property will be removed in v4.\n */\n i18n?: Partial<GenericLanguages>\n /**\n * Return the JSON schema for the field value. The JSON schema is read by\n * `json-schema-to-typescript` which is used to generate types for this richtext field\n * payload-types.ts)\n */\n outputSchema?: (args: {\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' }\n config?: SanitizedConfig\n field: RichTextField<Value, AdapterProps, ExtraFieldProperties>\n i18n?: I18n\n /**\n * Allows you to define new top-level interfaces that can be re-used in the output schema.\n */\n interfaceNameDefinitions: Map<string, JSONSchema4>\n isRequired: boolean\n }) => JSONSchema4\n /**\n * Provide validation function for the richText field. This function is run the same way\n * as other field validation functions.\n */\n validate: Validate<\n Value,\n Value,\n unknown,\n RichTextField<Value, AdapterProps, ExtraFieldProperties>\n >\n}\n\nexport type RichTextAdapter<\n Value extends object = any,\n AdapterProps = any,\n ExtraFieldProperties = any,\n> = {\n /**\n * Component that will be displayed in the list view. Can be typed as\n * `DefaultCellComponentProps` or `DefaultServerCellComponentProps`.\n */\n CellComponent: PayloadComponent<never>\n /**\n * Component that will be displayed in the version diff view.\n * If not provided, richtext content will be diffed as JSON.\n */\n DiffComponent?: PayloadComponent<\n FieldDiffServerProps<RichTextField, RichTextFieldClient>,\n FieldDiffClientProps<RichTextFieldClient>\n >\n /**\n * Component that will be displayed in the edit view.\n */\n FieldComponent: PayloadComponent<RichTextFieldServerProps, RichTextFieldClientProps>\n} & RichTextAdapterBase<Value, AdapterProps, ExtraFieldProperties>\n\nexport type RichTextAdapterProvider<\n Value extends object = object,\n AdapterProps = any,\n ExtraFieldProperties = {},\n> = ({\n config,\n isRoot,\n parentIsLocalized,\n}: {\n config: SanitizedConfig\n /**\n * Whether or not this is the root richText editor, defined in the top-level `editor` property\n * of the Payload Config.\n *\n * @default false\n */\n isRoot?: boolean\n parentIsLocalized: boolean\n}) =>\n | Promise<RichTextAdapter<Value, AdapterProps, ExtraFieldProperties>>\n | RichTextAdapter<Value, AdapterProps, ExtraFieldProperties>\n"],"names":[],"mappings":"AAAA,qDAAqD,GA+SrD,WAoB8D"}
|
|
1
|
+
{"version":3,"sources":["../../src/admin/RichText.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { GenericLanguages, I18n } from '@payloadcms/translations'\nimport type { JSONSchema4 } from 'json-schema'\n\nimport type { SanitizedCollectionConfig, TypeWithID } from '../collections/config/types.js'\nimport type { ImportMapGenerators, PayloadComponent, SanitizedConfig } from '../config/types.js'\nimport type { ValidationFieldError } from '../errors/ValidationError.js'\nimport type {\n FieldAffectingData,\n RichTextField,\n RichTextFieldClient,\n Validate,\n} from '../fields/config/types.js'\nimport type { SanitizedGlobalConfig } from '../globals/config/types.js'\nimport type { RequestContext, TypedFallbackLocale } from '../index.js'\nimport type { JsonObject, PayloadRequest, PopulateType } from '../types/index.js'\nimport type { RichTextFieldClientProps, RichTextFieldServerProps } from './fields/RichText.js'\nimport type { FieldDiffClientProps, FieldDiffServerProps, FieldSchemaMap } from './types.js'\n\nexport type AfterReadRichTextHookArgs<\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n TData extends TypeWithID = any,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n TValue = any,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n TSiblingData = any,\n> = {\n currentDepth?: number\n\n depth?: number\n\n draft?: boolean\n\n fallbackLocale?: TypedFallbackLocale\n fieldPromises?: Promise<void>[]\n\n /** Boolean to denote if this hook is running against finding one, or finding many within the afterRead hook. */\n findMany?: boolean\n\n flattenLocales?: boolean\n\n locale?: string\n\n /** A string relating to which operation the field type is currently executing within. */\n operation?: 'create' | 'delete' | 'read' | 'update'\n\n overrideAccess?: boolean\n\n populate?: PopulateType\n\n populationPromises?: Promise<void>[]\n showHiddenFields?: boolean\n triggerAccessControl?: boolean\n triggerHooks?: boolean\n}\n\nexport type AfterChangeRichTextHookArgs<\n TData extends TypeWithID = any,\n TValue = any,\n TSiblingData = any,\n> = {\n /** A string relating to which operation the field type is currently executing within. */\n operation: 'create' | 'update'\n /** The document before changes were applied. */\n previousDoc?: TData\n /** The sibling data of the document before changes being applied. */\n previousSiblingDoc?: TSiblingData\n /** The previous value of the field, before changes */\n previousValue?: TValue\n}\n\nexport type BeforeValidateRichTextHookArgs<\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n TData extends TypeWithID = any,\n TValue = any,\n TSiblingData = any,\n> = {\n /** A string relating to which operation the field type is currently executing within. */\n operation: 'create' | 'update'\n overrideAccess?: boolean\n /** The sibling data of the document before changes being applied. */\n previousSiblingDoc?: TSiblingData\n /** The previous value of the field, before changes */\n previousValue?: TValue\n}\n\nexport type BeforeChangeRichTextHookArgs<\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n TData extends TypeWithID = any,\n TValue = any,\n TSiblingData = any,\n> = {\n /**\n * The original data with locales (not modified by any hooks). Only available in `beforeChange` and `beforeDuplicate` field hooks.\n */\n docWithLocales?: JsonObject\n\n duplicate?: boolean\n\n errors?: ValidationFieldError[]\n /**\n * Built up field label\n *\n * @example \"Group Field > Tab Field > Rich Text Field\"\n */\n fieldLabelPath: string\n /** Only available in `beforeChange` field hooks */\n mergeLocaleActions?: (() => Promise<void> | void)[]\n /** A string relating to which operation the field type is currently executing within. */\n operation?: 'create' | 'delete' | 'read' | 'update'\n overrideAccess: boolean\n /** The sibling data of the document before changes being applied. */\n previousSiblingDoc?: TSiblingData\n /** The previous value of the field, before changes */\n previousValue?: TValue\n /**\n * The original siblingData with locales (not modified by any hooks).\n */\n siblingDocWithLocales?: JsonObject\n skipValidation?: boolean\n}\n\nexport type BaseRichTextHookArgs<\n TData extends TypeWithID = any,\n TValue = any,\n TSiblingData = any,\n> = {\n /** The collection which the field belongs to. If the field belongs to a global, this will be null. */\n collection: null | SanitizedCollectionConfig\n context: RequestContext\n /** The data passed to update the document within create and update operations, and the full document itself in the afterRead hook. */\n data?: Partial<TData>\n /** The field which the hook is running against. */\n field: FieldAffectingData\n /** The global which the field belongs to. If the field belongs to a collection, this will be null. */\n global: null | SanitizedGlobalConfig\n indexPath: number[]\n /** The full original document in `update` operations. In the `afterChange` hook, this is the resulting document of the operation. */\n originalDoc?: TData\n parentIsLocalized: boolean\n /**\n * The path of the field, e.g. [\"group\", \"myArray\", 1, \"textField\"]. The path is the schemaPath but with indexes and would be used in the context of field data, not field schemas.\n */\n path: (number | string)[]\n /** The Express request object. It is mocked for Local API operations. */\n req: PayloadRequest\n /**\n * The schemaPath of the field, e.g. [\"group\", \"myArray\", \"textField\"]. The schemaPath is the path but without indexes and would be used in the context of field schemas, not field data.\n */\n schemaPath: string[]\n /** The sibling data passed to a field that the hook is running against. */\n siblingData: Partial<TSiblingData>\n /** The value of the field. */\n value?: TValue\n}\n\nexport type AfterReadRichTextHook<\n TData extends TypeWithID = any,\n TValue = any,\n TSiblingData = any,\n> = (\n args: AfterReadRichTextHookArgs<TData, TValue, TSiblingData> &\n BaseRichTextHookArgs<TData, TValue, TSiblingData>,\n) => Promise<TValue> | TValue\n\nexport type AfterChangeRichTextHook<\n TData extends TypeWithID = any,\n TValue = any,\n TSiblingData = any,\n> = (\n args: AfterChangeRichTextHookArgs<TData, TValue, TSiblingData> &\n BaseRichTextHookArgs<TData, TValue, TSiblingData>,\n) => Promise<TValue> | TValue\n\nexport type BeforeChangeRichTextHook<\n TData extends TypeWithID = any,\n TValue = any,\n TSiblingData = any,\n> = (\n args: BaseRichTextHookArgs<TData, TValue, TSiblingData> &\n BeforeChangeRichTextHookArgs<TData, TValue, TSiblingData>,\n) => Promise<TValue> | TValue\n\nexport type BeforeValidateRichTextHook<\n TData extends TypeWithID = any,\n TValue = any,\n TSiblingData = any,\n> = (\n args: BaseRichTextHookArgs<TData, TValue, TSiblingData> &\n BeforeValidateRichTextHookArgs<TData, TValue, TSiblingData>,\n) => Promise<TValue> | TValue\n\nexport type RichTextHooks = {\n afterChange?: AfterChangeRichTextHook[]\n afterRead?: AfterReadRichTextHook[]\n beforeChange?: BeforeChangeRichTextHook[]\n beforeValidate?: BeforeValidateRichTextHook[]\n}\n\ntype RichTextAdapterBase<\n Value extends object = object,\n AdapterProps = any,\n ExtraFieldProperties = {},\n> = {\n /**\n * Provide a function that can be used to add items to the import map. This is useful for\n * making modules available to the client.\n */\n generateImportMap?: ImportMapGenerators[0]\n /**\n * Provide a function that can be used to add items to the schema map. This is useful for\n * richtext sub-fields the server needs to \"know\" about in order to do things like calculate form state.\n *\n * This function is run within `buildFieldSchemaMap`.\n */\n generateSchemaMap?: (args: {\n config: SanitizedConfig\n field: RichTextField\n i18n: I18n<any, any>\n schemaMap: FieldSchemaMap\n schemaPath: string\n }) => FieldSchemaMap\n /**\n * Like an afterRead hook, but runs only for the GraphQL resolver. For populating data, this should be used, as afterRead hooks do not have a depth in graphQL.\n *\n * To populate stuff / resolve field hooks, mutate the incoming populationPromises or fieldPromises array. They will then be awaited in the correct order within payload itself.\n * @param data\n */\n graphQLPopulationPromises?: (data: {\n context: RequestContext\n currentDepth?: number\n depth: number\n draft: boolean\n field: RichTextField<Value, AdapterProps, ExtraFieldProperties>\n fieldPromises: Promise<void>[]\n findMany: boolean\n flattenLocales: boolean\n overrideAccess?: boolean\n parentIsLocalized: boolean\n populateArg?: PopulateType\n populationPromises: Promise<void>[]\n req: PayloadRequest\n showHiddenFields: boolean\n siblingDoc: JsonObject\n }) => void\n hooks?: RichTextHooks\n /**\n * @deprecated - manually merge i18n translations into the config.i18n.translations object within the adapter provider instead.\n * This property will be removed in v4.\n */\n i18n?: Partial<GenericLanguages>\n /**\n * Return the JSON schema for the field value. The JSON schema is read by\n * `json-schema-to-typescript` which is used to generate types for this richtext field\n * payload-types.ts)\n */\n outputSchema?: (args: {\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' }\n config?: SanitizedConfig\n field: RichTextField<Value, AdapterProps, ExtraFieldProperties>\n i18n?: I18n\n /**\n * Allows you to define new top-level interfaces that can be re-used in the output schema.\n */\n interfaceNameDefinitions: Map<string, JSONSchema4>\n isRequired: boolean\n }) => JSONSchema4\n /**\n * Provide validation function for the richText field. This function is run the same way\n * as other field validation functions.\n */\n validate: Validate<\n Value,\n Value,\n unknown,\n RichTextField<Value, AdapterProps, ExtraFieldProperties>\n >\n}\n\nexport type RichTextAdapter<\n Value extends object = any,\n AdapterProps = any,\n ExtraFieldProperties = any,\n> = {\n /**\n * Component that will be displayed in the list view. Can be typed as\n * `DefaultCellComponentProps` or `DefaultServerCellComponentProps`.\n */\n CellComponent: PayloadComponent<never>\n /**\n * Component that will be displayed in the version diff view.\n * If not provided, richtext content will be diffed as JSON.\n */\n DiffComponent?: PayloadComponent<\n FieldDiffServerProps<RichTextField, RichTextFieldClient>,\n FieldDiffClientProps<RichTextFieldClient>\n >\n /**\n * Component that will be displayed in the edit view.\n */\n FieldComponent: PayloadComponent<RichTextFieldServerProps, RichTextFieldClientProps>\n} & RichTextAdapterBase<Value, AdapterProps, ExtraFieldProperties>\n\nexport type RichTextAdapterProvider<\n Value extends object = object,\n AdapterProps = any,\n ExtraFieldProperties = {},\n> = ({\n config,\n isRoot,\n parentIsLocalized,\n}: {\n config: SanitizedConfig\n /**\n * Whether or not this is the root richText editor, defined in the top-level `editor` property\n * of the Payload Config.\n *\n * @default false\n */\n isRoot?: boolean\n parentIsLocalized: boolean\n}) =>\n | Promise<RichTextAdapter<Value, AdapterProps, ExtraFieldProperties>>\n | RichTextAdapter<Value, AdapterProps, ExtraFieldProperties>\n"],"names":[],"mappings":"AAAA,qDAAqD,GA+SrD,WAoB8D"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import DataLoader from 'dataloader';
|
|
2
|
-
import type { Payload } from '../index.js';
|
|
2
|
+
import type { Payload, TypedFallbackLocale } from '../index.js';
|
|
3
3
|
import type { PayloadRequest, PopulateType, SelectType } from '../types/index.js';
|
|
4
4
|
import type { TypeWithID } from './config/types.js';
|
|
5
5
|
export declare const getDataLoader: (req: PayloadRequest) => {
|
|
@@ -11,7 +11,7 @@ type CreateCacheKeyArgs = {
|
|
|
11
11
|
depth: number;
|
|
12
12
|
docID: number | string;
|
|
13
13
|
draft: boolean;
|
|
14
|
-
fallbackLocale:
|
|
14
|
+
fallbackLocale: TypedFallbackLocale;
|
|
15
15
|
locale: string | string[];
|
|
16
16
|
overrideAccess: boolean;
|
|
17
17
|
populate?: PopulateType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataloader.d.ts","sourceRoot":"","sources":["../../src/collections/dataloader.ts"],"names":[],"mappings":"AAEA,OAAO,UAAU,MAAM,YAAY,CAAA;AAGnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"dataloader.d.ts","sourceRoot":"","sources":["../../src/collections/dataloader.ts"],"names":[],"mappings":"AAEA,OAAO,UAAU,MAAM,YAAY,CAAA;AAGnC,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACjF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AA0JnD,eAAO,MAAM,aAAa,QAAS,cAAc;;0CAgBhD,CAAA;AA4CD,KAAK,kBAAkB,GAAG;IACxB,cAAc,EAAE,MAAM,CAAA;IACtB,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;IACtB,KAAK,EAAE,OAAO,CAAA;IACd,cAAc,EAAE,mBAAmB,CAAA;IACnC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IACzB,cAAc,EAAE,OAAO,CAAA;IACvB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,gBAAgB,EAAE,OAAO,CAAA;IACzB,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,MAAM,CAAA;CAC1D,CAAA;AACD,eAAO,MAAM,wBAAwB,sJAalC,kBAAkB,KAAG,MAcpB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/collections/dataloader.ts"],"sourcesContent":["import type { BatchLoadFn } from 'dataloader'\n\nimport DataLoader from 'dataloader'\n\nimport type { FindArgs } from '../database/types.js'\nimport type { Payload } from '../index.js'\nimport type { PayloadRequest, PopulateType, SelectType } from '../types/index.js'\nimport type { TypeWithID } from './config/types.js'\nimport type { Options } from './operations/local/find.js'\n\nimport { isValidID } from '../utilities/isValidID.js'\n\n// Payload uses `dataloader` to solve the classic GraphQL N+1 problem.\n\n// We keep a list of all documents requested to be populated for any given request\n// and then batch together documents within the same collection,\n// making only 1 find per each collection, rather than `findByID` per each requested doc.\n\n// This dramatically improves performance for REST and Local API `depth` populations,\n// and also ensures complex GraphQL queries perform lightning-fast.\n\nconst batchAndLoadDocs =\n (req: PayloadRequest): BatchLoadFn<string, TypeWithID> =>\n async (keys: readonly string[]): Promise<TypeWithID[]> => {\n const { payload } = req\n\n // Create docs array of same length as keys, using null as value\n // We will replace nulls with injected docs as they are retrieved\n const docs: (null | TypeWithID)[] = keys.map(() => null)\n\n /**\n * Batch IDs by their `find` args\n * so we can make one find query per combination of collection, depth, locale, and fallbackLocale.\n *\n * Resulting shape will be as follows:\n {\n // key is stringified set of find args\n '[null,\"pages\",2,0,\"es\",\"en\",false,false]': [\n // value is array of IDs to find with these args\n 'q34tl23462346234524',\n '435523540194324280',\n '2346245j35l3j5234532li',\n ],\n // etc\n };\n *\n **/\n\n const batchByFindArgs: Record<string, string[]> = {}\n\n for (const key of keys) {\n const [\n transactionID,\n collection,\n id,\n depth,\n currentDepth,\n locale,\n fallbackLocale,\n overrideAccess,\n showHiddenFields,\n draft,\n select,\n populate,\n ] = JSON.parse(key)\n\n const batchKeyArray = [\n transactionID,\n collection,\n depth,\n currentDepth,\n locale,\n fallbackLocale,\n overrideAccess,\n showHiddenFields,\n draft,\n select,\n populate,\n ]\n\n const batchKey = JSON.stringify(batchKeyArray)\n\n const idType = payload.collections?.[collection]?.customIDType || payload.db.defaultIDType\n const sanitizedID = idType === 'number' ? parseFloat(id) : id\n\n if (isValidID(sanitizedID, idType)) {\n batchByFindArgs[batchKey] = [...(batchByFindArgs[batchKey] || []), sanitizedID]\n }\n }\n\n // Run find requests one after another, so as to not hang transactions\n\n for (const [batchKey, ids] of Object.entries(batchByFindArgs)) {\n const [\n transactionID,\n collection,\n depth,\n currentDepth,\n locale,\n fallbackLocale,\n overrideAccess,\n showHiddenFields,\n draft,\n select,\n populate,\n ] = JSON.parse(batchKey)\n\n req.transactionID = transactionID\n\n const result = await payload.find({\n collection,\n currentDepth,\n depth,\n disableErrors: true,\n draft,\n fallbackLocale,\n locale,\n overrideAccess: Boolean(overrideAccess),\n pagination: false,\n populate,\n req,\n select,\n showHiddenFields: Boolean(showHiddenFields),\n where: {\n id: {\n in: ids,\n },\n },\n })\n\n // For each returned doc, find index in original keys\n // Inject doc within docs array if index exists\n for (const doc of result.docs) {\n const docKey = createDataloaderCacheKey({\n collectionSlug: collection,\n currentDepth,\n depth,\n docID: doc.id,\n draft,\n fallbackLocale,\n locale,\n overrideAccess,\n populate,\n select,\n showHiddenFields,\n transactionID: req.transactionID!,\n })\n const docsIndex = keys.findIndex((key) => key === docKey)\n\n if (docsIndex > -1) {\n docs[docsIndex] = doc\n }\n }\n }\n\n // Return docs array,\n // which has now been injected with all fetched docs\n // and should match the length of the incoming keys arg\n return docs as TypeWithID[]\n }\n\nexport const getDataLoader = (req: PayloadRequest) => {\n const findQueries = new Map()\n const dataLoader = new DataLoader(batchAndLoadDocs(req)) as PayloadRequest['payloadDataLoader']\n\n dataLoader.find = ((args: FindArgs) => {\n const key = createFindDataloaderCacheKey(args)\n const cached = findQueries.get(key)\n if (cached) {\n return cached\n }\n const request = req.payload.find(args)\n findQueries.set(key, request)\n return request\n }) as Payload['find']\n\n return dataLoader\n}\n\nconst createFindDataloaderCacheKey = ({\n collection,\n currentDepth,\n depth,\n disableErrors,\n draft,\n includeLockStatus,\n joins,\n limit,\n overrideAccess,\n page,\n pagination,\n populate,\n req,\n select,\n showHiddenFields,\n sort,\n where,\n}: Options<string, SelectType>): string =>\n JSON.stringify([\n collection,\n currentDepth,\n depth,\n disableErrors,\n draft,\n includeLockStatus,\n joins,\n limit,\n overrideAccess,\n page,\n pagination,\n populate,\n req?.locale,\n req?.fallbackLocale,\n req?.user?.id,\n req?.transactionID,\n select,\n showHiddenFields,\n sort,\n where,\n ])\n\ntype CreateCacheKeyArgs = {\n collectionSlug: string\n currentDepth: number\n depth: number\n docID: number | string\n draft: boolean\n fallbackLocale: string | string[]\n locale: string | string[]\n overrideAccess: boolean\n populate?: PopulateType\n select?: SelectType\n showHiddenFields: boolean\n transactionID: number | Promise<number | string> | string\n}\nexport const createDataloaderCacheKey = ({\n collectionSlug,\n currentDepth,\n depth,\n docID,\n draft,\n fallbackLocale,\n locale,\n overrideAccess,\n populate,\n select,\n showHiddenFields,\n transactionID,\n}: CreateCacheKeyArgs): string =>\n JSON.stringify([\n transactionID,\n collectionSlug,\n docID,\n depth,\n currentDepth,\n locale,\n fallbackLocale,\n overrideAccess,\n showHiddenFields,\n draft,\n select,\n populate,\n ])\n"],"names":["DataLoader","isValidID","batchAndLoadDocs","req","keys","payload","docs","map","batchByFindArgs","key","transactionID","collection","id","depth","currentDepth","locale","fallbackLocale","overrideAccess","showHiddenFields","draft","select","populate","JSON","parse","batchKeyArray","batchKey","stringify","idType","collections","customIDType","db","defaultIDType","sanitizedID","parseFloat","ids","Object","entries","result","find","disableErrors","Boolean","pagination","where","in","doc","docKey","createDataloaderCacheKey","collectionSlug","docID","docsIndex","findIndex","getDataLoader","findQueries","Map","dataLoader","args","createFindDataloaderCacheKey","cached","get","request","set","includeLockStatus","joins","limit","page","sort","user"],"mappings":"AAEA,OAAOA,gBAAgB,aAAY;AAQnC,SAASC,SAAS,QAAQ,4BAA2B;AAErD,sEAAsE;AAEtE,kFAAkF;AAClF,gEAAgE;AAChE,yFAAyF;AAEzF,qFAAqF;AACrF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QACbf;QACAG;QACAD;QACA0B;QACApB;QACA0C;QACAC;QACAC;QACA9C;QACA+C;QACAvB;QACApB;QACAlB,KAAKY;QACLZ,KAAKa;QACLb,KAAK+D,MAAMtD;QACXT,KAAKO;QACLU;QACAF;QACA+C;QACAvB;KACD;AAgBH,OAAO,MAAMI,2BAA2B,CAAC,EACvCC,cAAc,EACdjC,YAAY,EACZD,KAAK,EACLmC,KAAK,EACL7B,KAAK,EACLH,cAAc,EACdD,MAAM,EACNE,cAAc,EACdI,QAAQ,EACRD,MAAM,EACNF,gBAAgB,EAChBR,aAAa,EACM,GACnBY,KAAKI,SAAS,CAAC;QACbhB;QACAqC;QACAC;QACAnC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;KACD,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/collections/dataloader.ts"],"sourcesContent":["import type { BatchLoadFn } from 'dataloader'\n\nimport DataLoader from 'dataloader'\n\nimport type { FindArgs } from '../database/types.js'\nimport type { Payload, TypedFallbackLocale } from '../index.js'\nimport type { PayloadRequest, PopulateType, SelectType } from '../types/index.js'\nimport type { TypeWithID } from './config/types.js'\nimport type { Options } from './operations/local/find.js'\n\nimport { isValidID } from '../utilities/isValidID.js'\n\n// Payload uses `dataloader` to solve the classic GraphQL N+1 problem.\n\n// We keep a list of all documents requested to be populated for any given request\n// and then batch together documents within the same collection,\n// making only 1 find per each collection, rather than `findByID` per each requested doc.\n\n// This dramatically improves performance for REST and Local API `depth` populations,\n// and also ensures complex GraphQL queries perform lightning-fast.\n\nconst batchAndLoadDocs =\n (req: PayloadRequest): BatchLoadFn<string, TypeWithID> =>\n async (keys: readonly string[]): Promise<TypeWithID[]> => {\n const { payload } = req\n\n // Create docs array of same length as keys, using null as value\n // We will replace nulls with injected docs as they are retrieved\n const docs: (null | TypeWithID)[] = keys.map(() => null)\n\n /**\n * Batch IDs by their `find` args\n * so we can make one find query per combination of collection, depth, locale, and fallbackLocale.\n *\n * Resulting shape will be as follows:\n {\n // key is stringified set of find args\n '[null,\"pages\",2,0,\"es\",\"en\",false,false]': [\n // value is array of IDs to find with these args\n 'q34tl23462346234524',\n '435523540194324280',\n '2346245j35l3j5234532li',\n ],\n // etc\n };\n *\n **/\n\n const batchByFindArgs: Record<string, string[]> = {}\n\n for (const key of keys) {\n const [\n transactionID,\n collection,\n id,\n depth,\n currentDepth,\n locale,\n fallbackLocale,\n overrideAccess,\n showHiddenFields,\n draft,\n select,\n populate,\n ] = JSON.parse(key)\n\n const batchKeyArray = [\n transactionID,\n collection,\n depth,\n currentDepth,\n locale,\n fallbackLocale,\n overrideAccess,\n showHiddenFields,\n draft,\n select,\n populate,\n ]\n\n const batchKey = JSON.stringify(batchKeyArray)\n\n const idType = payload.collections?.[collection]?.customIDType || payload.db.defaultIDType\n const sanitizedID = idType === 'number' ? parseFloat(id) : id\n\n if (isValidID(sanitizedID, idType)) {\n batchByFindArgs[batchKey] = [...(batchByFindArgs[batchKey] || []), sanitizedID]\n }\n }\n\n // Run find requests one after another, so as to not hang transactions\n\n for (const [batchKey, ids] of Object.entries(batchByFindArgs)) {\n const [\n transactionID,\n collection,\n depth,\n currentDepth,\n locale,\n fallbackLocale,\n overrideAccess,\n showHiddenFields,\n draft,\n select,\n populate,\n ] = JSON.parse(batchKey)\n\n req.transactionID = transactionID\n\n const result = await payload.find({\n collection,\n currentDepth,\n depth,\n disableErrors: true,\n draft,\n fallbackLocale,\n locale,\n overrideAccess: Boolean(overrideAccess),\n pagination: false,\n populate,\n req,\n select,\n showHiddenFields: Boolean(showHiddenFields),\n where: {\n id: {\n in: ids,\n },\n },\n })\n\n // For each returned doc, find index in original keys\n // Inject doc within docs array if index exists\n for (const doc of result.docs) {\n const docKey = createDataloaderCacheKey({\n collectionSlug: collection,\n currentDepth,\n depth,\n docID: doc.id,\n draft,\n fallbackLocale,\n locale,\n overrideAccess,\n populate,\n select,\n showHiddenFields,\n transactionID: req.transactionID!,\n })\n const docsIndex = keys.findIndex((key) => key === docKey)\n\n if (docsIndex > -1) {\n docs[docsIndex] = doc\n }\n }\n }\n\n // Return docs array,\n // which has now been injected with all fetched docs\n // and should match the length of the incoming keys arg\n return docs as TypeWithID[]\n }\n\nexport const getDataLoader = (req: PayloadRequest) => {\n const findQueries = new Map()\n const dataLoader = new DataLoader(batchAndLoadDocs(req)) as PayloadRequest['payloadDataLoader']\n\n dataLoader.find = ((args: FindArgs) => {\n const key = createFindDataloaderCacheKey(args)\n const cached = findQueries.get(key)\n if (cached) {\n return cached\n }\n const request = req.payload.find(args)\n findQueries.set(key, request)\n return request\n }) as Payload['find']\n\n return dataLoader\n}\n\nconst createFindDataloaderCacheKey = ({\n collection,\n currentDepth,\n depth,\n disableErrors,\n draft,\n includeLockStatus,\n joins,\n limit,\n overrideAccess,\n page,\n pagination,\n populate,\n req,\n select,\n showHiddenFields,\n sort,\n where,\n}: Options<string, SelectType>): string =>\n JSON.stringify([\n collection,\n currentDepth,\n depth,\n disableErrors,\n draft,\n includeLockStatus,\n joins,\n limit,\n overrideAccess,\n page,\n pagination,\n populate,\n req?.locale,\n req?.fallbackLocale,\n req?.user?.id,\n req?.transactionID,\n select,\n showHiddenFields,\n sort,\n where,\n ])\n\ntype CreateCacheKeyArgs = {\n collectionSlug: string\n currentDepth: number\n depth: number\n docID: number | string\n draft: boolean\n fallbackLocale: TypedFallbackLocale\n locale: string | string[]\n overrideAccess: boolean\n populate?: PopulateType\n select?: SelectType\n showHiddenFields: boolean\n transactionID: number | Promise<number | string> | string\n}\nexport const createDataloaderCacheKey = ({\n collectionSlug,\n currentDepth,\n depth,\n docID,\n draft,\n fallbackLocale,\n locale,\n overrideAccess,\n populate,\n select,\n showHiddenFields,\n transactionID,\n}: CreateCacheKeyArgs): string =>\n JSON.stringify([\n transactionID,\n collectionSlug,\n docID,\n depth,\n currentDepth,\n locale,\n fallbackLocale,\n overrideAccess,\n showHiddenFields,\n draft,\n select,\n populate,\n ])\n"],"names":["DataLoader","isValidID","batchAndLoadDocs","req","keys","payload","docs","map","batchByFindArgs","key","transactionID","collection","id","depth","currentDepth","locale","fallbackLocale","overrideAccess","showHiddenFields","draft","select","populate","JSON","parse","batchKeyArray","batchKey","stringify","idType","collections","customIDType","db","defaultIDType","sanitizedID","parseFloat","ids","Object","entries","result","find","disableErrors","Boolean","pagination","where","in","doc","docKey","createDataloaderCacheKey","collectionSlug","docID","docsIndex","findIndex","getDataLoader","findQueries","Map","dataLoader","args","createFindDataloaderCacheKey","cached","get","request","set","includeLockStatus","joins","limit","page","sort","user"],"mappings":"AAEA,OAAOA,gBAAgB,aAAY;AAQnC,SAASC,SAAS,QAAQ,4BAA2B;AAErD,sEAAsE;AAEtE,kFAAkF;AAClF,gEAAgE;AAChE,yFAAyF;AAEzF,qFAAqF;AACrF,mEAAmE;AAEnE,MAAMC,mBACJ,CAACC,MACD,OAAOC;QACL,MAAM,EAAEC,OAAO,EAAE,GAAGF;QAEpB,gEAAgE;QAChE,iEAAiE;QACjE,MAAMG,OAA8BF,KAAKG,GAAG,CAAC,IAAM;QAEnD;;;;;;;;;;;;;;;;KAgBC,GAED,MAAMC,kBAA4C,CAAC;QAEnD,KAAK,MAAMC,OAAOL,KAAM;YACtB,MAAM,CACJM,eACAC,YACAC,IACAC,OACAC,cACAC,QACAC,gBACAC,gBACAC,kBACAC,OACAC,QACAC,SACD,GAAGC,KAAKC,KAAK,CAACd;YAEf,MAAMe,gBAAgB;gBACpBd;gBACAC;gBACAE;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC;aACD;YAED,MAAMI,WAAWH,KAAKI,SAAS,CAACF;YAEhC,MAAMG,SAAStB,QAAQuB,WAAW,EAAE,CAACjB,WAAW,EAAEkB,gBAAgBxB,QAAQyB,EAAE,CAACC,aAAa;YAC1F,MAAMC,cAAcL,WAAW,WAAWM,WAAWrB,MAAMA;YAE3D,IAAIX,UAAU+B,aAAaL,SAAS;gBAClCnB,eAAe,CAACiB,SAAS,GAAG;uBAAKjB,eAAe,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AAG,CAACjD;QAC/B,IAAIgD,QAAQ;YACV,OAAOA;QACT;QACA,MAAME,UAAUxD,IAAIE,OAAO,CAACiC,IAAI,CAACiB;QACjCH,YAAYQ,GAAG,CAACnD,KAAKkD;QACrB,OAAOA;IACT;IAEA,OAAOL;AACT,EAAC;AAED,MAAME,+BAA+B,CAAC,EACpC7C,UAAU,EACVG,YAAY,EACZD,KAAK,EACL0B,aAAa,EACbpB,KAAK,EACL0C,iBAAiB,EACjBC,KAAK,EACLC,KAAK,EACL9C,cAAc,EACd+C,IAAI,EACJvB,UAAU,EACVpB,QAAQ,EACRlB,GAAG,EACHiB,MAAM,EACNF,gBAAgB,EAChB+C,IAAI,EACJvB,KAAK,EACuB,GAC5BpB,KAAKI,SAAS,CAAC;QACbf;QACAG;QACAD;QACA0B;QACApB;QACA0C;QACAC;QACAC;QACA9C;QACA+C;QACAvB;QACApB;QACAlB,KAAKY;QACLZ,KAAKa;QACLb,KAAK+D,MAAMtD;QACXT,KAAKO;QACLU;QACAF;QACA+C;QACAvB;KACD;AAgBH,OAAO,MAAMI,2BAA2B,CAAC,EACvCC,cAAc,EACdjC,YAAY,EACZD,KAAK,EACLmC,KAAK,EACL7B,KAAK,EACLH,cAAc,EACdD,MAAM,EACNE,cAAc,EACdI,QAAQ,EACRD,MAAM,EACNF,gBAAgB,EAChBR,aAAa,EACM,GACnBY,KAAKI,SAAS,CAAC;QACbhB;QACAqC;QACAC;QACAnC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;KACD,EAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PaginatedDocs } from '../../../database/types.js';
|
|
2
|
-
import type { CollectionSlug, JoinQuery, Payload, RequestContext, TypedLocale } from '../../../index.js';
|
|
2
|
+
import type { CollectionSlug, JoinQuery, Payload, RequestContext, TypedFallbackLocale, TypedLocale } from '../../../index.js';
|
|
3
3
|
import type { Document, PayloadRequest, PopulateType, 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> = {
|
|
@@ -34,7 +34,7 @@ export type Options<TSlug extends CollectionSlug, TSelect extends SelectType> =
|
|
|
34
34
|
/**
|
|
35
35
|
* Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.
|
|
36
36
|
*/
|
|
37
|
-
fallbackLocale?:
|
|
37
|
+
fallbackLocale?: TypedFallbackLocale;
|
|
38
38
|
/**
|
|
39
39
|
* Include info about the lock status to the result into all documents with fields: `_isLocked` and `_userEditing`
|
|
40
40
|
*/
|
|
@@ -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,4BAA4B,CAAA;AAC/D,OAAO,KAAK,EACV,cAAc,EACd,SAAS,EACT,OAAO,EACP,cAAc,EACd,WAAW,EACZ,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,UAAU,EACV,IAAI,EACJ,6BAA6B,EAC7B,KAAK,EACN,MAAM,yBAAyB,CAAA;AAEhC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAMrE,MAAM,MAAM,OAAO,CAAC,KAAK,SAAS,cAAc,EAAE,OAAO,SAAS,UAAU,IAAI;IAC9E;;OAEG;IACH,UAAU,EAAE,KAAK,CAAA;IACjB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;;OAEG;IACH,cAAc,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/find.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,KAAK,EACV,cAAc,EACd,SAAS,EACT,OAAO,EACP,cAAc,EACd,mBAAmB,EACnB,WAAW,EACZ,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,UAAU,EACV,IAAI,EACJ,6BAA6B,EAC7B,KAAK,EACN,MAAM,yBAAyB,CAAA;AAEhC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAMrE,MAAM,MAAM,OAAO,CAAC,KAAK,SAAS,cAAc,EAAE,OAAO,SAAS,UAAU,IAAI;IAC9E;;OAEG;IACH,UAAU,EAAE,KAAK,CAAA;IACjB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;;OAEG;IACH,cAAc,CAAC,EAAE,mBAAmB,CAAA;IACpC;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B;;;OAGG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,CAAA;IACxB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IAC5B;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;OAEG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;IAC7B;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B;;;;OAIG;IACH,IAAI,CAAC,EAAE,IAAI,CAAA;IACX;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;;OAEG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAA;IACf;;OAEG;IACH,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,CAiDvE"}
|
|
@@ -1 +1 @@
|
|
|
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 PopulateType,\n SelectType,\n Sort,\n TransformCollectionWithSelect,\n Where,\n} from '../../../types/index.js'\nimport type { CreateLocalReqOptions } from '../../../utilities/createLocalReq.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 /**\n * the Collection slug to operate against.\n */\n collection: TSlug\n /**\n * [Context](https://payloadcms.com/docs/hooks/context), which will then be passed to `context` and `req.context`,\n * which can be read by hooks. Useful if you want to pass additional information to the hooks which\n * shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook\n * to determine if it should run or not.\n */\n context?: RequestContext\n /**\n * The current population depth, used internally for relationships population.\n * @internal\n */\n currentDepth?: number\n /**\n * [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.\n */\n depth?: number\n /**\n * When set to `true`, errors will not be thrown.\n */\n disableErrors?: boolean\n /**\n * Whether the documents should be queried from the versions table/collection or not. [More](https://payloadcms.com/docs/versions/drafts#draft-api)\n */\n draft?: boolean\n /**\n * Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.\n */\n fallbackLocale?:
|
|
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 TypedFallbackLocale,\n TypedLocale,\n} from '../../../index.js'\nimport type {\n Document,\n PayloadRequest,\n PopulateType,\n SelectType,\n Sort,\n TransformCollectionWithSelect,\n Where,\n} from '../../../types/index.js'\nimport type { CreateLocalReqOptions } from '../../../utilities/createLocalReq.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 /**\n * the Collection slug to operate against.\n */\n collection: TSlug\n /**\n * [Context](https://payloadcms.com/docs/hooks/context), which will then be passed to `context` and `req.context`,\n * which can be read by hooks. Useful if you want to pass additional information to the hooks which\n * shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook\n * to determine if it should run or not.\n */\n context?: RequestContext\n /**\n * The current population depth, used internally for relationships population.\n * @internal\n */\n currentDepth?: number\n /**\n * [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.\n */\n depth?: number\n /**\n * When set to `true`, errors will not be thrown.\n */\n disableErrors?: boolean\n /**\n * Whether the documents should be queried from the versions table/collection or not. [More](https://payloadcms.com/docs/versions/drafts#draft-api)\n */\n draft?: boolean\n /**\n * Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.\n */\n fallbackLocale?: TypedFallbackLocale\n /**\n * Include info about the lock status to the result into all documents with fields: `_isLocked` and `_userEditing`\n */\n includeLockStatus?: boolean\n /**\n * The [Join Field Query](https://payloadcms.com/docs/fields/join#query-options).\n * Pass `false` to disable all join fields from the result.\n */\n joins?: JoinQuery<TSlug>\n /**\n * The maximum related documents to be returned.\n * Defaults unless `defaultLimit` is specified for the collection config\n * @default 10\n */\n limit?: number\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: 'all' | TypedLocale\n /**\n * Skip access control.\n * Set to `false` if you want to respect Access Control for the operation, for example when fetching data for the front-end.\n * @default true\n */\n overrideAccess?: boolean\n /**\n * Get a specific page number\n * @default 1\n */\n page?: number\n /**\n * Set to `false` to return all documents and avoid querying for document counts which introduces some overhead.\n * You can also combine that property with a specified `limit` to limit documents but avoid the count query.\n */\n pagination?: boolean\n /**\n * Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.\n */\n populate?: PopulateType\n /**\n * The `PayloadRequest` object. You can pass it to thread the current [transaction](https://payloadcms.com/docs/database/transactions), user and locale to the operation.\n * Recommended to pass when using the Local API from hooks, as usually you want to execute the operation within the current transaction.\n */\n req?: Partial<PayloadRequest>\n /**\n * Specify [select](https://payloadcms.com/docs/queries/select) to control which fields to include to the result.\n */\n select?: TSelect\n /**\n * Opt-in to receiving hidden fields. By default, they are hidden from returned documents in accordance to your config.\n * @default false\n */\n showHiddenFields?: boolean\n /**\n * Sort the documents, can be a string or an array of strings\n * @example '-createdAt' // Sort DESC by createdAt\n * @example ['group', '-createdAt'] // sort by 2 fields, ASC group and DESC createdAt\n */\n sort?: Sort\n /**\n * When set to `true`, the query will include both normal and trashed documents.\n * To query only trashed documents, pass `trash: true` and combine with a `where` clause filtering by `deletedAt`.\n * By default (`false`), the query will only include normal documents and exclude those with a `deletedAt` field.\n *\n * This argument has no effect unless `trash` is enabled on the collection.\n * @default false\n */\n trash?: boolean\n /**\n * If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.\n */\n user?: Document\n /**\n * A filter [query](https://payloadcms.com/docs/queries/overview)\n */\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 populate,\n select,\n showHiddenFields,\n sort,\n trash = false,\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 populate,\n req: await createLocalReq(options as CreateLocalReqOptions, payload),\n select,\n showHiddenFields,\n sort,\n trash,\n where,\n })\n}\n"],"names":["APIError","createLocalReq","findOperation","findLocal","payload","options","collection","collectionSlug","currentDepth","depth","disableErrors","draft","includeLockStatus","joins","limit","overrideAccess","page","pagination","populate","select","showHiddenFields","sort","trash","where","collections","String","req"],"mappings":"AAqBA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,aAAa,QAAQ,aAAY;AAiH1C,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,QAAQ,EACRC,MAAM,EACNC,gBAAgB,EAChBC,IAAI,EACJC,QAAQ,KAAK,EACbC,KAAK,EACN,GAAGlB;IAEJ,MAAMC,aAAaF,QAAQoB,WAAW,CAACjB,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIN,SACR,CAAC,yBAAyB,EAAEyB,OAAOlB,gBAAgB,gCAAgC,CAAC;IAExF;IAEA,OAAOL,cAA8B;QACnCI;QACAE;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAQ,KAAK,MAAMzB,eAAeI,SAAkCD;QAC5De;QACAC;QACAC;QACAC;QACAC;IACF;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CollectionSlug, JoinQuery, Payload, RequestContext, SelectType, TypedLocale } from '../../../index.js';
|
|
1
|
+
import type { CollectionSlug, JoinQuery, Payload, RequestContext, SelectType, TypedFallbackLocale, TypedLocale } from '../../../index.js';
|
|
2
2
|
import type { ApplyDisableErrors, Document, PayloadRequest, PopulateType, TransformCollectionWithSelect } from '../../../types/index.js';
|
|
3
3
|
import type { SelectFromCollectionSlug } from '../../config/types.js';
|
|
4
4
|
import { type FindByIDArgs } from '../findByID.js';
|
|
@@ -40,7 +40,7 @@ export type Options<TSlug extends CollectionSlug, TDisableErrors extends boolean
|
|
|
40
40
|
/**
|
|
41
41
|
* Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.
|
|
42
42
|
*/
|
|
43
|
-
fallbackLocale?:
|
|
43
|
+
fallbackLocale?: TypedFallbackLocale;
|
|
44
44
|
/**
|
|
45
45
|
* The ID of the document to find.
|
|
46
46
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findByID.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/findByID.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,SAAS,EACT,OAAO,EACP,cAAc,EACd,UAAU,EACV,WAAW,EACZ,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EACV,kBAAkB,EAClB,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,6BAA6B,EAC9B,MAAM,yBAAyB,CAAA;AAEhC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAIrE,OAAO,EAAE,KAAK,YAAY,EAAqB,MAAM,gBAAgB,CAAA;AAErE,MAAM,MAAM,OAAO,CACjB,KAAK,SAAS,cAAc,EAC5B,cAAc,SAAS,OAAO,EAC9B,OAAO,SAAS,UAAU,IACxB;IACF;;OAEG;IACH,UAAU,EAAE,KAAK,CAAA;IACjB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,aAAa,CAAC,EAAE,cAAc,CAAA;IAC9B;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;;OAEG;IACH,cAAc,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"findByID.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/findByID.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,SAAS,EACT,OAAO,EACP,cAAc,EACd,UAAU,EACV,mBAAmB,EACnB,WAAW,EACZ,MAAM,mBAAmB,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gB,CAAC,EAAE,OAAO,CAAA;IAC1B;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;;OAEG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAA;CAChB,GAAG,IAAI,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAA;AAExC,wBAAsB,aAAa,CACjC,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,CA6C5F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/collections/operations/local/findByID.ts"],"sourcesContent":["import type {\n CollectionSlug,\n JoinQuery,\n Payload,\n RequestContext,\n SelectType,\n TypedLocale,\n} from '../../../index.js'\nimport type {\n ApplyDisableErrors,\n Document,\n PayloadRequest,\n PopulateType,\n TransformCollectionWithSelect,\n} from '../../../types/index.js'\nimport type { CreateLocalReqOptions } from '../../../utilities/createLocalReq.js'\nimport type { SelectFromCollectionSlug } from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { type FindByIDArgs, findByIDOperation } from '../findByID.js'\n\nexport type Options<\n TSlug extends CollectionSlug,\n TDisableErrors extends boolean,\n TSelect extends SelectType,\n> = {\n /**\n * the Collection slug to operate against.\n */\n collection: TSlug\n /**\n * [Context](https://payloadcms.com/docs/hooks/context), which will then be passed to `context` and `req.context`,\n * which can be read by hooks. Useful if you want to pass additional information to the hooks which\n * shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook\n * to determine if it should run or not.\n */\n context?: RequestContext\n /**\n * The current population depth, used internally for relationships population.\n * @internal\n */\n currentDepth?: number\n /**\n * You may pass the document data directly which will skip the `db.findOne` database query.\n * This is useful if you want to use this endpoint solely for running hooks and populating data.\n */\n data?: Record<string, unknown>\n /**\n * [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.\n */\n depth?: number\n /**\n * When set to `true`, errors will not be thrown.\n * `null` will be returned instead, if the document on this ID was not found.\n */\n disableErrors?: TDisableErrors\n /**\n * Whether the document should be queried from the versions table/collection or not. [More](https://payloadcms.com/docs/versions/drafts#draft-api)\n */\n draft?: boolean\n /**\n * Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.\n */\n fallbackLocale?:
|
|
1
|
+
{"version":3,"sources":["../../../../src/collections/operations/local/findByID.ts"],"sourcesContent":["import type {\n CollectionSlug,\n JoinQuery,\n Payload,\n RequestContext,\n SelectType,\n TypedFallbackLocale,\n TypedLocale,\n} from '../../../index.js'\nimport type {\n ApplyDisableErrors,\n Document,\n PayloadRequest,\n PopulateType,\n TransformCollectionWithSelect,\n} from '../../../types/index.js'\nimport type { CreateLocalReqOptions } from '../../../utilities/createLocalReq.js'\nimport type { SelectFromCollectionSlug } from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { type FindByIDArgs, findByIDOperation } from '../findByID.js'\n\nexport type Options<\n TSlug extends CollectionSlug,\n TDisableErrors extends boolean,\n TSelect extends SelectType,\n> = {\n /**\n * the Collection slug to operate against.\n */\n collection: TSlug\n /**\n * [Context](https://payloadcms.com/docs/hooks/context), which will then be passed to `context` and `req.context`,\n * which can be read by hooks. Useful if you want to pass additional information to the hooks which\n * shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook\n * to determine if it should run or not.\n */\n context?: RequestContext\n /**\n * The current population depth, used internally for relationships population.\n * @internal\n */\n currentDepth?: number\n /**\n * You may pass the document data directly which will skip the `db.findOne` database query.\n * This is useful if you want to use this endpoint solely for running hooks and populating data.\n */\n data?: Record<string, unknown>\n /**\n * [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.\n */\n depth?: number\n /**\n * When set to `true`, errors will not be thrown.\n * `null` will be returned instead, if the document on this ID was not found.\n */\n disableErrors?: TDisableErrors\n /**\n * Whether the document should be queried from the versions table/collection or not. [More](https://payloadcms.com/docs/versions/drafts#draft-api)\n */\n draft?: boolean\n /**\n * Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.\n */\n fallbackLocale?: TypedFallbackLocale\n /**\n * The ID of the document to find.\n */\n id: number | string\n /**\n * Include info about the lock status to the result with fields: `_isLocked` and `_userEditing`\n */\n includeLockStatus?: boolean\n /**\n * The [Join Field Query](https://payloadcms.com/docs/fields/join#query-options).\n * Pass `false` to disable all join fields from the result.\n */\n joins?: JoinQuery<TSlug>\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: 'all' | TypedLocale\n /**\n * Skip access control.\n * Set to `false` if you want to respect Access Control for the operation, for example when fetching data for the front-end.\n * @default true\n */\n overrideAccess?: boolean\n /**\n * Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.\n */\n populate?: PopulateType\n /**\n * The `PayloadRequest` object. You can pass it to thread the current [transaction](https://payloadcms.com/docs/database/transactions), user and locale to the operation.\n * Recommended to pass when using the Local API from hooks, as usually you want to execute the operation within the current transaction.\n */\n req?: Partial<PayloadRequest>\n /**\n * Specify [select](https://payloadcms.com/docs/queries/select) to control which fields to include to the result.\n */\n select?: TSelect\n /**\n * Opt-in to receiving hidden fields. By default, they are hidden from returned documents in accordance to your config.\n * @default false\n */\n showHiddenFields?: boolean\n /**\n * When set to `true`, the operation will return a document by ID, even if it is trashed (soft-deleted).\n * By default (`false`), the operation will exclude trashed documents.\n * To fetch a trashed document, set `trash: true`.\n *\n * This argument has no effect unless `trash` is enabled on the collection.\n * @default false\n */\n trash?: boolean\n /**\n * If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.\n */\n user?: Document\n} & Pick<FindByIDArgs, 'flattenLocales'>\n\nexport 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 data,\n depth,\n disableErrors = false,\n draft = false,\n flattenLocales,\n includeLockStatus,\n joins,\n overrideAccess = true,\n populate,\n select,\n showHiddenFields,\n trash = false,\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 data,\n depth,\n disableErrors,\n draft,\n flattenLocales,\n includeLockStatus,\n joins,\n overrideAccess,\n populate,\n req: await createLocalReq(options as CreateLocalReqOptions, payload),\n select,\n showHiddenFields,\n trash,\n })\n}\n"],"names":["APIError","createLocalReq","findByIDOperation","findByIDLocal","payload","options","id","collection","collectionSlug","currentDepth","data","depth","disableErrors","draft","flattenLocales","includeLockStatus","joins","overrideAccess","populate","select","showHiddenFields","trash","collections","String","req"],"mappings":"AAmBA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAA4BC,iBAAiB,QAAQ,iBAAgB;AAqGrE,OAAO,eAAeC,cAKpBC,OAAgB,EAChBC,OAAgD;IAEhD,MAAM,EACJC,EAAE,EACFC,YAAYC,cAAc,EAC1BC,YAAY,EACZC,IAAI,EACJC,KAAK,EACLC,gBAAgB,KAAK,EACrBC,QAAQ,KAAK,EACbC,cAAc,EACdC,iBAAiB,EACjBC,KAAK,EACLC,iBAAiB,IAAI,EACrBC,QAAQ,EACRC,MAAM,EACNC,gBAAgB,EAChBC,QAAQ,KAAK,EACd,GAAGhB;IAEJ,MAAME,aAAaH,QAAQkB,WAAW,CAACd,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIP,SACR,CAAC,yBAAyB,EAAEuB,OAAOf,gBAAgB,sCAAsC,CAAC;IAE9F;IAEA,OAAON,kBAAkD;QACvDI;QACAC;QACAE;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAM,KAAK,MAAMvB,eAAeI,SAAkCD;QAC5De;QACAC;QACAC;IACF;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DeepPartial } from 'ts-essentials';
|
|
2
|
-
import type { AccessResult, CollectionSlug, FileToSave, SanitizedConfig } from '../../../index.js';
|
|
2
|
+
import type { AccessResult, CollectionSlug, FileToSave, SanitizedConfig, TypedFallbackLocale } from '../../../index.js';
|
|
3
3
|
import type { JsonObject, Payload, PayloadRequest, PopulateType, SelectType, TransformCollectionWithSelect } from '../../../types/index.js';
|
|
4
4
|
import type { DataFromCollectionSlug, SanitizedCollectionConfig, SelectFromCollectionSlug, TypeWithID } from '../../config/types.js';
|
|
5
5
|
export type SharedUpdateDocumentArgs<TSlug extends CollectionSlug> = {
|
|
@@ -11,7 +11,7 @@ export type SharedUpdateDocumentArgs<TSlug extends CollectionSlug> = {
|
|
|
11
11
|
depth: number;
|
|
12
12
|
docWithLocales: JsonObject & TypeWithID;
|
|
13
13
|
draftArg: boolean;
|
|
14
|
-
fallbackLocale:
|
|
14
|
+
fallbackLocale: TypedFallbackLocale;
|
|
15
15
|
filesToUpload: FileToSave[];
|
|
16
16
|
id: number | string;
|
|
17
17
|
locale: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/utilities/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAGhD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/utilities/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAGhD,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,UAAU,EACV,eAAe,EACf,mBAAmB,EACpB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EACV,UAAU,EACV,OAAO,EACP,cAAc,EACd,YAAY,EACZ,UAAU,EACV,6BAA6B,EAC9B,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EACV,sBAAsB,EACtB,yBAAyB,EACzB,wBAAwB,EACxB,UAAU,EACX,MAAM,uBAAuB,CAAA;AAe9B,MAAM,MAAM,wBAAwB,CAAC,KAAK,SAAS,cAAc,IAAI;IACnE,aAAa,EAAE,YAAY,CAAA;IAC3B,QAAQ,EAAE,OAAO,CAAA;IACjB,gBAAgB,EAAE,yBAAyB,CAAA;IAC3C,MAAM,EAAE,eAAe,CAAA;IACvB,IAAI,EAAE,WAAW,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAA;IAChD,KAAK,EAAE,MAAM,CAAA;IACb,cAAc,EAAE,UAAU,GAAG,UAAU,CAAA;IACvC,QAAQ,EAAE,OAAO,CAAA;IACjB,cAAc,EAAE,mBAAmB,CAAA;IACnC,aAAa,EAAE,UAAU,EAAE,CAAA;IAC3B,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,cAAc,EAAE,OAAO,CAAA;IACvB,YAAY,EAAE,OAAO,CAAA;IACrB,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,GAAG,EAAE,cAAc,CAAA;IACnB,MAAM,EAAE,UAAU,CAAA;IAClB,gBAAgB,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,GACzB,KAAK,SAAS,cAAc,EAC5B,OAAO,SAAS,wBAAwB,CAAC,KAAK,CAAC,gQAsB9C,wBAAwB,CAAC,KAAK,CAAC,KAAG,OAAO,CAAC,6BAA6B,CAAC,KAAK,EAAE,OAAO,CAAC,CA4SzF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/collections/operations/utilities/update.ts"],"sourcesContent":["import type { DeepPartial } from 'ts-essentials'\n\nimport type { Args } from '../../../fields/hooks/beforeChange/index.js'\nimport type { AccessResult, CollectionSlug, FileToSave, SanitizedConfig } from '../../../index.js'\nimport type {\n JsonObject,\n Payload,\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformCollectionWithSelect,\n} from '../../../types/index.js'\nimport type {\n DataFromCollectionSlug,\n SanitizedCollectionConfig,\n SelectFromCollectionSlug,\n TypeWithID,\n} from '../../config/types.js'\n\nimport { ensureUsernameOrEmail } from '../../../auth/ensureUsernameOrEmail.js'\nimport { generatePasswordSaltHash } from '../../../auth/strategies/local/generatePasswordSaltHash.js'\nimport { combineQueries } from '../../../database/combineQueries.js'\nimport { afterChange } from '../../../fields/hooks/afterChange/index.js'\nimport { afterRead } from '../../../fields/hooks/afterRead/index.js'\nimport { beforeChange } from '../../../fields/hooks/beforeChange/index.js'\nimport { beforeValidate } from '../../../fields/hooks/beforeValidate/index.js'\nimport { deepCopyObjectSimple, saveVersion } from '../../../index.js'\nimport { deleteAssociatedFiles } from '../../../uploads/deleteAssociatedFiles.js'\nimport { uploadFiles } from '../../../uploads/uploadFiles.js'\nimport { checkDocumentLockStatus } from '../../../utilities/checkDocumentLockStatus.js'\nimport { getLatestCollectionVersion } from '../../../versions/getLatestCollectionVersion.js'\n\nexport type SharedUpdateDocumentArgs<TSlug extends CollectionSlug> = {\n accessResults: AccessResult\n autosave: boolean\n collectionConfig: SanitizedCollectionConfig\n config: SanitizedConfig\n data: DeepPartial<DataFromCollectionSlug<TSlug>>\n depth: number\n docWithLocales: JsonObject & TypeWithID\n draftArg: boolean\n fallbackLocale: string | string[]\n filesToUpload: FileToSave[]\n id: number | string\n locale: string\n overrideAccess: boolean\n overrideLock: boolean\n payload: Payload\n populate?: PopulateType\n publishSpecificLocale?: string\n req: PayloadRequest\n select: SelectType\n showHiddenFields: boolean\n}\n\n/**\n * This function is used to update a document in the DB and return the result.\n *\n * It runs the following hooks in order:\n * - beforeValidate - Fields\n * - beforeValidate - Collection\n * - beforeChange - Collection\n * - beforeChange - Fields\n * - afterRead - Fields\n * - afterRead - Collection\n * - afterChange - Fields\n * - afterChange - Collection\n */\nexport const updateDocument = async <\n TSlug extends CollectionSlug,\n TSelect extends SelectFromCollectionSlug<TSlug> = SelectType,\n>({\n id,\n accessResults,\n autosave,\n collectionConfig,\n config,\n data,\n depth,\n docWithLocales,\n draftArg,\n fallbackLocale,\n filesToUpload,\n locale,\n overrideAccess,\n overrideLock,\n payload,\n populate,\n publishSpecificLocale,\n req,\n select,\n showHiddenFields,\n}: SharedUpdateDocumentArgs<TSlug>): Promise<TransformCollectionWithSelect<TSlug, TSelect>> => {\n const password = data?.password\n const isSavingDraft =\n Boolean(draftArg && collectionConfig.versions.drafts) && data._status !== 'published'\n const shouldSavePassword = Boolean(\n password &&\n collectionConfig.auth &&\n (!collectionConfig.auth.disableLocalStrategy ||\n (typeof collectionConfig.auth.disableLocalStrategy === 'object' &&\n collectionConfig.auth.disableLocalStrategy.enableFields)) &&\n !isSavingDraft,\n )\n\n // /////////////////////////////////////\n // Handle potentially locked documents\n // /////////////////////////////////////\n\n await checkDocumentLockStatus({\n id,\n collectionSlug: collectionConfig.slug,\n lockErrorMessage: `Document with ID ${id} is currently locked by another user and cannot be updated.`,\n overrideLock,\n req,\n })\n\n const originalDoc = await afterRead({\n collection: collectionConfig,\n context: req.context,\n depth: 0,\n doc: deepCopyObjectSimple(docWithLocales),\n draft: draftArg,\n fallbackLocale: id ? null : fallbackLocale,\n global: null,\n locale,\n overrideAccess: true,\n req,\n showHiddenFields: true,\n })\n\n const isRestoringDraftFromTrash = Boolean(originalDoc?.deletedAt) && data?._status !== 'published'\n\n if (collectionConfig.auth) {\n ensureUsernameOrEmail<TSlug>({\n authOptions: collectionConfig.auth,\n collectionSlug: collectionConfig.slug,\n data,\n operation: 'update',\n originalDoc,\n req,\n })\n }\n\n // /////////////////////////////////////\n // Delete any associated files\n // /////////////////////////////////////\n\n await deleteAssociatedFiles({\n collectionConfig,\n config,\n doc: docWithLocales,\n files: filesToUpload,\n overrideDelete: false,\n req,\n })\n\n // /////////////////////////////////////\n // beforeValidate - Fields\n // /////////////////////////////////////\n\n data = await beforeValidate<DeepPartial<DataFromCollectionSlug<TSlug>>>({\n id,\n collection: collectionConfig,\n context: req.context,\n data,\n doc: originalDoc,\n global: null,\n operation: 'update',\n overrideAccess,\n req,\n })\n\n // /////////////////////////////////////\n // beforeValidate - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.beforeValidate?.length) {\n for (const hook of collectionConfig.hooks.beforeValidate) {\n data =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n data,\n operation: 'update',\n originalDoc,\n req,\n })) || data\n }\n }\n\n // /////////////////////////////////////\n // Write files to local storage\n // /////////////////////////////////////\n\n if (!collectionConfig.upload.disableLocalStorage) {\n await uploadFiles(payload, filesToUpload, req)\n }\n\n // /////////////////////////////////////\n // beforeChange - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.beforeChange?.length) {\n for (const hook of collectionConfig.hooks.beforeChange) {\n data =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n data,\n operation: 'update',\n originalDoc,\n req,\n })) || data\n }\n }\n\n // /////////////////////////////////////\n // beforeChange - Fields\n // /////////////////////////////////////\n\n const beforeChangeArgs: Args<DataFromCollectionSlug<TSlug>> = {\n id,\n collection: collectionConfig,\n context: req.context,\n data: { ...data, id },\n doc: originalDoc,\n docWithLocales,\n global: null,\n operation: 'update',\n overrideAccess,\n req,\n skipValidation:\n (isSavingDraft &&\n collectionConfig.versions.drafts &&\n !collectionConfig.versions.drafts.validate) ||\n // Skip validation for trash operations since they're just metadata updates\n (collectionConfig.trash && (Boolean(data?.deletedAt) || isRestoringDraftFromTrash)),\n }\n\n let result: JsonObject = await beforeChange(beforeChangeArgs)\n let snapshotToSave: JsonObject | undefined\n\n if (config.localization && collectionConfig.versions) {\n if (publishSpecificLocale) {\n snapshotToSave = deepCopyObjectSimple(result)\n\n // the published data to save to the main document\n result = await beforeChange({\n ...beforeChangeArgs,\n docWithLocales:\n (await getLatestCollectionVersion({\n id,\n config: collectionConfig,\n payload,\n published: true,\n query: {\n collection: collectionConfig.slug,\n locale,\n req,\n where: combineQueries({ id: { equals: id } }, accessResults),\n },\n req,\n })) || {},\n })\n }\n }\n\n // /////////////////////////////////////\n // Handle potential password update\n // /////////////////////////////////////\n\n const dataToUpdate: JsonObject = { ...result }\n\n if (shouldSavePassword && typeof password === 'string') {\n const { hash, salt } = await generatePasswordSaltHash({\n collection: collectionConfig,\n password,\n req,\n })\n dataToUpdate.salt = salt\n dataToUpdate.hash = hash\n delete dataToUpdate.password\n delete data.password\n }\n\n // /////////////////////////////////////\n // Update\n // /////////////////////////////////////\n\n if (!isSavingDraft) {\n // Ensure updatedAt date is always updated\n dataToUpdate.updatedAt = new Date().toISOString()\n result = await req.payload.db.updateOne({\n id,\n collection: collectionConfig.slug,\n data: dataToUpdate,\n locale,\n req,\n })\n }\n\n // /////////////////////////////////////\n // Create version\n // /////////////////////////////////////\n\n if (collectionConfig.versions) {\n result = await saveVersion({\n id,\n autosave,\n collection: collectionConfig,\n docWithLocales: result,\n draft: isSavingDraft,\n operation: 'update',\n payload,\n publishSpecificLocale,\n req,\n snapshot: snapshotToSave,\n })\n }\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n result = await afterRead({\n collection: collectionConfig,\n context: req.context,\n depth,\n doc: result,\n draft: draftArg,\n fallbackLocale,\n global: null,\n locale,\n overrideAccess,\n populate,\n req,\n select,\n showHiddenFields,\n })\n\n // /////////////////////////////////////\n // afterRead - Collection\n // /////////////////////////////////////\n\n 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,\n req,\n })) || result\n }\n }\n\n // /////////////////////////////////////\n // afterChange - Fields\n // /////////////////////////////////////\n\n result = await afterChange({\n collection: collectionConfig,\n context: req.context,\n data,\n doc: result,\n global: null,\n operation: 'update',\n previousDoc: originalDoc,\n req,\n })\n\n // /////////////////////////////////////\n // afterChange - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.afterChange?.length) {\n for (const hook of collectionConfig.hooks.afterChange) {\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n data,\n doc: result,\n operation: 'update',\n previousDoc: originalDoc,\n req,\n })) || result\n }\n }\n\n return result as TransformCollectionWithSelect<TSlug, TSelect>\n}\n"],"names":["ensureUsernameOrEmail","generatePasswordSaltHash","combineQueries","afterChange","afterRead","beforeChange","beforeValidate","deepCopyObjectSimple","saveVersion","deleteAssociatedFiles","uploadFiles","checkDocumentLockStatus","getLatestCollectionVersion","updateDocument","id","accessResults","autosave","collectionConfig","config","data","depth","docWithLocales","draftArg","fallbackLocale","filesToUpload","locale","overrideAccess","overrideLock","payload","populate","publishSpecificLocale","req","select","showHiddenFields","password","isSavingDraft","Boolean","versions","drafts","_status","shouldSavePassword","auth","disableLocalStrategy","enableFields","collectionSlug","slug","lockErrorMessage","originalDoc","collection","context","doc","draft","global","isRestoringDraftFromTrash","deletedAt","authOptions","operation","files","overrideDelete","hooks","length","hook","upload","disableLocalStorage","beforeChangeArgs","skipValidation","validate","trash","result","snapshotToSave","localization","published","query","where","equals","dataToUpdate","hash","salt","updatedAt","Date","toISOString","db","updateOne","snapshot","previousDoc"],"mappings":"AAmBA,SAASA,q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AK,EAAEvD,WAAWwD,QAAQ;QAC7C,KAAK,MAAMC,QAAQ5C,iBAAiB0C,KAAK,CAACvD,SAAS,CAAE;YACnDgE,SACE,AAAC,MAAMP,KAAK;gBACVb,YAAY/B;gBACZgC,SAASlB,IAAIkB,OAAO;gBACpBC,KAAKkB;gBACLrC;YACF,MAAOqC;QACX;IACF;IAEA,wCAAwC;IACxC,uBAAuB;IACvB,wCAAwC;IAExCA,SAAS,MAAMjE,YAAY;QACzB6C,YAAY/B;QACZgC,SAASlB,IAAIkB,OAAO;QACpB9B;QACA+B,KAAKkB;QACLhB,QAAQ;QACRI,WAAW;QACX4B,aAAarC;QACbhB;IACF;IAEA,wCAAwC;IACxC,2BAA2B;IAC3B,wCAAwC;IAExC,IAAId,iBAAiB0C,KAAK,EAAExD,aAAayD,QAAQ;QAC/C,KAAK,MAAMC,QAAQ5C,iBAAiB0C,KAAK,CAACxD,WAAW,CAAE;YACrDiE,SACE,AAAC,MAAMP,KAAK;gBACVb,YAAY/B;gBACZgC,SAASlB,IAAIkB,OAAO;gBACpB9B;gBACA+B,KAAKkB;gBACLZ,WAAW;gBACX4B,aAAarC;gBACbhB;YACF,MAAOqC;QACX;IACF;IAEA,OAAOA;AACT,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/collections/operations/utilities/update.ts"],"sourcesContent":["import type { DeepPartial } from 'ts-essentials'\n\nimport type { Args } from '../../../fields/hooks/beforeChange/index.js'\nimport type {\n AccessResult,\n CollectionSlug,\n FileToSave,\n SanitizedConfig,\n TypedFallbackLocale,\n} from '../../../index.js'\nimport type {\n JsonObject,\n Payload,\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformCollectionWithSelect,\n} from '../../../types/index.js'\nimport type {\n DataFromCollectionSlug,\n SanitizedCollectionConfig,\n SelectFromCollectionSlug,\n TypeWithID,\n} from '../../config/types.js'\n\nimport { ensureUsernameOrEmail } from '../../../auth/ensureUsernameOrEmail.js'\nimport { generatePasswordSaltHash } from '../../../auth/strategies/local/generatePasswordSaltHash.js'\nimport { combineQueries } from '../../../database/combineQueries.js'\nimport { afterChange } from '../../../fields/hooks/afterChange/index.js'\nimport { afterRead } from '../../../fields/hooks/afterRead/index.js'\nimport { beforeChange } from '../../../fields/hooks/beforeChange/index.js'\nimport { beforeValidate } from '../../../fields/hooks/beforeValidate/index.js'\nimport { deepCopyObjectSimple, saveVersion } from '../../../index.js'\nimport { deleteAssociatedFiles } from '../../../uploads/deleteAssociatedFiles.js'\nimport { uploadFiles } from '../../../uploads/uploadFiles.js'\nimport { checkDocumentLockStatus } from '../../../utilities/checkDocumentLockStatus.js'\nimport { getLatestCollectionVersion } from '../../../versions/getLatestCollectionVersion.js'\n\nexport type SharedUpdateDocumentArgs<TSlug extends CollectionSlug> = {\n accessResults: AccessResult\n autosave: boolean\n collectionConfig: SanitizedCollectionConfig\n config: SanitizedConfig\n data: DeepPartial<DataFromCollectionSlug<TSlug>>\n depth: number\n docWithLocales: JsonObject & TypeWithID\n draftArg: boolean\n fallbackLocale: TypedFallbackLocale\n filesToUpload: FileToSave[]\n id: number | string\n locale: string\n overrideAccess: boolean\n overrideLock: boolean\n payload: Payload\n populate?: PopulateType\n publishSpecificLocale?: string\n req: PayloadRequest\n select: SelectType\n showHiddenFields: boolean\n}\n\n/**\n * This function is used to update a document in the DB and return the result.\n *\n * It runs the following hooks in order:\n * - beforeValidate - Fields\n * - beforeValidate - Collection\n * - beforeChange - Collection\n * - beforeChange - Fields\n * - afterRead - Fields\n * - afterRead - Collection\n * - afterChange - Fields\n * - afterChange - Collection\n */\nexport const updateDocument = async <\n TSlug extends CollectionSlug,\n TSelect extends SelectFromCollectionSlug<TSlug> = SelectType,\n>({\n id,\n accessResults,\n autosave,\n collectionConfig,\n config,\n data,\n depth,\n docWithLocales,\n draftArg,\n fallbackLocale,\n filesToUpload,\n locale,\n overrideAccess,\n overrideLock,\n payload,\n populate,\n publishSpecificLocale,\n req,\n select,\n showHiddenFields,\n}: SharedUpdateDocumentArgs<TSlug>): Promise<TransformCollectionWithSelect<TSlug, TSelect>> => {\n const password = data?.password\n const isSavingDraft =\n Boolean(draftArg && collectionConfig.versions.drafts) && data._status !== 'published'\n const shouldSavePassword = Boolean(\n password &&\n collectionConfig.auth &&\n (!collectionConfig.auth.disableLocalStrategy ||\n (typeof collectionConfig.auth.disableLocalStrategy === 'object' &&\n collectionConfig.auth.disableLocalStrategy.enableFields)) &&\n !isSavingDraft,\n )\n\n // /////////////////////////////////////\n // Handle potentially locked documents\n // /////////////////////////////////////\n\n await checkDocumentLockStatus({\n id,\n collectionSlug: collectionConfig.slug,\n lockErrorMessage: `Document with ID ${id} is currently locked by another user and cannot be updated.`,\n overrideLock,\n req,\n })\n\n const originalDoc = await afterRead({\n collection: collectionConfig,\n context: req.context,\n depth: 0,\n doc: deepCopyObjectSimple(docWithLocales),\n draft: draftArg,\n fallbackLocale: id ? null : fallbackLocale,\n global: null,\n locale,\n overrideAccess: true,\n req,\n showHiddenFields: true,\n })\n\n const isRestoringDraftFromTrash = Boolean(originalDoc?.deletedAt) && data?._status !== 'published'\n\n if (collectionConfig.auth) {\n ensureUsernameOrEmail<TSlug>({\n authOptions: collectionConfig.auth,\n collectionSlug: collectionConfig.slug,\n data,\n operation: 'update',\n originalDoc,\n req,\n })\n }\n\n // /////////////////////////////////////\n // Delete any associated files\n // /////////////////////////////////////\n\n await deleteAssociatedFiles({\n collectionConfig,\n config,\n doc: docWithLocales,\n files: filesToUpload,\n overrideDelete: false,\n req,\n })\n\n // /////////////////////////////////////\n // beforeValidate - Fields\n // /////////////////////////////////////\n\n data = await beforeValidate<DeepPartial<DataFromCollectionSlug<TSlug>>>({\n id,\n collection: collectionConfig,\n context: req.context,\n data,\n doc: originalDoc,\n global: null,\n operation: 'update',\n overrideAccess,\n req,\n })\n\n // /////////////////////////////////////\n // beforeValidate - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.beforeValidate?.length) {\n for (const hook of collectionConfig.hooks.beforeValidate) {\n data =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n data,\n operation: 'update',\n originalDoc,\n req,\n })) || data\n }\n }\n\n // /////////////////////////////////////\n // Write files to local storage\n // /////////////////////////////////////\n\n if (!collectionConfig.upload.disableLocalStorage) {\n await uploadFiles(payload, filesToUpload, req)\n }\n\n // /////////////////////////////////////\n // beforeChange - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.beforeChange?.length) {\n for (const hook of collectionConfig.hooks.beforeChange) {\n data =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n data,\n operation: 'update',\n originalDoc,\n req,\n })) || data\n }\n }\n\n // /////////////////////////////////////\n // beforeChange - Fields\n // /////////////////////////////////////\n\n const beforeChangeArgs: Args<DataFromCollectionSlug<TSlug>> = {\n id,\n collection: collectionConfig,\n context: req.context,\n data: { ...data, id },\n doc: originalDoc,\n docWithLocales,\n global: null,\n operation: 'update',\n overrideAccess,\n req,\n skipValidation:\n (isSavingDraft &&\n collectionConfig.versions.drafts &&\n !collectionConfig.versions.drafts.validate) ||\n // Skip validation for trash operations since they're just metadata updates\n (collectionConfig.trash && (Boolean(data?.deletedAt) || isRestoringDraftFromTrash)),\n }\n\n let result: JsonObject = await beforeChange(beforeChangeArgs)\n let snapshotToSave: JsonObject | undefined\n\n if (config.localization && collectionConfig.versions) {\n if (publishSpecificLocale) {\n snapshotToSave = deepCopyObjectSimple(result)\n\n // the published data to save to the main document\n result = await beforeChange({\n ...beforeChangeArgs,\n docWithLocales:\n (await getLatestCollectionVersion({\n id,\n config: collectionConfig,\n payload,\n published: true,\n query: {\n collection: collectionConfig.slug,\n locale,\n req,\n where: combineQueries({ id: { equals: id } }, accessResults),\n },\n req,\n })) || {},\n })\n }\n }\n\n // /////////////////////////////////////\n // Handle potential password update\n // /////////////////////////////////////\n\n const dataToUpdate: JsonObject = { ...result }\n\n if (shouldSavePassword && typeof password === 'string') {\n const { hash, salt } = await generatePasswordSaltHash({\n collection: collectionConfig,\n password,\n req,\n })\n dataToUpdate.salt = salt\n dataToUpdate.hash = hash\n delete dataToUpdate.password\n delete data.password\n }\n\n // /////////////////////////////////////\n // Update\n // /////////////////////////////////////\n\n if (!isSavingDraft) {\n // Ensure updatedAt date is always updated\n dataToUpdate.updatedAt = new Date().toISOString()\n result = await req.payload.db.updateOne({\n id,\n collection: collectionConfig.slug,\n data: dataToUpdate,\n locale,\n req,\n })\n }\n\n // /////////////////////////////////////\n // Create version\n // /////////////////////////////////////\n\n if (collectionConfig.versions) {\n result = await saveVersion({\n id,\n autosave,\n collection: collectionConfig,\n docWithLocales: result,\n draft: isSavingDraft,\n operation: 'update',\n payload,\n publishSpecificLocale,\n req,\n snapshot: snapshotToSave,\n })\n }\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n result = await afterRead({\n collection: collectionConfig,\n context: req.context,\n depth,\n doc: result,\n draft: draftArg,\n fallbackLocale,\n global: null,\n locale,\n overrideAccess,\n populate,\n req,\n select,\n showHiddenFields,\n })\n\n // /////////////////////////////////////\n // afterRead - Collection\n // /////////////////////////////////////\n\n 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,\n req,\n })) || result\n }\n }\n\n // /////////////////////////////////////\n // afterChange - Fields\n // /////////////////////////////////////\n\n result = await afterChange({\n collection: collectionConfig,\n context: req.context,\n data,\n doc: result,\n global: null,\n operation: 'update',\n previousDoc: originalDoc,\n req,\n })\n\n // /////////////////////////////////////\n // afterChange - Collection\n // /////////////////////////////////////\n\n if (collectionConfig.hooks?.afterChange?.length) {\n for (const hook of collectionConfig.hooks.afterChange) {\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n data,\n doc: result,\n operation: 'update',\n previousDoc: originalDoc,\n req,\n })) || result\n }\n }\n\n return result as TransformCollectionWithSelect<TSlug, TSelect>\n}\n"],"names":["ensureUsernameOrEmail","generatePasswordSaltHash","combineQueries","afterChange","afterRead","beforeChange","beforeValidate","deepCopyObjectSimple","saveVersion","deleteAssociatedFiles","uploadFiles","checkDocumentLockStatus","getLatestCollectionVersion","updateDocument","id","accessResults","autosave","collectionConfig","config","data","depth","docWithLocales","draftArg","fallbackLocale","filesToUpload","locale","overrideAccess","overrideLock","payload","populate","publishSpecificLocale","req","select","showHiddenFields","password","isSavingDraft","Boolean","versions","drafts","_status","shouldSavePassword","auth","disableLocalStrategy","enableFields","collectionSlug","slug","lockErrorMessage","originalDoc","collection","context","doc","draft","global","isRestoringDraftFromTrash","deletedAt","authOptions","operation","files","overrideDelete","hooks","length","hook","upload","disableLocalStorage","beforeChangeArgs","skipValidation","validate","trash","result","snapshotToSave","localization","published","query","where","equals","dataToUpdate","hash","salt","updatedAt","Date","toISOString","db","updateOne","snapshot","previousDoc"],"mappings":"AAyBA,SAASA,qBAAqB,QAAQ,yCAAwC;AAC9E,SAASC,wBAAwB,QAAQ,6DAA4D;AACrG,SAASC,cAAc,QAAQ,sCAAqC;AACpE,SAASC,WAAW,QAAQ,6CAA4C;AACxE,SAASC,SAAS,QAAQ,2CAA0C;AACpE,SAASC,YAAY,QAAQ,8CAA6C;AAC1E,SAASC,cAAc,QAAQ,gDAA+C;AAC9E,SAASC,oBAAoB,EAAEC,WAAW,QAAQ,oBAAmB;AACrE,SAASC,qBAAqB,QAAQ,4CAA2C;AACjF,SAASC,WAAW,QAAQ,kCAAiC;AAC7D,SAASC,uBAAuB,QAAQ,gDAA+C;AACvF,SAASC,0BAA0B,QAAQ,kDAAiD;AAyB5F;;;;;;;;;;;;CAYC,GACD,OAAO,MAAMC,iBAAiB,OAG5B,EACAC,EAAE,EACFC,aAAa,EACbC,QAAQ,EACRC,gBAAgB,EAChBC,MAAM,EACNC,IAAI,EACJC,KAAK,EACLC,cAAc,EACdC,QAAQ,EACRC,cAAc,EACdC,aAAa,EACbC,MAAM,EACNC,cAAc,EACdC,YAAY,EACZC,OAAO,EACPC,QAAQ,EACRC,qBAAqB,EACrBC,GAAG,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ACbhB;YACF,MAAOqC;QACX;IACF;IAEA,OAAOA;AACT,EAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SanitizedCollectionConfig } from '../../../collections/config/types.js';
|
|
2
2
|
import type { SanitizedGlobalConfig } from '../../../globals/config/types.js';
|
|
3
|
-
import type { RequestContext } from '../../../index.js';
|
|
3
|
+
import type { RequestContext, TypedFallbackLocale } from '../../../index.js';
|
|
4
4
|
import type { JsonObject, PayloadRequest, PopulateType, SelectType } from '../../../types/index.js';
|
|
5
5
|
export type AfterReadArgs<T extends JsonObject> = {
|
|
6
6
|
collection: null | SanitizedCollectionConfig;
|
|
@@ -9,7 +9,7 @@ export type AfterReadArgs<T extends JsonObject> = {
|
|
|
9
9
|
depth: number;
|
|
10
10
|
doc: T;
|
|
11
11
|
draft: boolean;
|
|
12
|
-
fallbackLocale:
|
|
12
|
+
fallbackLocale: TypedFallbackLocale;
|
|
13
13
|
findMany?: boolean;
|
|
14
14
|
/**
|
|
15
15
|
* Controls whether locales should be flattened into the requested locale.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/afterRead/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/afterRead/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAC5E,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAKnG,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,UAAU,IAAI;IAChD,UAAU,EAAE,IAAI,GAAG,yBAAyB,CAAA;IAC5C,OAAO,EAAE,cAAc,CAAA;IACvB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,CAAC,CAAA;IACN,KAAK,EAAE,OAAO,CAAA;IACd,cAAc,EAAE,mBAAmB,CAAA;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,MAAM,EAAE,IAAI,GAAG,qBAAqB,CAAA;IACpC,MAAM,EAAE,MAAM,CAAA;IACd,cAAc,EAAE,OAAO,CAAA;IACvB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,GAAG,EAAE,cAAc,CAAA;IACnB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,gBAAgB,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED;;;;;;;;GAQG;AAEH,wBAAsB,SAAS,CAAC,CAAC,SAAS,UAAU,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAmFxF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/fields/hooks/afterRead/index.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { RequestContext } from '../../../index.js'\nimport type { JsonObject, PayloadRequest, PopulateType, SelectType } from '../../../types/index.js'\n\nimport { getSelectMode } from '../../../utilities/getSelectMode.js'\nimport { traverseFields } from './traverseFields.js'\n\nexport type AfterReadArgs<T extends JsonObject> = {\n collection: null | SanitizedCollectionConfig\n context: RequestContext\n currentDepth?: number\n depth: number\n doc: T\n draft: boolean\n fallbackLocale:
|
|
1
|
+
{"version":3,"sources":["../../../../src/fields/hooks/afterRead/index.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { RequestContext, TypedFallbackLocale } from '../../../index.js'\nimport type { JsonObject, PayloadRequest, PopulateType, SelectType } from '../../../types/index.js'\n\nimport { getSelectMode } from '../../../utilities/getSelectMode.js'\nimport { traverseFields } from './traverseFields.js'\n\nexport type AfterReadArgs<T extends JsonObject> = {\n collection: null | SanitizedCollectionConfig\n context: RequestContext\n currentDepth?: number\n depth: number\n doc: T\n draft: boolean\n fallbackLocale: TypedFallbackLocale\n findMany?: boolean\n /**\n * Controls whether locales should be flattened into the requested locale.\n * E.g.: { [locale]: fields } -> fields\n *\n * @default true\n */\n flattenLocales?: boolean\n global: null | SanitizedGlobalConfig\n locale: string\n overrideAccess: boolean\n populate?: PopulateType\n req: PayloadRequest\n select?: SelectType\n showHiddenFields: boolean\n}\n\n/**\n * This function is responsible for the following actions, in order:\n * - Remove hidden fields from response\n * - Flatten locales into requested locale. If the input doc contains all locales, the output doc after this function will only contain the requested locale.\n * - Sanitize outgoing data (point field, etc.)\n * - Execute field hooks\n * - Execute read access control\n * - Populate relationships\n */\n\nexport async function afterRead<T extends JsonObject>(args: AfterReadArgs<T>): Promise<T> {\n const {\n collection,\n context,\n currentDepth: incomingCurrentDepth,\n depth: incomingDepth,\n doc: incomingDoc,\n draft,\n fallbackLocale,\n findMany,\n flattenLocales = true,\n global,\n locale,\n overrideAccess,\n populate,\n req,\n select,\n showHiddenFields,\n } = args\n\n const fieldPromises: Promise<void>[] = []\n const populationPromises: Promise<void>[] = []\n\n let depth =\n incomingDepth || incomingDepth === 0\n ? parseInt(String(incomingDepth), 10)\n : req.payload.config.defaultDepth\n if (depth > req.payload.config.maxDepth) {\n depth = req.payload.config.maxDepth\n }\n\n const currentDepth = incomingCurrentDepth || 1\n\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc: incomingDoc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: (collection?.fields || global?.fields)!,\n findMany: findMany!,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n parentIndexPath: '',\n parentIsLocalized: false,\n parentPath: '',\n parentSchemaPath: '',\n populate,\n populationPromises,\n req,\n select,\n selectMode: select ? getSelectMode(select) : undefined,\n showHiddenFields,\n siblingDoc: incomingDoc,\n })\n\n /**\n * Await all field and population promises in parallel.\n * A field promise is able to add more field promises to the fieldPromises array, which will not be\n * awaited in the first run.\n * This is why we need to loop again to process the new field promises, until there are no more field promises left.\n */\n let iterations = 0\n while (fieldPromises.length > 0 || populationPromises.length > 0) {\n const currentFieldPromises = fieldPromises.splice(0, fieldPromises.length)\n const currentPopulationPromises = populationPromises.splice(0, populationPromises.length)\n\n await Promise.all(currentFieldPromises)\n await Promise.all(currentPopulationPromises)\n\n iterations++\n if (iterations >= 100) {\n throw new Error(\n 'Infinite afterRead promise loop detected. A hook is likely adding field promises in an infinitely recursive way.',\n )\n }\n }\n return incomingDoc\n}\n"],"names":["getSelectMode","traverseFields","afterRead","args","collection","context","currentDepth","incomingCurrentDepth","depth","incomingDepth","doc","incomingDoc","draft","fallbackLocale","findMany","flattenLocales","global","locale","overrideAccess","populate","req","select","showHiddenFields","fieldPromises","populationPromises","parseInt","String","payload","config","defaultDepth","maxDepth","fields","parentIndexPath","parentIsLocalized","parentPath","parentSchemaPath","selectMode","undefined","siblingDoc","iterations","length","currentFieldPromises","splice","currentPopulationPromises","Promise","all","Error"],"mappings":"AAKA,SAASA,aAAa,QAAQ,sCAAqC;AACnE,SAASC,cAAc,QAAQ,sBAAqB;AA2BpD;;;;;;;;CAQC,GAED,OAAO,eAAeC,UAAgCC,IAAsB;IAC1E,MAAM,EACJC,UAAU,EACVC,OAAO,EACPC,cAAcC,oBAAoB,EAClCC,OAAOC,aAAa,EACpBC,KAAKC,WAAW,EA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type { SanitizedCollectionConfig } from '../../../collections/config/types.js';
|
|
2
2
|
import type { SanitizedGlobalConfig } from '../../../globals/config/types.js';
|
|
3
|
+
import type { RequestContext, TypedFallbackLocale } from '../../../index.js';
|
|
3
4
|
import type { JsonObject, PayloadRequest, PopulateType, SelectMode, SelectType } from '../../../types/index.js';
|
|
4
5
|
import type { Field, TabAsField } from '../../config/types.js';
|
|
5
6
|
import type { AfterReadArgs } from './index.js';
|
|
6
|
-
import { type RequestContext } from '../../../index.js';
|
|
7
7
|
type Args = {
|
|
8
8
|
/**
|
|
9
9
|
* Data of the nearest parent block. If no parent block exists, this will be the `undefined`
|
|
@@ -15,7 +15,7 @@ type Args = {
|
|
|
15
15
|
depth: number;
|
|
16
16
|
doc: JsonObject;
|
|
17
17
|
draft: boolean;
|
|
18
|
-
fallbackLocale:
|
|
18
|
+
fallbackLocale: TypedFallbackLocale;
|
|
19
19
|
field: Field | TabAsField;
|
|
20
20
|
fieldIndex: number;
|
|
21
21
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/afterRead/promise.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAC7E,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,YAAY,EACZ,UAAU,EACV,UAAU,EACX,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAS,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/afterRead/promise.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAA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