payload 3.80.0-internal-debug.cd99b1f → 3.80.0-internal-debug.7019cc9

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.
@@ -644,7 +644,7 @@ export type Config = {
644
644
  /**
645
645
  * Add extra and/or replace built-in components with custom components
646
646
  *
647
- * @see https://payloadcms.com/docs/admin/custom-components/overview
647
+ * @see https://payloadcms.com/docs/custom-components/overview
648
648
  */
649
649
  components?: {
650
650
  /**
@@ -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, LoggerOptions } 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 ClientField,\n DataFromWidgetSlug,\n DefaultDocumentIDType,\n Field,\n FlattenedBlock,\n JobsConfig,\n KVAdapterResult,\n Payload,\n RequestContext,\n SelectField,\n TypedUser,\n TypedWidget,\n WidgetSlug,\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?: DefaultDocumentIDType\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 */\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\nexport type 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 | 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 = {\n data?: any\n errors: {\n data?: Record<string, unknown>\n field?: string\n message?: string\n name?: string\n }[]\n stack?: string\n}\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\nexport type WidgetWidth = 'full' | 'large' | 'medium' | 'small' | 'x-large' | 'x-small'\n\nexport type Widget = {\n Component: PayloadComponent\n fields?: Field[]\n /**\n * Human-friendly label for the widget.\n * Supports i18n by passing an object with locale keys, or a function with `t` for translations.\n * If not provided, the label will be auto-generated from the slug.\n */\n label?: LabelFunction | StaticLabel\n maxWidth?: WidgetWidth\n minWidth?: WidgetWidth\n slug: string\n // Maybe:\n // ImageURL?: string // similar to Block\n}\n\n/**\n * Client-side widget type with resolved label (no functions).\n */\nexport type ClientWidget = {\n fields?: ClientField[]\n label?: StaticLabel\n maxWidth?: WidgetWidth\n minWidth?: WidgetWidth\n slug: string\n}\n\nexport type WidgetInstance<TSlug extends WidgetSlug = WidgetSlug> = TSlug extends WidgetSlug\n ? {\n data?: DataFromWidgetSlug<TSlug> extends Record<string, unknown>\n ? DataFromWidgetSlug<TSlug>\n : Record<string, unknown>\n widgetSlug: TSlug\n width: [\n Extract<\n TypedWidget[TSlug] extends { width: infer TWidth } ? TWidth : WidgetWidth,\n WidgetWidth\n >,\n ] extends [never]\n ? WidgetWidth\n : Extract<\n TypedWidget[TSlug] extends { width: infer TWidth } ? TWidth : WidgetWidth,\n WidgetWidth\n >\n }\n : never\n\nexport type DashboardConfig = {\n defaultLayout?:\n | ((args: { req: PayloadRequest }) => Array<WidgetInstance> | Promise<Array<WidgetInstance>>)\n | Array<WidgetInstance>\n widgets: Array<Widget>\n}\n\nexport type SanitizedDashboardConfig = {\n widgets: Array<Omit<Widget, 'Component'>>\n}\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 section\n */\n afterNav?: 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 section\n */\n beforeNav?: 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 * Add custom menu items to the navigation menu accessible via the gear icon.\n * These components will be rendered in a popup menu above the logout button.\n */\n settingsMenu?: CustomComponent[]\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 /**\n * Customize the dashboard widgets\n * @experimental This prop is subject to change in future releases.\n */\n dashboard?: DashboardConfig\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 position of the toast on the screen.\n * @default 'bottom-right'\n */\n position?:\n | 'bottom-center'\n | 'bottom-left'\n | 'bottom-right'\n | 'top-center'\n | 'top-left'\n | 'top-right'\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 * Experimental features may be unstable or change in future versions.\n */\n experimental?: {\n /**\n * Enable per-locale status for documents.\n *\n * Requires:\n * - `localization` enabled\n * - `versions.drafts` enabled\n * - `versions.drafts.localizeStatus` set at collection or global level\n *\n * @experimental\n */\n localizeStatus?: boolean\n }\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 * Pass in a KV adapter for use on this project.\n * @default `DatabaseKVAdapter` from:\n * ```ts\n * import { createDatabaseKVAdapter } from 'payload'\n * createDatabaseKVAdapter()\n * ```\n */\n kv?: KVAdapterResult\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: 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 /**\n * Define collection-level access control that applies to all presets globally.\n * This is separate from document-level access (constraints) which users can configure per-preset.\n */\n access: {\n create?: Access<QueryPreset>\n delete?: Access<QueryPreset>\n read?: Access<QueryPreset>\n update?: Access<QueryPreset>\n }\n /**\n * Define custom document-level access control options for presets.\n *\n * Payload provides sensible defaults (Only Me, Everyone, Specific Users), but you can\n * add custom constraints for more complex patterns like RBAC.\n *\n * @example\n * ```ts\n * constraints: {\n * read: [\n * {\n * label: 'Specific Roles',\n * value: 'specificRoles',\n * fields: [\n * {\n * name: 'roles',\n * type: 'select',\n * hasMany: true,\n * options: [\n * { label: 'Admin', value: 'admin' },\n * { label: 'User', value: 'user' },\n * ],\n * },\n * ],\n * access: ({ req: { user } }) => ({\n * 'access.read.roles': { in: [user?.roles] },\n * }),\n * },\n * ],\n * }\n * ```\n *\n * @see https://payloadcms.com/docs/query-presets/overview#custom-access-control\n */\n constraints: {\n create?: QueryPresetConstraints\n delete?: QueryPresetConstraints\n read?: QueryPresetConstraints\n update?: QueryPresetConstraints\n }\n /**\n * Used to dynamically filter which constraints are available based on the current user, document data,\n * or other criteria.\n *\n * Some examples of this might include:\n *\n * - Ensuring that only \"admins\" are allowed to make a preset available to \"everyone\"\n * - Preventing the \"onlyMe\" option from being selected based on a hypothetical \"disablePrivatePresets\" checkbox\n *\n * When a user lacks the permission to set a constraint, the option will either be hidden from them, or disabled if it is already saved to that preset.\n *\n * @see https://payloadcms.com/docs/query-presets/overview#constraint-access-control\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 * Enable strict type safety for draft operations. When enabled, the `draft` parameter is forbidden\n * on collections without drafts, and query results with `draft: true` type required fields as optional.\n * This prevents invalid draft usage at compile time and ensures type correctness across all Local API operations.\n *\n * @default false\n * @todo Remove in v4. Strict draft types will become the default behavior.\n */\n strictDraftTypes?: boolean\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":"AA+aA,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, LoggerOptions } 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 ClientField,\n DataFromWidgetSlug,\n DefaultDocumentIDType,\n Field,\n FlattenedBlock,\n JobsConfig,\n KVAdapterResult,\n Payload,\n RequestContext,\n SelectField,\n TypedUser,\n TypedWidget,\n WidgetSlug,\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?: DefaultDocumentIDType\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 */\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\nexport type 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 | 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 = {\n data?: any\n errors: {\n data?: Record<string, unknown>\n field?: string\n message?: string\n name?: string\n }[]\n stack?: string\n}\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\nexport type WidgetWidth = 'full' | 'large' | 'medium' | 'small' | 'x-large' | 'x-small'\n\nexport type Widget = {\n Component: PayloadComponent\n fields?: Field[]\n /**\n * Human-friendly label for the widget.\n * Supports i18n by passing an object with locale keys, or a function with `t` for translations.\n * If not provided, the label will be auto-generated from the slug.\n */\n label?: LabelFunction | StaticLabel\n maxWidth?: WidgetWidth\n minWidth?: WidgetWidth\n slug: string\n // Maybe:\n // ImageURL?: string // similar to Block\n}\n\n/**\n * Client-side widget type with resolved label (no functions).\n */\nexport type ClientWidget = {\n fields?: ClientField[]\n label?: StaticLabel\n maxWidth?: WidgetWidth\n minWidth?: WidgetWidth\n slug: string\n}\n\nexport type WidgetInstance<TSlug extends WidgetSlug = WidgetSlug> = TSlug extends WidgetSlug\n ? {\n data?: DataFromWidgetSlug<TSlug> extends Record<string, unknown>\n ? DataFromWidgetSlug<TSlug>\n : Record<string, unknown>\n widgetSlug: TSlug\n width: [\n Extract<\n TypedWidget[TSlug] extends { width: infer TWidth } ? TWidth : WidgetWidth,\n WidgetWidth\n >,\n ] extends [never]\n ? WidgetWidth\n : Extract<\n TypedWidget[TSlug] extends { width: infer TWidth } ? TWidth : WidgetWidth,\n WidgetWidth\n >\n }\n : never\n\nexport type DashboardConfig = {\n defaultLayout?:\n | ((args: { req: PayloadRequest }) => Array<WidgetInstance> | Promise<Array<WidgetInstance>>)\n | Array<WidgetInstance>\n widgets: Array<Widget>\n}\n\nexport type SanitizedDashboardConfig = {\n widgets: Array<Omit<Widget, 'Component'>>\n}\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/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 section\n */\n afterNav?: 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 section\n */\n beforeNav?: 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 * Add custom menu items to the navigation menu accessible via the gear icon.\n * These components will be rendered in a popup menu above the logout button.\n */\n settingsMenu?: CustomComponent[]\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 /**\n * Customize the dashboard widgets\n * @experimental This prop is subject to change in future releases.\n */\n dashboard?: DashboardConfig\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 position of the toast on the screen.\n * @default 'bottom-right'\n */\n position?:\n | 'bottom-center'\n | 'bottom-left'\n | 'bottom-right'\n | 'top-center'\n | 'top-left'\n | 'top-right'\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 * Experimental features may be unstable or change in future versions.\n */\n experimental?: {\n /**\n * Enable per-locale status for documents.\n *\n * Requires:\n * - `localization` enabled\n * - `versions.drafts` enabled\n * - `versions.drafts.localizeStatus` set at collection or global level\n *\n * @experimental\n */\n localizeStatus?: boolean\n }\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 * Pass in a KV adapter for use on this project.\n * @default `DatabaseKVAdapter` from:\n * ```ts\n * import { createDatabaseKVAdapter } from 'payload'\n * createDatabaseKVAdapter()\n * ```\n */\n kv?: KVAdapterResult\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: 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 /**\n * Define collection-level access control that applies to all presets globally.\n * This is separate from document-level access (constraints) which users can configure per-preset.\n */\n access: {\n create?: Access<QueryPreset>\n delete?: Access<QueryPreset>\n read?: Access<QueryPreset>\n update?: Access<QueryPreset>\n }\n /**\n * Define custom document-level access control options for presets.\n *\n * Payload provides sensible defaults (Only Me, Everyone, Specific Users), but you can\n * add custom constraints for more complex patterns like RBAC.\n *\n * @example\n * ```ts\n * constraints: {\n * read: [\n * {\n * label: 'Specific Roles',\n * value: 'specificRoles',\n * fields: [\n * {\n * name: 'roles',\n * type: 'select',\n * hasMany: true,\n * options: [\n * { label: 'Admin', value: 'admin' },\n * { label: 'User', value: 'user' },\n * ],\n * },\n * ],\n * access: ({ req: { user } }) => ({\n * 'access.read.roles': { in: [user?.roles] },\n * }),\n * },\n * ],\n * }\n * ```\n *\n * @see https://payloadcms.com/docs/query-presets/overview#custom-access-control\n */\n constraints: {\n create?: QueryPresetConstraints\n delete?: QueryPresetConstraints\n read?: QueryPresetConstraints\n update?: QueryPresetConstraints\n }\n /**\n * Used to dynamically filter which constraints are available based on the current user, document data,\n * or other criteria.\n *\n * Some examples of this might include:\n *\n * - Ensuring that only \"admins\" are allowed to make a preset available to \"everyone\"\n * - Preventing the \"onlyMe\" option from being selected based on a hypothetical \"disablePrivatePresets\" checkbox\n *\n * When a user lacks the permission to set a constraint, the option will either be hidden from them, or disabled if it is already saved to that preset.\n *\n * @see https://payloadcms.com/docs/query-presets/overview#constraint-access-control\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 * Enable strict type safety for draft operations. When enabled, the `draft` parameter is forbidden\n * on collections without drafts, and query results with `draft: true` type required fields as optional.\n * This prevents invalid draft usage at compile time and ensures type correctness across all Local API operations.\n *\n * @default false\n * @todo Remove in v4. Strict draft types will become the default behavior.\n */\n strictDraftTypes?: boolean\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":"AA+aA,OAAO,MAAMA,cAAqC;IAChD;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"sanitizeJoinQuery.d.ts","sourceRoot":"","sources":["../../src/database/sanitizeJoinQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAiB,MAAM,gCAAgC,CAAA;AAC9F,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAOlE,KAAK,IAAI,GAAG;IACV,gBAAgB,EAAE,yBAAyB,CAAA;IAC3C,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,cAAc,EAAE,OAAO,CAAA;IACvB,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAqED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,kEAK3B,IAAI;;;;;;;;GA+CN,CAAA"}
1
+ {"version":3,"file":"sanitizeJoinQuery.d.ts","sourceRoot":"","sources":["../../src/database/sanitizeJoinQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAiB,MAAM,gCAAgC,CAAA;AAC9F,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAQlE,KAAK,IAAI,GAAG;IACV,gBAAgB,EAAE,yBAAyB,CAAA;IAC3C,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,cAAc,EAAE,OAAO,CAAA;IACvB,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AA0ED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,kEAK3B,IAAI;;;;;;;;GA+CN,CAAA"}
@@ -2,6 +2,7 @@ import { executeAccess } from '../auth/executeAccess.js';
2
2
  import { QueryError } from '../errors/QueryError.js';
3
3
  import { combineQueries } from './combineQueries.js';
4
4
  import { validateQueryPaths } from './queryValidation/validateQueryPaths.js';
5
+ import { sanitizeWhereQuery } from './sanitizeWhereQuery.js';
5
6
  const sanitizeJoinFieldQuery = async ({ collectionSlug, errors, join, joinsQuery, overrideAccess, promises, req })=>{
6
7
  const { joinPath } = join;
7
8
  // TODO: fix any's in joinsQuery[joinPath]
@@ -39,6 +40,11 @@ const sanitizeJoinFieldQuery = async ({ collectionSlug, errors, join, joinsQuery
39
40
  where: joinQuery.where
40
41
  }));
41
42
  if (typeof accessResult === 'object') {
43
+ sanitizeWhereQuery({
44
+ fields: joinCollectionConfig.flattenedFields,
45
+ payload: req.payload,
46
+ where: accessResult
47
+ });
42
48
  joinQuery.where = combineQueries(joinQuery.where, accessResult);
43
49
  }
44
50
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/database/sanitizeJoinQuery.ts"],"sourcesContent":["import type { SanitizedCollectionConfig, SanitizedJoin } from '../collections/config/types.js'\nimport type { JoinQuery, PayloadRequest } from '../types/index.js'\n\nimport { executeAccess } from '../auth/executeAccess.js'\nimport { QueryError } from '../errors/QueryError.js'\nimport { combineQueries } from './combineQueries.js'\nimport { validateQueryPaths } from './queryValidation/validateQueryPaths.js'\n\ntype Args = {\n collectionConfig: SanitizedCollectionConfig\n joins?: JoinQuery\n overrideAccess: boolean\n req: PayloadRequest\n}\n\nconst sanitizeJoinFieldQuery = async ({\n collectionSlug,\n errors,\n join,\n joinsQuery,\n overrideAccess,\n promises,\n req,\n}: {\n collectionSlug: string\n errors: { path: string }[]\n join: SanitizedJoin\n joinsQuery: JoinQuery\n overrideAccess: boolean\n promises: Promise<void>[]\n req: PayloadRequest\n}) => {\n const { joinPath } = join\n\n // TODO: fix any's in joinsQuery[joinPath]\n\n if ((joinsQuery as any)[joinPath] === false) {\n return\n }\n\n const joinCollectionConfig = req.payload.collections[collectionSlug]!.config\n\n const accessResult = !overrideAccess\n ? await executeAccess({ disableErrors: true, req }, joinCollectionConfig.access.read)\n : true\n\n if (accessResult === false) {\n ;(joinsQuery as any)[joinPath] = false\n return\n }\n\n if (!(joinsQuery as any)[joinPath]) {\n ;(joinsQuery as any)[joinPath] = {}\n }\n\n const joinQuery = (joinsQuery as any)[joinPath]\n\n if (!joinQuery.where) {\n joinQuery.where = {}\n }\n\n if (join.field.where) {\n joinQuery.where = combineQueries(joinQuery.where, join.field.where)\n }\n\n promises.push(\n validateQueryPaths({\n collectionConfig: joinCollectionConfig,\n errors,\n overrideAccess,\n polymorphicJoin: Array.isArray(join.field.collection),\n req,\n // incoming where input, but we shouldn't validate generated from the access control.\n where: joinQuery.where,\n }),\n )\n\n if (typeof accessResult === 'object') {\n joinQuery.where = combineQueries(joinQuery.where, accessResult)\n }\n}\n\n/**\n * * Validates `where` for each join\n * * Combines the access result for joined collection\n * * Combines the default join's `where`\n */\nexport const sanitizeJoinQuery = async ({\n collectionConfig,\n joins: joinsQuery,\n overrideAccess,\n req,\n}: Args) => {\n if (joinsQuery === false) {\n return false\n }\n\n if (!joinsQuery) {\n joinsQuery = {}\n }\n\n const errors: { path: string }[] = []\n const promises: Promise<void>[] = []\n\n for (const collectionSlug in collectionConfig.joins) {\n for (const join of collectionConfig.joins[collectionSlug]!) {\n await sanitizeJoinFieldQuery({\n collectionSlug,\n errors,\n join,\n joinsQuery,\n overrideAccess,\n promises,\n req,\n })\n }\n }\n\n for (const join of collectionConfig.polymorphicJoins) {\n for (const collectionSlug of join.field.collection) {\n await sanitizeJoinFieldQuery({\n collectionSlug,\n errors,\n join,\n joinsQuery,\n overrideAccess,\n promises,\n req,\n })\n }\n }\n\n await Promise.all(promises)\n\n if (errors.length > 0) {\n throw new QueryError(errors)\n }\n\n return joinsQuery\n}\n"],"names":["executeAccess","QueryError","combineQueries","validateQueryPaths","sanitizeJoinFieldQuery","collectionSlug","errors","join","joinsQuery","overrideAccess","promises","req","joinPath","joinCollectionConfig","payload","collections","config","accessResult","disableErrors","access","read","joinQuery","where","field","push","collectionConfig","polymorphicJoin","Array","isArray","collection","sanitizeJoinQuery","joins","polymorphicJoins","Promise","all","length"],"mappings":"AAGA,SAASA,aAAa,QAAQ,2BAA0B;AACxD,SAASC,UAAU,QAAQ,0BAAyB;AACpD,SAASC,cAAc,QAAQ,sBAAqB;AACp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AAgB,EAChBM,OAAOvB,UAAU,EACjBC,cAAc,EACdE,GAAG,EACE;IACL,IAAIH,eAAe,OAAO;QACxB,OAAO;IACT;IAEA,IAAI,CAACA,YAAY;QACfA,aAAa,CAAC;IAChB;IAEA,MAAMF,SAA6B,EAAE;IACrC,MAAMI,WAA4B,EAAE;IAEpC,IAAK,MAAML,kBAAkBoB,iBAAiBM,KAAK,CAAE;QACnD,KAAK,MAAMxB,QAAQkB,iBAAiBM,KAAK,CAAC1B,eAAe,CAAG;YAC1D,MAAMD,uBAAuB;gBAC3BC;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC;YACF;QACF;IACF;IAEA,KAAK,MAAMJ,QAAQkB,iBAAiBO,gBAAgB,CAAE;QACpD,KAAK,MAAM3B,kBAAkBE,KAAKgB,KAAK,CAACM,UAAU,CAAE;YAClD,MAAMzB,uBAAuB;gBAC3BC;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC;YACF;QACF;IACF;IAEA,MAAMsB,QAAQC,GAAG,CAACxB;IAElB,IAAIJ,OAAO6B,MAAM,GAAG,GAAG;QACrB,MAAM,IAAIlC,WAAWK;IACvB;IAEA,OAAOE;AACT,EAAC"}
1
+ {"version":3,"sources":["../../src/database/sanitizeJoinQuery.ts"],"sourcesContent":["import type { SanitizedCollectionConfig, SanitizedJoin } from '../collections/config/types.js'\nimport type { JoinQuery, PayloadRequest } from '../types/index.js'\n\nimport { executeAccess } from '../auth/executeAccess.js'\nimport { QueryError } from '../errors/QueryError.js'\nimport { combineQueries } from './combineQueries.js'\nimport { validateQueryPaths } from './queryValidation/validateQueryPaths.js'\nimport { sanitizeWhereQuery } from './sanitizeWhereQuery.js'\n\ntype Args = {\n collectionConfig: SanitizedCollectionConfig\n joins?: JoinQuery\n overrideAccess: boolean\n req: PayloadRequest\n}\n\nconst sanitizeJoinFieldQuery = async ({\n collectionSlug,\n errors,\n join,\n joinsQuery,\n overrideAccess,\n promises,\n req,\n}: {\n collectionSlug: string\n errors: { path: string }[]\n join: SanitizedJoin\n joinsQuery: JoinQuery\n overrideAccess: boolean\n promises: Promise<void>[]\n req: PayloadRequest\n}) => {\n const { joinPath } = join\n\n // TODO: fix any's in joinsQuery[joinPath]\n\n if ((joinsQuery as any)[joinPath] === false) {\n return\n }\n\n const joinCollectionConfig = req.payload.collections[collectionSlug]!.config\n\n const accessResult = !overrideAccess\n ? await executeAccess({ disableErrors: true, req }, joinCollectionConfig.access.read)\n : true\n\n if (accessResult === false) {\n ;(joinsQuery as any)[joinPath] = false\n return\n }\n\n if (!(joinsQuery as any)[joinPath]) {\n ;(joinsQuery as any)[joinPath] = {}\n }\n\n const joinQuery = (joinsQuery as any)[joinPath]\n\n if (!joinQuery.where) {\n joinQuery.where = {}\n }\n\n if (join.field.where) {\n joinQuery.where = combineQueries(joinQuery.where, join.field.where)\n }\n\n promises.push(\n validateQueryPaths({\n collectionConfig: joinCollectionConfig,\n errors,\n overrideAccess,\n polymorphicJoin: Array.isArray(join.field.collection),\n req,\n // incoming where input, but we shouldn't validate generated from the access control.\n where: joinQuery.where,\n }),\n )\n\n if (typeof accessResult === 'object') {\n sanitizeWhereQuery({\n fields: joinCollectionConfig.flattenedFields,\n payload: req.payload,\n where: accessResult,\n })\n joinQuery.where = combineQueries(joinQuery.where, accessResult)\n }\n}\n\n/**\n * * Validates `where` for each join\n * * Combines the access result for joined collection\n * * Combines the default join's `where`\n */\nexport const sanitizeJoinQuery = async ({\n collectionConfig,\n joins: joinsQuery,\n overrideAccess,\n req,\n}: Args) => {\n if (joinsQuery === false) {\n return false\n }\n\n if (!joinsQuery) {\n joinsQuery = {}\n }\n\n const errors: { path: string }[] = []\n const promises: Promise<void>[] = []\n\n for (const collectionSlug in collectionConfig.joins) {\n for (const join of collectionConfig.joins[collectionSlug]!) {\n await sanitizeJoinFieldQuery({\n collectionSlug,\n errors,\n join,\n joinsQuery,\n overrideAccess,\n promises,\n req,\n })\n }\n }\n\n for (const join of collectionConfig.polymorphicJoins) {\n for (const collectionSlug of join.field.collection) {\n await sanitizeJoinFieldQuery({\n collectionSlug,\n errors,\n join,\n joinsQuery,\n overrideAccess,\n promises,\n req,\n })\n }\n }\n\n await Promise.all(promises)\n\n if (errors.length > 0) {\n throw new QueryError(errors)\n }\n\n return joinsQuery\n}\n"],"names":["executeAccess","QueryError","combineQueries","validateQueryPaths","sanitizeWhereQuery","sanitizeJoinFieldQuery","collectionSlug","errors","join","joinsQuery","overrideAccess","promises","req","joinPath","joinCollectionConfig","payload","collections","config","accessResult","disableErrors","access","read","joinQuery","where","field","push","collectionConfig","polymorphicJoin","Array","isArray","collection","fields","flattenedFields","sanitizeJoinQuery","joins","polymorphicJoins","Promise","all","length"],"mappings":"AAGA,SAASA,aAAa,QAAQ,2BAA0B;AACxD,SAASC,UAAU,QAAQ,0BAAyB;AACpD,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,kBAAkB,QAAQ,0CAAyC;AAC5E,SAASC,kBAAkB,QAAQ,0BAAyB;AAS5D,MAAMC,yBAAyB,OAAO,EACpCC,cAAc,EACdC,MAAM,EACNC,IAAI,EACJC,UAAU,EACVC,cAAc,EACdC,QAAQ,EACRC,GAAG,EASJ;IACC,MAAM,EAAEC,QAAQ,EAAE,GAAGL;IAErB,0CAA0C;IAE1C,IAAI,AAACC,UAAkB,CAACI,SAAS,KAAK,OAAO;QAC3C;IACF;IAEA,MAAMC,uBAAuBF,IAAIG,OAAO,CAACC,WAAW,CAACV,eAAe,CAAEW,MAAM;IAE5E,MAAMC,eAAe,CAACR,iBAClB,MAAMV,cAAc;QAAEmB,eAAe;QAAMP;IAAI,GAAGE,qBAAqBM,MAAM,CAACC,IAAI,IAClF;IAEJ,IAAIH,iBAAiB,OAAO;;QACxBT,UAAkB,CAACI,SAAS,GAAG;QACjC;IACF;IAEA,IAAI,CAAC,AAACJ,UAAkB,CAACI,SAAS,EAAE;;QAChCJ,UAAkB,CAACI,SAAS,GAAG,CAAC;IACpC;IAEA,MAAMS,YAAY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;gBAC3BC;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC;YACF;QACF;IACF;IAEA,MAAMwB,QAAQC,GAAG,CAAC1B;IAElB,IAAIJ,OAAO+B,MAAM,GAAG,GAAG;QACrB,MAAM,IAAIrC,WAAWM;IACvB;IAEA,OAAOE;AACT,EAAC"}
@@ -5936,7 +5936,7 @@ type Config = {
5936
5936
  /**
5937
5937
  * Add extra and/or replace built-in components with custom components
5938
5938
  *
5939
- * @see https://payloadcms.com/docs/admin/custom-components/overview
5939
+ * @see https://payloadcms.com/docs/custom-components/overview
5940
5940
  */
5941
5941
  components?: {
5942
5942
  /**
@@ -12648,6 +12648,9 @@ declare function commitTransaction(req: MarkRequired<Partial<PayloadRequest>, 'p
12648
12648
  * Returns a JSON Schema Type with 'null' added if the field is not required.
12649
12649
  */
12650
12650
  declare function withNullableJSONSchemaType(fieldType: JSONSchema4TypeName, isRequired: boolean): JSONSchema4TypeName | JSONSchema4TypeName[];
12651
+ type ConfigToJSONSchemaOptions = {
12652
+ forceInlineBlocks?: boolean;
12653
+ };
12651
12654
  declare function fieldsToJSONSchema(
12652
12655
  /**
12653
12656
  * Used for relationship fields, to determine whether to use a string or number type for the ID.
@@ -12660,7 +12663,7 @@ collectionIDFieldTypes: {
12660
12663
  /**
12661
12664
  * Allows you to define new top-level interfaces that can be re-used in the output schema.
12662
12665
  */
12663
- interfaceNameDefinitions: Map<string, JSONSchema4>, config?: SanitizedConfig, i18n?: I18n): {
12666
+ interfaceNameDefinitions: Map<string, JSONSchema4>, config?: SanitizedConfig, i18n?: I18n, opts?: ConfigToJSONSchemaOptions): {
12664
12667
  properties: {
12665
12668
  [k: string]: JSONSchema4;
12666
12669
  };
@@ -12668,11 +12671,11 @@ interfaceNameDefinitions: Map<string, JSONSchema4>, config?: SanitizedConfig, i1
12668
12671
  };
12669
12672
  declare function entityToJSONSchema(config: SanitizedConfig, entity: SanitizedCollectionConfig | SanitizedGlobalConfig, interfaceNameDefinitions: Map<string, JSONSchema4>, defaultIDType: 'number' | 'text', collectionIDFieldTypes?: {
12670
12673
  [key: string]: 'number' | 'string';
12671
- }, i18n?: I18n): JSONSchema4;
12674
+ }, i18n?: I18n, opts?: ConfigToJSONSchemaOptions): JSONSchema4;
12672
12675
  /**
12673
12676
  * This is used for generating the TypeScript types (payload-types.ts) with the payload generate:types command.
12674
12677
  */
12675
- declare function configToJSONSchema(config: SanitizedConfig, defaultIDType?: 'number' | 'text', i18n?: I18n): JSONSchema4;
12678
+ declare function configToJSONSchema(config: SanitizedConfig, defaultIDType?: 'number' | 'text', i18n?: I18n, opts?: ConfigToJSONSchemaOptions): JSONSchema4;
12676
12679
 
12677
12680
  declare function createArrayFromCommaDelineated(input: string): string[];
12678
12681
 
@@ -8,6 +8,9 @@ import type { SanitizedGlobalConfig } from '../globals/config/types.js';
8
8
  * Returns a JSON Schema Type with 'null' added if the field is not required.
9
9
  */
10
10
  export declare function withNullableJSONSchemaType(fieldType: JSONSchema4TypeName, isRequired: boolean): JSONSchema4TypeName | JSONSchema4TypeName[];
11
+ type ConfigToJSONSchemaOptions = {
12
+ forceInlineBlocks?: boolean;
13
+ };
11
14
  export declare function fieldsToJSONSchema(
12
15
  /**
13
16
  * Used for relationship fields, to determine whether to use a string or number type for the ID.
@@ -20,7 +23,7 @@ collectionIDFieldTypes: {
20
23
  /**
21
24
  * Allows you to define new top-level interfaces that can be re-used in the output schema.
22
25
  */
23
- interfaceNameDefinitions: Map<string, JSONSchema4>, config?: SanitizedConfig, i18n?: I18n): {
26
+ interfaceNameDefinitions: Map<string, JSONSchema4>, config?: SanitizedConfig, i18n?: I18n, opts?: ConfigToJSONSchemaOptions): {
24
27
  properties: {
25
28
  [k: string]: JSONSchema4;
26
29
  };
@@ -28,7 +31,7 @@ interfaceNameDefinitions: Map<string, JSONSchema4>, config?: SanitizedConfig, i1
28
31
  };
29
32
  export declare function entityToJSONSchema(config: SanitizedConfig, entity: SanitizedCollectionConfig | SanitizedGlobalConfig, interfaceNameDefinitions: Map<string, JSONSchema4>, defaultIDType: 'number' | 'text', collectionIDFieldTypes?: {
30
33
  [key: string]: 'number' | 'string';
31
- }, i18n?: I18n): JSONSchema4;
34
+ }, i18n?: I18n, opts?: ConfigToJSONSchemaOptions): JSONSchema4;
32
35
  export declare function fieldsToSelectJSONSchema({ config, fields, interfaceNameDefinitions, }: {
33
36
  config: SanitizedConfig;
34
37
  fields: FlattenedField[];
@@ -39,5 +42,6 @@ export declare function timezonesToJSONSchema(supportedTimezones: SanitizedConfi
39
42
  /**
40
43
  * This is used for generating the TypeScript types (payload-types.ts) with the payload generate:types command.
41
44
  */
42
- export declare function configToJSONSchema(config: SanitizedConfig, defaultIDType?: 'number' | 'text', i18n?: I18n): JSONSchema4;
45
+ export declare function configToJSONSchema(config: SanitizedConfig, defaultIDType?: 'number' | 'text', i18n?: I18n, opts?: ConfigToJSONSchemaOptions): JSONSchema4;
46
+ export {};
43
47
  //# sourceMappingURL=configToJSONSchema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"configToJSONSchema.d.ts","sourceRoot":"","sources":["../../src/utilities/configToJSONSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAGnE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAC/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,KAAK,EAAsB,cAAc,EAAU,MAAM,2BAA2B,CAAA;AAC3F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAySvE;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,mBAAmB,EAC9B,UAAU,EAAE,OAAO,GAClB,mBAAmB,GAAG,mBAAmB,EAAE,CAO7C;AA2BD,wBAAgB,kBAAkB;AAChC;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AyB,GAAG,qBAAqB,EACzD,wBAAwB,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,EAClD,aAAa,EAAE,QAAQ,GAAG,MAAM,EAChC,sBAAsB,CAAC,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAA;CAAE,EAC/D,IAAI,CAAC,EAAE,IAAI,EACX,IAAI,GAAE,yBAA8B,GACnC,WAAW,CAsFb;AAED,wBAAgB,wBAAwB,CAAC,EACvC,MAAM,EACN,MAAM,EACN,wBAAwB,GACzB,EAAE;IACD,MAAM,EAAE,eAAe,CAAA;IACvB,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,wBAAwB,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;CACnD,GAAG,WAAW,CAgGd;AAgHD,wBAAgB,oCAAoC,CAClD,MAAM,EAAE,yBAAyB,GAChC,WAAW,CA0Bb;AAGD,wBAAgB,qBAAqB,CACnC,kBAAkB,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,CAAC,oBAAoB,CAAC,GAC9E,WAAW,CAOb;AAuBD;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,eAAe,EACvB,aAAa,CAAC,EAAE,QAAQ,GAAG,MAAM,EACjC,IAAI,CAAC,EAAE,IAAI,EACX,IAAI,GAAE,yBAA8B,GACnC,WAAW,CAuMb"}
@@ -120,7 +120,7 @@ function getAllowedWidgetWidths({ maxWidth, minWidth }) {
120
120
  }
121
121
  return widgetWidths.slice(minIndex, maxIndex + 1);
122
122
  }
123
- function generateWidgetSchemas({ collectionIDFieldTypes, config, i18n, interfaceNameDefinitions }) {
123
+ function generateWidgetSchemas({ collectionIDFieldTypes, config, i18n, interfaceNameDefinitions, opts = {} }) {
124
124
  const widgets = config.admin?.dashboard?.widgets ?? [];
125
125
  const definitions = {};
126
126
  const properties = {};
@@ -134,7 +134,7 @@ function generateWidgetSchemas({ collectionIDFieldTypes, config, i18n, interface
134
134
  if (widget.fields?.length) {
135
135
  const widgetFieldSchemas = fieldsToJSONSchema(collectionIDFieldTypes, flattenAllFields({
136
136
  fields: widget.fields
137
- }), interfaceNameDefinitions, config, i18n);
137
+ }), interfaceNameDefinitions, config, i18n, opts);
138
138
  dataSchema = {
139
139
  type: 'object',
140
140
  additionalProperties: false,
@@ -305,7 +305,7 @@ export function fieldsToJSONSchema(/**
305
305
  * if they have custom ID fields.
306
306
  */ collectionIDFieldTypes, fields, /**
307
307
  * Allows you to define new top-level interfaces that can be re-used in the output schema.
308
- */ interfaceNameDefinitions, config, i18n) {
308
+ */ interfaceNameDefinitions, config, i18n, opts = {}) {
309
309
  const requiredFieldNames = new Set();
310
310
  return {
311
311
  properties: Object.fromEntries(fields.reduce((fieldSchemas, field, index)=>{
@@ -328,7 +328,7 @@ export function fieldsToJSONSchema(/**
328
328
  items: {
329
329
  type: 'object',
330
330
  additionalProperties: false,
331
- ...fieldsToJSONSchema(collectionIDFieldTypes, field.flattenedFields, interfaceNameDefinitions, config, i18n)
331
+ ...fieldsToJSONSchema(collectionIDFieldTypes, field.flattenedFields, interfaceNameDefinitions, config, i18n, opts)
332
332
  }
333
333
  };
334
334
  if (field.interfaceName) {
@@ -355,27 +355,14 @@ export function fieldsToJSONSchema(/**
355
355
  if (!resolvedBlock) {
356
356
  return {};
357
357
  }
358
- const resolvedBlockFieldSchemas = fieldsToJSONSchema(collectionIDFieldTypes, resolvedBlock.flattenedFields, interfaceNameDefinitions, config, i18n);
359
- const resolvedBlockSchema = {
360
- type: 'object',
361
- additionalProperties: false,
362
- properties: {
363
- ...resolvedBlockFieldSchemas.properties,
364
- blockType: {
365
- const: resolvedBlock.slug
366
- }
367
- },
368
- required: [
369
- 'blockType',
370
- ...resolvedBlockFieldSchemas.required
371
- ]
372
- };
373
- if (resolvedBlock.interfaceName) {
374
- interfaceNameDefinitions.set(resolvedBlock.interfaceName, resolvedBlockSchema);
358
+ if (!opts.forceInlineBlocks) {
359
+ return {
360
+ $ref: `#/definitions/${resolvedBlock.interfaceName ?? resolvedBlock.slug}`
361
+ };
375
362
  }
376
- return resolvedBlockSchema;
363
+ block = resolvedBlock;
377
364
  }
378
- const blockFieldSchemas = fieldsToJSONSchema(collectionIDFieldTypes, block.flattenedFields, interfaceNameDefinitions, config, i18n);
365
+ const blockFieldSchemas = fieldsToJSONSchema(collectionIDFieldTypes, block.flattenedFields, interfaceNameDefinitions, config, i18n, opts);
379
366
  const blockSchema = {
380
367
  type: 'object',
381
368
  additionalProperties: false,
@@ -390,9 +377,11 @@ export function fieldsToJSONSchema(/**
390
377
  ...blockFieldSchemas.required
391
378
  ]
392
379
  };
393
- if (block.interfaceName) {
380
+ if (!opts.forceInlineBlocks && block.interfaceName) {
394
381
  interfaceNameDefinitions.set(block.interfaceName, blockSchema);
395
- return blockSchema;
382
+ return {
383
+ $ref: `#/definitions/${block.interfaceName}`
384
+ };
396
385
  }
397
386
  return blockSchema;
398
387
  })
@@ -426,7 +415,7 @@ export function fieldsToJSONSchema(/**
426
415
  ...baseFieldSchema,
427
416
  type: 'object',
428
417
  additionalProperties: false,
429
- ...fieldsToJSONSchema(collectionIDFieldTypes, field.flattenedFields, interfaceNameDefinitions, config, i18n)
418
+ ...fieldsToJSONSchema(collectionIDFieldTypes, field.flattenedFields, interfaceNameDefinitions, config, i18n, opts)
430
419
  };
431
420
  if (field.interfaceName) {
432
421
  interfaceNameDefinitions.set(field.interfaceName, fieldSchema);
@@ -745,7 +734,7 @@ export function fieldsToJSONSchema(/**
745
734
  ...baseFieldSchema,
746
735
  type: 'object',
747
736
  additionalProperties: false,
748
- ...fieldsToJSONSchema(collectionIDFieldTypes, field.flattenedFields, interfaceNameDefinitions, config, i18n)
737
+ ...fieldsToJSONSchema(collectionIDFieldTypes, field.flattenedFields, interfaceNameDefinitions, config, i18n, opts)
749
738
  };
750
739
  if (field.interfaceName) {
751
740
  interfaceNameDefinitions.set(field.interfaceName, fieldSchema);
@@ -795,7 +784,7 @@ export function fieldsToJSONSchema(/**
795
784
  };
796
785
  }
797
786
  // This function is part of the public API and is exported through payload/utilities
798
- export function entityToJSONSchema(config, entity, interfaceNameDefinitions, defaultIDType, collectionIDFieldTypes, i18n) {
787
+ export function entityToJSONSchema(config, entity, interfaceNameDefinitions, defaultIDType, collectionIDFieldTypes, i18n, opts = {}) {
799
788
  if (!collectionIDFieldTypes) {
800
789
  collectionIDFieldTypes = getCollectionIDFieldTypes({
801
790
  config,
@@ -844,7 +833,7 @@ export function entityToJSONSchema(config, entity, interfaceNameDefinitions, def
844
833
  });
845
834
  }
846
835
  const isAuthCollection = 'auth' in entity && entity.auth;
847
- const fieldsSchema = fieldsToJSONSchema(collectionIDFieldTypes, mutableFields, interfaceNameDefinitions, config, i18n);
836
+ const fieldsSchema = fieldsToJSONSchema(collectionIDFieldTypes, mutableFields, interfaceNameDefinitions, config, i18n, opts);
848
837
  // Add collection property to auth collections
849
838
  if (isAuthCollection) {
850
839
  fieldsSchema.properties = {
@@ -1146,7 +1135,7 @@ function generateAuthOperationSchemas(collections) {
1146
1135
  }
1147
1136
  /**
1148
1137
  * This is used for generating the TypeScript types (payload-types.ts) with the payload generate:types command.
1149
- */ export function configToJSONSchema(config, defaultIDType, i18n) {
1138
+ */ export function configToJSONSchema(config, defaultIDType, i18n, opts = {}) {
1150
1139
  // a mutable Map to store custom top-level `interfaceName` types. Fields with an `interfaceName` property will be moved to the top-level definitions here
1151
1140
  const interfaceNameDefinitions = new Map();
1152
1141
  // Used for relationship fields, to determine whether to use a string or number type for the ID.
@@ -1167,7 +1156,7 @@ function generateAuthOperationSchemas(collections) {
1167
1156
  }))
1168
1157
  ];
1169
1158
  const entityDefinitions = entities.reduce((acc, { type, entity })=>{
1170
- acc[entity.slug] = entityToJSONSchema(config, entity, interfaceNameDefinitions, defaultIDType, collectionIDFieldTypes, i18n);
1159
+ acc[entity.slug] = entityToJSONSchema(config, entity, interfaceNameDefinitions, defaultIDType, collectionIDFieldTypes, i18n, opts);
1171
1160
  const select = fieldsToSelectJSONSchema({
1172
1161
  config,
1173
1162
  fields: entity.flattenedFields,
@@ -1190,7 +1179,8 @@ function generateAuthOperationSchemas(collections) {
1190
1179
  collectionIDFieldTypes,
1191
1180
  config,
1192
1181
  i18n,
1193
- interfaceNameDefinitions
1182
+ interfaceNameDefinitions,
1183
+ opts
1194
1184
  });
1195
1185
  const authOperationDefinitions = [
1196
1186
  ...config.collections
@@ -1209,7 +1199,7 @@ function generateAuthOperationSchemas(collections) {
1209
1199
  };
1210
1200
  if (config?.blocks?.length) {
1211
1201
  for (const block of config.blocks){
1212
- const blockFieldSchemas = fieldsToJSONSchema(collectionIDFieldTypes, block.flattenedFields, interfaceNameDefinitions, config, i18n);
1202
+ const blockFieldSchemas = fieldsToJSONSchema(collectionIDFieldTypes, block.flattenedFields, interfaceNameDefinitions, config, i18n, opts);
1213
1203
  const blockSchema = {
1214
1204
  type: 'object',
1215
1205
  additionalProperties: false,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/configToJSONSchema.ts"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { JSONSchema4, JSONSchema4TypeName } from 'json-schema'\n\nimport type { Auth } from '../auth/types.js'\nimport type { SanitizedCollectionConfig } from '../collections/config/types.js'\nimport type { SanitizedConfig } from '../config/types.js'\nimport type { FieldAffectingData, FlattenedField, Option } from '../fields/config/types.js'\nimport type { SanitizedGlobalConfig } from '../globals/config/types.js'\n\nimport { MissingEditorProp } from '../errors/MissingEditorProp.js'\nimport { fieldAffectsData } from '../fields/config/types.js'\nimport { generateJobsJSONSchemas } from '../queues/config/generateJobsJSONSchemas.js'\nimport { flattenAllFields } from './flattenAllFields.js'\nimport { formatNames } from './formatLabels.js'\nimport { getCollectionIDFieldTypes } from './getCollectionIDFieldTypes.js'\nimport { optionsAreEqual } from './optionsAreEqual.js'\n\nconst fieldIsRequired = (field: FlattenedField): boolean => {\n const isConditional = Boolean(field?.admin && field?.admin?.condition)\n if (isConditional) {\n return false\n }\n\n const isMarkedRequired = 'required' in field && field.required === true\n if (fieldAffectsData(field) && isMarkedRequired) {\n return true\n }\n\n // if any subfields are required, this field is required\n if ('fields' in field && field.type !== 'array') {\n return field.flattenedFields.some((subField) => fieldIsRequired(subField))\n }\n\n return false\n}\n\nfunction buildOptionEnums(options: Option[]): string[] {\n return options.map((option) => {\n if (typeof option === 'object' && 'value' in option) {\n return option.value\n }\n\n return option\n })\n}\n\nfunction generateEntitySchemas(\n entities: (SanitizedCollectionConfig | SanitizedGlobalConfig)[],\n): JSONSchema4 {\n const properties = [...entities].reduce(\n (acc, { slug }) => {\n acc[slug] = {\n $ref: `#/definitions/${slug}`,\n }\n\n return acc\n },\n {} as Record<string, JSONSchema4>,\n )\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n }\n}\n\nfunction generateEntitySelectSchemas(\n entities: (SanitizedCollectionConfig | SanitizedGlobalConfig)[],\n): JSONSchema4 {\n const properties = [...entities].reduce(\n (acc, { slug }) => {\n acc[slug] = {\n $ref: `#/definitions/${slug}_select`,\n }\n\n return acc\n },\n {} as Record<string, JSONSchema4>,\n )\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n }\n}\n\nfunction generateCollectionJoinsSchemas(collections: SanitizedCollectionConfig[]): JSONSchema4 {\n const properties = [...collections].reduce<Record<string, JSONSchema4>>(\n (acc, { slug, joins, polymorphicJoins }) => {\n const schema = {\n type: 'object',\n additionalProperties: false,\n properties: {},\n required: [] as string[],\n } satisfies JSONSchema4\n\n for (const collectionSlug in joins) {\n for (const join of joins[collectionSlug]!) {\n ;(schema.properties as any)[join.joinPath] = {\n type: 'string',\n enum: [collectionSlug],\n }\n schema.required.push(join.joinPath)\n }\n }\n\n for (const join of polymorphicJoins) {\n ;(schema.properties as any)[join.joinPath] = {\n type: 'string',\n enum: join.field.collection,\n }\n schema.required.push(join.joinPath)\n }\n\n if (Object.keys(schema.properties).length > 0) {\n acc[slug] = schema\n }\n\n return acc\n },\n {},\n )\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n }\n}\n\nconst widgetWidths = ['x-small', 'small', 'medium', 'large', 'x-large', 'full'] as const\n\nfunction getAllowedWidgetWidths({\n maxWidth,\n minWidth,\n}: {\n maxWidth?: (typeof widgetWidths)[number]\n minWidth?: (typeof widgetWidths)[number]\n}): string[] {\n const minIndex = minWidth ? widgetWidths.indexOf(minWidth) : 0\n const maxIndex = maxWidth ? widgetWidths.indexOf(maxWidth) : widgetWidths.length - 1\n\n if (minIndex === -1 || maxIndex === -1 || minIndex > maxIndex) {\n return [...widgetWidths]\n }\n\n return widgetWidths.slice(minIndex, maxIndex + 1)\n}\n\nfunction generateWidgetSchemas({\n collectionIDFieldTypes,\n config,\n i18n,\n interfaceNameDefinitions,\n}: {\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' }\n config: SanitizedConfig\n i18n?: I18n\n interfaceNameDefinitions: Map<string, JSONSchema4>\n}): {\n definitions: Record<string, JSONSchema4>\n schema: JSONSchema4\n} {\n const widgets = config.admin?.dashboard?.widgets ?? []\n const definitions: Record<string, JSONSchema4> = {}\n const properties: Record<string, JSONSchema4> = {}\n\n for (const widget of widgets) {\n const definition = `${widget.slug}_widget`\n const widthEnum = getAllowedWidgetWidths({\n maxWidth: widget.maxWidth,\n minWidth: widget.minWidth,\n })\n let dataSchema: JSONSchema4\n\n if (widget.fields?.length) {\n const widgetFieldSchemas = fieldsToJSONSchema(\n collectionIDFieldTypes,\n flattenAllFields({ fields: widget.fields }),\n interfaceNameDefinitions,\n config,\n i18n,\n )\n\n dataSchema = {\n type: 'object',\n additionalProperties: false,\n ...widgetFieldSchemas,\n }\n } else {\n dataSchema = {\n type: 'object',\n additionalProperties: true,\n }\n }\n\n definitions[definition] = {\n type: 'object',\n additionalProperties: false,\n properties: {\n data: dataSchema,\n width: {\n type: 'string',\n enum: widthEnum,\n },\n },\n required: ['width'],\n }\n\n properties[widget.slug] = {\n $ref: `#/definitions/${definition}`,\n }\n }\n\n return {\n definitions,\n schema: {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n },\n }\n}\n\nfunction generateLocaleEntitySchemas(localization: SanitizedConfig['localization']): JSONSchema4 {\n if (localization && 'locales' in localization && localization?.locales) {\n const localesFromConfig = localization?.locales\n\n const locales = [...localesFromConfig].map((locale) => {\n return locale.code\n }, [])\n\n return {\n type: 'string',\n enum: locales,\n }\n }\n\n return {\n type: 'null',\n }\n}\n\nfunction generateFallbackLocaleEntitySchemas(\n localization: SanitizedConfig['localization'],\n): JSONSchema4 {\n if (localization && 'localeCodes' in localization && localization?.localeCodes) {\n const localeCodes = [...localization.localeCodes].map((localeCode) => {\n return localeCode\n }, [])\n\n return {\n oneOf: [\n { type: 'string', enum: ['false', 'none', 'null'] },\n { type: 'boolean', enum: [false] },\n { type: 'null' },\n { type: 'string', enum: localeCodes },\n { type: 'array', items: { type: 'string', enum: localeCodes } },\n ],\n }\n }\n\n return {\n type: 'null',\n }\n}\n\nfunction generateAuthEntitySchemas(entities: SanitizedCollectionConfig[]): JSONSchema4 {\n const properties: JSONSchema4[] = [...entities]\n .filter(({ auth }) => Boolean(auth))\n .map(({ slug }) => {\n return { $ref: `#/definitions/${slug}` }\n }, {})\n\n return {\n oneOf: properties,\n }\n}\n\n/**\n * Generates the JSON Schema for database configuration\n *\n * @example { db: idType: string }\n */\nfunction generateDbEntitySchema(config: SanitizedConfig): JSONSchema4 {\n const defaultIDType: JSONSchema4 =\n config.db?.defaultIDType === 'number' ? { type: 'number' } : { type: 'string' }\n\n return {\n type: 'object',\n additionalProperties: false,\n properties: {\n defaultIDType,\n },\n required: ['defaultIDType'],\n }\n}\n\n/**\n * Returns a JSON Schema Type with 'null' added if the field is not required.\n */\nexport function withNullableJSONSchemaType(\n fieldType: JSONSchema4TypeName,\n isRequired: boolean,\n): JSONSchema4TypeName | JSONSchema4TypeName[] {\n const fieldTypes = [fieldType]\n if (isRequired) {\n return fieldType\n }\n fieldTypes.push('null')\n return fieldTypes\n}\n\nfunction entityOrFieldToJsDocs({\n entity,\n i18n,\n}: {\n entity: FlattenedField | SanitizedCollectionConfig | SanitizedGlobalConfig\n i18n?: I18n\n}): string | undefined {\n let description: string | undefined = undefined\n if (entity?.admin?.description) {\n if (typeof entity?.admin?.description === 'string') {\n description = entity?.admin?.description\n } else if (typeof entity?.admin?.description === 'object') {\n if (entity?.admin?.description?.en) {\n description = entity?.admin?.description?.en\n } else if (entity?.admin?.description?.[i18n!.language]) {\n description = entity?.admin?.description?.[i18n!.language]\n }\n } else if (typeof entity?.admin?.description === 'function' && i18n) {\n // do not evaluate description functions for generating JSDocs. The output of\n // those can differ depending on where and when they are called, creating\n // inconsistencies in the generated JSDocs.\n }\n }\n return description\n}\nexport function fieldsToJSONSchema(\n /**\n * Used for relationship fields, to determine whether to use a string or number type for the ID.\n * While there is a default ID field type set by the db adapter, they can differ on a collection-level\n * if they have custom ID fields.\n */\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' },\n fields: FlattenedField[],\n /**\n * Allows you to define new top-level interfaces that can be re-used in the output schema.\n */\n interfaceNameDefinitions: Map<string, JSONSchema4>,\n config?: SanitizedConfig,\n i18n?: I18n,\n): {\n properties: {\n [k: string]: JSONSchema4\n }\n required: string[]\n} {\n const requiredFieldNames = new Set<string>()\n\n return {\n properties: Object.fromEntries(\n fields.reduce((fieldSchemas, field, index) => {\n const isRequired = fieldAffectsData(field) && fieldIsRequired(field)\n\n const fieldDescription = entityOrFieldToJsDocs({ entity: field, i18n })\n const baseFieldSchema: JSONSchema4 = {}\n if (fieldDescription) {\n baseFieldSchema.description = fieldDescription\n }\n\n let fieldSchema: JSONSchema4\n\n switch (field.type) {\n case 'array': {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'object',\n additionalProperties: false,\n ...fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.flattenedFields,\n interfaceNameDefinitions,\n config,\n i18n,\n ),\n },\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = {\n $ref: `#/definitions/${field.interfaceName}`,\n }\n }\n break\n }\n case 'blocks': {\n // Check for a case where no blocks are provided.\n // We need to generate an empty array for this case, note that JSON schema 4 doesn't support empty arrays\n // so the best we can get is `unknown[]`\n const hasBlocks = Boolean(\n field.blockReferences ? field.blockReferences.length : field.blocks.length,\n )\n\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: hasBlocks\n ? {\n oneOf: (field.blockReferences ?? field.blocks).map((block) => {\n if (typeof block === 'string') {\n const resolvedBlock = config?.blocks?.find((b) => b.slug === block)\n if (!resolvedBlock) {\n return {}\n }\n\n const resolvedBlockFieldSchemas = fieldsToJSONSchema(\n collectionIDFieldTypes,\n resolvedBlock.flattenedFields,\n interfaceNameDefinitions,\n config,\n i18n,\n )\n\n const resolvedBlockSchema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n properties: {\n ...resolvedBlockFieldSchemas.properties,\n blockType: {\n const: resolvedBlock.slug,\n },\n },\n required: ['blockType', ...resolvedBlockFieldSchemas.required],\n }\n\n if (resolvedBlock.interfaceName) {\n interfaceNameDefinitions.set(\n resolvedBlock.interfaceName,\n resolvedBlockSchema,\n )\n }\n\n return resolvedBlockSchema\n }\n\n const blockFieldSchemas = fieldsToJSONSchema(\n collectionIDFieldTypes,\n block.flattenedFields,\n interfaceNameDefinitions,\n config,\n i18n,\n )\n const blockSchema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n properties: {\n ...blockFieldSchemas.properties,\n blockType: {\n const: block.slug,\n },\n },\n required: ['blockType', ...blockFieldSchemas.required],\n }\n\n if (block.interfaceName) {\n interfaceNameDefinitions.set(block.interfaceName, blockSchema)\n return blockSchema\n }\n\n return blockSchema\n }),\n }\n : {},\n }\n break\n }\n case 'checkbox': {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('boolean', isRequired),\n }\n break\n }\n case 'code':\n case 'date':\n case 'email':\n case 'textarea': {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('string', isRequired),\n }\n break\n }\n\n case 'group': {\n if (fieldAffectsData(field)) {\n fieldSchema = {\n ...baseFieldSchema,\n type: 'object',\n additionalProperties: false,\n ...fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.flattenedFields,\n interfaceNameDefinitions,\n config,\n i18n,\n ),\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = { $ref: `#/definitions/${field.interfaceName}` }\n }\n }\n break\n }\n\n case 'join': {\n let items: JSONSchema4\n\n if (Array.isArray(field.collection)) {\n items = {\n oneOf: field.collection.map((collection) => ({\n type: 'object',\n additionalProperties: false,\n properties: {\n relationTo: {\n const: collection,\n },\n value: {\n oneOf: [\n {\n type: collectionIDFieldTypes[collection],\n },\n {\n $ref: `#/definitions/${collection}`,\n },\n ],\n },\n },\n required: ['collectionSlug', 'value'],\n })),\n }\n } else {\n items = {\n oneOf: [\n {\n type: collectionIDFieldTypes[field.collection],\n },\n {\n $ref: `#/definitions/${field.collection}`,\n },\n ],\n }\n }\n\n fieldSchema = {\n ...baseFieldSchema,\n type: 'object',\n additionalProperties: false,\n properties: {\n docs: {\n type: 'array',\n items,\n },\n hasNextPage: { type: 'boolean' },\n totalDocs: { type: 'number' },\n },\n }\n break\n }\n\n case 'json': {\n fieldSchema = field.jsonSchema?.schema || {\n ...baseFieldSchema,\n type: ['object', 'array', 'string', 'number', 'boolean', 'null'],\n }\n break\n }\n\n case 'number': {\n if (field.hasMany === true) {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: { type: 'number' },\n }\n } else {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('number', isRequired),\n }\n }\n break\n }\n\n case 'point': {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: [\n {\n type: 'number',\n },\n {\n type: 'number',\n },\n ],\n maxItems: 2,\n minItems: 2,\n }\n break\n }\n\n case 'radio': {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('string', isRequired),\n enum: buildOptionEnums(field.options),\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = {\n $ref: `#/definitions/${field.interfaceName}`,\n }\n }\n\n break\n }\n case 'relationship':\n case 'upload': {\n if (Array.isArray(field.relationTo)) {\n if (field.hasMany) {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n oneOf: field.relationTo.map((relation) => {\n return {\n type: 'object',\n additionalProperties: false,\n properties: {\n relationTo: {\n const: relation,\n },\n value: {\n oneOf: [\n {\n type: collectionIDFieldTypes[relation],\n },\n {\n $ref: `#/definitions/${relation}`,\n },\n ],\n },\n },\n required: ['value', 'relationTo'],\n }\n }),\n },\n }\n } else {\n fieldSchema = {\n ...baseFieldSchema,\n oneOf: field.relationTo.map((relation) => {\n return {\n type: withNullableJSONSchemaType('object', isRequired),\n additionalProperties: false,\n properties: {\n relationTo: {\n const: relation,\n },\n value: {\n oneOf: [\n {\n type: collectionIDFieldTypes[relation],\n },\n {\n $ref: `#/definitions/${relation}`,\n },\n ],\n },\n },\n required: ['value', 'relationTo'],\n }\n }),\n }\n }\n } else if (field.hasMany) {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n oneOf: [\n {\n type: collectionIDFieldTypes[field.relationTo],\n },\n {\n $ref: `#/definitions/${field.relationTo}`,\n },\n ],\n },\n }\n } else {\n fieldSchema = {\n ...baseFieldSchema,\n oneOf: [\n {\n type: withNullableJSONSchemaType(\n collectionIDFieldTypes[field.relationTo]!,\n isRequired,\n ),\n },\n { $ref: `#/definitions/${field.relationTo}` },\n ],\n }\n }\n\n break\n }\n case 'richText': {\n if (!field?.editor) {\n throw new MissingEditorProp(field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n if (typeof field.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n if (field.editor.outputSchema) {\n fieldSchema = {\n ...baseFieldSchema,\n ...field.editor.outputSchema({\n collectionIDFieldTypes,\n config,\n field,\n i18n,\n interfaceNameDefinitions,\n isRequired,\n }),\n }\n } else {\n // Maintain backwards compatibility with existing rich text editors\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'object',\n },\n }\n }\n\n break\n }\n\n case 'select': {\n const optionEnums = buildOptionEnums(field.options)\n // We get the previous field to check for a date in the case of a timezone select\n // This works because timezone selects are always inserted right after a date with 'timezone: true'\n const previousField = fields?.[index - 1]\n const isTimezoneField =\n previousField?.type === 'date' && previousField.timezone && field.name.includes('_tz')\n\n // Check if the timezone field's options match the global config's supported timezones\n const hasMatchingGlobalTimezones =\n isTimezoneField &&\n config &&\n optionsAreEqual(field.options, config.admin?.timezones?.supportedTimezones)\n\n // Timezone selects should reference the supportedTimezones definition\n // only if the field's options match the global config\n if (isTimezoneField && hasMatchingGlobalTimezones) {\n fieldSchema = {\n $ref: `#/definitions/supportedTimezones`,\n }\n } else {\n if (field.hasMany) {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'string',\n },\n }\n if (optionEnums?.length) {\n ;(fieldSchema.items as JSONSchema4).enum = optionEnums\n }\n } else {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('string', isRequired),\n }\n if (optionEnums?.length) {\n fieldSchema.enum = optionEnums\n }\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = {\n $ref: `#/definitions/${field.interfaceName}`,\n }\n }\n break\n }\n\n break\n }\n case 'tab': {\n fieldSchema = {\n ...baseFieldSchema,\n type: 'object',\n additionalProperties: false,\n ...fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.flattenedFields,\n interfaceNameDefinitions,\n config,\n i18n,\n ),\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = { $ref: `#/definitions/${field.interfaceName}` }\n }\n break\n }\n\n case 'text':\n if (field.hasMany === true) {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: { type: 'string' },\n }\n } else {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('string', isRequired),\n }\n }\n break\n\n default: {\n break\n }\n }\n\n if ('typescriptSchema' in field && field?.typescriptSchema?.length) {\n for (const schema of field.typescriptSchema) {\n fieldSchema = schema({ jsonSchema: fieldSchema! })\n }\n }\n\n if (fieldSchema! && fieldAffectsData(field)) {\n if (isRequired && fieldSchema.required !== false) {\n requiredFieldNames.add(field.name)\n }\n fieldSchemas.set(field.name, fieldSchema)\n }\n\n return fieldSchemas\n }, new Map<string, JSONSchema4>()),\n ),\n required: Array.from(requiredFieldNames),\n }\n}\n\n// This function is part of the public API and is exported through payload/utilities\nexport function entityToJSONSchema(\n config: SanitizedConfig,\n entity: SanitizedCollectionConfig | SanitizedGlobalConfig,\n interfaceNameDefinitions: Map<string, JSONSchema4>,\n defaultIDType: 'number' | 'text',\n collectionIDFieldTypes?: { [key: string]: 'number' | 'string' },\n i18n?: I18n,\n): JSONSchema4 {\n if (!collectionIDFieldTypes) {\n collectionIDFieldTypes = getCollectionIDFieldTypes({ config, defaultIDType })\n }\n\n const title = entity.typescript?.interface\n ? entity.typescript.interface\n : formatNames(entity.slug).singular\n\n let mutableFields = [...entity.flattenedFields]\n\n const idField: FieldAffectingData = { name: 'id', type: defaultIDType as 'text', required: true }\n const customIdField = mutableFields.find((field) => field.name === 'id') as FieldAffectingData\n\n if (customIdField && customIdField.type !== 'group' && customIdField.type !== 'tab') {\n mutableFields = mutableFields.map((field) => {\n if (field === customIdField) {\n return { ...field, required: true }\n }\n\n return field\n })\n } else {\n mutableFields.unshift(idField)\n }\n\n // mark timestamp fields required\n if ('timestamps' in entity && entity.timestamps !== false) {\n mutableFields = mutableFields.map((field) => {\n if (field.name === 'createdAt' || field.name === 'updatedAt') {\n return {\n ...field,\n required: true,\n }\n }\n return field\n })\n }\n\n if (\n 'auth' in entity &&\n entity.auth &&\n (!entity.auth?.disableLocalStrategy ||\n (typeof entity.auth?.disableLocalStrategy === 'object' &&\n entity.auth.disableLocalStrategy.enableFields))\n ) {\n mutableFields.push({\n name: 'password',\n type: 'text',\n })\n }\n\n const isAuthCollection = 'auth' in entity && entity.auth\n\n const fieldsSchema = fieldsToJSONSchema(\n collectionIDFieldTypes,\n mutableFields,\n interfaceNameDefinitions,\n config,\n i18n,\n )\n\n // Add collection property to auth collections\n if (isAuthCollection) {\n fieldsSchema.properties = {\n ...fieldsSchema.properties,\n collection: { type: 'string', enum: [entity.slug] },\n }\n fieldsSchema.required = [...(fieldsSchema.required || []), 'collection']\n }\n\n const jsonSchema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n title,\n ...fieldsSchema,\n }\n\n const entityDescription = entityOrFieldToJsDocs({ entity, i18n })\n\n if (entityDescription) {\n jsonSchema.description = entityDescription\n }\n\n return jsonSchema\n}\n\nexport function fieldsToSelectJSONSchema({\n config,\n fields,\n interfaceNameDefinitions,\n}: {\n config: SanitizedConfig\n fields: FlattenedField[]\n interfaceNameDefinitions: Map<string, JSONSchema4>\n}): JSONSchema4 {\n const schema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n properties: {},\n }\n\n for (const field of fields) {\n switch (field.type) {\n case 'array':\n case 'group':\n case 'tab': {\n let fieldSchema: JSONSchema4 = fieldsToSelectJSONSchema({\n config,\n fields: field.flattenedFields,\n interfaceNameDefinitions,\n })\n\n if (field.interfaceName) {\n const definition = `${field.interfaceName}_select`\n interfaceNameDefinitions.set(definition, fieldSchema)\n\n fieldSchema = {\n $ref: `#/definitions/${definition}`,\n }\n }\n\n schema.properties![field.name] = {\n oneOf: [\n {\n type: 'boolean',\n },\n fieldSchema,\n ],\n }\n\n break\n }\n\n case 'blocks': {\n const blocksSchema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n properties: {},\n }\n\n for (const block of field.blockReferences ?? field.blocks) {\n if (typeof block === 'string') {\n continue // TODO\n }\n\n let blockSchema = fieldsToSelectJSONSchema({\n config,\n fields: block.flattenedFields,\n interfaceNameDefinitions,\n })\n\n if (block.interfaceName) {\n const definition = `${block.interfaceName}_select`\n interfaceNameDefinitions.set(definition, blockSchema)\n blockSchema = {\n $ref: `#/definitions/${definition}`,\n }\n }\n\n blocksSchema.properties![block.slug] = {\n oneOf: [\n {\n type: 'boolean',\n },\n blockSchema,\n ],\n }\n }\n\n schema.properties![field.name] = {\n oneOf: [\n {\n type: 'boolean',\n },\n blocksSchema,\n ],\n }\n\n break\n }\n\n default:\n schema.properties![field.name] = {\n type: 'boolean',\n }\n break\n }\n }\n\n return schema\n}\n\nconst fieldType: JSONSchema4 = {\n type: 'string',\n required: false,\n}\nconst generateAuthFieldTypes = ({\n type,\n loginWithUsername,\n}: {\n loginWithUsername: Auth['loginWithUsername']\n type: 'forgotOrUnlock' | 'login' | 'register'\n}): JSONSchema4 => {\n if (loginWithUsername) {\n switch (type) {\n case 'forgotOrUnlock': {\n if (loginWithUsername.allowEmailLogin) {\n // allow email or username for unlock/forgot-password\n return {\n additionalProperties: false,\n oneOf: [\n {\n additionalProperties: false,\n properties: { email: fieldType },\n required: ['email'],\n },\n {\n additionalProperties: false,\n properties: { username: fieldType },\n required: ['username'],\n },\n ],\n }\n } else {\n // allow only username for unlock/forgot-password\n return {\n additionalProperties: false,\n properties: { username: fieldType },\n required: ['username'],\n }\n }\n }\n\n case 'login': {\n if (loginWithUsername.allowEmailLogin) {\n // allow username or email and require password for login\n return {\n additionalProperties: false,\n oneOf: [\n {\n additionalProperties: false,\n properties: { email: fieldType, password: fieldType },\n required: ['email', 'password'],\n },\n {\n additionalProperties: false,\n properties: { password: fieldType, username: fieldType },\n required: ['username', 'password'],\n },\n ],\n }\n } else {\n // allow only username and password for login\n return {\n additionalProperties: false,\n properties: {\n password: fieldType,\n username: fieldType,\n },\n required: ['username', 'password'],\n }\n }\n }\n\n case 'register': {\n const requiredFields: ('email' | 'password' | 'username')[] = ['password']\n const properties: {\n email?: JSONSchema4['properties']\n password?: JSONSchema4['properties']\n username?: JSONSchema4['properties']\n } = {\n password: fieldType,\n username: fieldType,\n }\n\n if (loginWithUsername.requireEmail) {\n requiredFields.push('email')\n }\n if (loginWithUsername.requireUsername) {\n requiredFields.push('username')\n }\n if (loginWithUsername.requireEmail || loginWithUsername.allowEmailLogin) {\n properties.email = fieldType\n }\n\n return {\n additionalProperties: false,\n properties,\n required: requiredFields,\n }\n }\n }\n }\n\n // default email (and password for login/register)\n return {\n additionalProperties: false,\n properties: { email: fieldType, password: fieldType },\n required: ['email', 'password'],\n }\n}\n\nexport function authCollectionToOperationsJSONSchema(\n config: SanitizedCollectionConfig,\n): JSONSchema4 {\n const loginWithUsername = config.auth?.loginWithUsername\n const loginUserFields: JSONSchema4 = generateAuthFieldTypes({ type: 'login', loginWithUsername })\n const forgotOrUnlockUserFields: JSONSchema4 = generateAuthFieldTypes({\n type: 'forgotOrUnlock',\n loginWithUsername,\n })\n const registerUserFields: JSONSchema4 = generateAuthFieldTypes({\n type: 'register',\n loginWithUsername,\n })\n\n const properties: JSONSchema4['properties'] = {\n forgotPassword: forgotOrUnlockUserFields,\n login: loginUserFields,\n registerFirstUser: registerUserFields,\n unlock: forgotOrUnlockUserFields,\n }\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n title: `${formatNames(config.slug).singular}AuthOperations`,\n }\n}\n\n// Generates the JSON Schema for supported timezones\nexport function timezonesToJSONSchema(\n supportedTimezones: SanitizedConfig['admin']['timezones']['supportedTimezones'],\n): JSONSchema4 {\n return {\n description: 'Supported timezones in IANA format.',\n enum: supportedTimezones.map((timezone) =>\n typeof timezone === 'string' ? timezone : timezone.value,\n ),\n }\n}\n\nfunction generateAuthOperationSchemas(collections: SanitizedCollectionConfig[]): JSONSchema4 {\n const properties = collections.reduce(\n (acc, collection) => {\n if (collection.auth) {\n acc[collection.slug] = {\n $ref: `#/definitions/auth/${collection.slug}`,\n }\n }\n return acc\n },\n {} as Record<string, JSONSchema4>,\n )\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n }\n}\n\n/**\n * This is used for generating the TypeScript types (payload-types.ts) with the payload generate:types command.\n */\nexport function configToJSONSchema(\n config: SanitizedConfig,\n defaultIDType?: 'number' | 'text',\n i18n?: I18n,\n): JSONSchema4 {\n // a mutable Map to store custom top-level `interfaceName` types. Fields with an `interfaceName` property will be moved to the top-level definitions here\n const interfaceNameDefinitions: Map<string, JSONSchema4> = new Map()\n\n // Used for relationship fields, to determine whether to use a string or number type for the ID.\n const collectionIDFieldTypes = getCollectionIDFieldTypes({\n config,\n defaultIDType: defaultIDType!,\n })\n\n // Collections and Globals have to be moved to the top-level definitions as well. Reason: The top-level type will be the `Config` type - we don't want all collection and global\n // types to be inlined inside the `Config` type\n\n const entities: {\n entity: SanitizedCollectionConfig | SanitizedGlobalConfig\n type: 'collection' | 'global'\n }[] = [\n ...config.globals.map((global) => ({ type: 'global' as const, entity: global })),\n ...config.collections.map((collection) => ({\n type: 'collection' as const,\n entity: collection,\n })),\n ]\n\n const entityDefinitions: { [k: string]: JSONSchema4 } = entities.reduce(\n (acc, { type, entity }) => {\n acc[entity.slug] = entityToJSONSchema(\n config,\n entity,\n interfaceNameDefinitions,\n defaultIDType!,\n collectionIDFieldTypes,\n i18n,\n )\n const select = fieldsToSelectJSONSchema({\n config,\n fields: entity.flattenedFields,\n interfaceNameDefinitions,\n })\n\n if (type === 'global') {\n select.properties!.globalType = {\n type: 'boolean',\n }\n }\n\n acc[`${entity.slug}_select`] = {\n type: 'object',\n additionalProperties: false,\n ...select,\n }\n\n return acc\n },\n {} as Record<string, JSONSchema4>,\n )\n\n const timezoneDefinitions = timezonesToJSONSchema(config.admin.timezones.supportedTimezones)\n const widgetSchemas = generateWidgetSchemas({\n collectionIDFieldTypes,\n config,\n i18n,\n interfaceNameDefinitions,\n })\n\n const authOperationDefinitions = [...config.collections]\n .filter(({ auth }) => Boolean(auth))\n .reduce(\n (acc, authCollection) => {\n acc.auth[authCollection.slug] = authCollectionToOperationsJSONSchema(authCollection)\n return acc\n },\n { auth: {} as Record<string, JSONSchema4> },\n )\n\n const jobsSchemas = config.jobs\n ? generateJobsJSONSchemas(\n config,\n config.jobs,\n interfaceNameDefinitions,\n collectionIDFieldTypes,\n i18n,\n )\n : {}\n\n const blocksDefinition: JSONSchema4 | undefined = {\n type: 'object',\n additionalProperties: false,\n properties: {},\n required: [],\n }\n if (config?.blocks?.length) {\n for (const block of config.blocks) {\n const blockFieldSchemas = fieldsToJSONSchema(\n collectionIDFieldTypes,\n block.flattenedFields,\n interfaceNameDefinitions,\n config,\n i18n,\n )\n\n const blockSchema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n properties: {\n ...blockFieldSchemas.properties,\n blockType: {\n const: block.slug,\n },\n },\n required: ['blockType', ...blockFieldSchemas.required],\n }\n\n const interfaceName = block.interfaceName ?? block.slug\n interfaceNameDefinitions.set(interfaceName, blockSchema)\n\n blocksDefinition.properties![block.slug] = {\n $ref: `#/definitions/${interfaceName}`,\n }\n ;(blocksDefinition.required as string[]).push(block.slug)\n }\n }\n\n let jsonSchema: JSONSchema4 = {\n additionalProperties: false,\n definitions: {\n supportedTimezones: timezoneDefinitions,\n ...entityDefinitions,\n ...widgetSchemas.definitions,\n ...Object.fromEntries(interfaceNameDefinitions),\n ...authOperationDefinitions,\n },\n // These properties here will be very simple, as all the complexity is in the definitions. These are just the properties for the top-level `Config` type\n type: 'object',\n properties: {\n auth: generateAuthOperationSchemas(config.collections),\n blocks: blocksDefinition,\n collections: generateEntitySchemas(config.collections || []),\n collectionsJoins: generateCollectionJoinsSchemas(config.collections || []),\n collectionsSelect: generateEntitySelectSchemas(config.collections || []),\n db: generateDbEntitySchema(config),\n fallbackLocale: generateFallbackLocaleEntitySchemas(config.localization),\n globals: generateEntitySchemas(config.globals || []),\n globalsSelect: generateEntitySelectSchemas(config.globals || []),\n locale: generateLocaleEntitySchemas(config.localization),\n widgets: widgetSchemas.schema,\n ...(config.typescript?.strictDraftTypes\n ? {\n strictDraftTypes: {\n type: 'boolean',\n const: true,\n },\n }\n : {}),\n user: generateAuthEntitySchemas(config.collections),\n },\n required: [\n 'user',\n 'locale',\n 'fallbackLocale',\n 'collections',\n 'collectionsSelect',\n 'collectionsJoins',\n 'globalsSelect',\n ...(config.typescript?.strictDraftTypes ? ['strictDraftTypes'] : []),\n 'globals',\n 'auth',\n 'db',\n 'jobs',\n 'blocks',\n 'widgets',\n ],\n title: 'Config',\n }\n\n if (jobsSchemas.definitions?.size) {\n for (const [key, value] of jobsSchemas.definitions) {\n jsonSchema.definitions![key] = value\n }\n }\n if (jobsSchemas.properties) {\n jsonSchema.properties!.jobs = {\n type: 'object',\n additionalProperties: false,\n properties: jobsSchemas.properties,\n required: ['tasks', 'workflows'],\n }\n }\n\n if (config?.typescript?.schema?.length) {\n for (const schema of config.typescript.schema) {\n jsonSchema = schema({ collectionIDFieldTypes, config, i18n: i18n!, jsonSchema })\n }\n }\n\n return jsonSchema\n}\n"],"names":["MissingEditorProp","fieldAffectsData","generateJobsJSONSchemas","flattenAllFields","formatNames","getCollectionIDFieldTypes","optionsAreEqual","fieldIsRequired","field","isConditional","Boolean","admin","condition","isMarkedRequired","required","type","flattenedFields","some","subField","buildOptionEnums","options","map","option","value","generateEntitySchemas","entities","properties","reduce","acc","slug","$ref","additionalProperties","Object","keys","generateEntitySelectSchemas","generateCollectionJoinsSchemas","collections","joins","polymorphicJoins","schema","collectionSlug","join","joinPath","enum","push","collection","length","widgetWidths","getAllowedWidgetWidths","maxWidth","minWidth","minIndex","indexOf","maxIndex","slice","generateWidgetSchemas","collectionIDFieldTypes","config","i18n","interfaceNameDefinitions","widgets","dashboard","definitions","widget","definition","widthEnum","dataSchema","fields","widgetFieldSchemas","fieldsToJSONSchema","data","width","generateLocaleEntitySchemas","localization","locales","localesFromConfig","locale","code","generateFallbackLocaleEntitySchemas","localeCodes","localeCode","oneOf","items","generateAuthEntitySchemas","filter","auth","generateDbEntitySchema","defaultIDType","db","withNullableJSONSchemaType","fieldType","isRequired","fieldTypes","entityOrFieldToJsDocs","entity","description","undefined","en","language","requiredFieldNames","Set","fromEntries","fieldSchemas","index","fieldDescription","baseFieldSchema","fieldSchema","interfaceName","set","hasBlocks","blockReferences","blocks","block","resolvedBlock","find","b","resolvedBlockFieldSchemas","resolvedBlockSchema","blockType","const","blockFieldSchemas","blockSchema","Array","isArray","relationTo","docs","hasNextPage","totalDocs","jsonSchema","hasMany","maxItems","minItems","relation","editor","Error","outputSchema","optionEnums","previousField","isTimezoneField","timezone","name","includes","hasMatchingGlobalTimezones","timezones","supportedTimezones","typescriptSchema","add","Map","from","entityToJSONSchema","title","typescript","interface","singular","mutableFields","idField","customIdField","unshift","timestamps","disableLocalStrategy","enableFields","isAuthCollection","fieldsSchema","entityDescription","fieldsToSelectJSONSchema","blocksSchema","generateAuthFieldTypes","loginWithUsername","allowEmailLogin","email","username","password","requiredFields","requireEmail","requireUsername","authCollectionToOperationsJSONSchema","loginUserFields","forgotOrUnlockUserFields","registerUserFields","forgotPassword","login","registerFirstUser","unlock","timezonesToJSONSchema","generateAuthOperationSchemas","configToJSONSchema","globals","global","entityDefinitions","select","globalType","timezoneDefinitions","widgetSchemas","authOperationDefinitions","authCollection","jobsSchemas","jobs","blocksDefinition","collectionsJoins","collectionsSelect","fallbackLocale","globalsSelect","strictDraftTypes","user","size","key"],"mappings":"AASA,SAASA,iBAAiB,QAAQ,iCAAgC;AAClE,SAASC,gBAAgB,QAAQ,4BAA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U,EAAEmD,mBACnB;gBACEA,kBAAkB;oBAChB3L,MAAM;oBACNwG,OAAO;gBACT;YACF,IACA,CAAC,CAAC;YACNoF,MAAMxH,0BAA0B1B,OAAOrB,WAAW;QACpD;QACAtB,UAAU;YACR;YACA;YACA;YACA;YACA;YACA;YACA;eACI2C,OAAO8F,UAAU,EAAEmD,mBAAmB;gBAAC;aAAmB,GAAG,EAAE;YACnE;YACA;YACA;YACA;YACA;YACA;SACD;QACDpD,OAAO;IACT;IAEA,IAAI6C,YAAYrI,WAAW,EAAE8I,MAAM;QACjC,KAAK,MAAM,CAACC,KAAKtL,MAAM,IAAI4K,YAAYrI,WAAW,CAAE;YAClDkE,WAAWlE,WAAW,AAAC,CAAC+I,IAAI,GAAGtL;QACjC;IACF;IACA,IAAI4K,YAAYzK,UAAU,EAAE;QAC1BsG,WAAWtG,UAAU,CAAE0K,IAAI,GAAG;YAC5BrL,MAAM;YACNgB,sBAAsB;YACtBL,YAAYyK,YAAYzK,UAAU;YAClCZ,UAAU;gBAAC;gBAAS;aAAY;QAClC;IACF;IAEA,IAAI2C,QAAQ8F,YAAYhH,QAAQO,QAAQ;QACtC,KAAK,MAAMP,UAAUkB,OAAO8F,UAAU,CAAChH,MAAM,CAAE;YAC7CyF,aAAazF,OAAO;gBAAEiB;gBAAwBC;gBAAQC,MAAMA;gBAAOsE;YAAW;QAChF;IACF;IAEA,OAAOA;AACT"}
1
+ {"version":3,"sources":["../../src/utilities/configToJSONSchema.ts"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { JSONSchema4, JSONSchema4TypeName } from 'json-schema'\n\nimport type { Auth } from '../auth/types.js'\nimport type { SanitizedCollectionConfig } from '../collections/config/types.js'\nimport type { SanitizedConfig } from '../config/types.js'\nimport type { FieldAffectingData, FlattenedField, Option } from '../fields/config/types.js'\nimport type { SanitizedGlobalConfig } from '../globals/config/types.js'\n\nimport { MissingEditorProp } from '../errors/MissingEditorProp.js'\nimport { fieldAffectsData } from '../fields/config/types.js'\nimport { generateJobsJSONSchemas } from '../queues/config/generateJobsJSONSchemas.js'\nimport { flattenAllFields } from './flattenAllFields.js'\nimport { formatNames } from './formatLabels.js'\nimport { getCollectionIDFieldTypes } from './getCollectionIDFieldTypes.js'\nimport { optionsAreEqual } from './optionsAreEqual.js'\n\nconst fieldIsRequired = (field: FlattenedField): boolean => {\n const isConditional = Boolean(field?.admin && field?.admin?.condition)\n if (isConditional) {\n return false\n }\n\n const isMarkedRequired = 'required' in field && field.required === true\n if (fieldAffectsData(field) && isMarkedRequired) {\n return true\n }\n\n // if any subfields are required, this field is required\n if ('fields' in field && field.type !== 'array') {\n return field.flattenedFields.some((subField) => fieldIsRequired(subField))\n }\n\n return false\n}\n\nfunction buildOptionEnums(options: Option[]): string[] {\n return options.map((option) => {\n if (typeof option === 'object' && 'value' in option) {\n return option.value\n }\n\n return option\n })\n}\n\nfunction generateEntitySchemas(\n entities: (SanitizedCollectionConfig | SanitizedGlobalConfig)[],\n): JSONSchema4 {\n const properties = [...entities].reduce(\n (acc, { slug }) => {\n acc[slug] = {\n $ref: `#/definitions/${slug}`,\n }\n\n return acc\n },\n {} as Record<string, JSONSchema4>,\n )\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n }\n}\n\nfunction generateEntitySelectSchemas(\n entities: (SanitizedCollectionConfig | SanitizedGlobalConfig)[],\n): JSONSchema4 {\n const properties = [...entities].reduce(\n (acc, { slug }) => {\n acc[slug] = {\n $ref: `#/definitions/${slug}_select`,\n }\n\n return acc\n },\n {} as Record<string, JSONSchema4>,\n )\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n }\n}\n\nfunction generateCollectionJoinsSchemas(collections: SanitizedCollectionConfig[]): JSONSchema4 {\n const properties = [...collections].reduce<Record<string, JSONSchema4>>(\n (acc, { slug, joins, polymorphicJoins }) => {\n const schema = {\n type: 'object',\n additionalProperties: false,\n properties: {},\n required: [] as string[],\n } satisfies JSONSchema4\n\n for (const collectionSlug in joins) {\n for (const join of joins[collectionSlug]!) {\n ;(schema.properties as any)[join.joinPath] = {\n type: 'string',\n enum: [collectionSlug],\n }\n schema.required.push(join.joinPath)\n }\n }\n\n for (const join of polymorphicJoins) {\n ;(schema.properties as any)[join.joinPath] = {\n type: 'string',\n enum: join.field.collection,\n }\n schema.required.push(join.joinPath)\n }\n\n if (Object.keys(schema.properties).length > 0) {\n acc[slug] = schema\n }\n\n return acc\n },\n {},\n )\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n }\n}\n\nconst widgetWidths = ['x-small', 'small', 'medium', 'large', 'x-large', 'full'] as const\n\nfunction getAllowedWidgetWidths({\n maxWidth,\n minWidth,\n}: {\n maxWidth?: (typeof widgetWidths)[number]\n minWidth?: (typeof widgetWidths)[number]\n}): string[] {\n const minIndex = minWidth ? widgetWidths.indexOf(minWidth) : 0\n const maxIndex = maxWidth ? widgetWidths.indexOf(maxWidth) : widgetWidths.length - 1\n\n if (minIndex === -1 || maxIndex === -1 || minIndex > maxIndex) {\n return [...widgetWidths]\n }\n\n return widgetWidths.slice(minIndex, maxIndex + 1)\n}\n\nfunction generateWidgetSchemas({\n collectionIDFieldTypes,\n config,\n i18n,\n interfaceNameDefinitions,\n opts = {},\n}: {\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' }\n config: SanitizedConfig\n i18n?: I18n\n interfaceNameDefinitions: Map<string, JSONSchema4>\n opts?: ConfigToJSONSchemaOptions\n}): {\n definitions: Record<string, JSONSchema4>\n schema: JSONSchema4\n} {\n const widgets = config.admin?.dashboard?.widgets ?? []\n const definitions: Record<string, JSONSchema4> = {}\n const properties: Record<string, JSONSchema4> = {}\n\n for (const widget of widgets) {\n const definition = `${widget.slug}_widget`\n const widthEnum = getAllowedWidgetWidths({\n maxWidth: widget.maxWidth,\n minWidth: widget.minWidth,\n })\n let dataSchema: JSONSchema4\n\n if (widget.fields?.length) {\n const widgetFieldSchemas = fieldsToJSONSchema(\n collectionIDFieldTypes,\n flattenAllFields({ fields: widget.fields }),\n interfaceNameDefinitions,\n config,\n i18n,\n opts,\n )\n\n dataSchema = {\n type: 'object',\n additionalProperties: false,\n ...widgetFieldSchemas,\n }\n } else {\n dataSchema = {\n type: 'object',\n additionalProperties: true,\n }\n }\n\n definitions[definition] = {\n type: 'object',\n additionalProperties: false,\n properties: {\n data: dataSchema,\n width: {\n type: 'string',\n enum: widthEnum,\n },\n },\n required: ['width'],\n }\n\n properties[widget.slug] = {\n $ref: `#/definitions/${definition}`,\n }\n }\n\n return {\n definitions,\n schema: {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n },\n }\n}\n\nfunction generateLocaleEntitySchemas(localization: SanitizedConfig['localization']): JSONSchema4 {\n if (localization && 'locales' in localization && localization?.locales) {\n const localesFromConfig = localization?.locales\n\n const locales = [...localesFromConfig].map((locale) => {\n return locale.code\n }, [])\n\n return {\n type: 'string',\n enum: locales,\n }\n }\n\n return {\n type: 'null',\n }\n}\n\nfunction generateFallbackLocaleEntitySchemas(\n localization: SanitizedConfig['localization'],\n): JSONSchema4 {\n if (localization && 'localeCodes' in localization && localization?.localeCodes) {\n const localeCodes = [...localization.localeCodes].map((localeCode) => {\n return localeCode\n }, [])\n\n return {\n oneOf: [\n { type: 'string', enum: ['false', 'none', 'null'] },\n { type: 'boolean', enum: [false] },\n { type: 'null' },\n { type: 'string', enum: localeCodes },\n { type: 'array', items: { type: 'string', enum: localeCodes } },\n ],\n }\n }\n\n return {\n type: 'null',\n }\n}\n\nfunction generateAuthEntitySchemas(entities: SanitizedCollectionConfig[]): JSONSchema4 {\n const properties: JSONSchema4[] = [...entities]\n .filter(({ auth }) => Boolean(auth))\n .map(({ slug }) => {\n return { $ref: `#/definitions/${slug}` }\n }, {})\n\n return {\n oneOf: properties,\n }\n}\n\n/**\n * Generates the JSON Schema for database configuration\n *\n * @example { db: idType: string }\n */\nfunction generateDbEntitySchema(config: SanitizedConfig): JSONSchema4 {\n const defaultIDType: JSONSchema4 =\n config.db?.defaultIDType === 'number' ? { type: 'number' } : { type: 'string' }\n\n return {\n type: 'object',\n additionalProperties: false,\n properties: {\n defaultIDType,\n },\n required: ['defaultIDType'],\n }\n}\n\n/**\n * Returns a JSON Schema Type with 'null' added if the field is not required.\n */\nexport function withNullableJSONSchemaType(\n fieldType: JSONSchema4TypeName,\n isRequired: boolean,\n): JSONSchema4TypeName | JSONSchema4TypeName[] {\n const fieldTypes = [fieldType]\n if (isRequired) {\n return fieldType\n }\n fieldTypes.push('null')\n return fieldTypes\n}\n\nfunction entityOrFieldToJsDocs({\n entity,\n i18n,\n}: {\n entity: FlattenedField | SanitizedCollectionConfig | SanitizedGlobalConfig\n i18n?: I18n\n}): string | undefined {\n let description: string | undefined = undefined\n if (entity?.admin?.description) {\n if (typeof entity?.admin?.description === 'string') {\n description = entity?.admin?.description\n } else if (typeof entity?.admin?.description === 'object') {\n if (entity?.admin?.description?.en) {\n description = entity?.admin?.description?.en\n } else if (entity?.admin?.description?.[i18n!.language]) {\n description = entity?.admin?.description?.[i18n!.language]\n }\n } else if (typeof entity?.admin?.description === 'function' && i18n) {\n // do not evaluate description functions for generating JSDocs. The output of\n // those can differ depending on where and when they are called, creating\n // inconsistencies in the generated JSDocs.\n }\n }\n return description\n}\n\ntype ConfigToJSONSchemaOptions = {\n forceInlineBlocks?: boolean\n}\n\nexport function fieldsToJSONSchema(\n /**\n * Used for relationship fields, to determine whether to use a string or number type for the ID.\n * While there is a default ID field type set by the db adapter, they can differ on a collection-level\n * if they have custom ID fields.\n */\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' },\n fields: FlattenedField[],\n /**\n * Allows you to define new top-level interfaces that can be re-used in the output schema.\n */\n interfaceNameDefinitions: Map<string, JSONSchema4>,\n config?: SanitizedConfig,\n i18n?: I18n,\n opts: ConfigToJSONSchemaOptions = {},\n): {\n properties: {\n [k: string]: JSONSchema4\n }\n required: string[]\n} {\n const requiredFieldNames = new Set<string>()\n\n return {\n properties: Object.fromEntries(\n fields.reduce((fieldSchemas, field, index) => {\n const isRequired = fieldAffectsData(field) && fieldIsRequired(field)\n\n const fieldDescription = entityOrFieldToJsDocs({ entity: field, i18n })\n const baseFieldSchema: JSONSchema4 = {}\n if (fieldDescription) {\n baseFieldSchema.description = fieldDescription\n }\n\n let fieldSchema: JSONSchema4\n\n switch (field.type) {\n case 'array': {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'object',\n additionalProperties: false,\n ...fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.flattenedFields,\n interfaceNameDefinitions,\n config,\n i18n,\n opts,\n ),\n },\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = {\n $ref: `#/definitions/${field.interfaceName}`,\n }\n }\n break\n }\n case 'blocks': {\n // Check for a case where no blocks are provided.\n // We need to generate an empty array for this case, note that JSON schema 4 doesn't support empty arrays\n // so the best we can get is `unknown[]`\n const hasBlocks = Boolean(\n field.blockReferences ? field.blockReferences.length : field.blocks.length,\n )\n\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: hasBlocks\n ? {\n oneOf: (field.blockReferences ?? field.blocks).map((block) => {\n if (typeof block === 'string') {\n const resolvedBlock = config?.blocks?.find((b) => b.slug === block)\n\n if (!resolvedBlock) {\n return {}\n }\n\n if (!opts.forceInlineBlocks) {\n return {\n $ref: `#/definitions/${resolvedBlock.interfaceName ?? resolvedBlock.slug}`,\n }\n }\n\n block = resolvedBlock\n }\n const blockFieldSchemas = fieldsToJSONSchema(\n collectionIDFieldTypes,\n block.flattenedFields,\n interfaceNameDefinitions,\n config,\n i18n,\n opts,\n )\n\n const blockSchema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n properties: {\n ...blockFieldSchemas.properties,\n blockType: {\n const: block.slug,\n },\n },\n required: ['blockType', ...blockFieldSchemas.required],\n }\n\n if (!opts.forceInlineBlocks && block.interfaceName) {\n interfaceNameDefinitions.set(block.interfaceName, blockSchema)\n\n return {\n $ref: `#/definitions/${block.interfaceName}`,\n }\n }\n\n return blockSchema\n }),\n }\n : {},\n }\n break\n }\n case 'checkbox': {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('boolean', isRequired),\n }\n break\n }\n case 'code':\n case 'date':\n case 'email':\n case 'textarea': {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('string', isRequired),\n }\n break\n }\n\n case 'group': {\n if (fieldAffectsData(field)) {\n fieldSchema = {\n ...baseFieldSchema,\n type: 'object',\n additionalProperties: false,\n ...fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.flattenedFields,\n interfaceNameDefinitions,\n config,\n i18n,\n opts,\n ),\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = { $ref: `#/definitions/${field.interfaceName}` }\n }\n }\n break\n }\n\n case 'join': {\n let items: JSONSchema4\n\n if (Array.isArray(field.collection)) {\n items = {\n oneOf: field.collection.map((collection) => ({\n type: 'object',\n additionalProperties: false,\n properties: {\n relationTo: {\n const: collection,\n },\n value: {\n oneOf: [\n {\n type: collectionIDFieldTypes[collection],\n },\n {\n $ref: `#/definitions/${collection}`,\n },\n ],\n },\n },\n required: ['collectionSlug', 'value'],\n })),\n }\n } else {\n items = {\n oneOf: [\n {\n type: collectionIDFieldTypes[field.collection],\n },\n {\n $ref: `#/definitions/${field.collection}`,\n },\n ],\n }\n }\n\n fieldSchema = {\n ...baseFieldSchema,\n type: 'object',\n additionalProperties: false,\n properties: {\n docs: {\n type: 'array',\n items,\n },\n hasNextPage: { type: 'boolean' },\n totalDocs: { type: 'number' },\n },\n }\n break\n }\n\n case 'json': {\n fieldSchema = field.jsonSchema?.schema || {\n ...baseFieldSchema,\n type: ['object', 'array', 'string', 'number', 'boolean', 'null'],\n }\n break\n }\n\n case 'number': {\n if (field.hasMany === true) {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: { type: 'number' },\n }\n } else {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('number', isRequired),\n }\n }\n break\n }\n\n case 'point': {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: [\n {\n type: 'number',\n },\n {\n type: 'number',\n },\n ],\n maxItems: 2,\n minItems: 2,\n }\n break\n }\n\n case 'radio': {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('string', isRequired),\n enum: buildOptionEnums(field.options),\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = {\n $ref: `#/definitions/${field.interfaceName}`,\n }\n }\n\n break\n }\n case 'relationship':\n case 'upload': {\n if (Array.isArray(field.relationTo)) {\n if (field.hasMany) {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n oneOf: field.relationTo.map((relation) => {\n return {\n type: 'object',\n additionalProperties: false,\n properties: {\n relationTo: {\n const: relation,\n },\n value: {\n oneOf: [\n {\n type: collectionIDFieldTypes[relation],\n },\n {\n $ref: `#/definitions/${relation}`,\n },\n ],\n },\n },\n required: ['value', 'relationTo'],\n }\n }),\n },\n }\n } else {\n fieldSchema = {\n ...baseFieldSchema,\n oneOf: field.relationTo.map((relation) => {\n return {\n type: withNullableJSONSchemaType('object', isRequired),\n additionalProperties: false,\n properties: {\n relationTo: {\n const: relation,\n },\n value: {\n oneOf: [\n {\n type: collectionIDFieldTypes[relation],\n },\n {\n $ref: `#/definitions/${relation}`,\n },\n ],\n },\n },\n required: ['value', 'relationTo'],\n }\n }),\n }\n }\n } else if (field.hasMany) {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n oneOf: [\n {\n type: collectionIDFieldTypes[field.relationTo],\n },\n {\n $ref: `#/definitions/${field.relationTo}`,\n },\n ],\n },\n }\n } else {\n fieldSchema = {\n ...baseFieldSchema,\n oneOf: [\n {\n type: withNullableJSONSchemaType(\n collectionIDFieldTypes[field.relationTo]!,\n isRequired,\n ),\n },\n { $ref: `#/definitions/${field.relationTo}` },\n ],\n }\n }\n\n break\n }\n case 'richText': {\n if (!field?.editor) {\n throw new MissingEditorProp(field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n if (typeof field.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n if (field.editor.outputSchema) {\n fieldSchema = {\n ...baseFieldSchema,\n ...field.editor.outputSchema({\n collectionIDFieldTypes,\n config,\n field,\n i18n,\n interfaceNameDefinitions,\n isRequired,\n }),\n }\n } else {\n // Maintain backwards compatibility with existing rich text editors\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'object',\n },\n }\n }\n\n break\n }\n\n case 'select': {\n const optionEnums = buildOptionEnums(field.options)\n // We get the previous field to check for a date in the case of a timezone select\n // This works because timezone selects are always inserted right after a date with 'timezone: true'\n const previousField = fields?.[index - 1]\n const isTimezoneField =\n previousField?.type === 'date' && previousField.timezone && field.name.includes('_tz')\n\n // Check if the timezone field's options match the global config's supported timezones\n const hasMatchingGlobalTimezones =\n isTimezoneField &&\n config &&\n optionsAreEqual(field.options, config.admin?.timezones?.supportedTimezones)\n\n // Timezone selects should reference the supportedTimezones definition\n // only if the field's options match the global config\n if (isTimezoneField && hasMatchingGlobalTimezones) {\n fieldSchema = {\n $ref: `#/definitions/supportedTimezones`,\n }\n } else {\n if (field.hasMany) {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'string',\n },\n }\n if (optionEnums?.length) {\n ;(fieldSchema.items as JSONSchema4).enum = optionEnums\n }\n } else {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('string', isRequired),\n }\n if (optionEnums?.length) {\n fieldSchema.enum = optionEnums\n }\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = {\n $ref: `#/definitions/${field.interfaceName}`,\n }\n }\n break\n }\n\n break\n }\n case 'tab': {\n fieldSchema = {\n ...baseFieldSchema,\n type: 'object',\n additionalProperties: false,\n ...fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.flattenedFields,\n interfaceNameDefinitions,\n config,\n i18n,\n opts,\n ),\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = { $ref: `#/definitions/${field.interfaceName}` }\n }\n break\n }\n\n case 'text':\n if (field.hasMany === true) {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: { type: 'string' },\n }\n } else {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('string', isRequired),\n }\n }\n break\n\n default: {\n break\n }\n }\n\n if ('typescriptSchema' in field && field?.typescriptSchema?.length) {\n for (const schema of field.typescriptSchema) {\n fieldSchema = schema({ jsonSchema: fieldSchema! })\n }\n }\n\n if (fieldSchema! && fieldAffectsData(field)) {\n if (isRequired && fieldSchema.required !== false) {\n requiredFieldNames.add(field.name)\n }\n fieldSchemas.set(field.name, fieldSchema)\n }\n\n return fieldSchemas\n }, new Map<string, JSONSchema4>()),\n ),\n required: Array.from(requiredFieldNames),\n }\n}\n\n// This function is part of the public API and is exported through payload/utilities\nexport function entityToJSONSchema(\n config: SanitizedConfig,\n entity: SanitizedCollectionConfig | SanitizedGlobalConfig,\n interfaceNameDefinitions: Map<string, JSONSchema4>,\n defaultIDType: 'number' | 'text',\n collectionIDFieldTypes?: { [key: string]: 'number' | 'string' },\n i18n?: I18n,\n opts: ConfigToJSONSchemaOptions = {},\n): JSONSchema4 {\n if (!collectionIDFieldTypes) {\n collectionIDFieldTypes = getCollectionIDFieldTypes({ config, defaultIDType })\n }\n\n const title = entity.typescript?.interface\n ? entity.typescript.interface\n : formatNames(entity.slug).singular\n\n let mutableFields = [...entity.flattenedFields]\n\n const idField: FieldAffectingData = { name: 'id', type: defaultIDType as 'text', required: true }\n const customIdField = mutableFields.find((field) => field.name === 'id') as FieldAffectingData\n\n if (customIdField && customIdField.type !== 'group' && customIdField.type !== 'tab') {\n mutableFields = mutableFields.map((field) => {\n if (field === customIdField) {\n return { ...field, required: true }\n }\n\n return field\n })\n } else {\n mutableFields.unshift(idField)\n }\n\n // mark timestamp fields required\n if ('timestamps' in entity && entity.timestamps !== false) {\n mutableFields = mutableFields.map((field) => {\n if (field.name === 'createdAt' || field.name === 'updatedAt') {\n return {\n ...field,\n required: true,\n }\n }\n return field\n })\n }\n\n if (\n 'auth' in entity &&\n entity.auth &&\n (!entity.auth?.disableLocalStrategy ||\n (typeof entity.auth?.disableLocalStrategy === 'object' &&\n entity.auth.disableLocalStrategy.enableFields))\n ) {\n mutableFields.push({\n name: 'password',\n type: 'text',\n })\n }\n\n const isAuthCollection = 'auth' in entity && entity.auth\n\n const fieldsSchema = fieldsToJSONSchema(\n collectionIDFieldTypes,\n mutableFields,\n interfaceNameDefinitions,\n config,\n i18n,\n opts,\n )\n\n // Add collection property to auth collections\n if (isAuthCollection) {\n fieldsSchema.properties = {\n ...fieldsSchema.properties,\n collection: { type: 'string', enum: [entity.slug] },\n }\n fieldsSchema.required = [...(fieldsSchema.required || []), 'collection']\n }\n\n const jsonSchema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n title,\n ...fieldsSchema,\n }\n\n const entityDescription = entityOrFieldToJsDocs({ entity, i18n })\n\n if (entityDescription) {\n jsonSchema.description = entityDescription\n }\n\n return jsonSchema\n}\n\nexport function fieldsToSelectJSONSchema({\n config,\n fields,\n interfaceNameDefinitions,\n}: {\n config: SanitizedConfig\n fields: FlattenedField[]\n interfaceNameDefinitions: Map<string, JSONSchema4>\n}): JSONSchema4 {\n const schema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n properties: {},\n }\n\n for (const field of fields) {\n switch (field.type) {\n case 'array':\n case 'group':\n case 'tab': {\n let fieldSchema: JSONSchema4 = fieldsToSelectJSONSchema({\n config,\n fields: field.flattenedFields,\n interfaceNameDefinitions,\n })\n\n if (field.interfaceName) {\n const definition = `${field.interfaceName}_select`\n interfaceNameDefinitions.set(definition, fieldSchema)\n\n fieldSchema = {\n $ref: `#/definitions/${definition}`,\n }\n }\n\n schema.properties![field.name] = {\n oneOf: [\n {\n type: 'boolean',\n },\n fieldSchema,\n ],\n }\n\n break\n }\n\n case 'blocks': {\n const blocksSchema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n properties: {},\n }\n\n for (const block of field.blockReferences ?? field.blocks) {\n if (typeof block === 'string') {\n continue // TODO\n }\n\n let blockSchema = fieldsToSelectJSONSchema({\n config,\n fields: block.flattenedFields,\n interfaceNameDefinitions,\n })\n\n if (block.interfaceName) {\n const definition = `${block.interfaceName}_select`\n interfaceNameDefinitions.set(definition, blockSchema)\n blockSchema = {\n $ref: `#/definitions/${definition}`,\n }\n }\n\n blocksSchema.properties![block.slug] = {\n oneOf: [\n {\n type: 'boolean',\n },\n blockSchema,\n ],\n }\n }\n\n schema.properties![field.name] = {\n oneOf: [\n {\n type: 'boolean',\n },\n blocksSchema,\n ],\n }\n\n break\n }\n\n default:\n schema.properties![field.name] = {\n type: 'boolean',\n }\n break\n }\n }\n\n return schema\n}\n\nconst fieldType: JSONSchema4 = {\n type: 'string',\n required: false,\n}\nconst generateAuthFieldTypes = ({\n type,\n loginWithUsername,\n}: {\n loginWithUsername: Auth['loginWithUsername']\n type: 'forgotOrUnlock' | 'login' | 'register'\n}): JSONSchema4 => {\n if (loginWithUsername) {\n switch (type) {\n case 'forgotOrUnlock': {\n if (loginWithUsername.allowEmailLogin) {\n // allow email or username for unlock/forgot-password\n return {\n additionalProperties: false,\n oneOf: [\n {\n additionalProperties: false,\n properties: { email: fieldType },\n required: ['email'],\n },\n {\n additionalProperties: false,\n properties: { username: fieldType },\n required: ['username'],\n },\n ],\n }\n } else {\n // allow only username for unlock/forgot-password\n return {\n additionalProperties: false,\n properties: { username: fieldType },\n required: ['username'],\n }\n }\n }\n\n case 'login': {\n if (loginWithUsername.allowEmailLogin) {\n // allow username or email and require password for login\n return {\n additionalProperties: false,\n oneOf: [\n {\n additionalProperties: false,\n properties: { email: fieldType, password: fieldType },\n required: ['email', 'password'],\n },\n {\n additionalProperties: false,\n properties: { password: fieldType, username: fieldType },\n required: ['username', 'password'],\n },\n ],\n }\n } else {\n // allow only username and password for login\n return {\n additionalProperties: false,\n properties: {\n password: fieldType,\n username: fieldType,\n },\n required: ['username', 'password'],\n }\n }\n }\n\n case 'register': {\n const requiredFields: ('email' | 'password' | 'username')[] = ['password']\n const properties: {\n email?: JSONSchema4['properties']\n password?: JSONSchema4['properties']\n username?: JSONSchema4['properties']\n } = {\n password: fieldType,\n username: fieldType,\n }\n\n if (loginWithUsername.requireEmail) {\n requiredFields.push('email')\n }\n if (loginWithUsername.requireUsername) {\n requiredFields.push('username')\n }\n if (loginWithUsername.requireEmail || loginWithUsername.allowEmailLogin) {\n properties.email = fieldType\n }\n\n return {\n additionalProperties: false,\n properties,\n required: requiredFields,\n }\n }\n }\n }\n\n // default email (and password for login/register)\n return {\n additionalProperties: false,\n properties: { email: fieldType, password: fieldType },\n required: ['email', 'password'],\n }\n}\n\nexport function authCollectionToOperationsJSONSchema(\n config: SanitizedCollectionConfig,\n): JSONSchema4 {\n const loginWithUsername = config.auth?.loginWithUsername\n const loginUserFields: JSONSchema4 = generateAuthFieldTypes({ type: 'login', loginWithUsername })\n const forgotOrUnlockUserFields: JSONSchema4 = generateAuthFieldTypes({\n type: 'forgotOrUnlock',\n loginWithUsername,\n })\n const registerUserFields: JSONSchema4 = generateAuthFieldTypes({\n type: 'register',\n loginWithUsername,\n })\n\n const properties: JSONSchema4['properties'] = {\n forgotPassword: forgotOrUnlockUserFields,\n login: loginUserFields,\n registerFirstUser: registerUserFields,\n unlock: forgotOrUnlockUserFields,\n }\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n title: `${formatNames(config.slug).singular}AuthOperations`,\n }\n}\n\n// Generates the JSON Schema for supported timezones\nexport function timezonesToJSONSchema(\n supportedTimezones: SanitizedConfig['admin']['timezones']['supportedTimezones'],\n): JSONSchema4 {\n return {\n description: 'Supported timezones in IANA format.',\n enum: supportedTimezones.map((timezone) =>\n typeof timezone === 'string' ? timezone : timezone.value,\n ),\n }\n}\n\nfunction generateAuthOperationSchemas(collections: SanitizedCollectionConfig[]): JSONSchema4 {\n const properties = collections.reduce(\n (acc, collection) => {\n if (collection.auth) {\n acc[collection.slug] = {\n $ref: `#/definitions/auth/${collection.slug}`,\n }\n }\n return acc\n },\n {} as Record<string, JSONSchema4>,\n )\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n }\n}\n\n/**\n * This is used for generating the TypeScript types (payload-types.ts) with the payload generate:types command.\n */\nexport function configToJSONSchema(\n config: SanitizedConfig,\n defaultIDType?: 'number' | 'text',\n i18n?: I18n,\n opts: ConfigToJSONSchemaOptions = {},\n): JSONSchema4 {\n // a mutable Map to store custom top-level `interfaceName` types. Fields with an `interfaceName` property will be moved to the top-level definitions here\n const interfaceNameDefinitions: Map<string, JSONSchema4> = new Map()\n\n // Used for relationship fields, to determine whether to use a string or number type for the ID.\n const collectionIDFieldTypes = getCollectionIDFieldTypes({\n config,\n defaultIDType: defaultIDType!,\n })\n\n // Collections and Globals have to be moved to the top-level definitions as well. Reason: The top-level type will be the `Config` type - we don't want all collection and global\n // types to be inlined inside the `Config` type\n\n const entities: {\n entity: SanitizedCollectionConfig | SanitizedGlobalConfig\n type: 'collection' | 'global'\n }[] = [\n ...config.globals.map((global) => ({ type: 'global' as const, entity: global })),\n ...config.collections.map((collection) => ({\n type: 'collection' as const,\n entity: collection,\n })),\n ]\n\n const entityDefinitions: { [k: string]: JSONSchema4 } = entities.reduce(\n (acc, { type, entity }) => {\n acc[entity.slug] = entityToJSONSchema(\n config,\n entity,\n interfaceNameDefinitions,\n defaultIDType!,\n collectionIDFieldTypes,\n i18n,\n opts,\n )\n const select = fieldsToSelectJSONSchema({\n config,\n fields: entity.flattenedFields,\n interfaceNameDefinitions,\n })\n\n if (type === 'global') {\n select.properties!.globalType = {\n type: 'boolean',\n }\n }\n\n acc[`${entity.slug}_select`] = {\n type: 'object',\n additionalProperties: false,\n ...select,\n }\n\n return acc\n },\n {} as Record<string, JSONSchema4>,\n )\n\n const timezoneDefinitions = timezonesToJSONSchema(config.admin.timezones.supportedTimezones)\n const widgetSchemas = generateWidgetSchemas({\n collectionIDFieldTypes,\n config,\n i18n,\n interfaceNameDefinitions,\n opts,\n })\n\n const authOperationDefinitions = [...config.collections]\n .filter(({ auth }) => Boolean(auth))\n .reduce(\n (acc, authCollection) => {\n acc.auth[authCollection.slug] = authCollectionToOperationsJSONSchema(authCollection)\n return acc\n },\n { auth: {} as Record<string, JSONSchema4> },\n )\n\n const jobsSchemas = config.jobs\n ? generateJobsJSONSchemas(\n config,\n config.jobs,\n interfaceNameDefinitions,\n collectionIDFieldTypes,\n i18n,\n )\n : {}\n\n const blocksDefinition: JSONSchema4 | undefined = {\n type: 'object',\n additionalProperties: false,\n properties: {},\n required: [],\n }\n if (config?.blocks?.length) {\n for (const block of config.blocks) {\n const blockFieldSchemas = fieldsToJSONSchema(\n collectionIDFieldTypes,\n block.flattenedFields,\n interfaceNameDefinitions,\n config,\n i18n,\n opts,\n )\n\n const blockSchema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n properties: {\n ...blockFieldSchemas.properties,\n blockType: {\n const: block.slug,\n },\n },\n required: ['blockType', ...blockFieldSchemas.required],\n }\n\n const interfaceName = block.interfaceName ?? block.slug\n interfaceNameDefinitions.set(interfaceName, blockSchema)\n\n blocksDefinition.properties![block.slug] = {\n $ref: `#/definitions/${interfaceName}`,\n }\n ;(blocksDefinition.required as string[]).push(block.slug)\n }\n }\n\n let jsonSchema: JSONSchema4 = {\n additionalProperties: false,\n definitions: {\n supportedTimezones: timezoneDefinitions,\n ...entityDefinitions,\n ...widgetSchemas.definitions,\n ...Object.fromEntries(interfaceNameDefinitions),\n ...authOperationDefinitions,\n },\n // These properties here will be very simple, as all the complexity is in the definitions. These are just the properties for the top-level `Config` type\n type: 'object',\n properties: {\n auth: generateAuthOperationSchemas(config.collections),\n blocks: blocksDefinition,\n collections: generateEntitySchemas(config.collections || []),\n collectionsJoins: generateCollectionJoinsSchemas(config.collections || []),\n collectionsSelect: generateEntitySelectSchemas(config.collections || []),\n db: generateDbEntitySchema(config),\n fallbackLocale: generateFallbackLocaleEntitySchemas(config.localization),\n globals: generateEntitySchemas(config.globals || []),\n globalsSelect: generateEntitySelectSchemas(config.globals || []),\n locale: generateLocaleEntitySchemas(config.localization),\n widgets: widgetSchemas.schema,\n ...(config.typescript?.strictDraftTypes\n ? {\n strictDraftTypes: {\n type: 'boolean',\n const: true,\n },\n }\n : {}),\n user: generateAuthEntitySchemas(config.collections),\n },\n required: [\n 'user',\n 'locale',\n 'fallbackLocale',\n 'collections',\n 'collectionsSelect',\n 'collectionsJoins',\n 'globalsSelect',\n ...(config.typescript?.strictDraftTypes ? ['strictDraftTypes'] : []),\n 'globals',\n 'auth',\n 'db',\n 'jobs',\n 'blocks',\n 'widgets',\n ],\n title: 'Config',\n }\n\n if (jobsSchemas.definitions?.size) {\n for (const [key, value] of jobsSchemas.definitions) {\n jsonSchema.definitions![key] = value\n }\n }\n if (jobsSchemas.properties) {\n jsonSchema.properties!.jobs = {\n type: 'object',\n additionalProperties: false,\n properties: jobsSchemas.properties,\n required: ['tasks', 'workflows'],\n }\n }\n\n if (config?.typescript?.schema?.length) {\n for (const schema of config.typescript.schema) {\n jsonSchema = schema({ collectionIDFieldTypes, config, i18n: i18n!, jsonSchema })\n }\n }\n\n return jsonSchema\n}\n"],"names":["MissingEditorProp","fieldAffectsData","generateJobsJSONSchemas","flattenAllFields","formatNames","getCollectionIDFieldTypes","optionsAreEqual","fieldIsRequired","field","isConditional","Boolean","admin","condition","isMarkedRequired","required","type","flattenedFields","some","subField","buildOptionEnums","options","map","option","value","generateEntitySchemas","entities","properties","reduce","acc","slug","$ref","additionalProperties","Object","keys","generateEntitySelectSchemas","generateCollectionJoinsSchemas","collections","joins","polymorphicJoins","schema","collectionSlug","join","joinPath","enum","push","collection","length","widgetWidths","getAllowedWidgetWidths","maxWidth","minWidth","minIndex","indexOf","maxIndex","slice","generateWidgetSchemas","collectionIDFieldTypes","config","i18n","interfaceNameDefinitions","opts","widgets","dashboard","definitions","widget","definition","widthEnum","dataSchema","fields","widgetFieldSchemas","fieldsToJSONSchema","data","width","generateLocaleEntitySchemas","localization","locales","localesFromConfig","locale","code","generateFallbackLocaleEntitySchemas","localeCodes","localeCode","oneOf","items","generateAuthEntitySchemas","filter","auth","generateDbEntitySchema","defaultIDType","db","withNullableJSONSchemaType","fieldType","isRequired","fieldTypes","entityOrFieldToJsDocs","entity","description","undefined","en","language","requiredFieldNames","Set","fromEntries","fieldSchemas","index","fieldDescription","baseFieldSchema","fieldSchema","interfaceName","set","hasBlocks","blockReferences","blocks","block","resolvedBlock","find","b","forceInlineBlocks","blockFieldSchemas","blockSchema","blockType","const","Array","isArray","relationTo","docs","hasNextPage","totalDocs","jsonSchema","hasMany","maxItems","minItems","relation","editor","Error","outputSchema","optionEnums","previousField","isTimezoneField","timezone","name","includes","hasMatchingGlobalTimezones","timezones","supportedTimezones","typescriptSchema","add","Map","from","entityToJSONSchema","title","typescript","interface","singular","mutableFields","idField","customIdField","unshift","timestamps","disableLocalStrategy","enableFields","isAuthCollection","fieldsSchema","entityDescription","fieldsToSelectJSONSchema","blocksSchema","generateAuthFieldTypes","loginWithUsername","allowEmailLogin","email","username","password","requiredFields","requireEmail","requireUsername","authCollectionToOperationsJSONSchema","loginUserFields","forgotOrUnlockUserFields","registerUserFields","forgotPassword","login","registerFirstUser","unlock","timezonesToJSONSchema","generateAuthOperationSchemas","configToJSONSchema","globals","global","entityDefinitions","select","globalType","timezoneDefinitions","widgetSchemas","authOperationDefinitions","authCollection","jobsSchemas","jobs","blocksDefinition","collectionsJoins","collectionsSelect","fallbackLocale","globalsSelect","strictDraftTypes","user","size","key"],"mappings":"AASA,SAASA,iBAAiB,QAAQ,iCAAgC;AAClE,SAASC,gBAAgB,QAAQ,4BAA2B;AAC5D,SAASC,uBAAuB,QAAQ,8CAA6C;AACrF,SAASC,gBAAgB,QAAQ,wBAAuB;AACxD,SAASC,WAAW,QAAQ,oBAAmB;AAC/C,SAASC,yBAAyB,QAAQ,iCAAgC;AAC1E,SAASC,eAAe,QAAQ,uBAAsB;AAEtD,MAAMC,kBAAkB,CAACC;IACvB,MAAMC,gBAAgBC,QAAQF,OAAOG,SAASH,OAAOG,OAAOC;IAC5D,IAAIH,eAAe;QACjB,OAAO;IACT;IAEA,MAAMI,mBAAmB,cAAcL,SAASA,MAAMM,QAAQ,KAAK;IACnE,IAAIb,iBAAiBO,UAAUK,kBAAkB;QAC/C,OAAO;IACT;IAEA,wDAAwD;IACxD,IAAI,YAAYL,SAASA,MAAMO,IAAI,KAAK,SAAS;QAC/C,OAAOP,MAAMQ,eAAe,CAACC,IAAI,CAAC,CAACC,WAAaX,gBAAgBW;IAClE;IAEA,OAAO;AACT;AAEA,SAASC,iBAAiBC,OAAiB;IACzC,OAAOA,QAAQC,GAAG,CAAC,CAACC;QAClB,IAAI,OAAOA,WAAW,YAAY,WAAWA,QAAQ;YACnD,OAAOA,OAAOC,KAAK;QACrB;QAEA,OAAOD;IACT;AACF;AAEA,SAASE,sBACPC,QAA+D;IAE/D,MAAMC,aAAa;WAAID;KAAS,CAACE,MAAM,CACrC,CAACC,KAAK,EAAEC,IAAI,EAAE;QACZD,GAAG,CAACC,KAAK,GAAG;YACVC,MAAM,CAAC,cAAc,EAAED,MAAM;QAC/B;QAEA,OAAOD;IACT,GACA,CAAC;IAGH,OAAO;QACLb,MAAM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chema
474
+ {
475
+ $ref: '#/definitions/SharedBlock'
476
+ }
475
477
  ]
476
478
  }
477
479
  }
@@ -512,6 +514,78 @@ describe('configToJSONSchema', ()=>{
512
514
  // @ts-expect-error
513
515
  expect(schema.definitions.test.properties.title.required).toStrictEqual(false);
514
516
  });
517
+ it('should propagate forceInlineBlocks to nested fields (array, group, tab)', async ()=>{
518
+ const namedBlock = {
519
+ slug: 'myBlock',
520
+ interfaceName: 'MyBlock',
521
+ fields: [
522
+ {
523
+ name: 'text',
524
+ type: 'text'
525
+ }
526
+ ]
527
+ };
528
+ // @ts-expect-error
529
+ const config = {
530
+ collections: [
531
+ {
532
+ slug: 'test',
533
+ fields: [
534
+ {
535
+ name: 'arr',
536
+ type: 'array',
537
+ fields: [
538
+ {
539
+ name: 'blocks',
540
+ type: 'blocks',
541
+ blocks: [
542
+ namedBlock
543
+ ]
544
+ }
545
+ ]
546
+ },
547
+ {
548
+ name: 'grp',
549
+ type: 'group',
550
+ fields: [
551
+ {
552
+ name: 'blocks',
553
+ type: 'blocks',
554
+ blocks: [
555
+ namedBlock
556
+ ]
557
+ }
558
+ ]
559
+ }
560
+ ],
561
+ timestamps: false
562
+ }
563
+ ]
564
+ };
565
+ const sanitizedConfig = await sanitizeConfig(config);
566
+ // Without forceInlineBlocks: blocks field uses $ref
567
+ const schemaDefault = configToJSONSchema(sanitizedConfig, 'text');
568
+ const arrItemsDefault = schemaDefault.definitions.test.properties.arr.items;
569
+ const arrBlocksDefault = arrItemsDefault.properties.blocks.items.oneOf[0];
570
+ expect(arrBlocksDefault).toStrictEqual({
571
+ $ref: '#/definitions/MyBlock'
572
+ });
573
+ // With forceInlineBlocks: blocks field is inlined, no $ref
574
+ const schemaInline = configToJSONSchema(sanitizedConfig, 'text', undefined, {
575
+ forceInlineBlocks: true
576
+ });
577
+ const arrItemsInline = schemaInline.definitions.test.properties.arr.items;
578
+ const arrBlocksInline = arrItemsInline.properties.blocks.items.oneOf[0];
579
+ expect(arrBlocksInline).not.toHaveProperty('$ref');
580
+ expect(arrBlocksInline.properties?.blockType).toStrictEqual({
581
+ const: 'myBlock'
582
+ });
583
+ const grpBlocksInline = schemaInline.definitions.test.properties.grp.properties.blocks.items.oneOf[0];
584
+ expect(grpBlocksInline).not.toHaveProperty('$ref');
585
+ expect(grpBlocksInline.properties?.blockType).toStrictEqual({
586
+ const: 'myBlock'
587
+ });
588
+ });
515
589
  });
516
590
 
517
591
  //# sourceMappingURL=configToJSONSchema.spec.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/configToJSONSchema.spec.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\nimport { describe, it, expect } from 'vitest'\n\nimport type { Config } from '../config/types.js'\n\nimport { sanitizeConfig } from '../config/sanitize.js'\nimport { configToJSONSchema } from './configToJSONSchema.js'\nimport type { Block, BlocksField, RichTextField } from '../fields/config/types.js'\n\ndescribe('configToJSONSchema', () => {\n it('should handle optional arrays with required fields', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'someRequiredField',\n type: 'array',\n fields: [\n {\n name: 'someRequiredField',\n type: 'text',\n required: true,\n },\n ],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.definitions?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n someRequiredField: {\n type: ['array', 'null'],\n items: {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: ['string', 'null'],\n },\n someRequiredField: {\n type: 'string',\n },\n },\n required: ['someRequiredField'],\n },\n },\n },\n required: ['id'],\n title: 'Test',\n })\n })\n\n it('should handle block fields with no blocks', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'blockField',\n type: 'blocks',\n blocks: [],\n },\n {\n name: 'blockFieldRequired',\n type: 'blocks',\n blocks: [],\n required: true,\n },\n {\n name: 'blockFieldWithFields',\n type: 'blocks',\n blocks: [\n {\n slug: 'test',\n fields: [\n {\n name: 'field',\n type: 'text',\n },\n ],\n },\n ],\n },\n {\n name: 'blockFieldWithFieldsRequired',\n type: 'blocks',\n blocks: [\n {\n slug: 'test',\n fields: [\n {\n name: 'field',\n type: 'text',\n required: true,\n },\n ],\n },\n ],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.definitions?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n blockField: {\n type: ['array', 'null'],\n items: {},\n },\n blockFieldRequired: {\n type: 'array',\n items: {},\n },\n blockFieldWithFields: {\n type: ['array', 'null'],\n items: {\n oneOf: [\n {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: ['string', 'null'],\n },\n blockName: {\n type: ['string', 'null'],\n },\n blockType: {\n const: 'test',\n },\n field: {\n type: ['string', 'null'],\n },\n },\n required: ['blockType'],\n },\n ],\n },\n },\n blockFieldWithFieldsRequired: {\n type: ['array', 'null'],\n items: {\n oneOf: [\n {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: ['string', 'null'],\n },\n blockName: {\n type: ['string', 'null'],\n },\n blockType: {\n const: 'test',\n },\n field: {\n type: 'string',\n },\n },\n required: ['blockType', 'field'],\n },\n ],\n },\n },\n },\n required: ['id', 'blockFieldRequired'],\n title: 'Test',\n })\n })\n\n it('should handle tabs and named tabs with required fields', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n type: 'tabs',\n tabs: [\n {\n fields: [\n {\n name: 'fieldInUnnamedTab',\n type: 'text',\n },\n ],\n label: 'unnamedTab',\n },\n {\n name: 'namedTab',\n fields: [\n {\n name: 'fieldInNamedTab',\n type: 'text',\n },\n ],\n label: 'namedTab',\n },\n {\n name: 'namedTabWithRequired',\n fields: [\n {\n name: 'fieldInNamedTab',\n type: 'text',\n required: true,\n },\n ],\n label: 'namedTabWithRequired',\n },\n ],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.definitions?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n fieldInUnnamedTab: {\n type: ['string', 'null'],\n },\n namedTab: {\n type: 'object',\n additionalProperties: false,\n properties: {\n fieldInNamedTab: {\n type: ['string', 'null'],\n },\n },\n required: [],\n },\n namedTabWithRequired: {\n type: 'object',\n additionalProperties: false,\n properties: {\n fieldInNamedTab: {\n type: 'string',\n },\n },\n required: ['fieldInNamedTab'],\n },\n },\n required: ['id', 'namedTabWithRequired'],\n title: 'Test',\n })\n })\n\n it('should handle custom typescript schema and JSON field schema', async () => {\n const customSchema: JSONSchema4 = {\n type: 'object',\n properties: {\n id: {\n type: 'number',\n },\n required: ['id'],\n },\n }\n\n const config: Partial<Config> = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'withCustom',\n type: 'text',\n typescriptSchema: [() => customSchema],\n },\n {\n name: 'jsonWithSchema',\n type: 'json',\n jsonSchema: {\n fileMatch: ['a://b/foo.json'],\n schema: customSchema,\n uri: 'a://b/foo.json',\n },\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config as Config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.definitions?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n jsonWithSchema: customSchema,\n withCustom: customSchema,\n },\n required: ['id'],\n title: 'Test',\n })\n })\n\n it('should handle same block object being referenced in both collection and config.blocks', async () => {\n const sharedBlock: Block = {\n slug: 'sharedBlock',\n interfaceName: 'SharedBlock',\n fields: [\n {\n name: 'richText',\n type: 'richText',\n editor: () => {\n // stub rich text editor\n return {\n CellComponent: '',\n FieldComponent: '',\n validate: () => true,\n }\n },\n },\n ],\n }\n\n // @ts-expect-error\n const config: Config = {\n blocks: [sharedBlock],\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'someBlockField',\n type: 'blocks',\n blocks: [sharedBlock],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n // Ensure both rich text editor are sanitized\n const sanitizedConfig = await sanitizeConfig(config)\n expect(typeof (sanitizedConfig?.blocks?.[0]?.fields?.[0] as RichTextField)?.editor).toBe(\n 'object',\n )\n expect(\n typeof (\n (sanitizedConfig.collections[0].fields[0] as BlocksField)?.blocks?.[0]\n ?.fields?.[0] as RichTextField\n )?.editor,\n ).toBe('object')\n\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n const expectedBlockSchema = {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: { type: ['string', 'null'] },\n blockName: { type: ['string', 'null'] },\n blockType: { const: 'sharedBlock' },\n richText: { type: ['array', 'null'], items: { type: 'object' } },\n },\n required: ['blockType'],\n }\n\n expect(schema?.definitions?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n title: 'Test',\n properties: {\n id: {\n type: 'string',\n },\n someBlockField: {\n type: ['array', 'null'],\n items: {\n oneOf: [expectedBlockSchema],\n },\n },\n },\n required: ['id'],\n })\n\n // The definition should still be registered for TypeScript type generation\n expect(schema?.definitions?.SharedBlock).toStrictEqual(expectedBlockSchema)\n })\n\n it('should allow overriding required to false', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'title',\n type: 'text',\n required: true,\n defaultValue: 'test',\n typescriptSchema: [\n () => ({\n type: 'string',\n required: false,\n }),\n ],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n // @ts-expect-error\n expect(schema.definitions.test.properties.title.required).toStrictEqual(false)\n })\n})\n"],"names":["describe","it","expect","sanitizeConfig","configToJSONSchema","config","collections","slug","fields","name","type","required","timestamps","sanitizedConfig","schema","definitions","test","toStrictEqual","additionalProperties","properties","id","someRequiredField","items","title","blocks","blockField","blockFieldRequired","blockFieldWithFields","oneOf","blockName","blockType","const","field","blockFieldWithFieldsRequired","tabs","label","fieldInUnnamedTab","namedTab","fieldInNamedTab","namedTabWithRequired","customSchema","typescriptSchema","jsonSchema","fileMatch","uri","jsonWithSchema","withCustom","sharedBlock","interfaceName","editor","CellComponent","FieldComponent","validate","toBe","expectedBlockSchema","richText","someBlockField","SharedBlock","defaultValue"],"mappings":"AACA,SAASA,QAAQ,EAAEC,EAAE,EAAEC,MAAM,QAAQ,SAAQ;AAI7C,SAASC,cAAc,QAAQ,wBAAuB;AACtD,SAASC,kBAAkB,QAAQ,0BAAyB;AAG5DJ,SAAS,sBAAsB;IAC7BC,GAAG,sDAAsD;QACvD,mBAAmB;QACnB,MAAMI,SAAiB;YACrBC,aAAa;gBACX;oBACEC,MAAM;oBACNC,QAAQ;wBACN;4BACEC,MAAM;4BACNC,MAAM;4BACNF,QAAQ;gCACN;oCACEC,MAAM;oCACNC,MAAM;oCACNC,UAAU;gCACZ;6BACD;wBACH;qBACD;oBACDC,YAAY;gBACd;aACD;QACH;QAEA,MAAMC,kBAAkB,MAAMV,eAAeE;QAC7C,MAAMS,SAASV,mBAAmBS,iBAAiB;QAEnDX,OAAOY,QAAQC,aAAaC,MAAMC,aAAa,CAAC;YAC9CP,MAAM;YACNQ,sBAAsB;YACtBC,YAAY;gBACVC,IAAI;oBACFV,MAAM;gBACR;gBACAW,mBAAmB;oBACjBX,MAAM;wBAAC;wBAAS;qBAAO;oBACvBY,OAAO;wBACLZ,MAAM;wBACNQ,sBAAsB;wBACtBC,YAAY;4BACVC,IAAI;gCACFV,MAAM;oCAAC;oCAAU;iCAAO;4BAC1B;4BACAW,mBAAmB;gCACjBX,MAAM;4BACR;wBACF;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BAAsB;YACtBK,OAAO;YACPJ,YAAY;gBACVC,IAAI;oBACFV,MAAM;gBACR;gBACA8C,gBAAgB;oBACd9C,MAAM;wBAAC;wBAAS;qBAAO;oBACvBY,OAAO;wBACLM,OAAO;4BAAC0B;yBAAoB;oBAC9B;gBACF;YACF;YACA3C,UAAU;gBAAC;aAAK;QAClB;QAEA,2EAA2E;QAC3ET,OAAOY,QAAQC,aAAa0C,aAAaxC,aAAa,CAACqC;IACzD;IAEArD,GAAG,6CAA6C;QAC9C,mBAAmB;QACnB,MAAMI,SAAiB;YACrBC,aAAa;gBACX;oBACEC,MAAM;oBACNC,QAAQ;wBACN;4BACEC,MAAM;4BACNC,MAAM;4BACNC,UAAU;4BACV+C,cAAc;4BACdjB,kBAAkB;gCAChB,IAAO,CAAA;wCACL/B,MAAM;wCACNC,UAAU;oCACZ,CAAA;6BACD;wBACH;qBACD;oBACDC,YAAY;gBACd;aACD;QACH;QAEA,MAAMC,kBAAkB,MAAMV,eAAeE;QAC7C,MAAMS,SAASV,mBAAmBS,iBAAiB;QAEnD,mBAAmB;QACnBX,OAAOY,OAAOC,WAAW,CAACC,IAAI,CAACG,UAAU,CAACI,KAAK,CAACZ,QAAQ,EAAEM,aAAa,CAAC;IAC1E;AACF"}
1
+ {"version":3,"sources":["../../src/utilities/configToJSONSchema.spec.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\nimport { describe, it, expect } from 'vitest'\n\nimport type { Config } from '../config/types.js'\n\nimport { sanitizeConfig } from '../config/sanitize.js'\nimport { configToJSONSchema } from './configToJSONSchema.js'\nimport type { Block, BlocksField, RichTextField } from '../fields/config/types.js'\n\ndescribe('configToJSONSchema', () => {\n it('should handle optional arrays with required fields', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'someRequiredField',\n type: 'array',\n fields: [\n {\n name: 'someRequiredField',\n type: 'text',\n required: true,\n },\n ],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.definitions?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n someRequiredField: {\n type: ['array', 'null'],\n items: {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: ['string', 'null'],\n },\n someRequiredField: {\n type: 'string',\n },\n },\n required: ['someRequiredField'],\n },\n },\n },\n required: ['id'],\n title: 'Test',\n })\n })\n\n it('should handle block fields with no blocks', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'blockField',\n type: 'blocks',\n blocks: [],\n },\n {\n name: 'blockFieldRequired',\n type: 'blocks',\n blocks: [],\n required: true,\n },\n {\n name: 'blockFieldWithFields',\n type: 'blocks',\n blocks: [\n {\n slug: 'test',\n fields: [\n {\n name: 'field',\n type: 'text',\n },\n ],\n },\n ],\n },\n {\n name: 'blockFieldWithFieldsRequired',\n type: 'blocks',\n blocks: [\n {\n slug: 'test',\n fields: [\n {\n name: 'field',\n type: 'text',\n required: true,\n },\n ],\n },\n ],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.definitions?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n blockField: {\n type: ['array', 'null'],\n items: {},\n },\n blockFieldRequired: {\n type: 'array',\n items: {},\n },\n blockFieldWithFields: {\n type: ['array', 'null'],\n items: {\n oneOf: [\n {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: ['string', 'null'],\n },\n blockName: {\n type: ['string', 'null'],\n },\n blockType: {\n const: 'test',\n },\n field: {\n type: ['string', 'null'],\n },\n },\n required: ['blockType'],\n },\n ],\n },\n },\n blockFieldWithFieldsRequired: {\n type: ['array', 'null'],\n items: {\n oneOf: [\n {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: ['string', 'null'],\n },\n blockName: {\n type: ['string', 'null'],\n },\n blockType: {\n const: 'test',\n },\n field: {\n type: 'string',\n },\n },\n required: ['blockType', 'field'],\n },\n ],\n },\n },\n },\n required: ['id', 'blockFieldRequired'],\n title: 'Test',\n })\n })\n\n it('should handle tabs and named tabs with required fields', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n type: 'tabs',\n tabs: [\n {\n fields: [\n {\n name: 'fieldInUnnamedTab',\n type: 'text',\n },\n ],\n label: 'unnamedTab',\n },\n {\n name: 'namedTab',\n fields: [\n {\n name: 'fieldInNamedTab',\n type: 'text',\n },\n ],\n label: 'namedTab',\n },\n {\n name: 'namedTabWithRequired',\n fields: [\n {\n name: 'fieldInNamedTab',\n type: 'text',\n required: true,\n },\n ],\n label: 'namedTabWithRequired',\n },\n ],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.definitions?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n fieldInUnnamedTab: {\n type: ['string', 'null'],\n },\n namedTab: {\n type: 'object',\n additionalProperties: false,\n properties: {\n fieldInNamedTab: {\n type: ['string', 'null'],\n },\n },\n required: [],\n },\n namedTabWithRequired: {\n type: 'object',\n additionalProperties: false,\n properties: {\n fieldInNamedTab: {\n type: 'string',\n },\n },\n required: ['fieldInNamedTab'],\n },\n },\n required: ['id', 'namedTabWithRequired'],\n title: 'Test',\n })\n })\n\n it('should handle custom typescript schema and JSON field schema', async () => {\n const customSchema: JSONSchema4 = {\n type: 'object',\n properties: {\n id: {\n type: 'number',\n },\n required: ['id'],\n },\n }\n\n const config: Partial<Config> = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'withCustom',\n type: 'text',\n typescriptSchema: [() => customSchema],\n },\n {\n name: 'jsonWithSchema',\n type: 'json',\n jsonSchema: {\n fileMatch: ['a://b/foo.json'],\n schema: customSchema,\n uri: 'a://b/foo.json',\n },\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config as Config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.definitions?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n jsonWithSchema: customSchema,\n withCustom: customSchema,\n },\n required: ['id'],\n title: 'Test',\n })\n })\n\n it('should handle same block object being referenced in both collection and config.blocks', async () => {\n const sharedBlock: Block = {\n slug: 'sharedBlock',\n interfaceName: 'SharedBlock',\n fields: [\n {\n name: 'richText',\n type: 'richText',\n editor: () => {\n // stub rich text editor\n return {\n CellComponent: '',\n FieldComponent: '',\n validate: () => true,\n }\n },\n },\n ],\n }\n\n // @ts-expect-error\n const config: Config = {\n blocks: [sharedBlock],\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'someBlockField',\n type: 'blocks',\n blocks: [sharedBlock],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n // Ensure both rich text editor are sanitized\n const sanitizedConfig = await sanitizeConfig(config)\n expect(typeof (sanitizedConfig?.blocks?.[0]?.fields?.[0] as RichTextField)?.editor).toBe(\n 'object',\n )\n expect(\n typeof (\n (sanitizedConfig.collections[0].fields[0] as BlocksField)?.blocks?.[0]\n ?.fields?.[0] as RichTextField\n )?.editor,\n ).toBe('object')\n\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n const expectedBlockSchema = {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: { type: ['string', 'null'] },\n blockName: { type: ['string', 'null'] },\n blockType: { const: 'sharedBlock' },\n richText: { type: ['array', 'null'], items: { type: 'object' } },\n },\n required: ['blockType'],\n }\n\n expect(schema?.definitions?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n title: 'Test',\n properties: {\n id: {\n type: 'string',\n },\n someBlockField: {\n type: ['array', 'null'],\n items: {\n oneOf: [\n {\n $ref: '#/definitions/SharedBlock',\n },\n ],\n },\n },\n },\n required: ['id'],\n })\n\n // The definition should still be registered for TypeScript type generation\n expect(schema?.definitions?.SharedBlock).toStrictEqual(expectedBlockSchema)\n })\n\n it('should allow overriding required to false', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'title',\n type: 'text',\n required: true,\n defaultValue: 'test',\n typescriptSchema: [\n () => ({\n type: 'string',\n required: false,\n }),\n ],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n // @ts-expect-error\n expect(schema.definitions.test.properties.title.required).toStrictEqual(false)\n })\n\n it('should propagate forceInlineBlocks to nested fields (array, group, tab)', async () => {\n const namedBlock: Block = {\n slug: 'myBlock',\n interfaceName: 'MyBlock',\n fields: [{ name: 'text', type: 'text' }],\n }\n\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'arr',\n type: 'array',\n fields: [{ name: 'blocks', type: 'blocks', blocks: [namedBlock] }],\n },\n {\n name: 'grp',\n type: 'group',\n fields: [{ name: 'blocks', type: 'blocks', blocks: [namedBlock] }],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n\n // Without forceInlineBlocks: blocks field uses $ref\n const schemaDefault = configToJSONSchema(sanitizedConfig, 'text')\n const arrItemsDefault = schemaDefault.definitions!.test.properties!.arr.items as JSONSchema4\n const arrBlocksDefault = (arrItemsDefault.properties!.blocks.items as JSONSchema4).oneOf![0]\n expect(arrBlocksDefault).toStrictEqual({ $ref: '#/definitions/MyBlock' })\n\n // With forceInlineBlocks: blocks field is inlined, no $ref\n const schemaInline = configToJSONSchema(sanitizedConfig, 'text', undefined, {\n forceInlineBlocks: true,\n })\n const arrItemsInline = schemaInline.definitions!.test.properties!.arr.items as JSONSchema4\n const arrBlocksInline = (arrItemsInline.properties!.blocks.items as JSONSchema4).oneOf![0]\n expect(arrBlocksInline).not.toHaveProperty('$ref')\n expect(arrBlocksInline.properties?.blockType).toStrictEqual({ const: 'myBlock' })\n\n const grpBlocksInline = (\n schemaInline.definitions!.test.properties!.grp.properties!.blocks.items as JSONSchema4\n ).oneOf![0]\n expect(grpBlocksInline).not.toHaveProperty('$ref')\n expect(grpBlocksInline.properties?.blockType).toStrictEqual({ const: 'myBlock' })\n })\n})\n"],"names":["describe","it","expect","sanitizeConfig","configToJSONSchema","config","collections","slug","fields","name","type","required","timestamps","sanitizedConfig","schema","definitions","test","toStrictEqual","additionalProperties","properties","id","someRequiredField","items","title","blocks","blockField","blockFieldRequired","blockFieldWithFields","oneOf","blockName","blockType","const","field","blockFieldWithFieldsRequired","tabs","label","fieldInUnnamedTab","namedTab","fieldInNamedTab","namedTabWithRequired","customSchema","typescriptSchema","jsonSchema","fileMatch","uri","jsonWithSchema","withCustom","sharedBlock","interfaceName","editor","CellComponent","FieldComponent","validate","toBe","expectedBlockSchema","richText","someBlockField","$ref","SharedBlock","defaultValue","namedBlock","schemaDefault","arrItemsDefault","arr","arrBlocksDefault","schemaInline","undefined","forceInlineBlocks","arrItemsInline","arrBlocksInline","not","toHaveProperty","grpBlocksInline","grp"],"mappings":"AACA,SAASA,QAAQ,EAAEC,EAAE,EAAEC,MAAM,QAAQ,SAAQ;AAI7C,SAASC,cAAc,QAAQ,wBAAuB;AACtD,SAASC,kBAAkB,QAAQ,0BAAyB;AAG5DJ,SAAS,sBAAsB;IAC7BC,GAAG,sDAAsD;QACvD,mBAAmB;QACnB,MAAMI,SAAiB;YACrBC,aAAa;gBACX;oBACEC,MAAM;oBACNC,QAAQ;wBACN;4BACEC,MAAM;4BACNC,MAAM;4BACNF,QAAQ;gCACN;oCACEC,MAAM;oCACNC,MAAM;oCACNC,UAAU;gCACZ;6BACD;wBACH;qBACD;o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,gBAAgBlD,UAAU,EAAEW,WAAWb,aAAa,CAAC;YAAEc,OAAO;QAAU;QAE/E,MAAMyC,kBAAkB,AACtBP,aAAalD,WAAW,CAAEC,IAAI,CAACG,UAAU,CAAEsD,GAAG,CAACtD,UAAU,CAAEK,MAAM,CAACF,KAAK,CACvEM,KAAK,AAAC,CAAC,EAAE;QACX1B,OAAOsE,iBAAiBF,GAAG,CAACC,cAAc,CAAC;QAC3CrE,OAAOsE,gBAAgBrD,UAAU,EAAEW,WAAWb,aAAa,CAAC;YAAEc,OAAO;QAAU;IACjF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payload",
3
- "version": "3.80.0-internal-debug.cd99b1f",
3
+ "version": "3.80.0-internal-debug.7019cc9",
4
4
  "description": "Node, React, Headless CMS and Application Framework built on Next.js",
5
5
  "keywords": [
6
6
  "admin panel",
@@ -115,7 +115,7 @@
115
115
  "undici": "7.18.2",
116
116
  "uuid": "10.0.0",
117
117
  "ws": "^8.16.0",
118
- "@payloadcms/translations": "3.80.0-internal-debug.cd99b1f"
118
+ "@payloadcms/translations": "3.80.0-internal-debug.7019cc9"
119
119
  },
120
120
  "devDependencies": {
121
121
  "@hyrious/esbuild-plugin-commonjs": "0.2.6",