@redocly/ajv
Advanced tools
| import type { AnySchemaObject, Options } from "./core"; | ||
| import AjvCore from "./core"; | ||
| declare class Ajv extends AjvCore { | ||
| constructor(opts?: Options); | ||
| _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, Context, } 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"; |
| "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 draft4_1 = require("./vocabularies/draft4"); | ||
| const discriminator_1 = require("./vocabularies/discriminator"); | ||
| const draft4MetaSchema = require("./refs/json-schema-draft-04.json"); | ||
| const META_SUPPORT_DATA = ["/properties"]; | ||
| const META_SCHEMA_ID = "http://json-schema.org/draft-04/schema"; | ||
| class Ajv extends core_1.default { | ||
| constructor(opts = {}) { | ||
| super({ | ||
| ...opts, | ||
| schemaId: "id", | ||
| dynamicRef: true, | ||
| unevaluated: true, | ||
| }); | ||
| } | ||
| _addVocabularies() { | ||
| super._addVocabularies(); | ||
| draft4_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(draft4MetaSchema, META_SUPPORT_DATA) | ||
| : draft4MetaSchema; | ||
| 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=draft4.js.map |
| {"version":3,"file":"draft4.js","sourceRoot":"","sources":["../lib/draft4.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,YAAY,OAAgB,EAAE;QAC5B,KAAK,CAAC;YACJ,GAAG,IAAI;YACP,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,IAAI;YAChB,WAAW,EAAE,IAAI;SAClB,CAAC,CAAA;IACJ,CAAC;IAED,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;AA2BlB,+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"} |
| { | ||
| "id": "http://json-schema.org/draft-04/schema#", | ||
| "$schema": "http://json-schema.org/draft-04/schema#", | ||
| "description": "Core schema meta-schema", | ||
| "definitions": { | ||
| "schemaArray": { | ||
| "type": "array", | ||
| "minItems": 1, | ||
| "items": {"$ref": "#"} | ||
| }, | ||
| "positiveInteger": { | ||
| "type": "integer", | ||
| "minimum": 0 | ||
| }, | ||
| "positiveIntegerDefault0": { | ||
| "allOf": [{"$ref": "#/definitions/positiveInteger"}, {"default": 0}] | ||
| }, | ||
| "simpleTypes": { | ||
| "enum": ["array", "boolean", "integer", "null", "number", "object", "string"] | ||
| }, | ||
| "stringArray": { | ||
| "type": "array", | ||
| "items": {"type": "string"}, | ||
| "minItems": 1, | ||
| "uniqueItems": true | ||
| } | ||
| }, | ||
| "type": "object", | ||
| "properties": { | ||
| "id": { | ||
| "type": "string", | ||
| "format": "uri" | ||
| }, | ||
| "$schema": { | ||
| "type": "string", | ||
| "format": "uri" | ||
| }, | ||
| "title": { | ||
| "type": "string" | ||
| }, | ||
| "description": { | ||
| "type": "string" | ||
| }, | ||
| "default": {}, | ||
| "multipleOf": { | ||
| "type": "number", | ||
| "minimum": 0, | ||
| "exclusiveMinimum": true | ||
| }, | ||
| "maximum": { | ||
| "type": "number" | ||
| }, | ||
| "exclusiveMaximum": { | ||
| "type": "boolean", | ||
| "default": false | ||
| }, | ||
| "minimum": { | ||
| "type": "number" | ||
| }, | ||
| "exclusiveMinimum": { | ||
| "type": "boolean", | ||
| "default": false | ||
| }, | ||
| "maxLength": {"$ref": "#/definitions/positiveInteger"}, | ||
| "minLength": {"$ref": "#/definitions/positiveIntegerDefault0"}, | ||
| "pattern": { | ||
| "type": "string", | ||
| "format": "regex" | ||
| }, | ||
| "additionalItems": { | ||
| "anyOf": [{"type": "boolean"}, {"$ref": "#"}], | ||
| "default": {} | ||
| }, | ||
| "items": { | ||
| "anyOf": [{"$ref": "#"}, {"$ref": "#/definitions/schemaArray"}], | ||
| "default": {} | ||
| }, | ||
| "maxItems": {"$ref": "#/definitions/positiveInteger"}, | ||
| "minItems": {"$ref": "#/definitions/positiveIntegerDefault0"}, | ||
| "uniqueItems": { | ||
| "type": "boolean", | ||
| "default": false | ||
| }, | ||
| "maxProperties": {"$ref": "#/definitions/positiveInteger"}, | ||
| "minProperties": {"$ref": "#/definitions/positiveIntegerDefault0"}, | ||
| "required": {"$ref": "#/definitions/stringArray"}, | ||
| "additionalProperties": { | ||
| "anyOf": [{"type": "boolean"}, {"$ref": "#"}], | ||
| "default": {} | ||
| }, | ||
| "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"}] | ||
| } | ||
| }, | ||
| "enum": { | ||
| "type": "array", | ||
| "minItems": 1, | ||
| "uniqueItems": true | ||
| }, | ||
| "type": { | ||
| "anyOf": [ | ||
| {"$ref": "#/definitions/simpleTypes"}, | ||
| { | ||
| "type": "array", | ||
| "items": {"$ref": "#/definitions/simpleTypes"}, | ||
| "minItems": 1, | ||
| "uniqueItems": true | ||
| } | ||
| ] | ||
| }, | ||
| "allOf": {"$ref": "#/definitions/schemaArray"}, | ||
| "anyOf": {"$ref": "#/definitions/schemaArray"}, | ||
| "oneOf": {"$ref": "#/definitions/schemaArray"}, | ||
| "not": {"$ref": "#"} | ||
| }, | ||
| "dependencies": { | ||
| "exclusiveMaximum": ["maximum"], | ||
| "exclusiveMinimum": ["minimum"] | ||
| }, | ||
| "default": {} | ||
| } |
| import { Vocabulary } from "../types"; | ||
| declare const draft4Vocabularies: Vocabulary[]; | ||
| export default draft4Vocabularies; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const ref_1 = require("./core/ref"); | ||
| const applicator_1 = require("./applicator"); | ||
| const unevaluated_1 = require("./unevaluated"); | ||
| const format_1 = require("./format"); | ||
| const validation_1 = require("./validation"); | ||
| const limitNumber_1 = require("./validation/draft04/limitNumber"); | ||
| const limitNumberExclusive_1 = require("./validation/draft04/limitNumberExclusive"); | ||
| const metadataVocabulary = ["title", "description", "default"]; | ||
| const coreVocabulary = [ | ||
| "$schema", | ||
| "id", | ||
| "$defs", | ||
| { keyword: "$comment" }, | ||
| "definitions", | ||
| ref_1.default, | ||
| ]; | ||
| const validation = [...validation_1.default.slice(1), limitNumber_1.default, limitNumberExclusive_1.default]; | ||
| const draft4Vocabularies = [ | ||
| coreVocabulary, | ||
| validation, | ||
| (0, applicator_1.default)(), | ||
| format_1.default, | ||
| metadataVocabulary, | ||
| unevaluated_1.default, | ||
| ]; | ||
| exports.default = draft4Vocabularies; | ||
| //# sourceMappingURL=draft4.js.map |
| {"version":3,"file":"draft4.js","sourceRoot":"","sources":["../../lib/vocabularies/draft4.ts"],"names":[],"mappings":";;AACA,oCAAmC;AACnC,6CAAkD;AAClD,+CAAiD;AACjD,qCAAuC;AACvC,6CAA+C;AAC/C,kEAA0D;AAC1D,oFAA4E;AAE5E,MAAM,kBAAkB,GAAe,CAAC,OAAO,EAAE,aAAa,EAAE,SAAS,CAAC,CAAA;AAE1E,MAAM,cAAc,GAAe;IACjC,SAAS;IACT,IAAI;IACJ,OAAO;IACP,EAAC,OAAO,EAAE,UAAU,EAAC;IACrB,aAAa;IACb,aAAU;CACX,CAAA;AAED,MAAM,UAAU,GAAe,CAAC,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,qBAAW,EAAE,8BAAoB,CAAC,CAAA;AAEpG,MAAM,kBAAkB,GAAiB;IACvC,cAAc;IACd,UAAU;IACV,IAAA,oBAAuB,GAAE;IACzB,gBAAgB;IAChB,kBAAkB;IAClB,qBAAqB;CACtB,CAAA;AAED,kBAAe,kBAAkB,CAAA"} |
| import type { CodeKeywordDefinition, ErrorObject } from "../../../types"; | ||
| export type LimitKwd = "maximum" | "minimum"; | ||
| export type ExclusiveLimitKwd = "exclusiveMaximum" | "exclusiveMinimum"; | ||
| type Comparison = "<=" | ">=" | "<" | ">"; | ||
| export type LimitNumberError = ErrorObject<LimitKwd, { | ||
| limit: number; | ||
| comparison: Comparison; | ||
| }, number | { | ||
| $data: string; | ||
| }>; | ||
| declare const def: CodeKeywordDefinition; | ||
| export default def; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const codegen_1 = require("../../../compile/codegen"); | ||
| const ops = codegen_1.operators; | ||
| const KWDs = { | ||
| maximum: { | ||
| exclusive: "exclusiveMaximum", | ||
| ops: [ | ||
| { okStr: "<=", ok: ops.LTE, fail: ops.GT }, | ||
| { okStr: "<", ok: ops.LT, fail: ops.GTE }, | ||
| ], | ||
| }, | ||
| minimum: { | ||
| exclusive: "exclusiveMinimum", | ||
| ops: [ | ||
| { okStr: ">=", ok: ops.GTE, fail: ops.LT }, | ||
| { okStr: ">", ok: ops.GT, fail: ops.LTE }, | ||
| ], | ||
| }, | ||
| }; | ||
| const error = { | ||
| message: (cxt) => (0, codegen_1.str) `must be ${kwdOp(cxt).okStr} ${cxt.schemaCode}`, | ||
| params: (cxt) => (0, codegen_1._) `{comparison: ${kwdOp(cxt).okStr}, limit: ${cxt.schemaCode}}`, | ||
| }; | ||
| const def = { | ||
| keyword: Object.keys(KWDs), | ||
| type: "number", | ||
| schemaType: "number", | ||
| $data: true, | ||
| error, | ||
| code(cxt) { | ||
| const { data, schemaCode } = cxt; | ||
| cxt.fail$data((0, codegen_1._) `${data} ${kwdOp(cxt).fail} ${schemaCode} || isNaN(${data})`); | ||
| }, | ||
| }; | ||
| function kwdOp(cxt) { | ||
| var _a; | ||
| const keyword = cxt.keyword; | ||
| const opsIdx = ((_a = cxt.parentSchema) === null || _a === void 0 ? void 0 : _a[KWDs[keyword].exclusive]) ? 1 : 0; | ||
| return KWDs[keyword].ops[opsIdx]; | ||
| } | ||
| exports.default = def; | ||
| //# sourceMappingURL=limitNumber.js.map |
| {"version":3,"file":"limitNumber.js","sourceRoot":"","sources":["../../../../lib/vocabularies/validation/draft04/limitNumber.ts"],"names":[],"mappings":";;AAOA,sDAAgE;AAEhE,MAAM,GAAG,GAAG,mBAAS,CAAA;AAmBrB,MAAM,IAAI,GAA8B;IACtC,OAAO,EAAE;QACP,SAAS,EAAE,kBAAkB;QAC7B,GAAG,EAAE;YACH,EAAC,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,EAAE,EAAC;YACxC,EAAC,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,GAAG,CAAC,GAAG,EAAC;SACxC;KACF;IACD,OAAO,EAAE;QACP,SAAS,EAAE,kB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;IAClE,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;AAClC,CAAC;AAED,kBAAe,GAAG,CAAA"} |
| import type { CodeKeywordDefinition } from "../../../types"; | ||
| declare const def: CodeKeywordDefinition; | ||
| export default def; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const KWDs = { | ||
| exclusiveMaximum: "maximum", | ||
| exclusiveMinimum: "minimum", | ||
| }; | ||
| const def = { | ||
| keyword: Object.keys(KWDs), | ||
| type: "number", | ||
| schemaType: "boolean", | ||
| code({ keyword, parentSchema }) { | ||
| const limitKwd = KWDs[keyword]; | ||
| if (parentSchema[limitKwd] === undefined) { | ||
| throw new Error(`${keyword} can only be used with ${limitKwd}`); | ||
| } | ||
| }, | ||
| }; | ||
| exports.default = def; | ||
| //# sourceMappingURL=limitNumberExclusive.js.map |
| {"version":3,"file":"limitNumberExclusive.js","sourceRoot":"","sources":["../../../../lib/vocabularies/validation/draft04/limitNumberExclusive.ts"],"names":[],"mappings":";;AAQA,MAAM,IAAI,GAAyC;IACjD,gBAAgB,EAAE,SAAS;IAC3B,gBAAgB,EAAE,SAAS;CAC5B,CAAA;AAED,MAAM,GAAG,GAA0B;IACjC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;IAC1B,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE,SAAS;IACrB,IAAI,CAAC,EAAC,OAAO,EAAE,YAAY,EAAa;QACtC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAA4B,CAAC,CAAA;QACnD,IAAI,YAAY,CAAC,QAAQ,CAAC,KAAK,SAAS,EAAE,CAAC;YACzC,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,0BAA0B,QAAQ,EAAE,CAAC,CAAA;QACjE,CAAC;IACH,CAAC;CACF,CAAA;AAED,kBAAe,GAAG,CAAA"} |
| import type {AnySchemaObject, Options} from "./core" | ||
| import AjvCore from "./core" | ||
| import draft4Vocabularies from "./vocabularies/draft4" | ||
| import discriminator from "./vocabularies/discriminator" | ||
| import * as draft4MetaSchema from "./refs/json-schema-draft-04.json" | ||
| const META_SUPPORT_DATA = ["/properties"] | ||
| const META_SCHEMA_ID = "http://json-schema.org/draft-04/schema" | ||
| class Ajv extends AjvCore { | ||
| constructor(opts: Options = {}) { | ||
| super({ | ||
| ...opts, | ||
| schemaId: "id", | ||
| dynamicRef: true, | ||
| unevaluated: true, | ||
| }) | ||
| } | ||
| _addVocabularies(): void { | ||
| super._addVocabularies() | ||
| draft4Vocabularies.forEach((v) => this.addVocabulary(v)) | ||
| if (this.opts.discriminator) this.addKeyword(discriminator) | ||
| } | ||
| _addDefaultMetaSchema(): void { | ||
| super._addDefaultMetaSchema() | ||
| if (!this.opts.meta) return | ||
| const metaSchema = this.opts.$data | ||
| ? this.$dataMetaSchema(draft4MetaSchema, META_SUPPORT_DATA) | ||
| : draft4MetaSchema | ||
| this.addMetaSchema(metaSchema, META_SCHEMA_ID, false) | ||
| this.refs["http://json-schema.org/schema"] = META_SCHEMA_ID | ||
| } | ||
| defaultMeta(): string | AnySchemaObject | undefined { | ||
| 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}) | ||
| export default Ajv | ||
| export { | ||
| Format, | ||
| FormatDefinition, | ||
| AsyncFormatDefinition, | ||
| KeywordDefinition, | ||
| KeywordErrorDefinition, | ||
| CodeKeywordDefinition, | ||
| MacroKeywordDefinition, | ||
| FuncKeywordDefinition, | ||
| Vocabulary, | ||
| Schema, | ||
| SchemaObject, | ||
| AnySchemaObject, | ||
| AsyncSchema, | ||
| AnySchema, | ||
| ValidateFunction, | ||
| AsyncValidateFunction, | ||
| SchemaValidateFunction, | ||
| ErrorObject, | ||
| ErrorNoParams, | ||
| Context, | ||
| } 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" |
| { | ||
| "id": "http://json-schema.org/draft-04/schema#", | ||
| "$schema": "http://json-schema.org/draft-04/schema#", | ||
| "description": "Core schema meta-schema", | ||
| "definitions": { | ||
| "schemaArray": { | ||
| "type": "array", | ||
| "minItems": 1, | ||
| "items": {"$ref": "#"} | ||
| }, | ||
| "positiveInteger": { | ||
| "type": "integer", | ||
| "minimum": 0 | ||
| }, | ||
| "positiveIntegerDefault0": { | ||
| "allOf": [{"$ref": "#/definitions/positiveInteger"}, {"default": 0}] | ||
| }, | ||
| "simpleTypes": { | ||
| "enum": ["array", "boolean", "integer", "null", "number", "object", "string"] | ||
| }, | ||
| "stringArray": { | ||
| "type": "array", | ||
| "items": {"type": "string"}, | ||
| "minItems": 1, | ||
| "uniqueItems": true | ||
| } | ||
| }, | ||
| "type": "object", | ||
| "properties": { | ||
| "id": { | ||
| "type": "string", | ||
| "format": "uri" | ||
| }, | ||
| "$schema": { | ||
| "type": "string", | ||
| "format": "uri" | ||
| }, | ||
| "title": { | ||
| "type": "string" | ||
| }, | ||
| "description": { | ||
| "type": "string" | ||
| }, | ||
| "default": {}, | ||
| "multipleOf": { | ||
| "type": "number", | ||
| "minimum": 0, | ||
| "exclusiveMinimum": true | ||
| }, | ||
| "maximum": { | ||
| "type": "number" | ||
| }, | ||
| "exclusiveMaximum": { | ||
| "type": "boolean", | ||
| "default": false | ||
| }, | ||
| "minimum": { | ||
| "type": "number" | ||
| }, | ||
| "exclusiveMinimum": { | ||
| "type": "boolean", | ||
| "default": false | ||
| }, | ||
| "maxLength": {"$ref": "#/definitions/positiveInteger"}, | ||
| "minLength": {"$ref": "#/definitions/positiveIntegerDefault0"}, | ||
| "pattern": { | ||
| "type": "string", | ||
| "format": "regex" | ||
| }, | ||
| "additionalItems": { | ||
| "anyOf": [{"type": "boolean"}, {"$ref": "#"}], | ||
| "default": {} | ||
| }, | ||
| "items": { | ||
| "anyOf": [{"$ref": "#"}, {"$ref": "#/definitions/schemaArray"}], | ||
| "default": {} | ||
| }, | ||
| "maxItems": {"$ref": "#/definitions/positiveInteger"}, | ||
| "minItems": {"$ref": "#/definitions/positiveIntegerDefault0"}, | ||
| "uniqueItems": { | ||
| "type": "boolean", | ||
| "default": false | ||
| }, | ||
| "maxProperties": {"$ref": "#/definitions/positiveInteger"}, | ||
| "minProperties": {"$ref": "#/definitions/positiveIntegerDefault0"}, | ||
| "required": {"$ref": "#/definitions/stringArray"}, | ||
| "additionalProperties": { | ||
| "anyOf": [{"type": "boolean"}, {"$ref": "#"}], | ||
| "default": {} | ||
| }, | ||
| "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"}] | ||
| } | ||
| }, | ||
| "enum": { | ||
| "type": "array", | ||
| "minItems": 1, | ||
| "uniqueItems": true | ||
| }, | ||
| "type": { | ||
| "anyOf": [ | ||
| {"$ref": "#/definitions/simpleTypes"}, | ||
| { | ||
| "type": "array", | ||
| "items": {"$ref": "#/definitions/simpleTypes"}, | ||
| "minItems": 1, | ||
| "uniqueItems": true | ||
| } | ||
| ] | ||
| }, | ||
| "allOf": {"$ref": "#/definitions/schemaArray"}, | ||
| "anyOf": {"$ref": "#/definitions/schemaArray"}, | ||
| "oneOf": {"$ref": "#/definitions/schemaArray"}, | ||
| "not": {"$ref": "#"} | ||
| }, | ||
| "dependencies": { | ||
| "exclusiveMaximum": ["maximum"], | ||
| "exclusiveMinimum": ["minimum"] | ||
| }, | ||
| "default": {} | ||
| } |
| import {Vocabulary} from "../types" | ||
| import refKeyword from "./core/ref" | ||
| import getApplicatorVocabulary from "./applicator" | ||
| import unevaluatedVocabulary from "./unevaluated" | ||
| import formatVocabulary from "./format" | ||
| import validationVocabulary from "./validation" | ||
| import limitNumber from "./validation/draft04/limitNumber" | ||
| import limitNumberExclusive from "./validation/draft04/limitNumberExclusive" | ||
| const metadataVocabulary: Vocabulary = ["title", "description", "default"] | ||
| const coreVocabulary: Vocabulary = [ | ||
| "$schema", | ||
| "id", | ||
| "$defs", | ||
| {keyword: "$comment"}, | ||
| "definitions", | ||
| refKeyword, | ||
| ] | ||
| const validation: Vocabulary = [...validationVocabulary.slice(1), limitNumber, limitNumberExclusive] | ||
| const draft4Vocabularies: Vocabulary[] = [ | ||
| coreVocabulary, | ||
| validation, | ||
| getApplicatorVocabulary(), | ||
| formatVocabulary, | ||
| metadataVocabulary, | ||
| unevaluatedVocabulary, | ||
| ] | ||
| export default draft4Vocabularies |
| import type { | ||
| CodeKeywordDefinition, | ||
| ErrorObject, | ||
| KeywordErrorDefinition, | ||
| KeywordErrorCxt, | ||
| } from "../../../types" | ||
| import type {KeywordCxt} from "../../../compile/validate" | ||
| import {_, str, operators, Code} from "../../../compile/codegen" | ||
| const ops = operators | ||
| export type LimitKwd = "maximum" | "minimum" | ||
| export type ExclusiveLimitKwd = "exclusiveMaximum" | "exclusiveMinimum" | ||
| type Comparison = "<=" | ">=" | "<" | ">" | ||
| interface KwdOp { | ||
| okStr: Comparison | ||
| ok: Code | ||
| fail: Code | ||
| } | ||
| interface KwdDef { | ||
| exclusive: ExclusiveLimitKwd | ||
| ops: [KwdOp, KwdOp] | ||
| } | ||
| const KWDs: {[K in LimitKwd]: KwdDef} = { | ||
| maximum: { | ||
| exclusive: "exclusiveMaximum", | ||
| ops: [ | ||
| {okStr: "<=", ok: ops.LTE, fail: ops.GT}, | ||
| {okStr: "<", ok: ops.LT, fail: ops.GTE}, | ||
| ], | ||
| }, | ||
| minimum: { | ||
| exclusive: "exclusiveMinimum", | ||
| ops: [ | ||
| {okStr: ">=", ok: ops.GTE, fail: ops.LT}, | ||
| {okStr: ">", ok: ops.GT, fail: ops.LTE}, | ||
| ], | ||
| }, | ||
| } | ||
| export type LimitNumberError = ErrorObject< | ||
| LimitKwd, | ||
| {limit: number; comparison: Comparison}, | ||
| number | {$data: string} | ||
| > | ||
| const error: KeywordErrorDefinition = { | ||
| message: (cxt) => str`must be ${kwdOp(cxt).okStr} ${cxt.schemaCode}`, | ||
| params: (cxt) => _`{comparison: ${kwdOp(cxt).okStr}, limit: ${cxt.schemaCode}}`, | ||
| } | ||
| const def: CodeKeywordDefinition = { | ||
| keyword: Object.keys(KWDs), | ||
| type: "number", | ||
| schemaType: "number", | ||
| $data: true, | ||
| error, | ||
| code(cxt: KeywordCxt) { | ||
| const {data, schemaCode} = cxt | ||
| cxt.fail$data(_`${data} ${kwdOp(cxt).fail} ${schemaCode} || isNaN(${data})`) | ||
| }, | ||
| } | ||
| function kwdOp(cxt: KeywordErrorCxt): KwdOp { | ||
| const keyword = cxt.keyword as LimitKwd | ||
| const opsIdx = cxt.parentSchema?.[KWDs[keyword].exclusive] ? 1 : 0 | ||
| return KWDs[keyword].ops[opsIdx] | ||
| } | ||
| export default def |
| import type { | ||
| CodeKeywordDefinition, | ||
| // ErrorObject, | ||
| // KeywordErrorDefinition, | ||
| } from "../../../types" | ||
| import type {KeywordCxt} from "../../../compile/validate" | ||
| import {LimitKwd, ExclusiveLimitKwd} from "./limitNumber" | ||
| const KWDs: {[K in ExclusiveLimitKwd]: LimitKwd} = { | ||
| exclusiveMaximum: "maximum", | ||
| exclusiveMinimum: "minimum", | ||
| } | ||
| const def: CodeKeywordDefinition = { | ||
| keyword: Object.keys(KWDs), | ||
| type: "number", | ||
| schemaType: "boolean", | ||
| code({keyword, parentSchema}: KeywordCxt) { | ||
| const limitKwd = KWDs[keyword as ExclusiveLimitKwd] | ||
| if (parentSchema[limitKwd] === undefined) { | ||
| throw new Error(`${keyword} can only be used with ${limitKwd}`) | ||
| } | ||
| }, | ||
| } | ||
| export default def |
+1
-1
@@ -10,3 +10,3 @@ import type { AnySchemaObject } from "./types"; | ||
| 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 { Format, FormatDefinition, AsyncFormatDefinition, KeywordDefinition, KeywordErrorDefinition, CodeKeywordDefinition, MacroKeywordDefinition, FuncKeywordDefinition, Vocabulary, Schema, SchemaObject, AnySchemaObject, AsyncSchema, AnySchema, ValidateFunction, AsyncValidateFunction, ErrorObject, ErrorNoParams, Context, } from "./types"; | ||
| export { Plugin, Options, CodeOptions, InstanceOptions, Logger, ErrorsTextOptions } from "./core"; | ||
@@ -13,0 +13,0 @@ export { SchemaCxt, SchemaObjCxt } from "./compile"; |
+1
-1
@@ -1,1 +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,MAAa,OAAQ,SAAQ,cAAO;IAClC,YAAY,OAAgB,EAAE;QAC5B,KAAK,CAAC;YACJ,GAAG,IAAI;Y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AC,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;AA/BD,0BA+BC;AAED,MAAM,CAAC,OAAO,GAAG,OAAO,GAAG,OAAO,CAAA;AAClC,MAAM,CAAC,OAAO,CAAC,OAAO,GAAG,OAAO,CAAA;AAChC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAC,KAAK,EAAE,IAAI,EAAC,CAAC,CAAA;AAE3D,kBAAe,OAAO,CAAA;AA0BtB,+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"} |
+1
-1
@@ -10,3 +10,3 @@ import type { AnySchemaObject } from "./types"; | ||
| 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 { Format, FormatDefinition, AsyncFormatDefinition, KeywordDefinition, KeywordErrorDefinition, CodeKeywordDefinition, MacroKeywordDefinition, FuncKeywordDefinition, Vocabulary, Schema, SchemaObject, AnySchemaObject, AsyncSchema, AnySchema, ValidateFunction, AsyncValidateFunction, ErrorObject, ErrorNoParams, Context, } from "./types"; | ||
| export { Plugin, Options, CodeOptions, InstanceOptions, Logger, ErrorsTextOptions } from "./core"; | ||
@@ -13,0 +13,0 @@ export { SchemaCxt, SchemaObjCxt } from "./compile"; |
+1
-1
@@ -1,1 +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,MAAa,OAAQ,SAAQ,cAAO;IAClC,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,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AAqE;AAA7D,mHAAA,OAAO,OAAmB;AAClC,iDAA8D;AAAtD,4GAAA,OAAO,OAAmB"} |
+1
-1
@@ -9,3 +9,3 @@ import type { AnySchemaObject } from "./types"; | ||
| 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 { Format, FormatDefinition, AsyncFormatDefinition, KeywordDefinition, KeywordErrorDefinition, CodeKeywordDefinition, MacroKeywordDefinition, FuncKeywordDefinition, Vocabulary, Schema, SchemaObject, AnySchemaObject, AsyncSchema, AnySchema, ValidateFunction, AsyncValidateFunction, SchemaValidateFunction, ErrorObject, ErrorNoParams, Context, } from "./types"; | ||
| export { Plugin, Options, CodeOptions, InstanceOptions, Logger, ErrorsTextOptions } from "./core"; | ||
@@ -12,0 +12,0 @@ export { SchemaCxt, SchemaObjCxt } from "./compile"; |
+1
-1
@@ -1,1 +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,MAAa,GAAI,SAAQ,cAAO;IAC9B,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,CA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G,GAAG,GAAG,CAAA;AACxB,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAC,KAAK,EAAE,IAAI,EAAC,CAAC,CAAA;AAE3D,kBAAe,GAAG,CAAA;AA2BlB,+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"} |
@@ -183,2 +183,5 @@ import { URIComponent } from "fast-uri"; | ||
| } | ||
| export interface Context { | ||
| apiContext?: "request" | "response"; | ||
| } | ||
| export {}; |
@@ -16,12 +16,12 @@ "use strict"; | ||
| const conditions = []; | ||
| const oasContext = (0, codegen_1._) `typeof ${names_1.default.this} == "object" && ${names_1.default.this} && ${names_1.default.this}.oas`; | ||
| const apiContext = (0, codegen_1._) `typeof ${names_1.default.this} == "object" && ${names_1.default.this} && ${names_1.default.this}.apiContext`; | ||
| if (hasReadOnly) { | ||
| conditions.push((0, codegen_1._) `${oasContext} && ${names_1.default.this}.oas.mode === "request"`); | ||
| conditions.push((0, codegen_1._) `${apiContext} === "request"`); | ||
| } | ||
| if (hasWriteOnly) { | ||
| conditions.push((0, codegen_1._) `${oasContext} && ${names_1.default.this}.oas.mode === "response"`); | ||
| conditions.push((0, codegen_1._) `${apiContext} === "response"`); | ||
| } | ||
| return conditions.length === 1 ? conditions[0] : (0, codegen_1.or)(...conditions); | ||
| return (0, codegen_1.or)(...conditions); | ||
| } | ||
| exports.getSkipCondition = getSkipCondition; | ||
| //# sourceMappingURL=oasContext.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"oasContext.js","sourceRoot":"","sources":["../../lib/vocabularies/oasContext.ts"],"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CAAC,UAAU,0CAAG,IAAI,CAAC,CAAA;IAC5C,IAAI,CAAC,UAAU;QAAE,OAAO,SAAS,CAAA;IAEjC,MAAM,WAAW,GAAG,UAAU,CAAC,QAAQ,KAAK,IAAI,CAAA;IAChD,MAAM,YAAY,GAAG,UAAU,CAAC,SAAS,KAAK,IAAI,CAAA;IAElD,IAAI,CAAC,WAAW,IAAI,CAAC,YAAY;QAAE,OAAO,SAAS,CAAA;IAEnD,MAAM,UAAU,GAAW,EAAE,CAAA;IAC7B,MAAM,UAAU,GAAG,IAAA,WAAC,EAAA,UAAU,eAAC,CAAC,IAAI,mBAAmB,eAAC,CAAC,IAAI,OAAO,eAAC,CAAC,IAAI,aAAa,CAAA;IAEvF,IAAI,WAAW,EAAE,CAAC;QAChB,UAAU,CAAC,IAAI,CAAC,IAAA,WAAC,EAAA,GAAG,UAAU,gBAAgB,CAAC,CAAA;IACjD,CAAC;IAED,IAAI,YAAY,EAAE,CAAC;QACjB,UAAU,CAAC,IAAI,CAAC,IAAA,WAAC,EAAA,GAAG,UAAU,iBAAiB,CAAC,CAAA;IAClD,CAAC;IAED,OAAO,IAAA,YAAE,EAAC,GAAG,UAAU,CAAC,CAAA;AAC1B,CAAC;AArBD,4CAqBC"} |
@@ -6,4 +6,3 @@ "use strict"; | ||
| const error = { | ||
| message: ({ params }) => (0, codegen_1.str) `must NOT be present in ${params.mode || "this context"}${params.location ? (0, codegen_1.str) ` (${params.location})` : ""}`, | ||
| params: ({ params }) => (0, codegen_1._) `{mode: ${params.mode}, location: ${params.location}}`, | ||
| message: () => (0, codegen_1.str) `must NOT be present in request context`, | ||
| }; | ||
@@ -17,6 +16,4 @@ const def = { | ||
| return; | ||
| const mode = (0, codegen_1._) `(${names_1.default.this} && ${names_1.default.this}.oas ? ${names_1.default.this}.oas.mode : undefined)`; | ||
| const location = (0, codegen_1._) `(${names_1.default.this} && ${names_1.default.this}.oas ? ${names_1.default.this}.oas.location : undefined)`; | ||
| cxt.setParams({ mode, location }); | ||
| cxt.fail((0, codegen_1._) `typeof ${names_1.default.this} == "object" && ${names_1.default.this} && ${names_1.default.this}.oas && ${names_1.default.this}.oas.mode === "request"`); | ||
| const apiContext = (0, codegen_1._) `(${names_1.default.this} && ${names_1.default.this}.apiContext)`; | ||
| cxt.fail((0, codegen_1._) `${apiContext} === "request"`); | ||
| }, | ||
@@ -23,0 +20,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"readOnly.js","sourceRoot":"","sources":["../../../lib/vocabularies/validation/readOnly.ts"],"names":[],"mappings":";;AAEA,mDAA4C;AAC5C,+CAAmC;AAEnC,MAAM,KAAK,GAA2B;IACpC,OAAO,EAAE,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CACpB,IAAA,aAAG,EAAA,0BAA0B,MAAM,CAAC,IAAI,IAAI,cAAc,GACxD,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAA,aAAG,EAAA,KAAK,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,EACjD,EAAE;IACJ,MAAM,EAAE,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CAAC,IAAA,WAAC,EAAA,UAAU,MAAM,CAAC,IAAI,eAAe,MAAM,CAAC,QAAQ,GAAG;CAC9E,CAAA;AAED,MAAM,GAAG,GAA0B;IACjC,OAAO,EAAE,UAAU;IACnB,UAAU,EAAE,SAAS;IACrB,KAAK;IACL,IAAI,CAAC,GAAe;QAClB,IAAI,GAAG,CAAC,MAAM,KAAK,IAAI;YAAE,OAAM;QAE/B,MAAM,IAAI,GAAG,IAAA,WAAC,EAAA,IAAI,eAAC,CAAC,IAAI,OAAO,eAAC,CAAC,IAAI,UAAU,eAAC,CAAC,IAAI,wBAAwB,CAAA;QAC7E,MAAM,QAAQ,GAAG,IAAA,WAAC,EAAA,IAAI,eAAC,CAAC,IAAI,OAAO,eAAC,CAAC,IAAI,UAAU,eAAC,CAAC,IAAI,4BAA4B,CAAA;QACrF,GAAG,CAAC,SAAS,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC,CAAA;QAE/B,GAAG,CAAC,IAAI,CACN,IAAA,WAAC,EAAA,UAAU,eAAC,CAAC,IAAI,mBAAmB,eAAC,CAAC,IAAI,OAAO,eAAC,CAAC,IAAI,WAAW,eAAC,CAAC,IAAI,yBAAyB,CAClG,CAAA;IACH,CAAC;CACF,CAAA;AAED,kBAAe,GAAG,CAAA"} | ||
| {"version":3,"file":"readOnly.js","sourceRoot":"","sources":["../../../lib/vocabularies/validation/readOnly.ts"],"names":[],"mappings":";;AAEA,mDAA4C;AAC5C,+CAAmC;AAEnC,MAAM,KAAK,GAA2B;IACpC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAA,aAAG,EAAA,wCAAwC;CAC3D,CAAA;AAED,MAAM,GAAG,GAA0B;IACjC,OAAO,EAAE,UAAU;IACnB,UAAU,EAAE,SAAS;IACrB,KAAK;IACL,IAAI,CAAC,GAAe;QAClB,IAAI,GAAG,CAAC,MAAM,KAAK,IAAI;YAAE,OAAM;QAE/B,MAAM,UAAU,GAAG,IAAA,WAAC,EAAA,IAAI,eAAC,CAAC,IAAI,OAAO,eAAC,CAAC,IAAI,cAAc,CAAA;QAEzD,GAAG,CAAC,IAAI,CAAC,IAAA,WAAC,EAAA,GAAG,UAAU,gBAAgB,CAAC,CAAA;IAC1C,CAAC;CACF,CAAA;AAED,kBAAe,GAAG,CAAA"} |
@@ -6,4 +6,3 @@ "use strict"; | ||
| const error = { | ||
| message: ({ params }) => (0, codegen_1.str) `must NOT be present in ${params.mode || "this context"}${params.location ? (0, codegen_1.str) ` (${params.location})` : ""}`, | ||
| params: ({ params }) => (0, codegen_1._) `{mode: ${params.mode}, location: ${params.location}}`, | ||
| message: () => (0, codegen_1.str) `must NOT be present in response context`, | ||
| }; | ||
@@ -17,6 +16,4 @@ const def = { | ||
| return; | ||
| const mode = (0, codegen_1._) `(${names_1.default.this} && ${names_1.default.this}.oas ? ${names_1.default.this}.oas.mode : undefined)`; | ||
| const location = (0, codegen_1._) `(${names_1.default.this} && ${names_1.default.this}.oas ? ${names_1.default.this}.oas.location : undefined)`; | ||
| cxt.setParams({ mode, location }); | ||
| cxt.fail((0, codegen_1._) `typeof ${names_1.default.this} == "object" && ${names_1.default.this} && ${names_1.default.this}.oas && ${names_1.default.this}.oas.mode === "response"`); | ||
| const apiContext = (0, codegen_1._) `(${names_1.default.this} && ${names_1.default.this}.apiContext)`; | ||
| cxt.fail((0, codegen_1._) `${apiContext} === "response"`); | ||
| }, | ||
@@ -23,0 +20,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"writeOnly.js","sourceRoot":"","sources":["../../../lib/vocabularies/validation/writeOnly.ts"],"names":[],"mappings":";;AAEA,mDAA4C;AAC5C,+CAAmC;AAEnC,MAAM,KAAK,GAA2B;IACpC,OAAO,EAAE,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CACpB,IAAA,aAAG,EAAA,0BAA0B,MAAM,CAAC,IAAI,IAAI,cAAc,GACxD,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAA,aAAG,EAAA,KAAK,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,EACjD,EAAE;IACJ,MAAM,EAAE,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CAAC,IAAA,WAAC,EAAA,UAAU,MAAM,CAAC,IAAI,eAAe,MAAM,CAAC,QAAQ,GAAG;CAC9E,CAAA;AAED,MAAM,GAAG,GAA0B;IACjC,OAAO,EAAE,WAAW;IACpB,UAAU,EAAE,SAAS;IACrB,KAAK;IACL,IAAI,CAAC,GAAe;QAClB,IAAI,GAAG,CAAC,MAAM,KAAK,IAAI;YAAE,OAAM;QAC/B,MAAM,IAAI,GAAG,IAAA,WAAC,EAAA,IAAI,eAAC,CAAC,IAAI,OAAO,eAAC,CAAC,IAAI,UAAU,eAAC,CAAC,IAAI,wBAAwB,CAAA;QAC7E,MAAM,QAAQ,GAAG,IAAA,WAAC,EAAA,IAAI,eAAC,CAAC,IAAI,OAAO,eAAC,CAAC,IAAI,UAAU,eAAC,CAAC,IAAI,4BAA4B,CAAA;QACrF,GAAG,CAAC,SAAS,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC,CAAA;QAC/B,GAAG,CAAC,IAAI,CACN,IAAA,WAAC,EAAA,UAAU,eAAC,CAAC,IAAI,mBAAmB,eAAC,CAAC,IAAI,OAAO,eAAC,CAAC,IAAI,WAAW,eAAC,CAAC,IAAI,0BAA0B,CACnG,CAAA;IACH,CAAC;CACF,CAAA;AAED,kBAAe,GAAG,CAAA"} | ||
| {"version":3,"file":"writeOnly.js","sourceRoot":"","sources":["../../../lib/vocabularies/validation/writeOnly.ts"],"names":[],"mappings":";;AAEA,mDAA4C;AAC5C,+CAAmC;AAEnC,MAAM,KAAK,GAA2B;IACpC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAA,aAAG,EAAA,yCAAyC;CAC5D,CAAA;AAED,MAAM,GAAG,GAA0B;IACjC,OAAO,EAAE,WAAW;IACpB,UAAU,EAAE,SAAS;IACrB,KAAK;IACL,IAAI,CAAC,GAAe;QAClB,IAAI,GAAG,CAAC,MAAM,KAAK,IAAI;YAAE,OAAM;QAC/B,MAAM,UAAU,GAAG,IAAA,WAAC,EAAA,IAAI,eAAC,CAAC,IAAI,OAAO,eAAC,CAAC,IAAI,cAAc,CAAA;QAEzD,GAAG,CAAC,IAAI,CAAC,IAAA,WAAC,EAAA,GAAG,UAAU,iBAAiB,CAAC,CAAA;IAC3C,CAAC;CACF,CAAA;AAED,kBAAe,GAAG,CAAA"} |
+1
-0
@@ -71,2 +71,3 @@ import type {AnySchemaObject} from "./types" | ||
| ErrorNoParams, | ||
| Context, | ||
| } from "./types" | ||
@@ -73,0 +74,0 @@ |
+1
-0
@@ -65,2 +65,3 @@ import type {AnySchemaObject} from "./types" | ||
| ErrorNoParams, | ||
| Context, | ||
| } from "./types" | ||
@@ -67,0 +68,0 @@ |
+1
-0
@@ -60,2 +60,3 @@ import type {AnySchemaObject} from "./types" | ||
| ErrorNoParams, | ||
| Context, | ||
| } from "./types" | ||
@@ -62,0 +63,0 @@ |
@@ -245,1 +245,5 @@ import {URIComponent} from "fast-uri" | ||
| } | ||
| export interface Context { | ||
| apiContext?: "request" | "response" | ||
| } |
@@ -16,13 +16,13 @@ import type {AnySchemaObject} from "../types" | ||
| const conditions: Code[] = [] | ||
| const oasContext = _`typeof ${N.this} == "object" && ${N.this} && ${N.this}.oas` | ||
| const apiContext = _`typeof ${N.this} == "object" && ${N.this} && ${N.this}.apiContext` | ||
| if (hasReadOnly) { | ||
| conditions.push(_`${oasContext} && ${N.this}.oas.mode === "request"`) | ||
| conditions.push(_`${apiContext} === "request"`) | ||
| } | ||
| if (hasWriteOnly) { | ||
| conditions.push(_`${oasContext} && ${N.this}.oas.mode === "response"`) | ||
| conditions.push(_`${apiContext} === "response"`) | ||
| } | ||
| return conditions.length === 1 ? conditions[0] : or(...conditions) | ||
| return or(...conditions) | ||
| } |
@@ -7,7 +7,3 @@ import type {CodeKeywordDefinition, KeywordErrorDefinition} from "../../types" | ||
| const error: KeywordErrorDefinition = { | ||
| message: ({params}) => | ||
| str`must NOT be present in ${params.mode || "this context"}${ | ||
| params.location ? str` (${params.location})` : "" | ||
| }`, | ||
| params: ({params}) => _`{mode: ${params.mode}, location: ${params.location}}`, | ||
| message: () => str`must NOT be present in request context`, | ||
| } | ||
@@ -22,9 +18,5 @@ | ||
| const mode = _`(${N.this} && ${N.this}.oas ? ${N.this}.oas.mode : undefined)` | ||
| const location = _`(${N.this} && ${N.this}.oas ? ${N.this}.oas.location : undefined)` | ||
| cxt.setParams({mode, location}) | ||
| const apiContext = _`(${N.this} && ${N.this}.apiContext)` | ||
| cxt.fail( | ||
| _`typeof ${N.this} == "object" && ${N.this} && ${N.this}.oas && ${N.this}.oas.mode === "request"` | ||
| ) | ||
| cxt.fail(_`${apiContext} === "request"`) | ||
| }, | ||
@@ -31,0 +23,0 @@ } |
@@ -7,7 +7,3 @@ import type {CodeKeywordDefinition, KeywordErrorDefinition} from "../../types" | ||
| const error: KeywordErrorDefinition = { | ||
| message: ({params}) => | ||
| str`must NOT be present in ${params.mode || "this context"}${ | ||
| params.location ? str` (${params.location})` : "" | ||
| }`, | ||
| params: ({params}) => _`{mode: ${params.mode}, location: ${params.location}}`, | ||
| message: () => str`must NOT be present in response context`, | ||
| } | ||
@@ -21,8 +17,5 @@ | ||
| if (cxt.schema !== true) return | ||
| const mode = _`(${N.this} && ${N.this}.oas ? ${N.this}.oas.mode : undefined)` | ||
| const location = _`(${N.this} && ${N.this}.oas ? ${N.this}.oas.location : undefined)` | ||
| cxt.setParams({mode, location}) | ||
| cxt.fail( | ||
| _`typeof ${N.this} == "object" && ${N.this} && ${N.this}.oas && ${N.this}.oas.mode === "response"` | ||
| ) | ||
| const apiContext = _`(${N.this} && ${N.this}.apiContext)` | ||
| cxt.fail(_`${apiContext} === "response"`) | ||
| }, | ||
@@ -29,0 +22,0 @@ } |
+1
-1
| { | ||
| "name": "@redocly/ajv", | ||
| "version": "8.17.3", | ||
| "version": "8.17.4", | ||
| "description": "Another JSON Schema Validator", | ||
@@ -5,0 +5,0 @@ "main": "dist/ajv.js", |
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 2 instances
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
1082209
2.06%496
3.77%21092
3.06%3
50%