payload 3.0.0-beta.95 → 3.0.0-beta.97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/RichText.d.ts +4 -3
- package/dist/admin/RichText.d.ts.map +1 -1
- package/dist/admin/RichText.js.map +1 -1
- package/dist/admin/elements/Tab.d.ts +1 -1
- package/dist/admin/elements/Tab.d.ts.map +1 -1
- package/dist/admin/elements/Tab.js.map +1 -1
- package/dist/admin/forms/Description.d.ts +1 -1
- package/dist/admin/forms/Description.d.ts.map +1 -1
- package/dist/admin/forms/Description.js.map +1 -1
- package/dist/admin/forms/Error.d.ts +1 -1
- package/dist/admin/forms/Error.d.ts.map +1 -1
- package/dist/admin/forms/Error.js.map +1 -1
- package/dist/admin/forms/Form.d.ts +1 -1
- package/dist/admin/forms/Form.d.ts.map +1 -1
- package/dist/admin/forms/Form.js.map +1 -1
- package/dist/admin/forms/Label.d.ts +1 -1
- package/dist/admin/forms/Label.d.ts.map +1 -1
- package/dist/admin/forms/Label.js.map +1 -1
- package/dist/admin/types.d.ts +5 -5
- package/dist/admin/types.d.ts.map +1 -1
- package/dist/admin/types.js.map +1 -1
- package/dist/admin/views/types.d.ts +1 -1
- package/dist/admin/views/types.d.ts.map +1 -1
- package/dist/admin/views/types.js.map +1 -1
- package/dist/auth/executeAccess.d.ts.map +1 -1
- package/dist/auth/executeAccess.js +6 -2
- package/dist/auth/executeAccess.js.map +1 -1
- package/dist/auth/getAuthFields.d.ts.map +1 -1
- package/dist/auth/getAuthFields.js +3 -1
- package/dist/auth/getAuthFields.js.map +1 -1
- package/dist/auth/isLocked.d.ts.map +1 -1
- package/dist/auth/isLocked.js +3 -1
- package/dist/auth/isLocked.js.map +1 -1
- package/dist/auth/operations/auth.d.ts +1 -1
- package/dist/auth/operations/auth.d.ts.map +1 -1
- package/dist/auth/operations/auth.js +3 -1
- package/dist/auth/operations/auth.js.map +1 -1
- package/dist/auth/operations/forgotPassword.d.ts.map +1 -1
- package/dist/auth/operations/forgotPassword.js +6 -2
- package/dist/auth/operations/forgotPassword.js.map +1 -1
- package/dist/auth/operations/login.d.ts.map +1 -1
- package/dist/auth/operations/login.js +6 -2
- package/dist/auth/operations/login.js.map +1 -1
- package/dist/auth/operations/logout.d.ts.map +1 -1
- package/dist/auth/operations/logout.js +6 -2
- package/dist/auth/operations/logout.js.map +1 -1
- package/dist/auth/operations/me.d.ts.map +1 -1
- package/dist/auth/operations/me.js +6 -2
- package/dist/auth/operations/me.js.map +1 -1
- package/dist/auth/operations/refresh.d.ts.map +1 -1
- package/dist/auth/operations/refresh.js +6 -2
- package/dist/auth/operations/refresh.js.map +1 -1
- package/dist/auth/operations/registerFirstUser.d.ts.map +1 -1
- package/dist/auth/operations/registerFirstUser.js +6 -2
- package/dist/auth/operations/registerFirstUser.js.map +1 -1
- package/dist/auth/operations/resetPassword.d.ts.map +1 -1
- package/dist/auth/operations/resetPassword.js +6 -2
- package/dist/auth/operations/resetPassword.js.map +1 -1
- package/dist/auth/operations/unlock.d.ts.map +1 -1
- package/dist/auth/operations/unlock.js +3 -1
- package/dist/auth/operations/unlock.js.map +1 -1
- package/dist/auth/operations/verifyEmail.d.ts.map +1 -1
- package/dist/auth/operations/verifyEmail.js +9 -3
- package/dist/auth/operations/verifyEmail.js.map +1 -1
- package/dist/auth/strategies/jwt.js.map +1 -1
- package/dist/auth/strategies/local/authenticate.d.ts.map +1 -1
- package/dist/auth/strategies/local/authenticate.js +3 -1
- package/dist/auth/strategies/local/authenticate.js.map +1 -1
- package/dist/auth/strategies/local/register.d.ts.map +1 -1
- package/dist/auth/strategies/local/register.js +3 -1
- package/dist/auth/strategies/local/register.js.map +1 -1
- package/dist/auth/strategies/local/resetLoginAttempts.d.ts.map +1 -1
- package/dist/auth/strategies/local/resetLoginAttempts.js +3 -1
- package/dist/auth/strategies/local/resetLoginAttempts.js.map +1 -1
- package/dist/auth/types.d.ts +5 -5
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/auth/types.js.map +1 -1
- package/dist/bin/generateImportMap/iterateFields.js.map +1 -1
- package/dist/bin/generateTypes.d.ts.map +1 -1
- package/dist/bin/generateTypes.js +7 -3
- package/dist/bin/generateTypes.js.map +1 -1
- package/dist/bin/index.d.ts.map +1 -1
- package/dist/bin/index.js +3 -1
- package/dist/bin/index.js.map +1 -1
- package/dist/collections/config/client.d.ts +2 -2
- package/dist/collections/config/client.d.ts.map +1 -1
- package/dist/collections/config/client.js.map +1 -1
- package/dist/collections/config/reservedFieldNames.spec.js +4 -4
- package/dist/collections/config/reservedFieldNames.spec.js.map +1 -1
- package/dist/collections/config/sanitize.d.ts.map +1 -1
- package/dist/collections/config/sanitize.js +15 -6
- package/dist/collections/config/sanitize.js.map +1 -1
- package/dist/collections/config/types.d.ts +9 -9
- package/dist/collections/config/types.d.ts.map +1 -1
- package/dist/collections/config/types.js.map +1 -1
- package/dist/collections/dataloader.d.ts +1 -1
- package/dist/collections/dataloader.d.ts.map +1 -1
- package/dist/collections/dataloader.js +3 -1
- package/dist/collections/dataloader.js.map +1 -1
- package/dist/collections/operations/create.d.ts.map +1 -1
- package/dist/collections/operations/create.js +3 -1
- package/dist/collections/operations/create.js.map +1 -1
- package/dist/collections/operations/delete.d.ts.map +1 -1
- package/dist/collections/operations/delete.js +3 -1
- package/dist/collections/operations/delete.js.map +1 -1
- package/dist/collections/operations/deleteByID.d.ts.map +1 -1
- package/dist/collections/operations/deleteByID.js +9 -3
- package/dist/collections/operations/deleteByID.js.map +1 -1
- package/dist/collections/operations/duplicate.d.ts.map +1 -1
- package/dist/collections/operations/duplicate.js +9 -3
- package/dist/collections/operations/duplicate.js.map +1 -1
- package/dist/collections/operations/findByID.d.ts.map +1 -1
- package/dist/collections/operations/findByID.js +6 -2
- package/dist/collections/operations/findByID.js.map +1 -1
- package/dist/collections/operations/findVersionByID.d.ts.map +1 -1
- package/dist/collections/operations/findVersionByID.js +9 -3
- package/dist/collections/operations/findVersionByID.js.map +1 -1
- package/dist/collections/operations/restoreVersion.d.ts.map +1 -1
- package/dist/collections/operations/restoreVersion.js +6 -2
- package/dist/collections/operations/restoreVersion.js.map +1 -1
- package/dist/collections/operations/update.d.ts.map +1 -1
- package/dist/collections/operations/update.js +3 -1
- package/dist/collections/operations/update.js.map +1 -1
- package/dist/collections/operations/updateByID.d.ts.map +1 -1
- package/dist/collections/operations/updateByID.js +9 -3
- package/dist/collections/operations/updateByID.js.map +1 -1
- package/dist/collections/operations/utils.d.ts +1 -1
- package/dist/collections/operations/utils.d.ts.map +1 -1
- package/dist/collections/operations/utils.js.map +1 -1
- package/dist/config/client.d.ts +2 -2
- package/dist/config/client.d.ts.map +1 -1
- package/dist/config/client.js.map +1 -1
- package/dist/config/find.d.ts.map +1 -1
- package/dist/config/find.js +9 -3
- package/dist/config/find.js.map +1 -1
- package/dist/config/sanitize.d.ts.map +1 -1
- package/dist/config/sanitize.js +10 -5
- package/dist/config/sanitize.js.map +1 -1
- package/dist/config/types.d.ts +164 -35
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js.map +1 -1
- package/dist/database/combineQueries.d.ts +1 -1
- package/dist/database/combineQueries.d.ts.map +1 -1
- package/dist/database/combineQueries.js +9 -3
- package/dist/database/combineQueries.js.map +1 -1
- package/dist/database/getLocalizedPaths.d.ts.map +1 -1
- package/dist/database/getLocalizedPaths.js +3 -1
- package/dist/database/getLocalizedPaths.js.map +1 -1
- package/dist/database/migrations/readMigrationFiles.d.ts.map +1 -1
- package/dist/database/migrations/readMigrationFiles.js +3 -1
- package/dist/database/migrations/readMigrationFiles.js.map +1 -1
- package/dist/database/types.d.ts +3 -3
- package/dist/database/types.d.ts.map +1 -1
- package/dist/database/types.js.map +1 -1
- package/dist/fields/config/sanitize.d.ts +2 -1
- package/dist/fields/config/sanitize.d.ts.map +1 -1
- package/dist/fields/config/sanitize.js +28 -8
- package/dist/fields/config/sanitize.js.map +1 -1
- package/dist/fields/config/types.d.ts +56 -56
- package/dist/fields/config/types.d.ts.map +1 -1
- package/dist/fields/config/types.js.map +1 -1
- package/dist/fields/hooks/afterChange/index.d.ts +2 -2
- package/dist/fields/hooks/afterChange/index.d.ts.map +1 -1
- package/dist/fields/hooks/afterChange/index.js.map +1 -1
- package/dist/fields/hooks/afterChange/promise.d.ts +2 -2
- package/dist/fields/hooks/afterChange/promise.d.ts.map +1 -1
- package/dist/fields/hooks/afterChange/promise.js.map +1 -1
- package/dist/fields/hooks/afterChange/traverseFields.d.ts +2 -2
- package/dist/fields/hooks/afterChange/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/afterChange/traverseFields.js.map +1 -1
- package/dist/fields/hooks/afterRead/index.d.ts +2 -2
- package/dist/fields/hooks/afterRead/index.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/index.js +3 -1
- package/dist/fields/hooks/afterRead/index.js.map +1 -1
- package/dist/fields/hooks/afterRead/promise.d.ts +2 -2
- package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/promise.js +6 -2
- package/dist/fields/hooks/afterRead/promise.js.map +1 -1
- package/dist/fields/hooks/afterRead/traverseFields.d.ts +2 -2
- package/dist/fields/hooks/afterRead/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/traverseFields.js.map +1 -1
- package/dist/fields/hooks/beforeChange/getExistingRowDoc.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/getExistingRowDoc.js +6 -2
- package/dist/fields/hooks/beforeChange/getExistingRowDoc.js.map +1 -1
- package/dist/fields/hooks/beforeChange/index.d.ts +2 -2
- package/dist/fields/hooks/beforeChange/index.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/index.js.map +1 -1
- package/dist/fields/hooks/beforeChange/promise.d.ts +2 -2
- package/dist/fields/hooks/beforeChange/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/promise.js +18 -6
- package/dist/fields/hooks/beforeChange/promise.js.map +1 -1
- package/dist/fields/hooks/beforeChange/traverseFields.d.ts +2 -2
- package/dist/fields/hooks/beforeChange/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/traverseFields.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/index.d.ts +2 -2
- package/dist/fields/hooks/beforeValidate/index.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/index.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/promise.d.ts +2 -2
- package/dist/fields/hooks/beforeValidate/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/promise.js +21 -7
- package/dist/fields/hooks/beforeValidate/promise.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/traverseFields.d.ts +2 -2
- package/dist/fields/hooks/beforeValidate/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/traverseFields.js.map +1 -1
- package/dist/fields/validations.d.ts +1 -1
- package/dist/fields/validations.d.ts.map +1 -1
- package/dist/fields/validations.js +57 -19
- package/dist/fields/validations.js.map +1 -1
- package/dist/globals/config/sanitize.d.ts.map +1 -1
- package/dist/globals/config/sanitize.js +45 -16
- package/dist/globals/config/sanitize.js.map +1 -1
- package/dist/globals/config/types.d.ts +2 -2
- package/dist/globals/config/types.d.ts.map +1 -1
- package/dist/globals/config/types.js.map +1 -1
- package/dist/globals/operations/docAccess.d.ts.map +1 -1
- package/dist/globals/operations/docAccess.js +3 -1
- package/dist/globals/operations/docAccess.js.map +1 -1
- package/dist/globals/operations/findVersionByID.d.ts.map +1 -1
- package/dist/globals/operations/findVersionByID.js +12 -4
- package/dist/globals/operations/findVersionByID.js.map +1 -1
- package/dist/globals/operations/restoreVersion.d.ts.map +1 -1
- package/dist/globals/operations/restoreVersion.js +3 -1
- package/dist/globals/operations/restoreVersion.js.map +1 -1
- package/dist/globals/operations/update.d.ts.map +1 -1
- package/dist/globals/operations/update.js +3 -1
- package/dist/globals/operations/update.js.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -7
- package/dist/index.js.map +1 -1
- package/dist/preferences/operations/findOne.d.ts.map +1 -1
- package/dist/preferences/operations/findOne.js +3 -1
- package/dist/preferences/operations/findOne.js.map +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/uploads/cropImage.d.ts.map +1 -1
- package/dist/uploads/cropImage.js +3 -1
- package/dist/uploads/cropImage.js.map +1 -1
- package/dist/uploads/deleteAssociatedFiles.d.ts.map +1 -1
- package/dist/uploads/deleteAssociatedFiles.js +3 -1
- package/dist/uploads/deleteAssociatedFiles.js.map +1 -1
- package/dist/uploads/docWithFilenameExists.d.ts.map +1 -1
- package/dist/uploads/docWithFilenameExists.js +3 -1
- package/dist/uploads/docWithFilenameExists.js.map +1 -1
- package/dist/uploads/formatFilesize.d.ts.map +1 -1
- package/dist/uploads/formatFilesize.js +3 -1
- package/dist/uploads/formatFilesize.js.map +1 -1
- package/dist/uploads/generateFileData.d.ts.map +1 -1
- package/dist/uploads/generateFileData.js +12 -4
- package/dist/uploads/generateFileData.js.map +1 -1
- package/dist/uploads/getBaseFields.d.ts.map +1 -1
- package/dist/uploads/getBaseFields.js +6 -2
- package/dist/uploads/getBaseFields.js.map +1 -1
- package/dist/uploads/getExternalFile.d.ts.map +1 -1
- package/dist/uploads/getExternalFile.js +3 -1
- package/dist/uploads/getExternalFile.js.map +1 -1
- package/dist/uploads/imageResizer.d.ts.map +1 -1
- package/dist/uploads/imageResizer.js +35 -13
- package/dist/uploads/imageResizer.js.map +1 -1
- package/dist/uploads/optionallyAppendMetadata.d.ts.map +1 -1
- package/dist/uploads/optionallyAppendMetadata.js +3 -1
- package/dist/uploads/optionallyAppendMetadata.js.map +1 -1
- package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
- package/dist/utilities/configToJSONSchema.js +12 -4
- package/dist/utilities/configToJSONSchema.js.map +1 -1
- package/dist/utilities/createArrayFromCommaDelineated.d.ts.map +1 -1
- package/dist/utilities/createArrayFromCommaDelineated.js +3 -1
- package/dist/utilities/createArrayFromCommaDelineated.js.map +1 -1
- package/dist/utilities/createLocalReq.d.ts.map +1 -1
- package/dist/utilities/createLocalReq.js +28 -12
- package/dist/utilities/createLocalReq.js.map +1 -1
- package/dist/utilities/deepCopyObject.d.ts.map +1 -1
- package/dist/utilities/deepCopyObject.js +15 -5
- package/dist/utilities/deepCopyObject.js.map +1 -1
- package/dist/utilities/dependencies/versionUtils.d.ts.map +1 -1
- package/dist/utilities/dependencies/versionUtils.js +24 -8
- package/dist/utilities/dependencies/versionUtils.js.map +1 -1
- package/dist/utilities/getEntityPolicies.d.ts.map +1 -1
- package/dist/utilities/getEntityPolicies.js +9 -3
- package/dist/utilities/getEntityPolicies.js.map +1 -1
- package/dist/utilities/getObjectDotNotation.d.ts.map +1 -1
- package/dist/utilities/getObjectDotNotation.js +3 -1
- package/dist/utilities/getObjectDotNotation.js.map +1 -1
- package/dist/utilities/getSiblingData.d.ts.map +1 -1
- package/dist/utilities/getSiblingData.js +3 -1
- package/dist/utilities/getSiblingData.js.map +1 -1
- package/dist/utilities/isReactComponent.d.ts +3 -3
- package/dist/utilities/isReactComponent.d.ts.map +1 -1
- package/dist/utilities/isReactComponent.js.map +1 -1
- package/dist/utilities/isValidID.d.ts +1 -1
- package/dist/utilities/isValidID.d.ts.map +1 -1
- package/dist/utilities/isValidID.js +3 -1
- package/dist/utilities/isValidID.js.map +1 -1
- package/dist/utilities/logger.d.ts +8 -3
- package/dist/utilities/logger.d.ts.map +1 -1
- package/dist/utilities/logger.js +22 -14
- package/dist/utilities/logger.js.map +1 -1
- package/dist/utilities/reduceFieldsToValues.d.ts.map +1 -1
- package/dist/utilities/reduceFieldsToValues.js +3 -1
- package/dist/utilities/reduceFieldsToValues.js.map +1 -1
- package/dist/utilities/telemetry/conf/index.d.ts +1 -1
- package/dist/utilities/telemetry/conf/index.d.ts.map +1 -1
- package/dist/utilities/telemetry/conf/index.js +8 -8
- package/dist/utilities/telemetry/conf/index.js.map +1 -1
- package/dist/utilities/timestamp.d.ts.map +1 -1
- package/dist/utilities/timestamp.js +3 -1
- package/dist/utilities/timestamp.js.map +1 -1
- package/dist/versions/drafts/appendVersionToQueryKey.js +1 -1
- package/dist/versions/drafts/appendVersionToQueryKey.js.map +1 -1
- package/dist/versions/drafts/getQueryDraftsSort.d.ts.map +1 -1
- package/dist/versions/drafts/getQueryDraftsSort.js +3 -1
- package/dist/versions/drafts/getQueryDraftsSort.js.map +1 -1
- package/dist/versions/saveVersion.d.ts.map +1 -1
- package/dist/versions/saveVersion.js +18 -6
- package/dist/versions/saveVersion.js.map +1 -1
- package/dist/versions/types.d.ts +4 -4
- package/dist/versions/types.d.ts.map +1 -1
- package/dist/versions/types.js.map +1 -1
- package/package.json +7 -8
|
@@ -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 '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,i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AAG2F,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) {\n return false\n }\n\n const isMarkedRequired = 'required' in field && field.required === true\n if (fieldAffectsData(field) && isMarkedRequired) {\n return true\n }\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) {\n return fieldType\n }\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) {\n requiredFieldNames.add(field.name)\n }\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;QACjB,OAAO;IACT;IAEA,MAAMI,mBAAmB,cAAcL,SAASA,MAAMM,QAAQ,KAAK;IACnE,IAAIZ,iBAAiBM,UAAUK,kBAAkB;QAC/C,OAAO;IACT;IAEA,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,KAAK;QACrB;QAEA,OAAOD;IACT;AACF;AAEA,SAASE,sBACPC,QAA+D;IAE/D,MAAMC,aAAa;WAAID;KAAS,CAACE,MAAM,CAAC,CAACC,KAAK,EAAEC,IAAI,EAAE;QACpDD,GAAG,CAACC,KAAK,G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,CAAC,CAACC,KAAKyE;QACbzE,GAAG,CAACyE,OAAOxE,IAAI,CAAC,GAAGsE,mBAAmBnD,QAAQqD,QAAQ3C,0BAA0BT;QAChF,OAAOrB;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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createArrayFromCommaDelineated.d.ts","sourceRoot":"","sources":["../../src/utilities/createArrayFromCommaDelineated.ts"],"names":[],"mappings":"AAAA,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"createArrayFromCommaDelineated.d.ts","sourceRoot":"","sources":["../../src/utilities/createArrayFromCommaDelineated.ts"],"names":[],"mappings":"AAAA,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAQtE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/createArrayFromCommaDelineated.ts"],"sourcesContent":["export function createArrayFromCommaDelineated(input: string): string[] {\n if (Array.isArray(input)) return input\n if (input.indexOf(',') > -1) {\n return input.split(',')\n }\n return [input]\n}\n"],"names":["createArrayFromCommaDelineated","input","Array","isArray","indexOf","split"],"mappings":"AAAA,OAAO,SAASA,+BAA+BC,KAAa;IAC1D,IAAIC,MAAMC,OAAO,CAACF,QAAQ,OAAOA;
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/createArrayFromCommaDelineated.ts"],"sourcesContent":["export function createArrayFromCommaDelineated(input: string): string[] {\n if (Array.isArray(input)) {\n return input\n }\n if (input.indexOf(',') > -1) {\n return input.split(',')\n }\n return [input]\n}\n"],"names":["createArrayFromCommaDelineated","input","Array","isArray","indexOf","split"],"mappings":"AAAA,OAAO,SAASA,+BAA+BC,KAAa;IAC1D,IAAIC,MAAMC,OAAO,CAACF,QAAQ;QACxB,OAAOA;IACT;IACA,IAAIA,MAAMG,OAAO,CAAC,OAAO,CAAC,GAAG;QAC3B,OAAOH,MAAMI,KAAK,CAAC;IACrB;IACA,OAAO;QAACJ;KAAM;AAChB"}
|
|
@@ -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,cAAc,EAAE,MAAM,mBAAmB,CAAA;
|
|
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,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAoEvD,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,cAAc,CAAA;IACpB,IAAI,CAAC,EAAE,IAAI,CAAA;CACZ,EACD,OAAO,EAAE,OAAO,KACb,OAAO,CAAC,cAAc,CAAC,CAAA;AAC5B,eAAO,MAAM,cAAc,EAAE,cAyC5B,CAAA"}
|
|
@@ -26,7 +26,9 @@ const attachFakeURLProperties = (req)=>{
|
|
|
26
26
|
* since they do not exist yet we can safely ignore the error.
|
|
27
27
|
*/ let urlObject;
|
|
28
28
|
function getURLObject() {
|
|
29
|
-
if (urlObject)
|
|
29
|
+
if (urlObject) {
|
|
30
|
+
return urlObject;
|
|
31
|
+
}
|
|
30
32
|
const urlToUse = req?.url || req.payload.config?.serverURL || 'http://localhost';
|
|
31
33
|
try {
|
|
32
34
|
urlObject = new URL(urlToUse);
|
|
@@ -35,15 +37,27 @@ const attachFakeURLProperties = (req)=>{
|
|
|
35
37
|
}
|
|
36
38
|
return urlObject;
|
|
37
39
|
}
|
|
38
|
-
if (!req.host)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (!req.
|
|
45
|
-
|
|
46
|
-
|
|
40
|
+
if (!req.host) {
|
|
41
|
+
req.host = getURLObject().host;
|
|
42
|
+
}
|
|
43
|
+
if (!req.protocol) {
|
|
44
|
+
req.protocol = getURLObject().protocol;
|
|
45
|
+
}
|
|
46
|
+
if (!req.pathname) {
|
|
47
|
+
req.pathname = getURLObject().pathname;
|
|
48
|
+
}
|
|
49
|
+
if (!req.searchParams) {
|
|
50
|
+
// @ts-expect-error
|
|
51
|
+
req.searchParams = getURLObject().searchParams;
|
|
52
|
+
}
|
|
53
|
+
if (!req.origin) {
|
|
54
|
+
// @ts-expect-error
|
|
55
|
+
req.origin = getURLObject().origin;
|
|
56
|
+
}
|
|
57
|
+
if (!req?.url) {
|
|
58
|
+
// @ts-expect-error
|
|
59
|
+
req.url = getURLObject().href;
|
|
60
|
+
}
|
|
47
61
|
};
|
|
48
62
|
export const createLocalReq = async ({ context, fallbackLocale, locale: localeArg, req = {}, user }, payload)=>{
|
|
49
63
|
if (payload.config?.localization) {
|
|
@@ -62,8 +76,10 @@ export const createLocalReq = async ({ context, fallbackLocale, locale: localeAr
|
|
|
62
76
|
config: payload.config,
|
|
63
77
|
language: payload.config.i18n.fallbackLanguage
|
|
64
78
|
});
|
|
65
|
-
|
|
66
|
-
|
|
79
|
+
if (!req.headers) {
|
|
80
|
+
// @ts-expect-error
|
|
81
|
+
req.headers = new Headers();
|
|
82
|
+
}
|
|
67
83
|
req.context = getRequestContext(req, context);
|
|
68
84
|
req.payloadAPI = req?.payloadAPI || 'local';
|
|
69
85
|
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 { PayloadRequest } from '../types/index.js'\n\nimport { getDataLoader } from '../collections/dataloader.js'\nimport { getLocalI18n } from '../translations/getLocalI18n.js'\n\nfunction getRequestContext(\n req: PayloadRequest = { context: null } as PayloadRequest,\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: PayloadRequest) => {\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
|
|
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 { PayloadRequest } from '../types/index.js'\n\nimport { getDataLoader } from '../collections/dataloader.js'\nimport { getLocalI18n } from '../translations/getLocalI18n.js'\n\nfunction getRequestContext(\n req: PayloadRequest = { context: null } as PayloadRequest,\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: PayloadRequest) => {\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) {\n return urlObject\n }\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) {\n req.host = getURLObject().host\n }\n if (!req.protocol) {\n req.protocol = getURLObject().protocol\n }\n if (!req.pathname) {\n req.pathname = getURLObject().pathname\n }\n if (!req.searchParams) {\n // @ts-expect-error\n req.searchParams = getURLObject().searchParams\n }\n if (!req.origin) {\n // @ts-expect-error\n req.origin = getURLObject().origin\n }\n if (!req?.url) {\n // @ts-expect-error\n req.url = getURLObject().href\n }\n}\n\ntype CreateLocalReq = (\n options: {\n context?: RequestContext\n fallbackLocale?: string\n locale?: string\n req?: PayloadRequest\n user?: User\n },\n payload: Payload,\n) => Promise<PayloadRequest>\nexport const createLocalReq: CreateLocalReq = async (\n { context, fallbackLocale, locale: localeArg, req = {} as PayloadRequest, user },\n payload,\n) => {\n if (payload.config?.localization) {\n const locale = localeArg === '*' ? 'all' : localeArg\n const defaultLocale = payload.config.localization.defaultLocale\n const localeCandidate = locale || req?.locale || req?.query?.locale\n req.locale =\n localeCandidate && typeof localeCandidate === 'string' ? localeCandidate : 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 const i18n =\n req?.i18n ||\n (await getLocalI18n({ config: payload.config, language: payload.config.i18n.fallbackLanguage }))\n\n if (!req.headers) {\n // @ts-expect-error\n req.headers = new Headers()\n }\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","localization","defaultLocale","localeCandidate","query","fallbackLocaleFromConfig","locales","find","code","i18n","language","fallbackLanguage","headers","Headers","payloadAPI","t","payloadDataLoader","routeParams"],"mappings":"AAIA,SAASA,aAAa,QAAQ,+BAA8B;AAC5D,SAASC,YAAY,QAAQ,kCAAiC;AAE9D,SAASC,kBACPC,MAAsB;IAAEC,SAAS;AAAK,CAAmB,EACzDA,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;YACb,OAAOA;QACT;QACA,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,EAAE;QACbhB,IAAIgB,IAAI,GAAGR,eAAeQ,IAAI;IAChC;IACA,IAAI,CAAChB,IAAIiB,QAAQ,EAAE;QACjBjB,IAAIiB,QAAQ,GAAGT,eAAeS,QAAQ;IACxC;IACA,IAAI,CAACjB,IAAIkB,QAAQ,EAAE;QACjBlB,IAAIkB,QAAQ,GAAGV,eAAeU,QAAQ;IACxC;IACA,IAAI,CA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IAAIC;IACpB;IACAvC,IAAIC,OAAO,GAAGF,kBAAkBC,KAAKC;IACrCD,IAAIwC,UAAU,GAAGxC,KAAKwC,cAAc;IACpCxC,IAAIW,OAAO,GAAGA;IACdX,IAAImC,IAAI,GAAGA;IACXnC,IAAIyC,CAAC,GAAGN,KAAKM,CAAC;IACdzC,IAAI0B,IAAI,GAAGA,QAAQ1B,KAAK0B,QAAQ;IAChC1B,IAAI0C,iBAAiB,GAAG1C,KAAK0C,qBAAqB7C,cAAcG;IAChEA,IAAI2C,WAAW,GAAG3C,KAAK2C,eAAe,CAAC;IACvC3C,IAAI8B,KAAK,GAAG9B,KAAK8B,SAAS,CAAC;IAE3BxB,wBAAwBN;IAExB,OAAOA;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deepCopyObject.d.ts","sourceRoot":"","sources":["../../src/utilities/deepCopyObject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAuDlD,eAAO,MAAM,cAAc,GAAI,CAAC,KAAK,CAAC,KAAG,
|
|
1
|
+
{"version":3,"file":"deepCopyObject.d.ts","sourceRoot":"","sources":["../../src/utilities/deepCopyObject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAuDlD,eAAO,MAAM,cAAc,GAAI,CAAC,KAAK,CAAC,KAAG,CA2BxC,CAAA;AAQD;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,SAAS,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAkBrE;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,GAAE,OAAO,CAAC,GAAG,EAAE,GAAG,CAAiB,GAAG,CAAC,CAgE/F"}
|
|
@@ -46,14 +46,20 @@ function cloneArray(a, fn) {
|
|
|
46
46
|
return a2;
|
|
47
47
|
}
|
|
48
48
|
export const deepCopyObject = (o)=>{
|
|
49
|
-
if (typeof o !== 'object' || o === null)
|
|
50
|
-
|
|
49
|
+
if (typeof o !== 'object' || o === null) {
|
|
50
|
+
return o;
|
|
51
|
+
}
|
|
52
|
+
if (Array.isArray(o)) {
|
|
53
|
+
return cloneArray(o, deepCopyObject);
|
|
54
|
+
}
|
|
51
55
|
if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) {
|
|
52
56
|
return handler(o, deepCopyObject);
|
|
53
57
|
}
|
|
54
58
|
const o2 = {};
|
|
55
59
|
for(const k in o){
|
|
56
|
-
if (Object.hasOwnProperty.call(o, k) === false)
|
|
60
|
+
if (Object.hasOwnProperty.call(o, k) === false) {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
57
63
|
const cur = o[k];
|
|
58
64
|
if (typeof cur !== 'object' || cur === null) {
|
|
59
65
|
o2[k] = cur;
|
|
@@ -86,7 +92,9 @@ Benchmark: https://github.com/AlessioGr/fastest-deep-clone-json/blob/main/test/b
|
|
|
86
92
|
} else if (Array.isArray(value)) {
|
|
87
93
|
return value.map((e)=>typeof e !== 'object' || e === null ? e : deepCopyObjectSimple(e));
|
|
88
94
|
} else {
|
|
89
|
-
if (value instanceof Date)
|
|
95
|
+
if (value instanceof Date) {
|
|
96
|
+
return new Date(value);
|
|
97
|
+
}
|
|
90
98
|
const ret = {};
|
|
91
99
|
for(const k in value){
|
|
92
100
|
const v = value[k];
|
|
@@ -99,7 +107,9 @@ Benchmark: https://github.com/AlessioGr/fastest-deep-clone-json/blob/main/test/b
|
|
|
99
107
|
* A deepCopyObject implementation which is slower than deepCopyObject, but more correct.
|
|
100
108
|
* Can be used if correctness is more important than speed. Supports circular dependencies
|
|
101
109
|
*/ export function deepCopyObjectComplex(object, cache = new WeakMap()) {
|
|
102
|
-
if (object === null)
|
|
110
|
+
if (object === null) {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
103
113
|
if (cache.has(object)) {
|
|
104
114
|
return cache.get(object);
|
|
105
115
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/deepCopyObject.ts"],"sourcesContent":["import type { JsonValue } from '../types/index.js'\n\n/*\nMain deepCopyObject handling - from rfdc: https://github.com/davidmarkclements/rfdc/blob/master/index.js\n\nCopyright 2019 \"David Mark Clements <david.mark.clements@gmail.com>\"\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated\ndocumentation files (the \"Software\"), to deal in the Software without restriction, including without limitation\nthe rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and\nto permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions\nof the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED\nTO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\nTHE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF\nCONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\nIN THE SOFTWARE.\n*/\n\nfunction copyBuffer(cur) {\n if (cur instanceof Buffer) {\n return Buffer.from(cur)\n }\n\n return new cur.constructor(cur.buffer.slice(), cur.byteOffset, cur.length)\n}\n\nconst constructorHandlers = new Map()\nconstructorHandlers.set(Date, (o) => new Date(o))\nconstructorHandlers.set(Map, (o, fn) => new Map(cloneArray<any>(Array.from(o), fn)))\nconstructorHandlers.set(Set, (o, fn) => new Set(cloneArray(Array.from(o), fn)))\nlet handler = null\n\nfunction cloneArray<T>(a: T, fn): T {\n const keys = Object.keys(a)\n const a2 = new Array(keys.length)\n for (let i = 0; i < keys.length; i++) {\n const k = keys[i]\n const cur = a[k]\n if (typeof cur !== 'object' || cur === null) {\n a2[k] = cur\n } else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {\n a2[k] = handler(cur, fn)\n } else if (ArrayBuffer.isView(cur)) {\n a2[k] = copyBuffer(cur)\n } else {\n a2[k] = fn(cur)\n }\n }\n return a2 as T\n}\n\nexport const deepCopyObject = <T>(o: T): T => {\n if (typeof o !== 'object' || o === null) return o\n if (Array.isArray(o)) return cloneArray(o, deepCopyObject)\n if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) {\n return handler(o, deepCopyObject)\n }\n const o2 = {}\n for (const k in o) {\n if (Object.hasOwnProperty.call(o, k) === false) continue\n const cur = o[k]\n if (typeof cur !== 'object' || cur === null) {\n o2[k as string] = cur\n } else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {\n o2[k as string] = handler(cur, deepCopyObject)\n } else if (ArrayBuffer.isView(cur)) {\n o2[k as string] = copyBuffer(cur)\n } else {\n o2[k as string] = deepCopyObject(cur)\n }\n }\n return o2 as T\n}\n\n/*\nFast deepCopyObjectSimple handling - from fast-json-clone: https://github.com/rhysd/fast-json-clone\n\nBenchmark: https://github.com/AlessioGr/fastest-deep-clone-json/blob/main/test/benchmark.js\n*/\n\n/**\n * A deepCopyObject implementation which only works for JSON objects and arrays, and is faster than\n * JSON.parse(JSON.stringify(obj))\n *\n * @param value The JSON value to be cloned. There are two invariants. 1) It must not contain circles\n * as JSON does not allow it. This function will cause infinite loop for such values by\n * design. 2) It must contain JSON values only. Other values like `Date`, `Regexp`, `Map`,\n * `Set`, `Buffer`, ... are not allowed.\n * @returns The cloned JSON value.\n */\nexport function deepCopyObjectSimple<T extends JsonValue>(value: T): T {\n if (typeof value !== 'object' || value === null) {\n return value\n } else if (Array.isArray(value)) {\n return value.map((e) =>\n typeof e !== 'object' || e === null ? e : deepCopyObjectSimple(e),\n ) as T\n } else {\n if (value instanceof Date) return new Date(value) as unknown as T\n const ret: { [key: string]: T } = {}\n for (const k in value) {\n const v = value[k]\n ret[k] = typeof v !== 'object' || v === null ? v : (deepCopyObjectSimple(v as T) as any)\n }\n return ret as unknown as T\n }\n}\n\n/**\n * A deepCopyObject implementation which is slower than deepCopyObject, but more correct.\n * Can be used if correctness is more important than speed. Supports circular dependencies\n */\nexport function deepCopyObjectComplex<T>(object: T, cache: WeakMap<any, any> = new WeakMap()): T {\n if (object === null) return null\n\n if (cache.has(object)) {\n return cache.get(object)\n }\n\n // Handle Date\n if (object instanceof Date) {\n return new Date(object.getTime()) as unknown as T\n }\n\n // Handle RegExp\n if (object instanceof RegExp) {\n return new RegExp(object.source, object.flags) as unknown as T\n }\n\n // Handle Map\n if (object instanceof Map) {\n const clonedMap = new Map()\n cache.set(object, clonedMap)\n for (const [key, value] of object.entries()) {\n clonedMap.set(key, deepCopyObjectComplex(value, cache))\n }\n return clonedMap as unknown as T\n }\n\n // Handle Set\n if (object instanceof Set) {\n const clonedSet = new Set()\n cache.set(object, clonedSet)\n for (const value of object.values()) {\n clonedSet.add(deepCopyObjectComplex(value, cache))\n }\n return clonedSet as unknown as T\n }\n\n // Handle Array and Object\n if (typeof object === 'object' && object !== null) {\n if ('$$typeof' in object && typeof object.$$typeof === 'symbol') {\n return object\n }\n\n const clonedObject: any = Array.isArray(object)\n ? []\n : Object.create(Object.getPrototypeOf(object))\n cache.set(object, clonedObject)\n\n for (const key in object) {\n if (\n Object.prototype.hasOwnProperty.call(object, key) ||\n Object.getOwnPropertySymbols(object).includes(key as any)\n ) {\n clonedObject[key] = deepCopyObjectComplex(object[key], cache)\n }\n }\n\n return clonedObject as T\n }\n\n // Handle all other cases\n return object\n}\n"],"names":["copyBuffer","cur","Buffer","from","constructor","buffer","slice","byteOffset","length","constructorHandlers","Map","set","Date","o","fn","cloneArray","Array","Set","handler","a","keys","Object","a2","i","k","get","ArrayBuffer","isView","deepCopyObject","isArray","o2","hasOwnProperty","call","deepCopyObjectSimple","value","map","e","ret","v","deepCopyObjectComplex","object","cache","WeakMap","has","getTime","RegExp","source","flags","clonedMap","key","entries","clonedSet","values","add","$$typeof","clonedObject","create","getPrototypeOf","prototype","getOwnPropertySymbols","includes"],"mappings":"AAEA;;;;;;;;;;;;;;;;;;AAkBA,GAEA,SAASA,WAAWC,GAAG;IACrB,IAAIA,eAAeC,QAAQ;QACzB,OAAOA,OAAOC,IAAI,CAACF;IACrB;IAEA,OAAO,IAAIA,IAAIG,WAAW,CAACH,IAAII,MAAM,CAACC,KAAK,IAAIL,IAAIM,UAAU,EAAEN,IAAIO,MAAM;AAC3E;AAEA,MAAMC,sBAAsB,IAAIC;AAChCD,oBAAoBE,GAAG,CAACC,MAAM,CAACC,IAAM,IAAID,KAAKC;AAC9CJ,oBAAoBE,GAAG,CAACD,KAAK,CAACG,GAAGC,KAAO,IAAIJ,IAAIK,WAAgBC,MAAMb,IAAI,CAACU,IAAIC;AAC/EL,oBAAoBE,GAAG,CAACM,KAAK,CAACJ,GAAGC,KAAO,IAAIG,IAAIF,WAAWC,MAAMb,IAAI,CAACU,IAAIC;AAC1E,IAAII,UAAU;AAEd,SAASH,WAAcI,CAAI,EAAEL,EAAE;IAC7B,MAAMM,OAAOC,OAAOD,IAAI,CAACD;IACzB,MAAMG,KAAK,IAAIN,MAAMI,KAAKZ,MAAM;IAChC,IAAK,IAAIe,IAAI,GAAGA,IAAIH,KAAKZ,MAAM,EAAEe,IAAK;QACpC,MAAMC,IAAIJ,IAAI,CAACG,EAAE;QACjB,MAAMtB,MAAMkB,CAAC,CAACK,EAAE;QAChB,IAAI,OAAOvB,QAAQ,YAAYA,QAAQ,MAAM;YAC3CqB,EAAE,CAACE,EAAE,GAAGvB;QACV,OAAO,IAAIA,IAAIG,WAAW,KAAKiB,UAAWH,CAAAA,UAAUT,oBAAoBgB,GAAG,CAACxB,IAAIG,WAAW,CAAA,GAAI;YAC7FkB,EAAE,CAACE,EAAE,GAAGN,QAAQjB,KAAKa;QACvB,OAAO,IAAIY,YAAY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AYA,WAAW,MAAM;QACjD,IAAI,cAAcA,UAAU,OAAOA,OAAOc,QAAQ,KAAK,UAAU;YAC/D,OAAOd;QACT;QAEA,MAAMe,eAAoBvC,MAAMa,OAAO,CAACW,UACpC,EAAE,GACFnB,OAAOmC,MAAM,CAACnC,OAAOoC,cAAc,CAACjB;QACxCC,MAAM9B,GAAG,CAAC6B,QAAQe;QAElB,IAAK,MAAMN,OAAOT,OAAQ;YACxB,IACEnB,OAAOqC,SAAS,CAAC3B,cAAc,CAACC,IAAI,CAACQ,QAAQS,QAC7C5B,OAAOsC,qBAAqB,CAACnB,QAAQoB,QAAQ,CAACX,MAC9C;gBACAM,YAAY,CAACN,IAAI,GAAGV,sBAAsBC,MAAM,CAACS,IAAI,EAAER;YACzD;QACF;QAEA,OAAOc;IACT;IAEA,yBAAyB;IACzB,OAAOf;AACT"}
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/deepCopyObject.ts"],"sourcesContent":["import type { JsonValue } from '../types/index.js'\n\n/*\nMain deepCopyObject handling - from rfdc: https://github.com/davidmarkclements/rfdc/blob/master/index.js\n\nCopyright 2019 \"David Mark Clements <david.mark.clements@gmail.com>\"\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated\ndocumentation files (the \"Software\"), to deal in the Software without restriction, including without limitation\nthe rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and\nto permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions\nof the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED\nTO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\nTHE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF\nCONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\nIN THE SOFTWARE.\n*/\n\nfunction copyBuffer(cur) {\n if (cur instanceof Buffer) {\n return Buffer.from(cur)\n }\n\n return new cur.constructor(cur.buffer.slice(), cur.byteOffset, cur.length)\n}\n\nconst constructorHandlers = new Map()\nconstructorHandlers.set(Date, (o) => new Date(o))\nconstructorHandlers.set(Map, (o, fn) => new Map(cloneArray<any>(Array.from(o), fn)))\nconstructorHandlers.set(Set, (o, fn) => new Set(cloneArray(Array.from(o), fn)))\nlet handler = null\n\nfunction cloneArray<T>(a: T, fn): T {\n const keys = Object.keys(a)\n const a2 = new Array(keys.length)\n for (let i = 0; i < keys.length; i++) {\n const k = keys[i]\n const cur = a[k]\n if (typeof cur !== 'object' || cur === null) {\n a2[k] = cur\n } else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {\n a2[k] = handler(cur, fn)\n } else if (ArrayBuffer.isView(cur)) {\n a2[k] = copyBuffer(cur)\n } else {\n a2[k] = fn(cur)\n }\n }\n return a2 as T\n}\n\nexport const deepCopyObject = <T>(o: T): T => {\n if (typeof o !== 'object' || o === null) {\n return o\n }\n if (Array.isArray(o)) {\n return cloneArray(o, deepCopyObject)\n }\n if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) {\n return handler(o, deepCopyObject)\n }\n const o2 = {}\n for (const k in o) {\n if (Object.hasOwnProperty.call(o, k) === false) {\n continue\n }\n const cur = o[k]\n if (typeof cur !== 'object' || cur === null) {\n o2[k as string] = cur\n } else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) {\n o2[k as string] = handler(cur, deepCopyObject)\n } else if (ArrayBuffer.isView(cur)) {\n o2[k as string] = copyBuffer(cur)\n } else {\n o2[k as string] = deepCopyObject(cur)\n }\n }\n return o2 as T\n}\n\n/*\nFast deepCopyObjectSimple handling - from fast-json-clone: https://github.com/rhysd/fast-json-clone\n\nBenchmark: https://github.com/AlessioGr/fastest-deep-clone-json/blob/main/test/benchmark.js\n*/\n\n/**\n * A deepCopyObject implementation which only works for JSON objects and arrays, and is faster than\n * JSON.parse(JSON.stringify(obj))\n *\n * @param value The JSON value to be cloned. There are two invariants. 1) It must not contain circles\n * as JSON does not allow it. This function will cause infinite loop for such values by\n * design. 2) It must contain JSON values only. Other values like `Date`, `Regexp`, `Map`,\n * `Set`, `Buffer`, ... are not allowed.\n * @returns The cloned JSON value.\n */\nexport function deepCopyObjectSimple<T extends JsonValue>(value: T): T {\n if (typeof value !== 'object' || value === null) {\n return value\n } else if (Array.isArray(value)) {\n return value.map((e) =>\n typeof e !== 'object' || e === null ? e : deepCopyObjectSimple(e),\n ) as T\n } else {\n if (value instanceof Date) {\n return new Date(value) as unknown as T\n }\n const ret: { [key: string]: T } = {}\n for (const k in value) {\n const v = value[k]\n ret[k] = typeof v !== 'object' || v === null ? v : (deepCopyObjectSimple(v as T) as any)\n }\n return ret as unknown as T\n }\n}\n\n/**\n * A deepCopyObject implementation which is slower than deepCopyObject, but more correct.\n * Can be used if correctness is more important than speed. Supports circular dependencies\n */\nexport function deepCopyObjectComplex<T>(object: T, cache: WeakMap<any, any> = new WeakMap()): T {\n if (object === null) {\n return null\n }\n\n if (cache.has(object)) {\n return cache.get(object)\n }\n\n // Handle Date\n if (object instanceof Date) {\n return new Date(object.getTime()) as unknown as T\n }\n\n // Handle RegExp\n if (object instanceof RegExp) {\n return new RegExp(object.source, object.flags) as unknown as T\n }\n\n // Handle Map\n if (object instanceof Map) {\n const clonedMap = new Map()\n cache.set(object, clonedMap)\n for (const [key, value] of object.entries()) {\n clonedMap.set(key, deepCopyObjectComplex(value, cache))\n }\n return clonedMap as unknown as T\n }\n\n // Handle Set\n if (object instanceof Set) {\n const clonedSet = new Set()\n cache.set(object, clonedSet)\n for (const value of object.values()) {\n clonedSet.add(deepCopyObjectComplex(value, cache))\n }\n return clonedSet as unknown as T\n }\n\n // Handle Array and Object\n if (typeof object === 'object' && object !== null) {\n if ('$$typeof' in object && typeof object.$$typeof === 'symbol') {\n return object\n }\n\n const clonedObject: any = Array.isArray(object)\n ? []\n : Object.create(Object.getPrototypeOf(object))\n cache.set(object, clonedObject)\n\n for (const key in object) {\n if (\n Object.prototype.hasOwnProperty.call(object, key) ||\n Object.getOwnPropertySymbols(object).includes(key as any)\n ) {\n clonedObject[key] = deepCopyObjectComplex(object[key], cache)\n }\n }\n\n return clonedObject as T\n }\n\n // Handle all other cases\n return object\n}\n"],"names":["copyBuffer","cur","Buffer","from","constructor","buffer","slice","byteOffset","length","constructorHandlers","Map","set","Date","o","fn","cloneArray","Array","Set","handler","a","keys","Object","a2","i","k","get","ArrayBuffer","isView","deepCopyObject","isArray","o2","hasOwnProperty","call","deepCopyObjectSimple","value","map","e","ret","v","deepCopyObjectComplex","object","cache","WeakMap","has","getTime","RegExp","source","flags","clonedMap","key","entries","clonedSet","values","add","$$typeof","clonedObject","create","getPrototypeOf","prototype","getOwnPropertySymbols","includes"],"mappings":"AAEA;;;;;;;;;;;;;;;;;;AAkBA,GAEA,SAASA,WAAWC,GAAG;IACrB,IAAIA,eAAeC,QAAQ;QACzB,OAAOA,OAAOC,IAAI,CAACF;IACrB;IAEA,OAAO,IAAIA,IAAIG,WAAW,CAACH,IAAII,MAAM,CAACC,KAAK,IAAIL,IAAIM,UAAU,EAAEN,IAAIO,MAAM;AAC3E;AAEA,MAAMC,sBAAsB,IAAIC;AAChCD,oBAAoBE,GAAG,CAACC,MAAM,CAACC,IAAM,IAAID,KAAKC;AAC9CJ,oBAAoBE,GAAG,CAACD,KAAK,CAACG,GAAGC,KAAO,IAAIJ,IAAIK,WAAgBC,MAAMb,IAAI,CAACU,IAAIC;AAC/EL,oBAAoBE,GAAG,CAACM,KAAK,CAACJ,GAAGC,KAAO,IAAIG,IAAIF,WAAWC,MAAMb,IAAI,CAACU,IAAIC;AAC1E,IAAII,UAAU;AAEd,SAASH,WAAcI,CAAI,EAAEL,EA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AOL,OAAOM,MAAM,EAAEN,OAAOO,KAAK;IAC/C;IAEA,aAAa;IACb,IAAIP,kBAAkB9B,KAAK;QACzB,MAAMsC,YAAY,IAAItC;QACtB+B,MAAM9B,GAAG,CAAC6B,QAAQQ;QAClB,KAAK,MAAM,CAACC,KAAKf,MAAM,IAAIM,OAAOU,OAAO,GAAI;YAC3CF,UAAUrC,GAAG,CAACsC,KAAKV,sBAAsBL,OAAOO;QAClD;QACA,OAAOO;IACT;IAEA,aAAa;IACb,IAAIR,kBAAkBvB,KAAK;QACzB,MAAMkC,YAAY,IAAIlC;QACtBwB,MAAM9B,GAAG,CAAC6B,QAAQW;QAClB,KAAK,MAAMjB,SAASM,OAAOY,MAAM,GAAI;YACnCD,UAAUE,GAAG,CAACd,sBAAsBL,OAAOO;QAC7C;QACA,OAAOU;IACT;IAEA,0BAA0B;IAC1B,IAAI,OAAOX,WAAW,YAAYA,WAAW,MAAM;QACjD,IAAI,cAAcA,UAAU,OAAOA,OAAOc,QAAQ,KAAK,UAAU;YAC/D,OAAOd;QACT;QAEA,MAAMe,eAAoBvC,MAAMa,OAAO,CAACW,UACpC,EAAE,GACFnB,OAAOmC,MAAM,CAACnC,OAAOoC,cAAc,CAACjB;QACxCC,MAAM9B,GAAG,CAAC6B,QAAQe;QAElB,IAAK,MAAMN,OAAOT,OAAQ;YACxB,IACEnB,OAAOqC,SAAS,CAAC3B,cAAc,CAACC,IAAI,CAACQ,QAAQS,QAC7C5B,OAAOsC,qBAAqB,CAACnB,QAAQoB,QAAQ,CAACX,MAC9C;gBACAM,YAAY,CAACN,IAAI,GAAGV,sBAAsBC,MAAM,CAACS,IAAI,EAAER;YACzD;QACF;QAEA,OAAOc;IACT;IAEA,yBAAyB;IACzB,OAAOf;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"versionUtils.d.ts","sourceRoot":"","sources":["../../../src/utilities/dependencies/versionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAEjE,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,WAAW,EAAE,MAAM,EAAE,CAAA;CAAE,CAIxF;
|
|
1
|
+
{"version":3,"file":"versionUtils.d.ts","sourceRoot":"","sources":["../../../src/utilities/dependencies/versionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAEjE,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,WAAW,EAAE,MAAM,EAAE,CAAA;CAAE,CAIxF;AA8BD;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,EAAE,EAAE,MAAM,EACV,mBAAmB,CAAC,EAAE,mBAAmB,GACxC,OAAO,GAAG,SAAS,GAAG,OAAO,CAqC/B"}
|
|
@@ -14,12 +14,20 @@ function comparePreRelease(v1, v2) {
|
|
|
14
14
|
const num1 = extractNumbers(v1);
|
|
15
15
|
const num2 = extractNumbers(v2);
|
|
16
16
|
for(let i = 0; i < Math.max(num1.length, num2.length); i++){
|
|
17
|
-
if ((num1[i] || 0) < (num2[i] || 0))
|
|
18
|
-
|
|
17
|
+
if ((num1[i] || 0) < (num2[i] || 0)) {
|
|
18
|
+
return -1;
|
|
19
|
+
}
|
|
20
|
+
if ((num1[i] || 0) > (num2[i] || 0)) {
|
|
21
|
+
return 1;
|
|
22
|
+
}
|
|
19
23
|
}
|
|
20
24
|
// If numeric parts are equal, compare the whole string
|
|
21
|
-
if (v1 < v2)
|
|
22
|
-
|
|
25
|
+
if (v1 < v2) {
|
|
26
|
+
return -1;
|
|
27
|
+
}
|
|
28
|
+
if (v1 > v2) {
|
|
29
|
+
return 1;
|
|
30
|
+
}
|
|
23
31
|
return 0;
|
|
24
32
|
}
|
|
25
33
|
/**
|
|
@@ -39,14 +47,22 @@ function comparePreRelease(v1, v2) {
|
|
|
39
47
|
const { parts: parts2, preReleases: preReleases2 } = customVersionParser ? customVersionParser(to) : parseVersion(to);
|
|
40
48
|
// Compare main version parts
|
|
41
49
|
for(let i = 0; i < Math.max(parts1.length, parts2.length); i++){
|
|
42
|
-
if ((parts1[i] || 0) > (parts2[i] || 0))
|
|
43
|
-
|
|
50
|
+
if ((parts1[i] || 0) > (parts2[i] || 0)) {
|
|
51
|
+
return 'greater';
|
|
52
|
+
}
|
|
53
|
+
if ((parts1[i] || 0) < (parts2[i] || 0)) {
|
|
54
|
+
return 'lower';
|
|
55
|
+
}
|
|
44
56
|
}
|
|
45
57
|
// Compare pre-release parts if main versions are equal
|
|
46
58
|
if (preReleases1?.length || preReleases2?.length) {
|
|
47
59
|
for(let i = 0; i < Math.max(preReleases1.length, preReleases2.length); i++){
|
|
48
|
-
if (!preReleases1[i])
|
|
49
|
-
|
|
60
|
+
if (!preReleases1[i]) {
|
|
61
|
+
return 'greater';
|
|
62
|
+
}
|
|
63
|
+
if (!preReleases2[i]) {
|
|
64
|
+
return 'lower';
|
|
65
|
+
}
|
|
50
66
|
const result = comparePreRelease(preReleases1[i], preReleases2[i]);
|
|
51
67
|
if (result !== 0) {
|
|
52
68
|
return result === 1 ? 'greater' : 'lower';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utilities/dependencies/versionUtils.ts"],"sourcesContent":["import type { CustomVersionParser } from './dependencyChecker.js'\n\nexport function parseVersion(version: string): { parts: number[]; preReleases: string[] } {\n const [mainVersion, ...preReleases] = version.split('-')\n const parts = mainVersion.split('.').map(Number)\n return { parts, preReleases }\n}\n\nfunction extractNumbers(str: string): number[] {\n const matches = str.match(/\\d+/g) || []\n return matches.map(Number)\n}\n\nfunction comparePreRelease(v1: string, v2: string): number {\n const num1 = extractNumbers(v1)\n const num2 = extractNumbers(v2)\n\n for (let i = 0; i < Math.max(num1.length, num2.length); i++) {\n if ((num1[i] || 0) < (num2[i] || 0)) return -1\n if ((num1[i] || 0) > (num2[i] || 0)) return 1\n }\n\n // If numeric parts are equal, compare the whole string\n if (v1 < v2) return -1\n if (v1 > v2) return 1\n return 0\n}\n\n/**\n * Compares two semantic version strings, including handling pre-release identifiers.\n *\n * This function first compares the major, minor, and patch components as integers.\n * If these components are equal, it then moves on to compare pre-release versions.\n * Pre-release versions are compared first by extracting and comparing any numerical values.\n * If numerical values are equal, it compares the whole pre-release string lexicographically.\n *\n * @param {string} compare - The first version string to compare.\n * @param {string} to - The second version string to compare.\n * @param {function} [customVersionParser] - An optional function to parse version strings into parts and pre-releases.\n * @returns {string} - Returns greater if compare is greater than to, lower if compare is less than to, and equal if they are equal.\n */\nexport function compareVersions(\n compare: string,\n to: string,\n customVersionParser?: CustomVersionParser,\n): 'equal' | 'greater' | 'lower' {\n const { parts: parts1, preReleases: preReleases1 } = customVersionParser\n ? customVersionParser(compare)\n : parseVersion(compare)\n const { parts: parts2, preReleases: preReleases2 } = customVersionParser\n ? customVersionParser(to)\n : parseVersion(to)\n\n // Compare main version parts\n for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) {\n if ((parts1[i] || 0) > (parts2[i] || 0)) return 'greater'\n if ((parts1[i] || 0) < (parts2[i] || 0)) return 'lower'\n }\n\n // Compare pre-release parts if main versions are equal\n if (preReleases1?.length || preReleases2?.length) {\n for (let i = 0; i < Math.max(preReleases1.length, preReleases2.length); i++) {\n if (!preReleases1[i]) return 'greater'\n if (!preReleases2[i]) return 'lower'\n\n const result = comparePreRelease(preReleases1[i], preReleases2[i])\n if (result !== 0) {\n return result === 1 ? 'greater' : 'lower'\n }\n // Equal => continue for loop to check for next pre-release part\n }\n }\n\n return 'equal'\n}\n"],"names":["parseVersion","version","mainVersion","preReleases","split","parts","map","Number","extractNumbers","str","matches","match","comparePreRelease","v1","v2","num1","num2","i","Math","max","length","compareVersions","compare","to","customVersionParser","parts1","preReleases1","parts2","preReleases2","result"],"mappings":"AAEA,OAAO,SAASA,aAAaC,OAAe;IAC1C,MAAM,CAACC,aAAa,GAAGC,YAAY,GAAGF,QAAQG,KAAK,CAAC;IACpD,MAAMC,QAAQH,YAAYE,KAAK,CAAC,KAAKE,GAAG,CAACC;IACzC,OAAO;QAAEF;QAAOF;IAAY;AAC9B;AAEA,SAASK,eAAeC,GAAW;IACjC,MAAMC,UAAUD,IAAIE,KAAK,CAAC,WAAW,EAAE;IACvC,OAAOD,QAAQJ,GAAG,CAACC;AACrB;AAEA,SAASK,kBAAkBC,EAAU,EAAEC,EAAU;IAC/C,MAAMC,OAAOP,eAAeK;IAC5B,MAAMG,OAAOR,eAAeM;IAE5B,IAAK,IAAIG,IAAI,GAAGA,IAAIC,KAAKC,GAAG,CAACJ,KAAKK,MAAM,EAAEJ,KAAKI,MAAM,GAAGH,IAAK;QAC3D,IAAI,AAACF,CAAAA,IAAI,CAACE,EAAE,IAAI,CAAA,IAAMD,CAAAA,IAAI,CAACC,EAAE,IAAI,CAAA,GAAI,OAAO,CAAC;
|
|
1
|
+
{"version":3,"sources":["../../../src/utilities/dependencies/versionUtils.ts"],"sourcesContent":["import type { CustomVersionParser } from './dependencyChecker.js'\n\nexport function parseVersion(version: string): { parts: number[]; preReleases: string[] } {\n const [mainVersion, ...preReleases] = version.split('-')\n const parts = mainVersion.split('.').map(Number)\n return { parts, preReleases }\n}\n\nfunction extractNumbers(str: string): number[] {\n const matches = str.match(/\\d+/g) || []\n return matches.map(Number)\n}\n\nfunction comparePreRelease(v1: string, v2: string): number {\n const num1 = extractNumbers(v1)\n const num2 = extractNumbers(v2)\n\n for (let i = 0; i < Math.max(num1.length, num2.length); i++) {\n if ((num1[i] || 0) < (num2[i] || 0)) {\n return -1\n }\n if ((num1[i] || 0) > (num2[i] || 0)) {\n return 1\n }\n }\n\n // If numeric parts are equal, compare the whole string\n if (v1 < v2) {\n return -1\n }\n if (v1 > v2) {\n return 1\n }\n return 0\n}\n\n/**\n * Compares two semantic version strings, including handling pre-release identifiers.\n *\n * This function first compares the major, minor, and patch components as integers.\n * If these components are equal, it then moves on to compare pre-release versions.\n * Pre-release versions are compared first by extracting and comparing any numerical values.\n * If numerical values are equal, it compares the whole pre-release string lexicographically.\n *\n * @param {string} compare - The first version string to compare.\n * @param {string} to - The second version string to compare.\n * @param {function} [customVersionParser] - An optional function to parse version strings into parts and pre-releases.\n * @returns {string} - Returns greater if compare is greater than to, lower if compare is less than to, and equal if they are equal.\n */\nexport function compareVersions(\n compare: string,\n to: string,\n customVersionParser?: CustomVersionParser,\n): 'equal' | 'greater' | 'lower' {\n const { parts: parts1, preReleases: preReleases1 } = customVersionParser\n ? customVersionParser(compare)\n : parseVersion(compare)\n const { parts: parts2, preReleases: preReleases2 } = customVersionParser\n ? customVersionParser(to)\n : parseVersion(to)\n\n // Compare main version parts\n for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) {\n if ((parts1[i] || 0) > (parts2[i] || 0)) {\n return 'greater'\n }\n if ((parts1[i] || 0) < (parts2[i] || 0)) {\n return 'lower'\n }\n }\n\n // Compare pre-release parts if main versions are equal\n if (preReleases1?.length || preReleases2?.length) {\n for (let i = 0; i < Math.max(preReleases1.length, preReleases2.length); i++) {\n if (!preReleases1[i]) {\n return 'greater'\n }\n if (!preReleases2[i]) {\n return 'lower'\n }\n\n const result = comparePreRelease(preReleases1[i], preReleases2[i])\n if (result !== 0) {\n return result === 1 ? 'greater' : 'lower'\n }\n // Equal => continue for loop to check for next pre-release part\n }\n }\n\n return 'equal'\n}\n"],"names":["parseVersion","version","mainVersion","preReleases","split","parts","map","Number","extractNumbers","str","matches","match","comparePreRelease","v1","v2","num1","num2","i","Math","max","length","compareVersions","compare","to","customVersionParser","parts1","preReleases1","parts2","preReleases2","result"],"mappings":"AAEA,OAAO,SAASA,aAAaC,OAAe;IAC1C,MAAM,CAACC,aAAa,GAAGC,YAAY,GAAGF,QAAQG,KAAK,CAAC;IACpD,MAAMC,QAAQH,YAAYE,KAAK,C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A,IAAMU,CAAAA,MAAM,CAACV,EAAE,IAAI,CAAA,GAAI;YACvC,OAAO;QACT;QACA,IAAI,AAACQ,CAAAA,MAAM,CAACR,EAAE,IAAI,CAAA,IAAMU,CAAAA,MAAM,CAACV,EAAE,IAAI,CAAA,GAAI;YACvC,OAAO;QACT;IACF;IAEA,uDAAuD;IACvD,IAAIS,cAAcN,UAAUQ,cAAcR,QAAQ;QAChD,IAAK,IAAIH,IAAI,GAAGA,IAAIC,KAAKC,GAAG,CAACO,aAAaN,MAAM,EAAEQ,aAAaR,MAAM,GAAGH,IAAK;YAC3E,IAAI,CAACS,YAAY,CAACT,EAAE,EAAE;gBACpB,OAAO;YACT;YACA,IAAI,CAACW,YAAY,CAACX,EAAE,EAAE;gBACpB,OAAO;YACT;YAEA,MAAMY,SAASjB,kBAAkBc,YAAY,CAACT,EAAE,EAAEW,YAAY,CAACX,EAAE;YACjE,IAAIY,WAAW,GAAG;gBAChB,OAAOA,WAAW,IAAI,YAAY;YACpC;QACA,gEAAgE;QAClE;IACF;IAEA,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getEntityPolicies.d.ts","sourceRoot":"","sources":["../../src/utilities/getEntityPolicies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAC9E,OAAO,KAAK,EAAE,yBAAyB,EAAc,MAAM,gCAAgC,CAAA;AAG3F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AACvE,OAAO,KAAK,EAAE,aAAa,EAAY,cAAc,EAAS,MAAM,mBAAmB,CAAA;AAIvF,KAAK,IAAI,GAAG;IACV,MAAM,EAAE,yBAAyB,GAAG,qBAAqB,CAAA;IACzD,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,UAAU,EAAE,aAAa,EAAE,CAAA;IAC3B,GAAG,EAAE,cAAc,CAAA;IACnB,IAAI,EAAE,YAAY,GAAG,QAAQ,CAAA;CAC9B,CAAA;AAED,KAAK,UAAU,CAAC,CAAC,SAAS,IAAI,IAAI,CAAC,CAAC,MAAM,CAAC,SAAS,QAAQ,GACxD,gBAAgB,GAChB,oBAAoB,CAAA;AAYxB,wBAAsB,iBAAiB,CAAC,CAAC,SAAS,IAAI,EAAE,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"getEntityPolicies.d.ts","sourceRoot":"","sources":["../../src/utilities/getEntityPolicies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAC9E,OAAO,KAAK,EAAE,yBAAyB,EAAc,MAAM,gCAAgC,CAAA;AAG3F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AACvE,OAAO,KAAK,EAAE,aAAa,EAAY,cAAc,EAAS,MAAM,mBAAmB,CAAA;AAIvF,KAAK,IAAI,GAAG;IACV,MAAM,EAAE,yBAAyB,GAAG,qBAAqB,CAAA;IACzD,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,UAAU,EAAE,aAAa,EAAE,CAAA;IAC3B,GAAG,EAAE,cAAc,CAAA;IACnB,IAAI,EAAE,YAAY,GAAG,QAAQ,CAAA;CAC9B,CAAA;AAED,KAAK,UAAU,CAAC,CAAC,SAAS,IAAI,IAAI,CAAC,CAAC,MAAM,CAAC,SAAS,QAAQ,GACxD,gBAAgB,GAChB,oBAAoB,CAAA;AAYxB,wBAAsB,iBAAiB,CAAC,CAAC,SAAS,IAAI,EAAE,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAkPvF"}
|
|
@@ -90,7 +90,9 @@ export async function getEntityPolicies(args) {
|
|
|
90
90
|
const mutablePolicies = policiesObj.fields;
|
|
91
91
|
await Promise.all(fields.map(async (field)=>{
|
|
92
92
|
if ('name' in field && field.name) {
|
|
93
|
-
if (!mutablePolicies[field.name])
|
|
93
|
+
if (!mutablePolicies[field.name]) {
|
|
94
|
+
mutablePolicies[field.name] = {};
|
|
95
|
+
}
|
|
94
96
|
if ('access' in field && field.access && typeof field.access[operation] === 'function') {
|
|
95
97
|
await createAccessPromise({
|
|
96
98
|
access: field.access[operation],
|
|
@@ -105,7 +107,9 @@ export async function getEntityPolicies(args) {
|
|
|
105
107
|
};
|
|
106
108
|
}
|
|
107
109
|
if ('fields' in field && field.fields) {
|
|
108
|
-
if (!mutablePolicies[field.name].fields)
|
|
110
|
+
if (!mutablePolicies[field.name].fields) {
|
|
111
|
+
mutablePolicies[field.name].fields = {};
|
|
112
|
+
}
|
|
109
113
|
await executeFieldPolicies({
|
|
110
114
|
entityPermission,
|
|
111
115
|
fields: field.fields,
|
|
@@ -114,7 +118,9 @@ export async function getEntityPolicies(args) {
|
|
|
114
118
|
});
|
|
115
119
|
}
|
|
116
120
|
if ('blocks' in field && field?.blocks) {
|
|
117
|
-
if (!mutablePolicies[field.name]?.blocks)
|
|
121
|
+
if (!mutablePolicies[field.name]?.blocks) {
|
|
122
|
+
mutablePolicies[field.name].blocks = {};
|
|
123
|
+
}
|
|
118
124
|
await Promise.all(field.blocks.map(async (block)=>{
|
|
119
125
|
if (!mutablePolicies[field.name].blocks?.[block.slug]) {
|
|
120
126
|
mutablePolicies[field.name].blocks[block.slug] = {
|