payload 3.0.0-beta.67 → 3.0.0-beta.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/RichText.d.ts +4 -4
- package/dist/admin/RichText.d.ts.map +1 -1
- package/dist/admin/RichText.js.map +1 -1
- package/dist/auth/baseFields/email.js +1 -1
- package/dist/auth/baseFields/email.js.map +1 -1
- package/dist/auth/operations/resetPassword.js +1 -1
- package/dist/auth/operations/resetPassword.js.map +1 -1
- package/dist/auth/strategies/jwt.d.ts.map +1 -1
- package/dist/auth/strategies/jwt.js +29 -0
- package/dist/auth/strategies/jwt.js.map +1 -1
- package/dist/auth/strategies/local/incrementLoginAttempts.d.ts.map +1 -1
- package/dist/auth/strategies/local/incrementLoginAttempts.js +1 -1
- package/dist/auth/strategies/local/incrementLoginAttempts.js.map +1 -1
- package/dist/auth/strategies/local/register.d.ts +2 -2
- package/dist/auth/strategies/local/register.d.ts.map +1 -1
- package/dist/auth/strategies/local/register.js.map +1 -1
- package/dist/bin/generateTypes.js +2 -2
- package/dist/bin/generateTypes.js.map +1 -1
- package/dist/collections/config/client.d.ts.map +1 -1
- package/dist/collections/config/client.js +1 -0
- package/dist/collections/config/client.js.map +1 -1
- package/dist/collections/config/defaults.d.ts +4 -69
- package/dist/collections/config/defaults.d.ts.map +1 -1
- package/dist/collections/config/defaults.js.map +1 -1
- package/dist/collections/config/reservedFieldNames.d.ts +15 -0
- package/dist/collections/config/reservedFieldNames.d.ts.map +1 -0
- package/dist/collections/config/reservedFieldNames.js +104 -0
- package/dist/collections/config/reservedFieldNames.js.map +1 -0
- package/dist/collections/config/reservedFieldNames.spec.js +148 -0
- package/dist/collections/config/reservedFieldNames.spec.js.map +1 -0
- package/dist/collections/config/sanitize.d.ts.map +1 -1
- package/dist/collections/config/sanitize.js +13 -9
- package/dist/collections/config/sanitize.js.map +1 -1
- package/dist/collections/config/types.d.ts +2 -2
- package/dist/collections/config/types.d.ts.map +1 -1
- package/dist/collections/config/types.js.map +1 -1
- package/dist/collections/dataloader.d.ts.map +1 -1
- package/dist/collections/dataloader.js.map +1 -1
- package/dist/collections/operations/create.d.ts.map +1 -1
- package/dist/collections/operations/create.js.map +1 -1
- package/dist/collections/operations/deleteByID.d.ts.map +1 -1
- package/dist/collections/operations/deleteByID.js.map +1 -1
- package/dist/collections/operations/duplicate.js.map +1 -1
- package/dist/collections/operations/update.js.map +1 -1
- package/dist/collections/operations/updateByID.js.map +1 -1
- package/dist/config/client.d.ts.map +1 -1
- package/dist/config/client.js +26 -26
- package/dist/config/client.js.map +1 -1
- package/dist/config/sanitize.d.ts.map +1 -1
- package/dist/config/sanitize.js +6 -7
- package/dist/config/sanitize.js.map +1 -1
- package/dist/config/types.d.ts +7 -5
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js.map +1 -1
- package/dist/database/migrations/getPredefinedMigration.d.ts.map +1 -1
- package/dist/database/migrations/getPredefinedMigration.js +5 -2
- package/dist/database/migrations/getPredefinedMigration.js.map +1 -1
- package/dist/errors/APIError.d.ts +1 -0
- package/dist/errors/APIError.d.ts.map +1 -1
- package/dist/errors/APIError.js +3 -0
- package/dist/errors/APIError.js.map +1 -1
- package/dist/errors/ValidationError.d.ts +1 -0
- package/dist/errors/ValidationError.d.ts.map +1 -1
- package/dist/errors/ValidationError.js +3 -0
- package/dist/errors/ValidationError.js.map +1 -1
- package/dist/errors/index.d.ts +2 -2
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +2 -2
- package/dist/errors/index.js.map +1 -1
- package/dist/exports/components/utilities.d.ts +2 -0
- package/dist/exports/components/utilities.d.ts.map +1 -0
- package/dist/exports/components/utilities.js +2 -0
- package/dist/exports/components/utilities.js.map +1 -0
- package/dist/exports/shared.d.ts +3 -2
- package/dist/exports/shared.d.ts.map +1 -1
- package/dist/exports/shared.js +3 -2
- package/dist/exports/shared.js.map +1 -1
- package/dist/fields/config/client.d.ts.map +1 -1
- package/dist/fields/config/sanitize.d.ts +3 -2
- package/dist/fields/config/sanitize.d.ts.map +1 -1
- package/dist/fields/config/sanitize.js +8 -16
- package/dist/fields/config/sanitize.js.map +1 -1
- package/dist/fields/config/sanitize.spec.js +1 -17
- package/dist/fields/config/sanitize.spec.js.map +1 -1
- package/dist/fields/config/types.d.ts +1 -0
- package/dist/fields/config/types.d.ts.map +1 -1
- package/dist/fields/config/types.js.map +1 -1
- package/dist/fields/getDefaultValue.d.ts +5 -5
- package/dist/fields/getDefaultValue.d.ts.map +1 -1
- package/dist/fields/getDefaultValue.js +4 -6
- package/dist/fields/getDefaultValue.js.map +1 -1
- package/dist/fields/hooks/afterChange/index.d.ts +6 -6
- package/dist/fields/hooks/afterChange/index.d.ts.map +1 -1
- package/dist/fields/hooks/afterChange/index.js +2 -2
- package/dist/fields/hooks/afterChange/index.js.map +1 -1
- package/dist/fields/hooks/afterChange/promise.d.ts +7 -7
- package/dist/fields/hooks/afterChange/promise.d.ts.map +1 -1
- package/dist/fields/hooks/afterChange/promise.js.map +1 -1
- package/dist/fields/hooks/afterChange/traverseFields.d.ts +7 -7
- package/dist/fields/hooks/afterChange/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/afterChange/traverseFields.js.map +1 -1
- package/dist/fields/hooks/afterRead/index.d.ts +4 -4
- package/dist/fields/hooks/afterRead/index.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/index.js +2 -2
- package/dist/fields/hooks/afterRead/index.js.map +1 -1
- package/dist/fields/hooks/afterRead/promise.d.ts +3 -3
- package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/promise.js +2 -2
- package/dist/fields/hooks/afterRead/promise.js.map +1 -1
- package/dist/fields/hooks/afterRead/traverseFields.d.ts +3 -3
- package/dist/fields/hooks/afterRead/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/traverseFields.js.map +1 -1
- package/dist/fields/hooks/beforeChange/cloneDataFromOriginalDoc.d.ts +2 -1
- package/dist/fields/hooks/beforeChange/cloneDataFromOriginalDoc.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/cloneDataFromOriginalDoc.js.map +1 -1
- package/dist/fields/hooks/beforeChange/getExistingRowDoc.d.ts +2 -1
- package/dist/fields/hooks/beforeChange/getExistingRowDoc.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/getExistingRowDoc.js.map +1 -1
- package/dist/fields/hooks/beforeChange/index.d.ts +6 -6
- package/dist/fields/hooks/beforeChange/index.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/index.js +2 -2
- package/dist/fields/hooks/beforeChange/index.js.map +1 -1
- package/dist/fields/hooks/beforeChange/promise.d.ts +7 -7
- package/dist/fields/hooks/beforeChange/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/promise.js +3 -7
- package/dist/fields/hooks/beforeChange/promise.js.map +1 -1
- package/dist/fields/hooks/beforeChange/traverseFields.d.ts +7 -7
- package/dist/fields/hooks/beforeChange/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/traverseFields.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/index.d.ts +5 -5
- package/dist/fields/hooks/beforeValidate/index.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/index.js +2 -2
- package/dist/fields/hooks/beforeValidate/index.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/promise.d.ts +3 -3
- package/dist/fields/hooks/beforeValidate/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/promise.js +2 -2
- package/dist/fields/hooks/beforeValidate/promise.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/traverseFields.d.ts +3 -3
- package/dist/fields/hooks/beforeValidate/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/traverseFields.js.map +1 -1
- package/dist/fields/mergeBaseFields.d.ts.map +1 -1
- package/dist/fields/mergeBaseFields.js +2 -2
- package/dist/fields/mergeBaseFields.js.map +1 -1
- package/dist/fields/validations.d.ts.map +1 -1
- package/dist/globals/operations/findOne.d.ts.map +1 -1
- package/dist/globals/operations/findOne.js.map +1 -1
- package/dist/globals/operations/findVersionByID.d.ts.map +1 -1
- package/dist/globals/operations/findVersionByID.js +2 -1
- package/dist/globals/operations/findVersionByID.js.map +1 -1
- package/dist/globals/operations/findVersions.js.map +1 -1
- package/dist/globals/operations/update.d.ts.map +1 -1
- package/dist/globals/operations/update.js +2 -1
- package/dist/globals/operations/update.js.map +1 -1
- package/dist/index.d.ts +11 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -12
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +8 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/uploads/cropImage.d.ts +4 -1
- package/dist/uploads/cropImage.d.ts.map +1 -1
- package/dist/uploads/cropImage.js +8 -2
- package/dist/uploads/cropImage.js.map +1 -1
- package/dist/uploads/generateFileData.d.ts.map +1 -1
- package/dist/uploads/generateFileData.js +12 -3
- package/dist/uploads/generateFileData.js.map +1 -1
- package/dist/uploads/imageResizer.d.ts +3 -1
- package/dist/uploads/imageResizer.d.ts.map +1 -1
- package/dist/uploads/imageResizer.js +29 -20
- package/dist/uploads/imageResizer.js.map +1 -1
- package/dist/uploads/optionallyAppendMetadata.d.ts +12 -0
- package/dist/uploads/optionallyAppendMetadata.d.ts.map +1 -0
- package/dist/uploads/optionallyAppendMetadata.js +15 -0
- package/dist/uploads/optionallyAppendMetadata.js.map +1 -0
- package/dist/uploads/types.d.ts +12 -0
- package/dist/uploads/types.d.ts.map +1 -1
- package/dist/uploads/types.js.map +1 -1
- package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
- package/dist/utilities/configToJSONSchema.js +105 -72
- package/dist/utilities/configToJSONSchema.js.map +1 -1
- package/dist/utilities/createLocalReq.d.ts.map +1 -1
- package/dist/utilities/createLocalReq.js +2 -1
- package/dist/utilities/createLocalReq.js.map +1 -1
- package/dist/utilities/deepCopyObject.d.ts +18 -1
- package/dist/utilities/deepCopyObject.d.ts.map +1 -1
- package/dist/utilities/deepCopyObject.js +147 -16
- package/dist/utilities/deepCopyObject.js.map +1 -1
- package/dist/utilities/deepMerge.d.ts +18 -1
- package/dist/utilities/deepMerge.d.ts.map +1 -1
- package/dist/utilities/deepMerge.js +38 -13
- package/dist/utilities/deepMerge.js.map +1 -1
- package/dist/utilities/isPlainObject.d.ts +1 -1
- package/dist/utilities/isPlainObject.d.ts.map +1 -1
- package/dist/utilities/isPlainObject.js +4 -18
- package/dist/utilities/isPlainObject.js.map +1 -1
- package/dist/utilities/logger.d.ts +5 -7
- package/dist/utilities/logger.d.ts.map +1 -1
- package/dist/utilities/logger.js +4 -7
- package/dist/utilities/logger.js.map +1 -1
- package/dist/utilities/telemetry/events/adminInit.d.ts.map +1 -1
- package/dist/utilities/telemetry/events/adminInit.js.map +1 -1
- package/dist/versions/baseFields.d.ts.map +1 -1
- package/dist/versions/baseFields.js +1 -0
- package/dist/versions/baseFields.js.map +1 -1
- package/dist/versions/drafts/replaceWithDraftIfAvailable.d.ts.map +1 -1
- package/dist/versions/drafts/replaceWithDraftIfAvailable.js +2 -1
- package/dist/versions/drafts/replaceWithDraftIfAvailable.js.map +1 -1
- package/dist/versions/enforceMaxVersions.d.ts.map +1 -1
- package/dist/versions/enforceMaxVersions.js +2 -0
- package/dist/versions/enforceMaxVersions.js.map +1 -1
- package/dist/versions/saveVersion.js +2 -2
- package/dist/versions/saveVersion.js.map +1 -1
- package/package.json +5 -7
- package/dist/collections/config/schema.d.ts +0 -4
- package/dist/collections/config/schema.d.ts.map +0 -1
- package/dist/collections/config/schema.js +0 -191
- package/dist/collections/config/schema.js.map +0 -1
- package/dist/config/schema.d.ts +0 -5
- package/dist/config/schema.d.ts.map +0 -1
- package/dist/config/schema.js +0 -179
- package/dist/config/schema.js.map +0 -1
- package/dist/config/shared/adminViewSchema.d.ts +0 -3
- package/dist/config/shared/adminViewSchema.d.ts.map +0 -1
- package/dist/config/shared/adminViewSchema.js +0 -11
- package/dist/config/shared/adminViewSchema.js.map +0 -1
- package/dist/config/shared/componentSchema.d.ts +0 -16
- package/dist/config/shared/componentSchema.d.ts.map +0 -1
- package/dist/config/shared/componentSchema.js +0 -27
- package/dist/config/shared/componentSchema.js.map +0 -1
- package/dist/config/shared/openGraphSchema.d.ts +0 -3
- package/dist/config/shared/openGraphSchema.d.ts.map +0 -1
- package/dist/config/shared/openGraphSchema.js +0 -16
- package/dist/config/shared/openGraphSchema.js.map +0 -1
- package/dist/config/validate.d.ts +0 -4
- package/dist/config/validate.d.ts.map +0 -1
- package/dist/config/validate.js +0 -89
- package/dist/config/validate.js.map +0 -1
- package/dist/fields/config/schema.d.ts +0 -29
- package/dist/fields/config/schema.d.ts.map +0 -1
- package/dist/fields/config/schema.js +0 -508
- package/dist/fields/config/schema.js.map +0 -1
- package/dist/globals/config/schema.d.ts +0 -4
- package/dist/globals/config/schema.d.ts.map +0 -1
- package/dist/globals/config/schema.js +0 -79
- package/dist/globals/config/schema.js.map +0 -1
- package/dist/utilities/combineMerge.d.ts +0 -2
- package/dist/utilities/combineMerge.d.ts.map +0 -1
- package/dist/utilities/combineMerge.js +0 -16
- package/dist/utilities/combineMerge.js.map +0 -1
- package/dist/utilities/convertData.d.ts +0 -5
- package/dist/utilities/convertData.d.ts.map +0 -1
- package/dist/utilities/convertData.js +0 -16
- package/dist/utilities/convertData.js.map +0 -1
- package/dist/utilities/getCSSVariable.d.ts +0 -3
- package/dist/utilities/getCSSVariable.d.ts.map +0 -1
- package/dist/utilities/getCSSVariable.js +0 -3
- package/dist/utilities/getCSSVariable.js.map +0 -1
- package/dist/utilities/overwriteMerge.d.ts +0 -3
- package/dist/utilities/overwriteMerge.d.ts.map +0 -1
- package/dist/utilities/overwriteMerge.js +0 -4
- package/dist/utilities/overwriteMerge.js.map +0 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { ExecutionResult, GraphQLSchema, ValidationRule } from 'graphql'\nimport type { OperationArgs, Request as graphQLRequest } from 'graphql-http'\nimport type pino from 'pino'\n\nimport { spawn } from 'child_process'\nimport crypto from 'crypto'\nimport { fileURLToPath } from 'node:url'\nimport path from 'path'\n\nimport type { AuthArgs } from './auth/operations/auth.js'\nimport type { Result as ForgotPasswordResult } from './auth/operations/forgotPassword.js'\nimport type { Options as ForgotPasswordOptions } from './auth/operations/local/forgotPassword.js'\nimport type { Options as LoginOptions } from './auth/operations/local/login.js'\nimport type { Options as ResetPasswordOptions } from './auth/operations/local/resetPassword.js'\nimport type { Options as UnlockOptions } from './auth/operations/local/unlock.js'\nimport type { Options as VerifyEmailOptions } from './auth/operations/local/verifyEmail.js'\nimport type { Result as LoginResult } from './auth/operations/login.js'\nimport type { Result as ResetPasswordResult } from './auth/operations/resetPassword.js'\nimport type { AuthStrategy, User } from './auth/types.js'\nimport type {\n BulkOperationResult,\n Collection,\n DataFromCollectionSlug,\n TypeWithID,\n} from './collections/config/types.js'\nimport type { Options as CountOptions } from './collections/operations/local/count.js'\nimport type { Options as CreateOptions } from './collections/operations/local/create.js'\nimport type {\n ByIDOptions as DeleteByIDOptions,\n ManyOptions as DeleteManyOptions,\n Options as DeleteOptions,\n} from './collections/operations/local/delete.js'\nimport type { Options as DuplicateOptions } from './collections/operations/local/duplicate.js'\nimport type { Options as FindOptions } from './collections/operations/local/find.js'\nimport type { Options as FindByIDOptions } from './collections/operations/local/findByID.js'\nimport type { Options as FindVersionByIDOptions } from './collections/operations/local/findVersionByID.js'\nimport type { Options as FindVersionsOptions } from './collections/operations/local/findVersions.js'\nimport type { Options as RestoreVersionOptions } from './collections/operations/local/restoreVersion.js'\nimport type {\n ByIDOptions as UpdateByIDOptions,\n ManyOptions as UpdateManyOptions,\n Options as UpdateOptions,\n} from './collections/operations/local/update.js'\nimport type { InitOptions, SanitizedConfig } from './config/types.js'\nimport type { BaseDatabaseAdapter, PaginatedDocs } from './database/types.js'\nimport type { InitializedEmailAdapter } from './email/types.js'\nimport type { DataFromGlobalSlug, Globals } from './globals/config/types.js'\nimport type { Options as FindGlobalOptions } from './globals/operations/local/findOne.js'\nimport type { Options as FindGlobalVersionByIDOptions } from './globals/operations/local/findVersionByID.js'\nimport type { Options as FindGlobalVersionsOptions } from './globals/operations/local/findVersions.js'\nimport type { Options as RestoreGlobalVersionOptions } from './globals/operations/local/restoreVersion.js'\nimport type { Options as UpdateGlobalOptions } from './globals/operations/local/update.js'\nimport type { TypeWithVersion } from './versions/types.js'\n\nimport { decrypt, encrypt } from './auth/crypto.js'\nimport { APIKeyAuthentication } from './auth/strategies/apiKey.js'\nimport { JWTAuthentication } from './auth/strategies/jwt.js'\nimport localOperations from './collections/operations/local/index.js'\nimport { validateSchema } from './config/validate.js'\nimport { consoleEmailAdapter } from './email/consoleEmailAdapter.js'\nimport { fieldAffectsData } from './fields/config/types.js'\nimport localGlobalOperations from './globals/operations/local/index.js'\nimport { getDependencies } from './utilities/dependencies/getDependencies.js'\nimport flattenFields from './utilities/flattenTopLevelFields.js'\nimport Logger from './utilities/logger.js'\nimport { serverInit as serverInitTelemetry } from './utilities/telemetry/events/serverInit.js'\n\nexport interface GeneratedTypes {\n authUntyped: {\n [slug: string]: {\n forgotPassword: {\n email: string\n }\n login: {\n email: string\n password: string\n }\n registerFirstUser: {\n email: string\n password: string\n }\n unlock: {\n email: string\n }\n }\n }\n collectionsUntyped: {\n [slug: string]: Record<string, unknown> & TypeWithID\n }\n globalsUntyped: {\n [slug: string]: Record<string, unknown>\n }\n localeUntyped: null | string\n userUntyped: User\n}\n\n// Helper type to resolve the correct type using conditional types\ntype ResolveCollectionType<T> = 'collections' extends keyof T\n ? T['collections']\n : // @ts-expect-error\n T['collectionsUntyped']\n// @ts-expect-error\ntype ResolveGlobalType<T> = 'globals' extends keyof T ? T['globals'] : T['globalsUntyped']\n\n// Applying helper types to GeneratedTypes\nexport type TypedCollection = ResolveCollectionType<GeneratedTypes>\nexport type TypedGlobal = ResolveGlobalType<GeneratedTypes>\n\n// Extract string keys from the type\ntype StringKeyOf<T> = Extract<keyof T, string>\n\n// Define the types for slugs using the appropriate collections and globals\nexport type CollectionSlug = StringKeyOf<TypedCollection>\nexport type GlobalSlug = StringKeyOf<TypedGlobal>\n\n// now for locale and user\n\n// @ts-expect-error\ntype ResolveLocaleType<T> = 'locale' extends keyof T ? T['locale'] : T['localeUntyped']\n// @ts-expect-error\ntype ResolveUserType<T> = 'user' extends keyof T ? T['user'] : T['userUntyped']\n\nexport type TypedLocale = ResolveLocaleType<GeneratedTypes>\nexport type TypedUser = ResolveUserType<GeneratedTypes>\n\n// @ts-expect-error\ntype ResolveAuthOperationsType<T> = 'auth' extends keyof T ? T['auth'] : T['authUntyped']\nexport type TypedAuthOperations = ResolveAuthOperationsType<GeneratedTypes>\n\nconst filename = fileURLToPath(import.meta.url)\nconst dirname = path.dirname(filename)\n\n/**\n * @description Payload\n */\nexport class BasePayload {\n /**\n * @description Authorization and Authentication using headers and cookies to run auth user strategies\n * @returns permissions: Permissions\n * @returns user: User\n */\n auth = async (options: AuthArgs) => {\n const { auth } = localOperations.auth\n return auth(this, options)\n }\n\n authStrategies: AuthStrategy[]\n\n collections: {\n [slug: number | string | symbol]: Collection\n } = {}\n\n config: SanitizedConfig\n\n /**\n * @description Performs count operation\n * @param options\n * @returns count of documents satisfying query\n */\n count = async <T extends CollectionSlug>(\n options: CountOptions<T>,\n ): Promise<{ totalDocs: number }> => {\n const { count } = localOperations\n return count(this, options)\n }\n\n /**\n * @description Performs create operation\n * @param options\n * @returns created document\n */\n create = async <TSlug extends CollectionSlug>(\n options: CreateOptions<TSlug>,\n ): Promise<DataFromCollectionSlug<TSlug>> => {\n const { create } = localOperations\n return create<TSlug>(this, options)\n }\n db: DatabaseAdapter\n\n decrypt = decrypt\n\n duplicate = async <TSlug extends CollectionSlug>(\n options: DuplicateOptions<TSlug>,\n ): Promise<DataFromCollectionSlug<TSlug>> => {\n const { duplicate } = localOperations\n return duplicate<TSlug>(this, options)\n }\n\n email: InitializedEmailAdapter\n\n // TODO: re-implement or remove?\n // errorHandler: ErrorHandler\n\n encrypt = encrypt\n\n extensions: (args: {\n args: OperationArgs<any>\n req: graphQLRequest<unknown, unknown>\n result: ExecutionResult\n }) => Promise<any>\n\n /**\n * @description Find documents with criteria\n * @param options\n * @returns documents satisfying query\n */\n find = async <TSlug extends CollectionSlug>(\n options: FindOptions<TSlug>,\n ): Promise<PaginatedDocs<DataFromCollectionSlug<TSlug>>> => {\n const { find } = localOperations\n return find<TSlug>(this, options)\n }\n\n /**\n * @description Find document by ID\n * @param options\n * @returns document with specified ID\n */\n findByID = async <TSlug extends CollectionSlug>(\n options: FindByIDOptions<TSlug>,\n ): Promise<DataFromCollectionSlug<TSlug>> => {\n const { findByID } = localOperations\n return findByID<TSlug>(this, options)\n }\n\n findGlobal = async <TSlug extends GlobalSlug>(\n options: FindGlobalOptions<TSlug>,\n ): Promise<DataFromGlobalSlug<TSlug>> => {\n const { findOne } = localGlobalOperations\n return findOne<TSlug>(this, options)\n }\n\n /**\n * @description Find global version by ID\n * @param options\n * @returns global version with specified ID\n */\n findGlobalVersionByID = async <TSlug extends GlobalSlug>(\n options: FindGlobalVersionByIDOptions<TSlug>,\n ): Promise<TypeWithVersion<DataFromGlobalSlug<TSlug>>> => {\n const { findVersionByID } = localGlobalOperations\n return findVersionByID<TSlug>(this, options)\n }\n\n /**\n * @description Find global versions with criteria\n * @param options\n * @returns versions satisfying query\n */\n findGlobalVersions = async <TSlug extends GlobalSlug>(\n options: FindGlobalVersionsOptions<TSlug>,\n ): Promise<PaginatedDocs<TypeWithVersion<DataFromGlobalSlug<TSlug>>>> => {\n const { findVersions } = localGlobalOperations\n return findVersions<TSlug>(this, options)\n }\n\n /**\n * @description Find version by ID\n * @param options\n * @returns version with specified ID\n */\n findVersionByID = async <TSlug extends CollectionSlug>(\n options: FindVersionByIDOptions<TSlug>,\n ): Promise<TypeWithVersion<DataFromCollectionSlug<TSlug>>> => {\n const { findVersionByID } = localOperations\n return findVersionByID<TSlug>(this, options)\n }\n\n /**\n * @description Find versions with criteria\n * @param options\n * @returns versions satisfying query\n */\n findVersions = async <TSlug extends CollectionSlug>(\n options: FindVersionsOptions<TSlug>,\n ): Promise<PaginatedDocs<TypeWithVersion<DataFromCollectionSlug<TSlug>>>> => {\n const { findVersions } = localOperations\n return findVersions<TSlug>(this, options)\n }\n\n forgotPassword = async <TSlug extends CollectionSlug>(\n options: ForgotPasswordOptions<TSlug>,\n ): Promise<ForgotPasswordResult> => {\n const { forgotPassword } = localOperations.auth\n return forgotPassword<TSlug>(this, options)\n }\n\n getAPIURL = (): string => `${this.config.serverURL}${this.config.routes.api}`\n\n getAdminURL = (): string => `${this.config.serverURL}${this.config.routes.admin}`\n\n globals: Globals\n\n logger: pino.Logger\n\n login = async <TSlug extends CollectionSlug>(\n options: LoginOptions<TSlug>,\n ): Promise<{ user: DataFromCollectionSlug<TSlug> } & LoginResult> => {\n const { login } = localOperations.auth\n return login<TSlug>(this, options)\n }\n\n resetPassword = async <TSlug extends CollectionSlug>(\n options: ResetPasswordOptions<TSlug>,\n ): Promise<ResetPasswordResult> => {\n const { resetPassword } = localOperations.auth\n return resetPassword<TSlug>(this, options)\n }\n\n /**\n * @description Restore global version by ID\n * @param options\n * @returns version with specified ID\n */\n restoreGlobalVersion = async <TSlug extends GlobalSlug>(\n options: RestoreGlobalVersionOptions<TSlug>,\n ): Promise<DataFromGlobalSlug<TSlug>> => {\n const { restoreVersion } = localGlobalOperations\n return restoreVersion<TSlug>(this, options)\n }\n\n /**\n * @description Restore version by ID\n * @param options\n * @returns version with specified ID\n */\n restoreVersion = async <TSlug extends CollectionSlug>(\n options: RestoreVersionOptions<TSlug>,\n ): Promise<DataFromCollectionSlug<TSlug>> => {\n const { restoreVersion } = localOperations\n return restoreVersion<TSlug>(this, options)\n }\n\n schema: GraphQLSchema\n\n secret: string\n\n sendEmail: InitializedEmailAdapter['sendEmail']\n\n types: {\n arrayTypes: any\n blockInputTypes: any\n blockTypes: any\n fallbackLocaleInputType?: any\n groupTypes: any\n localeInputType?: any\n tabTypes: any\n }\n\n unlock = async <TSlug extends CollectionSlug>(\n options: UnlockOptions<TSlug>,\n ): Promise<boolean> => {\n const { unlock } = localOperations.auth\n return unlock<TSlug>(this, options)\n }\n\n updateGlobal = async <TSlug extends GlobalSlug>(\n options: UpdateGlobalOptions<TSlug>,\n ): Promise<DataFromGlobalSlug<TSlug>> => {\n const { update } = localGlobalOperations\n return update<TSlug>(this, options)\n }\n\n validationRules: (args: OperationArgs<any>) => ValidationRule[]\n\n verifyEmail = async <TSlug extends CollectionSlug>(\n options: VerifyEmailOptions<TSlug>,\n ): Promise<boolean> => {\n const { verifyEmail } = localOperations.auth\n return verifyEmail(this, options)\n }\n\n versions: {\n [slug: string]: any // TODO: Type this\n } = {}\n\n async bin({\n args,\n cwd,\n log,\n }: {\n args: string[]\n cwd?: string\n log?: boolean\n }): Promise<{ code: number }> {\n return new Promise((resolve, reject) => {\n const spawned = spawn('node', [path.resolve(dirname, '../bin.js'), ...args], {\n cwd,\n stdio: log || log === undefined ? 'inherit' : 'ignore',\n })\n\n spawned.on('exit', (code) => {\n resolve({ code })\n })\n\n spawned.on('error', (error) => {\n reject(error)\n })\n })\n }\n\n /**\n * @description delete one or more documents\n * @param options\n * @returns Updated document(s)\n */\n delete<TSlug extends CollectionSlug>(\n options: DeleteByIDOptions<TSlug>,\n ): Promise<DataFromCollectionSlug<TSlug>>\n\n delete<TSlug extends CollectionSlug>(\n options: DeleteManyOptions<TSlug>,\n ): Promise<BulkOperationResult<TSlug>>\n\n delete<TSlug extends CollectionSlug>(\n options: DeleteOptions<TSlug>,\n ): Promise<BulkOperationResult<TSlug> | DataFromCollectionSlug<TSlug>> {\n const { deleteLocal } = localOperations\n return deleteLocal<TSlug>(this, options)\n }\n\n /**\n * @description Initializes Payload\n * @param options\n */\n async init(options: InitOptions): Promise<Payload> {\n if (process.env.NODE_ENV !== 'production') {\n // First load. First check if there are mismatching dependency versions of payload packages\n const resolvedDependencies = await getDependencies(dirname, [\n '@payloadcms/ui/shared',\n 'payload',\n '@payloadcms/next/utilities',\n '@payloadcms/richtext-lexical',\n '@payloadcms/richtext-slate',\n '@payloadcms/graphql',\n '@payloadcms/plugin-cloud',\n '@payloadcms/db-mongodb',\n '@payloadcms/db-postgres',\n '@payloadcms/plugin-form-builder',\n '@payloadcms/plugin-nested-docs',\n '@payloadcms/plugin-seo',\n '@payloadcms/plugin-search',\n '@payloadcms/plugin-cloud-storage',\n '@payloadcms/plugin-stripe',\n '@payloadcms/plugin-zapier',\n '@payloadcms/plugin-redirects',\n '@payloadcms/plugin-sentry',\n '@payloadcms/bundler-webpack',\n '@payloadcms/bundler-vite',\n '@payloadcms/live-preview',\n '@payloadcms/live-preview-react',\n '@payloadcms/translations',\n '@payloadcms/email-nodemailer',\n '@payloadcms/email-resend',\n '@payloadcms/storage-azure',\n '@payloadcms/storage-s3',\n '@payloadcms/storage-gcs',\n '@payloadcms/storage-vercel-blob',\n '@payloadcms/storage-uploadthing',\n ])\n\n // Go through each resolved dependency. If any dependency has a mismatching version, throw an error\n const foundVersions: {\n [version: string]: string\n } = {}\n for (const [_pkg, { version }] of resolvedDependencies.resolved) {\n if (!Object.keys(foundVersions).includes(version)) {\n foundVersions[version] = _pkg\n }\n }\n if (Object.keys(foundVersions).length > 1) {\n const formattedVersionsWithPackageNameString = Object.entries(foundVersions)\n .map(([version, pkg]) => `${pkg}@${version}`)\n .join(', ')\n\n throw new Error(\n `Mismatching payload dependency versions found: ${formattedVersionsWithPackageNameString}. All payload and @payloadcms/* packages must have the same version. This is an error with your set-up, caused by you, not a bug in payload. Please go to your package.json and ensure all payload and @payloadcms/* packages have the same version.`,\n )\n }\n }\n\n if (!options?.config) {\n throw new Error('Error: the payload config is required to initialize payload.')\n }\n\n this.logger = Logger('payload', options.loggerOptions, options.loggerDestination)\n\n this.config = await options.config\n\n if (process.env.NODE_ENV !== 'production') {\n validateSchema(this.config, this.logger)\n }\n\n if (!this.config.secret) {\n throw new Error('Error: missing secret key. A secret key is needed to secure Payload.')\n }\n\n this.secret = crypto.createHash('sha256').update(this.config.secret).digest('hex').slice(0, 32)\n\n this.globals = {\n config: this.config.globals,\n }\n\n this.config.collections.forEach((collection) => {\n const customID = flattenFields(collection.fields).find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n )\n\n let customIDType\n\n if (customID?.type === 'number' || customID?.type === 'text') customIDType = customID.type\n\n this.collections[collection.slug] = {\n config: collection,\n customIDType,\n }\n })\n\n // Generate types on startup\n if (process.env.NODE_ENV !== 'production' && this.config.typescript.autoGenerate !== false) {\n // We cannot run it directly here, as generate-types imports json-schema-to-typescript, which breaks on turbopack.\n // see: https://github.com/vercel/next.js/issues/66723\n void this.bin({\n args: ['generate:types'],\n log: false,\n })\n }\n\n this.db = this.config.db.init({ payload: this })\n this.db.payload = this\n\n if (this.db?.init) {\n await this.db.init()\n }\n\n if (!options.disableDBConnect && this.db.connect) {\n await this.db.connect()\n }\n\n // Load email adapter\n if (this.config.email instanceof Promise) {\n const awaitedAdapter = await this.config.email\n this.email = awaitedAdapter({ payload: this })\n } else if (this.config.email) {\n this.email = this.config.email({ payload: this })\n } else {\n if (process.env.NEXT_PHASE !== 'phase-production-build') {\n this.logger.warn(\n `No email adapter provided. Email will be written to console. More info at https://payloadcms.com/docs/email/overview.`,\n )\n }\n\n this.email = consoleEmailAdapter({ payload: this })\n }\n\n // Warn if image resizing is enabled but sharp is not installed\n if (\n !this.config.sharp &&\n this.config.collections.some((c) => c.upload.imageSizes || c.upload.formatOptions)\n ) {\n this.logger.warn(\n `Image resizing is enabled for one or more collections, but sharp not installed. Please install 'sharp' and pass into the config.`,\n )\n }\n\n this.sendEmail = this.email['sendEmail']\n\n serverInitTelemetry(this)\n\n // 1. loop over collections, if collection has auth strategy, initialize and push to array\n let jwtStrategyEnabled = false\n this.authStrategies = this.config.collections.reduce((authStrategies, collection) => {\n if (collection?.auth) {\n if (collection.auth.strategies.length > 0) {\n authStrategies.push(...collection.auth.strategies)\n }\n\n // 2. if api key enabled, push api key strategy into the array\n if (collection.auth?.useAPIKey) {\n authStrategies.push({\n name: `${collection.slug}-api-key`,\n authenticate: APIKeyAuthentication(collection),\n })\n }\n\n // 3. if localStrategy flag is true\n if (!collection.auth.disableLocalStrategy && !jwtStrategyEnabled) {\n jwtStrategyEnabled = true\n }\n }\n\n return authStrategies\n }, [] as AuthStrategy[])\n\n // 4. if enabled, push jwt strategy into authStrategies last\n if (jwtStrategyEnabled) {\n this.authStrategies.push({\n name: 'local-jwt',\n authenticate: JWTAuthentication,\n })\n }\n\n if (!options.disableOnInit) {\n if (typeof options.onInit === 'function') await options.onInit(this)\n if (typeof this.config.onInit === 'function') await this.config.onInit(this)\n }\n\n return this\n }\n\n update<TSlug extends CollectionSlug>(\n options: UpdateManyOptions<TSlug>,\n ): Promise<BulkOperationResult<TSlug>>\n\n /**\n * @description Update one or more documents\n * @param options\n * @returns Updated document(s)\n */\n update<TSlug extends CollectionSlug>(\n options: UpdateByIDOptions<TSlug>,\n ): Promise<DataFromCollectionSlug<TSlug>>\n\n update<TSlug extends CollectionSlug>(\n options: UpdateOptions<TSlug>,\n ): Promise<BulkOperationResult<TSlug> | DataFromCollectionSlug<TSlug>> {\n const { update } = localOperations\n return update<TSlug>(this, options)\n }\n}\n\nconst initialized = new BasePayload()\n\nexport default initialized\n\nlet cached = global._payload\n\nif (!cached) {\n cached = global._payload = { payload: null, promise: null }\n}\n\nexport const getPayload = async (options: InitOptions): Promise<BasePayload> => {\n if (!options?.config) {\n throw new Error('Error: the payload config is required for getPayload to work.')\n }\n\n if (cached.payload) {\n return cached.payload\n }\n\n if (!cached.promise) {\n cached.promise = new BasePayload().init(options)\n }\n\n try {\n cached.payload = await cached.promise\n } catch (e) {\n cached.promise = null\n throw e\n }\n\n return cached.payload\n}\n\ntype Payload = BasePayload\n\ninterface RequestContext {\n [key: string]: unknown\n}\n\nexport interface DatabaseAdapter extends BaseDatabaseAdapter {}\nexport type { Payload, RequestContext }\nexport type { FieldTypes } from './admin/forms/FieldTypes.js'\nexport type * from './admin/types.js'\nexport { default as executeAccess } from './auth/executeAccess.js'\nexport { executeAuthStrategies } from './auth/executeAuthStrategies.js'\nexport { getAccessResults } from './auth/getAccessResults.js'\nexport { getFieldsToSign } from './auth/getFieldsToSign.js'\nexport * from './auth/index.js'\nexport { accessOperation } from './auth/operations/access.js'\nexport { forgotPasswordOperation } from './auth/operations/forgotPassword.js'\nexport { initOperation } from './auth/operations/init.js'\nexport { loginOperation } from './auth/operations/login.js'\nexport { logoutOperation } from './auth/operations/logout.js'\nexport type { MeOperationResult } from './auth/operations/me.js'\nexport { meOperation } from './auth/operations/me.js'\nexport { refreshOperation } from './auth/operations/refresh.js'\nexport { registerFirstUserOperation } from './auth/operations/registerFirstUser.js'\nexport { resetPasswordOperation } from './auth/operations/resetPassword.js'\nexport { unlockOperation } from './auth/operations/unlock.js'\nexport { verifyEmailOperation } from './auth/operations/verifyEmail.js'\nexport type {\n AuthStrategyFunction,\n AuthStrategyFunctionArgs,\n CollectionPermission,\n DocumentPermissions,\n FieldPermissions,\n GlobalPermission,\n IncomingAuthType,\n Permission,\n Permissions,\n User,\n VerifyConfig,\n} from './auth/types.js'\nexport type { ClientCollectionConfig } from './collections/config/client.js'\nexport { createClientCollectionConfig } from './collections/config/client.js'\nexport type {\n AfterChangeHook as CollectionAfterChangeHook,\n AfterDeleteHook as CollectionAfterDeleteHook,\n AfterErrorHook as CollectionAfterErrorHook,\n AfterForgotPasswordHook as CollectionAfterForgotPasswordHook,\n AfterLoginHook as CollectionAfterLoginHook,\n AfterLogoutHook as CollectionAfterLogoutHook,\n AfterMeHook as CollectionAfterMeHook,\n AfterOperationHook as CollectionAfterOperationHook,\n AfterReadHook as CollectionAfterReadHook,\n AfterRefreshHook as CollectionAfterRefreshHook,\n AuthCollection,\n AuthOperationsFromCollectionSlug,\n BeforeChangeHook as CollectionBeforeChangeHook,\n BeforeDeleteHook as CollectionBeforeDeleteHook,\n BeforeLoginHook as CollectionBeforeLoginHook,\n BeforeOperationHook as CollectionBeforeOperationHook,\n BeforeReadHook as CollectionBeforeReadHook,\n BeforeValidateHook as CollectionBeforeValidateHook,\n BulkOperationResult,\n Collection,\n CollectionAdminOptions,\n CollectionConfig,\n DataFromCollectionSlug,\n HookOperationType,\n MeHook as CollectionMeHook,\n RefreshHook as CollectionRefreshHook,\n RequiredDataFromCollection,\n RequiredDataFromCollectionSlug,\n SanitizedCollectionConfig,\n TypeWithID,\n TypeWithTimestamps,\n} from './collections/config/types.js'\nexport { createDataloaderCacheKey, getDataLoader } from './collections/dataloader.js'\nexport { countOperation } from './collections/operations/count.js'\nexport { createOperation } from './collections/operations/create.js'\nexport { deleteOperation } from './collections/operations/delete.js'\nexport { deleteByIDOperation } from './collections/operations/deleteByID.js'\nexport { docAccessOperation } from './collections/operations/docAccess.js'\nexport { duplicateOperation } from './collections/operations/duplicate.js'\nexport { findOperation } from './collections/operations/find.js'\nexport { findByIDOperation } from './collections/operations/findByID.js'\nexport { findVersionByIDOperation } from './collections/operations/findVersionByID.js'\nexport { findVersionsOperation } from './collections/operations/findVersions.js'\nexport { restoreVersionOperation } from './collections/operations/restoreVersion.js'\nexport { updateOperation } from './collections/operations/update.js'\nexport { updateByIDOperation } from './collections/operations/updateByID.js'\nexport { buildConfig } from './config/build.js'\nexport type { ClientConfig } from './config/client.js'\nexport { createClientConfig } from './config/client.js'\nexport { defaults } from './config/defaults.js'\nexport { sanitizeConfig } from './config/sanitize.js'\nexport type {\n Access,\n AccessArgs,\n EditViewComponent,\n EntityDescription,\n EntityDescriptionComponent,\n EntityDescriptionFunction,\n SanitizedConfig,\n} from './config/types.js'\nexport * from './config/types.js'\nexport { combineQueries } from './database/combineQueries.js'\nexport { createDatabaseAdapter } from './database/createDatabaseAdapter.js'\nexport { default as flattenWhereToOperators } from './database/flattenWhereToOperators.js'\nexport { getLocalizedPaths } from './database/getLocalizedPaths.js'\nexport { createMigration } from './database/migrations/createMigration.js'\nexport { getMigrations } from './database/migrations/getMigrations.js'\nexport { getPredefinedMigration } from './database/migrations/getPredefinedMigration.js'\nexport { migrate } from './database/migrations/migrate.js'\nexport { migrateDown } from './database/migrations/migrateDown.js'\nexport { migrateRefresh } from './database/migrations/migrateRefresh.js'\nexport { migrateReset } from './database/migrations/migrateReset.js'\nexport { migrateStatus } from './database/migrations/migrateStatus.js'\nexport { migrationTemplate } from './database/migrations/migrationTemplate.js'\nexport { migrationsCollection } from './database/migrations/migrationsCollection.js'\nexport { readMigrationFiles } from './database/migrations/readMigrationFiles.js'\nexport type * from './database/queryValidation/types.js'\nexport type { EntityPolicies, PathToQuery } from './database/queryValidation/types.js'\nexport { validateQueryPaths } from './database/queryValidation/validateQueryPaths.js'\nexport { validateSearchParam } from './database/queryValidation/validateSearchParams.js'\nexport type {\n BaseDatabaseAdapter,\n BeginTransaction,\n CommitTransaction,\n Connect,\n Count,\n CountArgs,\n Create,\n CreateArgs,\n CreateGlobal,\n CreateGlobalArgs,\n CreateGlobalVersion,\n CreateGlobalVersionArgs,\n CreateMigration,\n CreateVersion,\n CreateVersionArgs,\n DBIdentifierName,\n DatabaseAdapterResult as DatabaseAdapterObj,\n DeleteMany,\n DeleteManyArgs,\n DeleteOne,\n DeleteOneArgs,\n DeleteVersions,\n DeleteVersionsArgs,\n Destroy,\n Find,\n FindArgs,\n FindGlobal,\n FindGlobalArgs,\n FindGlobalVersions,\n FindGlobalVersionsArgs,\n FindOne,\n FindOneArgs,\n FindVersions,\n FindVersionsArgs,\n Init,\n Migration,\n MigrationData,\n MigrationTemplateArgs,\n PaginatedDocs,\n QueryDrafts,\n QueryDraftsArgs,\n RollbackTransaction,\n Transaction,\n UpdateGlobal,\n UpdateGlobalArgs,\n UpdateGlobalVersion,\n UpdateGlobalVersionArgs,\n UpdateOne,\n UpdateOneArgs,\n UpdateVersion,\n UpdateVersionArgs,\n} from './database/types.js'\nexport type { EmailAdapter as PayloadEmailAdapter, SendEmailOptions } from './email/types.js'\nexport {\n APIError,\n AuthenticationError,\n DuplicateCollection,\n DuplicateFieldName,\n DuplicateGlobal,\n ErrorDeletingFile,\n FileRetrievalError,\n FileUploadError,\n Forbidden,\n InvalidConfiguration,\n InvalidFieldName,\n InvalidFieldRelationship,\n LockedAuth,\n MissingCollectionLabel,\n MissingEditorProp,\n MissingFieldInputOptions,\n MissingFieldType,\n MissingFile,\n NotFound,\n QueryError,\n ValidationError,\n} from './errors/index.js'\nexport { baseBlockFields } from './fields/baseFields/baseBlockFields.js'\nexport { baseIDField } from './fields/baseFields/baseIDField.js'\nexport type { ClientFieldConfig } from './fields/config/client.js'\nexport { createClientFieldConfig } from './fields/config/client.js'\nexport { sanitizeFields } from './fields/config/sanitize.js'\nexport type {\n ArrayField,\n Block,\n BlockField,\n CheckboxField,\n ClientValidate,\n CodeField,\n CollapsibleField,\n Condition,\n DateField,\n EmailField,\n Field,\n FieldAccess,\n FieldAffectingData,\n FieldBase,\n FieldHook,\n FieldHookArgs,\n FieldPresentationalOnly,\n FieldWithMany,\n FieldWithMaxDepth,\n FieldWithPath,\n FieldWithSubFields,\n FilterOptions,\n FilterOptionsProps,\n GroupField,\n HookName,\n JSONField,\n Labels,\n NamedTab,\n NonPresentationalField,\n NumberField,\n Option,\n OptionObject,\n PointField,\n PolymorphicRelationshipField,\n RadioField,\n RelationshipField,\n RelationshipValue,\n RichTextField,\n RowAdmin,\n RowField,\n SelectField,\n SingleRelationshipField,\n Tab,\n TabAsField,\n TabsAdmin,\n TabsField,\n TextField,\n TextareaField,\n UIField,\n UnnamedTab,\n UploadField,\n Validate,\n ValidateOptions,\n ValueWithRelation,\n} from './fields/config/types.js'\nexport { default as getDefaultValue } from './fields/getDefaultValue.js'\nexport { traverseFields as afterChangeTraverseFields } from './fields/hooks/afterChange/traverseFields.js'\nexport { promise as afterReadPromise } from './fields/hooks/afterRead/promise.js'\nexport { traverseFields as afterReadTraverseFields } from './fields/hooks/afterRead/traverseFields.js'\nexport { traverseFields as beforeChangeTraverseFields } from './fields/hooks/beforeChange/traverseFields.js'\nexport { traverseFields as beforeValidateTraverseFields } from './fields/hooks/beforeValidate/traverseFields.js'\nexport { default as sortableFieldTypes } from './fields/sortableFieldTypes.js'\nexport type { ClientGlobalConfig } from './globals/config/client.js'\nexport { createClientGlobalConfig } from './globals/config/client.js'\nexport type {\n AfterChangeHook as GlobalAfterChangeHook,\n AfterReadHook as GlobalAfterReadHook,\n BeforeChangeHook as GlobalBeforeChangeHook,\n BeforeReadHook as GlobalBeforeReadHook,\n BeforeValidateHook as GlobalBeforeValidateHook,\n DataFromGlobalSlug,\n GlobalAdminOptions,\n GlobalConfig,\n SanitizedGlobalConfig,\n} from './globals/config/types.js'\nexport { docAccessOperation as docAccessOperationGlobal } from './globals/operations/docAccess.js'\nexport { findOneOperation } from './globals/operations/findOne.js'\nexport { findVersionByIDOperation as findVersionByIDOperationGlobal } from './globals/operations/findVersionByID.js'\nexport { findVersionsOperation as findVersionsOperationGlobal } from './globals/operations/findVersions.js'\nexport { restoreVersionOperation as restoreVersionOperationGlobal } from './globals/operations/restoreVersion.js'\nexport { updateOperation as updateOperationGlobal } from './globals/operations/update.js'\nexport type {\n CollapsedPreferences,\n DocumentPreferences,\n FieldsPreferences,\n InsideFieldsPreferences,\n PreferenceRequest,\n PreferenceUpdateRequest,\n TabsPreferences,\n} from './preferences/types.js'\nexport { getLocalI18n } from './translations/getLocalI18n.js'\nexport * from './types/index.js'\nexport { getFileByPath } from './uploads/getFileByPath.js'\nexport type * from './uploads/types.js'\nexport { combineMerge } from './utilities/combineMerge.js'\nexport { commitTransaction } from './utilities/commitTransaction.js'\nexport {\n configToJSONSchema,\n entityToJSONSchema,\n fieldsToJSONSchema,\n withNullableJSONSchemaType,\n} from './utilities/configToJSONSchema.js'\nexport { createArrayFromCommaDelineated } from './utilities/createArrayFromCommaDelineated.js'\nexport { createLocalReq } from './utilities/createLocalReq.js'\nexport { deepCopyObject } from './utilities/deepCopyObject.js'\nexport { deepMerge } from './utilities/deepMerge.js'\nexport { default as flattenTopLevelFields } from './utilities/flattenTopLevelFields.js'\nexport { formatLabels, formatNames, toWords } from './utilities/formatLabels.js'\nexport { getCollectionIDFieldTypes } from './utilities/getCollectionIDFieldTypes.js'\nexport { getObjectDotNotation } from './utilities/getObjectDotNotation.js'\nexport { initTransaction } from './utilities/initTransaction.js'\nexport { isEntityHidden } from './utilities/isEntityHidden.js'\nexport { isPlainObject } from './utilities/isPlainObject.js'\nexport { isValidID } from './utilities/isValidID.js'\nexport { default as isolateObjectProperty } from './utilities/isolateObjectProperty.js'\nexport { killTransaction } from './utilities/killTransaction.js'\nexport { mapAsync } from './utilities/mapAsync.js'\nexport { mergeListSearchAndWhere } from './utilities/mergeListSearchAndWhere.js'\nexport { 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 { getDependencies }\nexport { saveVersion } from './versions/saveVersion.js'\nexport type { TypeWithVersion } from './versions/types.js'\n"],"names":["spawn","crypto","fileURLToPath","path","decrypt","encrypt","APIKeyAuthentication","JWTAuthentication","localOperations","validateSchema","consoleEmailAdapter","fieldAffectsData","localGlobalOperations","getDependencies","flattenFields","Logger","serverInit","serverInitTelemetry","filename","url","dirname","BasePayload","auth","options","authStrategies","collections","config","count","create","db","duplicate","email","extensions","find","findByID","findGlobal","findOne","findGlobalVersionByID","findVersionByID","findGlobalVersions","findVersions","forgotPassword","getAPIURL","serverURL","routes","api","getAdminURL","admin","globals","logger","login","resetPassword","restoreGlobalVersion","restoreVersion","schema","secret","sendEmail","types","unlock","updateGlobal","update","validationRules","verifyEmail","versions","bin","args","cwd","log","Promise","resolve","reject","spawned","stdio","undefined","on","code","error","delete","deleteLocal","init","process","env","NODE_ENV","resolvedDependencies","foundVersions","_pkg","version","resolved","Object","keys","includes","length","formattedVersionsWithPackageNameString","entries","map","pkg","join","Error","loggerOptions","loggerDestination","createHash","digest","slice","forEach","collection","customID","fields","field","name","customIDType","type","slug","typescript","autoGenerate","payload","disableDBConnect","connect","awaitedAdapter","NEXT_PHASE","warn","sharp","some","c","upload","imageSizes","formatOptions","jwtStrategyEnabled","reduce","strategies","push","useAPIKey","authenticate","disableLocalStrategy","disableOnInit","onInit","initialized","cached","global","_payload","promise","getPayload","e","default","executeAccess","executeAuthStrategies","getAccessResults","getFieldsToSign","accessOperation","forgotPasswordOperation","initOperation","loginOperation","logoutOperation","meOperation","refreshOperation","registerFirstUserOperation","resetPasswordOperation","unlockOperation","verifyEmailOperation","createClientCollectionConfig","createDataloaderCacheKey","getDataLoader","countOperation","createOperation","deleteOperation","deleteByIDOperation","docAccessOperation","duplicateOperation","findOperation","findByIDOperation","findVersionByIDOperation","findVersionsOperation","restoreVersionOperation","updateOperation","updateByIDOperation","buildConfig","createClientConfig","defaults","sanitizeConfig","combineQueries","createDatabaseAdapter","flattenWhereToOperators","getLocalizedPaths","createMigration","getMigrations","getPredefinedMigration","migrate","migrateDown","migrateRefresh","migrateReset","migrateStatus","migrationTemplate","migrationsCollection","readMigrationFiles","validateQueryPaths","validateSearchParam","APIError","AuthenticationError","DuplicateCollection","DuplicateFieldName","DuplicateGlobal","ErrorDeletingFile","FileRetrievalError","FileUploadError","Forbidden","InvalidConfiguration","InvalidFieldName","InvalidFieldRelationship","LockedAuth","MissingCollectionLabel","MissingEditorProp","MissingFieldInputOptions","MissingFieldType","MissingFile","NotFound","QueryError","ValidationError","baseBlockFields","baseIDField","createClientFieldConfig","sanitizeFields","getDefaultValue","traverseFields","afterChangeTraverseFields","afterReadPromise","afterReadTraverseFields","beforeChangeTraverseFields","beforeValidateTraverseFields","sortableFieldTypes","createClientGlobalConfig","docAccessOperationGlobal","findOneOperation","findVersionByIDOperationGlobal","findVersionsOperationGlobal","restoreVersionOperationGlobal","updateOperationGlobal","getLocalI18n","getFileByPath","combineMerge","commitTransaction","configToJSONSchema","entityToJSONSchema","fieldsToJSONSchema","withNullableJSONSchemaType","createArrayFromCommaDelineated","createLocalReq","deepCopyObject","deepMerge","flattenTopLevelFields","formatLabels","formatNames","toWords","getCollectionIDFieldTypes","getObjectDotNotation","initTransaction","isEntityHidden","isPlainObject","isValidID","isolateObjectProperty","killTransaction","mapAsync","mergeListSearchAndWhere","buildVersionCollectionFields","buildVersionGlobalFields","versionDefaults","deleteCollectionVersions","enforceMaxVersions","getLatestCollectionVersion","getLatestGlobalVersion","saveVersion"],"mappings":"AAIA,SAASA,KAAK,QAAQ,gBAAe;AACrC,OAAOC,YAAY,SAAQ;AAC3B,SAASC,aAAa,QAAQ,WAAU;AACxC,OAAOC,UAAU,OAAM;AA+CvB,SAASC,OAAO,EAAEC,OAAO,QAAQ,mBAAkB;AACnD,SAASC,oBAAoB,QAAQ,8BAA6B;AAClE,SAASC,iBAAiB,QAAQ,2BAA0B;AAC5D,OAAOC,qBAAqB,0CAAyC;AACrE,SAASC,cAAc,QAAQ,uBAAsB;AACrD,SAASC,mBAAmB,QAAQ,iCAAgC;AACpE,SAASC,gBAAgB,QAAQ,2BAA0B;AAC3D,OAAOC,2BAA2B,sCAAqC;AACvE,SAASC,eAAe,QAAQ,8CAA6C;AAC7E,OAAOC,mBAAmB,uCAAsC;AAChE,OAAOC,YAAY,wBAAuB;AAC1C,SAASC,cAAcC,mBAAmB,QAAQ,6CAA4C;AAgE9F,MAAMC,WAAWhB,cAAc,YAAYiB,GAAG;AAC9C,MAAMC,UAAUjB,KAAKiB,OAAO,CAACF;AAE7B;;CAEC,GACD,OAAO,MAAMG;IACX;;;;GAIC,GACDC,OAAO,OAAOC;QACZ,MAAM,EAAED,IAAI,EAAE,GAAGd,gBAAgBc,IAAI;QACrC,OAAOA,KAAK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B,QAAQ,uCAAsC;AACvF,SAASC,eAAe,QAAQ,iCAAgC;AAChE,SAASC,QAAQ,QAAQ,0BAAyB;AAClD,SAASC,uBAAuB,QAAQ,yCAAwC;AAChF,SAASC,4BAA4B,QAAQ,sCAAqC;AAClF,SAASC,wBAAwB,QAAQ,kCAAiC;AAC1E,SAASC,eAAe,QAAQ,yBAAwB;AACxD,SAASC,wBAAwB,QAAQ,yCAAwC;AACjF,SAASC,kBAAkB,QAAQ,mCAAkC;AACrE,SAASC,0BAA0B,QAAQ,2CAA0C;AACrF,SAASC,sBAAsB,QAAQ,uCAAsC;AAC7E,SAAS9P,eAAe,GAAE;AAC1B,SAAS+P,WAAW,QAAQ,4BAA2B"}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { ExecutionResult, GraphQLSchema, ValidationRule } from 'graphql'\nimport type { OperationArgs, Request as graphQLRequest } from 'graphql-http'\nimport type { Logger } from 'pino'\n\nimport { spawn } from 'child_process'\nimport crypto from 'crypto'\nimport { fileURLToPath } from 'node:url'\nimport path from 'path'\n\nimport type { AuthArgs } from './auth/operations/auth.js'\nimport type { Result as ForgotPasswordResult } from './auth/operations/forgotPassword.js'\nimport type { Options as ForgotPasswordOptions } from './auth/operations/local/forgotPassword.js'\nimport type { Options as LoginOptions } from './auth/operations/local/login.js'\nimport type { Options as ResetPasswordOptions } from './auth/operations/local/resetPassword.js'\nimport type { Options as UnlockOptions } from './auth/operations/local/unlock.js'\nimport type { Options as VerifyEmailOptions } from './auth/operations/local/verifyEmail.js'\nimport type { Result as LoginResult } from './auth/operations/login.js'\nimport type { Result as ResetPasswordResult } from './auth/operations/resetPassword.js'\nimport type { AuthStrategy, User } from './auth/types.js'\nimport type {\n BulkOperationResult,\n Collection,\n DataFromCollectionSlug,\n TypeWithID,\n} from './collections/config/types.js'\nimport type { Options as CountOptions } from './collections/operations/local/count.js'\nimport type { Options as CreateOptions } from './collections/operations/local/create.js'\nimport type {\n ByIDOptions as DeleteByIDOptions,\n ManyOptions as DeleteManyOptions,\n Options as DeleteOptions,\n} from './collections/operations/local/delete.js'\nimport type { Options as DuplicateOptions } from './collections/operations/local/duplicate.js'\nimport type { Options as FindOptions } from './collections/operations/local/find.js'\nimport type { Options as FindByIDOptions } from './collections/operations/local/findByID.js'\nimport type { Options as FindVersionByIDOptions } from './collections/operations/local/findVersionByID.js'\nimport type { Options as FindVersionsOptions } from './collections/operations/local/findVersions.js'\nimport type { Options as RestoreVersionOptions } from './collections/operations/local/restoreVersion.js'\nimport type {\n ByIDOptions as UpdateByIDOptions,\n ManyOptions as UpdateManyOptions,\n Options as UpdateOptions,\n} from './collections/operations/local/update.js'\nimport type { InitOptions, SanitizedConfig } from './config/types.js'\nimport type { BaseDatabaseAdapter, PaginatedDocs } from './database/types.js'\nimport type { InitializedEmailAdapter } from './email/types.js'\nimport type { DataFromGlobalSlug, Globals } from './globals/config/types.js'\nimport type { Options as FindGlobalOptions } from './globals/operations/local/findOne.js'\nimport type { Options as FindGlobalVersionByIDOptions } from './globals/operations/local/findVersionByID.js'\nimport type { Options as FindGlobalVersionsOptions } from './globals/operations/local/findVersions.js'\nimport type { Options as RestoreGlobalVersionOptions } from './globals/operations/local/restoreVersion.js'\nimport type { Options as UpdateGlobalOptions } from './globals/operations/local/update.js'\nimport type { JsonObject } from './types/index.js'\nimport type { TypeWithVersion } from './versions/types.js'\n\nimport { decrypt, encrypt } from './auth/crypto.js'\nimport { APIKeyAuthentication } from './auth/strategies/apiKey.js'\nimport { JWTAuthentication } from './auth/strategies/jwt.js'\nimport localOperations from './collections/operations/local/index.js'\nimport { consoleEmailAdapter } from './email/consoleEmailAdapter.js'\nimport { fieldAffectsData } from './fields/config/types.js'\nimport localGlobalOperations from './globals/operations/local/index.js'\nimport { getDependencies } from './utilities/dependencies/getDependencies.js'\nimport flattenFields from './utilities/flattenTopLevelFields.js'\nimport { getLogger } from './utilities/logger.js'\nimport { serverInit as serverInitTelemetry } from './utilities/telemetry/events/serverInit.js'\n\nexport interface GeneratedTypes {\n authUntyped: {\n [slug: string]: {\n forgotPassword: {\n email: string\n }\n login: {\n email: string\n password: string\n }\n registerFirstUser: {\n email: string\n password: string\n }\n unlock: {\n email: string\n }\n }\n }\n collectionsUntyped: {\n [slug: string]: JsonObject & TypeWithID\n }\n globalsUntyped: {\n [slug: string]: JsonObject\n }\n localeUntyped: null | string\n userUntyped: User\n}\n\n// Helper type to resolve the correct type using conditional types\ntype ResolveCollectionType<T> = 'collections' extends keyof T\n ? T['collections']\n : // @ts-expect-error\n T['collectionsUntyped']\n// @ts-expect-error\ntype ResolveGlobalType<T> = 'globals' extends keyof T ? T['globals'] : T['globalsUntyped']\n\n// Applying helper types to GeneratedTypes\nexport type TypedCollection = ResolveCollectionType<GeneratedTypes>\nexport type TypedGlobal = ResolveGlobalType<GeneratedTypes>\n\n// Extract string keys from the type\ntype StringKeyOf<T> = Extract<keyof T, string>\n\n// Define the types for slugs using the appropriate collections and globals\nexport type CollectionSlug = StringKeyOf<TypedCollection>\nexport type GlobalSlug = StringKeyOf<TypedGlobal>\n\n// now for locale and user\n\n// @ts-expect-error\ntype ResolveLocaleType<T> = 'locale' extends keyof T ? T['locale'] : T['localeUntyped']\n// @ts-expect-error\ntype ResolveUserType<T> = 'user' extends keyof T ? T['user'] : T['userUntyped']\n\nexport type TypedLocale = ResolveLocaleType<GeneratedTypes>\nexport type TypedUser = ResolveUserType<GeneratedTypes>\n\n// @ts-expect-error\ntype ResolveAuthOperationsType<T> = 'auth' extends keyof T ? T['auth'] : T['authUntyped']\nexport type TypedAuthOperations = ResolveAuthOperationsType<GeneratedTypes>\n\nconst filename = fileURLToPath(import.meta.url)\nconst dirname = path.dirname(filename)\n\n/**\n * @description Payload\n */\nexport class BasePayload {\n /**\n * @description Authorization and Authentication using headers and cookies to run auth user strategies\n * @returns permissions: Permissions\n * @returns user: User\n */\n auth = async (options: AuthArgs) => {\n const { auth } = localOperations.auth\n return auth(this, options)\n }\n\n authStrategies: AuthStrategy[]\n\n collections: {\n [slug: number | string | symbol]: Collection\n } = {}\n\n config: SanitizedConfig\n\n /**\n * @description Performs count operation\n * @param options\n * @returns count of documents satisfying query\n */\n count = async <T extends CollectionSlug>(\n options: CountOptions<T>,\n ): Promise<{ totalDocs: number }> => {\n const { count } = localOperations\n return count(this, options)\n }\n\n /**\n * @description Performs create operation\n * @param options\n * @returns created document\n */\n create = async <TSlug extends CollectionSlug>(\n options: CreateOptions<TSlug>,\n ): Promise<DataFromCollectionSlug<TSlug>> => {\n const { create } = localOperations\n return create<TSlug>(this, options)\n }\n db: DatabaseAdapter\n\n decrypt = decrypt\n\n duplicate = async <TSlug extends CollectionSlug>(\n options: DuplicateOptions<TSlug>,\n ): Promise<DataFromCollectionSlug<TSlug>> => {\n const { duplicate } = localOperations\n return duplicate<TSlug>(this, options)\n }\n\n email: InitializedEmailAdapter\n\n // TODO: re-implement or remove?\n // errorHandler: ErrorHandler\n\n encrypt = encrypt\n\n extensions: (args: {\n args: OperationArgs<any>\n req: graphQLRequest<unknown, unknown>\n result: ExecutionResult\n }) => Promise<any>\n\n /**\n * @description Find documents with criteria\n * @param options\n * @returns documents satisfying query\n */\n find = async <TSlug extends CollectionSlug>(\n options: FindOptions<TSlug>,\n ): Promise<PaginatedDocs<DataFromCollectionSlug<TSlug>>> => {\n const { find } = localOperations\n return find<TSlug>(this, options)\n }\n\n /**\n * @description Find document by ID\n * @param options\n * @returns document with specified ID\n */\n findByID = async <TSlug extends CollectionSlug>(\n options: FindByIDOptions<TSlug>,\n ): Promise<DataFromCollectionSlug<TSlug>> => {\n const { findByID } = localOperations\n return findByID<TSlug>(this, options)\n }\n\n findGlobal = async <TSlug extends GlobalSlug>(\n options: FindGlobalOptions<TSlug>,\n ): Promise<DataFromGlobalSlug<TSlug>> => {\n const { findOne } = localGlobalOperations\n return findOne<TSlug>(this, options)\n }\n\n /**\n * @description Find global version by ID\n * @param options\n * @returns global version with specified ID\n */\n findGlobalVersionByID = async <TSlug extends GlobalSlug>(\n options: FindGlobalVersionByIDOptions<TSlug>,\n ): Promise<TypeWithVersion<DataFromGlobalSlug<TSlug>>> => {\n const { findVersionByID } = localGlobalOperations\n return findVersionByID<TSlug>(this, options)\n }\n\n /**\n * @description Find global versions with criteria\n * @param options\n * @returns versions satisfying query\n */\n findGlobalVersions = async <TSlug extends GlobalSlug>(\n options: FindGlobalVersionsOptions<TSlug>,\n ): Promise<PaginatedDocs<TypeWithVersion<DataFromGlobalSlug<TSlug>>>> => {\n const { findVersions } = localGlobalOperations\n return findVersions<TSlug>(this, options)\n }\n\n /**\n * @description Find version by ID\n * @param options\n * @returns version with specified ID\n */\n findVersionByID = async <TSlug extends CollectionSlug>(\n options: FindVersionByIDOptions<TSlug>,\n ): Promise<TypeWithVersion<DataFromCollectionSlug<TSlug>>> => {\n const { findVersionByID } = localOperations\n return findVersionByID<TSlug>(this, options)\n }\n\n /**\n * @description Find versions with criteria\n * @param options\n * @returns versions satisfying query\n */\n findVersions = async <TSlug extends CollectionSlug>(\n options: FindVersionsOptions<TSlug>,\n ): Promise<PaginatedDocs<TypeWithVersion<DataFromCollectionSlug<TSlug>>>> => {\n const { findVersions } = localOperations\n return findVersions<TSlug>(this, options)\n }\n\n forgotPassword = async <TSlug extends CollectionSlug>(\n options: ForgotPasswordOptions<TSlug>,\n ): Promise<ForgotPasswordResult> => {\n const { forgotPassword } = localOperations.auth\n return forgotPassword<TSlug>(this, options)\n }\n\n getAPIURL = (): string => `${this.config.serverURL}${this.config.routes.api}`\n\n getAdminURL = (): string => `${this.config.serverURL}${this.config.routes.admin}`\n\n globals: Globals\n\n logger: Logger\n\n login = async <TSlug extends CollectionSlug>(\n options: LoginOptions<TSlug>,\n ): Promise<{ user: DataFromCollectionSlug<TSlug> } & LoginResult> => {\n const { login } = localOperations.auth\n return login<TSlug>(this, options)\n }\n\n resetPassword = async <TSlug extends CollectionSlug>(\n options: ResetPasswordOptions<TSlug>,\n ): Promise<ResetPasswordResult> => {\n const { resetPassword } = localOperations.auth\n return resetPassword<TSlug>(this, options)\n }\n\n /**\n * @description Restore global version by ID\n * @param options\n * @returns version with specified ID\n */\n restoreGlobalVersion = async <TSlug extends GlobalSlug>(\n options: RestoreGlobalVersionOptions<TSlug>,\n ): Promise<DataFromGlobalSlug<TSlug>> => {\n const { restoreVersion } = localGlobalOperations\n return restoreVersion<TSlug>(this, options)\n }\n\n /**\n * @description Restore version by ID\n * @param options\n * @returns version with specified ID\n */\n restoreVersion = async <TSlug extends CollectionSlug>(\n options: RestoreVersionOptions<TSlug>,\n ): Promise<DataFromCollectionSlug<TSlug>> => {\n const { restoreVersion } = localOperations\n return restoreVersion<TSlug>(this, options)\n }\n\n schema: GraphQLSchema\n\n secret: string\n\n sendEmail: InitializedEmailAdapter['sendEmail']\n\n types: {\n arrayTypes: any\n blockInputTypes: any\n blockTypes: any\n fallbackLocaleInputType?: any\n groupTypes: any\n localeInputType?: any\n tabTypes: any\n }\n\n unlock = async <TSlug extends CollectionSlug>(\n options: UnlockOptions<TSlug>,\n ): Promise<boolean> => {\n const { unlock } = localOperations.auth\n return unlock<TSlug>(this, options)\n }\n\n updateGlobal = async <TSlug extends GlobalSlug>(\n options: UpdateGlobalOptions<TSlug>,\n ): Promise<DataFromGlobalSlug<TSlug>> => {\n const { update } = localGlobalOperations\n return update<TSlug>(this, options)\n }\n\n validationRules: (args: OperationArgs<any>) => ValidationRule[]\n\n verifyEmail = async <TSlug extends CollectionSlug>(\n options: VerifyEmailOptions<TSlug>,\n ): Promise<boolean> => {\n const { verifyEmail } = localOperations.auth\n return verifyEmail(this, options)\n }\n\n versions: {\n [slug: string]: any // TODO: Type this\n } = {}\n\n async bin({\n args,\n cwd,\n log,\n }: {\n args: string[]\n cwd?: string\n log?: boolean\n }): Promise<{ code: number }> {\n return new Promise((resolve, reject) => {\n const spawned = spawn('node', [path.resolve(dirname, '../bin.js'), ...args], {\n cwd,\n stdio: log || log === undefined ? 'inherit' : 'ignore',\n })\n\n spawned.on('exit', (code) => {\n resolve({ code })\n })\n\n spawned.on('error', (error) => {\n reject(error)\n })\n })\n }\n\n /**\n * @description delete one or more documents\n * @param options\n * @returns Updated document(s)\n */\n delete<TSlug extends CollectionSlug>(\n options: DeleteByIDOptions<TSlug>,\n ): Promise<DataFromCollectionSlug<TSlug>>\n\n delete<TSlug extends CollectionSlug>(\n options: DeleteManyOptions<TSlug>,\n ): Promise<BulkOperationResult<TSlug>>\n\n delete<TSlug extends CollectionSlug>(\n options: DeleteOptions<TSlug>,\n ): Promise<BulkOperationResult<TSlug> | DataFromCollectionSlug<TSlug>> {\n const { deleteLocal } = localOperations\n return deleteLocal<TSlug>(this, options)\n }\n\n /**\n * @description Initializes Payload\n * @param options\n */\n async init(options: InitOptions): Promise<Payload> {\n if (process.env.NODE_ENV !== 'production') {\n // First load. First check if there are mismatching dependency versions of payload packages\n const resolvedDependencies = await getDependencies(dirname, [\n '@payloadcms/ui/shared',\n 'payload',\n '@payloadcms/next/utilities',\n '@payloadcms/richtext-lexical',\n '@payloadcms/richtext-slate',\n '@payloadcms/graphql',\n '@payloadcms/plugin-cloud',\n '@payloadcms/db-mongodb',\n '@payloadcms/db-postgres',\n '@payloadcms/plugin-form-builder',\n '@payloadcms/plugin-nested-docs',\n '@payloadcms/plugin-seo',\n '@payloadcms/plugin-search',\n '@payloadcms/plugin-cloud-storage',\n '@payloadcms/plugin-stripe',\n '@payloadcms/plugin-zapier',\n '@payloadcms/plugin-redirects',\n '@payloadcms/plugin-sentry',\n '@payloadcms/bundler-webpack',\n '@payloadcms/bundler-vite',\n '@payloadcms/live-preview',\n '@payloadcms/live-preview-react',\n '@payloadcms/translations',\n '@payloadcms/email-nodemailer',\n '@payloadcms/email-resend',\n '@payloadcms/storage-azure',\n '@payloadcms/storage-s3',\n '@payloadcms/storage-gcs',\n '@payloadcms/storage-vercel-blob',\n '@payloadcms/storage-uploadthing',\n ])\n\n // Go through each resolved dependency. If any dependency has a mismatching version, throw an error\n const foundVersions: {\n [version: string]: string\n } = {}\n for (const [_pkg, { version }] of resolvedDependencies.resolved) {\n if (!Object.keys(foundVersions).includes(version)) {\n foundVersions[version] = _pkg\n }\n }\n if (Object.keys(foundVersions).length > 1) {\n const formattedVersionsWithPackageNameString = Object.entries(foundVersions)\n .map(([version, pkg]) => `${pkg}@${version}`)\n .join(', ')\n\n throw new Error(\n `Mismatching payload dependency versions found: ${formattedVersionsWithPackageNameString}. All payload and @payloadcms/* packages must have the same version. This is an error with your set-up, caused by you, not a bug in payload. Please go to your package.json and ensure all payload and @payloadcms/* packages have the same version.`,\n )\n }\n }\n\n if (!options?.config) {\n throw new Error('Error: the payload config is required to initialize payload.')\n }\n\n this.logger = getLogger('payload', options.loggerOptions, options.loggerDestination)\n\n this.config = await options.config\n\n if (!this.config.secret) {\n throw new Error('Error: missing secret key. A secret key is needed to secure Payload.')\n }\n\n this.secret = crypto.createHash('sha256').update(this.config.secret).digest('hex').slice(0, 32)\n\n this.globals = {\n config: this.config.globals,\n }\n\n this.config.collections.forEach((collection) => {\n const customID = flattenFields(collection.fields).find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n )\n\n let customIDType\n\n if (customID?.type === 'number' || customID?.type === 'text') customIDType = customID.type\n\n this.collections[collection.slug] = {\n config: collection,\n customIDType,\n }\n })\n\n // Generate types on startup\n if (process.env.NODE_ENV !== 'production' && this.config.typescript.autoGenerate !== false) {\n // We cannot run it directly here, as generate-types imports json-schema-to-typescript, which breaks on turbopack.\n // see: https://github.com/vercel/next.js/issues/66723\n void this.bin({\n args: ['generate:types'],\n log: false,\n })\n }\n\n this.db = this.config.db.init({ payload: this })\n this.db.payload = this\n\n if (this.db?.init) {\n await this.db.init()\n }\n\n if (!options.disableDBConnect && this.db.connect) {\n await this.db.connect()\n }\n\n // Load email adapter\n if (this.config.email instanceof Promise) {\n const awaitedAdapter = await this.config.email\n this.email = awaitedAdapter({ payload: this })\n } else if (this.config.email) {\n this.email = this.config.email({ payload: this })\n } else {\n if (process.env.NEXT_PHASE !== 'phase-production-build') {\n this.logger.warn(\n `No email adapter provided. Email will be written to console. More info at https://payloadcms.com/docs/email/overview.`,\n )\n }\n\n this.email = consoleEmailAdapter({ payload: this })\n }\n\n // Warn if image resizing is enabled but sharp is not installed\n if (\n !this.config.sharp &&\n this.config.collections.some((c) => c.upload.imageSizes || c.upload.formatOptions)\n ) {\n this.logger.warn(\n `Image resizing is enabled for one or more collections, but sharp not installed. Please install 'sharp' and pass into the config.`,\n )\n }\n\n this.sendEmail = this.email['sendEmail']\n\n serverInitTelemetry(this)\n\n // 1. loop over collections, if collection has auth strategy, initialize and push to array\n let jwtStrategyEnabled = false\n this.authStrategies = this.config.collections.reduce((authStrategies, collection) => {\n if (collection?.auth) {\n if (collection.auth.strategies.length > 0) {\n authStrategies.push(...collection.auth.strategies)\n }\n\n // 2. if api key enabled, push api key strategy into the array\n if (collection.auth?.useAPIKey) {\n authStrategies.push({\n name: `${collection.slug}-api-key`,\n authenticate: APIKeyAuthentication(collection),\n })\n }\n\n // 3. if localStrategy flag is true\n if (!collection.auth.disableLocalStrategy && !jwtStrategyEnabled) {\n jwtStrategyEnabled = true\n }\n }\n\n return authStrategies\n }, [] as AuthStrategy[])\n\n // 4. if enabled, push jwt strategy into authStrategies last\n if (jwtStrategyEnabled) {\n this.authStrategies.push({\n name: 'local-jwt',\n authenticate: JWTAuthentication,\n })\n }\n\n if (!options.disableOnInit) {\n if (typeof options.onInit === 'function') await options.onInit(this)\n if (typeof this.config.onInit === 'function') await this.config.onInit(this)\n }\n\n return this\n }\n\n update<TSlug extends CollectionSlug>(\n options: UpdateManyOptions<TSlug>,\n ): Promise<BulkOperationResult<TSlug>>\n\n /**\n * @description Update one or more documents\n * @param options\n * @returns Updated document(s)\n */\n update<TSlug extends CollectionSlug>(\n options: UpdateByIDOptions<TSlug>,\n ): Promise<DataFromCollectionSlug<TSlug>>\n\n update<TSlug extends CollectionSlug>(\n options: UpdateOptions<TSlug>,\n ): Promise<BulkOperationResult<TSlug> | DataFromCollectionSlug<TSlug>> {\n const { update } = localOperations\n return update<TSlug>(this, options)\n }\n}\n\nconst initialized = new BasePayload()\n\nexport default initialized\n\nlet cached = global._payload\n\nif (!cached) {\n cached = global._payload = { payload: null, promise: null }\n}\n\nexport const getPayload = async (options: InitOptions): Promise<BasePayload> => {\n if (!options?.config) {\n throw new Error('Error: the payload config is required for getPayload to work.')\n }\n\n if (cached.payload) {\n return cached.payload\n }\n\n if (!cached.promise) {\n cached.promise = new BasePayload().init(options)\n }\n\n try {\n cached.payload = await cached.promise\n } catch (e) {\n cached.promise = null\n throw e\n }\n\n return cached.payload\n}\n\ntype Payload = BasePayload\n\ninterface RequestContext {\n [key: string]: unknown\n}\n\nexport interface DatabaseAdapter extends BaseDatabaseAdapter {}\nexport type { Payload, RequestContext }\nexport type { FieldTypes } from './admin/forms/FieldTypes.js'\nexport type * from './admin/types.js'\nexport { default as executeAccess } from './auth/executeAccess.js'\nexport { executeAuthStrategies } from './auth/executeAuthStrategies.js'\nexport { getAccessResults } from './auth/getAccessResults.js'\nexport { getFieldsToSign } from './auth/getFieldsToSign.js'\nexport * from './auth/index.js'\nexport { accessOperation } from './auth/operations/access.js'\nexport { forgotPasswordOperation } from './auth/operations/forgotPassword.js'\nexport { initOperation } from './auth/operations/init.js'\nexport { loginOperation } from './auth/operations/login.js'\nexport { logoutOperation } from './auth/operations/logout.js'\nexport type { MeOperationResult } from './auth/operations/me.js'\nexport { meOperation } from './auth/operations/me.js'\nexport { refreshOperation } from './auth/operations/refresh.js'\nexport { registerFirstUserOperation } from './auth/operations/registerFirstUser.js'\nexport { resetPasswordOperation } from './auth/operations/resetPassword.js'\nexport { unlockOperation } from './auth/operations/unlock.js'\nexport { verifyEmailOperation } from './auth/operations/verifyEmail.js'\nexport type {\n AuthStrategyFunction,\n AuthStrategyFunctionArgs,\n CollectionPermission,\n DocumentPermissions,\n FieldPermissions,\n GlobalPermission,\n IncomingAuthType,\n Permission,\n Permissions,\n User,\n VerifyConfig,\n} from './auth/types.js'\nexport type { ClientCollectionConfig } from './collections/config/client.js'\nexport { createClientCollectionConfig } from './collections/config/client.js'\nexport type {\n AfterChangeHook as CollectionAfterChangeHook,\n AfterDeleteHook as CollectionAfterDeleteHook,\n AfterErrorHook as CollectionAfterErrorHook,\n AfterForgotPasswordHook as CollectionAfterForgotPasswordHook,\n AfterLoginHook as CollectionAfterLoginHook,\n AfterLogoutHook as CollectionAfterLogoutHook,\n AfterMeHook as CollectionAfterMeHook,\n AfterOperationHook as CollectionAfterOperationHook,\n AfterReadHook as CollectionAfterReadHook,\n AfterRefreshHook as CollectionAfterRefreshHook,\n AuthCollection,\n AuthOperationsFromCollectionSlug,\n BeforeChangeHook as CollectionBeforeChangeHook,\n BeforeDeleteHook as CollectionBeforeDeleteHook,\n BeforeLoginHook as CollectionBeforeLoginHook,\n BeforeOperationHook as CollectionBeforeOperationHook,\n BeforeReadHook as CollectionBeforeReadHook,\n BeforeValidateHook as CollectionBeforeValidateHook,\n BulkOperationResult,\n Collection,\n CollectionAdminOptions,\n CollectionConfig,\n DataFromCollectionSlug,\n HookOperationType,\n MeHook as CollectionMeHook,\n RefreshHook as CollectionRefreshHook,\n RequiredDataFromCollection,\n RequiredDataFromCollectionSlug,\n SanitizedCollectionConfig,\n TypeWithID,\n TypeWithTimestamps,\n} from './collections/config/types.js'\nexport { createDataloaderCacheKey, getDataLoader } from './collections/dataloader.js'\nexport { countOperation } from './collections/operations/count.js'\nexport { createOperation } from './collections/operations/create.js'\nexport { deleteOperation } from './collections/operations/delete.js'\nexport { deleteByIDOperation } from './collections/operations/deleteByID.js'\nexport { docAccessOperation } from './collections/operations/docAccess.js'\nexport { duplicateOperation } from './collections/operations/duplicate.js'\nexport { findOperation } from './collections/operations/find.js'\nexport { findByIDOperation } from './collections/operations/findByID.js'\nexport { findVersionByIDOperation } from './collections/operations/findVersionByID.js'\nexport { findVersionsOperation } from './collections/operations/findVersions.js'\nexport { restoreVersionOperation } from './collections/operations/restoreVersion.js'\nexport { updateOperation } from './collections/operations/update.js'\nexport { updateByIDOperation } from './collections/operations/updateByID.js'\nexport { buildConfig } from './config/build.js'\nexport type { ClientConfig } from './config/client.js'\nexport { createClientConfig } from './config/client.js'\nexport { defaults } from './config/defaults.js'\nexport { sanitizeConfig } from './config/sanitize.js'\nexport type {\n Access,\n AccessArgs,\n EditViewComponent,\n EntityDescription,\n EntityDescriptionComponent,\n EntityDescriptionFunction,\n SanitizedConfig,\n} from './config/types.js'\nexport * from './config/types.js'\nexport { combineQueries } from './database/combineQueries.js'\nexport { createDatabaseAdapter } from './database/createDatabaseAdapter.js'\nexport { default as flattenWhereToOperators } from './database/flattenWhereToOperators.js'\nexport { getLocalizedPaths } from './database/getLocalizedPaths.js'\nexport { createMigration } from './database/migrations/createMigration.js'\nexport { getMigrations } from './database/migrations/getMigrations.js'\nexport { getPredefinedMigration } from './database/migrations/getPredefinedMigration.js'\nexport { migrate } from './database/migrations/migrate.js'\nexport { migrateDown } from './database/migrations/migrateDown.js'\nexport { migrateRefresh } from './database/migrations/migrateRefresh.js'\nexport { migrateReset } from './database/migrations/migrateReset.js'\nexport { migrateStatus } from './database/migrations/migrateStatus.js'\nexport { migrationTemplate } from './database/migrations/migrationTemplate.js'\nexport { migrationsCollection } from './database/migrations/migrationsCollection.js'\nexport { readMigrationFiles } from './database/migrations/readMigrationFiles.js'\nexport type * from './database/queryValidation/types.js'\nexport type { EntityPolicies, PathToQuery } from './database/queryValidation/types.js'\nexport { validateQueryPaths } from './database/queryValidation/validateQueryPaths.js'\nexport { validateSearchParam } from './database/queryValidation/validateSearchParams.js'\nexport type {\n BaseDatabaseAdapter,\n BeginTransaction,\n CommitTransaction,\n Connect,\n Count,\n CountArgs,\n Create,\n CreateArgs,\n CreateGlobal,\n CreateGlobalArgs,\n CreateGlobalVersion,\n CreateGlobalVersionArgs,\n CreateMigration,\n CreateVersion,\n CreateVersionArgs,\n DBIdentifierName,\n DatabaseAdapterResult as DatabaseAdapterObj,\n DeleteMany,\n DeleteManyArgs,\n DeleteOne,\n DeleteOneArgs,\n DeleteVersions,\n DeleteVersionsArgs,\n Destroy,\n Find,\n FindArgs,\n FindGlobal,\n FindGlobalArgs,\n FindGlobalVersions,\n FindGlobalVersionsArgs,\n FindOne,\n FindOneArgs,\n FindVersions,\n FindVersionsArgs,\n Init,\n Migration,\n MigrationData,\n MigrationTemplateArgs,\n PaginatedDocs,\n QueryDrafts,\n QueryDraftsArgs,\n RollbackTransaction,\n Transaction,\n UpdateGlobal,\n UpdateGlobalArgs,\n UpdateGlobalVersion,\n UpdateGlobalVersionArgs,\n UpdateOne,\n UpdateOneArgs,\n UpdateVersion,\n UpdateVersionArgs,\n} from './database/types.js'\nexport type { EmailAdapter as PayloadEmailAdapter, SendEmailOptions } from './email/types.js'\nexport {\n APIError,\n APIErrorName,\n AuthenticationError,\n DuplicateCollection,\n DuplicateFieldName,\n DuplicateGlobal,\n ErrorDeletingFile,\n FileRetrievalError,\n FileUploadError,\n Forbidden,\n InvalidConfiguration,\n InvalidFieldName,\n InvalidFieldRelationship,\n LockedAuth,\n MissingCollectionLabel,\n MissingEditorProp,\n MissingFieldInputOptions,\n MissingFieldType,\n MissingFile,\n NotFound,\n QueryError,\n ValidationError,\n ValidationErrorName,\n} from './errors/index.js'\nexport { baseBlockFields } from './fields/baseFields/baseBlockFields.js'\nexport { baseIDField } from './fields/baseFields/baseIDField.js'\nexport type { ClientFieldConfig } from './fields/config/client.js'\nexport { createClientFieldConfig } from './fields/config/client.js'\nexport { sanitizeFields } from './fields/config/sanitize.js'\nexport type {\n ArrayField,\n Block,\n BlockField,\n CheckboxField,\n ClientValidate,\n CodeField,\n CollapsibleField,\n Condition,\n DateField,\n EmailField,\n Field,\n FieldAccess,\n FieldAffectingData,\n FieldBase,\n FieldHook,\n FieldHookArgs,\n FieldPresentationalOnly,\n FieldWithMany,\n FieldWithMaxDepth,\n FieldWithPath,\n FieldWithSubFields,\n FilterOptions,\n FilterOptionsProps,\n GroupField,\n HookName,\n JSONField,\n Labels,\n NamedTab,\n NonPresentationalField,\n NumberField,\n Option,\n OptionObject,\n PointField,\n PolymorphicRelationshipField,\n RadioField,\n RelationshipField,\n RelationshipValue,\n RichTextField,\n RowAdmin,\n RowField,\n SelectField,\n SingleRelationshipField,\n Tab,\n TabAsField,\n TabsAdmin,\n TabsField,\n TextField,\n TextareaField,\n UIField,\n UnnamedTab,\n UploadField,\n Validate,\n ValidateOptions,\n ValueWithRelation,\n} from './fields/config/types.js'\nexport { getDefaultValue } from './fields/getDefaultValue.js'\nexport { traverseFields as afterChangeTraverseFields } from './fields/hooks/afterChange/traverseFields.js'\nexport { promise as afterReadPromise } from './fields/hooks/afterRead/promise.js'\nexport { traverseFields as afterReadTraverseFields } from './fields/hooks/afterRead/traverseFields.js'\nexport { traverseFields as beforeChangeTraverseFields } from './fields/hooks/beforeChange/traverseFields.js'\nexport { traverseFields as beforeValidateTraverseFields } from './fields/hooks/beforeValidate/traverseFields.js'\nexport { default as sortableFieldTypes } from './fields/sortableFieldTypes.js'\nexport type { ClientGlobalConfig } from './globals/config/client.js'\nexport { createClientGlobalConfig } from './globals/config/client.js'\nexport type {\n AfterChangeHook as GlobalAfterChangeHook,\n AfterReadHook as GlobalAfterReadHook,\n BeforeChangeHook as GlobalBeforeChangeHook,\n BeforeReadHook as GlobalBeforeReadHook,\n BeforeValidateHook as GlobalBeforeValidateHook,\n DataFromGlobalSlug,\n GlobalAdminOptions,\n GlobalConfig,\n SanitizedGlobalConfig,\n} from './globals/config/types.js'\nexport { docAccessOperation as docAccessOperationGlobal } from './globals/operations/docAccess.js'\nexport { findOneOperation } from './globals/operations/findOne.js'\nexport { findVersionByIDOperation as findVersionByIDOperationGlobal } from './globals/operations/findVersionByID.js'\nexport { findVersionsOperation as findVersionsOperationGlobal } from './globals/operations/findVersions.js'\nexport { restoreVersionOperation as restoreVersionOperationGlobal } from './globals/operations/restoreVersion.js'\nexport { updateOperation as updateOperationGlobal } from './globals/operations/update.js'\nexport type {\n CollapsedPreferences,\n DocumentPreferences,\n FieldsPreferences,\n InsideFieldsPreferences,\n PreferenceRequest,\n PreferenceUpdateRequest,\n TabsPreferences,\n} from './preferences/types.js'\nexport { getLocalI18n } from './translations/getLocalI18n.js'\nexport * from './types/index.js'\nexport { getFileByPath } from './uploads/getFileByPath.js'\nexport type * from './uploads/types.js'\nexport { commitTransaction } from './utilities/commitTransaction.js'\nexport {\n configToJSONSchema,\n entityToJSONSchema,\n fieldsToJSONSchema,\n withNullableJSONSchemaType,\n} from './utilities/configToJSONSchema.js'\nexport { createArrayFromCommaDelineated } from './utilities/createArrayFromCommaDelineated.js'\nexport { createLocalReq } from './utilities/createLocalReq.js'\nexport {\n deepCopyObject,\n deepCopyObjectComplex,\n deepCopyObjectSimple,\n} from './utilities/deepCopyObject.js'\nexport {\n deepMerge,\n deepMergeWithCombinedArrays,\n deepMergeWithReactComponents,\n deepMergeWithSourceArrays,\n} from './utilities/deepMerge.js'\nexport { default as flattenTopLevelFields } from './utilities/flattenTopLevelFields.js'\nexport { formatLabels, formatNames, toWords } from './utilities/formatLabels.js'\nexport { getCollectionIDFieldTypes } from './utilities/getCollectionIDFieldTypes.js'\nexport { getObjectDotNotation } from './utilities/getObjectDotNotation.js'\nexport { initTransaction } from './utilities/initTransaction.js'\nexport { isEntityHidden } from './utilities/isEntityHidden.js'\nexport { isPlainObject } from './utilities/isPlainObject.js'\nexport { isValidID } from './utilities/isValidID.js'\nexport { default as isolateObjectProperty } from './utilities/isolateObjectProperty.js'\nexport { killTransaction } from './utilities/killTransaction.js'\nexport { mapAsync } from './utilities/mapAsync.js'\nexport { mergeListSearchAndWhere } from './utilities/mergeListSearchAndWhere.js'\nexport { 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 { getDependencies }\nexport type { TypeWithVersion } from './versions/types.js'\nexport { deepMergeSimple } from '@payloadcms/translations/utilities'\n"],"names":["spawn","crypto","fileURLToPath","path","decrypt","encrypt","APIKeyAuthentication","JWTAuthentication","localOperations","consoleEmailAdapter","fieldAffectsData","localGlobalOperations","getDependencies","flattenFields","getLogger","serverInit","serverInitTelemetry","filename","url","dirname","BasePayload","auth","options","authStrategies","collections","config","count","create","db","duplicate","email","extensions","find","findByID","findGlobal","findOne","findGlobalVersionByID","findVersionByID","findGlobalVersions","findVersions","forgotPassword","getAPIURL","serverURL","routes","api","getAdminURL","admin","globals","logger","login","resetPassword","restoreGlobalVersion","restoreVersion","schema","secret","sendEmail","types","unlock","updateGlobal","update","validationRules","verifyEmail","versions","bin","args","cwd","log","Promise","resolve","reject","spawned","stdio","undefined","on","code","error","delete","deleteLocal","init","process","env","NODE_ENV","resolvedDependencies","foundVersions","_pkg","version","resolved","Object","keys","includes","length","formattedVersionsWithPackageNameString","entries","map","pkg","join","Error","loggerOptions","loggerDestination","createHash","digest","slice","forEach","collection","customID","fields","field","name","customIDType","type","slug","typescript","autoGenerate","payload","disableDBConnect","connect","awaitedAdapter","NEXT_PHASE","warn","sharp","some","c","upload","imageSizes","formatOptions","jwtStrategyEnabled","reduce","strategies","push","useAPIKey","authenticate","disableLocalStrategy","disableOnInit","onInit","initialized","cached","global","_payload","promise","getPayload","e","default","executeAccess","executeAuthStrategies","getAccessResults","getFieldsToSign","accessOperation","forgotPasswordOperation","initOperation","loginOperation","logoutOperation","meOperation","refreshOperation","registerFirstUserOperation","resetPasswordOperation","unlockOperation","verifyEmailOperation","createClientCollectionConfig","createDataloaderCacheKey","getDataLoader","countOperation","createOperation","deleteOperation","deleteByIDOperation","docAccessOperation","duplicateOperation","findOperation","findByIDOperation","findVersionByIDOperation","findVersionsOperation","restoreVersionOperation","updateOperation","updateByIDOperation","buildConfig","createClientConfig","defaults","sanitizeConfig","combineQueries","createDatabaseAdapter","flattenWhereToOperators","getLocalizedPaths","createMigration","getMigrations","getPredefinedMigration","migrate","migrateDown","migrateRefresh","migrateReset","migrateStatus","migrationTemplate","migrationsCollection","readMigrationFiles","validateQueryPaths","validateSearchParam","APIError","APIErrorName","AuthenticationError","DuplicateCollection","DuplicateFieldName","DuplicateGlobal","ErrorDeletingFile","FileRetrievalError","FileUploadError","Forbidden","InvalidConfiguration","InvalidFieldName","InvalidFieldRelationship","LockedAuth","MissingCollectionLabel","MissingEditorProp","MissingFieldInputOptions","MissingFieldType","MissingFile","NotFound","QueryError","ValidationError","ValidationErrorName","baseBlockFields","baseIDField","createClientFieldConfig","sanitizeFields","getDefaultValue","traverseFields","afterChangeTraverseFields","afterReadPromise","afterReadTraverseFields","beforeChangeTraverseFields","beforeValidateTraverseFields","sortableFieldTypes","createClientGlobalConfig","docAccessOperationGlobal","findOneOperation","findVersionByIDOperationGlobal","findVersionsOperationGlobal","restoreVersionOperationGlobal","updateOperationGlobal","getLocalI18n","getFileByPath","commitTransaction","configToJSONSchema","entityToJSONSchema","fieldsToJSONSchema","withNullableJSONSchemaType","createArrayFromCommaDelineated","createLocalReq","deepCopyObject","deepCopyObjectComplex","deepCopyObjectSimple","deepMerge","deepMergeWithCombinedArrays","deepMergeWithReactComponents","deepMergeWithSourceArrays","flattenTopLevelFields","formatLabels","formatNames","toWords","getCollectionIDFieldTypes","getObjectDotNotation","initTransaction","isEntityHidden","isPlainObject","isValidID","isolateObjectProperty","killTransaction","mapAsync","mergeListSearchAndWhere","buildVersionCollectionFields","buildVersionGlobalFields","versionDefaults","deleteCollectionVersions","enforceMaxVersions","getLatestCollectionVersion","getLatestGlobalVersion","saveVersion","deepMergeSimple"],"mappings":"AAIA,SAASA,KAAK,QAAQ,gBAAe;AACrC,OAAOC,YAAY,SAAQ;AAC3B,SAASC,aAAa,QAAQ,WAAU;AACxC,OAAOC,UAAU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AAC1C,SAASC,8BAA8B,QAAQ,gDAA+C;AAC9F,SAASC,cAAc,QAAQ,gCAA+B;AAC9D,SACEC,cAAc,EACdC,qBAAqB,EACrBC,oBAAoB,QACf,gCAA+B;AACtC,SACEC,SAAS,EACTC,2BAA2B,EAC3BC,4BAA4B,EAC5BC,yBAAyB,QACpB,2BAA0B;AACjC,SAAS9G,WAAW+G,qBAAqB,QAAQ,uCAAsC;AACvF,SAASC,YAAY,EAAEC,WAAW,EAAEC,OAAO,QAAQ,8BAA6B;AAChF,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,eAAe,QAAQ,iCAAgC;AAChE,SAASC,cAAc,QAAQ,gCAA+B;AAC9D,SAASC,aAAa,QAAQ,+BAA8B;AAC5D,SAASC,SAAS,QAAQ,2BAA0B;AACpD,SAASxH,WAAWyH,qBAAqB,QAAQ,uCAAsC;AACvF,SAASC,eAAe,QAAQ,iCAAgC;AAChE,SAASC,QAAQ,QAAQ,0BAAyB;AAClD,SAASC,uBAAuB,QAAQ,yCAAwC;AAChF,SAASC,4BAA4B,QAAQ,sCAAqC;AAClF,SAASC,wBAAwB,QAAQ,kCAAiC;AAC1E,SAASC,eAAe,QAAQ,yBAAwB;AACxD,SAASC,wBAAwB,QAAQ,yCAAwC;AACjF,SAASC,kBAAkB,QAAQ,mCAAkC;AACrE,SAASC,0BAA0B,QAAQ,2CAA0C;AACrF,SAASC,sBAAsB,QAAQ,uCAAsC;AAC7E,SAASC,WAAW,QAAQ,4BAA2B;AACvD,SAASrQ,eAAe,GAAE;AAE1B,SAASsQ,eAAe,QAAQ,qCAAoC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -63,7 +63,7 @@ type PayloadRequestData = {
|
|
|
63
63
|
* 2. import { addDataAndFileToRequest } from '@payloadcms/next/utilities'
|
|
64
64
|
* `await addDataAndFileToRequest(req)`
|
|
65
65
|
* */
|
|
66
|
-
data?:
|
|
66
|
+
data?: JsonObject;
|
|
67
67
|
/** The file on the request, same rules apply as the `data` property */
|
|
68
68
|
file?: {
|
|
69
69
|
data: Buffer;
|
|
@@ -78,8 +78,14 @@ export interface RequestContext {
|
|
|
78
78
|
[key: string]: unknown;
|
|
79
79
|
}
|
|
80
80
|
export type Operator = (typeof validOperators)[number];
|
|
81
|
+
export type JsonValue = JsonArray | JsonObject | unknown;
|
|
82
|
+
export interface JsonArray extends Array<JsonValue> {
|
|
83
|
+
}
|
|
84
|
+
export interface JsonObject {
|
|
85
|
+
[key: string]: JsonValue;
|
|
86
|
+
}
|
|
81
87
|
export type WhereField = {
|
|
82
|
-
[key in Operator]?:
|
|
88
|
+
[key in Operator]?: JsonValue;
|
|
83
89
|
};
|
|
84
90
|
export type Where = {
|
|
85
91
|
[key: string]: Where[] | WhereField;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,KAAK,UAAU,MAAM,YAAY,CAAA;AAExC,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACpF,OAAO,KAAK,OAAO,MAAM,aAAa,CAAA;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,YAAY,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,aAAa,CAAA;AAErD,MAAM,MAAM,8BAA8B,GAAG;IAC3C,OAAO,EAAE,cAAc,CAAA;IACvB,mGAAmG;IACnG,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,IAAI,EAAE,IAAI,CAAA;IACV;;;OAGG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB;;OAEG;IACH,OAAO,E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A;AAE1B,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAA;AAC/D,MAAM,MAAM,iBAAiB,GAAG,cAAc,CAAA;AAC9C,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAA;AACrC,MAAM,MAAM,aAAa,GAAG,cAAc,GAAG,SAAS,GAAG,iBAAiB,CAAA;AAE1E,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,kBAAkB,CAEpE;AAED,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AACpD,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,CAAA;AAC5C,MAAM,MAAM,UAAU,CAAC,CAAC,EAAE,WAAW,IAAI,KAAK,CAAC,CAAC,CAAC,SAAS,IAAI,GAAG,WAAW,GAAG,CAAC,CAAA"}
|
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["import type { I18n, TFunction } from '@payloadcms/translations'\nimport type DataLoader from 'dataloader'\n\nimport type { TypeWithID, TypeWithTimestamps } from '../collections/config/types.js'\nimport type payload from '../index.js'\nimport type { TypedLocale, TypedUser } from '../index.js'\nimport type { validOperators } from './constants.js'\nexport type { Payload as Payload } from '../index.js'\n\nexport type CustomPayloadRequestProperties = {\n context: RequestContext\n /** The locale that should be used for a field when it is not translated to the requested locale */\n fallbackLocale?: string\n i18n: I18n\n /**\n * The requested locale if specified\n * Only available for localized collections\n */\n locale?: TypedLocale\n /**\n * The payload object\n */\n payload: typeof payload\n /**\n * The context in which the request is being made\n */\n payloadAPI: 'GraphQL' | 'REST' | 'local'\n /** Optimized document loader */\n payloadDataLoader?: DataLoader<string, TypeWithID>\n /** Resized versions of the image that was uploaded during this request */\n payloadUploadSizes?: Record<string, Buffer>\n /** Query params on the request */\n query: Record<string, unknown>\n /** Any response headers that are required to be set when a response is sent */\n responseHeaders?: Headers\n /** The route parameters\n * @example\n * /:collection/:id -> /posts/123\n * { collection: 'posts', id: '123' }\n */\n routeParams?: Record<string, unknown>\n /** Translate function - duplicate of i18n.t */\n t: TFunction\n /**\n * Identifier for the database transaction for interactions in a single, all-or-nothing operation.\n * Can also be used to ensure consistency when multiple operations try to create a transaction concurrently on the same request.\n */\n transactionID?: Promise<number | string> | number | string\n /**\n * Used to ensure consistency when multiple operations try to create a transaction concurrently on the same request\n */\n transactionIDPromise?: Promise<void>\n /** The signed-in user */\n user: TypedUser | null\n} & Pick<\n URL,\n 'hash' | 'host' | 'href' | 'origin' | 'pathname' | 'port' | 'protocol' | 'search' | 'searchParams'\n>\ntype PayloadRequestData = {\n /**\n * Data from the request body\n *\n * Within Payload operations, i.e. hooks, data will be there\n * BUT in custom endpoints it will not be, you will need to\n * use either:\n * 1. `const data = await req.json()`\n *\n * 2. import { addDataAndFileToRequest } from '@payloadcms/next/utilities'\n * `await addDataAndFileToRequest(req)`\n * */\n data?:
|
|
1
|
+
{"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["import type { I18n, TFunction } from '@payloadcms/translations'\nimport type DataLoader from 'dataloader'\n\nimport type { TypeWithID, TypeWithTimestamps } from '../collections/config/types.js'\nimport type payload from '../index.js'\nimport type { TypedLocale, TypedUser } from '../index.js'\nimport type { validOperators } from './constants.js'\nexport type { Payload as Payload } from '../index.js'\n\nexport type CustomPayloadRequestProperties = {\n context: RequestContext\n /** The locale that should be used for a field when it is not translated to the requested locale */\n fallbackLocale?: string\n i18n: I18n\n /**\n * The requested locale if specified\n * Only available for localized collections\n */\n locale?: TypedLocale\n /**\n * The payload object\n */\n payload: typeof payload\n /**\n * The context in which the request is being made\n */\n payloadAPI: 'GraphQL' | 'REST' | 'local'\n /** Optimized document loader */\n payloadDataLoader?: DataLoader<string, TypeWithID>\n /** Resized versions of the image that was uploaded during this request */\n payloadUploadSizes?: Record<string, Buffer>\n /** Query params on the request */\n query: Record<string, unknown>\n /** Any response headers that are required to be set when a response is sent */\n responseHeaders?: Headers\n /** The route parameters\n * @example\n * /:collection/:id -> /posts/123\n * { collection: 'posts', id: '123' }\n */\n routeParams?: Record<string, unknown>\n /** Translate function - duplicate of i18n.t */\n t: TFunction\n /**\n * Identifier for the database transaction for interactions in a single, all-or-nothing operation.\n * Can also be used to ensure consistency when multiple operations try to create a transaction concurrently on the same request.\n */\n transactionID?: Promise<number | string> | number | string\n /**\n * Used to ensure consistency when multiple operations try to create a transaction concurrently on the same request\n */\n transactionIDPromise?: Promise<void>\n /** The signed-in user */\n user: TypedUser | null\n} & Pick<\n URL,\n 'hash' | 'host' | 'href' | 'origin' | 'pathname' | 'port' | 'protocol' | 'search' | 'searchParams'\n>\ntype PayloadRequestData = {\n /**\n * Data from the request body\n *\n * Within Payload operations, i.e. hooks, data will be there\n * BUT in custom endpoints it will not be, you will need to\n * use either:\n * 1. `const data = await req.json()`\n *\n * 2. import { addDataAndFileToRequest } from '@payloadcms/next/utilities'\n * `await addDataAndFileToRequest(req)`\n * */\n data?: JsonObject\n /** The file on the request, same rules apply as the `data` property */\n file?: {\n data: Buffer\n mimetype: string\n name: string\n size: number\n tempFilePath?: string\n }\n}\nexport type PayloadRequest = CustomPayloadRequestProperties &\n Partial<Request> &\n PayloadRequestData &\n Required<Pick<Request, 'headers'>>\n\nexport interface RequestContext {\n [key: string]: unknown\n}\n\nexport type Operator = (typeof validOperators)[number]\n\n// Makes it so things like passing new Date() will error\nexport type JsonValue = JsonArray | JsonObject | unknown //Date | JsonArray | JsonObject | boolean | null | number | string // TODO: Evaluate proper, strong type for this\n\nexport interface JsonArray extends Array<JsonValue> {}\n\nexport interface JsonObject {\n [key: string]: JsonValue\n}\n\nexport type WhereField = {\n // any json-serializable value\n [key in Operator]?: JsonValue\n}\n\nexport type Where = {\n [key: string]: Where[] | WhereField\n and?: Where[]\n or?: Where[]\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type Document = any\n\nexport type Operation = 'create' | 'delete' | 'read' | 'update'\nexport type VersionOperations = 'readVersions'\nexport type AuthOperations = 'unlock'\nexport type AllOperations = AuthOperations | Operation | VersionOperations\n\nexport function docHasTimestamps(doc: any): doc is TypeWithTimestamps {\n return doc?.createdAt && doc?.updatedAt\n}\n\nexport type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N // This is a commonly used trick to detect 'any'\nexport type IsAny<T> = IfAny<T, true, false>\nexport type ReplaceAny<T, DefaultType> = IsAny<T> extends true ? DefaultType : T\n"],"names":["docHasTimestamps","doc","createdAt","updatedAt"],"mappings":"AAuHA,OAAO,SAASA,iBAAiBC,GAAQ;IACvC,OAAOA,KAAKC,aAAaD,KAAKE;AAChC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { SanitizedConfig } from '../config/types.js';
|
|
2
2
|
import type { PayloadRequest } from '../types/index.js';
|
|
3
|
+
import type { WithMetadata } from './optionallyAppendMetadata.js';
|
|
3
4
|
import type { UploadEdits } from './types.js';
|
|
4
5
|
export declare const percentToPixel: (value: any, dimension: any) => number;
|
|
5
6
|
type CropImageArgs = {
|
|
@@ -10,10 +11,12 @@ type CropImageArgs = {
|
|
|
10
11
|
};
|
|
11
12
|
file: PayloadRequest['file'];
|
|
12
13
|
heightInPixels: number;
|
|
14
|
+
req?: PayloadRequest;
|
|
13
15
|
sharp: SanitizedConfig['sharp'];
|
|
14
16
|
widthInPixels: number;
|
|
17
|
+
withMetadata?: WithMetadata;
|
|
15
18
|
};
|
|
16
|
-
export declare function cropImage({ cropData, dimensions, file, heightInPixels, sharp, widthInPixels, }: CropImageArgs): Promise<{
|
|
19
|
+
export declare function cropImage({ cropData, dimensions, file, heightInPixels, req, sharp, widthInPixels, withMetadata, }: CropImageArgs): Promise<{
|
|
17
20
|
data: Buffer;
|
|
18
21
|
info: import("sharp").OutputInfo;
|
|
19
22
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cropImage.d.ts","sourceRoot":"","sources":["../../src/uploads/cropImage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"cropImage.d.ts","sourceRoot":"","sources":["../../src/uploads/cropImage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAI7C,eAAO,MAAM,cAAc,wCAE1B,CAAA;AAED,KAAK,aAAa,GAAG;IACnB,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IAC7B,UAAU,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;IAC7C,IAAI,EAAE,cAAc,CAAC,MAAM,CAAC,CAAA;IAC5B,cAAc,EAAE,MAAM,CAAA;IACtB,GAAG,CAAC,EAAE,cAAc,CAAA;IACpB,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,CAAA;IAC/B,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,YAAY,CAAA;CAC5B,CAAA;AACD,wBAAsB,SAAS,CAAC,EAC9B,QAAQ,EACR,UAAU,EACV,IAAI,EACJ,cAAc,EACd,GAAG,EACH,KAAK,EACL,aAAa,EACb,YAAY,GACb,EAAE,aAAa;;;GAgCf"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { optionallyAppendMetadata } from './optionallyAppendMetadata.js';
|
|
1
2
|
export const percentToPixel = (value, dimension)=>{
|
|
2
3
|
return Math.floor(parseFloat(value) / 100 * dimension);
|
|
3
4
|
};
|
|
4
|
-
export async function cropImage({ cropData, dimensions, file, heightInPixels, sharp, widthInPixels }) {
|
|
5
|
+
export async function cropImage({ cropData, dimensions, file, heightInPixels, req, sharp, widthInPixels, withMetadata }) {
|
|
5
6
|
try {
|
|
6
7
|
const { x, y } = cropData;
|
|
7
8
|
const fileIsAnimatedType = [
|
|
@@ -17,7 +18,12 @@ export async function cropImage({ cropData, dimensions, file, heightInPixels, sh
|
|
|
17
18
|
top: percentToPixel(y, dimensions.height),
|
|
18
19
|
width: Number(widthInPixels)
|
|
19
20
|
};
|
|
20
|
-
|
|
21
|
+
let cropped = sharp(file.tempFilePath || file.data, sharpOptions).extract(formattedCropData);
|
|
22
|
+
cropped = await optionallyAppendMetadata({
|
|
23
|
+
req,
|
|
24
|
+
sharpFile: cropped,
|
|
25
|
+
withMetadata
|
|
26
|
+
});
|
|
21
27
|
return await cropped.toBuffer({
|
|
22
28
|
resolveWithObject: true
|
|
23
29
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/uploads/cropImage.ts"],"sourcesContent":["import type { SharpOptions } from 'sharp'\n\nimport type { SanitizedConfig } from '../config/types.js'\nimport type { PayloadRequest } from '../types/index.js'\nimport type { UploadEdits } from './types.js'\n\nexport const percentToPixel = (value, dimension) => {\n return Math.floor((parseFloat(value) / 100) * dimension)\n}\n\ntype CropImageArgs = {\n cropData: UploadEdits['crop']\n dimensions: { height: number; width: number }\n file: PayloadRequest['file']\n heightInPixels: number\n sharp: SanitizedConfig['sharp']\n widthInPixels: number\n}\nexport async function cropImage({\n cropData,\n dimensions,\n file,\n heightInPixels,\n sharp,\n widthInPixels,\n}: CropImageArgs) {\n try {\n const { x, y } = cropData\n\n const fileIsAnimatedType = ['image/avif', 'image/gif', 'image/webp'].includes(file.mimetype)\n\n const sharpOptions: SharpOptions = {}\n\n if (fileIsAnimatedType) sharpOptions.animated = true\n\n const formattedCropData = {\n height: Number(heightInPixels),\n left: percentToPixel(x, dimensions.width),\n top: percentToPixel(y, dimensions.height),\n width: Number(widthInPixels),\n }\n\n
|
|
1
|
+
{"version":3,"sources":["../../src/uploads/cropImage.ts"],"sourcesContent":["import type { SharpOptions } from 'sharp'\n\nimport type { SanitizedConfig } from '../config/types.js'\nimport type { PayloadRequest } from '../types/index.js'\nimport type { WithMetadata } from './optionallyAppendMetadata.js'\nimport type { UploadEdits } from './types.js'\n\nimport { optionallyAppendMetadata } from './optionallyAppendMetadata.js'\n\nexport const percentToPixel = (value, dimension) => {\n return Math.floor((parseFloat(value) / 100) * dimension)\n}\n\ntype CropImageArgs = {\n cropData: UploadEdits['crop']\n dimensions: { height: number; width: number }\n file: PayloadRequest['file']\n heightInPixels: number\n req?: PayloadRequest\n sharp: SanitizedConfig['sharp']\n widthInPixels: number\n withMetadata?: WithMetadata\n}\nexport async function cropImage({\n cropData,\n dimensions,\n file,\n heightInPixels,\n req,\n sharp,\n widthInPixels,\n withMetadata,\n}: CropImageArgs) {\n try {\n const { x, y } = cropData\n\n const fileIsAnimatedType = ['image/avif', 'image/gif', 'image/webp'].includes(file.mimetype)\n\n const sharpOptions: SharpOptions = {}\n\n if (fileIsAnimatedType) sharpOptions.animated = true\n\n const formattedCropData = {\n height: Number(heightInPixels),\n left: percentToPixel(x, dimensions.width),\n top: percentToPixel(y, dimensions.height),\n width: Number(widthInPixels),\n }\n\n let cropped = sharp(file.tempFilePath || file.data, sharpOptions).extract(formattedCropData)\n\n cropped = await optionallyAppendMetadata({\n req,\n sharpFile: cropped,\n withMetadata,\n })\n\n return await cropped.toBuffer({\n resolveWithObject: true,\n })\n } catch (error) {\n console.error(`Error cropping image:`, error)\n throw error\n }\n}\n"],"names":["optionallyAppendMetadata","percentToPixel","value","dimension","Math","floor","parseFloat","cropImage","cropData","dimensions","file","heightInPixels","req","sharp","widthInPixels","withMetadata","x","y","fileIsAnimatedType","includes","mimetype","sharpOptions","animated","formattedCropData","height","Number","left","width","top","cropped","tempFilePath","data","extract","sharpFile","toBuffer","resolveWithObject","error","console"],"mappings":"AAOA,SAASA,wBAAwB,QAAQ,gCAA+B;AAExE,OAAO,MAAMC,iBAAiB,CAACC,OAAOC;IACpC,OAAOC,KAAKC,KAAK,CAAC,AAACC,WAAWJ,SAAS,MAAOC;AAChD,EAAC;AAYD,OAAO,eAAeI,UAAU,EAC9BC,QAAQ,EACRC,UAAU,EACVC,IAAI,EACJC,cAAc,EACdC,GAAG,EACHC,KAAK,EACLC,aAAa,EACbC,YAAY,EACE;IACd,IAAI;QACF,MAAM,EAAEC,CAAC,EAAEC,CAAC,EAAE,GAAGT;QAEjB,MAAMU,qBAAqB;YAAC;YAAc;YAAa;SAAa,CAACC,QAAQ,CAACT,KAAKU,QAAQ;QAE3F,MAAMC,eAA6B,CAAC;QAEpC,IAAIH,oBAAoBG,aAAaC,QAAQ,GAAG;QAEhD,MAAMC,oBAAoB;YACxBC,QAAQC,OAAOd;YACfe,MAAMzB,eAAee,GAAGP,WAAWkB,KAAK;YACxCC,KAAK3B,eAAegB,GAAGR,WAAWe,MAAM;YACxCG,OAAOF,OAAOX;QAChB;QAEA,IAAIe,UAAUhB,MAAMH,KAAKoB,YAAY,IAAIpB,KAAKqB,IAAI,EAAEV,cAAcW,OAAO,CAACT;QAE1EM,UAAU,MAAM7B,yBAAyB;YACvCY;YACAqB,WAAWJ;YACXd;QACF;QAEA,OAAO,MAAMc,QAAQK,QAAQ,CAAC;YAC5BC,mBAAmB;QACrB;IACF,EAAE,OAAOC,OAAO;QACdC,QAAQD,KAAK,CAAC,CAAC,qBAAqB,CAAC,EAAEA;QACvC,MAAMA;IACR;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateFileData.d.ts","sourceRoot":"","sources":["../../src/uploads/generateFileData.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EAAY,UAAU,EAAgC,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"generateFileData.d.ts","sourceRoot":"","sources":["../../src/uploads/generateFileData.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EAAY,UAAU,EAAgC,MAAM,YAAY,CAAA;AAapF,KAAK,IAAI,CAAC,CAAC,IAAI;IACb,UAAU,EAAE,UAAU,CAAA;IACtB,MAAM,EAAE,eAAe,CAAA;IACvB,IAAI,EAAE,CAAC,CAAA;IACP,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC9B,WAAW,CAAC,EAAE,CAAC,CAAA;IACf,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC,GAAG,EAAE,cAAc,CAAA;IACnB,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC7B,CAAA;AAED,KAAK,MAAM,CAAC,CAAC,IAAI,OAAO,CAAC;IACvB,IAAI,EAAE,CAAC,CAAA;IACP,KAAK,EAAE,UAAU,EAAE,CAAA;CACpB,CAAC,CAAA;AAEF,eAAO,MAAM,gBAAgB,GAAU,CAAC,gIAQrC,IAAI,CAAC,CAAC,CAAC,KAAG,MAAM,CAAC,CAAC,CAoQpB,CAAA"}
|
|
@@ -11,6 +11,7 @@ import { getImageSize } from './getImageSize.js';
|
|
|
11
11
|
import { getSafeFileName } from './getSafeFilename.js';
|
|
12
12
|
import { resizeAndTransformImageSizes } from './imageResizer.js';
|
|
13
13
|
import { isImage } from './isImage.js';
|
|
14
|
+
import { optionallyAppendMetadata } from './optionallyAppendMetadata.js';
|
|
14
15
|
export const generateFileData = async ({ collection: { config: collectionConfig }, data, operation, originalDoc, overwriteExistingFiles, req, throwOnMissingFile })=>{
|
|
15
16
|
if (!collectionConfig.upload) {
|
|
16
17
|
return {
|
|
@@ -26,7 +27,7 @@ export const generateFileData = async ({ collection: { config: collectionConfig
|
|
|
26
27
|
originalDoc,
|
|
27
28
|
req
|
|
28
29
|
});
|
|
29
|
-
const { disableLocalStorage, focalPoint: focalPointEnabled = true, formatOptions, imageSizes, resizeOptions, staticDir, trimOptions } = collectionConfig.upload;
|
|
30
|
+
const { disableLocalStorage, focalPoint: focalPointEnabled = true, formatOptions, imageSizes, resizeOptions, staticDir, trimOptions, withMetadata } = collectionConfig.upload;
|
|
30
31
|
const staticPath = staticDir;
|
|
31
32
|
if (!file && uploadEdits && data) {
|
|
32
33
|
const { filename, url } = data;
|
|
@@ -107,6 +108,11 @@ export const generateFileData = async ({ collection: { config: collectionConfig
|
|
|
107
108
|
}
|
|
108
109
|
if (sharpFile) {
|
|
109
110
|
const metadata = await sharpFile.metadata();
|
|
111
|
+
sharpFile = await optionallyAppendMetadata({
|
|
112
|
+
req,
|
|
113
|
+
sharpFile,
|
|
114
|
+
withMetadata
|
|
115
|
+
});
|
|
110
116
|
fileBuffer = await sharpFile.toBuffer({
|
|
111
117
|
resolveWithObject: true
|
|
112
118
|
});
|
|
@@ -150,8 +156,10 @@ export const generateFileData = async ({ collection: { config: collectionConfig
|
|
|
150
156
|
dimensions,
|
|
151
157
|
file,
|
|
152
158
|
heightInPixels: uploadEdits.heightInPixels,
|
|
159
|
+
req,
|
|
153
160
|
sharp,
|
|
154
|
-
widthInPixels: uploadEdits.widthInPixels
|
|
161
|
+
widthInPixels: uploadEdits.widthInPixels,
|
|
162
|
+
withMetadata
|
|
155
163
|
});
|
|
156
164
|
filesToSave.push({
|
|
157
165
|
buffer: croppedImage,
|
|
@@ -210,7 +218,8 @@ export const generateFileData = async ({ collection: { config: collectionConfig
|
|
|
210
218
|
savedFilename: fsSafeName || file.name,
|
|
211
219
|
sharp,
|
|
212
220
|
staticPath,
|
|
213
|
-
uploadEdits
|
|
221
|
+
uploadEdits,
|
|
222
|
+
withMetadata
|
|
214
223
|
});
|
|
215
224
|
fileData.sizes = sizeData;
|
|
216
225
|
fileData.focalX = focalPoint?.x;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/uploads/generateFileData.ts"],"sourcesContent":["import type { OutputInfo, Sharp, SharpOptions } from 'sharp'\n\nimport { fileTypeFromBuffer } from 'file-type'\nimport fs from 'fs'\nimport { mkdirSync } from 'node:fs'\nimport sanitize from 'sanitize-filename'\n\nimport type { Collection } from '../collections/config/types.js'\nimport type { SanitizedConfig } from '../config/types.js'\nimport type { PayloadRequest } from '../types/index.js'\nimport type { FileData, FileToSave, ProbedImageSize, UploadEdits } from './types.js'\n\nimport { FileRetrievalError, FileUploadError, MissingFile } from '../errors/index.js'\nimport { canResizeImage } from './canResizeImage.js'\nimport { cropImage } from './cropImage.js'\nimport { getExternalFile } from './getExternalFile.js'\nimport { getFileByPath } from './getFileByPath.js'\nimport { getImageSize } from './getImageSize.js'\nimport { getSafeFileName } from './getSafeFilename.js'\nimport { resizeAndTransformImageSizes } from './imageResizer.js'\nimport { isImage } from './isImage.js'\n\ntype Args<T> = {\n collection: Collection\n config: SanitizedConfig\n data: T\n operation: 'create' | 'update'\n originalDoc?: T\n overwriteExistingFiles?: boolean\n req: PayloadRequest\n throwOnMissingFile?: boolean\n}\n\ntype Result<T> = Promise<{\n data: T\n files: FileToSave[]\n}>\n\nexport const generateFileData = async <T>({\n collection: { config: collectionConfig },\n data,\n operation,\n originalDoc,\n overwriteExistingFiles,\n req,\n throwOnMissingFile,\n}: Args<T>): Result<T> => {\n if (!collectionConfig.upload) {\n return {\n data,\n files: [],\n }\n }\n\n const { sharp } = req.payload.config\n\n let file = req.file\n\n const uploadEdits = parseUploadEditsFromReqOrIncomingData({\n data,\n operation,\n originalDoc,\n req,\n })\n\n const {\n disableLocalStorage,\n focalPoint: focalPointEnabled = true,\n formatOptions,\n imageSizes,\n resizeOptions,\n staticDir,\n trimOptions,\n } = collectionConfig.upload\n\n const staticPath = staticDir\n\n if (!file && uploadEdits && data) {\n const { filename, url } = data as FileData\n\n try {\n if (url && url.startsWith('/') && !disableLocalStorage) {\n const filePath = `${staticPath}/${filename}`\n const response = await getFileByPath(filePath)\n file = response\n overwriteExistingFiles = true\n } else if (filename && url) {\n file = await getExternalFile({\n data: data as FileData,\n req,\n uploadConfig: collectionConfig.upload,\n })\n overwriteExistingFiles = true\n }\n } catch (err: unknown) {\n throw new FileRetrievalError(req.t, err instanceof Error ? err.message : undefined)\n }\n }\n\n if (!file) {\n if (throwOnMissingFile) throw new MissingFile(req.t)\n\n return {\n data,\n files: [],\n }\n }\n\n if (!disableLocalStorage) {\n mkdirSync(staticPath, { recursive: true })\n }\n\n let newData = data\n const filesToSave: FileToSave[] = []\n const fileData: Partial<FileData> = {}\n const fileIsAnimatedType = ['image/avif', 'image/gif', 'image/webp'].includes(file.mimetype)\n const cropData =\n typeof uploadEdits === 'object' && 'crop' in uploadEdits ? uploadEdits.crop : undefined\n\n try {\n const fileSupportsResize = canResizeImage(file.mimetype)\n let fsSafeName: string\n let sharpFile: Sharp | undefined\n let dimensions: ProbedImageSize | undefined\n let fileBuffer: { data: Buffer; info: OutputInfo }\n let ext\n let mime: string\n const fileHasAdjustments =\n fileSupportsResize &&\n Boolean(resizeOptions || formatOptions || imageSizes || trimOptions || file.tempFilePath)\n\n const sharpOptions: SharpOptions = {}\n\n if (fileIsAnimatedType) sharpOptions.animated = true\n\n if (sharp && (fileIsAnimatedType || fileHasAdjustments)) {\n if (file.tempFilePath) {\n sharpFile = sharp(file.tempFilePath, sharpOptions).rotate() // pass rotate() to auto-rotate based on EXIF data. https://github.com/payloadcms/payload/pull/3081\n } else {\n sharpFile = sharp(file.data, sharpOptions).rotate() // pass rotate() to auto-rotate based on EXIF data. https://github.com/payloadcms/payload/pull/3081\n }\n\n if (fileHasAdjustments) {\n if (resizeOptions) {\n sharpFile = sharpFile.resize(resizeOptions)\n }\n if (formatOptions) {\n sharpFile = sharpFile.toFormat(formatOptions.format, formatOptions.options)\n }\n if (trimOptions) {\n sharpFile = sharpFile.trim(trimOptions)\n }\n }\n }\n\n if (fileSupportsResize || isImage(file.mimetype)) {\n dimensions = await getImageSize(file)\n fileData.width = dimensions.width\n fileData.height = dimensions.height\n }\n\n if (sharpFile) {\n const metadata = await sharpFile.metadata()\n fileBuffer = await sharpFile.toBuffer({ resolveWithObject: true })\n ;({ ext, mime } = await fileTypeFromBuffer(fileBuffer.data)) // This is getting an incorrect gif height back.\n fileData.width = fileBuffer.info.width\n fileData.height = fileBuffer.info.height\n fileData.filesize = fileBuffer.info.size\n\n // Animated GIFs + WebP aggregate the height from every frame, so we need to use divide by number of pages\n if (metadata.pages) {\n fileData.height = fileBuffer.info.height / metadata.pages\n fileData.filesize = fileBuffer.data.length\n }\n } else {\n mime = file.mimetype\n fileData.filesize = file.size\n\n if (file.name.includes('.')) {\n ext = file.name.split('.').pop().split('?')[0]\n } else {\n ext = ''\n }\n }\n\n // Adjust SVG mime type. fromBuffer modifies it.\n if (mime === 'application/xml' && ext === 'svg') mime = 'image/svg+xml'\n fileData.mimeType = mime\n\n const baseFilename = sanitize(file.name.substring(0, file.name.lastIndexOf('.')) || file.name)\n fsSafeName = `${baseFilename}${ext ? `.${ext}` : ''}`\n\n if (!overwriteExistingFiles) {\n fsSafeName = await getSafeFileName({\n collectionSlug: collectionConfig.slug,\n desiredFilename: fsSafeName,\n req,\n staticPath,\n })\n }\n\n fileData.filename = fsSafeName\n let fileForResize = file\n\n if (cropData && sharp) {\n const { data: croppedImage, info } = await cropImage({\n cropData,\n dimensions,\n file,\n heightInPixels: uploadEdits.heightInPixels,\n sharp,\n widthInPixels: uploadEdits.widthInPixels,\n })\n\n filesToSave.push({\n buffer: croppedImage,\n path: `${staticPath}/${fsSafeName}`,\n })\n\n fileForResize = {\n ...file,\n data: croppedImage,\n size: info.size,\n }\n fileData.width = info.width\n fileData.height = info.height\n if (fileIsAnimatedType) {\n const metadata = await sharpFile.metadata()\n fileData.height = metadata.pages ? info.height / metadata.pages : info.height\n }\n fileData.filesize = info.size\n\n if (file.tempFilePath) {\n await fs.promises.writeFile(file.tempFilePath, croppedImage) // write fileBuffer to the temp path\n } else {\n req.file = fileForResize\n }\n } else {\n filesToSave.push({\n buffer: fileBuffer?.data || file.data,\n path: `${staticPath}/${fsSafeName}`,\n })\n\n // If using temp files and the image is being resized, write the file to the temp path\n if (fileBuffer?.data || file.data.length > 0) {\n if (file.tempFilePath) {\n await fs.promises.writeFile(file.tempFilePath, fileBuffer?.data || file.data) // write fileBuffer to the temp path\n } else {\n // Assign the _possibly modified_ file to the request object\n req.file = {\n ...file,\n data: fileBuffer?.data || file.data,\n size: fileBuffer?.info.size,\n }\n }\n }\n }\n\n if (fileSupportsResize && (Array.isArray(imageSizes) || focalPointEnabled !== false)) {\n req.payloadUploadSizes = {}\n const { focalPoint, sizeData, sizesToSave } = await resizeAndTransformImageSizes({\n config: collectionConfig,\n dimensions: !cropData\n ? dimensions\n : {\n ...dimensions,\n height: fileData.height,\n width: fileData.width,\n },\n file: fileForResize,\n mimeType: fileData.mimeType,\n req,\n savedFilename: fsSafeName || file.name,\n sharp,\n staticPath,\n uploadEdits,\n })\n\n fileData.sizes = sizeData\n fileData.focalX = focalPoint?.x\n fileData.focalY = focalPoint?.y\n filesToSave.push(...sizesToSave)\n }\n } catch (err) {\n req.payload.logger.error(err)\n throw new FileUploadError(req.t)\n }\n\n newData = {\n ...newData,\n ...fileData,\n }\n\n return {\n data: newData,\n files: filesToSave,\n }\n}\n\n/**\n * Parse upload edits from req or incoming data\n */\nfunction parseUploadEditsFromReqOrIncomingData(args: {\n data: unknown\n operation: 'create' | 'update'\n originalDoc: unknown\n req: PayloadRequest\n}): UploadEdits {\n const { data, operation, originalDoc, req } = args\n\n // Get intended focal point change from query string or incoming data\n const uploadEdits =\n req.query?.uploadEdits && typeof req.query.uploadEdits === 'object'\n ? (req.query.uploadEdits as UploadEdits)\n : {}\n\n if (uploadEdits.focalPoint) return uploadEdits\n\n const incomingData = data as FileData\n const origDoc = originalDoc as FileData\n\n // If no change in focal point, return undefined.\n // This prevents a refocal operation triggered from admin, because it always sends the focal point.\n if (origDoc && incomingData.focalX === origDoc.focalX && incomingData.focalY === origDoc.focalY) {\n return undefined\n }\n\n if (incomingData?.focalX && incomingData?.focalY) {\n uploadEdits.focalPoint = {\n x: incomingData.focalX,\n y: incomingData.focalY,\n }\n return uploadEdits\n }\n\n // If no focal point is set, default to center\n if (operation === 'create') {\n uploadEdits.focalPoint = {\n x: 50,\n y: 50,\n }\n }\n return uploadEdits\n}\n"],"names":["fileTypeFromBuffer","fs","mkdirSync","sanitize","FileRetrievalError","FileUploadError","MissingFile","canResizeImage","cropImage","getExternalFile","getFileByPath","getImageSize","getSafeFileName","resizeAndTransformImageSizes","isImage","generateFileData","collection","config","collectionConfig","data","operation","originalDoc","overwriteExistingFiles","req","throwOnMissingFile","upload","files","sharp","payload","file","uploadEdits","parseUploadEditsFromReqOrIncomingData","disableLocalStorage","focalPoint","focalPointEnabled","formatOptions","imageSizes","resizeOptions","staticDir","trimOptions","staticPath","filename","url","startsWith","filePath","response","uploadConfig","err","t","Error","message","undefined","recursive","newData","filesToSave","fileData","fileIsAnimatedType","includes","mimetype","cropData","crop","fileSupportsResize","fsSafeName","sharpFile","dimensions","fileBuffer","ext","mime","fileHasAdjustments","Boolean","tempFilePath","sharpOptions","animated","rotate","resize","toFormat","format","options","trim","width","height","metadata","toBuffer","resolveWithObject","info","filesize","size","pages","length","name","split","pop","mimeType","baseFilename","substring","lastIndexOf","collectionSlug","slug","desiredFilename","fileForResize","croppedImage","heightInPixels","widthInPixels","push","buffer","path","promises","writeFile","Array","isArray","payloadUploadSizes","sizeData","sizesToSave","savedFilename","sizes","focalX","x","focalY","y","logger","error","args","query","incomingData","origDoc"],"mappings":"AAEA,SAASA,kBAAkB,QAAQ,YAAW;AAC9C,OAAOC,QAAQ,KAAI;AACnB,SAASC,SAAS,QAAQ,UAAS;AACnC,OAAOC,cAAc,oBAAmB;AAOxC,SAASC,kBAAkB,EAAEC,eAAe,EAAEC,WAAW,QAAQ,qBAAoB;AACrF,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,SAAS,QAAQ,iBAAgB;AAC1C,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,4BAA4B,QAAQ,oBAAmB;AAChE,SAASC,OAAO,QAAQ,eAAc;AAkBtC,OAAO,MAAMC,mBAAmB,OAAU,EACxCC,YAAY,EAAEC,QAAQC,gBAAgB,EAAE,EACxCC,IAAI,EACJC,SAAS,EACTC,WAAW,EACXC,sBAAsB,EACtBC,GAAG,EACHC,kBAAkB,EACV;IACR,IAAI,CAACN,iBAAiBO,MAAM,EAAE;QAC5B,OAAO;YACLN;YACAO,OAAO,EAAE;QACX;IACF;IAEA,MAAM,EAAEC,KAAK,EAAE,GAAGJ,IAAIK,OAAO,CAACX,MAAM;IAEpC,IAAIY,OAAON,IAAIM,IAAI;IAEnB,MAAMC,cAAcC,sCAAsC;QACxDZ;QACAC;QACAC;QACAE;IACF;IAEA,MAAM,EACJS,mBAAmB,EACnBC,YAAYC,oBAAoB,IAAI,EACpCC,aAAa,EACbC,UAAU,EACVC,aAAa,EACbC,SAAS,EACTC,WAAW,EACZ,GAAGrB,iBAAiBO,MAAM;IAE3B,MAAMe,aAAaF;IAEnB,IAAI,CAACT,QAAQC,eAAeX,MAAM;QAChC,MAAM,EAAEsB,QAAQ,EAAEC,GAAG,EAAE,GAAGvB;QAE1B,I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,cAAcR,UAAUQ,cAAcN,QAAQ;QAChDvF,YAAYG,UAAU,GAAG;YACvBmF,GAAGO,aAAaR,MAAM;YACtBG,GAAGK,aAAaN,MAAM;QACxB;QACA,OAAOvF;IACT;IAEA,8CAA8C;IAC9C,IAAIV,cAAc,UAAU;QAC1BU,YAAYG,UAAU,GAAG;YACvBmF,GAAG;YACHE,GAAG;QACL;IACF;IACA,OAAOxF;AACT"}
|
|
1
|
+
{"version":3,"sources":["../../src/uploads/generateFileData.ts"],"sourcesContent":["import type { OutputInfo, Sharp, SharpOptions } from 'sharp'\n\nimport { fileTypeFromBuffer } from 'file-type'\nimport fs from 'fs'\nimport { mkdirSync } from 'node:fs'\nimport sanitize from 'sanitize-filename'\n\nimport type { Collection } from '../collections/config/types.js'\nimport type { SanitizedConfig } from '../config/types.js'\nimport type { PayloadRequest } from '../types/index.js'\nimport type { FileData, FileToSave, ProbedImageSize, UploadEdits } from './types.js'\n\nimport { FileRetrievalError, FileUploadError, MissingFile } from '../errors/index.js'\nimport { canResizeImage } from './canResizeImage.js'\nimport { cropImage } from './cropImage.js'\nimport { getExternalFile } from './getExternalFile.js'\nimport { getFileByPath } from './getFileByPath.js'\nimport { getImageSize } from './getImageSize.js'\nimport { getSafeFileName } from './getSafeFilename.js'\nimport { resizeAndTransformImageSizes } from './imageResizer.js'\nimport { isImage } from './isImage.js'\nimport { optionallyAppendMetadata } from './optionallyAppendMetadata.js'\n\ntype Args<T> = {\n collection: Collection\n config: SanitizedConfig\n data: T\n operation: 'create' | 'update'\n originalDoc?: T\n overwriteExistingFiles?: boolean\n req: PayloadRequest\n throwOnMissingFile?: boolean\n}\n\ntype Result<T> = Promise<{\n data: T\n files: FileToSave[]\n}>\n\nexport const generateFileData = async <T>({\n collection: { config: collectionConfig },\n data,\n operation,\n originalDoc,\n overwriteExistingFiles,\n req,\n throwOnMissingFile,\n}: Args<T>): Result<T> => {\n if (!collectionConfig.upload) {\n return {\n data,\n files: [],\n }\n }\n\n const { sharp } = req.payload.config\n\n let file = req.file\n\n const uploadEdits = parseUploadEditsFromReqOrIncomingData({\n data,\n operation,\n originalDoc,\n req,\n })\n\n const {\n disableLocalStorage,\n focalPoint: focalPointEnabled = true,\n formatOptions,\n imageSizes,\n resizeOptions,\n staticDir,\n trimOptions,\n withMetadata,\n } = collectionConfig.upload\n\n const staticPath = staticDir\n\n if (!file && uploadEdits && data) {\n const { filename, url } = data as FileData\n\n try {\n if (url && url.startsWith('/') && !disableLocalStorage) {\n const filePath = `${staticPath}/${filename}`\n const response = await getFileByPath(filePath)\n file = response\n overwriteExistingFiles = true\n } else if (filename && url) {\n file = await getExternalFile({\n data: data as FileData,\n req,\n uploadConfig: collectionConfig.upload,\n })\n overwriteExistingFiles = true\n }\n } catch (err: unknown) {\n throw new FileRetrievalError(req.t, err instanceof Error ? err.message : undefined)\n }\n }\n\n if (!file) {\n if (throwOnMissingFile) throw new MissingFile(req.t)\n\n return {\n data,\n files: [],\n }\n }\n\n if (!disableLocalStorage) {\n mkdirSync(staticPath, { recursive: true })\n }\n\n let newData = data\n const filesToSave: FileToSave[] = []\n const fileData: Partial<FileData> = {}\n const fileIsAnimatedType = ['image/avif', 'image/gif', 'image/webp'].includes(file.mimetype)\n const cropData =\n typeof uploadEdits === 'object' && 'crop' in uploadEdits ? uploadEdits.crop : undefined\n\n try {\n const fileSupportsResize = canResizeImage(file.mimetype)\n let fsSafeName: string\n let sharpFile: Sharp | undefined\n let dimensions: ProbedImageSize | undefined\n let fileBuffer: { data: Buffer; info: OutputInfo }\n let ext\n let mime: string\n const fileHasAdjustments =\n fileSupportsResize &&\n Boolean(resizeOptions || formatOptions || imageSizes || trimOptions || file.tempFilePath)\n\n const sharpOptions: SharpOptions = {}\n\n if (fileIsAnimatedType) sharpOptions.animated = true\n\n if (sharp && (fileIsAnimatedType || fileHasAdjustments)) {\n if (file.tempFilePath) {\n sharpFile = sharp(file.tempFilePath, sharpOptions).rotate() // pass rotate() to auto-rotate based on EXIF data. https://github.com/payloadcms/payload/pull/3081\n } else {\n sharpFile = sharp(file.data, sharpOptions).rotate() // pass rotate() to auto-rotate based on EXIF data. https://github.com/payloadcms/payload/pull/3081\n }\n\n if (fileHasAdjustments) {\n if (resizeOptions) {\n sharpFile = sharpFile.resize(resizeOptions)\n }\n if (formatOptions) {\n sharpFile = sharpFile.toFormat(formatOptions.format, formatOptions.options)\n }\n if (trimOptions) {\n sharpFile = sharpFile.trim(trimOptions)\n }\n }\n }\n\n if (fileSupportsResize || isImage(file.mimetype)) {\n dimensions = await getImageSize(file)\n fileData.width = dimensions.width\n fileData.height = dimensions.height\n }\n\n if (sharpFile) {\n const metadata = await sharpFile.metadata()\n sharpFile = await optionallyAppendMetadata({\n req,\n sharpFile,\n withMetadata,\n })\n fileBuffer = await sharpFile.toBuffer({ resolveWithObject: true })\n ;({ ext, mime } = await fileTypeFromBuffer(fileBuffer.data)) // This is getting an incorrect gif height back.\n fileData.width = fileBuffer.info.width\n fileData.height = fileBuffer.info.height\n fileData.filesize = fileBuffer.info.size\n\n // Animated GIFs + WebP aggregate the height from every frame, so we need to use divide by number of pages\n if (metadata.pages) {\n fileData.height = fileBuffer.info.height / metadata.pages\n fileData.filesize = fileBuffer.data.length\n }\n } else {\n mime = file.mimetype\n fileData.filesize = file.size\n\n if (file.name.includes('.')) {\n ext = file.name.split('.').pop().split('?')[0]\n } else {\n ext = ''\n }\n }\n\n // Adjust SVG mime type. fromBuffer modifies it.\n if (mime === 'application/xml' && ext === 'svg') mime = 'image/svg+xml'\n fileData.mimeType = mime\n\n const baseFilename = sanitize(file.name.substring(0, file.name.lastIndexOf('.')) || file.name)\n fsSafeName = `${baseFilename}${ext ? `.${ext}` : ''}`\n\n if (!overwriteExistingFiles) {\n fsSafeName = await getSafeFileName({\n collectionSlug: collectionConfig.slug,\n desiredFilename: fsSafeName,\n req,\n staticPath,\n })\n }\n\n fileData.filename = fsSafeName\n let fileForResize = file\n\n if (cropData && sharp) {\n const { data: croppedImage, info } = await cropImage({\n cropData,\n dimensions,\n file,\n heightInPixels: uploadEdits.heightInPixels,\n req,\n sharp,\n widthInPixels: uploadEdits.widthInPixels,\n withMetadata,\n })\n\n filesToSave.push({\n buffer: croppedImage,\n path: `${staticPath}/${fsSafeName}`,\n })\n\n fileForResize = {\n ...file,\n data: croppedImage,\n size: info.size,\n }\n fileData.width = info.width\n fileData.height = info.height\n if (fileIsAnimatedType) {\n const metadata = await sharpFile.metadata()\n fileData.height = metadata.pages ? info.height / metadata.pages : info.height\n }\n fileData.filesize = info.size\n\n if (file.tempFilePath) {\n await fs.promises.writeFile(file.tempFilePath, croppedImage) // write fileBuffer to the temp path\n } else {\n req.file = fileForResize\n }\n } else {\n filesToSave.push({\n buffer: fileBuffer?.data || file.data,\n path: `${staticPath}/${fsSafeName}`,\n })\n\n // If using temp files and the image is being resized, write the file to the temp path\n if (fileBuffer?.data || file.data.length > 0) {\n if (file.tempFilePath) {\n await fs.promises.writeFile(file.tempFilePath, fileBuffer?.data || file.data) // write fileBuffer to the temp path\n } else {\n // Assign the _possibly modified_ file to the request object\n req.file = {\n ...file,\n data: fileBuffer?.data || file.data,\n size: fileBuffer?.info.size,\n }\n }\n }\n }\n\n if (fileSupportsResize && (Array.isArray(imageSizes) || focalPointEnabled !== false)) {\n req.payloadUploadSizes = {}\n const { focalPoint, sizeData, sizesToSave } = await resizeAndTransformImageSizes({\n config: collectionConfig,\n dimensions: !cropData\n ? dimensions\n : {\n ...dimensions,\n height: fileData.height,\n width: fileData.width,\n },\n file: fileForResize,\n mimeType: fileData.mimeType,\n req,\n savedFilename: fsSafeName || file.name,\n sharp,\n staticPath,\n uploadEdits,\n withMetadata,\n })\n\n fileData.sizes = sizeData\n fileData.focalX = focalPoint?.x\n fileData.focalY = focalPoint?.y\n filesToSave.push(...sizesToSave)\n }\n } catch (err) {\n req.payload.logger.error(err)\n throw new FileUploadError(req.t)\n }\n\n newData = {\n ...newData,\n ...fileData,\n }\n\n return {\n data: newData,\n files: filesToSave,\n }\n}\n\n/**\n * Parse upload edits from req or incoming data\n */\nfunction parseUploadEditsFromReqOrIncomingData(args: {\n data: unknown\n operation: 'create' | 'update'\n originalDoc: unknown\n req: PayloadRequest\n}): UploadEdits {\n const { data, operation, originalDoc, req } = args\n\n // Get intended focal point change from query string or incoming data\n const uploadEdits =\n req.query?.uploadEdits && typeof req.query.uploadEdits === 'object'\n ? (req.query.uploadEdits as UploadEdits)\n : {}\n\n if (uploadEdits.focalPoint) return uploadEdits\n\n const incomingData = data as FileData\n const origDoc = originalDoc as FileData\n\n // If no change in focal point, return undefined.\n // This prevents a refocal operation triggered from admin, because it always sends the focal point.\n if (origDoc && incomingData.focalX === origDoc.focalX && incomingData.focalY === origDoc.focalY) {\n return undefined\n }\n\n if (incomingData?.focalX && incomingData?.focalY) {\n uploadEdits.focalPoint = {\n x: incomingData.focalX,\n y: incomingData.focalY,\n }\n return uploadEdits\n }\n\n // If no focal point is set, default to center\n if (operation === 'create') {\n uploadEdits.focalPoint = {\n x: 50,\n y: 50,\n }\n }\n return uploadEdits\n}\n"],"names":["fileTypeFromBuffer","fs","mkdirSync","sanitize","FileRetrievalError","FileUploadError","MissingFile","canResizeImage","cropImage","getExternalFile","getFileByPath","getImageSize","getSafeFileName","resizeAndTransformImageSizes","isImage","optionallyAppendMetadata","generateFileData","collection","config","collectionConfig","data","operation","originalDoc","overwriteExistingFiles","req","throwOnMissingFile","upload","files","sharp","payload","file","uploadEdits","parseUploadEditsFromReqOrIncomingData","disableLocalStorage","focalPoint","focalPointEnabled","formatOptions","imageSizes","resizeOptions","staticDir","trimOptions","withMetadata","staticPath","filename","url","startsWith","filePath","response","uploadConfig","err","t","Error","message","undefined","recursive","newData","filesToSave","fileData","fileIsAnimatedType","includes","mimetype","cropData","crop","fileSupportsResize","fsSafeName","sharpFile","dimensions","fileBuffer","ext","mime","fileHasAdjustments","Boolean","tempFilePath","sharpOptions","animated","rotate","resize","toFormat","format","options","trim","width","height","metadata","toBuffer","resolveWithObject","info","filesize","size","pages","length","name","split","pop","mimeType","baseFilename","substring","lastIndexOf","collectionSlug","slug","desiredFilename","fileForResize","croppedImage","heightInPixels","widthInPixels","push","buffer","path","promises","writeFile","Array","isArray","payloadUploadSizes","sizeData","sizesToSave","savedFilename","sizes","focalX","x","focalY","y","logger","error","args","query","incomingData","origDoc"],"mappings":"AAEA,SAASA,kBAAkB,QAAQ,YAAW;AAC9C,OAAOC,QAAQ,KAAI;AACnB,SAASC,SAAS,QAAQ,UAAS;AACnC,OAAOC,cAAc,oBAAmB;AAOxC,SAASC,kBAAkB,EAAEC,eAAe,EAAEC,WAAW,QAAQ,qBAAoB;AACrF,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,SAAS,QAAQ,iBAAgB;AAC1C,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,4BAA4B,QAAQ,oBAAmB;AAChE,SAASC,OAAO,QAAQ,eAAc;AACtC,SAASC,wBAAwB,QAAQ,gCAA+B;AAkBxE,OAAO,MAAMC,mBAAmB,OAAU,EACxCC,YAAY,EAAEC,QAAQC,gBAAgB,EAAE,EACxCC,IAAI,EACJC,SAAS,EACTC,WAAW,EACXC,sBAAsB,EACtBC,GAAG,EACHC,kBAAkB,EACV;IACR,IAAI,CAACN,iBAAiBO,MAAM,EAAE;QAC5B,OAAO;YACLN;YACAO,OAAO,EAAE;QACX;IACF;IAEA,MAAM,EAAEC,KAAK,EAAE,GAAGJ,IAAIK,OAAO,CAACX,MAAM;IAEpC,IAAIY,OAAON,IAAIM,IAAI;IAEnB,MAAMC,cAAcC,sCAAsC;QACxDZ;QACAC;QACAC;QACAE;IACF;IAEA,MAAM,EACJS,mBAAmB,EACnBC,YAAYC,oBAAoB,IAAI,EACpCC,aAAa,EACbC,UAAU,EACVC,aAAa,EACbC,SAAS,EACTC,WAAW,EACXC,YAAY,EACb,G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