diff options
Diffstat (limited to 'sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd')
13 files changed, 0 insertions, 679 deletions
diff --git a/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/discriminator.ts b/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/discriminator.ts deleted file mode 100644 index f487c97f..00000000 --- a/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/discriminator.ts +++ /dev/null @@ -1,89 +0,0 @@ -import type {CodeKeywordDefinition, KeywordErrorDefinition} from "../../types" -import type {KeywordCxt} from "../../compile/validate" -import {_, not, getProperty, Name} from "../../compile/codegen" -import {checkMetadata} from "./metadata" -import {checkNullableObject} from "./nullable" -import {typeErrorMessage, typeErrorParams, _JTDTypeError} from "./error" -import {DiscrError, DiscrErrorObj} from "../discriminator/types" - -export type JTDDiscriminatorError = - | _JTDTypeError<"discriminator", "object", string> - | DiscrErrorObj<DiscrError.Tag> - | DiscrErrorObj<DiscrError.Mapping> - -const error: KeywordErrorDefinition = { - message: (cxt) => { - const {schema, params} = cxt - return params.discrError - ? params.discrError === DiscrError.Tag - ? `tag "${schema}" must be string` - : `value of tag "${schema}" must be in mapping` - : typeErrorMessage(cxt, "object") - }, - params: (cxt) => { - const {schema, params} = cxt - return params.discrError - ? _`{error: ${params.discrError}, tag: ${schema}, tagValue: ${params.tag}}` - : typeErrorParams(cxt, "object") - }, -} - -const def: CodeKeywordDefinition = { - keyword: "discriminator", - schemaType: "string", - implements: ["mapping"], - error, - code(cxt: KeywordCxt) { - checkMetadata(cxt) - const {gen, data, schema, parentSchema} = cxt - const [valid, cond] = checkNullableObject(cxt, data) - - gen.if(cond) - validateDiscriminator() - gen.elseIf(not(valid)) - cxt.error() - gen.endIf() - cxt.ok(valid) - - function validateDiscriminator(): void { - const tag = gen.const("tag", _`${data}${getProperty(schema)}`) - gen.if(_`${tag} === undefined`) - cxt.error(false, {discrError: DiscrError.Tag, tag}) - gen.elseIf(_`typeof ${tag} == "string"`) - validateMapping(tag) - gen.else() - cxt.error(false, {discrError: DiscrError.Tag, tag}, {instancePath: schema}) - gen.endIf() - } - - function validateMapping(tag: Name): void { - gen.if(false) - for (const tagValue in parentSchema.mapping) { - gen.elseIf(_`${tag} === ${tagValue}`) - gen.assign(valid, applyTagSchema(tagValue)) - } - gen.else() - cxt.error( - false, - {discrError: DiscrError.Mapping, tag}, - {instancePath: schema, schemaPath: "mapping", parentSchema: true} - ) - gen.endIf() - } - - function applyTagSchema(schemaProp: string): Name { - const _valid = gen.name("valid") - cxt.subschema( - { - keyword: "mapping", - schemaProp, - jtdDiscriminator: schema, - }, - _valid - ) - return _valid - } - }, -} - -export default def diff --git a/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/elements.ts b/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/elements.ts deleted file mode 100644 index 983af7c0..00000000 --- a/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/elements.ts +++ /dev/null @@ -1,32 +0,0 @@ -import type {CodeKeywordDefinition, SchemaObject} from "../../types" -import type {KeywordCxt} from "../../compile/validate" -import {alwaysValidSchema} from "../../compile/util" -import {validateArray} from "../code" -import {_, not} from "../../compile/codegen" -import {checkMetadata} from "./metadata" -import {checkNullable} from "./nullable" -import {typeError, _JTDTypeError} from "./error" - -export type JTDElementsError = _JTDTypeError<"elements", "array", SchemaObject> - -const def: CodeKeywordDefinition = { - keyword: "elements", - schemaType: "object", - error: typeError("array"), - code(cxt: KeywordCxt) { - checkMetadata(cxt) - const {gen, data, schema, it} = cxt - if (alwaysValidSchema(it, schema)) return - const [valid] = checkNullable(cxt) - gen.if(not(valid), () => - gen.if( - _`Array.isArray(${data})`, - () => gen.assign(valid, validateArray(cxt)), - () => cxt.error() - ) - ) - cxt.ok(valid) - }, -} - -export default def diff --git a/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/enum.ts b/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/enum.ts deleted file mode 100644 index 75464ff8..00000000 --- a/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/enum.ts +++ /dev/null @@ -1,45 +0,0 @@ -import type {CodeKeywordDefinition, KeywordErrorDefinition, ErrorObject} from "../../types" -import type {KeywordCxt} from "../../compile/validate" -import {_, or, and, Code} from "../../compile/codegen" -import {checkMetadata} from "./metadata" -import {checkNullable} from "./nullable" - -export type JTDEnumError = ErrorObject<"enum", {allowedValues: string[]}, string[]> - -const error: KeywordErrorDefinition = { - message: "must be equal to one of the allowed values", - params: ({schemaCode}) => _`{allowedValues: ${schemaCode}}`, -} - -const def: CodeKeywordDefinition = { - keyword: "enum", - schemaType: "array", - error, - code(cxt: KeywordCxt) { - checkMetadata(cxt) - const {gen, data, schema, schemaValue, parentSchema, it} = cxt - if (schema.length === 0) throw new Error("enum must have non-empty array") - if (schema.length !== new Set(schema).size) throw new Error("enum items must be unique") - let valid: Code - const isString = _`typeof ${data} == "string"` - if (schema.length >= it.opts.loopEnum) { - let cond: Code - ;[valid, cond] = checkNullable(cxt, isString) - gen.if(cond, loopEnum) - } else { - /* istanbul ignore if */ - if (!Array.isArray(schema)) throw new Error("ajv implementation error") - valid = and(isString, or(...schema.map((value: string) => _`${data} === ${value}`))) - if (parentSchema.nullable) valid = or(_`${data} === null`, valid) - } - cxt.pass(valid) - - function loopEnum(): void { - gen.forOf("v", schemaValue as Code, (v) => - gen.if(_`${valid} = ${data} === ${v}`, () => gen.break()) - ) - } - }, -} - -export default def diff --git a/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/error.ts b/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/error.ts deleted file mode 100644 index 50693225..00000000 --- a/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/error.ts +++ /dev/null @@ -1,23 +0,0 @@ -import type {KeywordErrorDefinition, KeywordErrorCxt, ErrorObject} from "../../types" -import {_, Code} from "../../compile/codegen" - -export type _JTDTypeError<K extends string, T extends string, S> = ErrorObject< - K, - {type: T; nullable: boolean}, - S -> - -export function typeError(t: string): KeywordErrorDefinition { - return { - message: (cxt) => typeErrorMessage(cxt, t), - params: (cxt) => typeErrorParams(cxt, t), - } -} - -export function typeErrorMessage({parentSchema}: KeywordErrorCxt, t: string): string { - return parentSchema?.nullable ? `must be ${t} or null` : `must be ${t}` -} - -export function typeErrorParams({parentSchema}: KeywordErrorCxt, t: string): Code { - return _`{type: ${t}, nullable: ${!!parentSchema?.nullable}}` -} diff --git a/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/index.ts b/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/index.ts deleted file mode 100644 index f7baebc3..00000000 --- a/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/index.ts +++ /dev/null @@ -1,37 +0,0 @@ -import type {Vocabulary} from "../../types" -import refKeyword from "./ref" -import typeKeyword, {JTDTypeError} from "./type" -import enumKeyword, {JTDEnumError} from "./enum" -import elements, {JTDElementsError} from "./elements" -import properties, {JTDPropertiesError} from "./properties" -import optionalProperties from "./optionalProperties" -import discriminator, {JTDDiscriminatorError} from "./discriminator" -import values, {JTDValuesError} from "./values" -import union from "./union" -import metadata from "./metadata" - -const jtdVocabulary: Vocabulary = [ - "definitions", - refKeyword, - typeKeyword, - enumKeyword, - elements, - properties, - optionalProperties, - discriminator, - values, - union, - metadata, - {keyword: "additionalProperties", schemaType: "boolean"}, - {keyword: "nullable", schemaType: "boolean"}, -] - -export default jtdVocabulary - -export type JTDErrorObject = - | JTDTypeError - | JTDEnumError - | JTDElementsError - | JTDPropertiesError - | JTDDiscriminatorError - | JTDValuesError diff --git a/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/metadata.ts b/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/metadata.ts deleted file mode 100644 index 19eeb8c7..00000000 --- a/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/metadata.ts +++ /dev/null @@ -1,24 +0,0 @@ -import {KeywordCxt} from "../../ajv" -import type {CodeKeywordDefinition} from "../../types" -import {alwaysValidSchema} from "../../compile/util" - -const def: CodeKeywordDefinition = { - keyword: "metadata", - schemaType: "object", - code(cxt: KeywordCxt) { - checkMetadata(cxt) - const {gen, schema, it} = cxt - if (alwaysValidSchema(it, schema)) return - const valid = gen.name("valid") - cxt.subschema({keyword: "metadata", jtdMetadata: true}, valid) - cxt.ok(valid) - }, -} - -export function checkMetadata({it, keyword}: KeywordCxt, metadata?: boolean): void { - if (it.jtdMetadata !== metadata) { - throw new Error(`JTD: "${keyword}" cannot be used in this schema location`) - } -} - -export default def diff --git a/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/nullable.ts b/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/nullable.ts deleted file mode 100644 index c74b05da..00000000 --- a/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/nullable.ts +++ /dev/null @@ -1,21 +0,0 @@ -import type {KeywordCxt} from "../../compile/validate" -import {_, not, nil, Code, Name} from "../../compile/codegen" - -export function checkNullable( - {gen, data, parentSchema}: KeywordCxt, - cond: Code = nil -): [Name, Code] { - const valid = gen.name("valid") - if (parentSchema.nullable) { - gen.let(valid, _`${data} === null`) - cond = not(valid) - } else { - gen.let(valid, false) - } - return [valid, cond] -} - -export function checkNullableObject(cxt: KeywordCxt, cond: Code): [Name, Code] { - const [valid, cond_] = checkNullable(cxt, cond) - return [valid, _`${cond_} && typeof ${cxt.data} == "object" && !Array.isArray(${cxt.data})`] -} diff --git a/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/optionalProperties.ts b/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/optionalProperties.ts deleted file mode 100644 index 8e91c8d9..00000000 --- a/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/optionalProperties.ts +++ /dev/null @@ -1,15 +0,0 @@ -import type {CodeKeywordDefinition} from "../../types" -import type {KeywordCxt} from "../../compile/validate" -import {validateProperties, error} from "./properties" - -const def: CodeKeywordDefinition = { - keyword: "optionalProperties", - schemaType: "object", - error, - code(cxt: KeywordCxt) { - if (cxt.parentSchema.properties) return - validateProperties(cxt) - }, -} - -export default def diff --git a/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/properties.ts b/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/properties.ts deleted file mode 100644 index 728c0b92..00000000 --- a/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/properties.ts +++ /dev/null @@ -1,177 +0,0 @@ -import type { - CodeKeywordDefinition, - ErrorObject, - KeywordErrorDefinition, - SchemaObject, -} from "../../types" -import type {KeywordCxt} from "../../compile/validate" -import {propertyInData, allSchemaProperties, isOwnProperty} from "../code" -import {alwaysValidSchema, schemaRefOrVal} from "../../compile/util" -import {_, and, not, Code, Name} from "../../compile/codegen" -import {checkMetadata} from "./metadata" -import {checkNullableObject} from "./nullable" -import {typeErrorMessage, typeErrorParams, _JTDTypeError} from "./error" - -enum PropError { - Additional = "additional", - Missing = "missing", -} - -type PropKeyword = "properties" | "optionalProperties" - -type PropSchema = {[P in string]?: SchemaObject} - -export type JTDPropertiesError = - | _JTDTypeError<PropKeyword, "object", PropSchema> - | ErrorObject<PropKeyword, {error: PropError.Additional; additionalProperty: string}, PropSchema> - | ErrorObject<PropKeyword, {error: PropError.Missing; missingProperty: string}, PropSchema> - -export const error: KeywordErrorDefinition = { - message: (cxt) => { - const {params} = cxt - return params.propError - ? params.propError === PropError.Additional - ? "must NOT have additional properties" - : `must have property '${params.missingProperty}'` - : typeErrorMessage(cxt, "object") - }, - params: (cxt) => { - const {params} = cxt - return params.propError - ? params.propError === PropError.Additional - ? _`{error: ${params.propError}, additionalProperty: ${params.additionalProperty}}` - : _`{error: ${params.propError}, missingProperty: ${params.missingProperty}}` - : typeErrorParams(cxt, "object") - }, -} - -const def: CodeKeywordDefinition = { - keyword: "properties", - schemaType: "object", - error, - code: validateProperties, -} - -// const error: KeywordErrorDefinition = { -// message: "should NOT have additional properties", -// params: ({params}) => _`{additionalProperty: ${params.additionalProperty}}`, -// } - -export function validateProperties(cxt: KeywordCxt): void { - checkMetadata(cxt) - const {gen, data, parentSchema, it} = cxt - const {additionalProperties, nullable} = parentSchema - if (it.jtdDiscriminator && nullable) throw new Error("JTD: nullable inside discriminator mapping") - if (commonProperties()) { - throw new Error("JTD: properties and optionalProperties have common members") - } - const [allProps, properties] = schemaProperties("properties") - const [allOptProps, optProperties] = schemaProperties("optionalProperties") - if (properties.length === 0 && optProperties.length === 0 && additionalProperties) { - return - } - - const [valid, cond] = - it.jtdDiscriminator === undefined - ? checkNullableObject(cxt, data) - : [gen.let("valid", false), true] - gen.if(cond, () => - gen.assign(valid, true).block(() => { - validateProps(properties, "properties", true) - validateProps(optProperties, "optionalProperties") - if (!additionalProperties) validateAdditional() - }) - ) - cxt.pass(valid) - - function commonProperties(): boolean { - const props = parentSchema.properties as Record<string, any> | undefined - const optProps = parentSchema.optionalProperties as Record<string, any> | undefined - if (!(props && optProps)) return false - for (const p in props) { - if (Object.prototype.hasOwnProperty.call(optProps, p)) return true - } - return false - } - - function schemaProperties(keyword: string): [string[], string[]] { - const schema = parentSchema[keyword] - const allPs = schema ? allSchemaProperties(schema) : [] - if (it.jtdDiscriminator && allPs.some((p) => p === it.jtdDiscriminator)) { - throw new Error(`JTD: discriminator tag used in ${keyword}`) - } - const ps = allPs.filter((p) => !alwaysValidSchema(it, schema[p])) - return [allPs, ps] - } - - function validateProps(props: string[], keyword: string, required?: boolean): void { - const _valid = gen.var("valid") - for (const prop of props) { - gen.if( - propertyInData(gen, data, prop, it.opts.ownProperties), - () => applyPropertySchema(prop, keyword, _valid), - () => missingProperty(prop) - ) - cxt.ok(_valid) - } - - function missingProperty(prop: string): void { - if (required) { - gen.assign(_valid, false) - cxt.error(false, {propError: PropError.Missing, missingProperty: prop}, {schemaPath: prop}) - } else { - gen.assign(_valid, true) - } - } - } - - function applyPropertySchema(prop: string, keyword: string, _valid: Name): void { - cxt.subschema( - { - keyword, - schemaProp: prop, - dataProp: prop, - }, - _valid - ) - } - - function validateAdditional(): void { - gen.forIn("key", data, (key: Name) => { - const _allProps = - it.jtdDiscriminator === undefined ? allProps : [it.jtdDiscriminator].concat(allProps) - const addProp = isAdditional(key, _allProps, "properties") - const addOptProp = isAdditional(key, allOptProps, "optionalProperties") - const extra = - addProp === true ? addOptProp : addOptProp === true ? addProp : and(addProp, addOptProp) - gen.if(extra, () => { - if (it.opts.removeAdditional) { - gen.code(_`delete ${data}[${key}]`) - } else { - cxt.error( - false, - {propError: PropError.Additional, additionalProperty: key}, - {instancePath: key, parentSchema: true} - ) - if (!it.opts.allErrors) gen.break() - } - }) - }) - } - - function isAdditional(key: Name, props: string[], keyword: string): Code | true { - let additional: Code | boolean - if (props.length > 8) { - // TODO maybe an option instead of hard-coded 8? - const propsSchema = schemaRefOrVal(it, parentSchema[keyword], keyword) - additional = not(isOwnProperty(gen, propsSchema as Code, key)) - } else if (props.length) { - additional = and(...props.map((p) => _`${key} !== ${p}`)) - } else { - additional = true - } - return additional - } -} - -export default def diff --git a/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/ref.ts b/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/ref.ts deleted file mode 100644 index 0731b1f6..00000000 --- a/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/ref.ts +++ /dev/null @@ -1,74 +0,0 @@ -import type {CodeKeywordDefinition, AnySchemaObject} from "../../types" -import type {KeywordCxt} from "../../compile/validate" -import {compileSchema, SchemaEnv} from "../../compile" -import {_, not, nil, stringify} from "../../compile/codegen" -import MissingRefError from "../../compile/ref_error" -import N from "../../compile/names" -import {getValidate, callRef} from "../core/ref" -import {checkMetadata} from "./metadata" - -const def: CodeKeywordDefinition = { - keyword: "ref", - schemaType: "string", - code(cxt: KeywordCxt) { - checkMetadata(cxt) - const {gen, data, schema: ref, parentSchema, it} = cxt - const { - schemaEnv: {root}, - } = it - const valid = gen.name("valid") - if (parentSchema.nullable) { - gen.var(valid, _`${data} === null`) - gen.if(not(valid), validateJtdRef) - } else { - gen.var(valid, false) - validateJtdRef() - } - cxt.ok(valid) - - function validateJtdRef(): void { - const refSchema = (root.schema as AnySchemaObject).definitions?.[ref] - if (!refSchema) throw new MissingRefError("", ref, `No definition ${ref}`) - if (hasRef(refSchema) || !it.opts.inlineRefs) callValidate(refSchema) - else inlineRefSchema(refSchema) - } - - function callValidate(schema: AnySchemaObject): void { - const sch = compileSchema.call( - it.self, - new SchemaEnv({schema, root, schemaPath: `/definitions/${ref}`}) - ) - const v = getValidate(cxt, sch) - const errsCount = gen.const("_errs", N.errors) - callRef(cxt, v, sch, sch.$async) - gen.assign(valid, _`${errsCount} === ${N.errors}`) - } - - function inlineRefSchema(schema: AnySchemaObject): void { - const schName = gen.scopeValue( - "schema", - it.opts.code.source === true ? {ref: schema, code: stringify(schema)} : {ref: schema} - ) - cxt.subschema( - { - schema, - dataTypes: [], - schemaPath: nil, - topSchemaRef: schName, - errSchemaPath: `/definitions/${ref}`, - }, - valid - ) - } - }, -} - -export function hasRef(schema: AnySchemaObject): boolean { - for (const key in schema) { - let sch: AnySchemaObject - if (key === "ref" || (typeof (sch = schema[key]) == "object" && hasRef(sch))) return true - } - return false -} - -export default def diff --git a/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/type.ts b/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/type.ts deleted file mode 100644 index 17274300..00000000 --- a/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/type.ts +++ /dev/null @@ -1,75 +0,0 @@ -import type {CodeKeywordDefinition, KeywordErrorDefinition} from "../../types" -import type {KeywordCxt} from "../../compile/validate" -import {_, nil, or, Code} from "../../compile/codegen" -import validTimestamp from "../../runtime/timestamp" -import {useFunc} from "../../compile/util" -import {checkMetadata} from "./metadata" -import {typeErrorMessage, typeErrorParams, _JTDTypeError} from "./error" - -export type JTDTypeError = _JTDTypeError<"type", JTDType, JTDType> - -export type IntType = "int8" | "uint8" | "int16" | "uint16" | "int32" | "uint32" - -export const intRange: {[T in IntType]: [number, number, number]} = { - int8: [-128, 127, 3], - uint8: [0, 255, 3], - int16: [-32768, 32767, 5], - uint16: [0, 65535, 5], - int32: [-2147483648, 2147483647, 10], - uint32: [0, 4294967295, 10], -} - -export type JTDType = "boolean" | "string" | "timestamp" | "float32" | "float64" | IntType - -const error: KeywordErrorDefinition = { - message: (cxt) => typeErrorMessage(cxt, cxt.schema), - params: (cxt) => typeErrorParams(cxt, cxt.schema), -} - -function timestampCode(cxt: KeywordCxt): Code { - const {gen, data, it} = cxt - const {timestamp, allowDate} = it.opts - if (timestamp === "date") return _`${data} instanceof Date ` - const vts = useFunc(gen, validTimestamp) - const allowDateArg = allowDate ? _`, true` : nil - const validString = _`typeof ${data} == "string" && ${vts}(${data}${allowDateArg})` - return timestamp === "string" ? validString : or(_`${data} instanceof Date`, validString) -} - -const def: CodeKeywordDefinition = { - keyword: "type", - schemaType: "string", - error, - code(cxt: KeywordCxt) { - checkMetadata(cxt) - const {data, schema, parentSchema, it} = cxt - let cond: Code - switch (schema) { - case "boolean": - case "string": - cond = _`typeof ${data} == ${schema}` - break - case "timestamp": { - cond = timestampCode(cxt) - break - } - case "float32": - case "float64": - cond = _`typeof ${data} == "number"` - break - default: { - const sch = schema as IntType - cond = _`typeof ${data} == "number" && isFinite(${data}) && !(${data} % 1)` - if (!it.opts.int32range && (sch === "int32" || sch === "uint32")) { - if (sch === "uint32") cond = _`${cond} && ${data} >= 0` - } else { - const [min, max] = intRange[sch] - cond = _`${cond} && ${data} >= ${min} && ${data} <= ${max}` - } - } - } - cxt.pass(parentSchema.nullable ? or(_`${data} === null`, cond) : cond) - }, -} - -export default def diff --git a/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/union.ts b/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/union.ts deleted file mode 100644 index 588f07ab..00000000 --- a/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/union.ts +++ /dev/null @@ -1,12 +0,0 @@ -import type {CodeKeywordDefinition} from "../../types" -import {validateUnion} from "../code" - -const def: CodeKeywordDefinition = { - keyword: "union", - schemaType: "array", - trackErrors: true, - code: validateUnion, - error: {message: "must match a schema in union"}, -} - -export default def diff --git a/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/values.ts b/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/values.ts deleted file mode 100644 index 86091b8c..00000000 --- a/sandbox/testAppNevena/Front/node_modules/ajv/lib/vocabularies/jtd/values.ts +++ /dev/null @@ -1,55 +0,0 @@ -import type {CodeKeywordDefinition, SchemaObject} from "../../types" -import type {KeywordCxt} from "../../compile/validate" -import {alwaysValidSchema, Type} from "../../compile/util" -import {not, Name} from "../../compile/codegen" -import {checkMetadata} from "./metadata" -import {checkNullableObject} from "./nullable" -import {typeError, _JTDTypeError} from "./error" - -export type JTDValuesError = _JTDTypeError<"values", "object", SchemaObject> - -const def: CodeKeywordDefinition = { - keyword: "values", - schemaType: "object", - error: typeError("object"), - code(cxt: KeywordCxt) { - checkMetadata(cxt) - const {gen, data, schema, it} = cxt - if (alwaysValidSchema(it, schema)) return - const [valid, cond] = checkNullableObject(cxt, data) - gen.if(cond) - gen.assign(valid, validateMap()) - gen.elseIf(not(valid)) - cxt.error() - gen.endIf() - cxt.ok(valid) - - function validateMap(): Name | boolean { - const _valid = gen.name("valid") - if (it.allErrors) { - const validMap = gen.let("valid", true) - validateValues(() => gen.assign(validMap, false)) - return validMap - } - gen.var(_valid, true) - validateValues(() => gen.break()) - return _valid - - function validateValues(notValid: () => void): void { - gen.forIn("key", data, (key) => { - cxt.subschema( - { - keyword: "values", - dataProp: key, - dataPropType: Type.Str, - }, - _valid - ) - gen.if(not(_valid), notValid) - }) - } - } - }, -} - -export default def |