mirror of
https://github.com/tvytlx/ai-agent-deep-dive.git
synced 2026-04-09 02:24:48 +08:00
Add extracted source directory and README navigation
This commit is contained in:
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