payload 3.0.0-beta.43 → 3.0.0-beta.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin.js +6 -3
- package/dist/bin/generateTypes.d.ts +3 -1
- package/dist/bin/generateTypes.d.ts.map +1 -1
- package/dist/bin/generateTypes.js +4 -3
- package/dist/bin/generateTypes.js.map +1 -1
- package/dist/collections/config/sanitize.d.ts.map +1 -1
- package/dist/collections/config/sanitize.js +2 -1
- package/dist/collections/config/sanitize.js.map +1 -1
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +1 -0
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/find.d.ts.map +1 -1
- package/dist/config/find.js +14 -16
- package/dist/config/find.js.map +1 -1
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +1 -0
- package/dist/config/schema.js.map +1 -1
- package/dist/config/types.d.ts +5 -0
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js.map +1 -1
- package/dist/exports/versions.d.ts +1 -0
- package/dist/exports/versions.d.ts.map +1 -1
- package/dist/exports/versions.js +1 -0
- package/dist/exports/versions.js.map +1 -1
- package/dist/globals/config/sanitize.d.ts.map +1 -1
- package/dist/globals/config/sanitize.js +7 -2
- package/dist/globals/config/sanitize.js.map +1 -1
- package/dist/globals/config/schema.d.ts.map +1 -1
- package/dist/globals/config/schema.js +2 -1
- package/dist/globals/config/schema.js.map +1 -1
- package/dist/globals/operations/update.d.ts.map +1 -1
- package/dist/globals/operations/update.js +1 -1
- package/dist/globals/operations/update.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -1
- package/dist/versions/defaults.d.ts +4 -0
- package/dist/versions/defaults.d.ts.map +1 -0
- package/dist/versions/defaults.js +5 -0
- package/dist/versions/defaults.js.map +1 -0
- package/package.json +2 -2
package/dist/config/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/config/types.ts"],"sourcesContent":["import type {\n DefaultTranslationsObject,\n I18nClient,\n I18nOptions,\n TFunction,\n} from '@payloadcms/translations'\nimport type { Options as ExpressFileUploadOptions } from 'express-fileupload'\nimport type GraphQL from 'graphql'\nimport type { Metadata as NextMetadata } from 'next'\nimport type { DestinationStream, LoggerOptions } from 'pino'\nimport type React from 'react'\nimport type { JSX } 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 { Permissions } from '../auth/index.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 { GeneratedTypes, 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 OGImageConfig = {\n alt?: string\n height?: number | string\n type?: string\n url: string\n width?: number | string\n}\n\nexport type OpenGraphConfig = {\n description?: string\n images?: OGImageConfig | OGImageConfig[]\n siteName?: string\n title?: string\n}\n\nexport type IconConfig = {\n color?: string\n /**\n * @see https://developer.mozilla.org/docs/Web/API/HTMLImageElement/fetchPriority\n */\n fetchPriority?: 'auto' | 'high' | 'low'\n media?: string\n /** defaults to rel=\"icon\" */\n rel?: string\n sizes?: string\n type?: string\n url: string\n}\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 * Overrides the auto-generated <meta name=\"description\"> of admin pages\n * @example `\"This is my custom CMS built with Payload.\"`\n */\n description?: string\n /**\n * Icons to be rendered by devices and browsers.\n *\n * For example browser tabs, phone home screens, and search engine results.\n */\n icons?: IconConfig\n /**\n * Overrides the auto-generated <meta name=\"keywords\"> of admin pages\n * @example `\"CMS, Payload, Custom\"`\n */\n keywords?: string\n /**\n * Metadata to be rendered as `og` meta tags in the head of the Admin Panel.\n *\n * For example when sharing the Admin Panel on social media or through messaging services.\n */\n openGraph?: OpenGraphConfig\n /**\n * Overrides the auto-generated <title> of admin pages\n * @example `\"My Admin Panel\"`\n */\n title?: string\n /**\n * String to append to the auto-generated <title> of admin pages\n * @example `\" - Custom CMS\"`\n */\n titleSuffix?: 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<TData = any> = {\n /**\n * The relevant resource that is being accessed.\n *\n * `data` is null when a list is requested\n */\n data?: TData\n /** ID of the resource being accessed */\n id?: number | string\n /** If true, the request is for a static file */\n isReadingStaticFile?: boolean\n /** The original request that requires an access check */\n req: PayloadRequestWithData\n}\n\n/**\n * Access function runs on the server\n * and is sent to the client allowing the dashboard to show accessible data and actions.\n *\n * @see https://payloadcms.com/docs/access-control/overview\n */\nexport type Access<TData = any> = (args: AccessArgs<TData>) => AccessResult | Promise<AccessResult>\n\n/** Web Request/Response model, but the req has more payload specific properties added to it. */\nexport type PayloadHandler = (req: PayloadRequest) => Promise<Response> | Response\n\n/**\n * Docs: https://payloadcms.com/docs/rest-api/overview#custom-endpoints\n */\nexport type Endpoint = {\n /** Extension point to add your custom data. */\n custom?: Record<string, any>\n\n /**\n * Middleware that will be called when the path/method matches\n *\n * Compatible with Web Request/Response Model\n */\n handler: PayloadHandler\n /** HTTP method (or \"all\") */\n method: 'connect' | 'delete' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put'\n /**\n * Pattern that should match the path of the incoming request\n *\n * Compatible with the Express router\n */\n path: string\n /**\n * Please add \"root\" routes under the /api folder in the Payload Project.\n * https://nextjs.org/docs/app/api-reference/file-conventions/route\n *\n * @deprecated in 3.0\n */\n root?: never\n}\n\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 [key: string]: unknown\n i18n: I18nClient\n locale?: Locale\n params?: { [key: string]: string | string[] | undefined }\n payload: Payload\n permissions?: Permissions\n searchParams?: { [key: string]: string | string[] | undefined }\n user?: GeneratedTypes['user']\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 CustomComponent<TAdditionalProps extends any = any> = React.ComponentType<\n TAdditionalProps & Partial<ServerProps>\n>\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 livePreview?: LivePreviewConfig & {\n collections?: string[]\n globals?: string[]\n }\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 account?: string\n /** The route for the create first user page. */\n createFirstUser?: string\n /** The route for the forgot password page. */\n forgot?: string\n /** The route the user will be redirected to after being inactive for too long. */\n inactivity?: string\n /** The route for the login page. */\n login?: string\n /** The route for the logout page. */\n logout?: string\n /** The route for the unauthorized page. */\n unauthorized?: string\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 /** 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 * Filepath to write the generated schema to\n */\n schemaOutputFile?: string\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<{} | 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 * 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?:\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 /** 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 = ({ t }: { t: TFunction }) => string\n\nexport type EntityDescription = EntityDescriptionFunction | Record<string, string> | string\n\nexport type { EmailAdapter, SendEmailOptions }\n"],"names":["serverProps"],"rangeMappings":";;;;;;;;","mappings":"AAkVA,OAAO,MAAMA,cAAqC;IAChD;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAA"}
|
|
1
|
+
{"version":3,"sources":["../../src/config/types.ts"],"sourcesContent":["import type {\n DefaultTranslationsObject,\n I18nClient,\n I18nOptions,\n TFunction,\n} from '@payloadcms/translations'\nimport type { Options as ExpressFileUploadOptions } from 'express-fileupload'\nimport type GraphQL from 'graphql'\nimport type { Metadata as NextMetadata } from 'next'\nimport type { DestinationStream, LoggerOptions } from 'pino'\nimport type React from 'react'\nimport type { JSX } 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 { Permissions } from '../auth/index.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 { GeneratedTypes, 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 OGImageConfig = {\n alt?: string\n height?: number | string\n type?: string\n url: string\n width?: number | string\n}\n\nexport type OpenGraphConfig = {\n description?: string\n images?: OGImageConfig | OGImageConfig[]\n siteName?: string\n title?: string\n}\n\nexport type IconConfig = {\n color?: string\n /**\n * @see https://developer.mozilla.org/docs/Web/API/HTMLImageElement/fetchPriority\n */\n fetchPriority?: 'auto' | 'high' | 'low'\n media?: string\n /** defaults to rel=\"icon\" */\n rel?: string\n sizes?: string\n type?: string\n url: string\n}\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 * Overrides the auto-generated <meta name=\"description\"> of admin pages\n * @example `\"This is my custom CMS built with Payload.\"`\n */\n description?: string\n /**\n * Icons to be rendered by devices and browsers.\n *\n * For example browser tabs, phone home screens, and search engine results.\n */\n icons?: IconConfig\n /**\n * Overrides the auto-generated <meta name=\"keywords\"> of admin pages\n * @example `\"CMS, Payload, Custom\"`\n */\n keywords?: string\n /**\n * Metadata to be rendered as `og` meta tags in the head of the Admin Panel.\n *\n * For example when sharing the Admin Panel on social media or through messaging services.\n */\n openGraph?: OpenGraphConfig\n /**\n * Overrides the auto-generated <title> of admin pages\n * @example `\"My Admin Panel\"`\n */\n title?: string\n /**\n * String to append to the auto-generated <title> of admin pages\n * @example `\" - Custom CMS\"`\n */\n titleSuffix?: 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<TData = any> = {\n /**\n * The relevant resource that is being accessed.\n *\n * `data` is null when a list is requested\n */\n data?: TData\n /** ID of the resource being accessed */\n id?: number | string\n /** If true, the request is for a static file */\n isReadingStaticFile?: boolean\n /** The original request that requires an access check */\n req: PayloadRequestWithData\n}\n\n/**\n * Access function runs on the server\n * and is sent to the client allowing the dashboard to show accessible data and actions.\n *\n * @see https://payloadcms.com/docs/access-control/overview\n */\nexport type Access<TData = any> = (args: AccessArgs<TData>) => AccessResult | Promise<AccessResult>\n\n/** Web Request/Response model, but the req has more payload specific properties added to it. */\nexport type PayloadHandler = (req: PayloadRequest) => Promise<Response> | Response\n\n/**\n * Docs: https://payloadcms.com/docs/rest-api/overview#custom-endpoints\n */\nexport type Endpoint = {\n /** Extension point to add your custom data. */\n custom?: Record<string, any>\n\n /**\n * Middleware that will be called when the path/method matches\n *\n * Compatible with Web Request/Response Model\n */\n handler: PayloadHandler\n /** HTTP method (or \"all\") */\n method: 'connect' | 'delete' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put'\n /**\n * Pattern that should match the path of the incoming request\n *\n * Compatible with the Express router\n */\n path: string\n /**\n * Please add \"root\" routes under the /api folder in the Payload Project.\n * https://nextjs.org/docs/app/api-reference/file-conventions/route\n *\n * @deprecated in 3.0\n */\n root?: never\n}\n\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 [key: string]: unknown\n i18n: I18nClient\n locale?: Locale\n params?: { [key: string]: string | string[] | undefined }\n payload: Payload\n permissions?: Permissions\n searchParams?: { [key: string]: string | string[] | undefined }\n user?: GeneratedTypes['user']\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 CustomComponent<TAdditionalProps extends any = any> = React.ComponentType<\n TAdditionalProps & Partial<ServerProps>\n>\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 livePreview?: LivePreviewConfig & {\n collections?: string[]\n globals?: string[]\n }\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 account?: string\n /** The route for the create first user page. */\n createFirstUser?: string\n /** The route for the forgot password page. */\n forgot?: string\n /** The route the user will be redirected to after being inactive for too long. */\n inactivity?: string\n /** The route for the login page. */\n login?: string\n /** The route for the logout page. */\n logout?: string\n /** The route for the unauthorized page. */\n unauthorized?: string\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 /** 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 * Filepath to write the generated schema to\n */\n schemaOutputFile?: string\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<{} | 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 * 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 /**\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 * 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 = ({ t }: { t: TFunction }) => string\n\nexport type EntityDescription = EntityDescriptionFunction | Record<string, string> | string\n\nexport type { EmailAdapter, SendEmailOptions }\n"],"names":["serverProps"],"rangeMappings":";;;;;;;;","mappings":"AAkVA,OAAO,MAAMA,cAAqC;IAChD;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { buildVersionCollectionFields } from '../versions/buildCollectionFields.js';
|
|
2
2
|
export { buildVersionGlobalFields } from '../versions/buildGlobalFields.js';
|
|
3
|
+
export { versionDefaults } from '../versions/defaults.js';
|
|
3
4
|
export { deleteCollectionVersions } from '../versions/deleteCollectionVersions.js';
|
|
4
5
|
export { enforceMaxVersions } from '../versions/enforceMaxVersions.js';
|
|
5
6
|
export { getLatestCollectionVersion } from '../versions/getLatestCollectionVersion.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../../src/exports/versions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAA;AACnF,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAA;AAC3E,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAA;AAClF,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AACtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAA;AACtF,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAA;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AACxD,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA"}
|
|
1
|
+
{"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../../src/exports/versions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAA;AACnF,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAA;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAA;AAClF,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AACtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAA;AACtF,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAA;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AACxD,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA"}
|
package/dist/exports/versions.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { buildVersionCollectionFields } from '../versions/buildCollectionFields.js';
|
|
2
2
|
export { buildVersionGlobalFields } from '../versions/buildGlobalFields.js';
|
|
3
|
+
export { versionDefaults } from '../versions/defaults.js';
|
|
3
4
|
export { deleteCollectionVersions } from '../versions/deleteCollectionVersions.js';
|
|
4
5
|
export { enforceMaxVersions } from '../versions/enforceMaxVersions.js';
|
|
5
6
|
export { getLatestCollectionVersion } from '../versions/getLatestCollectionVersion.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/exports/versions.ts"],"sourcesContent":["export { buildVersionCollectionFields } from '../versions/buildCollectionFields.js'\nexport { buildVersionGlobalFields } from '../versions/buildGlobalFields.js'\nexport { deleteCollectionVersions } from '../versions/deleteCollectionVersions.js'\nexport { enforceMaxVersions } from '../versions/enforceMaxVersions.js'\nexport { getLatestCollectionVersion } from '../versions/getLatestCollectionVersion.js'\nexport { getLatestGlobalVersion } from '../versions/getLatestGlobalVersion.js'\nexport { saveVersion } from '../versions/saveVersion.js'\nexport type { TypeWithVersion } from '../versions/types.js'\n"],"names":["buildVersionCollectionFields","buildVersionGlobalFields","deleteCollectionVersions","enforceMaxVersions","getLatestCollectionVersion","getLatestGlobalVersion","saveVersion"],"rangeMappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/exports/versions.ts"],"sourcesContent":["export { buildVersionCollectionFields } from '../versions/buildCollectionFields.js'\nexport { buildVersionGlobalFields } from '../versions/buildGlobalFields.js'\nexport { versionDefaults } from '../versions/defaults.js'\nexport { deleteCollectionVersions } from '../versions/deleteCollectionVersions.js'\nexport { enforceMaxVersions } from '../versions/enforceMaxVersions.js'\nexport { getLatestCollectionVersion } from '../versions/getLatestCollectionVersion.js'\nexport { getLatestGlobalVersion } from '../versions/getLatestGlobalVersion.js'\nexport { saveVersion } from '../versions/saveVersion.js'\nexport type { TypeWithVersion } from '../versions/types.js'\n"],"names":["buildVersionCollectionFields","buildVersionGlobalFields","versionDefaults","deleteCollectionVersions","enforceMaxVersions","getLatestCollectionVersion","getLatestGlobalVersion","saveVersion"],"rangeMappings":";;;;;;;","mappings":"AAAA,SAASA,4BAA4B,QAAQ,uCAAsC;AACnF,SAASC,wBAAwB,QAAQ,mCAAkC;AAC3E,SAASC,eAAe,QAAQ,0BAAyB;AACzD,SAASC,wBAAwB,QAAQ,0CAAyC;AAClF,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SAASC,0BAA0B,QAAQ,4CAA2C;AACtF,SAASC,sBAAsB,QAAQ,wCAAuC;AAC9E,SAASC,WAAW,QAAQ,6BAA4B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../src/globals/config/sanitize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../src/globals/config/sanitize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAUvD,eAAO,MAAM,eAAe,WAClB,MAAM,iCAKiB,MAAM,CAAC,MAAM,EAAE,eAAe,KAAK,QAAQ,IAAI,CAAC,CAAC,KAC/E,QAAQ,qBAAqB,EAAE,CAmGjC,CAAA"}
|
|
@@ -4,6 +4,7 @@ import { fieldAffectsData } from '../../fields/config/types.js';
|
|
|
4
4
|
import mergeBaseFields from '../../fields/mergeBaseFields.js';
|
|
5
5
|
import { toWords } from '../../utilities/formatLabels.js';
|
|
6
6
|
import baseVersionFields from '../../versions/baseFields.js';
|
|
7
|
+
import { versionDefaults } from '../../versions/defaults.js';
|
|
7
8
|
export const sanitizeGlobals = async (config, /**
|
|
8
9
|
* If this property is set, RichText fields won't be sanitized immediately. Instead, they will be added to this array as promises
|
|
9
10
|
* so that you can sanitize them together, after the config has been sanitized.
|
|
@@ -33,14 +34,18 @@ export const sanitizeGlobals = async (config, /**
|
|
|
33
34
|
if (global.versions.drafts) {
|
|
34
35
|
if (global.versions.drafts === true) {
|
|
35
36
|
global.versions.drafts = {
|
|
36
|
-
autosave: false
|
|
37
|
+
autosave: false,
|
|
38
|
+
validate: false
|
|
37
39
|
};
|
|
38
40
|
}
|
|
39
41
|
if (global.versions.drafts.autosave === true) {
|
|
40
42
|
global.versions.drafts.autosave = {
|
|
41
|
-
interval:
|
|
43
|
+
interval: versionDefaults.autosaveInterval
|
|
42
44
|
};
|
|
43
45
|
}
|
|
46
|
+
if (global.versions.drafts.validate === undefined) {
|
|
47
|
+
global.versions.drafts.validate = false;
|
|
48
|
+
}
|
|
44
49
|
global.fields = mergeBaseFields(global.fields, baseVersionFields);
|
|
45
50
|
}
|
|
46
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/globals/config/sanitize.ts"],"sourcesContent":["import type { Config, SanitizedConfig } from '../../config/types.js'\nimport type { SanitizedGlobalConfig } from './types.js'\n\nimport defaultAccess from '../../auth/defaultAccess.js'\nimport { sanitizeFields } from '../../fields/config/sanitize.js'\nimport { fieldAffectsData } from '../../fields/config/types.js'\nimport mergeBaseFields from '../../fields/mergeBaseFields.js'\nimport { toWords } from '../../utilities/formatLabels.js'\nimport baseVersionFields from '../../versions/baseFields.js'\n\nexport const sanitizeGlobals = async (\n config: Config,\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): Promise<SanitizedGlobalConfig[]> => {\n const { collections, globals } = config\n\n for (let i = 0; i < globals.length; i++) {\n const global = globals[i]\n global.label = global.label || toWords(global.slug)\n\n // /////////////////////////////////\n // Ensure that collection has required object structure\n // /////////////////////////////////\n\n global.endpoints = global.endpoints ?? []\n if (!global.hooks) global.hooks = {}\n if (!global.access) global.access = {}\n if (!global.admin) global.admin = {}\n\n if (!global.access.read) global.access.read = defaultAccess\n if (!global.access.update) global.access.update = defaultAccess\n\n if (!global.hooks.beforeValidate) global.hooks.beforeValidate = []\n if (!global.hooks.beforeChange) global.hooks.beforeChange = []\n if (!global.hooks.afterChange) global.hooks.afterChange = []\n if (!global.hooks.beforeRead) global.hooks.beforeRead = []\n if (!global.hooks.afterRead) global.hooks.afterRead = []\n\n if (global.versions) {\n if (global.versions === true) global.versions = { drafts: false }\n\n if (global.versions.drafts) {\n if (global.versions.drafts === true) {\n global.versions.drafts = {\n autosave: false,\n }\n }\n\n if (global.versions.drafts.autosave === true) {\n global.versions.drafts.autosave = {\n interval:
|
|
1
|
+
{"version":3,"sources":["../../../src/globals/config/sanitize.ts"],"sourcesContent":["import type { Config, SanitizedConfig } from '../../config/types.js'\nimport type { SanitizedGlobalConfig } from './types.js'\n\nimport defaultAccess from '../../auth/defaultAccess.js'\nimport { sanitizeFields } from '../../fields/config/sanitize.js'\nimport { fieldAffectsData } from '../../fields/config/types.js'\nimport mergeBaseFields from '../../fields/mergeBaseFields.js'\nimport { toWords } from '../../utilities/formatLabels.js'\nimport baseVersionFields from '../../versions/baseFields.js'\nimport { versionDefaults } from '../../versions/defaults.js'\n\nexport const sanitizeGlobals = async (\n config: Config,\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): Promise<SanitizedGlobalConfig[]> => {\n const { collections, globals } = config\n\n for (let i = 0; i < globals.length; i++) {\n const global = globals[i]\n global.label = global.label || toWords(global.slug)\n\n // /////////////////////////////////\n // Ensure that collection has required object structure\n // /////////////////////////////////\n\n global.endpoints = global.endpoints ?? []\n if (!global.hooks) global.hooks = {}\n if (!global.access) global.access = {}\n if (!global.admin) global.admin = {}\n\n if (!global.access.read) global.access.read = defaultAccess\n if (!global.access.update) global.access.update = defaultAccess\n\n if (!global.hooks.beforeValidate) global.hooks.beforeValidate = []\n if (!global.hooks.beforeChange) global.hooks.beforeChange = []\n if (!global.hooks.afterChange) global.hooks.afterChange = []\n if (!global.hooks.beforeRead) global.hooks.beforeRead = []\n if (!global.hooks.afterRead) global.hooks.afterRead = []\n\n if (global.versions) {\n if (global.versions === true) global.versions = { drafts: false }\n\n if (global.versions.drafts) {\n if (global.versions.drafts === true) {\n global.versions.drafts = {\n autosave: false,\n validate: false,\n }\n }\n\n if (global.versions.drafts.autosave === true) {\n global.versions.drafts.autosave = {\n interval: versionDefaults.autosaveInterval,\n }\n }\n\n if (global.versions.drafts.validate === undefined) {\n global.versions.drafts.validate = false\n }\n\n global.fields = mergeBaseFields(global.fields, baseVersionFields)\n }\n }\n\n if (!global.custom) global.custom = {}\n\n // /////////////////////////////////\n // Sanitize fields\n // /////////////////////////////////\n let hasUpdatedAt = null\n let hasCreatedAt = null\n global.fields.some((field) => {\n if (fieldAffectsData(field)) {\n if (field.name === 'updatedAt') hasUpdatedAt = true\n if (field.name === 'createdAt') hasCreatedAt = true\n }\n return hasCreatedAt && hasUpdatedAt\n })\n if (!hasUpdatedAt) {\n global.fields.push({\n name: 'updatedAt',\n type: 'date',\n admin: {\n disableBulkEdit: true,\n hidden: true,\n },\n label: ({ t }) => t('general:updatedAt'),\n })\n }\n if (!hasCreatedAt) {\n global.fields.push({\n name: 'createdAt',\n type: 'date',\n admin: {\n disableBulkEdit: true,\n hidden: true,\n },\n label: ({ t }) => t('general:createdAt'),\n })\n }\n\n const validRelationships = collections.map((c) => c.slug) || []\n global.fields = await sanitizeFields({\n config,\n fields: global.fields,\n richTextSanitizationPromises,\n validRelationships,\n })\n\n globals[i] = global\n }\n\n return globals as SanitizedGlobalConfig[]\n}\n"],"names":["defaultAccess","sanitizeFields","fieldAffectsData","mergeBaseFields","toWords","baseVersionFields","versionDefaults","sanitizeGlobals","config","richTextSanitizationPromises","collections","globals","i","length","global","label","slug","endpoints","hooks","access","admin","read","update","beforeValidate","beforeChange","afterChange","beforeRead","afterRead","versions","drafts","autosave","validate","interval","autosaveInterval","undefined","fields","custom","hasUpdatedAt","hasCreatedAt","some","field","name","push","type","disableBulkEdit","hidden","t","validRelationships","map","c"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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ACA,OAAOA,gBAAgBD;QACzB;QACA,IAAI,CAACA,cAAc;YACjBvB,OAAOqB,MAAM,CAACO,IAAI,CAAC;gBACjBD,MAAM;gBACNE,MAAM;gBACNvB,OAAO;oBACLwB,iBAAiB;oBACjBC,QAAQ;gBACV;gBACA9B,OAAO,CAAC,EAAE+B,CAAC,EAAE,GAAKA,EAAE;YACtB;QACF;QACA,IAAI,CAACR,cAAc;YACjBxB,OAAOqB,MAAM,CAACO,IAAI,CAAC;gBACjBD,MAAM;gBACNE,MAAM;gBACNvB,OAAO;oBACLwB,iBAAiB;oBACjBC,QAAQ;gBACV;gBACA9B,OAAO,CAAC,EAAE+B,CAAC,EAAE,GAAKA,EAAE;YACtB;QACF;QAEA,MAAMC,qBAAqBrC,YAAYsC,GAAG,CAAC,CAACC,IAAMA,EAAEjC,IAAI,KAAK,EAAE;QAC/DF,OAAOqB,MAAM,GAAG,MAAMlC,eAAe;YACnCO;YACA2B,QAAQrB,OAAOqB,MAAM;YACrB1B;YACAsC;QACF;QAEApC,OAAO,CAACC,EAAE,GAAGE;IACf;IAEA,OAAOH;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/globals/config/schema.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAA;AAUrB,QAAA,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/globals/config/schema.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAA;AAUrB,QAAA,MAAM,YAAY,uBA2FN,CAAA;AAEZ,eAAe,YAAY,CAAA"}
|
|
@@ -68,7 +68,8 @@ const globalSchema = joi.object().keys({
|
|
|
68
68
|
drafts: joi.alternatives().try(joi.object({
|
|
69
69
|
autosave: joi.alternatives().try(joi.boolean(), joi.object({
|
|
70
70
|
interval: joi.number()
|
|
71
|
-
}))
|
|
71
|
+
})),
|
|
72
|
+
validate: joi.boolean()
|
|
72
73
|
}), joi.boolean()),
|
|
73
74
|
max: joi.number()
|
|
74
75
|
}), joi.boolean())
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/globals/config/schema.ts"],"sourcesContent":["import joi from 'joi'\n\nimport { endpointsSchema } from '../../config/schema.js'\nimport {\n componentSchema,\n customViewSchema,\n livePreviewSchema,\n} from '../../config/shared/componentSchema.js'\nimport { openGraphSchema } from '../../config/shared/openGraphSchema.js'\n\nconst globalSchema = joi\n .object()\n .keys({\n slug: joi.string().required(),\n access: joi.object({\n read: joi.func(),\n readVersions: joi.func(),\n update: joi.func(),\n }),\n admin: joi.object({\n components: joi.object({\n elements: joi.object({\n Description: componentSchema,\n PreviewButton: componentSchema,\n PublishButton: componentSchema,\n SaveButton: componentSchema,\n SaveDraftButton: componentSchema,\n }),\n views: joi.object({\n Edit: joi.alternatives().try(\n componentSchema,\n joi.object({\n API: joi.alternatives().try(componentSchema, customViewSchema),\n Default: joi.alternatives().try(componentSchema, customViewSchema),\n Preview: joi.alternatives().try(componentSchema, customViewSchema),\n Version: joi.alternatives().try(componentSchema, customViewSchema),\n Versions: joi.alternatives().try(componentSchema, customViewSchema),\n // Relationships\n // References\n }),\n ),\n }),\n }),\n custom: joi.object().pattern(joi.string(), joi.any()),\n description: joi\n .alternatives()\n .try(joi.func(), joi.object().pattern(joi.string(), [joi.string()]), joi.string()),\n group: joi\n .alternatives()\n .try(joi.string(), joi.object().pattern(joi.string(), [joi.string()])),\n hidden: joi.alternatives().try(joi.boolean(), joi.func()),\n hideAPIURL: joi.boolean(),\n livePreview: joi.object(livePreviewSchema),\n meta: joi.object({\n description: joi.string(),\n openGraph: openGraphSchema,\n }),\n preview: joi.func(),\n }),\n custom: joi.object().pattern(joi.string(), joi.any()),\n dbName: joi.alternatives().try(joi.string(), joi.func()),\n endpoints: endpointsSchema,\n fields: joi.array(),\n graphQL: joi.alternatives().try(\n joi.object().keys({\n name: joi.string(),\n }),\n joi.boolean(),\n ),\n hooks: joi.object({\n afterChange: joi.array().items(joi.func()),\n afterRead: joi.array().items(joi.func()),\n beforeChange: joi.array().items(joi.func()),\n beforeRead: joi.array().items(joi.func()),\n beforeValidate: joi.array().items(joi.func()),\n }),\n label: joi\n .alternatives()\n .try(joi.func(), joi.string(), joi.object().pattern(joi.string(), [joi.string()])),\n typescript: joi.object().keys({\n interface: joi.string(),\n }),\n versions: joi.alternatives().try(\n joi.object({\n drafts: joi.alternatives().try(\n joi.object({\n autosave: joi.alternatives().try(\n joi.boolean(),\n joi.object({\n interval: joi.number(),\n }),\n ),\n }),\n joi.boolean(),\n ),\n max: joi.number(),\n }),\n joi.boolean(),\n ),\n })\n .unknown()\n\nexport default globalSchema\n"],"names":["joi","endpointsSchema","componentSchema","customViewSchema","livePreviewSchema","openGraphSchema","globalSchema","object","keys","slug","string","required","access","read","func","readVersions","update","admin","components","elements","Description","PreviewButton","PublishButton","SaveButton","SaveDraftButton","views","Edit","alternatives","try","API","Default","Preview","Version","Versions","custom","pattern","any","description","group","hidden","boolean","hideAPIURL","livePreview","meta","openGraph","preview","dbName","endpoints","fields","array","graphQL","name","hooks","afterChange","items","afterRead","beforeChange","beforeRead","beforeValidate","label","typescript","interface","versions","drafts","autosave","interval","number","max","unknown"],"rangeMappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/globals/config/schema.ts"],"sourcesContent":["import joi from 'joi'\n\nimport { endpointsSchema } from '../../config/schema.js'\nimport {\n componentSchema,\n customViewSchema,\n livePreviewSchema,\n} from '../../config/shared/componentSchema.js'\nimport { openGraphSchema } from '../../config/shared/openGraphSchema.js'\n\nconst globalSchema = joi\n .object()\n .keys({\n slug: joi.string().required(),\n access: joi.object({\n read: joi.func(),\n readVersions: joi.func(),\n update: joi.func(),\n }),\n admin: joi.object({\n components: joi.object({\n elements: joi.object({\n Description: componentSchema,\n PreviewButton: componentSchema,\n PublishButton: componentSchema,\n SaveButton: componentSchema,\n SaveDraftButton: componentSchema,\n }),\n views: joi.object({\n Edit: joi.alternatives().try(\n componentSchema,\n joi.object({\n API: joi.alternatives().try(componentSchema, customViewSchema),\n Default: joi.alternatives().try(componentSchema, customViewSchema),\n Preview: joi.alternatives().try(componentSchema, customViewSchema),\n Version: joi.alternatives().try(componentSchema, customViewSchema),\n Versions: joi.alternatives().try(componentSchema, customViewSchema),\n // Relationships\n // References\n }),\n ),\n }),\n }),\n custom: joi.object().pattern(joi.string(), joi.any()),\n description: joi\n .alternatives()\n .try(joi.func(), joi.object().pattern(joi.string(), [joi.string()]), joi.string()),\n group: joi\n .alternatives()\n .try(joi.string(), joi.object().pattern(joi.string(), [joi.string()])),\n hidden: joi.alternatives().try(joi.boolean(), joi.func()),\n hideAPIURL: joi.boolean(),\n livePreview: joi.object(livePreviewSchema),\n meta: joi.object({\n description: joi.string(),\n openGraph: openGraphSchema,\n }),\n preview: joi.func(),\n }),\n custom: joi.object().pattern(joi.string(), joi.any()),\n dbName: joi.alternatives().try(joi.string(), joi.func()),\n endpoints: endpointsSchema,\n fields: joi.array(),\n graphQL: joi.alternatives().try(\n joi.object().keys({\n name: joi.string(),\n }),\n joi.boolean(),\n ),\n hooks: joi.object({\n afterChange: joi.array().items(joi.func()),\n afterRead: joi.array().items(joi.func()),\n beforeChange: joi.array().items(joi.func()),\n beforeRead: joi.array().items(joi.func()),\n beforeValidate: joi.array().items(joi.func()),\n }),\n label: joi\n .alternatives()\n .try(joi.func(), joi.string(), joi.object().pattern(joi.string(), [joi.string()])),\n typescript: joi.object().keys({\n interface: joi.string(),\n }),\n versions: joi.alternatives().try(\n joi.object({\n drafts: joi.alternatives().try(\n joi.object({\n autosave: joi.alternatives().try(\n joi.boolean(),\n joi.object({\n interval: joi.number(),\n }),\n ),\n validate: joi.boolean(),\n }),\n joi.boolean(),\n ),\n max: joi.number(),\n }),\n joi.boolean(),\n ),\n })\n .unknown()\n\nexport default globalSchema\n"],"names":["joi","endpointsSchema","componentSchema","customViewSchema","livePreviewSchema","openGraphSchema","globalSchema","object","keys","slug","string","required","access","read","func","readVersions","update","admin","components","elements","Description","PreviewButton","PublishButton","SaveButton","SaveDraftButton","views","Edit","alternatives","try","API","Default","Preview","Version","Versions","custom","pattern","any","description","group","hidden","boolean","hideAPIURL","livePreview","meta","openGraph","preview","dbName","endpoints","fields","array","graphQL","name","hooks","afterChange","items","afterRead","beforeChange","beforeRead","beforeValidate","label","typescript","interface","versions","drafts","autosave","interval","number","validate","max","unknown"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,SAAS,MAAK;AAErB,SAASC,eAAe,QAAQ,yBAAwB;AACxD,SACEC,eAAe,EACfC,gBAAgB,EAChBC,iBAAiB,QACZ,yCAAwC;AAC/C,SAASC,eAAe,QAAQ,yCAAwC;AAExE,MAAMC,eAAeN,IAClBO,MAAM,GACNC,IAAI,CAAC;IACJC,MAAMT,IAAIU,MAAM,GAAGC,QAAQ;IAC3BC,QAAQZ,IAAIO,MAAM,CAAC;QACjBM,MAAMb,IAAIc,IAAI;QACdC,cAAcf,IAAIc,IAAI;QACtBE,QAAQhB,IAAIc,IAAI;IAClB;IACAG,OAAOjB,IAAIO,MAAM,CAAC;QAChBW,YAAYlB,IAAIO,MAAM,CAAC;YACrBY,UAAUnB,IAAIO,MAAM,CAAC;gBACnBa,aAAalB;gBACbmB,eAAenB;gBACfoB,eAAepB;gBACfqB,YAAYrB;gBACZsB,iBAAiBtB;YACnB;YACAuB,OAAOzB,IAAIO,MAAM,CAAC;gBAChBmB,MAAM1B,IAAI2B,YAAY,GAAGC,GAAG,CAC1B1B,iBACAF,IAAIO,MAAM,CAAC;oBACTsB,KAAK7B,IAAI2B,YAAY,GAAGC,GAAG,CAAC1B,iBAAiBC;oBAC7C2B,SAAS9B,IAAI2B,YAAY,GAAGC,GAAG,CAAC1B,iBAAiBC;oBACjD4B,SAAS/B,I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AAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAA;IAChC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,YAAY,EAAE,qBAAqB,CAAA;IACnC,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,GAAG,EAAE,sBAAsB,CAAA;IAC3B,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,eAAO,MAAM,eAAe,iDACpB,KAAK,cAAc,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC,KAC3C,QAAQ,cAAc,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAoQ1C,CAAA"}
|
|
@@ -107,7 +107,7 @@ export const updateOperation = async (args)=>{
|
|
|
107
107
|
global: globalConfig,
|
|
108
108
|
operation: 'update',
|
|
109
109
|
req,
|
|
110
|
-
skipValidation: shouldSaveDraft
|
|
110
|
+
skipValidation: shouldSaveDraft && globalConfig.versions.drafts && !globalConfig.versions.drafts.validate
|
|
111
111
|
});
|
|
112
112
|
// /////////////////////////////////////
|
|
113
113
|
// Update
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/globals/operations/update.ts"],"sourcesContent":["import type { DeepPartial } from 'ts-essentials'\n\nimport type { GeneratedTypes } from '../../index.js'\nimport type { PayloadRequestWithData, Where } from '../../types/index.js'\nimport type { SanitizedGlobalConfig } from '../config/types.js'\n\nimport executeAccess from '../../auth/executeAccess.js'\nimport { afterChange } from '../../fields/hooks/afterChange/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { beforeChange } from '../../fields/hooks/beforeChange/index.js'\nimport { beforeValidate } from '../../fields/hooks/beforeValidate/index.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { getLatestGlobalVersion } from '../../versions/getLatestGlobalVersion.js'\nimport { saveVersion } from '../../versions/saveVersion.js'\n\ntype Args<T extends { [field: number | string | symbol]: unknown }> = {\n autosave?: boolean\n data: DeepPartial<Omit<T, 'id'>>\n depth?: number\n draft?: boolean\n globalConfig: SanitizedGlobalConfig\n overrideAccess?: boolean\n req: PayloadRequestWithData\n showHiddenFields?: boolean\n slug: string\n}\n\nexport const updateOperation = async <TSlug extends keyof GeneratedTypes['globals']>(\n args: Args<GeneratedTypes['globals'][TSlug]>,\n): Promise<GeneratedTypes['globals'][TSlug]> => {\n const {\n slug,\n autosave,\n depth,\n draft: draftArg,\n globalConfig,\n overrideAccess,\n req: { fallbackLocale, locale, payload },\n req,\n showHiddenFields,\n } = args\n\n try {\n const shouldCommit = await initTransaction(req)\n\n let { data } = args\n\n const shouldSaveDraft = Boolean(draftArg && globalConfig.versions?.drafts)\n\n // /////////////////////////////////////\n // 1. Retrieve and execute access\n // /////////////////////////////////////\n\n const accessResults = !overrideAccess\n ? await executeAccess(\n {\n data,\n req,\n },\n globalConfig.access.update,\n )\n : true\n\n // /////////////////////////////////////\n // Retrieve document\n // /////////////////////////////////////\n\n const query: Where = overrideAccess ? undefined : (accessResults as Where)\n\n // /////////////////////////////////////\n // 2. Retrieve document\n // /////////////////////////////////////\n const { global, globalExists } = await getLatestGlobalVersion({\n slug,\n config: globalConfig,\n locale,\n payload,\n req,\n where: query,\n })\n\n let globalJSON: Record<string, unknown> = {}\n\n if (global) {\n globalJSON = JSON.parse(JSON.stringify(global))\n\n if (globalJSON._id) {\n delete globalJSON._id\n }\n }\n\n const originalDoc = await afterRead({\n collection: null,\n context: req.context,\n depth: 0,\n doc: globalJSON,\n draft: draftArg,\n fallbackLocale,\n global: globalConfig,\n locale,\n overrideAccess: true,\n req,\n showHiddenFields,\n })\n\n // /////////////////////////////////////\n // beforeValidate - Fields\n // /////////////////////////////////////\n\n data = await beforeValidate({\n collection: null,\n context: req.context,\n data,\n doc: originalDoc,\n global: globalConfig,\n operation: 'update',\n overrideAccess,\n req,\n })\n\n // /////////////////////////////////////\n // beforeValidate - Global\n // /////////////////////////////////////\n\n await globalConfig.hooks.beforeValidate.reduce(async (priorHook, hook) => {\n await priorHook\n\n data =\n (await hook({\n context: req.context,\n data,\n global: globalConfig,\n originalDoc,\n req,\n })) || data\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // beforeChange - Global\n // /////////////////////////////////////\n\n await globalConfig.hooks.beforeChange.reduce(async (priorHook, hook) => {\n await priorHook\n\n data =\n (await hook({\n context: req.context,\n data,\n global: globalConfig,\n originalDoc,\n req,\n })) || data\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // beforeChange - Fields\n // /////////////////////////////////////\n\n let result = await beforeChange({\n collection: null,\n context: req.context,\n data,\n doc: originalDoc,\n docWithLocales: globalJSON,\n global: globalConfig,\n operation: 'update',\n req,\n skipValidation: shouldSaveDraft,\n })\n\n // /////////////////////////////////////\n // Update\n // /////////////////////////////////////\n\n if (!shouldSaveDraft) {\n if (globalExists) {\n result = await payload.db.updateGlobal({\n slug,\n data: result,\n req,\n })\n } else {\n result = await payload.db.createGlobal({\n slug,\n data: result,\n req,\n })\n }\n }\n\n // /////////////////////////////////////\n // Create version\n // /////////////////////////////////////\n\n if (globalConfig.versions) {\n const { globalType } = result\n result = await saveVersion({\n autosave,\n docWithLocales: {\n ...result,\n createdAt: result.createdAt,\n updatedAt: result.updatedAt,\n },\n draft: shouldSaveDraft,\n global: globalConfig,\n payload,\n req,\n })\n result.globalType = globalType\n }\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n result = await afterRead({\n collection: null,\n context: req.context,\n depth,\n doc: result,\n draft: draftArg,\n fallbackLocale: null,\n global: globalConfig,\n locale,\n overrideAccess,\n req,\n showHiddenFields,\n })\n\n // /////////////////////////////////////\n // afterRead - Global\n // /////////////////////////////////////\n\n await globalConfig.hooks.afterRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n result =\n (await hook({\n context: req.context,\n doc: result,\n global: globalConfig,\n req,\n })) || result\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // afterChange - Fields\n // /////////////////////////////////////\n\n result = await afterChange({\n collection: null,\n context: req.context,\n data,\n doc: result,\n global: globalConfig,\n operation: 'update',\n previousDoc: originalDoc,\n req,\n })\n\n // /////////////////////////////////////\n // afterChange - Global\n // /////////////////////////////////////\n\n await globalConfig.hooks.afterChange.reduce(async (priorHook, hook) => {\n await priorHook\n\n result =\n (await hook({\n context: req.context,\n doc: result,\n global: globalConfig,\n previousDoc: originalDoc,\n req,\n })) || result\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n if (shouldCommit) await commitTransaction(req)\n\n return result\n } catch (error: unknown) {\n await killTransaction(req)\n throw error\n }\n}\n"],"names":["executeAccess","afterChange","afterRead","beforeChange","beforeValidate","commitTransaction","initTransaction","killTransaction","getLatestGlobalVersion","saveVersion","updateOperation","args","slug","autosave","depth","draft","draftArg","globalConfig","overrideAccess","req","fallbackLocale","locale","payload","showHiddenFields","shouldCommit","data","shouldSaveDraft","Boolean","versions","drafts","accessResults","access","update","query","undefined","global","globalExists","config","where","globalJSON","JSON","parse","stringify","_id","originalDoc","collection","context","doc","operation","hooks","reduce","priorHook","hook","Promise","resolve","result","docWithLocales","skipValidation","db","updateGlobal","createGlobal","globalType","createdAt","updatedAt","previousDoc","error"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAMA,OAAOA,mBAAmB,8BAA6B;AACvD,SAAS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B,aAAapB;YACbzB;QACF;QAEA,wCAAwC;QACxC,uBAAuB;QACvB,wCAAwC;QAExC,MAAMF,aAAagC,KAAK,CAAChD,WAAW,CAACiD,MAAM,CAAC,OAAOC,WAAWC;YAC5D,MAAMD;YAENI,SACE,AAAC,MAAMH,KAAK;gBACVN,SAAS3B,IAAI2B,OAAO;gBACpBC,KAAKQ;gBACLpB,QAAQlB;gBACR+C,aAAapB;gBACbzB;YACF,MAAOoC;QACX,GAAGF,QAAQC,OAAO;QAElB,wCAAwC;QACxC,iBAAiB;QACjB,wCAAwC;QAExC,IAAI9B,cAAc,MAAMnB,kBAAkBc;QAE1C,OAAOoC;IACT,EAAE,OAAOU,OAAgB;QACvB,MAAM1D,gBAAgBY;QACtB,MAAM8C;IACR;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/globals/operations/update.ts"],"sourcesContent":["import type { DeepPartial } from 'ts-essentials'\n\nimport type { GeneratedTypes } from '../../index.js'\nimport type { PayloadRequestWithData, Where } from '../../types/index.js'\nimport type { SanitizedGlobalConfig } from '../config/types.js'\n\nimport executeAccess from '../../auth/executeAccess.js'\nimport { afterChange } from '../../fields/hooks/afterChange/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { beforeChange } from '../../fields/hooks/beforeChange/index.js'\nimport { beforeValidate } from '../../fields/hooks/beforeValidate/index.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { getLatestGlobalVersion } from '../../versions/getLatestGlobalVersion.js'\nimport { saveVersion } from '../../versions/saveVersion.js'\n\ntype Args<T extends { [field: number | string | symbol]: unknown }> = {\n autosave?: boolean\n data: DeepPartial<Omit<T, 'id'>>\n depth?: number\n draft?: boolean\n globalConfig: SanitizedGlobalConfig\n overrideAccess?: boolean\n req: PayloadRequestWithData\n showHiddenFields?: boolean\n slug: string\n}\n\nexport const updateOperation = async <TSlug extends keyof GeneratedTypes['globals']>(\n args: Args<GeneratedTypes['globals'][TSlug]>,\n): Promise<GeneratedTypes['globals'][TSlug]> => {\n const {\n slug,\n autosave,\n depth,\n draft: draftArg,\n globalConfig,\n overrideAccess,\n req: { fallbackLocale, locale, payload },\n req,\n showHiddenFields,\n } = args\n\n try {\n const shouldCommit = await initTransaction(req)\n\n let { data } = args\n\n const shouldSaveDraft = Boolean(draftArg && globalConfig.versions?.drafts)\n\n // /////////////////////////////////////\n // 1. Retrieve and execute access\n // /////////////////////////////////////\n\n const accessResults = !overrideAccess\n ? await executeAccess(\n {\n data,\n req,\n },\n globalConfig.access.update,\n )\n : true\n\n // /////////////////////////////////////\n // Retrieve document\n // /////////////////////////////////////\n\n const query: Where = overrideAccess ? undefined : (accessResults as Where)\n\n // /////////////////////////////////////\n // 2. Retrieve document\n // /////////////////////////////////////\n const { global, globalExists } = await getLatestGlobalVersion({\n slug,\n config: globalConfig,\n locale,\n payload,\n req,\n where: query,\n })\n\n let globalJSON: Record<string, unknown> = {}\n\n if (global) {\n globalJSON = JSON.parse(JSON.stringify(global))\n\n if (globalJSON._id) {\n delete globalJSON._id\n }\n }\n\n const originalDoc = await afterRead({\n collection: null,\n context: req.context,\n depth: 0,\n doc: globalJSON,\n draft: draftArg,\n fallbackLocale,\n global: globalConfig,\n locale,\n overrideAccess: true,\n req,\n showHiddenFields,\n })\n\n // /////////////////////////////////////\n // beforeValidate - Fields\n // /////////////////////////////////////\n\n data = await beforeValidate({\n collection: null,\n context: req.context,\n data,\n doc: originalDoc,\n global: globalConfig,\n operation: 'update',\n overrideAccess,\n req,\n })\n\n // /////////////////////////////////////\n // beforeValidate - Global\n // /////////////////////////////////////\n\n await globalConfig.hooks.beforeValidate.reduce(async (priorHook, hook) => {\n await priorHook\n\n data =\n (await hook({\n context: req.context,\n data,\n global: globalConfig,\n originalDoc,\n req,\n })) || data\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // beforeChange - Global\n // /////////////////////////////////////\n\n await globalConfig.hooks.beforeChange.reduce(async (priorHook, hook) => {\n await priorHook\n\n data =\n (await hook({\n context: req.context,\n data,\n global: globalConfig,\n originalDoc,\n req,\n })) || data\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // beforeChange - Fields\n // /////////////////////////////////////\n\n let result = await beforeChange({\n collection: null,\n context: req.context,\n data,\n doc: originalDoc,\n docWithLocales: globalJSON,\n global: globalConfig,\n operation: 'update',\n req,\n skipValidation:\n shouldSaveDraft && globalConfig.versions.drafts && !globalConfig.versions.drafts.validate,\n })\n\n // /////////////////////////////////////\n // Update\n // /////////////////////////////////////\n\n if (!shouldSaveDraft) {\n if (globalExists) {\n result = await payload.db.updateGlobal({\n slug,\n data: result,\n req,\n })\n } else {\n result = await payload.db.createGlobal({\n slug,\n data: result,\n req,\n })\n }\n }\n\n // /////////////////////////////////////\n // Create version\n // /////////////////////////////////////\n\n if (globalConfig.versions) {\n const { globalType } = result\n result = await saveVersion({\n autosave,\n docWithLocales: {\n ...result,\n createdAt: result.createdAt,\n updatedAt: result.updatedAt,\n },\n draft: shouldSaveDraft,\n global: globalConfig,\n payload,\n req,\n })\n result.globalType = globalType\n }\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n result = await afterRead({\n collection: null,\n context: req.context,\n depth,\n doc: result,\n draft: draftArg,\n fallbackLocale: null,\n global: globalConfig,\n locale,\n overrideAccess,\n req,\n showHiddenFields,\n })\n\n // /////////////////////////////////////\n // afterRead - Global\n // /////////////////////////////////////\n\n await globalConfig.hooks.afterRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n result =\n (await hook({\n context: req.context,\n doc: result,\n global: globalConfig,\n req,\n })) || result\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // afterChange - Fields\n // /////////////////////////////////////\n\n result = await afterChange({\n collection: null,\n context: req.context,\n data,\n doc: result,\n global: globalConfig,\n operation: 'update',\n previousDoc: originalDoc,\n req,\n })\n\n // /////////////////////////////////////\n // afterChange - Global\n // /////////////////////////////////////\n\n await globalConfig.hooks.afterChange.reduce(async (priorHook, hook) => {\n await priorHook\n\n result =\n (await hook({\n context: req.context,\n doc: result,\n global: globalConfig,\n previousDoc: originalDoc,\n req,\n })) || result\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n if (shouldCommit) await commitTransaction(req)\n\n return result\n } catch (error: unknown) {\n await killTransaction(req)\n throw error\n }\n}\n"],"names":["executeAccess","afterChange","afterRead","beforeChange","beforeValidate","commitTransaction","initTransaction","killTransaction","getLatestGlobalVersion","saveVersion","updateOperation","args","slug","autosave","depth","draft","draftArg","globalConfig","overrideAccess","req","fallbackLocale","locale","payload","showHiddenFields","shouldCommit","data","shouldSaveDraft","Boolean","versions","drafts","accessResults","access","update","query","undefined","global","globalExists","config","where","globalJSON","JSON","parse","stringify","_id","originalDoc","collection","context","doc","operation","hooks","reduce","priorHook","hook","Promise","resolve","result","docWithLocales","skipValidation","validate","db","updateGlobal","createGlobal","globalType","createdAt","updatedAt","previousDoc","error"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAMA,OAAOA,mBAAmB,8BAA6B;AACvD,SAASC,WAAW,QAAQ,0CAAyC;AACrE,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,YAAY,QAAQ,2CAA0C;AACvE,SAASC,cAAc,QAAQ,6CAA4C;AAC3E,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,sBAAsB,QAAQ,2CAA0C;AACjF,S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K;gBACVN,SAAS3B,IAAI2B,OAAO;gBACpBC,KAAKQ;gBACLpB,QAAQlB;gBACRgD,aAAarB;gBACbzB;YACF,MAAOoC;QACX,GAAGF,QAAQC,OAAO;QAElB,wCAAwC;QACxC,iBAAiB;QACjB,wCAAwC;QAExC,IAAI9B,cAAc,MAAMnB,kBAAkBc;QAE1C,OAAOoC;IACT,EAAE,OAAOW,OAAgB;QACvB,MAAM3D,gBAAgBY;QACtB,MAAM+C;IACR;AACF,EAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -150,6 +150,13 @@ export declare class BasePayload<TGeneratedTypes extends GeneratedTypes> {
|
|
|
150
150
|
versions: {
|
|
151
151
|
[slug: string]: any;
|
|
152
152
|
};
|
|
153
|
+
bin({ args, cwd, log, }: {
|
|
154
|
+
args: string[];
|
|
155
|
+
cwd?: string;
|
|
156
|
+
log?: boolean;
|
|
157
|
+
}): Promise<{
|
|
158
|
+
code: number;
|
|
159
|
+
}>;
|
|
153
160
|
/**
|
|
154
161
|
* @description delete one or more documents
|
|
155
162
|
* @param options
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAC7E,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,cAAc,CAAA;AAC5E,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAC7E,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,cAAc,CAAA;AAC5E,OAAO,KAAK,IA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,EAAE,cAAc,EAAE,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { spawn } from 'child_process';
|
|
1
2
|
import crypto from 'crypto';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import path from 'path';
|
|
2
5
|
import { decrypt, encrypt } from './auth/crypto.js';
|
|
3
6
|
import { APIKeyAuthentication } from './auth/strategies/apiKey.js';
|
|
4
7
|
import { JWTAuthentication } from './auth/strategies/jwt.js';
|
|
@@ -10,6 +13,8 @@ import localGlobalOperations from './globals/operations/local/index.js';
|
|
|
10
13
|
import flattenFields from './utilities/flattenTopLevelFields.js';
|
|
11
14
|
import Logger from './utilities/logger.js';
|
|
12
15
|
import { serverInit as serverInitTelemetry } from './utilities/telemetry/events/serverInit.js';
|
|
16
|
+
const filename = fileURLToPath(import.meta.url);
|
|
17
|
+
const dirname = path.dirname(filename);
|
|
13
18
|
/**
|
|
14
19
|
* @description Payload
|
|
15
20
|
*/ export class BasePayload {
|
|
@@ -154,6 +159,25 @@ import { serverInit as serverInitTelemetry } from './utilities/telemetry/events/
|
|
|
154
159
|
return verifyEmail(this, options);
|
|
155
160
|
};
|
|
156
161
|
versions = {};
|
|
162
|
+
async bin({ args, cwd, log }) {
|
|
163
|
+
return new Promise((resolve, reject)=>{
|
|
164
|
+
const spawned = spawn('node', [
|
|
165
|
+
path.resolve(dirname, '../bin.js'),
|
|
166
|
+
...args
|
|
167
|
+
], {
|
|
168
|
+
cwd,
|
|
169
|
+
stdio: log || log === undefined ? 'inherit' : 'ignore'
|
|
170
|
+
});
|
|
171
|
+
spawned.on('exit', (code)=>{
|
|
172
|
+
resolve({
|
|
173
|
+
code
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
spawned.on('error', (error)=>{
|
|
177
|
+
reject(error);
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
}
|
|
157
181
|
delete(options) {
|
|
158
182
|
const { deleteLocal } = localOperations;
|
|
159
183
|
return deleteLocal(this, options);
|
|
@@ -186,6 +210,17 @@ import { serverInit as serverInitTelemetry } from './utilities/telemetry/events/
|
|
|
186
210
|
customIDType
|
|
187
211
|
};
|
|
188
212
|
});
|
|
213
|
+
// Generate types on startup
|
|
214
|
+
if (process.env.NODE_ENV !== 'production' && this.config.typescript.autoGenerate !== false) {
|
|
215
|
+
// We cannot run it directly here, as generate-types imports json-schema-to-typescript, which breaks on turbopack.
|
|
216
|
+
// see: https://github.com/vercel/next.js/issues/66723
|
|
217
|
+
void this.bin({
|
|
218
|
+
args: [
|
|
219
|
+
'generate:types'
|
|
220
|
+
],
|
|
221
|
+
log: false
|
|
222
|
+
});
|
|
223
|
+
}
|
|
189
224
|
this.db = this.config.db.init({
|
|
190
225
|
payload: this
|
|
191
226
|
});
|