payload 3.0.0-beta.20 → 3.0.0-beta.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/admin/RichText.d.ts +3 -0
  2. package/dist/admin/RichText.d.ts.map +1 -1
  3. package/dist/admin/RichText.js.map +1 -1
  4. package/dist/admin/types.d.ts +1 -1
  5. package/dist/admin/types.d.ts.map +1 -1
  6. package/dist/admin/types.js.map +1 -1
  7. package/dist/auth/getAccessResults.js +1 -1
  8. package/dist/auth/getAccessResults.js.map +1 -1
  9. package/dist/bin/loader/index.d.ts.map +1 -1
  10. package/dist/bin/loader/index.js +2 -1
  11. package/dist/bin/loader/index.js.map +1 -1
  12. package/dist/bin/loader/resolveOriginalPath.d.ts +10 -0
  13. package/dist/bin/loader/resolveOriginalPath.d.ts.map +1 -0
  14. package/dist/bin/loader/resolveOriginalPath.js +32 -0
  15. package/dist/bin/loader/resolveOriginalPath.js.map +1 -0
  16. package/dist/collections/config/sanitize.d.ts +2 -2
  17. package/dist/collections/config/sanitize.d.ts.map +1 -1
  18. package/dist/collections/config/sanitize.js +6 -2
  19. package/dist/collections/config/sanitize.js.map +1 -1
  20. package/dist/config/build.d.ts.map +1 -1
  21. package/dist/config/build.js +3 -4
  22. package/dist/config/build.js.map +1 -1
  23. package/dist/config/sanitize.d.ts +1 -1
  24. package/dist/config/sanitize.d.ts.map +1 -1
  25. package/dist/config/sanitize.js +20 -5
  26. package/dist/config/sanitize.js.map +1 -1
  27. package/dist/config/types.d.ts +5 -2
  28. package/dist/config/types.d.ts.map +1 -1
  29. package/dist/config/types.js.map +1 -1
  30. package/dist/exports/i18n.d.ts +2 -0
  31. package/dist/exports/i18n.d.ts.map +1 -0
  32. package/dist/exports/i18n.js +3 -0
  33. package/dist/exports/i18n.js.map +1 -0
  34. package/dist/fields/config/client.d.ts +1 -1
  35. package/dist/fields/config/sanitize.d.ts +7 -2
  36. package/dist/fields/config/sanitize.d.ts.map +1 -1
  37. package/dist/fields/config/sanitize.js +55 -44
  38. package/dist/fields/config/sanitize.js.map +1 -1
  39. package/dist/fields/config/sanitize.spec.js +76 -85
  40. package/dist/fields/config/sanitize.spec.js.map +1 -1
  41. package/dist/fields/config/types.d.ts +4 -3
  42. package/dist/fields/config/types.d.ts.map +1 -1
  43. package/dist/fields/config/types.js.map +1 -1
  44. package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
  45. package/dist/fields/hooks/afterRead/promise.js +3 -0
  46. package/dist/fields/hooks/afterRead/promise.js.map +1 -1
  47. package/dist/fields/validations.d.ts.map +1 -1
  48. package/dist/fields/validations.js +3 -0
  49. package/dist/fields/validations.js.map +1 -1
  50. package/dist/globals/config/sanitize.d.ts +2 -3
  51. package/dist/globals/config/sanitize.d.ts.map +1 -1
  52. package/dist/globals/config/sanitize.js +36 -35
  53. package/dist/globals/config/sanitize.js.map +1 -1
  54. package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
  55. package/dist/utilities/configToJSONSchema.js +3 -0
  56. package/dist/utilities/configToJSONSchema.js.map +1 -1
  57. package/dist/utilities/configToJSONSchema.spec.js +2 -2
  58. package/dist/utilities/configToJSONSchema.spec.js.map +1 -1
  59. package/dist/utilities/createLocalReq.js +1 -1
  60. package/dist/utilities/createLocalReq.js.map +1 -1
  61. package/dist/utilities/importWithoutClientFiles.js +1 -1
  62. package/dist/utilities/importWithoutClientFiles.js.map +1 -1
  63. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/config/types.ts"],"sourcesContent":["import type { I18nOptions, TFunction } from '@payloadcms/translations'\nimport type { Options as ExpressFileUploadOptions } from 'express-fileupload'\nimport type GraphQL from 'graphql'\nimport type { DestinationStream, LoggerOptions, P } from 'pino'\nimport type React from 'react'\nimport type { default as sharp } from 'sharp'\nimport type { DeepRequired } from 'ts-essentials'\n\nimport type { DocumentTab, RichTextAdapter } from '../admin/types.js'\nimport type { AdminView, ServerSideEditViewProps } from '../admin/views/types.js'\nimport type { User } from '../auth/types.js'\nimport type {\n AfterErrorHook,\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 { GlobalConfig, Globals, SanitizedGlobalConfig } from '../globals/config/types.js'\nimport type { Payload } from '../index.js'\nimport type { PayloadRequest, PayloadRequestWithData, Where } from '../types/index.js'\nimport type { PayloadLogger } from '../utilities/logger.js'\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\n// eslint-disable-next-line no-use-before-define\nexport type Plugin = (config: Config) => Config | Promise<Config>\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 Use the `useLivePreview` hook to get started in React applications.\n */\n url?:\n | ((args: {\n collectionConfig?: SanitizedCollectionConfig\n data: Record<string, any>\n globalConfig?: SanitizedGlobalConfig\n locale: Locale\n payload: Payload\n }) => Promise<string> | string)\n | string\n}\n\nexport type ServerOnlyLivePreviewProperties = keyof Pick<LivePreviewConfig, 'url'>\n\ntype GeneratePreviewURLOptions = {\n locale: string\n req: PayloadRequestWithData\n token: null | string\n}\n\nexport type GeneratePreviewURL = (\n doc: Record<string, unknown>,\n options: GeneratePreviewURLOptions,\n) => Promise<null | string> | null | string\n\nexport type GraphQLInfo = {\n Mutation: {\n fields: Record<string, any>\n name: string\n }\n Query: {\n fields: Record<string, any>\n name: string\n }\n collections: {\n [slug: number | string | symbol]: Collection\n }\n globals: Globals\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 * 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 /**\n * A previously instantiated logger instance. Must conform to the PayloadLogger interface which uses Pino\n * This allows you to bring your own logger instance and let payload use it\n */\n logger?: PayloadLogger\n\n loggerDestination?: DestinationStream\n\n /**\n * Specify options for the built-in Pino logger that Payload uses for internal logging.\n *\n * See Pino Docs for options: https://getpino.io/#/docs/api?id=options\n */\n loggerOptions?: LoggerOptions\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 = Where | boolean\n\nexport type AccessArgs<T = any, U = any> = {\n /**\n * The relevant resource that is being accessed.\n *\n * `data` is null when a list is requested\n */\n data?: T\n /** ID of the resource being accessed */\n id?: number | string\n /** If true, the request is for a static file */\n isReadingStaticFile?: boolean\n /** The original request that requires an access check */\n req: PayloadRequestWithData<U>\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<T = any, U = any> = (\n args: AccessArgs<T, U>,\n) => AccessResult | Promise<AccessResult>\n\n/** Web Request/Response model, but the 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<U = User> = {\n /** Extension point to add your custom data. */\n custom?: Record<string, any>\n\n /**\n * Middleware that will be called when the path/method matches\n *\n * Compatible with Web Request/Response Model\n */\n handler: PayloadHandler\n /** HTTP method (or \"all\") */\n method: 'connect' | 'delete' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put'\n /**\n * Pattern that should match the path of the incoming request\n *\n * Compatible with the Express router\n */\n path: string\n /**\n * Please add \"root\" routes under the /api folder in the Payload Project.\n * https://nextjs.org/docs/app/api-reference/file-conventions/route\n *\n * @deprecated in 3.0\n */\n root?: never\n}\n\nexport type EditViewComponent = React.ComponentType<ServerSideEditViewProps>\n\nexport type EditViewConfig =\n | {\n /**\n * Add a new Edit view to the admin panel\n * i.e. you can render a custom view that has no tab, if desired\n * Or override a specific properties of an existing one\n * i.e. you can customize the `Default` view tab label, if desired\n */\n Tab?: DocumentTab\n path?: string\n }\n | {\n Component: EditViewComponent\n path: string\n }\n | {\n actions?: CustomComponent[]\n }\n\n/**\n * Override existing views\n * i.e. Dashboard, Account, API, LivePreview, etc.\n * Path is not available here\n * All Tab properties become optional\n * i.e. you can change just the label, if desired\n */\nexport type EditView = EditViewComponent | EditViewConfig\n\nexport type ServerProps = {\n payload: Payload\n}\n\nexport const serverProps: (keyof ServerProps)[] = ['payload']\n\nexport type CustomComponent<T extends any = any> = React.ComponentType<T & ServerProps>\n\nexport type Locale = {\n /**\n * value of supported locale\n * @example \"en\"\n */\n code: string\n /**\n * Code of another locale to use when reading documents with fallback, if not specified defaultLocale is used\n */\n fallbackLocale?: string\n /**\n * label of supported locale\n * @example \"English\"\n */\n label: Record<string, string> | string\n /**\n * if true, defaults textAligmnent on text fields to RTL\n */\n rtl?: boolean\n}\n\nexport type BaseLocalizationConfig = {\n /**\n * Locale for users that have not expressed their preference for a specific locale\n * @example `\"en\"`\n */\n defaultLocale: string\n /** Set to `true` to let missing values in localised fields fall back to the values in `defaultLocale` */\n fallback?: boolean\n}\n\nexport type LocalizationConfigWithNoLabels = Prettify<\n BaseLocalizationConfig & {\n /**\n * List of supported locales\n * @example `[\"en\", \"es\", \"fr\", \"nl\", \"de\", \"jp\"]`\n */\n locales: string[]\n }\n>\n\nexport type LocalizationConfigWithLabels = Prettify<\n BaseLocalizationConfig & {\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 }\n>\n\nexport type SanitizedLocalizationConfig = Prettify<\n LocalizationConfigWithLabels & {\n /**\n * List of supported locales\n * @example `[\"en\", \"es\", \"fr\", \"nl\", \"de\", \"jp\"]`\n */\n localeCodes: string[]\n }\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 = ({ t }: { t: TFunction }) => string\n\nexport type SharpDependency = (\n input?:\n | ArrayBuffer\n | Buffer\n | Float32Array\n | Float64Array\n | Int8Array\n | Int16Array\n | Int32Array\n | Uint8Array\n | Uint8ClampedArray\n | Uint16Array\n | Uint32Array\n | string,\n options?: sharp.SharpOptions,\n) => sharp.Sharp\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 when visiting the admin dashboard. */\n autoLogin?:\n | {\n /**\n * The email address of the user to login as\n *\n */\n email: string\n /** The password of the user to login as */\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 }\n | false\n /** Set account profile picture. Options: gravatar, default or a custom React component. */\n avatar?: 'default' | 'gravatar' | React.ComponentType<any>\n\n /**\n * Add extra and/or replace built-in components with custom components\n *\n * @see https://payloadcms.com/docs/admin/components\n */\n components?: {\n /**\n * Replace the navigation with a custom component\n */\n Nav?: CustomComponent\n /**\n * Add custom components to the top right of the Admin Panel\n */\n actions?: CustomComponent[]\n /**\n * Add custom components after the collection overview\n */\n afterDashboard?: CustomComponent[]\n /**\n * Add custom components after the email/password field\n */\n afterLogin?: CustomComponent[]\n /**\n * Add custom components after the navigation links\n */\n afterNavLinks?: CustomComponent[]\n /**\n * Add custom components before the collection overview\n */\n beforeDashboard?: CustomComponent[]\n /**\n * Add custom components before the email/password field\n */\n beforeLogin?: CustomComponent[]\n /**\n * Add custom components before the navigation links\n */\n beforeNavLinks?: CustomComponent[]\n /** Replace graphical components */\n graphics?: {\n /** Replace the icon in the navigation */\n Icon?: CustomComponent\n /** Replace the logo on the login page */\n Logo?: CustomComponent\n }\n /** Replace logout related components */\n logout?: {\n /** Replace the logout button */\n Button?: CustomComponent\n }\n /**\n * Wrap the admin dashboard in custom context providers\n */\n providers?: React.ComponentType<{ children?: React.ReactNode }>[]\n /**\n * Replace or modify top-level admin routes, or add new ones:\n * + `Account` - `/admin/account`\n * + `Dashboard` - `/admin`\n * + `:path` - `/admin/:path`\n */\n views?: {\n /** Add custom admin views */\n [key: string]: AdminView\n /** Replace the account screen */\n Account?: AdminView\n /** Replace the admin homepage */\n Dashboard?: AdminView\n }\n }\n /** Extension point to add your custom data. Available in server and client. */\n custom?: Record<string, any>\n /** Global date format that will be used for all dates in the Admin panel. Any valid date-fns format pattern can be used. */\n dateFormat?: string\n /** If set to true, the entire Admin panel will be disabled. */\n disable?: boolean\n /** The route the user will be redirected to after being inactive for too long. */\n inactivityRoute?: string\n livePreview?: LivePreviewConfig & {\n collections?: string[]\n globals?: string[]\n }\n /** The route for the logout page. */\n logoutRoute?: string\n /** Base meta data to use for the Admin panel. Included properties are titleSuffix, ogImage, and favicon. */\n meta?: {\n /**\n * Public path to an icon\n *\n * This image may be displayed in the browser next to the title of the page\n */\n favicon?: string\n /**\n * Public path to an image\n *\n * This image may be displayed as preview when the link is shared on social media\n */\n ogImage?: string\n /**\n * String to append to the <title> of admin pages\n * @example `\" - My Brand\"`\n */\n titleSuffix?: string\n }\n /** The slug of a Collection that you want be used to log in to the Admin dashboard. */\n user?: string\n }\n /** Custom Payload bin scripts can be injected via the config. */\n bin?: BinScriptConfig[]\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 * Replace the built-in components with custom ones\n */\n components?: { [key: string]: (() => JSX.Element) | JSX.Element }\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?: '*' | 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\n /** Extension point to add your custom data. Server only. */\n custom?: Record<string, any>\n\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: RichTextAdapter<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 * @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 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 /**\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 i18n?: I18nOptions\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 * Translate your content to different languages/locales.\n *\n * @default false // disable localization\n */\n localization?: LocalizationConfig | false\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 /** 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 /** Control the routing structure that Payload binds itself to. */\n routes?: {\n /** @default \"/admin\" */\n admin?: string\n /** @default \"/api\" */\n api?: string\n /** @default \"/graphql\" */\n graphQL?: string\n /** @default \"/graphql-playground\" */\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 /** Disable declare block in generated types file */\n declare?: false\n /** Filename to write the generated types to */\n outputFile?: string\n }\n /**\n * Customize the handling of incoming file uploads for collections that have uploads enabled.\n */\n upload?: ExpressFileUploadOptions\n}\n\nexport type SanitizedConfig = Omit<\n DeepRequired<Config>,\n 'collections' | 'endpoint' | 'globals' | 'i18n' | 'localization' | 'upload'\n> & {\n collections: SanitizedCollectionConfig[]\n endpoints: Endpoint[]\n globals: SanitizedGlobalConfig[]\n i18n: Required<I18nOptions>\n localization: SanitizedLocalizationConfig | false\n paths: {\n config: string\n configDir: string\n rawConfig: string\n }\n upload: ExpressFileUploadOptions & {\n /**\n * Deduped list of adapters used in the project\n */\n adapters: string[]\n }\n}\n\nexport type EditConfig =\n | (\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 API?: EditViewComponent | Partial<EditViewConfig>\n Default?: EditViewComponent | Partial<EditViewConfig>\n LivePreview?: EditViewComponent | Partial<EditViewConfig>\n Version?: EditViewComponent | Partial<EditViewConfig>\n Versions?: EditViewComponent | Partial<EditViewConfig>\n // TODO: uncomment these as they are built\n // References?: EditView\n // Relationships?: EditView\n }\n | {\n [key: string]: EditViewConfig\n }\n )\n | EditViewComponent\n\nexport type EntityDescriptionComponent = CustomComponent\n\nexport type EntityDescriptionFunction = () => string\n\nexport type EntityDescription =\n | EntityDescriptionComponent\n | EntityDescriptionFunction\n | Record<string, string>\n | string\n\nexport type { EmailAdapter, SendEmailOptions }\n"],"names":["serverProps"],"rangeMappings":";;","mappings":"AA8PA,OAAO,MAAMA,cAAqC;IAAC;CAAU,CAAA"}
1
+ {"version":3,"sources":["../../src/config/types.ts"],"sourcesContent":["import type { I18nOptions, TFunction } from '@payloadcms/translations'\nimport type { Options as ExpressFileUploadOptions } from 'express-fileupload'\nimport type GraphQL from 'graphql'\nimport type { DestinationStream, LoggerOptions, P } 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 { DocumentTab, RichTextAdapter } from '../admin/types.js'\nimport type { AdminView, ServerSideEditViewProps } from '../admin/views/types.js'\nimport type { User } from '../auth/types.js'\nimport type {\n AfterErrorHook,\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 { GlobalConfig, Globals, SanitizedGlobalConfig } from '../globals/config/types.js'\nimport type { Payload } from '../index.js'\nimport type { PayloadRequest, PayloadRequestWithData, Where } from '../types/index.js'\nimport type { PayloadLogger } from '../utilities/logger.js'\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\n// eslint-disable-next-line no-use-before-define\nexport type Plugin = (config: Config) => Config | Promise<Config>\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 Use the `useLivePreview` hook to get started in React applications.\n */\n url?:\n | ((args: {\n collectionConfig?: SanitizedCollectionConfig\n data: Record<string, any>\n globalConfig?: SanitizedGlobalConfig\n locale: Locale\n payload: Payload\n }) => Promise<string> | string)\n | string\n}\n\nexport type ServerOnlyLivePreviewProperties = keyof Pick<LivePreviewConfig, 'url'>\n\ntype GeneratePreviewURLOptions = {\n locale: string\n req: PayloadRequestWithData\n token: null | string\n}\n\nexport type GeneratePreviewURL = (\n doc: Record<string, unknown>,\n options: GeneratePreviewURLOptions,\n) => Promise<null | string> | null | string\n\nexport type GraphQLInfo = {\n Mutation: {\n fields: Record<string, any>\n name: string\n }\n Query: {\n fields: Record<string, any>\n name: string\n }\n collections: {\n [slug: number | string | symbol]: Collection\n }\n globals: Globals\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 * 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 /**\n * A previously instantiated logger instance. Must conform to the PayloadLogger interface which uses Pino\n * This allows you to bring your own logger instance and let payload use it\n */\n logger?: PayloadLogger\n\n loggerDestination?: DestinationStream\n\n /**\n * Specify options for the built-in Pino logger that Payload uses for internal logging.\n *\n * See Pino Docs for options: https://getpino.io/#/docs/api?id=options\n */\n loggerOptions?: LoggerOptions\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 = Where | boolean\n\nexport type AccessArgs<T = any, U = any> = {\n /**\n * The relevant resource that is being accessed.\n *\n * `data` is null when a list is requested\n */\n data?: T\n /** ID of the resource being accessed */\n id?: number | string\n /** If true, the request is for a static file */\n isReadingStaticFile?: boolean\n /** The original request that requires an access check */\n req: PayloadRequestWithData<U>\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<T = any, U = any> = (\n args: AccessArgs<T, U>,\n) => AccessResult | Promise<AccessResult>\n\n/** Web Request/Response model, but the 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<U = User> = {\n /** Extension point to add your custom data. */\n custom?: Record<string, any>\n\n /**\n * Middleware that will be called when the path/method matches\n *\n * Compatible with Web Request/Response Model\n */\n handler: PayloadHandler\n /** HTTP method (or \"all\") */\n method: 'connect' | 'delete' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put'\n /**\n * Pattern that should match the path of the incoming request\n *\n * Compatible with the Express router\n */\n path: string\n /**\n * Please add \"root\" routes under the /api folder in the Payload Project.\n * https://nextjs.org/docs/app/api-reference/file-conventions/route\n *\n * @deprecated in 3.0\n */\n root?: never\n}\n\nexport type EditViewComponent = React.ComponentType<ServerSideEditViewProps>\n\nexport type EditViewConfig =\n | {\n /**\n * Add a new Edit view to the admin panel\n * i.e. you can render a custom view that has no tab, if desired\n * Or override a specific properties of an existing one\n * i.e. you can customize the `Default` view tab label, if desired\n */\n Tab?: DocumentTab\n path?: string\n }\n | {\n Component: EditViewComponent\n path: string\n }\n | {\n actions?: CustomComponent[]\n }\n\n/**\n * Override existing views\n * i.e. Dashboard, Account, API, LivePreview, etc.\n * Path is not available here\n * All Tab properties become optional\n * i.e. you can change just the label, if desired\n */\nexport type EditView = EditViewComponent | EditViewConfig\n\nexport type ServerProps = {\n payload: Payload\n}\n\nexport const serverProps: (keyof ServerProps)[] = ['payload']\n\nexport type CustomComponent<T extends any = any> = React.ComponentType<T & ServerProps>\n\nexport type Locale = {\n /**\n * value of supported locale\n * @example \"en\"\n */\n code: string\n /**\n * Code of another locale to use when reading documents with fallback, if not specified defaultLocale is used\n */\n fallbackLocale?: string\n /**\n * label of supported locale\n * @example \"English\"\n */\n label: Record<string, string> | string\n /**\n * if true, defaults textAligmnent on text fields to RTL\n */\n rtl?: boolean\n}\n\nexport type BaseLocalizationConfig = {\n /**\n * Locale for users that have not expressed their preference for a specific locale\n * @example `\"en\"`\n */\n defaultLocale: string\n /** Set to `true` to let missing values in localised fields fall back to the values in `defaultLocale` */\n fallback?: boolean\n}\n\nexport type LocalizationConfigWithNoLabels = Prettify<\n BaseLocalizationConfig & {\n /**\n * List of supported locales\n * @example `[\"en\", \"es\", \"fr\", \"nl\", \"de\", \"jp\"]`\n */\n locales: string[]\n }\n>\n\nexport type LocalizationConfigWithLabels = Prettify<\n BaseLocalizationConfig & {\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 }\n>\n\nexport type SanitizedLocalizationConfig = Prettify<\n LocalizationConfigWithLabels & {\n /**\n * List of supported locales\n * @example `[\"en\", \"es\", \"fr\", \"nl\", \"de\", \"jp\"]`\n */\n localeCodes: string[]\n }\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 = ({ t }: { t: TFunction }) => string\n\nexport type SharpDependency = (\n input?:\n | ArrayBuffer\n | Buffer\n | Float32Array\n | Float64Array\n | Int8Array\n | Int16Array\n | Int32Array\n | Uint8Array\n | Uint8ClampedArray\n | Uint16Array\n | Uint32Array\n | string,\n options?: sharp.SharpOptions,\n) => sharp.Sharp\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 when visiting the admin dashboard. */\n autoLogin?:\n | {\n /**\n * The email address of the user to login as\n *\n */\n email: string\n /** The password of the user to login as */\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 }\n | false\n /** Set account profile picture. Options: gravatar, default or a custom React component. */\n avatar?: 'default' | 'gravatar' | React.ComponentType<any>\n\n /**\n * Add extra and/or replace built-in components with custom components\n *\n * @see https://payloadcms.com/docs/admin/components\n */\n components?: {\n /**\n * Replace the navigation with a custom component\n */\n Nav?: CustomComponent\n /**\n * Add custom components to the top right of the Admin Panel\n */\n actions?: CustomComponent[]\n /**\n * Add custom components after the collection overview\n */\n afterDashboard?: CustomComponent[]\n /**\n * Add custom components after the email/password field\n */\n afterLogin?: CustomComponent[]\n /**\n * Add custom components after the navigation links\n */\n afterNavLinks?: CustomComponent[]\n /**\n * Add custom components before the collection overview\n */\n beforeDashboard?: CustomComponent[]\n /**\n * Add custom components before the email/password field\n */\n beforeLogin?: CustomComponent[]\n /**\n * Add custom components before the navigation links\n */\n beforeNavLinks?: CustomComponent[]\n /** Replace graphical components */\n graphics?: {\n /** Replace the icon in the navigation */\n Icon?: CustomComponent\n /** Replace the logo on the login page */\n Logo?: CustomComponent\n }\n /** Replace logout related components */\n logout?: {\n /** Replace the logout button */\n Button?: CustomComponent\n }\n /**\n * Wrap the admin dashboard in custom context providers\n */\n providers?: React.ComponentType<{ children?: React.ReactNode }>[]\n /**\n * Replace or modify top-level admin routes, or add new ones:\n * + `Account` - `/admin/account`\n * + `Dashboard` - `/admin`\n * + `:path` - `/admin/:path`\n */\n views?: {\n /** Add custom admin views */\n [key: string]: AdminView\n /** Replace the account screen */\n Account?: AdminView\n /** Replace the admin homepage */\n Dashboard?: AdminView\n }\n }\n /** Extension point to add your custom data. Available in server and client. */\n custom?: Record<string, any>\n /** Global date format that will be used for all dates in the Admin panel. Any valid date-fns format pattern can be used. */\n dateFormat?: string\n /** If set to true, the entire Admin panel will be disabled. */\n disable?: boolean\n /** The route the user will be redirected to after being inactive for too long. */\n inactivityRoute?: string\n livePreview?: LivePreviewConfig & {\n collections?: string[]\n globals?: string[]\n }\n /** The route for the logout page. */\n logoutRoute?: string\n /** Base meta data to use for the Admin panel. Included properties are titleSuffix, ogImage, and favicon. */\n meta?: {\n /**\n * Public path to an icon\n *\n * This image may be displayed in the browser next to the title of the page\n */\n favicon?: string\n /**\n * Public path to an image\n *\n * This image may be displayed as preview when the link is shared on social media\n */\n ogImage?: string\n /**\n * String to append to the <title> of admin pages\n * @example `\" - My Brand\"`\n */\n titleSuffix?: string\n }\n /** The slug of a Collection that you want be used to log in to the Admin dashboard. */\n user?: string\n }\n /** Custom Payload bin scripts can be injected via the config. */\n bin?: BinScriptConfig[]\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 * Replace the built-in components with custom ones\n */\n components?: { [key: string]: (() => JSX.Element) | JSX.Element }\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?: '*' | 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\n /** Extension point to add your custom data. Server only. */\n custom?: Record<string, any>\n\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 * @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 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 /**\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 i18n?: I18nOptions\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 * Translate your content to different languages/locales.\n *\n * @default false // disable localization\n */\n localization?: LocalizationConfig | false\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 /** 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 /** Control the routing structure that Payload binds itself to. */\n routes?: {\n /** @default \"/admin\" */\n admin?: string\n /** @default \"/api\" */\n api?: string\n /** @default \"/graphql\" */\n graphQL?: string\n /** @default \"/graphql-playground\" */\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 /** Disable declare block in generated types file */\n declare?: false\n /** Filename to write the generated types to */\n outputFile?: string\n }\n /**\n * Customize the handling of incoming file uploads for collections that have uploads enabled.\n */\n upload?: ExpressFileUploadOptions\n}\n\nexport type SanitizedConfig = Omit<\n DeepRequired<Config>,\n 'collections' | 'editor' | 'endpoint' | 'globals' | 'i18n' | 'localization' | 'upload'\n> & {\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 localization: SanitizedLocalizationConfig | false\n paths: {\n config: string\n configDir: string\n rawConfig: string\n }\n upload: ExpressFileUploadOptions & {\n /**\n * Deduped list of adapters used in the project\n */\n adapters: string[]\n }\n}\n\nexport type EditConfig =\n | (\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 API?: EditViewComponent | Partial<EditViewConfig>\n Default?: EditViewComponent | Partial<EditViewConfig>\n LivePreview?: EditViewComponent | Partial<EditViewConfig>\n Version?: EditViewComponent | Partial<EditViewConfig>\n Versions?: EditViewComponent | Partial<EditViewConfig>\n // TODO: uncomment these as they are built\n // References?: EditView\n // Relationships?: EditView\n }\n | {\n [key: string]: EditViewConfig\n }\n )\n | EditViewComponent\n\nexport type EntityDescriptionComponent = CustomComponent\n\nexport type EntityDescriptionFunction = () => string\n\nexport type EntityDescription =\n | EntityDescriptionComponent\n | EntityDescriptionFunction\n | Record<string, string>\n | string\n\nexport type { EmailAdapter, SendEmailOptions }\n"],"names":["serverProps"],"rangeMappings":";;","mappings":"AA+PA,OAAO,MAAMA,cAAqC;IAAC;CAAU,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { getLocalI18n } from '../translations/getLocalI18n.js';
2
+ //# sourceMappingURL=i18n.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/exports/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA"}
@@ -0,0 +1,3 @@
1
+ export { getLocalI18n } from '../translations/getLocalI18n.js';
2
+
3
+ //# sourceMappingURL=i18n.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/exports/i18n.ts"],"sourcesContent":["export { getLocalI18n } from '../translations/getLocalI18n.js'\n"],"names":["getLocalI18n"],"rangeMappings":"","mappings":"AAAA,SAASA,YAAY,QAAQ,kCAAiC"}
@@ -962,7 +962,7 @@ export declare const createClientFieldConfig: ({ field: incomingField, t, }: {
962
962
  saveToJWT?: string | boolean;
963
963
  unique?: boolean;
964
964
  validate?: import("../../fields/config/types.js").Validate<any, any, any, object>;
965
- editor?: import("../../admin/RichText.js").RichTextAdapter<any, any, any>;
965
+ editor?: import("../../admin/RichText.js").RichTextAdapter<any, any, any> | import("../../admin/RichText.js").RichTextAdapterProvider<any, any, any>;
966
966
  type: "richText";
967
967
  } | {
968
968
  custom?: Record<string, any>;
@@ -1,4 +1,4 @@
1
- import type { Config } from '../../config/types.js';
1
+ import type { Config, SanitizedConfig } from '../../config/types.js';
2
2
  import type { Field } from './types.js';
3
3
  type Args = {
4
4
  config: Config;
@@ -10,12 +10,17 @@ type Args = {
10
10
  * @default false
11
11
  */
12
12
  requireFieldLevelRichTextEditor?: boolean;
13
+ /**
14
+ * If this property is set, RichText fields won't be sanitized immediately. Instead, they will be added to this array as promises
15
+ * so that you can sanitize them together, after the config has been sanitized.
16
+ */
17
+ richTextSanitizationPromises?: Array<(config: SanitizedConfig) => Promise<void>>;
13
18
  /**
14
19
  * If not null, will validate that upload and relationship fields do not relate to a collection that is not in this array.
15
20
  * This validation will be skipped if validRelationships is null.
16
21
  */
17
22
  validRelationships: null | string[];
18
23
  };
19
- export declare const sanitizeFields: ({ config, existingFieldNames, fields, requireFieldLevelRichTextEditor, validRelationships, }: Args) => Field[];
24
+ export declare const sanitizeFields: ({ config, existingFieldNames, fields, requireFieldLevelRichTextEditor, richTextSanitizationPromises, validRelationships, }: Args) => Promise<Field[]>;
20
25
  export {};
21
26
  //# sourceMappingURL=sanitize.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../src/fields/config/sanitize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAgBvC,KAAK,IAAI,GAAG;IACV,MAAM,EAAE,MAAM,CAAA;IACd,kBAAkB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAChC,MAAM,EAAE,KAAK,EAAE,CAAA;IACf;;;;OAIG;IACH,+BAA+B,CAAC,EAAE,OAAO,CAAA;IACzC;;;OAGG;IACH,kBAAkB,EAAE,IAAI,GAAG,MAAM,EAAE,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,cAAc,iGAMxB,IAAI,KAAG,KAAK,EA6Ld,CAAA"}
1
+ {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../src/fields/config/sanitize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAgBvC,KAAK,IAAI,GAAG;IACV,MAAM,EAAE,MAAM,CAAA;IACd,kBAAkB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAChC,MAAM,EAAE,KAAK,EAAE,CAAA;IACf;;;;OAIG;IACH,+BAA+B,CAAC,EAAE,OAAO,CAAA;IACzC;;;OAGG;IACH,4BAA4B,CAAC,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;IAEhF;;;OAGG;IACH,kBAAkB,EAAE,IAAI,GAAG,MAAM,EAAE,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,cAAc,+HAOxB,IAAI,KAAG,QAAQ,KAAK,EAAE,CAoMxB,CAAA"}
@@ -6,12 +6,10 @@ import { baseIDField } from '../baseFields/baseIDField.js';
6
6
  import { setDefaultBeforeDuplicate } from '../setDefaultBeforeDuplicate.js';
7
7
  import validations from '../validations.js';
8
8
  import { fieldAffectsData, tabHasName } from './types.js';
9
- export const sanitizeFields = ({ config, existingFieldNames = new Set(), fields, requireFieldLevelRichTextEditor = false, validRelationships })=>{
9
+ export const sanitizeFields = async ({ config, existingFieldNames = new Set(), fields, requireFieldLevelRichTextEditor = false, richTextSanitizationPromises, validRelationships })=>{
10
10
  if (!fields) return [];
11
- return fields.map((unsanitizedField)=>{
12
- const field = {
13
- ...unsanitizedField
14
- };
11
+ for(let i = 0; i < fields.length; i++){
12
+ const field = fields[i];
15
13
  if (!field.type) throw new MissingFieldType(field);
16
14
  // assert that field names do not contain forbidden characters
17
15
  if (fieldAffectsData(field) && field.name.includes('.')) {
@@ -88,74 +86,87 @@ export const sanitizeFields = ({ config, existingFieldNames = new Set(), fields,
88
86
  }
89
87
  // Make sure that the richText field has an editor
90
88
  if (field.type === 'richText') {
91
- if (!field.editor) {
92
- if (config.editor && !requireFieldLevelRichTextEditor) {
93
- field.editor = config.editor;
94
- } else {
95
- throw new MissingEditorProp(field);
89
+ const sanitizeRichText = async (_config)=>{
90
+ if (!field.editor) {
91
+ if (_config.editor && !requireFieldLevelRichTextEditor) {
92
+ // config.editor should be sanitized at this point
93
+ field.editor = _config.editor;
94
+ } else {
95
+ throw new MissingEditorProp(field);
96
+ }
96
97
  }
97
- }
98
- // Add editor adapter hooks to field hooks
99
- if (!field.hooks) field.hooks = {};
100
- if (field?.editor?.hooks?.afterRead?.length) {
101
- field.hooks.afterRead = field.hooks.afterRead ? field.hooks.afterRead.concat(field.editor.hooks.afterRead) : field.editor.hooks.afterRead;
102
- }
103
- if (field?.editor?.hooks?.beforeChange?.length) {
104
- field.hooks.beforeChange = field.hooks.beforeChange ? field.hooks.beforeChange.concat(field.editor.hooks.beforeChange) : field.editor.hooks.beforeChange;
105
- }
106
- if (field?.editor?.hooks?.beforeValidate?.length) {
107
- field.hooks.beforeValidate = field.hooks.beforeValidate ? field.hooks.beforeValidate.concat(field.editor.hooks.beforeValidate) : field.editor.hooks.beforeValidate;
108
- }
109
- if (field?.editor?.hooks?.beforeChange?.length) {
110
- field.hooks.beforeChange = field.hooks.beforeChange ? field.hooks.beforeChange.concat(field.editor.hooks.beforeChange) : field.editor.hooks.beforeChange;
98
+ if (typeof field.editor === 'function') {
99
+ field.editor = await field.editor({
100
+ config: _config
101
+ });
102
+ }
103
+ // Add editor adapter hooks to field hooks
104
+ if (!field.hooks) field.hooks = {};
105
+ const mergeHooks = (hookName)=>{
106
+ if (typeof field.editor === 'function') return;
107
+ if (field.editor?.hooks?.[hookName]?.length) {
108
+ field.hooks[hookName] = field.hooks[hookName] ? field.hooks[hookName].concat(field.editor.hooks[hookName]) : [
109
+ ...field.editor.hooks[hookName]
110
+ ];
111
+ }
112
+ };
113
+ mergeHooks('afterRead');
114
+ mergeHooks('afterChange');
115
+ mergeHooks('beforeChange');
116
+ mergeHooks('beforeValidate');
117
+ mergeHooks('beforeDuplicate');
118
+ };
119
+ if (richTextSanitizationPromises) {
120
+ richTextSanitizationPromises.push(sanitizeRichText);
121
+ } else {
122
+ await sanitizeRichText(config);
111
123
  }
112
124
  }
113
- // TODO: Handle sanitization for any lexical sub-fields here as well
114
125
  if ('fields' in field && field.fields) {
115
- field.fields = sanitizeFields({
126
+ field.fields = await sanitizeFields({
116
127
  config,
117
128
  existingFieldNames: fieldAffectsData(field) ? new Set() : existingFieldNames,
118
129
  fields: field.fields,
119
130
  requireFieldLevelRichTextEditor,
131
+ richTextSanitizationPromises,
120
132
  validRelationships
121
133
  });
122
134
  }
123
135
  if (field.type === 'tabs') {
124
- field.tabs = field.tabs.map((tab)=>{
125
- const unsanitizedTab = {
126
- ...tab
127
- };
136
+ for(let j = 0; j < field.tabs.length; j++){
137
+ const tab = field.tabs[j];
128
138
  if (tabHasName(tab) && typeof tab.label === 'undefined') {
129
- unsanitizedTab.label = toWords(tab.name);
139
+ tab.label = toWords(tab.name);
130
140
  }
131
- unsanitizedTab.fields = sanitizeFields({
141
+ tab.fields = await sanitizeFields({
132
142
  config,
133
143
  existingFieldNames: tabHasName(tab) ? new Set() : existingFieldNames,
134
144
  fields: tab.fields,
135
145
  requireFieldLevelRichTextEditor,
146
+ richTextSanitizationPromises,
136
147
  validRelationships
137
148
  });
138
- return unsanitizedTab;
139
- });
149
+ field.tabs[j] = tab;
150
+ }
140
151
  }
141
152
  if ('blocks' in field && field.blocks) {
142
- field.blocks = field.blocks.map((block)=>{
143
- const unsanitizedBlock = {
144
- ...block
145
- };
146
- unsanitizedBlock.labels = !unsanitizedBlock.labels ? formatLabels(unsanitizedBlock.slug) : unsanitizedBlock.labels;
147
- unsanitizedBlock.fields = sanitizeFields({
153
+ for(let j = 0; j < field.blocks.length; j++){
154
+ const block = field.blocks[j];
155
+ block.labels = !block.labels ? formatLabels(block.slug) : block.labels;
156
+ block.fields = await sanitizeFields({
148
157
  config,
149
158
  existingFieldNames: new Set(),
150
159
  fields: block.fields,
151
160
  requireFieldLevelRichTextEditor,
161
+ richTextSanitizationPromises,
152
162
  validRelationships
153
163
  });
154
- return unsanitizedBlock;
155
- });
164
+ field.blocks[j] = block;
165
+ }
156
166
  }
157
- return field;
158
- });
167
+ fields[i] = field;
168
+ }
169
+ return fields;
159
170
  };
160
171
 
161
172
  //# sourceMappingURL=sanitize.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/config/sanitize.ts"],"sourcesContent":["import type { Config } from '../../config/types.js'\nimport type { Field } from './types.js'\n\nimport { MissingEditorProp } from '../../errors/MissingEditorProp.js'\nimport {\n DuplicateFieldName,\n InvalidFieldName,\n InvalidFieldRelationship,\n MissingFieldType,\n} from '../../errors/index.js'\nimport { formatLabels, toWords } from '../../utilities/formatLabels.js'\nimport { baseBlockFields } from '../baseFields/baseBlockFields.js'\nimport { baseIDField } from '../baseFields/baseIDField.js'\nimport { setDefaultBeforeDuplicate } from '../setDefaultBeforeDuplicate.js'\nimport validations from '../validations.js'\nimport { fieldAffectsData, tabHasName } from './types.js'\n\ntype Args = {\n config: Config\n existingFieldNames?: Set<string>\n fields: Field[]\n /**\n * If true, a richText field will require an editor property to be set, as the sanitizeFields function will not add it from the payload config if not present.\n *\n * @default false\n */\n requireFieldLevelRichTextEditor?: boolean\n /**\n * If not null, will validate that upload and relationship fields do not relate to a collection that is not in this array.\n * This validation will be skipped if validRelationships is null.\n */\n validRelationships: null | string[]\n}\n\nexport const sanitizeFields = ({\n config,\n existingFieldNames = new Set(),\n fields,\n requireFieldLevelRichTextEditor = false,\n validRelationships,\n}: Args): Field[] => {\n if (!fields) return []\n\n return fields.map((unsanitizedField) => {\n const field: Field = { ...unsanitizedField }\n\n if (!field.type) throw new MissingFieldType(field)\n\n // assert that field names do not contain forbidden characters\n if (fieldAffectsData(field) && field.name.includes('.')) {\n throw new InvalidFieldName(field, field.name)\n }\n\n // Auto-label\n if (\n 'name' in field &&\n field.name &&\n typeof field.label !== 'object' &&\n typeof field.label !== 'string' &&\n field.label !== false\n ) {\n field.label = toWords(field.name)\n }\n\n if (\n field.type === 'checkbox' &&\n typeof field.defaultValue === 'undefined' &&\n field.required === true\n ) {\n field.defaultValue = false\n }\n\n if (field.type === 'relationship' || field.type === 'upload') {\n if (validRelationships) {\n const relationships = Array.isArray(field.relationTo)\n ? field.relationTo\n : [field.relationTo]\n relationships.forEach((relationship: string) => {\n if (!validRelationships.includes(relationship)) {\n throw new InvalidFieldRelationship(field, relationship)\n }\n })\n }\n\n if (field.type === 'relationship') {\n if (field.min && !field.minRows) {\n console.warn(\n `(payload): The \"min\" property is deprecated for the Relationship field \"${field.name}\" and will be removed in a future version. Please use \"minRows\" instead.`,\n )\n }\n if (field.max && !field.maxRows) {\n console.warn(\n `(payload): The \"max\" property is deprecated for the Relationship field \"${field.name}\" and will be removed in a future version. Please use \"maxRows\" instead.`,\n )\n }\n field.minRows = field.minRows || field.min\n field.maxRows = field.maxRows || field.max\n }\n }\n\n if (field.type === 'blocks' && field.blocks) {\n field.blocks = field.blocks.map((block) => ({\n ...block,\n fields: block.fields.concat(baseBlockFields),\n }))\n }\n\n if (field.type === 'array' && field.fields) {\n field.fields.push(baseIDField)\n }\n\n if ((field.type === 'blocks' || field.type === 'array') && field.label) {\n field.labels = field.labels || formatLabels(field.name)\n }\n\n if (fieldAffectsData(field)) {\n if (existingFieldNames.has(field.name)) {\n throw new DuplicateFieldName(field.name)\n } else if (!['blockName', 'id'].includes(field.name)) {\n existingFieldNames.add(field.name)\n }\n\n if (field.localized && !config.localization) delete field.localized\n\n if (typeof field.validate === 'undefined') {\n const defaultValidate = validations[field.type]\n if (defaultValidate) {\n field.validate = (val, options) => defaultValidate(val, { ...field, ...options })\n } else {\n field.validate = () => true\n }\n }\n\n if (!field.hooks) field.hooks = {}\n if (!field.access) field.access = {}\n\n setDefaultBeforeDuplicate(field)\n }\n\n if (!field.admin) {\n field.admin = {}\n }\n\n // Make sure that the richText field has an editor\n if (field.type === 'richText') {\n if (!field.editor) {\n if (config.editor && !requireFieldLevelRichTextEditor) {\n field.editor = config.editor\n } else {\n throw new MissingEditorProp(field)\n }\n }\n\n // Add editor adapter hooks to field hooks\n if (!field.hooks) field.hooks = {}\n\n if (field?.editor?.hooks?.afterRead?.length) {\n field.hooks.afterRead = field.hooks.afterRead\n ? field.hooks.afterRead.concat(field.editor.hooks.afterRead)\n : field.editor.hooks.afterRead\n }\n if (field?.editor?.hooks?.beforeChange?.length) {\n field.hooks.beforeChange = field.hooks.beforeChange\n ? field.hooks.beforeChange.concat(field.editor.hooks.beforeChange)\n : field.editor.hooks.beforeChange\n }\n if (field?.editor?.hooks?.beforeValidate?.length) {\n field.hooks.beforeValidate = field.hooks.beforeValidate\n ? field.hooks.beforeValidate.concat(field.editor.hooks.beforeValidate)\n : field.editor.hooks.beforeValidate\n }\n if (field?.editor?.hooks?.beforeChange?.length) {\n field.hooks.beforeChange = field.hooks.beforeChange\n ? field.hooks.beforeChange.concat(field.editor.hooks.beforeChange)\n : field.editor.hooks.beforeChange\n }\n }\n\n // TODO: Handle sanitization for any lexical sub-fields here as well\n if ('fields' in field && field.fields) {\n field.fields = sanitizeFields({\n config,\n existingFieldNames: fieldAffectsData(field) ? new Set() : existingFieldNames,\n fields: field.fields,\n requireFieldLevelRichTextEditor,\n validRelationships,\n })\n }\n\n if (field.type === 'tabs') {\n field.tabs = field.tabs.map((tab) => {\n const unsanitizedTab = { ...tab }\n if (tabHasName(tab) && typeof tab.label === 'undefined') {\n unsanitizedTab.label = toWords(tab.name)\n }\n\n unsanitizedTab.fields = sanitizeFields({\n config,\n existingFieldNames: tabHasName(tab) ? new Set() : existingFieldNames,\n fields: tab.fields,\n requireFieldLevelRichTextEditor,\n validRelationships,\n })\n\n return unsanitizedTab\n })\n }\n\n if ('blocks' in field && field.blocks) {\n field.blocks = field.blocks.map((block) => {\n const unsanitizedBlock = { ...block }\n unsanitizedBlock.labels = !unsanitizedBlock.labels\n ? formatLabels(unsanitizedBlock.slug)\n : unsanitizedBlock.labels\n\n unsanitizedBlock.fields = sanitizeFields({\n config,\n existingFieldNames: new Set(),\n fields: block.fields,\n requireFieldLevelRichTextEditor,\n validRelationships,\n })\n\n return unsanitizedBlock\n })\n }\n\n return field\n })\n}\n"],"names":["MissingEditorProp","DuplicateFieldName","InvalidFieldName","InvalidFieldRelationship","MissingFieldType","formatLabels","toWords","baseBlockFields","baseIDField","setDefaultBeforeDuplicate","validations","fieldAffectsData","tabHasName","sanitizeFields","config","existingFieldNames","Set","fields","requireFieldLevelRichTextEditor","validRelationships","map","unsanitizedField","field","type","name","includes","label","defaultValue","required","relationships","Array","isArray","relationTo","forEach","relationship","min","minRows","console","warn","max","maxRows","blocks","block","concat","push","labels","has","add","localized","localization","validate","defaultValidate","val","options","hooks","access","admin","editor","afterRead","length","beforeChange","beforeValidate","tabs","tab","unsanitizedTab","unsanitizedBlock","slug"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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E;QACpE,IAAI,YAAYtC,SAASA,MAAML,MAAM,EAAE;YACrCK,MAAML,MAAM,GAAGJ,eAAe;gBAC5BC;gBACAC,oBAAoBJ,iBAAiBW,SAAS,IAAIN,QAAQD;gBAC1DE,QAAQK,MAAML,MAAM;gBACpBC;gBACAC;YACF;QACF;QAEA,IAAIG,MAAMC,IAAI,KAAK,QAAQ;YACzBD,MAAMwC,IAAI,GAAGxC,MAAMwC,IAAI,CAAC1C,GAAG,CAAC,CAAC2C;gBAC3B,MAAMC,iBAAiB;oBAAE,GAAGD,GAAG;gBAAC;gBAChC,IAAInD,WAAWmD,QAAQ,OAAOA,IAAIrC,KAAK,KAAK,aAAa;oBACvDsC,eAAetC,KAAK,GAAGpB,QAAQyD,IAAIvC,IAAI;gBACzC;gBAEAwC,eAAe/C,MAAM,GAAGJ,eAAe;oBACrCC;oBACAC,oBAAoBH,WAAWmD,OAAO,IAAI/C,QAAQD;oBAClDE,QAAQ8C,IAAI9C,MAAM;oBAClBC;oBACAC;gBACF;gBAEA,OAAO6C;YACT;QACF;QAEA,IAAI,YAAY1C,SAASA,MAAMmB,MAAM,EAAE;YACrCnB,MAAMmB,MAAM,GAAGnB,MAAMmB,MAAM,CAACrB,GAAG,CAAC,CAACsB;gBAC/B,MAAMuB,mBAAmB;oBAAE,GAAGvB,KAAK;gBAAC;gBACpCuB,iBAAiBpB,MAAM,GAAG,CAACoB,iBAAiBpB,MAAM,GAC9CxC,aAAa4D,iBAAiBC,IAAI,IAClCD,iBAAiBpB,MAAM;gBAE3BoB,iBAAiBhD,MAAM,GAAGJ,eAAe;oBACvCC;oBACAC,oBAAoB,IAAIC;oBACxBC,QAAQyB,MAAMzB,MAAM;oBACpBC;oBACAC;gBACF;gBAEA,OAAO8C;YACT;QACF;QAEA,OAAO3C;IACT;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/fields/config/sanitize.ts"],"sourcesContent":["import type { Config, SanitizedConfig } from '../../config/types.js'\nimport type { Field } from './types.js'\n\nimport { MissingEditorProp } from '../../errors/MissingEditorProp.js'\nimport {\n DuplicateFieldName,\n InvalidFieldName,\n InvalidFieldRelationship,\n MissingFieldType,\n} from '../../errors/index.js'\nimport { formatLabels, toWords } from '../../utilities/formatLabels.js'\nimport { baseBlockFields } from '../baseFields/baseBlockFields.js'\nimport { baseIDField } from '../baseFields/baseIDField.js'\nimport { setDefaultBeforeDuplicate } from '../setDefaultBeforeDuplicate.js'\nimport validations from '../validations.js'\nimport { fieldAffectsData, tabHasName } from './types.js'\n\ntype Args = {\n config: Config\n existingFieldNames?: Set<string>\n fields: Field[]\n /**\n * If true, a richText field will require an editor property to be set, as the sanitizeFields function will not add it from the payload config if not present.\n *\n * @default false\n */\n requireFieldLevelRichTextEditor?: boolean\n /**\n * If this property is set, RichText fields won't be sanitized immediately. Instead, they will be added to this array as promises\n * so that you can sanitize them together, after the config has been sanitized.\n */\n richTextSanitizationPromises?: Array<(config: SanitizedConfig) => Promise<void>>\n\n /**\n * If not null, will validate that upload and relationship fields do not relate to a collection that is not in this array.\n * This validation will be skipped if validRelationships is null.\n */\n validRelationships: null | string[]\n}\n\nexport const sanitizeFields = async ({\n config,\n existingFieldNames = new Set(),\n fields,\n requireFieldLevelRichTextEditor = false,\n richTextSanitizationPromises,\n validRelationships,\n}: Args): Promise<Field[]> => {\n if (!fields) return []\n\n for (let i = 0; i < fields.length; i++) {\n const field = fields[i]\n\n if (!field.type) throw new MissingFieldType(field)\n\n // assert that field names do not contain forbidden characters\n if (fieldAffectsData(field) && field.name.includes('.')) {\n throw new InvalidFieldName(field, field.name)\n }\n\n // Auto-label\n if (\n 'name' in field &&\n field.name &&\n typeof field.label !== 'object' &&\n typeof field.label !== 'string' &&\n field.label !== false\n ) {\n field.label = toWords(field.name)\n }\n\n if (\n field.type === 'checkbox' &&\n typeof field.defaultValue === 'undefined' &&\n field.required === true\n ) {\n field.defaultValue = false\n }\n\n if (field.type === 'relationship' || field.type === 'upload') {\n if (validRelationships) {\n const relationships = Array.isArray(field.relationTo)\n ? field.relationTo\n : [field.relationTo]\n relationships.forEach((relationship: string) => {\n if (!validRelationships.includes(relationship)) {\n throw new InvalidFieldRelationship(field, relationship)\n }\n })\n }\n\n if (field.type === 'relationship') {\n if (field.min && !field.minRows) {\n console.warn(\n `(payload): The \"min\" property is deprecated for the Relationship field \"${field.name}\" and will be removed in a future version. Please use \"minRows\" instead.`,\n )\n }\n if (field.max && !field.maxRows) {\n console.warn(\n `(payload): The \"max\" property is deprecated for the Relationship field \"${field.name}\" and will be removed in a future version. Please use \"maxRows\" instead.`,\n )\n }\n field.minRows = field.minRows || field.min\n field.maxRows = field.maxRows || field.max\n }\n }\n\n if (field.type === 'blocks' && field.blocks) {\n field.blocks = field.blocks.map((block) => ({\n ...block,\n fields: block.fields.concat(baseBlockFields),\n }))\n }\n\n if (field.type === 'array' && field.fields) {\n field.fields.push(baseIDField)\n }\n\n if ((field.type === 'blocks' || field.type === 'array') && field.label) {\n field.labels = field.labels || formatLabels(field.name)\n }\n\n if (fieldAffectsData(field)) {\n if (existingFieldNames.has(field.name)) {\n throw new DuplicateFieldName(field.name)\n } else if (!['blockName', 'id'].includes(field.name)) {\n existingFieldNames.add(field.name)\n }\n\n if (field.localized && !config.localization) delete field.localized\n\n if (typeof field.validate === 'undefined') {\n const defaultValidate = validations[field.type]\n if (defaultValidate) {\n field.validate = (val, options) => defaultValidate(val, { ...field, ...options })\n } else {\n field.validate = () => true\n }\n }\n\n if (!field.hooks) field.hooks = {}\n if (!field.access) field.access = {}\n\n setDefaultBeforeDuplicate(field)\n }\n\n if (!field.admin) {\n field.admin = {}\n }\n\n // Make sure that the richText field has an editor\n if (field.type === 'richText') {\n const sanitizeRichText = async (_config: SanitizedConfig) => {\n if (!field.editor) {\n if (_config.editor && !requireFieldLevelRichTextEditor) {\n // config.editor should be sanitized at this point\n field.editor = _config.editor\n } else {\n throw new MissingEditorProp(field)\n }\n }\n\n if (typeof field.editor === 'function') {\n field.editor = await field.editor({ config: _config })\n }\n\n // Add editor adapter hooks to field hooks\n if (!field.hooks) field.hooks = {}\n\n const mergeHooks = (hookName: keyof typeof field.editor.hooks) => {\n if (typeof field.editor === 'function') return\n\n if (field.editor?.hooks?.[hookName]?.length) {\n field.hooks[hookName] = field.hooks[hookName]\n ? field.hooks[hookName].concat(field.editor.hooks[hookName])\n : [...field.editor.hooks[hookName]]\n }\n }\n\n mergeHooks('afterRead')\n mergeHooks('afterChange')\n mergeHooks('beforeChange')\n mergeHooks('beforeValidate')\n mergeHooks('beforeDuplicate')\n }\n if (richTextSanitizationPromises) {\n richTextSanitizationPromises.push(sanitizeRichText)\n } else {\n await sanitizeRichText(config as unknown as SanitizedConfig)\n }\n }\n\n if ('fields' in field && field.fields) {\n field.fields = await sanitizeFields({\n config,\n existingFieldNames: fieldAffectsData(field) ? new Set() : existingFieldNames,\n fields: field.fields,\n requireFieldLevelRichTextEditor,\n richTextSanitizationPromises,\n validRelationships,\n })\n }\n\n if (field.type === 'tabs') {\n for (let j = 0; j < field.tabs.length; j++) {\n const tab = field.tabs[j]\n if (tabHasName(tab) && typeof tab.label === 'undefined') {\n tab.label = toWords(tab.name)\n }\n\n tab.fields = await sanitizeFields({\n config,\n existingFieldNames: tabHasName(tab) ? new Set() : existingFieldNames,\n fields: tab.fields,\n requireFieldLevelRichTextEditor,\n richTextSanitizationPromises,\n validRelationships,\n })\n field.tabs[j] = tab\n }\n }\n\n if ('blocks' in field && field.blocks) {\n for (let j = 0; j < field.blocks.length; j++) {\n const block = field.blocks[j]\n block.labels = !block.labels ? formatLabels(block.slug) : block.labels\n\n block.fields = await sanitizeFields({\n config,\n existingFieldNames: new Set(),\n fields: block.fields,\n requireFieldLevelRichTextEditor,\n richTextSanitizationPromises,\n validRelationships,\n })\n field.blocks[j] = block\n }\n }\n\n fields[i] = field\n }\n\n return fields\n}\n"],"names":["MissingEditorProp","DuplicateFieldName","InvalidFieldName","InvalidFieldRelationship","MissingFieldType","formatLabels","toWords","baseBlockFields","baseIDField","setDefaultBeforeDuplicate","validations","fieldAffectsData","tabHasName","sanitizeFields","config","existingFieldNames","Set","fields","requireFieldLevelRichTextEditor","richTextSanitizationPromises","validRelationships","i","length","field","type","name","includes","label","defaultValue","required","relationships","Array","isArray","relationTo","forEach","relationship","min","minRows","console","warn","max","maxRows","blocks","map","block","concat","push","labels","has","add","localized","localization","validate","defaultValidate","val","options","hooks","access","admin","sanitizeRichText","_config","editor","mergeHooks","hookName","j","tabs","tab","slug"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,iBAAiB,QAAQ,oCAAmC;AACrE,SACEC,kBAAkB,EAClBC,gBAAgB,EAChBC,wBAAwB,EACxBC,gBAAgB,QACX,wBAAuB;AAC9B,SAASC,YAAY,EAAEC,OAAO,QAAQ,kCAAiC;AACvE,SAASC,eAAe,QAAQ,mCAAkC;AAClE,SAASC,WAAW,QAAQ,+BAA8B;AAC1D,SAASC,yBAAyB,QAAQ,kCAAiC;AAC3E,OAAOC,iBAAiB,oBAAmB;AAC3C,SAASC,gBAAgB,EAAEC,UAAU,QAAQ,aAAY;AAyBzD,OAAO,MAAMC,iBAAiB,OAAO,EACnCC,MAAM,EACNC,qBAAqB,IAAIC,KAAK,EAC9BC,MAAM,EACNC,kCAAkC,KAAK,EACvCC,4BAA4B,EAC5BC,kBAAkB,EACb;IACL,IAAI,CAACH,QAAQ,OAAO,EAAE;IAEtB,IAAK,IAAII,IAAI,GAAGA,IAAIJ,OAAOK,MAAM,EAAED,IAAK;QACtC,MAAME,QAAQN,MAAM,CAACI,EAAE;QAEvB,IAAI,CAACE,MAAMC,IAAI,EAAE,MAAM,IAAIpB,iBAAiBmB;QAE5C,8DAA8D;QAC9D,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