payload 4.0.0-internal.2fddfc0 → 4.0.0-internal.3aa3d85
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/LICENSE.md +1 -1
- package/bin.js +11 -0
- package/dist/admin/RichText.d.ts +1 -21
- package/dist/admin/RichText.d.ts.map +1 -1
- package/dist/admin/RichText.js.map +1 -1
- package/dist/admin/forms/Field.d.ts +2 -2
- package/dist/admin/forms/Field.d.ts.map +1 -1
- package/dist/admin/forms/Field.js.map +1 -1
- package/dist/admin/forms/Form.d.ts +0 -29
- package/dist/admin/forms/Form.d.ts.map +1 -1
- package/dist/admin/forms/Form.js.map +1 -1
- package/dist/admin/functions/index.d.ts +1 -1
- package/dist/admin/functions/index.js.map +1 -1
- package/dist/admin/types.d.ts +1 -0
- package/dist/admin/types.d.ts.map +1 -1
- package/dist/admin/types.js.map +1 -1
- package/dist/auth/operations/auth.d.ts +2 -2
- package/dist/auth/operations/auth.d.ts.map +1 -1
- package/dist/auth/operations/auth.js.map +1 -1
- package/dist/auth/operations/login.d.ts +2 -1
- package/dist/auth/operations/login.d.ts.map +1 -1
- package/dist/auth/operations/login.js.map +1 -1
- package/dist/auth/operations/me.js.map +1 -1
- package/dist/auth/operations/refresh.d.ts.map +1 -1
- package/dist/auth/operations/refresh.js +9 -3
- package/dist/auth/operations/refresh.js.map +1 -1
- package/dist/auth/operations/resetPassword.d.ts.map +1 -1
- package/dist/auth/operations/resetPassword.js.map +1 -1
- package/dist/auth/sendVerificationEmail.d.ts +2 -2
- package/dist/auth/sendVerificationEmail.d.ts.map +1 -1
- package/dist/auth/sendVerificationEmail.js +1 -1
- package/dist/auth/sendVerificationEmail.js.map +1 -1
- package/dist/auth/sessions.d.ts +4 -5
- package/dist/auth/sessions.d.ts.map +1 -1
- package/dist/auth/sessions.js +5 -3
- package/dist/auth/sessions.js.map +1 -1
- package/dist/auth/strategies/apiKey.js.map +1 -1
- package/dist/auth/strategies/local/incrementLoginAttempts.d.ts +2 -2
- 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/types.d.ts +28 -21
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/auth/types.js.map +1 -1
- package/dist/bin/generateImportMap/iterateCollections.d.ts.map +1 -1
- package/dist/bin/generateImportMap/iterateCollections.js +10 -0
- package/dist/bin/generateImportMap/iterateCollections.js.map +1 -1
- package/dist/bin/generateImportMap/utilities/resolveImportMapFilePath.d.ts.map +1 -1
- package/dist/bin/generateImportMap/utilities/resolveImportMapFilePath.js +11 -3
- package/dist/bin/generateImportMap/utilities/resolveImportMapFilePath.js.map +1 -1
- package/dist/collections/config/client.d.ts +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 +0 -4
- package/dist/collections/config/defaults.d.ts.map +1 -1
- package/dist/collections/config/defaults.js +0 -15
- package/dist/collections/config/defaults.js.map +1 -1
- package/dist/collections/config/types.d.ts +6 -0
- package/dist/collections/config/types.d.ts.map +1 -1
- package/dist/collections/config/types.js.map +1 -1
- package/dist/collections/operations/findDistinct.d.ts.map +1 -1
- package/dist/collections/operations/findDistinct.js +1 -0
- package/dist/collections/operations/findDistinct.js.map +1 -1
- package/dist/collections/operations/local/count.d.ts +3 -3
- package/dist/collections/operations/local/count.d.ts.map +1 -1
- package/dist/collections/operations/local/count.js.map +1 -1
- package/dist/collections/operations/local/countVersions.d.ts +3 -3
- package/dist/collections/operations/local/countVersions.d.ts.map +1 -1
- package/dist/collections/operations/local/countVersions.js.map +1 -1
- package/dist/collections/operations/local/create.d.ts +3 -3
- package/dist/collections/operations/local/create.d.ts.map +1 -1
- package/dist/collections/operations/local/create.js.map +1 -1
- package/dist/collections/operations/local/delete.d.ts +3 -3
- package/dist/collections/operations/local/delete.d.ts.map +1 -1
- package/dist/collections/operations/local/delete.js.map +1 -1
- package/dist/collections/operations/local/duplicate.d.ts +3 -3
- package/dist/collections/operations/local/duplicate.d.ts.map +1 -1
- package/dist/collections/operations/local/duplicate.js.map +1 -1
- package/dist/collections/operations/local/find.d.ts +3 -3
- package/dist/collections/operations/local/find.d.ts.map +1 -1
- package/dist/collections/operations/local/find.js.map +1 -1
- package/dist/collections/operations/local/findByID.d.ts +3 -3
- package/dist/collections/operations/local/findByID.d.ts.map +1 -1
- package/dist/collections/operations/local/findByID.js.map +1 -1
- package/dist/collections/operations/local/findDistinct.d.ts +2 -2
- package/dist/collections/operations/local/findDistinct.d.ts.map +1 -1
- package/dist/collections/operations/local/findDistinct.js.map +1 -1
- package/dist/collections/operations/local/findVersionByID.d.ts +3 -3
- package/dist/collections/operations/local/findVersionByID.d.ts.map +1 -1
- package/dist/collections/operations/local/findVersionByID.js.map +1 -1
- package/dist/collections/operations/local/findVersions.d.ts +3 -3
- package/dist/collections/operations/local/findVersions.d.ts.map +1 -1
- package/dist/collections/operations/local/findVersions.js.map +1 -1
- package/dist/collections/operations/local/restoreVersion.d.ts +3 -3
- package/dist/collections/operations/local/restoreVersion.d.ts.map +1 -1
- package/dist/collections/operations/local/restoreVersion.js.map +1 -1
- package/dist/collections/operations/local/update.d.ts +3 -3
- package/dist/collections/operations/local/update.d.ts.map +1 -1
- package/dist/collections/operations/local/update.js.map +1 -1
- package/dist/collections/operations/utilities/types.d.ts +0 -9
- package/dist/collections/operations/utilities/types.d.ts.map +1 -1
- package/dist/collections/operations/utilities/types.js.map +1 -1
- package/dist/config/client.d.ts +2 -2
- package/dist/config/client.d.ts.map +1 -1
- package/dist/config/client.js.map +1 -1
- package/dist/config/defaults.d.ts +0 -4
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +0 -78
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/definePlugin.d.ts +10 -10
- package/dist/config/definePlugin.d.ts.map +1 -1
- package/dist/config/definePlugin.js +7 -11
- package/dist/config/definePlugin.js.map +1 -1
- package/dist/config/sanitize.d.ts.map +1 -1
- package/dist/config/sanitize.js +137 -13
- package/dist/config/sanitize.js.map +1 -1
- package/dist/config/types.d.ts +35 -3
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js.map +1 -1
- package/dist/exports/internal.d.ts +1 -0
- package/dist/exports/internal.d.ts.map +1 -1
- package/dist/exports/internal.js +1 -0
- package/dist/exports/internal.js.map +1 -1
- package/dist/exports/shared.d.ts +3 -2
- package/dist/exports/shared.d.ts.map +1 -1
- package/dist/exports/shared.js +2 -1
- package/dist/exports/shared.js.map +1 -1
- package/dist/fields/baseFields/slug/countVersions.d.ts.map +1 -1
- package/dist/fields/baseFields/slug/countVersions.js +6 -8
- package/dist/fields/baseFields/slug/countVersions.js.map +1 -1
- package/dist/fields/baseFields/slug/generateSlug.d.ts +14 -7
- package/dist/fields/baseFields/slug/generateSlug.d.ts.map +1 -1
- package/dist/fields/baseFields/slug/generateSlug.js +53 -73
- package/dist/fields/baseFields/slug/generateSlug.js.map +1 -1
- package/dist/fields/baseFields/slug/types.d.ts +14 -0
- package/dist/fields/baseFields/slug/types.d.ts.map +1 -0
- package/dist/fields/baseFields/slug/types.js +6 -0
- package/dist/fields/baseFields/slug/types.js.map +1 -0
- package/dist/fields/config/client.d.ts +1 -1
- package/dist/fields/config/client.d.ts.map +1 -1
- package/dist/fields/config/client.js +2 -1
- package/dist/fields/config/client.js.map +1 -1
- package/dist/fields/config/sanitize.d.ts.map +1 -1
- package/dist/fields/config/sanitize.js +39 -0
- package/dist/fields/config/sanitize.js.map +1 -1
- package/dist/fields/config/types.d.ts +44 -8
- package/dist/fields/config/types.d.ts.map +1 -1
- package/dist/fields/config/types.js.map +1 -1
- package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/promise.js +11 -1
- package/dist/fields/hooks/afterRead/promise.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/promise.js +10 -1
- package/dist/fields/hooks/beforeValidate/promise.js.map +1 -1
- package/dist/fields/setDefaultBeforeDuplicate.js +1 -0
- package/dist/fields/setDefaultBeforeDuplicate.js.map +1 -1
- package/dist/fields/sortableFieldTypes.d.ts.map +1 -1
- package/dist/fields/sortableFieldTypes.js +1 -0
- package/dist/fields/sortableFieldTypes.js.map +1 -1
- package/dist/fields/validations.d.ts +4 -1
- package/dist/fields/validations.d.ts.map +1 -1
- package/dist/fields/validations.js +7 -0
- package/dist/fields/validations.js.map +1 -1
- package/dist/globals/operations/local/countVersions.d.ts +3 -3
- package/dist/globals/operations/local/countVersions.d.ts.map +1 -1
- package/dist/globals/operations/local/countVersions.js.map +1 -1
- package/dist/globals/operations/local/findOne.d.ts +3 -3
- package/dist/globals/operations/local/findOne.d.ts.map +1 -1
- package/dist/globals/operations/local/findOne.js.map +1 -1
- package/dist/globals/operations/local/findVersionByID.d.ts +3 -3
- package/dist/globals/operations/local/findVersionByID.d.ts.map +1 -1
- package/dist/globals/operations/local/findVersionByID.js.map +1 -1
- package/dist/globals/operations/local/findVersions.d.ts +3 -3
- package/dist/globals/operations/local/findVersions.d.ts.map +1 -1
- package/dist/globals/operations/local/findVersions.js.map +1 -1
- package/dist/globals/operations/local/restoreVersion.d.ts +3 -3
- package/dist/globals/operations/local/restoreVersion.d.ts.map +1 -1
- package/dist/globals/operations/local/restoreVersion.js.map +1 -1
- package/dist/globals/operations/local/update.d.ts +3 -3
- package/dist/globals/operations/local/update.d.ts.map +1 -1
- package/dist/globals/operations/local/update.js.map +1 -1
- package/dist/index.bundled.d.ts +365 -300
- package/dist/index.d.ts +59 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/preferences/keys.d.ts +4 -0
- package/dist/preferences/keys.d.ts.map +1 -1
- package/dist/preferences/keys.js +4 -1
- package/dist/preferences/keys.js.map +1 -1
- package/dist/preferences/types.d.ts +15 -0
- package/dist/preferences/types.d.ts.map +1 -1
- package/dist/preferences/types.js +3 -1
- package/dist/preferences/types.js.map +1 -1
- package/dist/types/index.d.ts +8 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/uploads/fetchAPI-multipart/processMultipart.d.ts.map +1 -1
- package/dist/uploads/fetchAPI-multipart/processMultipart.js +1 -14
- package/dist/uploads/fetchAPI-multipart/processMultipart.js.map +1 -1
- package/dist/uploads/matchMimeType.d.ts +8 -0
- package/dist/uploads/matchMimeType.d.ts.map +1 -0
- package/dist/uploads/matchMimeType.js +19 -0
- package/dist/uploads/matchMimeType.js.map +1 -0
- package/dist/uploads/matchMimeType.spec.js +66 -0
- package/dist/uploads/matchMimeType.spec.js.map +1 -0
- package/dist/uploads/types.d.ts +21 -0
- package/dist/uploads/types.d.ts.map +1 -1
- package/dist/uploads/types.js.map +1 -1
- package/dist/utilities/addDataAndFileToRequest.d.ts.map +1 -1
- package/dist/utilities/addDataAndFileToRequest.js +6 -0
- package/dist/utilities/addDataAndFileToRequest.js.map +1 -1
- package/dist/utilities/configToJSONSchema.d.ts +13 -4
- package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
- package/dist/utilities/configToJSONSchema.js +139 -61
- package/dist/utilities/configToJSONSchema.js.map +1 -1
- package/dist/utilities/configToJSONSchema.spec.js +319 -0
- package/dist/utilities/configToJSONSchema.spec.js.map +1 -1
- package/dist/utilities/createLocalReq.d.ts +2 -2
- package/dist/utilities/createLocalReq.d.ts.map +1 -1
- package/dist/utilities/createLocalReq.js.map +1 -1
- package/dist/utilities/createPayloadRequest.d.ts.map +1 -1
- package/dist/utilities/createPayloadRequest.js +1 -0
- package/dist/utilities/createPayloadRequest.js.map +1 -1
- package/dist/utilities/getEntityPermissions/getEntityPermissions.d.ts.map +1 -1
- package/dist/utilities/getEntityPermissions/getEntityPermissions.js +2 -0
- package/dist/utilities/getEntityPermissions/getEntityPermissions.js.map +1 -1
- package/dist/utilities/getEntityPermissions/populateFieldPermissions.d.ts +7 -1
- package/dist/utilities/getEntityPermissions/populateFieldPermissions.d.ts.map +1 -1
- package/dist/utilities/getEntityPermissions/populateFieldPermissions.js +19 -2
- package/dist/utilities/getEntityPermissions/populateFieldPermissions.js.map +1 -1
- package/dist/utilities/isURLAllowed.d.ts.map +1 -1
- package/dist/utilities/isURLAllowed.js +9 -3
- package/dist/utilities/isURLAllowed.js.map +1 -1
- package/dist/utilities/isURLAllowed.spec.js +78 -0
- package/dist/utilities/isURLAllowed.spec.js.map +1 -0
- package/dist/utilities/telemetry/conf/envPaths.d.ts.map +1 -1
- package/dist/utilities/telemetry/conf/envPaths.js +40 -31
- package/dist/utilities/telemetry/conf/envPaths.js.map +1 -1
- package/dist/utilities/telemetry/events/adminInit.d.ts.map +1 -1
- package/dist/utilities/telemetry/events/adminInit.js +2 -3
- package/dist/utilities/telemetry/events/adminInit.js.map +1 -1
- package/dist/utilities/telemetry/events/serverInit.d.ts.map +1 -1
- package/dist/utilities/telemetry/events/serverInit.js +2 -3
- package/dist/utilities/telemetry/events/serverInit.js.map +1 -1
- package/dist/utilities/telemetry/index.d.ts +14 -3
- package/dist/utilities/telemetry/index.d.ts.map +1 -1
- package/dist/utilities/telemetry/index.js +6 -1
- package/dist/utilities/telemetry/index.js.map +1 -1
- package/dist/utilities/telemetry/index.spec.js +43 -0
- package/dist/utilities/telemetry/index.spec.js.map +1 -0
- package/dist/versions/schedule/job.js.map +1 -1
- package/package.json +3 -3
- package/dist/fields/baseFields/slug/index.d.ts +0 -89
- package/dist/fields/baseFields/slug/index.d.ts.map +0 -1
- package/dist/fields/baseFields/slug/index.js +0 -81
- package/dist/fields/baseFields/slug/index.js.map +0 -1
- package/dist/utilities/isRSCEnabled.d.ts +0 -12
- package/dist/utilities/isRSCEnabled.d.ts.map +0 -1
- package/dist/utilities/isRSCEnabled.js +0 -14
- package/dist/utilities/isRSCEnabled.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/fields/validations.ts"],"sourcesContent":["import ObjectIdImport from 'bson-objectid'\n\nconst ObjectId = 'default' in ObjectIdImport ? ObjectIdImport.default : ObjectIdImport\n\nimport type { TFunction } from '@payloadcms/translations'\nimport type { JSONSchema4 } from 'json-schema'\n\nimport type { RichTextAdapter } from '../admin/types.js'\nimport type { CollectionSlug } from '../index.js'\nimport type { Where } from '../types/index.js'\nimport type {\n ArrayField,\n BlocksField,\n CheckboxField,\n CodeField,\n DateField,\n EmailField,\n JSONField,\n NumberField,\n PointField,\n RadioField,\n RelationshipField,\n RelationshipValue,\n RelationshipValueMany,\n RelationshipValueSingle,\n RichTextField,\n SelectField,\n TextareaField,\n TextField,\n UploadField,\n Validate,\n ValueWithRelation,\n} from './config/types.js'\n\nimport { isNumber } from '../utilities/isNumber.js'\nimport { isValidID } from '../utilities/isValidID.js'\n\nexport type TextFieldValidation = Validate<string, unknown, unknown, TextField>\n\nexport type TextFieldManyValidation = Validate<string[], unknown, unknown, TextField>\n\nexport type TextFieldSingleValidation = Validate<string, unknown, unknown, TextField>\n\nexport const text: TextFieldValidation = (\n value,\n {\n hasMany,\n maxLength: fieldMaxLength,\n maxRows,\n minLength,\n minRows,\n req: {\n payload: { config },\n t,\n },\n required,\n },\n) => {\n let maxLength!: number\n\n if (!required) {\n if (value === undefined || value === null) {\n return true\n }\n }\n\n if (hasMany === true) {\n const lengthValidationResult = validateArrayLength(value, { maxRows, minRows, required, t })\n if (typeof lengthValidationResult === 'string') {\n return lengthValidationResult\n }\n }\n\n if (typeof config?.defaultMaxTextLength === 'number') {\n maxLength = config.defaultMaxTextLength\n }\n if (typeof fieldMaxLength === 'number') {\n maxLength = fieldMaxLength\n }\n\n const stringsToValidate: string[] = Array.isArray(value) ? value : [value!]\n\n for (const stringValue of stringsToValidate) {\n const length = stringValue?.length || 0\n\n if (typeof maxLength === 'number' && length > maxLength) {\n return t('validation:shorterThanMax', { label: t('general:value'), maxLength, stringValue })\n }\n\n if (typeof minLength === 'number' && length < minLength) {\n return t('validation:longerThanMin', { label: t('general:value'), minLength, stringValue })\n }\n }\n\n if (required) {\n if (!value || ((typeof value === 'string' || Array.isArray(value)) && value.length === 0)) {\n return t('validation:required')\n }\n }\n\n return true\n}\n\nexport type PasswordFieldValidation = Validate<string, unknown, unknown, TextField>\n\nexport const password: PasswordFieldValidation = (\n value,\n {\n maxLength: fieldMaxLength,\n minLength = 3,\n req: {\n payload: { config },\n t,\n },\n required,\n },\n) => {\n let maxLength!: number\n\n if (typeof config?.defaultMaxTextLength === 'number') {\n maxLength = config.defaultMaxTextLength\n }\n if (typeof fieldMaxLength === 'number') {\n maxLength = fieldMaxLength\n }\n\n if (value && maxLength && value.length > maxLength) {\n return t('validation:shorterThanMax', { maxLength })\n }\n\n if (value && minLength && value.length < minLength) {\n return t('validation:longerThanMin', { minLength })\n }\n\n if (required && !value) {\n return t('validation:required')\n }\n\n return true\n}\n\nexport type ConfirmPasswordFieldValidation = Validate<\n string,\n unknown,\n { password: string },\n TextField\n>\n\nexport const confirmPassword: ConfirmPasswordFieldValidation = (\n value,\n { req: { t }, required, siblingData },\n) => {\n if (required && !value) {\n return t('validation:required')\n }\n\n if (value && value !== siblingData.password) {\n return t('fields:passwordsDoNotMatch')\n }\n\n return true\n}\n\nexport type EmailFieldValidation = Validate<string, unknown, { username?: string }, EmailField>\n\nexport const email: EmailFieldValidation = (\n value,\n {\n collectionSlug,\n req: {\n payload: { collections, config },\n t,\n },\n required,\n siblingData,\n },\n) => {\n if (collectionSlug) {\n const collection =\n collections?.[collectionSlug]?.config ??\n config.collections.find(({ slug }) => slug === collectionSlug)! // If this is run on the client, `collections` will be undefined, but `config.collections` will be available\n\n if (\n collection.auth.loginWithUsername &&\n !collection.auth.loginWithUsername?.requireUsername &&\n !collection.auth.loginWithUsername?.requireEmail\n ) {\n if (!value && !siblingData?.username) {\n return t('validation:required')\n }\n }\n }\n\n /**\n * Disallows emails with double quotes (e.g., \"user\"@example.com, user@\"example.com\", \"user@example.com\")\n * Rejects spaces anywhere in the email (e.g., user @example.com, user@ example.com, user name@example.com)\n * Prevents consecutive dots in the local or domain part (e.g., user..name@example.com, user@example..com)\n * Disallows domains that start or end with a hyphen (e.g., user@-example.com, user@example-.com)\n * Allows standard email formats (e.g., user@example.com, user.name+alias@example.co.uk, user-name@example.org)\n * Allows domains with consecutive hyphens as long as they are not leading/trailing (e.g., user@ex--ample.com)\n * Supports multiple subdomains (e.g., user@sub.domain.example.com)\n */\n const emailRegex =\n /^(?!.*\\.\\.)[\\w!#$%&'*+/=?^`{|}~-](?:[\\w!#$%&'*+/=?^`{|}~.-]*[\\w!#$%&'*+/=?^`{|}~-])?@[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)*\\.[a-z]{2,}$/i\n\n if ((value && !emailRegex.test(value)) || (!value && required)) {\n return t('validation:emailAddress')\n }\n\n return true\n}\n\nexport type UsernameFieldValidation = Validate<string, unknown, { email?: string }, TextField>\n\nexport const username: UsernameFieldValidation = (\n value,\n {\n collectionSlug,\n req: {\n payload: { collections, config },\n t,\n },\n required,\n siblingData,\n },\n) => {\n let maxLength!: number\n\n if (collectionSlug) {\n const collection =\n collections?.[collectionSlug]?.config ??\n config.collections.find(({ slug }) => slug === collectionSlug)! // If this is run on the client, `collections` will be undefined, but `config.collections` will be available\n\n if (\n collection.auth.loginWithUsername &&\n !collection.auth.loginWithUsername?.requireUsername &&\n !collection.auth.loginWithUsername?.requireEmail\n ) {\n if (!value && !siblingData?.email) {\n return t('validation:required')\n }\n }\n }\n\n if (typeof config?.defaultMaxTextLength === 'number') {\n maxLength = config.defaultMaxTextLength\n }\n\n if (value && maxLength && value.length > maxLength) {\n return t('validation:shorterThanMax', { maxLength })\n }\n\n if (!value && required) {\n return t('validation:required')\n }\n\n return true\n}\n\nexport type TextareaFieldValidation = Validate<string, unknown, unknown, TextareaField>\n\nexport const textarea: TextareaFieldValidation = (\n value,\n {\n maxLength: fieldMaxLength,\n minLength,\n req: {\n payload: { config },\n t,\n },\n required,\n },\n) => {\n let maxLength!: number\n\n if (typeof config?.defaultMaxTextLength === 'number') {\n maxLength = config.defaultMaxTextLength\n }\n if (typeof fieldMaxLength === 'number') {\n maxLength = fieldMaxLength\n }\n if (value && maxLength && value.length > maxLength) {\n return t('validation:shorterThanMax', { maxLength })\n }\n\n if (value && minLength && value.length < minLength) {\n return t('validation:longerThanMin', { minLength })\n }\n\n if (required && !value) {\n return t('validation:required')\n }\n\n return true\n}\n\nexport type CodeFieldValidation = Validate<string, unknown, unknown, CodeField>\n\nexport const code: CodeFieldValidation = (value, { req: { t }, required }) => {\n if (required && (!value || (typeof value === 'string' && value.length === 0))) {\n return t('validation:required')\n }\n\n return true\n}\n\nexport type JSONFieldValidation = Validate<\n string,\n unknown,\n unknown,\n { jsonError?: string } & JSONField\n>\n\nexport const json: JSONFieldValidation = async (\n value,\n { jsonError, jsonSchema, req: { t }, required },\n) => {\n const isNotEmpty = (value: null | string | undefined) => {\n if (value === undefined || value === null) {\n return false\n }\n\n if (Array.isArray(value) && value.length === 0) {\n return false\n }\n\n if (typeof value === 'object' && Object.keys(value).length === 0) {\n return false\n }\n\n return true\n }\n\n const fetchSchema = ({ schema, uri }: { schema: JSONSchema4; uri: string }) => {\n if (uri && schema) {\n return schema\n }\n return fetch(uri)\n .then((response) => {\n if (!response.ok) {\n throw new Error('Network response was not ok')\n }\n return response.json()\n })\n .then((_json) => {\n const json = _json as {\n id: string\n }\n const jsonSchemaSanitizations = {\n id: undefined,\n $id: json.id,\n $schema: 'http://json-schema.org/draft-07/schema#',\n }\n\n return Object.assign(json, jsonSchemaSanitizations)\n })\n }\n\n if (required && !value) {\n return t('validation:required')\n }\n\n if (jsonError !== undefined) {\n return t('validation:invalidInput')\n }\n\n if (jsonSchema && isNotEmpty(value)) {\n try {\n jsonSchema.schema = fetchSchema(jsonSchema)\n const { schema } = jsonSchema\n const AjvModule = await import('ajv')\n // Handle both ESM default export and CJS interop where the module itself is the constructor\n const AjvClass: any =\n 'default' in AjvModule && typeof AjvModule.default === 'function'\n ? AjvModule.default\n : AjvModule\n const ajv = new AjvClass()\n\n if (!ajv.validate(schema, value)) {\n return ajv.errorsText()\n }\n } catch (error) {\n return error instanceof Error ? error.message : 'Unknown error'\n }\n }\n return true\n}\n\nexport type CheckboxFieldValidation = Validate<boolean, unknown, unknown, CheckboxField>\n\nexport const checkbox: CheckboxFieldValidation = (value, { req: { t }, required }) => {\n if ((value && typeof value !== 'boolean') || (required && typeof value !== 'boolean')) {\n return t('validation:trueOrFalse')\n }\n\n return true\n}\n\nexport type DateFieldValidation = Validate<Date, unknown, unknown, DateField>\n\nexport const date: DateFieldValidation = (\n value,\n { name, req: { t }, required, siblingData, timezone },\n) => {\n const validDate = value && !isNaN(Date.parse(value.toString()))\n\n // We need to also check for the timezone data based on this field's config\n // We cannot do this inside the timezone field validation as it's visually hidden\n const hasRequiredTimezone = timezone && required\n const selectedTimezone: string = siblingData?.[`${name}_tz` as keyof typeof siblingData]\n // Always resolve to true if the field is not required, as timezone may be optional too then\n const validTimezone = hasRequiredTimezone ? Boolean(selectedTimezone) : true\n\n if (validDate && validTimezone) {\n return true\n }\n\n if (validDate && !validTimezone) {\n return t('validation:timezoneRequired')\n }\n\n if (value) {\n return t('validation:notValidDate', { value })\n }\n\n if (required) {\n return t('validation:required')\n }\n\n return true\n}\n\nexport type RichTextFieldValidation = Validate<object, unknown, unknown, RichTextField>\n\nexport const richText: RichTextFieldValidation = async (value, options) => {\n if (!options?.editor) {\n throw new Error('richText field has no editor property.')\n }\n if (typeof options?.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n\n const editor: RichTextAdapter = options?.editor\n\n return editor.validate(value, options)\n}\n\nconst validateArrayLength = (\n value: unknown,\n options: {\n maxRows?: number\n minRows?: number\n required?: boolean\n t: TFunction\n },\n) => {\n const { maxRows, minRows, required, t } = options\n\n const arrayLength = Array.isArray(value) ? value.length : (value as number) || 0\n\n if (!required && arrayLength === 0) {\n return true\n }\n\n if (minRows && arrayLength < minRows) {\n return t('validation:requiresAtLeast', { count: minRows, label: t('general:rows') })\n }\n\n if (maxRows && arrayLength > maxRows) {\n return t('validation:requiresNoMoreThan', { count: maxRows, label: t('general:rows') })\n }\n\n if (required && !arrayLength) {\n return t('validation:requiresAtLeast', { count: 1, label: t('general:row') })\n }\n\n return true\n}\n\nexport type NumberFieldValidation = Validate<number | number[], unknown, unknown, NumberField>\n\nexport type NumberFieldManyValidation = Validate<number[], unknown, unknown, NumberField>\n\nexport type NumberFieldSingleValidation = Validate<number, unknown, unknown, NumberField>\n\nexport const number: NumberFieldValidation = (\n value,\n { hasMany, max, maxRows, min, minRows, req: { t }, required },\n) => {\n if (hasMany === true) {\n const lengthValidationResult = validateArrayLength(value, { maxRows, minRows, required, t })\n if (typeof lengthValidationResult === 'string') {\n return lengthValidationResult\n }\n }\n\n if (!value && !isNumber(value)) {\n // if no value is present, validate based on required\n if (required) {\n return t('validation:required')\n }\n if (!required) {\n return true\n }\n }\n\n const numbersToValidate: number[] = Array.isArray(value) ? value : [value!]\n\n for (const number of numbersToValidate) {\n if (!isNumber(number)) {\n return t('validation:enterNumber')\n }\n\n const numberValue = parseFloat(number as unknown as string)\n\n if (typeof max === 'number' && numberValue > max) {\n return t('validation:greaterThanMax', { label: t('general:value'), max, value })\n }\n\n if (typeof min === 'number' && numberValue < min) {\n return t('validation:lessThanMin', { label: t('general:value'), min, value })\n }\n }\n\n return true\n}\n\nexport type ArrayFieldValidation = Validate<unknown[], unknown, unknown, ArrayField>\n\nexport const array: ArrayFieldValidation = (value, { maxRows, minRows, req: { t }, required }) => {\n return validateArrayLength(value, { maxRows, minRows, required, t })\n}\n\nexport type BlocksFieldValidation = Validate<unknown, unknown, unknown, BlocksField>\n\n/**\n * This function validates the blocks in a blocks field against the provided filterOptions.\n * It will return a list of all block slugs found in the value, the allowed block slugs (if any),\n * and a list of invalid block slugs that are used despite being disallowed.\n *\n * @internal - this may break or be removed at any time\n */\nexport async function validateBlocksFilterOptions({\n id,\n data,\n filterOptions,\n req,\n siblingData,\n value,\n}: { value: Parameters<BlocksFieldValidation>[0] } & Pick<\n Parameters<BlocksFieldValidation>[1],\n 'data' | 'filterOptions' | 'id' | 'req' | 'siblingData'\n>): Promise<{\n /**\n * All block slugs found in the value of the blocks field\n */\n allBlockSlugs: string[]\n /**\n * All block slugs that are allowed. If undefined, all blocks are allowed.\n */\n allowedBlockSlugs: string[] | undefined\n /**\n * A list of block slugs that are used despite being disallowed. If undefined, field passed validation.\n */\n invalidBlockSlugs: string[] | undefined\n}> {\n const allBlockSlugs = Array.isArray(value)\n ? (value as Array<{ blockType?: string }>)\n .map((b) => b.blockType)\n .filter((s): s is string => Boolean(s))\n : []\n\n // if undefined => all blocks allowed\n let allowedBlockSlugs: string[] | undefined = undefined\n\n if (typeof filterOptions === 'function') {\n const result = await filterOptions({\n id: id!, // original code asserted presence\n data,\n req,\n siblingData,\n user: req.user,\n })\n if (result !== true && Array.isArray(result)) {\n allowedBlockSlugs = result\n }\n } else if (Array.isArray(filterOptions)) {\n allowedBlockSlugs = filterOptions\n }\n\n const invalidBlockSlugs: string[] = []\n if (allowedBlockSlugs) {\n for (const blockSlug of allBlockSlugs) {\n if (!allowedBlockSlugs.includes(blockSlug)) {\n invalidBlockSlugs.push(blockSlug)\n }\n }\n }\n\n return {\n allBlockSlugs,\n allowedBlockSlugs,\n invalidBlockSlugs,\n }\n}\nexport const blocks: BlocksFieldValidation = async (\n value,\n { id, data, filterOptions, maxRows, minRows, req: { t }, req, required, siblingData },\n) => {\n const lengthValidationResult = validateArrayLength(value, { maxRows, minRows, required, t })\n if (typeof lengthValidationResult === 'string') {\n return lengthValidationResult\n }\n\n if (filterOptions) {\n const { invalidBlockSlugs } = await validateBlocksFilterOptions({\n id,\n data,\n filterOptions,\n req,\n siblingData,\n value,\n })\n if (invalidBlockSlugs?.length) {\n return t('validation:invalidBlocks', { blocks: invalidBlockSlugs.join(', ') })\n }\n }\n\n return true\n}\n\nconst validateFilterOptions: Validate<\n unknown,\n unknown,\n unknown,\n RelationshipField | UploadField\n> = async (\n value,\n { id, blockData, data, filterOptions, relationTo, req, req: { t, user }, siblingData },\n) => {\n if (typeof filterOptions !== 'undefined' && value) {\n const options: {\n [collection: string]: (number | string)[]\n } = {}\n\n const falseCollections: CollectionSlug[] = []\n const collections = !Array.isArray(relationTo) ? [relationTo] : relationTo\n const values = Array.isArray(value) ? value : [value]\n\n for (const collection of collections) {\n try {\n let optionFilter =\n typeof filterOptions === 'function'\n ? await filterOptions({\n id: id!,\n blockData,\n data,\n relationTo: collection,\n req,\n siblingData,\n user,\n })\n : filterOptions\n\n if (optionFilter === true) {\n optionFilter = null\n }\n\n const valueIDs: (number | string)[] = []\n\n values.forEach((val) => {\n if (typeof val === 'object') {\n if (val?.value) {\n valueIDs.push(val.value)\n } else if (ObjectId.isValid(val)) {\n valueIDs.push(new ObjectId(val).toHexString())\n }\n }\n\n if (typeof val === 'string' || typeof val === 'number') {\n valueIDs.push(val)\n }\n })\n\n if (valueIDs.length > 0) {\n const findWhere: Where = {\n and: [{ id: { in: valueIDs } }],\n }\n\n // @ts-expect-error - I don't understand why optionFilter is inferred as `false | Where | null` instead of `boolean | Where | null`\n if (optionFilter && optionFilter !== true) {\n findWhere.and?.push(optionFilter)\n }\n\n if (optionFilter === false) {\n falseCollections.push(collection)\n }\n\n const result = await req.payloadDataLoader.find({\n collection,\n depth: 0,\n limit: 0,\n pagination: false,\n req,\n where: findWhere,\n })\n\n options[collection] = result.docs.map((doc) => doc.id)\n } else {\n options[collection] = []\n }\n } catch (err) {\n req.payload.logger.error({\n err,\n msg: `Error validating filter options for collection ${collection}`,\n })\n options[collection] = []\n }\n }\n\n const invalidRelationships = values.filter((val) => {\n let collection: string\n let requestedID: number | string\n\n if (typeof relationTo === 'string') {\n collection = relationTo\n\n if (typeof val === 'string' || typeof val === 'number') {\n requestedID = val\n }\n\n if (typeof val === 'object' && ObjectId.isValid(val)) {\n requestedID = new ObjectId(val).toHexString()\n }\n }\n\n if (Array.isArray(relationTo) && typeof val === 'object' && val?.relationTo) {\n collection = val.relationTo\n requestedID = val.value\n }\n\n if (falseCollections.find((slug) => relationTo === slug)) {\n return true\n }\n\n if (!options[collection!]) {\n return true\n }\n\n return options[collection!]!.indexOf(requestedID!) === -1\n })\n\n if (invalidRelationships.length > 0) {\n return invalidRelationships.reduce((err, invalid, i) => {\n return `${err} ${JSON.stringify(invalid)}${\n invalidRelationships.length === i + 1 ? ',' : ''\n } `\n }, t('validation:invalidSelections')) as string\n }\n\n return true\n }\n\n return true\n}\n\nexport type UploadFieldValidation = Validate<unknown, unknown, unknown, UploadField>\n\nexport type UploadFieldManyValidation = Validate<unknown[], unknown, unknown, UploadField>\n\nexport type UploadFieldSingleValidation = Validate<unknown, unknown, unknown, UploadField>\n\nexport const upload: UploadFieldValidation = async (value, options) => {\n const {\n event,\n maxRows,\n minRows,\n relationTo,\n req: { payload, t },\n required,\n } = options\n\n if (\n ((!value && typeof value !== 'number') || (Array.isArray(value) && value.length === 0)) &&\n required\n ) {\n return t('validation:required')\n }\n\n if (Array.isArray(value) && value.length > 0) {\n if (minRows && value.length < minRows) {\n return t('validation:lessThanMin', {\n label: t('general:rows'),\n min: minRows,\n value: value.length,\n })\n }\n\n if (maxRows && value.length > maxRows) {\n return t('validation:greaterThanMax', {\n label: t('general:rows'),\n max: maxRows,\n value: value.length,\n })\n }\n }\n\n if (typeof value !== 'undefined' && value !== null) {\n const values = Array.isArray(value) ? value : [value]\n\n const invalidRelationships = values.filter((val) => {\n let collectionSlug: string\n let requestedID\n\n if (typeof relationTo === 'string') {\n collectionSlug = relationTo\n\n // custom id\n if (val || typeof val === 'number') {\n requestedID = val\n }\n }\n\n if (Array.isArray(relationTo) && typeof val === 'object' && val?.relationTo) {\n collectionSlug = val.relationTo\n requestedID = val.value\n }\n\n if (requestedID === null) {\n return false\n }\n\n const idType =\n payload.collections[collectionSlug!]?.customIDType || payload?.db?.defaultIDType || 'text'\n\n return !isValidID(requestedID, idType)\n })\n\n if (invalidRelationships.length > 0) {\n return `This relationship field has the following invalid relationships: ${invalidRelationships\n .map((err, invalid) => {\n return `${err} ${JSON.stringify(invalid)}`\n })\n .join(', ')}`\n }\n }\n\n if (event === 'onChange') {\n return true\n }\n\n return validateFilterOptions(value, options)\n}\n\nexport type RelationshipFieldValidation = Validate<\n RelationshipValue,\n unknown,\n unknown,\n RelationshipField\n>\n\nexport type RelationshipFieldManyValidation = Validate<\n RelationshipValueMany,\n unknown,\n unknown,\n RelationshipField\n>\n\nexport type RelationshipFieldSingleValidation = Validate<\n RelationshipValueSingle,\n unknown,\n unknown,\n RelationshipField\n>\n\nexport const relationship: RelationshipFieldValidation = async (value, options) => {\n const {\n event,\n maxRows,\n minRows,\n relationTo,\n req: { payload, t },\n required,\n } = options\n\n if (\n ((!value && typeof value !== 'number') || (Array.isArray(value) && value.length === 0)) &&\n required\n ) {\n return t('validation:required')\n }\n\n if (Array.isArray(value) && value.length > 0) {\n if (minRows && value.length < minRows) {\n return t('validation:lessThanMin', {\n label: t('general:rows'),\n min: minRows,\n value: value.length,\n })\n }\n\n if (maxRows && value.length > maxRows) {\n return t('validation:greaterThanMax', {\n label: t('general:rows'),\n max: maxRows,\n value: value.length,\n })\n }\n }\n\n if (typeof value !== 'undefined' && value !== null) {\n const values = Array.isArray(value) ? value : [value]\n\n const invalidRelationships = values.filter((val) => {\n let collectionSlug: string\n let requestedID: number | string | undefined | ValueWithRelation\n\n if (typeof relationTo === 'string') {\n collectionSlug = relationTo\n\n // custom id\n if (val || typeof val === 'number') {\n requestedID = val\n }\n }\n\n if (Array.isArray(relationTo) && typeof val === 'object' && val?.relationTo) {\n collectionSlug = val.relationTo\n requestedID = val.value\n }\n\n if (requestedID === null) {\n return false\n }\n\n const idType =\n payload.collections[collectionSlug!]?.customIDType || payload?.db?.defaultIDType || 'text'\n\n return !isValidID(requestedID as number | string, idType)\n })\n\n if (invalidRelationships.length > 0) {\n return `This relationship field has the following invalid relationships: ${invalidRelationships\n .map((err, invalid) => {\n return `${err} ${JSON.stringify(invalid)}`\n })\n .join(', ')}`\n }\n }\n\n if (event === 'onChange') {\n return true\n }\n\n return validateFilterOptions(value, options)\n}\n\nexport type SelectFieldValidation = Validate<string | string[], unknown, unknown, SelectField>\n\nexport type SelectFieldManyValidation = Validate<string[], unknown, unknown, SelectField>\n\nexport type SelectFieldSingleValidation = Validate<string, unknown, unknown, SelectField>\n\nexport const select: SelectFieldValidation = (\n value,\n { data, filterOptions, hasMany, options, req, req: { t }, required, siblingData },\n) => {\n const filteredOptions =\n typeof filterOptions === 'function'\n ? filterOptions({\n data,\n options,\n req,\n siblingData,\n })\n : options\n\n if (\n Array.isArray(value) &&\n value.some(\n (input) =>\n !filteredOptions.some(\n (option) => option === input || (typeof option !== 'string' && option?.value === input),\n ),\n )\n ) {\n return t('validation:invalidSelection')\n }\n\n // Check for duplicate values when hasMany is true\n if (hasMany && Array.isArray(value) && value.length > 1) {\n const counts = new Map<unknown, number>()\n\n for (const item of value) {\n counts.set(item, (counts.get(item) || 0) + 1)\n }\n\n const duplicates: unknown[] = []\n for (const [item, count] of counts.entries()) {\n if (count > 1) {\n // Add the item 'count' times to show all occurrences\n for (let i = 0; i < count; i++) {\n duplicates.push(item)\n }\n }\n }\n\n if (duplicates.length > 0) {\n return duplicates.reduce((err, duplicate, i) => {\n return `${err} ${JSON.stringify(duplicate)}${i < duplicates.length - 1 ? ',' : ''}`\n }, t('validation:invalidSelections')) as string\n }\n }\n\n if (\n typeof value === 'string' &&\n !filteredOptions.some(\n (option) => option === value || (typeof option !== 'string' && option.value === value),\n )\n ) {\n return t('validation:invalidSelection')\n }\n\n if (\n required &&\n (typeof value === 'undefined' ||\n value === null ||\n (hasMany && Array.isArray(value) && (value as [])?.length === 0))\n ) {\n return t('validation:required')\n }\n\n return true\n}\n\nexport type RadioFieldValidation = Validate<unknown, unknown, unknown, RadioField>\n\nexport const radio: RadioFieldValidation = (value, { options, req: { t }, required }) => {\n if (value) {\n const valueMatchesOption = options.some(\n (option) => option === value || (typeof option !== 'string' && option.value === value),\n )\n return valueMatchesOption || t('validation:invalidSelection')\n }\n\n return required ? t('validation:required') : true\n}\n\nexport type PointFieldValidation = Validate<\n [number | string, number | string],\n unknown,\n unknown,\n PointField\n>\n\nexport const point: PointFieldValidation = (value = ['', ''], { req: { t }, required }) => {\n if (value === null) {\n if (required) {\n return t('validation:required')\n }\n\n return true\n }\n\n const lng = parseFloat(String(value[0]))\n const lat = parseFloat(String(value[1]))\n if (\n required &&\n ((value[0] && value[1] && typeof lng !== 'number' && typeof lat !== 'number') ||\n Number.isNaN(lng) ||\n Number.isNaN(lat) ||\n (Array.isArray(value) && value.length !== 2))\n ) {\n return t('validation:requiresTwoNumbers')\n }\n\n if ((value[1] && Number.isNaN(lng)) || (value[0] && Number.isNaN(lat))) {\n return t('validation:invalidInput')\n }\n\n // Validate longitude bounds (-180 to 180)\n if (value[0] && !Number.isNaN(lng) && (lng < -180 || lng > 180)) {\n return t('validation:longitudeOutOfBounds')\n }\n\n // Validate latitude bounds (-90 to 90)\n if (value[1] && !Number.isNaN(lat) && (lat < -90 || lat > 90)) {\n return t('validation:latitudeOutOfBounds')\n }\n\n return true\n}\n\n/**\n * Built-in field validations used by Payload\n *\n * These can be re-used in custom validations\n */\nexport const validations = {\n array,\n blocks,\n checkbox,\n code,\n confirmPassword,\n date,\n email,\n json,\n number,\n password,\n point,\n radio,\n relationship,\n richText,\n select,\n text,\n textarea,\n upload,\n}\n"],"names":["ObjectIdImport","ObjectId","default","isNumber","isValidID","text","value","hasMany","maxLength","fieldMaxLength","maxRows","minLength","minRows","req","payload","config","t","required","undefined","lengthValidationResult","validateArrayLength","defaultMaxTextLength","stringsToValidate","Array","isArray","stringValue","length","label","password","confirmPassword","siblingData","email","collectionSlug","collections","collection","find","slug","auth","loginWithUsername","requireUsername","requireEmail","username","emailRegex","test","textarea","code","json","jsonError","jsonSchema","isNotEmpty","Object","keys","fetchSchema","schema","uri","fetch","then","response","ok","Error","_json","jsonSchemaSanitizations","id","$id","$schema","assign","AjvModule","AjvClass","ajv","validate","errorsText","error","message","checkbox","date","name","timezone","validDate","isNaN","Date","parse","toString","hasRequiredTimezone","selectedTimezone","validTimezone","Boolean","richText","options","editor","arrayLength","count","number","max","min","numbersToValidate","numberValue","parseFloat","array","validateBlocksFilterOptions","data","filterOptions","allBlockSlugs","map","b","blockType","filter","s","allowedBlockSlugs","result","user","invalidBlockSlugs","blockSlug","includes","push","blocks","join","validateFilterOptions","blockData","relationTo","falseCollections","values","optionFilter","valueIDs","forEach","val","isValid","toHexString","findWhere","and","in","payloadDataLoader","depth","limit","pagination","where","docs","doc","err","logger","msg","invalidRelationships","requestedID","indexOf","reduce","invalid","i","JSON","stringify","upload","event","idType","customIDType","db","defaultIDType","relationship","select","filteredOptions","some","input","option","counts","Map","item","set","get","duplicates","entries","duplicate","radio","valueMatchesOption","point","lng","String","lat","Number","validations"],"mappings":"AAAA,OAAOA,oBAAoB,gBAAe;AAE1C,MAAMC,WAAW,aAAaD,iBAAiBA,eAAeE,OAAO,GAAGF;AAgCxE,SAASG,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,SAAS,QAAQ,4BAA2B;AAQrD,OAAO,MAAMC,OAA4B,CACvCC,OACA,EACEC,OAAO,EACPC,WAAWC,cAAc,EACzBC,OAAO,EACPC,SAAS,EACTC,OAAO,EACPC,KAAK,EACHC,SAAS,EAAEC,MAAM,EAAE,EACnBC,CAAC,EACF,EACDC,QAAQ,EACT;IAED,IAAIT;IAEJ,IAAI,CAACS,UAAU;QACb,IAAIX,UAAUY,aAAaZ,UAAU,MAAM;YACzC,OAAO;QACT;IACF;IAEA,IAAIC,YAAY,MAAM;QACpB,MAAMY,yBAAyBC,oBAAoBd,OAAO;YAAEI;YAASE;YAASK;YAAUD;QAAE;QAC1F,IAAI,OAAOG,2BAA2B,UAAU;YA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C+F,MAAO;QACtE,OAAO7J,EAAE;IACX;IAEA,0CAA0C;IAC1C,IAAIV,KAAK,CAAC,EAAE,IAAI,CAACwK,OAAOhG,KAAK,CAAC6F,QAASA,CAAAA,MAAM,CAAC,OAAOA,MAAM,GAAE,GAAI;QAC/D,OAAO3J,EAAE;IACX;IAEA,uCAAuC;IACvC,IAAIV,KAAK,CAAC,EAAE,IAAI,CAACwK,OAAOhG,KAAK,CAAC+F,QAASA,CAAAA,MAAM,CAAC,MAAMA,MAAM,EAAC,GAAI;QAC7D,OAAO7J,EAAE;IACX;IAEA,OAAO;AACT,EAAC;AAED;;;;CAIC,GACD,OAAO,MAAM+J,cAAc;IACzB9E;IACAiB;IACAzC;IACA5B;IACAhB;IACA6C;IACA3C;IACAe;IACA6C;IACA/D;IACA8I;IACAF;IACAd;IACApE;IACAqE;IACAtJ;IACAuC;IACAwG;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/fields/validations.ts"],"sourcesContent":["import ObjectIdImport from 'bson-objectid'\n\nconst ObjectId = 'default' in ObjectIdImport ? ObjectIdImport.default : ObjectIdImport\n\nimport type { TFunction } from '@payloadcms/translations'\nimport type { JSONSchema4 } from 'json-schema'\n\nimport type { RichTextAdapter } from '../admin/types.js'\nimport type { CollectionSlug } from '../index.js'\nimport type { Where } from '../types/index.js'\nimport type {\n ArrayField,\n BlocksField,\n CheckboxField,\n CodeField,\n DateField,\n EmailField,\n JSONField,\n NumberField,\n PointField,\n RadioField,\n RelationshipField,\n RelationshipValue,\n RelationshipValueMany,\n RelationshipValueSingle,\n RichTextField,\n SelectField,\n SlugField,\n TextareaField,\n TextField,\n UploadField,\n Validate,\n ValueWithRelation,\n} from './config/types.js'\n\nimport { isNumber } from '../utilities/isNumber.js'\nimport { isValidID } from '../utilities/isValidID.js'\n\nexport type TextFieldValidation = Validate<string, unknown, unknown, TextField>\n\nexport type TextFieldManyValidation = Validate<string[], unknown, unknown, TextField>\n\nexport type TextFieldSingleValidation = Validate<string, unknown, unknown, TextField>\n\nexport const text: TextFieldValidation = (\n value,\n {\n hasMany,\n maxLength: fieldMaxLength,\n maxRows,\n minLength,\n minRows,\n req: {\n payload: { config },\n t,\n },\n required,\n },\n) => {\n let maxLength!: number\n\n if (!required) {\n if (value === undefined || value === null) {\n return true\n }\n }\n\n if (hasMany === true) {\n const lengthValidationResult = validateArrayLength(value, { maxRows, minRows, required, t })\n if (typeof lengthValidationResult === 'string') {\n return lengthValidationResult\n }\n }\n\n if (typeof config?.defaultMaxTextLength === 'number') {\n maxLength = config.defaultMaxTextLength\n }\n if (typeof fieldMaxLength === 'number') {\n maxLength = fieldMaxLength\n }\n\n const stringsToValidate: string[] = Array.isArray(value) ? value : [value!]\n\n for (const stringValue of stringsToValidate) {\n const length = stringValue?.length || 0\n\n if (typeof maxLength === 'number' && length > maxLength) {\n return t('validation:shorterThanMax', { label: t('general:value'), maxLength, stringValue })\n }\n\n if (typeof minLength === 'number' && length < minLength) {\n return t('validation:longerThanMin', { label: t('general:value'), minLength, stringValue })\n }\n }\n\n if (required) {\n if (!value || ((typeof value === 'string' || Array.isArray(value)) && value.length === 0)) {\n return t('validation:required')\n }\n }\n\n return true\n}\n\nexport type SlugFieldValidation = Validate<string, unknown, unknown, SlugField>\n\nexport const slug: SlugFieldValidation = (value, { req: { t }, required }) => {\n if (required && !value) {\n return t('validation:required')\n }\n\n return true\n}\n\nexport type PasswordFieldValidation = Validate<string, unknown, unknown, TextField>\n\nexport const password: PasswordFieldValidation = (\n value,\n {\n maxLength: fieldMaxLength,\n minLength = 3,\n req: {\n payload: { config },\n t,\n },\n required,\n },\n) => {\n let maxLength!: number\n\n if (typeof config?.defaultMaxTextLength === 'number') {\n maxLength = config.defaultMaxTextLength\n }\n if (typeof fieldMaxLength === 'number') {\n maxLength = fieldMaxLength\n }\n\n if (value && maxLength && value.length > maxLength) {\n return t('validation:shorterThanMax', { maxLength })\n }\n\n if (value && minLength && value.length < minLength) {\n return t('validation:longerThanMin', { minLength })\n }\n\n if (required && !value) {\n return t('validation:required')\n }\n\n return true\n}\n\nexport type ConfirmPasswordFieldValidation = Validate<\n string,\n unknown,\n { password: string },\n TextField\n>\n\nexport const confirmPassword: ConfirmPasswordFieldValidation = (\n value,\n { req: { t }, required, siblingData },\n) => {\n if (required && !value) {\n return t('validation:required')\n }\n\n if (value && value !== siblingData.password) {\n return t('fields:passwordsDoNotMatch')\n }\n\n return true\n}\n\nexport type EmailFieldValidation = Validate<string, unknown, { username?: string }, EmailField>\n\nexport const email: EmailFieldValidation = (\n value,\n {\n collectionSlug,\n req: {\n payload: { collections, config },\n t,\n },\n required,\n siblingData,\n },\n) => {\n if (collectionSlug) {\n const collection =\n collections?.[collectionSlug]?.config ??\n config.collections.find(({ slug }) => slug === collectionSlug)! // If this is run on the client, `collections` will be undefined, but `config.collections` will be available\n\n if (\n collection.auth.loginWithUsername &&\n !collection.auth.loginWithUsername?.requireUsername &&\n !collection.auth.loginWithUsername?.requireEmail\n ) {\n if (!value && !siblingData?.username) {\n return t('validation:required')\n }\n }\n }\n\n /**\n * Disallows emails with double quotes (e.g., \"user\"@example.com, user@\"example.com\", \"user@example.com\")\n * Rejects spaces anywhere in the email (e.g., user @example.com, user@ example.com, user name@example.com)\n * Prevents consecutive dots in the local or domain part (e.g., user..name@example.com, user@example..com)\n * Disallows domains that start or end with a hyphen (e.g., user@-example.com, user@example-.com)\n * Allows standard email formats (e.g., user@example.com, user.name+alias@example.co.uk, user-name@example.org)\n * Allows domains with consecutive hyphens as long as they are not leading/trailing (e.g., user@ex--ample.com)\n * Supports multiple subdomains (e.g., user@sub.domain.example.com)\n */\n const emailRegex =\n /^(?!.*\\.\\.)[\\w!#$%&'*+/=?^`{|}~-](?:[\\w!#$%&'*+/=?^`{|}~.-]*[\\w!#$%&'*+/=?^`{|}~-])?@[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)*\\.[a-z]{2,}$/i\n\n if ((value && !emailRegex.test(value)) || (!value && required)) {\n return t('validation:emailAddress')\n }\n\n return true\n}\n\nexport type UsernameFieldValidation = Validate<string, unknown, { email?: string }, TextField>\n\nexport const username: UsernameFieldValidation = (\n value,\n {\n collectionSlug,\n req: {\n payload: { collections, config },\n t,\n },\n required,\n siblingData,\n },\n) => {\n let maxLength!: number\n\n if (collectionSlug) {\n const collection =\n collections?.[collectionSlug]?.config ??\n config.collections.find(({ slug }) => slug === collectionSlug)! // If this is run on the client, `collections` will be undefined, but `config.collections` will be available\n\n if (\n collection.auth.loginWithUsername &&\n !collection.auth.loginWithUsername?.requireUsername &&\n !collection.auth.loginWithUsername?.requireEmail\n ) {\n if (!value && !siblingData?.email) {\n return t('validation:required')\n }\n }\n }\n\n if (typeof config?.defaultMaxTextLength === 'number') {\n maxLength = config.defaultMaxTextLength\n }\n\n if (value && maxLength && value.length > maxLength) {\n return t('validation:shorterThanMax', { maxLength })\n }\n\n if (!value && required) {\n return t('validation:required')\n }\n\n return true\n}\n\nexport type TextareaFieldValidation = Validate<string, unknown, unknown, TextareaField>\n\nexport const textarea: TextareaFieldValidation = (\n value,\n {\n maxLength: fieldMaxLength,\n minLength,\n req: {\n payload: { config },\n t,\n },\n required,\n },\n) => {\n let maxLength!: number\n\n if (typeof config?.defaultMaxTextLength === 'number') {\n maxLength = config.defaultMaxTextLength\n }\n if (typeof fieldMaxLength === 'number') {\n maxLength = fieldMaxLength\n }\n if (value && maxLength && value.length > maxLength) {\n return t('validation:shorterThanMax', { maxLength })\n }\n\n if (value && minLength && value.length < minLength) {\n return t('validation:longerThanMin', { minLength })\n }\n\n if (required && !value) {\n return t('validation:required')\n }\n\n return true\n}\n\nexport type CodeFieldValidation = Validate<string, unknown, unknown, CodeField>\n\nexport const code: CodeFieldValidation = (value, { req: { t }, required }) => {\n if (required && (!value || (typeof value === 'string' && value.length === 0))) {\n return t('validation:required')\n }\n\n return true\n}\n\nexport type JSONFieldValidation = Validate<\n string,\n unknown,\n unknown,\n { jsonError?: string } & JSONField\n>\n\nexport const json: JSONFieldValidation = async (\n value,\n { jsonError, jsonSchema, req: { t }, required },\n) => {\n const isNotEmpty = (value: null | string | undefined) => {\n if (value === undefined || value === null) {\n return false\n }\n\n if (Array.isArray(value) && value.length === 0) {\n return false\n }\n\n if (typeof value === 'object' && Object.keys(value).length === 0) {\n return false\n }\n\n return true\n }\n\n const fetchSchema = ({ schema, uri }: { schema: JSONSchema4; uri: string }) => {\n if (uri && schema) {\n return schema\n }\n return fetch(uri)\n .then((response) => {\n if (!response.ok) {\n throw new Error('Network response was not ok')\n }\n return response.json()\n })\n .then((_json) => {\n const json = _json as {\n id: string\n }\n const jsonSchemaSanitizations = {\n id: undefined,\n $id: json.id,\n $schema: 'http://json-schema.org/draft-07/schema#',\n }\n\n return Object.assign(json, jsonSchemaSanitizations)\n })\n }\n\n if (required && !value) {\n return t('validation:required')\n }\n\n if (jsonError !== undefined) {\n return t('validation:invalidInput')\n }\n\n if (jsonSchema && isNotEmpty(value)) {\n try {\n jsonSchema.schema = fetchSchema(jsonSchema)\n const { schema } = jsonSchema\n const AjvModule = await import('ajv')\n // Handle both ESM default export and CJS interop where the module itself is the constructor\n const AjvClass: any =\n 'default' in AjvModule && typeof AjvModule.default === 'function'\n ? AjvModule.default\n : AjvModule\n const ajv = new AjvClass()\n\n if (!ajv.validate(schema, value)) {\n return ajv.errorsText()\n }\n } catch (error) {\n return error instanceof Error ? error.message : 'Unknown error'\n }\n }\n return true\n}\n\nexport type CheckboxFieldValidation = Validate<boolean, unknown, unknown, CheckboxField>\n\nexport const checkbox: CheckboxFieldValidation = (value, { req: { t }, required }) => {\n if ((value && typeof value !== 'boolean') || (required && typeof value !== 'boolean')) {\n return t('validation:trueOrFalse')\n }\n\n return true\n}\n\nexport type DateFieldValidation = Validate<Date, unknown, unknown, DateField>\n\nexport const date: DateFieldValidation = (\n value,\n { name, req: { t }, required, siblingData, timezone },\n) => {\n const validDate = value && !isNaN(Date.parse(value.toString()))\n\n // We need to also check for the timezone data based on this field's config\n // We cannot do this inside the timezone field validation as it's visually hidden\n const hasRequiredTimezone = timezone && required\n const selectedTimezone: string = siblingData?.[`${name}_tz` as keyof typeof siblingData]\n // Always resolve to true if the field is not required, as timezone may be optional too then\n const validTimezone = hasRequiredTimezone ? Boolean(selectedTimezone) : true\n\n if (validDate && validTimezone) {\n return true\n }\n\n if (validDate && !validTimezone) {\n return t('validation:timezoneRequired')\n }\n\n if (value) {\n return t('validation:notValidDate', { value })\n }\n\n if (required) {\n return t('validation:required')\n }\n\n return true\n}\n\nexport type RichTextFieldValidation = Validate<object, unknown, unknown, RichTextField>\n\nexport const richText: RichTextFieldValidation = async (value, options) => {\n if (!options?.editor) {\n throw new Error('richText field has no editor property.')\n }\n if (typeof options?.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n\n const editor: RichTextAdapter = options?.editor\n\n return editor.validate(value, options)\n}\n\nconst validateArrayLength = (\n value: unknown,\n options: {\n maxRows?: number\n minRows?: number\n required?: boolean\n t: TFunction\n },\n) => {\n const { maxRows, minRows, required, t } = options\n\n const arrayLength = Array.isArray(value) ? value.length : (value as number) || 0\n\n if (!required && arrayLength === 0) {\n return true\n }\n\n if (minRows && arrayLength < minRows) {\n return t('validation:requiresAtLeast', { count: minRows, label: t('general:rows') })\n }\n\n if (maxRows && arrayLength > maxRows) {\n return t('validation:requiresNoMoreThan', { count: maxRows, label: t('general:rows') })\n }\n\n if (required && !arrayLength) {\n return t('validation:requiresAtLeast', { count: 1, label: t('general:row') })\n }\n\n return true\n}\n\nexport type NumberFieldValidation = Validate<number | number[], unknown, unknown, NumberField>\n\nexport type NumberFieldManyValidation = Validate<number[], unknown, unknown, NumberField>\n\nexport type NumberFieldSingleValidation = Validate<number, unknown, unknown, NumberField>\n\nexport const number: NumberFieldValidation = (\n value,\n { hasMany, max, maxRows, min, minRows, req: { t }, required },\n) => {\n if (hasMany === true) {\n const lengthValidationResult = validateArrayLength(value, { maxRows, minRows, required, t })\n if (typeof lengthValidationResult === 'string') {\n return lengthValidationResult\n }\n }\n\n if (!value && !isNumber(value)) {\n // if no value is present, validate based on required\n if (required) {\n return t('validation:required')\n }\n if (!required) {\n return true\n }\n }\n\n const numbersToValidate: number[] = Array.isArray(value) ? value : [value!]\n\n for (const number of numbersToValidate) {\n if (!isNumber(number)) {\n return t('validation:enterNumber')\n }\n\n const numberValue = parseFloat(number as unknown as string)\n\n if (typeof max === 'number' && numberValue > max) {\n return t('validation:greaterThanMax', { label: t('general:value'), max, value })\n }\n\n if (typeof min === 'number' && numberValue < min) {\n return t('validation:lessThanMin', { label: t('general:value'), min, value })\n }\n }\n\n return true\n}\n\nexport type ArrayFieldValidation = Validate<unknown[], unknown, unknown, ArrayField>\n\nexport const array: ArrayFieldValidation = (value, { maxRows, minRows, req: { t }, required }) => {\n return validateArrayLength(value, { maxRows, minRows, required, t })\n}\n\nexport type BlocksFieldValidation = Validate<unknown, unknown, unknown, BlocksField>\n\n/**\n * This function validates the blocks in a blocks field against the provided filterOptions.\n * It will return a list of all block slugs found in the value, the allowed block slugs (if any),\n * and a list of invalid block slugs that are used despite being disallowed.\n *\n * @internal - this may break or be removed at any time\n */\nexport async function validateBlocksFilterOptions({\n id,\n data,\n filterOptions,\n req,\n siblingData,\n value,\n}: { value: Parameters<BlocksFieldValidation>[0] } & Pick<\n Parameters<BlocksFieldValidation>[1],\n 'data' | 'filterOptions' | 'id' | 'req' | 'siblingData'\n>): Promise<{\n /**\n * All block slugs found in the value of the blocks field\n */\n allBlockSlugs: string[]\n /**\n * All block slugs that are allowed. If undefined, all blocks are allowed.\n */\n allowedBlockSlugs: string[] | undefined\n /**\n * A list of block slugs that are used despite being disallowed. If undefined, field passed validation.\n */\n invalidBlockSlugs: string[] | undefined\n}> {\n const allBlockSlugs = Array.isArray(value)\n ? (value as Array<{ blockType?: string }>)\n .map((b) => b.blockType)\n .filter((s): s is string => Boolean(s))\n : []\n\n // if undefined => all blocks allowed\n let allowedBlockSlugs: string[] | undefined = undefined\n\n if (typeof filterOptions === 'function') {\n const result = await filterOptions({\n id: id!, // original code asserted presence\n data,\n req,\n siblingData,\n user: req.user,\n })\n if (result !== true && Array.isArray(result)) {\n allowedBlockSlugs = result\n }\n } else if (Array.isArray(filterOptions)) {\n allowedBlockSlugs = filterOptions\n }\n\n const invalidBlockSlugs: string[] = []\n if (allowedBlockSlugs) {\n for (const blockSlug of allBlockSlugs) {\n if (!allowedBlockSlugs.includes(blockSlug)) {\n invalidBlockSlugs.push(blockSlug)\n }\n }\n }\n\n return {\n allBlockSlugs,\n allowedBlockSlugs,\n invalidBlockSlugs,\n }\n}\nexport const blocks: BlocksFieldValidation = async (\n value,\n { id, data, filterOptions, maxRows, minRows, req: { t }, req, required, siblingData },\n) => {\n const lengthValidationResult = validateArrayLength(value, { maxRows, minRows, required, t })\n if (typeof lengthValidationResult === 'string') {\n return lengthValidationResult\n }\n\n if (filterOptions) {\n const { invalidBlockSlugs } = await validateBlocksFilterOptions({\n id,\n data,\n filterOptions,\n req,\n siblingData,\n value,\n })\n if (invalidBlockSlugs?.length) {\n return t('validation:invalidBlocks', { blocks: invalidBlockSlugs.join(', ') })\n }\n }\n\n return true\n}\n\nconst validateFilterOptions: Validate<\n unknown,\n unknown,\n unknown,\n RelationshipField | UploadField\n> = async (\n value,\n { id, blockData, data, filterOptions, relationTo, req, req: { t, user }, siblingData },\n) => {\n if (typeof filterOptions !== 'undefined' && value) {\n const options: {\n [collection: string]: (number | string)[]\n } = {}\n\n const falseCollections: CollectionSlug[] = []\n const collections = !Array.isArray(relationTo) ? [relationTo] : relationTo\n const values = Array.isArray(value) ? value : [value]\n\n for (const collection of collections) {\n try {\n let optionFilter =\n typeof filterOptions === 'function'\n ? await filterOptions({\n id: id!,\n blockData,\n data,\n relationTo: collection,\n req,\n siblingData,\n user,\n })\n : filterOptions\n\n if (optionFilter === true) {\n optionFilter = null\n }\n\n const valueIDs: (number | string)[] = []\n\n values.forEach((val) => {\n if (typeof val === 'object') {\n if (val?.value) {\n valueIDs.push(val.value)\n } else if (ObjectId.isValid(val)) {\n valueIDs.push(new ObjectId(val).toHexString())\n }\n }\n\n if (typeof val === 'string' || typeof val === 'number') {\n valueIDs.push(val)\n }\n })\n\n if (valueIDs.length > 0) {\n const findWhere: Where = {\n and: [{ id: { in: valueIDs } }],\n }\n\n // @ts-expect-error - I don't understand why optionFilter is inferred as `false | Where | null` instead of `boolean | Where | null`\n if (optionFilter && optionFilter !== true) {\n findWhere.and?.push(optionFilter)\n }\n\n if (optionFilter === false) {\n falseCollections.push(collection)\n }\n\n const result = await req.payloadDataLoader.find({\n collection,\n depth: 0,\n limit: 0,\n pagination: false,\n req,\n where: findWhere,\n })\n\n options[collection] = result.docs.map((doc) => doc.id)\n } else {\n options[collection] = []\n }\n } catch (err) {\n req.payload.logger.error({\n err,\n msg: `Error validating filter options for collection ${collection}`,\n })\n options[collection] = []\n }\n }\n\n const invalidRelationships = values.filter((val) => {\n let collection: string\n let requestedID: number | string\n\n if (typeof relationTo === 'string') {\n collection = relationTo\n\n if (typeof val === 'string' || typeof val === 'number') {\n requestedID = val\n }\n\n if (typeof val === 'object' && ObjectId.isValid(val)) {\n requestedID = new ObjectId(val).toHexString()\n }\n }\n\n if (Array.isArray(relationTo) && typeof val === 'object' && val?.relationTo) {\n collection = val.relationTo\n requestedID = val.value\n }\n\n if (falseCollections.find((slug) => relationTo === slug)) {\n return true\n }\n\n if (!options[collection!]) {\n return true\n }\n\n return options[collection!]!.indexOf(requestedID!) === -1\n })\n\n if (invalidRelationships.length > 0) {\n return invalidRelationships.reduce((err, invalid, i) => {\n return `${err} ${JSON.stringify(invalid)}${\n invalidRelationships.length === i + 1 ? ',' : ''\n } `\n }, t('validation:invalidSelections')) as string\n }\n\n return true\n }\n\n return true\n}\n\nexport type UploadFieldValidation = Validate<unknown, unknown, unknown, UploadField>\n\nexport type UploadFieldManyValidation = Validate<unknown[], unknown, unknown, UploadField>\n\nexport type UploadFieldSingleValidation = Validate<unknown, unknown, unknown, UploadField>\n\nexport const upload: UploadFieldValidation = async (value, options) => {\n const {\n event,\n maxRows,\n minRows,\n relationTo,\n req: { payload, t },\n required,\n } = options\n\n if (\n ((!value && typeof value !== 'number') || (Array.isArray(value) && value.length === 0)) &&\n required\n ) {\n return t('validation:required')\n }\n\n if (Array.isArray(value) && value.length > 0) {\n if (minRows && value.length < minRows) {\n return t('validation:lessThanMin', {\n label: t('general:rows'),\n min: minRows,\n value: value.length,\n })\n }\n\n if (maxRows && value.length > maxRows) {\n return t('validation:greaterThanMax', {\n label: t('general:rows'),\n max: maxRows,\n value: value.length,\n })\n }\n }\n\n if (typeof value !== 'undefined' && value !== null) {\n const values = Array.isArray(value) ? value : [value]\n\n const invalidRelationships = values.filter((val) => {\n let collectionSlug: string\n let requestedID\n\n if (typeof relationTo === 'string') {\n collectionSlug = relationTo\n\n // custom id\n if (val || typeof val === 'number') {\n requestedID = val\n }\n }\n\n if (Array.isArray(relationTo) && typeof val === 'object' && val?.relationTo) {\n collectionSlug = val.relationTo\n requestedID = val.value\n }\n\n if (requestedID === null) {\n return false\n }\n\n const idType =\n payload.collections[collectionSlug!]?.customIDType || payload?.db?.defaultIDType || 'text'\n\n return !isValidID(requestedID, idType)\n })\n\n if (invalidRelationships.length > 0) {\n return `This relationship field has the following invalid relationships: ${invalidRelationships\n .map((err, invalid) => {\n return `${err} ${JSON.stringify(invalid)}`\n })\n .join(', ')}`\n }\n }\n\n if (event === 'onChange') {\n return true\n }\n\n return validateFilterOptions(value, options)\n}\n\nexport type RelationshipFieldValidation = Validate<\n RelationshipValue,\n unknown,\n unknown,\n RelationshipField\n>\n\nexport type RelationshipFieldManyValidation = Validate<\n RelationshipValueMany,\n unknown,\n unknown,\n RelationshipField\n>\n\nexport type RelationshipFieldSingleValidation = Validate<\n RelationshipValueSingle,\n unknown,\n unknown,\n RelationshipField\n>\n\nexport const relationship: RelationshipFieldValidation = async (value, options) => {\n const {\n event,\n maxRows,\n minRows,\n relationTo,\n req: { payload, t },\n required,\n } = options\n\n if (\n ((!value && typeof value !== 'number') || (Array.isArray(value) && value.length === 0)) &&\n required\n ) {\n return t('validation:required')\n }\n\n if (Array.isArray(value) && value.length > 0) {\n if (minRows && value.length < minRows) {\n return t('validation:lessThanMin', {\n label: t('general:rows'),\n min: minRows,\n value: value.length,\n })\n }\n\n if (maxRows && value.length > maxRows) {\n return t('validation:greaterThanMax', {\n label: t('general:rows'),\n max: maxRows,\n value: value.length,\n })\n }\n }\n\n if (typeof value !== 'undefined' && value !== null) {\n const values = Array.isArray(value) ? value : [value]\n\n const invalidRelationships = values.filter((val) => {\n let collectionSlug: string\n let requestedID: number | string | undefined | ValueWithRelation\n\n if (typeof relationTo === 'string') {\n collectionSlug = relationTo\n\n // custom id\n if (val || typeof val === 'number') {\n requestedID = val\n }\n }\n\n if (Array.isArray(relationTo) && typeof val === 'object' && val?.relationTo) {\n collectionSlug = val.relationTo\n requestedID = val.value\n }\n\n if (requestedID === null) {\n return false\n }\n\n const idType =\n payload.collections[collectionSlug!]?.customIDType || payload?.db?.defaultIDType || 'text'\n\n return !isValidID(requestedID as number | string, idType)\n })\n\n if (invalidRelationships.length > 0) {\n return `This relationship field has the following invalid relationships: ${invalidRelationships\n .map((err, invalid) => {\n return `${err} ${JSON.stringify(invalid)}`\n })\n .join(', ')}`\n }\n }\n\n if (event === 'onChange') {\n return true\n }\n\n return validateFilterOptions(value, options)\n}\n\nexport type SelectFieldValidation = Validate<string | string[], unknown, unknown, SelectField>\n\nexport type SelectFieldManyValidation = Validate<string[], unknown, unknown, SelectField>\n\nexport type SelectFieldSingleValidation = Validate<string, unknown, unknown, SelectField>\n\nexport const select: SelectFieldValidation = (\n value,\n { data, filterOptions, hasMany, options, req, req: { t }, required, siblingData },\n) => {\n const filteredOptions =\n typeof filterOptions === 'function'\n ? filterOptions({\n data,\n options,\n req,\n siblingData,\n })\n : options\n\n if (\n Array.isArray(value) &&\n value.some(\n (input) =>\n !filteredOptions.some(\n (option) => option === input || (typeof option !== 'string' && option?.value === input),\n ),\n )\n ) {\n return t('validation:invalidSelection')\n }\n\n // Check for duplicate values when hasMany is true\n if (hasMany && Array.isArray(value) && value.length > 1) {\n const counts = new Map<unknown, number>()\n\n for (const item of value) {\n counts.set(item, (counts.get(item) || 0) + 1)\n }\n\n const duplicates: unknown[] = []\n for (const [item, count] of counts.entries()) {\n if (count > 1) {\n // Add the item 'count' times to show all occurrences\n for (let i = 0; i < count; i++) {\n duplicates.push(item)\n }\n }\n }\n\n if (duplicates.length > 0) {\n return duplicates.reduce((err, duplicate, i) => {\n return `${err} ${JSON.stringify(duplicate)}${i < duplicates.length - 1 ? ',' : ''}`\n }, t('validation:invalidSelections')) as string\n }\n }\n\n if (\n typeof value === 'string' &&\n !filteredOptions.some(\n (option) => option === value || (typeof option !== 'string' && option.value === value),\n )\n ) {\n return t('validation:invalidSelection')\n }\n\n if (\n required &&\n (typeof value === 'undefined' ||\n value === null ||\n (hasMany && Array.isArray(value) && (value as [])?.length === 0))\n ) {\n return t('validation:required')\n }\n\n return true\n}\n\nexport type RadioFieldValidation = Validate<unknown, unknown, unknown, RadioField>\n\nexport const radio: RadioFieldValidation = (value, { options, req: { t }, required }) => {\n if (value) {\n const valueMatchesOption = options.some(\n (option) => option === value || (typeof option !== 'string' && option.value === value),\n )\n return valueMatchesOption || t('validation:invalidSelection')\n }\n\n return required ? t('validation:required') : true\n}\n\nexport type PointFieldValidation = Validate<\n [number | string, number | string],\n unknown,\n unknown,\n PointField\n>\n\nexport const point: PointFieldValidation = (value = ['', ''], { req: { t }, required }) => {\n if (value === null) {\n if (required) {\n return t('validation:required')\n }\n\n return true\n }\n\n const lng = parseFloat(String(value[0]))\n const lat = parseFloat(String(value[1]))\n if (\n required &&\n ((value[0] && value[1] && typeof lng !== 'number' && typeof lat !== 'number') ||\n Number.isNaN(lng) ||\n Number.isNaN(lat) ||\n (Array.isArray(value) && value.length !== 2))\n ) {\n return t('validation:requiresTwoNumbers')\n }\n\n if ((value[1] && Number.isNaN(lng)) || (value[0] && Number.isNaN(lat))) {\n return t('validation:invalidInput')\n }\n\n // Validate longitude bounds (-180 to 180)\n if (value[0] && !Number.isNaN(lng) && (lng < -180 || lng > 180)) {\n return t('validation:longitudeOutOfBounds')\n }\n\n // Validate latitude bounds (-90 to 90)\n if (value[1] && !Number.isNaN(lat) && (lat < -90 || lat > 90)) {\n return t('validation:latitudeOutOfBounds')\n }\n\n return true\n}\n\n/**\n * Built-in field validations used by Payload\n *\n * These can be re-used in custom validations\n */\nexport const validations = {\n slug,\n array,\n blocks,\n checkbox,\n code,\n confirmPassword,\n date,\n email,\n json,\n number,\n password,\n point,\n radio,\n relationship,\n richText,\n select,\n text,\n textarea,\n upload,\n}\n"],"names":["ObjectIdImport","ObjectId","default","isNumber","isValidID","text","value","hasMany","maxLength","fieldMaxLength","maxRows","minLength","minRows","req","payload","config","t","required","undefined","lengthValidationResult","validateArrayLength","defaultMaxTextLength","stringsToValidate","Array","isArray","stringValue","length","label","slug","password","confirmPassword","siblingData","email","collectionSlug","collections","collection","find","auth","loginWithUsername","requireUsername","requireEmail","username","emailRegex","test","textarea","code","json","jsonError","jsonSchema","isNotEmpty","Object","keys","fetchSchema","schema","uri","fetch","then","response","ok","Error","_json","jsonSchemaSanitizations","id","$id","$schema","assign","AjvModule","AjvClass","ajv","validate","errorsText","error","message","checkbox","date","name","timezone","validDate","isNaN","Date","parse","toString","hasRequiredTimezone","selectedTimezone","validTimezone","Boolean","richText","options","editor","arrayLength","count","number","max","min","numbersToValidate","numberValue","parseFloat","array","validateBlocksFilterOptions","data","filterOptions","allBlockSlugs","map","b","blockType","filter","s","allowedBlockSlugs","result","user","invalidBlockSlugs","blockSlug","includes","push","blocks","join","validateFilterOptions","blockData","relationTo","falseCollections","values","optionFilter","valueIDs","forEach","val","isValid","toHexString","findWhere","and","in","payloadDataLoader","depth","limit","pagination","where","docs","doc","err","logger","msg","invalidRelationships","requestedID","indexOf","reduce","invalid","i","JSON","stringify","upload","event","idType","customIDType","db","defaultIDType","relationship","select","filteredOptions","some","input","option","counts","Map","item","set","get","duplicates","entries","duplicate","radio","valueMatchesOption","point","lng","String","lat","Number","validations"],"mappings":"AAAA,OAAOA,oBAAoB,gBAAe;AAE1C,MAAMC,WAAW,aAAaD,iBAAiBA,eAAeE,OAAO,GAAGF;AAiCxE,SAASG,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,SAAS,QAAQ,4BAA2B;AAQrD,OAAO,MAAMC,OAA4B,CACvCC,OACA,EACEC,OAAO,EACPC,WAAWC,cAAc,EACzBC,OAAO,EACPC,SAAS,EACTC,OAAO,EACPC,KAAK,EACHC,SAAS,EAAEC,MAAM,EAAE,EACnBC,CAAC,EACF,EACDC,QAAQ,EACT;IAED,IAAIT;IAEJ,IAAI,CAACS,UAAU;QACb,IAAIX,UAAUY,aAAaZ,UAAU,MAAM;YACzC,OAAO;QACT;IACF;IAEA,IAAIC,YAAY,MAAM;QACpB,MAAMY,yBAAyBC,oBAAoBd,OAAO;YAAEI;YAASE;YAASK;YAAUD;QAAE;QAC1F,IAAI,OAAOG,2BAA2B,UAAU;YAC9C,OAAOA;QACT;IACF;IAEA,IAAI,OAAOJ,QAAQM,yBAAyB,UAAU;QACpDb,YAAYO,OAAOM,oBAAoB;IACzC;IACA,IAAI,OAAOZ,mBAAmB,UAAU;QACtCD,YAAYC;IACd;IAEA,MAAMa,oBAA8BC,MAAMC,OAAO,CAAClB,SAASA,QAAQ;QAACA;KAAO;IAE3E,KAAK,MAAMmB,eAAeH,kBAAmB;QAC3C,MAAMI,SAASD,aAAaC,UAAU;QAEtC,IAAI,OAAOlB,cAAc,YAAYkB,SAASlB,WAAW;YACvD,OAAOQ,EAAE,6BAA6B;gBAAEW,OAAOX,EAAE;gBAAkBR;gBAAWiB;YAAY;QAC5F;QAEA,IAAI,OAAOd,cAAc,YAAYe,SAASf,WAAW;YACvD,OAAOK,EAAE,4BAA4B;gBAAEW,OAAOX,EAAE;gBAAkBL;gBAAWc;YAAY;QAC3F;IACF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CAIC,GACD,OAAO,MAAM+J,cAAc;IACzBnJ;IACAqE;IACAiB;IACAzC;IACA5B;IACAf;IACA4C;IACA1C;IACAc;IACA6C;IACA9D;IACA6I;IACAF;IACAd;IACApE;IACAqE;IACAtJ;IACAuC;IACAwG;AACF,EAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { GlobalSlug, Payload, RequestContext, TypedLocale } from '../../../index.js';
|
|
2
|
-
import type {
|
|
1
|
+
import type { GlobalSlug, Payload, RequestContext, TypedLocale, User } from '../../../index.js';
|
|
2
|
+
import type { PayloadRequest, Where } from '../../../types/index.js';
|
|
3
3
|
export type CountGlobalVersionsOptions<TSlug extends GlobalSlug> = {
|
|
4
4
|
/**
|
|
5
5
|
* [Context](https://payloadcms.com/docs/hooks/context), which will then be passed to `context` and `req.context`,
|
|
@@ -34,7 +34,7 @@ export type CountGlobalVersionsOptions<TSlug extends GlobalSlug> = {
|
|
|
34
34
|
/**
|
|
35
35
|
* If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.
|
|
36
36
|
*/
|
|
37
|
-
user?:
|
|
37
|
+
user?: null | User;
|
|
38
38
|
/**
|
|
39
39
|
* A filter [query](https://payloadcms.com/docs/queries/overview)
|
|
40
40
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"countVersions.d.ts","sourceRoot":"","sources":["../../../../src/globals/operations/local/countVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"countVersions.d.ts","sourceRoot":"","sources":["../../../../src/globals/operations/local/countVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AAC/F,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAOpE,MAAM,MAAM,0BAA0B,CAAC,KAAK,SAAS,UAAU,IAAI;IACjE;;;;;OAKG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;OAEG;IACH,MAAM,EAAE,KAAK,CAAA;IACb;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;IAC7B;;OAEG;IACH,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;IAClB;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAA;AAED,wBAAsB,wBAAwB,CAAC,KAAK,SAAS,UAAU,EACrE,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,0BAA0B,CAAC,KAAK,CAAC,GACzC,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAkBhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/globals/operations/local/countVersions.ts"],"sourcesContent":["import type { GlobalSlug, Payload, RequestContext, TypedLocale } from '../../../index.js'\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../../src/globals/operations/local/countVersions.ts"],"sourcesContent":["import type { GlobalSlug, Payload, RequestContext, TypedLocale, User } from '../../../index.js'\nimport type { PayloadRequest, Where } from '../../../types/index.js'\nimport type { CreateLocalReqOptions } from '../../../utilities/createLocalReq.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { countGlobalVersionsOperation } from '../countGlobalVersions.js'\n\nexport type CountGlobalVersionsOptions<TSlug extends GlobalSlug> = {\n /**\n * [Context](https://payloadcms.com/docs/hooks/context), which will then be passed to `context` and `req.context`,\n * which can be read by hooks. Useful if you want to pass additional information to the hooks which\n * shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook\n * to determine if it should run or not.\n */\n context?: RequestContext\n /**\n * When set to `true`, errors will not be thrown.\n */\n disableErrors?: boolean\n /**\n * the Global slug to operate against.\n */\n global: TSlug\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: TypedLocale\n /**\n * Skip access control.\n * Set to `false` if you want to respect Access Control for the operation, for example when fetching data for the front-end.\n * @default true\n */\n overrideAccess?: boolean\n /**\n * The `PayloadRequest` object. You can pass it to thread the current [transaction](https://payloadcms.com/docs/database/transactions), user and locale to the operation.\n * Recommended to pass when using the Local API from hooks, as usually you want to execute the operation within the current transaction.\n */\n req?: Partial<PayloadRequest>\n /**\n * If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.\n */\n user?: null | User\n /**\n * A filter [query](https://payloadcms.com/docs/queries/overview)\n */\n where?: Where\n}\n\nexport async function countGlobalVersionsLocal<TSlug extends GlobalSlug>(\n payload: Payload,\n options: CountGlobalVersionsOptions<TSlug>,\n): Promise<{ totalDocs: number }> {\n const { disableErrors, global: globalSlug, overrideAccess = true, where } = options\n\n const global = payload.globals.config.find(({ slug }) => slug === globalSlug)\n\n if (!global) {\n throw new APIError(\n `The global with slug ${String(globalSlug)} can't be found. Count Global Versions Operation.`,\n )\n }\n\n return countGlobalVersionsOperation<TSlug>({\n disableErrors,\n global,\n overrideAccess,\n req: await createLocalReq(options as CreateLocalReqOptions, payload),\n where,\n })\n}\n"],"names":["APIError","createLocalReq","countGlobalVersionsOperation","countGlobalVersionsLocal","payload","options","disableErrors","global","globalSlug","overrideAccess","where","globals","config","find","slug","String","req"],"mappings":"AAIA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,4BAA4B,QAAQ,4BAA2B;AA2CxE,OAAO,eAAeC,yBACpBC,OAAgB,EAChBC,OAA0C;IAE1C,MAAM,EAAEC,aAAa,EAAEC,QAAQC,UAAU,EAAEC,iBAAiB,IAAI,EAAEC,KAAK,EAAE,GAAGL;IAE5E,MAAME,SAASH,QAAQO,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKA,SAASN;IAElE,IAAI,CAACD,QAAQ;QACX,MAAM,IAAIP,SACR,CAAC,qBAAqB,EAAEe,OAAOP,YAAY,iDAAiD,CAAC;IAEjG;IAEA,OAAON,6BAAoC;QACzCI;QACAC;QACAE;QACAO,KAAK,MAAMf,eAAeI,SAAkCD;QAC5DM;IACF;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FindOptions } from '../../../collections/operations/local/find.js';
|
|
2
|
-
import type { GlobalSlug, Payload, RequestContext, TypedFallbackLocale, TypedLocale } from '../../../index.js';
|
|
3
|
-
import type {
|
|
2
|
+
import type { GlobalSlug, Payload, RequestContext, TypedFallbackLocale, TypedLocale, User } from '../../../index.js';
|
|
3
|
+
import type { PayloadRequest, PopulateType, SelectType, TransformGlobalWithSelect } from '../../../types/index.js';
|
|
4
4
|
import type { DraftFlagFromGlobalSlug, SelectFromGlobalSlug } from '../../config/types.js';
|
|
5
5
|
import { type GlobalFindOneArgs } from '../findOne.js';
|
|
6
6
|
type BaseFindOneOptions<TSlug extends GlobalSlug, TSelect extends SelectType> = {
|
|
@@ -67,7 +67,7 @@ type BaseFindOneOptions<TSlug extends GlobalSlug, TSelect extends SelectType> =
|
|
|
67
67
|
/**
|
|
68
68
|
* If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.
|
|
69
69
|
*/
|
|
70
|
-
user?:
|
|
70
|
+
user?: null | User;
|
|
71
71
|
} & Pick<FindOptions<string, SelectType>, 'select'> & Pick<GlobalFindOneArgs, 'flattenLocales'>;
|
|
72
72
|
export type Options<TSlug extends GlobalSlug, TSelect extends SelectType> = BaseFindOneOptions<TSlug, TSelect> & DraftFlagFromGlobalSlug<TSlug>;
|
|
73
73
|
export declare function findOneGlobalLocal<TSlug extends GlobalSlug, TSelect extends SelectFromGlobalSlug<TSlug>>(payload: Payload, options: Options<TSlug, TSelect>): Promise<TransformGlobalWithSelect<TSlug, TSelect>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findOne.d.ts","sourceRoot":"","sources":["../../../../src/globals/operations/local/findOne.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAA;AAChF,OAAO,KAAK,EACV,UAAU,EACV,OAAO,EACP,cAAc,EACd,mBAAmB,EACnB,WAAW,
|
|
1
|
+
{"version":3,"file":"findOne.d.ts","sourceRoot":"","sources":["../../../../src/globals/operations/local/findOne.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAA;AAChF,OAAO,KAAK,EACV,UAAU,EACV,OAAO,EACP,cAAc,EACd,mBAAmB,EACnB,WAAW,EACX,IAAI,EACL,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,UAAU,EACV,yBAAyB,EAC1B,MAAM,yBAAyB,CAAA;AAEhC,OAAO,KAAK,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAI1F,OAAO,EAAoB,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAExE,KAAK,kBAAkB,CAAC,KAAK,SAAS,UAAU,EAAE,OAAO,SAAS,UAAU,IAAI;IAC9E;;;;;OAKG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;;OAEG;IACH,cAAc,CAAC,EAAE,mBAAmB,CAAA;IACpC;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IAC5B;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;OAEG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;IAC7B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B;;OAEG;IACH,IAAI,EAAE,KAAK,CAAA;IACX;;OAEG;IACH,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;CACnB,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,QAAQ,CAAC,GACjD,IAAI,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,CAAA;AAE3C,MAAM,MAAM,OAAO,CAAC,KAAK,SAAS,UAAU,EAAE,OAAO,SAAS,UAAU,IAAI,kBAAkB,CAC5F,KAAK,EACL,OAAO,CACR,GACC,uBAAuB,CAAC,KAAK,CAAC,CAAA;AAEhC,wBAAsB,kBAAkB,CACtC,KAAK,SAAS,UAAU,EACxB,OAAO,SAAS,oBAAoB,CAAC,KAAK,CAAC,EAE3C,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,yBAAyB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAoCpD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/globals/operations/local/findOne.ts"],"sourcesContent":["import type { FindOptions } from '../../../collections/operations/local/find.js'\nimport type {\n GlobalSlug,\n Payload,\n RequestContext,\n TypedFallbackLocale,\n TypedLocale,\n} from '../../../index.js'\nimport type {\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/globals/operations/local/findOne.ts"],"sourcesContent":["import type { FindOptions } from '../../../collections/operations/local/find.js'\nimport type {\n GlobalSlug,\n Payload,\n RequestContext,\n TypedFallbackLocale,\n TypedLocale,\n User,\n} from '../../../index.js'\nimport type {\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformGlobalWithSelect,\n} from '../../../types/index.js'\nimport type { CreateLocalReqOptions } from '../../../utilities/createLocalReq.js'\nimport type { DraftFlagFromGlobalSlug, SelectFromGlobalSlug } from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { findOneOperation, type GlobalFindOneArgs } from '../findOne.js'\n\ntype BaseFindOneOptions<TSlug extends GlobalSlug, TSelect extends SelectType> = {\n /**\n * [Context](https://payloadcms.com/docs/hooks/context), which will then be passed to `context` and `req.context`,\n * which can be read by hooks. Useful if you want to pass additional information to the hooks which\n * shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook\n * to determine if it should run or not.\n */\n context?: RequestContext\n /**\n * You may pass the document data directly which will skip the `db.findOne` database query.\n * This is useful if you want to use this endpoint solely for running hooks and populating data.\n */\n data?: Record<string, unknown>\n /**\n * [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.\n */\n depth?: number\n /**\n * When set to `true`, errors will not be thrown.\n */\n disableErrors?: boolean\n /**\n * Whether the document should be queried from the versions table/collection or not. [More](https://payloadcms.com/docs/versions/drafts#draft-api)\n */\n draft?: boolean\n /**\n * Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.\n */\n fallbackLocale?: TypedFallbackLocale\n /**\n * Include info about the lock status to the result with fields: `_isLocked` and `_userEditing`\n */\n includeLockStatus?: boolean\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: 'all' | TypedLocale\n /**\n * Skip access control.\n * Set to `false` if you want to respect Access Control for the operation, for example when fetching data for the front-end.\n * @default true\n */\n overrideAccess?: boolean\n /**\n * Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.\n */\n populate?: PopulateType\n /**\n * The `PayloadRequest` object. You can pass it to thread the current [transaction](https://payloadcms.com/docs/database/transactions), user and locale to the operation.\n * Recommended to pass when using the Local API from hooks, as usually you want to execute the operation within the current transaction.\n */\n req?: Partial<PayloadRequest>\n /**\n * Opt-in to receiving hidden fields. By default, they are hidden from returned documents in accordance to your config.\n * @default false\n */\n showHiddenFields?: boolean\n /**\n * the Global slug to operate against.\n */\n slug: TSlug\n /**\n * If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.\n */\n user?: null | User\n} & Pick<FindOptions<string, SelectType>, 'select'> &\n Pick<GlobalFindOneArgs, 'flattenLocales'>\n\nexport type Options<TSlug extends GlobalSlug, TSelect extends SelectType> = BaseFindOneOptions<\n TSlug,\n TSelect\n> &\n DraftFlagFromGlobalSlug<TSlug>\n\nexport async function findOneGlobalLocal<\n TSlug extends GlobalSlug,\n TSelect extends SelectFromGlobalSlug<TSlug>,\n>(\n payload: Payload,\n options: Options<TSlug, TSelect>,\n): Promise<TransformGlobalWithSelect<TSlug, TSelect>> {\n const {\n slug: globalSlug,\n data,\n depth,\n disableErrors,\n draft = false,\n flattenLocales,\n includeLockStatus,\n overrideAccess = true,\n populate,\n select,\n showHiddenFields,\n } = options\n\n const globalConfig = payload.globals.config.find((config) => config.slug === globalSlug)\n\n if (!globalConfig) {\n throw new APIError(`The global with slug ${String(globalSlug)} can't be found.`)\n }\n\n return findOneOperation({\n slug: globalSlug as string,\n data,\n depth,\n disableErrors,\n draft,\n flattenLocales,\n globalConfig,\n includeLockStatus,\n overrideAccess,\n populate,\n req: await createLocalReq(options as CreateLocalReqOptions, payload),\n select,\n showHiddenFields,\n })\n}\n"],"names":["APIError","createLocalReq","findOneOperation","findOneGlobalLocal","payload","options","slug","globalSlug","data","depth","disableErrors","draft","flattenLocales","includeLockStatus","overrideAccess","populate","select","showHiddenFields","globalConfig","globals","config","find","String","req"],"mappings":"AAkBA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,gBAAgB,QAAgC,gBAAe;AA4ExE,OAAO,eAAeC,mBAIpBC,OAAgB,EAChBC,OAAgC;IAEhC,MAAM,EACJC,MAAMC,UAAU,EAChBC,IAAI,EACJC,KAAK,EACLC,aAAa,EACbC,QAAQ,KAAK,EACbC,cAAc,EACdC,iBAAiB,EACjBC,iBAAiB,IAAI,EACrBC,QAAQ,EACRC,MAAM,EACNC,gBAAgB,EACjB,GAAGZ;IAEJ,MAAMa,eAAed,QAAQe,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAACD,SAAWA,OAAOd,IAAI,KAAKC;IAE7E,IAAI,CAACW,cAAc;QACjB,MAAM,IAAIlB,SAAS,CAAC,qBAAqB,EAAEsB,OAAOf,YAAY,gBAAgB,CAAC;IACjF;IAEA,OAAOL,iBAAiB;QACtBI,MAAMC;QACNC;QACAC;QACAC;QACAC;QACAC;QACAM;QACAL;QACAC;QACAC;QACAQ,KAAK,MAAMtB,eAAeI,SAAkCD;QAC5DY;QACAC;IACF;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { FindOptions, GlobalSlug, Payload, RequestContext, TypedLocale } from '../../../index.js';
|
|
2
|
-
import type {
|
|
1
|
+
import type { FindOptions, GlobalSlug, Payload, RequestContext, TypedLocale, User } from '../../../index.js';
|
|
2
|
+
import type { PayloadRequest, PopulateType, SelectType } from '../../../types/index.js';
|
|
3
3
|
import type { TypeWithVersion } from '../../../versions/types.js';
|
|
4
4
|
import type { DataFromGlobalSlug } from '../../config/types.js';
|
|
5
5
|
export type Options<TSlug extends GlobalSlug> = {
|
|
@@ -58,7 +58,7 @@ export type Options<TSlug extends GlobalSlug> = {
|
|
|
58
58
|
/**
|
|
59
59
|
* If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.
|
|
60
60
|
*/
|
|
61
|
-
user?:
|
|
61
|
+
user?: null | User;
|
|
62
62
|
} & Pick<FindOptions<string, SelectType>, 'select'>;
|
|
63
63
|
export declare function findGlobalVersionByIDLocal<TSlug extends GlobalSlug>(payload: Payload, options: Options<TSlug>): Promise<TypeWithVersion<DataFromGlobalSlug<TSlug>>>;
|
|
64
64
|
//# sourceMappingURL=findVersionByID.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findVersionByID.d.ts","sourceRoot":"","sources":["../../../../src/globals/operations/local/findVersionByID.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,OAAO,EACP,cAAc,EACd,WAAW,
|
|
1
|
+
{"version":3,"file":"findVersionByID.d.ts","sourceRoot":"","sources":["../../../../src/globals/operations/local/findVersionByID.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,OAAO,EACP,cAAc,EACd,WAAW,EACX,IAAI,EACL,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAEvF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAM/D,MAAM,MAAM,OAAO,CAAC,KAAK,SAAS,UAAU,IAAI;IAC9C;;;;;OAKG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IACpC;;OAEG;IACH,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IAC5B;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;OAEG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;IAE7B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B;;OAEG;IACH,IAAI,EAAE,KAAK,CAAA;IACX;;OAEG;IACH,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;CACnB,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,QAAQ,CAAC,CAAA;AAEnD,wBAAsB,0BAA0B,CAAC,KAAK,SAAS,UAAU,EACvE,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,GACtB,OAAO,CAAC,eAAe,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CA6BrD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/globals/operations/local/findVersionByID.ts"],"sourcesContent":["import type {\n FindOptions,\n GlobalSlug,\n Payload,\n RequestContext,\n TypedLocale,\n} from '../../../index.js'\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../../src/globals/operations/local/findVersionByID.ts"],"sourcesContent":["import type {\n FindOptions,\n GlobalSlug,\n Payload,\n RequestContext,\n TypedLocale,\n User,\n} from '../../../index.js'\nimport type { PayloadRequest, PopulateType, SelectType } from '../../../types/index.js'\nimport type { CreateLocalReqOptions } from '../../../utilities/createLocalReq.js'\nimport type { TypeWithVersion } from '../../../versions/types.js'\nimport type { DataFromGlobalSlug } from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { findVersionByIDOperation } from '../findVersionByID.js'\n\nexport type Options<TSlug extends GlobalSlug> = {\n /**\n * [Context](https://payloadcms.com/docs/hooks/context), which will then be passed to `context` and `req.context`,\n * which can be read by hooks. Useful if you want to pass additional information to the hooks which\n * shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook\n * to determine if it should run or not.\n */\n context?: RequestContext\n /**\n * [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.\n */\n depth?: number\n /**\n * When set to `true`, errors will not be thrown.\n * `null` will be returned instead, if the document on this ID was not found.\n */\n disableErrors?: boolean\n /**\n * Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.\n */\n fallbackLocale?: false | TypedLocale\n /**\n * The ID of the version to find.\n */\n id: number | string\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: 'all' | TypedLocale\n /**\n * Skip access control.\n * Set to `false` if you want to respect Access Control for the operation, for example when fetching data for the front-end.\n * @default true\n */\n overrideAccess?: boolean\n /**\n * Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.\n */\n populate?: PopulateType\n /**\n * The `PayloadRequest` object. You can pass it to thread the current [transaction](https://payloadcms.com/docs/database/transactions), user and locale to the operation.\n * Recommended to pass when using the Local API from hooks, as usually you want to execute the operation within the current transaction.\n */\n req?: Partial<PayloadRequest>\n\n /**\n * Opt-in to receiving hidden fields. By default, they are hidden from returned documents in accordance to your config.\n * @default false\n */\n showHiddenFields?: boolean\n /**\n * the Global slug to operate against.\n */\n slug: TSlug\n /**\n * If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.\n */\n user?: null | User\n} & Pick<FindOptions<string, SelectType>, 'select'>\n\nexport async function findGlobalVersionByIDLocal<TSlug extends GlobalSlug>(\n payload: Payload,\n options: Options<TSlug>,\n): Promise<TypeWithVersion<DataFromGlobalSlug<TSlug>>> {\n const {\n id,\n slug: globalSlug,\n depth,\n disableErrors = false,\n overrideAccess = true,\n populate,\n select,\n showHiddenFields,\n } = options\n\n const globalConfig = payload.globals.config.find((config) => config.slug === globalSlug)\n\n if (!globalConfig) {\n throw new APIError(`The global with slug ${String(globalSlug)} can't be found.`)\n }\n\n return findVersionByIDOperation({\n id,\n depth,\n disableErrors,\n globalConfig,\n overrideAccess,\n populate,\n req: await createLocalReq(options as CreateLocalReqOptions, payload),\n select,\n showHiddenFields,\n })\n}\n"],"names":["APIError","createLocalReq","findVersionByIDOperation","findGlobalVersionByIDLocal","payload","options","id","slug","globalSlug","depth","disableErrors","overrideAccess","populate","select","showHiddenFields","globalConfig","globals","config","find","String","req"],"mappings":"AAaA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,wBAAwB,QAAQ,wBAAuB;AA8DhE,OAAO,eAAeC,2BACpBC,OAAgB,EAChBC,OAAuB;IAEvB,MAAM,EACJC,EAAE,EACFC,MAAMC,UAAU,EAChBC,KAAK,EACLC,gBAAgB,KAAK,EACrBC,iBAAiB,IAAI,EACrBC,QAAQ,EACRC,MAAM,EACNC,gBAAgB,EACjB,GAAGT;IAEJ,MAAMU,eAAeX,QAAQY,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAACD,SAAWA,OAAOV,IAAI,KAAKC;IAE7E,IAAI,CAACO,cAAc;QACjB,MAAM,IAAIf,SAAS,CAAC,qBAAqB,EAAEmB,OAAOX,YAAY,gBAAgB,CAAC;IACjF;IAEA,OAAON,yBAAyB;QAC9BI;QACAG;QACAC;QACAK;QACAJ;QACAC;QACAQ,KAAK,MAAMnB,eAAeI,SAAkCD;QAC5DS;QACAC;IACF;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PaginatedDocs } from '../../../database/types.js';
|
|
2
|
-
import type { FindOptions, GlobalSlug, Payload, RequestContext, TypedLocale } from '../../../index.js';
|
|
3
|
-
import type {
|
|
2
|
+
import type { FindOptions, GlobalSlug, Payload, RequestContext, TypedLocale, User } from '../../../index.js';
|
|
3
|
+
import type { PayloadRequest, PopulateType, SelectType, Sort, Where } from '../../../types/index.js';
|
|
4
4
|
import type { TypeWithVersion } from '../../../versions/types.js';
|
|
5
5
|
import type { DataFromGlobalSlug } from '../../config/types.js';
|
|
6
6
|
export type Options<TSlug extends GlobalSlug> = {
|
|
@@ -72,7 +72,7 @@ export type Options<TSlug extends GlobalSlug> = {
|
|
|
72
72
|
/**
|
|
73
73
|
* If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.
|
|
74
74
|
*/
|
|
75
|
-
user?:
|
|
75
|
+
user?: null | User;
|
|
76
76
|
/**
|
|
77
77
|
* A filter [query](https://payloadcms.com/docs/queries/overview)
|
|
78
78
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findVersions.d.ts","sourceRoot":"","sources":["../../../../src/globals/operations/local/findVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,OAAO,EACP,cAAc,EACd,WAAW,
|
|
1
|
+
{"version":3,"file":"findVersions.d.ts","sourceRoot":"","sources":["../../../../src/globals/operations/local/findVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,OAAO,EACP,cAAc,EACd,WAAW,EACX,IAAI,EACL,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAEpG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAM/D,MAAM,MAAM,OAAO,CAAC,KAAK,SAAS,UAAU,IAAI;IAC9C;;;;;OAKG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IACpC;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IAC5B;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;OAEG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;IAC7B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B;;OAEG;IACH,IAAI,EAAE,KAAK,CAAA;IACX;;;;OAIG;IACH,IAAI,CAAC,EAAE,IAAI,CAAA;IACX;;OAEG;IACH,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;IAClB;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,QAAQ,CAAC,CAAA;AAEnD,wBAAsB,uBAAuB,CAAC,KAAK,SAAS,UAAU,EACpE,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,GACtB,OAAO,CAAC,aAAa,CAAC,eAAe,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAmCpE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/globals/operations/local/findVersions.ts"],"sourcesContent":["import type { PaginatedDocs } from '../../../database/types.js'\nimport type {\n FindOptions,\n GlobalSlug,\n Payload,\n RequestContext,\n TypedLocale,\n} from '../../../index.js'\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../../src/globals/operations/local/findVersions.ts"],"sourcesContent":["import type { PaginatedDocs } from '../../../database/types.js'\nimport type {\n FindOptions,\n GlobalSlug,\n Payload,\n RequestContext,\n TypedLocale,\n User,\n} from '../../../index.js'\nimport type { PayloadRequest, PopulateType, SelectType, Sort, Where } from '../../../types/index.js'\nimport type { CreateLocalReqOptions } from '../../../utilities/createLocalReq.js'\nimport type { TypeWithVersion } from '../../../versions/types.js'\nimport type { DataFromGlobalSlug } from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { findVersionsOperation } from '../findVersions.js'\n\nexport type Options<TSlug extends GlobalSlug> = {\n /**\n * [Context](https://payloadcms.com/docs/hooks/context), which will then be passed to `context` and `req.context`,\n * which can be read by hooks. Useful if you want to pass additional information to the hooks which\n * shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook\n * to determine if it should run or not.\n */\n context?: RequestContext\n /**\n * [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.\n */\n depth?: number\n /**\n * Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.\n */\n fallbackLocale?: false | TypedLocale\n /**\n * The maximum related documents to be returned.\n * Defaults unless `defaultLimit` is specified for the collection config\n * @default 10\n */\n limit?: number\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: 'all' | TypedLocale\n /**\n * Skip access control.\n * Set to `false` if you want to respect Access Control for the operation, for example when fetching data for the front-end.\n * @default true\n */\n overrideAccess?: boolean\n /**\n * Get a specific page number\n * @default 1\n */\n page?: number\n /**\n * Set to `false` to return all documents and avoid querying for document counts which introduces some overhead.\n * You can also combine that property with a specified `limit` to limit documents but avoid the count query.\n */\n pagination?: boolean\n /**\n * Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.\n */\n populate?: PopulateType\n /**\n * The `PayloadRequest` object. You can pass it to thread the current [transaction](https://payloadcms.com/docs/database/transactions), user and locale to the operation.\n * Recommended to pass when using the Local API from hooks, as usually you want to execute the operation within the current transaction.\n */\n req?: Partial<PayloadRequest>\n /**\n * Opt-in to receiving hidden fields. By default, they are hidden from returned documents in accordance to your config.\n * @default false\n */\n showHiddenFields?: boolean\n /**\n * the Global slug to operate against.\n */\n slug: TSlug\n /**\n * Sort the documents, can be a string or an array of strings\n * @example '-version.createdAt' // Sort DESC by createdAt\n * @example ['version.group', '-version.createdAt'] // sort by 2 fields, ASC group and DESC createdAt\n */\n sort?: Sort\n /**\n * If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.\n */\n user?: null | User\n /**\n * A filter [query](https://payloadcms.com/docs/queries/overview)\n */\n where?: Where\n} & Pick<FindOptions<string, SelectType>, 'select'>\n\nexport async function findGlobalVersionsLocal<TSlug extends GlobalSlug>(\n payload: Payload,\n options: Options<TSlug>,\n): Promise<PaginatedDocs<TypeWithVersion<DataFromGlobalSlug<TSlug>>>> {\n const {\n slug: globalSlug,\n depth,\n limit,\n overrideAccess = true,\n page,\n pagination = true,\n populate,\n select,\n showHiddenFields,\n sort,\n where,\n } = options\n\n const globalConfig = payload.globals.config.find((config) => config.slug === globalSlug)\n\n if (!globalConfig) {\n throw new APIError(`The global with slug ${String(globalSlug)} can't be found.`)\n }\n\n return findVersionsOperation({\n depth,\n globalConfig,\n limit,\n overrideAccess,\n page,\n pagination,\n populate,\n req: await createLocalReq(options as CreateLocalReqOptions, payload),\n select,\n showHiddenFields,\n sort,\n where,\n })\n}\n"],"names":["APIError","createLocalReq","findVersionsOperation","findGlobalVersionsLocal","payload","options","slug","globalSlug","depth","limit","overrideAccess","page","pagination","populate","select","showHiddenFields","sort","where","globalConfig","globals","config","find","String","req"],"mappings":"AAcA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,qBAAqB,QAAQ,qBAAoB;AA8E1D,OAAO,eAAeC,wBACpBC,OAAgB,EAChBC,OAAuB;IAEvB,MAAM,EACJC,MAAMC,UAAU,EAChBC,KAAK,EACLC,KAAK,EACLC,iBAAiB,IAAI,EACrBC,IAAI,EACJC,aAAa,IAAI,EACjBC,QAAQ,EACRC,MAAM,EACNC,gBAAgB,EAChBC,IAAI,EACJC,KAAK,EACN,GAAGZ;IAEJ,MAAMa,eAAed,QAAQe,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAACD,SAAWA,OAAOd,IAAI,KAAKC;IAE7E,IAAI,CAACW,cAAc;QACjB,MAAM,IAAIlB,SAAS,CAAC,qBAAqB,EAAEsB,OAAOf,YAAY,gBAAgB,CAAC;IACjF;IAEA,OAAOL,sBAAsB;QAC3BM;QACAU;QACAT;QACAC;QACAC;QACAC;QACAC;QACAU,KAAK,MAAMtB,eAAeI,SAAkCD;QAC5DU;QACAC;QACAC;QACAC;IACF;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { GlobalSlug, Payload, RequestContext, TypedLocale } from '../../../index.js';
|
|
2
|
-
import type {
|
|
1
|
+
import type { GlobalSlug, Payload, RequestContext, TypedLocale, User } from '../../../index.js';
|
|
2
|
+
import type { PayloadRequest, PopulateType } from '../../../types/index.js';
|
|
3
3
|
import type { DataFromGlobalSlug } from '../../config/types.js';
|
|
4
4
|
export type Options<TSlug extends GlobalSlug> = {
|
|
5
5
|
/**
|
|
@@ -52,7 +52,7 @@ export type Options<TSlug extends GlobalSlug> = {
|
|
|
52
52
|
/**
|
|
53
53
|
* If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.
|
|
54
54
|
*/
|
|
55
|
-
user?:
|
|
55
|
+
user?: null | User;
|
|
56
56
|
};
|
|
57
57
|
export declare function restoreGlobalVersionLocal<TSlug extends GlobalSlug>(payload: Payload, options: Options<TSlug>): Promise<DataFromGlobalSlug<TSlug>>;
|
|
58
58
|
//# sourceMappingURL=restoreVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restoreVersion.d.ts","sourceRoot":"","sources":["../../../../src/globals/operations/local/restoreVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"restoreVersion.d.ts","sourceRoot":"","sources":["../../../../src/globals/operations/local/restoreVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AAC/F,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAE3E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAM/D,MAAM,MAAM,OAAO,CAAC,KAAK,SAAS,UAAU,IAAI;IAC9C;;;;;OAKG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IACpC;;OAEG;IACH,EAAE,EAAE,MAAM,CAAA;IACV;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;OAEG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;IAC7B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B;;OAEG;IACH,IAAI,EAAE,KAAK,CAAA;IACX;;OAEG;IACH,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;CACnB,CAAA;AAED,wBAAsB,yBAAyB,CAAC,KAAK,SAAS,UAAU,EACtE,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,GACtB,OAAO,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAkBpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/globals/operations/local/restoreVersion.ts"],"sourcesContent":["import type { GlobalSlug, Payload, RequestContext, TypedLocale } from '../../../index.js'\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../../src/globals/operations/local/restoreVersion.ts"],"sourcesContent":["import type { GlobalSlug, Payload, RequestContext, TypedLocale, User } from '../../../index.js'\nimport type { PayloadRequest, PopulateType } from '../../../types/index.js'\nimport type { CreateLocalReqOptions } from '../../../utilities/createLocalReq.js'\nimport type { DataFromGlobalSlug } from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { restoreVersionOperation } from '../restoreVersion.js'\n\nexport type Options<TSlug extends GlobalSlug> = {\n /**\n * [Context](https://payloadcms.com/docs/hooks/context), which will then be passed to `context` and `req.context`,\n * which can be read by hooks. Useful if you want to pass additional information to the hooks which\n * shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook\n * to determine if it should run or not.\n */\n context?: RequestContext\n /**\n * [Control auto-population](https://payloadcms.com/docs/queries/depth) of nested relationship and upload fields.\n */\n depth?: number\n /**\n * Specify a [fallback locale](https://payloadcms.com/docs/configuration/localization) to use for any returned documents.\n */\n fallbackLocale?: false | TypedLocale\n /**\n * The ID of the version to restore.\n */\n id: string\n /**\n * Specify [locale](https://payloadcms.com/docs/configuration/localization) for any returned documents.\n */\n locale?: TypedLocale\n /**\n * Skip access control.\n * Set to `false` if you want to respect Access Control for the operation, for example when fetching data for the front-end.\n * @default true\n */\n overrideAccess?: boolean\n /**\n * Specify [populate](https://payloadcms.com/docs/queries/select#populate) to control which fields to include to the result from populated documents.\n */\n populate?: PopulateType\n /**\n * The `PayloadRequest` object. You can pass it to thread the current [transaction](https://payloadcms.com/docs/database/transactions), user and locale to the operation.\n * Recommended to pass when using the Local API from hooks, as usually you want to execute the operation within the current transaction.\n */\n req?: Partial<PayloadRequest>\n /**\n * Opt-in to receiving hidden fields. By default, they are hidden from returned documents in accordance to your config.\n * @default false\n */\n showHiddenFields?: boolean\n /**\n * the Global slug to operate against.\n */\n slug: TSlug\n /**\n * If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.\n */\n user?: null | User\n}\n\nexport async function restoreGlobalVersionLocal<TSlug extends GlobalSlug>(\n payload: Payload,\n options: Options<TSlug>,\n): Promise<DataFromGlobalSlug<TSlug>> {\n const { id, slug: globalSlug, depth, overrideAccess = true, populate, showHiddenFields } = options\n\n const globalConfig = payload.globals.config.find((config) => config.slug === globalSlug)\n\n if (!globalConfig) {\n throw new APIError(`The global with slug ${String(globalSlug)} can't be found.`)\n }\n\n return restoreVersionOperation({\n id,\n depth,\n globalConfig,\n overrideAccess,\n populate,\n req: await createLocalReq(options as CreateLocalReqOptions, payload),\n showHiddenFields,\n })\n}\n"],"names":["APIError","createLocalReq","restoreVersionOperation","restoreGlobalVersionLocal","payload","options","id","slug","globalSlug","depth","overrideAccess","populate","showHiddenFields","globalConfig","globals","config","find","String","req"],"mappings":"AAKA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,uBAAuB,QAAQ,uBAAsB;AAwD9D,OAAO,eAAeC,0BACpBC,OAAgB,EAChBC,OAAuB;IAEvB,MAAM,EAAEC,EAAE,EAAEC,MAAMC,UAAU,EAAEC,KAAK,EAAEC,iBAAiB,IAAI,EAAEC,QAAQ,EAAEC,gBAAgB,EAAE,GAAGP;IAE3F,MAAMQ,eAAeT,QAAQU,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAACD,SAAWA,OAAOR,IAAI,KAAKC;IAE7E,IAAI,CAACK,cAAc;QACjB,MAAM,IAAIb,SAAS,CAAC,qBAAqB,EAAEiB,OAAOT,YAAY,gBAAgB,CAAC;IACjF;IAEA,OAAON,wBAAwB;QAC7BI;QACAG;QACAI;QACAH;QACAC;QACAO,KAAK,MAAMjB,eAAeI,SAAkCD;QAC5DQ;IACF;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DeepPartial } from 'ts-essentials';
|
|
2
|
-
import type {
|
|
2
|
+
import type { PayloadRequest, PopulateType, SelectType, TransformGlobalWithSelect } from '../../../types/index.js';
|
|
3
3
|
import type { DataFromGlobalSlug, DraftFlagFromGlobalSlug, SelectFromGlobalSlug } from '../../config/types.js';
|
|
4
|
-
import { type FindOptions, type GlobalSlug, type Payload, type RequestContext, type TypedLocale } from '../../../index.js';
|
|
4
|
+
import { type FindOptions, type GlobalSlug, type Payload, type RequestContext, type TypedLocale, type User } from '../../../index.js';
|
|
5
5
|
type BaseOptions<TSlug extends GlobalSlug, TSelect extends SelectType> = {
|
|
6
6
|
/**
|
|
7
7
|
* [Context](https://payloadcms.com/docs/hooks/context), which will then be passed to `context` and `req.context`,
|
|
@@ -71,7 +71,7 @@ type BaseOptions<TSlug extends GlobalSlug, TSelect extends SelectType> = {
|
|
|
71
71
|
/**
|
|
72
72
|
* If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks.
|
|
73
73
|
*/
|
|
74
|
-
user?:
|
|
74
|
+
user?: null | User;
|
|
75
75
|
} & Pick<FindOptions<string, SelectType>, 'select'>;
|
|
76
76
|
export type Options<TSlug extends GlobalSlug, TSelect extends SelectType> = BaseOptions<TSlug, TSelect> & DraftFlagFromGlobalSlug<TSlug>;
|
|
77
77
|
export declare function updateGlobalLocal<TSlug extends GlobalSlug, TSelect extends SelectFromGlobalSlug<TSlug>>(payload: Payload, options: Options<TSlug, TSelect>): Promise<TransformGlobalWithSelect<TSlug, TSelect>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/globals/operations/local/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAEhD,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/globals/operations/local/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAEhD,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,UAAU,EACV,yBAAyB,EAC1B,MAAM,yBAAyB,CAAA;AAEhC,OAAO,KAAK,EACV,kBAAkB,EAClB,uBAAuB,EACvB,oBAAoB,EACrB,MAAM,uBAAuB,CAAA;AAG9B,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,IAAI,EACV,MAAM,mBAAmB,CAAA;AAI1B,KAAK,WAAW,CAAC,KAAK,SAAS,UAAU,EAAE,OAAO,SAAS,UAAU,IAAI;IACvE;;;;;OAKG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB;;OAEG;IACH,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC,CAAA;IACxD;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IACpC;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;IAC5B;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;OAEG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;IAC7B;;;OAGG;IACH,gBAAgB,CA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