[6a3a178] | 1 | "use strict";
|
---|
| 2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
| 3 | exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = void 0;
|
---|
| 4 | const core_1 = require("./core");
|
---|
| 5 | const jtd_1 = require("./vocabularies/jtd");
|
---|
| 6 | const jtd_schema_1 = require("./refs/jtd-schema");
|
---|
| 7 | const serialize_1 = require("./compile/jtd/serialize");
|
---|
| 8 | const parse_1 = require("./compile/jtd/parse");
|
---|
| 9 | const META_SCHEMA_ID = "JTD-meta-schema";
|
---|
| 10 | class Ajv extends core_1.default {
|
---|
| 11 | constructor(opts = {}) {
|
---|
| 12 | super({
|
---|
| 13 | ...opts,
|
---|
| 14 | jtd: true,
|
---|
| 15 | });
|
---|
| 16 | }
|
---|
| 17 | _addVocabularies() {
|
---|
| 18 | super._addVocabularies();
|
---|
| 19 | this.addVocabulary(jtd_1.default);
|
---|
| 20 | }
|
---|
| 21 | _addDefaultMetaSchema() {
|
---|
| 22 | super._addDefaultMetaSchema();
|
---|
| 23 | if (!this.opts.meta)
|
---|
| 24 | return;
|
---|
| 25 | this.addMetaSchema(jtd_schema_1.default, META_SCHEMA_ID, false);
|
---|
| 26 | }
|
---|
| 27 | defaultMeta() {
|
---|
| 28 | return (this.opts.defaultMeta =
|
---|
| 29 | super.defaultMeta() || (this.getSchema(META_SCHEMA_ID) ? META_SCHEMA_ID : undefined));
|
---|
| 30 | }
|
---|
| 31 | compileSerializer(schema) {
|
---|
| 32 | const sch = this._addSchema(schema);
|
---|
| 33 | return sch.serialize || this._compileSerializer(sch);
|
---|
| 34 | }
|
---|
| 35 | compileParser(schema) {
|
---|
| 36 | const sch = this._addSchema(schema);
|
---|
| 37 | return (sch.parse || this._compileParser(sch));
|
---|
| 38 | }
|
---|
| 39 | _compileSerializer(sch) {
|
---|
| 40 | serialize_1.default.call(this, sch, sch.schema.definitions || {});
|
---|
| 41 | /* istanbul ignore if */
|
---|
| 42 | if (!sch.serialize)
|
---|
| 43 | throw new Error("ajv implementation error");
|
---|
| 44 | return sch.serialize;
|
---|
| 45 | }
|
---|
| 46 | _compileParser(sch) {
|
---|
| 47 | parse_1.default.call(this, sch, sch.schema.definitions || {});
|
---|
| 48 | /* istanbul ignore if */
|
---|
| 49 | if (!sch.parse)
|
---|
| 50 | throw new Error("ajv implementation error");
|
---|
| 51 | return sch.parse;
|
---|
| 52 | }
|
---|
| 53 | }
|
---|
| 54 | module.exports = exports = Ajv;
|
---|
| 55 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
| 56 | exports.default = Ajv;
|
---|
| 57 | var validate_1 = require("./compile/validate");
|
---|
| 58 | Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function () { return validate_1.KeywordCxt; } });
|
---|
| 59 | var codegen_1 = require("./compile/codegen");
|
---|
| 60 | Object.defineProperty(exports, "_", { enumerable: true, get: function () { return codegen_1._; } });
|
---|
| 61 | Object.defineProperty(exports, "str", { enumerable: true, get: function () { return codegen_1.str; } });
|
---|
| 62 | Object.defineProperty(exports, "stringify", { enumerable: true, get: function () { return codegen_1.stringify; } });
|
---|
| 63 | Object.defineProperty(exports, "nil", { enumerable: true, get: function () { return codegen_1.nil; } });
|
---|
| 64 | Object.defineProperty(exports, "Name", { enumerable: true, get: function () { return codegen_1.Name; } });
|
---|
| 65 | Object.defineProperty(exports, "CodeGen", { enumerable: true, get: function () { return codegen_1.CodeGen; } });
|
---|
| 66 | //# sourceMappingURL=jtd.js.map |
---|