Updated the files.
This commit is contained in:
parent
1553e6b971
commit
753967d4f5
23418 changed files with 3784666 additions and 0 deletions
19
my-app/node_modules/ajv/dist/2019.d.ts
generated
vendored
Executable file
19
my-app/node_modules/ajv/dist/2019.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,19 @@
|
|||
import type { AnySchemaObject } from "./types";
|
||||
import AjvCore, { Options } from "./core";
|
||||
declare class Ajv2019 extends AjvCore {
|
||||
constructor(opts?: Options);
|
||||
_addVocabularies(): void;
|
||||
_addDefaultMetaSchema(): void;
|
||||
defaultMeta(): string | AnySchemaObject | undefined;
|
||||
}
|
||||
export default Ajv2019;
|
||||
export { Format, FormatDefinition, AsyncFormatDefinition, KeywordDefinition, KeywordErrorDefinition, CodeKeywordDefinition, MacroKeywordDefinition, FuncKeywordDefinition, Vocabulary, Schema, SchemaObject, AnySchemaObject, AsyncSchema, AnySchema, ValidateFunction, AsyncValidateFunction, ErrorObject, ErrorNoParams, } from "./types";
|
||||
export { Plugin, Options, CodeOptions, InstanceOptions, Logger, ErrorsTextOptions } from "./core";
|
||||
export { SchemaCxt, SchemaObjCxt } from "./compile";
|
||||
export { KeywordCxt } from "./compile/validate";
|
||||
export { DefinedError } from "./vocabularies/errors";
|
||||
export { JSONType } from "./compile/rules";
|
||||
export { JSONSchemaType } from "./types/json-schema";
|
||||
export { _, str, stringify, nil, Name, Code, CodeGen, CodeGenOptions } from "./compile/codegen";
|
||||
export { default as ValidationError } from "./runtime/validation_error";
|
||||
export { default as MissingRefError } from "./compile/ref_error";
|
59
my-app/node_modules/ajv/dist/2019.js
generated
vendored
Executable file
59
my-app/node_modules/ajv/dist/2019.js
generated
vendored
Executable file
|
@ -0,0 +1,59 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MissingRefError = exports.ValidationError = exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = void 0;
|
||||
const core_1 = require("./core");
|
||||
const draft7_1 = require("./vocabularies/draft7");
|
||||
const dynamic_1 = require("./vocabularies/dynamic");
|
||||
const next_1 = require("./vocabularies/next");
|
||||
const unevaluated_1 = require("./vocabularies/unevaluated");
|
||||
const discriminator_1 = require("./vocabularies/discriminator");
|
||||
const json_schema_2019_09_1 = require("./refs/json-schema-2019-09");
|
||||
const META_SCHEMA_ID = "https://json-schema.org/draft/2019-09/schema";
|
||||
class Ajv2019 extends core_1.default {
|
||||
constructor(opts = {}) {
|
||||
super({
|
||||
...opts,
|
||||
dynamicRef: true,
|
||||
next: true,
|
||||
unevaluated: true,
|
||||
});
|
||||
}
|
||||
_addVocabularies() {
|
||||
super._addVocabularies();
|
||||
this.addVocabulary(dynamic_1.default);
|
||||
draft7_1.default.forEach((v) => this.addVocabulary(v));
|
||||
this.addVocabulary(next_1.default);
|
||||
this.addVocabulary(unevaluated_1.default);
|
||||
if (this.opts.discriminator)
|
||||
this.addKeyword(discriminator_1.default);
|
||||
}
|
||||
_addDefaultMetaSchema() {
|
||||
super._addDefaultMetaSchema();
|
||||
const { $data, meta } = this.opts;
|
||||
if (!meta)
|
||||
return;
|
||||
json_schema_2019_09_1.default.call(this, $data);
|
||||
this.refs["http://json-schema.org/schema"] = META_SCHEMA_ID;
|
||||
}
|
||||
defaultMeta() {
|
||||
return (this.opts.defaultMeta =
|
||||
super.defaultMeta() || (this.getSchema(META_SCHEMA_ID) ? META_SCHEMA_ID : undefined));
|
||||
}
|
||||
}
|
||||
module.exports = exports = Ajv2019;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = Ajv2019;
|
||||
var validate_1 = require("./compile/validate");
|
||||
Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function () { return validate_1.KeywordCxt; } });
|
||||
var codegen_1 = require("./compile/codegen");
|
||||
Object.defineProperty(exports, "_", { enumerable: true, get: function () { return codegen_1._; } });
|
||||
Object.defineProperty(exports, "str", { enumerable: true, get: function () { return codegen_1.str; } });
|
||||
Object.defineProperty(exports, "stringify", { enumerable: true, get: function () { return codegen_1.stringify; } });
|
||||
Object.defineProperty(exports, "nil", { enumerable: true, get: function () { return codegen_1.nil; } });
|
||||
Object.defineProperty(exports, "Name", { enumerable: true, get: function () { return codegen_1.Name; } });
|
||||
Object.defineProperty(exports, "CodeGen", { enumerable: true, get: function () { return codegen_1.CodeGen; } });
|
||||
var validation_error_1 = require("./runtime/validation_error");
|
||||
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return validation_error_1.default; } });
|
||||
var ref_error_1 = require("./compile/ref_error");
|
||||
Object.defineProperty(exports, "MissingRefError", { enumerable: true, get: function () { return ref_error_1.default; } });
|
||||
//# sourceMappingURL=2019.js.map
|
1
my-app/node_modules/ajv/dist/2019.js.map
generated
vendored
Executable file
1
my-app/node_modules/ajv/dist/2019.js.map
generated
vendored
Executable file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"2019.js","sourceRoot":"","sources":["../lib/2019.ts"],"names":[],"mappings":";;;AACA,iCAAuC;AAEvC,kDAAsD;AACtD,oDAAsD;AACtD,8CAAgD;AAChD,4DAA8D;AAC9D,gEAAwD;AACxD,oEAA0D;AAE1D,MAAM,cAAc,GAAG,8CAA8C,CAAA;AAErE,MAAM,OAAQ,SAAQ,cAAO;IAC3B,YAAY,OAAgB,EAAE;QAC5B,KAAK,CAAC;YACJ,GAAG,IAAI;YACP,UAAU,EAAE,IAAI;YAChB,IAAI,EAAE,IAAI;YACV,WAAW,EAAE,IAAI;SAClB,CAAC,CAAA;IACJ,CAAC;IAED,gBAAgB;QACd,KAAK,CAAC,gBAAgB,EAAE,CAAA;QACxB,IAAI,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAA;QACrC,gBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAA;QACxD,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,CAAA;QAClC,IAAI,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAA;QACzC,IAAI,IAAI,CAAC,IAAI,CAAC,aAAa;YAAE,IAAI,CAAC,UAAU,CAAC,uBAAa,CAAC,CAAA;IAC7D,CAAC;IAED,qBAAqB;QACnB,KAAK,CAAC,qBAAqB,EAAE,CAAA;QAC7B,MAAM,EAAC,KAAK,EAAE,IAAI,EAAC,GAAG,IAAI,CAAC,IAAI,CAAA;QAC/B,IAAI,CAAC,IAAI;YAAE,OAAM;QACjB,6BAAiB,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;QACnC,IAAI,CAAC,IAAI,CAAC,+BAA+B,CAAC,GAAG,cAAc,CAAA;IAC7D,CAAC;IAED,WAAW;QACT,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW;YAC3B,KAAK,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAA;IACzF,CAAC;CACF;AAED,MAAM,CAAC,OAAO,GAAG,OAAO,GAAG,OAAO,CAAA;AAClC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAC,KAAK,EAAE,IAAI,EAAC,CAAC,CAAA;AAE3D,kBAAe,OAAO,CAAA;AAyBtB,+CAA6C;AAArC,sGAAA,UAAU,OAAA;AAIlB,6CAA6F;AAArF,4FAAA,CAAC,OAAA;AAAE,8FAAA,GAAG,OAAA;AAAE,oGAAA,SAAS,OAAA;AAAE,8FAAA,GAAG,OAAA;AAAE,+FAAA,IAAI,OAAA;AAAQ,kGAAA,OAAO,OAAA;AACnD,+DAAqE;AAA7D,mHAAA,OAAO,OAAmB;AAClC,iDAA8D;AAAtD,4GAAA,OAAO,OAAmB"}
|
19
my-app/node_modules/ajv/dist/2020.d.ts
generated
vendored
Executable file
19
my-app/node_modules/ajv/dist/2020.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,19 @@
|
|||
import type { AnySchemaObject } from "./types";
|
||||
import AjvCore, { Options } from "./core";
|
||||
declare class Ajv2020 extends AjvCore {
|
||||
constructor(opts?: Options);
|
||||
_addVocabularies(): void;
|
||||
_addDefaultMetaSchema(): void;
|
||||
defaultMeta(): string | AnySchemaObject | undefined;
|
||||
}
|
||||
export default Ajv2020;
|
||||
export { Format, FormatDefinition, AsyncFormatDefinition, KeywordDefinition, KeywordErrorDefinition, CodeKeywordDefinition, MacroKeywordDefinition, FuncKeywordDefinition, Vocabulary, Schema, SchemaObject, AnySchemaObject, AsyncSchema, AnySchema, ValidateFunction, AsyncValidateFunction, ErrorObject, ErrorNoParams, } from "./types";
|
||||
export { Plugin, Options, CodeOptions, InstanceOptions, Logger, ErrorsTextOptions } from "./core";
|
||||
export { SchemaCxt, SchemaObjCxt } from "./compile";
|
||||
export { KeywordCxt } from "./compile/validate";
|
||||
export { DefinedError } from "./vocabularies/errors";
|
||||
export { JSONType } from "./compile/rules";
|
||||
export { JSONSchemaType } from "./types/json-schema";
|
||||
export { _, str, stringify, nil, Name, Code, CodeGen, CodeGenOptions } from "./compile/codegen";
|
||||
export { default as ValidationError } from "./runtime/validation_error";
|
||||
export { default as MissingRefError } from "./compile/ref_error";
|
53
my-app/node_modules/ajv/dist/2020.js
generated
vendored
Executable file
53
my-app/node_modules/ajv/dist/2020.js
generated
vendored
Executable file
|
@ -0,0 +1,53 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MissingRefError = exports.ValidationError = exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = void 0;
|
||||
const core_1 = require("./core");
|
||||
const draft2020_1 = require("./vocabularies/draft2020");
|
||||
const discriminator_1 = require("./vocabularies/discriminator");
|
||||
const json_schema_2020_12_1 = require("./refs/json-schema-2020-12");
|
||||
const META_SCHEMA_ID = "https://json-schema.org/draft/2020-12/schema";
|
||||
class Ajv2020 extends core_1.default {
|
||||
constructor(opts = {}) {
|
||||
super({
|
||||
...opts,
|
||||
dynamicRef: true,
|
||||
next: true,
|
||||
unevaluated: true,
|
||||
});
|
||||
}
|
||||
_addVocabularies() {
|
||||
super._addVocabularies();
|
||||
draft2020_1.default.forEach((v) => this.addVocabulary(v));
|
||||
if (this.opts.discriminator)
|
||||
this.addKeyword(discriminator_1.default);
|
||||
}
|
||||
_addDefaultMetaSchema() {
|
||||
super._addDefaultMetaSchema();
|
||||
const { $data, meta } = this.opts;
|
||||
if (!meta)
|
||||
return;
|
||||
json_schema_2020_12_1.default.call(this, $data);
|
||||
this.refs["http://json-schema.org/schema"] = META_SCHEMA_ID;
|
||||
}
|
||||
defaultMeta() {
|
||||
return (this.opts.defaultMeta =
|
||||
super.defaultMeta() || (this.getSchema(META_SCHEMA_ID) ? META_SCHEMA_ID : undefined));
|
||||
}
|
||||
}
|
||||
module.exports = exports = Ajv2020;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = Ajv2020;
|
||||
var validate_1 = require("./compile/validate");
|
||||
Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function () { return validate_1.KeywordCxt; } });
|
||||
var codegen_1 = require("./compile/codegen");
|
||||
Object.defineProperty(exports, "_", { enumerable: true, get: function () { return codegen_1._; } });
|
||||
Object.defineProperty(exports, "str", { enumerable: true, get: function () { return codegen_1.str; } });
|
||||
Object.defineProperty(exports, "stringify", { enumerable: true, get: function () { return codegen_1.stringify; } });
|
||||
Object.defineProperty(exports, "nil", { enumerable: true, get: function () { return codegen_1.nil; } });
|
||||
Object.defineProperty(exports, "Name", { enumerable: true, get: function () { return codegen_1.Name; } });
|
||||
Object.defineProperty(exports, "CodeGen", { enumerable: true, get: function () { return codegen_1.CodeGen; } });
|
||||
var validation_error_1 = require("./runtime/validation_error");
|
||||
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return validation_error_1.default; } });
|
||||
var ref_error_1 = require("./compile/ref_error");
|
||||
Object.defineProperty(exports, "MissingRefError", { enumerable: true, get: function () { return ref_error_1.default; } });
|
||||
//# sourceMappingURL=2020.js.map
|
1
my-app/node_modules/ajv/dist/2020.js.map
generated
vendored
Executable file
1
my-app/node_modules/ajv/dist/2020.js.map
generated
vendored
Executable file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"2020.js","sourceRoot":"","sources":["../lib/2020.ts"],"names":[],"mappings":";;;AACA,iCAAuC;AAEvC,wDAA4D;AAC5D,gEAAwD;AACxD,oEAA0D;AAE1D,MAAM,cAAc,GAAG,8CAA8C,CAAA;AAErE,MAAM,OAAQ,SAAQ,cAAO;IAC3B,YAAY,OAAgB,EAAE;QAC5B,KAAK,CAAC;YACJ,GAAG,IAAI;YACP,UAAU,EAAE,IAAI;YAChB,IAAI,EAAE,IAAI;YACV,WAAW,EAAE,IAAI;SAClB,CAAC,CAAA;IACJ,CAAC;IAED,gBAAgB;QACd,KAAK,CAAC,gBAAgB,EAAE,CAAA;QACxB,mBAAqB,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAA;QAC3D,IAAI,IAAI,CAAC,IAAI,CAAC,aAAa;YAAE,IAAI,CAAC,UAAU,CAAC,uBAAa,CAAC,CAAA;IAC7D,CAAC;IAED,qBAAqB;QACnB,KAAK,CAAC,qBAAqB,EAAE,CAAA;QAC7B,MAAM,EAAC,KAAK,EAAE,IAAI,EAAC,GAAG,IAAI,CAAC,IAAI,CAAA;QAC/B,IAAI,CAAC,IAAI;YAAE,OAAM;QACjB,6BAAiB,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;QACnC,IAAI,CAAC,IAAI,CAAC,+BAA+B,CAAC,GAAG,cAAc,CAAA;IAC7D,CAAC;IAED,WAAW;QACT,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW;YAC3B,KAAK,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAA;IACzF,CAAC;CACF;AAED,MAAM,CAAC,OAAO,GAAG,OAAO,GAAG,OAAO,CAAA;AAClC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAC,KAAK,EAAE,IAAI,EAAC,CAAC,CAAA;AAE3D,kBAAe,OAAO,CAAA;AAyBtB,+CAA6C;AAArC,sGAAA,UAAU,OAAA;AAIlB,6CAA6F;AAArF,4FAAA,CAAC,OAAA;AAAE,8FAAA,GAAG,OAAA;AAAE,oGAAA,SAAS,OAAA;AAAE,8FAAA,GAAG,OAAA;AAAE,+FAAA,IAAI,OAAA;AAAQ,kGAAA,OAAO,OAAA;AACnD,+DAAqE;AAA7D,mHAAA,OAAO,OAAmB;AAClC,iDAA8D;AAAtD,4GAAA,OAAO,OAAmB"}
|
18
my-app/node_modules/ajv/dist/ajv.d.ts
generated
vendored
Executable file
18
my-app/node_modules/ajv/dist/ajv.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,18 @@
|
|||
import type { AnySchemaObject } from "./types";
|
||||
import AjvCore from "./core";
|
||||
declare class Ajv extends AjvCore {
|
||||
_addVocabularies(): void;
|
||||
_addDefaultMetaSchema(): void;
|
||||
defaultMeta(): string | AnySchemaObject | undefined;
|
||||
}
|
||||
export default Ajv;
|
||||
export { Format, FormatDefinition, AsyncFormatDefinition, KeywordDefinition, KeywordErrorDefinition, CodeKeywordDefinition, MacroKeywordDefinition, FuncKeywordDefinition, Vocabulary, Schema, SchemaObject, AnySchemaObject, AsyncSchema, AnySchema, ValidateFunction, AsyncValidateFunction, SchemaValidateFunction, ErrorObject, ErrorNoParams, } from "./types";
|
||||
export { Plugin, Options, CodeOptions, InstanceOptions, Logger, ErrorsTextOptions } from "./core";
|
||||
export { SchemaCxt, SchemaObjCxt } from "./compile";
|
||||
export { KeywordCxt } from "./compile/validate";
|
||||
export { DefinedError } from "./vocabularies/errors";
|
||||
export { JSONType } from "./compile/rules";
|
||||
export { JSONSchemaType } from "./types/json-schema";
|
||||
export { _, str, stringify, nil, Name, Code, CodeGen, CodeGenOptions } from "./compile/codegen";
|
||||
export { default as ValidationError } from "./runtime/validation_error";
|
||||
export { default as MissingRefError } from "./compile/ref_error";
|
48
my-app/node_modules/ajv/dist/ajv.js
generated
vendored
Executable file
48
my-app/node_modules/ajv/dist/ajv.js
generated
vendored
Executable file
|
@ -0,0 +1,48 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MissingRefError = exports.ValidationError = exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = void 0;
|
||||
const core_1 = require("./core");
|
||||
const draft7_1 = require("./vocabularies/draft7");
|
||||
const discriminator_1 = require("./vocabularies/discriminator");
|
||||
const draft7MetaSchema = require("./refs/json-schema-draft-07.json");
|
||||
const META_SUPPORT_DATA = ["/properties"];
|
||||
const META_SCHEMA_ID = "http://json-schema.org/draft-07/schema";
|
||||
class Ajv extends core_1.default {
|
||||
_addVocabularies() {
|
||||
super._addVocabularies();
|
||||
draft7_1.default.forEach((v) => this.addVocabulary(v));
|
||||
if (this.opts.discriminator)
|
||||
this.addKeyword(discriminator_1.default);
|
||||
}
|
||||
_addDefaultMetaSchema() {
|
||||
super._addDefaultMetaSchema();
|
||||
if (!this.opts.meta)
|
||||
return;
|
||||
const metaSchema = this.opts.$data
|
||||
? this.$dataMetaSchema(draft7MetaSchema, META_SUPPORT_DATA)
|
||||
: draft7MetaSchema;
|
||||
this.addMetaSchema(metaSchema, META_SCHEMA_ID, false);
|
||||
this.refs["http://json-schema.org/schema"] = META_SCHEMA_ID;
|
||||
}
|
||||
defaultMeta() {
|
||||
return (this.opts.defaultMeta =
|
||||
super.defaultMeta() || (this.getSchema(META_SCHEMA_ID) ? META_SCHEMA_ID : undefined));
|
||||
}
|
||||
}
|
||||
module.exports = exports = Ajv;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = Ajv;
|
||||
var validate_1 = require("./compile/validate");
|
||||
Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function () { return validate_1.KeywordCxt; } });
|
||||
var codegen_1 = require("./compile/codegen");
|
||||
Object.defineProperty(exports, "_", { enumerable: true, get: function () { return codegen_1._; } });
|
||||
Object.defineProperty(exports, "str", { enumerable: true, get: function () { return codegen_1.str; } });
|
||||
Object.defineProperty(exports, "stringify", { enumerable: true, get: function () { return codegen_1.stringify; } });
|
||||
Object.defineProperty(exports, "nil", { enumerable: true, get: function () { return codegen_1.nil; } });
|
||||
Object.defineProperty(exports, "Name", { enumerable: true, get: function () { return codegen_1.Name; } });
|
||||
Object.defineProperty(exports, "CodeGen", { enumerable: true, get: function () { return codegen_1.CodeGen; } });
|
||||
var validation_error_1 = require("./runtime/validation_error");
|
||||
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return validation_error_1.default; } });
|
||||
var ref_error_1 = require("./compile/ref_error");
|
||||
Object.defineProperty(exports, "MissingRefError", { enumerable: true, get: function () { return ref_error_1.default; } });
|
||||
//# sourceMappingURL=ajv.js.map
|
1
my-app/node_modules/ajv/dist/ajv.js.map
generated
vendored
Executable file
1
my-app/node_modules/ajv/dist/ajv.js.map
generated
vendored
Executable file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"ajv.js","sourceRoot":"","sources":["../lib/ajv.ts"],"names":[],"mappings":";;;AACA,iCAA4B;AAC5B,kDAAsD;AACtD,gEAAwD;AACxD,qEAAoE;AAEpE,MAAM,iBAAiB,GAAG,CAAC,aAAa,CAAC,CAAA;AAEzC,MAAM,cAAc,GAAG,wCAAwC,CAAA;AAE/D,MAAM,GAAI,SAAQ,cAAO;IACvB,gBAAgB;QACd,KAAK,CAAC,gBAAgB,EAAE,CAAA;QACxB,gBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAA;QACxD,IAAI,IAAI,CAAC,IAAI,CAAC,aAAa;YAAE,IAAI,CAAC,UAAU,CAAC,uBAAa,CAAC,CAAA;IAC7D,CAAC;IAED,qBAAqB;QACnB,KAAK,CAAC,qBAAqB,EAAE,CAAA;QAC7B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;YAAE,OAAM;QAC3B,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK;YAChC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,gBAAgB,EAAE,iBAAiB,CAAC;YAC3D,CAAC,CAAC,gBAAgB,CAAA;QACpB,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,cAAc,EAAE,KAAK,CAAC,CAAA;QACrD,IAAI,CAAC,IAAI,CAAC,+BAA+B,CAAC,GAAG,cAAc,CAAA;IAC7D,CAAC;IAED,WAAW;QACT,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW;YAC3B,KAAK,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAA;IACzF,CAAC;CACF;AAED,MAAM,CAAC,OAAO,GAAG,OAAO,GAAG,GAAG,CAAA;AAC9B,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAC,KAAK,EAAE,IAAI,EAAC,CAAC,CAAA;AAE3D,kBAAe,GAAG,CAAA;AA0BlB,+CAA6C;AAArC,sGAAA,UAAU,OAAA;AAIlB,6CAA6F;AAArF,4FAAA,CAAC,OAAA;AAAE,8FAAA,GAAG,OAAA;AAAE,oGAAA,SAAS,OAAA;AAAE,8FAAA,GAAG,OAAA;AAAE,+FAAA,IAAI,OAAA;AAAQ,kGAAA,OAAO,OAAA;AACnD,+DAAqE;AAA7D,mHAAA,OAAO,OAAmB;AAClC,iDAA8D;AAAtD,4GAAA,OAAO,OAAmB"}
|
40
my-app/node_modules/ajv/dist/compile/codegen/code.d.ts
generated
vendored
Executable file
40
my-app/node_modules/ajv/dist/compile/codegen/code.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,40 @@
|
|||
export declare abstract class _CodeOrName {
|
||||
abstract readonly str: string;
|
||||
abstract readonly names: UsedNames;
|
||||
abstract toString(): string;
|
||||
abstract emptyStr(): boolean;
|
||||
}
|
||||
export declare const IDENTIFIER: RegExp;
|
||||
export declare class Name extends _CodeOrName {
|
||||
readonly str: string;
|
||||
constructor(s: string);
|
||||
toString(): string;
|
||||
emptyStr(): boolean;
|
||||
get names(): UsedNames;
|
||||
}
|
||||
export declare class _Code extends _CodeOrName {
|
||||
readonly _items: readonly CodeItem[];
|
||||
private _str?;
|
||||
private _names?;
|
||||
constructor(code: string | readonly CodeItem[]);
|
||||
toString(): string;
|
||||
emptyStr(): boolean;
|
||||
get str(): string;
|
||||
get names(): UsedNames;
|
||||
}
|
||||
export type CodeItem = Name | string | number | boolean | null;
|
||||
export type UsedNames = Record<string, number | undefined>;
|
||||
export type Code = _Code | Name;
|
||||
export type SafeExpr = Code | number | boolean | null;
|
||||
export declare const nil: _Code;
|
||||
type CodeArg = SafeExpr | string | undefined;
|
||||
export declare function _(strs: TemplateStringsArray, ...args: CodeArg[]): _Code;
|
||||
export declare function str(strs: TemplateStringsArray, ...args: (CodeArg | string[])[]): _Code;
|
||||
export declare function addCodeArg(code: CodeItem[], arg: CodeArg | string[]): void;
|
||||
export declare function strConcat(c1: Code, c2: Code): Code;
|
||||
export declare function stringify(x: unknown): Code;
|
||||
export declare function safeStringify(x: unknown): string;
|
||||
export declare function getProperty(key: Code | string | number): Code;
|
||||
export declare function getEsmExportName(key: Code | string | number): Code;
|
||||
export declare function regexpCode(rx: RegExp): Code;
|
||||
export {};
|
155
my-app/node_modules/ajv/dist/compile/codegen/code.js
generated
vendored
Executable file
155
my-app/node_modules/ajv/dist/compile/codegen/code.js
generated
vendored
Executable file
|
@ -0,0 +1,155 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.regexpCode = exports.getEsmExportName = exports.getProperty = exports.safeStringify = exports.stringify = exports.strConcat = exports.addCodeArg = exports.str = exports._ = exports.nil = exports._Code = exports.Name = exports.IDENTIFIER = exports._CodeOrName = void 0;
|
||||
class _CodeOrName {
|
||||
}
|
||||
exports._CodeOrName = _CodeOrName;
|
||||
exports.IDENTIFIER = /^[a-z$_][a-z$_0-9]*$/i;
|
||||
class Name extends _CodeOrName {
|
||||
constructor(s) {
|
||||
super();
|
||||
if (!exports.IDENTIFIER.test(s))
|
||||
throw new Error("CodeGen: name must be a valid identifier");
|
||||
this.str = s;
|
||||
}
|
||||
toString() {
|
||||
return this.str;
|
||||
}
|
||||
emptyStr() {
|
||||
return false;
|
||||
}
|
||||
get names() {
|
||||
return { [this.str]: 1 };
|
||||
}
|
||||
}
|
||||
exports.Name = Name;
|
||||
class _Code extends _CodeOrName {
|
||||
constructor(code) {
|
||||
super();
|
||||
this._items = typeof code === "string" ? [code] : code;
|
||||
}
|
||||
toString() {
|
||||
return this.str;
|
||||
}
|
||||
emptyStr() {
|
||||
if (this._items.length > 1)
|
||||
return false;
|
||||
const item = this._items[0];
|
||||
return item === "" || item === '""';
|
||||
}
|
||||
get str() {
|
||||
var _a;
|
||||
return ((_a = this._str) !== null && _a !== void 0 ? _a : (this._str = this._items.reduce((s, c) => `${s}${c}`, "")));
|
||||
}
|
||||
get names() {
|
||||
var _a;
|
||||
return ((_a = this._names) !== null && _a !== void 0 ? _a : (this._names = this._items.reduce((names, c) => {
|
||||
if (c instanceof Name)
|
||||
names[c.str] = (names[c.str] || 0) + 1;
|
||||
return names;
|
||||
}, {})));
|
||||
}
|
||||
}
|
||||
exports._Code = _Code;
|
||||
exports.nil = new _Code("");
|
||||
function _(strs, ...args) {
|
||||
const code = [strs[0]];
|
||||
let i = 0;
|
||||
while (i < args.length) {
|
||||
addCodeArg(code, args[i]);
|
||||
code.push(strs[++i]);
|
||||
}
|
||||
return new _Code(code);
|
||||
}
|
||||
exports._ = _;
|
||||
const plus = new _Code("+");
|
||||
function str(strs, ...args) {
|
||||
const expr = [safeStringify(strs[0])];
|
||||
let i = 0;
|
||||
while (i < args.length) {
|
||||
expr.push(plus);
|
||||
addCodeArg(expr, args[i]);
|
||||
expr.push(plus, safeStringify(strs[++i]));
|
||||
}
|
||||
optimize(expr);
|
||||
return new _Code(expr);
|
||||
}
|
||||
exports.str = str;
|
||||
function addCodeArg(code, arg) {
|
||||
if (arg instanceof _Code)
|
||||
code.push(...arg._items);
|
||||
else if (arg instanceof Name)
|
||||
code.push(arg);
|
||||
else
|
||||
code.push(interpolate(arg));
|
||||
}
|
||||
exports.addCodeArg = addCodeArg;
|
||||
function optimize(expr) {
|
||||
let i = 1;
|
||||
while (i < expr.length - 1) {
|
||||
if (expr[i] === plus) {
|
||||
const res = mergeExprItems(expr[i - 1], expr[i + 1]);
|
||||
if (res !== undefined) {
|
||||
expr.splice(i - 1, 3, res);
|
||||
continue;
|
||||
}
|
||||
expr[i++] = "+";
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
function mergeExprItems(a, b) {
|
||||
if (b === '""')
|
||||
return a;
|
||||
if (a === '""')
|
||||
return b;
|
||||
if (typeof a == "string") {
|
||||
if (b instanceof Name || a[a.length - 1] !== '"')
|
||||
return;
|
||||
if (typeof b != "string")
|
||||
return `${a.slice(0, -1)}${b}"`;
|
||||
if (b[0] === '"')
|
||||
return a.slice(0, -1) + b.slice(1);
|
||||
return;
|
||||
}
|
||||
if (typeof b == "string" && b[0] === '"' && !(a instanceof Name))
|
||||
return `"${a}${b.slice(1)}`;
|
||||
return;
|
||||
}
|
||||
function strConcat(c1, c2) {
|
||||
return c2.emptyStr() ? c1 : c1.emptyStr() ? c2 : str `${c1}${c2}`;
|
||||
}
|
||||
exports.strConcat = strConcat;
|
||||
// TODO do not allow arrays here
|
||||
function interpolate(x) {
|
||||
return typeof x == "number" || typeof x == "boolean" || x === null
|
||||
? x
|
||||
: safeStringify(Array.isArray(x) ? x.join(",") : x);
|
||||
}
|
||||
function stringify(x) {
|
||||
return new _Code(safeStringify(x));
|
||||
}
|
||||
exports.stringify = stringify;
|
||||
function safeStringify(x) {
|
||||
return JSON.stringify(x)
|
||||
.replace(/\u2028/g, "\\u2028")
|
||||
.replace(/\u2029/g, "\\u2029");
|
||||
}
|
||||
exports.safeStringify = safeStringify;
|
||||
function getProperty(key) {
|
||||
return typeof key == "string" && exports.IDENTIFIER.test(key) ? new _Code(`.${key}`) : _ `[${key}]`;
|
||||
}
|
||||
exports.getProperty = getProperty;
|
||||
//Does best effort to format the name properly
|
||||
function getEsmExportName(key) {
|
||||
if (typeof key == "string" && exports.IDENTIFIER.test(key)) {
|
||||
return new _Code(`${key}`);
|
||||
}
|
||||
throw new Error(`CodeGen: invalid export name: ${key}, use explicit $id name mapping`);
|
||||
}
|
||||
exports.getEsmExportName = getEsmExportName;
|
||||
function regexpCode(rx) {
|
||||
return new _Code(rx.toString());
|
||||
}
|
||||
exports.regexpCode = regexpCode;
|
||||
//# sourceMappingURL=code.js.map
|
1
my-app/node_modules/ajv/dist/compile/codegen/code.js.map
generated
vendored
Executable file
1
my-app/node_modules/ajv/dist/compile/codegen/code.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
79
my-app/node_modules/ajv/dist/compile/codegen/index.d.ts
generated
vendored
Executable file
79
my-app/node_modules/ajv/dist/compile/codegen/index.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,79 @@
|
|||
import type { ScopeValueSets, NameValue, ValueScope, ValueScopeName } from "./scope";
|
||||
import { _Code, Code, Name } from "./code";
|
||||
import { Scope } from "./scope";
|
||||
export { _, str, strConcat, nil, getProperty, stringify, regexpCode, Name, Code } from "./code";
|
||||
export { Scope, ScopeStore, ValueScope, ValueScopeName, ScopeValueSets, varKinds } from "./scope";
|
||||
export type SafeExpr = Code | number | boolean | null;
|
||||
export type Block = Code | (() => void);
|
||||
export declare const operators: {
|
||||
GT: _Code;
|
||||
GTE: _Code;
|
||||
LT: _Code;
|
||||
LTE: _Code;
|
||||
EQ: _Code;
|
||||
NEQ: _Code;
|
||||
NOT: _Code;
|
||||
OR: _Code;
|
||||
AND: _Code;
|
||||
ADD: _Code;
|
||||
};
|
||||
export interface CodeGenOptions {
|
||||
es5?: boolean;
|
||||
lines?: boolean;
|
||||
ownProperties?: boolean;
|
||||
}
|
||||
export declare class CodeGen {
|
||||
readonly _scope: Scope;
|
||||
readonly _extScope: ValueScope;
|
||||
readonly _values: ScopeValueSets;
|
||||
private readonly _nodes;
|
||||
private readonly _blockStarts;
|
||||
private readonly _constants;
|
||||
private readonly opts;
|
||||
constructor(extScope: ValueScope, opts?: CodeGenOptions);
|
||||
toString(): string;
|
||||
name(prefix: string): Name;
|
||||
scopeName(prefix: string): ValueScopeName;
|
||||
scopeValue(prefixOrName: ValueScopeName | string, value: NameValue): Name;
|
||||
getScopeValue(prefix: string, keyOrRef: unknown): ValueScopeName | undefined;
|
||||
scopeRefs(scopeName: Name): Code;
|
||||
scopeCode(): Code;
|
||||
private _def;
|
||||
const(nameOrPrefix: Name | string, rhs: SafeExpr, _constant?: boolean): Name;
|
||||
let(nameOrPrefix: Name | string, rhs?: SafeExpr, _constant?: boolean): Name;
|
||||
var(nameOrPrefix: Name | string, rhs?: SafeExpr, _constant?: boolean): Name;
|
||||
assign(lhs: Code, rhs: SafeExpr, sideEffects?: boolean): CodeGen;
|
||||
add(lhs: Code, rhs: SafeExpr): CodeGen;
|
||||
code(c: Block | SafeExpr): CodeGen;
|
||||
object(...keyValues: [Name | string, SafeExpr | string][]): _Code;
|
||||
if(condition: Code | boolean, thenBody?: Block, elseBody?: Block): CodeGen;
|
||||
elseIf(condition: Code | boolean): CodeGen;
|
||||
else(): CodeGen;
|
||||
endIf(): CodeGen;
|
||||
private _for;
|
||||
for(iteration: Code, forBody?: Block): CodeGen;
|
||||
forRange(nameOrPrefix: Name | string, from: SafeExpr, to: SafeExpr, forBody: (index: Name) => void, varKind?: Code): CodeGen;
|
||||
forOf(nameOrPrefix: Name | string, iterable: Code, forBody: (item: Name) => void, varKind?: Code): CodeGen;
|
||||
forIn(nameOrPrefix: Name | string, obj: Code, forBody: (item: Name) => void, varKind?: Code): CodeGen;
|
||||
endFor(): CodeGen;
|
||||
label(label: Name): CodeGen;
|
||||
break(label?: Code): CodeGen;
|
||||
return(value: Block | SafeExpr): CodeGen;
|
||||
try(tryBody: Block, catchCode?: (e: Name) => void, finallyCode?: Block): CodeGen;
|
||||
throw(error: Code): CodeGen;
|
||||
block(body?: Block, nodeCount?: number): CodeGen;
|
||||
endBlock(nodeCount?: number): CodeGen;
|
||||
func(name: Name, args?: Code, async?: boolean, funcBody?: Block): CodeGen;
|
||||
endFunc(): CodeGen;
|
||||
optimize(n?: number): void;
|
||||
private _leafNode;
|
||||
private _blockNode;
|
||||
private _endBlockNode;
|
||||
private _elseNode;
|
||||
private get _root();
|
||||
private get _currNode();
|
||||
private set _currNode(value);
|
||||
}
|
||||
export declare function not<T extends Code | SafeExpr>(x: T): T;
|
||||
export declare function and(...args: Code[]): Code;
|
||||
export declare function or(...args: Code[]): Code;
|
697
my-app/node_modules/ajv/dist/compile/codegen/index.js
generated
vendored
Executable file
697
my-app/node_modules/ajv/dist/compile/codegen/index.js
generated
vendored
Executable file
|
@ -0,0 +1,697 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.or = exports.and = exports.not = exports.CodeGen = exports.operators = exports.varKinds = exports.ValueScopeName = exports.ValueScope = exports.Scope = exports.Name = exports.regexpCode = exports.stringify = exports.getProperty = exports.nil = exports.strConcat = exports.str = exports._ = void 0;
|
||||
const code_1 = require("./code");
|
||||
const scope_1 = require("./scope");
|
||||
var code_2 = require("./code");
|
||||
Object.defineProperty(exports, "_", { enumerable: true, get: function () { return code_2._; } });
|
||||
Object.defineProperty(exports, "str", { enumerable: true, get: function () { return code_2.str; } });
|
||||
Object.defineProperty(exports, "strConcat", { enumerable: true, get: function () { return code_2.strConcat; } });
|
||||
Object.defineProperty(exports, "nil", { enumerable: true, get: function () { return code_2.nil; } });
|
||||
Object.defineProperty(exports, "getProperty", { enumerable: true, get: function () { return code_2.getProperty; } });
|
||||
Object.defineProperty(exports, "stringify", { enumerable: true, get: function () { return code_2.stringify; } });
|
||||
Object.defineProperty(exports, "regexpCode", { enumerable: true, get: function () { return code_2.regexpCode; } });
|
||||
Object.defineProperty(exports, "Name", { enumerable: true, get: function () { return code_2.Name; } });
|
||||
var scope_2 = require("./scope");
|
||||
Object.defineProperty(exports, "Scope", { enumerable: true, get: function () { return scope_2.Scope; } });
|
||||
Object.defineProperty(exports, "ValueScope", { enumerable: true, get: function () { return scope_2.ValueScope; } });
|
||||
Object.defineProperty(exports, "ValueScopeName", { enumerable: true, get: function () { return scope_2.ValueScopeName; } });
|
||||
Object.defineProperty(exports, "varKinds", { enumerable: true, get: function () { return scope_2.varKinds; } });
|
||||
exports.operators = {
|
||||
GT: new code_1._Code(">"),
|
||||
GTE: new code_1._Code(">="),
|
||||
LT: new code_1._Code("<"),
|
||||
LTE: new code_1._Code("<="),
|
||||
EQ: new code_1._Code("==="),
|
||||
NEQ: new code_1._Code("!=="),
|
||||
NOT: new code_1._Code("!"),
|
||||
OR: new code_1._Code("||"),
|
||||
AND: new code_1._Code("&&"),
|
||||
ADD: new code_1._Code("+"),
|
||||
};
|
||||
class Node {
|
||||
optimizeNodes() {
|
||||
return this;
|
||||
}
|
||||
optimizeNames(_names, _constants) {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class Def extends Node {
|
||||
constructor(varKind, name, rhs) {
|
||||
super();
|
||||
this.varKind = varKind;
|
||||
this.name = name;
|
||||
this.rhs = rhs;
|
||||
}
|
||||
render({ es5, _n }) {
|
||||
const varKind = es5 ? scope_1.varKinds.var : this.varKind;
|
||||
const rhs = this.rhs === undefined ? "" : ` = ${this.rhs}`;
|
||||
return `${varKind} ${this.name}${rhs};` + _n;
|
||||
}
|
||||
optimizeNames(names, constants) {
|
||||
if (!names[this.name.str])
|
||||
return;
|
||||
if (this.rhs)
|
||||
this.rhs = optimizeExpr(this.rhs, names, constants);
|
||||
return this;
|
||||
}
|
||||
get names() {
|
||||
return this.rhs instanceof code_1._CodeOrName ? this.rhs.names : {};
|
||||
}
|
||||
}
|
||||
class Assign extends Node {
|
||||
constructor(lhs, rhs, sideEffects) {
|
||||
super();
|
||||
this.lhs = lhs;
|
||||
this.rhs = rhs;
|
||||
this.sideEffects = sideEffects;
|
||||
}
|
||||
render({ _n }) {
|
||||
return `${this.lhs} = ${this.rhs};` + _n;
|
||||
}
|
||||
optimizeNames(names, constants) {
|
||||
if (this.lhs instanceof code_1.Name && !names[this.lhs.str] && !this.sideEffects)
|
||||
return;
|
||||
this.rhs = optimizeExpr(this.rhs, names, constants);
|
||||
return this;
|
||||
}
|
||||
get names() {
|
||||
const names = this.lhs instanceof code_1.Name ? {} : { ...this.lhs.names };
|
||||
return addExprNames(names, this.rhs);
|
||||
}
|
||||
}
|
||||
class AssignOp extends Assign {
|
||||
constructor(lhs, op, rhs, sideEffects) {
|
||||
super(lhs, rhs, sideEffects);
|
||||
this.op = op;
|
||||
}
|
||||
render({ _n }) {
|
||||
return `${this.lhs} ${this.op}= ${this.rhs};` + _n;
|
||||
}
|
||||
}
|
||||
class Label extends Node {
|
||||
constructor(label) {
|
||||
super();
|
||||
this.label = label;
|
||||
this.names = {};
|
||||
}
|
||||
render({ _n }) {
|
||||
return `${this.label}:` + _n;
|
||||
}
|
||||
}
|
||||
class Break extends Node {
|
||||
constructor(label) {
|
||||
super();
|
||||
this.label = label;
|
||||
this.names = {};
|
||||
}
|
||||
render({ _n }) {
|
||||
const label = this.label ? ` ${this.label}` : "";
|
||||
return `break${label};` + _n;
|
||||
}
|
||||
}
|
||||
class Throw extends Node {
|
||||
constructor(error) {
|
||||
super();
|
||||
this.error = error;
|
||||
}
|
||||
render({ _n }) {
|
||||
return `throw ${this.error};` + _n;
|
||||
}
|
||||
get names() {
|
||||
return this.error.names;
|
||||
}
|
||||
}
|
||||
class AnyCode extends Node {
|
||||
constructor(code) {
|
||||
super();
|
||||
this.code = code;
|
||||
}
|
||||
render({ _n }) {
|
||||
return `${this.code};` + _n;
|
||||
}
|
||||
optimizeNodes() {
|
||||
return `${this.code}` ? this : undefined;
|
||||
}
|
||||
optimizeNames(names, constants) {
|
||||
this.code = optimizeExpr(this.code, names, constants);
|
||||
return this;
|
||||
}
|
||||
get names() {
|
||||
return this.code instanceof code_1._CodeOrName ? this.code.names : {};
|
||||
}
|
||||
}
|
||||
class ParentNode extends Node {
|
||||
constructor(nodes = []) {
|
||||
super();
|
||||
this.nodes = nodes;
|
||||
}
|
||||
render(opts) {
|
||||
return this.nodes.reduce((code, n) => code + n.render(opts), "");
|
||||
}
|
||||
optimizeNodes() {
|
||||
const { nodes } = this;
|
||||
let i = nodes.length;
|
||||
while (i--) {
|
||||
const n = nodes[i].optimizeNodes();
|
||||
if (Array.isArray(n))
|
||||
nodes.splice(i, 1, ...n);
|
||||
else if (n)
|
||||
nodes[i] = n;
|
||||
else
|
||||
nodes.splice(i, 1);
|
||||
}
|
||||
return nodes.length > 0 ? this : undefined;
|
||||
}
|
||||
optimizeNames(names, constants) {
|
||||
const { nodes } = this;
|
||||
let i = nodes.length;
|
||||
while (i--) {
|
||||
// iterating backwards improves 1-pass optimization
|
||||
const n = nodes[i];
|
||||
if (n.optimizeNames(names, constants))
|
||||
continue;
|
||||
subtractNames(names, n.names);
|
||||
nodes.splice(i, 1);
|
||||
}
|
||||
return nodes.length > 0 ? this : undefined;
|
||||
}
|
||||
get names() {
|
||||
return this.nodes.reduce((names, n) => addNames(names, n.names), {});
|
||||
}
|
||||
}
|
||||
class BlockNode extends ParentNode {
|
||||
render(opts) {
|
||||
return "{" + opts._n + super.render(opts) + "}" + opts._n;
|
||||
}
|
||||
}
|
||||
class Root extends ParentNode {
|
||||
}
|
||||
class Else extends BlockNode {
|
||||
}
|
||||
Else.kind = "else";
|
||||
class If extends BlockNode {
|
||||
constructor(condition, nodes) {
|
||||
super(nodes);
|
||||
this.condition = condition;
|
||||
}
|
||||
render(opts) {
|
||||
let code = `if(${this.condition})` + super.render(opts);
|
||||
if (this.else)
|
||||
code += "else " + this.else.render(opts);
|
||||
return code;
|
||||
}
|
||||
optimizeNodes() {
|
||||
super.optimizeNodes();
|
||||
const cond = this.condition;
|
||||
if (cond === true)
|
||||
return this.nodes; // else is ignored here
|
||||
let e = this.else;
|
||||
if (e) {
|
||||
const ns = e.optimizeNodes();
|
||||
e = this.else = Array.isArray(ns) ? new Else(ns) : ns;
|
||||
}
|
||||
if (e) {
|
||||
if (cond === false)
|
||||
return e instanceof If ? e : e.nodes;
|
||||
if (this.nodes.length)
|
||||
return this;
|
||||
return new If(not(cond), e instanceof If ? [e] : e.nodes);
|
||||
}
|
||||
if (cond === false || !this.nodes.length)
|
||||
return undefined;
|
||||
return this;
|
||||
}
|
||||
optimizeNames(names, constants) {
|
||||
var _a;
|
||||
this.else = (_a = this.else) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants);
|
||||
if (!(super.optimizeNames(names, constants) || this.else))
|
||||
return;
|
||||
this.condition = optimizeExpr(this.condition, names, constants);
|
||||
return this;
|
||||
}
|
||||
get names() {
|
||||
const names = super.names;
|
||||
addExprNames(names, this.condition);
|
||||
if (this.else)
|
||||
addNames(names, this.else.names);
|
||||
return names;
|
||||
}
|
||||
}
|
||||
If.kind = "if";
|
||||
class For extends BlockNode {
|
||||
}
|
||||
For.kind = "for";
|
||||
class ForLoop extends For {
|
||||
constructor(iteration) {
|
||||
super();
|
||||
this.iteration = iteration;
|
||||
}
|
||||
render(opts) {
|
||||
return `for(${this.iteration})` + super.render(opts);
|
||||
}
|
||||
optimizeNames(names, constants) {
|
||||
if (!super.optimizeNames(names, constants))
|
||||
return;
|
||||
this.iteration = optimizeExpr(this.iteration, names, constants);
|
||||
return this;
|
||||
}
|
||||
get names() {
|
||||
return addNames(super.names, this.iteration.names);
|
||||
}
|
||||
}
|
||||
class ForRange extends For {
|
||||
constructor(varKind, name, from, to) {
|
||||
super();
|
||||
this.varKind = varKind;
|
||||
this.name = name;
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
}
|
||||
render(opts) {
|
||||
const varKind = opts.es5 ? scope_1.varKinds.var : this.varKind;
|
||||
const { name, from, to } = this;
|
||||
return `for(${varKind} ${name}=${from}; ${name}<${to}; ${name}++)` + super.render(opts);
|
||||
}
|
||||
get names() {
|
||||
const names = addExprNames(super.names, this.from);
|
||||
return addExprNames(names, this.to);
|
||||
}
|
||||
}
|
||||
class ForIter extends For {
|
||||
constructor(loop, varKind, name, iterable) {
|
||||
super();
|
||||
this.loop = loop;
|
||||
this.varKind = varKind;
|
||||
this.name = name;
|
||||
this.iterable = iterable;
|
||||
}
|
||||
render(opts) {
|
||||
return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts);
|
||||
}
|
||||
optimizeNames(names, constants) {
|
||||
if (!super.optimizeNames(names, constants))
|
||||
return;
|
||||
this.iterable = optimizeExpr(this.iterable, names, constants);
|
||||
return this;
|
||||
}
|
||||
get names() {
|
||||
return addNames(super.names, this.iterable.names);
|
||||
}
|
||||
}
|
||||
class Func extends BlockNode {
|
||||
constructor(name, args, async) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.args = args;
|
||||
this.async = async;
|
||||
}
|
||||
render(opts) {
|
||||
const _async = this.async ? "async " : "";
|
||||
return `${_async}function ${this.name}(${this.args})` + super.render(opts);
|
||||
}
|
||||
}
|
||||
Func.kind = "func";
|
||||
class Return extends ParentNode {
|
||||
render(opts) {
|
||||
return "return " + super.render(opts);
|
||||
}
|
||||
}
|
||||
Return.kind = "return";
|
||||
class Try extends BlockNode {
|
||||
render(opts) {
|
||||
let code = "try" + super.render(opts);
|
||||
if (this.catch)
|
||||
code += this.catch.render(opts);
|
||||
if (this.finally)
|
||||
code += this.finally.render(opts);
|
||||
return code;
|
||||
}
|
||||
optimizeNodes() {
|
||||
var _a, _b;
|
||||
super.optimizeNodes();
|
||||
(_a = this.catch) === null || _a === void 0 ? void 0 : _a.optimizeNodes();
|
||||
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNodes();
|
||||
return this;
|
||||
}
|
||||
optimizeNames(names, constants) {
|
||||
var _a, _b;
|
||||
super.optimizeNames(names, constants);
|
||||
(_a = this.catch) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants);
|
||||
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants);
|
||||
return this;
|
||||
}
|
||||
get names() {
|
||||
const names = super.names;
|
||||
if (this.catch)
|
||||
addNames(names, this.catch.names);
|
||||
if (this.finally)
|
||||
addNames(names, this.finally.names);
|
||||
return names;
|
||||
}
|
||||
}
|
||||
class Catch extends BlockNode {
|
||||
constructor(error) {
|
||||
super();
|
||||
this.error = error;
|
||||
}
|
||||
render(opts) {
|
||||
return `catch(${this.error})` + super.render(opts);
|
||||
}
|
||||
}
|
||||
Catch.kind = "catch";
|
||||
class Finally extends BlockNode {
|
||||
render(opts) {
|
||||
return "finally" + super.render(opts);
|
||||
}
|
||||
}
|
||||
Finally.kind = "finally";
|
||||
class CodeGen {
|
||||
constructor(extScope, opts = {}) {
|
||||
this._values = {};
|
||||
this._blockStarts = [];
|
||||
this._constants = {};
|
||||
this.opts = { ...opts, _n: opts.lines ? "\n" : "" };
|
||||
this._extScope = extScope;
|
||||
this._scope = new scope_1.Scope({ parent: extScope });
|
||||
this._nodes = [new Root()];
|
||||
}
|
||||
toString() {
|
||||
return this._root.render(this.opts);
|
||||
}
|
||||
// returns unique name in the internal scope
|
||||
name(prefix) {
|
||||
return this._scope.name(prefix);
|
||||
}
|
||||
// reserves unique name in the external scope
|
||||
scopeName(prefix) {
|
||||
return this._extScope.name(prefix);
|
||||
}
|
||||
// reserves unique name in the external scope and assigns value to it
|
||||
scopeValue(prefixOrName, value) {
|
||||
const name = this._extScope.value(prefixOrName, value);
|
||||
const vs = this._values[name.prefix] || (this._values[name.prefix] = new Set());
|
||||
vs.add(name);
|
||||
return name;
|
||||
}
|
||||
getScopeValue(prefix, keyOrRef) {
|
||||
return this._extScope.getValue(prefix, keyOrRef);
|
||||
}
|
||||
// return code that assigns values in the external scope to the names that are used internally
|
||||
// (same names that were returned by gen.scopeName or gen.scopeValue)
|
||||
scopeRefs(scopeName) {
|
||||
return this._extScope.scopeRefs(scopeName, this._values);
|
||||
}
|
||||
scopeCode() {
|
||||
return this._extScope.scopeCode(this._values);
|
||||
}
|
||||
_def(varKind, nameOrPrefix, rhs, constant) {
|
||||
const name = this._scope.toName(nameOrPrefix);
|
||||
if (rhs !== undefined && constant)
|
||||
this._constants[name.str] = rhs;
|
||||
this._leafNode(new Def(varKind, name, rhs));
|
||||
return name;
|
||||
}
|
||||
// `const` declaration (`var` in es5 mode)
|
||||
const(nameOrPrefix, rhs, _constant) {
|
||||
return this._def(scope_1.varKinds.const, nameOrPrefix, rhs, _constant);
|
||||
}
|
||||
// `let` declaration with optional assignment (`var` in es5 mode)
|
||||
let(nameOrPrefix, rhs, _constant) {
|
||||
return this._def(scope_1.varKinds.let, nameOrPrefix, rhs, _constant);
|
||||
}
|
||||
// `var` declaration with optional assignment
|
||||
var(nameOrPrefix, rhs, _constant) {
|
||||
return this._def(scope_1.varKinds.var, nameOrPrefix, rhs, _constant);
|
||||
}
|
||||
// assignment code
|
||||
assign(lhs, rhs, sideEffects) {
|
||||
return this._leafNode(new Assign(lhs, rhs, sideEffects));
|
||||
}
|
||||
// `+=` code
|
||||
add(lhs, rhs) {
|
||||
return this._leafNode(new AssignOp(lhs, exports.operators.ADD, rhs));
|
||||
}
|
||||
// appends passed SafeExpr to code or executes Block
|
||||
code(c) {
|
||||
if (typeof c == "function")
|
||||
c();
|
||||
else if (c !== code_1.nil)
|
||||
this._leafNode(new AnyCode(c));
|
||||
return this;
|
||||
}
|
||||
// returns code for object literal for the passed argument list of key-value pairs
|
||||
object(...keyValues) {
|
||||
const code = ["{"];
|
||||
for (const [key, value] of keyValues) {
|
||||
if (code.length > 1)
|
||||
code.push(",");
|
||||
code.push(key);
|
||||
if (key !== value || this.opts.es5) {
|
||||
code.push(":");
|
||||
(0, code_1.addCodeArg)(code, value);
|
||||
}
|
||||
}
|
||||
code.push("}");
|
||||
return new code_1._Code(code);
|
||||
}
|
||||
// `if` clause (or statement if `thenBody` and, optionally, `elseBody` are passed)
|
||||
if(condition, thenBody, elseBody) {
|
||||
this._blockNode(new If(condition));
|
||||
if (thenBody && elseBody) {
|
||||
this.code(thenBody).else().code(elseBody).endIf();
|
||||
}
|
||||
else if (thenBody) {
|
||||
this.code(thenBody).endIf();
|
||||
}
|
||||
else if (elseBody) {
|
||||
throw new Error('CodeGen: "else" body without "then" body');
|
||||
}
|
||||
return this;
|
||||
}
|
||||
// `else if` clause - invalid without `if` or after `else` clauses
|
||||
elseIf(condition) {
|
||||
return this._elseNode(new If(condition));
|
||||
}
|
||||
// `else` clause - only valid after `if` or `else if` clauses
|
||||
else() {
|
||||
return this._elseNode(new Else());
|
||||
}
|
||||
// end `if` statement (needed if gen.if was used only with condition)
|
||||
endIf() {
|
||||
return this._endBlockNode(If, Else);
|
||||
}
|
||||
_for(node, forBody) {
|
||||
this._blockNode(node);
|
||||
if (forBody)
|
||||
this.code(forBody).endFor();
|
||||
return this;
|
||||
}
|
||||
// a generic `for` clause (or statement if `forBody` is passed)
|
||||
for(iteration, forBody) {
|
||||
return this._for(new ForLoop(iteration), forBody);
|
||||
}
|
||||
// `for` statement for a range of values
|
||||
forRange(nameOrPrefix, from, to, forBody, varKind = this.opts.es5 ? scope_1.varKinds.var : scope_1.varKinds.let) {
|
||||
const name = this._scope.toName(nameOrPrefix);
|
||||
return this._for(new ForRange(varKind, name, from, to), () => forBody(name));
|
||||
}
|
||||
// `for-of` statement (in es5 mode replace with a normal for loop)
|
||||
forOf(nameOrPrefix, iterable, forBody, varKind = scope_1.varKinds.const) {
|
||||
const name = this._scope.toName(nameOrPrefix);
|
||||
if (this.opts.es5) {
|
||||
const arr = iterable instanceof code_1.Name ? iterable : this.var("_arr", iterable);
|
||||
return this.forRange("_i", 0, (0, code_1._) `${arr}.length`, (i) => {
|
||||
this.var(name, (0, code_1._) `${arr}[${i}]`);
|
||||
forBody(name);
|
||||
});
|
||||
}
|
||||
return this._for(new ForIter("of", varKind, name, iterable), () => forBody(name));
|
||||
}
|
||||
// `for-in` statement.
|
||||
// With option `ownProperties` replaced with a `for-of` loop for object keys
|
||||
forIn(nameOrPrefix, obj, forBody, varKind = this.opts.es5 ? scope_1.varKinds.var : scope_1.varKinds.const) {
|
||||
if (this.opts.ownProperties) {
|
||||
return this.forOf(nameOrPrefix, (0, code_1._) `Object.keys(${obj})`, forBody);
|
||||
}
|
||||
const name = this._scope.toName(nameOrPrefix);
|
||||
return this._for(new ForIter("in", varKind, name, obj), () => forBody(name));
|
||||
}
|
||||
// end `for` loop
|
||||
endFor() {
|
||||
return this._endBlockNode(For);
|
||||
}
|
||||
// `label` statement
|
||||
label(label) {
|
||||
return this._leafNode(new Label(label));
|
||||
}
|
||||
// `break` statement
|
||||
break(label) {
|
||||
return this._leafNode(new Break(label));
|
||||
}
|
||||
// `return` statement
|
||||
return(value) {
|
||||
const node = new Return();
|
||||
this._blockNode(node);
|
||||
this.code(value);
|
||||
if (node.nodes.length !== 1)
|
||||
throw new Error('CodeGen: "return" should have one node');
|
||||
return this._endBlockNode(Return);
|
||||
}
|
||||
// `try` statement
|
||||
try(tryBody, catchCode, finallyCode) {
|
||||
if (!catchCode && !finallyCode)
|
||||
throw new Error('CodeGen: "try" without "catch" and "finally"');
|
||||
const node = new Try();
|
||||
this._blockNode(node);
|
||||
this.code(tryBody);
|
||||
if (catchCode) {
|
||||
const error = this.name("e");
|
||||
this._currNode = node.catch = new Catch(error);
|
||||
catchCode(error);
|
||||
}
|
||||
if (finallyCode) {
|
||||
this._currNode = node.finally = new Finally();
|
||||
this.code(finallyCode);
|
||||
}
|
||||
return this._endBlockNode(Catch, Finally);
|
||||
}
|
||||
// `throw` statement
|
||||
throw(error) {
|
||||
return this._leafNode(new Throw(error));
|
||||
}
|
||||
// start self-balancing block
|
||||
block(body, nodeCount) {
|
||||
this._blockStarts.push(this._nodes.length);
|
||||
if (body)
|
||||
this.code(body).endBlock(nodeCount);
|
||||
return this;
|
||||
}
|
||||
// end the current self-balancing block
|
||||
endBlock(nodeCount) {
|
||||
const len = this._blockStarts.pop();
|
||||
if (len === undefined)
|
||||
throw new Error("CodeGen: not in self-balancing block");
|
||||
const toClose = this._nodes.length - len;
|
||||
if (toClose < 0 || (nodeCount !== undefined && toClose !== nodeCount)) {
|
||||
throw new Error(`CodeGen: wrong number of nodes: ${toClose} vs ${nodeCount} expected`);
|
||||
}
|
||||
this._nodes.length = len;
|
||||
return this;
|
||||
}
|
||||
// `function` heading (or definition if funcBody is passed)
|
||||
func(name, args = code_1.nil, async, funcBody) {
|
||||
this._blockNode(new Func(name, args, async));
|
||||
if (funcBody)
|
||||
this.code(funcBody).endFunc();
|
||||
return this;
|
||||
}
|
||||
// end function definition
|
||||
endFunc() {
|
||||
return this._endBlockNode(Func);
|
||||
}
|
||||
optimize(n = 1) {
|
||||
while (n-- > 0) {
|
||||
this._root.optimizeNodes();
|
||||
this._root.optimizeNames(this._root.names, this._constants);
|
||||
}
|
||||
}
|
||||
_leafNode(node) {
|
||||
this._currNode.nodes.push(node);
|
||||
return this;
|
||||
}
|
||||
_blockNode(node) {
|
||||
this._currNode.nodes.push(node);
|
||||
this._nodes.push(node);
|
||||
}
|
||||
_endBlockNode(N1, N2) {
|
||||
const n = this._currNode;
|
||||
if (n instanceof N1 || (N2 && n instanceof N2)) {
|
||||
this._nodes.pop();
|
||||
return this;
|
||||
}
|
||||
throw new Error(`CodeGen: not in block "${N2 ? `${N1.kind}/${N2.kind}` : N1.kind}"`);
|
||||
}
|
||||
_elseNode(node) {
|
||||
const n = this._currNode;
|
||||
if (!(n instanceof If)) {
|
||||
throw new Error('CodeGen: "else" without "if"');
|
||||
}
|
||||
this._currNode = n.else = node;
|
||||
return this;
|
||||
}
|
||||
get _root() {
|
||||
return this._nodes[0];
|
||||
}
|
||||
get _currNode() {
|
||||
const ns = this._nodes;
|
||||
return ns[ns.length - 1];
|
||||
}
|
||||
set _currNode(node) {
|
||||
const ns = this._nodes;
|
||||
ns[ns.length - 1] = node;
|
||||
}
|
||||
}
|
||||
exports.CodeGen = CodeGen;
|
||||
function addNames(names, from) {
|
||||
for (const n in from)
|
||||
names[n] = (names[n] || 0) + (from[n] || 0);
|
||||
return names;
|
||||
}
|
||||
function addExprNames(names, from) {
|
||||
return from instanceof code_1._CodeOrName ? addNames(names, from.names) : names;
|
||||
}
|
||||
function optimizeExpr(expr, names, constants) {
|
||||
if (expr instanceof code_1.Name)
|
||||
return replaceName(expr);
|
||||
if (!canOptimize(expr))
|
||||
return expr;
|
||||
return new code_1._Code(expr._items.reduce((items, c) => {
|
||||
if (c instanceof code_1.Name)
|
||||
c = replaceName(c);
|
||||
if (c instanceof code_1._Code)
|
||||
items.push(...c._items);
|
||||
else
|
||||
items.push(c);
|
||||
return items;
|
||||
}, []));
|
||||
function replaceName(n) {
|
||||
const c = constants[n.str];
|
||||
if (c === undefined || names[n.str] !== 1)
|
||||
return n;
|
||||
delete names[n.str];
|
||||
return c;
|
||||
}
|
||||
function canOptimize(e) {
|
||||
return (e instanceof code_1._Code &&
|
||||
e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants[c.str] !== undefined));
|
||||
}
|
||||
}
|
||||
function subtractNames(names, from) {
|
||||
for (const n in from)
|
||||
names[n] = (names[n] || 0) - (from[n] || 0);
|
||||
}
|
||||
function not(x) {
|
||||
return typeof x == "boolean" || typeof x == "number" || x === null ? !x : (0, code_1._) `!${par(x)}`;
|
||||
}
|
||||
exports.not = not;
|
||||
const andCode = mappend(exports.operators.AND);
|
||||
// boolean AND (&&) expression with the passed arguments
|
||||
function and(...args) {
|
||||
return args.reduce(andCode);
|
||||
}
|
||||
exports.and = and;
|
||||
const orCode = mappend(exports.operators.OR);
|
||||
// boolean OR (||) expression with the passed arguments
|
||||
function or(...args) {
|
||||
return args.reduce(orCode);
|
||||
}
|
||||
exports.or = or;
|
||||
function mappend(op) {
|
||||
return (x, y) => (x === code_1.nil ? y : y === code_1.nil ? x : (0, code_1._) `${par(x)} ${op} ${par(y)}`);
|
||||
}
|
||||
function par(x) {
|
||||
return x instanceof code_1.Name ? x : (0, code_1._) `(${x})`;
|
||||
}
|
||||
//# sourceMappingURL=index.js.map
|
1
my-app/node_modules/ajv/dist/compile/codegen/index.js.map
generated
vendored
Executable file
1
my-app/node_modules/ajv/dist/compile/codegen/index.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
79
my-app/node_modules/ajv/dist/compile/codegen/scope.d.ts
generated
vendored
Executable file
79
my-app/node_modules/ajv/dist/compile/codegen/scope.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,79 @@
|
|||
import { Code, Name } from "./code";
|
||||
interface NameGroup {
|
||||
prefix: string;
|
||||
index: number;
|
||||
}
|
||||
export interface NameValue {
|
||||
ref: ValueReference;
|
||||
key?: unknown;
|
||||
code?: Code;
|
||||
}
|
||||
export type ValueReference = unknown;
|
||||
interface ScopeOptions {
|
||||
prefixes?: Set<string>;
|
||||
parent?: Scope;
|
||||
}
|
||||
interface ValueScopeOptions extends ScopeOptions {
|
||||
scope: ScopeStore;
|
||||
es5?: boolean;
|
||||
lines?: boolean;
|
||||
}
|
||||
export type ScopeStore = Record<string, ValueReference[] | undefined>;
|
||||
type ScopeValues = {
|
||||
[Prefix in string]?: Map<unknown, ValueScopeName>;
|
||||
};
|
||||
export type ScopeValueSets = {
|
||||
[Prefix in string]?: Set<ValueScopeName>;
|
||||
};
|
||||
export declare enum UsedValueState {
|
||||
Started = 0,
|
||||
Completed = 1
|
||||
}
|
||||
export type UsedScopeValues = {
|
||||
[Prefix in string]?: Map<ValueScopeName, UsedValueState | undefined>;
|
||||
};
|
||||
export declare const varKinds: {
|
||||
const: Name;
|
||||
let: Name;
|
||||
var: Name;
|
||||
};
|
||||
export declare class Scope {
|
||||
protected readonly _names: {
|
||||
[Prefix in string]?: NameGroup;
|
||||
};
|
||||
protected readonly _prefixes?: Set<string>;
|
||||
protected readonly _parent?: Scope;
|
||||
constructor({ prefixes, parent }?: ScopeOptions);
|
||||
toName(nameOrPrefix: Name | string): Name;
|
||||
name(prefix: string): Name;
|
||||
protected _newName(prefix: string): string;
|
||||
private _nameGroup;
|
||||
}
|
||||
interface ScopePath {
|
||||
property: string;
|
||||
itemIndex: number;
|
||||
}
|
||||
export declare class ValueScopeName extends Name {
|
||||
readonly prefix: string;
|
||||
value?: NameValue;
|
||||
scopePath?: Code;
|
||||
constructor(prefix: string, nameStr: string);
|
||||
setValue(value: NameValue, { property, itemIndex }: ScopePath): void;
|
||||
}
|
||||
interface VSOptions extends ValueScopeOptions {
|
||||
_n: Code;
|
||||
}
|
||||
export declare class ValueScope extends Scope {
|
||||
protected readonly _values: ScopeValues;
|
||||
protected readonly _scope: ScopeStore;
|
||||
readonly opts: VSOptions;
|
||||
constructor(opts: ValueScopeOptions);
|
||||
get(): ScopeStore;
|
||||
name(prefix: string): ValueScopeName;
|
||||
value(nameOrPrefix: ValueScopeName | string, value: NameValue): ValueScopeName;
|
||||
getValue(prefix: string, keyOrRef: unknown): ValueScopeName | undefined;
|
||||
scopeRefs(scopeName: Name, values?: ScopeValues | ScopeValueSets): Code;
|
||||
scopeCode(values?: ScopeValues | ScopeValueSets, usedValues?: UsedScopeValues, getCode?: (n: ValueScopeName) => Code | undefined): Code;
|
||||
private _reduceValues;
|
||||
}
|
||||
export {};
|
143
my-app/node_modules/ajv/dist/compile/codegen/scope.js
generated
vendored
Executable file
143
my-app/node_modules/ajv/dist/compile/codegen/scope.js
generated
vendored
Executable file
|
@ -0,0 +1,143 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ValueScope = exports.ValueScopeName = exports.Scope = exports.varKinds = exports.UsedValueState = void 0;
|
||||
const code_1 = require("./code");
|
||||
class ValueError extends Error {
|
||||
constructor(name) {
|
||||
super(`CodeGen: "code" for ${name} not defined`);
|
||||
this.value = name.value;
|
||||
}
|
||||
}
|
||||
var UsedValueState;
|
||||
(function (UsedValueState) {
|
||||
UsedValueState[UsedValueState["Started"] = 0] = "Started";
|
||||
UsedValueState[UsedValueState["Completed"] = 1] = "Completed";
|
||||
})(UsedValueState = exports.UsedValueState || (exports.UsedValueState = {}));
|
||||
exports.varKinds = {
|
||||
const: new code_1.Name("const"),
|
||||
let: new code_1.Name("let"),
|
||||
var: new code_1.Name("var"),
|
||||
};
|
||||
class Scope {
|
||||
constructor({ prefixes, parent } = {}) {
|
||||
this._names = {};
|
||||
this._prefixes = prefixes;
|
||||
this._parent = parent;
|
||||
}
|
||||
toName(nameOrPrefix) {
|
||||
return nameOrPrefix instanceof code_1.Name ? nameOrPrefix : this.name(nameOrPrefix);
|
||||
}
|
||||
name(prefix) {
|
||||
return new code_1.Name(this._newName(prefix));
|
||||
}
|
||||
_newName(prefix) {
|
||||
const ng = this._names[prefix] || this._nameGroup(prefix);
|
||||
return `${prefix}${ng.index++}`;
|
||||
}
|
||||
_nameGroup(prefix) {
|
||||
var _a, _b;
|
||||
if (((_b = (_a = this._parent) === null || _a === void 0 ? void 0 : _a._prefixes) === null || _b === void 0 ? void 0 : _b.has(prefix)) || (this._prefixes && !this._prefixes.has(prefix))) {
|
||||
throw new Error(`CodeGen: prefix "${prefix}" is not allowed in this scope`);
|
||||
}
|
||||
return (this._names[prefix] = { prefix, index: 0 });
|
||||
}
|
||||
}
|
||||
exports.Scope = Scope;
|
||||
class ValueScopeName extends code_1.Name {
|
||||
constructor(prefix, nameStr) {
|
||||
super(nameStr);
|
||||
this.prefix = prefix;
|
||||
}
|
||||
setValue(value, { property, itemIndex }) {
|
||||
this.value = value;
|
||||
this.scopePath = (0, code_1._) `.${new code_1.Name(property)}[${itemIndex}]`;
|
||||
}
|
||||
}
|
||||
exports.ValueScopeName = ValueScopeName;
|
||||
const line = (0, code_1._) `\n`;
|
||||
class ValueScope extends Scope {
|
||||
constructor(opts) {
|
||||
super(opts);
|
||||
this._values = {};
|
||||
this._scope = opts.scope;
|
||||
this.opts = { ...opts, _n: opts.lines ? line : code_1.nil };
|
||||
}
|
||||
get() {
|
||||
return this._scope;
|
||||
}
|
||||
name(prefix) {
|
||||
return new ValueScopeName(prefix, this._newName(prefix));
|
||||
}
|
||||
value(nameOrPrefix, value) {
|
||||
var _a;
|
||||
if (value.ref === undefined)
|
||||
throw new Error("CodeGen: ref must be passed in value");
|
||||
const name = this.toName(nameOrPrefix);
|
||||
const { prefix } = name;
|
||||
const valueKey = (_a = value.key) !== null && _a !== void 0 ? _a : value.ref;
|
||||
let vs = this._values[prefix];
|
||||
if (vs) {
|
||||
const _name = vs.get(valueKey);
|
||||
if (_name)
|
||||
return _name;
|
||||
}
|
||||
else {
|
||||
vs = this._values[prefix] = new Map();
|
||||
}
|
||||
vs.set(valueKey, name);
|
||||
const s = this._scope[prefix] || (this._scope[prefix] = []);
|
||||
const itemIndex = s.length;
|
||||
s[itemIndex] = value.ref;
|
||||
name.setValue(value, { property: prefix, itemIndex });
|
||||
return name;
|
||||
}
|
||||
getValue(prefix, keyOrRef) {
|
||||
const vs = this._values[prefix];
|
||||
if (!vs)
|
||||
return;
|
||||
return vs.get(keyOrRef);
|
||||
}
|
||||
scopeRefs(scopeName, values = this._values) {
|
||||
return this._reduceValues(values, (name) => {
|
||||
if (name.scopePath === undefined)
|
||||
throw new Error(`CodeGen: name "${name}" has no value`);
|
||||
return (0, code_1._) `${scopeName}${name.scopePath}`;
|
||||
});
|
||||
}
|
||||
scopeCode(values = this._values, usedValues, getCode) {
|
||||
return this._reduceValues(values, (name) => {
|
||||
if (name.value === undefined)
|
||||
throw new Error(`CodeGen: name "${name}" has no value`);
|
||||
return name.value.code;
|
||||
}, usedValues, getCode);
|
||||
}
|
||||
_reduceValues(values, valueCode, usedValues = {}, getCode) {
|
||||
let code = code_1.nil;
|
||||
for (const prefix in values) {
|
||||
const vs = values[prefix];
|
||||
if (!vs)
|
||||
continue;
|
||||
const nameSet = (usedValues[prefix] = usedValues[prefix] || new Map());
|
||||
vs.forEach((name) => {
|
||||
if (nameSet.has(name))
|
||||
return;
|
||||
nameSet.set(name, UsedValueState.Started);
|
||||
let c = valueCode(name);
|
||||
if (c) {
|
||||
const def = this.opts.es5 ? exports.varKinds.var : exports.varKinds.const;
|
||||
code = (0, code_1._) `${code}${def} ${name} = ${c};${this.opts._n}`;
|
||||
}
|
||||
else if ((c = getCode === null || getCode === void 0 ? void 0 : getCode(name))) {
|
||||
code = (0, code_1._) `${code}${c}${this.opts._n}`;
|
||||
}
|
||||
else {
|
||||
throw new ValueError(name);
|
||||
}
|
||||
nameSet.set(name, UsedValueState.Completed);
|
||||
});
|
||||
}
|
||||
return code;
|
||||
}
|
||||
}
|
||||
exports.ValueScope = ValueScope;
|
||||
//# sourceMappingURL=scope.js.map
|
1
my-app/node_modules/ajv/dist/compile/codegen/scope.js.map
generated
vendored
Executable file
1
my-app/node_modules/ajv/dist/compile/codegen/scope.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
13
my-app/node_modules/ajv/dist/compile/errors.d.ts
generated
vendored
Executable file
13
my-app/node_modules/ajv/dist/compile/errors.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,13 @@
|
|||
import type { KeywordErrorCxt, KeywordErrorDefinition } from "../types";
|
||||
import { CodeGen, Code, Name } from "./codegen";
|
||||
export declare const keywordError: KeywordErrorDefinition;
|
||||
export declare const keyword$DataError: KeywordErrorDefinition;
|
||||
export interface ErrorPaths {
|
||||
instancePath?: Code;
|
||||
schemaPath?: string;
|
||||
parentSchema?: boolean;
|
||||
}
|
||||
export declare function reportError(cxt: KeywordErrorCxt, error?: KeywordErrorDefinition, errorPaths?: ErrorPaths, overrideAllErrors?: boolean): void;
|
||||
export declare function reportExtraError(cxt: KeywordErrorCxt, error?: KeywordErrorDefinition, errorPaths?: ErrorPaths): void;
|
||||
export declare function resetErrorsCount(gen: CodeGen, errsCount: Name): void;
|
||||
export declare function extendErrors({ gen, keyword, schemaValue, data, errsCount, it, }: KeywordErrorCxt): void;
|
123
my-app/node_modules/ajv/dist/compile/errors.js
generated
vendored
Executable file
123
my-app/node_modules/ajv/dist/compile/errors.js
generated
vendored
Executable file
|
@ -0,0 +1,123 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.extendErrors = exports.resetErrorsCount = exports.reportExtraError = exports.reportError = exports.keyword$DataError = exports.keywordError = void 0;
|
||||
const codegen_1 = require("./codegen");
|
||||
const util_1 = require("./util");
|
||||
const names_1 = require("./names");
|
||||
exports.keywordError = {
|
||||
message: ({ keyword }) => (0, codegen_1.str) `must pass "${keyword}" keyword validation`,
|
||||
};
|
||||
exports.keyword$DataError = {
|
||||
message: ({ keyword, schemaType }) => schemaType
|
||||
? (0, codegen_1.str) `"${keyword}" keyword must be ${schemaType} ($data)`
|
||||
: (0, codegen_1.str) `"${keyword}" keyword is invalid ($data)`,
|
||||
};
|
||||
function reportError(cxt, error = exports.keywordError, errorPaths, overrideAllErrors) {
|
||||
const { it } = cxt;
|
||||
const { gen, compositeRule, allErrors } = it;
|
||||
const errObj = errorObjectCode(cxt, error, errorPaths);
|
||||
if (overrideAllErrors !== null && overrideAllErrors !== void 0 ? overrideAllErrors : (compositeRule || allErrors)) {
|
||||
addError(gen, errObj);
|
||||
}
|
||||
else {
|
||||
returnErrors(it, (0, codegen_1._) `[${errObj}]`);
|
||||
}
|
||||
}
|
||||
exports.reportError = reportError;
|
||||
function reportExtraError(cxt, error = exports.keywordError, errorPaths) {
|
||||
const { it } = cxt;
|
||||
const { gen, compositeRule, allErrors } = it;
|
||||
const errObj = errorObjectCode(cxt, error, errorPaths);
|
||||
addError(gen, errObj);
|
||||
if (!(compositeRule || allErrors)) {
|
||||
returnErrors(it, names_1.default.vErrors);
|
||||
}
|
||||
}
|
||||
exports.reportExtraError = reportExtraError;
|
||||
function resetErrorsCount(gen, errsCount) {
|
||||
gen.assign(names_1.default.errors, errsCount);
|
||||
gen.if((0, codegen_1._) `${names_1.default.vErrors} !== null`, () => gen.if(errsCount, () => gen.assign((0, codegen_1._) `${names_1.default.vErrors}.length`, errsCount), () => gen.assign(names_1.default.vErrors, null)));
|
||||
}
|
||||
exports.resetErrorsCount = resetErrorsCount;
|
||||
function extendErrors({ gen, keyword, schemaValue, data, errsCount, it, }) {
|
||||
/* istanbul ignore if */
|
||||
if (errsCount === undefined)
|
||||
throw new Error("ajv implementation error");
|
||||
const err = gen.name("err");
|
||||
gen.forRange("i", errsCount, names_1.default.errors, (i) => {
|
||||
gen.const(err, (0, codegen_1._) `${names_1.default.vErrors}[${i}]`);
|
||||
gen.if((0, codegen_1._) `${err}.instancePath === undefined`, () => gen.assign((0, codegen_1._) `${err}.instancePath`, (0, codegen_1.strConcat)(names_1.default.instancePath, it.errorPath)));
|
||||
gen.assign((0, codegen_1._) `${err}.schemaPath`, (0, codegen_1.str) `${it.errSchemaPath}/${keyword}`);
|
||||
if (it.opts.verbose) {
|
||||
gen.assign((0, codegen_1._) `${err}.schema`, schemaValue);
|
||||
gen.assign((0, codegen_1._) `${err}.data`, data);
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.extendErrors = extendErrors;
|
||||
function addError(gen, errObj) {
|
||||
const err = gen.const("err", errObj);
|
||||
gen.if((0, codegen_1._) `${names_1.default.vErrors} === null`, () => gen.assign(names_1.default.vErrors, (0, codegen_1._) `[${err}]`), (0, codegen_1._) `${names_1.default.vErrors}.push(${err})`);
|
||||
gen.code((0, codegen_1._) `${names_1.default.errors}++`);
|
||||
}
|
||||
function returnErrors(it, errs) {
|
||||
const { gen, validateName, schemaEnv } = it;
|
||||
if (schemaEnv.$async) {
|
||||
gen.throw((0, codegen_1._) `new ${it.ValidationError}(${errs})`);
|
||||
}
|
||||
else {
|
||||
gen.assign((0, codegen_1._) `${validateName}.errors`, errs);
|
||||
gen.return(false);
|
||||
}
|
||||
}
|
||||
const E = {
|
||||
keyword: new codegen_1.Name("keyword"),
|
||||
schemaPath: new codegen_1.Name("schemaPath"),
|
||||
params: new codegen_1.Name("params"),
|
||||
propertyName: new codegen_1.Name("propertyName"),
|
||||
message: new codegen_1.Name("message"),
|
||||
schema: new codegen_1.Name("schema"),
|
||||
parentSchema: new codegen_1.Name("parentSchema"),
|
||||
};
|
||||
function errorObjectCode(cxt, error, errorPaths) {
|
||||
const { createErrors } = cxt.it;
|
||||
if (createErrors === false)
|
||||
return (0, codegen_1._) `{}`;
|
||||
return errorObject(cxt, error, errorPaths);
|
||||
}
|
||||
function errorObject(cxt, error, errorPaths = {}) {
|
||||
const { gen, it } = cxt;
|
||||
const keyValues = [
|
||||
errorInstancePath(it, errorPaths),
|
||||
errorSchemaPath(cxt, errorPaths),
|
||||
];
|
||||
extraErrorProps(cxt, error, keyValues);
|
||||
return gen.object(...keyValues);
|
||||
}
|
||||
function errorInstancePath({ errorPath }, { instancePath }) {
|
||||
const instPath = instancePath
|
||||
? (0, codegen_1.str) `${errorPath}${(0, util_1.getErrorPath)(instancePath, util_1.Type.Str)}`
|
||||
: errorPath;
|
||||
return [names_1.default.instancePath, (0, codegen_1.strConcat)(names_1.default.instancePath, instPath)];
|
||||
}
|
||||
function errorSchemaPath({ keyword, it: { errSchemaPath } }, { schemaPath, parentSchema }) {
|
||||
let schPath = parentSchema ? errSchemaPath : (0, codegen_1.str) `${errSchemaPath}/${keyword}`;
|
||||
if (schemaPath) {
|
||||
schPath = (0, codegen_1.str) `${schPath}${(0, util_1.getErrorPath)(schemaPath, util_1.Type.Str)}`;
|
||||
}
|
||||
return [E.schemaPath, schPath];
|
||||
}
|
||||
function extraErrorProps(cxt, { params, message }, keyValues) {
|
||||
const { keyword, data, schemaValue, it } = cxt;
|
||||
const { opts, propertyName, topSchemaRef, schemaPath } = it;
|
||||
keyValues.push([E.keyword, keyword], [E.params, typeof params == "function" ? params(cxt) : params || (0, codegen_1._) `{}`]);
|
||||
if (opts.messages) {
|
||||
keyValues.push([E.message, typeof message == "function" ? message(cxt) : message]);
|
||||
}
|
||||
if (opts.verbose) {
|
||||
keyValues.push([E.schema, schemaValue], [E.parentSchema, (0, codegen_1._) `${topSchemaRef}${schemaPath}`], [names_1.default.data, data]);
|
||||
}
|
||||
if (propertyName)
|
||||
keyValues.push([E.propertyName, propertyName]);
|
||||
}
|
||||
//# sourceMappingURL=errors.js.map
|
1
my-app/node_modules/ajv/dist/compile/errors.js.map
generated
vendored
Executable file
1
my-app/node_modules/ajv/dist/compile/errors.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
80
my-app/node_modules/ajv/dist/compile/index.d.ts
generated
vendored
Executable file
80
my-app/node_modules/ajv/dist/compile/index.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,80 @@
|
|||
import type { AnySchema, AnySchemaObject, AnyValidateFunction, EvaluatedProperties, EvaluatedItems } from "../types";
|
||||
import type Ajv from "../core";
|
||||
import type { InstanceOptions } from "../core";
|
||||
import { CodeGen, Name, Code, ValueScopeName } from "./codegen";
|
||||
import { LocalRefs } from "./resolve";
|
||||
import { JSONType } from "./rules";
|
||||
export type SchemaRefs = {
|
||||
[Ref in string]?: SchemaEnv | AnySchema;
|
||||
};
|
||||
export interface SchemaCxt {
|
||||
readonly gen: CodeGen;
|
||||
readonly allErrors?: boolean;
|
||||
readonly data: Name;
|
||||
readonly parentData: Name;
|
||||
readonly parentDataProperty: Code | number;
|
||||
readonly dataNames: Name[];
|
||||
readonly dataPathArr: (Code | number)[];
|
||||
readonly dataLevel: number;
|
||||
dataTypes: JSONType[];
|
||||
definedProperties: Set<string>;
|
||||
readonly topSchemaRef: Code;
|
||||
readonly validateName: Name;
|
||||
evaluated?: Name;
|
||||
readonly ValidationError?: Name;
|
||||
readonly schema: AnySchema;
|
||||
readonly schemaEnv: SchemaEnv;
|
||||
readonly rootId: string;
|
||||
baseId: string;
|
||||
readonly schemaPath: Code;
|
||||
readonly errSchemaPath: string;
|
||||
readonly errorPath: Code;
|
||||
readonly propertyName?: Name;
|
||||
readonly compositeRule?: boolean;
|
||||
props?: EvaluatedProperties | Name;
|
||||
items?: EvaluatedItems | Name;
|
||||
jtdDiscriminator?: string;
|
||||
jtdMetadata?: boolean;
|
||||
readonly createErrors?: boolean;
|
||||
readonly opts: InstanceOptions;
|
||||
readonly self: Ajv;
|
||||
}
|
||||
export interface SchemaObjCxt extends SchemaCxt {
|
||||
readonly schema: AnySchemaObject;
|
||||
}
|
||||
interface SchemaEnvArgs {
|
||||
readonly schema: AnySchema;
|
||||
readonly schemaId?: "$id" | "id";
|
||||
readonly root?: SchemaEnv;
|
||||
readonly baseId?: string;
|
||||
readonly schemaPath?: string;
|
||||
readonly localRefs?: LocalRefs;
|
||||
readonly meta?: boolean;
|
||||
}
|
||||
export declare class SchemaEnv implements SchemaEnvArgs {
|
||||
readonly schema: AnySchema;
|
||||
readonly schemaId?: "$id" | "id";
|
||||
readonly root: SchemaEnv;
|
||||
baseId: string;
|
||||
schemaPath?: string;
|
||||
localRefs?: LocalRefs;
|
||||
readonly meta?: boolean;
|
||||
readonly $async?: boolean;
|
||||
readonly refs: SchemaRefs;
|
||||
readonly dynamicAnchors: {
|
||||
[Ref in string]?: true;
|
||||
};
|
||||
validate?: AnyValidateFunction;
|
||||
validateName?: ValueScopeName;
|
||||
serialize?: (data: unknown) => string;
|
||||
serializeName?: ValueScopeName;
|
||||
parse?: (data: string) => unknown;
|
||||
parseName?: ValueScopeName;
|
||||
constructor(env: SchemaEnvArgs);
|
||||
}
|
||||
export declare function compileSchema(this: Ajv, sch: SchemaEnv): SchemaEnv;
|
||||
export declare function resolveRef(this: Ajv, root: SchemaEnv, baseId: string, ref: string): AnySchema | SchemaEnv | undefined;
|
||||
export declare function getCompilingSchema(this: Ajv, schEnv: SchemaEnv): SchemaEnv | void;
|
||||
export declare function resolveSchema(this: Ajv, root: SchemaEnv, // root object with properties schema, refs TODO below SchemaEnv is assigned to it
|
||||
ref: string): SchemaEnv | undefined;
|
||||
export {};
|
242
my-app/node_modules/ajv/dist/compile/index.js
generated
vendored
Executable file
242
my-app/node_modules/ajv/dist/compile/index.js
generated
vendored
Executable file
|
@ -0,0 +1,242 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.resolveSchema = exports.getCompilingSchema = exports.resolveRef = exports.compileSchema = exports.SchemaEnv = void 0;
|
||||
const codegen_1 = require("./codegen");
|
||||
const validation_error_1 = require("../runtime/validation_error");
|
||||
const names_1 = require("./names");
|
||||
const resolve_1 = require("./resolve");
|
||||
const util_1 = require("./util");
|
||||
const validate_1 = require("./validate");
|
||||
class SchemaEnv {
|
||||
constructor(env) {
|
||||
var _a;
|
||||
this.refs = {};
|
||||
this.dynamicAnchors = {};
|
||||
let schema;
|
||||
if (typeof env.schema == "object")
|
||||
schema = env.schema;
|
||||
this.schema = env.schema;
|
||||
this.schemaId = env.schemaId;
|
||||
this.root = env.root || this;
|
||||
this.baseId = (_a = env.baseId) !== null && _a !== void 0 ? _a : (0, resolve_1.normalizeId)(schema === null || schema === void 0 ? void 0 : schema[env.schemaId || "$id"]);
|
||||
this.schemaPath = env.schemaPath;
|
||||
this.localRefs = env.localRefs;
|
||||
this.meta = env.meta;
|
||||
this.$async = schema === null || schema === void 0 ? void 0 : schema.$async;
|
||||
this.refs = {};
|
||||
}
|
||||
}
|
||||
exports.SchemaEnv = SchemaEnv;
|
||||
// let codeSize = 0
|
||||
// let nodeCount = 0
|
||||
// Compiles schema in SchemaEnv
|
||||
function compileSchema(sch) {
|
||||
// TODO refactor - remove compilations
|
||||
const _sch = getCompilingSchema.call(this, sch);
|
||||
if (_sch)
|
||||
return _sch;
|
||||
const rootId = (0, resolve_1.getFullPath)(this.opts.uriResolver, sch.root.baseId); // TODO if getFullPath removed 1 tests fails
|
||||
const { es5, lines } = this.opts.code;
|
||||
const { ownProperties } = this.opts;
|
||||
const gen = new codegen_1.CodeGen(this.scope, { es5, lines, ownProperties });
|
||||
let _ValidationError;
|
||||
if (sch.$async) {
|
||||
_ValidationError = gen.scopeValue("Error", {
|
||||
ref: validation_error_1.default,
|
||||
code: (0, codegen_1._) `require("ajv/dist/runtime/validation_error").default`,
|
||||
});
|
||||
}
|
||||
const validateName = gen.scopeName("validate");
|
||||
sch.validateName = validateName;
|
||||
const schemaCxt = {
|
||||
gen,
|
||||
allErrors: this.opts.allErrors,
|
||||
data: names_1.default.data,
|
||||
parentData: names_1.default.parentData,
|
||||
parentDataProperty: names_1.default.parentDataProperty,
|
||||
dataNames: [names_1.default.data],
|
||||
dataPathArr: [codegen_1.nil],
|
||||
dataLevel: 0,
|
||||
dataTypes: [],
|
||||
definedProperties: new Set(),
|
||||
topSchemaRef: gen.scopeValue("schema", this.opts.code.source === true
|
||||
? { ref: sch.schema, code: (0, codegen_1.stringify)(sch.schema) }
|
||||
: { ref: sch.schema }),
|
||||
validateName,
|
||||
ValidationError: _ValidationError,
|
||||
schema: sch.schema,
|
||||
schemaEnv: sch,
|
||||
rootId,
|
||||
baseId: sch.baseId || rootId,
|
||||
schemaPath: codegen_1.nil,
|
||||
errSchemaPath: sch.schemaPath || (this.opts.jtd ? "" : "#"),
|
||||
errorPath: (0, codegen_1._) `""`,
|
||||
opts: this.opts,
|
||||
self: this,
|
||||
};
|
||||
let sourceCode;
|
||||
try {
|
||||
this._compilations.add(sch);
|
||||
(0, validate_1.validateFunctionCode)(schemaCxt);
|
||||
gen.optimize(this.opts.code.optimize);
|
||||
// gen.optimize(1)
|
||||
const validateCode = gen.toString();
|
||||
sourceCode = `${gen.scopeRefs(names_1.default.scope)}return ${validateCode}`;
|
||||
// console.log((codeSize += sourceCode.length), (nodeCount += gen.nodeCount))
|
||||
if (this.opts.code.process)
|
||||
sourceCode = this.opts.code.process(sourceCode, sch);
|
||||
// console.log("\n\n\n *** \n", sourceCode)
|
||||
const makeValidate = new Function(`${names_1.default.self}`, `${names_1.default.scope}`, sourceCode);
|
||||
const validate = makeValidate(this, this.scope.get());
|
||||
this.scope.value(validateName, { ref: validate });
|
||||
validate.errors = null;
|
||||
validate.schema = sch.schema;
|
||||
validate.schemaEnv = sch;
|
||||
if (sch.$async)
|
||||
validate.$async = true;
|
||||
if (this.opts.code.source === true) {
|
||||
validate.source = { validateName, validateCode, scopeValues: gen._values };
|
||||
}
|
||||
if (this.opts.unevaluated) {
|
||||
const { props, items } = schemaCxt;
|
||||
validate.evaluated = {
|
||||
props: props instanceof codegen_1.Name ? undefined : props,
|
||||
items: items instanceof codegen_1.Name ? undefined : items,
|
||||
dynamicProps: props instanceof codegen_1.Name,
|
||||
dynamicItems: items instanceof codegen_1.Name,
|
||||
};
|
||||
if (validate.source)
|
||||
validate.source.evaluated = (0, codegen_1.stringify)(validate.evaluated);
|
||||
}
|
||||
sch.validate = validate;
|
||||
return sch;
|
||||
}
|
||||
catch (e) {
|
||||
delete sch.validate;
|
||||
delete sch.validateName;
|
||||
if (sourceCode)
|
||||
this.logger.error("Error compiling schema, function code:", sourceCode);
|
||||
// console.log("\n\n\n *** \n", sourceCode, this.opts)
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
this._compilations.delete(sch);
|
||||
}
|
||||
}
|
||||
exports.compileSchema = compileSchema;
|
||||
function resolveRef(root, baseId, ref) {
|
||||
var _a;
|
||||
ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, ref);
|
||||
const schOrFunc = root.refs[ref];
|
||||
if (schOrFunc)
|
||||
return schOrFunc;
|
||||
let _sch = resolve.call(this, root, ref);
|
||||
if (_sch === undefined) {
|
||||
const schema = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref]; // TODO maybe localRefs should hold SchemaEnv
|
||||
const { schemaId } = this.opts;
|
||||
if (schema)
|
||||
_sch = new SchemaEnv({ schema, schemaId, root, baseId });
|
||||
}
|
||||
if (_sch === undefined)
|
||||
return;
|
||||
return (root.refs[ref] = inlineOrCompile.call(this, _sch));
|
||||
}
|
||||
exports.resolveRef = resolveRef;
|
||||
function inlineOrCompile(sch) {
|
||||
if ((0, resolve_1.inlineRef)(sch.schema, this.opts.inlineRefs))
|
||||
return sch.schema;
|
||||
return sch.validate ? sch : compileSchema.call(this, sch);
|
||||
}
|
||||
// Index of schema compilation in the currently compiled list
|
||||
function getCompilingSchema(schEnv) {
|
||||
for (const sch of this._compilations) {
|
||||
if (sameSchemaEnv(sch, schEnv))
|
||||
return sch;
|
||||
}
|
||||
}
|
||||
exports.getCompilingSchema = getCompilingSchema;
|
||||
function sameSchemaEnv(s1, s2) {
|
||||
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
||||
}
|
||||
// resolve and compile the references ($ref)
|
||||
// TODO returns AnySchemaObject (if the schema can be inlined) or validation function
|
||||
function resolve(root, // information about the root schema for the current schema
|
||||
ref // reference to resolve
|
||||
) {
|
||||
let sch;
|
||||
while (typeof (sch = this.refs[ref]) == "string")
|
||||
ref = sch;
|
||||
return sch || this.schemas[ref] || resolveSchema.call(this, root, ref);
|
||||
}
|
||||
// Resolve schema, its root and baseId
|
||||
function resolveSchema(root, // root object with properties schema, refs TODO below SchemaEnv is assigned to it
|
||||
ref // reference to resolve
|
||||
) {
|
||||
const p = this.opts.uriResolver.parse(ref);
|
||||
const refPath = (0, resolve_1._getFullPath)(this.opts.uriResolver, p);
|
||||
let baseId = (0, resolve_1.getFullPath)(this.opts.uriResolver, root.baseId, undefined);
|
||||
// TODO `Object.keys(root.schema).length > 0` should not be needed - but removing breaks 2 tests
|
||||
if (Object.keys(root.schema).length > 0 && refPath === baseId) {
|
||||
return getJsonPointer.call(this, p, root);
|
||||
}
|
||||
const id = (0, resolve_1.normalizeId)(refPath);
|
||||
const schOrRef = this.refs[id] || this.schemas[id];
|
||||
if (typeof schOrRef == "string") {
|
||||
const sch = resolveSchema.call(this, root, schOrRef);
|
||||
if (typeof (sch === null || sch === void 0 ? void 0 : sch.schema) !== "object")
|
||||
return;
|
||||
return getJsonPointer.call(this, p, sch);
|
||||
}
|
||||
if (typeof (schOrRef === null || schOrRef === void 0 ? void 0 : schOrRef.schema) !== "object")
|
||||
return;
|
||||
if (!schOrRef.validate)
|
||||
compileSchema.call(this, schOrRef);
|
||||
if (id === (0, resolve_1.normalizeId)(ref)) {
|
||||
const { schema } = schOrRef;
|
||||
const { schemaId } = this.opts;
|
||||
const schId = schema[schemaId];
|
||||
if (schId)
|
||||
baseId = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schId);
|
||||
return new SchemaEnv({ schema, schemaId, root, baseId });
|
||||
}
|
||||
return getJsonPointer.call(this, p, schOrRef);
|
||||
}
|
||||
exports.resolveSchema = resolveSchema;
|
||||
const PREVENT_SCOPE_CHANGE = new Set([
|
||||
"properties",
|
||||
"patternProperties",
|
||||
"enum",
|
||||
"dependencies",
|
||||
"definitions",
|
||||
]);
|
||||
function getJsonPointer(parsedRef, { baseId, schema, root }) {
|
||||
var _a;
|
||||
if (((_a = parsedRef.fragment) === null || _a === void 0 ? void 0 : _a[0]) !== "/")
|
||||
return;
|
||||
for (const part of parsedRef.fragment.slice(1).split("/")) {
|
||||
if (typeof schema === "boolean")
|
||||
return;
|
||||
const partSchema = schema[(0, util_1.unescapeFragment)(part)];
|
||||
if (partSchema === undefined)
|
||||
return;
|
||||
schema = partSchema;
|
||||
// TODO PREVENT_SCOPE_CHANGE could be defined in keyword def?
|
||||
const schId = typeof schema === "object" && schema[this.opts.schemaId];
|
||||
if (!PREVENT_SCOPE_CHANGE.has(part) && schId) {
|
||||
baseId = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schId);
|
||||
}
|
||||
}
|
||||
let env;
|
||||
if (typeof schema != "boolean" && schema.$ref && !(0, util_1.schemaHasRulesButRef)(schema, this.RULES)) {
|
||||
const $ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schema.$ref);
|
||||
env = resolveSchema.call(this, root, $ref);
|
||||
}
|
||||
// even though resolution failed we need to return SchemaEnv to throw exception
|
||||
// so that compileAsync loads missing schema.
|
||||
const { schemaId } = this.opts;
|
||||
env = env || new SchemaEnv({ schema, schemaId, root, baseId });
|
||||
if (env.schema !== env.root.schema)
|
||||
return env;
|
||||
return undefined;
|
||||
}
|
||||
//# sourceMappingURL=index.js.map
|
1
my-app/node_modules/ajv/dist/compile/index.js.map
generated
vendored
Executable file
1
my-app/node_modules/ajv/dist/compile/index.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
4
my-app/node_modules/ajv/dist/compile/jtd/parse.d.ts
generated
vendored
Executable file
4
my-app/node_modules/ajv/dist/compile/jtd/parse.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,4 @@
|
|||
import type Ajv from "../../core";
|
||||
import { SchemaObjectMap } from "./types";
|
||||
import { SchemaEnv } from "..";
|
||||
export default function compileParser(this: Ajv, sch: SchemaEnv, definitions: SchemaObjectMap): SchemaEnv;
|
350
my-app/node_modules/ajv/dist/compile/jtd/parse.js
generated
vendored
Executable file
350
my-app/node_modules/ajv/dist/compile/jtd/parse.js
generated
vendored
Executable file
|
@ -0,0 +1,350 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const types_1 = require("./types");
|
||||
const __1 = require("..");
|
||||
const codegen_1 = require("../codegen");
|
||||
const ref_error_1 = require("../ref_error");
|
||||
const names_1 = require("../names");
|
||||
const code_1 = require("../../vocabularies/code");
|
||||
const ref_1 = require("../../vocabularies/jtd/ref");
|
||||
const type_1 = require("../../vocabularies/jtd/type");
|
||||
const parseJson_1 = require("../../runtime/parseJson");
|
||||
const util_1 = require("../util");
|
||||
const timestamp_1 = require("../../runtime/timestamp");
|
||||
const genParse = {
|
||||
elements: parseElements,
|
||||
values: parseValues,
|
||||
discriminator: parseDiscriminator,
|
||||
properties: parseProperties,
|
||||
optionalProperties: parseProperties,
|
||||
enum: parseEnum,
|
||||
type: parseType,
|
||||
ref: parseRef,
|
||||
};
|
||||
function compileParser(sch, definitions) {
|
||||
const _sch = __1.getCompilingSchema.call(this, sch);
|
||||
if (_sch)
|
||||
return _sch;
|
||||
const { es5, lines } = this.opts.code;
|
||||
const { ownProperties } = this.opts;
|
||||
const gen = new codegen_1.CodeGen(this.scope, { es5, lines, ownProperties });
|
||||
const parseName = gen.scopeName("parse");
|
||||
const cxt = {
|
||||
self: this,
|
||||
gen,
|
||||
schema: sch.schema,
|
||||
schemaEnv: sch,
|
||||
definitions,
|
||||
data: names_1.default.data,
|
||||
parseName,
|
||||
char: gen.name("c"),
|
||||
};
|
||||
let sourceCode;
|
||||
try {
|
||||
this._compilations.add(sch);
|
||||
sch.parseName = parseName;
|
||||
parserFunction(cxt);
|
||||
gen.optimize(this.opts.code.optimize);
|
||||
const parseFuncCode = gen.toString();
|
||||
sourceCode = `${gen.scopeRefs(names_1.default.scope)}return ${parseFuncCode}`;
|
||||
const makeParse = new Function(`${names_1.default.scope}`, sourceCode);
|
||||
const parse = makeParse(this.scope.get());
|
||||
this.scope.value(parseName, { ref: parse });
|
||||
sch.parse = parse;
|
||||
}
|
||||
catch (e) {
|
||||
if (sourceCode)
|
||||
this.logger.error("Error compiling parser, function code:", sourceCode);
|
||||
delete sch.parse;
|
||||
delete sch.parseName;
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
this._compilations.delete(sch);
|
||||
}
|
||||
return sch;
|
||||
}
|
||||
exports.default = compileParser;
|
||||
const undef = (0, codegen_1._) `undefined`;
|
||||
function parserFunction(cxt) {
|
||||
const { gen, parseName, char } = cxt;
|
||||
gen.func(parseName, (0, codegen_1._) `${names_1.default.json}, ${names_1.default.jsonPos}, ${names_1.default.jsonPart}`, false, () => {
|
||||
gen.let(names_1.default.data);
|
||||
gen.let(char);
|
||||
gen.assign((0, codegen_1._) `${parseName}.message`, undef);
|
||||
gen.assign((0, codegen_1._) `${parseName}.position`, undef);
|
||||
gen.assign(names_1.default.jsonPos, (0, codegen_1._) `${names_1.default.jsonPos} || 0`);
|
||||
gen.const(names_1.default.jsonLen, (0, codegen_1._) `${names_1.default.json}.length`);
|
||||
parseCode(cxt);
|
||||
skipWhitespace(cxt);
|
||||
gen.if(names_1.default.jsonPart, () => {
|
||||
gen.assign((0, codegen_1._) `${parseName}.position`, names_1.default.jsonPos);
|
||||
gen.return(names_1.default.data);
|
||||
});
|
||||
gen.if((0, codegen_1._) `${names_1.default.jsonPos} === ${names_1.default.jsonLen}`, () => gen.return(names_1.default.data));
|
||||
jsonSyntaxError(cxt);
|
||||
});
|
||||
}
|
||||
function parseCode(cxt) {
|
||||
let form;
|
||||
for (const key of types_1.jtdForms) {
|
||||
if (key in cxt.schema) {
|
||||
form = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (form)
|
||||
parseNullable(cxt, genParse[form]);
|
||||
else
|
||||
parseEmpty(cxt);
|
||||
}
|
||||
const parseBoolean = parseBooleanToken(true, parseBooleanToken(false, jsonSyntaxError));
|
||||
function parseNullable(cxt, parseForm) {
|
||||
const { gen, schema, data } = cxt;
|
||||
if (!schema.nullable)
|
||||
return parseForm(cxt);
|
||||
tryParseToken(cxt, "null", parseForm, () => gen.assign(data, null));
|
||||
}
|
||||
function parseElements(cxt) {
|
||||
const { gen, schema, data } = cxt;
|
||||
parseToken(cxt, "[");
|
||||
const ix = gen.let("i", 0);
|
||||
gen.assign(data, (0, codegen_1._) `[]`);
|
||||
parseItems(cxt, "]", () => {
|
||||
const el = gen.let("el");
|
||||
parseCode({ ...cxt, schema: schema.elements, data: el });
|
||||
gen.assign((0, codegen_1._) `${data}[${ix}++]`, el);
|
||||
});
|
||||
}
|
||||
function parseValues(cxt) {
|
||||
const { gen, schema, data } = cxt;
|
||||
parseToken(cxt, "{");
|
||||
gen.assign(data, (0, codegen_1._) `{}`);
|
||||
parseItems(cxt, "}", () => parseKeyValue(cxt, schema.values));
|
||||
}
|
||||
function parseItems(cxt, endToken, block) {
|
||||
tryParseItems(cxt, endToken, block);
|
||||
parseToken(cxt, endToken);
|
||||
}
|
||||
function tryParseItems(cxt, endToken, block) {
|
||||
const { gen } = cxt;
|
||||
gen.for((0, codegen_1._) `;${names_1.default.jsonPos}<${names_1.default.jsonLen} && ${jsonSlice(1)}!==${endToken};`, () => {
|
||||
block();
|
||||
tryParseToken(cxt, ",", () => gen.break(), hasItem);
|
||||
});
|
||||
function hasItem() {
|
||||
tryParseToken(cxt, endToken, () => { }, jsonSyntaxError);
|
||||
}
|
||||
}
|
||||
function parseKeyValue(cxt, schema) {
|
||||
const { gen } = cxt;
|
||||
const key = gen.let("key");
|
||||
parseString({ ...cxt, data: key });
|
||||
parseToken(cxt, ":");
|
||||
parsePropertyValue(cxt, key, schema);
|
||||
}
|
||||
function parseDiscriminator(cxt) {
|
||||
const { gen, data, schema } = cxt;
|
||||
const { discriminator, mapping } = schema;
|
||||
parseToken(cxt, "{");
|
||||
gen.assign(data, (0, codegen_1._) `{}`);
|
||||
const startPos = gen.const("pos", names_1.default.jsonPos);
|
||||
const value = gen.let("value");
|
||||
const tag = gen.let("tag");
|
||||
tryParseItems(cxt, "}", () => {
|
||||
const key = gen.let("key");
|
||||
parseString({ ...cxt, data: key });
|
||||
parseToken(cxt, ":");
|
||||
gen.if((0, codegen_1._) `${key} === ${discriminator}`, () => {
|
||||
parseString({ ...cxt, data: tag });
|
||||
gen.assign((0, codegen_1._) `${data}[${key}]`, tag);
|
||||
gen.break();
|
||||
}, () => parseEmpty({ ...cxt, data: value }) // can be discarded/skipped
|
||||
);
|
||||
});
|
||||
gen.assign(names_1.default.jsonPos, startPos);
|
||||
gen.if((0, codegen_1._) `${tag} === undefined`);
|
||||
parsingError(cxt, (0, codegen_1.str) `discriminator tag not found`);
|
||||
for (const tagValue in mapping) {
|
||||
gen.elseIf((0, codegen_1._) `${tag} === ${tagValue}`);
|
||||
parseSchemaProperties({ ...cxt, schema: mapping[tagValue] }, discriminator);
|
||||
}
|
||||
gen.else();
|
||||
parsingError(cxt, (0, codegen_1.str) `discriminator value not in schema`);
|
||||
gen.endIf();
|
||||
}
|
||||
function parseProperties(cxt) {
|
||||
const { gen, data } = cxt;
|
||||
parseToken(cxt, "{");
|
||||
gen.assign(data, (0, codegen_1._) `{}`);
|
||||
parseSchemaProperties(cxt);
|
||||
}
|
||||
function parseSchemaProperties(cxt, discriminator) {
|
||||
const { gen, schema, data } = cxt;
|
||||
const { properties, optionalProperties, additionalProperties } = schema;
|
||||
parseItems(cxt, "}", () => {
|
||||
const key = gen.let("key");
|
||||
parseString({ ...cxt, data: key });
|
||||
parseToken(cxt, ":");
|
||||
gen.if(false);
|
||||
parseDefinedProperty(cxt, key, properties);
|
||||
parseDefinedProperty(cxt, key, optionalProperties);
|
||||
if (discriminator) {
|
||||
gen.elseIf((0, codegen_1._) `${key} === ${discriminator}`);
|
||||
const tag = gen.let("tag");
|
||||
parseString({ ...cxt, data: tag }); // can be discarded, it is already assigned
|
||||
}
|
||||
gen.else();
|
||||
if (additionalProperties) {
|
||||
parseEmpty({ ...cxt, data: (0, codegen_1._) `${data}[${key}]` });
|
||||
}
|
||||
else {
|
||||
parsingError(cxt, (0, codegen_1.str) `property ${key} not allowed`);
|
||||
}
|
||||
gen.endIf();
|
||||
});
|
||||
if (properties) {
|
||||
const hasProp = (0, code_1.hasPropFunc)(gen);
|
||||
const allProps = (0, codegen_1.and)(...Object.keys(properties).map((p) => (0, codegen_1._) `${hasProp}.call(${data}, ${p})`));
|
||||
gen.if((0, codegen_1.not)(allProps), () => parsingError(cxt, (0, codegen_1.str) `missing required properties`));
|
||||
}
|
||||
}
|
||||
function parseDefinedProperty(cxt, key, schemas = {}) {
|
||||
const { gen } = cxt;
|
||||
for (const prop in schemas) {
|
||||
gen.elseIf((0, codegen_1._) `${key} === ${prop}`);
|
||||
parsePropertyValue(cxt, key, schemas[prop]);
|
||||
}
|
||||
}
|
||||
function parsePropertyValue(cxt, key, schema) {
|
||||
parseCode({ ...cxt, schema, data: (0, codegen_1._) `${cxt.data}[${key}]` });
|
||||
}
|
||||
function parseType(cxt) {
|
||||
const { gen, schema, data, self } = cxt;
|
||||
switch (schema.type) {
|
||||
case "boolean":
|
||||
parseBoolean(cxt);
|
||||
break;
|
||||
case "string":
|
||||
parseString(cxt);
|
||||
break;
|
||||
case "timestamp": {
|
||||
parseString(cxt);
|
||||
const vts = (0, util_1.useFunc)(gen, timestamp_1.default);
|
||||
const { allowDate, parseDate } = self.opts;
|
||||
const notValid = allowDate ? (0, codegen_1._) `!${vts}(${data}, true)` : (0, codegen_1._) `!${vts}(${data})`;
|
||||
const fail = parseDate
|
||||
? (0, codegen_1.or)(notValid, (0, codegen_1._) `(${data} = new Date(${data}), false)`, (0, codegen_1._) `isNaN(${data}.valueOf())`)
|
||||
: notValid;
|
||||
gen.if(fail, () => parsingError(cxt, (0, codegen_1.str) `invalid timestamp`));
|
||||
break;
|
||||
}
|
||||
case "float32":
|
||||
case "float64":
|
||||
parseNumber(cxt);
|
||||
break;
|
||||
default: {
|
||||
const t = schema.type;
|
||||
if (!self.opts.int32range && (t === "int32" || t === "uint32")) {
|
||||
parseNumber(cxt, 16); // 2 ** 53 - max safe integer
|
||||
if (t === "uint32") {
|
||||
gen.if((0, codegen_1._) `${data} < 0`, () => parsingError(cxt, (0, codegen_1.str) `integer out of range`));
|
||||
}
|
||||
}
|
||||
else {
|
||||
const [min, max, maxDigits] = type_1.intRange[t];
|
||||
parseNumber(cxt, maxDigits);
|
||||
gen.if((0, codegen_1._) `${data} < ${min} || ${data} > ${max}`, () => parsingError(cxt, (0, codegen_1.str) `integer out of range`));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function parseString(cxt) {
|
||||
parseToken(cxt, '"');
|
||||
parseWith(cxt, parseJson_1.parseJsonString);
|
||||
}
|
||||
function parseEnum(cxt) {
|
||||
const { gen, data, schema } = cxt;
|
||||
const enumSch = schema.enum;
|
||||
parseToken(cxt, '"');
|
||||
// TODO loopEnum
|
||||
gen.if(false);
|
||||
for (const value of enumSch) {
|
||||
const valueStr = JSON.stringify(value).slice(1); // remove starting quote
|
||||
gen.elseIf((0, codegen_1._) `${jsonSlice(valueStr.length)} === ${valueStr}`);
|
||||
gen.assign(data, (0, codegen_1.str) `${value}`);
|
||||
gen.add(names_1.default.jsonPos, valueStr.length);
|
||||
}
|
||||
gen.else();
|
||||
jsonSyntaxError(cxt);
|
||||
gen.endIf();
|
||||
}
|
||||
function parseNumber(cxt, maxDigits) {
|
||||
const { gen } = cxt;
|
||||
skipWhitespace(cxt);
|
||||
gen.if((0, codegen_1._) `"-0123456789".indexOf(${jsonSlice(1)}) < 0`, () => jsonSyntaxError(cxt), () => parseWith(cxt, parseJson_1.parseJsonNumber, maxDigits));
|
||||
}
|
||||
function parseBooleanToken(bool, fail) {
|
||||
return (cxt) => {
|
||||
const { gen, data } = cxt;
|
||||
tryParseToken(cxt, `${bool}`, () => fail(cxt), () => gen.assign(data, bool));
|
||||
};
|
||||
}
|
||||
function parseRef(cxt) {
|
||||
const { gen, self, definitions, schema, schemaEnv } = cxt;
|
||||
const { ref } = schema;
|
||||
const refSchema = definitions[ref];
|
||||
if (!refSchema)
|
||||
throw new ref_error_1.default(self.opts.uriResolver, "", ref, `No definition ${ref}`);
|
||||
if (!(0, ref_1.hasRef)(refSchema))
|
||||
return parseCode({ ...cxt, schema: refSchema });
|
||||
const { root } = schemaEnv;
|
||||
const sch = compileParser.call(self, new __1.SchemaEnv({ schema: refSchema, root }), definitions);
|
||||
partialParse(cxt, getParser(gen, sch), true);
|
||||
}
|
||||
function getParser(gen, sch) {
|
||||
return sch.parse
|
||||
? gen.scopeValue("parse", { ref: sch.parse })
|
||||
: (0, codegen_1._) `${gen.scopeValue("wrapper", { ref: sch })}.parse`;
|
||||
}
|
||||
function parseEmpty(cxt) {
|
||||
parseWith(cxt, parseJson_1.parseJson);
|
||||
}
|
||||
function parseWith(cxt, parseFunc, args) {
|
||||
partialParse(cxt, (0, util_1.useFunc)(cxt.gen, parseFunc), args);
|
||||
}
|
||||
function partialParse(cxt, parseFunc, args) {
|
||||
const { gen, data } = cxt;
|
||||
gen.assign(data, (0, codegen_1._) `${parseFunc}(${names_1.default.json}, ${names_1.default.jsonPos}${args ? (0, codegen_1._) `, ${args}` : codegen_1.nil})`);
|
||||
gen.assign(names_1.default.jsonPos, (0, codegen_1._) `${parseFunc}.position`);
|
||||
gen.if((0, codegen_1._) `${data} === undefined`, () => parsingError(cxt, (0, codegen_1._) `${parseFunc}.message`));
|
||||
}
|
||||
function parseToken(cxt, tok) {
|
||||
tryParseToken(cxt, tok, jsonSyntaxError);
|
||||
}
|
||||
function tryParseToken(cxt, tok, fail, success) {
|
||||
const { gen } = cxt;
|
||||
const n = tok.length;
|
||||
skipWhitespace(cxt);
|
||||
gen.if((0, codegen_1._) `${jsonSlice(n)} === ${tok}`, () => {
|
||||
gen.add(names_1.default.jsonPos, n);
|
||||
success === null || success === void 0 ? void 0 : success(cxt);
|
||||
}, () => fail(cxt));
|
||||
}
|
||||
function skipWhitespace({ gen, char: c }) {
|
||||
gen.code((0, codegen_1._) `while((${c}=${names_1.default.json}[${names_1.default.jsonPos}],${c}===" "||${c}==="\\n"||${c}==="\\r"||${c}==="\\t"))${names_1.default.jsonPos}++;`);
|
||||
}
|
||||
function jsonSlice(len) {
|
||||
return len === 1
|
||||
? (0, codegen_1._) `${names_1.default.json}[${names_1.default.jsonPos}]`
|
||||
: (0, codegen_1._) `${names_1.default.json}.slice(${names_1.default.jsonPos}, ${names_1.default.jsonPos}+${len})`;
|
||||
}
|
||||
function jsonSyntaxError(cxt) {
|
||||
parsingError(cxt, (0, codegen_1._) `"unexpected token " + ${names_1.default.json}[${names_1.default.jsonPos}]`);
|
||||
}
|
||||
function parsingError({ gen, parseName }, msg) {
|
||||
gen.assign((0, codegen_1._) `${parseName}.message`, msg);
|
||||
gen.assign((0, codegen_1._) `${parseName}.position`, names_1.default.jsonPos);
|
||||
gen.return(undef);
|
||||
}
|
||||
//# sourceMappingURL=parse.js.map
|
1
my-app/node_modules/ajv/dist/compile/jtd/parse.js.map
generated
vendored
Executable file
1
my-app/node_modules/ajv/dist/compile/jtd/parse.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
4
my-app/node_modules/ajv/dist/compile/jtd/serialize.d.ts
generated
vendored
Executable file
4
my-app/node_modules/ajv/dist/compile/jtd/serialize.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,4 @@
|
|||
import type Ajv from "../../core";
|
||||
import { SchemaObjectMap } from "./types";
|
||||
import { SchemaEnv } from "..";
|
||||
export default function compileSerializer(this: Ajv, sch: SchemaEnv, definitions: SchemaObjectMap): SchemaEnv;
|
229
my-app/node_modules/ajv/dist/compile/jtd/serialize.js
generated
vendored
Executable file
229
my-app/node_modules/ajv/dist/compile/jtd/serialize.js
generated
vendored
Executable file
|
@ -0,0 +1,229 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const types_1 = require("./types");
|
||||
const __1 = require("..");
|
||||
const codegen_1 = require("../codegen");
|
||||
const ref_error_1 = require("../ref_error");
|
||||
const names_1 = require("../names");
|
||||
const code_1 = require("../../vocabularies/code");
|
||||
const ref_1 = require("../../vocabularies/jtd/ref");
|
||||
const util_1 = require("../util");
|
||||
const quote_1 = require("../../runtime/quote");
|
||||
const genSerialize = {
|
||||
elements: serializeElements,
|
||||
values: serializeValues,
|
||||
discriminator: serializeDiscriminator,
|
||||
properties: serializeProperties,
|
||||
optionalProperties: serializeProperties,
|
||||
enum: serializeString,
|
||||
type: serializeType,
|
||||
ref: serializeRef,
|
||||
};
|
||||
function compileSerializer(sch, definitions) {
|
||||
const _sch = __1.getCompilingSchema.call(this, sch);
|
||||
if (_sch)
|
||||
return _sch;
|
||||
const { es5, lines } = this.opts.code;
|
||||
const { ownProperties } = this.opts;
|
||||
const gen = new codegen_1.CodeGen(this.scope, { es5, lines, ownProperties });
|
||||
const serializeName = gen.scopeName("serialize");
|
||||
const cxt = {
|
||||
self: this,
|
||||
gen,
|
||||
schema: sch.schema,
|
||||
schemaEnv: sch,
|
||||
definitions,
|
||||
data: names_1.default.data,
|
||||
};
|
||||
let sourceCode;
|
||||
try {
|
||||
this._compilations.add(sch);
|
||||
sch.serializeName = serializeName;
|
||||
gen.func(serializeName, names_1.default.data, false, () => {
|
||||
gen.let(names_1.default.json, (0, codegen_1.str) ``);
|
||||
serializeCode(cxt);
|
||||
gen.return(names_1.default.json);
|
||||
});
|
||||
gen.optimize(this.opts.code.optimize);
|
||||
const serializeFuncCode = gen.toString();
|
||||
sourceCode = `${gen.scopeRefs(names_1.default.scope)}return ${serializeFuncCode}`;
|
||||
const makeSerialize = new Function(`${names_1.default.scope}`, sourceCode);
|
||||
const serialize = makeSerialize(this.scope.get());
|
||||
this.scope.value(serializeName, { ref: serialize });
|
||||
sch.serialize = serialize;
|
||||
}
|
||||
catch (e) {
|
||||
if (sourceCode)
|
||||
this.logger.error("Error compiling serializer, function code:", sourceCode);
|
||||
delete sch.serialize;
|
||||
delete sch.serializeName;
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
this._compilations.delete(sch);
|
||||
}
|
||||
return sch;
|
||||
}
|
||||
exports.default = compileSerializer;
|
||||
function serializeCode(cxt) {
|
||||
let form;
|
||||
for (const key of types_1.jtdForms) {
|
||||
if (key in cxt.schema) {
|
||||
form = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
serializeNullable(cxt, form ? genSerialize[form] : serializeEmpty);
|
||||
}
|
||||
function serializeNullable(cxt, serializeForm) {
|
||||
const { gen, schema, data } = cxt;
|
||||
if (!schema.nullable)
|
||||
return serializeForm(cxt);
|
||||
gen.if((0, codegen_1._) `${data} === undefined || ${data} === null`, () => gen.add(names_1.default.json, (0, codegen_1._) `"null"`), () => serializeForm(cxt));
|
||||
}
|
||||
function serializeElements(cxt) {
|
||||
const { gen, schema, data } = cxt;
|
||||
gen.add(names_1.default.json, (0, codegen_1.str) `[`);
|
||||
const first = gen.let("first", true);
|
||||
gen.forOf("el", data, (el) => {
|
||||
addComma(cxt, first);
|
||||
serializeCode({ ...cxt, schema: schema.elements, data: el });
|
||||
});
|
||||
gen.add(names_1.default.json, (0, codegen_1.str) `]`);
|
||||
}
|
||||
function serializeValues(cxt) {
|
||||
const { gen, schema, data } = cxt;
|
||||
gen.add(names_1.default.json, (0, codegen_1.str) `{`);
|
||||
const first = gen.let("first", true);
|
||||
gen.forIn("key", data, (key) => serializeKeyValue(cxt, key, schema.values, first));
|
||||
gen.add(names_1.default.json, (0, codegen_1.str) `}`);
|
||||
}
|
||||
function serializeKeyValue(cxt, key, schema, first) {
|
||||
const { gen, data } = cxt;
|
||||
addComma(cxt, first);
|
||||
serializeString({ ...cxt, data: key });
|
||||
gen.add(names_1.default.json, (0, codegen_1.str) `:`);
|
||||
const value = gen.const("value", (0, codegen_1._) `${data}${(0, codegen_1.getProperty)(key)}`);
|
||||
serializeCode({ ...cxt, schema, data: value });
|
||||
}
|
||||
function serializeDiscriminator(cxt) {
|
||||
const { gen, schema, data } = cxt;
|
||||
const { discriminator } = schema;
|
||||
gen.add(names_1.default.json, (0, codegen_1.str) `{${JSON.stringify(discriminator)}:`);
|
||||
const tag = gen.const("tag", (0, codegen_1._) `${data}${(0, codegen_1.getProperty)(discriminator)}`);
|
||||
serializeString({ ...cxt, data: tag });
|
||||
gen.if(false);
|
||||
for (const tagValue in schema.mapping) {
|
||||
gen.elseIf((0, codegen_1._) `${tag} === ${tagValue}`);
|
||||
const sch = schema.mapping[tagValue];
|
||||
serializeSchemaProperties({ ...cxt, schema: sch }, discriminator);
|
||||
}
|
||||
gen.endIf();
|
||||
gen.add(names_1.default.json, (0, codegen_1.str) `}`);
|
||||
}
|
||||
function serializeProperties(cxt) {
|
||||
const { gen } = cxt;
|
||||
gen.add(names_1.default.json, (0, codegen_1.str) `{`);
|
||||
serializeSchemaProperties(cxt);
|
||||
gen.add(names_1.default.json, (0, codegen_1.str) `}`);
|
||||
}
|
||||
function serializeSchemaProperties(cxt, discriminator) {
|
||||
const { gen, schema, data } = cxt;
|
||||
const { properties, optionalProperties } = schema;
|
||||
const props = keys(properties);
|
||||
const optProps = keys(optionalProperties);
|
||||
const allProps = allProperties(props.concat(optProps));
|
||||
let first = !discriminator;
|
||||
let firstProp;
|
||||
for (const key of props) {
|
||||
if (first)
|
||||
first = false;
|
||||
else
|
||||
gen.add(names_1.default.json, (0, codegen_1.str) `,`);
|
||||
serializeProperty(key, properties[key], keyValue(key));
|
||||
}
|
||||
if (first)
|
||||
firstProp = gen.let("first", true);
|
||||
for (const key of optProps) {
|
||||
const value = keyValue(key);
|
||||
gen.if((0, codegen_1.and)((0, codegen_1._) `${value} !== undefined`, (0, code_1.isOwnProperty)(gen, data, key)), () => {
|
||||
addComma(cxt, firstProp);
|
||||
serializeProperty(key, optionalProperties[key], value);
|
||||
});
|
||||
}
|
||||
if (schema.additionalProperties) {
|
||||
gen.forIn("key", data, (key) => gen.if(isAdditional(key, allProps), () => serializeKeyValue(cxt, key, {}, firstProp)));
|
||||
}
|
||||
function keys(ps) {
|
||||
return ps ? Object.keys(ps) : [];
|
||||
}
|
||||
function allProperties(ps) {
|
||||
if (discriminator)
|
||||
ps.push(discriminator);
|
||||
if (new Set(ps).size !== ps.length) {
|
||||
throw new Error("JTD: properties/optionalProperties/disciminator overlap");
|
||||
}
|
||||
return ps;
|
||||
}
|
||||
function keyValue(key) {
|
||||
return gen.const("value", (0, codegen_1._) `${data}${(0, codegen_1.getProperty)(key)}`);
|
||||
}
|
||||
function serializeProperty(key, propSchema, value) {
|
||||
gen.add(names_1.default.json, (0, codegen_1.str) `${JSON.stringify(key)}:`);
|
||||
serializeCode({ ...cxt, schema: propSchema, data: value });
|
||||
}
|
||||
function isAdditional(key, ps) {
|
||||
return ps.length ? (0, codegen_1.and)(...ps.map((p) => (0, codegen_1._) `${key} !== ${p}`)) : true;
|
||||
}
|
||||
}
|
||||
function serializeType(cxt) {
|
||||
const { gen, schema, data } = cxt;
|
||||
switch (schema.type) {
|
||||
case "boolean":
|
||||
gen.add(names_1.default.json, (0, codegen_1._) `${data} ? "true" : "false"`);
|
||||
break;
|
||||
case "string":
|
||||
serializeString(cxt);
|
||||
break;
|
||||
case "timestamp":
|
||||
gen.if((0, codegen_1._) `${data} instanceof Date`, () => gen.add(names_1.default.json, (0, codegen_1._) `'"' + ${data}.toISOString() + '"'`), () => serializeString(cxt));
|
||||
break;
|
||||
default:
|
||||
serializeNumber(cxt);
|
||||
}
|
||||
}
|
||||
function serializeString({ gen, data }) {
|
||||
gen.add(names_1.default.json, (0, codegen_1._) `${(0, util_1.useFunc)(gen, quote_1.default)}(${data})`);
|
||||
}
|
||||
function serializeNumber({ gen, data }) {
|
||||
gen.add(names_1.default.json, (0, codegen_1._) `"" + ${data}`);
|
||||
}
|
||||
function serializeRef(cxt) {
|
||||
const { gen, self, data, definitions, schema, schemaEnv } = cxt;
|
||||
const { ref } = schema;
|
||||
const refSchema = definitions[ref];
|
||||
if (!refSchema)
|
||||
throw new ref_error_1.default(self.opts.uriResolver, "", ref, `No definition ${ref}`);
|
||||
if (!(0, ref_1.hasRef)(refSchema))
|
||||
return serializeCode({ ...cxt, schema: refSchema });
|
||||
const { root } = schemaEnv;
|
||||
const sch = compileSerializer.call(self, new __1.SchemaEnv({ schema: refSchema, root }), definitions);
|
||||
gen.add(names_1.default.json, (0, codegen_1._) `${getSerialize(gen, sch)}(${data})`);
|
||||
}
|
||||
function getSerialize(gen, sch) {
|
||||
return sch.serialize
|
||||
? gen.scopeValue("serialize", { ref: sch.serialize })
|
||||
: (0, codegen_1._) `${gen.scopeValue("wrapper", { ref: sch })}.serialize`;
|
||||
}
|
||||
function serializeEmpty({ gen, data }) {
|
||||
gen.add(names_1.default.json, (0, codegen_1._) `JSON.stringify(${data})`);
|
||||
}
|
||||
function addComma({ gen }, first) {
|
||||
if (first) {
|
||||
gen.if(first, () => gen.assign(first, false), () => gen.add(names_1.default.json, (0, codegen_1.str) `,`));
|
||||
}
|
||||
else {
|
||||
gen.add(names_1.default.json, (0, codegen_1.str) `,`);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=serialize.js.map
|
1
my-app/node_modules/ajv/dist/compile/jtd/serialize.js.map
generated
vendored
Executable file
1
my-app/node_modules/ajv/dist/compile/jtd/serialize.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
6
my-app/node_modules/ajv/dist/compile/jtd/types.d.ts
generated
vendored
Executable file
6
my-app/node_modules/ajv/dist/compile/jtd/types.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,6 @@
|
|||
import type { SchemaObject } from "../../types";
|
||||
export type SchemaObjectMap = {
|
||||
[Ref in string]?: SchemaObject;
|
||||
};
|
||||
export declare const jtdForms: readonly ["elements", "values", "discriminator", "properties", "optionalProperties", "enum", "type", "ref"];
|
||||
export type JTDForm = typeof jtdForms[number];
|
14
my-app/node_modules/ajv/dist/compile/jtd/types.js
generated
vendored
Executable file
14
my-app/node_modules/ajv/dist/compile/jtd/types.js
generated
vendored
Executable file
|
@ -0,0 +1,14 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.jtdForms = void 0;
|
||||
exports.jtdForms = [
|
||||
"elements",
|
||||
"values",
|
||||
"discriminator",
|
||||
"properties",
|
||||
"optionalProperties",
|
||||
"enum",
|
||||
"type",
|
||||
"ref",
|
||||
];
|
||||
//# sourceMappingURL=types.js.map
|
1
my-app/node_modules/ajv/dist/compile/jtd/types.js.map
generated
vendored
Executable file
1
my-app/node_modules/ajv/dist/compile/jtd/types.js.map
generated
vendored
Executable file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../lib/compile/jtd/types.ts"],"names":[],"mappings":";;;AAIa,QAAA,QAAQ,GAAG;IACtB,UAAU;IACV,QAAQ;IACR,eAAe;IACf,YAAY;IACZ,oBAAoB;IACpB,MAAM;IACN,MAAM;IACN,KAAK;CACG,CAAA"}
|
20
my-app/node_modules/ajv/dist/compile/names.d.ts
generated
vendored
Executable file
20
my-app/node_modules/ajv/dist/compile/names.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,20 @@
|
|||
import { Name } from "./codegen";
|
||||
declare const names: {
|
||||
data: Name;
|
||||
valCxt: Name;
|
||||
instancePath: Name;
|
||||
parentData: Name;
|
||||
parentDataProperty: Name;
|
||||
rootData: Name;
|
||||
dynamicAnchors: Name;
|
||||
vErrors: Name;
|
||||
errors: Name;
|
||||
this: Name;
|
||||
self: Name;
|
||||
scope: Name;
|
||||
json: Name;
|
||||
jsonPos: Name;
|
||||
jsonLen: Name;
|
||||
jsonPart: Name;
|
||||
};
|
||||
export default names;
|
28
my-app/node_modules/ajv/dist/compile/names.js
generated
vendored
Executable file
28
my-app/node_modules/ajv/dist/compile/names.js
generated
vendored
Executable file
|
@ -0,0 +1,28 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const codegen_1 = require("./codegen");
|
||||
const names = {
|
||||
// validation function arguments
|
||||
data: new codegen_1.Name("data"),
|
||||
// args passed from referencing schema
|
||||
valCxt: new codegen_1.Name("valCxt"),
|
||||
instancePath: new codegen_1.Name("instancePath"),
|
||||
parentData: new codegen_1.Name("parentData"),
|
||||
parentDataProperty: new codegen_1.Name("parentDataProperty"),
|
||||
rootData: new codegen_1.Name("rootData"),
|
||||
dynamicAnchors: new codegen_1.Name("dynamicAnchors"),
|
||||
// function scoped variables
|
||||
vErrors: new codegen_1.Name("vErrors"),
|
||||
errors: new codegen_1.Name("errors"),
|
||||
this: new codegen_1.Name("this"),
|
||||
// "globals"
|
||||
self: new codegen_1.Name("self"),
|
||||
scope: new codegen_1.Name("scope"),
|
||||
// JTD serialize/parse name for JSON string and position
|
||||
json: new codegen_1.Name("json"),
|
||||
jsonPos: new codegen_1.Name("jsonPos"),
|
||||
jsonLen: new codegen_1.Name("jsonLen"),
|
||||
jsonPart: new codegen_1.Name("jsonPart"),
|
||||
};
|
||||
exports.default = names;
|
||||
//# sourceMappingURL=names.js.map
|
1
my-app/node_modules/ajv/dist/compile/names.js.map
generated
vendored
Executable file
1
my-app/node_modules/ajv/dist/compile/names.js.map
generated
vendored
Executable file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"names.js","sourceRoot":"","sources":["../../lib/compile/names.ts"],"names":[],"mappings":";;AAAA,uCAA8B;AAE9B,MAAM,KAAK,GAAG;IACZ,gCAAgC;IAChC,IAAI,EAAE,IAAI,cAAI,CAAC,MAAM,CAAC;IACtB,sCAAsC;IACtC,MAAM,EAAE,IAAI,cAAI,CAAC,QAAQ,CAAC;IAC1B,YAAY,EAAE,IAAI,cAAI,CAAC,cAAc,CAAC;IACtC,UAAU,EAAE,IAAI,cAAI,CAAC,YAAY,CAAC;IAClC,kBAAkB,EAAE,IAAI,cAAI,CAAC,oBAAoB,CAAC;IAClD,QAAQ,EAAE,IAAI,cAAI,CAAC,UAAU,CAAC;IAC9B,cAAc,EAAE,IAAI,cAAI,CAAC,gBAAgB,CAAC;IAC1C,4BAA4B;IAC5B,OAAO,EAAE,IAAI,cAAI,CAAC,SAAS,CAAC;IAC5B,MAAM,EAAE,IAAI,cAAI,CAAC,QAAQ,CAAC;IAC1B,IAAI,EAAE,IAAI,cAAI,CAAC,MAAM,CAAC;IACtB,YAAY;IACZ,IAAI,EAAE,IAAI,cAAI,CAAC,MAAM,CAAC;IACtB,KAAK,EAAE,IAAI,cAAI,CAAC,OAAO,CAAC;IACxB,wDAAwD;IACxD,IAAI,EAAE,IAAI,cAAI,CAAC,MAAM,CAAC;IACtB,OAAO,EAAE,IAAI,cAAI,CAAC,SAAS,CAAC;IAC5B,OAAO,EAAE,IAAI,cAAI,CAAC,SAAS,CAAC;IAC5B,QAAQ,EAAE,IAAI,cAAI,CAAC,UAAU,CAAC;CAC/B,CAAA;AAED,kBAAe,KAAK,CAAA"}
|
6
my-app/node_modules/ajv/dist/compile/ref_error.d.ts
generated
vendored
Executable file
6
my-app/node_modules/ajv/dist/compile/ref_error.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,6 @@
|
|||
import type { UriResolver } from "../types";
|
||||
export default class MissingRefError extends Error {
|
||||
readonly missingRef: string;
|
||||
readonly missingSchema: string;
|
||||
constructor(resolver: UriResolver, baseId: string, ref: string, msg?: string);
|
||||
}
|
12
my-app/node_modules/ajv/dist/compile/ref_error.js
generated
vendored
Executable file
12
my-app/node_modules/ajv/dist/compile/ref_error.js
generated
vendored
Executable file
|
@ -0,0 +1,12 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const resolve_1 = require("./resolve");
|
||||
class MissingRefError extends Error {
|
||||
constructor(resolver, baseId, ref, msg) {
|
||||
super(msg || `can't resolve reference ${ref} from id ${baseId}`);
|
||||
this.missingRef = (0, resolve_1.resolveUrl)(resolver, baseId, ref);
|
||||
this.missingSchema = (0, resolve_1.normalizeId)((0, resolve_1.getFullPath)(resolver, this.missingRef));
|
||||
}
|
||||
}
|
||||
exports.default = MissingRefError;
|
||||
//# sourceMappingURL=ref_error.js.map
|
1
my-app/node_modules/ajv/dist/compile/ref_error.js.map
generated
vendored
Executable file
1
my-app/node_modules/ajv/dist/compile/ref_error.js.map
generated
vendored
Executable file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"ref_error.js","sourceRoot":"","sources":["../../lib/compile/ref_error.ts"],"names":[],"mappings":";;AAAA,uCAA8D;AAG9D,MAAqB,eAAgB,SAAQ,KAAK;IAIhD,YAAY,QAAqB,EAAE,MAAc,EAAE,GAAW,EAAE,GAAY;QAC1E,KAAK,CAAC,GAAG,IAAI,2BAA2B,GAAG,YAAY,MAAM,EAAE,CAAC,CAAA;QAChE,IAAI,CAAC,UAAU,GAAG,IAAA,oBAAU,EAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,CAAC,CAAA;QACnD,IAAI,CAAC,aAAa,GAAG,IAAA,qBAAW,EAAC,IAAA,qBAAW,EAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAA;IAC1E,CAAC;CACF;AATD,kCASC"}
|
12
my-app/node_modules/ajv/dist/compile/resolve.d.ts
generated
vendored
Executable file
12
my-app/node_modules/ajv/dist/compile/resolve.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,12 @@
|
|||
import type { AnySchema, AnySchemaObject, UriResolver } from "../types";
|
||||
import type Ajv from "../ajv";
|
||||
import type { URIComponents } from "uri-js";
|
||||
export type LocalRefs = {
|
||||
[Ref in string]?: AnySchemaObject;
|
||||
};
|
||||
export declare function inlineRef(schema: AnySchema, limit?: boolean | number): boolean;
|
||||
export declare function getFullPath(resolver: UriResolver, id?: string, normalize?: boolean): string;
|
||||
export declare function _getFullPath(resolver: UriResolver, p: URIComponents): string;
|
||||
export declare function normalizeId(id: string | undefined): string;
|
||||
export declare function resolveUrl(resolver: UriResolver, baseId: string, id: string): string;
|
||||
export declare function getSchemaRefs(this: Ajv, schema: AnySchema, baseId: string): LocalRefs;
|
155
my-app/node_modules/ajv/dist/compile/resolve.js
generated
vendored
Executable file
155
my-app/node_modules/ajv/dist/compile/resolve.js
generated
vendored
Executable file
|
@ -0,0 +1,155 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getSchemaRefs = exports.resolveUrl = exports.normalizeId = exports._getFullPath = exports.getFullPath = exports.inlineRef = void 0;
|
||||
const util_1 = require("./util");
|
||||
const equal = require("fast-deep-equal");
|
||||
const traverse = require("json-schema-traverse");
|
||||
// TODO refactor to use keyword definitions
|
||||
const SIMPLE_INLINED = new Set([
|
||||
"type",
|
||||
"format",
|
||||
"pattern",
|
||||
"maxLength",
|
||||
"minLength",
|
||||
"maxProperties",
|
||||
"minProperties",
|
||||
"maxItems",
|
||||
"minItems",
|
||||
"maximum",
|
||||
"minimum",
|
||||
"uniqueItems",
|
||||
"multipleOf",
|
||||
"required",
|
||||
"enum",
|
||||
"const",
|
||||
]);
|
||||
function inlineRef(schema, limit = true) {
|
||||
if (typeof schema == "boolean")
|
||||
return true;
|
||||
if (limit === true)
|
||||
return !hasRef(schema);
|
||||
if (!limit)
|
||||
return false;
|
||||
return countKeys(schema) <= limit;
|
||||
}
|
||||
exports.inlineRef = inlineRef;
|
||||
const REF_KEYWORDS = new Set([
|
||||
"$ref",
|
||||
"$recursiveRef",
|
||||
"$recursiveAnchor",
|
||||
"$dynamicRef",
|
||||
"$dynamicAnchor",
|
||||
]);
|
||||
function hasRef(schema) {
|
||||
for (const key in schema) {
|
||||
if (REF_KEYWORDS.has(key))
|
||||
return true;
|
||||
const sch = schema[key];
|
||||
if (Array.isArray(sch) && sch.some(hasRef))
|
||||
return true;
|
||||
if (typeof sch == "object" && hasRef(sch))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function countKeys(schema) {
|
||||
let count = 0;
|
||||
for (const key in schema) {
|
||||
if (key === "$ref")
|
||||
return Infinity;
|
||||
count++;
|
||||
if (SIMPLE_INLINED.has(key))
|
||||
continue;
|
||||
if (typeof schema[key] == "object") {
|
||||
(0, util_1.eachItem)(schema[key], (sch) => (count += countKeys(sch)));
|
||||
}
|
||||
if (count === Infinity)
|
||||
return Infinity;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
function getFullPath(resolver, id = "", normalize) {
|
||||
if (normalize !== false)
|
||||
id = normalizeId(id);
|
||||
const p = resolver.parse(id);
|
||||
return _getFullPath(resolver, p);
|
||||
}
|
||||
exports.getFullPath = getFullPath;
|
||||
function _getFullPath(resolver, p) {
|
||||
const serialized = resolver.serialize(p);
|
||||
return serialized.split("#")[0] + "#";
|
||||
}
|
||||
exports._getFullPath = _getFullPath;
|
||||
const TRAILING_SLASH_HASH = /#\/?$/;
|
||||
function normalizeId(id) {
|
||||
return id ? id.replace(TRAILING_SLASH_HASH, "") : "";
|
||||
}
|
||||
exports.normalizeId = normalizeId;
|
||||
function resolveUrl(resolver, baseId, id) {
|
||||
id = normalizeId(id);
|
||||
return resolver.resolve(baseId, id);
|
||||
}
|
||||
exports.resolveUrl = resolveUrl;
|
||||
const ANCHOR = /^[a-z_][-a-z0-9._]*$/i;
|
||||
function getSchemaRefs(schema, baseId) {
|
||||
if (typeof schema == "boolean")
|
||||
return {};
|
||||
const { schemaId, uriResolver } = this.opts;
|
||||
const schId = normalizeId(schema[schemaId] || baseId);
|
||||
const baseIds = { "": schId };
|
||||
const pathPrefix = getFullPath(uriResolver, schId, false);
|
||||
const localRefs = {};
|
||||
const schemaRefs = new Set();
|
||||
traverse(schema, { allKeys: true }, (sch, jsonPtr, _, parentJsonPtr) => {
|
||||
if (parentJsonPtr === undefined)
|
||||
return;
|
||||
const fullPath = pathPrefix + jsonPtr;
|
||||
let baseId = baseIds[parentJsonPtr];
|
||||
if (typeof sch[schemaId] == "string")
|
||||
baseId = addRef.call(this, sch[schemaId]);
|
||||
addAnchor.call(this, sch.$anchor);
|
||||
addAnchor.call(this, sch.$dynamicAnchor);
|
||||
baseIds[jsonPtr] = baseId;
|
||||
function addRef(ref) {
|
||||
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||
const _resolve = this.opts.uriResolver.resolve;
|
||||
ref = normalizeId(baseId ? _resolve(baseId, ref) : ref);
|
||||
if (schemaRefs.has(ref))
|
||||
throw ambiguos(ref);
|
||||
schemaRefs.add(ref);
|
||||
let schOrRef = this.refs[ref];
|
||||
if (typeof schOrRef == "string")
|
||||
schOrRef = this.refs[schOrRef];
|
||||
if (typeof schOrRef == "object") {
|
||||
checkAmbiguosRef(sch, schOrRef.schema, ref);
|
||||
}
|
||||
else if (ref !== normalizeId(fullPath)) {
|
||||
if (ref[0] === "#") {
|
||||
checkAmbiguosRef(sch, localRefs[ref], ref);
|
||||
localRefs[ref] = sch;
|
||||
}
|
||||
else {
|
||||
this.refs[ref] = fullPath;
|
||||
}
|
||||
}
|
||||
return ref;
|
||||
}
|
||||
function addAnchor(anchor) {
|
||||
if (typeof anchor == "string") {
|
||||
if (!ANCHOR.test(anchor))
|
||||
throw new Error(`invalid anchor "${anchor}"`);
|
||||
addRef.call(this, `#${anchor}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
return localRefs;
|
||||
function checkAmbiguosRef(sch1, sch2, ref) {
|
||||
if (sch2 !== undefined && !equal(sch1, sch2))
|
||||
throw ambiguos(ref);
|
||||
}
|
||||
function ambiguos(ref) {
|
||||
return new Error(`reference "${ref}" resolves to more than one schema`);
|
||||
}
|
||||
}
|
||||
exports.getSchemaRefs = getSchemaRefs;
|
||||
//# sourceMappingURL=resolve.js.map
|
1
my-app/node_modules/ajv/dist/compile/resolve.js.map
generated
vendored
Executable file
1
my-app/node_modules/ajv/dist/compile/resolve.js.map
generated
vendored
Executable file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../lib/compile/resolve.ts"],"names":[],"mappings":";;;AAGA,iCAA+B;AAC/B,yCAAwC;AACxC,iDAAgD;AAKhD,2CAA2C;AAC3C,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;IAC7B,MAAM;IACN,QAAQ;IACR,SAAS;IACT,WAAW;IACX,WAAW;IACX,eAAe;IACf,eAAe;IACf,UAAU;IACV,UAAU;IACV,SAAS;IACT,SAAS;IACT,aAAa;IACb,YAAY;IACZ,UAAU;IACV,MAAM;IACN,OAAO;CACR,CAAC,CAAA;AAEF,SAAgB,SAAS,CAAC,MAAiB,EAAE,QAA0B,IAAI;IACzE,IAAI,OAAO,MAAM,IAAI,SAAS;QAAE,OAAO,IAAI,CAAA;IAC3C,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAC1C,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAA;IACxB,OAAO,SAAS,CAAC,MAAM,CAAC,IAAI,KAAK,CAAA;AACnC,CAAC;AALD,8BAKC;AAED,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC;IAC3B,MAAM;IACN,eAAe;IACf,kBAAkB;IAClB,aAAa;IACb,gBAAgB;CACjB,CAAC,CAAA;AAEF,SAAS,MAAM,CAAC,MAAuB;IACrC,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE;QACxB,IAAI,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,OAAO,IAAI,CAAA;QACtC,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;QACvB,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC;YAAE,OAAO,IAAI,CAAA;QACvD,IAAI,OAAO,GAAG,IAAI,QAAQ,IAAI,MAAM,CAAC,GAAG,CAAC;YAAE,OAAO,IAAI,CAAA;KACvD;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAED,SAAS,SAAS,CAAC,MAAuB;IACxC,IAAI,KAAK,GAAG,CAAC,CAAA;IACb,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE;QACxB,IAAI,GAAG,KAAK,MAAM;YAAE,OAAO,QAAQ,CAAA;QACnC,KAAK,EAAE,CAAA;QACP,IAAI,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,SAAQ;QACrC,IAAI,OAAO,MAAM,CAAC,GAAG,CAAC,IAAI,QAAQ,EAAE;YAClC,IAAA,eAAQ,EAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;SAC1D;QACD,IAAI,KAAK,KAAK,QAAQ;YAAE,OAAO,QAAQ,CAAA;KACxC;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAED,SAAgB,WAAW,CAAC,QAAqB,EAAE,EAAE,GAAG,EAAE,EAAE,SAAmB;IAC7E,IAAI,SAAS,KAAK,KAAK;QAAE,EAAE,GAAG,WAAW,CAAC,EAAE,CAAC,CAAA;IAC7C,MAAM,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IAC5B,OAAO,YAAY,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAA;AAClC,CAAC;AAJD,kCAIC;AAED,SAAgB,YAAY,CAAC,QAAqB,EAAE,CAAgB;IAClE,MAAM,UAAU,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;IACxC,OAAO,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAA;AACvC,CAAC;AAHD,oCAGC;AAED,MAAM,mBAAmB,GAAG,OAAO,CAAA;AACnC,SAAgB,WAAW,CAAC,EAAsB;IAChD,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;AACtD,CAAC;AAFD,kCAEC;AAED,SAAgB,UAAU,CAAC,QAAqB,EAAE,MAAc,EAAE,EAAU;IAC1E,EAAE,GAAG,WAAW,CAAC,EAAE,CAAC,CAAA;IACpB,OAAO,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;AACrC,CAAC;AAHD,gCAGC;AAED,MAAM,MAAM,GAAG,uBAAuB,CAAA;AAEtC,SAAgB,aAAa,CAAY,MAAiB,EAAE,MAAc;IACxE,IAAI,OAAO,MAAM,IAAI,SAAS;QAAE,OAAO,EAAE,CAAA;IACzC,MAAM,EAAC,QAAQ,EAAE,WAAW,EAAC,GAAG,IAAI,CAAC,IAAI,CAAA;IACzC,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,CAAA;IACrD,MAAM,OAAO,GAAmC,EAAC,EAAE,EAAE,KAAK,EAAC,CAAA;IAC3D,MAAM,UAAU,GAAG,WAAW,CAAC,WAAW,EAAE,KAAK,EAAE,KAAK,CAAC,CAAA;IACzD,MAAM,SAAS,GAAc,EAAE,CAAA;IAC/B,MAAM,UAAU,GAAgB,IAAI,GAAG,EAAE,CAAA;IAEzC,QAAQ,CAAC,MAAM,EAAE,EAAC,OAAO,EAAE,IAAI,EAAC,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,CAAC,EAAE,aAAa,EAAE,EAAE;QACnE,IAAI,aAAa,KAAK,SAAS;YAAE,OAAM;QACvC,MAAM,QAAQ,GAAG,UAAU,GAAG,OAAO,CAAA;QACrC,IAAI,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;QACnC,IAAI,OAAO,GAAG,CAAC,QAAQ,CAAC,IAAI,QAAQ;YAAE,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAA;QAC/E,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;QACjC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,cAAc,CAAC,CAAA;QACxC,OAAO,CAAC,OAAO,CAAC,GAAG,MAAM,CAAA;QAEzB,SAAS,MAAM,CAAY,GAAW;YACpC,6DAA6D;YAC7D,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAA;YAC9C,GAAG,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;YACvD,IAAI,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC;gBAAE,MAAM,QAAQ,CAAC,GAAG,CAAC,CAAA;YAC5C,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YACnB,IAAI,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YAC7B,IAAI,OAAO,QAAQ,IAAI,QAAQ;gBAAE,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;YAC/D,IAAI,OAAO,QAAQ,IAAI,QAAQ,EAAE;gBAC/B,gBAAgB,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;aAC5C;iBAAM,IAAI,GAAG,KAAK,WAAW,CAAC,QAAQ,CAAC,EAAE;gBACxC,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;oBAClB,gBAAgB,CAAC,GAAG,EAAE,SAAS,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAA;oBAC1C,SAAS,CAAC,GAAG,CAAC,GAAG,GAAG,CAAA;iBACrB;qBAAM;oBACL,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAA;iBAC1B;aACF;YACD,OAAO,GAAG,CAAA;QACZ,CAAC;QAED,SAAS,SAAS,CAAY,MAAe;YAC3C,IAAI,OAAO,MAAM,IAAI,QAAQ,EAAE;gBAC7B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;oBAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,MAAM,GAAG,CAAC,CAAA;gBACvE,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,MAAM,EAAE,CAAC,CAAA;aAChC;QACH,CAAC;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,SAAS,CAAA;IAEhB,SAAS,gBAAgB,CAAC,IAAe,EAAE,IAA2B,EAAE,GAAW;QACjF,IAAI,IAAI,KAAK,SAAS,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC;YAAE,MAAM,QAAQ,CAAC,GAAG,CAAC,CAAA;IACnE,CAAC;IAED,SAAS,QAAQ,CAAC,GAAW;QAC3B,OAAO,IAAI,KAAK,CAAC,cAAc,GAAG,oCAAoC,CAAC,CAAA;IACzE,CAAC;AACH,CAAC;AAxDD,sCAwDC"}
|
28
my-app/node_modules/ajv/dist/compile/rules.d.ts
generated
vendored
Executable file
28
my-app/node_modules/ajv/dist/compile/rules.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,28 @@
|
|||
import type { AddedKeywordDefinition } from "../types";
|
||||
declare const _jsonTypes: readonly ["string", "number", "integer", "boolean", "null", "object", "array"];
|
||||
export type JSONType = typeof _jsonTypes[number];
|
||||
export declare function isJSONType(x: unknown): x is JSONType;
|
||||
type ValidationTypes = {
|
||||
[K in JSONType]: boolean | RuleGroup | undefined;
|
||||
};
|
||||
export interface ValidationRules {
|
||||
rules: RuleGroup[];
|
||||
post: RuleGroup;
|
||||
all: {
|
||||
[Key in string]?: boolean | Rule;
|
||||
};
|
||||
keywords: {
|
||||
[Key in string]?: boolean;
|
||||
};
|
||||
types: ValidationTypes;
|
||||
}
|
||||
export interface RuleGroup {
|
||||
type?: JSONType;
|
||||
rules: Rule[];
|
||||
}
|
||||
export interface Rule {
|
||||
keyword: string;
|
||||
definition: AddedKeywordDefinition;
|
||||
}
|
||||
export declare function getRules(): ValidationRules;
|
||||
export {};
|
26
my-app/node_modules/ajv/dist/compile/rules.js
generated
vendored
Executable file
26
my-app/node_modules/ajv/dist/compile/rules.js
generated
vendored
Executable file
|
@ -0,0 +1,26 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getRules = exports.isJSONType = void 0;
|
||||
const _jsonTypes = ["string", "number", "integer", "boolean", "null", "object", "array"];
|
||||
const jsonTypes = new Set(_jsonTypes);
|
||||
function isJSONType(x) {
|
||||
return typeof x == "string" && jsonTypes.has(x);
|
||||
}
|
||||
exports.isJSONType = isJSONType;
|
||||
function getRules() {
|
||||
const groups = {
|
||||
number: { type: "number", rules: [] },
|
||||
string: { type: "string", rules: [] },
|
||||
array: { type: "array", rules: [] },
|
||||
object: { type: "object", rules: [] },
|
||||
};
|
||||
return {
|
||||
types: { ...groups, integer: true, boolean: true, null: true },
|
||||
rules: [{ rules: [] }, groups.number, groups.string, groups.array, groups.object],
|
||||
post: { rules: [] },
|
||||
all: {},
|
||||
keywords: {},
|
||||
};
|
||||
}
|
||||
exports.getRules = getRules;
|
||||
//# sourceMappingURL=rules.js.map
|
1
my-app/node_modules/ajv/dist/compile/rules.js.map
generated
vendored
Executable file
1
my-app/node_modules/ajv/dist/compile/rules.js.map
generated
vendored
Executable file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"rules.js","sourceRoot":"","sources":["../../lib/compile/rules.ts"],"names":[],"mappings":";;;AAEA,MAAM,UAAU,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAU,CAAA;AAIjG,MAAM,SAAS,GAAgB,IAAI,GAAG,CAAC,UAAU,CAAC,CAAA;AAElD,SAAgB,UAAU,CAAC,CAAU;IACnC,OAAO,OAAO,CAAC,IAAI,QAAQ,IAAI,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;AACjD,CAAC;AAFD,gCAEC;AAyBD,SAAgB,QAAQ;IACtB,MAAM,MAAM,GAAgE;QAC1E,MAAM,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAC;QACnC,MAAM,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAC;QACnC,KAAK,EAAE,EAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAC;QACjC,MAAM,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAC;KACpC,CAAA;IACD,OAAO;QACL,KAAK,EAAE,EAAC,GAAG,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAC;QAC5D,KAAK,EAAE,CAAC,EAAC,KAAK,EAAE,EAAE,EAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC;QAC/E,IAAI,EAAE,EAAC,KAAK,EAAE,EAAE,EAAC;QACjB,GAAG,EAAE,EAAE;QACP,QAAQ,EAAE,EAAE;KACb,CAAA;AACH,CAAC;AAdD,4BAcC"}
|
40
my-app/node_modules/ajv/dist/compile/util.d.ts
generated
vendored
Executable file
40
my-app/node_modules/ajv/dist/compile/util.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,40 @@
|
|||
import type { AnySchema, EvaluatedProperties, EvaluatedItems } from "../types";
|
||||
import type { SchemaCxt, SchemaObjCxt } from ".";
|
||||
import { Code, Name, CodeGen } from "./codegen";
|
||||
import type { Rule, ValidationRules } from "./rules";
|
||||
export declare function toHash<T extends string = string>(arr: T[]): {
|
||||
[K in T]?: true;
|
||||
};
|
||||
export declare function alwaysValidSchema(it: SchemaCxt, schema: AnySchema): boolean | void;
|
||||
export declare function checkUnknownRules(it: SchemaCxt, schema?: AnySchema): void;
|
||||
export declare function schemaHasRules(schema: AnySchema, rules: {
|
||||
[Key in string]?: boolean | Rule;
|
||||
}): boolean;
|
||||
export declare function schemaHasRulesButRef(schema: AnySchema, RULES: ValidationRules): boolean;
|
||||
export declare function schemaRefOrVal({ topSchemaRef, schemaPath }: SchemaObjCxt, schema: unknown, keyword: string, $data?: string | false): Code | number | boolean;
|
||||
export declare function unescapeFragment(str: string): string;
|
||||
export declare function escapeFragment(str: string | number): string;
|
||||
export declare function escapeJsonPointer(str: string | number): string;
|
||||
export declare function unescapeJsonPointer(str: string): string;
|
||||
export declare function eachItem<T>(xs: T | T[], f: (x: T) => void): void;
|
||||
type SomeEvaluated = EvaluatedProperties | EvaluatedItems;
|
||||
type MergeEvaluatedFunc<T extends SomeEvaluated> = (gen: CodeGen, from: Name | T, to: Name | Exclude<T, true> | undefined, toName?: typeof Name) => Name | T;
|
||||
interface MergeEvaluated {
|
||||
props: MergeEvaluatedFunc<EvaluatedProperties>;
|
||||
items: MergeEvaluatedFunc<EvaluatedItems>;
|
||||
}
|
||||
export declare const mergeEvaluated: MergeEvaluated;
|
||||
export declare function evaluatedPropsToName(gen: CodeGen, ps?: EvaluatedProperties): Name;
|
||||
export declare function setEvaluated(gen: CodeGen, props: Name, ps: {
|
||||
[K in string]?: true;
|
||||
}): void;
|
||||
export declare function useFunc(gen: CodeGen, f: {
|
||||
code: string;
|
||||
}): Name;
|
||||
export declare enum Type {
|
||||
Num = 0,
|
||||
Str = 1
|
||||
}
|
||||
export declare function getErrorPath(dataProp: Name | string | number, dataPropType?: Type, jsPropertySyntax?: boolean): Code | string;
|
||||
export declare function checkStrictMode(it: SchemaCxt, msg: string, mode?: boolean | "log"): void;
|
||||
export {};
|
178
my-app/node_modules/ajv/dist/compile/util.js
generated
vendored
Executable file
178
my-app/node_modules/ajv/dist/compile/util.js
generated
vendored
Executable file
|
@ -0,0 +1,178 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.checkStrictMode = exports.getErrorPath = exports.Type = exports.useFunc = exports.setEvaluated = exports.evaluatedPropsToName = exports.mergeEvaluated = exports.eachItem = exports.unescapeJsonPointer = exports.escapeJsonPointer = exports.escapeFragment = exports.unescapeFragment = exports.schemaRefOrVal = exports.schemaHasRulesButRef = exports.schemaHasRules = exports.checkUnknownRules = exports.alwaysValidSchema = exports.toHash = void 0;
|
||||
const codegen_1 = require("./codegen");
|
||||
const code_1 = require("./codegen/code");
|
||||
// TODO refactor to use Set
|
||||
function toHash(arr) {
|
||||
const hash = {};
|
||||
for (const item of arr)
|
||||
hash[item] = true;
|
||||
return hash;
|
||||
}
|
||||
exports.toHash = toHash;
|
||||
function alwaysValidSchema(it, schema) {
|
||||
if (typeof schema == "boolean")
|
||||
return schema;
|
||||
if (Object.keys(schema).length === 0)
|
||||
return true;
|
||||
checkUnknownRules(it, schema);
|
||||
return !schemaHasRules(schema, it.self.RULES.all);
|
||||
}
|
||||
exports.alwaysValidSchema = alwaysValidSchema;
|
||||
function checkUnknownRules(it, schema = it.schema) {
|
||||
const { opts, self } = it;
|
||||
if (!opts.strictSchema)
|
||||
return;
|
||||
if (typeof schema === "boolean")
|
||||
return;
|
||||
const rules = self.RULES.keywords;
|
||||
for (const key in schema) {
|
||||
if (!rules[key])
|
||||
checkStrictMode(it, `unknown keyword: "${key}"`);
|
||||
}
|
||||
}
|
||||
exports.checkUnknownRules = checkUnknownRules;
|
||||
function schemaHasRules(schema, rules) {
|
||||
if (typeof schema == "boolean")
|
||||
return !schema;
|
||||
for (const key in schema)
|
||||
if (rules[key])
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
exports.schemaHasRules = schemaHasRules;
|
||||
function schemaHasRulesButRef(schema, RULES) {
|
||||
if (typeof schema == "boolean")
|
||||
return !schema;
|
||||
for (const key in schema)
|
||||
if (key !== "$ref" && RULES.all[key])
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
exports.schemaHasRulesButRef = schemaHasRulesButRef;
|
||||
function schemaRefOrVal({ topSchemaRef, schemaPath }, schema, keyword, $data) {
|
||||
if (!$data) {
|
||||
if (typeof schema == "number" || typeof schema == "boolean")
|
||||
return schema;
|
||||
if (typeof schema == "string")
|
||||
return (0, codegen_1._) `${schema}`;
|
||||
}
|
||||
return (0, codegen_1._) `${topSchemaRef}${schemaPath}${(0, codegen_1.getProperty)(keyword)}`;
|
||||
}
|
||||
exports.schemaRefOrVal = schemaRefOrVal;
|
||||
function unescapeFragment(str) {
|
||||
return unescapeJsonPointer(decodeURIComponent(str));
|
||||
}
|
||||
exports.unescapeFragment = unescapeFragment;
|
||||
function escapeFragment(str) {
|
||||
return encodeURIComponent(escapeJsonPointer(str));
|
||||
}
|
||||
exports.escapeFragment = escapeFragment;
|
||||
function escapeJsonPointer(str) {
|
||||
if (typeof str == "number")
|
||||
return `${str}`;
|
||||
return str.replace(/~/g, "~0").replace(/\//g, "~1");
|
||||
}
|
||||
exports.escapeJsonPointer = escapeJsonPointer;
|
||||
function unescapeJsonPointer(str) {
|
||||
return str.replace(/~1/g, "/").replace(/~0/g, "~");
|
||||
}
|
||||
exports.unescapeJsonPointer = unescapeJsonPointer;
|
||||
function eachItem(xs, f) {
|
||||
if (Array.isArray(xs)) {
|
||||
for (const x of xs)
|
||||
f(x);
|
||||
}
|
||||
else {
|
||||
f(xs);
|
||||
}
|
||||
}
|
||||
exports.eachItem = eachItem;
|
||||
function makeMergeEvaluated({ mergeNames, mergeToName, mergeValues, resultToName, }) {
|
||||
return (gen, from, to, toName) => {
|
||||
const res = to === undefined
|
||||
? from
|
||||
: to instanceof codegen_1.Name
|
||||
? (from instanceof codegen_1.Name ? mergeNames(gen, from, to) : mergeToName(gen, from, to), to)
|
||||
: from instanceof codegen_1.Name
|
||||
? (mergeToName(gen, to, from), from)
|
||||
: mergeValues(from, to);
|
||||
return toName === codegen_1.Name && !(res instanceof codegen_1.Name) ? resultToName(gen, res) : res;
|
||||
};
|
||||
}
|
||||
exports.mergeEvaluated = {
|
||||
props: makeMergeEvaluated({
|
||||
mergeNames: (gen, from, to) => gen.if((0, codegen_1._) `${to} !== true && ${from} !== undefined`, () => {
|
||||
gen.if((0, codegen_1._) `${from} === true`, () => gen.assign(to, true), () => gen.assign(to, (0, codegen_1._) `${to} || {}`).code((0, codegen_1._) `Object.assign(${to}, ${from})`));
|
||||
}),
|
||||
mergeToName: (gen, from, to) => gen.if((0, codegen_1._) `${to} !== true`, () => {
|
||||
if (from === true) {
|
||||
gen.assign(to, true);
|
||||
}
|
||||
else {
|
||||
gen.assign(to, (0, codegen_1._) `${to} || {}`);
|
||||
setEvaluated(gen, to, from);
|
||||
}
|
||||
}),
|
||||
mergeValues: (from, to) => (from === true ? true : { ...from, ...to }),
|
||||
resultToName: evaluatedPropsToName,
|
||||
}),
|
||||
items: makeMergeEvaluated({
|
||||
mergeNames: (gen, from, to) => gen.if((0, codegen_1._) `${to} !== true && ${from} !== undefined`, () => gen.assign(to, (0, codegen_1._) `${from} === true ? true : ${to} > ${from} ? ${to} : ${from}`)),
|
||||
mergeToName: (gen, from, to) => gen.if((0, codegen_1._) `${to} !== true`, () => gen.assign(to, from === true ? true : (0, codegen_1._) `${to} > ${from} ? ${to} : ${from}`)),
|
||||
mergeValues: (from, to) => (from === true ? true : Math.max(from, to)),
|
||||
resultToName: (gen, items) => gen.var("items", items),
|
||||
}),
|
||||
};
|
||||
function evaluatedPropsToName(gen, ps) {
|
||||
if (ps === true)
|
||||
return gen.var("props", true);
|
||||
const props = gen.var("props", (0, codegen_1._) `{}`);
|
||||
if (ps !== undefined)
|
||||
setEvaluated(gen, props, ps);
|
||||
return props;
|
||||
}
|
||||
exports.evaluatedPropsToName = evaluatedPropsToName;
|
||||
function setEvaluated(gen, props, ps) {
|
||||
Object.keys(ps).forEach((p) => gen.assign((0, codegen_1._) `${props}${(0, codegen_1.getProperty)(p)}`, true));
|
||||
}
|
||||
exports.setEvaluated = setEvaluated;
|
||||
const snippets = {};
|
||||
function useFunc(gen, f) {
|
||||
return gen.scopeValue("func", {
|
||||
ref: f,
|
||||
code: snippets[f.code] || (snippets[f.code] = new code_1._Code(f.code)),
|
||||
});
|
||||
}
|
||||
exports.useFunc = useFunc;
|
||||
var Type;
|
||||
(function (Type) {
|
||||
Type[Type["Num"] = 0] = "Num";
|
||||
Type[Type["Str"] = 1] = "Str";
|
||||
})(Type = exports.Type || (exports.Type = {}));
|
||||
function getErrorPath(dataProp, dataPropType, jsPropertySyntax) {
|
||||
// let path
|
||||
if (dataProp instanceof codegen_1.Name) {
|
||||
const isNumber = dataPropType === Type.Num;
|
||||
return jsPropertySyntax
|
||||
? isNumber
|
||||
? (0, codegen_1._) `"[" + ${dataProp} + "]"`
|
||||
: (0, codegen_1._) `"['" + ${dataProp} + "']"`
|
||||
: isNumber
|
||||
? (0, codegen_1._) `"/" + ${dataProp}`
|
||||
: (0, codegen_1._) `"/" + ${dataProp}.replace(/~/g, "~0").replace(/\\//g, "~1")`; // TODO maybe use global escapePointer
|
||||
}
|
||||
return jsPropertySyntax ? (0, codegen_1.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp);
|
||||
}
|
||||
exports.getErrorPath = getErrorPath;
|
||||
function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
|
||||
if (!mode)
|
||||
return;
|
||||
msg = `strict mode: ${msg}`;
|
||||
if (mode === true)
|
||||
throw new Error(msg);
|
||||
it.self.logger.warn(msg);
|
||||
}
|
||||
exports.checkStrictMode = checkStrictMode;
|
||||
//# sourceMappingURL=util.js.map
|
1
my-app/node_modules/ajv/dist/compile/util.js.map
generated
vendored
Executable file
1
my-app/node_modules/ajv/dist/compile/util.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
6
my-app/node_modules/ajv/dist/compile/validate/applicability.d.ts
generated
vendored
Executable file
6
my-app/node_modules/ajv/dist/compile/validate/applicability.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,6 @@
|
|||
import type { AnySchemaObject } from "../../types";
|
||||
import type { SchemaObjCxt } from "..";
|
||||
import type { JSONType, RuleGroup, Rule } from "../rules";
|
||||
export declare function schemaHasRulesForType({ schema, self }: SchemaObjCxt, type: JSONType): boolean | undefined;
|
||||
export declare function shouldUseGroup(schema: AnySchemaObject, group: RuleGroup): boolean;
|
||||
export declare function shouldUseRule(schema: AnySchemaObject, rule: Rule): boolean | undefined;
|
19
my-app/node_modules/ajv/dist/compile/validate/applicability.js
generated
vendored
Executable file
19
my-app/node_modules/ajv/dist/compile/validate/applicability.js
generated
vendored
Executable file
|
@ -0,0 +1,19 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.shouldUseRule = exports.shouldUseGroup = exports.schemaHasRulesForType = void 0;
|
||||
function schemaHasRulesForType({ schema, self }, type) {
|
||||
const group = self.RULES.types[type];
|
||||
return group && group !== true && shouldUseGroup(schema, group);
|
||||
}
|
||||
exports.schemaHasRulesForType = schemaHasRulesForType;
|
||||
function shouldUseGroup(schema, group) {
|
||||
return group.rules.some((rule) => shouldUseRule(schema, rule));
|
||||
}
|
||||
exports.shouldUseGroup = shouldUseGroup;
|
||||
function shouldUseRule(schema, rule) {
|
||||
var _a;
|
||||
return (schema[rule.keyword] !== undefined ||
|
||||
((_a = rule.definition.implements) === null || _a === void 0 ? void 0 : _a.some((kwd) => schema[kwd] !== undefined)));
|
||||
}
|
||||
exports.shouldUseRule = shouldUseRule;
|
||||
//# sourceMappingURL=applicability.js.map
|
1
my-app/node_modules/ajv/dist/compile/validate/applicability.js.map
generated
vendored
Executable file
1
my-app/node_modules/ajv/dist/compile/validate/applicability.js.map
generated
vendored
Executable file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"applicability.js","sourceRoot":"","sources":["../../../lib/compile/validate/applicability.ts"],"names":[],"mappings":";;;AAIA,SAAgB,qBAAqB,CACnC,EAAC,MAAM,EAAE,IAAI,EAAe,EAC5B,IAAc;IAEd,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IACpC,OAAO,KAAK,IAAI,KAAK,KAAK,IAAI,IAAI,cAAc,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;AACjE,CAAC;AAND,sDAMC;AAED,SAAgB,cAAc,CAAC,MAAuB,EAAE,KAAgB;IACtE,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAA;AAChE,CAAC;AAFD,wCAEC;AAED,SAAgB,aAAa,CAAC,MAAuB,EAAE,IAAU;;IAC/D,OAAO,CACL,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,SAAS;SAClC,MAAA,IAAI,CAAC,UAAU,CAAC,UAAU,0CAAE,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC,CAAA,CACrE,CAAA;AACH,CAAC;AALD,sCAKC"}
|
4
my-app/node_modules/ajv/dist/compile/validate/boolSchema.d.ts
generated
vendored
Executable file
4
my-app/node_modules/ajv/dist/compile/validate/boolSchema.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,4 @@
|
|||
import type { SchemaCxt } from "..";
|
||||
import { Name } from "../codegen";
|
||||
export declare function topBoolOrEmptySchema(it: SchemaCxt): void;
|
||||
export declare function boolOrEmptySchema(it: SchemaCxt, valid: Name): void;
|
50
my-app/node_modules/ajv/dist/compile/validate/boolSchema.js
generated
vendored
Executable file
50
my-app/node_modules/ajv/dist/compile/validate/boolSchema.js
generated
vendored
Executable file
|
@ -0,0 +1,50 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.boolOrEmptySchema = exports.topBoolOrEmptySchema = void 0;
|
||||
const errors_1 = require("../errors");
|
||||
const codegen_1 = require("../codegen");
|
||||
const names_1 = require("../names");
|
||||
const boolError = {
|
||||
message: "boolean schema is false",
|
||||
};
|
||||
function topBoolOrEmptySchema(it) {
|
||||
const { gen, schema, validateName } = it;
|
||||
if (schema === false) {
|
||||
falseSchemaError(it, false);
|
||||
}
|
||||
else if (typeof schema == "object" && schema.$async === true) {
|
||||
gen.return(names_1.default.data);
|
||||
}
|
||||
else {
|
||||
gen.assign((0, codegen_1._) `${validateName}.errors`, null);
|
||||
gen.return(true);
|
||||
}
|
||||
}
|
||||
exports.topBoolOrEmptySchema = topBoolOrEmptySchema;
|
||||
function boolOrEmptySchema(it, valid) {
|
||||
const { gen, schema } = it;
|
||||
if (schema === false) {
|
||||
gen.var(valid, false); // TODO var
|
||||
falseSchemaError(it);
|
||||
}
|
||||
else {
|
||||
gen.var(valid, true); // TODO var
|
||||
}
|
||||
}
|
||||
exports.boolOrEmptySchema = boolOrEmptySchema;
|
||||
function falseSchemaError(it, overrideAllErrors) {
|
||||
const { gen, data } = it;
|
||||
// TODO maybe some other interface should be used for non-keyword validation errors...
|
||||
const cxt = {
|
||||
gen,
|
||||
keyword: "false schema",
|
||||
data,
|
||||
schema: false,
|
||||
schemaCode: false,
|
||||
schemaValue: false,
|
||||
params: {},
|
||||
it,
|
||||
};
|
||||
(0, errors_1.reportError)(cxt, boolError, undefined, overrideAllErrors);
|
||||
}
|
||||
//# sourceMappingURL=boolSchema.js.map
|
1
my-app/node_modules/ajv/dist/compile/validate/boolSchema.js.map
generated
vendored
Executable file
1
my-app/node_modules/ajv/dist/compile/validate/boolSchema.js.map
generated
vendored
Executable file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"boolSchema.js","sourceRoot":"","sources":["../../../lib/compile/validate/boolSchema.ts"],"names":[],"mappings":";;;AAEA,sCAAqC;AACrC,wCAAkC;AAClC,oCAAwB;AAExB,MAAM,SAAS,GAA2B;IACxC,OAAO,EAAE,yBAAyB;CACnC,CAAA;AAED,SAAgB,oBAAoB,CAAC,EAAa;IAChD,MAAM,EAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAC,GAAG,EAAE,CAAA;IACtC,IAAI,MAAM,KAAK,KAAK,EAAE;QACpB,gBAAgB,CAAC,EAAE,EAAE,KAAK,CAAC,CAAA;KAC5B;SAAM,IAAI,OAAO,MAAM,IAAI,QAAQ,IAAI,MAAM,CAAC,MAAM,KAAK,IAAI,EAAE;QAC9D,GAAG,CAAC,MAAM,CAAC,eAAC,CAAC,IAAI,CAAC,CAAA;KACnB;SAAM;QACL,GAAG,CAAC,MAAM,CAAC,IAAA,WAAC,EAAA,GAAG,YAAY,SAAS,EAAE,IAAI,CAAC,CAAA;QAC3C,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;KACjB;AACH,CAAC;AAVD,oDAUC;AAED,SAAgB,iBAAiB,CAAC,EAAa,EAAE,KAAW;IAC1D,MAAM,EAAC,GAAG,EAAE,MAAM,EAAC,GAAG,EAAE,CAAA;IACxB,IAAI,MAAM,KAAK,KAAK,EAAE;QACpB,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA,CAAC,WAAW;QACjC,gBAAgB,CAAC,EAAE,CAAC,CAAA;KACrB;SAAM;QACL,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA,CAAC,WAAW;KACjC;AACH,CAAC;AARD,8CAQC;AAED,SAAS,gBAAgB,CAAC,EAAa,EAAE,iBAA2B;IAClE,MAAM,EAAC,GAAG,EAAE,IAAI,EAAC,GAAG,EAAE,CAAA;IACtB,sFAAsF;IACtF,MAAM,GAAG,GAAoB;QAC3B,GAAG;QACH,OAAO,EAAE,cAAc;QACvB,IAAI;QACJ,MAAM,EAAE,KAAK;QACb,UAAU,EAAE,KAAK;QACjB,WAAW,EAAE,KAAK;QAClB,MAAM,EAAE,EAAE;QACV,EAAE;KACH,CAAA;IACD,IAAA,oBAAW,EAAC,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,iBAAiB,CAAC,CAAA;AAC3D,CAAC"}
|
17
my-app/node_modules/ajv/dist/compile/validate/dataType.d.ts
generated
vendored
Executable file
17
my-app/node_modules/ajv/dist/compile/validate/dataType.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,17 @@
|
|||
import type { ErrorObject, AnySchemaObject } from "../../types";
|
||||
import type { SchemaObjCxt } from "..";
|
||||
import { JSONType } from "../rules";
|
||||
import { Code, Name } from "../codegen";
|
||||
export declare enum DataType {
|
||||
Correct = 0,
|
||||
Wrong = 1
|
||||
}
|
||||
export declare function getSchemaTypes(schema: AnySchemaObject): JSONType[];
|
||||
export declare function getJSONTypes(ts: unknown | unknown[]): JSONType[];
|
||||
export declare function coerceAndCheckDataType(it: SchemaObjCxt, types: JSONType[]): boolean;
|
||||
export declare function checkDataType(dataType: JSONType, data: Name, strictNums?: boolean | "log", correct?: DataType): Code;
|
||||
export declare function checkDataTypes(dataTypes: JSONType[], data: Name, strictNums?: boolean | "log", correct?: DataType): Code;
|
||||
export type TypeError = ErrorObject<"type", {
|
||||
type: string;
|
||||
}>;
|
||||
export declare function reportTypeError(it: SchemaObjCxt): void;
|
202
my-app/node_modules/ajv/dist/compile/validate/dataType.js
generated
vendored
Executable file
202
my-app/node_modules/ajv/dist/compile/validate/dataType.js
generated
vendored
Executable file
|
@ -0,0 +1,202 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.reportTypeError = exports.checkDataTypes = exports.checkDataType = exports.coerceAndCheckDataType = exports.getJSONTypes = exports.getSchemaTypes = exports.DataType = void 0;
|
||||
const rules_1 = require("../rules");
|
||||
const applicability_1 = require("./applicability");
|
||||
const errors_1 = require("../errors");
|
||||
const codegen_1 = require("../codegen");
|
||||
const util_1 = require("../util");
|
||||
var DataType;
|
||||
(function (DataType) {
|
||||
DataType[DataType["Correct"] = 0] = "Correct";
|
||||
DataType[DataType["Wrong"] = 1] = "Wrong";
|
||||
})(DataType = exports.DataType || (exports.DataType = {}));
|
||||
function getSchemaTypes(schema) {
|
||||
const types = getJSONTypes(schema.type);
|
||||
const hasNull = types.includes("null");
|
||||
if (hasNull) {
|
||||
if (schema.nullable === false)
|
||||
throw new Error("type: null contradicts nullable: false");
|
||||
}
|
||||
else {
|
||||
if (!types.length && schema.nullable !== undefined) {
|
||||
throw new Error('"nullable" cannot be used without "type"');
|
||||
}
|
||||
if (schema.nullable === true)
|
||||
types.push("null");
|
||||
}
|
||||
return types;
|
||||
}
|
||||
exports.getSchemaTypes = getSchemaTypes;
|
||||
function getJSONTypes(ts) {
|
||||
const types = Array.isArray(ts) ? ts : ts ? [ts] : [];
|
||||
if (types.every(rules_1.isJSONType))
|
||||
return types;
|
||||
throw new Error("type must be JSONType or JSONType[]: " + types.join(","));
|
||||
}
|
||||
exports.getJSONTypes = getJSONTypes;
|
||||
function coerceAndCheckDataType(it, types) {
|
||||
const { gen, data, opts } = it;
|
||||
const coerceTo = coerceToTypes(types, opts.coerceTypes);
|
||||
const checkTypes = types.length > 0 &&
|
||||
!(coerceTo.length === 0 && types.length === 1 && (0, applicability_1.schemaHasRulesForType)(it, types[0]));
|
||||
if (checkTypes) {
|
||||
const wrongType = checkDataTypes(types, data, opts.strictNumbers, DataType.Wrong);
|
||||
gen.if(wrongType, () => {
|
||||
if (coerceTo.length)
|
||||
coerceData(it, types, coerceTo);
|
||||
else
|
||||
reportTypeError(it);
|
||||
});
|
||||
}
|
||||
return checkTypes;
|
||||
}
|
||||
exports.coerceAndCheckDataType = coerceAndCheckDataType;
|
||||
const COERCIBLE = new Set(["string", "number", "integer", "boolean", "null"]);
|
||||
function coerceToTypes(types, coerceTypes) {
|
||||
return coerceTypes
|
||||
? types.filter((t) => COERCIBLE.has(t) || (coerceTypes === "array" && t === "array"))
|
||||
: [];
|
||||
}
|
||||
function coerceData(it, types, coerceTo) {
|
||||
const { gen, data, opts } = it;
|
||||
const dataType = gen.let("dataType", (0, codegen_1._) `typeof ${data}`);
|
||||
const coerced = gen.let("coerced", (0, codegen_1._) `undefined`);
|
||||
if (opts.coerceTypes === "array") {
|
||||
gen.if((0, codegen_1._) `${dataType} == 'object' && Array.isArray(${data}) && ${data}.length == 1`, () => gen
|
||||
.assign(data, (0, codegen_1._) `${data}[0]`)
|
||||
.assign(dataType, (0, codegen_1._) `typeof ${data}`)
|
||||
.if(checkDataTypes(types, data, opts.strictNumbers), () => gen.assign(coerced, data)));
|
||||
}
|
||||
gen.if((0, codegen_1._) `${coerced} !== undefined`);
|
||||
for (const t of coerceTo) {
|
||||
if (COERCIBLE.has(t) || (t === "array" && opts.coerceTypes === "array")) {
|
||||
coerceSpecificType(t);
|
||||
}
|
||||
}
|
||||
gen.else();
|
||||
reportTypeError(it);
|
||||
gen.endIf();
|
||||
gen.if((0, codegen_1._) `${coerced} !== undefined`, () => {
|
||||
gen.assign(data, coerced);
|
||||
assignParentData(it, coerced);
|
||||
});
|
||||
function coerceSpecificType(t) {
|
||||
switch (t) {
|
||||
case "string":
|
||||
gen
|
||||
.elseIf((0, codegen_1._) `${dataType} == "number" || ${dataType} == "boolean"`)
|
||||
.assign(coerced, (0, codegen_1._) `"" + ${data}`)
|
||||
.elseIf((0, codegen_1._) `${data} === null`)
|
||||
.assign(coerced, (0, codegen_1._) `""`);
|
||||
return;
|
||||
case "number":
|
||||
gen
|
||||
.elseIf((0, codegen_1._) `${dataType} == "boolean" || ${data} === null
|
||||
|| (${dataType} == "string" && ${data} && ${data} == +${data})`)
|
||||
.assign(coerced, (0, codegen_1._) `+${data}`);
|
||||
return;
|
||||
case "integer":
|
||||
gen
|
||||
.elseIf((0, codegen_1._) `${dataType} === "boolean" || ${data} === null
|
||||
|| (${dataType} === "string" && ${data} && ${data} == +${data} && !(${data} % 1))`)
|
||||
.assign(coerced, (0, codegen_1._) `+${data}`);
|
||||
return;
|
||||
case "boolean":
|
||||
gen
|
||||
.elseIf((0, codegen_1._) `${data} === "false" || ${data} === 0 || ${data} === null`)
|
||||
.assign(coerced, false)
|
||||
.elseIf((0, codegen_1._) `${data} === "true" || ${data} === 1`)
|
||||
.assign(coerced, true);
|
||||
return;
|
||||
case "null":
|
||||
gen.elseIf((0, codegen_1._) `${data} === "" || ${data} === 0 || ${data} === false`);
|
||||
gen.assign(coerced, null);
|
||||
return;
|
||||
case "array":
|
||||
gen
|
||||
.elseIf((0, codegen_1._) `${dataType} === "string" || ${dataType} === "number"
|
||||
|| ${dataType} === "boolean" || ${data} === null`)
|
||||
.assign(coerced, (0, codegen_1._) `[${data}]`);
|
||||
}
|
||||
}
|
||||
}
|
||||
function assignParentData({ gen, parentData, parentDataProperty }, expr) {
|
||||
// TODO use gen.property
|
||||
gen.if((0, codegen_1._) `${parentData} !== undefined`, () => gen.assign((0, codegen_1._) `${parentData}[${parentDataProperty}]`, expr));
|
||||
}
|
||||
function checkDataType(dataType, data, strictNums, correct = DataType.Correct) {
|
||||
const EQ = correct === DataType.Correct ? codegen_1.operators.EQ : codegen_1.operators.NEQ;
|
||||
let cond;
|
||||
switch (dataType) {
|
||||
case "null":
|
||||
return (0, codegen_1._) `${data} ${EQ} null`;
|
||||
case "array":
|
||||
cond = (0, codegen_1._) `Array.isArray(${data})`;
|
||||
break;
|
||||
case "object":
|
||||
cond = (0, codegen_1._) `${data} && typeof ${data} == "object" && !Array.isArray(${data})`;
|
||||
break;
|
||||
case "integer":
|
||||
cond = numCond((0, codegen_1._) `!(${data} % 1) && !isNaN(${data})`);
|
||||
break;
|
||||
case "number":
|
||||
cond = numCond();
|
||||
break;
|
||||
default:
|
||||
return (0, codegen_1._) `typeof ${data} ${EQ} ${dataType}`;
|
||||
}
|
||||
return correct === DataType.Correct ? cond : (0, codegen_1.not)(cond);
|
||||
function numCond(_cond = codegen_1.nil) {
|
||||
return (0, codegen_1.and)((0, codegen_1._) `typeof ${data} == "number"`, _cond, strictNums ? (0, codegen_1._) `isFinite(${data})` : codegen_1.nil);
|
||||
}
|
||||
}
|
||||
exports.checkDataType = checkDataType;
|
||||
function checkDataTypes(dataTypes, data, strictNums, correct) {
|
||||
if (dataTypes.length === 1) {
|
||||
return checkDataType(dataTypes[0], data, strictNums, correct);
|
||||
}
|
||||
let cond;
|
||||
const types = (0, util_1.toHash)(dataTypes);
|
||||
if (types.array && types.object) {
|
||||
const notObj = (0, codegen_1._) `typeof ${data} != "object"`;
|
||||
cond = types.null ? notObj : (0, codegen_1._) `!${data} || ${notObj}`;
|
||||
delete types.null;
|
||||
delete types.array;
|
||||
delete types.object;
|
||||
}
|
||||
else {
|
||||
cond = codegen_1.nil;
|
||||
}
|
||||
if (types.number)
|
||||
delete types.integer;
|
||||
for (const t in types)
|
||||
cond = (0, codegen_1.and)(cond, checkDataType(t, data, strictNums, correct));
|
||||
return cond;
|
||||
}
|
||||
exports.checkDataTypes = checkDataTypes;
|
||||
const typeError = {
|
||||
message: ({ schema }) => `must be ${schema}`,
|
||||
params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1._) `{type: ${schema}}` : (0, codegen_1._) `{type: ${schemaValue}}`,
|
||||
};
|
||||
function reportTypeError(it) {
|
||||
const cxt = getTypeErrorContext(it);
|
||||
(0, errors_1.reportError)(cxt, typeError);
|
||||
}
|
||||
exports.reportTypeError = reportTypeError;
|
||||
function getTypeErrorContext(it) {
|
||||
const { gen, data, schema } = it;
|
||||
const schemaCode = (0, util_1.schemaRefOrVal)(it, schema, "type");
|
||||
return {
|
||||
gen,
|
||||
keyword: "type",
|
||||
data,
|
||||
schema: schema.type,
|
||||
schemaCode,
|
||||
schemaValue: schemaCode,
|
||||
parentSchema: schema,
|
||||
params: {},
|
||||
it,
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=dataType.js.map
|
1
my-app/node_modules/ajv/dist/compile/validate/dataType.js.map
generated
vendored
Executable file
1
my-app/node_modules/ajv/dist/compile/validate/dataType.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
2
my-app/node_modules/ajv/dist/compile/validate/defaults.d.ts
generated
vendored
Executable file
2
my-app/node_modules/ajv/dist/compile/validate/defaults.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,2 @@
|
|||
import type { SchemaObjCxt } from "..";
|
||||
export declare function assignDefaults(it: SchemaObjCxt, ty?: string): void;
|
35
my-app/node_modules/ajv/dist/compile/validate/defaults.js
generated
vendored
Executable file
35
my-app/node_modules/ajv/dist/compile/validate/defaults.js
generated
vendored
Executable file
|
@ -0,0 +1,35 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.assignDefaults = void 0;
|
||||
const codegen_1 = require("../codegen");
|
||||
const util_1 = require("../util");
|
||||
function assignDefaults(it, ty) {
|
||||
const { properties, items } = it.schema;
|
||||
if (ty === "object" && properties) {
|
||||
for (const key in properties) {
|
||||
assignDefault(it, key, properties[key].default);
|
||||
}
|
||||
}
|
||||
else if (ty === "array" && Array.isArray(items)) {
|
||||
items.forEach((sch, i) => assignDefault(it, i, sch.default));
|
||||
}
|
||||
}
|
||||
exports.assignDefaults = assignDefaults;
|
||||
function assignDefault(it, prop, defaultValue) {
|
||||
const { gen, compositeRule, data, opts } = it;
|
||||
if (defaultValue === undefined)
|
||||
return;
|
||||
const childData = (0, codegen_1._) `${data}${(0, codegen_1.getProperty)(prop)}`;
|
||||
if (compositeRule) {
|
||||
(0, util_1.checkStrictMode)(it, `default is ignored for: ${childData}`);
|
||||
return;
|
||||
}
|
||||
let condition = (0, codegen_1._) `${childData} === undefined`;
|
||||
if (opts.useDefaults === "empty") {
|
||||
condition = (0, codegen_1._) `${condition} || ${childData} === null || ${childData} === ""`;
|
||||
}
|
||||
// `${childData} === undefined` +
|
||||
// (opts.useDefaults === "empty" ? ` || ${childData} === null || ${childData} === ""` : "")
|
||||
gen.if(condition, (0, codegen_1._) `${childData} = ${(0, codegen_1.stringify)(defaultValue)}`);
|
||||
}
|
||||
//# sourceMappingURL=defaults.js.map
|
1
my-app/node_modules/ajv/dist/compile/validate/defaults.js.map
generated
vendored
Executable file
1
my-app/node_modules/ajv/dist/compile/validate/defaults.js.map
generated
vendored
Executable file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../../lib/compile/validate/defaults.ts"],"names":[],"mappings":";;;AACA,wCAAoD;AACpD,kCAAuC;AAEvC,SAAgB,cAAc,CAAC,EAAgB,EAAE,EAAW;IAC1D,MAAM,EAAC,UAAU,EAAE,KAAK,EAAC,GAAG,EAAE,CAAC,MAAM,CAAA;IACrC,IAAI,EAAE,KAAK,QAAQ,IAAI,UAAU,EAAE;QACjC,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE;YAC5B,aAAa,CAAC,EAAE,EAAE,GAAG,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAA;SAChD;KACF;SAAM,IAAI,EAAE,KAAK,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACjD,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAS,EAAE,EAAE,CAAC,aAAa,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAA;KACrE;AACH,CAAC;AATD,wCASC;AAED,SAAS,aAAa,CAAC,EAAgB,EAAE,IAAqB,EAAE,YAAqB;IACnF,MAAM,EAAC,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,EAAC,GAAG,EAAE,CAAA;IAC3C,IAAI,YAAY,KAAK,SAAS;QAAE,OAAM;IACtC,MAAM,SAAS,GAAG,IAAA,WAAC,EAAA,GAAG,IAAI,GAAG,IAAA,qBAAW,EAAC,IAAI,CAAC,EAAE,CAAA;IAChD,IAAI,aAAa,EAAE;QACjB,IAAA,sBAAe,EAAC,EAAE,EAAE,2BAA2B,SAAS,EAAE,CAAC,CAAA;QAC3D,OAAM;KACP;IAED,IAAI,SAAS,GAAG,IAAA,WAAC,EAAA,GAAG,SAAS,gBAAgB,CAAA;IAC7C,IAAI,IAAI,CAAC,WAAW,KAAK,OAAO,EAAE;QAChC,SAAS,GAAG,IAAA,WAAC,EAAA,GAAG,SAAS,OAAO,SAAS,gBAAgB,SAAS,SAAS,CAAA;KAC5E;IACD,iCAAiC;IACjC,2FAA2F;IAC3F,GAAG,CAAC,EAAE,CAAC,SAAS,EAAE,IAAA,WAAC,EAAA,GAAG,SAAS,MAAM,IAAA,mBAAS,EAAC,YAAY,CAAC,EAAE,CAAC,CAAA;AACjE,CAAC"}
|
42
my-app/node_modules/ajv/dist/compile/validate/index.d.ts
generated
vendored
Executable file
42
my-app/node_modules/ajv/dist/compile/validate/index.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,42 @@
|
|||
import type { AddedKeywordDefinition, AnySchemaObject, KeywordErrorCxt, KeywordCxtParams } from "../../types";
|
||||
import type { SchemaCxt, SchemaObjCxt } from "..";
|
||||
import { SubschemaArgs } from "./subschema";
|
||||
import { Code, Name, CodeGen } from "../codegen";
|
||||
import type { JSONType } from "../rules";
|
||||
import { ErrorPaths } from "../errors";
|
||||
export declare function validateFunctionCode(it: SchemaCxt): void;
|
||||
export declare class KeywordCxt implements KeywordErrorCxt {
|
||||
readonly gen: CodeGen;
|
||||
readonly allErrors?: boolean;
|
||||
readonly keyword: string;
|
||||
readonly data: Name;
|
||||
readonly $data?: string | false;
|
||||
schema: any;
|
||||
readonly schemaValue: Code | number | boolean;
|
||||
readonly schemaCode: Code | number | boolean;
|
||||
readonly schemaType: JSONType[];
|
||||
readonly parentSchema: AnySchemaObject;
|
||||
readonly errsCount?: Name;
|
||||
params: KeywordCxtParams;
|
||||
readonly it: SchemaObjCxt;
|
||||
readonly def: AddedKeywordDefinition;
|
||||
constructor(it: SchemaObjCxt, def: AddedKeywordDefinition, keyword: string);
|
||||
result(condition: Code, successAction?: () => void, failAction?: () => void): void;
|
||||
failResult(condition: Code, successAction?: () => void, failAction?: () => void): void;
|
||||
pass(condition: Code, failAction?: () => void): void;
|
||||
fail(condition?: Code): void;
|
||||
fail$data(condition: Code): void;
|
||||
error(append?: boolean, errorParams?: KeywordCxtParams, errorPaths?: ErrorPaths): void;
|
||||
private _error;
|
||||
$dataError(): void;
|
||||
reset(): void;
|
||||
ok(cond: Code | boolean): void;
|
||||
setParams(obj: KeywordCxtParams, assign?: true): void;
|
||||
block$data(valid: Name, codeBlock: () => void, $dataValid?: Code): void;
|
||||
check$data(valid?: Name, $dataValid?: Code): void;
|
||||
invalid$data(): Code;
|
||||
subschema(appl: SubschemaArgs, valid: Name): SchemaCxt;
|
||||
mergeEvaluated(schemaCxt: SchemaCxt, toName?: typeof Name): void;
|
||||
mergeValidEvaluated(schemaCxt: SchemaCxt, valid: Name): boolean | void;
|
||||
}
|
||||
export declare function getData($data: string, { dataLevel, dataNames, dataPathArr }: SchemaCxt): Code | number;
|
520
my-app/node_modules/ajv/dist/compile/validate/index.js
generated
vendored
Executable file
520
my-app/node_modules/ajv/dist/compile/validate/index.js
generated
vendored
Executable file
|
@ -0,0 +1,520 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getData = exports.KeywordCxt = exports.validateFunctionCode = void 0;
|
||||
const boolSchema_1 = require("./boolSchema");
|
||||
const dataType_1 = require("./dataType");
|
||||
const applicability_1 = require("./applicability");
|
||||
const dataType_2 = require("./dataType");
|
||||
const defaults_1 = require("./defaults");
|
||||
const keyword_1 = require("./keyword");
|
||||
const subschema_1 = require("./subschema");
|
||||
const codegen_1 = require("../codegen");
|
||||
const names_1 = require("../names");
|
||||
const resolve_1 = require("../resolve");
|
||||
const util_1 = require("../util");
|
||||
const errors_1 = require("../errors");
|
||||
// schema compilation - generates validation function, subschemaCode (below) is used for subschemas
|
||||
function validateFunctionCode(it) {
|
||||
if (isSchemaObj(it)) {
|
||||
checkKeywords(it);
|
||||
if (schemaCxtHasRules(it)) {
|
||||
topSchemaObjCode(it);
|
||||
return;
|
||||
}
|
||||
}
|
||||
validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
|
||||
}
|
||||
exports.validateFunctionCode = validateFunctionCode;
|
||||
function validateFunction({ gen, validateName, schema, schemaEnv, opts }, body) {
|
||||
if (opts.code.es5) {
|
||||
gen.func(validateName, (0, codegen_1._) `${names_1.default.data}, ${names_1.default.valCxt}`, schemaEnv.$async, () => {
|
||||
gen.code((0, codegen_1._) `"use strict"; ${funcSourceUrl(schema, opts)}`);
|
||||
destructureValCxtES5(gen, opts);
|
||||
gen.code(body);
|
||||
});
|
||||
}
|
||||
else {
|
||||
gen.func(validateName, (0, codegen_1._) `${names_1.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
|
||||
}
|
||||
}
|
||||
function destructureValCxt(opts) {
|
||||
return (0, codegen_1._) `{${names_1.default.instancePath}="", ${names_1.default.parentData}, ${names_1.default.parentDataProperty}, ${names_1.default.rootData}=${names_1.default.data}${opts.dynamicRef ? (0, codegen_1._) `, ${names_1.default.dynamicAnchors}={}` : codegen_1.nil}}={}`;
|
||||
}
|
||||
function destructureValCxtES5(gen, opts) {
|
||||
gen.if(names_1.default.valCxt, () => {
|
||||
gen.var(names_1.default.instancePath, (0, codegen_1._) `${names_1.default.valCxt}.${names_1.default.instancePath}`);
|
||||
gen.var(names_1.default.parentData, (0, codegen_1._) `${names_1.default.valCxt}.${names_1.default.parentData}`);
|
||||
gen.var(names_1.default.parentDataProperty, (0, codegen_1._) `${names_1.default.valCxt}.${names_1.default.parentDataProperty}`);
|
||||
gen.var(names_1.default.rootData, (0, codegen_1._) `${names_1.default.valCxt}.${names_1.default.rootData}`);
|
||||
if (opts.dynamicRef)
|
||||
gen.var(names_1.default.dynamicAnchors, (0, codegen_1._) `${names_1.default.valCxt}.${names_1.default.dynamicAnchors}`);
|
||||
}, () => {
|
||||
gen.var(names_1.default.instancePath, (0, codegen_1._) `""`);
|
||||
gen.var(names_1.default.parentData, (0, codegen_1._) `undefined`);
|
||||
gen.var(names_1.default.parentDataProperty, (0, codegen_1._) `undefined`);
|
||||
gen.var(names_1.default.rootData, names_1.default.data);
|
||||
if (opts.dynamicRef)
|
||||
gen.var(names_1.default.dynamicAnchors, (0, codegen_1._) `{}`);
|
||||
});
|
||||
}
|
||||
function topSchemaObjCode(it) {
|
||||
const { schema, opts, gen } = it;
|
||||
validateFunction(it, () => {
|
||||
if (opts.$comment && schema.$comment)
|
||||
commentKeyword(it);
|
||||
checkNoDefault(it);
|
||||
gen.let(names_1.default.vErrors, null);
|
||||
gen.let(names_1.default.errors, 0);
|
||||
if (opts.unevaluated)
|
||||
resetEvaluated(it);
|
||||
typeAndKeywords(it);
|
||||
returnResults(it);
|
||||
});
|
||||
return;
|
||||
}
|
||||
function resetEvaluated(it) {
|
||||
// TODO maybe some hook to execute it in the end to check whether props/items are Name, as in assignEvaluated
|
||||
const { gen, validateName } = it;
|
||||
it.evaluated = gen.const("evaluated", (0, codegen_1._) `${validateName}.evaluated`);
|
||||
gen.if((0, codegen_1._) `${it.evaluated}.dynamicProps`, () => gen.assign((0, codegen_1._) `${it.evaluated}.props`, (0, codegen_1._) `undefined`));
|
||||
gen.if((0, codegen_1._) `${it.evaluated}.dynamicItems`, () => gen.assign((0, codegen_1._) `${it.evaluated}.items`, (0, codegen_1._) `undefined`));
|
||||
}
|
||||
function funcSourceUrl(schema, opts) {
|
||||
const schId = typeof schema == "object" && schema[opts.schemaId];
|
||||
return schId && (opts.code.source || opts.code.process) ? (0, codegen_1._) `/*# sourceURL=${schId} */` : codegen_1.nil;
|
||||
}
|
||||
// schema compilation - this function is used recursively to generate code for sub-schemas
|
||||
function subschemaCode(it, valid) {
|
||||
if (isSchemaObj(it)) {
|
||||
checkKeywords(it);
|
||||
if (schemaCxtHasRules(it)) {
|
||||
subSchemaObjCode(it, valid);
|
||||
return;
|
||||
}
|
||||
}
|
||||
(0, boolSchema_1.boolOrEmptySchema)(it, valid);
|
||||
}
|
||||
function schemaCxtHasRules({ schema, self }) {
|
||||
if (typeof schema == "boolean")
|
||||
return !schema;
|
||||
for (const key in schema)
|
||||
if (self.RULES.all[key])
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
function isSchemaObj(it) {
|
||||
return typeof it.schema != "boolean";
|
||||
}
|
||||
function subSchemaObjCode(it, valid) {
|
||||
const { schema, gen, opts } = it;
|
||||
if (opts.$comment && schema.$comment)
|
||||
commentKeyword(it);
|
||||
updateContext(it);
|
||||
checkAsyncSchema(it);
|
||||
const errsCount = gen.const("_errs", names_1.default.errors);
|
||||
typeAndKeywords(it, errsCount);
|
||||
// TODO var
|
||||
gen.var(valid, (0, codegen_1._) `${errsCount} === ${names_1.default.errors}`);
|
||||
}
|
||||
function checkKeywords(it) {
|
||||
(0, util_1.checkUnknownRules)(it);
|
||||
checkRefsAndKeywords(it);
|
||||
}
|
||||
function typeAndKeywords(it, errsCount) {
|
||||
if (it.opts.jtd)
|
||||
return schemaKeywords(it, [], false, errsCount);
|
||||
const types = (0, dataType_1.getSchemaTypes)(it.schema);
|
||||
const checkedTypes = (0, dataType_1.coerceAndCheckDataType)(it, types);
|
||||
schemaKeywords(it, types, !checkedTypes, errsCount);
|
||||
}
|
||||
function checkRefsAndKeywords(it) {
|
||||
const { schema, errSchemaPath, opts, self } = it;
|
||||
if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_1.schemaHasRulesButRef)(schema, self.RULES)) {
|
||||
self.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
|
||||
}
|
||||
}
|
||||
function checkNoDefault(it) {
|
||||
const { schema, opts } = it;
|
||||
if (schema.default !== undefined && opts.useDefaults && opts.strictSchema) {
|
||||
(0, util_1.checkStrictMode)(it, "default is ignored in the schema root");
|
||||
}
|
||||
}
|
||||
function updateContext(it) {
|
||||
const schId = it.schema[it.opts.schemaId];
|
||||
if (schId)
|
||||
it.baseId = (0, resolve_1.resolveUrl)(it.opts.uriResolver, it.baseId, schId);
|
||||
}
|
||||
function checkAsyncSchema(it) {
|
||||
if (it.schema.$async && !it.schemaEnv.$async)
|
||||
throw new Error("async schema in sync schema");
|
||||
}
|
||||
function commentKeyword({ gen, schemaEnv, schema, errSchemaPath, opts }) {
|
||||
const msg = schema.$comment;
|
||||
if (opts.$comment === true) {
|
||||
gen.code((0, codegen_1._) `${names_1.default.self}.logger.log(${msg})`);
|
||||
}
|
||||
else if (typeof opts.$comment == "function") {
|
||||
const schemaPath = (0, codegen_1.str) `${errSchemaPath}/$comment`;
|
||||
const rootName = gen.scopeValue("root", { ref: schemaEnv.root });
|
||||
gen.code((0, codegen_1._) `${names_1.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`);
|
||||
}
|
||||
}
|
||||
function returnResults(it) {
|
||||
const { gen, schemaEnv, validateName, ValidationError, opts } = it;
|
||||
if (schemaEnv.$async) {
|
||||
// TODO assign unevaluated
|
||||
gen.if((0, codegen_1._) `${names_1.default.errors} === 0`, () => gen.return(names_1.default.data), () => gen.throw((0, codegen_1._) `new ${ValidationError}(${names_1.default.vErrors})`));
|
||||
}
|
||||
else {
|
||||
gen.assign((0, codegen_1._) `${validateName}.errors`, names_1.default.vErrors);
|
||||
if (opts.unevaluated)
|
||||
assignEvaluated(it);
|
||||
gen.return((0, codegen_1._) `${names_1.default.errors} === 0`);
|
||||
}
|
||||
}
|
||||
function assignEvaluated({ gen, evaluated, props, items }) {
|
||||
if (props instanceof codegen_1.Name)
|
||||
gen.assign((0, codegen_1._) `${evaluated}.props`, props);
|
||||
if (items instanceof codegen_1.Name)
|
||||
gen.assign((0, codegen_1._) `${evaluated}.items`, items);
|
||||
}
|
||||
function schemaKeywords(it, types, typeErrors, errsCount) {
|
||||
const { gen, schema, data, allErrors, opts, self } = it;
|
||||
const { RULES } = self;
|
||||
if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1.schemaHasRulesButRef)(schema, RULES))) {
|
||||
gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition)); // TODO typecast
|
||||
return;
|
||||
}
|
||||
if (!opts.jtd)
|
||||
checkStrictTypes(it, types);
|
||||
gen.block(() => {
|
||||
for (const group of RULES.rules)
|
||||
groupKeywords(group);
|
||||
groupKeywords(RULES.post);
|
||||
});
|
||||
function groupKeywords(group) {
|
||||
if (!(0, applicability_1.shouldUseGroup)(schema, group))
|
||||
return;
|
||||
if (group.type) {
|
||||
gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers));
|
||||
iterateKeywords(it, group);
|
||||
if (types.length === 1 && types[0] === group.type && typeErrors) {
|
||||
gen.else();
|
||||
(0, dataType_2.reportTypeError)(it);
|
||||
}
|
||||
gen.endIf();
|
||||
}
|
||||
else {
|
||||
iterateKeywords(it, group);
|
||||
}
|
||||
// TODO make it "ok" call?
|
||||
if (!allErrors)
|
||||
gen.if((0, codegen_1._) `${names_1.default.errors} === ${errsCount || 0}`);
|
||||
}
|
||||
}
|
||||
function iterateKeywords(it, group) {
|
||||
const { gen, schema, opts: { useDefaults }, } = it;
|
||||
if (useDefaults)
|
||||
(0, defaults_1.assignDefaults)(it, group.type);
|
||||
gen.block(() => {
|
||||
for (const rule of group.rules) {
|
||||
if ((0, applicability_1.shouldUseRule)(schema, rule)) {
|
||||
keywordCode(it, rule.keyword, rule.definition, group.type);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
function checkStrictTypes(it, types) {
|
||||
if (it.schemaEnv.meta || !it.opts.strictTypes)
|
||||
return;
|
||||
checkContextTypes(it, types);
|
||||
if (!it.opts.allowUnionTypes)
|
||||
checkMultipleTypes(it, types);
|
||||
checkKeywordTypes(it, it.dataTypes);
|
||||
}
|
||||
function checkContextTypes(it, types) {
|
||||
if (!types.length)
|
||||
return;
|
||||
if (!it.dataTypes.length) {
|
||||
it.dataTypes = types;
|
||||
return;
|
||||
}
|
||||
types.forEach((t) => {
|
||||
if (!includesType(it.dataTypes, t)) {
|
||||
strictTypesError(it, `type "${t}" not allowed by context "${it.dataTypes.join(",")}"`);
|
||||
}
|
||||
});
|
||||
narrowSchemaTypes(it, types);
|
||||
}
|
||||
function checkMultipleTypes(it, ts) {
|
||||
if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
|
||||
strictTypesError(it, "use allowUnionTypes to allow union type keyword");
|
||||
}
|
||||
}
|
||||
function checkKeywordTypes(it, ts) {
|
||||
const rules = it.self.RULES.all;
|
||||
for (const keyword in rules) {
|
||||
const rule = rules[keyword];
|
||||
if (typeof rule == "object" && (0, applicability_1.shouldUseRule)(it.schema, rule)) {
|
||||
const { type } = rule.definition;
|
||||
if (type.length && !type.some((t) => hasApplicableType(ts, t))) {
|
||||
strictTypesError(it, `missing type "${type.join(",")}" for keyword "${keyword}"`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function hasApplicableType(schTs, kwdT) {
|
||||
return schTs.includes(kwdT) || (kwdT === "number" && schTs.includes("integer"));
|
||||
}
|
||||
function includesType(ts, t) {
|
||||
return ts.includes(t) || (t === "integer" && ts.includes("number"));
|
||||
}
|
||||
function narrowSchemaTypes(it, withTypes) {
|
||||
const ts = [];
|
||||
for (const t of it.dataTypes) {
|
||||
if (includesType(withTypes, t))
|
||||
ts.push(t);
|
||||
else if (withTypes.includes("integer") && t === "number")
|
||||
ts.push("integer");
|
||||
}
|
||||
it.dataTypes = ts;
|
||||
}
|
||||
function strictTypesError(it, msg) {
|
||||
const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
|
||||
msg += ` at "${schemaPath}" (strictTypes)`;
|
||||
(0, util_1.checkStrictMode)(it, msg, it.opts.strictTypes);
|
||||
}
|
||||
class KeywordCxt {
|
||||
constructor(it, def, keyword) {
|
||||
(0, keyword_1.validateKeywordUsage)(it, def, keyword);
|
||||
this.gen = it.gen;
|
||||
this.allErrors = it.allErrors;
|
||||
this.keyword = keyword;
|
||||
this.data = it.data;
|
||||
this.schema = it.schema[keyword];
|
||||
this.$data = def.$data && it.opts.$data && this.schema && this.schema.$data;
|
||||
this.schemaValue = (0, util_1.schemaRefOrVal)(it, this.schema, keyword, this.$data);
|
||||
this.schemaType = def.schemaType;
|
||||
this.parentSchema = it.schema;
|
||||
this.params = {};
|
||||
this.it = it;
|
||||
this.def = def;
|
||||
if (this.$data) {
|
||||
this.schemaCode = it.gen.const("vSchema", getData(this.$data, it));
|
||||
}
|
||||
else {
|
||||
this.schemaCode = this.schemaValue;
|
||||
if (!(0, keyword_1.validSchemaType)(this.schema, def.schemaType, def.allowUndefined)) {
|
||||
throw new Error(`${keyword} value must be ${JSON.stringify(def.schemaType)}`);
|
||||
}
|
||||
}
|
||||
if ("code" in def ? def.trackErrors : def.errors !== false) {
|
||||
this.errsCount = it.gen.const("_errs", names_1.default.errors);
|
||||
}
|
||||
}
|
||||
result(condition, successAction, failAction) {
|
||||
this.failResult((0, codegen_1.not)(condition), successAction, failAction);
|
||||
}
|
||||
failResult(condition, successAction, failAction) {
|
||||
this.gen.if(condition);
|
||||
if (failAction)
|
||||
failAction();
|
||||
else
|
||||
this.error();
|
||||
if (successAction) {
|
||||
this.gen.else();
|
||||
successAction();
|
||||
if (this.allErrors)
|
||||
this.gen.endIf();
|
||||
}
|
||||
else {
|
||||
if (this.allErrors)
|
||||
this.gen.endIf();
|
||||
else
|
||||
this.gen.else();
|
||||
}
|
||||
}
|
||||
pass(condition, failAction) {
|
||||
this.failResult((0, codegen_1.not)(condition), undefined, failAction);
|
||||
}
|
||||
fail(condition) {
|
||||
if (condition === undefined) {
|
||||
this.error();
|
||||
if (!this.allErrors)
|
||||
this.gen.if(false); // this branch will be removed by gen.optimize
|
||||
return;
|
||||
}
|
||||
this.gen.if(condition);
|
||||
this.error();
|
||||
if (this.allErrors)
|
||||
this.gen.endIf();
|
||||
else
|
||||
this.gen.else();
|
||||
}
|
||||
fail$data(condition) {
|
||||
if (!this.$data)
|
||||
return this.fail(condition);
|
||||
const { schemaCode } = this;
|
||||
this.fail((0, codegen_1._) `${schemaCode} !== undefined && (${(0, codegen_1.or)(this.invalid$data(), condition)})`);
|
||||
}
|
||||
error(append, errorParams, errorPaths) {
|
||||
if (errorParams) {
|
||||
this.setParams(errorParams);
|
||||
this._error(append, errorPaths);
|
||||
this.setParams({});
|
||||
return;
|
||||
}
|
||||
this._error(append, errorPaths);
|
||||
}
|
||||
_error(append, errorPaths) {
|
||||
;
|
||||
(append ? errors_1.reportExtraError : errors_1.reportError)(this, this.def.error, errorPaths);
|
||||
}
|
||||
$dataError() {
|
||||
(0, errors_1.reportError)(this, this.def.$dataError || errors_1.keyword$DataError);
|
||||
}
|
||||
reset() {
|
||||
if (this.errsCount === undefined)
|
||||
throw new Error('add "trackErrors" to keyword definition');
|
||||
(0, errors_1.resetErrorsCount)(this.gen, this.errsCount);
|
||||
}
|
||||
ok(cond) {
|
||||
if (!this.allErrors)
|
||||
this.gen.if(cond);
|
||||
}
|
||||
setParams(obj, assign) {
|
||||
if (assign)
|
||||
Object.assign(this.params, obj);
|
||||
else
|
||||
this.params = obj;
|
||||
}
|
||||
block$data(valid, codeBlock, $dataValid = codegen_1.nil) {
|
||||
this.gen.block(() => {
|
||||
this.check$data(valid, $dataValid);
|
||||
codeBlock();
|
||||
});
|
||||
}
|
||||
check$data(valid = codegen_1.nil, $dataValid = codegen_1.nil) {
|
||||
if (!this.$data)
|
||||
return;
|
||||
const { gen, schemaCode, schemaType, def } = this;
|
||||
gen.if((0, codegen_1.or)((0, codegen_1._) `${schemaCode} === undefined`, $dataValid));
|
||||
if (valid !== codegen_1.nil)
|
||||
gen.assign(valid, true);
|
||||
if (schemaType.length || def.validateSchema) {
|
||||
gen.elseIf(this.invalid$data());
|
||||
this.$dataError();
|
||||
if (valid !== codegen_1.nil)
|
||||
gen.assign(valid, false);
|
||||
}
|
||||
gen.else();
|
||||
}
|
||||
invalid$data() {
|
||||
const { gen, schemaCode, schemaType, def, it } = this;
|
||||
return (0, codegen_1.or)(wrong$DataType(), invalid$DataSchema());
|
||||
function wrong$DataType() {
|
||||
if (schemaType.length) {
|
||||
/* istanbul ignore if */
|
||||
if (!(schemaCode instanceof codegen_1.Name))
|
||||
throw new Error("ajv implementation error");
|
||||
const st = Array.isArray(schemaType) ? schemaType : [schemaType];
|
||||
return (0, codegen_1._) `${(0, dataType_2.checkDataTypes)(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)}`;
|
||||
}
|
||||
return codegen_1.nil;
|
||||
}
|
||||
function invalid$DataSchema() {
|
||||
if (def.validateSchema) {
|
||||
const validateSchemaRef = gen.scopeValue("validate$data", { ref: def.validateSchema }); // TODO value.code for standalone
|
||||
return (0, codegen_1._) `!${validateSchemaRef}(${schemaCode})`;
|
||||
}
|
||||
return codegen_1.nil;
|
||||
}
|
||||
}
|
||||
subschema(appl, valid) {
|
||||
const subschema = (0, subschema_1.getSubschema)(this.it, appl);
|
||||
(0, subschema_1.extendSubschemaData)(subschema, this.it, appl);
|
||||
(0, subschema_1.extendSubschemaMode)(subschema, appl);
|
||||
const nextContext = { ...this.it, ...subschema, items: undefined, props: undefined };
|
||||
subschemaCode(nextContext, valid);
|
||||
return nextContext;
|
||||
}
|
||||
mergeEvaluated(schemaCxt, toName) {
|
||||
const { it, gen } = this;
|
||||
if (!it.opts.unevaluated)
|
||||
return;
|
||||
if (it.props !== true && schemaCxt.props !== undefined) {
|
||||
it.props = util_1.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
|
||||
}
|
||||
if (it.items !== true && schemaCxt.items !== undefined) {
|
||||
it.items = util_1.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName);
|
||||
}
|
||||
}
|
||||
mergeValidEvaluated(schemaCxt, valid) {
|
||||
const { it, gen } = this;
|
||||
if (it.opts.unevaluated && (it.props !== true || it.items !== true)) {
|
||||
gen.if(valid, () => this.mergeEvaluated(schemaCxt, codegen_1.Name));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.KeywordCxt = KeywordCxt;
|
||||
function keywordCode(it, keyword, def, ruleType) {
|
||||
const cxt = new KeywordCxt(it, def, keyword);
|
||||
if ("code" in def) {
|
||||
def.code(cxt, ruleType);
|
||||
}
|
||||
else if (cxt.$data && def.validate) {
|
||||
(0, keyword_1.funcKeywordCode)(cxt, def);
|
||||
}
|
||||
else if ("macro" in def) {
|
||||
(0, keyword_1.macroKeywordCode)(cxt, def);
|
||||
}
|
||||
else if (def.compile || def.validate) {
|
||||
(0, keyword_1.funcKeywordCode)(cxt, def);
|
||||
}
|
||||
}
|
||||
const JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
|
||||
const RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
|
||||
function getData($data, { dataLevel, dataNames, dataPathArr }) {
|
||||
let jsonPointer;
|
||||
let data;
|
||||
if ($data === "")
|
||||
return names_1.default.rootData;
|
||||
if ($data[0] === "/") {
|
||||
if (!JSON_POINTER.test($data))
|
||||
throw new Error(`Invalid JSON-pointer: ${$data}`);
|
||||
jsonPointer = $data;
|
||||
data = names_1.default.rootData;
|
||||
}
|
||||
else {
|
||||
const matches = RELATIVE_JSON_POINTER.exec($data);
|
||||
if (!matches)
|
||||
throw new Error(`Invalid JSON-pointer: ${$data}`);
|
||||
const up = +matches[1];
|
||||
jsonPointer = matches[2];
|
||||
if (jsonPointer === "#") {
|
||||
if (up >= dataLevel)
|
||||
throw new Error(errorMsg("property/index", up));
|
||||
return dataPathArr[dataLevel - up];
|
||||
}
|
||||
if (up > dataLevel)
|
||||
throw new Error(errorMsg("data", up));
|
||||
data = dataNames[dataLevel - up];
|
||||
if (!jsonPointer)
|
||||
return data;
|
||||
}
|
||||
let expr = data;
|
||||
const segments = jsonPointer.split("/");
|
||||
for (const segment of segments) {
|
||||
if (segment) {
|
||||
data = (0, codegen_1._) `${data}${(0, codegen_1.getProperty)((0, util_1.unescapeJsonPointer)(segment))}`;
|
||||
expr = (0, codegen_1._) `${expr} && ${data}`;
|
||||
}
|
||||
}
|
||||
return expr;
|
||||
function errorMsg(pointerType, up) {
|
||||
return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`;
|
||||
}
|
||||
}
|
||||
exports.getData = getData;
|
||||
//# sourceMappingURL=index.js.map
|
1
my-app/node_modules/ajv/dist/compile/validate/index.js.map
generated
vendored
Executable file
1
my-app/node_modules/ajv/dist/compile/validate/index.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
8
my-app/node_modules/ajv/dist/compile/validate/keyword.d.ts
generated
vendored
Executable file
8
my-app/node_modules/ajv/dist/compile/validate/keyword.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,8 @@
|
|||
import type { KeywordCxt } from ".";
|
||||
import type { AddedKeywordDefinition, MacroKeywordDefinition, FuncKeywordDefinition } from "../../types";
|
||||
import type { SchemaObjCxt } from "..";
|
||||
import type { JSONType } from "../rules";
|
||||
export declare function macroKeywordCode(cxt: KeywordCxt, def: MacroKeywordDefinition): void;
|
||||
export declare function funcKeywordCode(cxt: KeywordCxt, def: FuncKeywordDefinition): void;
|
||||
export declare function validSchemaType(schema: unknown, schemaType: JSONType[], allowUndefined?: boolean): boolean;
|
||||
export declare function validateKeywordUsage({ schema, opts, self, errSchemaPath }: SchemaObjCxt, def: AddedKeywordDefinition, keyword: string): void;
|
124
my-app/node_modules/ajv/dist/compile/validate/keyword.js
generated
vendored
Executable file
124
my-app/node_modules/ajv/dist/compile/validate/keyword.js
generated
vendored
Executable file
|
@ -0,0 +1,124 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.validateKeywordUsage = exports.validSchemaType = exports.funcKeywordCode = exports.macroKeywordCode = void 0;
|
||||
const codegen_1 = require("../codegen");
|
||||
const names_1 = require("../names");
|
||||
const code_1 = require("../../vocabularies/code");
|
||||
const errors_1 = require("../errors");
|
||||
function macroKeywordCode(cxt, def) {
|
||||
const { gen, keyword, schema, parentSchema, it } = cxt;
|
||||
const macroSchema = def.macro.call(it.self, schema, parentSchema, it);
|
||||
const schemaRef = useKeyword(gen, keyword, macroSchema);
|
||||
if (it.opts.validateSchema !== false)
|
||||
it.self.validateSchema(macroSchema, true);
|
||||
const valid = gen.name("valid");
|
||||
cxt.subschema({
|
||||
schema: macroSchema,
|
||||
schemaPath: codegen_1.nil,
|
||||
errSchemaPath: `${it.errSchemaPath}/${keyword}`,
|
||||
topSchemaRef: schemaRef,
|
||||
compositeRule: true,
|
||||
}, valid);
|
||||
cxt.pass(valid, () => cxt.error(true));
|
||||
}
|
||||
exports.macroKeywordCode = macroKeywordCode;
|
||||
function funcKeywordCode(cxt, def) {
|
||||
var _a;
|
||||
const { gen, keyword, schema, parentSchema, $data, it } = cxt;
|
||||
checkAsyncKeyword(it, def);
|
||||
const validate = !$data && def.compile ? def.compile.call(it.self, schema, parentSchema, it) : def.validate;
|
||||
const validateRef = useKeyword(gen, keyword, validate);
|
||||
const valid = gen.let("valid");
|
||||
cxt.block$data(valid, validateKeyword);
|
||||
cxt.ok((_a = def.valid) !== null && _a !== void 0 ? _a : valid);
|
||||
function validateKeyword() {
|
||||
if (def.errors === false) {
|
||||
assignValid();
|
||||
if (def.modifying)
|
||||
modifyData(cxt);
|
||||
reportErrs(() => cxt.error());
|
||||
}
|
||||
else {
|
||||
const ruleErrs = def.async ? validateAsync() : validateSync();
|
||||
if (def.modifying)
|
||||
modifyData(cxt);
|
||||
reportErrs(() => addErrs(cxt, ruleErrs));
|
||||
}
|
||||
}
|
||||
function validateAsync() {
|
||||
const ruleErrs = gen.let("ruleErrs", null);
|
||||
gen.try(() => assignValid((0, codegen_1._) `await `), (e) => gen.assign(valid, false).if((0, codegen_1._) `${e} instanceof ${it.ValidationError}`, () => gen.assign(ruleErrs, (0, codegen_1._) `${e}.errors`), () => gen.throw(e)));
|
||||
return ruleErrs;
|
||||
}
|
||||
function validateSync() {
|
||||
const validateErrs = (0, codegen_1._) `${validateRef}.errors`;
|
||||
gen.assign(validateErrs, null);
|
||||
assignValid(codegen_1.nil);
|
||||
return validateErrs;
|
||||
}
|
||||
function assignValid(_await = def.async ? (0, codegen_1._) `await ` : codegen_1.nil) {
|
||||
const passCxt = it.opts.passContext ? names_1.default.this : names_1.default.self;
|
||||
const passSchema = !(("compile" in def && !$data) || def.schema === false);
|
||||
gen.assign(valid, (0, codegen_1._) `${_await}${(0, code_1.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def.modifying);
|
||||
}
|
||||
function reportErrs(errors) {
|
||||
var _a;
|
||||
gen.if((0, codegen_1.not)((_a = def.valid) !== null && _a !== void 0 ? _a : valid), errors);
|
||||
}
|
||||
}
|
||||
exports.funcKeywordCode = funcKeywordCode;
|
||||
function modifyData(cxt) {
|
||||
const { gen, data, it } = cxt;
|
||||
gen.if(it.parentData, () => gen.assign(data, (0, codegen_1._) `${it.parentData}[${it.parentDataProperty}]`));
|
||||
}
|
||||
function addErrs(cxt, errs) {
|
||||
const { gen } = cxt;
|
||||
gen.if((0, codegen_1._) `Array.isArray(${errs})`, () => {
|
||||
gen
|
||||
.assign(names_1.default.vErrors, (0, codegen_1._) `${names_1.default.vErrors} === null ? ${errs} : ${names_1.default.vErrors}.concat(${errs})`)
|
||||
.assign(names_1.default.errors, (0, codegen_1._) `${names_1.default.vErrors}.length`);
|
||||
(0, errors_1.extendErrors)(cxt);
|
||||
}, () => cxt.error());
|
||||
}
|
||||
function checkAsyncKeyword({ schemaEnv }, def) {
|
||||
if (def.async && !schemaEnv.$async)
|
||||
throw new Error("async keyword in sync schema");
|
||||
}
|
||||
function useKeyword(gen, keyword, result) {
|
||||
if (result === undefined)
|
||||
throw new Error(`keyword "${keyword}" failed to compile`);
|
||||
return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: (0, codegen_1.stringify)(result) });
|
||||
}
|
||||
function validSchemaType(schema, schemaType, allowUndefined = false) {
|
||||
// TODO add tests
|
||||
return (!schemaType.length ||
|
||||
schemaType.some((st) => st === "array"
|
||||
? Array.isArray(schema)
|
||||
: st === "object"
|
||||
? schema && typeof schema == "object" && !Array.isArray(schema)
|
||||
: typeof schema == st || (allowUndefined && typeof schema == "undefined")));
|
||||
}
|
||||
exports.validSchemaType = validSchemaType;
|
||||
function validateKeywordUsage({ schema, opts, self, errSchemaPath }, def, keyword) {
|
||||
/* istanbul ignore if */
|
||||
if (Array.isArray(def.keyword) ? !def.keyword.includes(keyword) : def.keyword !== keyword) {
|
||||
throw new Error("ajv implementation error");
|
||||
}
|
||||
const deps = def.dependencies;
|
||||
if (deps === null || deps === void 0 ? void 0 : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(schema, kwd))) {
|
||||
throw new Error(`parent schema must have dependencies of ${keyword}: ${deps.join(",")}`);
|
||||
}
|
||||
if (def.validateSchema) {
|
||||
const valid = def.validateSchema(schema[keyword]);
|
||||
if (!valid) {
|
||||
const msg = `keyword "${keyword}" value is invalid at path "${errSchemaPath}": ` +
|
||||
self.errorsText(def.validateSchema.errors);
|
||||
if (opts.validateSchema === "log")
|
||||
self.logger.error(msg);
|
||||
else
|
||||
throw new Error(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.validateKeywordUsage = validateKeywordUsage;
|
||||
//# sourceMappingURL=keyword.js.map
|
1
my-app/node_modules/ajv/dist/compile/validate/keyword.js.map
generated
vendored
Executable file
1
my-app/node_modules/ajv/dist/compile/validate/keyword.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
47
my-app/node_modules/ajv/dist/compile/validate/subschema.d.ts
generated
vendored
Executable file
47
my-app/node_modules/ajv/dist/compile/validate/subschema.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,47 @@
|
|||
import type { AnySchema } from "../../types";
|
||||
import type { SchemaObjCxt } from "..";
|
||||
import { Code, Name } from "../codegen";
|
||||
import { Type } from "../util";
|
||||
import type { JSONType } from "../rules";
|
||||
export interface SubschemaContext {
|
||||
schema: AnySchema;
|
||||
schemaPath: Code;
|
||||
errSchemaPath: string;
|
||||
topSchemaRef?: Code;
|
||||
errorPath?: Code;
|
||||
dataLevel?: number;
|
||||
dataTypes?: JSONType[];
|
||||
data?: Name;
|
||||
parentData?: Name;
|
||||
parentDataProperty?: Code | number;
|
||||
dataNames?: Name[];
|
||||
dataPathArr?: (Code | number)[];
|
||||
propertyName?: Name;
|
||||
jtdDiscriminator?: string;
|
||||
jtdMetadata?: boolean;
|
||||
compositeRule?: true;
|
||||
createErrors?: boolean;
|
||||
allErrors?: boolean;
|
||||
}
|
||||
export type SubschemaArgs = Partial<{
|
||||
keyword: string;
|
||||
schemaProp: string | number;
|
||||
schema: AnySchema;
|
||||
schemaPath: Code;
|
||||
errSchemaPath: string;
|
||||
topSchemaRef: Code;
|
||||
data: Name | Code;
|
||||
dataProp: Code | string | number;
|
||||
dataTypes: JSONType[];
|
||||
definedProperties: Set<string>;
|
||||
propertyName: Name;
|
||||
dataPropType: Type;
|
||||
jtdDiscriminator: string;
|
||||
jtdMetadata: boolean;
|
||||
compositeRule: true;
|
||||
createErrors: boolean;
|
||||
allErrors: boolean;
|
||||
}>;
|
||||
export declare function getSubschema(it: SchemaObjCxt, { keyword, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }: SubschemaArgs): SubschemaContext;
|
||||
export declare function extendSubschemaData(subschema: SubschemaContext, it: SchemaObjCxt, { dataProp, dataPropType: dpType, data, dataTypes, propertyName }: SubschemaArgs): void;
|
||||
export declare function extendSubschemaMode(subschema: SubschemaContext, { jtdDiscriminator, jtdMetadata, compositeRule, createErrors, allErrors }: SubschemaArgs): void;
|
81
my-app/node_modules/ajv/dist/compile/validate/subschema.js
generated
vendored
Executable file
81
my-app/node_modules/ajv/dist/compile/validate/subschema.js
generated
vendored
Executable file
|
@ -0,0 +1,81 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.extendSubschemaMode = exports.extendSubschemaData = exports.getSubschema = void 0;
|
||||
const codegen_1 = require("../codegen");
|
||||
const util_1 = require("../util");
|
||||
function getSubschema(it, { keyword, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) {
|
||||
if (keyword !== undefined && schema !== undefined) {
|
||||
throw new Error('both "keyword" and "schema" passed, only one allowed');
|
||||
}
|
||||
if (keyword !== undefined) {
|
||||
const sch = it.schema[keyword];
|
||||
return schemaProp === undefined
|
||||
? {
|
||||
schema: sch,
|
||||
schemaPath: (0, codegen_1._) `${it.schemaPath}${(0, codegen_1.getProperty)(keyword)}`,
|
||||
errSchemaPath: `${it.errSchemaPath}/${keyword}`,
|
||||
}
|
||||
: {
|
||||
schema: sch[schemaProp],
|
||||
schemaPath: (0, codegen_1._) `${it.schemaPath}${(0, codegen_1.getProperty)(keyword)}${(0, codegen_1.getProperty)(schemaProp)}`,
|
||||
errSchemaPath: `${it.errSchemaPath}/${keyword}/${(0, util_1.escapeFragment)(schemaProp)}`,
|
||||
};
|
||||
}
|
||||
if (schema !== undefined) {
|
||||
if (schemaPath === undefined || errSchemaPath === undefined || topSchemaRef === undefined) {
|
||||
throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');
|
||||
}
|
||||
return {
|
||||
schema,
|
||||
schemaPath,
|
||||
topSchemaRef,
|
||||
errSchemaPath,
|
||||
};
|
||||
}
|
||||
throw new Error('either "keyword" or "schema" must be passed');
|
||||
}
|
||||
exports.getSubschema = getSubschema;
|
||||
function extendSubschemaData(subschema, it, { dataProp, dataPropType: dpType, data, dataTypes, propertyName }) {
|
||||
if (data !== undefined && dataProp !== undefined) {
|
||||
throw new Error('both "data" and "dataProp" passed, only one allowed');
|
||||
}
|
||||
const { gen } = it;
|
||||
if (dataProp !== undefined) {
|
||||
const { errorPath, dataPathArr, opts } = it;
|
||||
const nextData = gen.let("data", (0, codegen_1._) `${it.data}${(0, codegen_1.getProperty)(dataProp)}`, true);
|
||||
dataContextProps(nextData);
|
||||
subschema.errorPath = (0, codegen_1.str) `${errorPath}${(0, util_1.getErrorPath)(dataProp, dpType, opts.jsPropertySyntax)}`;
|
||||
subschema.parentDataProperty = (0, codegen_1._) `${dataProp}`;
|
||||
subschema.dataPathArr = [...dataPathArr, subschema.parentDataProperty];
|
||||
}
|
||||
if (data !== undefined) {
|
||||
const nextData = data instanceof codegen_1.Name ? data : gen.let("data", data, true); // replaceable if used once?
|
||||
dataContextProps(nextData);
|
||||
if (propertyName !== undefined)
|
||||
subschema.propertyName = propertyName;
|
||||
// TODO something is possibly wrong here with not changing parentDataProperty and not appending dataPathArr
|
||||
}
|
||||
if (dataTypes)
|
||||
subschema.dataTypes = dataTypes;
|
||||
function dataContextProps(_nextData) {
|
||||
subschema.data = _nextData;
|
||||
subschema.dataLevel = it.dataLevel + 1;
|
||||
subschema.dataTypes = [];
|
||||
it.definedProperties = new Set();
|
||||
subschema.parentData = it.data;
|
||||
subschema.dataNames = [...it.dataNames, _nextData];
|
||||
}
|
||||
}
|
||||
exports.extendSubschemaData = extendSubschemaData;
|
||||
function extendSubschemaMode(subschema, { jtdDiscriminator, jtdMetadata, compositeRule, createErrors, allErrors }) {
|
||||
if (compositeRule !== undefined)
|
||||
subschema.compositeRule = compositeRule;
|
||||
if (createErrors !== undefined)
|
||||
subschema.createErrors = createErrors;
|
||||
if (allErrors !== undefined)
|
||||
subschema.allErrors = allErrors;
|
||||
subschema.jtdDiscriminator = jtdDiscriminator; // not inherited
|
||||
subschema.jtdMetadata = jtdMetadata; // not inherited
|
||||
}
|
||||
exports.extendSubschemaMode = extendSubschemaMode;
|
||||
//# sourceMappingURL=subschema.js.map
|
1
my-app/node_modules/ajv/dist/compile/validate/subschema.js.map
generated
vendored
Executable file
1
my-app/node_modules/ajv/dist/compile/validate/subschema.js.map
generated
vendored
Executable file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"subschema.js","sourceRoot":"","sources":["../../../lib/compile/validate/subschema.ts"],"names":[],"mappings":";;;AAEA,wCAA0D;AAC1D,kCAA0D;AA6C1D,SAAgB,YAAY,CAC1B,EAAgB,EAChB,EAAC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAgB;IAErF,IAAI,OAAO,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS,EAAE;QACjD,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAA;KACxE;IAED,IAAI,OAAO,KAAK,SAAS,EAAE;QACzB,MAAM,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QAC9B,OAAO,UAAU,KAAK,SAAS;YAC7B,CAAC,CAAC;gBACE,MAAM,EAAE,GAAG;gBACX,UAAU,EAAE,IAAA,WAAC,EAAA,GAAG,EAAE,CAAC,UAAU,GAAG,IAAA,qBAAW,EAAC,OAAO,CAAC,EAAE;gBACtD,aAAa,EAAE,GAAG,EAAE,CAAC,aAAa,IAAI,OAAO,EAAE;aAChD;YACH,CAAC,CAAC;gBACE,MAAM,EAAE,GAAG,CAAC,UAAU,CAAC;gBACvB,UAAU,EAAE,IAAA,WAAC,EAAA,GAAG,EAAE,CAAC,UAAU,GAAG,IAAA,qBAAW,EAAC,OAAO,CAAC,GAAG,IAAA,qBAAW,EAAC,UAAU,CAAC,EAAE;gBAChF,aAAa,EAAE,GAAG,EAAE,CAAC,aAAa,IAAI,OAAO,IAAI,IAAA,qBAAc,EAAC,UAAU,CAAC,EAAE;aAC9E,CAAA;KACN;IAED,IAAI,MAAM,KAAK,SAAS,EAAE;QACxB,IAAI,UAAU,KAAK,SAAS,IAAI,aAAa,KAAK,SAAS,IAAI,YAAY,KAAK,SAAS,EAAE;YACzF,MAAM,IAAI,KAAK,CAAC,6EAA6E,CAAC,CAAA;SAC/F;QACD,OAAO;YACL,MAAM;YACN,UAAU;YACV,YAAY;YACZ,aAAa;SACd,CAAA;KACF;IAED,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;AAChE,CAAC;AApCD,oCAoCC;AAED,SAAgB,mBAAmB,CACjC,SAA2B,EAC3B,EAAgB,EAChB,EAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAgB;IAE9E,IAAI,IAAI,KAAK,SAAS,IAAI,QAAQ,KAAK,SAAS,EAAE;QAChD,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAA;KACvE;IAED,MAAM,EAAC,GAAG,EAAC,GAAG,EAAE,CAAA;IAEhB,IAAI,QAAQ,KAAK,SAAS,EAAE;QAC1B,MAAM,EAAC,SAAS,EAAE,WAAW,EAAE,IAAI,EAAC,GAAG,EAAE,CAAA;QACzC,MAAM,QAAQ,GAAG,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,IAAA,WAAC,EAAA,GAAG,EAAE,CAAC,IAAI,GAAG,IAAA,qBAAW,EAAC,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC,CAAA;QAC7E,gBAAgB,CAAC,QAAQ,CAAC,CAAA;QAC1B,SAAS,CAAC,SAAS,GAAG,IAAA,aAAG,EAAA,GAAG,SAAS,GAAG,IAAA,mBAAY,EAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,gBAAgB,CAAC,EAAE,CAAA;QAC/F,SAAS,CAAC,kBAAkB,GAAG,IAAA,WAAC,EAAA,GAAG,QAAQ,EAAE,CAAA;QAC7C,SAAS,CAAC,WAAW,GAAG,CAAC,GAAG,WAAW,EAAE,SAAS,CAAC,kBAAkB,CAAC,CAAA;KACvE;IAED,IAAI,IAAI,KAAK,SAAS,EAAE;QACtB,MAAM,QAAQ,GAAG,IAAI,YAAY,cAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA,CAAC,4BAA4B;QACvG,gBAAgB,CAAC,QAAQ,CAAC,CAAA;QAC1B,IAAI,YAAY,KAAK,SAAS;YAAE,SAAS,CAAC,YAAY,GAAG,YAAY,CAAA;QACrE,2GAA2G;KAC5G;IAED,IAAI,SAAS;QAAE,SAAS,CAAC,SAAS,GAAG,SAAS,CAAA;IAE9C,SAAS,gBAAgB,CAAC,SAAe;QACvC,SAAS,CAAC,IAAI,GAAG,SAAS,CAAA;QAC1B,SAAS,CAAC,SAAS,GAAG,EAAE,CAAC,SAAS,GAAG,CAAC,CAAA;QACtC,SAAS,CAAC,SAAS,GAAG,EAAE,CAAA;QACxB,EAAE,CAAC,iBAAiB,GAAG,IAAI,GAAG,EAAU,CAAA;QACxC,SAAS,CAAC,UAAU,GAAG,EAAE,CAAC,IAAI,CAAA;QAC9B,SAAS,CAAC,SAAS,GAAG,CAAC,GAAG,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;IACpD,CAAC;AACH,CAAC;AArCD,kDAqCC;AAED,SAAgB,mBAAmB,CACjC,SAA2B,EAC3B,EAAC,gBAAgB,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAgB;IAEtF,IAAI,aAAa,KAAK,SAAS;QAAE,SAAS,CAAC,aAAa,GAAG,aAAa,CAAA;IACxE,IAAI,YAAY,KAAK,SAAS;QAAE,SAAS,CAAC,YAAY,GAAG,YAAY,CAAA;IACrE,IAAI,SAAS,KAAK,SAAS;QAAE,SAAS,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5D,SAAS,CAAC,gBAAgB,GAAG,gBAAgB,CAAA,CAAC,gBAAgB;IAC9D,SAAS,CAAC,WAAW,GAAG,WAAW,CAAA,CAAC,gBAAgB;AACtD,CAAC;AATD,kDASC"}
|
173
my-app/node_modules/ajv/dist/core.d.ts
generated
vendored
Executable file
173
my-app/node_modules/ajv/dist/core.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,173 @@
|
|||
export { Format, FormatDefinition, AsyncFormatDefinition, KeywordDefinition, KeywordErrorDefinition, CodeKeywordDefinition, MacroKeywordDefinition, FuncKeywordDefinition, Vocabulary, Schema, SchemaObject, AnySchemaObject, AsyncSchema, AnySchema, ValidateFunction, AsyncValidateFunction, AnyValidateFunction, ErrorObject, ErrorNoParams, } from "./types";
|
||||
export { SchemaCxt, SchemaObjCxt } from "./compile";
|
||||
export interface Plugin<Opts> {
|
||||
(ajv: Ajv, options?: Opts): Ajv;
|
||||
[prop: string]: any;
|
||||
}
|
||||
export { KeywordCxt } from "./compile/validate";
|
||||
export { DefinedError } from "./vocabularies/errors";
|
||||
export { JSONType } from "./compile/rules";
|
||||
export { JSONSchemaType } from "./types/json-schema";
|
||||
export { JTDSchemaType, SomeJTDSchemaType, JTDDataType } from "./types/jtd-schema";
|
||||
export { _, str, stringify, nil, Name, Code, CodeGen, CodeGenOptions } from "./compile/codegen";
|
||||
import type { Schema, AnySchema, AnySchemaObject, SchemaObject, AsyncSchema, Vocabulary, KeywordDefinition, AddedKeywordDefinition, AnyValidateFunction, ValidateFunction, AsyncValidateFunction, ErrorObject, Format, AddedFormat, RegExpEngine, UriResolver } from "./types";
|
||||
import type { JSONSchemaType } from "./types/json-schema";
|
||||
import type { JTDSchemaType, SomeJTDSchemaType, JTDDataType } from "./types/jtd-schema";
|
||||
import ValidationError from "./runtime/validation_error";
|
||||
import MissingRefError from "./compile/ref_error";
|
||||
import { ValidationRules } from "./compile/rules";
|
||||
import { SchemaEnv } from "./compile";
|
||||
import { Code, ValueScope } from "./compile/codegen";
|
||||
export type Options = CurrentOptions & DeprecatedOptions;
|
||||
export interface CurrentOptions {
|
||||
strict?: boolean | "log";
|
||||
strictSchema?: boolean | "log";
|
||||
strictNumbers?: boolean | "log";
|
||||
strictTypes?: boolean | "log";
|
||||
strictTuples?: boolean | "log";
|
||||
strictRequired?: boolean | "log";
|
||||
allowMatchingProperties?: boolean;
|
||||
allowUnionTypes?: boolean;
|
||||
validateFormats?: boolean;
|
||||
$data?: boolean;
|
||||
allErrors?: boolean;
|
||||
verbose?: boolean;
|
||||
discriminator?: boolean;
|
||||
unicodeRegExp?: boolean;
|
||||
timestamp?: "string" | "date";
|
||||
parseDate?: boolean;
|
||||
allowDate?: boolean;
|
||||
$comment?: true | ((comment: string, schemaPath?: string, rootSchema?: AnySchemaObject) => unknown);
|
||||
formats?: {
|
||||
[Name in string]?: Format;
|
||||
};
|
||||
keywords?: Vocabulary;
|
||||
schemas?: AnySchema[] | {
|
||||
[Key in string]?: AnySchema;
|
||||
};
|
||||
logger?: Logger | false;
|
||||
loadSchema?: (uri: string) => Promise<AnySchemaObject>;
|
||||
removeAdditional?: boolean | "all" | "failing";
|
||||
useDefaults?: boolean | "empty";
|
||||
coerceTypes?: boolean | "array";
|
||||
next?: boolean;
|
||||
unevaluated?: boolean;
|
||||
dynamicRef?: boolean;
|
||||
schemaId?: "id" | "$id";
|
||||
jtd?: boolean;
|
||||
meta?: SchemaObject | boolean;
|
||||
defaultMeta?: string | AnySchemaObject;
|
||||
validateSchema?: boolean | "log";
|
||||
addUsedSchema?: boolean;
|
||||
inlineRefs?: boolean | number;
|
||||
passContext?: boolean;
|
||||
loopRequired?: number;
|
||||
loopEnum?: number;
|
||||
ownProperties?: boolean;
|
||||
multipleOfPrecision?: number;
|
||||
int32range?: boolean;
|
||||
messages?: boolean;
|
||||
code?: CodeOptions;
|
||||
uriResolver?: UriResolver;
|
||||
}
|
||||
export interface CodeOptions {
|
||||
es5?: boolean;
|
||||
esm?: boolean;
|
||||
lines?: boolean;
|
||||
optimize?: boolean | number;
|
||||
formats?: Code;
|
||||
source?: boolean;
|
||||
process?: (code: string, schema?: SchemaEnv) => string;
|
||||
regExp?: RegExpEngine;
|
||||
}
|
||||
interface InstanceCodeOptions extends CodeOptions {
|
||||
regExp: RegExpEngine;
|
||||
optimize: number;
|
||||
}
|
||||
interface DeprecatedOptions {
|
||||
/** @deprecated */
|
||||
ignoreKeywordsWithRef?: boolean;
|
||||
/** @deprecated */
|
||||
jsPropertySyntax?: boolean;
|
||||
/** @deprecated */
|
||||
unicode?: boolean;
|
||||
}
|
||||
type RequiredInstanceOptions = {
|
||||
[K in "strictSchema" | "strictNumbers" | "strictTypes" | "strictTuples" | "strictRequired" | "inlineRefs" | "loopRequired" | "loopEnum" | "meta" | "messages" | "schemaId" | "addUsedSchema" | "validateSchema" | "validateFormats" | "int32range" | "unicodeRegExp" | "uriResolver"]: NonNullable<Options[K]>;
|
||||
} & {
|
||||
code: InstanceCodeOptions;
|
||||
};
|
||||
export type InstanceOptions = Options & RequiredInstanceOptions;
|
||||
export interface Logger {
|
||||
log(...args: unknown[]): unknown;
|
||||
warn(...args: unknown[]): unknown;
|
||||
error(...args: unknown[]): unknown;
|
||||
}
|
||||
export default class Ajv {
|
||||
opts: InstanceOptions;
|
||||
errors?: ErrorObject[] | null;
|
||||
logger: Logger;
|
||||
readonly scope: ValueScope;
|
||||
readonly schemas: {
|
||||
[Key in string]?: SchemaEnv;
|
||||
};
|
||||
readonly refs: {
|
||||
[Ref in string]?: SchemaEnv | string;
|
||||
};
|
||||
readonly formats: {
|
||||
[Name in string]?: AddedFormat;
|
||||
};
|
||||
readonly RULES: ValidationRules;
|
||||
readonly _compilations: Set<SchemaEnv>;
|
||||
private readonly _loading;
|
||||
private readonly _cache;
|
||||
private readonly _metaOpts;
|
||||
static ValidationError: typeof ValidationError;
|
||||
static MissingRefError: typeof MissingRefError;
|
||||
constructor(opts?: Options);
|
||||
_addVocabularies(): void;
|
||||
_addDefaultMetaSchema(): void;
|
||||
defaultMeta(): string | AnySchemaObject | undefined;
|
||||
validate(schema: Schema | string, data: unknown): boolean;
|
||||
validate(schemaKeyRef: AnySchema | string, data: unknown): boolean | Promise<unknown>;
|
||||
validate<T>(schema: Schema | JSONSchemaType<T> | string, data: unknown): data is T;
|
||||
validate<T>(schema: JTDSchemaType<T>, data: unknown): data is T;
|
||||
validate<N extends never, T extends SomeJTDSchemaType>(schema: T, data: unknown): data is JTDDataType<T>;
|
||||
validate<T>(schema: AsyncSchema, data: unknown | T): Promise<T>;
|
||||
validate<T>(schemaKeyRef: AnySchema | string, data: unknown): data is T | Promise<T>;
|
||||
compile<T = unknown>(schema: Schema | JSONSchemaType<T>, _meta?: boolean): ValidateFunction<T>;
|
||||
compile<T = unknown>(schema: JTDSchemaType<T>, _meta?: boolean): ValidateFunction<T>;
|
||||
compile<N extends never, T extends SomeJTDSchemaType>(schema: T, _meta?: boolean): ValidateFunction<JTDDataType<T>>;
|
||||
compile<T = unknown>(schema: AsyncSchema, _meta?: boolean): AsyncValidateFunction<T>;
|
||||
compile<T = unknown>(schema: AnySchema, _meta?: boolean): AnyValidateFunction<T>;
|
||||
compileAsync<T = unknown>(schema: SchemaObject | JSONSchemaType<T>, _meta?: boolean): Promise<ValidateFunction<T>>;
|
||||
compileAsync<T = unknown>(schema: JTDSchemaType<T>, _meta?: boolean): Promise<ValidateFunction<T>>;
|
||||
compileAsync<T = unknown>(schema: AsyncSchema, meta?: boolean): Promise<AsyncValidateFunction<T>>;
|
||||
compileAsync<T = unknown>(schema: AnySchemaObject, meta?: boolean): Promise<AnyValidateFunction<T>>;
|
||||
addSchema(schema: AnySchema | AnySchema[], // If array is passed, `key` will be ignored
|
||||
key?: string, // Optional schema key. Can be passed to `validate` method instead of schema object or id/ref. One schema per instance can have empty `id` and `key`.
|
||||
_meta?: boolean, // true if schema is a meta-schema. Used internally, addMetaSchema should be used instead.
|
||||
_validateSchema?: boolean | "log"): Ajv;
|
||||
addMetaSchema(schema: AnySchemaObject, key?: string, // schema key
|
||||
_validateSchema?: boolean | "log"): Ajv;
|
||||
validateSchema(schema: AnySchema, throwOrLogError?: boolean): boolean | Promise<unknown>;
|
||||
getSchema<T = unknown>(keyRef: string): AnyValidateFunction<T> | undefined;
|
||||
removeSchema(schemaKeyRef?: AnySchema | string | RegExp): Ajv;
|
||||
addVocabulary(definitions: Vocabulary): Ajv;
|
||||
addKeyword(kwdOrDef: string | KeywordDefinition, def?: KeywordDefinition): Ajv;
|
||||
getKeyword(keyword: string): AddedKeywordDefinition | boolean;
|
||||
removeKeyword(keyword: string): Ajv;
|
||||
addFormat(name: string, format: Format): Ajv;
|
||||
errorsText(errors?: ErrorObject[] | null | undefined, // optional array of validation errors
|
||||
{ separator, dataVar }?: ErrorsTextOptions): string;
|
||||
$dataMetaSchema(metaSchema: AnySchemaObject, keywordsJsonPointers: string[]): AnySchemaObject;
|
||||
private _removeAllSchemas;
|
||||
_addSchema(schema: AnySchema, meta?: boolean, baseId?: string, validateSchema?: boolean | "log", addSchema?: boolean): SchemaEnv;
|
||||
private _checkUnique;
|
||||
private _compileSchemaEnv;
|
||||
private _compileMetaSchema;
|
||||
}
|
||||
export interface ErrorsTextOptions {
|
||||
separator?: string;
|
||||
dataVar?: string;
|
||||
}
|
617
my-app/node_modules/ajv/dist/core.js
generated
vendored
Executable file
617
my-app/node_modules/ajv/dist/core.js
generated
vendored
Executable file
|
@ -0,0 +1,617 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = void 0;
|
||||
var validate_1 = require("./compile/validate");
|
||||
Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function () { return validate_1.KeywordCxt; } });
|
||||
var codegen_1 = require("./compile/codegen");
|
||||
Object.defineProperty(exports, "_", { enumerable: true, get: function () { return codegen_1._; } });
|
||||
Object.defineProperty(exports, "str", { enumerable: true, get: function () { return codegen_1.str; } });
|
||||
Object.defineProperty(exports, "stringify", { enumerable: true, get: function () { return codegen_1.stringify; } });
|
||||
Object.defineProperty(exports, "nil", { enumerable: true, get: function () { return codegen_1.nil; } });
|
||||
Object.defineProperty(exports, "Name", { enumerable: true, get: function () { return codegen_1.Name; } });
|
||||
Object.defineProperty(exports, "CodeGen", { enumerable: true, get: function () { return codegen_1.CodeGen; } });
|
||||
const validation_error_1 = require("./runtime/validation_error");
|
||||
const ref_error_1 = require("./compile/ref_error");
|
||||
const rules_1 = require("./compile/rules");
|
||||
const compile_1 = require("./compile");
|
||||
const codegen_2 = require("./compile/codegen");
|
||||
const resolve_1 = require("./compile/resolve");
|
||||
const dataType_1 = require("./compile/validate/dataType");
|
||||
const util_1 = require("./compile/util");
|
||||
const $dataRefSchema = require("./refs/data.json");
|
||||
const uri_1 = require("./runtime/uri");
|
||||
const defaultRegExp = (str, flags) => new RegExp(str, flags);
|
||||
defaultRegExp.code = "new RegExp";
|
||||
const META_IGNORE_OPTIONS = ["removeAdditional", "useDefaults", "coerceTypes"];
|
||||
const EXT_SCOPE_NAMES = new Set([
|
||||
"validate",
|
||||
"serialize",
|
||||
"parse",
|
||||
"wrapper",
|
||||
"root",
|
||||
"schema",
|
||||
"keyword",
|
||||
"pattern",
|
||||
"formats",
|
||||
"validate$data",
|
||||
"func",
|
||||
"obj",
|
||||
"Error",
|
||||
]);
|
||||
const removedOptions = {
|
||||
errorDataPath: "",
|
||||
format: "`validateFormats: false` can be used instead.",
|
||||
nullable: '"nullable" keyword is supported by default.',
|
||||
jsonPointers: "Deprecated jsPropertySyntax can be used instead.",
|
||||
extendRefs: "Deprecated ignoreKeywordsWithRef can be used instead.",
|
||||
missingRefs: "Pass empty schema with $id that should be ignored to ajv.addSchema.",
|
||||
processCode: "Use option `code: {process: (code, schemaEnv: object) => string}`",
|
||||
sourceCode: "Use option `code: {source: true}`",
|
||||
strictDefaults: "It is default now, see option `strict`.",
|
||||
strictKeywords: "It is default now, see option `strict`.",
|
||||
uniqueItems: '"uniqueItems" keyword is always validated.',
|
||||
unknownFormats: "Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",
|
||||
cache: "Map is used as cache, schema object as key.",
|
||||
serialize: "Map is used as cache, schema object as key.",
|
||||
ajvErrors: "It is default now.",
|
||||
};
|
||||
const deprecatedOptions = {
|
||||
ignoreKeywordsWithRef: "",
|
||||
jsPropertySyntax: "",
|
||||
unicode: '"minLength"/"maxLength" account for unicode characters by default.',
|
||||
};
|
||||
const MAX_EXPRESSION = 200;
|
||||
// eslint-disable-next-line complexity
|
||||
function requiredOptions(o) {
|
||||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
|
||||
const s = o.strict;
|
||||
const _optz = (_a = o.code) === null || _a === void 0 ? void 0 : _a.optimize;
|
||||
const optimize = _optz === true || _optz === undefined ? 1 : _optz || 0;
|
||||
const regExp = (_c = (_b = o.code) === null || _b === void 0 ? void 0 : _b.regExp) !== null && _c !== void 0 ? _c : defaultRegExp;
|
||||
const uriResolver = (_d = o.uriResolver) !== null && _d !== void 0 ? _d : uri_1.default;
|
||||
return {
|
||||
strictSchema: (_f = (_e = o.strictSchema) !== null && _e !== void 0 ? _e : s) !== null && _f !== void 0 ? _f : true,
|
||||
strictNumbers: (_h = (_g = o.strictNumbers) !== null && _g !== void 0 ? _g : s) !== null && _h !== void 0 ? _h : true,
|
||||
strictTypes: (_k = (_j = o.strictTypes) !== null && _j !== void 0 ? _j : s) !== null && _k !== void 0 ? _k : "log",
|
||||
strictTuples: (_m = (_l = o.strictTuples) !== null && _l !== void 0 ? _l : s) !== null && _m !== void 0 ? _m : "log",
|
||||
strictRequired: (_p = (_o = o.strictRequired) !== null && _o !== void 0 ? _o : s) !== null && _p !== void 0 ? _p : false,
|
||||
code: o.code ? { ...o.code, optimize, regExp } : { optimize, regExp },
|
||||
loopRequired: (_q = o.loopRequired) !== null && _q !== void 0 ? _q : MAX_EXPRESSION,
|
||||
loopEnum: (_r = o.loopEnum) !== null && _r !== void 0 ? _r : MAX_EXPRESSION,
|
||||
meta: (_s = o.meta) !== null && _s !== void 0 ? _s : true,
|
||||
messages: (_t = o.messages) !== null && _t !== void 0 ? _t : true,
|
||||
inlineRefs: (_u = o.inlineRefs) !== null && _u !== void 0 ? _u : true,
|
||||
schemaId: (_v = o.schemaId) !== null && _v !== void 0 ? _v : "$id",
|
||||
addUsedSchema: (_w = o.addUsedSchema) !== null && _w !== void 0 ? _w : true,
|
||||
validateSchema: (_x = o.validateSchema) !== null && _x !== void 0 ? _x : true,
|
||||
validateFormats: (_y = o.validateFormats) !== null && _y !== void 0 ? _y : true,
|
||||
unicodeRegExp: (_z = o.unicodeRegExp) !== null && _z !== void 0 ? _z : true,
|
||||
int32range: (_0 = o.int32range) !== null && _0 !== void 0 ? _0 : true,
|
||||
uriResolver: uriResolver,
|
||||
};
|
||||
}
|
||||
class Ajv {
|
||||
constructor(opts = {}) {
|
||||
this.schemas = {};
|
||||
this.refs = {};
|
||||
this.formats = {};
|
||||
this._compilations = new Set();
|
||||
this._loading = {};
|
||||
this._cache = new Map();
|
||||
opts = this.opts = { ...opts, ...requiredOptions(opts) };
|
||||
const { es5, lines } = this.opts.code;
|
||||
this.scope = new codegen_2.ValueScope({ scope: {}, prefixes: EXT_SCOPE_NAMES, es5, lines });
|
||||
this.logger = getLogger(opts.logger);
|
||||
const formatOpt = opts.validateFormats;
|
||||
opts.validateFormats = false;
|
||||
this.RULES = (0, rules_1.getRules)();
|
||||
checkOptions.call(this, removedOptions, opts, "NOT SUPPORTED");
|
||||
checkOptions.call(this, deprecatedOptions, opts, "DEPRECATED", "warn");
|
||||
this._metaOpts = getMetaSchemaOptions.call(this);
|
||||
if (opts.formats)
|
||||
addInitialFormats.call(this);
|
||||
this._addVocabularies();
|
||||
this._addDefaultMetaSchema();
|
||||
if (opts.keywords)
|
||||
addInitialKeywords.call(this, opts.keywords);
|
||||
if (typeof opts.meta == "object")
|
||||
this.addMetaSchema(opts.meta);
|
||||
addInitialSchemas.call(this);
|
||||
opts.validateFormats = formatOpt;
|
||||
}
|
||||
_addVocabularies() {
|
||||
this.addKeyword("$async");
|
||||
}
|
||||
_addDefaultMetaSchema() {
|
||||
const { $data, meta, schemaId } = this.opts;
|
||||
let _dataRefSchema = $dataRefSchema;
|
||||
if (schemaId === "id") {
|
||||
_dataRefSchema = { ...$dataRefSchema };
|
||||
_dataRefSchema.id = _dataRefSchema.$id;
|
||||
delete _dataRefSchema.$id;
|
||||
}
|
||||
if (meta && $data)
|
||||
this.addMetaSchema(_dataRefSchema, _dataRefSchema[schemaId], false);
|
||||
}
|
||||
defaultMeta() {
|
||||
const { meta, schemaId } = this.opts;
|
||||
return (this.opts.defaultMeta = typeof meta == "object" ? meta[schemaId] || meta : undefined);
|
||||
}
|
||||
validate(schemaKeyRef, // key, ref or schema object
|
||||
data // to be validated
|
||||
) {
|
||||
let v;
|
||||
if (typeof schemaKeyRef == "string") {
|
||||
v = this.getSchema(schemaKeyRef);
|
||||
if (!v)
|
||||
throw new Error(`no schema with key or ref "${schemaKeyRef}"`);
|
||||
}
|
||||
else {
|
||||
v = this.compile(schemaKeyRef);
|
||||
}
|
||||
const valid = v(data);
|
||||
if (!("$async" in v))
|
||||
this.errors = v.errors;
|
||||
return valid;
|
||||
}
|
||||
compile(schema, _meta) {
|
||||
const sch = this._addSchema(schema, _meta);
|
||||
return (sch.validate || this._compileSchemaEnv(sch));
|
||||
}
|
||||
compileAsync(schema, meta) {
|
||||
if (typeof this.opts.loadSchema != "function") {
|
||||
throw new Error("options.loadSchema should be a function");
|
||||
}
|
||||
const { loadSchema } = this.opts;
|
||||
return runCompileAsync.call(this, schema, meta);
|
||||
async function runCompileAsync(_schema, _meta) {
|
||||
await loadMetaSchema.call(this, _schema.$schema);
|
||||
const sch = this._addSchema(_schema, _meta);
|
||||
return sch.validate || _compileAsync.call(this, sch);
|
||||
}
|
||||
async function loadMetaSchema($ref) {
|
||||
if ($ref && !this.getSchema($ref)) {
|
||||
await runCompileAsync.call(this, { $ref }, true);
|
||||
}
|
||||
}
|
||||
async function _compileAsync(sch) {
|
||||
try {
|
||||
return this._compileSchemaEnv(sch);
|
||||
}
|
||||
catch (e) {
|
||||
if (!(e instanceof ref_error_1.default))
|
||||
throw e;
|
||||
checkLoaded.call(this, e);
|
||||
await loadMissingSchema.call(this, e.missingSchema);
|
||||
return _compileAsync.call(this, sch);
|
||||
}
|
||||
}
|
||||
function checkLoaded({ missingSchema: ref, missingRef }) {
|
||||
if (this.refs[ref]) {
|
||||
throw new Error(`AnySchema ${ref} is loaded but ${missingRef} cannot be resolved`);
|
||||
}
|
||||
}
|
||||
async function loadMissingSchema(ref) {
|
||||
const _schema = await _loadSchema.call(this, ref);
|
||||
if (!this.refs[ref])
|
||||
await loadMetaSchema.call(this, _schema.$schema);
|
||||
if (!this.refs[ref])
|
||||
this.addSchema(_schema, ref, meta);
|
||||
}
|
||||
async function _loadSchema(ref) {
|
||||
const p = this._loading[ref];
|
||||
if (p)
|
||||
return p;
|
||||
try {
|
||||
return await (this._loading[ref] = loadSchema(ref));
|
||||
}
|
||||
finally {
|
||||
delete this._loading[ref];
|
||||
}
|
||||
}
|
||||
}
|
||||
// Adds schema to the instance
|
||||
addSchema(schema, // If array is passed, `key` will be ignored
|
||||
key, // Optional schema key. Can be passed to `validate` method instead of schema object or id/ref. One schema per instance can have empty `id` and `key`.
|
||||
_meta, // true if schema is a meta-schema. Used internally, addMetaSchema should be used instead.
|
||||
_validateSchema = this.opts.validateSchema // false to skip schema validation. Used internally, option validateSchema should be used instead.
|
||||
) {
|
||||
if (Array.isArray(schema)) {
|
||||
for (const sch of schema)
|
||||
this.addSchema(sch, undefined, _meta, _validateSchema);
|
||||
return this;
|
||||
}
|
||||
let id;
|
||||
if (typeof schema === "object") {
|
||||
const { schemaId } = this.opts;
|
||||
id = schema[schemaId];
|
||||
if (id !== undefined && typeof id != "string") {
|
||||
throw new Error(`schema ${schemaId} must be string`);
|
||||
}
|
||||
}
|
||||
key = (0, resolve_1.normalizeId)(key || id);
|
||||
this._checkUnique(key);
|
||||
this.schemas[key] = this._addSchema(schema, _meta, key, _validateSchema, true);
|
||||
return this;
|
||||
}
|
||||
// Add schema that will be used to validate other schemas
|
||||
// options in META_IGNORE_OPTIONS are alway set to false
|
||||
addMetaSchema(schema, key, // schema key
|
||||
_validateSchema = this.opts.validateSchema // false to skip schema validation, can be used to override validateSchema option for meta-schema
|
||||
) {
|
||||
this.addSchema(schema, key, true, _validateSchema);
|
||||
return this;
|
||||
}
|
||||
// Validate schema against its meta-schema
|
||||
validateSchema(schema, throwOrLogError) {
|
||||
if (typeof schema == "boolean")
|
||||
return true;
|
||||
let $schema;
|
||||
$schema = schema.$schema;
|
||||
if ($schema !== undefined && typeof $schema != "string") {
|
||||
throw new Error("$schema must be a string");
|
||||
}
|
||||
$schema = $schema || this.opts.defaultMeta || this.defaultMeta();
|
||||
if (!$schema) {
|
||||
this.logger.warn("meta-schema not available");
|
||||
this.errors = null;
|
||||
return true;
|
||||
}
|
||||
const valid = this.validate($schema, schema);
|
||||
if (!valid && throwOrLogError) {
|
||||
const message = "schema is invalid: " + this.errorsText();
|
||||
if (this.opts.validateSchema === "log")
|
||||
this.logger.error(message);
|
||||
else
|
||||
throw new Error(message);
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
// Get compiled schema by `key` or `ref`.
|
||||
// (`key` that was passed to `addSchema` or full schema reference - `schema.$id` or resolved id)
|
||||
getSchema(keyRef) {
|
||||
let sch;
|
||||
while (typeof (sch = getSchEnv.call(this, keyRef)) == "string")
|
||||
keyRef = sch;
|
||||
if (sch === undefined) {
|
||||
const { schemaId } = this.opts;
|
||||
const root = new compile_1.SchemaEnv({ schema: {}, schemaId });
|
||||
sch = compile_1.resolveSchema.call(this, root, keyRef);
|
||||
if (!sch)
|
||||
return;
|
||||
this.refs[keyRef] = sch;
|
||||
}
|
||||
return (sch.validate || this._compileSchemaEnv(sch));
|
||||
}
|
||||
// Remove cached schema(s).
|
||||
// If no parameter is passed all schemas but meta-schemas are removed.
|
||||
// If RegExp is passed all schemas with key/id matching pattern but meta-schemas are removed.
|
||||
// Even if schema is referenced by other schemas it still can be removed as other schemas have local references.
|
||||
removeSchema(schemaKeyRef) {
|
||||
if (schemaKeyRef instanceof RegExp) {
|
||||
this._removeAllSchemas(this.schemas, schemaKeyRef);
|
||||
this._removeAllSchemas(this.refs, schemaKeyRef);
|
||||
return this;
|
||||
}
|
||||
switch (typeof schemaKeyRef) {
|
||||
case "undefined":
|
||||
this._removeAllSchemas(this.schemas);
|
||||
this._removeAllSchemas(this.refs);
|
||||
this._cache.clear();
|
||||
return this;
|
||||
case "string": {
|
||||
const sch = getSchEnv.call(this, schemaKeyRef);
|
||||
if (typeof sch == "object")
|
||||
this._cache.delete(sch.schema);
|
||||
delete this.schemas[schemaKeyRef];
|
||||
delete this.refs[schemaKeyRef];
|
||||
return this;
|
||||
}
|
||||
case "object": {
|
||||
const cacheKey = schemaKeyRef;
|
||||
this._cache.delete(cacheKey);
|
||||
let id = schemaKeyRef[this.opts.schemaId];
|
||||
if (id) {
|
||||
id = (0, resolve_1.normalizeId)(id);
|
||||
delete this.schemas[id];
|
||||
delete this.refs[id];
|
||||
}
|
||||
return this;
|
||||
}
|
||||
default:
|
||||
throw new Error("ajv.removeSchema: invalid parameter");
|
||||
}
|
||||
}
|
||||
// add "vocabulary" - a collection of keywords
|
||||
addVocabulary(definitions) {
|
||||
for (const def of definitions)
|
||||
this.addKeyword(def);
|
||||
return this;
|
||||
}
|
||||
addKeyword(kwdOrDef, def // deprecated
|
||||
) {
|
||||
let keyword;
|
||||
if (typeof kwdOrDef == "string") {
|
||||
keyword = kwdOrDef;
|
||||
if (typeof def == "object") {
|
||||
this.logger.warn("these parameters are deprecated, see docs for addKeyword");
|
||||
def.keyword = keyword;
|
||||
}
|
||||
}
|
||||
else if (typeof kwdOrDef == "object" && def === undefined) {
|
||||
def = kwdOrDef;
|
||||
keyword = def.keyword;
|
||||
if (Array.isArray(keyword) && !keyword.length) {
|
||||
throw new Error("addKeywords: keyword must be string or non-empty array");
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new Error("invalid addKeywords parameters");
|
||||
}
|
||||
checkKeyword.call(this, keyword, def);
|
||||
if (!def) {
|
||||
(0, util_1.eachItem)(keyword, (kwd) => addRule.call(this, kwd));
|
||||
return this;
|
||||
}
|
||||
keywordMetaschema.call(this, def);
|
||||
const definition = {
|
||||
...def,
|
||||
type: (0, dataType_1.getJSONTypes)(def.type),
|
||||
schemaType: (0, dataType_1.getJSONTypes)(def.schemaType),
|
||||
};
|
||||
(0, util_1.eachItem)(keyword, definition.type.length === 0
|
||||
? (k) => addRule.call(this, k, definition)
|
||||
: (k) => definition.type.forEach((t) => addRule.call(this, k, definition, t)));
|
||||
return this;
|
||||
}
|
||||
getKeyword(keyword) {
|
||||
const rule = this.RULES.all[keyword];
|
||||
return typeof rule == "object" ? rule.definition : !!rule;
|
||||
}
|
||||
// Remove keyword
|
||||
removeKeyword(keyword) {
|
||||
// TODO return type should be Ajv
|
||||
const { RULES } = this;
|
||||
delete RULES.keywords[keyword];
|
||||
delete RULES.all[keyword];
|
||||
for (const group of RULES.rules) {
|
||||
const i = group.rules.findIndex((rule) => rule.keyword === keyword);
|
||||
if (i >= 0)
|
||||
group.rules.splice(i, 1);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
// Add format
|
||||
addFormat(name, format) {
|
||||
if (typeof format == "string")
|
||||
format = new RegExp(format);
|
||||
this.formats[name] = format;
|
||||
return this;
|
||||
}
|
||||
errorsText(errors = this.errors, // optional array of validation errors
|
||||
{ separator = ", ", dataVar = "data" } = {} // optional options with properties `separator` and `dataVar`
|
||||
) {
|
||||
if (!errors || errors.length === 0)
|
||||
return "No errors";
|
||||
return errors
|
||||
.map((e) => `${dataVar}${e.instancePath} ${e.message}`)
|
||||
.reduce((text, msg) => text + separator + msg);
|
||||
}
|
||||
$dataMetaSchema(metaSchema, keywordsJsonPointers) {
|
||||
const rules = this.RULES.all;
|
||||
metaSchema = JSON.parse(JSON.stringify(metaSchema));
|
||||
for (const jsonPointer of keywordsJsonPointers) {
|
||||
const segments = jsonPointer.split("/").slice(1); // first segment is an empty string
|
||||
let keywords = metaSchema;
|
||||
for (const seg of segments)
|
||||
keywords = keywords[seg];
|
||||
for (const key in rules) {
|
||||
const rule = rules[key];
|
||||
if (typeof rule != "object")
|
||||
continue;
|
||||
const { $data } = rule.definition;
|
||||
const schema = keywords[key];
|
||||
if ($data && schema)
|
||||
keywords[key] = schemaOrData(schema);
|
||||
}
|
||||
}
|
||||
return metaSchema;
|
||||
}
|
||||
_removeAllSchemas(schemas, regex) {
|
||||
for (const keyRef in schemas) {
|
||||
const sch = schemas[keyRef];
|
||||
if (!regex || regex.test(keyRef)) {
|
||||
if (typeof sch == "string") {
|
||||
delete schemas[keyRef];
|
||||
}
|
||||
else if (sch && !sch.meta) {
|
||||
this._cache.delete(sch.schema);
|
||||
delete schemas[keyRef];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_addSchema(schema, meta, baseId, validateSchema = this.opts.validateSchema, addSchema = this.opts.addUsedSchema) {
|
||||
let id;
|
||||
const { schemaId } = this.opts;
|
||||
if (typeof schema == "object") {
|
||||
id = schema[schemaId];
|
||||
}
|
||||
else {
|
||||
if (this.opts.jtd)
|
||||
throw new Error("schema must be object");
|
||||
else if (typeof schema != "boolean")
|
||||
throw new Error("schema must be object or boolean");
|
||||
}
|
||||
let sch = this._cache.get(schema);
|
||||
if (sch !== undefined)
|
||||
return sch;
|
||||
baseId = (0, resolve_1.normalizeId)(id || baseId);
|
||||
const localRefs = resolve_1.getSchemaRefs.call(this, schema, baseId);
|
||||
sch = new compile_1.SchemaEnv({ schema, schemaId, meta, baseId, localRefs });
|
||||
this._cache.set(sch.schema, sch);
|
||||
if (addSchema && !baseId.startsWith("#")) {
|
||||
// TODO atm it is allowed to overwrite schemas without id (instead of not adding them)
|
||||
if (baseId)
|
||||
this._checkUnique(baseId);
|
||||
this.refs[baseId] = sch;
|
||||
}
|
||||
if (validateSchema)
|
||||
this.validateSchema(schema, true);
|
||||
return sch;
|
||||
}
|
||||
_checkUnique(id) {
|
||||
if (this.schemas[id] || this.refs[id]) {
|
||||
throw new Error(`schema with key or id "${id}" already exists`);
|
||||
}
|
||||
}
|
||||
_compileSchemaEnv(sch) {
|
||||
if (sch.meta)
|
||||
this._compileMetaSchema(sch);
|
||||
else
|
||||
compile_1.compileSchema.call(this, sch);
|
||||
/* istanbul ignore if */
|
||||
if (!sch.validate)
|
||||
throw new Error("ajv implementation error");
|
||||
return sch.validate;
|
||||
}
|
||||
_compileMetaSchema(sch) {
|
||||
const currentOpts = this.opts;
|
||||
this.opts = this._metaOpts;
|
||||
try {
|
||||
compile_1.compileSchema.call(this, sch);
|
||||
}
|
||||
finally {
|
||||
this.opts = currentOpts;
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.default = Ajv;
|
||||
Ajv.ValidationError = validation_error_1.default;
|
||||
Ajv.MissingRefError = ref_error_1.default;
|
||||
function checkOptions(checkOpts, options, msg, log = "error") {
|
||||
for (const key in checkOpts) {
|
||||
const opt = key;
|
||||
if (opt in options)
|
||||
this.logger[log](`${msg}: option ${key}. ${checkOpts[opt]}`);
|
||||
}
|
||||
}
|
||||
function getSchEnv(keyRef) {
|
||||
keyRef = (0, resolve_1.normalizeId)(keyRef); // TODO tests fail without this line
|
||||
return this.schemas[keyRef] || this.refs[keyRef];
|
||||
}
|
||||
function addInitialSchemas() {
|
||||
const optsSchemas = this.opts.schemas;
|
||||
if (!optsSchemas)
|
||||
return;
|
||||
if (Array.isArray(optsSchemas))
|
||||
this.addSchema(optsSchemas);
|
||||
else
|
||||
for (const key in optsSchemas)
|
||||
this.addSchema(optsSchemas[key], key);
|
||||
}
|
||||
function addInitialFormats() {
|
||||
for (const name in this.opts.formats) {
|
||||
const format = this.opts.formats[name];
|
||||
if (format)
|
||||
this.addFormat(name, format);
|
||||
}
|
||||
}
|
||||
function addInitialKeywords(defs) {
|
||||
if (Array.isArray(defs)) {
|
||||
this.addVocabulary(defs);
|
||||
return;
|
||||
}
|
||||
this.logger.warn("keywords option as map is deprecated, pass array");
|
||||
for (const keyword in defs) {
|
||||
const def = defs[keyword];
|
||||
if (!def.keyword)
|
||||
def.keyword = keyword;
|
||||
this.addKeyword(def);
|
||||
}
|
||||
}
|
||||
function getMetaSchemaOptions() {
|
||||
const metaOpts = { ...this.opts };
|
||||
for (const opt of META_IGNORE_OPTIONS)
|
||||
delete metaOpts[opt];
|
||||
return metaOpts;
|
||||
}
|
||||
const noLogs = { log() { }, warn() { }, error() { } };
|
||||
function getLogger(logger) {
|
||||
if (logger === false)
|
||||
return noLogs;
|
||||
if (logger === undefined)
|
||||
return console;
|
||||
if (logger.log && logger.warn && logger.error)
|
||||
return logger;
|
||||
throw new Error("logger must implement log, warn and error methods");
|
||||
}
|
||||
const KEYWORD_NAME = /^[a-z_$][a-z0-9_$:-]*$/i;
|
||||
function checkKeyword(keyword, def) {
|
||||
const { RULES } = this;
|
||||
(0, util_1.eachItem)(keyword, (kwd) => {
|
||||
if (RULES.keywords[kwd])
|
||||
throw new Error(`Keyword ${kwd} is already defined`);
|
||||
if (!KEYWORD_NAME.test(kwd))
|
||||
throw new Error(`Keyword ${kwd} has invalid name`);
|
||||
});
|
||||
if (!def)
|
||||
return;
|
||||
if (def.$data && !("code" in def || "validate" in def)) {
|
||||
throw new Error('$data keyword must have "code" or "validate" function');
|
||||
}
|
||||
}
|
||||
function addRule(keyword, definition, dataType) {
|
||||
var _a;
|
||||
const post = definition === null || definition === void 0 ? void 0 : definition.post;
|
||||
if (dataType && post)
|
||||
throw new Error('keyword with "post" flag cannot have "type"');
|
||||
const { RULES } = this;
|
||||
let ruleGroup = post ? RULES.post : RULES.rules.find(({ type: t }) => t === dataType);
|
||||
if (!ruleGroup) {
|
||||
ruleGroup = { type: dataType, rules: [] };
|
||||
RULES.rules.push(ruleGroup);
|
||||
}
|
||||
RULES.keywords[keyword] = true;
|
||||
if (!definition)
|
||||
return;
|
||||
const rule = {
|
||||
keyword,
|
||||
definition: {
|
||||
...definition,
|
||||
type: (0, dataType_1.getJSONTypes)(definition.type),
|
||||
schemaType: (0, dataType_1.getJSONTypes)(definition.schemaType),
|
||||
},
|
||||
};
|
||||
if (definition.before)
|
||||
addBeforeRule.call(this, ruleGroup, rule, definition.before);
|
||||
else
|
||||
ruleGroup.rules.push(rule);
|
||||
RULES.all[keyword] = rule;
|
||||
(_a = definition.implements) === null || _a === void 0 ? void 0 : _a.forEach((kwd) => this.addKeyword(kwd));
|
||||
}
|
||||
function addBeforeRule(ruleGroup, rule, before) {
|
||||
const i = ruleGroup.rules.findIndex((_rule) => _rule.keyword === before);
|
||||
if (i >= 0) {
|
||||
ruleGroup.rules.splice(i, 0, rule);
|
||||
}
|
||||
else {
|
||||
ruleGroup.rules.push(rule);
|
||||
this.logger.warn(`rule ${before} is not defined`);
|
||||
}
|
||||
}
|
||||
function keywordMetaschema(def) {
|
||||
let { metaSchema } = def;
|
||||
if (metaSchema === undefined)
|
||||
return;
|
||||
if (def.$data && this.opts.$data)
|
||||
metaSchema = schemaOrData(metaSchema);
|
||||
def.validateSchema = this.compile(metaSchema, true);
|
||||
}
|
||||
const $dataRef = {
|
||||
$ref: "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",
|
||||
};
|
||||
function schemaOrData(schema) {
|
||||
return { anyOf: [schema, $dataRef] };
|
||||
}
|
||||
//# sourceMappingURL=core.js.map
|
1
my-app/node_modules/ajv/dist/core.js.map
generated
vendored
Executable file
1
my-app/node_modules/ajv/dist/core.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
47
my-app/node_modules/ajv/dist/jtd.d.ts
generated
vendored
Executable file
47
my-app/node_modules/ajv/dist/jtd.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,47 @@
|
|||
import type { AnySchemaObject, SchemaObject, JTDParser } from "./types";
|
||||
import type { JTDSchemaType, SomeJTDSchemaType, JTDDataType } from "./types/jtd-schema";
|
||||
import AjvCore, { CurrentOptions } from "./core";
|
||||
type JTDOptions = CurrentOptions & {
|
||||
strict?: never;
|
||||
allowMatchingProperties?: never;
|
||||
allowUnionTypes?: never;
|
||||
validateFormats?: never;
|
||||
$data?: never;
|
||||
verbose?: boolean;
|
||||
$comment?: never;
|
||||
formats?: never;
|
||||
loadSchema?: never;
|
||||
useDefaults?: never;
|
||||
coerceTypes?: never;
|
||||
next?: never;
|
||||
unevaluated?: never;
|
||||
dynamicRef?: never;
|
||||
meta?: boolean;
|
||||
defaultMeta?: never;
|
||||
inlineRefs?: boolean;
|
||||
loopRequired?: never;
|
||||
multipleOfPrecision?: never;
|
||||
};
|
||||
declare class Ajv extends AjvCore {
|
||||
constructor(opts?: JTDOptions);
|
||||
_addVocabularies(): void;
|
||||
_addDefaultMetaSchema(): void;
|
||||
defaultMeta(): string | AnySchemaObject | undefined;
|
||||
compileSerializer<T = unknown>(schema: SchemaObject): (data: T) => string;
|
||||
compileSerializer<T = unknown>(schema: JTDSchemaType<T>): (data: T) => string;
|
||||
compileParser<T = unknown>(schema: SchemaObject): JTDParser<T>;
|
||||
compileParser<T = unknown>(schema: JTDSchemaType<T>): JTDParser<T>;
|
||||
private _compileSerializer;
|
||||
private _compileParser;
|
||||
}
|
||||
export default Ajv;
|
||||
export { Format, FormatDefinition, AsyncFormatDefinition, KeywordDefinition, KeywordErrorDefinition, CodeKeywordDefinition, MacroKeywordDefinition, FuncKeywordDefinition, Vocabulary, Schema, SchemaObject, AnySchemaObject, AsyncSchema, AnySchema, ValidateFunction, AsyncValidateFunction, ErrorObject, ErrorNoParams, JTDParser, } from "./types";
|
||||
export { Plugin, Options, CodeOptions, InstanceOptions, Logger, ErrorsTextOptions } from "./core";
|
||||
export { SchemaCxt, SchemaObjCxt } from "./compile";
|
||||
export { KeywordCxt } from "./compile/validate";
|
||||
export { JTDErrorObject } from "./vocabularies/jtd";
|
||||
export { _, str, stringify, nil, Name, Code, CodeGen, CodeGenOptions } from "./compile/codegen";
|
||||
export { JTDSchemaType, SomeJTDSchemaType, JTDDataType };
|
||||
export { JTDOptions };
|
||||
export { default as ValidationError } from "./runtime/validation_error";
|
||||
export { default as MissingRefError } from "./compile/ref_error";
|
70
my-app/node_modules/ajv/dist/jtd.js
generated
vendored
Executable file
70
my-app/node_modules/ajv/dist/jtd.js
generated
vendored
Executable file
|
@ -0,0 +1,70 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MissingRefError = exports.ValidationError = exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = void 0;
|
||||
const core_1 = require("./core");
|
||||
const jtd_1 = require("./vocabularies/jtd");
|
||||
const jtd_schema_1 = require("./refs/jtd-schema");
|
||||
const serialize_1 = require("./compile/jtd/serialize");
|
||||
const parse_1 = require("./compile/jtd/parse");
|
||||
const META_SCHEMA_ID = "JTD-meta-schema";
|
||||
class Ajv extends core_1.default {
|
||||
constructor(opts = {}) {
|
||||
super({
|
||||
...opts,
|
||||
jtd: true,
|
||||
});
|
||||
}
|
||||
_addVocabularies() {
|
||||
super._addVocabularies();
|
||||
this.addVocabulary(jtd_1.default);
|
||||
}
|
||||
_addDefaultMetaSchema() {
|
||||
super._addDefaultMetaSchema();
|
||||
if (!this.opts.meta)
|
||||
return;
|
||||
this.addMetaSchema(jtd_schema_1.default, META_SCHEMA_ID, false);
|
||||
}
|
||||
defaultMeta() {
|
||||
return (this.opts.defaultMeta =
|
||||
super.defaultMeta() || (this.getSchema(META_SCHEMA_ID) ? META_SCHEMA_ID : undefined));
|
||||
}
|
||||
compileSerializer(schema) {
|
||||
const sch = this._addSchema(schema);
|
||||
return sch.serialize || this._compileSerializer(sch);
|
||||
}
|
||||
compileParser(schema) {
|
||||
const sch = this._addSchema(schema);
|
||||
return (sch.parse || this._compileParser(sch));
|
||||
}
|
||||
_compileSerializer(sch) {
|
||||
serialize_1.default.call(this, sch, sch.schema.definitions || {});
|
||||
/* istanbul ignore if */
|
||||
if (!sch.serialize)
|
||||
throw new Error("ajv implementation error");
|
||||
return sch.serialize;
|
||||
}
|
||||
_compileParser(sch) {
|
||||
parse_1.default.call(this, sch, sch.schema.definitions || {});
|
||||
/* istanbul ignore if */
|
||||
if (!sch.parse)
|
||||
throw new Error("ajv implementation error");
|
||||
return sch.parse;
|
||||
}
|
||||
}
|
||||
module.exports = exports = Ajv;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = Ajv;
|
||||
var validate_1 = require("./compile/validate");
|
||||
Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function () { return validate_1.KeywordCxt; } });
|
||||
var codegen_1 = require("./compile/codegen");
|
||||
Object.defineProperty(exports, "_", { enumerable: true, get: function () { return codegen_1._; } });
|
||||
Object.defineProperty(exports, "str", { enumerable: true, get: function () { return codegen_1.str; } });
|
||||
Object.defineProperty(exports, "stringify", { enumerable: true, get: function () { return codegen_1.stringify; } });
|
||||
Object.defineProperty(exports, "nil", { enumerable: true, get: function () { return codegen_1.nil; } });
|
||||
Object.defineProperty(exports, "Name", { enumerable: true, get: function () { return codegen_1.Name; } });
|
||||
Object.defineProperty(exports, "CodeGen", { enumerable: true, get: function () { return codegen_1.CodeGen; } });
|
||||
var validation_error_1 = require("./runtime/validation_error");
|
||||
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return validation_error_1.default; } });
|
||||
var ref_error_1 = require("./compile/ref_error");
|
||||
Object.defineProperty(exports, "MissingRefError", { enumerable: true, get: function () { return ref_error_1.default; } });
|
||||
//# sourceMappingURL=jtd.js.map
|
1
my-app/node_modules/ajv/dist/jtd.js.map
generated
vendored
Executable file
1
my-app/node_modules/ajv/dist/jtd.js.map
generated
vendored
Executable file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"jtd.js","sourceRoot":"","sources":["../lib/jtd.ts"],"names":[],"mappings":";;;AAEA,iCAA8C;AAC9C,4CAA8C;AAC9C,kDAA6C;AAC7C,uDAAuD;AACvD,+CAA+C;AAG/C,MAAM,cAAc,GAAG,iBAAiB,CAAA;AA4BxC,MAAM,GAAI,SAAQ,cAAO;IACvB,YAAY,OAAmB,EAAE;QAC/B,KAAK,CAAC;YACJ,GAAG,IAAI;YACP,GAAG,EAAE,IAAI;SACV,CAAC,CAAA;IACJ,CAAC;IAED,gBAAgB;QACd,KAAK,CAAC,gBAAgB,EAAE,CAAA;QACxB,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,CAAA;IACnC,CAAC;IAED,qBAAqB;QACnB,KAAK,CAAC,qBAAqB,EAAE,CAAA;QAC7B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;YAAE,OAAM;QAC3B,IAAI,CAAC,aAAa,CAAC,oBAAa,EAAE,cAAc,EAAE,KAAK,CAAC,CAAA;IAC1D,CAAC;IAED,WAAW;QACT,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW;YAC3B,KAAK,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAA;IACzF,CAAC;IAMD,iBAAiB,CAAc,MAAoB;QACjD,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;QACnC,OAAO,GAAG,CAAC,SAAS,IAAI,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAA;IACtD,CAAC;IAMD,aAAa,CAAc,MAAoB;QAC7C,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;QACnC,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAiB,CAAA;IAChE,CAAC;IAEO,kBAAkB,CAAI,GAAc;QAC1C,mBAAiB,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAG,GAAG,CAAC,MAA0B,CAAC,WAAW,IAAI,EAAE,CAAC,CAAA;QACpF,wBAAwB;QACxB,IAAI,CAAC,GAAG,CAAC,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAA;QAC/D,OAAO,GAAG,CAAC,SAAS,CAAA;IACtB,CAAC;IAEO,cAAc,CAAC,GAAc;QACnC,eAAa,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAG,GAAG,CAAC,MAA0B,CAAC,WAAW,IAAI,EAAE,CAAC,CAAA;QAChF,wBAAwB;QACxB,IAAI,CAAC,GAAG,CAAC,KAAK;YAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAA;QAC3D,OAAO,GAAG,CAAC,KAAK,CAAA;IAClB,CAAC;CACF;AAED,MAAM,CAAC,OAAO,GAAG,OAAO,GAAG,GAAG,CAAA;AAC9B,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAC,KAAK,EAAE,IAAI,EAAC,CAAC,CAAA;AAE3D,kBAAe,GAAG,CAAA;AA0BlB,+CAA6C;AAArC,sGAAA,UAAU,OAAA;AAElB,6CAA6F;AAArF,4FAAA,CAAC,OAAA;AAAE,8FAAA,GAAG,OAAA;AAAE,oGAAA,SAAS,OAAA;AAAE,8FAAA,GAAG,OAAA;AAAE,+FAAA,IAAI,OAAA;AAAQ,kGAAA,OAAO,OAAA;AAInD,+DAAqE;AAA7D,mHAAA,OAAO,OAAmB;AAClC,iDAA8D;AAAtD,4GAAA,OAAO,OAAmB"}
|
13
my-app/node_modules/ajv/dist/refs/data.json
generated
vendored
Executable file
13
my-app/node_modules/ajv/dist/refs/data.json
generated
vendored
Executable file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"$id": "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",
|
||||
"description": "Meta-schema for $data reference (JSON AnySchema extension proposal)",
|
||||
"type": "object",
|
||||
"required": ["$data"],
|
||||
"properties": {
|
||||
"$data": {
|
||||
"type": "string",
|
||||
"anyOf": [{"format": "relative-json-pointer"}, {"format": "json-pointer"}]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
2
my-app/node_modules/ajv/dist/refs/json-schema-2019-09/index.d.ts
generated
vendored
Executable file
2
my-app/node_modules/ajv/dist/refs/json-schema-2019-09/index.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,2 @@
|
|||
import type Ajv from "../../core";
|
||||
export default function addMetaSchema2019(this: Ajv, $data?: boolean): Ajv;
|
28
my-app/node_modules/ajv/dist/refs/json-schema-2019-09/index.js
generated
vendored
Executable file
28
my-app/node_modules/ajv/dist/refs/json-schema-2019-09/index.js
generated
vendored
Executable file
|
@ -0,0 +1,28 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const metaSchema = require("./schema.json");
|
||||
const applicator = require("./meta/applicator.json");
|
||||
const content = require("./meta/content.json");
|
||||
const core = require("./meta/core.json");
|
||||
const format = require("./meta/format.json");
|
||||
const metadata = require("./meta/meta-data.json");
|
||||
const validation = require("./meta/validation.json");
|
||||
const META_SUPPORT_DATA = ["/properties"];
|
||||
function addMetaSchema2019($data) {
|
||||
;
|
||||
[
|
||||
metaSchema,
|
||||
applicator,
|
||||
content,
|
||||
core,
|
||||
with$data(this, format),
|
||||
metadata,
|
||||
with$data(this, validation),
|
||||
].forEach((sch) => this.addMetaSchema(sch, undefined, false));
|
||||
return this;
|
||||
function with$data(ajv, sch) {
|
||||
return $data ? ajv.$dataMetaSchema(sch, META_SUPPORT_DATA) : sch;
|
||||
}
|
||||
}
|
||||
exports.default = addMetaSchema2019;
|
||||
//# sourceMappingURL=index.js.map
|
1
my-app/node_modules/ajv/dist/refs/json-schema-2019-09/index.js.map
generated
vendored
Executable file
1
my-app/node_modules/ajv/dist/refs/json-schema-2019-09/index.js.map
generated
vendored
Executable file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/refs/json-schema-2019-09/index.ts"],"names":[],"mappings":";;AAEA,4CAA2C;AAC3C,qDAAoD;AACpD,+CAA8C;AAC9C,yCAAwC;AACxC,6CAA4C;AAC5C,kDAAiD;AACjD,qDAAoD;AAEpD,MAAM,iBAAiB,GAAG,CAAC,aAAa,CAAC,CAAA;AAEzC,SAAwB,iBAAiB,CAAY,KAAe;IAClE,CAAC;IAAA;QACC,UAAU;QACV,UAAU;QACV,OAAO;QACP,IAAI;QACJ,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC;QACvB,QAAQ;QACR,SAAS,CAAC,IAAI,EAAE,UAAU,CAAC;KAC5B,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC,CAAA;IAC7D,OAAO,IAAI,CAAA;IAEX,SAAS,SAAS,CAAC,GAAQ,EAAE,GAAoB;QAC/C,OAAO,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,eAAe,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC,GAAG,CAAA;IAClE,CAAC;AACH,CAAC;AAfD,oCAeC"}
|
53
my-app/node_modules/ajv/dist/refs/json-schema-2019-09/meta/applicator.json
generated
vendored
Executable file
53
my-app/node_modules/ajv/dist/refs/json-schema-2019-09/meta/applicator.json
generated
vendored
Executable file
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2019-09/schema",
|
||||
"$id": "https://json-schema.org/draft/2019-09/meta/applicator",
|
||||
"$vocabulary": {
|
||||
"https://json-schema.org/draft/2019-09/vocab/applicator": true
|
||||
},
|
||||
"$recursiveAnchor": true,
|
||||
|
||||
"title": "Applicator vocabulary meta-schema",
|
||||
"type": ["object", "boolean"],
|
||||
"properties": {
|
||||
"additionalItems": {"$recursiveRef": "#"},
|
||||
"unevaluatedItems": {"$recursiveRef": "#"},
|
||||
"items": {
|
||||
"anyOf": [{"$recursiveRef": "#"}, {"$ref": "#/$defs/schemaArray"}]
|
||||
},
|
||||
"contains": {"$recursiveRef": "#"},
|
||||
"additionalProperties": {"$recursiveRef": "#"},
|
||||
"unevaluatedProperties": {"$recursiveRef": "#"},
|
||||
"properties": {
|
||||
"type": "object",
|
||||
"additionalProperties": {"$recursiveRef": "#"},
|
||||
"default": {}
|
||||
},
|
||||
"patternProperties": {
|
||||
"type": "object",
|
||||
"additionalProperties": {"$recursiveRef": "#"},
|
||||
"propertyNames": {"format": "regex"},
|
||||
"default": {}
|
||||
},
|
||||
"dependentSchemas": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"$recursiveRef": "#"
|
||||
}
|
||||
},
|
||||
"propertyNames": {"$recursiveRef": "#"},
|
||||
"if": {"$recursiveRef": "#"},
|
||||
"then": {"$recursiveRef": "#"},
|
||||
"else": {"$recursiveRef": "#"},
|
||||
"allOf": {"$ref": "#/$defs/schemaArray"},
|
||||
"anyOf": {"$ref": "#/$defs/schemaArray"},
|
||||
"oneOf": {"$ref": "#/$defs/schemaArray"},
|
||||
"not": {"$recursiveRef": "#"}
|
||||
},
|
||||
"$defs": {
|
||||
"schemaArray": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {"$recursiveRef": "#"}
|
||||
}
|
||||
}
|
||||
}
|
17
my-app/node_modules/ajv/dist/refs/json-schema-2019-09/meta/content.json
generated
vendored
Executable file
17
my-app/node_modules/ajv/dist/refs/json-schema-2019-09/meta/content.json
generated
vendored
Executable file
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2019-09/schema",
|
||||
"$id": "https://json-schema.org/draft/2019-09/meta/content",
|
||||
"$vocabulary": {
|
||||
"https://json-schema.org/draft/2019-09/vocab/content": true
|
||||
},
|
||||
"$recursiveAnchor": true,
|
||||
|
||||
"title": "Content vocabulary meta-schema",
|
||||
|
||||
"type": ["object", "boolean"],
|
||||
"properties": {
|
||||
"contentMediaType": {"type": "string"},
|
||||
"contentEncoding": {"type": "string"},
|
||||
"contentSchema": {"$recursiveRef": "#"}
|
||||
}
|
||||
}
|
57
my-app/node_modules/ajv/dist/refs/json-schema-2019-09/meta/core.json
generated
vendored
Executable file
57
my-app/node_modules/ajv/dist/refs/json-schema-2019-09/meta/core.json
generated
vendored
Executable file
|
@ -0,0 +1,57 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2019-09/schema",
|
||||
"$id": "https://json-schema.org/draft/2019-09/meta/core",
|
||||
"$vocabulary": {
|
||||
"https://json-schema.org/draft/2019-09/vocab/core": true
|
||||
},
|
||||
"$recursiveAnchor": true,
|
||||
|
||||
"title": "Core vocabulary meta-schema",
|
||||
"type": ["object", "boolean"],
|
||||
"properties": {
|
||||
"$id": {
|
||||
"type": "string",
|
||||
"format": "uri-reference",
|
||||
"$comment": "Non-empty fragments not allowed.",
|
||||
"pattern": "^[^#]*#?$"
|
||||
},
|
||||
"$schema": {
|
||||
"type": "string",
|
||||
"format": "uri"
|
||||
},
|
||||
"$anchor": {
|
||||
"type": "string",
|
||||
"pattern": "^[A-Za-z][-A-Za-z0-9.:_]*$"
|
||||
},
|
||||
"$ref": {
|
||||
"type": "string",
|
||||
"format": "uri-reference"
|
||||
},
|
||||
"$recursiveRef": {
|
||||
"type": "string",
|
||||
"format": "uri-reference"
|
||||
},
|
||||
"$recursiveAnchor": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"$vocabulary": {
|
||||
"type": "object",
|
||||
"propertyNames": {
|
||||
"type": "string",
|
||||
"format": "uri"
|
||||
},
|
||||
"additionalProperties": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"$comment": {
|
||||
"type": "string"
|
||||
},
|
||||
"$defs": {
|
||||
"type": "object",
|
||||
"additionalProperties": {"$recursiveRef": "#"},
|
||||
"default": {}
|
||||
}
|
||||
}
|
||||
}
|
14
my-app/node_modules/ajv/dist/refs/json-schema-2019-09/meta/format.json
generated
vendored
Executable file
14
my-app/node_modules/ajv/dist/refs/json-schema-2019-09/meta/format.json
generated
vendored
Executable file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2019-09/schema",
|
||||
"$id": "https://json-schema.org/draft/2019-09/meta/format",
|
||||
"$vocabulary": {
|
||||
"https://json-schema.org/draft/2019-09/vocab/format": true
|
||||
},
|
||||
"$recursiveAnchor": true,
|
||||
|
||||
"title": "Format vocabulary meta-schema",
|
||||
"type": ["object", "boolean"],
|
||||
"properties": {
|
||||
"format": {"type": "string"}
|
||||
}
|
||||
}
|
37
my-app/node_modules/ajv/dist/refs/json-schema-2019-09/meta/meta-data.json
generated
vendored
Executable file
37
my-app/node_modules/ajv/dist/refs/json-schema-2019-09/meta/meta-data.json
generated
vendored
Executable file
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2019-09/schema",
|
||||
"$id": "https://json-schema.org/draft/2019-09/meta/meta-data",
|
||||
"$vocabulary": {
|
||||
"https://json-schema.org/draft/2019-09/vocab/meta-data": true
|
||||
},
|
||||
"$recursiveAnchor": true,
|
||||
|
||||
"title": "Meta-data vocabulary meta-schema",
|
||||
|
||||
"type": ["object", "boolean"],
|
||||
"properties": {
|
||||
"title": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"default": true,
|
||||
"deprecated": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"readOnly": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"writeOnly": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"examples": {
|
||||
"type": "array",
|
||||
"items": true
|
||||
}
|
||||
}
|
||||
}
|
90
my-app/node_modules/ajv/dist/refs/json-schema-2019-09/meta/validation.json
generated
vendored
Executable file
90
my-app/node_modules/ajv/dist/refs/json-schema-2019-09/meta/validation.json
generated
vendored
Executable file
|
@ -0,0 +1,90 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2019-09/schema",
|
||||
"$id": "https://json-schema.org/draft/2019-09/meta/validation",
|
||||
"$vocabulary": {
|
||||
"https://json-schema.org/draft/2019-09/vocab/validation": true
|
||||
},
|
||||
"$recursiveAnchor": true,
|
||||
|
||||
"title": "Validation vocabulary meta-schema",
|
||||
"type": ["object", "boolean"],
|
||||
"properties": {
|
||||
"multipleOf": {
|
||||
"type": "number",
|
||||
"exclusiveMinimum": 0
|
||||
},
|
||||
"maximum": {
|
||||
"type": "number"
|
||||
},
|
||||
"exclusiveMaximum": {
|
||||
"type": "number"
|
||||
},
|
||||
"minimum": {
|
||||
"type": "number"
|
||||
},
|
||||
"exclusiveMinimum": {
|
||||
"type": "number"
|
||||
},
|
||||
"maxLength": {"$ref": "#/$defs/nonNegativeInteger"},
|
||||
"minLength": {"$ref": "#/$defs/nonNegativeIntegerDefault0"},
|
||||
"pattern": {
|
||||
"type": "string",
|
||||
"format": "regex"
|
||||
},
|
||||
"maxItems": {"$ref": "#/$defs/nonNegativeInteger"},
|
||||
"minItems": {"$ref": "#/$defs/nonNegativeIntegerDefault0"},
|
||||
"uniqueItems": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"maxContains": {"$ref": "#/$defs/nonNegativeInteger"},
|
||||
"minContains": {
|
||||
"$ref": "#/$defs/nonNegativeInteger",
|
||||
"default": 1
|
||||
},
|
||||
"maxProperties": {"$ref": "#/$defs/nonNegativeInteger"},
|
||||
"minProperties": {"$ref": "#/$defs/nonNegativeIntegerDefault0"},
|
||||
"required": {"$ref": "#/$defs/stringArray"},
|
||||
"dependentRequired": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"$ref": "#/$defs/stringArray"
|
||||
}
|
||||
},
|
||||
"const": true,
|
||||
"enum": {
|
||||
"type": "array",
|
||||
"items": true
|
||||
},
|
||||
"type": {
|
||||
"anyOf": [
|
||||
{"$ref": "#/$defs/simpleTypes"},
|
||||
{
|
||||
"type": "array",
|
||||
"items": {"$ref": "#/$defs/simpleTypes"},
|
||||
"minItems": 1,
|
||||
"uniqueItems": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"$defs": {
|
||||
"nonNegativeInteger": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"nonNegativeIntegerDefault0": {
|
||||
"$ref": "#/$defs/nonNegativeInteger",
|
||||
"default": 0
|
||||
},
|
||||
"simpleTypes": {
|
||||
"enum": ["array", "boolean", "integer", "null", "number", "object", "string"]
|
||||
},
|
||||
"stringArray": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"},
|
||||
"uniqueItems": true,
|
||||
"default": []
|
||||
}
|
||||
}
|
||||
}
|
39
my-app/node_modules/ajv/dist/refs/json-schema-2019-09/schema.json
generated
vendored
Executable file
39
my-app/node_modules/ajv/dist/refs/json-schema-2019-09/schema.json
generated
vendored
Executable file
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2019-09/schema",
|
||||
"$id": "https://json-schema.org/draft/2019-09/schema",
|
||||
"$vocabulary": {
|
||||
"https://json-schema.org/draft/2019-09/vocab/core": true,
|
||||
"https://json-schema.org/draft/2019-09/vocab/applicator": true,
|
||||
"https://json-schema.org/draft/2019-09/vocab/validation": true,
|
||||
"https://json-schema.org/draft/2019-09/vocab/meta-data": true,
|
||||
"https://json-schema.org/draft/2019-09/vocab/format": false,
|
||||
"https://json-schema.org/draft/2019-09/vocab/content": true
|
||||
},
|
||||
"$recursiveAnchor": true,
|
||||
|
||||
"title": "Core and Validation specifications meta-schema",
|
||||
"allOf": [
|
||||
{"$ref": "meta/core"},
|
||||
{"$ref": "meta/applicator"},
|
||||
{"$ref": "meta/validation"},
|
||||
{"$ref": "meta/meta-data"},
|
||||
{"$ref": "meta/format"},
|
||||
{"$ref": "meta/content"}
|
||||
],
|
||||
"type": ["object", "boolean"],
|
||||
"properties": {
|
||||
"definitions": {
|
||||
"$comment": "While no longer an official keyword as it is replaced by $defs, this keyword is retained in the meta-schema to prevent incompatible extensions as it remains in common use.",
|
||||
"type": "object",
|
||||
"additionalProperties": {"$recursiveRef": "#"},
|
||||
"default": {}
|
||||
},
|
||||
"dependencies": {
|
||||
"$comment": "\"dependencies\" is no longer a keyword, but schema authors should avoid redefining it to facilitate a smooth transition to \"dependentSchemas\" and \"dependentRequired\"",
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"anyOf": [{"$recursiveRef": "#"}, {"$ref": "meta/validation#/$defs/stringArray"}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
2
my-app/node_modules/ajv/dist/refs/json-schema-2020-12/index.d.ts
generated
vendored
Executable file
2
my-app/node_modules/ajv/dist/refs/json-schema-2020-12/index.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,2 @@
|
|||
import type Ajv from "../../core";
|
||||
export default function addMetaSchema2020(this: Ajv, $data?: boolean): Ajv;
|
30
my-app/node_modules/ajv/dist/refs/json-schema-2020-12/index.js
generated
vendored
Executable file
30
my-app/node_modules/ajv/dist/refs/json-schema-2020-12/index.js
generated
vendored
Executable file
|
@ -0,0 +1,30 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const metaSchema = require("./schema.json");
|
||||
const applicator = require("./meta/applicator.json");
|
||||
const unevaluated = require("./meta/unevaluated.json");
|
||||
const content = require("./meta/content.json");
|
||||
const core = require("./meta/core.json");
|
||||
const format = require("./meta/format-annotation.json");
|
||||
const metadata = require("./meta/meta-data.json");
|
||||
const validation = require("./meta/validation.json");
|
||||
const META_SUPPORT_DATA = ["/properties"];
|
||||
function addMetaSchema2020($data) {
|
||||
;
|
||||
[
|
||||
metaSchema,
|
||||
applicator,
|
||||
unevaluated,
|
||||
content,
|
||||
core,
|
||||
with$data(this, format),
|
||||
metadata,
|
||||
with$data(this, validation),
|
||||
].forEach((sch) => this.addMetaSchema(sch, undefined, false));
|
||||
return this;
|
||||
function with$data(ajv, sch) {
|
||||
return $data ? ajv.$dataMetaSchema(sch, META_SUPPORT_DATA) : sch;
|
||||
}
|
||||
}
|
||||
exports.default = addMetaSchema2020;
|
||||
//# sourceMappingURL=index.js.map
|
1
my-app/node_modules/ajv/dist/refs/json-schema-2020-12/index.js.map
generated
vendored
Executable file
1
my-app/node_modules/ajv/dist/refs/json-schema-2020-12/index.js.map
generated
vendored
Executable file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/refs/json-schema-2020-12/index.ts"],"names":[],"mappings":";;AAEA,4CAA2C;AAC3C,qDAAoD;AACpD,uDAAsD;AACtD,+CAA8C;AAC9C,yCAAwC;AACxC,wDAAuD;AACvD,kDAAiD;AACjD,qDAAoD;AAEpD,MAAM,iBAAiB,GAAG,CAAC,aAAa,CAAC,CAAA;AAEzC,SAAwB,iBAAiB,CAAY,KAAe;IAClE,CAAC;IAAA;QACC,UAAU;QACV,UAAU;QACV,WAAW;QACX,OAAO;QACP,IAAI;QACJ,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC;QACvB,QAAQ;QACR,SAAS,CAAC,IAAI,EAAE,UAAU,CAAC;KAC5B,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC,CAAA;IAC7D,OAAO,IAAI,CAAA;IAEX,SAAS,SAAS,CAAC,GAAQ,EAAE,GAAoB;QAC/C,OAAO,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,eAAe,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC,GAAG,CAAA;IAClE,CAAC;AACH,CAAC;AAhBD,oCAgBC"}
|
48
my-app/node_modules/ajv/dist/refs/json-schema-2020-12/meta/applicator.json
generated
vendored
Executable file
48
my-app/node_modules/ajv/dist/refs/json-schema-2020-12/meta/applicator.json
generated
vendored
Executable file
|
@ -0,0 +1,48 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://json-schema.org/draft/2020-12/meta/applicator",
|
||||
"$vocabulary": {
|
||||
"https://json-schema.org/draft/2020-12/vocab/applicator": true
|
||||
},
|
||||
"$dynamicAnchor": "meta",
|
||||
|
||||
"title": "Applicator vocabulary meta-schema",
|
||||
"type": ["object", "boolean"],
|
||||
"properties": {
|
||||
"prefixItems": {"$ref": "#/$defs/schemaArray"},
|
||||
"items": {"$dynamicRef": "#meta"},
|
||||
"contains": {"$dynamicRef": "#meta"},
|
||||
"additionalProperties": {"$dynamicRef": "#meta"},
|
||||
"properties": {
|
||||
"type": "object",
|
||||
"additionalProperties": {"$dynamicRef": "#meta"},
|
||||
"default": {}
|
||||
},
|
||||
"patternProperties": {
|
||||
"type": "object",
|
||||
"additionalProperties": {"$dynamicRef": "#meta"},
|
||||
"propertyNames": {"format": "regex"},
|
||||
"default": {}
|
||||
},
|
||||
"dependentSchemas": {
|
||||
"type": "object",
|
||||
"additionalProperties": {"$dynamicRef": "#meta"},
|
||||
"default": {}
|
||||
},
|
||||
"propertyNames": {"$dynamicRef": "#meta"},
|
||||
"if": {"$dynamicRef": "#meta"},
|
||||
"then": {"$dynamicRef": "#meta"},
|
||||
"else": {"$dynamicRef": "#meta"},
|
||||
"allOf": {"$ref": "#/$defs/schemaArray"},
|
||||
"anyOf": {"$ref": "#/$defs/schemaArray"},
|
||||
"oneOf": {"$ref": "#/$defs/schemaArray"},
|
||||
"not": {"$dynamicRef": "#meta"}
|
||||
},
|
||||
"$defs": {
|
||||
"schemaArray": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {"$dynamicRef": "#meta"}
|
||||
}
|
||||
}
|
||||
}
|
17
my-app/node_modules/ajv/dist/refs/json-schema-2020-12/meta/content.json
generated
vendored
Executable file
17
my-app/node_modules/ajv/dist/refs/json-schema-2020-12/meta/content.json
generated
vendored
Executable file
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://json-schema.org/draft/2020-12/meta/content",
|
||||
"$vocabulary": {
|
||||
"https://json-schema.org/draft/2020-12/vocab/content": true
|
||||
},
|
||||
"$dynamicAnchor": "meta",
|
||||
|
||||
"title": "Content vocabulary meta-schema",
|
||||
|
||||
"type": ["object", "boolean"],
|
||||
"properties": {
|
||||
"contentEncoding": {"type": "string"},
|
||||
"contentMediaType": {"type": "string"},
|
||||
"contentSchema": {"$dynamicRef": "#meta"}
|
||||
}
|
||||
}
|
51
my-app/node_modules/ajv/dist/refs/json-schema-2020-12/meta/core.json
generated
vendored
Executable file
51
my-app/node_modules/ajv/dist/refs/json-schema-2020-12/meta/core.json
generated
vendored
Executable file
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://json-schema.org/draft/2020-12/meta/core",
|
||||
"$vocabulary": {
|
||||
"https://json-schema.org/draft/2020-12/vocab/core": true
|
||||
},
|
||||
"$dynamicAnchor": "meta",
|
||||
|
||||
"title": "Core vocabulary meta-schema",
|
||||
"type": ["object", "boolean"],
|
||||
"properties": {
|
||||
"$id": {
|
||||
"$ref": "#/$defs/uriReferenceString",
|
||||
"$comment": "Non-empty fragments not allowed.",
|
||||
"pattern": "^[^#]*#?$"
|
||||
},
|
||||
"$schema": {"$ref": "#/$defs/uriString"},
|
||||
"$ref": {"$ref": "#/$defs/uriReferenceString"},
|
||||
"$anchor": {"$ref": "#/$defs/anchorString"},
|
||||
"$dynamicRef": {"$ref": "#/$defs/uriReferenceString"},
|
||||
"$dynamicAnchor": {"$ref": "#/$defs/anchorString"},
|
||||
"$vocabulary": {
|
||||
"type": "object",
|
||||
"propertyNames": {"$ref": "#/$defs/uriString"},
|
||||
"additionalProperties": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"$comment": {
|
||||
"type": "string"
|
||||
},
|
||||
"$defs": {
|
||||
"type": "object",
|
||||
"additionalProperties": {"$dynamicRef": "#meta"}
|
||||
}
|
||||
},
|
||||
"$defs": {
|
||||
"anchorString": {
|
||||
"type": "string",
|
||||
"pattern": "^[A-Za-z_][-A-Za-z0-9._]*$"
|
||||
},
|
||||
"uriString": {
|
||||
"type": "string",
|
||||
"format": "uri"
|
||||
},
|
||||
"uriReferenceString": {
|
||||
"type": "string",
|
||||
"format": "uri-reference"
|
||||
}
|
||||
}
|
||||
}
|
14
my-app/node_modules/ajv/dist/refs/json-schema-2020-12/meta/format-annotation.json
generated
vendored
Executable file
14
my-app/node_modules/ajv/dist/refs/json-schema-2020-12/meta/format-annotation.json
generated
vendored
Executable file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://json-schema.org/draft/2020-12/meta/format-annotation",
|
||||
"$vocabulary": {
|
||||
"https://json-schema.org/draft/2020-12/vocab/format-annotation": true
|
||||
},
|
||||
"$dynamicAnchor": "meta",
|
||||
|
||||
"title": "Format vocabulary meta-schema for annotation results",
|
||||
"type": ["object", "boolean"],
|
||||
"properties": {
|
||||
"format": {"type": "string"}
|
||||
}
|
||||
}
|
37
my-app/node_modules/ajv/dist/refs/json-schema-2020-12/meta/meta-data.json
generated
vendored
Executable file
37
my-app/node_modules/ajv/dist/refs/json-schema-2020-12/meta/meta-data.json
generated
vendored
Executable file
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://json-schema.org/draft/2020-12/meta/meta-data",
|
||||
"$vocabulary": {
|
||||
"https://json-schema.org/draft/2020-12/vocab/meta-data": true
|
||||
},
|
||||
"$dynamicAnchor": "meta",
|
||||
|
||||
"title": "Meta-data vocabulary meta-schema",
|
||||
|
||||
"type": ["object", "boolean"],
|
||||
"properties": {
|
||||
"title": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"default": true,
|
||||
"deprecated": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"readOnly": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"writeOnly": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"examples": {
|
||||
"type": "array",
|
||||
"items": true
|
||||
}
|
||||
}
|
||||
}
|
15
my-app/node_modules/ajv/dist/refs/json-schema-2020-12/meta/unevaluated.json
generated
vendored
Executable file
15
my-app/node_modules/ajv/dist/refs/json-schema-2020-12/meta/unevaluated.json
generated
vendored
Executable file
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://json-schema.org/draft/2020-12/meta/unevaluated",
|
||||
"$vocabulary": {
|
||||
"https://json-schema.org/draft/2020-12/vocab/unevaluated": true
|
||||
},
|
||||
"$dynamicAnchor": "meta",
|
||||
|
||||
"title": "Unevaluated applicator vocabulary meta-schema",
|
||||
"type": ["object", "boolean"],
|
||||
"properties": {
|
||||
"unevaluatedItems": {"$dynamicRef": "#meta"},
|
||||
"unevaluatedProperties": {"$dynamicRef": "#meta"}
|
||||
}
|
||||
}
|
90
my-app/node_modules/ajv/dist/refs/json-schema-2020-12/meta/validation.json
generated
vendored
Executable file
90
my-app/node_modules/ajv/dist/refs/json-schema-2020-12/meta/validation.json
generated
vendored
Executable file
|
@ -0,0 +1,90 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://json-schema.org/draft/2020-12/meta/validation",
|
||||
"$vocabulary": {
|
||||
"https://json-schema.org/draft/2020-12/vocab/validation": true
|
||||
},
|
||||
"$dynamicAnchor": "meta",
|
||||
|
||||
"title": "Validation vocabulary meta-schema",
|
||||
"type": ["object", "boolean"],
|
||||
"properties": {
|
||||
"type": {
|
||||
"anyOf": [
|
||||
{"$ref": "#/$defs/simpleTypes"},
|
||||
{
|
||||
"type": "array",
|
||||
"items": {"$ref": "#/$defs/simpleTypes"},
|
||||
"minItems": 1,
|
||||
"uniqueItems": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"const": true,
|
||||
"enum": {
|
||||
"type": "array",
|
||||
"items": true
|
||||
},
|
||||
"multipleOf": {
|
||||
"type": "number",
|
||||
"exclusiveMinimum": 0
|
||||
},
|
||||
"maximum": {
|
||||
"type": "number"
|
||||
},
|
||||
"exclusiveMaximum": {
|
||||
"type": "number"
|
||||
},
|
||||
"minimum": {
|
||||
"type": "number"
|
||||
},
|
||||
"exclusiveMinimum": {
|
||||
"type": "number"
|
||||
},
|
||||
"maxLength": {"$ref": "#/$defs/nonNegativeInteger"},
|
||||
"minLength": {"$ref": "#/$defs/nonNegativeIntegerDefault0"},
|
||||
"pattern": {
|
||||
"type": "string",
|
||||
"format": "regex"
|
||||
},
|
||||
"maxItems": {"$ref": "#/$defs/nonNegativeInteger"},
|
||||
"minItems": {"$ref": "#/$defs/nonNegativeIntegerDefault0"},
|
||||
"uniqueItems": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"maxContains": {"$ref": "#/$defs/nonNegativeInteger"},
|
||||
"minContains": {
|
||||
"$ref": "#/$defs/nonNegativeInteger",
|
||||
"default": 1
|
||||
},
|
||||
"maxProperties": {"$ref": "#/$defs/nonNegativeInteger"},
|
||||
"minProperties": {"$ref": "#/$defs/nonNegativeIntegerDefault0"},
|
||||
"required": {"$ref": "#/$defs/stringArray"},
|
||||
"dependentRequired": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"$ref": "#/$defs/stringArray"
|
||||
}
|
||||
}
|
||||
},
|
||||
"$defs": {
|
||||
"nonNegativeInteger": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"nonNegativeIntegerDefault0": {
|
||||
"$ref": "#/$defs/nonNegativeInteger",
|
||||
"default": 0
|
||||
},
|
||||
"simpleTypes": {
|
||||
"enum": ["array", "boolean", "integer", "null", "number", "object", "string"]
|
||||
},
|
||||
"stringArray": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"},
|
||||
"uniqueItems": true,
|
||||
"default": []
|
||||
}
|
||||
}
|
||||
}
|
55
my-app/node_modules/ajv/dist/refs/json-schema-2020-12/schema.json
generated
vendored
Executable file
55
my-app/node_modules/ajv/dist/refs/json-schema-2020-12/schema.json
generated
vendored
Executable file
|
@ -0,0 +1,55 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$vocabulary": {
|
||||
"https://json-schema.org/draft/2020-12/vocab/core": true,
|
||||
"https://json-schema.org/draft/2020-12/vocab/applicator": true,
|
||||
"https://json-schema.org/draft/2020-12/vocab/unevaluated": true,
|
||||
"https://json-schema.org/draft/2020-12/vocab/validation": true,
|
||||
"https://json-schema.org/draft/2020-12/vocab/meta-data": true,
|
||||
"https://json-schema.org/draft/2020-12/vocab/format-annotation": true,
|
||||
"https://json-schema.org/draft/2020-12/vocab/content": true
|
||||
},
|
||||
"$dynamicAnchor": "meta",
|
||||
|
||||
"title": "Core and Validation specifications meta-schema",
|
||||
"allOf": [
|
||||
{"$ref": "meta/core"},
|
||||
{"$ref": "meta/applicator"},
|
||||
{"$ref": "meta/unevaluated"},
|
||||
{"$ref": "meta/validation"},
|
||||
{"$ref": "meta/meta-data"},
|
||||
{"$ref": "meta/format-annotation"},
|
||||
{"$ref": "meta/content"}
|
||||
],
|
||||
"type": ["object", "boolean"],
|
||||
"$comment": "This meta-schema also defines keywords that have appeared in previous drafts in order to prevent incompatible extensions as they remain in common use.",
|
||||
"properties": {
|
||||
"definitions": {
|
||||
"$comment": "\"definitions\" has been replaced by \"$defs\".",
|
||||
"type": "object",
|
||||
"additionalProperties": {"$dynamicRef": "#meta"},
|
||||
"deprecated": true,
|
||||
"default": {}
|
||||
},
|
||||
"dependencies": {
|
||||
"$comment": "\"dependencies\" has been split and replaced by \"dependentSchemas\" and \"dependentRequired\" in order to serve their differing semantics.",
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"anyOf": [{"$dynamicRef": "#meta"}, {"$ref": "meta/validation#/$defs/stringArray"}]
|
||||
},
|
||||
"deprecated": true,
|
||||
"default": {}
|
||||
},
|
||||
"$recursiveAnchor": {
|
||||
"$comment": "\"$recursiveAnchor\" has been replaced by \"$dynamicAnchor\".",
|
||||
"$ref": "meta/core#/$defs/anchorString",
|
||||
"deprecated": true
|
||||
},
|
||||
"$recursiveRef": {
|
||||
"$comment": "\"$recursiveRef\" has been replaced by \"$dynamicRef\".",
|
||||
"$ref": "meta/core#/$defs/uriReferenceString",
|
||||
"deprecated": true
|
||||
}
|
||||
}
|
||||
}
|
137
my-app/node_modules/ajv/dist/refs/json-schema-draft-06.json
generated
vendored
Executable file
137
my-app/node_modules/ajv/dist/refs/json-schema-draft-06.json
generated
vendored
Executable file
|
@ -0,0 +1,137 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-06/schema#",
|
||||
"$id": "http://json-schema.org/draft-06/schema#",
|
||||
"title": "Core schema meta-schema",
|
||||
"definitions": {
|
||||
"schemaArray": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {"$ref": "#"}
|
||||
},
|
||||
"nonNegativeInteger": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"nonNegativeIntegerDefault0": {
|
||||
"allOf": [{"$ref": "#/definitions/nonNegativeInteger"}, {"default": 0}]
|
||||
},
|
||||
"simpleTypes": {
|
||||
"enum": ["array", "boolean", "integer", "null", "number", "object", "string"]
|
||||
},
|
||||
"stringArray": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"},
|
||||
"uniqueItems": true,
|
||||
"default": []
|
||||
}
|
||||
},
|
||||
"type": ["object", "boolean"],
|
||||
"properties": {
|
||||
"$id": {
|
||||
"type": "string",
|
||||
"format": "uri-reference"
|
||||
},
|
||||
"$schema": {
|
||||
"type": "string",
|
||||
"format": "uri"
|
||||
},
|
||||
"$ref": {
|
||||
"type": "string",
|
||||
"format": "uri-reference"
|
||||
},
|
||||
"title": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"default": {},
|
||||
"examples": {
|
||||
"type": "array",
|
||||
"items": {}
|
||||
},
|
||||
"multipleOf": {
|
||||
"type": "number",
|
||||
"exclusiveMinimum": 0
|
||||
},
|
||||
"maximum": {
|
||||
"type": "number"
|
||||
},
|
||||
"exclusiveMaximum": {
|
||||
"type": "number"
|
||||
},
|
||||
"minimum": {
|
||||
"type": "number"
|
||||
},
|
||||
"exclusiveMinimum": {
|
||||
"type": "number"
|
||||
},
|
||||
"maxLength": {"$ref": "#/definitions/nonNegativeInteger"},
|
||||
"minLength": {"$ref": "#/definitions/nonNegativeIntegerDefault0"},
|
||||
"pattern": {
|
||||
"type": "string",
|
||||
"format": "regex"
|
||||
},
|
||||
"additionalItems": {"$ref": "#"},
|
||||
"items": {
|
||||
"anyOf": [{"$ref": "#"}, {"$ref": "#/definitions/schemaArray"}],
|
||||
"default": {}
|
||||
},
|
||||
"maxItems": {"$ref": "#/definitions/nonNegativeInteger"},
|
||||
"minItems": {"$ref": "#/definitions/nonNegativeIntegerDefault0"},
|
||||
"uniqueItems": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"contains": {"$ref": "#"},
|
||||
"maxProperties": {"$ref": "#/definitions/nonNegativeInteger"},
|
||||
"minProperties": {"$ref": "#/definitions/nonNegativeIntegerDefault0"},
|
||||
"required": {"$ref": "#/definitions/stringArray"},
|
||||
"additionalProperties": {"$ref": "#"},
|
||||
"definitions": {
|
||||
"type": "object",
|
||||
"additionalProperties": {"$ref": "#"},
|
||||
"default": {}
|
||||
},
|
||||
"properties": {
|
||||
"type": "object",
|
||||
"additionalProperties": {"$ref": "#"},
|
||||
"default": {}
|
||||
},
|
||||
"patternProperties": {
|
||||
"type": "object",
|
||||
"additionalProperties": {"$ref": "#"},
|
||||
"default": {}
|
||||
},
|
||||
"dependencies": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"anyOf": [{"$ref": "#"}, {"$ref": "#/definitions/stringArray"}]
|
||||
}
|
||||
},
|
||||
"propertyNames": {"$ref": "#"},
|
||||
"const": {},
|
||||
"enum": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"uniqueItems": true
|
||||
},
|
||||
"type": {
|
||||
"anyOf": [
|
||||
{"$ref": "#/definitions/simpleTypes"},
|
||||
{
|
||||
"type": "array",
|
||||
"items": {"$ref": "#/definitions/simpleTypes"},
|
||||
"minItems": 1,
|
||||
"uniqueItems": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"format": {"type": "string"},
|
||||
"allOf": {"$ref": "#/definitions/schemaArray"},
|
||||
"anyOf": {"$ref": "#/definitions/schemaArray"},
|
||||
"oneOf": {"$ref": "#/definitions/schemaArray"},
|
||||
"not": {"$ref": "#"}
|
||||
},
|
||||
"default": {}
|
||||
}
|
151
my-app/node_modules/ajv/dist/refs/json-schema-draft-07.json
generated
vendored
Executable file
151
my-app/node_modules/ajv/dist/refs/json-schema-draft-07.json
generated
vendored
Executable file
|
@ -0,0 +1,151 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"$id": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "Core schema meta-schema",
|
||||
"definitions": {
|
||||
"schemaArray": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {"$ref": "#"}
|
||||
},
|
||||
"nonNegativeInteger": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
},
|
||||
"nonNegativeIntegerDefault0": {
|
||||
"allOf": [{"$ref": "#/definitions/nonNegativeInteger"}, {"default": 0}]
|
||||
},
|
||||
"simpleTypes": {
|
||||
"enum": ["array", "boolean", "integer", "null", "number", "object", "string"]
|
||||
},
|
||||
"stringArray": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"},
|
||||
"uniqueItems": true,
|
||||
"default": []
|
||||
}
|
||||
},
|
||||
"type": ["object", "boolean"],
|
||||
"properties": {
|
||||
"$id": {
|
||||
"type": "string",
|
||||
"format": "uri-reference"
|
||||
},
|
||||
"$schema": {
|
||||
"type": "string",
|
||||
"format": "uri"
|
||||
},
|
||||
"$ref": {
|
||||
"type": "string",
|
||||
"format": "uri-reference"
|
||||
},
|
||||
"$comment": {
|
||||
"type": "string"
|
||||
},
|
||||
"title": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"default": true,
|
||||
"readOnly": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"examples": {
|
||||
"type": "array",
|
||||
"items": true
|
||||
},
|
||||
"multipleOf": {
|
||||
"type": "number",
|
||||
"exclusiveMinimum": 0
|
||||
},
|
||||
"maximum": {
|
||||
"type": "number"
|
||||
},
|
||||
"exclusiveMaximum": {
|
||||
"type": "number"
|
||||
},
|
||||
"minimum": {
|
||||
"type": "number"
|
||||
},
|
||||
"exclusiveMinimum": {
|
||||
"type": "number"
|
||||
},
|
||||
"maxLength": {"$ref": "#/definitions/nonNegativeInteger"},
|
||||
"minLength": {"$ref": "#/definitions/nonNegativeIntegerDefault0"},
|
||||
"pattern": {
|
||||
"type": "string",
|
||||
"format": "regex"
|
||||
},
|
||||
"additionalItems": {"$ref": "#"},
|
||||
"items": {
|
||||
"anyOf": [{"$ref": "#"}, {"$ref": "#/definitions/schemaArray"}],
|
||||
"default": true
|
||||
},
|
||||
"maxItems": {"$ref": "#/definitions/nonNegativeInteger"},
|
||||
"minItems": {"$ref": "#/definitions/nonNegativeIntegerDefault0"},
|
||||
"uniqueItems": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"contains": {"$ref": "#"},
|
||||
"maxProperties": {"$ref": "#/definitions/nonNegativeInteger"},
|
||||
"minProperties": {"$ref": "#/definitions/nonNegativeIntegerDefault0"},
|
||||
"required": {"$ref": "#/definitions/stringArray"},
|
||||
"additionalProperties": {"$ref": "#"},
|
||||
"definitions": {
|
||||
"type": "object",
|
||||
"additionalProperties": {"$ref": "#"},
|
||||
"default": {}
|
||||
},
|
||||
"properties": {
|
||||
"type": "object",
|
||||
"additionalProperties": {"$ref": "#"},
|
||||
"default": {}
|
||||
},
|
||||
"patternProperties": {
|
||||
"type": "object",
|
||||
"additionalProperties": {"$ref": "#"},
|
||||
"propertyNames": {"format": "regex"},
|
||||
"default": {}
|
||||
},
|
||||
"dependencies": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"anyOf": [{"$ref": "#"}, {"$ref": "#/definitions/stringArray"}]
|
||||
}
|
||||
},
|
||||
"propertyNames": {"$ref": "#"},
|
||||
"const": true,
|
||||
"enum": {
|
||||
"type": "array",
|
||||
"items": true,
|
||||
"minItems": 1,
|
||||
"uniqueItems": true
|
||||
},
|
||||
"type": {
|
||||
"anyOf": [
|
||||
{"$ref": "#/definitions/simpleTypes"},
|
||||
{
|
||||
"type": "array",
|
||||
"items": {"$ref": "#/definitions/simpleTypes"},
|
||||
"minItems": 1,
|
||||
"uniqueItems": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"format": {"type": "string"},
|
||||
"contentMediaType": {"type": "string"},
|
||||
"contentEncoding": {"type": "string"},
|
||||
"if": {"$ref": "#"},
|
||||
"then": {"$ref": "#"},
|
||||
"else": {"$ref": "#"},
|
||||
"allOf": {"$ref": "#/definitions/schemaArray"},
|
||||
"anyOf": {"$ref": "#/definitions/schemaArray"},
|
||||
"oneOf": {"$ref": "#/definitions/schemaArray"},
|
||||
"not": {"$ref": "#"}
|
||||
},
|
||||
"default": true
|
||||
}
|
88
my-app/node_modules/ajv/dist/refs/json-schema-secure.json
generated
vendored
Executable file
88
my-app/node_modules/ajv/dist/refs/json-schema-secure.json
generated
vendored
Executable file
|
@ -0,0 +1,88 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"$id": "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/json-schema-secure.json#",
|
||||
"title": "Meta-schema for the security assessment of JSON Schemas",
|
||||
"description": "If a JSON AnySchema fails validation against this meta-schema, it may be unsafe to validate untrusted data",
|
||||
"definitions": {
|
||||
"schemaArray": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {"$ref": "#"}
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"patternProperties": {
|
||||
"description": "prevent slow validation of large property names",
|
||||
"required": ["propertyNames"],
|
||||
"properties": {
|
||||
"propertyNames": {
|
||||
"required": ["maxLength"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"uniqueItems": {
|
||||
"description": "prevent slow validation of large non-scalar arrays",
|
||||
"if": {
|
||||
"properties": {
|
||||
"uniqueItems": {"const": true},
|
||||
"items": {
|
||||
"properties": {
|
||||
"type": {
|
||||
"anyOf": [
|
||||
{
|
||||
"enum": ["object", "array"]
|
||||
},
|
||||
{
|
||||
"type": "array",
|
||||
"contains": {"enum": ["object", "array"]}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"required": ["maxItems"]
|
||||
}
|
||||
},
|
||||
"pattern": {
|
||||
"description": "prevent slow pattern matching of large strings",
|
||||
"required": ["maxLength"]
|
||||
},
|
||||
"format": {
|
||||
"description": "prevent slow format validation of large strings",
|
||||
"required": ["maxLength"]
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"additionalItems": {"$ref": "#"},
|
||||
"additionalProperties": {"$ref": "#"},
|
||||
"dependencies": {
|
||||
"additionalProperties": {
|
||||
"anyOf": [{"type": "array"}, {"$ref": "#"}]
|
||||
}
|
||||
},
|
||||
"items": {
|
||||
"anyOf": [{"$ref": "#"}, {"$ref": "#/definitions/schemaArray"}]
|
||||
},
|
||||
"definitions": {
|
||||
"additionalProperties": {"$ref": "#"}
|
||||
},
|
||||
"patternProperties": {
|
||||
"additionalProperties": {"$ref": "#"}
|
||||
},
|
||||
"properties": {
|
||||
"additionalProperties": {"$ref": "#"}
|
||||
},
|
||||
"if": {"$ref": "#"},
|
||||
"then": {"$ref": "#"},
|
||||
"else": {"$ref": "#"},
|
||||
"allOf": {"$ref": "#/definitions/schemaArray"},
|
||||
"anyOf": {"$ref": "#/definitions/schemaArray"},
|
||||
"oneOf": {"$ref": "#/definitions/schemaArray"},
|
||||
"not": {"$ref": "#"},
|
||||
"contains": {"$ref": "#"},
|
||||
"propertyNames": {"$ref": "#"}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue