payload 3.59.0-internal.ff6711a → 3.59.0

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.
Files changed (49) hide show
  1. package/dist/admin/forms/Form.d.ts +2 -2
  2. package/dist/admin/forms/Form.js.map +1 -1
  3. package/dist/collections/config/types.d.ts +2 -2
  4. package/dist/collections/config/types.js.map +1 -1
  5. package/dist/collections/operations/findDistinct.d.ts.map +1 -1
  6. package/dist/collections/operations/findDistinct.js +2 -0
  7. package/dist/collections/operations/findDistinct.js.map +1 -1
  8. package/dist/config/types.d.ts +2 -2
  9. package/dist/config/types.js.map +1 -1
  10. package/dist/database/getLocalizedPaths.d.ts.map +1 -1
  11. package/dist/database/getLocalizedPaths.js +5 -0
  12. package/dist/database/getLocalizedPaths.js.map +1 -1
  13. package/dist/exports/shared.d.ts +1 -0
  14. package/dist/exports/shared.d.ts.map +1 -1
  15. package/dist/exports/shared.js +1 -0
  16. package/dist/exports/shared.js.map +1 -1
  17. package/dist/fields/baseFields/slug/countVersions.d.ts +13 -0
  18. package/dist/fields/baseFields/slug/countVersions.d.ts.map +1 -0
  19. package/dist/fields/baseFields/slug/countVersions.js +31 -0
  20. package/dist/fields/baseFields/slug/countVersions.js.map +1 -0
  21. package/dist/fields/baseFields/slug/generateSlug.d.ts +7 -0
  22. package/dist/fields/baseFields/slug/generateSlug.d.ts.map +1 -0
  23. package/dist/fields/baseFields/slug/generateSlug.js +60 -0
  24. package/dist/fields/baseFields/slug/generateSlug.js.map +1 -0
  25. package/dist/fields/baseFields/slug/index.d.ts +60 -0
  26. package/dist/fields/baseFields/slug/index.d.ts.map +1 -0
  27. package/dist/fields/baseFields/slug/index.js +67 -0
  28. package/dist/fields/baseFields/slug/index.js.map +1 -0
  29. package/dist/fields/config/types.d.ts +46 -47
  30. package/dist/fields/config/types.d.ts.map +1 -1
  31. package/dist/fields/config/types.js.map +1 -1
  32. package/dist/index.bundled.d.ts +114 -56
  33. package/dist/index.d.ts +1 -0
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +4 -1
  36. package/dist/index.js.map +1 -1
  37. package/dist/utilities/getFieldByPath.d.ts +4 -1
  38. package/dist/utilities/getFieldByPath.d.ts.map +1 -1
  39. package/dist/utilities/getFieldByPath.js +9 -1
  40. package/dist/utilities/getFieldByPath.js.map +1 -1
  41. package/dist/utilities/slugify.d.ts +2 -0
  42. package/dist/utilities/slugify.d.ts.map +1 -0
  43. package/dist/utilities/slugify.js +3 -0
  44. package/dist/utilities/slugify.js.map +1 -0
  45. package/dist/utilities/toKebabCase.d.ts +1 -1
  46. package/dist/utilities/toKebabCase.d.ts.map +1 -1
  47. package/dist/utilities/toKebabCase.js +1 -1
  48. package/dist/utilities/toKebabCase.js.map +1 -1
  49. package/package.json +2 -2
@@ -62,7 +62,7 @@ export type FieldState = {
62
62
  * Every time a field is changed locally, this flag is set to true. Prevents form state from server from overwriting local changes.
63
63
  * After merging server form state, this flag is reset.
64
64
  *
65
- * @experimental This property is experimental and may change in the future. Use at your own discretion.
65
+ * @experimental This property is experimental and may change in the future. Use at your own risk.
66
66
  */
67
67
  isModified?: boolean;
68
68
  /**
@@ -137,7 +137,7 @@ export type BuildFormStateArgs = {
137
137
  * This will retrieve the client config in its entirety, even when unauthenticated.
138
138
  * For example, the create-first-user view needs the entire config, but there is no user yet.
139
139
  *
140
- * @experimental This property is experimental and may change in the future. Use at your own discretion.
140
+ * @experimental This property is experimental and may change in the future. Use at your own risk.
141
141
  */
142
142
  skipClientConfigAuth?: boolean;
143
143
  skipValidation?: boolean;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/admin/forms/Form.ts"],"sourcesContent":["import { type SupportedLanguages } from '@payloadcms/translations'\n\nimport type { SanitizedDocumentPermissions } from '../../auth/types.js'\nimport type { Field, Option, Validate } from '../../fields/config/types.js'\nimport type { TypedLocale } from '../../index.js'\nimport type { DocumentPreferences } from '../../preferences/types.js'\nimport type { PayloadRequest, SelectType, Where } from '../../types/index.js'\n\nexport type Data = {\n [key: string]: any\n}\n\nexport type Row = {\n addedByServer?: FieldState['addedByServer']\n blockType?: string\n collapsed?: boolean\n customComponents?: {\n RowLabel?: React.ReactNode\n }\n id: string\n isLoading?: boolean\n lastRenderedPath?: string\n}\n\nexport type FilterOptionsResult = {\n [relation: string]: boolean | Where\n}\n\nexport type FieldState = {\n /**\n * This is used to determine if the field was added by the server.\n * This ensures the field is not ignored by the client when merging form state.\n * This can happen because the current local state is treated as the source of truth.\n * See `mergeServerFormState` for more details.\n */\n addedByServer?: boolean\n /**\n * If the field is a `blocks` field, this will contain the slugs of blocks that are allowed, based on the result of `field.filterOptions`.\n * If this is undefined, all blocks are allowed.\n * If this is an empty array, no blocks are allowed.\n */\n blocksFilterOptions?: string[]\n customComponents?: {\n /**\n * This is used by UI fields, as they can have arbitrary components defined if used\n * as a vessel to bring in custom components.\n */\n [key: string]: React.ReactNode | React.ReactNode[] | undefined\n AfterInput?: React.ReactNode\n BeforeInput?: React.ReactNode\n Description?: React.ReactNode\n Error?: React.ReactNode\n Field?: React.ReactNode\n Label?: React.ReactNode\n }\n disableFormData?: boolean\n errorMessage?: string\n errorPaths?: string[]\n /**\n * The fieldSchema may be part of the form state if `includeSchema: true` is passed to buildFormState.\n * This will never be in the form state of the client.\n */\n fieldSchema?: Field\n filterOptions?: FilterOptionsResult\n initialValue?: unknown\n /**\n * Every time a field is changed locally, this flag is set to true. Prevents form state from server from overwriting local changes.\n * After merging server form state, this flag is reset.\n *\n * @experimental This property is experimental and may change in the future. Use at your own discretion.\n */\n isModified?: boolean\n /**\n * The path of the field when its custom components were last rendered.\n * This is used to denote if a field has been rendered, and if so,\n * what path it was rendered under last.\n *\n * If this path is undefined, or, if it is different\n * from the current path of a given field, the field's components will be re-rendered.\n */\n lastRenderedPath?: string\n passesCondition?: boolean\n rows?: Row[]\n /**\n * The result of running `field.filterOptions` on select fields.\n */\n selectFilterOptions?: Option[]\n valid?: boolean\n validate?: Validate\n value?: unknown\n}\n\nexport type FieldStateWithoutComponents = Omit<FieldState, 'customComponents'>\n\nexport type FormState = {\n [path: string]: FieldState\n}\n\nexport type FormStateWithoutComponents = {\n [path: string]: FieldStateWithoutComponents\n}\n\nexport type BuildFormStateArgs = {\n data?: Data\n docPermissions: SanitizedDocumentPermissions | undefined\n docPreferences: DocumentPreferences\n /**\n * In case `formState` is not the top-level, document form state, this can be passed to\n * provide the top-level form state.\n */\n documentFormState?: FormState\n fallbackLocale?: false | TypedLocale\n formState?: FormState\n id?: number | string\n initialBlockData?: Data\n initialBlockFormState?: FormState\n /*\n If not i18n was passed, the language can be passed to init i18n\n */\n language?: keyof SupportedLanguages\n locale?: string\n /**\n * If true, will not render RSCs and instead return a simple string in their place.\n * This is useful for environments that lack RSC support, such as Jest.\n * Form state can still be built, but any server components will be omitted.\n * @default false\n */\n mockRSCs?: boolean\n operation?: 'create' | 'update'\n readOnly?: boolean\n /**\n * If true, will render field components within their state object.\n * Performance optimization: Setting to `false` ensures that only fields that have changed paths will re-render, e.g. new array rows, etc.\n * For example, you only need to render ALL fields on initial render, not on every onChange.\n */\n renderAllFields?: boolean\n req: PayloadRequest\n /**\n * If true, will return a fresh URL for live preview based on the current form state.\n * Note: this will run on every form state event, so if your `livePreview.url` function is long running or expensive,\n * ensure it caches itself as needed.\n */\n returnLivePreviewURL?: boolean\n returnLockStatus?: boolean\n schemaPath: string\n select?: SelectType\n /**\n * When true, sets `user: true` when calling `getClientConfig`.\n * This will retrieve the client config in its entirety, even when unauthenticated.\n * For example, the create-first-user view needs the entire config, but there is no user yet.\n *\n * @experimental This property is experimental and may change in the future. Use at your own discretion.\n */\n skipClientConfigAuth?: boolean\n skipValidation?: boolean\n updateLastEdited?: boolean\n} & (\n | {\n collectionSlug: string\n // Do not type it as never. This still makes it so that either collectionSlug or globalSlug is required, but makes it easier to provide both collectionSlug and globalSlug if it's\n // unclear which one is actually available.\n globalSlug?: string\n }\n | {\n collectionSlug?: string\n globalSlug: string\n }\n)\n"],"names":[],"mappings":"AAsGA,WAiEC"}
1
+ {"version":3,"sources":["../../../src/admin/forms/Form.ts"],"sourcesContent":["import { type SupportedLanguages } from '@payloadcms/translations'\n\nimport type { SanitizedDocumentPermissions } from '../../auth/types.js'\nimport type { Field, Option, Validate } from '../../fields/config/types.js'\nimport type { TypedLocale } from '../../index.js'\nimport type { DocumentPreferences } from '../../preferences/types.js'\nimport type { PayloadRequest, SelectType, Where } from '../../types/index.js'\n\nexport type Data = {\n [key: string]: any\n}\n\nexport type Row = {\n addedByServer?: FieldState['addedByServer']\n blockType?: string\n collapsed?: boolean\n customComponents?: {\n RowLabel?: React.ReactNode\n }\n id: string\n isLoading?: boolean\n lastRenderedPath?: string\n}\n\nexport type FilterOptionsResult = {\n [relation: string]: boolean | Where\n}\n\nexport type FieldState = {\n /**\n * This is used to determine if the field was added by the server.\n * This ensures the field is not ignored by the client when merging form state.\n * This can happen because the current local state is treated as the source of truth.\n * See `mergeServerFormState` for more details.\n */\n addedByServer?: boolean\n /**\n * If the field is a `blocks` field, this will contain the slugs of blocks that are allowed, based on the result of `field.filterOptions`.\n * If this is undefined, all blocks are allowed.\n * If this is an empty array, no blocks are allowed.\n */\n blocksFilterOptions?: string[]\n customComponents?: {\n /**\n * This is used by UI fields, as they can have arbitrary components defined if used\n * as a vessel to bring in custom components.\n */\n [key: string]: React.ReactNode | React.ReactNode[] | undefined\n AfterInput?: React.ReactNode\n BeforeInput?: React.ReactNode\n Description?: React.ReactNode\n Error?: React.ReactNode\n Field?: React.ReactNode\n Label?: React.ReactNode\n }\n disableFormData?: boolean\n errorMessage?: string\n errorPaths?: string[]\n /**\n * The fieldSchema may be part of the form state if `includeSchema: true` is passed to buildFormState.\n * This will never be in the form state of the client.\n */\n fieldSchema?: Field\n filterOptions?: FilterOptionsResult\n initialValue?: unknown\n /**\n * Every time a field is changed locally, this flag is set to true. Prevents form state from server from overwriting local changes.\n * After merging server form state, this flag is reset.\n *\n * @experimental This property is experimental and may change in the future. Use at your own risk.\n */\n isModified?: boolean\n /**\n * The path of the field when its custom components were last rendered.\n * This is used to denote if a field has been rendered, and if so,\n * what path it was rendered under last.\n *\n * If this path is undefined, or, if it is different\n * from the current path of a given field, the field's components will be re-rendered.\n */\n lastRenderedPath?: string\n passesCondition?: boolean\n rows?: Row[]\n /**\n * The result of running `field.filterOptions` on select fields.\n */\n selectFilterOptions?: Option[]\n valid?: boolean\n validate?: Validate\n value?: unknown\n}\n\nexport type FieldStateWithoutComponents = Omit<FieldState, 'customComponents'>\n\nexport type FormState = {\n [path: string]: FieldState\n}\n\nexport type FormStateWithoutComponents = {\n [path: string]: FieldStateWithoutComponents\n}\n\nexport type BuildFormStateArgs = {\n data?: Data\n docPermissions: SanitizedDocumentPermissions | undefined\n docPreferences: DocumentPreferences\n /**\n * In case `formState` is not the top-level, document form state, this can be passed to\n * provide the top-level form state.\n */\n documentFormState?: FormState\n fallbackLocale?: false | TypedLocale\n formState?: FormState\n id?: number | string\n initialBlockData?: Data\n initialBlockFormState?: FormState\n /*\n If not i18n was passed, the language can be passed to init i18n\n */\n language?: keyof SupportedLanguages\n locale?: string\n /**\n * If true, will not render RSCs and instead return a simple string in their place.\n * This is useful for environments that lack RSC support, such as Jest.\n * Form state can still be built, but any server components will be omitted.\n * @default false\n */\n mockRSCs?: boolean\n operation?: 'create' | 'update'\n readOnly?: boolean\n /**\n * If true, will render field components within their state object.\n * Performance optimization: Setting to `false` ensures that only fields that have changed paths will re-render, e.g. new array rows, etc.\n * For example, you only need to render ALL fields on initial render, not on every onChange.\n */\n renderAllFields?: boolean\n req: PayloadRequest\n /**\n * If true, will return a fresh URL for live preview based on the current form state.\n * Note: this will run on every form state event, so if your `livePreview.url` function is long running or expensive,\n * ensure it caches itself as needed.\n */\n returnLivePreviewURL?: boolean\n returnLockStatus?: boolean\n schemaPath: string\n select?: SelectType\n /**\n * When true, sets `user: true` when calling `getClientConfig`.\n * This will retrieve the client config in its entirety, even when unauthenticated.\n * For example, the create-first-user view needs the entire config, but there is no user yet.\n *\n * @experimental This property is experimental and may change in the future. Use at your own risk.\n */\n skipClientConfigAuth?: boolean\n skipValidation?: boolean\n updateLastEdited?: boolean\n} & (\n | {\n collectionSlug: string\n // Do not type it as never. This still makes it so that either collectionSlug or globalSlug is required, but makes it easier to provide both collectionSlug and globalSlug if it's\n // unclear which one is actually available.\n globalSlug?: string\n }\n | {\n collectionSlug?: string\n globalSlug: string\n }\n)\n"],"names":[],"mappings":"AAsGA,WAiEC"}
@@ -296,7 +296,7 @@ export type CollectionAdminOptions = {
296
296
  * If your cells require specific fields that may be unselected, such as within hooks, etc.,
297
297
  * use `forceSelect` in conjunction with this property.
298
298
  *
299
- * @experimental This is an experimental feature and may change in the future. Use at your own discretion.
299
+ * @experimental This is an experimental feature and may change in the future. Use at your own risk.
300
300
  */
301
301
  enableListViewSelectAPI?: boolean;
302
302
  enableRichTextLink?: boolean;
@@ -333,7 +333,7 @@ export type CollectionAdminOptions = {
333
333
  * @description Enable grouping by a field in the list view.
334
334
  * Uses `payload.findDistinct` under the hood to populate the group-by options.
335
335
  *
336
- * @experimental This option is currently in beta and may change in future releases. Use at your own discretion.
336
+ * @experimental This option is currently in beta and may change in future releases. Use at your own risk.
337
337
  */
338
338
  groupBy?: boolean;
339
339
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/collections/config/types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { GraphQLInputObjectType, GraphQLNonNull, GraphQLObjectType } from 'graphql'\nimport type { DeepRequired, IsAny, MarkOptional } from 'ts-essentials'\n\nimport type { CustomUpload, ViewTypes } from '../../admin/types.js'\nimport type { Arguments as MeArguments } from '../../auth/operations/me.js'\nimport type {\n Arguments as RefreshArguments,\n Result as RefreshResult,\n} from '../../auth/operations/refresh.js'\nimport type { Auth, ClientUser, IncomingAuthType } from '../../auth/types.js'\nimport type {\n Access,\n AfterErrorHookArgs,\n AfterErrorResult,\n CustomComponent,\n EditConfig,\n Endpoint,\n EntityDescription,\n EntityDescriptionComponent,\n GeneratePreviewURL,\n LabelFunction,\n LivePreviewConfig,\n MetaConfig,\n PayloadComponent,\n StaticLabel,\n} from '../../config/types.js'\nimport type { DBIdentifierName } from '../../database/types.js'\nimport type {\n Field,\n FlattenedField,\n JoinField,\n RelationshipField,\n UploadField,\n} from '../../fields/config/types.js'\nimport type { CollectionFoldersConfiguration } from '../../folders/types.js'\nimport type {\n CollectionSlug,\n JsonObject,\n RequestContext,\n TypedAuthOperations,\n TypedCollection,\n TypedCollectionSelect,\n TypedLocale,\n} from '../../index.js'\nimport type {\n PayloadRequest,\n SelectIncludeType,\n SelectType,\n Sort,\n TransformCollectionWithSelect,\n Where,\n} from '../../types/index.js'\nimport type { SanitizedUploadConfig, UploadConfig } from '../../uploads/types.js'\nimport type {\n IncomingCollectionVersions,\n SanitizedCollectionVersions,\n} from '../../versions/types.js'\nimport type { AfterOperationArg, AfterOperationMap } from '../operations/utils.js'\n\nexport type DataFromCollectionSlug<TSlug extends CollectionSlug> = TypedCollection[TSlug]\n\nexport type SelectFromCollectionSlug<TSlug extends CollectionSlug> = TypedCollectionSelect[TSlug]\n\nexport type AuthOperationsFromCollectionSlug<TSlug extends CollectionSlug> =\n TypedAuthOperations[TSlug]\n\nexport type RequiredDataFromCollection<TData extends JsonObject> = MarkOptional<\n TData,\n 'createdAt' | 'deletedAt' | 'id' | 'sizes' | 'updatedAt'\n>\n\nexport type RequiredDataFromCollectionSlug<TSlug extends CollectionSlug> =\n RequiredDataFromCollection<DataFromCollectionSlug<TSlug>>\n\nexport type HookOperationType =\n | 'autosave'\n | 'count'\n | 'countVersions'\n | 'create'\n | 'delete'\n | 'forgotPassword'\n | 'login'\n | 'read'\n | 'readDistinct'\n | 'refresh'\n | 'resetPassword'\n | 'restoreVersion'\n | 'update'\n\ntype CreateOrUpdateOperation = Extract<HookOperationType, 'create' | 'update'>\n\nexport type BeforeOperationHook = (args: {\n args?: any\n /**\n * The collection which this hook is being run on\n */\n collection: SanitizedCollectionConfig\n context: RequestContext\n /**\n * Hook operation being performed\n */\n operation: HookOperationType\n req: PayloadRequest\n}) => any\n\nexport type BeforeValidateHook<T extends TypeWithID = any> = (args: {\n /** The collection which this hook is being run on */\n collection: SanitizedCollectionConfig\n context: RequestContext\n data?: Partial<T>\n /**\n * Hook operation being performed\n */\n operation: CreateOrUpdateOperation\n /**\n * Original document before change\n *\n * `undefined` on 'create' operation\n */\n originalDoc?: T\n req: PayloadRequest\n}) => any\n\nexport type BeforeChangeHook<T extends TypeWithID = any> = (args: {\n /** The collection which this hook is being run on */\n collection: SanitizedCollectionConfig\n context: RequestContext\n data: Partial<T>\n /**\n * Hook operation being performed\n */\n operation: CreateOrUpdateOperation\n /**\n * Original document before change\n *\n * `undefined` on 'create' operation\n */\n originalDoc?: T\n req: PayloadRequest\n}) => any\n\nexport type AfterChangeHook<T extends TypeWithID = any> = (args: {\n /** The collection which this hook is being run on */\n collection: SanitizedCollectionConfig\n context: RequestContext\n data: Partial<T>\n doc: T\n /**\n * Hook operation being performed\n */\n operation: CreateOrUpdateOperation\n previousDoc: T\n req: PayloadRequest\n}) => any\n\nexport type BeforeReadHook<T extends TypeWithID = any> = (args: {\n /** The collection which this hook is being run on */\n collection: SanitizedCollectionConfig\n context: RequestContext\n doc: T\n query: { [key: string]: any }\n req: PayloadRequest\n}) => any\n\nexport type AfterReadHook<T extends TypeWithID = any> = (args: {\n /** The collection which this hook is being run on */\n collection: SanitizedCollectionConfig\n context: RequestContext\n doc: T\n findMany?: boolean\n query?: { [key: string]: any }\n req: PayloadRequest\n}) => any\n\nexport type BeforeDeleteHook = (args: {\n /** The collection which this hook is being run on */\n collection: SanitizedCollectionConfig\n context: RequestContext\n id: number | string\n req: PayloadRequest\n}) => any\n\nexport type AfterDeleteHook<T extends TypeWithID = any> = (args: {\n /** The collection which this hook is being run on */\n collection: SanitizedCollectionConfig\n context: RequestContext\n doc: T\n id: number | string\n req: PayloadRequest\n}) => any\n\nexport type AfterOperationHook<TOperationGeneric extends CollectionSlug = string> = (\n arg: AfterOperationArg<TOperationGeneric>,\n) =>\n | Awaited<\n ReturnType<AfterOperationMap<TOperationGeneric>[keyof AfterOperationMap<TOperationGeneric>]>\n >\n | Promise<\n Awaited<\n ReturnType<AfterOperationMap<TOperationGeneric>[keyof AfterOperationMap<TOperationGeneric>]>\n >\n >\n\nexport type BeforeLoginHook<T extends TypeWithID = any> = (args: {\n /** The collection which this hook is being run on */\n collection: SanitizedCollectionConfig\n context: RequestContext\n req: PayloadRequest\n user: T\n}) => any\n\nexport type AfterLoginHook<T extends TypeWithID = any> = (args: {\n /** The collection which this hook is being run on */\n collection: SanitizedCollectionConfig\n context: RequestContext\n req: PayloadRequest\n token: string\n user: T\n}) => any\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport type AfterLogoutHook<T extends TypeWithID = any> = (args: {\n /** The collection which this hook is being run on */\n collection: SanitizedCollectionConfig\n context: RequestContext\n req: PayloadRequest\n}) => any\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport type AfterMeHook<T extends TypeWithID = any> = (args: {\n /** The collection which this hook is being run on */\n collection: SanitizedCollectionConfig\n context: RequestContext\n req: PayloadRequest\n response: unknown\n}) => any\n\nexport type RefreshHook<T extends TypeWithID = any> = (args: {\n args: RefreshArguments\n user: T\n}) => Promise<RefreshResult | void> | (RefreshResult | void)\n\nexport type MeHook<T extends TypeWithID = any> = (args: {\n args: MeArguments\n user: T\n}) => ({ exp: number; user: T } | void) | Promise<{ exp: number; user: T } | void>\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport type AfterRefreshHook<T extends TypeWithID = any> = (args: {\n /** The collection which this hook is being run on */\n collection: SanitizedCollectionConfig\n context: RequestContext\n exp: number\n req: PayloadRequest\n token: string\n}) => any\n\nexport type AfterErrorHook = (\n args: { collection: SanitizedCollectionConfig } & AfterErrorHookArgs,\n) => AfterErrorResult | Promise<AfterErrorResult>\n\nexport type AfterForgotPasswordHook = (args: {\n args?: any\n /** The collection which this hook is being run on */\n collection: SanitizedCollectionConfig\n context: RequestContext\n}) => any\n\nexport type EnableFoldersOptions = {\n // Displays the folder collection and parentFolder field in the document view\n debug?: boolean\n}\n\nexport type BaseFilter = (args: {\n limit: number\n locale?: TypedLocale\n page: number\n req: PayloadRequest\n sort: string\n}) => null | Promise<null | Where> | Where\n\n/**\n * @deprecated Use `BaseFilter` instead.\n */\nexport type BaseListFilter = BaseFilter\n\nexport type CollectionAdminOptions = {\n /**\n * Defines a default base filter which will be applied in the following parts of the admin panel:\n * - List View\n * - Relationship fields for internal links within the Lexical editor\n *\n * This is especially useful for plugins like multi-tenant. For example,\n * a user may have access to multiple tenants, but should only see content\n * related to the currently active or selected tenant in those places.\n */\n baseFilter?: BaseFilter\n /**\n * @deprecated Use `baseFilter` instead. If both are defined,\n * `baseFilter` will take precedence. This property remains only\n * for backward compatibility and may be removed in a future version.\n *\n * Originally, `baseListFilter` was intended to filter only the List View\n * in the admin panel. However, base filtering is often required in other areas\n * such as internal link relationships in the Lexical editor.\n */\n baseListFilter?: BaseListFilter\n /**\n * Custom admin components\n */\n components?: {\n afterList?: CustomComponent[]\n afterListTable?: CustomComponent[]\n beforeList?: CustomComponent[]\n beforeListTable?: CustomComponent[]\n Description?: EntityDescriptionComponent\n /**\n * Components within the edit view\n */\n edit?: {\n /**\n * Inject custom components before the document controls\n */\n beforeDocumentControls?: CustomComponent[]\n /**\n * Inject custom components within the 3-dot menu dropdown\n */\n editMenuItems?: CustomComponent[]\n /**\n * Replaces the \"Preview\" button\n */\n PreviewButton?: CustomComponent\n /**\n * Replaces the \"Publish\" button\n * + drafts must be enabled\n */\n PublishButton?: CustomComponent\n /**\n * Replaces the \"Save\" button\n * + drafts must be disabled\n */\n SaveButton?: CustomComponent\n /**\n * Replaces the \"Save Draft\" button\n * + drafts must be enabled\n * + autosave must be disabled\n */\n SaveDraftButton?: CustomComponent\n /**\n * Replaces the \"Upload\" section\n * + upload must be enabled\n */\n Upload?: CustomUpload\n }\n listMenuItems?: CustomComponent[]\n views?: {\n /**\n * Replace, modify, or add new \"document\" views.\n * @link https://payloadcms.com/docs/custom-components/document-views\n */\n edit?: EditConfig\n /**\n * Replace or modify the \"list\" view.\n * @link https://payloadcms.com/docs/custom-components/list-view\n */\n list?: {\n actions?: CustomComponent[]\n Component?: PayloadComponent\n }\n }\n }\n /** Extension point to add your custom data. Available in server and client. */\n custom?: Record<string, any>\n /**\n * Default columns to show in list view\n */\n defaultColumns?: string[]\n /**\n * Custom description for collection. This will also be used as JSDoc for the generated types\n */\n description?: EntityDescription\n /**\n * Disable the Copy To Locale button in the edit document view\n * @default false\n */\n disableCopyToLocale?: boolean\n /**\n * Performance opt-in. If true, will use the [Select API](https://payloadcms.com/docs/queries/select) when\n * loading the list view to query only the active columns, as opposed to the entire documents.\n * If your cells require specific fields that may be unselected, such as within hooks, etc.,\n * use `forceSelect` in conjunction with this property.\n *\n * @experimental This is an experimental feature and may change in the future. Use at your own discretion.\n */\n enableListViewSelectAPI?: boolean\n enableRichTextLink?: boolean\n enableRichTextRelationship?: boolean\n /**\n * Function to format the URL for document links in the list view.\n * Return null to disable linking for that document.\n * Return a string to customize the link destination.\n * If not provided, uses the default admin edit URL.\n */\n formatDocURL?: (args: {\n collectionSlug: string\n /**\n * The default URL that would normally be used for this document link.\n * You can return this as-is, modify it, or completely replace it.\n */\n defaultURL: string\n doc: Record<string, unknown>\n req: PayloadRequest\n /**\n * The current view context where the link is being generated.\n * Most relevant values for document linking are 'list' and 'trash'.\n */\n viewType?: ViewTypes\n }) => null | string\n /**\n * Specify a navigational group for collections in the admin sidebar.\n * - Provide a string to place the entity in a custom group.\n * - Provide a record to define localized group names.\n * - Set to `false` to exclude the entity from the sidebar / dashboard without disabling its routes.\n */\n group?: false | Record<string, string> | string\n /**\n * @description Enable grouping by a field in the list view.\n * Uses `payload.findDistinct` under the hood to populate the group-by options.\n *\n * @experimental This option is currently in beta and may change in future releases. Use at your own discretion.\n */\n groupBy?: boolean\n /**\n * Exclude the collection from the admin nav and routes\n */\n hidden?: ((args: { user: ClientUser }) => boolean) | boolean\n /**\n * Hide the API URL within the Edit view\n */\n hideAPIURL?: boolean\n /**\n * Additional fields to be searched via the full text search\n */\n listSearchableFields?: string[]\n /**\n * Live Preview options.\n *\n * @see https://payloadcms.com/docs/live-preview/overview\n */\n livePreview?: LivePreviewConfig\n meta?: MetaConfig\n pagination?: {\n defaultLimit?: number\n limits?: number[]\n }\n /**\n * Function to generate custom preview URL\n */\n preview?: GeneratePreviewURL\n /**\n * Field to use as title in Edit View and first column in List view\n */\n useAsTitle?: string\n}\n\n/** Manage all aspects of a data collection */\nexport type CollectionConfig<TSlug extends CollectionSlug = any> = {\n /**\n * Do not set this property manually. This is set to true during sanitization, to avoid\n * sanitizing the same collection multiple times.\n */\n _sanitized?: boolean\n /**\n * Access control\n */\n access?: {\n admin?: ({ req }: { req: PayloadRequest }) => boolean | Promise<boolean>\n create?: Access\n delete?: Access\n read?: Access\n readVersions?: Access\n unlock?: Access\n update?: Access\n }\n /**\n * Collection admin options\n */\n admin?: CollectionAdminOptions\n /**\n * Collection login options\n *\n * Use `true` to enable with default options\n */\n auth?: boolean | IncomingAuthType\n /** Extension point to add your custom data. Server only. */\n custom?: Record<string, any>\n /**\n * Used to override the default naming of the database table or collection with your using a function or string\n * @WARNING: If you change this property with existing data, you will need to handle the renaming of the table in your database or by using migrations\n */\n dbName?: DBIdentifierName\n defaultPopulate?: IsAny<SelectFromCollectionSlug<TSlug>> extends true\n ? SelectType\n : SelectFromCollectionSlug<TSlug>\n /**\n * Default field to sort by in collection list view\n */\n defaultSort?: Sort\n /**\n * Disable the bulk edit operation for the collection in the admin panel and the API\n */\n disableBulkEdit?: boolean\n /**\n * When true, do not show the \"Duplicate\" button while editing documents within this collection and prevent `duplicate` from all APIs\n */\n disableDuplicate?: boolean\n /**\n * Opt-in to enable query presets for this collection.\n * @see https://payloadcms.com/docs/query-presets/overview\n */\n enableQueryPresets?: boolean\n /**\n * Custom rest api endpoints, set false to disable all rest endpoints for this collection.\n */\n endpoints?: false | Omit<Endpoint, 'root'>[]\n fields: Field[]\n /**\n * Enables folders for this collection\n */\n folders?: boolean | CollectionFoldersConfiguration\n /**\n * Specify which fields should be selected always, regardless of the `select` query which can be useful that the field exists for access control / hooks\n */\n forceSelect?: IsAny<SelectFromCollectionSlug<TSlug>> extends true\n ? SelectIncludeType\n : SelectFromCollectionSlug<TSlug>\n /**\n * GraphQL configuration\n */\n graphQL?:\n | {\n disableMutations?: true\n disableQueries?: true\n pluralName?: string\n singularName?: string\n }\n | false\n /**\n * Hooks to modify Payload functionality\n */\n hooks?: {\n afterChange?: AfterChangeHook[]\n afterDelete?: AfterDeleteHook[]\n afterError?: AfterErrorHook[]\n afterForgotPassword?: AfterForgotPasswordHook[]\n afterLogin?: AfterLoginHook[]\n afterLogout?: AfterLogoutHook[]\n afterMe?: AfterMeHook[]\n afterOperation?: AfterOperationHook<TSlug>[]\n afterRead?: AfterReadHook[]\n afterRefresh?: AfterRefreshHook[]\n beforeChange?: BeforeChangeHook[]\n beforeDelete?: BeforeDeleteHook[]\n beforeLogin?: BeforeLoginHook[]\n beforeOperation?: BeforeOperationHook[]\n beforeRead?: BeforeReadHook[]\n beforeValidate?: BeforeValidateHook[]\n /**\n /**\n * Use the `me` hook to control the `me` operation.\n * Here, you can optionally instruct the me operation to return early,\n * and skip its default logic.\n */\n me?: MeHook[]\n /**\n * Use the `refresh` hook to control the refresh operation.\n * Here, you can optionally instruct the refresh operation to return early,\n * and skip its default logic.\n */\n refresh?: RefreshHook[]\n }\n /**\n * Define compound indexes for this collection.\n * This can be used to either speed up querying/sorting by 2 or more fields at the same time or\n * to ensure uniqueness between several fields.\n * Specify field paths\n * @example\n * [{ unique: true, fields: ['title', 'group.name'] }]\n * @default []\n */\n indexes?: CompoundIndex[]\n /**\n * Label configuration\n */\n labels?: {\n plural?: LabelFunction | StaticLabel\n singular?: LabelFunction | StaticLabel\n }\n /**\n * Enables / Disables the ability to lock documents while editing\n * @default true\n */\n lockDocuments?:\n | {\n duration: number\n }\n | false\n /**\n * If true, enables custom ordering for the collection, and documents in the listView can be reordered via drag and drop.\n * New documents are inserted at the end of the list according to this parameter.\n *\n * Under the hood, a field with {@link https://observablehq.com/@dgreensp/implementing-fractional-indexing|fractional indexing} is used to optimize inserts and reorderings.\n *\n * @default false\n *\n * @experimental There may be frequent breaking changes to this API\n */\n orderable?: boolean\n slug: string\n /**\n * Add `createdAt`, `deletedAt` and `updatedAt` fields\n *\n * @default true\n */\n timestamps?: boolean\n /**\n * Enables trash support for this collection.\n *\n * When enabled, documents will include a `deletedAt` timestamp field.\n * This allows documents to be marked as deleted without being permanently removed.\n * The `deletedAt` field will be set to the current date and time when a document is trashed.\n *\n * @experimental This is a beta feature and its behavior may be refined in future releases.\n * @default false\n */\n trash?: boolean\n /**\n * Options used in typescript generation\n */\n typescript?: {\n /**\n * Typescript generation name given to the interface type\n */\n interface?: string\n }\n /**\n * Customize the handling of incoming file uploads\n *\n * @default false // disable uploads\n */\n upload?: boolean | UploadConfig\n /**\n * Enable versioning. Set it to true to enable default versions settings,\n * or customize versions options by setting the property equal to an object\n * containing the version options.\n *\n * @default false // disable versioning\n */\n versions?: boolean | IncomingCollectionVersions\n}\n\nexport type SanitizedJoin = {\n /**\n * The field configuration defining the join\n */\n field: JoinField\n getForeignPath?(args: { locale?: TypedLocale }): string\n /**\n * The path of the join field in dot notation\n */\n joinPath: string\n /**\n * `parentIsLocalized` is true if any parent field of the\n * field configuration defining the join is localized\n */\n parentIsLocalized: boolean\n targetField: RelationshipField | UploadField\n}\n\nexport type SanitizedJoins = {\n [collectionSlug: string]: SanitizedJoin[]\n}\n\n/**\n * @todo remove the `DeepRequired` in v4.\n * We don't actually guarantee that all properties are set when sanitizing configs.\n */\nexport interface SanitizedCollectionConfig\n extends Omit<\n DeepRequired<CollectionConfig>,\n 'admin' | 'auth' | 'endpoints' | 'fields' | 'folders' | 'slug' | 'upload' | 'versions'\n > {\n admin: CollectionAdminOptions\n auth: Auth\n endpoints: Endpoint[] | false\n fields: Field[]\n /**\n * Fields in the database schema structure\n * Rows / collapsible / tabs w/o name `fields` merged to top, UIs are excluded\n */\n flattenedFields: FlattenedField[]\n /**\n * Object of collections to join 'Join Fields object keyed by collection\n */\n folders: CollectionFoldersConfiguration | false\n joins: SanitizedJoins\n\n /**\n * List of all polymorphic join fields\n */\n polymorphicJoins: SanitizedJoin[]\n\n sanitizedIndexes: SanitizedCompoundIndex[]\n\n slug: CollectionSlug\n upload: SanitizedUploadConfig\n versions: SanitizedCollectionVersions\n}\n\nexport type Collection = {\n config: SanitizedCollectionConfig\n customIDType?: 'number' | 'text'\n graphQL?: {\n countType: GraphQLObjectType\n JWT: GraphQLObjectType\n mutationInputType: GraphQLNonNull<any>\n paginatedType: GraphQLObjectType\n type: GraphQLObjectType\n updateMutationInputType: GraphQLNonNull<any>\n versionType: GraphQLObjectType\n whereInputType: GraphQLInputObjectType\n }\n}\n\nexport type BulkOperationResult<TSlug extends CollectionSlug, TSelect extends SelectType> = {\n docs: TransformCollectionWithSelect<TSlug, TSelect>[]\n errors: {\n id: DataFromCollectionSlug<TSlug>['id']\n message: string\n }[]\n}\n\nexport type AuthCollection = {\n config: SanitizedCollectionConfig\n}\n\nexport type TypeWithID = {\n deletedAt?: null | string\n docId?: any\n id: number | string\n}\n\nexport type TypeWithTimestamps = {\n [key: string]: unknown\n createdAt: string\n deletedAt?: null | string\n id: number | string\n updatedAt: string\n}\n\nexport type CompoundIndex = {\n fields: string[]\n unique?: boolean\n}\n\nexport type SanitizedCompoundIndex = {\n fields: {\n field: FlattenedField\n localizedPath: string\n path: string\n pathHasLocalized: boolean\n }[]\n unique: boolean\n}\n"],"names":[],"mappings":"AAAA,qDAAqD,GA8vBrD,WAQC"}
1
+ {"version":3,"sources":["../../../src/collections/config/types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { GraphQLInputObjectType, GraphQLNonNull, GraphQLObjectType } from 'graphql'\nimport type { DeepRequired, IsAny, MarkOptional } from 'ts-essentials'\n\nimport type { CustomUpload, ViewTypes } from '../../admin/types.js'\nimport type { Arguments as MeArguments } from '../../auth/operations/me.js'\nimport type {\n Arguments as RefreshArguments,\n Result as RefreshResult,\n} from '../../auth/operations/refresh.js'\nimport type { Auth, ClientUser, IncomingAuthType } from '../../auth/types.js'\nimport type {\n Access,\n AfterErrorHookArgs,\n AfterErrorResult,\n CustomComponent,\n EditConfig,\n Endpoint,\n EntityDescription,\n EntityDescriptionComponent,\n GeneratePreviewURL,\n LabelFunction,\n LivePreviewConfig,\n MetaConfig,\n PayloadComponent,\n StaticLabel,\n} from '../../config/types.js'\nimport type { DBIdentifierName } from '../../database/types.js'\nimport type {\n Field,\n FlattenedField,\n JoinField,\n RelationshipField,\n UploadField,\n} from '../../fields/config/types.js'\nimport type { CollectionFoldersConfiguration } from '../../folders/types.js'\nimport type {\n CollectionSlug,\n JsonObject,\n RequestContext,\n TypedAuthOperations,\n TypedCollection,\n TypedCollectionSelect,\n TypedLocale,\n} from '../../index.js'\nimport type {\n PayloadRequest,\n SelectIncludeType,\n SelectType,\n Sort,\n TransformCollectionWithSelect,\n Where,\n} from '../../types/index.js'\nimport type { SanitizedUploadConfig, UploadConfig } from '../../uploads/types.js'\nimport type {\n IncomingCollectionVersions,\n SanitizedCollectionVersions,\n} from '../../versions/types.js'\nimport type { AfterOperationArg, AfterOperationMap } from '../operations/utils.js'\n\nexport type DataFromCollectionSlug<TSlug extends CollectionSlug> = TypedCollection[TSlug]\n\nexport type SelectFromCollectionSlug<TSlug extends CollectionSlug> = TypedCollectionSelect[TSlug]\n\nexport type AuthOperationsFromCollectionSlug<TSlug extends CollectionSlug> =\n TypedAuthOperations[TSlug]\n\nexport type RequiredDataFromCollection<TData extends JsonObject> = MarkOptional<\n TData,\n 'createdAt' | 'deletedAt' | 'id' | 'sizes' | 'updatedAt'\n>\n\nexport type RequiredDataFromCollectionSlug<TSlug extends CollectionSlug> =\n RequiredDataFromCollection<DataFromCollectionSlug<TSlug>>\n\nexport type HookOperationType =\n | 'autosave'\n | 'count'\n | 'countVersions'\n | 'create'\n | 'delete'\n | 'forgotPassword'\n | 'login'\n | 'read'\n | 'readDistinct'\n | 'refresh'\n | 'resetPassword'\n | 'restoreVersion'\n | 'update'\n\ntype CreateOrUpdateOperation = Extract<HookOperationType, 'create' | 'update'>\n\nexport type BeforeOperationHook = (args: {\n args?: any\n /**\n * The collection which this hook is being run on\n */\n collection: SanitizedCollectionConfig\n context: RequestContext\n /**\n * Hook operation being performed\n */\n operation: HookOperationType\n req: PayloadRequest\n}) => any\n\nexport type BeforeValidateHook<T extends TypeWithID = any> = (args: {\n /** The collection which this hook is being run on */\n collection: SanitizedCollectionConfig\n context: RequestContext\n data?: Partial<T>\n /**\n * Hook operation being performed\n */\n operation: CreateOrUpdateOperation\n /**\n * Original document before change\n *\n * `undefined` on 'create' operation\n */\n originalDoc?: T\n req: PayloadRequest\n}) => any\n\nexport type BeforeChangeHook<T extends TypeWithID = any> = (args: {\n /** The collection which this hook is being run on */\n collection: SanitizedCollectionConfig\n context: RequestContext\n data: Partial<T>\n /**\n * Hook operation being performed\n */\n operation: CreateOrUpdateOperation\n /**\n * Original document before change\n *\n * `undefined` on 'create' operation\n */\n originalDoc?: T\n req: PayloadRequest\n}) => any\n\nexport type AfterChangeHook<T extends TypeWithID = any> = (args: {\n /** The collection which this hook is being run on */\n collection: SanitizedCollectionConfig\n context: RequestContext\n data: Partial<T>\n doc: T\n /**\n * Hook operation being performed\n */\n operation: CreateOrUpdateOperation\n previousDoc: T\n req: PayloadRequest\n}) => any\n\nexport type BeforeReadHook<T extends TypeWithID = any> = (args: {\n /** The collection which this hook is being run on */\n collection: SanitizedCollectionConfig\n context: RequestContext\n doc: T\n query: { [key: string]: any }\n req: PayloadRequest\n}) => any\n\nexport type AfterReadHook<T extends TypeWithID = any> = (args: {\n /** The collection which this hook is being run on */\n collection: SanitizedCollectionConfig\n context: RequestContext\n doc: T\n findMany?: boolean\n query?: { [key: string]: any }\n req: PayloadRequest\n}) => any\n\nexport type BeforeDeleteHook = (args: {\n /** The collection which this hook is being run on */\n collection: SanitizedCollectionConfig\n context: RequestContext\n id: number | string\n req: PayloadRequest\n}) => any\n\nexport type AfterDeleteHook<T extends TypeWithID = any> = (args: {\n /** The collection which this hook is being run on */\n collection: SanitizedCollectionConfig\n context: RequestContext\n doc: T\n id: number | string\n req: PayloadRequest\n}) => any\n\nexport type AfterOperationHook<TOperationGeneric extends CollectionSlug = string> = (\n arg: AfterOperationArg<TOperationGeneric>,\n) =>\n | Awaited<\n ReturnType<AfterOperationMap<TOperationGeneric>[keyof AfterOperationMap<TOperationGeneric>]>\n >\n | Promise<\n Awaited<\n ReturnType<AfterOperationMap<TOperationGeneric>[keyof AfterOperationMap<TOperationGeneric>]>\n >\n >\n\nexport type BeforeLoginHook<T extends TypeWithID = any> = (args: {\n /** The collection which this hook is being run on */\n collection: SanitizedCollectionConfig\n context: RequestContext\n req: PayloadRequest\n user: T\n}) => any\n\nexport type AfterLoginHook<T extends TypeWithID = any> = (args: {\n /** The collection which this hook is being run on */\n collection: SanitizedCollectionConfig\n context: RequestContext\n req: PayloadRequest\n token: string\n user: T\n}) => any\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport type AfterLogoutHook<T extends TypeWithID = any> = (args: {\n /** The collection which this hook is being run on */\n collection: SanitizedCollectionConfig\n context: RequestContext\n req: PayloadRequest\n}) => any\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport type AfterMeHook<T extends TypeWithID = any> = (args: {\n /** The collection which this hook is being run on */\n collection: SanitizedCollectionConfig\n context: RequestContext\n req: PayloadRequest\n response: unknown\n}) => any\n\nexport type RefreshHook<T extends TypeWithID = any> = (args: {\n args: RefreshArguments\n user: T\n}) => Promise<RefreshResult | void> | (RefreshResult | void)\n\nexport type MeHook<T extends TypeWithID = any> = (args: {\n args: MeArguments\n user: T\n}) => ({ exp: number; user: T } | void) | Promise<{ exp: number; user: T } | void>\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport type AfterRefreshHook<T extends TypeWithID = any> = (args: {\n /** The collection which this hook is being run on */\n collection: SanitizedCollectionConfig\n context: RequestContext\n exp: number\n req: PayloadRequest\n token: string\n}) => any\n\nexport type AfterErrorHook = (\n args: { collection: SanitizedCollectionConfig } & AfterErrorHookArgs,\n) => AfterErrorResult | Promise<AfterErrorResult>\n\nexport type AfterForgotPasswordHook = (args: {\n args?: any\n /** The collection which this hook is being run on */\n collection: SanitizedCollectionConfig\n context: RequestContext\n}) => any\n\nexport type EnableFoldersOptions = {\n // Displays the folder collection and parentFolder field in the document view\n debug?: boolean\n}\n\nexport type BaseFilter = (args: {\n limit: number\n locale?: TypedLocale\n page: number\n req: PayloadRequest\n sort: string\n}) => null | Promise<null | Where> | Where\n\n/**\n * @deprecated Use `BaseFilter` instead.\n */\nexport type BaseListFilter = BaseFilter\n\nexport type CollectionAdminOptions = {\n /**\n * Defines a default base filter which will be applied in the following parts of the admin panel:\n * - List View\n * - Relationship fields for internal links within the Lexical editor\n *\n * This is especially useful for plugins like multi-tenant. For example,\n * a user may have access to multiple tenants, but should only see content\n * related to the currently active or selected tenant in those places.\n */\n baseFilter?: BaseFilter\n /**\n * @deprecated Use `baseFilter` instead. If both are defined,\n * `baseFilter` will take precedence. This property remains only\n * for backward compatibility and may be removed in a future version.\n *\n * Originally, `baseListFilter` was intended to filter only the List View\n * in the admin panel. However, base filtering is often required in other areas\n * such as internal link relationships in the Lexical editor.\n */\n baseListFilter?: BaseListFilter\n /**\n * Custom admin components\n */\n components?: {\n afterList?: CustomComponent[]\n afterListTable?: CustomComponent[]\n beforeList?: CustomComponent[]\n beforeListTable?: CustomComponent[]\n Description?: EntityDescriptionComponent\n /**\n * Components within the edit view\n */\n edit?: {\n /**\n * Inject custom components before the document controls\n */\n beforeDocumentControls?: CustomComponent[]\n /**\n * Inject custom components within the 3-dot menu dropdown\n */\n editMenuItems?: CustomComponent[]\n /**\n * Replaces the \"Preview\" button\n */\n PreviewButton?: CustomComponent\n /**\n * Replaces the \"Publish\" button\n * + drafts must be enabled\n */\n PublishButton?: CustomComponent\n /**\n * Replaces the \"Save\" button\n * + drafts must be disabled\n */\n SaveButton?: CustomComponent\n /**\n * Replaces the \"Save Draft\" button\n * + drafts must be enabled\n * + autosave must be disabled\n */\n SaveDraftButton?: CustomComponent\n /**\n * Replaces the \"Upload\" section\n * + upload must be enabled\n */\n Upload?: CustomUpload\n }\n listMenuItems?: CustomComponent[]\n views?: {\n /**\n * Replace, modify, or add new \"document\" views.\n * @link https://payloadcms.com/docs/custom-components/document-views\n */\n edit?: EditConfig\n /**\n * Replace or modify the \"list\" view.\n * @link https://payloadcms.com/docs/custom-components/list-view\n */\n list?: {\n actions?: CustomComponent[]\n Component?: PayloadComponent\n }\n }\n }\n /** Extension point to add your custom data. Available in server and client. */\n custom?: Record<string, any>\n /**\n * Default columns to show in list view\n */\n defaultColumns?: string[]\n /**\n * Custom description for collection. This will also be used as JSDoc for the generated types\n */\n description?: EntityDescription\n /**\n * Disable the Copy To Locale button in the edit document view\n * @default false\n */\n disableCopyToLocale?: boolean\n /**\n * Performance opt-in. If true, will use the [Select API](https://payloadcms.com/docs/queries/select) when\n * loading the list view to query only the active columns, as opposed to the entire documents.\n * If your cells require specific fields that may be unselected, such as within hooks, etc.,\n * use `forceSelect` in conjunction with this property.\n *\n * @experimental This is an experimental feature and may change in the future. Use at your own risk.\n */\n enableListViewSelectAPI?: boolean\n enableRichTextLink?: boolean\n enableRichTextRelationship?: boolean\n /**\n * Function to format the URL for document links in the list view.\n * Return null to disable linking for that document.\n * Return a string to customize the link destination.\n * If not provided, uses the default admin edit URL.\n */\n formatDocURL?: (args: {\n collectionSlug: string\n /**\n * The default URL that would normally be used for this document link.\n * You can return this as-is, modify it, or completely replace it.\n */\n defaultURL: string\n doc: Record<string, unknown>\n req: PayloadRequest\n /**\n * The current view context where the link is being generated.\n * Most relevant values for document linking are 'list' and 'trash'.\n */\n viewType?: ViewTypes\n }) => null | string\n /**\n * Specify a navigational group for collections in the admin sidebar.\n * - Provide a string to place the entity in a custom group.\n * - Provide a record to define localized group names.\n * - Set to `false` to exclude the entity from the sidebar / dashboard without disabling its routes.\n */\n group?: false | Record<string, string> | string\n /**\n * @description Enable grouping by a field in the list view.\n * Uses `payload.findDistinct` under the hood to populate the group-by options.\n *\n * @experimental This option is currently in beta and may change in future releases. Use at your own risk.\n */\n groupBy?: boolean\n /**\n * Exclude the collection from the admin nav and routes\n */\n hidden?: ((args: { user: ClientUser }) => boolean) | boolean\n /**\n * Hide the API URL within the Edit view\n */\n hideAPIURL?: boolean\n /**\n * Additional fields to be searched via the full text search\n */\n listSearchableFields?: string[]\n /**\n * Live Preview options.\n *\n * @see https://payloadcms.com/docs/live-preview/overview\n */\n livePreview?: LivePreviewConfig\n meta?: MetaConfig\n pagination?: {\n defaultLimit?: number\n limits?: number[]\n }\n /**\n * Function to generate custom preview URL\n */\n preview?: GeneratePreviewURL\n /**\n * Field to use as title in Edit View and first column in List view\n */\n useAsTitle?: string\n}\n\n/** Manage all aspects of a data collection */\nexport type CollectionConfig<TSlug extends CollectionSlug = any> = {\n /**\n * Do not set this property manually. This is set to true during sanitization, to avoid\n * sanitizing the same collection multiple times.\n */\n _sanitized?: boolean\n /**\n * Access control\n */\n access?: {\n admin?: ({ req }: { req: PayloadRequest }) => boolean | Promise<boolean>\n create?: Access\n delete?: Access\n read?: Access\n readVersions?: Access\n unlock?: Access\n update?: Access\n }\n /**\n * Collection admin options\n */\n admin?: CollectionAdminOptions\n /**\n * Collection login options\n *\n * Use `true` to enable with default options\n */\n auth?: boolean | IncomingAuthType\n /** Extension point to add your custom data. Server only. */\n custom?: Record<string, any>\n /**\n * Used to override the default naming of the database table or collection with your using a function or string\n * @WARNING: If you change this property with existing data, you will need to handle the renaming of the table in your database or by using migrations\n */\n dbName?: DBIdentifierName\n defaultPopulate?: IsAny<SelectFromCollectionSlug<TSlug>> extends true\n ? SelectType\n : SelectFromCollectionSlug<TSlug>\n /**\n * Default field to sort by in collection list view\n */\n defaultSort?: Sort\n /**\n * Disable the bulk edit operation for the collection in the admin panel and the API\n */\n disableBulkEdit?: boolean\n /**\n * When true, do not show the \"Duplicate\" button while editing documents within this collection and prevent `duplicate` from all APIs\n */\n disableDuplicate?: boolean\n /**\n * Opt-in to enable query presets for this collection.\n * @see https://payloadcms.com/docs/query-presets/overview\n */\n enableQueryPresets?: boolean\n /**\n * Custom rest api endpoints, set false to disable all rest endpoints for this collection.\n */\n endpoints?: false | Omit<Endpoint, 'root'>[]\n fields: Field[]\n /**\n * Enables folders for this collection\n */\n folders?: boolean | CollectionFoldersConfiguration\n /**\n * Specify which fields should be selected always, regardless of the `select` query which can be useful that the field exists for access control / hooks\n */\n forceSelect?: IsAny<SelectFromCollectionSlug<TSlug>> extends true\n ? SelectIncludeType\n : SelectFromCollectionSlug<TSlug>\n /**\n * GraphQL configuration\n */\n graphQL?:\n | {\n disableMutations?: true\n disableQueries?: true\n pluralName?: string\n singularName?: string\n }\n | false\n /**\n * Hooks to modify Payload functionality\n */\n hooks?: {\n afterChange?: AfterChangeHook[]\n afterDelete?: AfterDeleteHook[]\n afterError?: AfterErrorHook[]\n afterForgotPassword?: AfterForgotPasswordHook[]\n afterLogin?: AfterLoginHook[]\n afterLogout?: AfterLogoutHook[]\n afterMe?: AfterMeHook[]\n afterOperation?: AfterOperationHook<TSlug>[]\n afterRead?: AfterReadHook[]\n afterRefresh?: AfterRefreshHook[]\n beforeChange?: BeforeChangeHook[]\n beforeDelete?: BeforeDeleteHook[]\n beforeLogin?: BeforeLoginHook[]\n beforeOperation?: BeforeOperationHook[]\n beforeRead?: BeforeReadHook[]\n beforeValidate?: BeforeValidateHook[]\n /**\n /**\n * Use the `me` hook to control the `me` operation.\n * Here, you can optionally instruct the me operation to return early,\n * and skip its default logic.\n */\n me?: MeHook[]\n /**\n * Use the `refresh` hook to control the refresh operation.\n * Here, you can optionally instruct the refresh operation to return early,\n * and skip its default logic.\n */\n refresh?: RefreshHook[]\n }\n /**\n * Define compound indexes for this collection.\n * This can be used to either speed up querying/sorting by 2 or more fields at the same time or\n * to ensure uniqueness between several fields.\n * Specify field paths\n * @example\n * [{ unique: true, fields: ['title', 'group.name'] }]\n * @default []\n */\n indexes?: CompoundIndex[]\n /**\n * Label configuration\n */\n labels?: {\n plural?: LabelFunction | StaticLabel\n singular?: LabelFunction | StaticLabel\n }\n /**\n * Enables / Disables the ability to lock documents while editing\n * @default true\n */\n lockDocuments?:\n | {\n duration: number\n }\n | false\n /**\n * If true, enables custom ordering for the collection, and documents in the listView can be reordered via drag and drop.\n * New documents are inserted at the end of the list according to this parameter.\n *\n * Under the hood, a field with {@link https://observablehq.com/@dgreensp/implementing-fractional-indexing|fractional indexing} is used to optimize inserts and reorderings.\n *\n * @default false\n *\n * @experimental There may be frequent breaking changes to this API\n */\n orderable?: boolean\n slug: string\n /**\n * Add `createdAt`, `deletedAt` and `updatedAt` fields\n *\n * @default true\n */\n timestamps?: boolean\n /**\n * Enables trash support for this collection.\n *\n * When enabled, documents will include a `deletedAt` timestamp field.\n * This allows documents to be marked as deleted without being permanently removed.\n * The `deletedAt` field will be set to the current date and time when a document is trashed.\n *\n * @experimental This is a beta feature and its behavior may be refined in future releases.\n * @default false\n */\n trash?: boolean\n /**\n * Options used in typescript generation\n */\n typescript?: {\n /**\n * Typescript generation name given to the interface type\n */\n interface?: string\n }\n /**\n * Customize the handling of incoming file uploads\n *\n * @default false // disable uploads\n */\n upload?: boolean | UploadConfig\n /**\n * Enable versioning. Set it to true to enable default versions settings,\n * or customize versions options by setting the property equal to an object\n * containing the version options.\n *\n * @default false // disable versioning\n */\n versions?: boolean | IncomingCollectionVersions\n}\n\nexport type SanitizedJoin = {\n /**\n * The field configuration defining the join\n */\n field: JoinField\n getForeignPath?(args: { locale?: TypedLocale }): string\n /**\n * The path of the join field in dot notation\n */\n joinPath: string\n /**\n * `parentIsLocalized` is true if any parent field of the\n * field configuration defining the join is localized\n */\n parentIsLocalized: boolean\n targetField: RelationshipField | UploadField\n}\n\nexport type SanitizedJoins = {\n [collectionSlug: string]: SanitizedJoin[]\n}\n\n/**\n * @todo remove the `DeepRequired` in v4.\n * We don't actually guarantee that all properties are set when sanitizing configs.\n */\nexport interface SanitizedCollectionConfig\n extends Omit<\n DeepRequired<CollectionConfig>,\n 'admin' | 'auth' | 'endpoints' | 'fields' | 'folders' | 'slug' | 'upload' | 'versions'\n > {\n admin: CollectionAdminOptions\n auth: Auth\n endpoints: Endpoint[] | false\n fields: Field[]\n /**\n * Fields in the database schema structure\n * Rows / collapsible / tabs w/o name `fields` merged to top, UIs are excluded\n */\n flattenedFields: FlattenedField[]\n /**\n * Object of collections to join 'Join Fields object keyed by collection\n */\n folders: CollectionFoldersConfiguration | false\n joins: SanitizedJoins\n\n /**\n * List of all polymorphic join fields\n */\n polymorphicJoins: SanitizedJoin[]\n\n sanitizedIndexes: SanitizedCompoundIndex[]\n\n slug: CollectionSlug\n upload: SanitizedUploadConfig\n versions: SanitizedCollectionVersions\n}\n\nexport type Collection = {\n config: SanitizedCollectionConfig\n customIDType?: 'number' | 'text'\n graphQL?: {\n countType: GraphQLObjectType\n JWT: GraphQLObjectType\n mutationInputType: GraphQLNonNull<any>\n paginatedType: GraphQLObjectType\n type: GraphQLObjectType\n updateMutationInputType: GraphQLNonNull<any>\n versionType: GraphQLObjectType\n whereInputType: GraphQLInputObjectType\n }\n}\n\nexport type BulkOperationResult<TSlug extends CollectionSlug, TSelect extends SelectType> = {\n docs: TransformCollectionWithSelect<TSlug, TSelect>[]\n errors: {\n id: DataFromCollectionSlug<TSlug>['id']\n message: string\n }[]\n}\n\nexport type AuthCollection = {\n config: SanitizedCollectionConfig\n}\n\nexport type TypeWithID = {\n deletedAt?: null | string\n docId?: any\n id: number | string\n}\n\nexport type TypeWithTimestamps = {\n [key: string]: unknown\n createdAt: string\n deletedAt?: null | string\n id: number | string\n updatedAt: string\n}\n\nexport type CompoundIndex = {\n fields: string[]\n unique?: boolean\n}\n\nexport type SanitizedCompoundIndex = {\n fields: {\n field: FlattenedField\n localizedPath: string\n path: string\n pathHasLocalized: boolean\n }[]\n unique: boolean\n}\n"],"names":[],"mappings":"AAAA,qDAAqD,GA8vBrD,WAQC"}
@@ -1 +1 @@
1
- {"version":3,"file":"findDistinct.d.ts","sourceRoot":"","sources":["../../../src/collections/operations/findDistinct.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAEpE,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AACrF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAcpD,MAAM,MAAM,SAAS,GAAG;IACtB,UAAU,EAAE,UAAU,CAAA;IACtB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,GAAG,CAAC,EAAE,cAAc,CAAA;IACpB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAA;AACD,eAAO,MAAM,qBAAqB,iBAClB,SAAS,KACtB,OAAO,CAAC,qBAAqB,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAuNxD,CAAA"}
1
+ {"version":3,"file":"findDistinct.d.ts","sourceRoot":"","sources":["../../../src/collections/operations/findDistinct.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAEpE,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AACrF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAcpD,MAAM,MAAM,SAAS,GAAG;IACtB,UAAU,EAAE,UAAU,CAAA;IACtB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,GAAG,CAAC,EAAE,cAAc,CAAA;IACpB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAA;AACD,eAAO,MAAM,qBAAqB,iBAClB,SAAS,KACtB,OAAO,CAAC,qBAAqB,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAyNxD,CAAA"}
@@ -77,7 +77,9 @@ export const findDistinctOperation = async (incomingArgs)=>{
77
77
  where: where ?? {}
78
78
  });
79
79
  const fieldResult = getFieldByPath({
80
+ config: payload.config,
80
81
  fields: collectionConfig.flattenedFields,
82
+ includeRelationships: true,
81
83
  path: args.field
82
84
  });
83
85
  if (!fieldResult) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/collections/operations/findDistinct.ts"],"sourcesContent":["import httpStatus from 'http-status'\n\nimport type { AccessResult } from '../../config/types.js'\nimport type { PaginatedDistinctDocs } from '../../database/types.js'\nimport type { FlattenedField } from '../../fields/config/types.js'\nimport type { PayloadRequest, PopulateType, Sort, Where } from '../../types/index.js'\nimport type { Collection } from '../config/types.js'\n\nimport { executeAccess } from '../../auth/executeAccess.js'\nimport { combineQueries } from '../../database/combineQueries.js'\nimport { validateQueryPaths } from '../../database/queryValidation/validateQueryPaths.js'\nimport { sanitizeWhereQuery } from '../../database/sanitizeWhereQuery.js'\nimport { APIError } from '../../errors/APIError.js'\nimport { Forbidden } from '../../errors/Forbidden.js'\nimport { relationshipPopulationPromise } from '../../fields/hooks/afterRead/relationshipPopulationPromise.js'\nimport { appendNonTrashedFilter } from '../../utilities/appendNonTrashedFilter.js'\nimport { getFieldByPath } from '../../utilities/getFieldByPath.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { buildAfterOperation } from './utils.js'\n\nexport type Arguments = {\n collection: Collection\n depth?: number\n disableErrors?: boolean\n field: string\n limit?: number\n locale?: string\n overrideAccess?: boolean\n page?: number\n populate?: PopulateType\n req?: PayloadRequest\n showHiddenFields?: boolean\n sort?: Sort\n trash?: boolean\n where?: Where\n}\nexport const findDistinctOperation = async (\n incomingArgs: Arguments,\n): Promise<PaginatedDistinctDocs<Record<string, unknown>>> => {\n let args = incomingArgs\n\n try {\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n if (args.collection.config.hooks?.beforeOperation?.length) {\n for (const hook of args.collection.config.hooks.beforeOperation) {\n args =\n (await hook({\n args,\n collection: args.collection.config,\n context: args.req!.context,\n operation: 'readDistinct',\n req: args.req!,\n })) || args\n }\n }\n\n const {\n collection: { config: collectionConfig },\n disableErrors,\n overrideAccess,\n populate,\n showHiddenFields = false,\n trash = false,\n where,\n } = args\n\n const req = args.req!\n const { locale, payload } = req\n\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n let accessResult: AccessResult\n\n if (!overrideAccess) {\n accessResult = await executeAccess({ disableErrors, req }, collectionConfig.access.read)\n\n // If errors are disabled, and access returns false, return empty results\n if (accessResult === false) {\n return {\n hasNextPage: false,\n hasPrevPage: false,\n limit: args.limit || 0,\n nextPage: null,\n page: 1,\n pagingCounter: 1,\n prevPage: null,\n totalDocs: 0,\n totalPages: 0,\n values: [],\n }\n }\n }\n\n // /////////////////////////////////////\n // Find Distinct\n // /////////////////////////////////////\n\n let fullWhere = combineQueries(where!, accessResult!)\n sanitizeWhereQuery({ fields: collectionConfig.flattenedFields, payload, where: fullWhere })\n\n // Exclude trashed documents when trash: false\n fullWhere = appendNonTrashedFilter({\n enableTrash: collectionConfig.trash,\n trash,\n where: fullWhere,\n })\n\n await validateQueryPaths({\n collectionConfig,\n overrideAccess: overrideAccess!,\n req,\n where: where ?? {},\n })\n\n const fieldResult = getFieldByPath({\n fields: collectionConfig.flattenedFields,\n path: args.field,\n })\n\n if (!fieldResult) {\n throw new APIError(\n `Field ${args.field} was not found in the collection ${collectionConfig.slug}`,\n httpStatus.BAD_REQUEST,\n )\n }\n\n if (fieldResult.field.hidden && !showHiddenFields) {\n throw new Forbidden(req.t)\n }\n\n if (fieldResult.field.access?.read) {\n const hasAccess = await fieldResult.field.access.read({ req })\n if (!hasAccess) {\n throw new Forbidden(req.t)\n }\n }\n\n if ('virtual' in fieldResult.field && fieldResult.field.virtual) {\n if (typeof fieldResult.field.virtual !== 'string') {\n throw new APIError(\n `Cannot findDistinct by a virtual field that isn't linked to a relationship field.`,\n )\n }\n\n let relationPath: string = ''\n let currentFields: FlattenedField[] = collectionConfig.flattenedFields\n const fieldPathSegments = fieldResult.field.virtual.split('.')\n for (const segment of fieldResult.field.virtual.split('.')) {\n relationPath = `${relationPath}${segment}`\n fieldPathSegments.shift()\n const field = currentFields.find((e) => e.name === segment)!\n if (\n (field.type === 'relationship' || field.type === 'upload') &&\n typeof field.relationTo === 'string'\n ) {\n break\n }\n if ('flattenedFields' in field) {\n currentFields = field.flattenedFields\n }\n }\n\n const path = `${relationPath}.${fieldPathSegments.join('.')}`\n\n const result = await payload.findDistinct({\n collection: collectionConfig.slug,\n depth: args.depth,\n disableErrors,\n field: path,\n locale,\n overrideAccess,\n populate,\n req,\n showHiddenFields,\n sort: args.sort,\n trash,\n where,\n })\n\n for (const val of result.values) {\n val[args.field] = val[path]\n delete val[path]\n }\n\n return result\n }\n\n let result = await payload.db.findDistinct({\n collection: collectionConfig.slug,\n field: args.field,\n limit: args.limit,\n locale: locale!,\n page: args.page,\n req,\n sort: args.sort,\n where: fullWhere,\n })\n\n if (\n (fieldResult.field.type === 'relationship' || fieldResult.field.type === 'upload') &&\n args.depth\n ) {\n const populationPromises: Promise<void>[] = []\n const sanitizedField = { ...fieldResult.field }\n if (fieldResult.field.hasMany) {\n sanitizedField.hasMany = false\n }\n for (const doc of result.values) {\n populationPromises.push(\n relationshipPopulationPromise({\n currentDepth: 0,\n depth: args.depth,\n draft: false,\n fallbackLocale: req.fallbackLocale || null,\n field: sanitizedField,\n locale: req.locale || null,\n overrideAccess: args.overrideAccess ?? true,\n parentIsLocalized: false,\n populate,\n req,\n showHiddenFields: false,\n siblingDoc: doc,\n }),\n )\n }\n await Promise.all(populationPromises)\n }\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n result = await buildAfterOperation({\n args,\n collection: collectionConfig,\n operation: 'findDistinct',\n result,\n })\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n return result\n } catch (error: unknown) {\n await killTransaction(args.req!)\n throw error\n }\n}\n"],"names":["httpStatus","executeAccess","combineQueries","validateQueryPaths","sanitizeWhereQuery","APIError","Forbidden","relationshipPopulationPromise","appendNonTrashedFilter","getFieldByPath","killTransaction","buildAfterOperation","findDistinctOperation","incomingArgs","args","collection","config","hooks","beforeOperation","length","hook","context","req","operation","collectionConfig","disableErrors","overrideAccess","populate","showHiddenFields","trash","where","locale","payload","accessResult","access","read","hasNextPage","hasPrevPage","limit","nextPage","page","pagingCounter","prevPage","totalDocs","totalPages","values","fullWhere","fields","flattenedFields","enableTrash","fieldResult","path","field","slug","BAD_REQUEST","hidden","t","hasAccess","virtual","relationPath","currentFields","fieldPathSegments","split","segment","shift","find","e","name","type","relationTo","join","result","findDistinct","depth","sort","val","db","populationPromises","sanitizedField","hasMany","doc","push","currentDepth","draft","fallbackLocale","parentIsLocalized","siblingDoc","Promise","all","error"],"mappings":"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"}
1
+ {"version":3,"sources":["../../../src/collections/operations/findDistinct.ts"],"sourcesContent":["import httpStatus from 'http-status'\n\nimport type { AccessResult } from '../../config/types.js'\nimport type { PaginatedDistinctDocs } from '../../database/types.js'\nimport type { FlattenedField } from '../../fields/config/types.js'\nimport type { PayloadRequest, PopulateType, Sort, Where } from '../../types/index.js'\nimport type { Collection } from '../config/types.js'\n\nimport { executeAccess } from '../../auth/executeAccess.js'\nimport { combineQueries } from '../../database/combineQueries.js'\nimport { validateQueryPaths } from '../../database/queryValidation/validateQueryPaths.js'\nimport { sanitizeWhereQuery } from '../../database/sanitizeWhereQuery.js'\nimport { APIError } from '../../errors/APIError.js'\nimport { Forbidden } from '../../errors/Forbidden.js'\nimport { relationshipPopulationPromise } from '../../fields/hooks/afterRead/relationshipPopulationPromise.js'\nimport { appendNonTrashedFilter } from '../../utilities/appendNonTrashedFilter.js'\nimport { getFieldByPath } from '../../utilities/getFieldByPath.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { buildAfterOperation } from './utils.js'\n\nexport type Arguments = {\n collection: Collection\n depth?: number\n disableErrors?: boolean\n field: string\n limit?: number\n locale?: string\n overrideAccess?: boolean\n page?: number\n populate?: PopulateType\n req?: PayloadRequest\n showHiddenFields?: boolean\n sort?: Sort\n trash?: boolean\n where?: Where\n}\nexport const findDistinctOperation = async (\n incomingArgs: Arguments,\n): Promise<PaginatedDistinctDocs<Record<string, unknown>>> => {\n let args = incomingArgs\n\n try {\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n if (args.collection.config.hooks?.beforeOperation?.length) {\n for (const hook of args.collection.config.hooks.beforeOperation) {\n args =\n (await hook({\n args,\n collection: args.collection.config,\n context: args.req!.context,\n operation: 'readDistinct',\n req: args.req!,\n })) || args\n }\n }\n\n const {\n collection: { config: collectionConfig },\n disableErrors,\n overrideAccess,\n populate,\n showHiddenFields = false,\n trash = false,\n where,\n } = args\n\n const req = args.req!\n const { locale, payload } = req\n\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n let accessResult: AccessResult\n\n if (!overrideAccess) {\n accessResult = await executeAccess({ disableErrors, req }, collectionConfig.access.read)\n\n // If errors are disabled, and access returns false, return empty results\n if (accessResult === false) {\n return {\n hasNextPage: false,\n hasPrevPage: false,\n limit: args.limit || 0,\n nextPage: null,\n page: 1,\n pagingCounter: 1,\n prevPage: null,\n totalDocs: 0,\n totalPages: 0,\n values: [],\n }\n }\n }\n\n // /////////////////////////////////////\n // Find Distinct\n // /////////////////////////////////////\n\n let fullWhere = combineQueries(where!, accessResult!)\n sanitizeWhereQuery({ fields: collectionConfig.flattenedFields, payload, where: fullWhere })\n\n // Exclude trashed documents when trash: false\n fullWhere = appendNonTrashedFilter({\n enableTrash: collectionConfig.trash,\n trash,\n where: fullWhere,\n })\n\n await validateQueryPaths({\n collectionConfig,\n overrideAccess: overrideAccess!,\n req,\n where: where ?? {},\n })\n\n const fieldResult = getFieldByPath({\n config: payload.config,\n fields: collectionConfig.flattenedFields,\n includeRelationships: true,\n path: args.field,\n })\n\n if (!fieldResult) {\n throw new APIError(\n `Field ${args.field} was not found in the collection ${collectionConfig.slug}`,\n httpStatus.BAD_REQUEST,\n )\n }\n\n if (fieldResult.field.hidden && !showHiddenFields) {\n throw new Forbidden(req.t)\n }\n\n if (fieldResult.field.access?.read) {\n const hasAccess = await fieldResult.field.access.read({ req })\n if (!hasAccess) {\n throw new Forbidden(req.t)\n }\n }\n\n if ('virtual' in fieldResult.field && fieldResult.field.virtual) {\n if (typeof fieldResult.field.virtual !== 'string') {\n throw new APIError(\n `Cannot findDistinct by a virtual field that isn't linked to a relationship field.`,\n )\n }\n\n let relationPath: string = ''\n let currentFields: FlattenedField[] = collectionConfig.flattenedFields\n const fieldPathSegments = fieldResult.field.virtual.split('.')\n for (const segment of fieldResult.field.virtual.split('.')) {\n relationPath = `${relationPath}${segment}`\n fieldPathSegments.shift()\n const field = currentFields.find((e) => e.name === segment)!\n if (\n (field.type === 'relationship' || field.type === 'upload') &&\n typeof field.relationTo === 'string'\n ) {\n break\n }\n if ('flattenedFields' in field) {\n currentFields = field.flattenedFields\n }\n }\n\n const path = `${relationPath}.${fieldPathSegments.join('.')}`\n\n const result = await payload.findDistinct({\n collection: collectionConfig.slug,\n depth: args.depth,\n disableErrors,\n field: path,\n locale,\n overrideAccess,\n populate,\n req,\n showHiddenFields,\n sort: args.sort,\n trash,\n where,\n })\n\n for (const val of result.values) {\n val[args.field] = val[path]\n delete val[path]\n }\n\n return result\n }\n\n let result = await payload.db.findDistinct({\n collection: collectionConfig.slug,\n field: args.field,\n limit: args.limit,\n locale: locale!,\n page: args.page,\n req,\n sort: args.sort,\n where: fullWhere,\n })\n\n if (\n (fieldResult.field.type === 'relationship' || fieldResult.field.type === 'upload') &&\n args.depth\n ) {\n const populationPromises: Promise<void>[] = []\n const sanitizedField = { ...fieldResult.field }\n if (fieldResult.field.hasMany) {\n sanitizedField.hasMany = false\n }\n for (const doc of result.values) {\n populationPromises.push(\n relationshipPopulationPromise({\n currentDepth: 0,\n depth: args.depth,\n draft: false,\n fallbackLocale: req.fallbackLocale || null,\n field: sanitizedField,\n locale: req.locale || null,\n overrideAccess: args.overrideAccess ?? true,\n parentIsLocalized: false,\n populate,\n req,\n showHiddenFields: false,\n siblingDoc: doc,\n }),\n )\n }\n await Promise.all(populationPromises)\n }\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n result = await buildAfterOperation({\n args,\n collection: collectionConfig,\n operation: 'findDistinct',\n result,\n })\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n return result\n } catch (error: unknown) {\n await killTransaction(args.req!)\n throw error\n }\n}\n"],"names":["httpStatus","executeAccess","combineQueries","validateQueryPaths","sanitizeWhereQuery","APIError","Forbidden","relationshipPopulationPromise","appendNonTrashedFilter","getFieldByPath","killTransaction","buildAfterOperation","findDistinctOperation","incomingArgs","args","collection","config","hooks","beforeOperation","length","hook","context","req","operation","collectionConfig","disableErrors","overrideAccess","populate","showHiddenFields","trash","where","locale","payload","accessResult","access","read","hasNextPage","hasPrevPage","limit","nextPage","page","pagingCounter","prevPage","totalDocs","totalPages","values","fullWhere","fields","flattenedFields","enableTrash","fieldResult","includeRelationships","path","field","slug","BAD_REQUEST","hidden","t","hasAccess","virtual","relationPath","currentFields","fieldPathSegments","split","segment","shift","find","e","name","type","relationTo","join","result","findDistinct","depth","sort","val","db","populationPromises","sanitizedField","hasMany","doc","push","currentDepth","draft","fallbackLocale","parentIsLocalized","siblingDoc","Promise","all","error"],"mappings":"AAAA,OAAOA,gBAAgB,cAAa;AAQpC,SAASC,aAAa,QAAQ,8BAA6B;AAC3D,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,kBAAkB,QAAQ,uDAAsD;AACzF,SAASC,kBAAkB,QAAQ,uCAAsC;AACzE,SAASC,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,SAAS,QAAQ,4BAA2B;AACrD,SAASC,6BAA6B,QAAQ,gEAA+D;AAC7G,SAASC,sBAAsB,QAAQ,4CAA2C;AAClF,SAASC,cAAc,QAAQ,oCAAmC;AAClE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,mBAAmB,QAAQ,aAAY;AAkBhD,OAAO,MAAMC,wBAAwB,OACnCC;IAEA,IAAIC,OAAOD;IAEX,IAAI;QACF,wCAAwC;QACxC,+BAA+B;QAC/B,wCAAwC;QAExC,IAAIC,KAAKC,UAAU,CAACC,MAAM,CAACC,KAAK,EAAEC,iBAAiBC,QAAQ;YACzD,KAAK,MAAMC,QAAQN,KAAKC,UAAU,CAACC,MAAM,CAACC,KAAK,CAACC,eAAe,CAAE;gBAC/DJ,OACE,AAAC,MAAMM,KAAK;oBACVN;oBACAC,YAAYD,KAAKC,UAAU,CAACC,MAAM;oBAClCK,SAASP,KAAKQ,GAAG,CAAED,OAAO;oBAC1BE,WAAW;oBACXD,KAAKR,KAAKQ,GAAG;gBACf,MAAOR;YACX;QACF;QAEA,MAAM,EACJC,YAAY,EAAEC,QAAQQ,gBAAgB,EAAE,EACxCC,aAAa,EACbC,cAAc,EACdC,QAAQ,EACRC,mBAAmB,KAAK,EACxBC,QAAQ,KAAK,EACbC,KAAK,EACN,GAAGhB;QAEJ,MAAMQ,MAAMR,KAAKQ,GAAG;QACpB,MAAM,EAAES,MAAM,EAAEC,OAAO,EAAE,GAAGV;QAE5B,wCAAwC;QACxC,SAAS;QACT,wCAAwC;QAExC,IAAIW;QAEJ,IAAI,CAACP,gBAAgB;YACnBO,eAAe,MAAMhC,cAAc;gBAAEwB;gBAAeH;YAAI,GAAGE,iBAAiBU,MAAM,CAACC,IAAI;YAEvF,yEAAyE;YACzE,IAAIF,iBAAiB,OAAO;gBAC1B,OAAO;oBACLG,aAAa;oBACbC,aAAa;oBACbC,OAAOxB,KAAKwB,KAAK,IAAI;oBACrBC,UAAU;oBACVC,MAAM;oBACNC,eAAe;oBACfC,UAAU;oBACVC,WAAW;oBACXC,YAAY;oBACZC,QAAQ,EAAE;gBACZ;YACF;QACF;QAEA,wCAAwC;QACxC,gBAAgB;QAChB,wCAAwC;QAExC,IAAIC,YAAY5C,eAAe4B,OAAQG;QACvC7B,mBAAmB;YAAE2C,QAAQvB,iBAAiBwB,eAAe;YAAEhB;YAASF,OAAOgB;QAAU;QAEzF,8CAA8C;QAC9CA,YAAYtC,uBAAuB;YACjCyC,aAAazB,iBAAiBK,KAAK;YACnCA;YACAC,OAAOgB;QACT;QAEA,MAAM3C,mBAAmB;YACvBqB;YACAE,gBAAgBA;YAChBJ;YACAQ,OAAOA,SAAS,CAAC;QACnB;QAEA,MAAMoB,cAAczC,eAAe;YACjCO,QAAQgB,QAAQhB,MAAM;YACtB+B,QAAQvB,iBAAiBwB,eAAe;YACxCG,sBAAsB;YACtBC,MAAMtC,KAAKuC,KAAK;QAClB;QAEA,IAAI,CAACH,aAAa;YAChB,MAAM,IAAI7C,SACR,CAAC,MAAM,EAAES,KAAKuC,KAAK,CAAC,iCAAiC,EAAE7B,iBAAiB8B,IAAI,EAAE,EAC9EtD,WAAWuD,WAAW;QAE1B;QAEA,IAAIL,YAAYG,KAAK,CAACG,MAAM,IAAI,CAAC5B,kBAAkB;YACjD,MAAM,IAAItB,UAAUgB,IAAImC,CAAC;QAC3B;QAEA,IAAIP,YAAYG,KAAK,CAACnB,MAAM,EAAEC,MAAM;YAClC,MAAMuB,YAAY,MAAMR,YAAYG,KAAK,CAACnB,MAAM,CAACC,IAAI,CAAC;gBAAEb;YAAI;YAC5D,IAAI,CAACoC,WAAW;gBACd,MAAM,IAAIpD,UAAUgB,IAAImC,CAAC;YAC3B;QACF;QAEA,IAAI,aAAaP,YAAYG,KAAK,IAAIH,YAAYG,KAAK,CAACM,OAAO,EAAE;YAC/D,IAAI,OAAOT,YAAYG,KAAK,CAACM,OAAO,KAAK,UAAU;gBACjD,MAAM,IAAItD,SACR,CAAC,iFAAiF,CAAC;YAEvF;YAEA,IAAIuD,eAAuB;YAC3B,IAAIC,gBAAkCrC,iBAAiBwB,eAAe;YACtE,MAAMc,oBAAoBZ,YAAYG,KAAK,CAACM,OAAO,CAACI,KAAK,CAAC;YAC1D,KAAK,MAAMC,WAAWd,YAAYG,KAAK,CAACM,OAAO,CAACI,KAAK,CAAC,KAAM;gBAC1DH,eAAe,GAAGA,eAAeI,SAAS;gBAC1CF,kBAAkBG,KAAK;gBACvB,MAAMZ,QAAQQ,cAAcK,IAAI,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAKJ;gBACnD,IACE,AAACX,CAAAA,MAAMgB,IAAI,KAAK,kBAAkBhB,MAAMgB,IAAI,KAAK,QAAO,KACxD,OAAOhB,MAAMiB,UAAU,KAAK,UAC5B;oBACA;gBACF;gBACA,IAAI,qBAAqBjB,OAAO;oBAC9BQ,gBAAgBR,MAAML,eAAe;gBACvC;YACF;YAEA,MAAMI,OAAO,GAAGQ,aAAa,CAAC,EAAEE,kBAAkBS,IAAI,CAAC,MAAM;YAE7D,MAAMC,SAAS,MAAMxC,QAAQyC,YAAY,CAAC;gBACxC1D,YAAYS,iBAAiB8B,IAAI;gBACjCoB,OAAO5D,KAAK4D,KAAK;gBACjBjD;gBACA4B,OAAOD;gBACPrB;gBACAL;gBACAC;gBACAL;gBACAM;gBACA+C,MAAM7D,KAAK6D,IAAI;gBACf9C;gBACAC;YACF;YAEA,KAAK,MAAM8C,OAAOJ,OAAO3B,MAAM,CAAE;gBAC/B+B,GAAG,CAAC9D,KAAKuC,KAAK,CAAC,GAAGuB,GAAG,CAACxB,KAAK;gBAC3B,OAAOwB,GAAG,CAACxB,KAAK;YAClB;YAEA,OAAOoB;QACT;QAEA,IAAIA,SAAS,MAAMxC,QAAQ6C,EAAE,CAACJ,YAAY,CAAC;YACzC1D,YAAYS,iBAAiB8B,IAAI;YACjCD,OAAOvC,KAAKuC,KAAK;YACjBf,OAAOxB,KAAKwB,KAAK;YACjBP,QAAQA;YACRS,MAAM1B,KAAK0B,IAAI;YACflB;YACAqD,MAAM7D,KAAK6D,IAAI;YACf7C,OAAOgB;QACT;QAEA,IACE,AAACI,CAAAA,YAAYG,KAAK,CAACgB,IAAI,KAAK,kBAAkBnB,YAAYG,KAAK,CAACgB,IAAI,KAAK,QAAO,KAChFvD,KAAK4D,KAAK,EACV;YACA,MAAMI,qBAAsC,EAAE;YAC9C,MAAMC,iBAAiB;gBAAE,GAAG7B,YAAYG,KAAK;YAAC;YAC9C,IAAIH,YAAYG,KAAK,CAAC2B,OAAO,EAAE;gBAC7BD,eAAeC,OAAO,GAAG;YAC3B;YACA,KAAK,MAAMC,OAAOT,OAAO3B,MAAM,CAAE;gBAC/BiC,mBAAmBI,IAAI,CACrB3E,8BAA8B;oBAC5B4E,cAAc;oBACdT,OAAO5D,KAAK4D,KAAK;oBACjBU,OAAO;oBACPC,gBAAgB/D,IAAI+D,cAAc,IAAI;oBACtChC,OAAO0B;oBACPhD,QAAQT,IAAIS,MAAM,IAAI;oBACtBL,gBAAgBZ,KAAKY,cAAc,IAAI;oBACvC4D,mBAAmB;oBACnB3D;oBACAL;oBACAM,kBAAkB;oBAClB2D,YAAYN;gBACd;YAEJ;YACA,MAAMO,QAAQC,GAAG,CAACX;QACpB;QAEA,wCAAwC;QACxC,8BAA8B;QAC9B,wCAAwC;QAExCN,SAAS,MAAM7D,oBAAoB;YACjCG;YACAC,YAAYS;YACZD,WAAW;YACXiD;QACF;QAEA,wCAAwC;QACxC,iBAAiB;QACjB,wCAAwC;QAExC,OAAOA;IACT,EAAE,OAAOkB,OAAgB;QACvB,MAAMhF,gBAAgBI,KAAKQ,GAAG;QAC9B,MAAMoE;IACR;AACF,EAAC"}
@@ -782,7 +782,7 @@ export type Config = {
782
782
  * Configure toast message behavior and appearance in the admin panel.
783
783
  * Currently using [Sonner](https://sonner.emilkowal.ski) for toast notifications.
784
784
  *
785
- * @experimental This property is experimental and may change in future releases. Use at your own discretion.
785
+ * @experimental This property is experimental and may change in future releases. Use at your own risk.
786
786
  */
787
787
  toast?: {
788
788
  /**
@@ -824,7 +824,7 @@ export type Config = {
824
824
  * For example, you may want to increase the `limits` imposed by the parser.
825
825
  * Currently using @link {https://www.npmjs.com/package/busboy|busboy} under the hood.
826
826
  *
827
- * @experimental This property is experimental and may change in future releases. Use at your own discretion.
827
+ * @experimental This property is experimental and may change in future releases. Use at your own risk.
828
828
  */
829
829
  bodyParser?: Partial<BusboyConfig>;
830
830
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/config/types.ts"],"sourcesContent":["import type {\n DefaultTranslationKeys,\n DefaultTranslationsObject,\n I18n,\n I18nClient,\n I18nOptions,\n TFunction,\n} from '@payloadcms/translations'\nimport type { BusboyConfig } from 'busboy'\nimport type GraphQL from 'graphql'\nimport type { GraphQLFormattedError } from 'graphql'\nimport type { JSONSchema4 } from 'json-schema'\nimport type { Metadata } from 'next'\nimport type { DestinationStream, Level, pino } from 'pino'\nimport type React from 'react'\nimport type { default as sharp } from 'sharp'\nimport type { DeepRequired } from 'ts-essentials'\n\nimport type { RichTextAdapterProvider } from '../admin/RichText.js'\nimport type {\n DocumentSubViewTypes,\n DocumentTabConfig,\n DocumentViewServerProps,\n RichTextAdapter,\n} from '../admin/types.js'\nimport type { AdminViewConfig, ViewTypes, VisibleEntities } from '../admin/views/index.js'\nimport type { SanitizedPermissions } from '../auth/index.js'\nimport type {\n AddToImportMap,\n ImportMap,\n Imports,\n InternalImportMap,\n} from '../bin/generateImportMap/index.js'\nimport type {\n Collection,\n CollectionConfig,\n SanitizedCollectionConfig,\n} from '../collections/config/types.js'\nimport type { DatabaseAdapterResult } from '../database/types.js'\nimport type { EmailAdapter, SendEmailOptions } from '../email/types.js'\nimport type { ErrorName } from '../errors/types.js'\nimport type { RootFoldersConfiguration } from '../folders/types.js'\nimport type { GlobalConfig, Globals, SanitizedGlobalConfig } from '../globals/config/types.js'\nimport type {\n Block,\n FlattenedBlock,\n JobsConfig,\n Payload,\n RequestContext,\n SelectField,\n TypedUser,\n} from '../index.js'\nimport type { QueryPreset, QueryPresetConstraints } from '../query-presets/types.js'\nimport type { SanitizedJobsConfig } from '../queues/config/types/index.js'\nimport type { PayloadRequest, Where } from '../types/index.js'\nimport type { PayloadLogger } from '../utilities/logger.js'\n\n/**\n * The string path pointing to the React component. If one of the generics is `never`, you effectively mark it as a server-only or client-only component.\n *\n * If it is `false` an empty component will be rendered.\n */\nexport type PayloadComponent<\n TComponentServerProps extends never | object = Record<string, any>,\n TComponentClientProps extends never | object = Record<string, any>,\n> = false | RawPayloadComponent<TComponentServerProps, TComponentClientProps> | string\n\n// We need the actual object as its own type, otherwise the infers for the PayloadClientReactComponent / PayloadServerReactComponent will not work due to the string union.\n// We also NEED to actually use those generics for this to work, thus they are part of the props.\nexport type RawPayloadComponent<\n TComponentServerProps extends never | object = Record<string, any>,\n TComponentClientProps extends never | object = Record<string, any>,\n> = {\n clientProps?: object | TComponentClientProps\n exportName?: string\n path: string\n serverProps?: object | TComponentServerProps\n}\n\nexport type PayloadComponentProps<TPayloadComponent> =\n TPayloadComponent extends RawPayloadComponent<\n infer TComponentServerProps,\n infer TComponentClientProps\n >\n ? TComponentClientProps | TComponentServerProps\n : never\n\nexport type PayloadClientComponentProps<TPayloadComponent> =\n TPayloadComponent extends RawPayloadComponent<infer _, infer TComponentClientProps>\n ? TComponentClientProps\n : never\n\nexport type PayloadServerComponentProps<TPayloadComponent> =\n TPayloadComponent extends RawPayloadComponent<infer TComponentServerProps, infer _>\n ? TComponentServerProps\n : never\n\nexport type PayloadReactComponent<TPayloadComponent> = React.FC<\n PayloadComponentProps<TPayloadComponent>\n>\n\n// This also ensures that if never is passed to TComponentClientProps, this entire type will be never.\n// => TypeScript will now ensure that users cannot even define the typed Server Components if the PayloadComponent is marked as\n// Client-Only (marked as Client-Only = TComponentServerProps is never)\nexport type PayloadClientReactComponent<TPayloadComponent> =\n TPayloadComponent extends RawPayloadComponent<infer _, infer TComponentClientProps>\n ? TComponentClientProps extends never\n ? never\n : React.FC<TComponentClientProps>\n : never\n\nexport type PayloadServerReactComponent<TPayloadComponent> =\n TPayloadComponent extends RawPayloadComponent<infer TComponentServerProps, infer _>\n ? TComponentServerProps extends never\n ? never\n : React.FC<TComponentServerProps>\n : never\n\nexport type ResolvedComponent<\n TComponentServerProps extends never | object,\n TComponentClientProps extends never | object,\n> = {\n clientProps?: TComponentClientProps\n Component: React.FC<TComponentClientProps | TComponentServerProps>\n serverProps?: TComponentServerProps\n}\n\nexport type BinScriptConfig = {\n key: string\n scriptPath: string\n}\n\nexport type BinScript = (config: SanitizedConfig) => Promise<void> | void\n\ntype Prettify<T> = {\n [K in keyof T]: T[K]\n} & NonNullable<unknown>\n\nexport type Plugin = (config: Config) => Config | Promise<Config>\n\nexport type LivePreviewURLType = null | string | undefined\n\nexport type LivePreviewConfig = {\n /**\n Device breakpoints to use for the `iframe` of the Live Preview window.\n Options are displayed in the Live Preview toolbar.\n The `responsive` breakpoint is included by default.\n */\n breakpoints?: {\n height: number | string\n label: string\n name: string\n width: number | string\n }[]\n /**\n * The URL of the frontend application. This will be rendered within an `iframe` as its `src`.\n * Payload will send a `window.postMessage()` to this URL with the document data in real-time.\n * The frontend application is responsible for receiving the message and updating the UI accordingly.\n * @see https://payloadcms.com/docs/live-preview/frontend\n *\n * To conditionally render Live Preview, use a function that returns `undefined` or `null`.\n *\n * Note: this function may run often if autosave is enabled with a small interval.\n * For performance, avoid long-running tasks or expensive operations within this function,\n * or if you need to do something more complex, cache your function as needed.\n */\n url?:\n | ((args: {\n collectionConfig?: SanitizedCollectionConfig\n data: Record<string, any>\n globalConfig?: SanitizedGlobalConfig\n locale: Locale\n /**\n * @deprecated\n * Use `req.payload` instead. This will be removed in the next major version.\n */\n payload: Payload\n req: PayloadRequest\n }) => LivePreviewURLType | Promise<LivePreviewURLType>)\n | LivePreviewURLType\n}\n\nexport type RootLivePreviewConfig = {\n collections?: string[]\n globals?: string[]\n} & LivePreviewConfig\n\nexport type OGImageConfig = {\n alt?: string\n height?: number | string\n type?: string\n url: string\n width?: number | string\n}\n\n/**\n * @todo find a way to remove the deep clone here.\n * It can probably be removed after the `DeepRequired` from `Config` to `SanitizedConfig` is removed.\n * Same with `CollectionConfig` to `SanitizedCollectionConfig`.\n */\ntype DeepClone<T> = T extends object ? { [K in keyof T]: DeepClone<T[K]> } : T\n\nexport type MetaConfig = {\n /**\n * When `static`, a pre-made image will be used for all pages.\n * When `dynamic`, a unique image will be generated for each page based on page content and given overrides.\n * When `off`, no Open Graph images will be generated and the `/api/og` endpoint will be disabled. You can still provide custom images using the `openGraph.images` property.\n * @default 'dynamic'\n */\n defaultOGImageType?: 'dynamic' | 'off' | 'static'\n /**\n * String to append to the auto-generated <title> of admin pages\n * @example `\" - Custom CMS\"`\n */\n titleSuffix?: string\n} & DeepClone<Metadata>\n\nexport type ServerOnlyLivePreviewProperties = keyof Pick<RootLivePreviewConfig, 'url'>\n\ntype GeneratePreviewURLOptions = {\n locale: string\n req: PayloadRequest\n token: null | string\n}\n\nexport type GeneratePreviewURL = (\n doc: Record<string, unknown>,\n options: GeneratePreviewURLOptions,\n) => null | Promise<null | string> | string\n\nexport type GraphQLInfo = {\n collections: {\n [slug: string]: Collection\n }\n globals: Globals\n Mutation: {\n fields: Record<string, any>\n name: string\n }\n Query: {\n fields: Record<string, any>\n name: string\n }\n types: {\n arrayTypes: Record<string, GraphQL.GraphQLType>\n blockInputTypes: Record<string, GraphQL.GraphQLInputObjectType>\n blockTypes: Record<string, GraphQL.GraphQLObjectType>\n fallbackLocaleInputType?: GraphQL.GraphQLEnumType | GraphQL.GraphQLScalarType\n groupTypes: Record<string, GraphQL.GraphQLObjectType>\n localeInputType?: GraphQL.GraphQLEnumType | GraphQL.GraphQLScalarType\n tabTypes: Record<string, GraphQL.GraphQLObjectType>\n }\n}\nexport type GraphQLExtension = (\n graphQL: typeof GraphQL,\n context: {\n config: SanitizedConfig\n } & GraphQLInfo,\n) => Record<string, unknown>\n\nexport type InitOptions = {\n /**\n * Sometimes, with the local API, you might need to pass a config file directly, for example, serverless on Vercel\n * The passed config should match the config file, and if it doesn't, there could be mismatches between the admin UI\n * and the backend functionality\n */\n config: Promise<SanitizedConfig> | SanitizedConfig\n /**\n * If set to `true`, payload will initialize crons for things like autorunning jobs on initialization.\n *\n * @default false\n */\n cron?: boolean\n\n /**\n * Disable connect to the database on init\n */\n disableDBConnect?: boolean\n\n /**\n * Disable running of the `onInit` function\n */\n disableOnInit?: boolean\n\n importMap?: ImportMap\n\n /**\n * A function that is called immediately following startup that receives the Payload instance as it's only argument.\n */\n onInit?: (payload: Payload) => Promise<void> | void\n}\n\n/**\n * This result is calculated on the server\n * and then sent to the client allowing the dashboard to show accessible data and actions.\n *\n * If the result is `true`, the user has access.\n * If the result is an object, it is interpreted as a MongoDB query.\n *\n * @example `{ createdBy: { equals: id } }`\n *\n * @example `{ tenant: { in: tenantIds } }`\n *\n * @see https://payloadcms.com/docs/access-control/overview\n */\nexport type AccessResult = boolean | Where\n\nexport type AccessArgs<TData = any> = {\n /**\n * The relevant resource that is being accessed.\n *\n * `data` is null when a list is requested\n */\n data?: TData\n /** ID of the resource being accessed */\n id?: number | string\n /** If true, the request is for a static file */\n isReadingStaticFile?: boolean\n /** The original request that requires an access check */\n req: PayloadRequest\n}\n\n/**\n * Access function runs on the server\n * and is sent to the client allowing the dashboard to show accessible data and actions.\n *\n * @see https://payloadcms.com/docs/access-control/overview\n */\nexport type Access<TData = any> = (args: AccessArgs<TData>) => AccessResult | Promise<AccessResult>\n\n/** Web Request/Response model, but the req has more payload specific properties added to it. */\nexport type PayloadHandler = (req: PayloadRequest) => Promise<Response> | Response\n\n/**\n * Docs: https://payloadcms.com/docs/rest-api/overview#custom-endpoints\n */\nexport type Endpoint = {\n /** Extension point to add your custom data. */\n custom?: Record<string, any>\n\n /**\n * Middleware that will be called when the path/method matches\n *\n * Compatible with Web Request/Response Model\n */\n handler: PayloadHandler\n /** HTTP method (or \"all\") */\n method: 'connect' | 'delete' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put'\n /**\n * Pattern that should match the path of the incoming request\n *\n * Compatible with the Express router\n */\n path: string\n /**\n * Please add \"root\" routes under the /api folder in the Payload Project.\n * https://nextjs.org/docs/app/api-reference/file-conventions/route\n *\n * @deprecated in 3.0\n */\n root?: never\n}\n\n/**\n * @deprecated\n * This type will be renamed in v4.\n * Use `DocumentViewComponent` instead.\n */\nexport type EditViewComponent = DocumentViewComponent\n\nexport type DocumentViewComponent = PayloadComponent<DocumentViewServerProps>\n\n/**\n * @deprecated\n * This type will be renamed in v4.\n * Use `DocumentViewConfig` instead.\n */\nexport type EditViewConfig = DocumentViewConfig\n\ntype BaseDocumentViewConfig = {\n actions?: CustomComponent[]\n meta?: MetaConfig\n tab?: DocumentTabConfig\n}\n\n/*\n If your view does not originate from a \"known\" key, e.g. `myCustomView`, then it is considered a \"custom\" view and can accept a `path`, etc.\n To render just a tab component without an accompanying view, you can omit the `path` and `Component` properties altogether.\n*/\nexport type CustomDocumentViewConfig =\n | ({\n Component: DocumentViewComponent\n path: `/${string}`\n } & BaseDocumentViewConfig)\n | ({\n Component?: DocumentViewComponent\n path?: never\n } & BaseDocumentViewConfig)\n\n/*\n If your view does originates from a \"known\" key, e.g. `api`, then it is considered a \"default\" view and cannot accept a `path`, etc.\n*/\nexport type DefaultDocumentViewConfig = {\n Component?: DocumentViewComponent\n} & BaseDocumentViewConfig\n\nexport type DocumentViewConfig = CustomDocumentViewConfig | DefaultDocumentViewConfig\n\nexport type Params = { [key: string]: string | string[] | undefined }\n\nexport type ServerProps = {\n readonly documentSubViewType?: DocumentSubViewTypes\n readonly i18n: I18nClient\n readonly id?: number | string\n readonly locale?: Locale\n readonly params?: Params\n readonly payload: Payload\n readonly permissions?: SanitizedPermissions\n readonly searchParams?: Params\n readonly user?: TypedUser\n readonly viewType?: ViewTypes\n readonly visibleEntities?: VisibleEntities\n}\n\nexport const serverProps: (keyof ServerProps)[] = [\n 'payload',\n 'i18n',\n 'locale',\n 'params',\n 'permissions',\n 'searchParams',\n 'permissions',\n]\n\nexport type Timezone = {\n label: string\n value: string\n}\n\ntype SupportedTimezonesFn = (args: { defaultTimezones: Timezone[] }) => Timezone[]\n\ntype TimezonesConfig = {\n /**\n * The default timezone to use for the admin panel.\n */\n defaultTimezone?: string\n /**\n * Provide your own list of supported timezones for the admin panel\n *\n * Values should be IANA timezone names, eg. `America/New_York`\n *\n * We use `@date-fns/tz` to handle timezones\n */\n supportedTimezones?: SupportedTimezonesFn | Timezone[]\n}\n\ntype SanitizedTimezoneConfig = {\n supportedTimezones: Timezone[]\n} & Omit<TimezonesConfig, 'supportedTimezones'>\n\nexport type CustomComponent<TAdditionalProps extends object = Record<string, any>> =\n PayloadComponent<ServerProps & TAdditionalProps, TAdditionalProps>\n\nexport type Locale = {\n /**\n * value of supported locale\n * @example \"en\"\n */\n code: string\n /**\n * Code of another locale to use when reading documents with fallback, if not specified defaultLocale is used\n */\n fallbackLocale?: string\n /**\n * label of supported locale\n * @example \"English\"\n */\n label: Record<string, string> | string\n /**\n * if true, defaults textAligmnent on text fields to RTL\n */\n rtl?: boolean\n}\n\nexport type BaseLocalizationConfig = {\n /**\n * Locale for users that have not expressed their preference for a specific locale\n * @example `\"en\"`\n */\n defaultLocale: string\n /**\n * Change the locale used by the default Publish button.\n * If set to `all`, all locales will be published.\n * If set to `active`, only the locale currently being edited will be published.\n * The non-default option will be available via the secondary button.\n * @default 'all'\n */\n defaultLocalePublishOption?: 'active' | 'all'\n /** Set to `true` to let missing values in localised fields fall back to the values in `defaultLocale`\n *\n * If false, then no requests will fallback unless a fallbackLocale is specified in the request.\n * @default true\n */\n fallback?: boolean\n /**\n * Define a function to filter the locales made available in Payload admin UI\n * based on user.\n */\n filterAvailableLocales?: (args: {\n locales: Locale[]\n req: PayloadRequest\n }) => Locale[] | Promise<Locale[]>\n}\n\nexport type LocalizationConfigWithNoLabels = Prettify<\n {\n /**\n * List of supported locales\n * @example `[\"en\", \"es\", \"fr\", \"nl\", \"de\", \"jp\"]`\n */\n locales: string[]\n } & BaseLocalizationConfig\n>\n\nexport type LocalizationConfigWithLabels = Prettify<\n {\n /**\n * List of supported locales with labels\n * @example {\n * label: 'English',\n * value: 'en',\n * rtl: false\n * }\n */\n locales: Locale[]\n } & BaseLocalizationConfig\n>\n\nexport type SanitizedLocalizationConfig = Prettify<\n {\n /**\n * List of supported locales\n * @example `[\"en\", \"es\", \"fr\", \"nl\", \"de\", \"jp\"]`\n */\n localeCodes: string[]\n } & LocalizationConfigWithLabels\n>\n\n/**\n * @see https://payloadcms.com/docs/configuration/localization#localization\n */\nexport type LocalizationConfig = Prettify<\n LocalizationConfigWithLabels | LocalizationConfigWithNoLabels\n>\n\nexport type LabelFunction<TTranslationKeys = DefaultTranslationKeys> = (args: {\n i18n: I18nClient\n t: TFunction<TTranslationKeys>\n}) => string\n\nexport type StaticLabel = Record<string, string> | string\n\nexport type SharpDependency = (\n input?:\n | ArrayBuffer\n | Buffer\n | Float32Array\n | Float64Array\n | Int8Array\n | Int16Array\n | Int32Array\n | string\n | Uint8Array\n | Uint8ClampedArray\n | Uint16Array\n | Uint32Array,\n options?: sharp.SharpOptions,\n) => sharp.Sharp\n\nexport type CORSConfig = {\n headers?: string[]\n origins: '*' | string[]\n}\n\nexport type AdminFunction = {\n args?: object\n path: string\n type: 'function'\n}\n\nexport type AdminComponent = {\n clientProps?: object\n path: string\n serverProps?: object\n type: 'component'\n}\n\nexport interface AdminDependencies {\n [key: string]: AdminComponent | AdminFunction\n}\n\nexport type FetchAPIFileUploadOptions = {\n /**\n * Returns a HTTP 413 when the file is bigger than the size limit if `true`.\n * Otherwise, it will add a `truncated = true` to the resulting file structure.\n * @default false\n */\n abortOnLimit?: boolean | undefined\n /**\n * Automatically creates the directory path specified in `.mv(filePathName)`\n * @default false\n */\n createParentPath?: boolean | undefined\n /**\n * Turn on/off upload process logging. Can be useful for troubleshooting.\n * @default false\n */\n debug?: boolean | undefined\n /**\n * User defined limit handler which will be invoked if the file is bigger than configured limits.\n * @default false\n */\n limitHandler?: ((args: { request: Request; size: number }) => void) | boolean | undefined\n /**\n * By default, `req.body` and `req.files` are flattened like this:\n * `{'name': 'John', 'hobbies[0]': 'Cinema', 'hobbies[1]': 'Bike'}\n *\n * When this option is enabled they are parsed in order to be nested like this:\n * `{'name': 'John', 'hobbies': ['Cinema', 'Bike']}`\n * @default false\n */\n parseNested?: boolean | undefined\n /**\n * Preserves filename extension when using `safeFileNames` option.\n * If set to `true`, will default to an extension length of `3`.\n * If set to `number`, this will be the max allowable extension length.\n * If an extension is smaller than the extension length, it remains untouched. If the extension is longer,\n * it is shifted.\n * @default false\n *\n * @example\n * // true\n * app.use(fileUpload({ safeFileNames: true, preserveExtension: true }));\n * // myFileName.ext --> myFileName.ext\n *\n * @example\n * // max extension length 2, extension shifted\n * app.use(fileUpload({ safeFileNames: true, preserveExtension: 2 }));\n * // myFileName.ext --> myFileNamee.xt\n */\n preserveExtension?: boolean | number | undefined\n /**\n * Response which will be send to client if file size limit exceeded when `abortOnLimit` set to `true`.\n * @default 'File size limit has been reached'\n */\n responseOnLimit?: string | undefined\n /**\n * Strips characters from the upload's filename.\n * You can use custom regex to determine what to strip.\n * If set to `true`, non-alphanumeric characters _except_ dashes and underscores will be stripped.\n * This option is off by default.\n * @default false\n *\n * @example\n * // strip slashes from file names\n * app.use(fileUpload({ safeFileNames: /\\\\/g }))\n *\n * @example\n * app.use(fileUpload({ safeFileNames: true }))\n */\n safeFileNames?: boolean | RegExp | undefined\n /**\n * Path to store temporary files.\n * Used along with the `useTempFiles` option. By default this module uses `'tmp'` folder\n * in the current working directory.\n * You can use trailing slash, but it is not necessary.\n * @default './tmp'\n */\n tempFileDir?: string | undefined\n /**\n * This defines how long to wait for data before aborting. Set to `0` if you want to turn off timeout checks.\n * @default 60_000\n */\n uploadTimeout?: number | undefined\n /**\n * Applies uri decoding to file names if set `true`.\n * @default false\n */\n uriDecodeFileNames?: boolean | undefined\n /**\n * By default this module uploads files into RAM.\n * Setting this option to `true` turns on using temporary files instead of utilising RAM.\n * This avoids memory overflow issues when uploading large files or in case of uploading\n * lots of files at same time.\n * @default false\n */\n useTempFiles?: boolean | undefined\n} & Partial<BusboyConfig>\n\nexport type ErrorResult = { data?: any; errors: unknown[]; stack?: string }\n\nexport type AfterErrorResult = {\n graphqlResult?: GraphQLFormattedError\n response?: Partial<ErrorResult> & Record<string, unknown>\n status?: number\n} | void\n\nexport type AfterErrorHookArgs = {\n /** The Collection that the hook is operating on. This will be undefined if the hook is executed from a non-collection endpoint or GraphQL. */\n collection?: SanitizedCollectionConfig\n /** \tCustom context passed between hooks */\n context: RequestContext\n /** The error that occurred. */\n error: Error\n /** The GraphQL result object, available if the hook is executed within a GraphQL context. */\n graphqlResult?: GraphQLFormattedError\n /** The Request object containing the currently authenticated user. */\n req: PayloadRequest\n /** The formatted error result object, available if the hook is executed from a REST context. */\n result?: ErrorResult\n}\n\nexport type ImportMapGenerators = Array<\n (props: {\n addToImportMap: AddToImportMap\n baseDir: string\n config: SanitizedConfig\n importMap: InternalImportMap\n imports: Imports\n }) => void\n>\n\nexport type AfterErrorHook = (\n args: AfterErrorHookArgs,\n) => AfterErrorResult | Promise<AfterErrorResult>\n\n/**\n * This is the central configuration\n *\n * @see https://payloadcms.com/docs/configuration/overview\n */\nexport type Config = {\n /** Configure admin dashboard */\n admin?: {\n /** Automatically log in as a user */\n autoLogin?:\n | {\n /**\n * The email address of the user to login as\n */\n email?: string\n /** The password of the user to login as. This is only needed if `prefillOnly` is set to true */\n password?: string\n /**\n * If set to true, the login credentials will be prefilled but the user will still need to click the login button.\n *\n * @default false\n */\n prefillOnly?: boolean\n /** The username of the user to login as */\n username?: string\n }\n | false\n /**\n * Automatically refresh user tokens for users logged into the dashboard\n *\n * @default false\n */\n autoRefresh?: boolean\n /** Set account profile picture. Options: gravatar, default or a custom React component. */\n avatar?:\n | 'default'\n | 'gravatar'\n | {\n Component: PayloadComponent\n }\n\n /**\n * Add extra and/or replace built-in components with custom components\n *\n * @see https://payloadcms.com/docs/admin/custom-components/overview\n */\n components?: {\n /**\n * Add custom components to the top right of the Admin Panel\n */\n actions?: CustomComponent[]\n /**\n * Add custom components after the collection overview\n */\n afterDashboard?: CustomComponent[]\n /**\n * Add custom components after the email/password field\n */\n afterLogin?: CustomComponent[]\n /**\n * Add custom components after the navigation links\n */\n afterNavLinks?: CustomComponent[]\n /**\n * Add custom components before the collection overview\n */\n beforeDashboard?: CustomComponent[]\n /**\n * Add custom components before the email/password field\n */\n beforeLogin?: CustomComponent[]\n /**\n * Add custom components before the navigation links\n */\n beforeNavLinks?: CustomComponent[]\n /** Replace graphical components */\n graphics?: {\n /** Replace the icon in the navigation */\n Icon?: CustomComponent\n /** Replace the logo on the login page */\n Logo?: CustomComponent\n }\n /**\n * Add custom header to top of page globally\n */\n header?: CustomComponent[]\n /** Replace logout related components */\n logout?: {\n /** Replace the logout button */\n Button?: CustomComponent\n }\n /**\n * Replace the navigation with a custom component\n */\n Nav?: CustomComponent\n /**\n * Wrap the admin dashboard in custom context providers\n */\n providers?: PayloadComponent<{ children?: React.ReactNode }, { children?: React.ReactNode }>[]\n /**\n * Replace or modify top-level admin routes, or add new ones:\n * + `Account` - `/admin/account`\n * + `Dashboard` - `/admin`\n * + `:path` - `/admin/:path`\n */\n views?: {\n /** Add custom admin views */\n [key: string]: AdminViewConfig\n /** Replace the account screen */\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n account?: AdminViewConfig\n /** Replace the admin homepage */\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n dashboard?: AdminViewConfig\n }\n }\n /** Extension point to add your custom data. Available in server and client. */\n custom?: Record<string, any>\n /** Global date format that will be used for all dates in the Admin panel. Any valid date-fns format pattern can be used. */\n dateFormat?: string\n /**\n * Each entry in this map generates an entry in the importMap.\n */\n dependencies?: AdminDependencies\n /**\n * @deprecated\n * This option is deprecated and will be removed in v4.\n * To disable the admin panel itself, delete your `/app/(payload)/admin` directory.\n * To disable all REST API and GraphQL endpoints, delete your `/app/(payload)/api` directory.\n * Note: If you've modified the default paths via `admin.routes`, delete those directories instead.\n */\n disable?: boolean\n importMap?: {\n /**\n * Automatically generate component map during development\n * @default true\n */\n autoGenerate?: boolean\n /**\n * The base directory for component paths starting with /.\n * @default process.cwd()\n **/\n baseDir?: string\n /**\n * You can use generators to add custom components to the component import map.\n * This allows you to import custom components in the admin panel.\n */\n generators?: ImportMapGenerators\n /**\n * If Payload cannot find the import map file location automatically,\n * you can manually provide it here.\n */\n importMapFile?: string\n }\n /**\n * Live Preview options.\n *\n * @see https://payloadcms.com/docs/live-preview/overview\n */\n livePreview?: RootLivePreviewConfig\n /** Base meta data to use for the Admin Panel. Included properties are titleSuffix, ogImage, and favicon. */\n meta?: MetaConfig\n routes?: {\n /** The route for the account page.\n *\n * @default '/account'\n */\n account?: `/${string}`\n /** The route for the browse by folder view.\n *\n * @default '/browse-by-folder'\n */\n browseByFolder?: `/${string}`\n /** The route for the create first user page.\n *\n * @default '/create-first-user'\n */\n createFirstUser?: `/${string}`\n /** The route for the forgot password page.\n *\n * @default '/forgot'\n */\n forgot?: `/${string}`\n /** The route the user will be redirected to after being inactive for too long.\n *\n * @default '/logout-inactivity'\n */\n inactivity?: `/${string}`\n /** The route for the login page.\n *\n * @default '/login'\n */\n login?: `/${string}`\n /** The route for the logout page.\n *\n * @default '/logout'\n */\n logout?: `/${string}`\n /** The route for the reset password page.\n *\n * @default '/reset'\n */\n reset?: `/${string}`\n /** The route for the unauthorized page.\n *\n * @default '/unauthorized'\n */\n unauthorized?: `/${string}`\n }\n /**\n * Suppresses React hydration mismatch warnings during the hydration of the root <html> tag.\n * Useful in scenarios where the server-rendered HTML might intentionally differ from the client-rendered DOM.\n * @default false\n */\n suppressHydrationWarning?: boolean\n /**\n * Restrict the Admin Panel theme to use only one of your choice\n *\n * @default 'all' // The theme can be configured by users\n */\n theme?: 'all' | 'dark' | 'light'\n /**\n * Configure timezone related settings for the admin panel.\n */\n timezones?: TimezonesConfig\n /**\n * Configure toast message behavior and appearance in the admin panel.\n * Currently using [Sonner](https://sonner.emilkowal.ski) for toast notifications.\n *\n * @experimental This property is experimental and may change in future releases. Use at your own discretion.\n */\n toast?: {\n /**\n * Time in milliseconds until the toast automatically closes.\n * @default 4000\n */\n duration?: number\n /**\n * If `true`, will expand the message stack so that all messages are shown simultaneously without user interaction.\n * Otherwise only the latest notification can be read until the user hovers the stack.\n * @default false\n */\n expand?: boolean\n /**\n * The maximum number of toasts that can be visible on the screen at once.\n * @default 5\n */\n limit?: number\n }\n /** The slug of a Collection that you want to be used to log in to the Admin dashboard. */\n user?: string\n }\n\n /**\n * Configure authentication-related Payload-wide settings.\n */\n auth?: {\n /**\n * Define which JWT identification methods you'd like to support for Payload's local auth strategy, as well as the order that they're retrieved in.\n * Defaults to ['JWT', 'Bearer', 'cookie]\n */\n jwtOrder: ('Bearer' | 'cookie' | 'JWT')[]\n }\n /** Custom Payload bin scripts can be injected via the config. */\n bin?: BinScriptConfig[]\n blocks?: Block[]\n /**\n * Pass additional options to the parser used to process `multipart/form-data` requests.\n * For example, a PATCH request containing HTML form data.\n * For example, you may want to increase the `limits` imposed by the parser.\n * Currently using @link {https://www.npmjs.com/package/busboy|busboy} under the hood.\n *\n * @experimental This property is experimental and may change in future releases. Use at your own discretion.\n */\n bodyParser?: Partial<BusboyConfig>\n /**\n * Manage the datamodel of your application\n *\n * @see https://payloadcms.com/docs/configuration/collections#collection-configs\n */\n collections?: CollectionConfig[]\n /**\n * Compatibility flags for prior Payload versions\n */\n compatibility?: {\n /**\n * By default, Payload will remove the `localized: true` property\n * from fields if a parent field is localized. Set this property\n * to `true` only if you have an existing Payload database from pre-3.0\n * that you would like to maintain without migrating. This is only\n * relevant for MongoDB databases.\n *\n * @todo Remove in v4\n */\n allowLocalizedWithinLocalized: true\n }\n /**\n * Prefix a string to all cookies that Payload sets.\n *\n * @default \"payload\"\n */\n cookiePrefix?: string\n /** Either a whitelist array of URLS to allow CORS requests from, or a wildcard string ('*') to accept incoming requests from any domain. */\n cors?: '*' | CORSConfig | string[]\n /** A whitelist array of URLs to allow Payload cookies to be accepted from as a form of CSRF protection. */\n csrf?: string[]\n /** Extension point to add your custom data. Server only. */\n custom?: Record<string, any>\n /** Pass in a database adapter for use on this project. */\n db: DatabaseAdapterResult\n /** Enable to expose more detailed error information. */\n debug?: boolean\n /**\n * If a user does not specify `depth` while requesting a resource, this depth will be used.\n *\n * @see https://payloadcms.com/docs/getting-started/concepts#depth\n *\n * @default 2\n */\n defaultDepth?: number\n /**\n * The maximum allowed depth to be permitted application-wide. This setting helps prevent against malicious queries.\n *\n * @default 40000\n */\n defaultMaxTextLength?: number\n /** Default richtext editor to use for richText fields */\n editor?: RichTextAdapterProvider<any, any, any>\n /**\n * Email Adapter\n *\n * @see https://payloadcms.com/docs/email/overview\n */\n email?: EmailAdapter | Promise<EmailAdapter>\n /** Custom REST endpoints */\n endpoints?: Endpoint[]\n /**\n * Options for folder view within the admin panel\n *\n * @experimental This feature may change in minor versions until it is fully stable\n */\n folders?: false | RootFoldersConfiguration\n /**\n * @see https://payloadcms.com/docs/configuration/globals#global-configs\n */\n globals?: GlobalConfig[]\n /**\n * Manage the GraphQL API\n *\n * You can add your own GraphQL queries and mutations to Payload, making use of all the types that Payload has defined for you.\n *\n * @see https://payloadcms.com/docs/graphql/overview\n */\n graphQL?: {\n disable?: boolean\n /**\n * Disable introspection queries in production.\n *\n * @default true\n */\n disableIntrospectionInProduction?: boolean\n /**\n * Disable the GraphQL Playground in production.\n *\n * @default true\n */\n disablePlaygroundInProduction?: boolean\n maxComplexity?: number\n /**\n * Function that returns an object containing keys to custom GraphQL mutations\n *\n * @see https://payloadcms.com/docs/graphql/extending\n */\n mutations?: GraphQLExtension\n /**\n * Function that returns an object containing keys to custom GraphQL queries\n *\n * @see https://payloadcms.com/docs/graphql/extending\n */\n queries?: GraphQLExtension\n /**\n * Filepath to write the generated schema to\n */\n schemaOutputFile?: string\n /**\n * Function that returns an array of validation rules to apply to the GraphQL schema\n *\n * @see https://payloadcms.com/docs/graphql/overview#custom-validation-rules\n */\n validationRules?: (args: GraphQL.ExecutionArgs) => GraphQL.ValidationRule[]\n }\n /**\n * Tap into Payload-wide hooks.\n *\n * @see https://payloadcms.com/docs/hooks/overview\n */\n hooks?: {\n afterError?: AfterErrorHook[]\n }\n /** i18n config settings */\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n i18n?: I18nOptions<{} | DefaultTranslationsObject> // loosen the type here to allow for custom translations\n /** Automatically index all sortable top-level fields in the database to improve sort performance and add database compatibility for Azure Cosmos and similar. */\n indexSortableFields?: boolean\n /**\n * @experimental There may be frequent breaking changes to this API\n */\n jobs?: JobsConfig\n /**\n * Translate your content to different languages/locales.\n *\n * @default false // disable localization\n */\n localization?: false | LocalizationConfig\n /**\n * Logger options, logger options with a destination stream, or an instantiated logger instance.\n *\n * See Pino Docs for options: https://getpino.io/#/docs/api?id=options\n *\n * ```ts\n * // Logger options only\n * logger: {\n * level: 'info',\n * }\n *\n * // Logger options with destination stream\n * logger: {\n * options: {\n * level: 'info',\n * },\n * destination: process.stdout\n * },\n *\n * // Logger instance\n * logger: pino({ name: 'my-logger' })\n *\n * ```\n */\n logger?: 'sync' | { destination?: DestinationStream; options: pino.LoggerOptions } | PayloadLogger\n\n /**\n * Override the log level of errors for Payload's error handler or disable logging with `false`.\n * Levels can be any of the following: 'trace', 'debug', 'info', 'warn', 'error', 'fatal' or false.\n *\n * Default levels:\n * {\n `* APIError: 'error',\n `* AuthenticationError: 'error',\n `* ErrorDeletingFile: 'error',\n `* FileRetrievalError: 'error',\n `* FileUploadError: 'error',\n `* Forbidden: 'info',\n `* Locked: 'info',\n `* LockedAuth: 'error',\n `* MissingFile: 'info',\n `* NotFound: 'info',\n `* QueryError: 'error',\n `* ValidationError: 'info',\n * }\n */\n loggingLevels?: Partial<Record<ErrorName, false | Level>>\n\n /**\n * The maximum allowed depth to be permitted application-wide. This setting helps prevent against malicious queries.\n *\n * @see https://payloadcms.com/docs/getting-started/concepts#depth\n *\n * @default 10\n */\n maxDepth?: number\n\n /** A function that is called immediately following startup that receives the Payload instance as its only argument. */\n onInit?: (payload: Payload) => Promise<void> | void\n /**\n * An array of Payload plugins.\n *\n * @see https://payloadcms.com/docs/plugins/overview\n */\n plugins?: Plugin[]\n /**\n * Allow you to save and share filters, columns, and sort orders for your collections.\n * @see https://payloadcms.com/docs/query-presets/overview\n */\n queryPresets?: {\n access: {\n create?: Access<QueryPreset>\n delete?: Access<QueryPreset>\n read?: Access<QueryPreset>\n update?: Access<QueryPreset>\n }\n constraints: {\n create?: QueryPresetConstraints\n delete?: QueryPresetConstraints\n read?: QueryPresetConstraints\n update?: QueryPresetConstraints\n }\n filterConstraints?: SelectField['filterOptions']\n labels?: CollectionConfig['labels']\n }\n /**\n * Control the routing structure that Payload binds itself to.\n * @link https://payloadcms.com/docs/admin/overview#root-level-routes\n */\n routes?: {\n /**\n * The route for the admin panel.\n * @example \"/my-admin\" or \"/\"\n * @default \"/admin\"\n * @link https://payloadcms.com/docs/admin/overview#root-level-routes\n */\n admin?: string\n /**\n * The base route for all REST API endpoints.\n * @default \"/api\"\n * @link https://payloadcms.com/docs/admin/overview#root-level-routes\n */\n api?: string\n /**\n * The base route for all GraphQL endpoints.\n * @default \"/graphql\"\n * @link https://payloadcms.com/docs/admin/overview#root-level-routes\n */\n graphQL?: string\n /**\n * The route for the GraphQL Playground.\n * @default \"/graphql-playground\"\n * @link https://payloadcms.com/docs/admin/overview#root-level-routes\n */\n graphQLPlayground?: string\n }\n /** Secure string that Payload will use for any encryption workflows */\n secret: string\n /**\n * Define the absolute URL of your app including the protocol, for example `https://example.org`.\n * No paths allowed, only protocol, domain and (optionally) port.\n *\n * @see https://payloadcms.com/docs/configuration/overview#options\n */\n serverURL?: string\n /**\n * Pass in a local copy of Sharp if you'd like to use it.\n *\n */\n sharp?: SharpDependency\n /** Send anonymous telemetry data about general usage. */\n telemetry?: boolean\n /** Control how typescript interfaces are generated from your collections. */\n typescript?: {\n /**\n * Automatically generate types during development\n * @default true\n */\n autoGenerate?: boolean\n\n /** Disable declare block in generated types file */\n declare?:\n | {\n /**\n * @internal internal use only to allow for multiple declarations within a monorepo and suppress the \"Duplicate identifier GeneratedTypes\" error\n *\n * Adds a @ts-ignore flag above the GeneratedTypes interface declaration\n *\n * @default false\n */\n ignoreTSError?: boolean\n }\n | false\n\n /** Filename to write the generated types to */\n outputFile?: string\n\n /**\n * Allows you to modify the base JSON schema that is generated during generate:types. This JSON schema will be used\n * to generate the TypeScript interfaces.\n */\n schema?: Array<\n (args: {\n collectionIDFieldTypes: {\n [key: string]: 'number' | 'string'\n }\n config: SanitizedConfig\n i18n: I18n\n jsonSchema: JSONSchema4\n }) => JSONSchema4\n >\n }\n /**\n * Customize the handling of incoming file uploads for collections that have uploads enabled.\n */\n upload?: FetchAPIFileUploadOptions\n}\n\n/**\n * @todo remove the `DeepRequired` in v4.\n * We don't actually guarantee that all properties are set when sanitizing configs.\n */\nexport type SanitizedConfig = {\n admin: {\n timezones: SanitizedTimezoneConfig\n } & DeepRequired<Config['admin']>\n blocks?: FlattenedBlock[]\n collections: SanitizedCollectionConfig[]\n /** Default richtext editor to use for richText fields */\n editor?: RichTextAdapter<any, any, any>\n endpoints: Endpoint[]\n globals: SanitizedGlobalConfig[]\n i18n: Required<I18nOptions>\n jobs: SanitizedJobsConfig\n localization: false | SanitizedLocalizationConfig\n paths: {\n config: string\n configDir: string\n rawConfig: string\n }\n upload: {\n /**\n * Deduped list of adapters used in the project\n */\n adapters: string[]\n } & FetchAPIFileUploadOptions\n} & Omit<\n // TODO: DeepRequired breaks certain, advanced TypeScript types / certain type information is lost. We should remove it when possible.\n // E.g. in packages/ui/src/graphics/Account/index.tsx in getComponent, if avatar.Component is casted to what it's supposed to be,\n // the result type is different\n DeepRequired<Config>,\n | 'admin'\n | 'blocks'\n | 'collections'\n | 'editor'\n | 'endpoint'\n | 'globals'\n | 'i18n'\n | 'jobs'\n | 'localization'\n | 'upload'\n>\n\nexport type EditConfig = EditConfigWithoutRoot | EditConfigWithRoot\n\n/**\n * Replace or modify _all_ nested document views and routes, including the document header, controls, and tabs. This cannot be used in conjunction with other nested views.\n * + `root` - `/admin/collections/:collection/:id/**\\/*`\n * @link https://payloadcms.com/docs/custom-components/document-views#document-root\n */\nexport type EditConfigWithRoot = {\n api?: never\n default?: never\n livePreview?: never\n root: DefaultDocumentViewConfig\n version?: never\n versions?: never\n}\n\ntype KnownEditKeys = 'api' | 'default' | 'livePreview' | 'root' | 'version' | 'versions'\n\n/**\n * Replace or modify individual nested routes, or add new ones:\n * + `default` - `/admin/collections/:collection/:id`\n * + `api` - `/admin/collections/:collection/:id/api`\n * + `livePreview` - `/admin/collections/:collection/:id/preview`\n * + `references` - `/admin/collections/:collection/:id/references`\n * + `relationships` - `/admin/collections/:collection/:id/relationships`\n * + `versions` - `/admin/collections/:collection/:id/versions`\n * + `version` - `/admin/collections/:collection/:id/versions/:version`\n * + `customView` - `/admin/collections/:collection/:id/:path`\n *\n * To override the entire Edit View including all nested views, use the `root` key.\n *\n * @link https://payloadcms.com/docs/custom-components/document-views\n */\nexport type EditConfigWithoutRoot = {\n [K in Exclude<string, KnownEditKeys>]: CustomDocumentViewConfig\n} & {\n api?: DefaultDocumentViewConfig\n default?: DefaultDocumentViewConfig\n livePreview?: DefaultDocumentViewConfig\n root?: never\n version?: DefaultDocumentViewConfig\n versions?: DefaultDocumentViewConfig\n}\n\nexport type EntityDescriptionComponent = CustomComponent\n\nexport type EntityDescriptionFunction = ({ t }: { t: TFunction }) => string\n\nexport type EntityDescription = EntityDescriptionFunction | Record<string, string> | string\n\nexport type { EmailAdapter, SendEmailOptions }\n"],"names":["serverProps"],"mappings":"AAwaA,OAAO,MAAMA,cAAqC;IAChD;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAA"}
1
+ {"version":3,"sources":["../../src/config/types.ts"],"sourcesContent":["import type {\n DefaultTranslationKeys,\n DefaultTranslationsObject,\n I18n,\n I18nClient,\n I18nOptions,\n TFunction,\n} from '@payloadcms/translations'\nimport type { BusboyConfig } from 'busboy'\nimport type GraphQL from 'graphql'\nimport type { GraphQLFormattedError } from 'graphql'\nimport type { JSONSchema4 } from 'json-schema'\nimport type { Metadata } from 'next'\nimport type { DestinationStream, Level, pino } from 'pino'\nimport type React from 'react'\nimport type { default as sharp } from 'sharp'\nimport type { DeepRequired } from 'ts-essentials'\n\nimport type { RichTextAdapterProvider } from '../admin/RichText.js'\nimport type {\n DocumentSubViewTypes,\n DocumentTabConfig,\n DocumentViewServerProps,\n RichTextAdapter,\n} from '../admin/types.js'\nimport type { AdminViewConfig, ViewTypes, VisibleEntities } from '../admin/views/index.js'\nimport type { SanitizedPermissions } from '../auth/index.js'\nimport type {\n AddToImportMap,\n ImportMap,\n Imports,\n InternalImportMap,\n} from '../bin/generateImportMap/index.js'\nimport type {\n Collection,\n CollectionConfig,\n SanitizedCollectionConfig,\n} from '../collections/config/types.js'\nimport type { DatabaseAdapterResult } from '../database/types.js'\nimport type { EmailAdapter, SendEmailOptions } from '../email/types.js'\nimport type { ErrorName } from '../errors/types.js'\nimport type { RootFoldersConfiguration } from '../folders/types.js'\nimport type { GlobalConfig, Globals, SanitizedGlobalConfig } from '../globals/config/types.js'\nimport type {\n Block,\n FlattenedBlock,\n JobsConfig,\n Payload,\n RequestContext,\n SelectField,\n TypedUser,\n} from '../index.js'\nimport type { QueryPreset, QueryPresetConstraints } from '../query-presets/types.js'\nimport type { SanitizedJobsConfig } from '../queues/config/types/index.js'\nimport type { PayloadRequest, Where } from '../types/index.js'\nimport type { PayloadLogger } from '../utilities/logger.js'\n\n/**\n * The string path pointing to the React component. If one of the generics is `never`, you effectively mark it as a server-only or client-only component.\n *\n * If it is `false` an empty component will be rendered.\n */\nexport type PayloadComponent<\n TComponentServerProps extends never | object = Record<string, any>,\n TComponentClientProps extends never | object = Record<string, any>,\n> = false | RawPayloadComponent<TComponentServerProps, TComponentClientProps> | string\n\n// We need the actual object as its own type, otherwise the infers for the PayloadClientReactComponent / PayloadServerReactComponent will not work due to the string union.\n// We also NEED to actually use those generics for this to work, thus they are part of the props.\nexport type RawPayloadComponent<\n TComponentServerProps extends never | object = Record<string, any>,\n TComponentClientProps extends never | object = Record<string, any>,\n> = {\n clientProps?: object | TComponentClientProps\n exportName?: string\n path: string\n serverProps?: object | TComponentServerProps\n}\n\nexport type PayloadComponentProps<TPayloadComponent> =\n TPayloadComponent extends RawPayloadComponent<\n infer TComponentServerProps,\n infer TComponentClientProps\n >\n ? TComponentClientProps | TComponentServerProps\n : never\n\nexport type PayloadClientComponentProps<TPayloadComponent> =\n TPayloadComponent extends RawPayloadComponent<infer _, infer TComponentClientProps>\n ? TComponentClientProps\n : never\n\nexport type PayloadServerComponentProps<TPayloadComponent> =\n TPayloadComponent extends RawPayloadComponent<infer TComponentServerProps, infer _>\n ? TComponentServerProps\n : never\n\nexport type PayloadReactComponent<TPayloadComponent> = React.FC<\n PayloadComponentProps<TPayloadComponent>\n>\n\n// This also ensures that if never is passed to TComponentClientProps, this entire type will be never.\n// => TypeScript will now ensure that users cannot even define the typed Server Components if the PayloadComponent is marked as\n// Client-Only (marked as Client-Only = TComponentServerProps is never)\nexport type PayloadClientReactComponent<TPayloadComponent> =\n TPayloadComponent extends RawPayloadComponent<infer _, infer TComponentClientProps>\n ? TComponentClientProps extends never\n ? never\n : React.FC<TComponentClientProps>\n : never\n\nexport type PayloadServerReactComponent<TPayloadComponent> =\n TPayloadComponent extends RawPayloadComponent<infer TComponentServerProps, infer _>\n ? TComponentServerProps extends never\n ? never\n : React.FC<TComponentServerProps>\n : never\n\nexport type ResolvedComponent<\n TComponentServerProps extends never | object,\n TComponentClientProps extends never | object,\n> = {\n clientProps?: TComponentClientProps\n Component: React.FC<TComponentClientProps | TComponentServerProps>\n serverProps?: TComponentServerProps\n}\n\nexport type BinScriptConfig = {\n key: string\n scriptPath: string\n}\n\nexport type BinScript = (config: SanitizedConfig) => Promise<void> | void\n\ntype Prettify<T> = {\n [K in keyof T]: T[K]\n} & NonNullable<unknown>\n\nexport type Plugin = (config: Config) => Config | Promise<Config>\n\nexport type LivePreviewURLType = null | string | undefined\n\nexport type LivePreviewConfig = {\n /**\n Device breakpoints to use for the `iframe` of the Live Preview window.\n Options are displayed in the Live Preview toolbar.\n The `responsive` breakpoint is included by default.\n */\n breakpoints?: {\n height: number | string\n label: string\n name: string\n width: number | string\n }[]\n /**\n * The URL of the frontend application. This will be rendered within an `iframe` as its `src`.\n * Payload will send a `window.postMessage()` to this URL with the document data in real-time.\n * The frontend application is responsible for receiving the message and updating the UI accordingly.\n * @see https://payloadcms.com/docs/live-preview/frontend\n *\n * To conditionally render Live Preview, use a function that returns `undefined` or `null`.\n *\n * Note: this function may run often if autosave is enabled with a small interval.\n * For performance, avoid long-running tasks or expensive operations within this function,\n * or if you need to do something more complex, cache your function as needed.\n */\n url?:\n | ((args: {\n collectionConfig?: SanitizedCollectionConfig\n data: Record<string, any>\n globalConfig?: SanitizedGlobalConfig\n locale: Locale\n /**\n * @deprecated\n * Use `req.payload` instead. This will be removed in the next major version.\n */\n payload: Payload\n req: PayloadRequest\n }) => LivePreviewURLType | Promise<LivePreviewURLType>)\n | LivePreviewURLType\n}\n\nexport type RootLivePreviewConfig = {\n collections?: string[]\n globals?: string[]\n} & LivePreviewConfig\n\nexport type OGImageConfig = {\n alt?: string\n height?: number | string\n type?: string\n url: string\n width?: number | string\n}\n\n/**\n * @todo find a way to remove the deep clone here.\n * It can probably be removed after the `DeepRequired` from `Config` to `SanitizedConfig` is removed.\n * Same with `CollectionConfig` to `SanitizedCollectionConfig`.\n */\ntype DeepClone<T> = T extends object ? { [K in keyof T]: DeepClone<T[K]> } : T\n\nexport type MetaConfig = {\n /**\n * When `static`, a pre-made image will be used for all pages.\n * When `dynamic`, a unique image will be generated for each page based on page content and given overrides.\n * When `off`, no Open Graph images will be generated and the `/api/og` endpoint will be disabled. You can still provide custom images using the `openGraph.images` property.\n * @default 'dynamic'\n */\n defaultOGImageType?: 'dynamic' | 'off' | 'static'\n /**\n * String to append to the auto-generated <title> of admin pages\n * @example `\" - Custom CMS\"`\n */\n titleSuffix?: string\n} & DeepClone<Metadata>\n\nexport type ServerOnlyLivePreviewProperties = keyof Pick<RootLivePreviewConfig, 'url'>\n\ntype GeneratePreviewURLOptions = {\n locale: string\n req: PayloadRequest\n token: null | string\n}\n\nexport type GeneratePreviewURL = (\n doc: Record<string, unknown>,\n options: GeneratePreviewURLOptions,\n) => null | Promise<null | string> | string\n\nexport type GraphQLInfo = {\n collections: {\n [slug: string]: Collection\n }\n globals: Globals\n Mutation: {\n fields: Record<string, any>\n name: string\n }\n Query: {\n fields: Record<string, any>\n name: string\n }\n types: {\n arrayTypes: Record<string, GraphQL.GraphQLType>\n blockInputTypes: Record<string, GraphQL.GraphQLInputObjectType>\n blockTypes: Record<string, GraphQL.GraphQLObjectType>\n fallbackLocaleInputType?: GraphQL.GraphQLEnumType | GraphQL.GraphQLScalarType\n groupTypes: Record<string, GraphQL.GraphQLObjectType>\n localeInputType?: GraphQL.GraphQLEnumType | GraphQL.GraphQLScalarType\n tabTypes: Record<string, GraphQL.GraphQLObjectType>\n }\n}\nexport type GraphQLExtension = (\n graphQL: typeof GraphQL,\n context: {\n config: SanitizedConfig\n } & GraphQLInfo,\n) => Record<string, unknown>\n\nexport type InitOptions = {\n /**\n * Sometimes, with the local API, you might need to pass a config file directly, for example, serverless on Vercel\n * The passed config should match the config file, and if it doesn't, there could be mismatches between the admin UI\n * and the backend functionality\n */\n config: Promise<SanitizedConfig> | SanitizedConfig\n /**\n * If set to `true`, payload will initialize crons for things like autorunning jobs on initialization.\n *\n * @default false\n */\n cron?: boolean\n\n /**\n * Disable connect to the database on init\n */\n disableDBConnect?: boolean\n\n /**\n * Disable running of the `onInit` function\n */\n disableOnInit?: boolean\n\n importMap?: ImportMap\n\n /**\n * A function that is called immediately following startup that receives the Payload instance as it's only argument.\n */\n onInit?: (payload: Payload) => Promise<void> | void\n}\n\n/**\n * This result is calculated on the server\n * and then sent to the client allowing the dashboard to show accessible data and actions.\n *\n * If the result is `true`, the user has access.\n * If the result is an object, it is interpreted as a MongoDB query.\n *\n * @example `{ createdBy: { equals: id } }`\n *\n * @example `{ tenant: { in: tenantIds } }`\n *\n * @see https://payloadcms.com/docs/access-control/overview\n */\nexport type AccessResult = boolean | Where\n\nexport type AccessArgs<TData = any> = {\n /**\n * The relevant resource that is being accessed.\n *\n * `data` is null when a list is requested\n */\n data?: TData\n /** ID of the resource being accessed */\n id?: number | string\n /** If true, the request is for a static file */\n isReadingStaticFile?: boolean\n /** The original request that requires an access check */\n req: PayloadRequest\n}\n\n/**\n * Access function runs on the server\n * and is sent to the client allowing the dashboard to show accessible data and actions.\n *\n * @see https://payloadcms.com/docs/access-control/overview\n */\nexport type Access<TData = any> = (args: AccessArgs<TData>) => AccessResult | Promise<AccessResult>\n\n/** Web Request/Response model, but the req has more payload specific properties added to it. */\nexport type PayloadHandler = (req: PayloadRequest) => Promise<Response> | Response\n\n/**\n * Docs: https://payloadcms.com/docs/rest-api/overview#custom-endpoints\n */\nexport type Endpoint = {\n /** Extension point to add your custom data. */\n custom?: Record<string, any>\n\n /**\n * Middleware that will be called when the path/method matches\n *\n * Compatible with Web Request/Response Model\n */\n handler: PayloadHandler\n /** HTTP method (or \"all\") */\n method: 'connect' | 'delete' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put'\n /**\n * Pattern that should match the path of the incoming request\n *\n * Compatible with the Express router\n */\n path: string\n /**\n * Please add \"root\" routes under the /api folder in the Payload Project.\n * https://nextjs.org/docs/app/api-reference/file-conventions/route\n *\n * @deprecated in 3.0\n */\n root?: never\n}\n\n/**\n * @deprecated\n * This type will be renamed in v4.\n * Use `DocumentViewComponent` instead.\n */\nexport type EditViewComponent = DocumentViewComponent\n\nexport type DocumentViewComponent = PayloadComponent<DocumentViewServerProps>\n\n/**\n * @deprecated\n * This type will be renamed in v4.\n * Use `DocumentViewConfig` instead.\n */\nexport type EditViewConfig = DocumentViewConfig\n\ntype BaseDocumentViewConfig = {\n actions?: CustomComponent[]\n meta?: MetaConfig\n tab?: DocumentTabConfig\n}\n\n/*\n If your view does not originate from a \"known\" key, e.g. `myCustomView`, then it is considered a \"custom\" view and can accept a `path`, etc.\n To render just a tab component without an accompanying view, you can omit the `path` and `Component` properties altogether.\n*/\nexport type CustomDocumentViewConfig =\n | ({\n Component: DocumentViewComponent\n path: `/${string}`\n } & BaseDocumentViewConfig)\n | ({\n Component?: DocumentViewComponent\n path?: never\n } & BaseDocumentViewConfig)\n\n/*\n If your view does originates from a \"known\" key, e.g. `api`, then it is considered a \"default\" view and cannot accept a `path`, etc.\n*/\nexport type DefaultDocumentViewConfig = {\n Component?: DocumentViewComponent\n} & BaseDocumentViewConfig\n\nexport type DocumentViewConfig = CustomDocumentViewConfig | DefaultDocumentViewConfig\n\nexport type Params = { [key: string]: string | string[] | undefined }\n\nexport type ServerProps = {\n readonly documentSubViewType?: DocumentSubViewTypes\n readonly i18n: I18nClient\n readonly id?: number | string\n readonly locale?: Locale\n readonly params?: Params\n readonly payload: Payload\n readonly permissions?: SanitizedPermissions\n readonly searchParams?: Params\n readonly user?: TypedUser\n readonly viewType?: ViewTypes\n readonly visibleEntities?: VisibleEntities\n}\n\nexport const serverProps: (keyof ServerProps)[] = [\n 'payload',\n 'i18n',\n 'locale',\n 'params',\n 'permissions',\n 'searchParams',\n 'permissions',\n]\n\nexport type Timezone = {\n label: string\n value: string\n}\n\ntype SupportedTimezonesFn = (args: { defaultTimezones: Timezone[] }) => Timezone[]\n\ntype TimezonesConfig = {\n /**\n * The default timezone to use for the admin panel.\n */\n defaultTimezone?: string\n /**\n * Provide your own list of supported timezones for the admin panel\n *\n * Values should be IANA timezone names, eg. `America/New_York`\n *\n * We use `@date-fns/tz` to handle timezones\n */\n supportedTimezones?: SupportedTimezonesFn | Timezone[]\n}\n\ntype SanitizedTimezoneConfig = {\n supportedTimezones: Timezone[]\n} & Omit<TimezonesConfig, 'supportedTimezones'>\n\nexport type CustomComponent<TAdditionalProps extends object = Record<string, any>> =\n PayloadComponent<ServerProps & TAdditionalProps, TAdditionalProps>\n\nexport type Locale = {\n /**\n * value of supported locale\n * @example \"en\"\n */\n code: string\n /**\n * Code of another locale to use when reading documents with fallback, if not specified defaultLocale is used\n */\n fallbackLocale?: string\n /**\n * label of supported locale\n * @example \"English\"\n */\n label: Record<string, string> | string\n /**\n * if true, defaults textAligmnent on text fields to RTL\n */\n rtl?: boolean\n}\n\nexport type BaseLocalizationConfig = {\n /**\n * Locale for users that have not expressed their preference for a specific locale\n * @example `\"en\"`\n */\n defaultLocale: string\n /**\n * Change the locale used by the default Publish button.\n * If set to `all`, all locales will be published.\n * If set to `active`, only the locale currently being edited will be published.\n * The non-default option will be available via the secondary button.\n * @default 'all'\n */\n defaultLocalePublishOption?: 'active' | 'all'\n /** Set to `true` to let missing values in localised fields fall back to the values in `defaultLocale`\n *\n * If false, then no requests will fallback unless a fallbackLocale is specified in the request.\n * @default true\n */\n fallback?: boolean\n /**\n * Define a function to filter the locales made available in Payload admin UI\n * based on user.\n */\n filterAvailableLocales?: (args: {\n locales: Locale[]\n req: PayloadRequest\n }) => Locale[] | Promise<Locale[]>\n}\n\nexport type LocalizationConfigWithNoLabels = Prettify<\n {\n /**\n * List of supported locales\n * @example `[\"en\", \"es\", \"fr\", \"nl\", \"de\", \"jp\"]`\n */\n locales: string[]\n } & BaseLocalizationConfig\n>\n\nexport type LocalizationConfigWithLabels = Prettify<\n {\n /**\n * List of supported locales with labels\n * @example {\n * label: 'English',\n * value: 'en',\n * rtl: false\n * }\n */\n locales: Locale[]\n } & BaseLocalizationConfig\n>\n\nexport type SanitizedLocalizationConfig = Prettify<\n {\n /**\n * List of supported locales\n * @example `[\"en\", \"es\", \"fr\", \"nl\", \"de\", \"jp\"]`\n */\n localeCodes: string[]\n } & LocalizationConfigWithLabels\n>\n\n/**\n * @see https://payloadcms.com/docs/configuration/localization#localization\n */\nexport type LocalizationConfig = Prettify<\n LocalizationConfigWithLabels | LocalizationConfigWithNoLabels\n>\n\nexport type LabelFunction<TTranslationKeys = DefaultTranslationKeys> = (args: {\n i18n: I18nClient\n t: TFunction<TTranslationKeys>\n}) => string\n\nexport type StaticLabel = Record<string, string> | string\n\nexport type SharpDependency = (\n input?:\n | ArrayBuffer\n | Buffer\n | Float32Array\n | Float64Array\n | Int8Array\n | Int16Array\n | Int32Array\n | string\n | Uint8Array\n | Uint8ClampedArray\n | Uint16Array\n | Uint32Array,\n options?: sharp.SharpOptions,\n) => sharp.Sharp\n\nexport type CORSConfig = {\n headers?: string[]\n origins: '*' | string[]\n}\n\nexport type AdminFunction = {\n args?: object\n path: string\n type: 'function'\n}\n\nexport type AdminComponent = {\n clientProps?: object\n path: string\n serverProps?: object\n type: 'component'\n}\n\nexport interface AdminDependencies {\n [key: string]: AdminComponent | AdminFunction\n}\n\nexport type FetchAPIFileUploadOptions = {\n /**\n * Returns a HTTP 413 when the file is bigger than the size limit if `true`.\n * Otherwise, it will add a `truncated = true` to the resulting file structure.\n * @default false\n */\n abortOnLimit?: boolean | undefined\n /**\n * Automatically creates the directory path specified in `.mv(filePathName)`\n * @default false\n */\n createParentPath?: boolean | undefined\n /**\n * Turn on/off upload process logging. Can be useful for troubleshooting.\n * @default false\n */\n debug?: boolean | undefined\n /**\n * User defined limit handler which will be invoked if the file is bigger than configured limits.\n * @default false\n */\n limitHandler?: ((args: { request: Request; size: number }) => void) | boolean | undefined\n /**\n * By default, `req.body` and `req.files` are flattened like this:\n * `{'name': 'John', 'hobbies[0]': 'Cinema', 'hobbies[1]': 'Bike'}\n *\n * When this option is enabled they are parsed in order to be nested like this:\n * `{'name': 'John', 'hobbies': ['Cinema', 'Bike']}`\n * @default false\n */\n parseNested?: boolean | undefined\n /**\n * Preserves filename extension when using `safeFileNames` option.\n * If set to `true`, will default to an extension length of `3`.\n * If set to `number`, this will be the max allowable extension length.\n * If an extension is smaller than the extension length, it remains untouched. If the extension is longer,\n * it is shifted.\n * @default false\n *\n * @example\n * // true\n * app.use(fileUpload({ safeFileNames: true, preserveExtension: true }));\n * // myFileName.ext --> myFileName.ext\n *\n * @example\n * // max extension length 2, extension shifted\n * app.use(fileUpload({ safeFileNames: true, preserveExtension: 2 }));\n * // myFileName.ext --> myFileNamee.xt\n */\n preserveExtension?: boolean | number | undefined\n /**\n * Response which will be send to client if file size limit exceeded when `abortOnLimit` set to `true`.\n * @default 'File size limit has been reached'\n */\n responseOnLimit?: string | undefined\n /**\n * Strips characters from the upload's filename.\n * You can use custom regex to determine what to strip.\n * If set to `true`, non-alphanumeric characters _except_ dashes and underscores will be stripped.\n * This option is off by default.\n * @default false\n *\n * @example\n * // strip slashes from file names\n * app.use(fileUpload({ safeFileNames: /\\\\/g }))\n *\n * @example\n * app.use(fileUpload({ safeFileNames: true }))\n */\n safeFileNames?: boolean | RegExp | undefined\n /**\n * Path to store temporary files.\n * Used along with the `useTempFiles` option. By default this module uses `'tmp'` folder\n * in the current working directory.\n * You can use trailing slash, but it is not necessary.\n * @default './tmp'\n */\n tempFileDir?: string | undefined\n /**\n * This defines how long to wait for data before aborting. Set to `0` if you want to turn off timeout checks.\n * @default 60_000\n */\n uploadTimeout?: number | undefined\n /**\n * Applies uri decoding to file names if set `true`.\n * @default false\n */\n uriDecodeFileNames?: boolean | undefined\n /**\n * By default this module uploads files into RAM.\n * Setting this option to `true` turns on using temporary files instead of utilising RAM.\n * This avoids memory overflow issues when uploading large files or in case of uploading\n * lots of files at same time.\n * @default false\n */\n useTempFiles?: boolean | undefined\n} & Partial<BusboyConfig>\n\nexport type ErrorResult = { data?: any; errors: unknown[]; stack?: string }\n\nexport type AfterErrorResult = {\n graphqlResult?: GraphQLFormattedError\n response?: Partial<ErrorResult> & Record<string, unknown>\n status?: number\n} | void\n\nexport type AfterErrorHookArgs = {\n /** The Collection that the hook is operating on. This will be undefined if the hook is executed from a non-collection endpoint or GraphQL. */\n collection?: SanitizedCollectionConfig\n /** \tCustom context passed between hooks */\n context: RequestContext\n /** The error that occurred. */\n error: Error\n /** The GraphQL result object, available if the hook is executed within a GraphQL context. */\n graphqlResult?: GraphQLFormattedError\n /** The Request object containing the currently authenticated user. */\n req: PayloadRequest\n /** The formatted error result object, available if the hook is executed from a REST context. */\n result?: ErrorResult\n}\n\nexport type ImportMapGenerators = Array<\n (props: {\n addToImportMap: AddToImportMap\n baseDir: string\n config: SanitizedConfig\n importMap: InternalImportMap\n imports: Imports\n }) => void\n>\n\nexport type AfterErrorHook = (\n args: AfterErrorHookArgs,\n) => AfterErrorResult | Promise<AfterErrorResult>\n\n/**\n * This is the central configuration\n *\n * @see https://payloadcms.com/docs/configuration/overview\n */\nexport type Config = {\n /** Configure admin dashboard */\n admin?: {\n /** Automatically log in as a user */\n autoLogin?:\n | {\n /**\n * The email address of the user to login as\n */\n email?: string\n /** The password of the user to login as. This is only needed if `prefillOnly` is set to true */\n password?: string\n /**\n * If set to true, the login credentials will be prefilled but the user will still need to click the login button.\n *\n * @default false\n */\n prefillOnly?: boolean\n /** The username of the user to login as */\n username?: string\n }\n | false\n /**\n * Automatically refresh user tokens for users logged into the dashboard\n *\n * @default false\n */\n autoRefresh?: boolean\n /** Set account profile picture. Options: gravatar, default or a custom React component. */\n avatar?:\n | 'default'\n | 'gravatar'\n | {\n Component: PayloadComponent\n }\n\n /**\n * Add extra and/or replace built-in components with custom components\n *\n * @see https://payloadcms.com/docs/admin/custom-components/overview\n */\n components?: {\n /**\n * Add custom components to the top right of the Admin Panel\n */\n actions?: CustomComponent[]\n /**\n * Add custom components after the collection overview\n */\n afterDashboard?: CustomComponent[]\n /**\n * Add custom components after the email/password field\n */\n afterLogin?: CustomComponent[]\n /**\n * Add custom components after the navigation links\n */\n afterNavLinks?: CustomComponent[]\n /**\n * Add custom components before the collection overview\n */\n beforeDashboard?: CustomComponent[]\n /**\n * Add custom components before the email/password field\n */\n beforeLogin?: CustomComponent[]\n /**\n * Add custom components before the navigation links\n */\n beforeNavLinks?: CustomComponent[]\n /** Replace graphical components */\n graphics?: {\n /** Replace the icon in the navigation */\n Icon?: CustomComponent\n /** Replace the logo on the login page */\n Logo?: CustomComponent\n }\n /**\n * Add custom header to top of page globally\n */\n header?: CustomComponent[]\n /** Replace logout related components */\n logout?: {\n /** Replace the logout button */\n Button?: CustomComponent\n }\n /**\n * Replace the navigation with a custom component\n */\n Nav?: CustomComponent\n /**\n * Wrap the admin dashboard in custom context providers\n */\n providers?: PayloadComponent<{ children?: React.ReactNode }, { children?: React.ReactNode }>[]\n /**\n * Replace or modify top-level admin routes, or add new ones:\n * + `Account` - `/admin/account`\n * + `Dashboard` - `/admin`\n * + `:path` - `/admin/:path`\n */\n views?: {\n /** Add custom admin views */\n [key: string]: AdminViewConfig\n /** Replace the account screen */\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n account?: AdminViewConfig\n /** Replace the admin homepage */\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n dashboard?: AdminViewConfig\n }\n }\n /** Extension point to add your custom data. Available in server and client. */\n custom?: Record<string, any>\n /** Global date format that will be used for all dates in the Admin panel. Any valid date-fns format pattern can be used. */\n dateFormat?: string\n /**\n * Each entry in this map generates an entry in the importMap.\n */\n dependencies?: AdminDependencies\n /**\n * @deprecated\n * This option is deprecated and will be removed in v4.\n * To disable the admin panel itself, delete your `/app/(payload)/admin` directory.\n * To disable all REST API and GraphQL endpoints, delete your `/app/(payload)/api` directory.\n * Note: If you've modified the default paths via `admin.routes`, delete those directories instead.\n */\n disable?: boolean\n importMap?: {\n /**\n * Automatically generate component map during development\n * @default true\n */\n autoGenerate?: boolean\n /**\n * The base directory for component paths starting with /.\n * @default process.cwd()\n **/\n baseDir?: string\n /**\n * You can use generators to add custom components to the component import map.\n * This allows you to import custom components in the admin panel.\n */\n generators?: ImportMapGenerators\n /**\n * If Payload cannot find the import map file location automatically,\n * you can manually provide it here.\n */\n importMapFile?: string\n }\n /**\n * Live Preview options.\n *\n * @see https://payloadcms.com/docs/live-preview/overview\n */\n livePreview?: RootLivePreviewConfig\n /** Base meta data to use for the Admin Panel. Included properties are titleSuffix, ogImage, and favicon. */\n meta?: MetaConfig\n routes?: {\n /** The route for the account page.\n *\n * @default '/account'\n */\n account?: `/${string}`\n /** The route for the browse by folder view.\n *\n * @default '/browse-by-folder'\n */\n browseByFolder?: `/${string}`\n /** The route for the create first user page.\n *\n * @default '/create-first-user'\n */\n createFirstUser?: `/${string}`\n /** The route for the forgot password page.\n *\n * @default '/forgot'\n */\n forgot?: `/${string}`\n /** The route the user will be redirected to after being inactive for too long.\n *\n * @default '/logout-inactivity'\n */\n inactivity?: `/${string}`\n /** The route for the login page.\n *\n * @default '/login'\n */\n login?: `/${string}`\n /** The route for the logout page.\n *\n * @default '/logout'\n */\n logout?: `/${string}`\n /** The route for the reset password page.\n *\n * @default '/reset'\n */\n reset?: `/${string}`\n /** The route for the unauthorized page.\n *\n * @default '/unauthorized'\n */\n unauthorized?: `/${string}`\n }\n /**\n * Suppresses React hydration mismatch warnings during the hydration of the root <html> tag.\n * Useful in scenarios where the server-rendered HTML might intentionally differ from the client-rendered DOM.\n * @default false\n */\n suppressHydrationWarning?: boolean\n /**\n * Restrict the Admin Panel theme to use only one of your choice\n *\n * @default 'all' // The theme can be configured by users\n */\n theme?: 'all' | 'dark' | 'light'\n /**\n * Configure timezone related settings for the admin panel.\n */\n timezones?: TimezonesConfig\n /**\n * Configure toast message behavior and appearance in the admin panel.\n * Currently using [Sonner](https://sonner.emilkowal.ski) for toast notifications.\n *\n * @experimental This property is experimental and may change in future releases. Use at your own risk.\n */\n toast?: {\n /**\n * Time in milliseconds until the toast automatically closes.\n * @default 4000\n */\n duration?: number\n /**\n * If `true`, will expand the message stack so that all messages are shown simultaneously without user interaction.\n * Otherwise only the latest notification can be read until the user hovers the stack.\n * @default false\n */\n expand?: boolean\n /**\n * The maximum number of toasts that can be visible on the screen at once.\n * @default 5\n */\n limit?: number\n }\n /** The slug of a Collection that you want to be used to log in to the Admin dashboard. */\n user?: string\n }\n\n /**\n * Configure authentication-related Payload-wide settings.\n */\n auth?: {\n /**\n * Define which JWT identification methods you'd like to support for Payload's local auth strategy, as well as the order that they're retrieved in.\n * Defaults to ['JWT', 'Bearer', 'cookie]\n */\n jwtOrder: ('Bearer' | 'cookie' | 'JWT')[]\n }\n /** Custom Payload bin scripts can be injected via the config. */\n bin?: BinScriptConfig[]\n blocks?: Block[]\n /**\n * Pass additional options to the parser used to process `multipart/form-data` requests.\n * For example, a PATCH request containing HTML form data.\n * For example, you may want to increase the `limits` imposed by the parser.\n * Currently using @link {https://www.npmjs.com/package/busboy|busboy} under the hood.\n *\n * @experimental This property is experimental and may change in future releases. Use at your own risk.\n */\n bodyParser?: Partial<BusboyConfig>\n /**\n * Manage the datamodel of your application\n *\n * @see https://payloadcms.com/docs/configuration/collections#collection-configs\n */\n collections?: CollectionConfig[]\n /**\n * Compatibility flags for prior Payload versions\n */\n compatibility?: {\n /**\n * By default, Payload will remove the `localized: true` property\n * from fields if a parent field is localized. Set this property\n * to `true` only if you have an existing Payload database from pre-3.0\n * that you would like to maintain without migrating. This is only\n * relevant for MongoDB databases.\n *\n * @todo Remove in v4\n */\n allowLocalizedWithinLocalized: true\n }\n /**\n * Prefix a string to all cookies that Payload sets.\n *\n * @default \"payload\"\n */\n cookiePrefix?: string\n /** Either a whitelist array of URLS to allow CORS requests from, or a wildcard string ('*') to accept incoming requests from any domain. */\n cors?: '*' | CORSConfig | string[]\n /** A whitelist array of URLs to allow Payload cookies to be accepted from as a form of CSRF protection. */\n csrf?: string[]\n /** Extension point to add your custom data. Server only. */\n custom?: Record<string, any>\n /** Pass in a database adapter for use on this project. */\n db: DatabaseAdapterResult\n /** Enable to expose more detailed error information. */\n debug?: boolean\n /**\n * If a user does not specify `depth` while requesting a resource, this depth will be used.\n *\n * @see https://payloadcms.com/docs/getting-started/concepts#depth\n *\n * @default 2\n */\n defaultDepth?: number\n /**\n * The maximum allowed depth to be permitted application-wide. This setting helps prevent against malicious queries.\n *\n * @default 40000\n */\n defaultMaxTextLength?: number\n /** Default richtext editor to use for richText fields */\n editor?: RichTextAdapterProvider<any, any, any>\n /**\n * Email Adapter\n *\n * @see https://payloadcms.com/docs/email/overview\n */\n email?: EmailAdapter | Promise<EmailAdapter>\n /** Custom REST endpoints */\n endpoints?: Endpoint[]\n /**\n * Options for folder view within the admin panel\n *\n * @experimental This feature may change in minor versions until it is fully stable\n */\n folders?: false | RootFoldersConfiguration\n /**\n * @see https://payloadcms.com/docs/configuration/globals#global-configs\n */\n globals?: GlobalConfig[]\n /**\n * Manage the GraphQL API\n *\n * You can add your own GraphQL queries and mutations to Payload, making use of all the types that Payload has defined for you.\n *\n * @see https://payloadcms.com/docs/graphql/overview\n */\n graphQL?: {\n disable?: boolean\n /**\n * Disable introspection queries in production.\n *\n * @default true\n */\n disableIntrospectionInProduction?: boolean\n /**\n * Disable the GraphQL Playground in production.\n *\n * @default true\n */\n disablePlaygroundInProduction?: boolean\n maxComplexity?: number\n /**\n * Function that returns an object containing keys to custom GraphQL mutations\n *\n * @see https://payloadcms.com/docs/graphql/extending\n */\n mutations?: GraphQLExtension\n /**\n * Function that returns an object containing keys to custom GraphQL queries\n *\n * @see https://payloadcms.com/docs/graphql/extending\n */\n queries?: GraphQLExtension\n /**\n * Filepath to write the generated schema to\n */\n schemaOutputFile?: string\n /**\n * Function that returns an array of validation rules to apply to the GraphQL schema\n *\n * @see https://payloadcms.com/docs/graphql/overview#custom-validation-rules\n */\n validationRules?: (args: GraphQL.ExecutionArgs) => GraphQL.ValidationRule[]\n }\n /**\n * Tap into Payload-wide hooks.\n *\n * @see https://payloadcms.com/docs/hooks/overview\n */\n hooks?: {\n afterError?: AfterErrorHook[]\n }\n /** i18n config settings */\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n i18n?: I18nOptions<{} | DefaultTranslationsObject> // loosen the type here to allow for custom translations\n /** Automatically index all sortable top-level fields in the database to improve sort performance and add database compatibility for Azure Cosmos and similar. */\n indexSortableFields?: boolean\n /**\n * @experimental There may be frequent breaking changes to this API\n */\n jobs?: JobsConfig\n /**\n * Translate your content to different languages/locales.\n *\n * @default false // disable localization\n */\n localization?: false | LocalizationConfig\n /**\n * Logger options, logger options with a destination stream, or an instantiated logger instance.\n *\n * See Pino Docs for options: https://getpino.io/#/docs/api?id=options\n *\n * ```ts\n * // Logger options only\n * logger: {\n * level: 'info',\n * }\n *\n * // Logger options with destination stream\n * logger: {\n * options: {\n * level: 'info',\n * },\n * destination: process.stdout\n * },\n *\n * // Logger instance\n * logger: pino({ name: 'my-logger' })\n *\n * ```\n */\n logger?: 'sync' | { destination?: DestinationStream; options: pino.LoggerOptions } | PayloadLogger\n\n /**\n * Override the log level of errors for Payload's error handler or disable logging with `false`.\n * Levels can be any of the following: 'trace', 'debug', 'info', 'warn', 'error', 'fatal' or false.\n *\n * Default levels:\n * {\n `* APIError: 'error',\n `* AuthenticationError: 'error',\n `* ErrorDeletingFile: 'error',\n `* FileRetrievalError: 'error',\n `* FileUploadError: 'error',\n `* Forbidden: 'info',\n `* Locked: 'info',\n `* LockedAuth: 'error',\n `* MissingFile: 'info',\n `* NotFound: 'info',\n `* QueryError: 'error',\n `* ValidationError: 'info',\n * }\n */\n loggingLevels?: Partial<Record<ErrorName, false | Level>>\n\n /**\n * The maximum allowed depth to be permitted application-wide. This setting helps prevent against malicious queries.\n *\n * @see https://payloadcms.com/docs/getting-started/concepts#depth\n *\n * @default 10\n */\n maxDepth?: number\n\n /** A function that is called immediately following startup that receives the Payload instance as its only argument. */\n onInit?: (payload: Payload) => Promise<void> | void\n /**\n * An array of Payload plugins.\n *\n * @see https://payloadcms.com/docs/plugins/overview\n */\n plugins?: Plugin[]\n /**\n * Allow you to save and share filters, columns, and sort orders for your collections.\n * @see https://payloadcms.com/docs/query-presets/overview\n */\n queryPresets?: {\n access: {\n create?: Access<QueryPreset>\n delete?: Access<QueryPreset>\n read?: Access<QueryPreset>\n update?: Access<QueryPreset>\n }\n constraints: {\n create?: QueryPresetConstraints\n delete?: QueryPresetConstraints\n read?: QueryPresetConstraints\n update?: QueryPresetConstraints\n }\n filterConstraints?: SelectField['filterOptions']\n labels?: CollectionConfig['labels']\n }\n /**\n * Control the routing structure that Payload binds itself to.\n * @link https://payloadcms.com/docs/admin/overview#root-level-routes\n */\n routes?: {\n /**\n * The route for the admin panel.\n * @example \"/my-admin\" or \"/\"\n * @default \"/admin\"\n * @link https://payloadcms.com/docs/admin/overview#root-level-routes\n */\n admin?: string\n /**\n * The base route for all REST API endpoints.\n * @default \"/api\"\n * @link https://payloadcms.com/docs/admin/overview#root-level-routes\n */\n api?: string\n /**\n * The base route for all GraphQL endpoints.\n * @default \"/graphql\"\n * @link https://payloadcms.com/docs/admin/overview#root-level-routes\n */\n graphQL?: string\n /**\n * The route for the GraphQL Playground.\n * @default \"/graphql-playground\"\n * @link https://payloadcms.com/docs/admin/overview#root-level-routes\n */\n graphQLPlayground?: string\n }\n /** Secure string that Payload will use for any encryption workflows */\n secret: string\n /**\n * Define the absolute URL of your app including the protocol, for example `https://example.org`.\n * No paths allowed, only protocol, domain and (optionally) port.\n *\n * @see https://payloadcms.com/docs/configuration/overview#options\n */\n serverURL?: string\n /**\n * Pass in a local copy of Sharp if you'd like to use it.\n *\n */\n sharp?: SharpDependency\n /** Send anonymous telemetry data about general usage. */\n telemetry?: boolean\n /** Control how typescript interfaces are generated from your collections. */\n typescript?: {\n /**\n * Automatically generate types during development\n * @default true\n */\n autoGenerate?: boolean\n\n /** Disable declare block in generated types file */\n declare?:\n | {\n /**\n * @internal internal use only to allow for multiple declarations within a monorepo and suppress the \"Duplicate identifier GeneratedTypes\" error\n *\n * Adds a @ts-ignore flag above the GeneratedTypes interface declaration\n *\n * @default false\n */\n ignoreTSError?: boolean\n }\n | false\n\n /** Filename to write the generated types to */\n outputFile?: string\n\n /**\n * Allows you to modify the base JSON schema that is generated during generate:types. This JSON schema will be used\n * to generate the TypeScript interfaces.\n */\n schema?: Array<\n (args: {\n collectionIDFieldTypes: {\n [key: string]: 'number' | 'string'\n }\n config: SanitizedConfig\n i18n: I18n\n jsonSchema: JSONSchema4\n }) => JSONSchema4\n >\n }\n /**\n * Customize the handling of incoming file uploads for collections that have uploads enabled.\n */\n upload?: FetchAPIFileUploadOptions\n}\n\n/**\n * @todo remove the `DeepRequired` in v4.\n * We don't actually guarantee that all properties are set when sanitizing configs.\n */\nexport type SanitizedConfig = {\n admin: {\n timezones: SanitizedTimezoneConfig\n } & DeepRequired<Config['admin']>\n blocks?: FlattenedBlock[]\n collections: SanitizedCollectionConfig[]\n /** Default richtext editor to use for richText fields */\n editor?: RichTextAdapter<any, any, any>\n endpoints: Endpoint[]\n globals: SanitizedGlobalConfig[]\n i18n: Required<I18nOptions>\n jobs: SanitizedJobsConfig\n localization: false | SanitizedLocalizationConfig\n paths: {\n config: string\n configDir: string\n rawConfig: string\n }\n upload: {\n /**\n * Deduped list of adapters used in the project\n */\n adapters: string[]\n } & FetchAPIFileUploadOptions\n} & Omit<\n // TODO: DeepRequired breaks certain, advanced TypeScript types / certain type information is lost. We should remove it when possible.\n // E.g. in packages/ui/src/graphics/Account/index.tsx in getComponent, if avatar.Component is casted to what it's supposed to be,\n // the result type is different\n DeepRequired<Config>,\n | 'admin'\n | 'blocks'\n | 'collections'\n | 'editor'\n | 'endpoint'\n | 'globals'\n | 'i18n'\n | 'jobs'\n | 'localization'\n | 'upload'\n>\n\nexport type EditConfig = EditConfigWithoutRoot | EditConfigWithRoot\n\n/**\n * Replace or modify _all_ nested document views and routes, including the document header, controls, and tabs. This cannot be used in conjunction with other nested views.\n * + `root` - `/admin/collections/:collection/:id/**\\/*`\n * @link https://payloadcms.com/docs/custom-components/document-views#document-root\n */\nexport type EditConfigWithRoot = {\n api?: never\n default?: never\n livePreview?: never\n root: DefaultDocumentViewConfig\n version?: never\n versions?: never\n}\n\ntype KnownEditKeys = 'api' | 'default' | 'livePreview' | 'root' | 'version' | 'versions'\n\n/**\n * Replace or modify individual nested routes, or add new ones:\n * + `default` - `/admin/collections/:collection/:id`\n * + `api` - `/admin/collections/:collection/:id/api`\n * + `livePreview` - `/admin/collections/:collection/:id/preview`\n * + `references` - `/admin/collections/:collection/:id/references`\n * + `relationships` - `/admin/collections/:collection/:id/relationships`\n * + `versions` - `/admin/collections/:collection/:id/versions`\n * + `version` - `/admin/collections/:collection/:id/versions/:version`\n * + `customView` - `/admin/collections/:collection/:id/:path`\n *\n * To override the entire Edit View including all nested views, use the `root` key.\n *\n * @link https://payloadcms.com/docs/custom-components/document-views\n */\nexport type EditConfigWithoutRoot = {\n [K in Exclude<string, KnownEditKeys>]: CustomDocumentViewConfig\n} & {\n api?: DefaultDocumentViewConfig\n default?: DefaultDocumentViewConfig\n livePreview?: DefaultDocumentViewConfig\n root?: never\n version?: DefaultDocumentViewConfig\n versions?: DefaultDocumentViewConfig\n}\n\nexport type EntityDescriptionComponent = CustomComponent\n\nexport type EntityDescriptionFunction = ({ t }: { t: TFunction }) => string\n\nexport type EntityDescription = EntityDescriptionFunction | Record<string, string> | string\n\nexport type { EmailAdapter, SendEmailOptions }\n"],"names":["serverProps"],"mappings":"AAwaA,OAAO,MAAMA,cAAqC;IAChD;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"getLocalizedPaths.d.ts","sourceRoot":"","sources":["../../src/database/getLocalizedPaths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAE7D,OAAO,EAIL,KAAK,cAAc,EACpB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAY,KAAK,OAAO,EAAkC,MAAM,aAAa,CAAA;AAEpF,wBAAgB,iBAAiB,CAAC,EAChC,cAAc,EACd,MAAM,EACN,UAAU,EACV,YAAY,EACZ,MAAM,EACN,cAAsB,EACtB,iBAAiB,EACjB,OAAO,GACR,EAAE;IACD,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,OAAO,EAAE,OAAO,CAAA;CACjB,GAAG,WAAW,EAAE,CAsMhB"}
1
+ {"version":3,"file":"getLocalizedPaths.d.ts","sourceRoot":"","sources":["../../src/database/getLocalizedPaths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAE7D,OAAO,EAIL,KAAK,cAAc,EACpB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAY,KAAK,OAAO,EAAkC,MAAM,aAAa,CAAA;AAEpF,wBAAgB,iBAAiB,CAAC,EAChC,cAAc,EACd,MAAM,EACN,UAAU,EACV,YAAY,EACZ,MAAM,EACN,cAAsB,EACtB,iBAAiB,EACjB,OAAO,GACR,EAAE;IACD,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,OAAO,EAAE,OAAO,CAAA;CACjB,GAAG,WAAW,EAAE,CA2MhB"}
@@ -154,6 +154,11 @@ export function getLocalizedPaths({ collectionSlug, fields, globalSlug, incoming
154
154
  case 'richText':
155
155
  {
156
156
  const upcomingSegments = pathSegments.slice(i + 1).join('.');
157
+ pathSegments.forEach((path)=>{
158
+ if (!/^\w+(?:\.\w+)*$/.test(path)) {
159
+ lastIncompletePath.invalid = true;
160
+ }
161
+ });
157
162
  lastIncompletePath.complete = true;
158
163
  lastIncompletePath.path = upcomingSegments ? `${currentPath}.${upcomingSegments}` : currentPath;
159
164
  return paths;