mirror of
https://github.com/tvytlx/ai-agent-deep-dive.git
synced 2026-04-11 19:44:49 +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
|
||||
Reference in New Issue
Block a user