payload 3.0.0-beta.88 → 3.0.0-beta.89

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/bin.js +1 -1
  2. package/dist/bin/generateImportMap/index.d.ts.map +1 -1
  3. package/dist/bin/generateImportMap/index.js.map +1 -1
  4. package/dist/bin/generateImportMap/iterateCollections.js +1 -1
  5. package/dist/bin/generateImportMap/iterateCollections.js.map +1 -1
  6. package/dist/collections/config/client.d.ts +0 -1
  7. package/dist/collections/config/client.d.ts.map +1 -1
  8. package/dist/collections/config/client.js.map +1 -1
  9. package/dist/collections/config/sanitize.d.ts.map +1 -1
  10. package/dist/collections/config/sanitize.js +1 -0
  11. package/dist/collections/config/sanitize.js.map +1 -1
  12. package/dist/collections/config/types.d.ts +1 -1
  13. package/dist/collections/config/types.d.ts.map +1 -1
  14. package/dist/collections/config/types.js.map +1 -1
  15. package/dist/database/queryValidation/validateSearchParams.d.ts.map +1 -1
  16. package/dist/database/queryValidation/validateSearchParams.js +1 -1
  17. package/dist/database/queryValidation/validateSearchParams.js.map +1 -1
  18. package/dist/errors/ValidationError.d.ts +1 -0
  19. package/dist/errors/ValidationError.d.ts.map +1 -1
  20. package/dist/errors/ValidationError.js.map +1 -1
  21. package/dist/fields/config/sanitize.d.ts.map +1 -1
  22. package/dist/fields/config/sanitize.js +15 -9
  23. package/dist/fields/config/sanitize.js.map +1 -1
  24. package/dist/fields/config/types.d.ts +70 -18
  25. package/dist/fields/config/types.d.ts.map +1 -1
  26. package/dist/fields/config/types.js.map +1 -1
  27. package/dist/fields/hooks/beforeChange/index.d.ts.map +1 -1
  28. package/dist/fields/hooks/beforeChange/index.js +1 -0
  29. package/dist/fields/hooks/beforeChange/index.js.map +1 -1
  30. package/dist/fields/hooks/beforeValidate/promise.d.ts.map +1 -1
  31. package/dist/fields/hooks/beforeValidate/promise.js +29 -21
  32. package/dist/fields/hooks/beforeValidate/promise.js.map +1 -1
  33. package/dist/fields/validations.d.ts.map +1 -1
  34. package/dist/fields/validations.js +45 -6
  35. package/dist/fields/validations.js.map +1 -1
  36. package/dist/uploads/types.d.ts +5 -0
  37. package/dist/uploads/types.d.ts.map +1 -1
  38. package/dist/uploads/types.js.map +1 -1
  39. package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
  40. package/dist/utilities/configToJSONSchema.js +1 -17
  41. package/dist/utilities/configToJSONSchema.js.map +1 -1
  42. package/package.json +2 -2
@@ -393,14 +393,53 @@ const validateFilterOptions = async (value, { id, data, filterOptions, relationT
393
393
  }
394
394
  return true;
395
395
  };
396
- export const upload = (value, options)=>{
397
- if (!value && options.required) {
398
- return options?.req?.t('validation:required');
396
+ export const upload = async (value, options)=>{
397
+ const { maxRows, minRows, relationTo, req: { payload, t }, required } = options;
398
+ if ((!value && typeof value !== 'number' || Array.isArray(value) && value.length === 0) && required) {
399
+ return t('validation:required');
400
+ }
401
+ if (Array.isArray(value) && value.length > 0) {
402
+ if (minRows && value.length < minRows) {
403
+ return t('validation:lessThanMin', {
404
+ label: t('general:rows'),
405
+ min: minRows,
406
+ value: value.length
407
+ });
408
+ }
409
+ if (maxRows && value.length > maxRows) {
410
+ return t('validation:greaterThanMax', {
411
+ label: t('general:rows'),
412
+ max: maxRows,
413
+ value: value.length
414
+ });
415
+ }
399
416
  }
400
417
  if (typeof value !== 'undefined' && value !== null) {
401
- const idType = options?.req?.payload?.collections[options.relationTo]?.customIDType || options?.req?.payload?.db?.defaultIDType;
402
- if (!isValidID(value, idType)) {
403
- return options.req?.t('validation:validUploadID');
418
+ const values = Array.isArray(value) ? value : [
419
+ value
420
+ ];
421
+ const invalidRelationships = values.filter((val)=>{
422
+ let collectionSlug;
423
+ let requestedID;
424
+ if (typeof relationTo === 'string') {
425
+ collectionSlug = relationTo;
426
+ // custom id
427
+ if (val || typeof val === 'number') {
428
+ requestedID = val;
429
+ }
430
+ }
431
+ if (Array.isArray(relationTo) && typeof val === 'object' && val?.relationTo) {
432
+ collectionSlug = val.relationTo;
433
+ requestedID = val.value;
434
+ }
435
+ if (requestedID === null) return false;
436
+ const idType = payload.collections[collectionSlug]?.customIDType || payload?.db?.defaultIDType || 'text';
437
+ return !isValidID(requestedID, idType);
438
+ });
439
+ if (invalidRelationships.length > 0) {
440
+ return `This relationship field has the following invalid relationships: ${invalidRelationships.map((err, invalid)=>{
441
+ return `${err} ${JSON.stringify(invalid)}`;
442
+ }).join(', ')}`;
404
443
  }
405
444
  }
406
445
  return validateFilterOptions(value, options);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/fields/validations.ts"],"sourcesContent":["import Ajv from 'ajv'\nimport ObjectIdImport from 'bson-objectid'\n\nconst ObjectId = (ObjectIdImport.default ||\n ObjectIdImport) as unknown as typeof ObjectIdImport.default\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 BlockField,\n CheckboxField,\n CodeField,\n DateField,\n EmailField,\n JSONField,\n NumberField,\n PointField,\n RadioField,\n RelationshipField,\n RelationshipValue,\n RichTextField,\n SelectField,\n TextField,\n TextareaField,\n UploadField,\n Validate,\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>\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) return true\n }\n\n if (hasMany === true) {\n const lengthValidationResult = validateArrayLength(value, { maxRows, minRows, required, t })\n if (typeof lengthValidationResult === 'string') return lengthValidationResult\n }\n\n if (typeof config?.defaultMaxTextLength === 'number') maxLength = config.defaultMaxTextLength\n if (typeof fieldMaxLength === 'number') maxLength = fieldMaxLength\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 (!(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>\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') maxLength = config.defaultMaxTextLength\n if (typeof fieldMaxLength === 'number') 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 ConfirmPasswordFieldValidation = Validate<\n string,\n unknown,\n { password: string },\n TextField\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>\nexport const email: EmailFieldValidation = (\n value,\n {\n collectionSlug,\n req: {\n payload: { config },\n t,\n },\n required,\n siblingData,\n },\n) => {\n if (collectionSlug) {\n const collection = config.collections.find(({ slug }) => slug === collectionSlug)\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 if ((value && !/\\S[^\\s@]*@\\S+\\.\\S+/.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>\nexport const username: UsernameFieldValidation = (\n value,\n {\n collectionSlug,\n req: {\n payload: { config },\n t,\n },\n required,\n siblingData,\n },\n) => {\n let maxLength: number\n\n if (collectionSlug) {\n const collection = config.collections.find(({ slug }) => slug === collectionSlug)\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') maxLength = config.defaultMaxTextLength\n\n if (value && maxLength && value.length > maxLength) {\n return t('validation:shorterThanMax', { maxLength })\n }\n\n if ((value && !/^[\\w.-]+$/.test(value)) || (!value && required)) {\n return t('validation:username')\n }\n\n return true\n}\n\nexport type TextareaFieldValidation = Validate<string, unknown, unknown, TextareaField>\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') maxLength = config.defaultMaxTextLength\n if (typeof fieldMaxLength === 'number') maxLength = fieldMaxLength\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>\nexport const code: CodeFieldValidation = (value, { req: { t }, required }) => {\n if (required && value === undefined) {\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>\nexport const json: JSONFieldValidation = async (\n value,\n { jsonError, jsonSchema, req: { t }, required },\n) => {\n const isNotEmpty = (value) => {\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 }: Record<string, unknown>) => {\n if (uri && schema) return schema\n // @ts-expect-error\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 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 = await fetchSchema(jsonSchema)\n const { schema } = jsonSchema\n // @ts-expect-error\n const ajv = new Ajv()\n\n if (!ajv.validate(schema, value)) {\n return t(ajv.errorsText())\n }\n } catch (error) {\n return t(error.message)\n }\n }\n return true\n}\n\nexport type CheckboxFieldValidation = Validate<boolean, unknown, unknown, CheckboxField>\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>\nexport const date: DateFieldValidation = (value, { req: { t }, required }) => {\n if (value && !isNaN(Date.parse(value.toString()))) {\n return true\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>\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,\n options: {\n maxRows?: number\n minRows?: number\n required?: boolean\n t: (key: string, options?: { [key: string]: number | string }) => string\n },\n) => {\n const { maxRows, minRows, required, t } = options\n\n const arrayLength = Array.isArray(value) ? value.length : value || 0\n\n if (!required && arrayLength === 0) return true\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>\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') return lengthValidationResult\n }\n\n if (!value && !isNumber(value)) {\n // if no value is present, validate based on required\n if (required) return t('validation:required')\n if (!required) return true\n }\n\n const numbersToValidate: number[] = Array.isArray(value) ? value : [value]\n\n for (const number of numbersToValidate) {\n if (!isNumber(number)) return t('validation:enterNumber')\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>\nexport const array: ArrayFieldValidation = (value, { maxRows, minRows, req: { t }, required }) => {\n return validateArrayLength(value, { maxRows, minRows, required, t })\n}\n\nexport type BlockFieldValidation = Validate<unknown, unknown, unknown, BlockField>\nexport const blocks: BlockFieldValidation = (value, { maxRows, minRows, req: { t }, required }) => {\n return validateArrayLength(value, { maxRows, minRows, required, t })\n}\n\nconst validateFilterOptions: Validate<\n unknown,\n unknown,\n unknown,\n RelationshipField | UploadField\n> = async (\n value,\n { id, data, filterOptions, relationTo, req, req: { payload, 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,\n data,\n relationTo: collection,\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 if (optionFilter && optionFilter !== true) findWhere.and.push(optionFilter)\n\n if (optionFilter === false) {\n falseCollections.push(collection)\n }\n\n const result = await payload.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]) return true\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>\nexport const upload: UploadFieldValidation = (value: string, options) => {\n if (!value && options.required) {\n return options?.req?.t('validation:required')\n }\n\n if (typeof value !== 'undefined' && value !== null) {\n const idType =\n options?.req?.payload?.collections[options.relationTo]?.customIDType ||\n options?.req?.payload?.db?.defaultIDType\n\n if (!isValidID(value, idType)) {\n return options.req?.t('validation:validUploadID')\n }\n }\n\n return validateFilterOptions(value, options)\n}\n\nexport type RelationshipFieldValidation = Validate<\n RelationshipValue,\n unknown,\n unknown,\n RelationshipField\n>\nexport const relationship: RelationshipFieldValidation = async (value, options) => {\n const {\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) return false\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 return validateFilterOptions(value, options)\n}\n\nexport type SelectFieldValidation = Validate<string | string[], unknown, unknown, SelectField>\nexport const select: SelectFieldValidation = (\n value,\n { hasMany, options, req: { t }, required },\n) => {\n if (\n Array.isArray(value) &&\n value.some(\n (input) =>\n !options.some(\n (option) => option === input || (typeof option !== 'string' && option?.value === input),\n ),\n )\n ) {\n return t('validation:invalidSelection')\n }\n\n if (\n typeof value === 'string' &&\n !options.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>\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>\nexport const point: PointFieldValidation = (value = ['', ''], { req: { t }, required }) => {\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 return true\n}\n\nexport default {\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":["Ajv","ObjectIdImport","ObjectId","default","isNumber","isValidID","text","value","hasMany","maxLength","fieldMaxLength","maxRows","minLength","minRows","req","payload","config","t","required","lengthValidationResult","validateArrayLength","defaultMaxTextLength","stringsToValidate","Array","isArray","stringValue","length","label","password","confirmPassword","siblingData","email","collectionSlug","collection","collections","find","slug","auth","loginWithUsername","requireUsername","requireEmail","username","test","textarea","code","undefined","json","jsonError","jsonSchema","isNotEmpty","Object","keys","fetchSchema","schema","uri","fetch","then","response","ok","Error","jsonSchemaSanitizations","id","$id","$schema","assign","ajv","validate","errorsText","error","message","checkbox","date","isNaN","Date","parse","toString","richText","options","editor","arrayLength","count","number","max","min","numbersToValidate","numberValue","parseFloat","array","blocks","validateFilterOptions","data","filterOptions","relationTo","user","falseCollections","values","optionFilter","valueIDs","forEach","val","push","isValid","toHexString","findWhere","and","in","result","depth","limit","pagination","where","docs","map","doc","err","logger","msg","invalidRelationships","filter","requestedID","indexOf","reduce","invalid","i","JSON","stringify","upload","idType","customIDType","db","defaultIDType","relationship","join","select","some","input","option","radio","valueMatchesOption","point","lng","String","lat","Number"],"mappings":"AAAA,OAAOA,SAAS,MAAK;AACrB,OAAOC,oBAAoB,gBAAe;AAE1C,MAAMC,WAAYD,eAAeE,OAAO,IACtCF;AA0BF,SAASG,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,SAAS,QAAQ,4BAA2B;AAGrD,OAAO,MAAMC,OAA4B,CACvCC,OACA,EACEC,OAAO,EACPC,WAAWC,cAAc,EACzBC,OAAO,EACPC,SAAS,EACTC,OAAO,EACPC,KAAK,EACHC,SAAS,EAAEC,MAAM,EAAE,EACnBC,C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D,QAAQyD,IAAI,CACrC,CAACE,SAAWA,WAAWjI,SAAU,OAAOiI,WAAW,YAAYA,OAAOjI,KAAK,KAAKA;QAElF,OAAOmI,sBAAsBzH,EAAE;IACjC;IAEA,OAAOC,WAAWD,EAAE,yBAAyB;AAC/C,EAAC;AAQD,OAAO,MAAM0H,QAA8B,CAACpI,QAAQ;IAAC;IAAI;CAAG,EAAE,EAAEO,KAAK,EAAEG,CAAC,EAAE,EAAEC,QAAQ,EAAE;IACpF,MAAM0H,MAAMtD,WAAWuD,OAAOtI,KAAK,CAAC,EAAE;IACtC,MAAMuI,MAAMxD,WAAWuD,OAAOtI,KAAK,CAAC,EAAE;IACtC,IACEW,YACC,CAAA,AAACX,KAAK,CAAC,EAAE,IAAIA,KAAK,CAAC,EAAE,IAAI,OAAOqI,QAAQ,YAAY,OAAOE,QAAQ,YAClEC,OAAOvE,KAAK,CAACoE,QACbG,OAAOvE,KAAK,CAACsE,QACZvH,MAAMC,OAAO,CAACjB,UAAUA,MAAMmB,MAAM,KAAK,CAAC,GAC7C;QACA,OAAOT,EAAE;IACX;IAEA,IAAI,AAACV,KAAK,CAAC,EAAE,IAAIwI,OAAOvE,KAAK,CAACoE,QAAUrI,KAAK,CAAC,EAAE,IAAIwI,OAAOvE,KAAK,CAACsE,MAAO;QACtE,OAAO7H,EAAE;IACX;IAEA,OAAO;AACT,EAAC;AAED,eAAe;IACbsE;IACAC;IACAlB;IACA1B;IACAf;IACA0C;IACAxC;IACAe;IACAmC;IACArD;IACA+G;IACAF;IACAN;IACAvD;IACAyD;IACA/H;IACAqC;IACAmF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../src/fields/validations.ts"],"sourcesContent":["import Ajv from 'ajv'\nimport ObjectIdImport from 'bson-objectid'\n\nconst ObjectId = (ObjectIdImport.default ||\n ObjectIdImport) as unknown as typeof ObjectIdImport.default\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 BlockField,\n CheckboxField,\n CodeField,\n DateField,\n EmailField,\n JSONField,\n NumberField,\n PointField,\n RadioField,\n RelationshipField,\n RelationshipValue,\n RichTextField,\n SelectField,\n TextField,\n TextareaField,\n UploadField,\n Validate,\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>\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) return true\n }\n\n if (hasMany === true) {\n const lengthValidationResult = validateArrayLength(value, { maxRows, minRows, required, t })\n if (typeof lengthValidationResult === 'string') return lengthValidationResult\n }\n\n if (typeof config?.defaultMaxTextLength === 'number') maxLength = config.defaultMaxTextLength\n if (typeof fieldMaxLength === 'number') maxLength = fieldMaxLength\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 (!(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>\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') maxLength = config.defaultMaxTextLength\n if (typeof fieldMaxLength === 'number') 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 ConfirmPasswordFieldValidation = Validate<\n string,\n unknown,\n { password: string },\n TextField\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>\nexport const email: EmailFieldValidation = (\n value,\n {\n collectionSlug,\n req: {\n payload: { config },\n t,\n },\n required,\n siblingData,\n },\n) => {\n if (collectionSlug) {\n const collection = config.collections.find(({ slug }) => slug === collectionSlug)\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 if ((value && !/\\S[^\\s@]*@\\S+\\.\\S+/.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>\nexport const username: UsernameFieldValidation = (\n value,\n {\n collectionSlug,\n req: {\n payload: { config },\n t,\n },\n required,\n siblingData,\n },\n) => {\n let maxLength: number\n\n if (collectionSlug) {\n const collection = config.collections.find(({ slug }) => slug === collectionSlug)\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') maxLength = config.defaultMaxTextLength\n\n if (value && maxLength && value.length > maxLength) {\n return t('validation:shorterThanMax', { maxLength })\n }\n\n if ((value && !/^[\\w.-]+$/.test(value)) || (!value && required)) {\n return t('validation:username')\n }\n\n return true\n}\n\nexport type TextareaFieldValidation = Validate<string, unknown, unknown, TextareaField>\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') maxLength = config.defaultMaxTextLength\n if (typeof fieldMaxLength === 'number') maxLength = fieldMaxLength\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>\nexport const code: CodeFieldValidation = (value, { req: { t }, required }) => {\n if (required && value === undefined) {\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>\nexport const json: JSONFieldValidation = async (\n value,\n { jsonError, jsonSchema, req: { t }, required },\n) => {\n const isNotEmpty = (value) => {\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 }: Record<string, unknown>) => {\n if (uri && schema) return schema\n // @ts-expect-error\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 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 = await fetchSchema(jsonSchema)\n const { schema } = jsonSchema\n // @ts-expect-error\n const ajv = new Ajv()\n\n if (!ajv.validate(schema, value)) {\n return t(ajv.errorsText())\n }\n } catch (error) {\n return t(error.message)\n }\n }\n return true\n}\n\nexport type CheckboxFieldValidation = Validate<boolean, unknown, unknown, CheckboxField>\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>\nexport const date: DateFieldValidation = (value, { req: { t }, required }) => {\n if (value && !isNaN(Date.parse(value.toString()))) {\n return true\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>\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,\n options: {\n maxRows?: number\n minRows?: number\n required?: boolean\n t: (key: string, options?: { [key: string]: number | string }) => string\n },\n) => {\n const { maxRows, minRows, required, t } = options\n\n const arrayLength = Array.isArray(value) ? value.length : value || 0\n\n if (!required && arrayLength === 0) return true\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>\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') return lengthValidationResult\n }\n\n if (!value && !isNumber(value)) {\n // if no value is present, validate based on required\n if (required) return t('validation:required')\n if (!required) return true\n }\n\n const numbersToValidate: number[] = Array.isArray(value) ? value : [value]\n\n for (const number of numbersToValidate) {\n if (!isNumber(number)) return t('validation:enterNumber')\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>\nexport const array: ArrayFieldValidation = (value, { maxRows, minRows, req: { t }, required }) => {\n return validateArrayLength(value, { maxRows, minRows, required, t })\n}\n\nexport type BlockFieldValidation = Validate<unknown, unknown, unknown, BlockField>\nexport const blocks: BlockFieldValidation = (value, { maxRows, minRows, req: { t }, required }) => {\n return validateArrayLength(value, { maxRows, minRows, required, t })\n}\n\nconst validateFilterOptions: Validate<\n unknown,\n unknown,\n unknown,\n RelationshipField | UploadField\n> = async (\n value,\n { id, data, filterOptions, relationTo, req, req: { payload, 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,\n data,\n relationTo: collection,\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 if (optionFilter && optionFilter !== true) findWhere.and.push(optionFilter)\n\n if (optionFilter === false) {\n falseCollections.push(collection)\n }\n\n const result = await payload.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]) return true\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 const upload: UploadFieldValidation = async (value, options) => {\n const {\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) return false\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 return validateFilterOptions(value, options)\n}\n\nexport type RelationshipFieldValidation = Validate<\n RelationshipValue,\n unknown,\n unknown,\n RelationshipField\n>\nexport const relationship: RelationshipFieldValidation = async (value, options) => {\n const {\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) return false\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 return validateFilterOptions(value, options)\n}\n\nexport type SelectFieldValidation = Validate<string | string[], unknown, unknown, SelectField>\nexport const select: SelectFieldValidation = (\n value,\n { hasMany, options, req: { t }, required },\n) => {\n if (\n Array.isArray(value) &&\n value.some(\n (input) =>\n !options.some(\n (option) => option === input || (typeof option !== 'string' && option?.value === input),\n ),\n )\n ) {\n return t('validation:invalidSelection')\n }\n\n if (\n typeof value === 'string' &&\n !options.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>\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>\nexport const point: PointFieldValidation = (value = ['', ''], { req: { t }, required }) => {\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 return true\n}\n\nexport default {\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":["Ajv","ObjectIdImport","ObjectId","default","isNumber","isValidID","text","value","hasMany","maxLength","fieldMaxLength","maxRows","minLength","minRows","req","payload","config","t","required","lengthValidationResult","validateArrayLength","defaultMaxTextLength","stringsToValidate","Array","isArray","stringValue","length","label","password","confirmPassword","siblingData","email","collectionSlug","collection","collections","find","slug","auth","loginWithUsername","requireUsername","requireEmail","username","test","textarea","code","undefined","json","jsonError","jsonSchema","isNotEmpty","Object","keys","fetchSchema","schema","uri","fetch","then","response","ok","Error","jsonSchemaSanitizations","id","$id","$schema","assign","ajv","validate","errorsText","error","message","checkbox","date","isNaN","Date","parse","toString","richText","options","editor","arrayLength","count","number","max","min","numbersToValidate","numberValue","parseFloat","array","blocks","validateFilterOptions","data","filterOptions","relationTo","user","falseCollections","values","optionFilter","valueIDs","forEach","val","push","isValid","toHexString","findWhere","and","in","result","depth","limit","pagination","where","docs","map","doc","err","logger","msg","invalidRelationships","filter","requestedID","indexOf","reduce","invalid","i","JSON","stringify","upload","idType","customIDType","db","defaultIDType","join","relationship","select","some","input","option","radio","valueMatchesOption","point","lng","String","lat","Number"],"mappings":"AAAA,OAAOA,SAAS,MAAK;AACrB,OAAOC,oBAAoB,gBAAe;AAE1C,MAAMC,WAAYD,eAAeE,OAAO,IACtCF;AA0BF,SAASG,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,SAAS,QAAQ,4BAA2B;AAGrD,OAAO,MAAMC,OAA4B,CACvCC,OACA,EACEC,OAAO,EACPC,WAAWC,cAAc,EACzBC,OAAO,EACPC,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OAAO;QACT,MAAMmI,qBAAqB7D,QAAQyD,IAAI,CACrC,CAACE,SAAWA,WAAWjI,SAAU,OAAOiI,WAAW,YAAYA,OAAOjI,KAAK,KAAKA;QAElF,OAAOmI,sBAAsBzH,EAAE;IACjC;IAEA,OAAOC,WAAWD,EAAE,yBAAyB;AAC/C,EAAC;AAQD,OAAO,MAAM0H,QAA8B,CAACpI,QAAQ;IAAC;IAAI;CAAG,EAAE,EAAEO,KAAK,EAAEG,CAAC,EAAE,EAAEC,QAAQ,EAAE;IACpF,MAAM0H,MAAMtD,WAAWuD,OAAOtI,KAAK,CAAC,EAAE;IACtC,MAAMuI,MAAMxD,WAAWuD,OAAOtI,KAAK,CAAC,EAAE;IACtC,IACEW,YACC,CAAA,AAACX,KAAK,CAAC,EAAE,IAAIA,KAAK,CAAC,EAAE,IAAI,OAAOqI,QAAQ,YAAY,OAAOE,QAAQ,YAClEC,OAAOvE,KAAK,CAACoE,QACbG,OAAOvE,KAAK,CAACsE,QACZvH,MAAMC,OAAO,CAACjB,UAAUA,MAAMmB,MAAM,KAAK,CAAC,GAC7C;QACA,OAAOT,EAAE;IACX;IAEA,IAAI,AAACV,KAAK,CAAC,EAAE,IAAIwI,OAAOvE,KAAK,CAACoE,QAAUrI,KAAK,CAAC,EAAE,IAAIwI,OAAOvE,KAAK,CAACsE,MAAO;QACtE,OAAO7H,EAAE;IACX;IAEA,OAAO;AACT,EAAC;AAED,eAAe;IACbsE;IACAC;IACAlB;IACA1B;IACAf;IACA0C;IACAxC;IACAe;IACAmC;IACArD;IACA+G;IACAF;IACAL;IACAxD;IACAyD;IACA/H;IACAqC;IACAmF;AACF,EAAC"}
@@ -86,6 +86,11 @@ export type UploadConfig = {
86
86
  * - A function that generates a fully qualified URL for the thumbnail, receives the doc as the only argument.
87
87
  **/
88
88
  adminThumbnail?: GetAdminThumbnail | string;
89
+ /**
90
+ * Enables bulk upload of files from the list view.
91
+ * @default true
92
+ */
93
+ bulkUpload?: boolean;
89
94
  /**
90
95
  * Enables cropping of images.
91
96
  * @default true
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/uploads/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,KAAK,EAA6B,MAAM,OAAO,CAAA;AAE5E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAEjE,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,EAAE,IAAI,GAAG,MAAM,CAAA;IACvB,QAAQ,EAAE,IAAI,GAAG,MAAM,CAAA;IACvB,MAAM,EAAE,IAAI,GAAG,MAAM,CAAA;IACrB,QAAQ,EAAE,IAAI,GAAG,MAAM,CAAA;IACvB,KAAK,EAAE,IAAI,GAAG,MAAM,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,SAAS,CAAA;IAChB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,MAAM,EAAE,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,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,KAAK,IAAI,GAAG;IACV,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,GAAG,GAAG,IAAI,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV,CAAA;AAED,KAAK,UAAU,GAAG;IAChB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/uploads/types.ts"],"sourcesContent":["import type { ResizeOptions, Sharp, Metadata as SharpMetadata } from 'sharp'\n\nimport type { TypeWithID } from '../collections/config/types.js'\nimport type { PayloadRequest } from '../types/index.js'\nimport type { WithMetadata } from './optionallyAppendMetadata.js'\n\nexport type FileSize = {\n filename: null | string\n filesize: null | number\n height: null | number\n mimeType: null | string\n width: null | number\n}\n\nexport type FileSizes = {\n [size: string]: FileSize\n}\n\nexport type FileData = {\n filename: string\n filesize: number\n focalX?: number\n focalY?: number\n height: number\n mimeType: string\n sizes: FileSizes\n tempFilePath?: string\n url?: string\n width: number\n}\n\nexport type ProbedImageSize = {\n height: number\n width: number\n}\n\n/**\n * Params sent to the sharp `toFormat()` function\n * @link https://sharp.pixelplumbing.com/api-output#toformat\n */\nexport type ImageUploadFormatOptions = {\n format: Parameters<Sharp['toFormat']>[0]\n options?: Parameters<Sharp['toFormat']>[1]\n}\n\n/**\n * Params sent to the sharp trim() function\n * @link https://sharp.pixelplumbing.com/api-resize#trim\n */\nexport type ImageUploadTrimOptions = Parameters<Sharp['trim']>[0]\n\nexport type GenerateImageName = (args: {\n extension: string\n height: number\n originalName: string\n sizeName: string\n width: number\n}) => string\n\nexport type ImageSize = {\n /**\n * @deprecated prefer position\n */\n crop?: string // comes from sharp package\n formatOptions?: ImageUploadFormatOptions\n /**\n * Generate a custom name for the file of this image size.\n */\n generateImageName?: GenerateImageName\n name: string\n trimOptions?: ImageUploadTrimOptions\n /**\n * When an uploaded image is smaller than the defined image size, we have 3 options:\n *\n * `undefined | false | true`\n *\n * 1. `undefined` [default]: uploading images with smaller width AND height than the image size will return null\n * 2. `false`: always enlarge images to the image size\n * 3. `true`: if the image is smaller than the image size, return the original image\n */\n withoutEnlargement?: ResizeOptions['withoutEnlargement']\n} & Omit<ResizeOptions, 'withoutEnlargement'>\n\nexport type GetAdminThumbnail = (args: { doc: Record<string, unknown> }) => false | null | string\n\nexport type UploadConfig = {\n /**\n * The adapter name to use for uploads. Used for storage adapter telemetry.\n * @default undefined\n */\n adapter?: string\n /**\n * Represents an admin thumbnail, which can be either a React component or a string.\n * - If a string, it should be one of the image size names.\n * - A function that generates a fully qualified URL for the thumbnail, receives the doc as the only argument.\n **/\n adminThumbnail?: GetAdminThumbnail | string\n /**\n * Enables cropping of images.\n * @default true\n */\n crop?: boolean\n /**\n * Disable the ability to save files to disk.\n * @default false\n */\n disableLocalStorage?: boolean\n /**\n * Enable displaying preview of the uploaded file in Upload fields related to this Collection.\n * Can be locally overridden by `displayPreview` option in Upload field.\n * @default false\n */\n displayPreview?: boolean\n /**\n * Ability to filter/modify Request Headers when fetching a file.\n *\n * Useful for adding custom headers to fetch from external providers.\n * @default undefined\n */\n externalFileHeaderFilter?: (headers: Record<string, string>) => Record<string, string>\n /**\n * Field slugs to use for a compount index instead of the default filename index.\n */\n filenameCompoundIndex?: string[]\n /**\n * Require files to be uploaded when creating a document.\n * @default true\n */\n filesRequiredOnCreate?: boolean\n /**\n * Enables focal point positioning for image manipulation.\n * @default false\n */\n focalPoint?: boolean\n /**\n * Format options for the uploaded file. Formatting image sizes needs to be done within each formatOptions individually.\n */\n formatOptions?: ImageUploadFormatOptions\n /**\n * Custom handlers to run when a file is fetched.\n *\n * - If a handler returns a Response, the response will be sent to the client and no further handlers will be run.\n * - If a handler returns null, the next handler will be run.\n * - If no handlers return a response the file will be returned by default.\n *\n * @default undefined\n */\n handlers?: ((\n req: PayloadRequest,\n args: {\n doc: TypeWithID\n params: { collection: string; filename: string }\n },\n ) => Promise<Response> | Promise<void> | Response | void)[]\n imageSizes?: ImageSize[]\n /**\n * Restrict mimeTypes in the file picker. Array of valid mime types or mimetype wildcards\n * @example ['image/*', 'application/pdf']\n * @default undefined\n */\n mimeTypes?: string[]\n /**\n * Ability to modify the response headers fetching a file.\n * @default undefined\n */\n modifyResponseHeaders?: ({ headers }: { headers: Headers }) => Headers\n /**\n * Sharp resize options for the original image.\n * @link https://sharp.pixelplumbing.com/api-resize#resize\n * @default undefined\n */\n resizeOptions?: ResizeOptions\n /**\n * The directory to serve static files from. Defaults to collection slug.\n * @default undefined\n */\n staticDir?: string\n trimOptions?: ImageUploadTrimOptions\n /**\n * Optionally append metadata to the image during processing.\n *\n * Can be a boolean or a function.\n *\n * If true, metadata will be appended to the image.\n * If false, no metadata will be appended.\n * If a function, it will receive an object containing the metadata and should return a boolean indicating whether to append the metadata.\n * @default false\n */\n withMetadata?: WithMetadata\n}\n\nexport type SanitizedUploadConfig = {\n staticDir: UploadConfig['staticDir']\n} & UploadConfig\n\nexport type File = {\n /**\n * The buffer of the file.\n */\n data: Buffer\n /**\n * The mimetype of the file.\n */\n mimetype: string\n /**\n * The name of the file.\n */\n name: string\n /**\n * The size of the file in bytes.\n */\n size: number\n}\n\nexport type FileToSave = {\n /**\n * The buffer of the file.\n */\n buffer: Buffer\n /**\n * The path to save the file.\n */\n path: string\n}\n\ntype Crop = {\n height: number\n unit: '%' | 'px'\n width: number\n x: number\n y: number\n}\n\ntype FocalPoint = {\n x: number\n y: number\n}\n\nexport type UploadEdits = {\n crop?: Crop\n focalPoint?: FocalPoint\n heightInPixels?: number\n widthInPixels?: number\n}\n"],"names":[],"mappings":"AA8OA,WAKC"}
1
+ {"version":3,"sources":["../../src/uploads/types.ts"],"sourcesContent":["import type { ResizeOptions, Sharp, Metadata as SharpMetadata } from 'sharp'\n\nimport type { TypeWithID } from '../collections/config/types.js'\nimport type { PayloadRequest } from '../types/index.js'\nimport type { WithMetadata } from './optionallyAppendMetadata.js'\n\nexport type FileSize = {\n filename: null | string\n filesize: null | number\n height: null | number\n mimeType: null | string\n width: null | number\n}\n\nexport type FileSizes = {\n [size: string]: FileSize\n}\n\nexport type FileData = {\n filename: string\n filesize: number\n focalX?: number\n focalY?: number\n height: number\n mimeType: string\n sizes: FileSizes\n tempFilePath?: string\n url?: string\n width: number\n}\n\nexport type ProbedImageSize = {\n height: number\n width: number\n}\n\n/**\n * Params sent to the sharp `toFormat()` function\n * @link https://sharp.pixelplumbing.com/api-output#toformat\n */\nexport type ImageUploadFormatOptions = {\n format: Parameters<Sharp['toFormat']>[0]\n options?: Parameters<Sharp['toFormat']>[1]\n}\n\n/**\n * Params sent to the sharp trim() function\n * @link https://sharp.pixelplumbing.com/api-resize#trim\n */\nexport type ImageUploadTrimOptions = Parameters<Sharp['trim']>[0]\n\nexport type GenerateImageName = (args: {\n extension: string\n height: number\n originalName: string\n sizeName: string\n width: number\n}) => string\n\nexport type ImageSize = {\n /**\n * @deprecated prefer position\n */\n crop?: string // comes from sharp package\n formatOptions?: ImageUploadFormatOptions\n /**\n * Generate a custom name for the file of this image size.\n */\n generateImageName?: GenerateImageName\n name: string\n trimOptions?: ImageUploadTrimOptions\n /**\n * When an uploaded image is smaller than the defined image size, we have 3 options:\n *\n * `undefined | false | true`\n *\n * 1. `undefined` [default]: uploading images with smaller width AND height than the image size will return null\n * 2. `false`: always enlarge images to the image size\n * 3. `true`: if the image is smaller than the image size, return the original image\n */\n withoutEnlargement?: ResizeOptions['withoutEnlargement']\n} & Omit<ResizeOptions, 'withoutEnlargement'>\n\nexport type GetAdminThumbnail = (args: { doc: Record<string, unknown> }) => false | null | string\n\nexport type UploadConfig = {\n /**\n * The adapter name to use for uploads. Used for storage adapter telemetry.\n * @default undefined\n */\n adapter?: string\n /**\n * Represents an admin thumbnail, which can be either a React component or a string.\n * - If a string, it should be one of the image size names.\n * - A function that generates a fully qualified URL for the thumbnail, receives the doc as the only argument.\n **/\n adminThumbnail?: GetAdminThumbnail | string\n /**\n * Enables bulk upload of files from the list view.\n * @default true\n */\n bulkUpload?: boolean\n /**\n * Enables cropping of images.\n * @default true\n */\n crop?: boolean\n /**\n * Disable the ability to save files to disk.\n * @default false\n */\n disableLocalStorage?: boolean\n /**\n * Enable displaying preview of the uploaded file in Upload fields related to this Collection.\n * Can be locally overridden by `displayPreview` option in Upload field.\n * @default false\n */\n displayPreview?: boolean\n /**\n * Ability to filter/modify Request Headers when fetching a file.\n *\n * Useful for adding custom headers to fetch from external providers.\n * @default undefined\n */\n externalFileHeaderFilter?: (headers: Record<string, string>) => Record<string, string>\n /**\n * Field slugs to use for a compount index instead of the default filename index.\n */\n filenameCompoundIndex?: string[]\n /**\n * Require files to be uploaded when creating a document.\n * @default true\n */\n filesRequiredOnCreate?: boolean\n /**\n * Enables focal point positioning for image manipulation.\n * @default false\n */\n focalPoint?: boolean\n /**\n * Format options for the uploaded file. Formatting image sizes needs to be done within each formatOptions individually.\n */\n formatOptions?: ImageUploadFormatOptions\n /**\n * Custom handlers to run when a file is fetched.\n *\n * - If a handler returns a Response, the response will be sent to the client and no further handlers will be run.\n * - If a handler returns null, the next handler will be run.\n * - If no handlers return a response the file will be returned by default.\n *\n * @default undefined\n */\n handlers?: ((\n req: PayloadRequest,\n args: {\n doc: TypeWithID\n params: { collection: string; filename: string }\n },\n ) => Promise<Response> | Promise<void> | Response | void)[]\n imageSizes?: ImageSize[]\n /**\n * Restrict mimeTypes in the file picker. Array of valid mime types or mimetype wildcards\n * @example ['image/*', 'application/pdf']\n * @default undefined\n */\n mimeTypes?: string[]\n /**\n * Ability to modify the response headers fetching a file.\n * @default undefined\n */\n modifyResponseHeaders?: ({ headers }: { headers: Headers }) => Headers\n /**\n * Sharp resize options for the original image.\n * @link https://sharp.pixelplumbing.com/api-resize#resize\n * @default undefined\n */\n resizeOptions?: ResizeOptions\n /**\n * The directory to serve static files from. Defaults to collection slug.\n * @default undefined\n */\n staticDir?: string\n trimOptions?: ImageUploadTrimOptions\n /**\n * Optionally append metadata to the image during processing.\n *\n * Can be a boolean or a function.\n *\n * If true, metadata will be appended to the image.\n * If false, no metadata will be appended.\n * If a function, it will receive an object containing the metadata and should return a boolean indicating whether to append the metadata.\n * @default false\n */\n withMetadata?: WithMetadata\n}\n\nexport type SanitizedUploadConfig = {\n staticDir: UploadConfig['staticDir']\n} & UploadConfig\n\nexport type File = {\n /**\n * The buffer of the file.\n */\n data: Buffer\n /**\n * The mimetype of the file.\n */\n mimetype: string\n /**\n * The name of the file.\n */\n name: string\n /**\n * The size of the file in bytes.\n */\n size: number\n}\n\nexport type FileToSave = {\n /**\n * The buffer of the file.\n */\n buffer: Buffer\n /**\n * The path to save the file.\n */\n path: string\n}\n\ntype Crop = {\n height: number\n unit: '%' | 'px'\n width: number\n x: number\n y: number\n}\n\ntype FocalPoint = {\n x: number\n y: number\n}\n\nexport type UploadEdits = {\n crop?: Crop\n focalPoint?: FocalPoint\n heightInPixels?: number\n widthInPixels?: number\n}\n"],"names":[],"mappings":"AAmPA,WAKC"}
@@ -1 +1 @@
1
- {"version":3,"file":"configToJSONSchema.d.ts","sourceRoot":"","sources":["../../src/utilities/configToJSONSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAMnE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAC/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,KAAK,EAAE,KAAK,EAA8B,MAAM,2BA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,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,KAAK,EAAE,KAAK,EAA8B,MAAM,2BAA2B,CAAA;AAClF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AA4HvE;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,mBAAmB,EAC9B,UAAU,EAAE,OAAO,GAClB,mBAAmB,GAAG,mBAAmB,EAAE,CAK7C;AAED,wBAAgB,kBAAkB;AAChC;;;;GAIG;AACH,sBAAsB,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAA;CAAE,EAC9D,MAAM,EAAE,KAAK,EAAE;AACf;;GAEG;AACH,wBAAwB,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,EAClD,MAAM,CAAC,EAAE,eAAe,GACvB;IACD,UAAU,EAAE;QACV,CAAC,CAAC,EAAE,MAAM,GAAG,WAAW,CAAA;KACzB,CAAA;IACD,QAAQ,EAAE,MAAM,EAAE,CAAA;CACnB,CA+XA;AAGD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,eAAe,EACvB,cAAc,EAAE,yBAAyB,GAAG,qBAAqB,EACjE,wBAAwB,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,EAClD,aAAa,EAAE,QAAQ,GAAG,MAAM,GAC/B,WAAW,CA8Cb;AAgHD,wBAAgB,oCAAoC,CAClD,MAAM,EAAE,yBAAyB,GAChC,WAAW,CA0Bb;AAoBD;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,eAAe,EACvB,aAAa,CAAC,EAAE,QAAQ,GAAG,MAAM,GAChC,WAAW,CAoDb"}
@@ -275,6 +275,7 @@ export function fieldsToJSONSchema(/**
275
275
  };
276
276
  break;
277
277
  }
278
+ case 'upload':
278
279
  case 'relationship':
279
280
  {
280
281
  if (Array.isArray(field.relationTo)) {
@@ -366,23 +367,6 @@ export function fieldsToJSONSchema(/**
366
367
  }
367
368
  break;
368
369
  }
369
- case 'upload':
370
- {
371
- fieldSchema = {
372
- oneOf: [
373
- {
374
- type: collectionIDFieldTypes[field.relationTo]
375
- },
376
- {
377
- $ref: `#/definitions/${field.relationTo}`
378
- }
379
- ]
380
- };
381
- if (!isRequired) fieldSchema.oneOf.push({
382
- type: 'null'
383
- });
384
- break;
385
- }
386
370
  case 'blocks':
387
371
  {
388
372
  // Check for a case where no blocks are provided.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/configToJSONSchema.ts"],"sourcesContent":["import type { JSONSchema4, JSONSchema4TypeName } from 'json-schema'\n\nimport pluralize from 'pluralize'\nconst { singular } = pluralize\n\nimport type { Auth } from '../auth/types.js'\nimport type { SanitizedCollectionConfig } from '../collections/config/types.js'\nimport type { SanitizedConfig } from '../config/types.js'\nimport type { Field, FieldAffectingData, Option } from '../fields/config/types.js'\nimport type { SanitizedGlobalConfig } from '../globals/config/types.js'\n\nimport { MissingEditorProp } from '../errors/MissingEditorProp.js'\nimport { fieldAffectsData, tabHasName } from '../fields/config/types.js'\nimport { deepCopyObject } from './deepCopyObject.js'\nimport { toWords } from './formatLabels.js'\nimport { getCollectionIDFieldTypes } from './getCollectionIDFieldTypes.js'\n\nconst fieldIsRequired = (field: Field) => {\n const isConditional = Boolean(field?.admin && field?.admin?.condition)\n if (isConditional) return false\n\n const isMarkedRequired = 'required' in field && field.required === true\n if (fieldAffectsData(field) && isMarkedRequired) return true\n\n // if any subfields are required, this field is required\n if ('fields' in field && field.type !== 'array') {\n return field.fields.some((subField) => fieldIsRequired(subField))\n }\n\n // if any tab subfields have required fields, this field is required\n if (field.type === 'tabs') {\n return field.tabs.some((tab) => {\n if ('name' in tab) {\n return tab.fields.some((subField) => fieldIsRequired(subField))\n }\n return false\n })\n }\n\n return false\n}\n\nfunction buildOptionEnums(options: Option[]): string[] {\n return options.map((option) => {\n if (typeof option === 'object' && 'value' in option) {\n return option.value\n }\n\n return option\n })\n}\n\nfunction generateEntitySchemas(\n entities: (SanitizedCollectionConfig | SanitizedGlobalConfig)[],\n): JSONSchema4 {\n const properties = [...entities].reduce((acc, { slug }) => {\n acc[slug] = {\n $ref: `#/definitions/${slug}`,\n }\n\n return acc\n }, {})\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n }\n}\n\nfunction generateLocaleEntitySchemas(localization: SanitizedConfig['localization']): JSONSchema4 {\n if (localization && 'locales' in localization && localization?.locales) {\n const localesFromConfig = localization?.locales\n\n const locales = [...localesFromConfig].map((locale) => {\n return locale.code\n }, [])\n\n return {\n type: 'string',\n enum: locales,\n }\n }\n\n return {\n type: 'null',\n }\n}\n\nfunction generateAuthEntitySchemas(entities: SanitizedCollectionConfig[]): JSONSchema4 {\n const properties: JSONSchema4[] = [...entities]\n .filter(({ auth }) => Boolean(auth))\n .map(({ slug }) => {\n return {\n allOf: [\n { $ref: `#/definitions/${slug}` },\n {\n type: 'object',\n additionalProperties: false,\n properties: {\n collection: { type: 'string', enum: [slug] },\n },\n required: ['collection'],\n },\n ],\n }\n }, {})\n\n return {\n oneOf: properties,\n }\n}\n\n/**\n * Generates the JSON Schema for database configuration\n *\n * @example { db: idType: string }\n */\nfunction generateDbEntitySchema(config: SanitizedConfig): JSONSchema4 {\n const defaultIDType: JSONSchema4 =\n config.db?.defaultIDType === 'number' ? { type: 'number' } : { type: 'string' }\n\n return {\n type: 'object',\n additionalProperties: false,\n properties: {\n defaultIDType,\n },\n required: ['defaultIDType'],\n }\n}\n\n/**\n * Returns a JSON Schema Type with 'null' added if the field is not required.\n */\nexport function withNullableJSONSchemaType(\n fieldType: JSONSchema4TypeName,\n isRequired: boolean,\n): JSONSchema4TypeName | JSONSchema4TypeName[] {\n const fieldTypes = [fieldType]\n if (isRequired) return fieldType\n fieldTypes.push('null')\n return fieldTypes\n}\n\nexport function fieldsToJSONSchema(\n /**\n * Used for relationship fields, to determine whether to use a string or number type for the ID.\n * While there is a default ID field type set by the db adapter, they can differ on a collection-level\n * if they have custom ID fields.\n */\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' },\n fields: Field[],\n /**\n * Allows you to define new top-level interfaces that can be re-used in the output schema.\n */\n interfaceNameDefinitions: Map<string, JSONSchema4>,\n config?: SanitizedConfig,\n): {\n properties: {\n [k: string]: JSONSchema4\n }\n required: string[]\n} {\n const requiredFieldNames = new Set<string>()\n\n return {\n properties: Object.fromEntries(\n fields.reduce((fieldSchemas, field) => {\n const isRequired = fieldAffectsData(field) && fieldIsRequired(field)\n if (isRequired) requiredFieldNames.add(field.name)\n\n let fieldSchema: JSONSchema4\n\n switch (field.type) {\n case 'text':\n if (field.hasMany === true) {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: { type: 'string' },\n }\n } else {\n fieldSchema = { type: withNullableJSONSchemaType('string', isRequired) }\n }\n break\n case 'textarea':\n case 'code':\n case 'email':\n case 'date': {\n fieldSchema = { type: withNullableJSONSchemaType('string', isRequired) }\n break\n }\n\n case 'number': {\n if (field.hasMany === true) {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: { type: 'number' },\n }\n } else {\n fieldSchema = { type: withNullableJSONSchemaType('number', isRequired) }\n }\n break\n }\n\n case 'checkbox': {\n fieldSchema = { type: withNullableJSONSchemaType('boolean', isRequired) }\n break\n }\n\n case 'json': {\n fieldSchema = field.jsonSchema?.schema || {\n type: ['object', 'array', 'string', 'number', 'boolean', 'null'],\n }\n break\n }\n\n case 'richText': {\n if (!field?.editor) {\n throw new MissingEditorProp(field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n if (typeof field.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n if (field.editor.outputSchema) {\n fieldSchema = field.editor.outputSchema({\n collectionIDFieldTypes,\n config,\n field,\n interfaceNameDefinitions,\n isRequired,\n })\n } else {\n // Maintain backwards compatibility with existing rich text editors\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'object',\n },\n }\n }\n\n break\n }\n\n case 'radio': {\n fieldSchema = {\n type: withNullableJSONSchemaType('string', isRequired),\n enum: buildOptionEnums(field.options),\n }\n\n break\n }\n\n case 'select': {\n const optionEnums = buildOptionEnums(field.options)\n\n if (field.hasMany) {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'string',\n enum: optionEnums,\n },\n }\n } else {\n fieldSchema = {\n type: withNullableJSONSchemaType('string', isRequired),\n enum: optionEnums,\n }\n }\n\n break\n }\n\n case 'point': {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: [\n {\n type: 'number',\n },\n {\n type: 'number',\n },\n ],\n maxItems: 2,\n minItems: 2,\n }\n break\n }\n\n case 'relationship': {\n if (Array.isArray(field.relationTo)) {\n if (field.hasMany) {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n oneOf: field.relationTo.map((relation) => {\n return {\n type: 'object',\n additionalProperties: false,\n properties: {\n relationTo: {\n const: relation,\n },\n value: {\n oneOf: [\n {\n type: collectionIDFieldTypes[relation],\n },\n {\n $ref: `#/definitions/${relation}`,\n },\n ],\n },\n },\n required: ['value', 'relationTo'],\n }\n }),\n },\n }\n } else {\n fieldSchema = {\n oneOf: field.relationTo.map((relation) => {\n return {\n type: withNullableJSONSchemaType('object', isRequired),\n additionalProperties: false,\n properties: {\n relationTo: {\n const: relation,\n },\n value: {\n oneOf: [\n {\n type: collectionIDFieldTypes[relation],\n },\n {\n $ref: `#/definitions/${relation}`,\n },\n ],\n },\n },\n required: ['value', 'relationTo'],\n }\n }),\n }\n }\n } else if (field.hasMany) {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n oneOf: [\n {\n type: collectionIDFieldTypes[field.relationTo],\n },\n {\n $ref: `#/definitions/${field.relationTo}`,\n },\n ],\n },\n }\n } else {\n fieldSchema = {\n oneOf: [\n {\n type: withNullableJSONSchemaType(\n collectionIDFieldTypes[field.relationTo],\n isRequired,\n ),\n },\n {\n $ref: `#/definitions/${field.relationTo}`,\n },\n ],\n }\n }\n\n break\n }\n\n case 'upload': {\n fieldSchema = {\n oneOf: [\n {\n type: collectionIDFieldTypes[field.relationTo],\n },\n {\n $ref: `#/definitions/${field.relationTo}`,\n },\n ],\n }\n if (!isRequired) fieldSchema.oneOf.push({ type: 'null' })\n break\n }\n\n case 'blocks': {\n // Check for a case where no blocks are provided.\n // We need to generate an empty array for this case, note that JSON schema 4 doesn't support empty arrays\n // so the best we can get is `unknown[]`\n const hasBlocks = Boolean(field.blocks.length)\n\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: hasBlocks\n ? {\n oneOf: field.blocks.map((block) => {\n const blockFieldSchemas = fieldsToJSONSchema(\n collectionIDFieldTypes,\n block.fields,\n interfaceNameDefinitions,\n config,\n )\n\n const blockSchema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n properties: {\n ...blockFieldSchemas.properties,\n blockType: {\n const: block.slug,\n },\n },\n required: ['blockType', ...blockFieldSchemas.required],\n }\n\n if (block.interfaceName) {\n interfaceNameDefinitions.set(block.interfaceName, blockSchema)\n\n return {\n $ref: `#/definitions/${block.interfaceName}`,\n }\n }\n\n return blockSchema\n }),\n }\n : {},\n }\n break\n }\n\n case 'array': {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'object',\n additionalProperties: false,\n ...fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.fields,\n interfaceNameDefinitions,\n config,\n ),\n },\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = {\n $ref: `#/definitions/${field.interfaceName}`,\n }\n }\n break\n }\n\n case 'row':\n case 'collapsible': {\n const childSchema = fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.fields,\n interfaceNameDefinitions,\n config,\n )\n Object.entries(childSchema.properties).forEach(([propName, propSchema]) => {\n fieldSchemas.set(propName, propSchema)\n })\n childSchema.required.forEach((propName) => {\n requiredFieldNames.add(propName)\n })\n break\n }\n\n case 'tabs': {\n field.tabs.forEach((tab) => {\n const childSchema = fieldsToJSONSchema(\n collectionIDFieldTypes,\n tab.fields,\n interfaceNameDefinitions,\n config,\n )\n if (tabHasName(tab)) {\n // could have interface\n fieldSchemas.set(tab.name, {\n type: 'object',\n additionalProperties: false,\n ...childSchema,\n })\n\n // If the named tab has any required fields then we mark this as required otherwise it should be optional\n const hasRequiredFields = tab.fields.some((subField) => fieldIsRequired(subField))\n\n if (hasRequiredFields) {\n requiredFieldNames.add(tab.name)\n }\n } else {\n Object.entries(childSchema.properties).forEach(([propName, propSchema]) => {\n fieldSchemas.set(propName, propSchema)\n })\n childSchema.required.forEach((propName) => {\n requiredFieldNames.add(propName)\n })\n }\n })\n break\n }\n\n case 'group': {\n fieldSchema = {\n type: 'object',\n additionalProperties: false,\n ...fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.fields,\n interfaceNameDefinitions,\n config,\n ),\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = {\n $ref: `#/definitions/${field.interfaceName}`,\n }\n }\n break\n }\n\n default: {\n break\n }\n }\n\n if ('typescriptSchema' in field && field?.typescriptSchema?.length) {\n for (const schema of field.typescriptSchema) {\n fieldSchema = schema({ jsonSchema: fieldSchema })\n }\n }\n\n if (fieldSchema && fieldAffectsData(field)) {\n fieldSchemas.set(field.name, fieldSchema)\n }\n\n return fieldSchemas\n }, new Map<string, JSONSchema4>()),\n ),\n required: Array.from(requiredFieldNames),\n }\n}\n\n// This function is part of the public API and is exported through payload/utilities\nexport function entityToJSONSchema(\n config: SanitizedConfig,\n incomingEntity: SanitizedCollectionConfig | SanitizedGlobalConfig,\n interfaceNameDefinitions: Map<string, JSONSchema4>,\n defaultIDType: 'number' | 'text',\n): JSONSchema4 {\n const entity: SanitizedCollectionConfig | SanitizedGlobalConfig = deepCopyObject(incomingEntity)\n const title = entity.typescript?.interface\n ? entity.typescript.interface\n : singular(toWords(entity.slug, true))\n\n const idField: FieldAffectingData = { name: 'id', type: defaultIDType as 'text', required: true }\n const customIdField = entity.fields.find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n ) as FieldAffectingData\n\n if (customIdField && customIdField.type !== 'group' && customIdField.type !== 'tab') {\n customIdField.required = true\n } else {\n entity.fields.unshift(idField)\n }\n\n // mark timestamp fields required\n if ('timestamps' in entity && entity.timestamps !== false) {\n entity.fields = entity.fields.map((field) => {\n if (fieldAffectsData(field) && (field.name === 'createdAt' || field.name === 'updatedAt')) {\n return {\n ...field,\n required: true,\n }\n }\n return field\n })\n }\n\n if ('auth' in entity && entity.auth && !entity.auth?.disableLocalStrategy) {\n entity.fields.push({\n name: 'password',\n type: 'text',\n })\n }\n\n // Used for relationship fields, to determine whether to use a string or number type for the ID.\n const collectionIDFieldTypes = getCollectionIDFieldTypes({ config, defaultIDType })\n\n return {\n type: 'object',\n additionalProperties: false,\n title,\n ...fieldsToJSONSchema(collectionIDFieldTypes, entity.fields, interfaceNameDefinitions, config),\n }\n}\n\nconst fieldType: JSONSchema4 = {\n type: 'string',\n required: false,\n}\nconst generateAuthFieldTypes = ({\n type,\n loginWithUsername,\n}: {\n loginWithUsername: Auth['loginWithUsername']\n type: 'forgotOrUnlock' | 'login' | 'register'\n}): JSONSchema4 => {\n if (loginWithUsername) {\n switch (type) {\n case 'login': {\n if (loginWithUsername.allowEmailLogin) {\n // allow username or email and require password for login\n return {\n additionalProperties: false,\n oneOf: [\n {\n additionalProperties: false,\n properties: { email: fieldType, password: fieldType },\n required: ['email', 'password'],\n },\n {\n additionalProperties: false,\n properties: { password: fieldType, username: fieldType },\n required: ['username', 'password'],\n },\n ],\n }\n } else {\n // allow only username and password for login\n return {\n additionalProperties: false,\n properties: {\n password: fieldType,\n username: fieldType,\n },\n required: ['username', 'password'],\n }\n }\n }\n\n case 'register': {\n const requiredFields: ('email' | 'password' | 'username')[] = ['password']\n const properties: {\n email?: JSONSchema4['properties']\n password?: JSONSchema4['properties']\n username?: JSONSchema4['properties']\n } = {\n password: fieldType,\n username: fieldType,\n }\n\n if (loginWithUsername.requireEmail) {\n requiredFields.push('email')\n }\n if (loginWithUsername.requireUsername) {\n requiredFields.push('username')\n }\n if (loginWithUsername.requireEmail || loginWithUsername.allowEmailLogin) {\n properties.email = fieldType\n }\n\n return {\n additionalProperties: false,\n properties,\n required: requiredFields,\n }\n }\n\n case 'forgotOrUnlock': {\n if (loginWithUsername.allowEmailLogin) {\n // allow email or username for unlock/forgot-password\n return {\n additionalProperties: false,\n oneOf: [\n {\n additionalProperties: false,\n properties: { email: fieldType },\n required: ['email'],\n },\n {\n additionalProperties: false,\n properties: { username: fieldType },\n required: ['username'],\n },\n ],\n }\n } else {\n // allow only username for unlock/forgot-password\n return {\n additionalProperties: false,\n properties: { username: fieldType },\n required: ['username'],\n }\n }\n }\n }\n }\n\n // default email (and password for login/register)\n return {\n additionalProperties: false,\n properties: { email: fieldType, password: fieldType },\n required: ['email', 'password'],\n }\n}\n\nexport function authCollectionToOperationsJSONSchema(\n config: SanitizedCollectionConfig,\n): JSONSchema4 {\n const loginWithUsername = config.auth?.loginWithUsername\n const loginUserFields: JSONSchema4 = generateAuthFieldTypes({ type: 'login', loginWithUsername })\n const forgotOrUnlockUserFields: JSONSchema4 = generateAuthFieldTypes({\n type: 'forgotOrUnlock',\n loginWithUsername,\n })\n const registerUserFields: JSONSchema4 = generateAuthFieldTypes({\n type: 'register',\n loginWithUsername,\n })\n\n const properties: JSONSchema4['properties'] = {\n forgotPassword: forgotOrUnlockUserFields,\n login: loginUserFields,\n registerFirstUser: registerUserFields,\n unlock: forgotOrUnlockUserFields,\n }\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n title: `${singular(toWords(`${config.slug}`, true))}AuthOperations`,\n }\n}\n\nfunction generateAuthOperationSchemas(collections: SanitizedCollectionConfig[]): JSONSchema4 {\n const properties = collections.reduce((acc, collection) => {\n if (collection.auth) {\n acc[collection.slug] = {\n $ref: `#/definitions/auth/${collection.slug}`,\n }\n }\n return acc\n }, {})\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n }\n}\n\n/**\n * This is used for generating the TypeScript types (payload-types.ts) with the payload generate:types command.\n */\nexport function configToJSONSchema(\n config: SanitizedConfig,\n defaultIDType?: 'number' | 'text',\n): JSONSchema4 {\n // a mutable Map to store custom top-level `interfaceName` types. Fields with an `interfaceName` property will be moved to the top-level definitions here\n const interfaceNameDefinitions: Map<string, JSONSchema4> = new Map()\n\n // Collections and Globals have to be moved to the top-level definitions as well. Reason: The top-level type will be the `Config` type - we don't want all collection and global\n // types to be inlined inside the `Config` type\n const entityDefinitions: { [k: string]: JSONSchema4 } = [\n ...config.globals,\n ...config.collections,\n ].reduce((acc, entity) => {\n acc[entity.slug] = entityToJSONSchema(config, entity, interfaceNameDefinitions, defaultIDType)\n return acc\n }, {})\n\n const authOperationDefinitions = [...config.collections]\n .filter(({ auth }) => Boolean(auth))\n .reduce(\n (acc, authCollection) => {\n acc.auth[authCollection.slug] = authCollectionToOperationsJSONSchema(authCollection)\n return acc\n },\n { auth: {} },\n )\n\n let jsonSchema: JSONSchema4 = {\n additionalProperties: false,\n definitions: {\n ...entityDefinitions,\n ...Object.fromEntries(interfaceNameDefinitions),\n ...authOperationDefinitions,\n },\n // These properties here will be very simple, as all the complexity is in the definitions. These are just the properties for the top-level `Config` type\n type: 'object',\n properties: {\n auth: generateAuthOperationSchemas(config.collections),\n collections: generateEntitySchemas(config.collections || []),\n db: generateDbEntitySchema(config),\n globals: generateEntitySchemas(config.globals || []),\n locale: generateLocaleEntitySchemas(config.localization),\n user: generateAuthEntitySchemas(config.collections),\n },\n required: ['user', 'locale', 'collections', 'globals', 'auth', 'db'],\n title: 'Config',\n }\n\n if (config?.typescript?.schema?.length) {\n for (const schema of config.typescript.schema) {\n jsonSchema = schema({ jsonSchema })\n }\n }\n\n return jsonSchema\n}\n"],"names":["pluralize","singular","MissingEditorProp","fieldAffectsData","tabHasName","deepCopyObject","toWords","getCollectionIDFieldTypes","fieldIsRequired","field","isConditional","Boolean","admin","condition","isMarkedRequired","required","type","fields","some","subField","tabs","tab","buildOptionEnums","options","map","option","value","generateEntitySchemas","entities","properties","reduce","acc","slug","$ref","additionalProperties","Object","keys","generateLocaleEntitySchemas","localization","locales","localesFromConfig","locale","code","enum","generateAuthEntitySchemas","filter","auth","allOf","collection","oneOf","generateDbEntitySchema","config","defaultIDType","db","withNullableJSONSchemaType","fieldType","isRequired","fieldTypes","push","fieldsToJSONSchema","collectionIDFieldTypes","interfaceNameDefinitions","requiredFieldNames","Set","fromEntries","fieldSchemas","add","name","fieldSchema","hasMany","items","jsonSchema","schema","editor","Error","outputSchema","optionEnums","maxItems","minItems","Array","isArray","relationTo","relation","const","hasBlocks","blocks","length","block","blockFieldSchemas","blockSchema","blockType","interfaceName","set","childSchema","entries","forEach","propName","propSchema","hasRequiredFields","typescriptSchema","Map","from","entityToJSONSchema","incomingEntity","entity","title","typescript","interface","idField","customIdField","find","unshift","timestamps","disableLocalStrategy","generateAuthFieldTypes","loginWithUsername","allowEmailLogin","email","password","username","requiredFields","requireEmail","requireUsername","authCollectionToOperationsJSONSchema","loginUserFields","forgotOrUnlockUserFields","registerUserFields","forgotPassword","login","registerFirstUser","unlock","generateAuthOperationSchemas","collections","configToJSONSchema","entityDefinitions","globals","authOperationDefinitions","authCollection","definitions","user"],"mappings":"AAEA,OAAOA,eAAe,YAAW;AACjC,MAAM,EAAEC,QAAQ,EAAE,GAAGD;AAQrB,SAASE,iBAAiB,QAAQ,iCAAgC;AAClE,SAASC,gBAAgB,EAAEC,UAAU,QAAQ,4BAA2B;AACxE,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,OAAO,QAAQ,oBAAmB;AAC3C,SAASC,yBAAyB,QAAQ,iCAAgC;AAE1E,MAAMC,kBAAkB,CAACC;IACvB,MAAMC,gBAAgBC,Q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AAOrB;IACT,GAAG,CAAC;IAEJ,MAAMyG,2BAA2B;WAAIrF,OAAOiF,WAAW;KAAC,CACrDvF,MAAM,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKnC,QAAQmC,OAC7BhB,MAAM,CACL,CAACC,KAAK0G;QACJ1G,IAAIe,IAAI,CAAC2F,eAAezG,IAAI,CAAC,GAAG2F,qCAAqCc;QACrE,OAAO1G;IACT,GACA;QAAEe,MAAM,CAAC;IAAE;IAGf,IAAIyB,aAA0B;QAC5BrC,sBAAsB;QACtBwG,aAAa;YACX,GAAGJ,iBAAiB;YACpB,GAAGnG,OAAO6B,WAAW,CAACH,yBAAyB;YAC/C,GAAG2E,wBAAwB;QAC7B;QACA,wJAAwJ;QACxJxH,MAAM;QACNa,YAAY;YACViB,MAAMqF,6BAA6BhF,OAAOiF,WAAW;YACrDA,aAAazG,sBAAsBwB,OAAOiF,WAAW,IAAI,EAAE;YAC3D/E,IAAIH,uBAAuBC;YAC3BoF,SAAS5G,sBAAsBwB,OAAOoF,OAAO,IAAI,EAAE;YACnD9F,QAAQJ,4BAA4Bc,OAAOb,YAAY;YACvDqG,MAAM/F,0BAA0BO,OAAOiF,WAAW;QACpD;QACArH,UAAU;YAAC;YAAQ;YAAU;YAAe;YAAW;YAAQ;SAAK;QACpE0F,OAAO;IACT;IAEA,IAAItD,QAAQuD,YAAYlC,QAAQc,QAAQ;QACtC,KAAK,MAAMd,UAAUrB,OAAOuD,UAAU,CAAClC,MAAM,CAAE;YAC7CD,aAAaC,OAAO;gBAAED;YAAW;QACnC;IACF;IAEA,OAAOA;AACT"}
1
+ {"version":3,"sources":["../../src/utilities/configToJSONSchema.ts"],"sourcesContent":["import type { JSONSchema4, JSONSchema4TypeName } from 'json-schema'\n\nimport pluralize from 'pluralize'\nconst { singular } = pluralize\n\nimport type { Auth } from '../auth/types.js'\nimport type { SanitizedCollectionConfig } from '../collections/config/types.js'\nimport type { SanitizedConfig } from '../config/types.js'\nimport type { Field, FieldAffectingData, Option } from '../fields/config/types.js'\nimport type { SanitizedGlobalConfig } from '../globals/config/types.js'\n\nimport { MissingEditorProp } from '../errors/MissingEditorProp.js'\nimport { fieldAffectsData, tabHasName } from '../fields/config/types.js'\nimport { deepCopyObject } from './deepCopyObject.js'\nimport { toWords } from './formatLabels.js'\nimport { getCollectionIDFieldTypes } from './getCollectionIDFieldTypes.js'\n\nconst fieldIsRequired = (field: Field) => {\n const isConditional = Boolean(field?.admin && field?.admin?.condition)\n if (isConditional) return false\n\n const isMarkedRequired = 'required' in field && field.required === true\n if (fieldAffectsData(field) && isMarkedRequired) return true\n\n // if any subfields are required, this field is required\n if ('fields' in field && field.type !== 'array') {\n return field.fields.some((subField) => fieldIsRequired(subField))\n }\n\n // if any tab subfields have required fields, this field is required\n if (field.type === 'tabs') {\n return field.tabs.some((tab) => {\n if ('name' in tab) {\n return tab.fields.some((subField) => fieldIsRequired(subField))\n }\n return false\n })\n }\n\n return false\n}\n\nfunction buildOptionEnums(options: Option[]): string[] {\n return options.map((option) => {\n if (typeof option === 'object' && 'value' in option) {\n return option.value\n }\n\n return option\n })\n}\n\nfunction generateEntitySchemas(\n entities: (SanitizedCollectionConfig | SanitizedGlobalConfig)[],\n): JSONSchema4 {\n const properties = [...entities].reduce((acc, { slug }) => {\n acc[slug] = {\n $ref: `#/definitions/${slug}`,\n }\n\n return acc\n }, {})\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n }\n}\n\nfunction generateLocaleEntitySchemas(localization: SanitizedConfig['localization']): JSONSchema4 {\n if (localization && 'locales' in localization && localization?.locales) {\n const localesFromConfig = localization?.locales\n\n const locales = [...localesFromConfig].map((locale) => {\n return locale.code\n }, [])\n\n return {\n type: 'string',\n enum: locales,\n }\n }\n\n return {\n type: 'null',\n }\n}\n\nfunction generateAuthEntitySchemas(entities: SanitizedCollectionConfig[]): JSONSchema4 {\n const properties: JSONSchema4[] = [...entities]\n .filter(({ auth }) => Boolean(auth))\n .map(({ slug }) => {\n return {\n allOf: [\n { $ref: `#/definitions/${slug}` },\n {\n type: 'object',\n additionalProperties: false,\n properties: {\n collection: { type: 'string', enum: [slug] },\n },\n required: ['collection'],\n },\n ],\n }\n }, {})\n\n return {\n oneOf: properties,\n }\n}\n\n/**\n * Generates the JSON Schema for database configuration\n *\n * @example { db: idType: string }\n */\nfunction generateDbEntitySchema(config: SanitizedConfig): JSONSchema4 {\n const defaultIDType: JSONSchema4 =\n config.db?.defaultIDType === 'number' ? { type: 'number' } : { type: 'string' }\n\n return {\n type: 'object',\n additionalProperties: false,\n properties: {\n defaultIDType,\n },\n required: ['defaultIDType'],\n }\n}\n\n/**\n * Returns a JSON Schema Type with 'null' added if the field is not required.\n */\nexport function withNullableJSONSchemaType(\n fieldType: JSONSchema4TypeName,\n isRequired: boolean,\n): JSONSchema4TypeName | JSONSchema4TypeName[] {\n const fieldTypes = [fieldType]\n if (isRequired) return fieldType\n fieldTypes.push('null')\n return fieldTypes\n}\n\nexport function fieldsToJSONSchema(\n /**\n * Used for relationship fields, to determine whether to use a string or number type for the ID.\n * While there is a default ID field type set by the db adapter, they can differ on a collection-level\n * if they have custom ID fields.\n */\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' },\n fields: Field[],\n /**\n * Allows you to define new top-level interfaces that can be re-used in the output schema.\n */\n interfaceNameDefinitions: Map<string, JSONSchema4>,\n config?: SanitizedConfig,\n): {\n properties: {\n [k: string]: JSONSchema4\n }\n required: string[]\n} {\n const requiredFieldNames = new Set<string>()\n\n return {\n properties: Object.fromEntries(\n fields.reduce((fieldSchemas, field) => {\n const isRequired = fieldAffectsData(field) && fieldIsRequired(field)\n if (isRequired) requiredFieldNames.add(field.name)\n\n let fieldSchema: JSONSchema4\n\n switch (field.type) {\n case 'text':\n if (field.hasMany === true) {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: { type: 'string' },\n }\n } else {\n fieldSchema = { type: withNullableJSONSchemaType('string', isRequired) }\n }\n break\n case 'textarea':\n case 'code':\n case 'email':\n case 'date': {\n fieldSchema = { type: withNullableJSONSchemaType('string', isRequired) }\n break\n }\n\n case 'number': {\n if (field.hasMany === true) {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: { type: 'number' },\n }\n } else {\n fieldSchema = { type: withNullableJSONSchemaType('number', isRequired) }\n }\n break\n }\n\n case 'checkbox': {\n fieldSchema = { type: withNullableJSONSchemaType('boolean', isRequired) }\n break\n }\n\n case 'json': {\n fieldSchema = field.jsonSchema?.schema || {\n type: ['object', 'array', 'string', 'number', 'boolean', 'null'],\n }\n break\n }\n\n case 'richText': {\n if (!field?.editor) {\n throw new MissingEditorProp(field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n if (typeof field.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n if (field.editor.outputSchema) {\n fieldSchema = field.editor.outputSchema({\n collectionIDFieldTypes,\n config,\n field,\n interfaceNameDefinitions,\n isRequired,\n })\n } else {\n // Maintain backwards compatibility with existing rich text editors\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'object',\n },\n }\n }\n\n break\n }\n\n case 'radio': {\n fieldSchema = {\n type: withNullableJSONSchemaType('string', isRequired),\n enum: buildOptionEnums(field.options),\n }\n\n break\n }\n\n case 'select': {\n const optionEnums = buildOptionEnums(field.options)\n\n if (field.hasMany) {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'string',\n enum: optionEnums,\n },\n }\n } else {\n fieldSchema = {\n type: withNullableJSONSchemaType('string', isRequired),\n enum: optionEnums,\n }\n }\n\n break\n }\n\n case 'point': {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: [\n {\n type: 'number',\n },\n {\n type: 'number',\n },\n ],\n maxItems: 2,\n minItems: 2,\n }\n break\n }\n\n case 'upload':\n case 'relationship': {\n if (Array.isArray(field.relationTo)) {\n if (field.hasMany) {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n oneOf: field.relationTo.map((relation) => {\n return {\n type: 'object',\n additionalProperties: false,\n properties: {\n relationTo: {\n const: relation,\n },\n value: {\n oneOf: [\n {\n type: collectionIDFieldTypes[relation],\n },\n {\n $ref: `#/definitions/${relation}`,\n },\n ],\n },\n },\n required: ['value', 'relationTo'],\n }\n }),\n },\n }\n } else {\n fieldSchema = {\n oneOf: field.relationTo.map((relation) => {\n return {\n type: withNullableJSONSchemaType('object', isRequired),\n additionalProperties: false,\n properties: {\n relationTo: {\n const: relation,\n },\n value: {\n oneOf: [\n {\n type: collectionIDFieldTypes[relation],\n },\n {\n $ref: `#/definitions/${relation}`,\n },\n ],\n },\n },\n required: ['value', 'relationTo'],\n }\n }),\n }\n }\n } else if (field.hasMany) {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n oneOf: [\n {\n type: collectionIDFieldTypes[field.relationTo],\n },\n {\n $ref: `#/definitions/${field.relationTo}`,\n },\n ],\n },\n }\n } else {\n fieldSchema = {\n oneOf: [\n {\n type: withNullableJSONSchemaType(\n collectionIDFieldTypes[field.relationTo],\n isRequired,\n ),\n },\n {\n $ref: `#/definitions/${field.relationTo}`,\n },\n ],\n }\n }\n\n break\n }\n\n case 'blocks': {\n // Check for a case where no blocks are provided.\n // We need to generate an empty array for this case, note that JSON schema 4 doesn't support empty arrays\n // so the best we can get is `unknown[]`\n const hasBlocks = Boolean(field.blocks.length)\n\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: hasBlocks\n ? {\n oneOf: field.blocks.map((block) => {\n const blockFieldSchemas = fieldsToJSONSchema(\n collectionIDFieldTypes,\n block.fields,\n interfaceNameDefinitions,\n config,\n )\n\n const blockSchema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n properties: {\n ...blockFieldSchemas.properties,\n blockType: {\n const: block.slug,\n },\n },\n required: ['blockType', ...blockFieldSchemas.required],\n }\n\n if (block.interfaceName) {\n interfaceNameDefinitions.set(block.interfaceName, blockSchema)\n\n return {\n $ref: `#/definitions/${block.interfaceName}`,\n }\n }\n\n return blockSchema\n }),\n }\n : {},\n }\n break\n }\n\n case 'array': {\n fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'object',\n additionalProperties: false,\n ...fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.fields,\n interfaceNameDefinitions,\n config,\n ),\n },\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = {\n $ref: `#/definitions/${field.interfaceName}`,\n }\n }\n break\n }\n\n case 'row':\n case 'collapsible': {\n const childSchema = fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.fields,\n interfaceNameDefinitions,\n config,\n )\n Object.entries(childSchema.properties).forEach(([propName, propSchema]) => {\n fieldSchemas.set(propName, propSchema)\n })\n childSchema.required.forEach((propName) => {\n requiredFieldNames.add(propName)\n })\n break\n }\n\n case 'tabs': {\n field.tabs.forEach((tab) => {\n const childSchema = fieldsToJSONSchema(\n collectionIDFieldTypes,\n tab.fields,\n interfaceNameDefinitions,\n config,\n )\n if (tabHasName(tab)) {\n // could have interface\n fieldSchemas.set(tab.name, {\n type: 'object',\n additionalProperties: false,\n ...childSchema,\n })\n\n // If the named tab has any required fields then we mark this as required otherwise it should be optional\n const hasRequiredFields = tab.fields.some((subField) => fieldIsRequired(subField))\n\n if (hasRequiredFields) {\n requiredFieldNames.add(tab.name)\n }\n } else {\n Object.entries(childSchema.properties).forEach(([propName, propSchema]) => {\n fieldSchemas.set(propName, propSchema)\n })\n childSchema.required.forEach((propName) => {\n requiredFieldNames.add(propName)\n })\n }\n })\n break\n }\n\n case 'group': {\n fieldSchema = {\n type: 'object',\n additionalProperties: false,\n ...fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.fields,\n interfaceNameDefinitions,\n config,\n ),\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = {\n $ref: `#/definitions/${field.interfaceName}`,\n }\n }\n break\n }\n\n default: {\n break\n }\n }\n\n if ('typescriptSchema' in field && field?.typescriptSchema?.length) {\n for (const schema of field.typescriptSchema) {\n fieldSchema = schema({ jsonSchema: fieldSchema })\n }\n }\n\n if (fieldSchema && fieldAffectsData(field)) {\n fieldSchemas.set(field.name, fieldSchema)\n }\n\n return fieldSchemas\n }, new Map<string, JSONSchema4>()),\n ),\n required: Array.from(requiredFieldNames),\n }\n}\n\n// This function is part of the public API and is exported through payload/utilities\nexport function entityToJSONSchema(\n config: SanitizedConfig,\n incomingEntity: SanitizedCollectionConfig | SanitizedGlobalConfig,\n interfaceNameDefinitions: Map<string, JSONSchema4>,\n defaultIDType: 'number' | 'text',\n): JSONSchema4 {\n const entity: SanitizedCollectionConfig | SanitizedGlobalConfig = deepCopyObject(incomingEntity)\n const title = entity.typescript?.interface\n ? entity.typescript.interface\n : singular(toWords(entity.slug, true))\n\n const idField: FieldAffectingData = { name: 'id', type: defaultIDType as 'text', required: true }\n const customIdField = entity.fields.find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n ) as FieldAffectingData\n\n if (customIdField && customIdField.type !== 'group' && customIdField.type !== 'tab') {\n customIdField.required = true\n } else {\n entity.fields.unshift(idField)\n }\n\n // mark timestamp fields required\n if ('timestamps' in entity && entity.timestamps !== false) {\n entity.fields = entity.fields.map((field) => {\n if (fieldAffectsData(field) && (field.name === 'createdAt' || field.name === 'updatedAt')) {\n return {\n ...field,\n required: true,\n }\n }\n return field\n })\n }\n\n if ('auth' in entity && entity.auth && !entity.auth?.disableLocalStrategy) {\n entity.fields.push({\n name: 'password',\n type: 'text',\n })\n }\n\n // Used for relationship fields, to determine whether to use a string or number type for the ID.\n const collectionIDFieldTypes = getCollectionIDFieldTypes({ config, defaultIDType })\n\n return {\n type: 'object',\n additionalProperties: false,\n title,\n ...fieldsToJSONSchema(collectionIDFieldTypes, entity.fields, interfaceNameDefinitions, config),\n }\n}\n\nconst fieldType: JSONSchema4 = {\n type: 'string',\n required: false,\n}\nconst generateAuthFieldTypes = ({\n type,\n loginWithUsername,\n}: {\n loginWithUsername: Auth['loginWithUsername']\n type: 'forgotOrUnlock' | 'login' | 'register'\n}): JSONSchema4 => {\n if (loginWithUsername) {\n switch (type) {\n case 'login': {\n if (loginWithUsername.allowEmailLogin) {\n // allow username or email and require password for login\n return {\n additionalProperties: false,\n oneOf: [\n {\n additionalProperties: false,\n properties: { email: fieldType, password: fieldType },\n required: ['email', 'password'],\n },\n {\n additionalProperties: false,\n properties: { password: fieldType, username: fieldType },\n required: ['username', 'password'],\n },\n ],\n }\n } else {\n // allow only username and password for login\n return {\n additionalProperties: false,\n properties: {\n password: fieldType,\n username: fieldType,\n },\n required: ['username', 'password'],\n }\n }\n }\n\n case 'register': {\n const requiredFields: ('email' | 'password' | 'username')[] = ['password']\n const properties: {\n email?: JSONSchema4['properties']\n password?: JSONSchema4['properties']\n username?: JSONSchema4['properties']\n } = {\n password: fieldType,\n username: fieldType,\n }\n\n if (loginWithUsername.requireEmail) {\n requiredFields.push('email')\n }\n if (loginWithUsername.requireUsername) {\n requiredFields.push('username')\n }\n if (loginWithUsername.requireEmail || loginWithUsername.allowEmailLogin) {\n properties.email = fieldType\n }\n\n return {\n additionalProperties: false,\n properties,\n required: requiredFields,\n }\n }\n\n case 'forgotOrUnlock': {\n if (loginWithUsername.allowEmailLogin) {\n // allow email or username for unlock/forgot-password\n return {\n additionalProperties: false,\n oneOf: [\n {\n additionalProperties: false,\n properties: { email: fieldType },\n required: ['email'],\n },\n {\n additionalProperties: false,\n properties: { username: fieldType },\n required: ['username'],\n },\n ],\n }\n } else {\n // allow only username for unlock/forgot-password\n return {\n additionalProperties: false,\n properties: { username: fieldType },\n required: ['username'],\n }\n }\n }\n }\n }\n\n // default email (and password for login/register)\n return {\n additionalProperties: false,\n properties: { email: fieldType, password: fieldType },\n required: ['email', 'password'],\n }\n}\n\nexport function authCollectionToOperationsJSONSchema(\n config: SanitizedCollectionConfig,\n): JSONSchema4 {\n const loginWithUsername = config.auth?.loginWithUsername\n const loginUserFields: JSONSchema4 = generateAuthFieldTypes({ type: 'login', loginWithUsername })\n const forgotOrUnlockUserFields: JSONSchema4 = generateAuthFieldTypes({\n type: 'forgotOrUnlock',\n loginWithUsername,\n })\n const registerUserFields: JSONSchema4 = generateAuthFieldTypes({\n type: 'register',\n loginWithUsername,\n })\n\n const properties: JSONSchema4['properties'] = {\n forgotPassword: forgotOrUnlockUserFields,\n login: loginUserFields,\n registerFirstUser: registerUserFields,\n unlock: forgotOrUnlockUserFields,\n }\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n title: `${singular(toWords(`${config.slug}`, true))}AuthOperations`,\n }\n}\n\nfunction generateAuthOperationSchemas(collections: SanitizedCollectionConfig[]): JSONSchema4 {\n const properties = collections.reduce((acc, collection) => {\n if (collection.auth) {\n acc[collection.slug] = {\n $ref: `#/definitions/auth/${collection.slug}`,\n }\n }\n return acc\n }, {})\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n }\n}\n\n/**\n * This is used for generating the TypeScript types (payload-types.ts) with the payload generate:types command.\n */\nexport function configToJSONSchema(\n config: SanitizedConfig,\n defaultIDType?: 'number' | 'text',\n): JSONSchema4 {\n // a mutable Map to store custom top-level `interfaceName` types. Fields with an `interfaceName` property will be moved to the top-level definitions here\n const interfaceNameDefinitions: Map<string, JSONSchema4> = new Map()\n\n // Collections and Globals have to be moved to the top-level definitions as well. Reason: The top-level type will be the `Config` type - we don't want all collection and global\n // types to be inlined inside the `Config` type\n const entityDefinitions: { [k: string]: JSONSchema4 } = [\n ...config.globals,\n ...config.collections,\n ].reduce((acc, entity) => {\n acc[entity.slug] = entityToJSONSchema(config, entity, interfaceNameDefinitions, defaultIDType)\n return acc\n }, {})\n\n const authOperationDefinitions = [...config.collections]\n .filter(({ auth }) => Boolean(auth))\n .reduce(\n (acc, authCollection) => {\n acc.auth[authCollection.slug] = authCollectionToOperationsJSONSchema(authCollection)\n return acc\n },\n { auth: {} },\n )\n\n let jsonSchema: JSONSchema4 = {\n additionalProperties: false,\n definitions: {\n ...entityDefinitions,\n ...Object.fromEntries(interfaceNameDefinitions),\n ...authOperationDefinitions,\n },\n // These properties here will be very simple, as all the complexity is in the definitions. These are just the properties for the top-level `Config` type\n type: 'object',\n properties: {\n auth: generateAuthOperationSchemas(config.collections),\n collections: generateEntitySchemas(config.collections || []),\n db: generateDbEntitySchema(config),\n globals: generateEntitySchemas(config.globals || []),\n locale: generateLocaleEntitySchemas(config.localization),\n user: generateAuthEntitySchemas(config.collections),\n },\n required: ['user', 'locale', 'collections', 'globals', 'auth', 'db'],\n title: 'Config',\n }\n\n if (config?.typescript?.schema?.length) {\n for (const schema of config.typescript.schema) {\n jsonSchema = schema({ jsonSchema })\n }\n }\n\n return jsonSchema\n}\n"],"names":["pluralize","singular","MissingEditorProp","fieldAffectsData","tabHasName","deepCopyObject","toWords","getCollectionIDFieldTypes","fieldIsRequired","field","isConditional","Boolean","admin","condition","isMarkedRequired","required","type","fields","some","subField","tabs","tab","buildOptionEnums","options","map","option","value","generateEntitySchemas","entities","properties","reduce","acc","slug","$ref","additionalProperties","Object","keys","generateLocaleEntitySchemas","localization","locales","localesFromConfig","locale","code","enum","generateAuthEntitySchemas","filter","auth","allOf","collection","oneOf","generateDbEntitySchema","config","defaultIDType","db","withNullableJSONSchemaType","fieldType","isRequired","fieldTypes","push","fieldsToJSONSchema","collectionIDFieldTypes","interfaceNameDefinitions","requiredFieldNames","Set","fromEntries","fieldSchemas","add","name","fieldSchema","hasMany","items","jsonSchema","schema","editor","Error","outputSchema","optionEnums","maxItems","minItems","Array","isArray","relationTo","relation","const","hasBlocks","blocks","length","block","blockFieldSchemas","blockSchema","blockType","interfaceName","set","childSchema","entries","forEach","propName","propSchema","hasRequiredFields","typescriptSchema","Map","from","entityToJSONSchema","incomingEntity","entity","title","typescript","interface","idField","customIdField","find","unshift","timestamps","disableLocalStrategy","generateAuthFieldTypes","loginWithUsername","allowEmailLogin","email","password","username","requiredFields","requireEmail","requireUsername","authCollectionToOperationsJSONSchema","loginUserFields","forgotOrUnlockUserFields","registerUserFields","forgotPassword","login","registerFirstUser","unlock","generateAuthOperationSchemas","collections","configToJSONSchema","entityDefinitions","globals","authOperationDefinitions","authCollection","definitions","user"],"mappings":"AAEA,OAAOA,eAAe,YAAW;AACjC,MAAM,EAAEC,QAAQ,EAAE,GAAGD;AAQrB,SAASE,iBAAiB,QAAQ,iCAAgC;AAClE,SAASC,gBAAgB,EAAEC,UAAU,QAAQ,4BAA2B;AACxE,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,OAAO,QAAQ,oBAAmB;AAC3C,SAASC,yBAAyB,QAAQ,iCAAgC;AAE1E,MAAMC,kBAAkB,CAACC;IACvB,MAAMC,gBAAgBC,QAAQF,OAAOG,SAASH,OAAOG,OAAOC;IAC5D,IAAIH,eAAe,OAAO;IAE1B,MAAMI,mBAAmB,cAAcL,SAASA,MAAMM,QAAQ,KAAK;IACnE,IAAIZ,iBAAiBM,UAAUK,kBAAkB,OAAO;IAExD,wDAAwD;IACxD,IAAI,YAAYL,SAASA,MAAMO,IAAI,KAAK,SAAS;QAC/C,OAAOP,MAAMQ,MAAM,CAACC,IAAI,CAAC,CAACC,WAAaX,gBAAgBW;IACzD;IAEA,oEAAoE;IACpE,IAAIV,MAAMO,IAAI,KAAK,QAAQ;QACzB,OAAOP,MAAMW,IAAI,CAACF,IAAI,CAAC,CAACG;YACtB,IAAI,UAAUA,KAAK;gBACjB,OAAOA,IAAIJ,MAAM,CAACC,IAAI,CAAC,CAACC,WAAaX,gBAAgBW;YACvD;YACA,OAAO;QACT;IACF;IAEA,OAAO;AACT;AAEA,SAASG,iBAAiBC,OAAiB;IACzC,OAAOA,QAAQC,GAAG,CAAC,CAACC;QAClB,IAAI,OAAOA,WAAW,YAAY,WAAWA,QAAQ;YACnD,OAAOA,OAAOC,KA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ACF;IAEA,OAAOA;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payload",
3
- "version": "3.0.0-beta.88",
3
+ "version": "3.0.0-beta.89",
4
4
  "description": "Node, React, Headless CMS and Application Framework built on Next.js",
5
5
  "keywords": [
6
6
  "admin panel",
@@ -95,7 +95,7 @@
95
95
  "ts-essentials": "7.0.3",
96
96
  "tsx": "4.17.0",
97
97
  "uuid": "10.0.0",
98
- "@payloadcms/translations": "3.0.0-beta.88"
98
+ "@payloadcms/translations": "3.0.0-beta.89"
99
99
  },
100
100
  "devDependencies": {
101
101
  "@hyrious/esbuild-plugin-commonjs": "^0.2.4",