UNPKG

@rjsf/utils

Version:
4 lines 389 kB
{ "version": 3, "sources": ["../src/index.ts", "../src/isObject.ts", "../src/allowAdditionalItems.ts", "../src/asNumber.ts", "../src/constants.ts", "../src/getUiOptions.ts", "../src/canExpand.ts", "../src/createErrorHandler.ts", "../src/deepEquals.ts", "../src/schema/findFieldInSchema.ts", "../src/schema/findSelectedOptionInXxxOf.ts", "../src/schema/retrieveSchema.ts", "../src/findSchemaDefinition.ts", "../src/getDiscriminatorFieldFromSchema.ts", "../src/guessType.ts", "../src/mergeSchemas.ts", "../src/getSchemaType.ts", "../src/schema/getFirstMatchingOption.ts", "../src/getOptionMatchingSimpleDiscriminator.ts", "../src/schema/getFromSchema.ts", "../src/schema/getDefaultFormState.ts", "../src/schema/getClosestMatchingOption.ts", "../src/isFixedItems.ts", "../src/mergeDefaultsWithFormData.ts", "../src/mergeObjects.ts", "../src/isConstant.ts", "../src/schema/isSelect.ts", "../src/schema/isMultiSelect.ts", "../src/constIsAjvDataReference.ts", "../src/optionsList.ts", "../src/toConstant.ts", "../src/schema/getDisplayLabel.ts", "../src/isCustomWidget.ts", "../src/schema/isFilesArray.ts", "../src/schema/omitExtraData.ts", "../src/schema/toPathSchema.ts", "../src/schema/sanitizeDataForNewSchema.ts", "../src/createSchemaUtils.ts", "../src/dataURItoBlob.ts", "../src/pad.ts", "../src/dateRangeOptions.ts", "../src/shallowEquals.ts", "../src/replaceStringParameters.ts", "../src/englishStringTranslator.ts", "../src/enumOptionsValueForIndex.ts", "../src/enumOptionsDeselectValue.ts", "../src/enumOptionsIsSelected.ts", "../src/enumOptionsIndexForValue.ts", "../src/enumOptionsSelectValue.ts", "../src/ErrorSchemaBuilder.ts", "../src/getChangedFields.ts", "../src/getDateElementProps.ts", "../src/rangeSpec.ts", "../src/getInputProps.ts", "../src/getSubmitButtonOptions.ts", "../src/getTemplate.ts", "../src/getTestIds.ts", "../src/getWidget.tsx", "../src/hashForSchema.ts", "../src/hasWidget.ts", "../src/idGenerators.ts", "../src/isFormDataAvailable.ts", "../src/isRootSchema.ts", "../src/labelValue.ts", "../src/localToUTC.ts", "../src/lookupFromFormContext.ts", "../src/orderProperties.ts", "../src/parseDateString.ts", "../src/resolveUiSchema.ts", "../src/schemaRequiresTrueValue.ts", "../src/shouldRender.ts", "../src/shouldRenderOptionalField.ts", "../src/toDateString.ts", "../src/toErrorList.ts", "../src/toErrorSchema.ts", "../src/toFieldPathId.ts", "../src/unwrapErrorHandler.ts", "../src/useAltDateWidgetProps.tsx", "../src/useDeepCompareMemo.ts", "../src/useFileWidgetProps.ts", "../src/utcToLocal.ts", "../src/validationDataMerge.ts", "../src/withIdRefPrefix.ts", "../src/nameGenerators.ts", "../src/enums.ts", "../src/parser/schemaParser.ts", "../src/parser/ParserValidator.ts"], "sourcesContent": ["import allowAdditionalItems from './allowAdditionalItems';\nimport asNumber from './asNumber';\nimport canExpand from './canExpand';\nimport createErrorHandler from './createErrorHandler';\nimport createSchemaUtils from './createSchemaUtils';\nimport dataURItoBlob from './dataURItoBlob';\nimport dateRangeOptions from './dateRangeOptions';\nimport deepEquals from './deepEquals';\nimport shallowEquals from './shallowEquals';\nimport englishStringTranslator from './englishStringTranslator';\nimport enumOptionsDeselectValue from './enumOptionsDeselectValue';\nimport enumOptionsIndexForValue from './enumOptionsIndexForValue';\nimport enumOptionsIsSelected from './enumOptionsIsSelected';\nimport enumOptionsSelectValue from './enumOptionsSelectValue';\nimport enumOptionsValueForIndex from './enumOptionsValueForIndex';\nimport ErrorSchemaBuilder from './ErrorSchemaBuilder';\nimport findSchemaDefinition from './findSchemaDefinition';\nimport getChangedFields from './getChangedFields';\nimport getDateElementProps, { DateElementFormat, DateElementProp } from './getDateElementProps';\nimport getDiscriminatorFieldFromSchema from './getDiscriminatorFieldFromSchema';\nimport getInputProps from './getInputProps';\nimport getOptionMatchingSimpleDiscriminator from './getOptionMatchingSimpleDiscriminator';\nimport getSchemaType from './getSchemaType';\nimport getSubmitButtonOptions from './getSubmitButtonOptions';\nimport getTemplate from './getTemplate';\nimport getTestIds from './getTestIds';\nimport getUiOptions from './getUiOptions';\nimport getWidget from './getWidget';\nimport guessType from './guessType';\nimport hashForSchema, { hashObject, hashString, sortedJSONStringify } from './hashForSchema';\nimport hasWidget from './hasWidget';\nimport {\n ariaDescribedByIds,\n buttonId,\n descriptionId,\n errorId,\n examplesId,\n helpId,\n optionalControlsId,\n optionId,\n titleId,\n} from './idGenerators';\nimport isConstant from './isConstant';\nimport isCustomWidget from './isCustomWidget';\nimport isFixedItems from './isFixedItems';\nimport isFormDataAvailable from './isFormDataAvailable';\nimport isObject from './isObject';\nimport isRootSchema from './isRootSchema';\nimport labelValue from './labelValue';\nimport localToUTC from './localToUTC';\nimport lookupFromFormContext from './lookupFromFormContext';\nimport mergeDefaultsWithFormData from './mergeDefaultsWithFormData';\nimport mergeObjects from './mergeObjects';\nimport mergeSchemas from './mergeSchemas';\nimport optionsList from './optionsList';\nimport orderProperties from './orderProperties';\nimport pad from './pad';\nimport parseDateString from './parseDateString';\nimport rangeSpec from './rangeSpec';\nimport replaceStringParameters from './replaceStringParameters';\nimport resolveUiSchema, { expandUiSchemaDefinitions } from './resolveUiSchema';\nimport schemaRequiresTrueValue from './schemaRequiresTrueValue';\nimport shouldRender, { ComponentUpdateStrategy } from './shouldRender';\nimport shouldRenderOptionalField from './shouldRenderOptionalField';\nimport toConstant from './toConstant';\nimport toDateString from './toDateString';\nimport toErrorList from './toErrorList';\nimport toErrorSchema from './toErrorSchema';\nimport toFieldPathId from './toFieldPathId';\nimport unwrapErrorHandler from './unwrapErrorHandler';\nimport useAltDateWidgetProps, { DateElement, DateElementProps, UseAltDateWidgetResult } from './useAltDateWidgetProps';\nimport useDeepCompareMemo from './useDeepCompareMemo';\nimport useFileWidgetProps, { FileInfoType, UseFileWidgetPropsResult } from './useFileWidgetProps';\nimport utcToLocal from './utcToLocal';\nimport validationDataMerge from './validationDataMerge';\nimport withIdRefPrefix from './withIdRefPrefix';\nimport { bracketNameGenerator, dotNotationNameGenerator } from './nameGenerators';\n\nexport * from './types';\nexport * from './enums';\n\nexport * from './constants';\nexport * from './parser';\nexport * from './schema';\n\nexport type {\n ComponentUpdateStrategy,\n DateElementFormat,\n DateElementProp,\n DateElementProps,\n FileInfoType,\n UseAltDateWidgetResult,\n UseFileWidgetPropsResult,\n};\n\nexport {\n allowAdditionalItems,\n ariaDescribedByIds,\n asNumber,\n buttonId,\n canExpand,\n createErrorHandler,\n createSchemaUtils,\n DateElement,\n dataURItoBlob,\n dateRangeOptions,\n deepEquals,\n descriptionId,\n englishStringTranslator,\n enumOptionsDeselectValue,\n enumOptionsIndexForValue,\n enumOptionsIsSelected,\n enumOptionsSelectValue,\n enumOptionsValueForIndex,\n errorId,\n examplesId,\n ErrorSchemaBuilder,\n findSchemaDefinition,\n getChangedFields,\n getDateElementProps,\n getDiscriminatorFieldFromSchema,\n getInputProps,\n getOptionMatchingSimpleDiscriminator,\n getSchemaType,\n getSubmitButtonOptions,\n getTemplate,\n getTestIds,\n getUiOptions,\n getWidget,\n guessType,\n hasWidget,\n hashForSchema,\n hashObject,\n hashString,\n helpId,\n isConstant,\n isCustomWidget,\n isFixedItems,\n isFormDataAvailable,\n isObject,\n isRootSchema,\n labelValue,\n localToUTC,\n lookupFromFormContext,\n mergeDefaultsWithFormData,\n mergeObjects,\n mergeSchemas,\n optionalControlsId,\n optionId,\n optionsList,\n orderProperties,\n pad,\n parseDateString,\n rangeSpec,\n replaceStringParameters,\n resolveUiSchema,\n expandUiSchemaDefinitions,\n schemaRequiresTrueValue,\n shallowEquals,\n shouldRender,\n shouldRenderOptionalField,\n sortedJSONStringify,\n titleId,\n toConstant,\n toDateString,\n toErrorList,\n toErrorSchema,\n toFieldPathId,\n unwrapErrorHandler,\n useAltDateWidgetProps,\n useDeepCompareMemo,\n useFileWidgetProps,\n utcToLocal,\n validationDataMerge,\n withIdRefPrefix,\n bracketNameGenerator,\n dotNotationNameGenerator,\n};\n", "/** Determines whether a `thing` is an object for the purposes of RJSF. In this case, `thing` is an object if it has\n * the type `object` but is NOT null, an array or a File.\n *\n * @param thing - The thing to check to see whether it is an object\n * @returns - True if it is a non-null, non-array, non-File object\n */\nexport default function isObject(thing: any): thing is object {\n if (typeof thing !== 'object' || thing === null) {\n return false;\n }\n // lastModified is guaranteed to be a number on a File instance\n // as per https://w3c.github.io/FileAPI/#dfn-lastModified\n if (typeof thing.lastModified === 'number' && typeof File !== 'undefined' && thing instanceof File) {\n return false;\n }\n // getMonth is guaranteed to be a method on a Date instance\n // as per https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.getmonth\n if (typeof thing.getMonth === 'function' && typeof Date !== 'undefined' && thing instanceof Date) {\n return false;\n }\n return !Array.isArray(thing);\n}\n", "import isObject from './isObject';\nimport { RJSFSchema, StrictRJSFSchema } from './types';\n\n/** Checks the schema to see if it is allowing additional items, by verifying that `schema.additionalItems` is an\n * object. The user is warned in the console if `schema.additionalItems` has the value `true`.\n *\n * @param schema - The schema object to check\n * @returns - True if additional items is allowed, otherwise false\n */\nexport default function allowAdditionalItems<S extends StrictRJSFSchema = RJSFSchema>(schema: S) {\n if (schema.additionalItems === true) {\n console.warn('additionalItems=true is currently not supported');\n }\n return isObject(schema.additionalItems);\n}\n", "/** Attempts to convert the string into a number. If an empty string is provided, then `undefined` is returned. If a\n * `null` is provided, it is returned. If the string ends in a `.` then the string is returned because the user may be\n * in the middle of typing a float number. If a number ends in a pattern like `.0`, `.20`, `.030`, string is returned\n * because the user may be typing number that will end in a non-zero digit. Otherwise, the string is wrapped by\n * `Number()` and if that result is not `NaN`, that number will be returned, otherwise the string `value` will be.\n *\n * @param value - The string or null value to convert to a number\n * @returns - The `value` converted to a number when appropriate, otherwise the `value`\n */\nexport default function asNumber(value: string | null) {\n if (value === '') {\n return undefined;\n }\n if (value === null) {\n return null;\n }\n if (/\\.$/.test(value)) {\n // '3.' can't really be considered a number even if it parses in js. The\n // user is most likely entering a float.\n return value;\n }\n if (/\\.0$/.test(value)) {\n // we need to return this as a string here, to allow for input like 3.07\n return value;\n }\n\n if (/\\.\\d*0$/.test(value)) {\n // It's a number, that's cool - but we need it as a string so it doesn't screw\n // with the user when entering dollar amounts or other values (such as those with\n // specific precision or number of significant digits)\n return value;\n }\n\n const n = Number(value);\n const valid = typeof n === 'number' && !Number.isNaN(n);\n\n return valid ? n : value;\n}\n", "/** Below are the list of all the keys into various elements of a RJSFSchema or UiSchema that are used by the various\n * utility functions. In addition to those keys, there are the special `ADDITIONAL_PROPERTY_FLAG` and\n * `RJSF_ADDITIONAL_PROPERTIES_FLAG` flags that is added to a schema under certain conditions by the `retrieveSchema()`\n * utility.\n */\nexport const ADDITIONAL_PROPERTY_FLAG = '__additional_property';\nexport const ADDITIONAL_PROPERTIES_KEY = 'additionalProperties';\nexport const ALL_OF_KEY = 'allOf';\nexport const ANY_OF_KEY = 'anyOf';\nexport const CONST_KEY = 'const';\nexport const DEFAULT_KEY = 'default';\nexport const DEFINITIONS_KEY = 'definitions';\nexport const DEPENDENCIES_KEY = 'dependencies';\nexport const ENUM_KEY = 'enum';\nexport const ERRORS_KEY = '__errors';\nexport const ID_KEY = '$id';\nexport const IF_KEY = 'if';\nexport const ITEMS_KEY = 'items';\nexport const JUNK_OPTION_ID = '_$junk_option_schema_id$_';\nexport const NAME_KEY = '$name';\nexport const ONE_OF_KEY = 'oneOf';\nexport const PATTERN_PROPERTIES_KEY = 'patternProperties';\nexport const PROPERTIES_KEY = 'properties';\nexport const READONLY_KEY = 'readonly';\nexport const REQUIRED_KEY = 'required';\nexport const SUBMIT_BTN_OPTIONS_KEY = 'submitButtonOptions';\nexport const REF_KEY = '$ref';\nexport const RJSF_REF_KEY = '__rjsf_ref';\nexport const SCHEMA_KEY = '$schema';\nexport const DEFAULT_ID_PREFIX = 'root';\nexport const DEFAULT_ID_SEPARATOR = '_';\n/** The path of the discriminator value returned by the schema endpoint.\n * The discriminator is the value in a `oneOf` that determines which option is selected.\n */\nexport const DISCRIMINATOR_PATH = ['discriminator', 'propertyName'];\n/** The name of the `formContext` attribute in the React JSON Schema Form Registry\n */\nexport const FORM_CONTEXT_NAME = 'formContext';\n\n/** The name of the `layoutGridLookupMap` attribute in the form context\n */\nexport const LOOKUP_MAP_NAME = 'layoutGridLookupMap';\nexport const RJSF_ADDITIONAL_PROPERTIES_FLAG = '__rjsf_additionalProperties';\nexport const ROOT_SCHEMA_PREFIX = '__rjsf_rootSchema';\nexport const UI_FIELD_KEY = 'ui:field';\nexport const UI_WIDGET_KEY = 'ui:widget';\nexport const UI_OPTIONS_KEY = 'ui:options';\nexport const UI_GLOBAL_OPTIONS_KEY = 'ui:globalOptions';\nexport const UI_DEFINITIONS_KEY = 'ui:definitions';\n\n/** The JSON Schema version strings\n */\nexport const JSON_SCHEMA_DRAFT_2019_09 = 'https://json-schema.org/draft/2019-09/schema';\nexport const JSON_SCHEMA_DRAFT_2020_12 = 'https://json-schema.org/draft/2020-12/schema';\n", "import { UI_OPTIONS_KEY, UI_WIDGET_KEY } from './constants';\nimport isObject from './isObject';\nimport { FormContextType, GlobalUISchemaOptions, RJSFSchema, StrictRJSFSchema, UIOptionsType, UiSchema } from './types';\n\n/** Get all passed options from ui:options, and ui:<optionName>, returning them in an object with the `ui:`\n * stripped off. Any `globalOptions` will always be returned, unless they are overridden by options in the `uiSchema`.\n *\n * @param [uiSchema={}] - The UI Schema from which to get any `ui:xxx` options\n * @param [globalOptions={}] - The optional Global UI Schema from which to get any fallback `xxx` options\n * @returns - An object containing all the `ui:xxx` options with the `ui:` stripped off along with all `globalOptions`\n */\nexport default function getUiOptions<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n uiSchema: UiSchema<T, S, F> = {},\n globalOptions: GlobalUISchemaOptions = {},\n): UIOptionsType<T, S, F> {\n // Handle null or undefined uiSchema\n if (!uiSchema) {\n return { ...globalOptions };\n }\n return Object.keys(uiSchema)\n .filter((key) => key.indexOf('ui:') === 0)\n .reduce(\n (options, key) => {\n const value = uiSchema[key];\n if (key === UI_WIDGET_KEY && isObject(value)) {\n console.error('Setting options via ui:widget object is no longer supported, use ui:options instead');\n return options;\n }\n if (key === UI_OPTIONS_KEY && isObject(value)) {\n return { ...options, ...value };\n }\n return { ...options, [key.substring(3)]: value };\n },\n { ...globalOptions },\n );\n}\n", "import { FormContextType, RJSFSchema, StrictRJSFSchema, UiSchema } from './types';\nimport getUiOptions from './getUiOptions';\n\n/** Checks whether the field described by `schema`, having the `uiSchema` and `formData` supports expanding. The UI for\n * the field can expand if it has additional properties, is not forced as non-expandable by the `uiSchema` and the\n * `formData` object doesn't already have `schema.maxProperties` elements.\n *\n * @param schema - The schema for the field that is being checked\n * @param [uiSchema={}] - The uiSchema for the field\n * @param [formData] - The formData for the field\n * @returns - True if the schema element has additionalProperties, is expandable, and not at the maxProperties limit\n */\nexport default function canExpand<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n schema: RJSFSchema,\n uiSchema: UiSchema<T, S, F> = {},\n formData?: T,\n) {\n if (!(schema.additionalProperties || schema.patternProperties)) {\n return false;\n }\n const { expandable = true } = getUiOptions<T, S, F>(uiSchema);\n if (expandable === false) {\n return expandable;\n }\n // if ui:options.expandable was not explicitly set to false, we can add\n // another property if we have not exceeded maxProperties yet\n if (schema.maxProperties !== undefined && formData) {\n return Object.keys(formData).length < schema.maxProperties;\n }\n return true;\n}\n", "import isPlainObject from 'lodash/isPlainObject';\n\nimport { ERRORS_KEY } from './constants';\nimport { FieldValidation, FormValidation, GenericObjectType } from './types';\n\n/** Given a `formData` object, recursively creates a `FormValidation` error handling structure around it\n *\n * @param formData - The form data around which the error handler is created\n * @returns - A `FormValidation` object based on the `formData` structure\n */\nexport default function createErrorHandler<T = any>(formData: T): FormValidation<T> {\n const handler: FieldValidation = {\n // We store the list of errors for this node in a property named __errors\n // to avoid name collision with a possible sub schema field named\n // 'errors' (see `utils.toErrorSchema`).\n [ERRORS_KEY]: [],\n addError(message: string) {\n this[ERRORS_KEY]!.push(message);\n },\n };\n if (Array.isArray(formData)) {\n return formData.reduce((acc, value, key) => {\n return { ...acc, [key]: createErrorHandler(value) };\n }, handler);\n }\n if (isPlainObject(formData)) {\n const formObject: GenericObjectType = formData as GenericObjectType;\n return Object.keys(formObject).reduce((acc, key) => {\n return { ...acc, [key]: createErrorHandler(formObject[key]) };\n }, handler as FormValidation<T>);\n }\n return handler as FormValidation<T>;\n}\n", "import isEqualWith from 'lodash/isEqualWith';\n\n/** Implements a deep equals using the `lodash.isEqualWith` function, that provides a customized comparator that\n * assumes all functions are equivalent.\n *\n * @param a - The first element to compare\n * @param b - The second element to compare\n * @returns - True if the `a` and `b` are deeply equal, false otherwise\n */\nexport default function deepEquals(a: any, b: any): boolean {\n return isEqualWith(a, b, (obj: any, other: any) => {\n if (typeof obj === 'function' && typeof other === 'function') {\n // Assume all functions are equivalent\n // see https://github.com/rjsf-team/react-jsonschema-form/issues/255\n return true;\n }\n return undefined; // fallback to default isEquals behavior\n });\n}\n", "import get from 'lodash/get';\nimport has from 'lodash/has';\n\nimport findSelectedOptionInXxxOf from './findSelectedOptionInXxxOf';\nimport getFromSchema from './getFromSchema';\nimport { ANY_OF_KEY, ONE_OF_KEY, PROPERTIES_KEY, REQUIRED_KEY } from '../constants';\nimport {\n Experimental_CustomMergeAllOf,\n FormContextType,\n FoundFieldType,\n RJSFSchema,\n StrictRJSFSchema,\n ValidatorType,\n} from '../types';\n\n/** Unique schema that represents no schema was found, exported for testing purposes */\nexport const NOT_FOUND_SCHEMA = { title: '!@#$_UNKNOWN_$#@!' };\n\n/** Finds the field specified by the `path` within the root or recursed `schema`. If there is no field for the specified\n * `path`, then the default `{ field: undefined, isRequired: undefined }` is returned. It determines whether a leaf\n * field is in the `required` list for its parent and if so, it is marked as required on return.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param schema - The node within the JSON schema in which to search\n * @param path - The keys in the path to the desired field\n * @param [formData={}] - The form data that is used to determine which anyOf/oneOf option to descend\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - An object that contains the field and its required state. If no field can be found then\n * `{ field: undefined, isRequired: undefined }` is returned.\n */\nexport default function findFieldInSchema<\n T = undefined,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n rootSchema: S,\n schema: S,\n path: string | string[],\n formData: T = {} as T,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): FoundFieldType<S> {\n const pathList = Array.isArray(path) ? [...path] : path.split('.');\n let parentField = schema;\n\n // store the desired field into a variable and removing it from the `pathList`\n const fieldName = pathList.pop()!;\n\n if (pathList.length) {\n // drilling into the schema for each sub-path and taking into account of the any/oneOfs\n pathList.forEach((subPath) => {\n parentField = getFromSchema<T, S, F>(\n validator,\n rootSchema,\n parentField,\n [PROPERTIES_KEY, subPath],\n {} as S,\n experimental_customMergeAllOf,\n );\n if (has(parentField, ONE_OF_KEY)) {\n // if this sub-path has a `oneOf` then use the formData to drill into the schema with the selected option\n parentField = findSelectedOptionInXxxOf(\n validator,\n rootSchema,\n parentField,\n fieldName,\n ONE_OF_KEY,\n get(formData, subPath),\n experimental_customMergeAllOf,\n )!;\n } else if (has(parentField, ANY_OF_KEY)) {\n // if this sub-path has a `anyOf` then use the formData to drill into the schema with the selected option\n parentField = findSelectedOptionInXxxOf(\n validator,\n rootSchema,\n parentField,\n fieldName,\n ANY_OF_KEY,\n get(formData, subPath),\n experimental_customMergeAllOf,\n )!;\n }\n });\n }\n\n if (has(parentField, ONE_OF_KEY)) {\n // When oneOf is in the root schema, use the formData to drill into the schema with the selected option\n parentField = findSelectedOptionInXxxOf(\n validator,\n rootSchema,\n parentField,\n fieldName,\n ONE_OF_KEY,\n formData,\n experimental_customMergeAllOf,\n )!;\n } else if (has(parentField, ANY_OF_KEY)) {\n // When anyOf is in the root schema, use the formData to drill into the schema with the selected option\n parentField = findSelectedOptionInXxxOf(\n validator,\n rootSchema,\n parentField,\n fieldName,\n ANY_OF_KEY,\n formData,\n experimental_customMergeAllOf,\n )!;\n }\n\n // taking the most updated `parentField`, get our desired field\n let field: S | undefined = getFromSchema<T, S, F>(\n validator,\n rootSchema,\n parentField,\n [PROPERTIES_KEY, fieldName],\n NOT_FOUND_SCHEMA as S,\n experimental_customMergeAllOf,\n );\n if (field === NOT_FOUND_SCHEMA) {\n field = undefined;\n }\n // check to see if our desired field is in the `required` list for its parent\n const requiredArray = getFromSchema<T, S, F>(\n validator,\n rootSchema,\n parentField,\n REQUIRED_KEY,\n [] as T,\n experimental_customMergeAllOf,\n );\n let isRequired: boolean | undefined;\n if (field && Array.isArray(requiredArray)) {\n isRequired = requiredArray.includes(fieldName);\n }\n\n return { field, isRequired };\n}\n", "import get from 'lodash/get';\nimport isEqual from 'lodash/isEqual';\n\nimport { CONST_KEY, DEFAULT_KEY, PROPERTIES_KEY } from '../constants';\nimport { Experimental_CustomMergeAllOf, FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '../types';\nimport retrieveSchema from './retrieveSchema';\nimport getDiscriminatorFieldFromSchema from '../getDiscriminatorFieldFromSchema';\n\n/** Finds the option inside the `schema['any/oneOf']` list which has the `properties[selectorField].default` or\n * `properties[selectorField].const` that matches the `formData[selectorField]` value. For the purposes of this\n * function, `selectorField` is either `schema.discriminator.propertyName` or `fallbackField`. The `LayoutGridField`\n * works directly with schemas in a recursive manner, making this faster than `getFirstMatchingOption()`.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param schema - The schema element in which to search for the selected anyOf/oneOf option\n * @param fallbackField - The field to use as a backup selector field if the schema does not have a required field\n * @param xxx - Either `anyOf` or `oneOf`, defines which value is being sought\n * @param [formData={}] - The form data that is used to determine which anyOf/oneOf option to descend\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The anyOf/oneOf option that matches the selector field in the schema or undefined if nothing is selected\n */\nexport default function findSelectedOptionInXxxOf<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n rootSchema: S,\n schema: S,\n fallbackField: string,\n xxx: 'anyOf' | 'oneOf',\n formData: T = {} as T,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): S | undefined {\n if (Array.isArray(schema[xxx])) {\n const discriminator = getDiscriminatorFieldFromSchema<S>(schema);\n const selectorField = discriminator || fallbackField;\n const xxxOfs = schema[xxx]!.map((xxxOf) =>\n retrieveSchema<T, S, F>(validator, xxxOf as S, rootSchema, formData, experimental_customMergeAllOf),\n );\n const data = get(formData, selectorField);\n if (data !== undefined) {\n return xxxOfs.find((xxx) => {\n return isEqual(\n get(xxx, [PROPERTIES_KEY, selectorField, DEFAULT_KEY], get(xxx, [PROPERTIES_KEY, selectorField, CONST_KEY])),\n data,\n );\n });\n }\n }\n return undefined;\n}\n", "import get from 'lodash/get';\nimport set from 'lodash/set';\nimport times from 'lodash/times';\nimport transform from 'lodash/transform';\nimport merge from 'lodash/merge';\nimport flattenDeep from 'lodash/flattenDeep';\nimport uniq from 'lodash/uniq';\nimport isEmpty from 'lodash/isEmpty';\nimport { createComparator, createMerger, createShallowAllOfMerge } from '@x0k/json-schema-merge';\nimport { createDeduplicator, createIntersector } from '@x0k/json-schema-merge/lib/array';\n\nimport {\n ADDITIONAL_PROPERTIES_KEY,\n ADDITIONAL_PROPERTY_FLAG,\n ALL_OF_KEY,\n ANY_OF_KEY,\n DEPENDENCIES_KEY,\n ID_KEY,\n IF_KEY,\n ITEMS_KEY,\n ONE_OF_KEY,\n PATTERN_PROPERTIES_KEY,\n PROPERTIES_KEY,\n REF_KEY,\n RJSF_REF_KEY,\n} from '../constants';\nimport findSchemaDefinition, { splitKeyElementFromObject } from '../findSchemaDefinition';\nimport getDiscriminatorFieldFromSchema from '../getDiscriminatorFieldFromSchema';\nimport guessType from '../guessType';\nimport isObject from '../isObject';\nimport mergeSchemas from '../mergeSchemas';\nimport {\n Experimental_CustomMergeAllOf,\n FormContextType,\n GenericObjectType,\n RJSFSchema,\n StrictRJSFSchema,\n ValidatorType,\n} from '../types';\nimport getFirstMatchingOption from './getFirstMatchingOption';\nimport deepEquals from '../deepEquals';\n\n/** Retrieves an expanded schema that has had all of its conditions, additional properties, references and dependencies\n * resolved and merged into the `schema` given a `validator`, `rootSchema` and `rawFormData` that is used to do the\n * potentially recursive resolution.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs\n * @param schema - The schema for which retrieving a schema is desired\n * @param [rootSchema={}] - The root schema that will be forwarded to all the APIs\n * @param [rawFormData] - The current formData, if any, to assist retrieving a schema\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @param [resolveAnyOfOrOneOfRefs = false] - Optional flag indicating whether to resolved refs in anyOf/oneOf lists\n * @returns - The schema having its conditions, additional properties, references and dependencies resolved\n */\nexport default function retrieveSchema<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n rootSchema: S = {} as S,\n rawFormData?: T,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n resolveAnyOfOrOneOfRefs = false,\n): S {\n return retrieveSchemaInternal<T, S, F>(\n validator,\n schema,\n rootSchema,\n rawFormData,\n undefined,\n undefined,\n experimental_customMergeAllOf,\n resolveAnyOfOrOneOfRefs,\n )[0];\n}\n\n/** Resolves a conditional block (if/else/then) by removing the condition and merging the appropriate conditional branch\n * with the rest of the schema. If `expandAllBranches` is true, then the `retrieveSchemaInteral()` results for both\n * conditions will be returned.\n *\n * @param validator - An implementation of the `ValidatorType` interface that is used to detect valid schema conditions\n * @param schema - The schema for which resolving a condition is desired\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param expandAllBranches - Flag, if true, will return all possible branches of conditions, any/oneOf and\n * dependencies as a list of schemas\n * @param recurseList - The list of recursive references already processed\n * @param [formData] - The current formData to assist retrieving a schema\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - A list of schemas with the appropriate conditions resolved, possibly with all branches expanded\n */\nexport function resolveCondition<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n rootSchema: S,\n expandAllBranches: boolean,\n recurseList: string[],\n formData?: T,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): S[] {\n const { if: expression, then, else: otherwise, ...resolvedSchemaLessConditional } = schema;\n\n const conditionValue = validator.isValid(expression as S, formData || ({} as T), rootSchema);\n let resolvedSchemas = [resolvedSchemaLessConditional as S];\n let schemas: S[] = [];\n if (expandAllBranches) {\n if (then && typeof then !== 'boolean') {\n schemas = schemas.concat(\n retrieveSchemaInternal<T, S, F>(\n validator,\n then as S,\n rootSchema,\n formData,\n expandAllBranches,\n recurseList,\n experimental_customMergeAllOf,\n ),\n );\n }\n if (otherwise && typeof otherwise !== 'boolean') {\n schemas = schemas.concat(\n retrieveSchemaInternal<T, S, F>(\n validator,\n otherwise as S,\n rootSchema,\n formData,\n expandAllBranches,\n recurseList,\n experimental_customMergeAllOf,\n ),\n );\n }\n } else {\n const conditionalSchema = conditionValue ? then : otherwise;\n if (conditionalSchema && typeof conditionalSchema !== 'boolean') {\n schemas = schemas.concat(\n retrieveSchemaInternal<T, S, F>(\n validator,\n conditionalSchema as S,\n rootSchema,\n formData,\n expandAllBranches,\n recurseList,\n experimental_customMergeAllOf,\n ),\n );\n }\n }\n if (schemas.length) {\n resolvedSchemas = schemas.map((s) => mergeSchemas(resolvedSchemaLessConditional, s) as S);\n }\n return resolvedSchemas.flatMap((s) =>\n retrieveSchemaInternal<T, S, F>(\n validator,\n s,\n rootSchema,\n formData,\n expandAllBranches,\n recurseList,\n experimental_customMergeAllOf,\n ),\n );\n}\n\n/** Given a list of lists of allOf, anyOf or oneOf values, create a list of lists of all permutations of the values. The\n * `listOfLists` is expected to be all resolved values of the 1st...nth schemas within an `allOf`, `anyOf` or `oneOf`.\n * From those lists, build a matrix for each `xxxOf` where there is more than one schema for a row in the list of lists.\n *\n * For example:\n * - If there are three xxxOf rows (A, B, C) and they have been resolved such that there is only one A, two B and three\n * C schemas then:\n * - The permutation for the first row is `[[A]]`\n * - The permutations for the second row are `[[A,B1], [A,B2]]`\n * - The permutations for the third row are `[[A,B1,C1], [A,B1,C2], [A,B1,C3], [A,B2,C1], [A,B2,C2], [A,B2,C3]]`\n *\n * @param listOfLists - The list of lists of elements that represent the allOf, anyOf or oneOf resolved values in order\n * @returns - The list of all permutations of schemas for a set of `xxxOf`s\n */\nexport function getAllPermutationsOfXxxOf<S extends StrictRJSFSchema = RJSFSchema>(listOfLists: S[][]) {\n const allPermutations: S[][] = listOfLists.reduce<S[][]>(\n (permutations, list) => {\n // When there are more than one set of schemas for a row, duplicate the set of permutations and add in the values\n if (list.length > 1) {\n return list.flatMap((element) => times(permutations.length, (i) => [...permutations[i]].concat(element)));\n }\n // Otherwise just push in the single value into the current set of permutations\n permutations.forEach((permutation) => permutation.push(list[0]));\n return permutations;\n },\n [[]] as S[][], // Start with an empty list\n );\n\n return allPermutations;\n}\n\n/** Returns the subset of 'patternProperties' specifications that match the given 'key'\n *\n * @param schema - The schema whose 'patternProperties' are to be filtered\n * @param key - The key to match against the 'patternProperties' specifications\n * @returns - The subset of 'patternProperties' specifications that match the given 'key'\n */\nexport function getMatchingPatternProperties<S extends StrictRJSFSchema = RJSFSchema>(\n schema: S,\n key: string,\n): Required<S['patternProperties']> {\n return Object.keys(schema.patternProperties!)\n .filter((pattern: string) => RegExp(pattern).test(key))\n .reduce(\n (obj, pattern) => {\n // Pass the pattern using the `[]` index notation so that any `.` in the pattern are not used as a dotted path\n set(obj, [pattern], schema.patternProperties![pattern]);\n return obj;\n },\n {} as Required<S['patternProperties']>,\n );\n}\n\n/** Resolves references and dependencies within a schema and its 'allOf' children. Passes the `expandAllBranches` flag\n * down to the `retrieveSchemaInternal()`, `resolveReference()` and `resolveDependencies()` helper calls. If\n * `expandAllBranches` is true, then all possible dependencies and/or allOf branches are returned.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs\n * @param schema - The schema for which resolving a schema is desired\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param expandAllBranches - Flag, if true, will return all possible branches of conditions, any/oneOf and dependencies\n * as a list of schemas\n * @param recurseList - The list of recursive references already processed\n * @param [formData] - The current formData, if any, to assist retrieving a schema\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @param [resolveAnyOfOrOneOfRefs] - Optional flag indicating whether to resolved refs in anyOf/oneOf lists\n * @returns - The list of schemas having its references, dependencies and allOf schemas resolved\n */\nexport function resolveSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n rootSchema: S,\n expandAllBranches: boolean,\n recurseList: string[],\n formData?: T,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n resolveAnyOfOrOneOfRefs?: boolean,\n): S[] {\n const updatedSchemas = resolveReference<T, S, F>(\n validator,\n schema,\n rootSchema,\n expandAllBranches,\n recurseList,\n formData,\n experimental_customMergeAllOf,\n resolveAnyOfOrOneOfRefs,\n );\n if (updatedSchemas.length > 1 || updatedSchemas[0] !== schema) {\n // return the updatedSchemas array if it has either multiple schemas within it\n // OR the first schema is not the same as the original schema\n return updatedSchemas;\n }\n if (DEPENDENCIES_KEY in schema) {\n const resolvedSchemas = resolveDependencies<T, S, F>(\n validator,\n schema,\n rootSchema,\n expandAllBranches,\n recurseList,\n formData,\n experimental_customMergeAllOf,\n );\n return resolvedSchemas.flatMap((s) => {\n return retrieveSchemaInternal<T, S, F>(\n validator,\n s,\n rootSchema,\n formData,\n expandAllBranches,\n recurseList,\n experimental_customMergeAllOf,\n );\n });\n }\n if (ALL_OF_KEY in schema && Array.isArray(schema[ALL_OF_KEY])) {\n const allOfSchemaElements: S[][] = schema.allOf.map((allOfSubschema) =>\n retrieveSchemaInternal<T, S, F>(\n validator,\n allOfSubschema as S,\n rootSchema,\n formData,\n expandAllBranches,\n recurseList,\n experimental_customMergeAllOf,\n ),\n );\n const allPermutations = getAllPermutationsOfXxxOf<S>(allOfSchemaElements);\n return allPermutations.map((permutation) => ({\n ...schema,\n allOf: permutation,\n }));\n }\n // No $ref or dependencies or allOf attribute was found, returning the original schema.\n return [schema];\n}\n\n/** Resolves all references within a schema and then returns the `retrieveSchemaInternal()` if the resolved schema is\n * actually different than the original. Passes the `expandAllBranches` flag down to the `retrieveSchemaInternal()`\n * helper call.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs\n * @param schema - The schema for which resolving a reference is desired\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param expandAllBranches - Flag, if true, will return all possible branches of conditions, any/oneOf and dependencies\n * as a list of schemas\n * @param recurseList - The list of recursive references already processed\n * @param [formData] - The current formData, if any, to assist retrieving a schema\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @param [resolveAnyOfOrOneOfRefs] - Optional flag indicating whether to resolved refs in anyOf/oneOf lists\n * @returns - The list schemas retrieved after having all references resolved\n */\nexport function resolveReference<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(\n validator: ValidatorType<T, S, F>,\n schema: S,\n rootSchema: S,\n expandAllBranches: boolean,\n recurseList: string[],\n formData?: T,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n resolveAnyOfOrOneOfRefs?: boolean,\n): S[] {\n const updatedSchema = resolveAllReferences<S>(schema, rootSchema, recurseList, undefined, resolveAnyOfOrOneOfRefs);\n if (updatedSchema !== schema) {\n // Only call this if the schema was actually changed by the `resolveAllReferences()` function\n return retrieveSchemaInternal<T, S, F>(\n validator,\n updatedSchema,\n rootSchema,\n formData,\n expandAllBranches,\n recurseList,\n experimental_customMergeAllOf,\n resolveAnyOfOrOneOfRefs,\n );\n }\n return [schema];\n}\n\n/** Resolves all references within the schema itself as well as any of its properties and array items.\n *\n * @param schema - The schema for which resolving all references is desired\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param recurseList - List of $refs already resolved to prevent recursion\n * @param [baseURI] - The base URI to be used for resolving relative references\n * @param [resolveAnyOfOrOneOfRefs] - Optional flag indicating whether to resolved refs in anyOf/oneOf lists\n * @returns - given schema will all references resolved or the original schema if no internal `$refs` were resolved\n */\nexport function resolveAllReferences<S extends StrictRJSFSchema = RJSFSchema>(\n schema: S,\n rootSchema: S,\n recurseList: string[],\n baseURI?: string,\n resolveAnyOfOrOneOfRefs?: boolean,\n): S {\n if (!isObject(schema)) {\n return schema;\n }\n let resolvedSchema: S = schema;\n // resolve top level ref\n if (REF_KEY in resolvedSchema) {\n const { $ref, ...localSchema } = resolvedSchema;\n // Check for a recursive reference and stop the loop\n if (recurseList.includes($ref!)) {\n return resolvedSchema;\n }\n recurseList.push($ref!);\n // Retrieve the referenced schema definition.\n const refSchema = findSchemaDefinition<S>($ref, rootSchema, baseURI);\n resolvedSchema = { ...refSchema, ...localSchema, [RJSF_REF_KEY]: $ref };\n if (ID_KEY in resolvedSchema) {\n baseURI = resolvedSchema[ID_KEY];\n }\n }\n\n if (PROPERTIES_KEY in resolvedSchema) {\n const childrenLists: string[][] = [];\n const updatedProps = transform(\n resolvedSchema[PROPERTIES_KEY]!,\n (result, value, key: string) => {\n const childList: string[] = [...recurseList];\n result[key] = resolveAllReferences(value as S, rootSchema, childList, baseURI, resolveAnyOfOrOneOfRefs);\n childrenLists.push(childList);\n },\n {} as RJSFSchema,\n );\n merge(recurseList, uniq(flattenDeep(childrenLists)));\n resolvedSchema = { ...resolvedSchema, [PROPERTIES_KEY]: updatedProps };\n }\n\n if (\n ITEMS_KEY in resolvedSchema &&\n !Array.isArray(resolvedSchema.items) &&\n typeof resolvedSchema.items !== 'boolean'\n ) {\n resolvedSchema = {\n ...resolvedSchema,\n items: resolveAllReferences(resolvedSchema.items as S, rootSchema, recurseList, baseURI, resolveAnyOfOrOneOfRefs),\n };\n }\n\n if (resolveAnyOfOrOneOfRefs) {\n let key: 'anyOf' | 'oneOf' | undefined;\n let schemas: S[] | undefined;\n if (ANY_OF_KEY in schema && Array.isArray(schema[ANY_OF_KEY])) {\n key = ANY_OF_KEY;\n schemas = resolvedSchema[ANY_OF_KEY] as S[];\n } else if (ONE_OF_KEY in schema && Array.isArray(schema[ONE_OF_KEY])) {\n key = ONE_OF_KEY;\n schemas = resolvedSchema[ONE_OF_KEY] as S[];\n }\n if (key && schemas) {\n resolvedSchema = {\n ...resolvedSchema,\n [key]: schemas.map((s: S) =>\n resolveAllReferences(s, rootSchema, recurseList, baseURI, resolveAnyOfOrOneOfRefs),\n ),\n };\n }\n }\n\n return deepEquals(schema, resolvedSchema) ? schema : resolvedSchema;\n}\n\n/** Creates new 'properties' items for each key in the `formData`\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary\n * @param theSchema - The schema for which the existing additional properties is desired\n * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s * @param validator\n * @param [aFormData] - The current formData, if any, to assist retrieving a schema\n * @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas\n * @returns - The updated schema with additional properties stubbed\n */\nexport function stubExistingAdditionalProperties<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(\n validator: ValidatorType<T, S, F>,\n theSchema: S,\n rootSchema?: S,\n aFormData?: T,\n experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>,\n): S {\n // Clone the schema so that we don't ruin the consumer's original\n const schema = {\n ...theSchema,\n properties: { ...theSchema.properties },\n };\n\n // make sure formData is an object\n const formData: GenericObjectType = aFormData && isObject(aFormData) ? aFormData : {};\n Object.keys(formData).forEach((key) => {\n if (key in schema.properties) {\n // No need to stub, our schema already has the property\n return;\n }\n if (PATTERN_PROPERTIES_KEY in schema) {\n const matchingProperties = getMatchingPatternProperties(schema, key);\n if (!isEmpty(matchingProperties)) {\n schema.properties[key] = retrieveSchema<T, S, F>(\n validator,\n { [ALL_OF_KEY]: Object.values(matchingProperties) } as S,\n rootSchema,\n get(formData, [key]) as T,\n experimental_customMergeAllOf,\n );\n set(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);\n return;\n }\n }\n if (ADDITIONAL_PROPERTIES_KEY in schema && schema.additionalProperties !== false) {\n let additionalProperties: S['additionalProperties'];\n if (typeof schema.additionalProperties !== 'boolean') {\n if (REF_KEY in schema.additionalProperties!) {\n additionalProperties = retrieveSchema<T, S, F>(\n validator,\n { [REF_KEY]: get(schema.additionalProperties, [REF_KEY]) } as S,\n rootSchema,\n formData as T,\n experimental_customMergeAllOf,\n );\n } else if ('type' in schema.additionalProperties!) {\n additionalProperties = { ...schema.additionalProperties };\n } else if (ANY_OF_KEY in schema.additionalProperties! || ONE_OF_KEY in schema.additionalProperties!) {\n additionalProperties = {\n type: 'object',\n ...schema.additionalProperties,\n };\n } else {\n additionalProperties = { type: guessType(get(formData, [key])) };\n }\n } else {\n additionalProperties = { type: guessType(get(formData, [key])) };\n }\n\n // The type of our new key should match the additionalProperties value;\n schema.properties[key] = additionalProperties;\n // Set our additional property flag so we know it was dynamically added\n set(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);\n } else {\n // Invalid property\n schema.properties[key] = { type: 'null' };\n // Set our additional property flag so we know it was dynamically added\n set(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);\n }\n });\n\n return schema;\n}\n\n// Set up @x0k/json-schema-merge utilities\nconst { compareSchemaDefinitions, compareSchemaValues } = createComparator();\nconst { mergeArrayOfSchemaDefinitions } = createMerger({\n intersectJson: createIntersector(compareSchemaValues),\n deduplicateJsonSchemaDef: createDeduplicator(compareSchemaDefinitions),\n});\n\nconst shallowAllOfMerge = createShallowAllOfMerge(mergeArrayOfSchemaDefinitions);\n\n/**\n * Internal helper that merges allOf schemas using @x0k/json-schema-merge's shallow allOf merge\n * @param schema - The schema containing an `allOf` keyword\n * @returns The schema with allOf schemas merged\n */\nfunction mergeAllOf<S extends StrictRJSFSchema = RJSFSchema>(schema: S): S {\n return shallowAllOfMerge(schema) as S;\n}\n\n/** Internal handler that retrieves an expanded schema that has had all of its conditions, additional properties,\n * references and dependencies resolved and merged into the `schema` given a `validator`, `rootSchema` and `rawFormData`\n * that is used to do the potentially recursive resolution. If `expandAllBranches` is true, then all possible branches\n * of the schema and its references, conditions and dependencies are returned.\n *\n * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs\n * @param schema - The schema for which retrieving a schema is desired\n * @param rootSchema - The root schema that will be forwarded to all the APIs\n * @param [rawFormData] - The cu