Upload via GUI (7543 Dateien)
This commit is contained in:
+1
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../../lib/vocabularies/format/format.ts"],"names":[],"mappings":";;AASA,mDAAoF;AAapF,MAAM,KAAK,GAA2B;IACpC,OAAO,EAAE,CAAC,EAAC,UAAU,EAAC,EAAE,EAAE,CAAC,IAAA,aAAG,EAAA,sBAAsB,UAAU,GAAG;IACjE,MAAM,EAAE,CAAC,EAAC,UAAU,EAAC,EAAE,EAAE,CAAC,IAAA,WAAC,EAAA,YAAY,UAAU,GAAG;CACrD,CAAA;AAED,MAAM,GAAG,GAA0B;IACjC,OAAO,EAAE,QAAQ;IACjB,IAAI,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC1B,UAAU,EAAE,QAAQ;IACpB,KAAK,EAAE,IAAI;IACX,KAAK;IACL,IAAI,CAAC,GAAe,EAAE,QAAiB;QACrC,MAAM,EAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,EAAC,GAAG,GAAG,CAAA;QACtD,MAAM,EAAC,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,IAAI,EAAC,GAAG,EAAE,CAAA;QACjD,IAAI,CAAC,IAAI,CAAC,eAAe;YAAE,OAAM;QAEjC,IAAI,KAAK;YAAE,mBAAmB,EAAE,CAAA;;YAC3B,cAAc,EAAE,CAAA;QAErB,SAAS,mBAAmB;YAC1B,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,SAAS,EAAE;gBACrC,GAAG,EAAE,IAAI,CAAC,OAAO;gBACjB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO;aACxB,CAAC,CAAA;YACF,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,IAAA,WAAC,EAAA,GAAG,IAAI,IAAI,UAAU,GAAG,CAAC,CAAA;YACzD,MAAM,KAAK,GAAG,GAAG,CAAC,G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,QAAQ,IAAI,CAAC,CAAC,MAAM,YAAY,MAAM,CAAC,EAAE,CAAC;oBAC7D,OAAO,CAAC,MAAM,CAAC,IAAI,IAAI,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,IAAA,WAAC,EAAA,GAAG,GAAG,WAAW,CAAC,CAAA;gBACvE,CAAC;gBAED,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,CAAC,CAAA;YAChC,CAAC;YAED,SAAS,cAAc;gBACrB,IAAI,OAAO,SAAS,IAAI,QAAQ,IAAI,CAAC,CAAC,SAAS,YAAY,MAAM,CAAC,IAAI,SAAS,CAAC,KAAK,EAAE,CAAC;oBACtF,IAAI,CAAC,SAAS,CAAC,MAAM;wBAAE,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAA;oBACrE,OAAO,IAAA,WAAC,EAAA,SAAS,MAAM,IAAI,IAAI,GAAG,CAAA;gBACpC,CAAC;gBACD,OAAO,OAAO,MAAM,IAAI,UAAU,CAAC,CAAC,CAAC,IAAA,WAAC,EAAA,GAAG,MAAM,IAAI,IAAI,GAAG,CAAC,CAAC,CAAC,IAAA,WAAC,EAAA,GAAG,MAAM,SAAS,IAAI,GAAG,CAAA;YACzF,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAA;AAED,kBAAe,GAAG,CAAA"}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
import type { Vocabulary } from "../../types";
|
||||||
|
declare const format: Vocabulary;
|
||||||
|
export default format;
|
||||||
+6
@@ -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
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/vocabularies/format/index.ts"],"names":[],"mappings":";;AACA,qCAAoC;AAEpC,MAAM,MAAM,GAAe,CAAC,gBAAa,CAAC,CAAA;AAE1C,kBAAe,MAAM,CAAA"}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
import type { CodeKeywordDefinition } from "../../types";
|
||||||
|
import { _JTDTypeError } from "./error";
|
||||||
|
import { DiscrError, DiscrErrorObj } from "../discriminator/types";
|
||||||
|
export type JTDDiscriminatorError = _JTDTypeError<"discriminator", "object", string> | DiscrErrorObj<DiscrError.Tag> | DiscrErrorObj<DiscrError.Mapping>;
|
||||||
|
declare const def: CodeKeywordDefinition;
|
||||||
|
export default def;
|
||||||
+71
@@ -0,0 +1,71 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const codegen_1 = require("../../compile/codegen");
|
||||||
|
const metadata_1 = require("./metadata");
|
||||||
|
const nullable_1 = require("./nullable");
|
||||||
|
const error_1 = require("./error");
|
||||||
|
const types_1 = require("../discriminator/types");
|
||||||
|
const error = {
|
||||||
|
message: (cxt) => {
|
||||||
|
const { schema, params } = cxt;
|
||||||
|
return params.discrError
|
||||||
|
? params.discrError === types_1.DiscrError.Tag
|
||||||
|
? `tag "${schema}" must be string`
|
||||||
|
: `value of tag "${schema}" must be in mapping`
|
||||||
|
: (0, error_1.typeErrorMessage)(cxt, "object");
|
||||||
|
},
|
||||||
|
params: (cxt) => {
|
||||||
|
const { schema, params } = cxt;
|
||||||
|
return params.discrError
|
||||||
|
? (0, codegen_1._) `{error: ${params.discrError}, tag: ${schema}, tagValue: ${params.tag}}`
|
||||||
|
: (0, error_1.typeErrorParams)(cxt, "object");
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const def = {
|
||||||
|
keyword: "discriminator",
|
||||||
|
schemaType: "string",
|
||||||
|
implements: ["mapping"],
|
||||||
|
error,
|
||||||
|
code(cxt) {
|
||||||
|
(0, metadata_1.checkMetadata)(cxt);
|
||||||
|
const { gen, data, schema, parentSchema } = cxt;
|
||||||
|
const [valid, cond] = (0, nullable_1.checkNullableObject)(cxt, data);
|
||||||
|
gen.if(cond);
|
||||||
|
validateDiscriminator();
|
||||||
|
gen.elseIf((0, codegen_1.not)(valid));
|
||||||
|
cxt.error();
|
||||||
|
gen.endIf();
|
||||||
|
cxt.ok(valid);
|
||||||
|
function validateDiscriminator() {
|
||||||
|
const tag = gen.const("tag", (0, codegen_1._) `${data}${(0, codegen_1.getProperty)(schema)}`);
|
||||||
|
gen.if((0, codegen_1._) `${tag} === undefined`);
|
||||||
|
cxt.error(false, { discrError: types_1.DiscrError.Tag, tag });
|
||||||
|
gen.elseIf((0, codegen_1._) `typeof ${tag} == "string"`);
|
||||||
|
validateMapping(tag);
|
||||||
|
gen.else();
|
||||||
|
cxt.error(false, { discrError: types_1.DiscrError.Tag, tag }, { instancePath: schema });
|
||||||
|
gen.endIf();
|
||||||
|
}
|
||||||
|
function validateMapping(tag) {
|
||||||
|
gen.if(false);
|
||||||
|
for (const tagValue in parentSchema.mapping) {
|
||||||
|
gen.elseIf((0, codegen_1._) `${tag} === ${tagValue}`);
|
||||||
|
gen.assign(valid, applyTagSchema(tagValue));
|
||||||
|
}
|
||||||
|
gen.else();
|
||||||
|
cxt.error(false, { discrError: types_1.DiscrError.Mapping, tag }, { instancePath: schema, schemaPath: "mapping", parentSchema: true });
|
||||||
|
gen.endIf();
|
||||||
|
}
|
||||||
|
function applyTagSchema(schemaProp) {
|
||||||
|
const _valid = gen.name("valid");
|
||||||
|
cxt.subschema({
|
||||||
|
keyword: "mapping",
|
||||||
|
schemaProp,
|
||||||
|
jtdDiscriminator: schema,
|
||||||
|
}, _valid);
|
||||||
|
return _valid;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
exports.default = def;
|
||||||
|
//# sourceMappingURL=discriminator.js.map
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"discriminator.js","sourceRoot":"","sources":["../../../lib/vocabularies/jtd/discriminator.ts"],"names":[],"mappings":";;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AAC,IAAI,EAAE,CAAA;YACV,GAAG,CAAC,KAAK,CACP,KAAK,EACL,EAAC,UAAU,EAAE,kBAAU,CAAC,OAAO,EAAE,GAAG,EAAC,EACrC,EAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,IAAI,EAAC,CAClE,CAAA;YACD,GAAG,CAAC,KAAK,EAAE,CAAA;QACb,CAAC;QAED,SAAS,cAAc,CAAC,UAAkB;YACxC,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;YAChC,GAAG,CAAC,SAAS,CACX;gBACE,OAAO,EAAE,SAAS;gBAClB,UAAU;gBACV,gBAAgB,EAAE,MAAM;aACzB,EACD,MAAM,CACP,CAAA;YACD,OAAO,MAAM,CAAA;QACf,CAAC;IACH,CAAC;CACF,CAAA;AAED,kBAAe,GAAG,CAAA"}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
import type { CodeKeywordDefinition, SchemaObject } from "../../types";
|
||||||
|
import { _JTDTypeError } from "./error";
|
||||||
|
export type JTDElementsError = _JTDTypeError<"elements", "array", SchemaObject>;
|
||||||
|
declare const def: CodeKeywordDefinition;
|
||||||
|
export default def;
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const util_1 = require("../../compile/util");
|
||||||
|
const code_1 = require("../code");
|
||||||
|
const codegen_1 = require("../../compile/codegen");
|
||||||
|
const metadata_1 = require("./metadata");
|
||||||
|
const nullable_1 = require("./nullable");
|
||||||
|
const error_1 = require("./error");
|
||||||
|
const def = {
|
||||||
|
keyword: "elements",
|
||||||
|
schemaType: "object",
|
||||||
|
error: (0, error_1.typeError)("array"),
|
||||||
|
code(cxt) {
|
||||||
|
(0, metadata_1.checkMetadata)(cxt);
|
||||||
|
const { gen, data, schema, it } = cxt;
|
||||||
|
if ((0, util_1.alwaysValidSchema)(it, schema))
|
||||||
|
return;
|
||||||
|
const [valid] = (0, nullable_1.checkNullable)(cxt);
|
||||||
|
gen.if((0, codegen_1.not)(valid), () => gen.if((0, codegen_1._) `Array.isArray(${data})`, () => gen.assign(valid, (0, code_1.validateArray)(cxt)), () => cxt.error()));
|
||||||
|
cxt.ok(valid);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
exports.default = def;
|
||||||
|
//# sourceMappingURL=elements.js.map
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"elements.js","sourceRoot":"","sources":["../../../lib/vocabularies/jtd/elements.ts"],"names":[],"mappings":";;AAEA,6CAAoD;AACpD,kCAAqC;AACrC,mDAA4C;AAC5C,yCAAwC;AACxC,yCAAwC;AACxC,mCAAgD;AAIhD,MAAM,GAAG,GAA0B;IACjC,OAAO,EAAE,UAAU;IACnB,UAAU,EAAE,QAAQ;IACpB,KAAK,EAAE,IAAA,iBAAS,EAAC,OAAO,CAAC;IACzB,IAAI,CAAC,GAAe;QAClB,IAAA,wBAAa,EAAC,GAAG,CAAC,CAAA;QAClB,MAAM,EAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAC,GAAG,GAAG,CAAA;QACnC,IAAI,IAAA,wBAAiB,EAAC,EAAE,EAAE,MAAM,CAAC;YAAE,OAAM;QACzC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAA,wBAAa,EAAC,GAAG,CAAC,CAAA;QAClC,GAAG,CAAC,EAAE,CAAC,IAAA,aAAG,EAAC,KAAK,CAAC,EAAE,GAAG,EAAE,CACtB,GAAG,CAAC,EAAE,CACJ,IAAA,WAAC,EAAA,iBAAiB,IAAI,GAAG,EACzB,GAAG,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,IAAA,oBAAa,EAAC,GAAG,CAAC,CAAC,EAC3C,GAAG,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,CAClB,CACF,CAAA;QACD,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,CAAA;IACf,CAAC;CACF,CAAA;AAED,kBAAe,GAAG,CAAA"}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
import type { CodeKeywordDefinition, ErrorObject } from "../../types";
|
||||||
|
export type JTDEnumError = ErrorObject<"enum", {
|
||||||
|
allowedValues: string[];
|
||||||
|
}, string[]>;
|
||||||
|
declare const def: CodeKeywordDefinition;
|
||||||
|
export default def;
|
||||||
+43
@@ -0,0 +1,43 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const codegen_1 = require("../../compile/codegen");
|
||||||
|
const metadata_1 = require("./metadata");
|
||||||
|
const nullable_1 = require("./nullable");
|
||||||
|
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",
|
||||||
|
error,
|
||||||
|
code(cxt) {
|
||||||
|
(0, metadata_1.checkMetadata)(cxt);
|
||||||
|
const { gen, data, schema, schemaValue, parentSchema, it } = cxt;
|
||||||
|
if (schema.length === 0)
|
||||||
|
throw new Error("enum must have non-empty array");
|
||||||
|
if (schema.length !== new Set(schema).size)
|
||||||
|
throw new Error("enum items must be unique");
|
||||||
|
let valid;
|
||||||
|
const isString = (0, codegen_1._) `typeof ${data} == "string"`;
|
||||||
|
if (schema.length >= it.opts.loopEnum) {
|
||||||
|
let cond;
|
||||||
|
[valid, cond] = (0, nullable_1.checkNullable)(cxt, isString);
|
||||||
|
gen.if(cond, loopEnum);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* istanbul ignore if */
|
||||||
|
if (!Array.isArray(schema))
|
||||||
|
throw new Error("ajv implementation error");
|
||||||
|
valid = (0, codegen_1.and)(isString, (0, codegen_1.or)(...schema.map((value) => (0, codegen_1._) `${data} === ${value}`)));
|
||||||
|
if (parentSchema.nullable)
|
||||||
|
valid = (0, codegen_1.or)((0, codegen_1._) `${data} === null`, valid);
|
||||||
|
}
|
||||||
|
cxt.pass(valid);
|
||||||
|
function loopEnum() {
|
||||||
|
gen.forOf("v", schemaValue, (v) => gen.if((0, codegen_1._) `${valid} = ${data} === ${v}`, () => gen.break()));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
exports.default = def;
|
||||||
|
//# sourceMappingURL=enum.js.map
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"enum.js","sourceRoot":"","sources":["../../../lib/vocabularies/jtd/enum.ts"],"names":[],"mappings":";;AAEA,mDAAsD;AACtD,yCAAwC;AACxC,yCAAwC;AAIxC,MAAM,KAAK,GAA2B;IACpC,OAAO,EAAE,4CAA4C;IACrD,MAAM,EAAE,CAAC,EAAC,UAAU,EAAC,EAAE,EAAE,CAAC,IAAA,WAAC,EAAA,mBAAmB,UAAU,GAAG;CAC5D,CAAA;AAED,MAAM,GAAG,GAA0B;IACjC,OAAO,EAAE,MAAM;IACf,UAAU,EAAE,OAAO;IACnB,KAAK;IACL,IAAI,CAAC,GAAe;QAClB,IAAA,wBAAa,EAAC,GAAG,CAAC,CAAA;QAClB,MAAM,EAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,EAAE,EAAC,GAAG,GAAG,CAAA;QAC9D,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;QAC1E,IAAI,MAAM,CAAC,MAAM,KAAK,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAA;QACxF,IAAI,KAAW,CAAA;QACf,MAAM,QAAQ,GAAG,IAAA,WAAC,EAAA,UAAU,IAAI,cAAc,CAAA;QAC9C,IAAI,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACtC,IAAI,IAAU,CACb;YAAA,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,IAAA,wBAAa,EAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;YAC7C,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;QACxB,CAAC;aAAM,CAAC;YACN,wBAAwB;YACxB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;gBAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAA;YACvE,KAAK,GAAG,IAAA,aAAG,EAAC,QAAQ,EAAE,IAAA,YAAE,EAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAa,EAAE,EAAE,CAAC,IAAA,WAAC,EAAA,GAAG,IAAI,QAAQ,KAAK,EAAE,CAAC,CAAC,CAAC,CAAA;YACpF,IAAI,YAAY,CAAC,QAAQ;gBAAE,KAAK,GAAG,IAAA,YAAE,EAAC,IAAA,WAAC,EAAA,GAAG,IAAI,WAAW,EAAE,KAAK,CAAC,CAAA;QACnE,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QAEf,SAAS,QAAQ;YACf,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,WAAmB,EAAE,CAAC,CAAC,EAAE,EAAE,CACxC,GAAG,CAAC,EAAE,CAAC,IAAA,WAAC,EAAA,GAAG,KAAK,MAAM,IAAI,QAAQ,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAC1D,CAAA;QACH,CAAC;IACH,CAAC;CACF,CAAA;AAED,kBAAe,GAAG,CAAA"}
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
import type { KeywordErrorDefinition, KeywordErrorCxt, ErrorObject } from "../../types";
|
||||||
|
import { Code } from "../../compile/codegen";
|
||||||
|
export type _JTDTypeError<K extends string, T extends string, S> = ErrorObject<K, {
|
||||||
|
type: T;
|
||||||
|
nullable: boolean;
|
||||||
|
}, S>;
|
||||||
|
export declare function typeError(t: string): KeywordErrorDefinition;
|
||||||
|
export declare function typeErrorMessage({ parentSchema }: KeywordErrorCxt, t: string): string;
|
||||||
|
export declare function typeErrorParams({ parentSchema }: KeywordErrorCxt, t: string): Code;
|
||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.typeErrorParams = exports.typeErrorMessage = exports.typeError = void 0;
|
||||||
|
const codegen_1 = require("../../compile/codegen");
|
||||||
|
function typeError(t) {
|
||||||
|
return {
|
||||||
|
message: (cxt) => typeErrorMessage(cxt, t),
|
||||||
|
params: (cxt) => typeErrorParams(cxt, t),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
exports.typeError = typeError;
|
||||||
|
function typeErrorMessage({ parentSchema }, t) {
|
||||||
|
return (parentSchema === null || parentSchema === void 0 ? void 0 : parentSchema.nullable) ? `must be ${t} or null` : `must be ${t}`;
|
||||||
|
}
|
||||||
|
exports.typeErrorMessage = typeErrorMessage;
|
||||||
|
function typeErrorParams({ parentSchema }, t) {
|
||||||
|
return (0, codegen_1._) `{type: ${t}, nullable: ${!!(parentSchema === null || parentSchema === void 0 ? void 0 : parentSchema.nullable)}}`;
|
||||||
|
}
|
||||||
|
exports.typeErrorParams = typeErrorParams;
|
||||||
|
//# sourceMappingURL=error.js.map
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../../lib/vocabularies/jtd/error.ts"],"names":[],"mappings":";;;AACA,mDAA6C;AAQ7C,SAAgB,SAAS,CAAC,CAAS;IACjC,OAAO;QACL,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,gBAAgB,CAAC,GAAG,EAAE,CAAC,CAAC;QAC1C,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,eAAe,CAAC,GAAG,EAAE,CAAC,CAAC;KACzC,CAAA;AACH,CAAC;AALD,8BAKC;AAED,SAAgB,gBAAgB,CAAC,EAAC,YAAY,EAAkB,EAAE,CAAS;IACzE,OAAO,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,QAAQ,EAAC,CAAC,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,CAAA;AACzE,CAAC;AAFD,4CAEC;AAED,SAAgB,eAAe,CAAC,EAAC,YAAY,EAAkB,EAAE,CAAS;IACxE,OAAO,IAAA,WAAC,EAAA,UAAU,CAAC,eAAe,CAAC,CAAC,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,QAAQ,CAAA,GAAG,CAAA;AAC/D,CAAC;AAFD,0CAEC"}
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
import type { Vocabulary } from "../../types";
|
||||||
|
import { JTDTypeError } from "./type";
|
||||||
|
import { JTDEnumError } from "./enum";
|
||||||
|
import { JTDElementsError } from "./elements";
|
||||||
|
import { JTDPropertiesError } from "./properties";
|
||||||
|
import { JTDDiscriminatorError } from "./discriminator";
|
||||||
|
import { JTDValuesError } from "./values";
|
||||||
|
declare const jtdVocabulary: Vocabulary;
|
||||||
|
export default jtdVocabulary;
|
||||||
|
export type JTDErrorObject = JTDTypeError | JTDEnumError | JTDElementsError | JTDPropertiesError | JTDDiscriminatorError | JTDValuesError;
|
||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const ref_1 = require("./ref");
|
||||||
|
const type_1 = require("./type");
|
||||||
|
const enum_1 = require("./enum");
|
||||||
|
const elements_1 = require("./elements");
|
||||||
|
const properties_1 = require("./properties");
|
||||||
|
const optionalProperties_1 = require("./optionalProperties");
|
||||||
|
const discriminator_1 = require("./discriminator");
|
||||||
|
const values_1 = require("./values");
|
||||||
|
const union_1 = require("./union");
|
||||||
|
const metadata_1 = require("./metadata");
|
||||||
|
const jtdVocabulary = [
|
||||||
|
"definitions",
|
||||||
|
ref_1.default,
|
||||||
|
type_1.default,
|
||||||
|
enum_1.default,
|
||||||
|
elements_1.default,
|
||||||
|
properties_1.default,
|
||||||
|
optionalProperties_1.default,
|
||||||
|
discriminator_1.default,
|
||||||
|
values_1.default,
|
||||||
|
union_1.default,
|
||||||
|
metadata_1.default,
|
||||||
|
{ keyword: "additionalProperties", schemaType: "boolean" },
|
||||||
|
{ keyword: "nullable", schemaType: "boolean" },
|
||||||
|
];
|
||||||
|
exports.default = jtdVocabulary;
|
||||||
|
//# sourceMappingURL=index.js.map
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/vocabularies/jtd/index.ts"],"names":[],"mappings":";;AACA,+BAA8B;AAC9B,iCAAgD;AAChD,iCAAgD;AAChD,yCAAqD;AACrD,6CAA2D;AAC3D,6DAAqD;AACrD,mDAAoE;AACpE,qCAA+C;AAC/C,mCAA2B;AAC3B,yCAAiC;AAEjC,MAAM,aAAa,GAAe;IAChC,aAAa;IACb,aAAU;IACV,cAAW;IACX,cAAW;IACX,kBAAQ;IACR,oBAAU;IACV,4BAAkB;IAClB,uBAAa;IACb,gBAAM;IACN,eAAK;IACL,kBAAQ;IACR,EAAC,OAAO,EAAE,sBAAsB,EAAE,UAAU,EAAE,SAAS,EAAC;IACxD,EAAC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAC;CAC7C,CAAA;AAED,kBAAe,aAAa,CAAA"}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
import { KeywordCxt } from "../../ajv";
|
||||||
|
import type { CodeKeywordDefinition } from "../../types";
|
||||||
|
declare const def: CodeKeywordDefinition;
|
||||||
|
export declare function checkMetadata({ it, keyword }: KeywordCxt, metadata?: boolean): void;
|
||||||
|
export default def;
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.checkMetadata = void 0;
|
||||||
|
const util_1 = require("../../compile/util");
|
||||||
|
const def = {
|
||||||
|
keyword: "metadata",
|
||||||
|
schemaType: "object",
|
||||||
|
code(cxt) {
|
||||||
|
checkMetadata(cxt);
|
||||||
|
const { gen, schema, it } = cxt;
|
||||||
|
if ((0, util_1.alwaysValidSchema)(it, schema))
|
||||||
|
return;
|
||||||
|
const valid = gen.name("valid");
|
||||||
|
cxt.subschema({ keyword: "metadata", jtdMetadata: true }, valid);
|
||||||
|
cxt.ok(valid);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
function checkMetadata({ it, keyword }, metadata) {
|
||||||
|
if (it.jtdMetadata !== metadata) {
|
||||||
|
throw new Error(`JTD: "${keyword}" cannot be used in this schema location`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.checkMetadata = checkMetadata;
|
||||||
|
exports.default = def;
|
||||||
|
//# sourceMappingURL=metadata.js.map
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../../lib/vocabularies/jtd/metadata.ts"],"names":[],"mappings":";;;AAEA,6CAAoD;AAEpD,MAAM,GAAG,GAA0B;IACjC,OAAO,EAAE,UAAU;IACnB,UAAU,EAAE,QAAQ;IACpB,IAAI,CAAC,GAAe;QAClB,aAAa,CAAC,GAAG,CAAC,CAAA;QAClB,MAAM,EAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAC,GAAG,GAAG,CAAA;QAC7B,IAAI,IAAA,wBAAiB,EAAC,EAAE,EAAE,MAAM,CAAC;YAAE,OAAM;QACzC,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC/B,GAAG,CAAC,SAAS,CAAC,EAAC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,IAAI,EAAC,EAAE,KAAK,CAAC,CAAA;QAC9D,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,CAAA;IACf,CAAC;CACF,CAAA;AAED,SAAgB,aAAa,CAAC,EAAC,EAAE,EAAE,OAAO,EAAa,EAAE,QAAkB;IACzE,IAAI,EAAE,CAAC,WAAW,KAAK,QAAQ,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,SAAS,OAAO,0CAA0C,CAAC,CAAA;IAC7E,CAAC;AACH,CAAC;AAJD,sCAIC;AAED,kBAAe,GAAG,CAAA"}
|
||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
import type { KeywordCxt } from "../../compile/validate";
|
||||||
|
import { Code, Name } from "../../compile/codegen";
|
||||||
|
export declare function checkNullable({ gen, data, parentSchema }: KeywordCxt, cond?: Code): [Name, Code];
|
||||||
|
export declare function checkNullableObject(cxt: KeywordCxt, cond: Code): [Name, Code];
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.checkNullableObject = exports.checkNullable = void 0;
|
||||||
|
const codegen_1 = require("../../compile/codegen");
|
||||||
|
function checkNullable({ gen, data, parentSchema }, cond = codegen_1.nil) {
|
||||||
|
const valid = gen.name("valid");
|
||||||
|
if (parentSchema.nullable) {
|
||||||
|
gen.let(valid, (0, codegen_1._) `${data} === null`);
|
||||||
|
cond = (0, codegen_1.not)(valid);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
gen.let(valid, false);
|
||||||
|
}
|
||||||
|
return [valid, cond];
|
||||||
|
}
|
||||||
|
exports.checkNullable = checkNullable;
|
||||||
|
function checkNullableObject(cxt, cond) {
|
||||||
|
const [valid, cond_] = checkNullable(cxt, cond);
|
||||||
|
return [valid, (0, codegen_1._) `${cond_} && typeof ${cxt.data} == "object" && !Array.isArray(${cxt.data})`];
|
||||||
|
}
|
||||||
|
exports.checkNullableObject = checkNullableObject;
|
||||||
|
//# sourceMappingURL=nullable.js.map
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"nullable.js","sourceRoot":"","sources":["../../../lib/vocabularies/jtd/nullable.ts"],"names":[],"mappings":";;;AACA,mDAA6D;AAE7D,SAAgB,aAAa,CAC3B,EAAC,GAAG,EAAE,IAAI,EAAE,YAAY,EAAa,EACrC,OAAa,aAAG;IAEhB,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAC/B,IAAI,YAAY,CAAC,QAAQ,EAAE,CAAC;QAC1B,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,IAAA,WAAC,EAAA,GAAG,IAAI,WAAW,CAAC,CAAA;QACnC,IAAI,GAAG,IAAA,aAAG,EAAC,KAAK,CAAC,CAAA;IACnB,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;IACvB,CAAC;IACD,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;AACtB,CAAC;AAZD,sCAYC;AAED,SAAgB,mBAAmB,CAAC,GAAe,EAAE,IAAU;IAC7D,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IAC/C,OAAO,CAAC,KAAK,EAAE,IAAA,WAAC,EAAA,GAAG,KAAK,cAAc,GAAG,CAAC,IAAI,kCAAkC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAA;AAC9F,CAAC;AAHD,kDAGC"}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
import type { CodeKeywordDefinition } from "../../types";
|
||||||
|
declare const def: CodeKeywordDefinition;
|
||||||
|
export default def;
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const properties_1 = require("./properties");
|
||||||
|
const def = {
|
||||||
|
keyword: "optionalProperties",
|
||||||
|
schemaType: "object",
|
||||||
|
error: properties_1.error,
|
||||||
|
code(cxt) {
|
||||||
|
if (cxt.parentSchema.properties)
|
||||||
|
return;
|
||||||
|
(0, properties_1.validateProperties)(cxt);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
exports.default = def;
|
||||||
|
//# sourceMappingURL=optionalProperties.js.map
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"optionalProperties.js","sourceRoot":"","sources":["../../../lib/vocabularies/jtd/optionalProperties.ts"],"names":[],"mappings":";;AAEA,6CAAsD;AAEtD,MAAM,GAAG,GAA0B;IACjC,OAAO,EAAE,oBAAoB;IAC7B,UAAU,EAAE,QAAQ;IACpB,KAAK,EAAL,kBAAK;IACL,IAAI,CAAC,GAAe;QAClB,IAAI,GAAG,CAAC,YAAY,CAAC,UAAU;YAAE,OAAM;QACvC,IAAA,+BAAkB,EAAC,GAAG,CAAC,CAAA;IACzB,CAAC;CACF,CAAA;AAED,kBAAe,GAAG,CAAA"}
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
import type { CodeKeywordDefinition, ErrorObject, KeywordErrorDefinition, SchemaObject } from "../../types";
|
||||||
|
import type { KeywordCxt } from "../../compile/validate";
|
||||||
|
import { _JTDTypeError } from "./error";
|
||||||
|
declare enum PropError {
|
||||||
|
Additional = "additional",
|
||||||
|
Missing = "missing"
|
||||||
|
}
|
||||||
|
type PropKeyword = "properties" | "optionalProperties";
|
||||||
|
type PropSchema = {
|
||||||
|
[P in string]?: SchemaObject;
|
||||||
|
};
|
||||||
|
export type JTDPropertiesError = _JTDTypeError<PropKeyword, "object", PropSchema> | ErrorObject<PropKeyword, {
|
||||||
|
error: PropError.Additional;
|
||||||
|
additionalProperty: string;
|
||||||
|
}, PropSchema> | ErrorObject<PropKeyword, {
|
||||||
|
error: PropError.Missing;
|
||||||
|
missingProperty: string;
|
||||||
|
}, PropSchema>;
|
||||||
|
export declare const error: KeywordErrorDefinition;
|
||||||
|
declare const def: CodeKeywordDefinition;
|
||||||
|
export declare function validateProperties(cxt: KeywordCxt): void;
|
||||||
|
export default def;
|
||||||
+149
@@ -0,0 +1,149 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.validateProperties = exports.error = void 0;
|
||||||
|
const code_1 = require("../code");
|
||||||
|
const util_1 = require("../../compile/util");
|
||||||
|
const codegen_1 = require("../../compile/codegen");
|
||||||
|
const metadata_1 = require("./metadata");
|
||||||
|
const nullable_1 = require("./nullable");
|
||||||
|
const error_1 = require("./error");
|
||||||
|
var PropError;
|
||||||
|
(function (PropError) {
|
||||||
|
PropError["Additional"] = "additional";
|
||||||
|
PropError["Missing"] = "missing";
|
||||||
|
})(PropError || (PropError = {}));
|
||||||
|
exports.error = {
|
||||||
|
message: (cxt) => {
|
||||||
|
const { params } = cxt;
|
||||||
|
return params.propError
|
||||||
|
? params.propError === PropError.Additional
|
||||||
|
? "must NOT have additional properties"
|
||||||
|
: `must have property '${params.missingProperty}'`
|
||||||
|
: (0, error_1.typeErrorMessage)(cxt, "object");
|
||||||
|
},
|
||||||
|
params: (cxt) => {
|
||||||
|
const { params } = cxt;
|
||||||
|
return params.propError
|
||||||
|
? params.propError === PropError.Additional
|
||||||
|
? (0, codegen_1._) `{error: ${params.propError}, additionalProperty: ${params.additionalProperty}}`
|
||||||
|
: (0, codegen_1._) `{error: ${params.propError}, missingProperty: ${params.missingProperty}}`
|
||||||
|
: (0, error_1.typeErrorParams)(cxt, "object");
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const def = {
|
||||||
|
keyword: "properties",
|
||||||
|
schemaType: "object",
|
||||||
|
error: exports.error,
|
||||||
|
code: validateProperties,
|
||||||
|
};
|
||||||
|
// const error: KeywordErrorDefinition = {
|
||||||
|
// message: "should NOT have additional properties",
|
||||||
|
// params: ({params}) => _`{additionalProperty: ${params.additionalProperty}}`,
|
||||||
|
// }
|
||||||
|
function validateProperties(cxt) {
|
||||||
|
(0, metadata_1.checkMetadata)(cxt);
|
||||||
|
const { gen, data, parentSchema, it } = cxt;
|
||||||
|
const { additionalProperties, nullable } = parentSchema;
|
||||||
|
if (it.jtdDiscriminator && nullable)
|
||||||
|
throw new Error("JTD: nullable inside discriminator mapping");
|
||||||
|
if (commonProperties()) {
|
||||||
|
throw new Error("JTD: properties and optionalProperties have common members");
|
||||||
|
}
|
||||||
|
const [allProps, properties] = schemaProperties("properties");
|
||||||
|
const [allOptProps, optProperties] = schemaProperties("optionalProperties");
|
||||||
|
if (properties.length === 0 && optProperties.length === 0 && additionalProperties) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const [valid, cond] = it.jtdDiscriminator === undefined
|
||||||
|
? (0, nullable_1.checkNullableObject)(cxt, data)
|
||||||
|
: [gen.let("valid", false), true];
|
||||||
|
gen.if(cond, () => gen.assign(valid, true).block(() => {
|
||||||
|
validateProps(properties, "properties", true);
|
||||||
|
validateProps(optProperties, "optionalProperties");
|
||||||
|
if (!additionalProperties)
|
||||||
|
validateAdditional();
|
||||||
|
}));
|
||||||
|
cxt.pass(valid);
|
||||||
|
function commonProperties() {
|
||||||
|
const props = parentSchema.properties;
|
||||||
|
const optProps = parentSchema.optionalProperties;
|
||||||
|
if (!(props && optProps))
|
||||||
|
return false;
|
||||||
|
for (const p in props) {
|
||||||
|
if (Object.prototype.hasOwnProperty.call(optProps, p))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
function schemaProperties(keyword) {
|
||||||
|
const schema = parentSchema[keyword];
|
||||||
|
const allPs = schema ? (0, code_1.allSchemaProperties)(schema) : [];
|
||||||
|
if (it.jtdDiscriminator && allPs.some((p) => p === it.jtdDiscriminator)) {
|
||||||
|
throw new Error(`JTD: discriminator tag used in ${keyword}`);
|
||||||
|
}
|
||||||
|
const ps = allPs.filter((p) => !(0, util_1.alwaysValidSchema)(it, schema[p]));
|
||||||
|
return [allPs, ps];
|
||||||
|
}
|
||||||
|
function validateProps(props, keyword, required) {
|
||||||
|
const _valid = gen.var("valid");
|
||||||
|
for (const prop of props) {
|
||||||
|
gen.if((0, code_1.propertyInData)(gen, data, prop, it.opts.ownProperties), () => applyPropertySchema(prop, keyword, _valid), () => missingProperty(prop));
|
||||||
|
cxt.ok(_valid);
|
||||||
|
}
|
||||||
|
function missingProperty(prop) {
|
||||||
|
if (required) {
|
||||||
|
gen.assign(_valid, false);
|
||||||
|
cxt.error(false, { propError: PropError.Missing, missingProperty: prop }, { schemaPath: prop });
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
gen.assign(_valid, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function applyPropertySchema(prop, keyword, _valid) {
|
||||||
|
cxt.subschema({
|
||||||
|
keyword,
|
||||||
|
schemaProp: prop,
|
||||||
|
dataProp: prop,
|
||||||
|
}, _valid);
|
||||||
|
}
|
||||||
|
function validateAdditional() {
|
||||||
|
gen.forIn("key", data, (key) => {
|
||||||
|
const addProp = isAdditional(key, allProps, "properties", it.jtdDiscriminator);
|
||||||
|
const addOptProp = isAdditional(key, allOptProps, "optionalProperties");
|
||||||
|
const extra = addProp === true ? addOptProp : addOptProp === true ? addProp : (0, codegen_1.and)(addProp, addOptProp);
|
||||||
|
gen.if(extra, () => {
|
||||||
|
if (it.opts.removeAdditional) {
|
||||||
|
gen.code((0, codegen_1._) `delete ${data}[${key}]`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cxt.error(false, { propError: PropError.Additional, additionalProperty: key }, { instancePath: key, parentSchema: true });
|
||||||
|
if (!it.opts.allErrors)
|
||||||
|
gen.break();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function isAdditional(key, props, keyword, jtdDiscriminator) {
|
||||||
|
let additional;
|
||||||
|
if (props.length > 8) {
|
||||||
|
// TODO maybe an option instead of hard-coded 8?
|
||||||
|
const propsSchema = (0, util_1.schemaRefOrVal)(it, parentSchema[keyword], keyword);
|
||||||
|
additional = (0, codegen_1.not)((0, code_1.isOwnProperty)(gen, propsSchema, key));
|
||||||
|
if (jtdDiscriminator !== undefined) {
|
||||||
|
additional = (0, codegen_1.and)(additional, (0, codegen_1._) `${key} !== ${jtdDiscriminator}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (props.length || jtdDiscriminator !== undefined) {
|
||||||
|
const ps = jtdDiscriminator === undefined ? props : [jtdDiscriminator].concat(props);
|
||||||
|
additional = (0, codegen_1.and)(...ps.map((p) => (0, codegen_1._) `${key} !== ${p}`));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
additional = true;
|
||||||
|
}
|
||||||
|
return additional;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.validateProperties = validateProperties;
|
||||||
|
exports.default = def;
|
||||||
|
//# sourceMappingURL=properties.js.map
|
||||||
+1
File diff suppressed because one or more lines are too long
+4
@@ -0,0 +1,4 @@
|
|||||||
|
import type { CodeKeywordDefinition, AnySchemaObject } from "../../types";
|
||||||
|
declare const def: CodeKeywordDefinition;
|
||||||
|
export declare function hasRef(schema: AnySchemaObject): boolean;
|
||||||
|
export default def;
|
||||||
+67
@@ -0,0 +1,67 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.hasRef = void 0;
|
||||||
|
const compile_1 = require("../../compile");
|
||||||
|
const codegen_1 = require("../../compile/codegen");
|
||||||
|
const ref_error_1 = require("../../compile/ref_error");
|
||||||
|
const names_1 = require("../../compile/names");
|
||||||
|
const ref_1 = require("../core/ref");
|
||||||
|
const metadata_1 = require("./metadata");
|
||||||
|
const def = {
|
||||||
|
keyword: "ref",
|
||||||
|
schemaType: "string",
|
||||||
|
code(cxt) {
|
||||||
|
(0, metadata_1.checkMetadata)(cxt);
|
||||||
|
const { gen, data, schema: ref, parentSchema, it } = cxt;
|
||||||
|
const { schemaEnv: { root }, } = it;
|
||||||
|
const valid = gen.name("valid");
|
||||||
|
if (parentSchema.nullable) {
|
||||||
|
gen.var(valid, (0, codegen_1._) `${data} === null`);
|
||||||
|
gen.if((0, codegen_1.not)(valid), validateJtdRef);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
gen.var(valid, false);
|
||||||
|
validateJtdRef();
|
||||||
|
}
|
||||||
|
cxt.ok(valid);
|
||||||
|
function validateJtdRef() {
|
||||||
|
var _a;
|
||||||
|
const refSchema = (_a = root.schema.definitions) === null || _a === void 0 ? void 0 : _a[ref];
|
||||||
|
if (!refSchema) {
|
||||||
|
throw new ref_error_1.default(it.opts.uriResolver, "", ref, `No definition ${ref}`);
|
||||||
|
}
|
||||||
|
if (hasRef(refSchema) || !it.opts.inlineRefs)
|
||||||
|
callValidate(refSchema);
|
||||||
|
else
|
||||||
|
inlineRefSchema(refSchema);
|
||||||
|
}
|
||||||
|
function callValidate(schema) {
|
||||||
|
const sch = compile_1.compileSchema.call(it.self, new compile_1.SchemaEnv({ schema, root, schemaPath: `/definitions/${ref}` }));
|
||||||
|
const v = (0, ref_1.getValidate)(cxt, sch);
|
||||||
|
const errsCount = gen.const("_errs", names_1.default.errors);
|
||||||
|
(0, ref_1.callRef)(cxt, v, sch, sch.$async);
|
||||||
|
gen.assign(valid, (0, codegen_1._) `${errsCount} === ${names_1.default.errors}`);
|
||||||
|
}
|
||||||
|
function inlineRefSchema(schema) {
|
||||||
|
const schName = gen.scopeValue("schema", it.opts.code.source === true ? { ref: schema, code: (0, codegen_1.stringify)(schema) } : { ref: schema });
|
||||||
|
cxt.subschema({
|
||||||
|
schema,
|
||||||
|
dataTypes: [],
|
||||||
|
schemaPath: codegen_1.nil,
|
||||||
|
topSchemaRef: schName,
|
||||||
|
errSchemaPath: `/definitions/${ref}`,
|
||||||
|
}, valid);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
function hasRef(schema) {
|
||||||
|
for (const key in schema) {
|
||||||
|
let sch;
|
||||||
|
if (key === "ref" || (typeof (sch = schema[key]) == "object" && hasRef(sch)))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
exports.hasRef = hasRef;
|
||||||
|
exports.default = def;
|
||||||
|
//# sourceMappingURL=ref.js.map
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"ref.js","sourceRoot":"","sources":["../../../lib/vocabularies/jtd/ref.ts"],"names":[],"mappings":";;;AAEA,2CAAsD;AACtD,mDAA4D;AAC5D,uDAAqD;AACrD,+CAAmC;AACnC,qCAAgD;AAChD,yCAAwC;AAExC,MAAM,GAAG,GAA0B;IACjC,OAAO,EAAE,KAAK;IACd,UAAU,EAAE,QAAQ;IACpB,IAAI,CAAC,GAAe;QAClB,IAAA,wBAAa,EAAC,GAAG,CAAC,CAAA;QAClB,MAAM,EAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,EAAE,EAAC,GAAG,GAAG,CAAA;QACtD,MAAM,EACJ,SAAS,EAAE,EAAC,IAAI,EAAC,GAClB,GAAG,EAAE,CAAA;QACN,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC/B,IAAI,YAAY,CAAC,QAAQ,EAAE,CAAC;YAC1B,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,IAAA,WAAC,EAAA,GAAG,IAAI,WAAW,CAAC,CAAA;YACnC,GAAG,CAAC,EAAE,CAAC,IAAA,aAAG,EAAC,KAAK,CAAC,EAAE,cAAc,CAAC,CAAA;QACpC,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;YACrB,cAAc,EAAE,CAAA;QAClB,CAAC;QACD,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,CAAA;QAEb,SAAS,cAAc;;YACrB,MAAM,SAAS,GAAG,MAAC,IAAI,CAAC,MAA0B,CAAC,WAAW,0CAAG,GAAG,CAAC,CAAA;YACrE,IAAI,CAAC,SAAS,EAAE,CAAC;gBACf,MAAM,IAAI,mBAAe,CAAC,EAAE,CA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U,EAAE,aAAG;gBACf,YAAY,EAAE,OAAO;gBACrB,aAAa,EAAE,gBAAgB,GAAG,EAAE;aACrC,EACD,KAAK,CACN,CAAA;QACH,CAAC;IACH,CAAC;CACF,CAAA;AAED,SAAgB,MAAM,CAAC,MAAuB;IAC5C,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QACzB,IAAI,GAAoB,CAAA;QACxB,IAAI,GAAG,KAAK,KAAK,IAAI,CAAC,OAAO,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,QAAQ,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC;YAAE,OAAO,IAAI,CAAA;IAC3F,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAND,wBAMC;AAED,kBAAe,GAAG,CAAA"}
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
import type { CodeKeywordDefinition } from "../../types";
|
||||||
|
import { _JTDTypeError } from "./error";
|
||||||
|
export type JTDTypeError = _JTDTypeError<"type", JTDType, JTDType>;
|
||||||
|
export type IntType = "int8" | "uint8" | "int16" | "uint16" | "int32" | "uint32";
|
||||||
|
export declare const intRange: {
|
||||||
|
[T in IntType]: [number, number, number];
|
||||||
|
};
|
||||||
|
export type JTDType = "boolean" | "string" | "timestamp" | "float32" | "float64" | IntType;
|
||||||
|
declare const def: CodeKeywordDefinition;
|
||||||
|
export default def;
|
||||||
+69
@@ -0,0 +1,69 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.intRange = void 0;
|
||||||
|
const codegen_1 = require("../../compile/codegen");
|
||||||
|
const timestamp_1 = require("../../runtime/timestamp");
|
||||||
|
const util_1 = require("../../compile/util");
|
||||||
|
const metadata_1 = require("./metadata");
|
||||||
|
const error_1 = require("./error");
|
||||||
|
exports.intRange = {
|
||||||
|
int8: [-128, 127, 3],
|
||||||
|
uint8: [0, 255, 3],
|
||||||
|
int16: [-32768, 32767, 5],
|
||||||
|
uint16: [0, 65535, 5],
|
||||||
|
int32: [-2147483648, 2147483647, 10],
|
||||||
|
uint32: [0, 4294967295, 10],
|
||||||
|
};
|
||||||
|
const error = {
|
||||||
|
message: (cxt) => (0, error_1.typeErrorMessage)(cxt, cxt.schema),
|
||||||
|
params: (cxt) => (0, error_1.typeErrorParams)(cxt, cxt.schema),
|
||||||
|
};
|
||||||
|
function timestampCode(cxt) {
|
||||||
|
const { gen, data, it } = cxt;
|
||||||
|
const { timestamp, allowDate } = it.opts;
|
||||||
|
if (timestamp === "date")
|
||||||
|
return (0, codegen_1._) `${data} instanceof Date `;
|
||||||
|
const vts = (0, util_1.useFunc)(gen, timestamp_1.default);
|
||||||
|
const allowDateArg = allowDate ? (0, codegen_1._) `, true` : codegen_1.nil;
|
||||||
|
const validString = (0, codegen_1._) `typeof ${data} == "string" && ${vts}(${data}${allowDateArg})`;
|
||||||
|
return timestamp === "string" ? validString : (0, codegen_1.or)((0, codegen_1._) `${data} instanceof Date`, validString);
|
||||||
|
}
|
||||||
|
const def = {
|
||||||
|
keyword: "type",
|
||||||
|
schemaType: "string",
|
||||||
|
error,
|
||||||
|
code(cxt) {
|
||||||
|
(0, metadata_1.checkMetadata)(cxt);
|
||||||
|
const { data, schema, parentSchema, it } = cxt;
|
||||||
|
let cond;
|
||||||
|
switch (schema) {
|
||||||
|
case "boolean":
|
||||||
|
case "string":
|
||||||
|
cond = (0, codegen_1._) `typeof ${data} == ${schema}`;
|
||||||
|
break;
|
||||||
|
case "timestamp": {
|
||||||
|
cond = timestampCode(cxt);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "float32":
|
||||||
|
case "float64":
|
||||||
|
cond = (0, codegen_1._) `typeof ${data} == "number"`;
|
||||||
|
break;
|
||||||
|
default: {
|
||||||
|
const sch = schema;
|
||||||
|
cond = (0, codegen_1._) `typeof ${data} == "number" && isFinite(${data}) && !(${data} % 1)`;
|
||||||
|
if (!it.opts.int32range && (sch === "int32" || sch === "uint32")) {
|
||||||
|
if (sch === "uint32")
|
||||||
|
cond = (0, codegen_1._) `${cond} && ${data} >= 0`;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const [min, max] = exports.intRange[sch];
|
||||||
|
cond = (0, codegen_1._) `${cond} && ${data} >= ${min} && ${data} <= ${max}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cxt.pass(parentSchema.nullable ? (0, codegen_1.or)((0, codegen_1._) `${data} === null`, cond) : cond);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
exports.default = def;
|
||||||
|
//# sourceMappingURL=type.js.map
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../../lib/vocabularies/jtd/type.ts"],"names":[],"mappings":";;;AAEA,mDAAsD;AACtD,uDAAoD;AACpD,6CAA0C;AAC1C,yCAAwC;AACxC,mCAAwE;AAM3D,QAAA,QAAQ,GAA+C;IAClE,IAAI,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;IACpB,KAAK,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;IAClB,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACzB,MAAM,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IACrB,KAAK,EAAE,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,EAAE,CAAC;IACpC,MAAM,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,CAAC;CAC5B,CAAA;AAID,MAAM,KAAK,GAA2B;IACpC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAA,wBAAgB,EAAC,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC;IACnD,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAA,uBAAe,EAAC,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC;CAClD,CAAA;AAED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YACD,KAAK,SAAS,CAAC;YACf,KAAK,SAAS;gBACZ,IAAI,GAAG,IAAA,WAAC,EAAA,UAAU,IAAI,cAAc,CAAA;gBACpC,MAAK;YACP,OAAO,CAAC,CAAC,CAAC;gBACR,MAAM,GAAG,GAAG,MAAiB,CAAA;gBAC7B,IAAI,GAAG,IAAA,WAAC,EAAA,UAAU,IAAI,4BAA4B,IAAI,UAAU,IAAI,OAAO,CAAA;gBAC3E,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,GAAG,KAAK,OAAO,IAAI,GAAG,KAAK,QAAQ,CAAC,EAAE,CAAC;oBACjE,IAAI,GAAG,KAAK,QAAQ;wBAAE,IAAI,GAAG,IAAA,WAAC,EAAA,GAAG,IAAI,OAAO,IAAI,OAAO,CAAA;gBACzD,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,gBAAQ,CAAC,GAAG,CAAC,CAAA;oBAChC,IAAI,GAAG,IAAA,WAAC,EAAA,GAAG,IAAI,OAAO,IAAI,OAAO,GAAG,OAAO,IAAI,OAAO,GAAG,EAAE,CAAA;gBAC7D,CAAC;YACH,CAAC;QACH,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAA,YAAE,EAAC,IAAA,WAAC,EAAA,GAAG,IAAI,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;IACxE,CAAC;CACF,CAAA;AAED,kBAAe,GAAG,CAAA"}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
import type { CodeKeywordDefinition } from "../../types";
|
||||||
|
declare const def: CodeKeywordDefinition;
|
||||||
|
export default def;
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const code_1 = require("../code");
|
||||||
|
const def = {
|
||||||
|
keyword: "union",
|
||||||
|
schemaType: "array",
|
||||||
|
trackErrors: true,
|
||||||
|
code: code_1.validateUnion,
|
||||||
|
error: { message: "must match a schema in union" },
|
||||||
|
};
|
||||||
|
exports.default = def;
|
||||||
|
//# sourceMappingURL=union.js.map
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"union.js","sourceRoot":"","sources":["../../../lib/vocabularies/jtd/union.ts"],"names":[],"mappings":";;AACA,kCAAqC;AAErC,MAAM,GAAG,GAA0B;IACjC,OAAO,EAAE,OAAO;IAChB,UAAU,EAAE,OAAO;IACnB,WAAW,EAAE,IAAI;IACjB,IAAI,EAAE,oBAAa;IACnB,KAAK,EAAE,EAAC,OAAO,EAAE,8BAA8B,EAAC;CACjD,CAAA;AAED,kBAAe,GAAG,CAAA"}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
import type { CodeKeywordDefinition, SchemaObject } from "../../types";
|
||||||
|
import { _JTDTypeError } from "./error";
|
||||||
|
export type JTDValuesError = _JTDTypeError<"values", "object", SchemaObject>;
|
||||||
|
declare const def: CodeKeywordDefinition;
|
||||||
|
export default def;
|
||||||
+51
@@ -0,0 +1,51 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const util_1 = require("../../compile/util");
|
||||||
|
const codegen_1 = require("../../compile/codegen");
|
||||||
|
const metadata_1 = require("./metadata");
|
||||||
|
const nullable_1 = require("./nullable");
|
||||||
|
const error_1 = require("./error");
|
||||||
|
const def = {
|
||||||
|
keyword: "values",
|
||||||
|
schemaType: "object",
|
||||||
|
error: (0, error_1.typeError)("object"),
|
||||||
|
code(cxt) {
|
||||||
|
(0, metadata_1.checkMetadata)(cxt);
|
||||||
|
const { gen, data, schema, it } = cxt;
|
||||||
|
const [valid, cond] = (0, nullable_1.checkNullableObject)(cxt, data);
|
||||||
|
if ((0, util_1.alwaysValidSchema)(it, schema)) {
|
||||||
|
gen.if((0, codegen_1.not)((0, codegen_1.or)(cond, valid)), () => cxt.error());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
gen.if(cond);
|
||||||
|
gen.assign(valid, validateMap());
|
||||||
|
gen.elseIf((0, codegen_1.not)(valid));
|
||||||
|
cxt.error();
|
||||||
|
gen.endIf();
|
||||||
|
}
|
||||||
|
cxt.ok(valid);
|
||||||
|
function validateMap() {
|
||||||
|
const _valid = gen.name("valid");
|
||||||
|
if (it.allErrors) {
|
||||||
|
const validMap = gen.let("valid", true);
|
||||||
|
validateValues(() => gen.assign(validMap, false));
|
||||||
|
return validMap;
|
||||||
|
}
|
||||||
|
gen.var(_valid, true);
|
||||||
|
validateValues(() => gen.break());
|
||||||
|
return _valid;
|
||||||
|
function validateValues(notValid) {
|
||||||
|
gen.forIn("key", data, (key) => {
|
||||||
|
cxt.subschema({
|
||||||
|
keyword: "values",
|
||||||
|
dataProp: key,
|
||||||
|
dataPropType: util_1.Type.Str,
|
||||||
|
}, _valid);
|
||||||
|
gen.if((0, codegen_1.not)(_valid), notValid);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
exports.default = def;
|
||||||
|
//# sourceMappingURL=values.js.map
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"values.js","sourceRoot":"","sources":["../../../lib/vocabularies/jtd/values.ts"],"names":[],"mappings":";;AAEA,6CAA0D;AAC1D,mDAAmD;AACnD,yCAAwC;AACxC,yCAA8C;AAC9C,mCAAgD;AAIhD,MAAM,GAAG,GAA0B;IACjC,OAAO,EAAE,QAAQ;IACjB,UAAU,EAAE,QAAQ;IACpB,KAAK,EAAE,IAAA,iBAAS,EAAC,QAAQ,CAAC;IAC1B,IAAI,CAAC,GAAe;QAClB,IAAA,wBAAa,EAAC,GAAG,CAAC,CAAA;QAClB,MAAM,EAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAC,GAAG,GAAG,CAAA;QACnC,MAAM,CAAC,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AAC,GAAG,EAAE,EAAE;oBAC7B,GAAG,CAAC,SAAS,CACX;wBACE,OAAO,EAAE,QAAQ;wBACjB,QAAQ,EAAE,GAAG;wBACb,YAAY,EAAE,WAAI,CAAC,GAAG;qBACvB,EACD,MAAM,CACP,CAAA;oBACD,GAAG,CAAC,EAAE,CAAC,IAAA,aAAG,EAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAA;gBAC/B,CAAC,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAA;AAED,kBAAe,GAAG,CAAA"}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
import type { Vocabulary } from "../types";
|
||||||
|
export declare const metadataVocabulary: Vocabulary;
|
||||||
|
export declare const contentVocabulary: Vocabulary;
|
||||||
+18
@@ -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
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../lib/vocabularies/metadata.ts"],"names":[],"mappings":";;;AAEa,QAAA,kBAAkB,GAAe;IAC5C,OAAO;IACP,aAAa;IACb,SAAS;IACT,YAAY;IACZ,UAAU;IACV,WAAW;IACX,UAAU;CACX,CAAA;AAEY,QAAA,iBAAiB,GAAe;IAC3C,kBAAkB;IAClB,iBAAiB;IACjB,eAAe;CAChB,CAAA"}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
import type { Vocabulary } from "../types";
|
||||||
|
declare const next: Vocabulary;
|
||||||
|
export default next;
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const dependentRequired_1 = require("./validation/dependentRequired");
|
||||||
|
const dependentSchemas_1 = require("./applicator/dependentSchemas");
|
||||||
|
const limitContains_1 = require("./validation/limitContains");
|
||||||
|
const next = [dependentRequired_1.default, dependentSchemas_1.default, limitContains_1.default];
|
||||||
|
exports.default = next;
|
||||||
|
//# sourceMappingURL=next.js.map
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"next.js","sourceRoot":"","sources":["../../lib/vocabularies/next.ts"],"names":[],"mappings":";;AACA,sEAA8D;AAC9D,oEAA4D;AAC5D,8DAAsD;AAEtD,MAAM,IAAI,GAAe,CAAC,2BAAiB,EAAE,0BAAgB,EAAE,uBAAa,CAAC,CAAA;AAE7E,kBAAe,IAAI,CAAA"}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
import type { Vocabulary } from "../../types";
|
||||||
|
declare const unevaluated: Vocabulary;
|
||||||
|
export default unevaluated;
|
||||||
Reference in New Issue
Block a user