mirror of
https://github.com/tvytlx/ai-agent-deep-dive.git
synced 2026-04-09 18:44:48 +08:00
Add extracted source directory and README navigation
This commit is contained in:
49
extracted-source/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js
generated
vendored
Normal file
49
extracted-source/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.validateAdditionalItems = void 0;
|
||||
const codegen_1 = require("../../compile/codegen");
|
||||
const util_1 = require("../../compile/util");
|
||||
const error = {
|
||||
message: ({ params: { len } }) => (0, codegen_1.str) `must NOT have more than ${len} items`,
|
||||
params: ({ params: { len } }) => (0, codegen_1._) `{limit: ${len}}`,
|
||||
};
|
||||
const def = {
|
||||
keyword: "additionalItems",
|
||||
type: "array",
|
||||
schemaType: ["boolean", "object"],
|
||||
before: "uniqueItems",
|
||||
error,
|
||||
code(cxt) {
|
||||
const { parentSchema, it } = cxt;
|
||||
const { items } = parentSchema;
|
||||
if (!Array.isArray(items)) {
|
||||
(0, util_1.checkStrictMode)(it, '"additionalItems" is ignored when "items" is not an array of schemas');
|
||||
return;
|
||||
}
|
||||
validateAdditionalItems(cxt, items);
|
||||
},
|
||||
};
|
||||
function validateAdditionalItems(cxt, items) {
|
||||
const { gen, schema, data, keyword, it } = cxt;
|
||||
it.items = true;
|
||||
const len = gen.const("len", (0, codegen_1._) `${data}.length`);
|
||||
if (schema === false) {
|
||||
cxt.setParams({ len: items.length });
|
||||
cxt.pass((0, codegen_1._) `${len} <= ${items.length}`);
|
||||
}
|
||||
else if (typeof schema == "object" && !(0, util_1.alwaysValidSchema)(it, schema)) {
|
||||
const valid = gen.var("valid", (0, codegen_1._) `${len} <= ${items.length}`); // TODO var
|
||||
gen.if((0, codegen_1.not)(valid), () => validateItems(valid));
|
||||
cxt.ok(valid);
|
||||
}
|
||||
function validateItems(valid) {
|
||||
gen.forRange("i", items.length, len, (i) => {
|
||||
cxt.subschema({ keyword, dataProp: i, dataPropType: util_1.Type.Num }, valid);
|
||||
if (!it.allErrors)
|
||||
gen.if((0, codegen_1.not)(valid), () => gen.break());
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.validateAdditionalItems = validateAdditionalItems;
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=additionalItems.js.map
|
||||
106
extracted-source/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js
generated
vendored
Normal file
106
extracted-source/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js
generated
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const code_1 = require("../code");
|
||||
const codegen_1 = require("../../compile/codegen");
|
||||
const names_1 = require("../../compile/names");
|
||||
const util_1 = require("../../compile/util");
|
||||
const error = {
|
||||
message: "must NOT have additional properties",
|
||||
params: ({ params }) => (0, codegen_1._) `{additionalProperty: ${params.additionalProperty}}`,
|
||||
};
|
||||
const def = {
|
||||
keyword: "additionalProperties",
|
||||
type: ["object"],
|
||||
schemaType: ["boolean", "object"],
|
||||
allowUndefined: true,
|
||||
trackErrors: true,
|
||||
error,
|
||||
code(cxt) {
|
||||
const { gen, schema, parentSchema, data, errsCount, it } = cxt;
|
||||
/* istanbul ignore if */
|
||||
if (!errsCount)
|
||||
throw new Error("ajv implementation error");
|
||||
const { allErrors, opts } = it;
|
||||
it.props = true;
|
||||
if (opts.removeAdditional !== "all" && (0, util_1.alwaysValidSchema)(it, schema))
|
||||
return;
|
||||
const props = (0, code_1.allSchemaProperties)(parentSchema.properties);
|
||||
const patProps = (0, code_1.allSchemaProperties)(parentSchema.patternProperties);
|
||||
checkAdditionalProperties();
|
||||
cxt.ok((0, codegen_1._) `${errsCount} === ${names_1.default.errors}`);
|
||||
function checkAdditionalProperties() {
|
||||
gen.forIn("key", data, (key) => {
|
||||
if (!props.length && !patProps.length)
|
||||
additionalPropertyCode(key);
|
||||
else
|
||||
gen.if(isAdditional(key), () => additionalPropertyCode(key));
|
||||
});
|
||||
}
|
||||
function isAdditional(key) {
|
||||
let definedProp;
|
||||
if (props.length > 8) {
|
||||
// TODO maybe an option instead of hard-coded 8?
|
||||
const propsSchema = (0, util_1.schemaRefOrVal)(it, parentSchema.properties, "properties");
|
||||
definedProp = (0, code_1.isOwnProperty)(gen, propsSchema, key);
|
||||
}
|
||||
else if (props.length) {
|
||||
definedProp = (0, codegen_1.or)(...props.map((p) => (0, codegen_1._) `${key} === ${p}`));
|
||||
}
|
||||
else {
|
||||
definedProp = codegen_1.nil;
|
||||
}
|
||||
if (patProps.length) {
|
||||
definedProp = (0, codegen_1.or)(definedProp, ...patProps.map((p) => (0, codegen_1._) `${(0, code_1.usePattern)(cxt, p)}.test(${key})`));
|
||||
}
|
||||
return (0, codegen_1.not)(definedProp);
|
||||
}
|
||||
function deleteAdditional(key) {
|
||||
gen.code((0, codegen_1._) `delete ${data}[${key}]`);
|
||||
}
|
||||
function additionalPropertyCode(key) {
|
||||
if (opts.removeAdditional === "all" || (opts.removeAdditional && schema === false)) {
|
||||
deleteAdditional(key);
|
||||
return;
|
||||
}
|
||||
if (schema === false) {
|
||||
cxt.setParams({ additionalProperty: key });
|
||||
cxt.error();
|
||||
if (!allErrors)
|
||||
gen.break();
|
||||
return;
|
||||
}
|
||||
if (typeof schema == "object" && !(0, util_1.alwaysValidSchema)(it, schema)) {
|
||||
const valid = gen.name("valid");
|
||||
if (opts.removeAdditional === "failing") {
|
||||
applyAdditionalSchema(key, valid, false);
|
||||
gen.if((0, codegen_1.not)(valid), () => {
|
||||
cxt.reset();
|
||||
deleteAdditional(key);
|
||||
});
|
||||
}
|
||||
else {
|
||||
applyAdditionalSchema(key, valid);
|
||||
if (!allErrors)
|
||||
gen.if((0, codegen_1.not)(valid), () => gen.break());
|
||||
}
|
||||
}
|
||||
}
|
||||
function applyAdditionalSchema(key, valid, errors) {
|
||||
const subschema = {
|
||||
keyword: "additionalProperties",
|
||||
dataProp: key,
|
||||
dataPropType: util_1.Type.Str,
|
||||
};
|
||||
if (errors === false) {
|
||||
Object.assign(subschema, {
|
||||
compositeRule: true,
|
||||
createErrors: false,
|
||||
allErrors: false,
|
||||
});
|
||||
}
|
||||
cxt.subschema(subschema, valid);
|
||||
}
|
||||
},
|
||||
};
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=additionalProperties.js.map
|
||||
23
extracted-source/node_modules/ajv/dist/vocabularies/applicator/allOf.js
generated
vendored
Normal file
23
extracted-source/node_modules/ajv/dist/vocabularies/applicator/allOf.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const util_1 = require("../../compile/util");
|
||||
const def = {
|
||||
keyword: "allOf",
|
||||
schemaType: "array",
|
||||
code(cxt) {
|
||||
const { gen, schema, it } = cxt;
|
||||
/* istanbul ignore if */
|
||||
if (!Array.isArray(schema))
|
||||
throw new Error("ajv implementation error");
|
||||
const valid = gen.name("valid");
|
||||
schema.forEach((sch, i) => {
|
||||
if ((0, util_1.alwaysValidSchema)(it, sch))
|
||||
return;
|
||||
const schCxt = cxt.subschema({ keyword: "allOf", schemaProp: i }, valid);
|
||||
cxt.ok(valid);
|
||||
cxt.mergeEvaluated(schCxt);
|
||||
});
|
||||
},
|
||||
};
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=allOf.js.map
|
||||
12
extracted-source/node_modules/ajv/dist/vocabularies/applicator/anyOf.js
generated
vendored
Normal file
12
extracted-source/node_modules/ajv/dist/vocabularies/applicator/anyOf.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const code_1 = require("../code");
|
||||
const def = {
|
||||
keyword: "anyOf",
|
||||
schemaType: "array",
|
||||
trackErrors: true,
|
||||
code: code_1.validateUnion,
|
||||
error: { message: "must match a schema in anyOf" },
|
||||
};
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=anyOf.js.map
|
||||
95
extracted-source/node_modules/ajv/dist/vocabularies/applicator/contains.js
generated
vendored
Normal file
95
extracted-source/node_modules/ajv/dist/vocabularies/applicator/contains.js
generated
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const codegen_1 = require("../../compile/codegen");
|
||||
const util_1 = require("../../compile/util");
|
||||
const error = {
|
||||
message: ({ params: { min, max } }) => max === undefined
|
||||
? (0, codegen_1.str) `must contain at least ${min} valid item(s)`
|
||||
: (0, codegen_1.str) `must contain at least ${min} and no more than ${max} valid item(s)`,
|
||||
params: ({ params: { min, max } }) => max === undefined ? (0, codegen_1._) `{minContains: ${min}}` : (0, codegen_1._) `{minContains: ${min}, maxContains: ${max}}`,
|
||||
};
|
||||
const def = {
|
||||
keyword: "contains",
|
||||
type: "array",
|
||||
schemaType: ["object", "boolean"],
|
||||
before: "uniqueItems",
|
||||
trackErrors: true,
|
||||
error,
|
||||
code(cxt) {
|
||||
const { gen, schema, parentSchema, data, it } = cxt;
|
||||
let min;
|
||||
let max;
|
||||
const { minContains, maxContains } = parentSchema;
|
||||
if (it.opts.next) {
|
||||
min = minContains === undefined ? 1 : minContains;
|
||||
max = maxContains;
|
||||
}
|
||||
else {
|
||||
min = 1;
|
||||
}
|
||||
const len = gen.const("len", (0, codegen_1._) `${data}.length`);
|
||||
cxt.setParams({ min, max });
|
||||
if (max === undefined && min === 0) {
|
||||
(0, util_1.checkStrictMode)(it, `"minContains" == 0 without "maxContains": "contains" keyword ignored`);
|
||||
return;
|
||||
}
|
||||
if (max !== undefined && min > max) {
|
||||
(0, util_1.checkStrictMode)(it, `"minContains" > "maxContains" is always invalid`);
|
||||
cxt.fail();
|
||||
return;
|
||||
}
|
||||
if ((0, util_1.alwaysValidSchema)(it, schema)) {
|
||||
let cond = (0, codegen_1._) `${len} >= ${min}`;
|
||||
if (max !== undefined)
|
||||
cond = (0, codegen_1._) `${cond} && ${len} <= ${max}`;
|
||||
cxt.pass(cond);
|
||||
return;
|
||||
}
|
||||
it.items = true;
|
||||
const valid = gen.name("valid");
|
||||
if (max === undefined && min === 1) {
|
||||
validateItems(valid, () => gen.if(valid, () => gen.break()));
|
||||
}
|
||||
else if (min === 0) {
|
||||
gen.let(valid, true);
|
||||
if (max !== undefined)
|
||||
gen.if((0, codegen_1._) `${data}.length > 0`, validateItemsWithCount);
|
||||
}
|
||||
else {
|
||||
gen.let(valid, false);
|
||||
validateItemsWithCount();
|
||||
}
|
||||
cxt.result(valid, () => cxt.reset());
|
||||
function validateItemsWithCount() {
|
||||
const schValid = gen.name("_valid");
|
||||
const count = gen.let("count", 0);
|
||||
validateItems(schValid, () => gen.if(schValid, () => checkLimits(count)));
|
||||
}
|
||||
function validateItems(_valid, block) {
|
||||
gen.forRange("i", 0, len, (i) => {
|
||||
cxt.subschema({
|
||||
keyword: "contains",
|
||||
dataProp: i,
|
||||
dataPropType: util_1.Type.Num,
|
||||
compositeRule: true,
|
||||
}, _valid);
|
||||
block();
|
||||
});
|
||||
}
|
||||
function checkLimits(count) {
|
||||
gen.code((0, codegen_1._) `${count}++`);
|
||||
if (max === undefined) {
|
||||
gen.if((0, codegen_1._) `${count} >= ${min}`, () => gen.assign(valid, true).break());
|
||||
}
|
||||
else {
|
||||
gen.if((0, codegen_1._) `${count} > ${max}`, () => gen.assign(valid, false).break());
|
||||
if (min === 1)
|
||||
gen.assign(valid, true);
|
||||
else
|
||||
gen.if((0, codegen_1._) `${count} >= ${min}`, () => gen.assign(valid, true));
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=contains.js.map
|
||||
85
extracted-source/node_modules/ajv/dist/vocabularies/applicator/dependencies.js
generated
vendored
Normal file
85
extracted-source/node_modules/ajv/dist/vocabularies/applicator/dependencies.js
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.validateSchemaDeps = exports.validatePropertyDeps = exports.error = void 0;
|
||||
const codegen_1 = require("../../compile/codegen");
|
||||
const util_1 = require("../../compile/util");
|
||||
const code_1 = require("../code");
|
||||
exports.error = {
|
||||
message: ({ params: { property, depsCount, deps } }) => {
|
||||
const property_ies = depsCount === 1 ? "property" : "properties";
|
||||
return (0, codegen_1.str) `must have ${property_ies} ${deps} when property ${property} is present`;
|
||||
},
|
||||
params: ({ params: { property, depsCount, deps, missingProperty } }) => (0, codegen_1._) `{property: ${property},
|
||||
missingProperty: ${missingProperty},
|
||||
depsCount: ${depsCount},
|
||||
deps: ${deps}}`, // TODO change to reference
|
||||
};
|
||||
const def = {
|
||||
keyword: "dependencies",
|
||||
type: "object",
|
||||
schemaType: "object",
|
||||
error: exports.error,
|
||||
code(cxt) {
|
||||
const [propDeps, schDeps] = splitDependencies(cxt);
|
||||
validatePropertyDeps(cxt, propDeps);
|
||||
validateSchemaDeps(cxt, schDeps);
|
||||
},
|
||||
};
|
||||
function splitDependencies({ schema }) {
|
||||
const propertyDeps = {};
|
||||
const schemaDeps = {};
|
||||
for (const key in schema) {
|
||||
if (key === "__proto__")
|
||||
continue;
|
||||
const deps = Array.isArray(schema[key]) ? propertyDeps : schemaDeps;
|
||||
deps[key] = schema[key];
|
||||
}
|
||||
return [propertyDeps, schemaDeps];
|
||||
}
|
||||
function validatePropertyDeps(cxt, propertyDeps = cxt.schema) {
|
||||
const { gen, data, it } = cxt;
|
||||
if (Object.keys(propertyDeps).length === 0)
|
||||
return;
|
||||
const missing = gen.let("missing");
|
||||
for (const prop in propertyDeps) {
|
||||
const deps = propertyDeps[prop];
|
||||
if (deps.length === 0)
|
||||
continue;
|
||||
const hasProperty = (0, code_1.propertyInData)(gen, data, prop, it.opts.ownProperties);
|
||||
cxt.setParams({
|
||||
property: prop,
|
||||
depsCount: deps.length,
|
||||
deps: deps.join(", "),
|
||||
});
|
||||
if (it.allErrors) {
|
||||
gen.if(hasProperty, () => {
|
||||
for (const depProp of deps) {
|
||||
(0, code_1.checkReportMissingProp)(cxt, depProp);
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
gen.if((0, codegen_1._) `${hasProperty} && (${(0, code_1.checkMissingProp)(cxt, deps, missing)})`);
|
||||
(0, code_1.reportMissingProp)(cxt, missing);
|
||||
gen.else();
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.validatePropertyDeps = validatePropertyDeps;
|
||||
function validateSchemaDeps(cxt, schemaDeps = cxt.schema) {
|
||||
const { gen, data, keyword, it } = cxt;
|
||||
const valid = gen.name("valid");
|
||||
for (const prop in schemaDeps) {
|
||||
if ((0, util_1.alwaysValidSchema)(it, schemaDeps[prop]))
|
||||
continue;
|
||||
gen.if((0, code_1.propertyInData)(gen, data, prop, it.opts.ownProperties), () => {
|
||||
const schCxt = cxt.subschema({ keyword, schemaProp: prop }, valid);
|
||||
cxt.mergeValidEvaluated(schCxt, valid);
|
||||
}, () => gen.var(valid, true) // TODO var
|
||||
);
|
||||
cxt.ok(valid);
|
||||
}
|
||||
}
|
||||
exports.validateSchemaDeps = validateSchemaDeps;
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=dependencies.js.map
|
||||
66
extracted-source/node_modules/ajv/dist/vocabularies/applicator/if.js
generated
vendored
Normal file
66
extracted-source/node_modules/ajv/dist/vocabularies/applicator/if.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const codegen_1 = require("../../compile/codegen");
|
||||
const util_1 = require("../../compile/util");
|
||||
const error = {
|
||||
message: ({ params }) => (0, codegen_1.str) `must match "${params.ifClause}" schema`,
|
||||
params: ({ params }) => (0, codegen_1._) `{failingKeyword: ${params.ifClause}}`,
|
||||
};
|
||||
const def = {
|
||||
keyword: "if",
|
||||
schemaType: ["object", "boolean"],
|
||||
trackErrors: true,
|
||||
error,
|
||||
code(cxt) {
|
||||
const { gen, parentSchema, it } = cxt;
|
||||
if (parentSchema.then === undefined && parentSchema.else === undefined) {
|
||||
(0, util_1.checkStrictMode)(it, '"if" without "then" and "else" is ignored');
|
||||
}
|
||||
const hasThen = hasSchema(it, "then");
|
||||
const hasElse = hasSchema(it, "else");
|
||||
if (!hasThen && !hasElse)
|
||||
return;
|
||||
const valid = gen.let("valid", true);
|
||||
const schValid = gen.name("_valid");
|
||||
validateIf();
|
||||
cxt.reset();
|
||||
if (hasThen && hasElse) {
|
||||
const ifClause = gen.let("ifClause");
|
||||
cxt.setParams({ ifClause });
|
||||
gen.if(schValid, validateClause("then", ifClause), validateClause("else", ifClause));
|
||||
}
|
||||
else if (hasThen) {
|
||||
gen.if(schValid, validateClause("then"));
|
||||
}
|
||||
else {
|
||||
gen.if((0, codegen_1.not)(schValid), validateClause("else"));
|
||||
}
|
||||
cxt.pass(valid, () => cxt.error(true));
|
||||
function validateIf() {
|
||||
const schCxt = cxt.subschema({
|
||||
keyword: "if",
|
||||
compositeRule: true,
|
||||
createErrors: false,
|
||||
allErrors: false,
|
||||
}, schValid);
|
||||
cxt.mergeEvaluated(schCxt);
|
||||
}
|
||||
function validateClause(keyword, ifClause) {
|
||||
return () => {
|
||||
const schCxt = cxt.subschema({ keyword }, schValid);
|
||||
gen.assign(valid, schValid);
|
||||
cxt.mergeValidEvaluated(schCxt, valid);
|
||||
if (ifClause)
|
||||
gen.assign(ifClause, (0, codegen_1._) `${keyword}`);
|
||||
else
|
||||
cxt.setParams({ ifClause: keyword });
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
function hasSchema(it, keyword) {
|
||||
const schema = it.schema[keyword];
|
||||
return schema !== undefined && !(0, util_1.alwaysValidSchema)(it, schema);
|
||||
}
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=if.js.map
|
||||
44
extracted-source/node_modules/ajv/dist/vocabularies/applicator/index.js
generated
vendored
Normal file
44
extracted-source/node_modules/ajv/dist/vocabularies/applicator/index.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const additionalItems_1 = require("./additionalItems");
|
||||
const prefixItems_1 = require("./prefixItems");
|
||||
const items_1 = require("./items");
|
||||
const items2020_1 = require("./items2020");
|
||||
const contains_1 = require("./contains");
|
||||
const dependencies_1 = require("./dependencies");
|
||||
const propertyNames_1 = require("./propertyNames");
|
||||
const additionalProperties_1 = require("./additionalProperties");
|
||||
const properties_1 = require("./properties");
|
||||
const patternProperties_1 = require("./patternProperties");
|
||||
const not_1 = require("./not");
|
||||
const anyOf_1 = require("./anyOf");
|
||||
const oneOf_1 = require("./oneOf");
|
||||
const allOf_1 = require("./allOf");
|
||||
const if_1 = require("./if");
|
||||
const thenElse_1 = require("./thenElse");
|
||||
function getApplicator(draft2020 = false) {
|
||||
const applicator = [
|
||||
// any
|
||||
not_1.default,
|
||||
anyOf_1.default,
|
||||
oneOf_1.default,
|
||||
allOf_1.default,
|
||||
if_1.default,
|
||||
thenElse_1.default,
|
||||
// object
|
||||
propertyNames_1.default,
|
||||
additionalProperties_1.default,
|
||||
dependencies_1.default,
|
||||
properties_1.default,
|
||||
patternProperties_1.default,
|
||||
];
|
||||
// array
|
||||
if (draft2020)
|
||||
applicator.push(prefixItems_1.default, items2020_1.default);
|
||||
else
|
||||
applicator.push(additionalItems_1.default, items_1.default);
|
||||
applicator.push(contains_1.default);
|
||||
return applicator;
|
||||
}
|
||||
exports.default = getApplicator;
|
||||
//# sourceMappingURL=index.js.map
|
||||
52
extracted-source/node_modules/ajv/dist/vocabularies/applicator/items.js
generated
vendored
Normal file
52
extracted-source/node_modules/ajv/dist/vocabularies/applicator/items.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.validateTuple = void 0;
|
||||
const codegen_1 = require("../../compile/codegen");
|
||||
const util_1 = require("../../compile/util");
|
||||
const code_1 = require("../code");
|
||||
const def = {
|
||||
keyword: "items",
|
||||
type: "array",
|
||||
schemaType: ["object", "array", "boolean"],
|
||||
before: "uniqueItems",
|
||||
code(cxt) {
|
||||
const { schema, it } = cxt;
|
||||
if (Array.isArray(schema))
|
||||
return validateTuple(cxt, "additionalItems", schema);
|
||||
it.items = true;
|
||||
if ((0, util_1.alwaysValidSchema)(it, schema))
|
||||
return;
|
||||
cxt.ok((0, code_1.validateArray)(cxt));
|
||||
},
|
||||
};
|
||||
function validateTuple(cxt, extraItems, schArr = cxt.schema) {
|
||||
const { gen, parentSchema, data, keyword, it } = cxt;
|
||||
checkStrictTuple(parentSchema);
|
||||
if (it.opts.unevaluated && schArr.length && it.items !== true) {
|
||||
it.items = util_1.mergeEvaluated.items(gen, schArr.length, it.items);
|
||||
}
|
||||
const valid = gen.name("valid");
|
||||
const len = gen.const("len", (0, codegen_1._) `${data}.length`);
|
||||
schArr.forEach((sch, i) => {
|
||||
if ((0, util_1.alwaysValidSchema)(it, sch))
|
||||
return;
|
||||
gen.if((0, codegen_1._) `${len} > ${i}`, () => cxt.subschema({
|
||||
keyword,
|
||||
schemaProp: i,
|
||||
dataProp: i,
|
||||
}, valid));
|
||||
cxt.ok(valid);
|
||||
});
|
||||
function checkStrictTuple(sch) {
|
||||
const { opts, errSchemaPath } = it;
|
||||
const l = schArr.length;
|
||||
const fullTuple = l === sch.minItems && (l === sch.maxItems || sch[extraItems] === false);
|
||||
if (opts.strictTuples && !fullTuple) {
|
||||
const msg = `"${keyword}" is ${l}-tuple, but minItems or maxItems/${extraItems} are not specified or different at path "${errSchemaPath}"`;
|
||||
(0, util_1.checkStrictMode)(it, msg, opts.strictTuples);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.validateTuple = validateTuple;
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=items.js.map
|
||||
30
extracted-source/node_modules/ajv/dist/vocabularies/applicator/items2020.js
generated
vendored
Normal file
30
extracted-source/node_modules/ajv/dist/vocabularies/applicator/items2020.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const codegen_1 = require("../../compile/codegen");
|
||||
const util_1 = require("../../compile/util");
|
||||
const code_1 = require("../code");
|
||||
const additionalItems_1 = require("./additionalItems");
|
||||
const error = {
|
||||
message: ({ params: { len } }) => (0, codegen_1.str) `must NOT have more than ${len} items`,
|
||||
params: ({ params: { len } }) => (0, codegen_1._) `{limit: ${len}}`,
|
||||
};
|
||||
const def = {
|
||||
keyword: "items",
|
||||
type: "array",
|
||||
schemaType: ["object", "boolean"],
|
||||
before: "uniqueItems",
|
||||
error,
|
||||
code(cxt) {
|
||||
const { schema, parentSchema, it } = cxt;
|
||||
const { prefixItems } = parentSchema;
|
||||
it.items = true;
|
||||
if ((0, util_1.alwaysValidSchema)(it, schema))
|
||||
return;
|
||||
if (prefixItems)
|
||||
(0, additionalItems_1.validateAdditionalItems)(cxt, prefixItems);
|
||||
else
|
||||
cxt.ok((0, code_1.validateArray)(cxt));
|
||||
},
|
||||
};
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=items2020.js.map
|
||||
26
extracted-source/node_modules/ajv/dist/vocabularies/applicator/not.js
generated
vendored
Normal file
26
extracted-source/node_modules/ajv/dist/vocabularies/applicator/not.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const util_1 = require("../../compile/util");
|
||||
const def = {
|
||||
keyword: "not",
|
||||
schemaType: ["object", "boolean"],
|
||||
trackErrors: true,
|
||||
code(cxt) {
|
||||
const { gen, schema, it } = cxt;
|
||||
if ((0, util_1.alwaysValidSchema)(it, schema)) {
|
||||
cxt.fail();
|
||||
return;
|
||||
}
|
||||
const valid = gen.name("valid");
|
||||
cxt.subschema({
|
||||
keyword: "not",
|
||||
compositeRule: true,
|
||||
createErrors: false,
|
||||
allErrors: false,
|
||||
}, valid);
|
||||
cxt.failResult(valid, () => cxt.reset(), () => cxt.error());
|
||||
},
|
||||
error: { message: "must NOT be valid" },
|
||||
};
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=not.js.map
|
||||
60
extracted-source/node_modules/ajv/dist/vocabularies/applicator/oneOf.js
generated
vendored
Normal file
60
extracted-source/node_modules/ajv/dist/vocabularies/applicator/oneOf.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const codegen_1 = require("../../compile/codegen");
|
||||
const util_1 = require("../../compile/util");
|
||||
const error = {
|
||||
message: "must match exactly one schema in oneOf",
|
||||
params: ({ params }) => (0, codegen_1._) `{passingSchemas: ${params.passing}}`,
|
||||
};
|
||||
const def = {
|
||||
keyword: "oneOf",
|
||||
schemaType: "array",
|
||||
trackErrors: true,
|
||||
error,
|
||||
code(cxt) {
|
||||
const { gen, schema, parentSchema, it } = cxt;
|
||||
/* istanbul ignore if */
|
||||
if (!Array.isArray(schema))
|
||||
throw new Error("ajv implementation error");
|
||||
if (it.opts.discriminator && parentSchema.discriminator)
|
||||
return;
|
||||
const schArr = schema;
|
||||
const valid = gen.let("valid", false);
|
||||
const passing = gen.let("passing", null);
|
||||
const schValid = gen.name("_valid");
|
||||
cxt.setParams({ passing });
|
||||
// TODO possibly fail straight away (with warning or exception) if there are two empty always valid schemas
|
||||
gen.block(validateOneOf);
|
||||
cxt.result(valid, () => cxt.reset(), () => cxt.error(true));
|
||||
function validateOneOf() {
|
||||
schArr.forEach((sch, i) => {
|
||||
let schCxt;
|
||||
if ((0, util_1.alwaysValidSchema)(it, sch)) {
|
||||
gen.var(schValid, true);
|
||||
}
|
||||
else {
|
||||
schCxt = cxt.subschema({
|
||||
keyword: "oneOf",
|
||||
schemaProp: i,
|
||||
compositeRule: true,
|
||||
}, schValid);
|
||||
}
|
||||
if (i > 0) {
|
||||
gen
|
||||
.if((0, codegen_1._) `${schValid} && ${valid}`)
|
||||
.assign(valid, false)
|
||||
.assign(passing, (0, codegen_1._) `[${passing}, ${i}]`)
|
||||
.else();
|
||||
}
|
||||
gen.if(schValid, () => {
|
||||
gen.assign(valid, true);
|
||||
gen.assign(passing, i);
|
||||
if (schCxt)
|
||||
cxt.mergeEvaluated(schCxt, codegen_1.Name);
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=oneOf.js.map
|
||||
75
extracted-source/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js
generated
vendored
Normal file
75
extracted-source/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const code_1 = require("../code");
|
||||
const codegen_1 = require("../../compile/codegen");
|
||||
const util_1 = require("../../compile/util");
|
||||
const util_2 = require("../../compile/util");
|
||||
const def = {
|
||||
keyword: "patternProperties",
|
||||
type: "object",
|
||||
schemaType: "object",
|
||||
code(cxt) {
|
||||
const { gen, schema, data, parentSchema, it } = cxt;
|
||||
const { opts } = it;
|
||||
const patterns = (0, code_1.allSchemaProperties)(schema);
|
||||
const alwaysValidPatterns = patterns.filter((p) => (0, util_1.alwaysValidSchema)(it, schema[p]));
|
||||
if (patterns.length === 0 ||
|
||||
(alwaysValidPatterns.length === patterns.length &&
|
||||
(!it.opts.unevaluated || it.props === true))) {
|
||||
return;
|
||||
}
|
||||
const checkProperties = opts.strictSchema && !opts.allowMatchingProperties && parentSchema.properties;
|
||||
const valid = gen.name("valid");
|
||||
if (it.props !== true && !(it.props instanceof codegen_1.Name)) {
|
||||
it.props = (0, util_2.evaluatedPropsToName)(gen, it.props);
|
||||
}
|
||||
const { props } = it;
|
||||
validatePatternProperties();
|
||||
function validatePatternProperties() {
|
||||
for (const pat of patterns) {
|
||||
if (checkProperties)
|
||||
checkMatchingProperties(pat);
|
||||
if (it.allErrors) {
|
||||
validateProperties(pat);
|
||||
}
|
||||
else {
|
||||
gen.var(valid, true); // TODO var
|
||||
validateProperties(pat);
|
||||
gen.if(valid);
|
||||
}
|
||||
}
|
||||
}
|
||||
function checkMatchingProperties(pat) {
|
||||
for (const prop in checkProperties) {
|
||||
if (new RegExp(pat).test(prop)) {
|
||||
(0, util_1.checkStrictMode)(it, `property ${prop} matches pattern ${pat} (use allowMatchingProperties)`);
|
||||
}
|
||||
}
|
||||
}
|
||||
function validateProperties(pat) {
|
||||
gen.forIn("key", data, (key) => {
|
||||
gen.if((0, codegen_1._) `${(0, code_1.usePattern)(cxt, pat)}.test(${key})`, () => {
|
||||
const alwaysValid = alwaysValidPatterns.includes(pat);
|
||||
if (!alwaysValid) {
|
||||
cxt.subschema({
|
||||
keyword: "patternProperties",
|
||||
schemaProp: pat,
|
||||
dataProp: key,
|
||||
dataPropType: util_2.Type.Str,
|
||||
}, valid);
|
||||
}
|
||||
if (it.opts.unevaluated && props !== true) {
|
||||
gen.assign((0, codegen_1._) `${props}[${key}]`, true);
|
||||
}
|
||||
else if (!alwaysValid && !it.allErrors) {
|
||||
// can short-circuit if `unevaluatedProperties` is not supported (opts.next === false)
|
||||
// or if all properties were evaluated (props === true)
|
||||
gen.if((0, codegen_1.not)(valid), () => gen.break());
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=patternProperties.js.map
|
||||
12
extracted-source/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js
generated
vendored
Normal file
12
extracted-source/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const items_1 = require("./items");
|
||||
const def = {
|
||||
keyword: "prefixItems",
|
||||
type: "array",
|
||||
schemaType: ["array"],
|
||||
before: "uniqueItems",
|
||||
code: (cxt) => (0, items_1.validateTuple)(cxt, "items"),
|
||||
};
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=prefixItems.js.map
|
||||
54
extracted-source/node_modules/ajv/dist/vocabularies/applicator/properties.js
generated
vendored
Normal file
54
extracted-source/node_modules/ajv/dist/vocabularies/applicator/properties.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const validate_1 = require("../../compile/validate");
|
||||
const code_1 = require("../code");
|
||||
const util_1 = require("../../compile/util");
|
||||
const additionalProperties_1 = require("./additionalProperties");
|
||||
const def = {
|
||||
keyword: "properties",
|
||||
type: "object",
|
||||
schemaType: "object",
|
||||
code(cxt) {
|
||||
const { gen, schema, parentSchema, data, it } = cxt;
|
||||
if (it.opts.removeAdditional === "all" && parentSchema.additionalProperties === undefined) {
|
||||
additionalProperties_1.default.code(new validate_1.KeywordCxt(it, additionalProperties_1.default, "additionalProperties"));
|
||||
}
|
||||
const allProps = (0, code_1.allSchemaProperties)(schema);
|
||||
for (const prop of allProps) {
|
||||
it.definedProperties.add(prop);
|
||||
}
|
||||
if (it.opts.unevaluated && allProps.length && it.props !== true) {
|
||||
it.props = util_1.mergeEvaluated.props(gen, (0, util_1.toHash)(allProps), it.props);
|
||||
}
|
||||
const properties = allProps.filter((p) => !(0, util_1.alwaysValidSchema)(it, schema[p]));
|
||||
if (properties.length === 0)
|
||||
return;
|
||||
const valid = gen.name("valid");
|
||||
for (const prop of properties) {
|
||||
if (hasDefault(prop)) {
|
||||
applyPropertySchema(prop);
|
||||
}
|
||||
else {
|
||||
gen.if((0, code_1.propertyInData)(gen, data, prop, it.opts.ownProperties));
|
||||
applyPropertySchema(prop);
|
||||
if (!it.allErrors)
|
||||
gen.else().var(valid, true);
|
||||
gen.endIf();
|
||||
}
|
||||
cxt.it.definedProperties.add(prop);
|
||||
cxt.ok(valid);
|
||||
}
|
||||
function hasDefault(prop) {
|
||||
return it.opts.useDefaults && !it.compositeRule && schema[prop].default !== undefined;
|
||||
}
|
||||
function applyPropertySchema(prop) {
|
||||
cxt.subschema({
|
||||
keyword: "properties",
|
||||
schemaProp: prop,
|
||||
dataProp: prop,
|
||||
}, valid);
|
||||
}
|
||||
},
|
||||
};
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=properties.js.map
|
||||
38
extracted-source/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js
generated
vendored
Normal file
38
extracted-source/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const codegen_1 = require("../../compile/codegen");
|
||||
const util_1 = require("../../compile/util");
|
||||
const error = {
|
||||
message: "property name must be valid",
|
||||
params: ({ params }) => (0, codegen_1._) `{propertyName: ${params.propertyName}}`,
|
||||
};
|
||||
const def = {
|
||||
keyword: "propertyNames",
|
||||
type: "object",
|
||||
schemaType: ["object", "boolean"],
|
||||
error,
|
||||
code(cxt) {
|
||||
const { gen, schema, data, it } = cxt;
|
||||
if ((0, util_1.alwaysValidSchema)(it, schema))
|
||||
return;
|
||||
const valid = gen.name("valid");
|
||||
gen.forIn("key", data, (key) => {
|
||||
cxt.setParams({ propertyName: key });
|
||||
cxt.subschema({
|
||||
keyword: "propertyNames",
|
||||
data: key,
|
||||
dataTypes: ["string"],
|
||||
propertyName: key,
|
||||
compositeRule: true,
|
||||
}, valid);
|
||||
gen.if((0, codegen_1.not)(valid), () => {
|
||||
cxt.error(true);
|
||||
if (!it.allErrors)
|
||||
gen.break();
|
||||
});
|
||||
});
|
||||
cxt.ok(valid);
|
||||
},
|
||||
};
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=propertyNames.js.map
|
||||
13
extracted-source/node_modules/ajv/dist/vocabularies/applicator/thenElse.js
generated
vendored
Normal file
13
extracted-source/node_modules/ajv/dist/vocabularies/applicator/thenElse.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const util_1 = require("../../compile/util");
|
||||
const def = {
|
||||
keyword: ["then", "else"],
|
||||
schemaType: ["object", "boolean"],
|
||||
code({ keyword, parentSchema, it }) {
|
||||
if (parentSchema.if === undefined)
|
||||
(0, util_1.checkStrictMode)(it, `"${keyword}" without "if" is ignored`);
|
||||
},
|
||||
};
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=thenElse.js.map
|
||||
131
extracted-source/node_modules/ajv/dist/vocabularies/code.js
generated
vendored
Normal file
131
extracted-source/node_modules/ajv/dist/vocabularies/code.js
generated
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.validateUnion = exports.validateArray = exports.usePattern = exports.callValidateCode = exports.schemaProperties = exports.allSchemaProperties = exports.noPropertyInData = exports.propertyInData = exports.isOwnProperty = exports.hasPropFunc = exports.reportMissingProp = exports.checkMissingProp = exports.checkReportMissingProp = void 0;
|
||||
const codegen_1 = require("../compile/codegen");
|
||||
const util_1 = require("../compile/util");
|
||||
const names_1 = require("../compile/names");
|
||||
const util_2 = require("../compile/util");
|
||||
function checkReportMissingProp(cxt, prop) {
|
||||
const { gen, data, it } = cxt;
|
||||
gen.if(noPropertyInData(gen, data, prop, it.opts.ownProperties), () => {
|
||||
cxt.setParams({ missingProperty: (0, codegen_1._) `${prop}` }, true);
|
||||
cxt.error();
|
||||
});
|
||||
}
|
||||
exports.checkReportMissingProp = checkReportMissingProp;
|
||||
function checkMissingProp({ gen, data, it: { opts } }, properties, missing) {
|
||||
return (0, codegen_1.or)(...properties.map((prop) => (0, codegen_1.and)(noPropertyInData(gen, data, prop, opts.ownProperties), (0, codegen_1._) `${missing} = ${prop}`)));
|
||||
}
|
||||
exports.checkMissingProp = checkMissingProp;
|
||||
function reportMissingProp(cxt, missing) {
|
||||
cxt.setParams({ missingProperty: missing }, true);
|
||||
cxt.error();
|
||||
}
|
||||
exports.reportMissingProp = reportMissingProp;
|
||||
function hasPropFunc(gen) {
|
||||
return gen.scopeValue("func", {
|
||||
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||
ref: Object.prototype.hasOwnProperty,
|
||||
code: (0, codegen_1._) `Object.prototype.hasOwnProperty`,
|
||||
});
|
||||
}
|
||||
exports.hasPropFunc = hasPropFunc;
|
||||
function isOwnProperty(gen, data, property) {
|
||||
return (0, codegen_1._) `${hasPropFunc(gen)}.call(${data}, ${property})`;
|
||||
}
|
||||
exports.isOwnProperty = isOwnProperty;
|
||||
function propertyInData(gen, data, property, ownProperties) {
|
||||
const cond = (0, codegen_1._) `${data}${(0, codegen_1.getProperty)(property)} !== undefined`;
|
||||
return ownProperties ? (0, codegen_1._) `${cond} && ${isOwnProperty(gen, data, property)}` : cond;
|
||||
}
|
||||
exports.propertyInData = propertyInData;
|
||||
function noPropertyInData(gen, data, property, ownProperties) {
|
||||
const cond = (0, codegen_1._) `${data}${(0, codegen_1.getProperty)(property)} === undefined`;
|
||||
return ownProperties ? (0, codegen_1.or)(cond, (0, codegen_1.not)(isOwnProperty(gen, data, property))) : cond;
|
||||
}
|
||||
exports.noPropertyInData = noPropertyInData;
|
||||
function allSchemaProperties(schemaMap) {
|
||||
return schemaMap ? Object.keys(schemaMap).filter((p) => p !== "__proto__") : [];
|
||||
}
|
||||
exports.allSchemaProperties = allSchemaProperties;
|
||||
function schemaProperties(it, schemaMap) {
|
||||
return allSchemaProperties(schemaMap).filter((p) => !(0, util_1.alwaysValidSchema)(it, schemaMap[p]));
|
||||
}
|
||||
exports.schemaProperties = schemaProperties;
|
||||
function callValidateCode({ schemaCode, data, it: { gen, topSchemaRef, schemaPath, errorPath }, it }, func, context, passSchema) {
|
||||
const dataAndSchema = passSchema ? (0, codegen_1._) `${schemaCode}, ${data}, ${topSchemaRef}${schemaPath}` : data;
|
||||
const valCxt = [
|
||||
[names_1.default.instancePath, (0, codegen_1.strConcat)(names_1.default.instancePath, errorPath)],
|
||||
[names_1.default.parentData, it.parentData],
|
||||
[names_1.default.parentDataProperty, it.parentDataProperty],
|
||||
[names_1.default.rootData, names_1.default.rootData],
|
||||
];
|
||||
if (it.opts.dynamicRef)
|
||||
valCxt.push([names_1.default.dynamicAnchors, names_1.default.dynamicAnchors]);
|
||||
const args = (0, codegen_1._) `${dataAndSchema}, ${gen.object(...valCxt)}`;
|
||||
return context !== codegen_1.nil ? (0, codegen_1._) `${func}.call(${context}, ${args})` : (0, codegen_1._) `${func}(${args})`;
|
||||
}
|
||||
exports.callValidateCode = callValidateCode;
|
||||
const newRegExp = (0, codegen_1._) `new RegExp`;
|
||||
function usePattern({ gen, it: { opts } }, pattern) {
|
||||
const u = opts.unicodeRegExp ? "u" : "";
|
||||
const { regExp } = opts.code;
|
||||
const rx = regExp(pattern, u);
|
||||
return gen.scopeValue("pattern", {
|
||||
key: rx.toString(),
|
||||
ref: rx,
|
||||
code: (0, codegen_1._) `${regExp.code === "new RegExp" ? newRegExp : (0, util_2.useFunc)(gen, regExp)}(${pattern}, ${u})`,
|
||||
});
|
||||
}
|
||||
exports.usePattern = usePattern;
|
||||
function validateArray(cxt) {
|
||||
const { gen, data, keyword, it } = cxt;
|
||||
const valid = gen.name("valid");
|
||||
if (it.allErrors) {
|
||||
const validArr = gen.let("valid", true);
|
||||
validateItems(() => gen.assign(validArr, false));
|
||||
return validArr;
|
||||
}
|
||||
gen.var(valid, true);
|
||||
validateItems(() => gen.break());
|
||||
return valid;
|
||||
function validateItems(notValid) {
|
||||
const len = gen.const("len", (0, codegen_1._) `${data}.length`);
|
||||
gen.forRange("i", 0, len, (i) => {
|
||||
cxt.subschema({
|
||||
keyword,
|
||||
dataProp: i,
|
||||
dataPropType: util_1.Type.Num,
|
||||
}, valid);
|
||||
gen.if((0, codegen_1.not)(valid), notValid);
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.validateArray = validateArray;
|
||||
function validateUnion(cxt) {
|
||||
const { gen, schema, keyword, it } = cxt;
|
||||
/* istanbul ignore if */
|
||||
if (!Array.isArray(schema))
|
||||
throw new Error("ajv implementation error");
|
||||
const alwaysValid = schema.some((sch) => (0, util_1.alwaysValidSchema)(it, sch));
|
||||
if (alwaysValid && !it.opts.unevaluated)
|
||||
return;
|
||||
const valid = gen.let("valid", false);
|
||||
const schValid = gen.name("_valid");
|
||||
gen.block(() => schema.forEach((_sch, i) => {
|
||||
const schCxt = cxt.subschema({
|
||||
keyword,
|
||||
schemaProp: i,
|
||||
compositeRule: true,
|
||||
}, schValid);
|
||||
gen.assign(valid, (0, codegen_1._) `${valid} || ${schValid}`);
|
||||
const merged = cxt.mergeValidEvaluated(schCxt, schValid);
|
||||
// can short-circuit if `unevaluatedProperties/Items` not supported (opts.unevaluated !== true)
|
||||
// or if all properties and items were evaluated (it.props === true && it.items === true)
|
||||
if (!merged)
|
||||
gen.if((0, codegen_1.not)(valid));
|
||||
}));
|
||||
cxt.result(valid, () => cxt.reset(), () => cxt.error(true));
|
||||
}
|
||||
exports.validateUnion = validateUnion;
|
||||
//# sourceMappingURL=code.js.map
|
||||
10
extracted-source/node_modules/ajv/dist/vocabularies/core/id.js
generated
vendored
Normal file
10
extracted-source/node_modules/ajv/dist/vocabularies/core/id.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const def = {
|
||||
keyword: "id",
|
||||
code() {
|
||||
throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID');
|
||||
},
|
||||
};
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=id.js.map
|
||||
16
extracted-source/node_modules/ajv/dist/vocabularies/core/index.js
generated
vendored
Normal file
16
extracted-source/node_modules/ajv/dist/vocabularies/core/index.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const id_1 = require("./id");
|
||||
const ref_1 = require("./ref");
|
||||
const core = [
|
||||
"$schema",
|
||||
"$id",
|
||||
"$defs",
|
||||
"$vocabulary",
|
||||
{ keyword: "$comment" },
|
||||
"definitions",
|
||||
id_1.default,
|
||||
ref_1.default,
|
||||
];
|
||||
exports.default = core;
|
||||
//# sourceMappingURL=index.js.map
|
||||
122
extracted-source/node_modules/ajv/dist/vocabularies/core/ref.js
generated
vendored
Normal file
122
extracted-source/node_modules/ajv/dist/vocabularies/core/ref.js
generated
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.callRef = exports.getValidate = void 0;
|
||||
const ref_error_1 = require("../../compile/ref_error");
|
||||
const code_1 = require("../code");
|
||||
const codegen_1 = require("../../compile/codegen");
|
||||
const names_1 = require("../../compile/names");
|
||||
const compile_1 = require("../../compile");
|
||||
const util_1 = require("../../compile/util");
|
||||
const def = {
|
||||
keyword: "$ref",
|
||||
schemaType: "string",
|
||||
code(cxt) {
|
||||
const { gen, schema: $ref, it } = cxt;
|
||||
const { baseId, schemaEnv: env, validateName, opts, self } = it;
|
||||
const { root } = env;
|
||||
if (($ref === "#" || $ref === "#/") && baseId === root.baseId)
|
||||
return callRootRef();
|
||||
const schOrEnv = compile_1.resolveRef.call(self, root, baseId, $ref);
|
||||
if (schOrEnv === undefined)
|
||||
throw new ref_error_1.default(it.opts.uriResolver, baseId, $ref);
|
||||
if (schOrEnv instanceof compile_1.SchemaEnv)
|
||||
return callValidate(schOrEnv);
|
||||
return inlineRefSchema(schOrEnv);
|
||||
function callRootRef() {
|
||||
if (env === root)
|
||||
return callRef(cxt, validateName, env, env.$async);
|
||||
const rootName = gen.scopeValue("root", { ref: root });
|
||||
return callRef(cxt, (0, codegen_1._) `${rootName}.validate`, root, root.$async);
|
||||
}
|
||||
function callValidate(sch) {
|
||||
const v = getValidate(cxt, sch);
|
||||
callRef(cxt, v, sch, sch.$async);
|
||||
}
|
||||
function inlineRefSchema(sch) {
|
||||
const schName = gen.scopeValue("schema", opts.code.source === true ? { ref: sch, code: (0, codegen_1.stringify)(sch) } : { ref: sch });
|
||||
const valid = gen.name("valid");
|
||||
const schCxt = cxt.subschema({
|
||||
schema: sch,
|
||||
dataTypes: [],
|
||||
schemaPath: codegen_1.nil,
|
||||
topSchemaRef: schName,
|
||||
errSchemaPath: $ref,
|
||||
}, valid);
|
||||
cxt.mergeEvaluated(schCxt);
|
||||
cxt.ok(valid);
|
||||
}
|
||||
},
|
||||
};
|
||||
function getValidate(cxt, sch) {
|
||||
const { gen } = cxt;
|
||||
return sch.validate
|
||||
? gen.scopeValue("validate", { ref: sch.validate })
|
||||
: (0, codegen_1._) `${gen.scopeValue("wrapper", { ref: sch })}.validate`;
|
||||
}
|
||||
exports.getValidate = getValidate;
|
||||
function callRef(cxt, v, sch, $async) {
|
||||
const { gen, it } = cxt;
|
||||
const { allErrors, schemaEnv: env, opts } = it;
|
||||
const passCxt = opts.passContext ? names_1.default.this : codegen_1.nil;
|
||||
if ($async)
|
||||
callAsyncRef();
|
||||
else
|
||||
callSyncRef();
|
||||
function callAsyncRef() {
|
||||
if (!env.$async)
|
||||
throw new Error("async schema referenced by sync schema");
|
||||
const valid = gen.let("valid");
|
||||
gen.try(() => {
|
||||
gen.code((0, codegen_1._) `await ${(0, code_1.callValidateCode)(cxt, v, passCxt)}`);
|
||||
addEvaluatedFrom(v); // TODO will not work with async, it has to be returned with the result
|
||||
if (!allErrors)
|
||||
gen.assign(valid, true);
|
||||
}, (e) => {
|
||||
gen.if((0, codegen_1._) `!(${e} instanceof ${it.ValidationError})`, () => gen.throw(e));
|
||||
addErrorsFrom(e);
|
||||
if (!allErrors)
|
||||
gen.assign(valid, false);
|
||||
});
|
||||
cxt.ok(valid);
|
||||
}
|
||||
function callSyncRef() {
|
||||
cxt.result((0, code_1.callValidateCode)(cxt, v, passCxt), () => addEvaluatedFrom(v), () => addErrorsFrom(v));
|
||||
}
|
||||
function addErrorsFrom(source) {
|
||||
const errs = (0, codegen_1._) `${source}.errors`;
|
||||
gen.assign(names_1.default.vErrors, (0, codegen_1._) `${names_1.default.vErrors} === null ? ${errs} : ${names_1.default.vErrors}.concat(${errs})`); // TODO tagged
|
||||
gen.assign(names_1.default.errors, (0, codegen_1._) `${names_1.default.vErrors}.length`);
|
||||
}
|
||||
function addEvaluatedFrom(source) {
|
||||
var _a;
|
||||
if (!it.opts.unevaluated)
|
||||
return;
|
||||
const schEvaluated = (_a = sch === null || sch === void 0 ? void 0 : sch.validate) === null || _a === void 0 ? void 0 : _a.evaluated;
|
||||
// TODO refactor
|
||||
if (it.props !== true) {
|
||||
if (schEvaluated && !schEvaluated.dynamicProps) {
|
||||
if (schEvaluated.props !== undefined) {
|
||||
it.props = util_1.mergeEvaluated.props(gen, schEvaluated.props, it.props);
|
||||
}
|
||||
}
|
||||
else {
|
||||
const props = gen.var("props", (0, codegen_1._) `${source}.evaluated.props`);
|
||||
it.props = util_1.mergeEvaluated.props(gen, props, it.props, codegen_1.Name);
|
||||
}
|
||||
}
|
||||
if (it.items !== true) {
|
||||
if (schEvaluated && !schEvaluated.dynamicItems) {
|
||||
if (schEvaluated.items !== undefined) {
|
||||
it.items = util_1.mergeEvaluated.items(gen, schEvaluated.items, it.items);
|
||||
}
|
||||
}
|
||||
else {
|
||||
const items = gen.var("items", (0, codegen_1._) `${source}.evaluated.items`);
|
||||
it.items = util_1.mergeEvaluated.items(gen, items, it.items, codegen_1.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.callRef = callRef;
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=ref.js.map
|
||||
104
extracted-source/node_modules/ajv/dist/vocabularies/discriminator/index.js
generated
vendored
Normal file
104
extracted-source/node_modules/ajv/dist/vocabularies/discriminator/index.js
generated
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const codegen_1 = require("../../compile/codegen");
|
||||
const types_1 = require("../discriminator/types");
|
||||
const compile_1 = require("../../compile");
|
||||
const ref_error_1 = require("../../compile/ref_error");
|
||||
const util_1 = require("../../compile/util");
|
||||
const error = {
|
||||
message: ({ params: { discrError, tagName } }) => discrError === types_1.DiscrError.Tag
|
||||
? `tag "${tagName}" must be string`
|
||||
: `value of tag "${tagName}" must be in oneOf`,
|
||||
params: ({ params: { discrError, tag, tagName } }) => (0, codegen_1._) `{error: ${discrError}, tag: ${tagName}, tagValue: ${tag}}`,
|
||||
};
|
||||
const def = {
|
||||
keyword: "discriminator",
|
||||
type: "object",
|
||||
schemaType: "object",
|
||||
error,
|
||||
code(cxt) {
|
||||
const { gen, data, schema, parentSchema, it } = cxt;
|
||||
const { oneOf } = parentSchema;
|
||||
if (!it.opts.discriminator) {
|
||||
throw new Error("discriminator: requires discriminator option");
|
||||
}
|
||||
const tagName = schema.propertyName;
|
||||
if (typeof tagName != "string")
|
||||
throw new Error("discriminator: requires propertyName");
|
||||
if (schema.mapping)
|
||||
throw new Error("discriminator: mapping is not supported");
|
||||
if (!oneOf)
|
||||
throw new Error("discriminator: requires oneOf keyword");
|
||||
const valid = gen.let("valid", false);
|
||||
const tag = gen.const("tag", (0, codegen_1._) `${data}${(0, codegen_1.getProperty)(tagName)}`);
|
||||
gen.if((0, codegen_1._) `typeof ${tag} == "string"`, () => validateMapping(), () => cxt.error(false, { discrError: types_1.DiscrError.Tag, tag, tagName }));
|
||||
cxt.ok(valid);
|
||||
function validateMapping() {
|
||||
const mapping = getMapping();
|
||||
gen.if(false);
|
||||
for (const tagValue in mapping) {
|
||||
gen.elseIf((0, codegen_1._) `${tag} === ${tagValue}`);
|
||||
gen.assign(valid, applyTagSchema(mapping[tagValue]));
|
||||
}
|
||||
gen.else();
|
||||
cxt.error(false, { discrError: types_1.DiscrError.Mapping, tag, tagName });
|
||||
gen.endIf();
|
||||
}
|
||||
function applyTagSchema(schemaProp) {
|
||||
const _valid = gen.name("valid");
|
||||
const schCxt = cxt.subschema({ keyword: "oneOf", schemaProp }, _valid);
|
||||
cxt.mergeEvaluated(schCxt, codegen_1.Name);
|
||||
return _valid;
|
||||
}
|
||||
function getMapping() {
|
||||
var _a;
|
||||
const oneOfMapping = {};
|
||||
const topRequired = hasRequired(parentSchema);
|
||||
let tagRequired = true;
|
||||
for (let i = 0; i < oneOf.length; i++) {
|
||||
let sch = oneOf[i];
|
||||
if ((sch === null || sch === void 0 ? void 0 : sch.$ref) && !(0, util_1.schemaHasRulesButRef)(sch, it.self.RULES)) {
|
||||
const ref = sch.$ref;
|
||||
sch = compile_1.resolveRef.call(it.self, it.schemaEnv.root, it.baseId, ref);
|
||||
if (sch instanceof compile_1.SchemaEnv)
|
||||
sch = sch.schema;
|
||||
if (sch === undefined)
|
||||
throw new ref_error_1.default(it.opts.uriResolver, it.baseId, ref);
|
||||
}
|
||||
const propSch = (_a = sch === null || sch === void 0 ? void 0 : sch.properties) === null || _a === void 0 ? void 0 : _a[tagName];
|
||||
if (typeof propSch != "object") {
|
||||
throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${tagName}"`);
|
||||
}
|
||||
tagRequired = tagRequired && (topRequired || hasRequired(sch));
|
||||
addMappings(propSch, i);
|
||||
}
|
||||
if (!tagRequired)
|
||||
throw new Error(`discriminator: "${tagName}" must be required`);
|
||||
return oneOfMapping;
|
||||
function hasRequired({ required }) {
|
||||
return Array.isArray(required) && required.includes(tagName);
|
||||
}
|
||||
function addMappings(sch, i) {
|
||||
if (sch.const) {
|
||||
addMapping(sch.const, i);
|
||||
}
|
||||
else if (sch.enum) {
|
||||
for (const tagValue of sch.enum) {
|
||||
addMapping(tagValue, i);
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new Error(`discriminator: "properties/${tagName}" must have "const" or "enum"`);
|
||||
}
|
||||
}
|
||||
function addMapping(tagValue, i) {
|
||||
if (typeof tagValue != "string" || tagValue in oneOfMapping) {
|
||||
throw new Error(`discriminator: "${tagName}" values must be unique strings`);
|
||||
}
|
||||
oneOfMapping[tagValue] = i;
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=index.js.map
|
||||
9
extracted-source/node_modules/ajv/dist/vocabularies/discriminator/types.js
generated
vendored
Normal file
9
extracted-source/node_modules/ajv/dist/vocabularies/discriminator/types.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DiscrError = void 0;
|
||||
var DiscrError;
|
||||
(function (DiscrError) {
|
||||
DiscrError["Tag"] = "tag";
|
||||
DiscrError["Mapping"] = "mapping";
|
||||
})(DiscrError || (exports.DiscrError = DiscrError = {}));
|
||||
//# sourceMappingURL=types.js.map
|
||||
17
extracted-source/node_modules/ajv/dist/vocabularies/draft7.js
generated
vendored
Normal file
17
extracted-source/node_modules/ajv/dist/vocabularies/draft7.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core_1 = require("./core");
|
||||
const validation_1 = require("./validation");
|
||||
const applicator_1 = require("./applicator");
|
||||
const format_1 = require("./format");
|
||||
const metadata_1 = require("./metadata");
|
||||
const draft7Vocabularies = [
|
||||
core_1.default,
|
||||
validation_1.default,
|
||||
(0, applicator_1.default)(),
|
||||
format_1.default,
|
||||
metadata_1.metadataVocabulary,
|
||||
metadata_1.contentVocabulary,
|
||||
];
|
||||
exports.default = draft7Vocabularies;
|
||||
//# sourceMappingURL=draft7.js.map
|
||||
92
extracted-source/node_modules/ajv/dist/vocabularies/format/format.js
generated
vendored
Normal file
92
extracted-source/node_modules/ajv/dist/vocabularies/format/format.js
generated
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const codegen_1 = require("../../compile/codegen");
|
||||
const error = {
|
||||
message: ({ schemaCode }) => (0, codegen_1.str) `must match format "${schemaCode}"`,
|
||||
params: ({ schemaCode }) => (0, codegen_1._) `{format: ${schemaCode}}`,
|
||||
};
|
||||
const def = {
|
||||
keyword: "format",
|
||||
type: ["number", "string"],
|
||||
schemaType: "string",
|
||||
$data: true,
|
||||
error,
|
||||
code(cxt, ruleType) {
|
||||
const { gen, data, $data, schema, schemaCode, it } = cxt;
|
||||
const { opts, errSchemaPath, schemaEnv, self } = it;
|
||||
if (!opts.validateFormats)
|
||||
return;
|
||||
if ($data)
|
||||
validate$DataFormat();
|
||||
else
|
||||
validateFormat();
|
||||
function validate$DataFormat() {
|
||||
const fmts = gen.scopeValue("formats", {
|
||||
ref: self.formats,
|
||||
code: opts.code.formats,
|
||||
});
|
||||
const fDef = gen.const("fDef", (0, codegen_1._) `${fmts}[${schemaCode}]`);
|
||||
const fType = gen.let("fType");
|
||||
const format = gen.let("format");
|
||||
// TODO simplify
|
||||
gen.if((0, codegen_1._) `typeof ${fDef} == "object" && !(${fDef} instanceof RegExp)`, () => gen.assign(fType, (0, codegen_1._) `${fDef}.type || "string"`).assign(format, (0, codegen_1._) `${fDef}.validate`), () => gen.assign(fType, (0, codegen_1._) `"string"`).assign(format, fDef));
|
||||
cxt.fail$data((0, codegen_1.or)(unknownFmt(), invalidFmt()));
|
||||
function unknownFmt() {
|
||||
if (opts.strictSchema === false)
|
||||
return codegen_1.nil;
|
||||
return (0, codegen_1._) `${schemaCode} && !${format}`;
|
||||
}
|
||||
function invalidFmt() {
|
||||
const callFormat = schemaEnv.$async
|
||||
? (0, codegen_1._) `(${fDef}.async ? await ${format}(${data}) : ${format}(${data}))`
|
||||
: (0, codegen_1._) `${format}(${data})`;
|
||||
const validData = (0, codegen_1._) `(typeof ${format} == "function" ? ${callFormat} : ${format}.test(${data}))`;
|
||||
return (0, codegen_1._) `${format} && ${format} !== true && ${fType} === ${ruleType} && !${validData}`;
|
||||
}
|
||||
}
|
||||
function validateFormat() {
|
||||
const formatDef = self.formats[schema];
|
||||
if (!formatDef) {
|
||||
unknownFormat();
|
||||
return;
|
||||
}
|
||||
if (formatDef === true)
|
||||
return;
|
||||
const [fmtType, format, fmtRef] = getFormat(formatDef);
|
||||
if (fmtType === ruleType)
|
||||
cxt.pass(validCondition());
|
||||
function unknownFormat() {
|
||||
if (opts.strictSchema === false) {
|
||||
self.logger.warn(unknownMsg());
|
||||
return;
|
||||
}
|
||||
throw new Error(unknownMsg());
|
||||
function unknownMsg() {
|
||||
return `unknown format "${schema}" ignored in schema at path "${errSchemaPath}"`;
|
||||
}
|
||||
}
|
||||
function getFormat(fmtDef) {
|
||||
const code = fmtDef instanceof RegExp
|
||||
? (0, codegen_1.regexpCode)(fmtDef)
|
||||
: opts.code.formats
|
||||
? (0, codegen_1._) `${opts.code.formats}${(0, codegen_1.getProperty)(schema)}`
|
||||
: undefined;
|
||||
const fmt = gen.scopeValue("formats", { key: schema, ref: fmtDef, code });
|
||||
if (typeof fmtDef == "object" && !(fmtDef instanceof RegExp)) {
|
||||
return [fmtDef.type || "string", fmtDef.validate, (0, codegen_1._) `${fmt}.validate`];
|
||||
}
|
||||
return ["string", fmtDef, fmt];
|
||||
}
|
||||
function validCondition() {
|
||||
if (typeof formatDef == "object" && !(formatDef instanceof RegExp) && formatDef.async) {
|
||||
if (!schemaEnv.$async)
|
||||
throw new Error("async format in sync schema");
|
||||
return (0, codegen_1._) `await ${fmtRef}(${data})`;
|
||||
}
|
||||
return typeof format == "function" ? (0, codegen_1._) `${fmtRef}(${data})` : (0, codegen_1._) `${fmtRef}.test(${data})`;
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=format.js.map
|
||||
6
extracted-source/node_modules/ajv/dist/vocabularies/format/index.js
generated
vendored
Normal file
6
extracted-source/node_modules/ajv/dist/vocabularies/format/index.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const format_1 = require("./format");
|
||||
const format = [format_1.default];
|
||||
exports.default = format;
|
||||
//# sourceMappingURL=index.js.map
|
||||
18
extracted-source/node_modules/ajv/dist/vocabularies/metadata.js
generated
vendored
Normal file
18
extracted-source/node_modules/ajv/dist/vocabularies/metadata.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.contentVocabulary = exports.metadataVocabulary = void 0;
|
||||
exports.metadataVocabulary = [
|
||||
"title",
|
||||
"description",
|
||||
"default",
|
||||
"deprecated",
|
||||
"readOnly",
|
||||
"writeOnly",
|
||||
"examples",
|
||||
];
|
||||
exports.contentVocabulary = [
|
||||
"contentMediaType",
|
||||
"contentEncoding",
|
||||
"contentSchema",
|
||||
];
|
||||
//# sourceMappingURL=metadata.js.map
|
||||
25
extracted-source/node_modules/ajv/dist/vocabularies/validation/const.js
generated
vendored
Normal file
25
extracted-source/node_modules/ajv/dist/vocabularies/validation/const.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const codegen_1 = require("../../compile/codegen");
|
||||
const util_1 = require("../../compile/util");
|
||||
const equal_1 = require("../../runtime/equal");
|
||||
const error = {
|
||||
message: "must be equal to constant",
|
||||
params: ({ schemaCode }) => (0, codegen_1._) `{allowedValue: ${schemaCode}}`,
|
||||
};
|
||||
const def = {
|
||||
keyword: "const",
|
||||
$data: true,
|
||||
error,
|
||||
code(cxt) {
|
||||
const { gen, data, $data, schemaCode, schema } = cxt;
|
||||
if ($data || (schema && typeof schema == "object")) {
|
||||
cxt.fail$data((0, codegen_1._) `!${(0, util_1.useFunc)(gen, equal_1.default)}(${data}, ${schemaCode})`);
|
||||
}
|
||||
else {
|
||||
cxt.fail((0, codegen_1._) `${schema} !== ${data}`);
|
||||
}
|
||||
},
|
||||
};
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=const.js.map
|
||||
48
extracted-source/node_modules/ajv/dist/vocabularies/validation/enum.js
generated
vendored
Normal file
48
extracted-source/node_modules/ajv/dist/vocabularies/validation/enum.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const codegen_1 = require("../../compile/codegen");
|
||||
const util_1 = require("../../compile/util");
|
||||
const equal_1 = require("../../runtime/equal");
|
||||
const error = {
|
||||
message: "must be equal to one of the allowed values",
|
||||
params: ({ schemaCode }) => (0, codegen_1._) `{allowedValues: ${schemaCode}}`,
|
||||
};
|
||||
const def = {
|
||||
keyword: "enum",
|
||||
schemaType: "array",
|
||||
$data: true,
|
||||
error,
|
||||
code(cxt) {
|
||||
const { gen, data, $data, schema, schemaCode, it } = cxt;
|
||||
if (!$data && schema.length === 0)
|
||||
throw new Error("enum must have non-empty array");
|
||||
const useLoop = schema.length >= it.opts.loopEnum;
|
||||
let eql;
|
||||
const getEql = () => (eql !== null && eql !== void 0 ? eql : (eql = (0, util_1.useFunc)(gen, equal_1.default)));
|
||||
let valid;
|
||||
if (useLoop || $data) {
|
||||
valid = gen.let("valid");
|
||||
cxt.block$data(valid, loopEnum);
|
||||
}
|
||||
else {
|
||||
/* istanbul ignore if */
|
||||
if (!Array.isArray(schema))
|
||||
throw new Error("ajv implementation error");
|
||||
const vSchema = gen.const("vSchema", schemaCode);
|
||||
valid = (0, codegen_1.or)(...schema.map((_x, i) => equalCode(vSchema, i)));
|
||||
}
|
||||
cxt.pass(valid);
|
||||
function loopEnum() {
|
||||
gen.assign(valid, false);
|
||||
gen.forOf("v", schemaCode, (v) => gen.if((0, codegen_1._) `${getEql()}(${data}, ${v})`, () => gen.assign(valid, true).break()));
|
||||
}
|
||||
function equalCode(vSchema, i) {
|
||||
const sch = schema[i];
|
||||
return typeof sch === "object" && sch !== null
|
||||
? (0, codegen_1._) `${getEql()}(${data}, ${vSchema}[${i}])`
|
||||
: (0, codegen_1._) `${data} === ${sch}`;
|
||||
}
|
||||
},
|
||||
};
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=enum.js.map
|
||||
33
extracted-source/node_modules/ajv/dist/vocabularies/validation/index.js
generated
vendored
Normal file
33
extracted-source/node_modules/ajv/dist/vocabularies/validation/index.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const limitNumber_1 = require("./limitNumber");
|
||||
const multipleOf_1 = require("./multipleOf");
|
||||
const limitLength_1 = require("./limitLength");
|
||||
const pattern_1 = require("./pattern");
|
||||
const limitProperties_1 = require("./limitProperties");
|
||||
const required_1 = require("./required");
|
||||
const limitItems_1 = require("./limitItems");
|
||||
const uniqueItems_1 = require("./uniqueItems");
|
||||
const const_1 = require("./const");
|
||||
const enum_1 = require("./enum");
|
||||
const validation = [
|
||||
// number
|
||||
limitNumber_1.default,
|
||||
multipleOf_1.default,
|
||||
// string
|
||||
limitLength_1.default,
|
||||
pattern_1.default,
|
||||
// object
|
||||
limitProperties_1.default,
|
||||
required_1.default,
|
||||
// array
|
||||
limitItems_1.default,
|
||||
uniqueItems_1.default,
|
||||
// any
|
||||
{ keyword: "type", schemaType: ["string", "array"] },
|
||||
{ keyword: "nullable", schemaType: "boolean" },
|
||||
const_1.default,
|
||||
enum_1.default,
|
||||
];
|
||||
exports.default = validation;
|
||||
//# sourceMappingURL=index.js.map
|
||||
24
extracted-source/node_modules/ajv/dist/vocabularies/validation/limitItems.js
generated
vendored
Normal file
24
extracted-source/node_modules/ajv/dist/vocabularies/validation/limitItems.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const codegen_1 = require("../../compile/codegen");
|
||||
const error = {
|
||||
message({ keyword, schemaCode }) {
|
||||
const comp = keyword === "maxItems" ? "more" : "fewer";
|
||||
return (0, codegen_1.str) `must NOT have ${comp} than ${schemaCode} items`;
|
||||
},
|
||||
params: ({ schemaCode }) => (0, codegen_1._) `{limit: ${schemaCode}}`,
|
||||
};
|
||||
const def = {
|
||||
keyword: ["maxItems", "minItems"],
|
||||
type: "array",
|
||||
schemaType: "number",
|
||||
$data: true,
|
||||
error,
|
||||
code(cxt) {
|
||||
const { keyword, data, schemaCode } = cxt;
|
||||
const op = keyword === "maxItems" ? codegen_1.operators.GT : codegen_1.operators.LT;
|
||||
cxt.fail$data((0, codegen_1._) `${data}.length ${op} ${schemaCode}`);
|
||||
},
|
||||
};
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=limitItems.js.map
|
||||
27
extracted-source/node_modules/ajv/dist/vocabularies/validation/limitLength.js
generated
vendored
Normal file
27
extracted-source/node_modules/ajv/dist/vocabularies/validation/limitLength.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const codegen_1 = require("../../compile/codegen");
|
||||
const util_1 = require("../../compile/util");
|
||||
const ucs2length_1 = require("../../runtime/ucs2length");
|
||||
const error = {
|
||||
message({ keyword, schemaCode }) {
|
||||
const comp = keyword === "maxLength" ? "more" : "fewer";
|
||||
return (0, codegen_1.str) `must NOT have ${comp} than ${schemaCode} characters`;
|
||||
},
|
||||
params: ({ schemaCode }) => (0, codegen_1._) `{limit: ${schemaCode}}`,
|
||||
};
|
||||
const def = {
|
||||
keyword: ["maxLength", "minLength"],
|
||||
type: "string",
|
||||
schemaType: "number",
|
||||
$data: true,
|
||||
error,
|
||||
code(cxt) {
|
||||
const { keyword, data, schemaCode, it } = cxt;
|
||||
const op = keyword === "maxLength" ? codegen_1.operators.GT : codegen_1.operators.LT;
|
||||
const len = it.opts.unicode === false ? (0, codegen_1._) `${data}.length` : (0, codegen_1._) `${(0, util_1.useFunc)(cxt.gen, ucs2length_1.default)}(${data})`;
|
||||
cxt.fail$data((0, codegen_1._) `${len} ${op} ${schemaCode}`);
|
||||
},
|
||||
};
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=limitLength.js.map
|
||||
27
extracted-source/node_modules/ajv/dist/vocabularies/validation/limitNumber.js
generated
vendored
Normal file
27
extracted-source/node_modules/ajv/dist/vocabularies/validation/limitNumber.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const codegen_1 = require("../../compile/codegen");
|
||||
const ops = codegen_1.operators;
|
||||
const KWDs = {
|
||||
maximum: { okStr: "<=", ok: ops.LTE, fail: ops.GT },
|
||||
minimum: { okStr: ">=", ok: ops.GTE, fail: ops.LT },
|
||||
exclusiveMaximum: { okStr: "<", ok: ops.LT, fail: ops.GTE },
|
||||
exclusiveMinimum: { okStr: ">", ok: ops.GT, fail: ops.LTE },
|
||||
};
|
||||
const error = {
|
||||
message: ({ keyword, schemaCode }) => (0, codegen_1.str) `must be ${KWDs[keyword].okStr} ${schemaCode}`,
|
||||
params: ({ keyword, schemaCode }) => (0, codegen_1._) `{comparison: ${KWDs[keyword].okStr}, limit: ${schemaCode}}`,
|
||||
};
|
||||
const def = {
|
||||
keyword: Object.keys(KWDs),
|
||||
type: "number",
|
||||
schemaType: "number",
|
||||
$data: true,
|
||||
error,
|
||||
code(cxt) {
|
||||
const { keyword, data, schemaCode } = cxt;
|
||||
cxt.fail$data((0, codegen_1._) `${data} ${KWDs[keyword].fail} ${schemaCode} || isNaN(${data})`);
|
||||
},
|
||||
};
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=limitNumber.js.map
|
||||
24
extracted-source/node_modules/ajv/dist/vocabularies/validation/limitProperties.js
generated
vendored
Normal file
24
extracted-source/node_modules/ajv/dist/vocabularies/validation/limitProperties.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const codegen_1 = require("../../compile/codegen");
|
||||
const error = {
|
||||
message({ keyword, schemaCode }) {
|
||||
const comp = keyword === "maxProperties" ? "more" : "fewer";
|
||||
return (0, codegen_1.str) `must NOT have ${comp} than ${schemaCode} properties`;
|
||||
},
|
||||
params: ({ schemaCode }) => (0, codegen_1._) `{limit: ${schemaCode}}`,
|
||||
};
|
||||
const def = {
|
||||
keyword: ["maxProperties", "minProperties"],
|
||||
type: "object",
|
||||
schemaType: "number",
|
||||
$data: true,
|
||||
error,
|
||||
code(cxt) {
|
||||
const { keyword, data, schemaCode } = cxt;
|
||||
const op = keyword === "maxProperties" ? codegen_1.operators.GT : codegen_1.operators.LT;
|
||||
cxt.fail$data((0, codegen_1._) `Object.keys(${data}).length ${op} ${schemaCode}`);
|
||||
},
|
||||
};
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=limitProperties.js.map
|
||||
26
extracted-source/node_modules/ajv/dist/vocabularies/validation/multipleOf.js
generated
vendored
Normal file
26
extracted-source/node_modules/ajv/dist/vocabularies/validation/multipleOf.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const codegen_1 = require("../../compile/codegen");
|
||||
const error = {
|
||||
message: ({ schemaCode }) => (0, codegen_1.str) `must be multiple of ${schemaCode}`,
|
||||
params: ({ schemaCode }) => (0, codegen_1._) `{multipleOf: ${schemaCode}}`,
|
||||
};
|
||||
const def = {
|
||||
keyword: "multipleOf",
|
||||
type: "number",
|
||||
schemaType: "number",
|
||||
$data: true,
|
||||
error,
|
||||
code(cxt) {
|
||||
const { gen, data, schemaCode, it } = cxt;
|
||||
// const bdt = bad$DataType(schemaCode, <string>def.schemaType, $data)
|
||||
const prec = it.opts.multipleOfPrecision;
|
||||
const res = gen.let("res");
|
||||
const invalid = prec
|
||||
? (0, codegen_1._) `Math.abs(Math.round(${res}) - ${res}) > 1e-${prec}`
|
||||
: (0, codegen_1._) `${res} !== parseInt(${res})`;
|
||||
cxt.fail$data((0, codegen_1._) `(${schemaCode} === 0 || (${res} = ${data}/${schemaCode}, ${invalid}))`);
|
||||
},
|
||||
};
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=multipleOf.js.map
|
||||
33
extracted-source/node_modules/ajv/dist/vocabularies/validation/pattern.js
generated
vendored
Normal file
33
extracted-source/node_modules/ajv/dist/vocabularies/validation/pattern.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const code_1 = require("../code");
|
||||
const util_1 = require("../../compile/util");
|
||||
const codegen_1 = require("../../compile/codegen");
|
||||
const error = {
|
||||
message: ({ schemaCode }) => (0, codegen_1.str) `must match pattern "${schemaCode}"`,
|
||||
params: ({ schemaCode }) => (0, codegen_1._) `{pattern: ${schemaCode}}`,
|
||||
};
|
||||
const def = {
|
||||
keyword: "pattern",
|
||||
type: "string",
|
||||
schemaType: "string",
|
||||
$data: true,
|
||||
error,
|
||||
code(cxt) {
|
||||
const { gen, data, $data, schema, schemaCode, it } = cxt;
|
||||
const u = it.opts.unicodeRegExp ? "u" : "";
|
||||
if ($data) {
|
||||
const { regExp } = it.opts.code;
|
||||
const regExpCode = regExp.code === "new RegExp" ? (0, codegen_1._) `new RegExp` : (0, util_1.useFunc)(gen, regExp);
|
||||
const valid = gen.let("valid");
|
||||
gen.try(() => gen.assign(valid, (0, codegen_1._) `${regExpCode}(${schemaCode}, ${u}).test(${data})`), () => gen.assign(valid, false));
|
||||
cxt.fail$data((0, codegen_1._) `!${valid}`);
|
||||
}
|
||||
else {
|
||||
const regExp = (0, code_1.usePattern)(cxt, schema);
|
||||
cxt.fail$data((0, codegen_1._) `!${regExp}.test(${data})`);
|
||||
}
|
||||
},
|
||||
};
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=pattern.js.map
|
||||
79
extracted-source/node_modules/ajv/dist/vocabularies/validation/required.js
generated
vendored
Normal file
79
extracted-source/node_modules/ajv/dist/vocabularies/validation/required.js
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const code_1 = require("../code");
|
||||
const codegen_1 = require("../../compile/codegen");
|
||||
const util_1 = require("../../compile/util");
|
||||
const error = {
|
||||
message: ({ params: { missingProperty } }) => (0, codegen_1.str) `must have required property '${missingProperty}'`,
|
||||
params: ({ params: { missingProperty } }) => (0, codegen_1._) `{missingProperty: ${missingProperty}}`,
|
||||
};
|
||||
const def = {
|
||||
keyword: "required",
|
||||
type: "object",
|
||||
schemaType: "array",
|
||||
$data: true,
|
||||
error,
|
||||
code(cxt) {
|
||||
const { gen, schema, schemaCode, data, $data, it } = cxt;
|
||||
const { opts } = it;
|
||||
if (!$data && schema.length === 0)
|
||||
return;
|
||||
const useLoop = schema.length >= opts.loopRequired;
|
||||
if (it.allErrors)
|
||||
allErrorsMode();
|
||||
else
|
||||
exitOnErrorMode();
|
||||
if (opts.strictRequired) {
|
||||
const props = cxt.parentSchema.properties;
|
||||
const { definedProperties } = cxt.it;
|
||||
for (const requiredKey of schema) {
|
||||
if ((props === null || props === void 0 ? void 0 : props[requiredKey]) === undefined && !definedProperties.has(requiredKey)) {
|
||||
const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
|
||||
const msg = `required property "${requiredKey}" is not defined at "${schemaPath}" (strictRequired)`;
|
||||
(0, util_1.checkStrictMode)(it, msg, it.opts.strictRequired);
|
||||
}
|
||||
}
|
||||
}
|
||||
function allErrorsMode() {
|
||||
if (useLoop || $data) {
|
||||
cxt.block$data(codegen_1.nil, loopAllRequired);
|
||||
}
|
||||
else {
|
||||
for (const prop of schema) {
|
||||
(0, code_1.checkReportMissingProp)(cxt, prop);
|
||||
}
|
||||
}
|
||||
}
|
||||
function exitOnErrorMode() {
|
||||
const missing = gen.let("missing");
|
||||
if (useLoop || $data) {
|
||||
const valid = gen.let("valid", true);
|
||||
cxt.block$data(valid, () => loopUntilMissing(missing, valid));
|
||||
cxt.ok(valid);
|
||||
}
|
||||
else {
|
||||
gen.if((0, code_1.checkMissingProp)(cxt, schema, missing));
|
||||
(0, code_1.reportMissingProp)(cxt, missing);
|
||||
gen.else();
|
||||
}
|
||||
}
|
||||
function loopAllRequired() {
|
||||
gen.forOf("prop", schemaCode, (prop) => {
|
||||
cxt.setParams({ missingProperty: prop });
|
||||
gen.if((0, code_1.noPropertyInData)(gen, data, prop, opts.ownProperties), () => cxt.error());
|
||||
});
|
||||
}
|
||||
function loopUntilMissing(missing, valid) {
|
||||
cxt.setParams({ missingProperty: missing });
|
||||
gen.forOf(missing, schemaCode, () => {
|
||||
gen.assign(valid, (0, code_1.propertyInData)(gen, data, missing, opts.ownProperties));
|
||||
gen.if((0, codegen_1.not)(valid), () => {
|
||||
cxt.error();
|
||||
gen.break();
|
||||
});
|
||||
}, codegen_1.nil);
|
||||
}
|
||||
},
|
||||
};
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=required.js.map
|
||||
64
extracted-source/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js
generated
vendored
Normal file
64
extracted-source/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const dataType_1 = require("../../compile/validate/dataType");
|
||||
const codegen_1 = require("../../compile/codegen");
|
||||
const util_1 = require("../../compile/util");
|
||||
const equal_1 = require("../../runtime/equal");
|
||||
const error = {
|
||||
message: ({ params: { i, j } }) => (0, codegen_1.str) `must NOT have duplicate items (items ## ${j} and ${i} are identical)`,
|
||||
params: ({ params: { i, j } }) => (0, codegen_1._) `{i: ${i}, j: ${j}}`,
|
||||
};
|
||||
const def = {
|
||||
keyword: "uniqueItems",
|
||||
type: "array",
|
||||
schemaType: "boolean",
|
||||
$data: true,
|
||||
error,
|
||||
code(cxt) {
|
||||
const { gen, data, $data, schema, parentSchema, schemaCode, it } = cxt;
|
||||
if (!$data && !schema)
|
||||
return;
|
||||
const valid = gen.let("valid");
|
||||
const itemTypes = parentSchema.items ? (0, dataType_1.getSchemaTypes)(parentSchema.items) : [];
|
||||
cxt.block$data(valid, validateUniqueItems, (0, codegen_1._) `${schemaCode} === false`);
|
||||
cxt.ok(valid);
|
||||
function validateUniqueItems() {
|
||||
const i = gen.let("i", (0, codegen_1._) `${data}.length`);
|
||||
const j = gen.let("j");
|
||||
cxt.setParams({ i, j });
|
||||
gen.assign(valid, true);
|
||||
gen.if((0, codegen_1._) `${i} > 1`, () => (canOptimize() ? loopN : loopN2)(i, j));
|
||||
}
|
||||
function canOptimize() {
|
||||
return itemTypes.length > 0 && !itemTypes.some((t) => t === "object" || t === "array");
|
||||
}
|
||||
function loopN(i, j) {
|
||||
const item = gen.name("item");
|
||||
const wrongType = (0, dataType_1.checkDataTypes)(itemTypes, item, it.opts.strictNumbers, dataType_1.DataType.Wrong);
|
||||
const indices = gen.const("indices", (0, codegen_1._) `{}`);
|
||||
gen.for((0, codegen_1._) `;${i}--;`, () => {
|
||||
gen.let(item, (0, codegen_1._) `${data}[${i}]`);
|
||||
gen.if(wrongType, (0, codegen_1._) `continue`);
|
||||
if (itemTypes.length > 1)
|
||||
gen.if((0, codegen_1._) `typeof ${item} == "string"`, (0, codegen_1._) `${item} += "_"`);
|
||||
gen
|
||||
.if((0, codegen_1._) `typeof ${indices}[${item}] == "number"`, () => {
|
||||
gen.assign(j, (0, codegen_1._) `${indices}[${item}]`);
|
||||
cxt.error();
|
||||
gen.assign(valid, false).break();
|
||||
})
|
||||
.code((0, codegen_1._) `${indices}[${item}] = ${i}`);
|
||||
});
|
||||
}
|
||||
function loopN2(i, j) {
|
||||
const eql = (0, util_1.useFunc)(gen, equal_1.default);
|
||||
const outer = gen.name("outer");
|
||||
gen.label(outer).for((0, codegen_1._) `;${i}--;`, () => gen.for((0, codegen_1._) `${j} = ${i}; ${j}--;`, () => gen.if((0, codegen_1._) `${eql}(${data}[${i}], ${data}[${j}])`, () => {
|
||||
cxt.error();
|
||||
gen.assign(valid, false).break(outer);
|
||||
})));
|
||||
}
|
||||
},
|
||||
};
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=uniqueItems.js.map
|
||||
Reference in New Issue
Block a user