payload 3.0.0-alpha.65 → 3.0.0-alpha.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/RichText.d.ts +3 -0
- package/dist/admin/RichText.d.ts.map +1 -1
- package/dist/admin/RichText.js.map +1 -1
- package/dist/admin/elements/Tab.d.ts +3 -0
- package/dist/admin/elements/Tab.d.ts.map +1 -1
- package/dist/admin/elements/Tab.js.map +1 -1
- package/dist/admin/types.d.ts +1 -1
- package/dist/admin/types.d.ts.map +1 -1
- package/dist/admin/types.js.map +1 -1
- package/dist/auth/getAccessResults.js +1 -1
- package/dist/auth/getAccessResults.js.map +1 -1
- package/dist/auth/operations/forgotPassword.js +3 -2
- package/dist/auth/operations/forgotPassword.js.map +1 -1
- package/dist/auth/sendVerificationEmail.js +3 -2
- package/dist/auth/sendVerificationEmail.js.map +1 -1
- package/dist/bin/loader/index.d.ts.map +1 -1
- package/dist/bin/loader/index.js +2 -1
- package/dist/bin/loader/index.js.map +1 -1
- package/dist/bin/loader/resolveOriginalPath.d.ts +10 -0
- package/dist/bin/loader/resolveOriginalPath.d.ts.map +1 -0
- package/dist/bin/loader/resolveOriginalPath.js +32 -0
- package/dist/bin/loader/resolveOriginalPath.js.map +1 -0
- package/dist/collections/config/sanitize.d.ts +2 -3
- package/dist/collections/config/sanitize.d.ts.map +1 -1
- package/dist/collections/config/sanitize.js +7 -4
- package/dist/collections/config/sanitize.js.map +1 -1
- package/dist/collections/config/schema.d.ts.map +1 -1
- package/dist/collections/config/schema.js +1 -0
- package/dist/collections/config/schema.js.map +1 -1
- package/dist/config/build.d.ts.map +1 -1
- package/dist/config/build.js +3 -4
- package/dist/config/build.js.map +1 -1
- package/dist/config/sanitize.d.ts +1 -1
- package/dist/config/sanitize.d.ts.map +1 -1
- package/dist/config/sanitize.js +28 -7
- package/dist/config/sanitize.js.map +1 -1
- package/dist/config/schema.js +1 -1
- package/dist/config/schema.js.map +1 -1
- package/dist/config/types.d.ts +11 -2
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js.map +1 -1
- package/dist/database/queryValidation/validateQueryPaths.js +1 -1
- package/dist/database/queryValidation/validateQueryPaths.js.map +1 -1
- package/dist/email/consoleEmailAdapter.d.ts.map +1 -1
- package/dist/email/consoleEmailAdapter.js +1 -0
- package/dist/email/consoleEmailAdapter.js.map +1 -1
- package/dist/email/types.d.ts +1 -0
- package/dist/email/types.d.ts.map +1 -1
- package/dist/email/types.js.map +1 -1
- package/dist/errors/APIError.d.ts +2 -2
- package/dist/errors/APIError.d.ts.map +1 -1
- package/dist/errors/APIError.js +1 -2
- package/dist/errors/APIError.js.map +1 -1
- package/dist/errors/AuthenticationError.d.ts +2 -3
- package/dist/errors/AuthenticationError.d.ts.map +1 -1
- package/dist/errors/AuthenticationError.js +2 -3
- package/dist/errors/AuthenticationError.js.map +1 -1
- package/dist/errors/DuplicateCollection.d.ts +2 -3
- package/dist/errors/DuplicateCollection.d.ts.map +1 -1
- package/dist/errors/DuplicateCollection.js +2 -3
- package/dist/errors/DuplicateCollection.js.map +1 -1
- package/dist/errors/DuplicateFieldName.d.ts +2 -3
- package/dist/errors/DuplicateFieldName.d.ts.map +1 -1
- package/dist/errors/DuplicateFieldName.js +2 -3
- package/dist/errors/DuplicateFieldName.js.map +1 -1
- package/dist/errors/DuplicateGlobal.d.ts +2 -3
- package/dist/errors/DuplicateGlobal.d.ts.map +1 -1
- package/dist/errors/DuplicateGlobal.js +2 -3
- package/dist/errors/DuplicateGlobal.js.map +1 -1
- package/dist/errors/ErrorDeletingFile.d.ts +2 -3
- package/dist/errors/ErrorDeletingFile.d.ts.map +1 -1
- package/dist/errors/ErrorDeletingFile.js +2 -3
- package/dist/errors/ErrorDeletingFile.js.map +1 -1
- package/dist/errors/FileRetrievalError.d.ts +6 -0
- package/dist/errors/FileRetrievalError.d.ts.map +1 -0
- package/dist/errors/FileRetrievalError.js +13 -0
- package/dist/errors/FileRetrievalError.js.map +1 -0
- package/dist/errors/FileUploadError.d.ts +2 -3
- package/dist/errors/FileUploadError.d.ts.map +1 -1
- package/dist/errors/FileUploadError.js +2 -3
- package/dist/errors/FileUploadError.js.map +1 -1
- package/dist/errors/Forbidden.d.ts +2 -3
- package/dist/errors/Forbidden.d.ts.map +1 -1
- package/dist/errors/Forbidden.js +2 -3
- package/dist/errors/Forbidden.js.map +1 -1
- package/dist/errors/InvalidConfiguration.d.ts +2 -3
- package/dist/errors/InvalidConfiguration.d.ts.map +1 -1
- package/dist/errors/InvalidConfiguration.js +2 -3
- package/dist/errors/InvalidConfiguration.js.map +1 -1
- package/dist/errors/InvalidFieldName.d.ts +2 -3
- package/dist/errors/InvalidFieldName.d.ts.map +1 -1
- package/dist/errors/InvalidFieldName.js +2 -3
- package/dist/errors/InvalidFieldName.js.map +1 -1
- package/dist/errors/InvalidFieldRelationship.d.ts +2 -3
- package/dist/errors/InvalidFieldRelationship.d.ts.map +1 -1
- package/dist/errors/InvalidFieldRelationship.js +2 -3
- package/dist/errors/InvalidFieldRelationship.js.map +1 -1
- package/dist/errors/InvalidSchema.d.ts +2 -3
- package/dist/errors/InvalidSchema.d.ts.map +1 -1
- package/dist/errors/InvalidSchema.js +2 -3
- package/dist/errors/InvalidSchema.js.map +1 -1
- package/dist/errors/LockedAuth.d.ts +2 -3
- package/dist/errors/LockedAuth.d.ts.map +1 -1
- package/dist/errors/LockedAuth.js +2 -3
- package/dist/errors/LockedAuth.js.map +1 -1
- package/dist/errors/MissingCollectionLabel.d.ts +2 -3
- package/dist/errors/MissingCollectionLabel.d.ts.map +1 -1
- package/dist/errors/MissingCollectionLabel.js +2 -3
- package/dist/errors/MissingCollectionLabel.js.map +1 -1
- package/dist/errors/MissingEditorProp.d.ts +2 -3
- package/dist/errors/MissingEditorProp.d.ts.map +1 -1
- package/dist/errors/MissingEditorProp.js +2 -3
- package/dist/errors/MissingEditorProp.js.map +1 -1
- package/dist/errors/MissingFieldInputOptions.d.ts +2 -3
- package/dist/errors/MissingFieldInputOptions.d.ts.map +1 -1
- package/dist/errors/MissingFieldInputOptions.js +2 -3
- package/dist/errors/MissingFieldInputOptions.js.map +1 -1
- package/dist/errors/MissingFieldType.d.ts +2 -3
- package/dist/errors/MissingFieldType.d.ts.map +1 -1
- package/dist/errors/MissingFieldType.js +2 -3
- package/dist/errors/MissingFieldType.js.map +1 -1
- package/dist/errors/MissingFile.d.ts +2 -3
- package/dist/errors/MissingFile.d.ts.map +1 -1
- package/dist/errors/MissingFile.js +2 -3
- package/dist/errors/MissingFile.js.map +1 -1
- package/dist/errors/NotFound.d.ts +2 -3
- package/dist/errors/NotFound.d.ts.map +1 -1
- package/dist/errors/NotFound.js +2 -3
- package/dist/errors/NotFound.js.map +1 -1
- package/dist/errors/QueryError.d.ts +2 -3
- package/dist/errors/QueryError.d.ts.map +1 -1
- package/dist/errors/QueryError.js +2 -3
- package/dist/errors/QueryError.js.map +1 -1
- package/dist/errors/TimestampsRequired.d.ts +2 -3
- package/dist/errors/TimestampsRequired.d.ts.map +1 -1
- package/dist/errors/TimestampsRequired.js +2 -3
- package/dist/errors/TimestampsRequired.js.map +1 -1
- package/dist/errors/UnathorizedError.d.ts +2 -3
- package/dist/errors/UnathorizedError.d.ts.map +1 -1
- package/dist/errors/UnathorizedError.js +2 -3
- package/dist/errors/UnathorizedError.js.map +1 -1
- package/dist/errors/ValidationError.d.ts +2 -3
- package/dist/errors/ValidationError.d.ts.map +1 -1
- package/dist/errors/ValidationError.js +2 -3
- package/dist/errors/ValidationError.js.map +1 -1
- package/dist/errors/index.d.ts +20 -19
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +20 -19
- package/dist/errors/index.js.map +1 -1
- package/dist/exports/i18n.d.ts +2 -0
- package/dist/exports/i18n.d.ts.map +1 -0
- package/dist/exports/i18n.js +3 -0
- package/dist/exports/i18n.js.map +1 -0
- package/dist/fields/config/client.d.ts +1 -1
- package/dist/fields/config/sanitize.d.ts +7 -2
- package/dist/fields/config/sanitize.d.ts.map +1 -1
- package/dist/fields/config/sanitize.js +56 -45
- package/dist/fields/config/sanitize.js.map +1 -1
- package/dist/fields/config/sanitize.spec.js +76 -85
- package/dist/fields/config/sanitize.spec.js.map +1 -1
- package/dist/fields/config/types.d.ts +4 -3
- package/dist/fields/config/types.d.ts.map +1 -1
- package/dist/fields/config/types.js.map +1 -1
- package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/promise.js +3 -0
- package/dist/fields/hooks/afterRead/promise.js.map +1 -1
- package/dist/fields/validations.d.ts.map +1 -1
- package/dist/fields/validations.js +3 -0
- package/dist/fields/validations.js.map +1 -1
- package/dist/globals/config/sanitize.d.ts +2 -3
- package/dist/globals/config/sanitize.d.ts.map +1 -1
- package/dist/globals/config/sanitize.js +36 -35
- package/dist/globals/config/sanitize.js.map +1 -1
- package/dist/preferences/operations/delete.js +2 -2
- package/dist/preferences/operations/delete.js.map +1 -1
- package/dist/preferences/operations/update.js +1 -1
- package/dist/preferences/operations/update.js.map +1 -1
- package/dist/uploads/generateFileData.js +2 -2
- package/dist/uploads/generateFileData.js.map +1 -1
- package/dist/uploads/getExternalFile.d.ts.map +1 -1
- package/dist/uploads/getExternalFile.js +5 -2
- package/dist/uploads/getExternalFile.js.map +1 -1
- package/dist/uploads/types.d.ts +4 -0
- package/dist/uploads/types.d.ts.map +1 -1
- package/dist/uploads/types.js.map +1 -1
- package/dist/utilities/checkDuplicateCollections.js +1 -1
- package/dist/utilities/checkDuplicateCollections.js.map +1 -1
- package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
- package/dist/utilities/configToJSONSchema.js +3 -0
- package/dist/utilities/configToJSONSchema.js.map +1 -1
- package/dist/utilities/configToJSONSchema.spec.js +2 -2
- package/dist/utilities/configToJSONSchema.spec.js.map +1 -1
- package/dist/utilities/createLocalReq.d.ts.map +1 -1
- package/dist/utilities/createLocalReq.js +4 -2
- package/dist/utilities/createLocalReq.js.map +1 -1
- package/dist/utilities/importWithoutClientFiles.js +1 -1
- package/dist/utilities/importWithoutClientFiles.js.map +1 -1
- package/dist/utilities/parseCookies.js +1 -1
- package/dist/utilities/parseCookies.js.map +1 -1
- package/dist/utilities/telemetry/index.d.ts +7 -1
- package/dist/utilities/telemetry/index.d.ts.map +1 -1
- package/dist/utilities/telemetry/index.js +41 -19
- package/dist/utilities/telemetry/index.js.map +1 -1
- package/package.json +67 -70
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/checkDuplicateCollections.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../collections/config/types.js'\n\nimport DuplicateCollection from '../errors/DuplicateCollection.js'\n\nconst getDuplicates = (arr: string[]) => arr.filter((item, index) => arr.indexOf(item) !== index)\n\nconst checkDuplicateCollections = (collections: SanitizedCollectionConfig[]): void => {\n const duplicateSlugs = getDuplicates(collections.map((c) => c.slug))\n if (duplicateSlugs.length > 0) {\n throw new DuplicateCollection('slug', duplicateSlugs)\n }\n}\n\nexport default checkDuplicateCollections\n"],"names":["DuplicateCollection","getDuplicates","arr","filter","item","index","indexOf","checkDuplicateCollections","collections","duplicateSlugs","map","c","slug","length"],"rangeMappings":";;;;;;;;","mappings":"AAEA,
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/checkDuplicateCollections.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../collections/config/types.js'\n\nimport { DuplicateCollection } from '../errors/DuplicateCollection.js'\n\nconst getDuplicates = (arr: string[]) => arr.filter((item, index) => arr.indexOf(item) !== index)\n\nconst checkDuplicateCollections = (collections: SanitizedCollectionConfig[]): void => {\n const duplicateSlugs = getDuplicates(collections.map((c) => c.slug))\n if (duplicateSlugs.length > 0) {\n throw new DuplicateCollection('slug', duplicateSlugs)\n }\n}\n\nexport default checkDuplicateCollections\n"],"names":["DuplicateCollection","getDuplicates","arr","filter","item","index","indexOf","checkDuplicateCollections","collections","duplicateSlugs","map","c","slug","length"],"rangeMappings":";;;;;;;;","mappings":"AA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a,CAAC,EAAE,QAAQ,GAAG,MAAM,GAChC,WAAW,CA4Bb"}
|
|
@@ -183,6 +183,9 @@ export function fieldsToJSONSchema(/**
|
|
|
183
183
|
}
|
|
184
184
|
case 'richText':
|
|
185
185
|
{
|
|
186
|
+
if (typeof field.editor === 'function') {
|
|
187
|
+
throw new Error('Attempted to access unsanitized rich text editor.');
|
|
188
|
+
}
|
|
186
189
|
if (field.editor.outputSchema) {
|
|
187
190
|
fieldSchema = field.editor.outputSchema({
|
|
188
191
|
collectionIDFieldTypes,
|
|
@@ -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 { 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 { 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 * 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 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 = {\n type: ['object', 'array', 'string', 'number', 'boolean', 'null'],\n }\n break\n }\n\n case 'richText': {\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 fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\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 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 requiredFieldNames.add(tab.name)\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 (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\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 return {\n additionalProperties: false,\n definitions: { ...entityDefinitions, ...Object.fromEntries(interfaceNameDefinitions) },\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 collections: generateEntitySchemas(config.collections || []),\n globals: generateEntitySchemas(config.globals || []),\n locale: generateLocaleEntitySchemas(config.localization),\n user: generateAuthEntitySchemas(config.collections),\n },\n required: ['user', 'locale', 'collections', 'globals'],\n title: 'Config',\n }\n}\n"],"names":["pluralize","singular","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","withNullableJSONSchemaType","fieldType","isRequired","fieldTypes","push","fieldsToJSONSchema","collectionIDFieldTypes","interfaceNameDefinitions","config","requiredFieldNames","Set","fromEntries","fieldSchemas","add","name","fieldSchema","hasMany","items","editor","outputSchema","optionEnums","maxItems","minItems","Array","isArray","relationTo","relation","const","blocks","block","blockFieldSchemas","blockSchema","blockType","interfaceName","set","childSchema","entries","forEach","propName","propSchema","Map","from","entityToJSONSchema","incomingEntity","defaultIDType","entity","title","typescript","interface","idField","customIdField","find","unshift","timestamps","disableLocalStrategy","configToJSONSchema","entityDefinitions","globals","collections","definitions","user"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,OAAOA,eAAe,YAAW;AACjC,MAAM,EAAEC,QAAQ,EAAE,GAAGD;AAOrB,SAASE,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,iBAA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QtC,0BAA0BqC;QAChF,OAAO/D;IACT,GAAG,CAAC;IAEJ,OAAO;QACLG,sBAAsB;QACtB2E,aAAa;YAAE,GAAGH,iBAAiB;YAAE,GAAGvE,OAAO0B,WAAW,CAACJ,yBAAyB;QAAC;QACrF,wJAAwJ;QACxJzC,MAAM;QACNa,YAAY;YACV+E,aAAajF,sBAAsB+B,OAAOkD,WAAW,IAAI,EAAE;YAC3DD,SAAShF,sBAAsB+B,OAAOiD,OAAO,IAAI,EAAE;YACnDlE,QAAQJ,4BAA4BqB,OAAOpB,YAAY;YACvDwE,MAAMlE,0BAA0Bc,OAAOkD,WAAW;QACpD;QACA7F,UAAU;YAAC;YAAQ;YAAU;YAAe;SAAU;QACtDiF,OAAO;IACT;AACF"}
|
|
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 { 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 { 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 * 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 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 = {\n type: ['object', 'array', 'string', 'number', 'boolean', 'null'],\n }\n break\n }\n\n case 'richText': {\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 fieldSchema = {\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\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 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 requiredFieldNames.add(tab.name)\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 (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\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 return {\n additionalProperties: false,\n definitions: { ...entityDefinitions, ...Object.fromEntries(interfaceNameDefinitions) },\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 collections: generateEntitySchemas(config.collections || []),\n globals: generateEntitySchemas(config.globals || []),\n locale: generateLocaleEntitySchemas(config.localization),\n user: generateAuthEntitySchemas(config.collections),\n },\n required: ['user', 'locale', 'collections', 'globals'],\n title: 'Config',\n }\n}\n"],"names":["pluralize","singular","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","withNullableJSONSchemaType","fieldType","isRequired","fieldTypes","push","fieldsToJSONSchema","collectionIDFieldTypes","interfaceNameDefinitions","config","requiredFieldNames","Set","fromEntries","fieldSchemas","add","name","fieldSchema","hasMany","items","editor","Error","outputSchema","optionEnums","maxItems","minItems","Array","isArray","relationTo","relation","const","blocks","block","blockFieldSchemas","blockSchema","blockType","interfaceName","set","childSchema","entries","forEach","propName","propSchema","Map","from","entityToJSONSchema","incomingEntity","defaultIDType","entity","title","typescript","interface","idField","customIdField","find","unshift","timestamps","disableLocalStrategy","configToJSONSchema","entityDefinitions","globals","collections","definitions","user"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,OAAOA,eAAe,YAAW;AACjC,MAAM,EAAEC,QAAQ,EAAE,GAAGD;AAOrB,SAASE,gBAAgB,EAAEC,UAAU,QAAQ,4BAA2B;AACxE,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,OAAO,QAAQ,oBAAmB;AAC3C,SAASC,yBAAyB,QAAQ,iCAAgC;AAE1E,MAAM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C,yJAAyJ;IACzJ,MAAMtC,2BAAqD,IAAIkC;IAE/D,gLAAgL;IAChL,+CAA+C;IAC/C,MAAMgB,oBAAkD;WACnDjD,OAAOkD,OAAO;WACdlD,OAAOmD,WAAW;KACtB,CAAC/E,MAAM,CAAC,CAACC,KAAKiE;QACbjE,GAAG,CAACiE,OAAOhE,IAAI,CAAC,GAAG6D,mBAAmBnC,QAAQsC,QAAQvC,0BAA0BsC;QAChF,OAAOhE;IACT,GAAG,CAAC;IAEJ,OAAO;QACLG,sBAAsB;QACtB4E,aAAa;YAAE,GAAGH,iBAAiB;YAAE,GAAGxE,OAAO0B,WAAW,CAACJ,yBAAyB;QAAC;QACrF,wJAAwJ;QACxJzC,MAAM;QACNa,YAAY;YACVgF,aAAalF,sBAAsB+B,OAAOmD,WAAW,IAAI,EAAE;YAC3DD,SAASjF,sBAAsB+B,OAAOkD,OAAO,IAAI,EAAE;YACnDnE,QAAQJ,4BAA4BqB,OAAOpB,YAAY;YACvDyE,MAAMnE,0BAA0Bc,OAAOmD,WAAW;QACpD;QACA9F,UAAU;YAAC;YAAQ;YAAU;YAAe;SAAU;QACtDkF,OAAO;IACT;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { sanitizeConfig } from '../config/sanitize.js';
|
|
2
2
|
import { configToJSONSchema } from './configToJSONSchema.js';
|
|
3
3
|
describe('configToJSONSchema', ()=>{
|
|
4
|
-
it('should handle optional arrays with required fields', ()=>{
|
|
4
|
+
it('should handle optional arrays with required fields', async ()=>{
|
|
5
5
|
const config = {
|
|
6
6
|
collections: [
|
|
7
7
|
{
|
|
@@ -23,7 +23,7 @@ describe('configToJSONSchema', ()=>{
|
|
|
23
23
|
}
|
|
24
24
|
]
|
|
25
25
|
};
|
|
26
|
-
const sanitizedConfig = sanitizeConfig(config);
|
|
26
|
+
const sanitizedConfig = await sanitizeConfig(config);
|
|
27
27
|
const schema = configToJSONSchema(sanitizedConfig, 'text');
|
|
28
28
|
expect(schema?.definitions?.test).toStrictEqual({
|
|
29
29
|
additionalProperties: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/configToJSONSchema.spec.ts"],"sourcesContent":["import type { Config } from '../config/types.js'\n\nimport { sanitizeConfig } from '../config/sanitize.js'\nimport { configToJSONSchema } from './configToJSONSchema.js'\n\ndescribe('configToJSONSchema', () => {\n it('should handle optional arrays with required fields', () => {\n const config: Config = {\n collections: [\n {\n fields: [\n {\n name: 'someRequiredField',\n type: 'array',\n fields: [\n {\n name: 'someRequiredField',\n required: true,\n type: 'text',\n },\n ],\n },\n ],\n slug: 'test',\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = sanitizeConfig(config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.definitions?.test).toStrictEqual({\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n someRequiredField: {\n items: {\n additionalProperties: false,\n properties: {\n id: {\n type: ['string', 'null'],\n },\n someRequiredField: {\n type: 'string',\n },\n },\n required: ['someRequiredField'],\n type: 'object',\n },\n type: ['array', 'null'],\n },\n },\n required: ['id'],\n title: 'Test',\n type: 'object',\n })\n })\n})\n"],"names":["sanitizeConfig","configToJSONSchema","describe","it","config","collections","fields","name","type","required","slug","timestamps","sanitizedConfig","schema","expect","definitions","test","toStrictEqual","additionalProperties","properties","id","someRequiredField","items","title"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,cAAc,QAAQ,wBAAuB;AACtD,SAASC,kBAAkB,QAAQ,0BAAyB;AAE5DC,SAAS,sBAAsB;IAC7BC,GAAG,sDAAsD;QACvD,MAAMC,SAAiB;YACrBC,aAAa;gBACX;oBACEC,QAAQ;wBACN;4BACEC,MAAM;4BACNC,MAAM;4BACNF,QAAQ;gCACN;oCACEC,MAAM;oCACNE,UAAU;oCACVD,MAAM;gCACR;6BACD;wBACH;qBACD;oBACDE,MAAM;oBACNC,YAAY;gBACd;aACD;QACH;QAEA,MAAMC,
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/configToJSONSchema.spec.ts"],"sourcesContent":["import type { Config } from '../config/types.js'\n\nimport { sanitizeConfig } from '../config/sanitize.js'\nimport { configToJSONSchema } from './configToJSONSchema.js'\n\ndescribe('configToJSONSchema', () => {\n it('should handle optional arrays with required fields', async () => {\n const config: Config = {\n collections: [\n {\n fields: [\n {\n name: 'someRequiredField',\n type: 'array',\n fields: [\n {\n name: 'someRequiredField',\n required: true,\n type: 'text',\n },\n ],\n },\n ],\n slug: 'test',\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.definitions?.test).toStrictEqual({\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n someRequiredField: {\n items: {\n additionalProperties: false,\n properties: {\n id: {\n type: ['string', 'null'],\n },\n someRequiredField: {\n type: 'string',\n },\n },\n required: ['someRequiredField'],\n type: 'object',\n },\n type: ['array', 'null'],\n },\n },\n required: ['id'],\n title: 'Test',\n type: 'object',\n })\n })\n})\n"],"names":["sanitizeConfig","configToJSONSchema","describe","it","config","collections","fields","name","type","required","slug","timestamps","sanitizedConfig","schema","expect","definitions","test","toStrictEqual","additionalProperties","properties","id","someRequiredField","items","title"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,cAAc,QAAQ,wBAAuB;AACtD,SAASC,kBAAkB,QAAQ,0BAAyB;AAE5DC,SAAS,sBAAsB;IAC7BC,GAAG,sDAAsD;QACvD,MAAMC,SAAiB;YACrBC,aAAa;gBACX;oBACEC,QAAQ;wBACN;4BACEC,MAAM;4BACNC,MAAM;4BACNF,QAAQ;gCACN;oCACEC,MAAM;oCACNE,UAAU;oCACVD,MAAM;gCACR;6BACD;wBACH;qBACD;oBACDE,MAAM;oBACNC,YAAY;gBACd;aACD;QACH;QAEA,MAAMC,kBAAkB,MAAMZ,eAAeI;QAC7C,MAAMS,SAASZ,mBAAmBW,iBAAiB;QAEnDE,OAAOD,QAAQE,aAAaC,MAAMC,aAAa,CAAC;YAC9CC,sBAAsB;YACtBC,YAAY;gBACVC,IAAI;oBACFZ,MAAM;gBACR;gBACAa,mBAAmB;oBACjBC,OAAO;wBACLJ,sBAAsB;wBACtBC,YAAY;4BACVC,IAAI;gCACFZ,MAAM;oCAAC;oCAAU;iCAAO;4BAC1B;4BACAa,mBAAmB;gCACjBb,MAAM;4BACR;wBACF;wBACAC,UAAU;4BAAC;yBAAoB;wBAC/BD,MAAM;oBACR;oBACAA,MAAM;wBAAC;wBAAS;qBAAO;gBACzB;YACF;YACAC,UAAU;gBAAC;aAAK;YAChBc,OAAO;YACPf,MAAM;QACR;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createLocalReq.d.ts","sourceRoot":"","sources":["../../src/utilities/createLocalReq.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAsD/D,KAAK,cAAc,GAAG,CACpB,OAAO,EAAE;IACP,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,sBAAsB,CAAA;IAC5B,IAAI,CAAC,EAAE,IAAI,CAAA;CACZ,EACD,OAAO,EAAE,OAAO,KACb,OAAO,CAAC,sBAAsB,CAAC,CAAA;AACpC,eAAO,MAAM,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"createLocalReq.d.ts","sourceRoot":"","sources":["../../src/utilities/createLocalReq.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAsD/D,KAAK,cAAc,GAAG,CACpB,OAAO,EAAE;IACP,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,sBAAsB,CAAA;IAC5B,IAAI,CAAC,EAAE,IAAI,CAAA;CACZ,EACD,OAAO,EAAE,OAAO,KACb,OAAO,CAAC,sBAAsB,CAAC,CAAA;AACpC,eAAO,MAAM,cAAc,EAAE,cAmC5B,CAAA"}
|
|
@@ -22,7 +22,7 @@ const attachFakeURLProperties = (req)=>{
|
|
|
22
22
|
* *NOTE*
|
|
23
23
|
* If no URL is provided, the local API was called directly outside
|
|
24
24
|
* the context of a request. Therefore we create a fake URL object.
|
|
25
|
-
* `ts-
|
|
25
|
+
* `ts-expect-error` is used below for properties that are 'read-only'
|
|
26
26
|
* since they do not exist yet we can safely ignore the error.
|
|
27
27
|
*/ let urlObject;
|
|
28
28
|
function getURLObject() {
|
|
@@ -43,7 +43,7 @@ const attachFakeURLProperties = (req)=>{
|
|
|
43
43
|
// @ts-expect-error
|
|
44
44
|
if (!req.origin) req.origin = getURLObject().origin;
|
|
45
45
|
// @ts-expect-error
|
|
46
|
-
if (!req?.url) req.url = getURLObject().
|
|
46
|
+
if (!req?.url) req.url = getURLObject().href;
|
|
47
47
|
};
|
|
48
48
|
export const createLocalReq = async ({ context, fallbackLocale, locale: localeArg, req = {}, user }, payload)=>{
|
|
49
49
|
const i18n = req?.i18n || await getLocalI18n({
|
|
@@ -60,6 +60,8 @@ export const createLocalReq = async ({ context, fallbackLocale, locale: localeAr
|
|
|
60
60
|
req.fallbackLocale = fallbackLocaleFromConfig || defaultLocale;
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
+
// @ts-expect-error
|
|
64
|
+
if (!req.headers) req.headers = new Headers();
|
|
63
65
|
req.context = getRequestContext(req, context);
|
|
64
66
|
req.payloadAPI = req?.payloadAPI || 'local';
|
|
65
67
|
req.payload = payload;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/createLocalReq.ts"],"sourcesContent":["import type { User } from '../auth/types.js'\nimport type { Payload, RequestContext } from '../index.js'\nimport type { PayloadRequestWithData } from '../types/index.js'\n\nimport { getDataLoader } from '../collections/dataloader.js'\nimport { getLocalI18n } from '../translations/getLocalI18n.js'\n\nfunction getRequestContext(\n req: PayloadRequestWithData = { context: null } as PayloadRequestWithData,\n context: RequestContext = {},\n): RequestContext {\n if (req.context) {\n if (Object.keys(req.context).length === 0 && req.context.constructor === Object) {\n // if req.context is `{}` avoid unnecessary spread\n return context\n } else {\n return { ...req.context, ...context }\n }\n } else {\n return context\n }\n}\n\nconst attachFakeURLProperties = (req: PayloadRequestWithData) => {\n /**\n * *NOTE*\n * If no URL is provided, the local API was called directly outside\n * the context of a request. Therefore we create a fake URL object.\n * `ts-
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/createLocalReq.ts"],"sourcesContent":["import type { User } from '../auth/types.js'\nimport type { Payload, RequestContext } from '../index.js'\nimport type { PayloadRequestWithData } from '../types/index.js'\n\nimport { getDataLoader } from '../collections/dataloader.js'\nimport { getLocalI18n } from '../translations/getLocalI18n.js'\n\nfunction getRequestContext(\n req: PayloadRequestWithData = { context: null } as PayloadRequestWithData,\n context: RequestContext = {},\n): RequestContext {\n if (req.context) {\n if (Object.keys(req.context).length === 0 && req.context.constructor === Object) {\n // if req.context is `{}` avoid unnecessary spread\n return context\n } else {\n return { ...req.context, ...context }\n }\n } else {\n return context\n }\n}\n\nconst attachFakeURLProperties = (req: PayloadRequestWithData) => {\n /**\n * *NOTE*\n * If no URL is provided, the local API was called directly outside\n * the context of a request. Therefore we create a fake URL object.\n * `ts-expect-error` is used below for properties that are 'read-only'\n * since they do not exist yet we can safely ignore the error.\n */\n let urlObject\n\n function getURLObject() {\n if (urlObject) return urlObject\n const urlToUse = req?.url || req.payload.config?.serverURL || 'http://localhost'\n try {\n urlObject = new URL(urlToUse)\n } catch (error) {\n urlObject = new URL('http://localhost')\n }\n\n return urlObject\n }\n\n if (!req.host) req.host = getURLObject().host\n if (!req.protocol) req.protocol = getURLObject().protocol\n if (!req.pathname) req.pathname = getURLObject().pathname\n // @ts-expect-error\n if (!req.searchParams) req.searchParams = getURLObject().searchParams\n // @ts-expect-error\n if (!req.origin) req.origin = getURLObject().origin\n // @ts-expect-error\n if (!req?.url) req.url = getURLObject().href\n}\n\ntype CreateLocalReq = (\n options: {\n context?: RequestContext\n fallbackLocale?: string\n locale?: string\n req?: PayloadRequestWithData\n user?: User\n },\n payload: Payload,\n) => Promise<PayloadRequestWithData>\nexport const createLocalReq: CreateLocalReq = async (\n { context, fallbackLocale, locale: localeArg, req = {} as PayloadRequestWithData, user },\n payload,\n) => {\n const i18n = req?.i18n || (await getLocalI18n({ config: payload.config }))\n\n if (payload.config?.localization) {\n const locale = localeArg === '*' ? 'all' : localeArg\n const defaultLocale = payload.config.localization.defaultLocale\n req.locale = locale || req?.locale || defaultLocale\n const fallbackLocaleFromConfig = payload.config.localization.locales.find(\n ({ code }) => req.locale === code,\n )?.fallbackLocale\n if (typeof fallbackLocale !== 'undefined') {\n req.fallbackLocale = fallbackLocale\n } else if (typeof req?.fallbackLocale === 'undefined') {\n req.fallbackLocale = fallbackLocaleFromConfig || defaultLocale\n }\n }\n\n // @ts-expect-error\n if (!req.headers) req.headers = new Headers()\n req.context = getRequestContext(req, context)\n req.payloadAPI = req?.payloadAPI || 'local'\n req.payload = payload\n req.i18n = i18n\n req.t = i18n.t\n req.user = user || req?.user || null\n req.payloadDataLoader = req?.payloadDataLoader || getDataLoader(req)\n req.routeParams = req?.routeParams || {}\n req.query = req?.query || {}\n\n attachFakeURLProperties(req)\n\n return req\n}\n"],"names":["getDataLoader","getLocalI18n","getRequestContext","req","context","Object","keys","length","constructor","attachFakeURLProperties","urlObject","getURLObject","urlToUse","url","payload","config","serverURL","URL","error","host","protocol","pathname","searchParams","origin","href","createLocalReq","fallbackLocale","locale","localeArg","user","i18n","localization","defaultLocale","fallbackLocaleFromConfig","locales","find","code","headers","Headers","payloadAPI","t","payloadDataLoader","routeParams","query"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,aAAa,QAAQ,+BAA8B;AAC5D,SAASC,YAAY,QAAQ,kCAAiC;AAE9D,SAASC,kBACPC,MAA8B;IAAEC,SAAS;AAAK,CAA2B,EACzEA,UAA0B,CAAC,CAAC;IAE5B,IAAID,IAAIC,OAAO,EAAE;QACf,IAAIC,OAAOC,IAAI,CAACH,IAAIC,OAAO,EAAEG,MAAM,KAAK,KAAKJ,IAAIC,OAAO,CAACI,WAAW,KAAKH,QAAQ;YAC/E,kDAAkD;YAClD,OAAOD;QACT,OAAO;YACL,OAAO;gBAAE,GAAGD,IAAIC,OAAO;gBAAE,GAAGA,OAAO;YAAC;QACtC;IACF,OAAO;QACL,OAAOA;IACT;AACF;AAEA,MAAMK,0BAA0B,CAACN;IAC/B;;;;;;GAMC,GACD,IAAIO;IAEJ,SAASC;QACP,IAAID,WAAW,OAAOA;QACtB,MAAME,WAAWT,KAAKU,OAAOV,IAAIW,OAAO,CAACC,MAAM,EAAEC,aAAa;QAC9D,IAAI;YACFN,YAAY,IAAIO,IAAIL;QACtB,EAAE,OAAOM,OAAO;YACdR,YAAY,IAAIO,IAAI;QACtB;QAEA,OAAOP;IACT;IAEA,IAAI,CAACP,IAAIgB,IAAI,EAAEhB,IAAIgB,IAAI,G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AAElC,IAAIkC,OAAO,GAAG,IAAIC;IACpCnC,IAAIC,OAAO,GAAGF,kBAAkBC,KAAKC;IACrCD,IAAIoC,UAAU,GAAGpC,KAAKoC,cAAc;IACpCpC,IAAIW,OAAO,GAAGA;IACdX,IAAI2B,IAAI,GAAGA;IACX3B,IAAIqC,CAAC,GAAGV,KAAKU,CAAC;IACdrC,IAAI0B,IAAI,GAAGA,QAAQ1B,KAAK0B,QAAQ;IAChC1B,IAAIsC,iBAAiB,GAAGtC,KAAKsC,qBAAqBzC,cAAcG;IAChEA,IAAIuC,WAAW,GAAGvC,KAAKuC,eAAe,CAAC;IACvCvC,IAAIwC,KAAK,GAAGxC,KAAKwC,SAAS,CAAC;IAE3BlC,wBAAwBN;IAExB,OAAOA;AACT,EAAC"}
|
|
@@ -7,7 +7,7 @@ export const importWithoutClientFiles = async (filePath)=>{
|
|
|
7
7
|
const { href: filePathUrl } = pathToFileURL(filePath);
|
|
8
8
|
const { href: loaderUrl } = pathToFileURL(path.resolve(dirname, '../../dist/bin/loader/index.js'));
|
|
9
9
|
register(loaderUrl, filePathUrl);
|
|
10
|
-
const result = await import(
|
|
10
|
+
const result = await import(filePath);
|
|
11
11
|
return result;
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/importWithoutClientFiles.ts"],"sourcesContent":["import { register } from 'node:module'\nimport { URL, fileURLToPath, pathToFileURL } from 'node:url'\nimport path from 'path'\n\nimport type { SanitizedConfig } from '../config/types.js'\n\nconst filename = fileURLToPath(import.meta.url)\nconst dirname = path.dirname(filename)\n\nexport const importWithoutClientFiles = async <T = unknown>(filePath: string) => {\n const { href: filePathUrl } = pathToFileURL(filePath)\n const { href: loaderUrl } = pathToFileURL(path.resolve(dirname, '../../dist/bin/loader/index.js'))\n\n register(loaderUrl, filePathUrl)\n const result = await import(
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/importWithoutClientFiles.ts"],"sourcesContent":["import { register } from 'node:module'\nimport { URL, fileURLToPath, pathToFileURL } from 'node:url'\nimport path from 'path'\n\nimport type { SanitizedConfig } from '../config/types.js'\n\nconst filename = fileURLToPath(import.meta.url)\nconst dirname = path.dirname(filename)\n\nexport const importWithoutClientFiles = async <T = unknown>(filePath: string) => {\n const { href: filePathUrl } = pathToFileURL(filePath)\n const { href: loaderUrl } = pathToFileURL(path.resolve(dirname, '../../dist/bin/loader/index.js'))\n\n register(loaderUrl, filePathUrl)\n const result = await import(filePath)\n return result as T\n}\n\n/**\n * Resolve and load Payload config from either a relative or absolute path\n */\nexport const importConfig = async (configPath: string) => {\n const isAbsolutePath = path.isAbsolute(configPath)\n if (isAbsolutePath) {\n const config = await importWithoutClientFiles<{ default: Promise<SanitizedConfig> }>(configPath)\n return await config.default\n }\n\n const callerFilename = getCallerInfo()[1].getFileName()\n\n const url = new URL(callerFilename)\n\n const callerDir = path.dirname(fileURLToPath(url))\n\n const fullConfigPath = path.resolve(callerDir, configPath)\n\n const config = await importWithoutClientFiles<{ default: Promise<SanitizedConfig> }>(\n fullConfigPath,\n )\n return await config.default\n}\n\nconst getCallerInfo = () => {\n const _prepareStackTrace = Error.prepareStackTrace\n try {\n let result = []\n Error.prepareStackTrace = (_, callSites) => {\n const callSitesWithoutCurrent = callSites.slice(1)\n result = callSitesWithoutCurrent\n return callSitesWithoutCurrent\n }\n\n new Error().stack\n return result\n } finally {\n Error.prepareStackTrace = _prepareStackTrace\n }\n}\n"],"names":["register","URL","fileURLToPath","pathToFileURL","path","filename","url","dirname","importWithoutClientFiles","filePath","href","filePathUrl","loaderUrl","resolve","result","importConfig","configPath","isAbsolutePath","isAbsolute","config","default","callerFilename","getCallerInfo","getFileName","callerDir","fullConfigPath","_prepareStackTrace","Error","prepareStackTrace","_","callSites","callSitesWithoutCurrent","slice","stack"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAa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../src/utilities/parseCookies.ts"],"sourcesContent":["import APIError from '../errors/APIError.js'\n\nexport const parseCookies = (headers: Request['headers']): Map<string, string> => {\n const list = new Map<string, string>()\n const rc = headers.get('Cookie')\n\n if (rc) {\n rc.split(';').forEach((cookie) => {\n const parts = cookie.split('=')\n const key = parts.shift().trim()\n const encodedValue = parts.join('=')\n\n try {\n const decodedValue = decodeURI(encodedValue)\n list.set(key, decodedValue)\n } catch (e) {\n throw new APIError(`Error decoding cookie value for key ${key}: ${e.message}`)\n }\n })\n }\n\n return list\n}\n"],"names":["APIError","parseCookies","headers","list","Map","rc","get","split","forEach","cookie","parts","key","shift","trim","encodedValue","join","decodedValue","decodeURI","set","e","message"],"rangeMappings":";;;;;;;;;;;;;;;;;;","mappings":"AAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/parseCookies.ts"],"sourcesContent":["import { APIError } from '../errors/APIError.js'\n\nexport const parseCookies = (headers: Request['headers']): Map<string, string> => {\n const list = new Map<string, string>()\n const rc = headers.get('Cookie')\n\n if (rc) {\n rc.split(';').forEach((cookie) => {\n const parts = cookie.split('=')\n const key = parts.shift().trim()\n const encodedValue = parts.join('=')\n\n try {\n const decodedValue = decodeURI(encodedValue)\n list.set(key, decodedValue)\n } catch (e) {\n throw new APIError(`Error decoding cookie value for key ${key}: ${e.message}`)\n }\n })\n }\n\n return list\n}\n"],"names":["APIError","parseCookies","headers","list","Map","rc","get","split","forEach","cookie","parts","key","shift","trim","encodedValue","join","decodedValue","decodeURI","set","e","message"],"rangeMappings":";;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,QAAQ,QAAQ,wBAAuB;AAEhD,OAAO,MAAMC,eAAe,CAACC;IAC3B,MAAMC,OAAO,IAAIC;IACjB,MAAMC,KAAKH,QAAQI,GAAG,CAAC;IAEvB,IAAID,IAAI;QACNA,GAAGE,KAAK,CAAC,KAAKC,OAAO,CAAC,CAACC;YACrB,MAAMC,QAAQD,OAAOF,KAAK,CAAC;YAC3B,MAAMI,MAAMD,MAAME,KAAK,GAAGC,IAAI;YAC9B,MAAMC,eAAeJ,MAAMK,IAAI,CAAC;YAEhC,IAAI;gBACF,MAAMC,eAAeC,UAAUH;gBAC/BX,KAAKe,GAAG,CAACP,KAAKK;YAChB,EAAE,OAAOG,GAAG;gBACV,MAAM,IAAInB,SAAS,CAAC,oCAAoC,EAAEW,IAAI,EAAE,EAAEQ,EAAEC,OAAO,CAAC,CAAC;YAC/E;QACF;IACF;IAEA,OAAOjB;AACT,EAAC"}
|
|
@@ -3,13 +3,18 @@ import type { AdminInitEvent } from './events/adminInit.js';
|
|
|
3
3
|
import type { ServerInitEvent } from './events/serverInit.js';
|
|
4
4
|
export type BaseEvent = {
|
|
5
5
|
ciName: null | string;
|
|
6
|
+
dbAdapter: string;
|
|
7
|
+
emailAdapter: null | string;
|
|
6
8
|
envID: string;
|
|
7
9
|
isCI: boolean;
|
|
10
|
+
locales: string[];
|
|
11
|
+
localizationDefaultLocale: null | string;
|
|
12
|
+
localizationEnabled: boolean;
|
|
8
13
|
nodeEnv: string;
|
|
9
14
|
nodeVersion: string;
|
|
10
|
-
payloadPackages: Record<string, string>;
|
|
11
15
|
payloadVersion: string;
|
|
12
16
|
projectID: string;
|
|
17
|
+
uploadAdapters: string[];
|
|
13
18
|
};
|
|
14
19
|
type PackageJSON = {
|
|
15
20
|
dependencies: Record<string, string | undefined>;
|
|
@@ -22,5 +27,6 @@ type Args = {
|
|
|
22
27
|
};
|
|
23
28
|
export declare const sendEvent: ({ event, payload }: Args) => Promise<void>;
|
|
24
29
|
export declare const getPayloadVersion: (packageJSON: PackageJSON) => string;
|
|
30
|
+
export declare const getLocalizationInfo: (payload: Payload) => Pick<BaseEvent, 'locales' | 'localizationDefaultLocale' | 'localizationEnabled'>;
|
|
25
31
|
export {};
|
|
26
32
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utilities/telemetry/index.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAM7D,MAAM,MAAM,SAAS,GAAG;IACtB,MAAM,EAAE,IAAI,GAAG,MAAM,CAAA;IACrB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,OAAO,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utilities/telemetry/index.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAM7D,MAAM,MAAM,SAAS,GAAG;IACtB,MAAM,EAAE,IAAI,GAAG,MAAM,CAAA;IACrB,SAAS,EAAE,MAAM,CAAA;IACjB,YAAY,EAAE,IAAI,GAAG,MAAM,CAAA;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,OAAO,CAAA;IACb,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,yBAAyB,EAAE,IAAI,GAAG,MAAM,CAAA;IACxC,mBAAmB,EAAE,OAAO,CAAA;IAC5B,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,EAAE,MAAM,EAAE,CAAA;CACzB,CAAA;AAED,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;IAChD,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,KAAK,cAAc,GAAG,cAAc,GAAG,eAAe,CAAA;AAEtD,KAAK,IAAI,GAAG;IACV,KAAK,EAAE,cAAc,CAAA;IACrB,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAID,eAAO,MAAM,SAAS,uBAA8B,IAAI,KAAG,QAAQ,IAAI,CAyCtE,CAAA;AAiED,eAAO,MAAM,iBAAiB,gBAAiB,WAAW,KAAG,MAE5D,CAAA;AAED,eAAO,MAAM,mBAAmB,wBAE7B,KAAK,SAAS,EAAE,SAAS,GAAG,2BAA2B,GAAG,qBAAqB,CAcjF,CAAA"}
|
|
@@ -11,7 +11,7 @@ const Conf = ConfImport.default || ConfImport;
|
|
|
11
11
|
let baseEvent = null;
|
|
12
12
|
export const sendEvent = async ({ event, payload })=>{
|
|
13
13
|
try {
|
|
14
|
-
const packageJSON = await getPackageJSON();
|
|
14
|
+
const { packageJSON, packageJSONPath } = await getPackageJSON();
|
|
15
15
|
// Only generate the base event once
|
|
16
16
|
if (!baseEvent) {
|
|
17
17
|
baseEvent = {
|
|
@@ -20,16 +20,20 @@ export const sendEvent = async ({ event, payload })=>{
|
|
|
20
20
|
isCI: ciInfo.isCI,
|
|
21
21
|
nodeEnv: process.env.NODE_ENV || 'development',
|
|
22
22
|
nodeVersion: process.version,
|
|
23
|
-
payloadPackages: getPayloadPackages(packageJSON),
|
|
24
23
|
payloadVersion: getPayloadVersion(packageJSON),
|
|
25
|
-
projectID: getProjectID(payload, packageJSON)
|
|
24
|
+
projectID: getProjectID(payload, packageJSON),
|
|
25
|
+
...getLocalizationInfo(payload),
|
|
26
|
+
dbAdapter: payload.db.name,
|
|
27
|
+
emailAdapter: payload.email?.name || null,
|
|
28
|
+
uploadAdapters: payload.config.upload.adapters
|
|
26
29
|
};
|
|
27
30
|
}
|
|
28
31
|
if (process.env.PAYLOAD_TELEMETRY_DEBUG) {
|
|
29
32
|
payload.logger.info({
|
|
30
33
|
event: {
|
|
31
34
|
...baseEvent,
|
|
32
|
-
...event
|
|
35
|
+
...event,
|
|
36
|
+
packageJSONPath
|
|
33
37
|
},
|
|
34
38
|
msg: 'Telemetry Event'
|
|
35
39
|
});
|
|
@@ -80,22 +84,26 @@ const getGitID = (payload)=>{
|
|
|
80
84
|
return null;
|
|
81
85
|
}
|
|
82
86
|
};
|
|
83
|
-
const getPayloadPackages = (packageJSON)=>{
|
|
84
|
-
return Object.keys(packageJSON.dependencies || {}).reduce((acc, key)=>{
|
|
85
|
-
return key.startsWith('@payloadcms/') ? {
|
|
86
|
-
...acc,
|
|
87
|
-
[key]: packageJSON.dependencies[key]
|
|
88
|
-
} : acc;
|
|
89
|
-
}, {});
|
|
90
|
-
};
|
|
91
87
|
const getPackageJSON = async ()=>{
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
88
|
+
let packageJSONPath = path.resolve(process.cwd(), 'package.json');
|
|
89
|
+
if (!fs.existsSync(packageJSONPath)) {
|
|
90
|
+
// Old logic
|
|
91
|
+
const filename = fileURLToPath(import.meta.url);
|
|
92
|
+
const dirname = path.dirname(filename);
|
|
93
|
+
packageJSONPath = await findUp('package.json', {
|
|
94
|
+
cwd: dirname
|
|
95
|
+
});
|
|
96
|
+
const jsonContent = JSON.parse(fs.readFileSync(packageJSONPath, 'utf-8'));
|
|
97
|
+
return {
|
|
98
|
+
packageJSON: jsonContent,
|
|
99
|
+
packageJSONPath
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
const packageJSON = JSON.parse(fs.readFileSync(packageJSONPath, 'utf-8'));
|
|
103
|
+
return {
|
|
104
|
+
packageJSON,
|
|
105
|
+
packageJSONPath
|
|
106
|
+
};
|
|
99
107
|
};
|
|
100
108
|
const getPackageJSONID = (payload, packageJSON)=>{
|
|
101
109
|
return oneWayHash(packageJSON.name, payload.secret);
|
|
@@ -103,5 +111,19 @@ const getPackageJSONID = (payload, packageJSON)=>{
|
|
|
103
111
|
export const getPayloadVersion = (packageJSON)=>{
|
|
104
112
|
return packageJSON?.dependencies?.payload ?? '';
|
|
105
113
|
};
|
|
114
|
+
export const getLocalizationInfo = (payload)=>{
|
|
115
|
+
if (!payload.config.localization) {
|
|
116
|
+
return {
|
|
117
|
+
locales: [],
|
|
118
|
+
localizationDefaultLocale: null,
|
|
119
|
+
localizationEnabled: false
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
locales: payload.config.localization.localeCodes,
|
|
124
|
+
localizationDefaultLocale: payload.config.localization.defaultLocale,
|
|
125
|
+
localizationEnabled: true
|
|
126
|
+
};
|
|
127
|
+
};
|
|
106
128
|
|
|
107
129
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utilities/telemetry/index.ts"],"sourcesContent":["import { execSync } from 'child_process'\nimport ciInfo from 'ci-info'\nimport ConfImport from 'conf'\nimport { randomBytes } from 'crypto'\nimport findUp from 'find-up'\nimport fs from 'fs'\nimport path from 'path'\nimport { fileURLToPath } from 'url'\n\nimport type { Payload } from '../../types/index.js'\nimport type { AdminInitEvent } from './events/adminInit.js'\nimport type { ServerInitEvent } from './events/serverInit.js'\n\nimport { oneWayHash } from './oneWayHash.js'\n\nconst Conf = (ConfImport.default || ConfImport) as unknown as typeof ConfImport.default\n\nexport type BaseEvent = {\n ciName: null | string\n envID: string\n isCI: boolean\n
|
|
1
|
+
{"version":3,"sources":["../../../src/utilities/telemetry/index.ts"],"sourcesContent":["import { execSync } from 'child_process'\nimport ciInfo from 'ci-info'\nimport ConfImport from 'conf'\nimport { randomBytes } from 'crypto'\nimport findUp from 'find-up'\nimport fs from 'fs'\nimport path from 'path'\nimport { fileURLToPath } from 'url'\n\nimport type { Payload } from '../../types/index.js'\nimport type { AdminInitEvent } from './events/adminInit.js'\nimport type { ServerInitEvent } from './events/serverInit.js'\n\nimport { oneWayHash } from './oneWayHash.js'\n\nconst Conf = (ConfImport.default || ConfImport) as unknown as typeof ConfImport.default\n\nexport type BaseEvent = {\n ciName: null | string\n dbAdapter: string\n emailAdapter: null | string\n envID: string\n isCI: boolean\n locales: string[]\n localizationDefaultLocale: null | string\n localizationEnabled: boolean\n nodeEnv: string\n nodeVersion: string\n payloadVersion: string\n projectID: string\n uploadAdapters: string[]\n}\n\ntype PackageJSON = {\n dependencies: Record<string, string | undefined>\n name: string\n}\n\ntype TelemetryEvent = AdminInitEvent | ServerInitEvent\n\ntype Args = {\n event: TelemetryEvent\n payload: Payload\n}\n\nlet baseEvent: BaseEvent | null = null\n\nexport const sendEvent = async ({ event, payload }: Args): Promise<void> => {\n try {\n const { packageJSON, packageJSONPath } = await getPackageJSON()\n\n // Only generate the base event once\n if (!baseEvent) {\n baseEvent = {\n ciName: ciInfo.isCI ? ciInfo.name : null,\n envID: getEnvID(),\n isCI: ciInfo.isCI,\n nodeEnv: process.env.NODE_ENV || 'development',\n nodeVersion: process.version,\n payloadVersion: getPayloadVersion(packageJSON),\n projectID: getProjectID(payload, packageJSON),\n ...getLocalizationInfo(payload),\n dbAdapter: payload.db.name,\n emailAdapter: payload.email?.name || null,\n uploadAdapters: payload.config.upload.adapters,\n }\n }\n\n if (process.env.PAYLOAD_TELEMETRY_DEBUG) {\n payload.logger.info({\n event: { ...baseEvent, ...event, packageJSONPath },\n msg: 'Telemetry Event',\n })\n return\n }\n\n if (payload.config.telemetry !== false) {\n await fetch('https://telemetry.payloadcms.com/events', {\n body: JSON.stringify({ ...baseEvent, ...event }),\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'post',\n })\n }\n } catch (_) {\n // Eat any errors in sending telemetry event\n }\n}\n\n/**\n * This is a quasi-persistent identifier used to dedupe recurring events. It's\n * generated from random data and completely anonymous.\n */\nconst getEnvID = (): string => {\n const conf = new Conf()\n const ENV_ID = 'envID'\n\n const val = conf.get(ENV_ID)\n if (val) {\n return val as string\n }\n\n const generated = randomBytes(32).toString('hex')\n conf.set(ENV_ID, generated)\n return generated\n}\n\nconst getProjectID = (payload: Payload, packageJSON: PackageJSON): string => {\n const projectID =\n getGitID(payload) ||\n getPackageJSONID(payload, packageJSON) ||\n payload.config.serverURL ||\n process.cwd()\n return oneWayHash(projectID, payload.secret)\n}\n\nconst getGitID = (payload: Payload) => {\n try {\n const originBuffer = execSync('git config --local --get remote.origin.url', {\n stdio: 'pipe',\n timeout: 1000,\n })\n\n return oneWayHash(String(originBuffer).trim(), payload.secret)\n } catch (_) {\n return null\n }\n}\n\nconst getPackageJSON = async (): Promise<{\n packageJSON?: PackageJSON\n packageJSONPath: string\n}> => {\n let packageJSONPath = path.resolve(process.cwd(), 'package.json')\n\n if (!fs.existsSync(packageJSONPath)) {\n // Old logic\n const filename = fileURLToPath(import.meta.url)\n const dirname = path.dirname(filename)\n packageJSONPath = await findUp('package.json', { cwd: dirname })\n const jsonContent: PackageJSON = JSON.parse(fs.readFileSync(packageJSONPath, 'utf-8'))\n return { packageJSON: jsonContent, packageJSONPath }\n }\n\n const packageJSON: PackageJSON = JSON.parse(fs.readFileSync(packageJSONPath, 'utf-8'))\n return { packageJSON, packageJSONPath }\n}\n\nconst getPackageJSONID = (payload: Payload, packageJSON: PackageJSON): string => {\n return oneWayHash(packageJSON.name, payload.secret)\n}\n\nexport const getPayloadVersion = (packageJSON: PackageJSON): string => {\n return packageJSON?.dependencies?.payload ?? ''\n}\n\nexport const getLocalizationInfo = (\n payload: Payload,\n): Pick<BaseEvent, 'locales' | 'localizationDefaultLocale' | 'localizationEnabled'> => {\n if (!payload.config.localization) {\n return {\n locales: [],\n localizationDefaultLocale: null,\n localizationEnabled: false,\n }\n }\n\n return {\n locales: payload.config.localization.localeCodes,\n localizationDefaultLocale: payload.config.localization.defaultLocale,\n localizationEnabled: true,\n }\n}\n"],"names":["execSync","ciInfo","ConfImport","randomBytes","findUp","fs","path","fileURLToPath","oneWayHash","Conf","default","baseEvent","sendEvent","event","payload","packageJSON","packageJSONPath","getPackageJSON","ciName","isCI","name","envID","getEnvID","nodeEnv","process","env","NODE_ENV","nodeVersion","version","payloadVersion","getPayloadVersion","projectID","getProjectID","getLocalizationInfo","dbAdapter","db","emailAdapter","email","uploadAdapters","config","upload","adapters","PAYLOAD_TELEMETRY_DEBUG","logger","info","msg","telemetry","fetch","body","JSON","stringify","headers","method","_","conf","ENV_ID","val","get","generated","toString","set","getGitID","getPackageJSONID","serverURL","cwd","secret","originBuffer","stdio","timeout","String","trim","resolve","existsSync","filename","url","dirname","jsonContent","parse","readFileSync","dependencies","localization","locales","localizationDefaultLocale","localizationEnabled","localeCodes","defaultLocale"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,QAAQ,QAAQ,gBAAe;AACxC,OAAOC,YAAY,UAAS;AAC5B,OAAOC,gBAAgB,OAAM;AAC7B,SAASC,WAAW,QAAQ,SAAQ;AACpC,OAAOC,YAAY,UAAS;AAC5B,OAAOC,QAAQ,KAAI;AACnB,OAAOC,UAAU,OAAM;AACvB,SAASC,aAAa,QAAQ,MAAK;AAMnC,SAASC,UAAU,QAAQ,kBAAiB;AAE5C,MAAMC,OAAQP,WAAWQ,OAAO,IAAIR;AA8BpC,IAAIS,YAA8B;AAElC,OAAO,MAAMC,YAAY,OAAO,EAAEC,KAAK,EAAEC,OAAO,EAAQ;IACtD,IAAI;QACF,MAAM,EAAEC,WAAW,EAAEC,eAAe,EAAE,GAAG,MAAMC;QAE/C,oCAAoC;QACpC,IAAI,CAACN,WAAW;YACdA,YAAY;gBACVO,QAAQjB,OAAOkB,IAAI,GAAGlB,OAAOmB,IAAI,GAAG;gBACpCC,OAAOC;gBACPH,MAAMlB,OAAOkB,IAAI;gBACjBI,SAASC,QAAQC,GAAG,CAACC,QAAQ,IAAI;gBACjCC,aAAaH,QAAQI,OAAO;gBAC5B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