@spotlightjs/spotlight 4.11.4 → 4.11.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/ajv.js +6 -3
- package/dist/_virtual/ajv2.js +13 -0
- package/dist/_virtual/index.js +6 -3
- package/dist/_virtual/index10.js +3 -3
- package/dist/_virtual/index11.js +3 -3
- package/dist/_virtual/index12.js +13 -0
- package/dist/_virtual/index2.js +3 -3
- package/dist/_virtual/index3.js +3 -3
- package/dist/_virtual/index4.js +3 -3
- package/dist/_virtual/index5.js +3 -3
- package/dist/_virtual/index6.js +3 -3
- package/dist/_virtual/index7.js +3 -3
- package/dist/_virtual/index8.js +3 -3
- package/dist/_virtual/index9.js +3 -3
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js +1 -1
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js.map +1 -1
- package/dist/node_modules/.pnpm/@modelcontextprotocol_sdk@1.27.1_zod@4.1.13/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js +3 -3
- package/dist/node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/formats.js +203 -194
- package/dist/node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/formats.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/index.js +47 -47
- package/dist/node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/index.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/limit.js +77 -69
- package/dist/node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/limit.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/ajv.js +78 -81
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/ajv.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/code.js +145 -136
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/code.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/index.js +692 -685
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/index.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/scope.js +143 -135
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/scope.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/errors.js +122 -116
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/errors.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/index.js +216 -214
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/index.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/names.js +43 -35
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/names.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/ref_error.js +19 -11
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/ref_error.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/resolve.js +149 -144
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/resolve.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/rules.js +31 -25
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/rules.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/util.js +164 -160
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/util.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/applicability.js +23 -17
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/applicability.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/boolSchema.js +7 -10
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/boolSchema.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/dataType.js +174 -173
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/dataType.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/defaults.js +5 -7
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/defaults.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/index.js +21 -28
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/index.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/keyword.js +11 -15
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/keyword.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/subschema.js +5 -7
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/subschema.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.js +571 -570
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/refs/data.json.js +3 -17
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/refs/data.json.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/refs/json-schema-draft-07.json.js +4 -236
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/refs/json-schema-draft-07.json.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/equal.js +16 -7
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/equal.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/ucs2length.js +27 -18
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/ucs2length.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/uri.js +16 -7
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/uri.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/validation_error.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +55 -48
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +104 -99
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/allOf.js +30 -22
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/allOf.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +20 -12
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/anyOf.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/contains.js +95 -88
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/contains.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +94 -88
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/dependencies.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/if.js +71 -64
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/if.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/index.js +67 -74
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/index.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/items.js +60 -54
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/items.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/items2020.js +41 -36
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/items2020.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/not.js +34 -26
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/not.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +60 -53
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/oneOf.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +73 -67
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +20 -12
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/properties.js +61 -55
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/properties.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +46 -39
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +21 -13
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/thenElse.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/code.js +132 -129
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/code.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/id.js +17 -8
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/id.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/index.js +27 -20
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/index.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/ref.js +121 -118
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/ref.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/discriminator/index.js +104 -100
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/discriminator/index.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/discriminator/types.js +15 -9
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/discriminator/types.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/draft7.js +30 -26
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/draft7.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/format/format.js +84 -76
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/format/format.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/format/index.js +16 -8
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/format/index.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/metadata.js +24 -18
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/metadata.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/const.js +33 -27
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/const.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/enum.js +53 -47
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/enum.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/index.js +52 -53
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/index.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitItems.js +32 -24
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitItems.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitLength.js +37 -31
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitLength.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +35 -27
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitNumber.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +32 -24
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitProperties.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +31 -23
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/multipleOf.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/pattern.js +41 -35
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/pattern.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/required.js +80 -74
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/required.js.map +1 -1
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +71 -66
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js.map +1 -1
- package/dist/node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js +34 -27
- package/dist/node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js.map +1 -1
- package/dist/node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/index.js +250 -245
- package/dist/node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/index.js.map +1 -1
- package/dist/node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/lib/schemes.js +201 -175
- package/dist/node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/lib/schemes.js.map +1 -1
- package/dist/node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/lib/utils.js +267 -259
- package/dist/node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/lib/utils.js.map +1 -1
- package/dist/node_modules/.pnpm/json-schema-traverse@1.0.0/node_modules/json-schema-traverse/index.js +83 -78
- package/dist/node_modules/.pnpm/json-schema-traverse@1.0.0/node_modules/json-schema-traverse/index.js.map +1 -1
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@4.1.13/node_modules/zod-to-json-schema/dist/esm/Options.js +1 -1
- package/dist/node_modules/.pnpm/zod-to-json-schema@3.25.1_zod@4.1.13/node_modules/zod-to-json-schema/dist/esm/Options.js.map +1 -1
- package/dist/node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/core/util.js +1 -1
- package/dist/node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/core/util.js.map +1 -1
- package/dist/sentry-config.js +2 -2
- package/dist/server/cli/run.js +2 -2
- package/dist/server/cli.js +2 -2
- package/dist/server/mcp/mcp.js +2 -2
- package/dist/ui/assets/index.js +61 -70
- package/dist/ui/assets/index2.js +1 -1
- package/dist/ui/assets/instrumentation.js +18 -18
- package/dist/ui/assets/main.css +1 -1
- package/dist/ui/assets/main.js +1 -1
- package/dist/ui/assets/serverTimingMeta.js +23 -30
- package/package.json +4 -4
|
@@ -2,634 +2,635 @@
|
|
|
2
2
|
!(function() {
|
|
3
3
|
try {
|
|
4
4
|
var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
|
|
5
|
-
n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "
|
|
5
|
+
n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "c8f163c9-517a-47f2-904c-28e555b29a77", e._sentryDebugIdIdentifier = "sentry-dbid-c8f163c9-517a-47f2-904c-28e555b29a77");
|
|
6
6
|
} catch (e2) {
|
|
7
7
|
}
|
|
8
8
|
})();
|
|
9
9
|
import { __exports as core } from "../../../../../../_virtual/core.js";
|
|
10
10
|
import { __require as requireValidate } from "./compile/validate/index.js";
|
|
11
|
-
import "./compile/codegen/index.js";
|
|
11
|
+
import { __require as requireCodegen } from "./compile/codegen/index.js";
|
|
12
12
|
import { __require as requireValidation_error } from "./runtime/validation_error.js";
|
|
13
|
-
import "./compile/ref_error.js";
|
|
14
|
-
import "./compile/rules.js";
|
|
15
|
-
import "./compile/index.js";
|
|
16
|
-
import "./compile/resolve.js";
|
|
17
|
-
import "./compile/validate/dataType.js";
|
|
18
|
-
import "./compile/util.js";
|
|
13
|
+
import { __require as requireRef_error } from "./compile/ref_error.js";
|
|
14
|
+
import { __require as requireRules } from "./compile/rules.js";
|
|
15
|
+
import { __require as requireCompile } from "./compile/index.js";
|
|
16
|
+
import { __require as requireResolve } from "./compile/resolve.js";
|
|
17
|
+
import { __require as requireDataType } from "./compile/validate/dataType.js";
|
|
18
|
+
import { __require as requireUtil } from "./compile/util.js";
|
|
19
19
|
import require$$9 from "./refs/data.json.js";
|
|
20
|
-
import "./runtime/uri.js";
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
unknownFormats: "Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",
|
|
96
|
-
cache: "Map is used as cache, schema object as key.",
|
|
97
|
-
serialize: "Map is used as cache, schema object as key.",
|
|
98
|
-
ajvErrors: "It is default now."
|
|
99
|
-
};
|
|
100
|
-
const deprecatedOptions = {
|
|
101
|
-
ignoreKeywordsWithRef: "",
|
|
102
|
-
jsPropertySyntax: "",
|
|
103
|
-
unicode: '"minLength"/"maxLength" account for unicode characters by default.'
|
|
104
|
-
};
|
|
105
|
-
const MAX_EXPRESSION = 200;
|
|
106
|
-
function requiredOptions(o) {
|
|
107
|
-
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;
|
|
108
|
-
const s = o.strict;
|
|
109
|
-
const _optz = (_a = o.code) === null || _a === void 0 ? void 0 : _a.optimize;
|
|
110
|
-
const optimize = _optz === true || _optz === void 0 ? 1 : _optz || 0;
|
|
111
|
-
const regExp = (_c = (_b = o.code) === null || _b === void 0 ? void 0 : _b.regExp) !== null && _c !== void 0 ? _c : defaultRegExp;
|
|
112
|
-
const uriResolver = (_d = o.uriResolver) !== null && _d !== void 0 ? _d : uri_1.default;
|
|
113
|
-
return {
|
|
114
|
-
strictSchema: (_f = (_e = o.strictSchema) !== null && _e !== void 0 ? _e : s) !== null && _f !== void 0 ? _f : true,
|
|
115
|
-
strictNumbers: (_h = (_g = o.strictNumbers) !== null && _g !== void 0 ? _g : s) !== null && _h !== void 0 ? _h : true,
|
|
116
|
-
strictTypes: (_k = (_j = o.strictTypes) !== null && _j !== void 0 ? _j : s) !== null && _k !== void 0 ? _k : "log",
|
|
117
|
-
strictTuples: (_m = (_l = o.strictTuples) !== null && _l !== void 0 ? _l : s) !== null && _m !== void 0 ? _m : "log",
|
|
118
|
-
strictRequired: (_p = (_o = o.strictRequired) !== null && _o !== void 0 ? _o : s) !== null && _p !== void 0 ? _p : false,
|
|
119
|
-
code: o.code ? { ...o.code, optimize, regExp } : { optimize, regExp },
|
|
120
|
-
loopRequired: (_q = o.loopRequired) !== null && _q !== void 0 ? _q : MAX_EXPRESSION,
|
|
121
|
-
loopEnum: (_r = o.loopEnum) !== null && _r !== void 0 ? _r : MAX_EXPRESSION,
|
|
122
|
-
meta: (_s = o.meta) !== null && _s !== void 0 ? _s : true,
|
|
123
|
-
messages: (_t = o.messages) !== null && _t !== void 0 ? _t : true,
|
|
124
|
-
inlineRefs: (_u = o.inlineRefs) !== null && _u !== void 0 ? _u : true,
|
|
125
|
-
schemaId: (_v = o.schemaId) !== null && _v !== void 0 ? _v : "$id",
|
|
126
|
-
addUsedSchema: (_w = o.addUsedSchema) !== null && _w !== void 0 ? _w : true,
|
|
127
|
-
validateSchema: (_x = o.validateSchema) !== null && _x !== void 0 ? _x : true,
|
|
128
|
-
validateFormats: (_y = o.validateFormats) !== null && _y !== void 0 ? _y : true,
|
|
129
|
-
unicodeRegExp: (_z = o.unicodeRegExp) !== null && _z !== void 0 ? _z : true,
|
|
130
|
-
int32range: (_0 = o.int32range) !== null && _0 !== void 0 ? _0 : true,
|
|
131
|
-
uriResolver
|
|
20
|
+
import { __require as requireUri } from "./runtime/uri.js";
|
|
21
|
+
var hasRequiredCore;
|
|
22
|
+
function requireCore() {
|
|
23
|
+
if (hasRequiredCore) return core;
|
|
24
|
+
hasRequiredCore = 1;
|
|
25
|
+
(function(exports$1) {
|
|
26
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
27
|
+
exports$1.CodeGen = exports$1.Name = exports$1.nil = exports$1.stringify = exports$1.str = exports$1._ = exports$1.KeywordCxt = void 0;
|
|
28
|
+
var validate_1 = /* @__PURE__ */ requireValidate();
|
|
29
|
+
Object.defineProperty(exports$1, "KeywordCxt", { enumerable: true, get: function() {
|
|
30
|
+
return validate_1.KeywordCxt;
|
|
31
|
+
} });
|
|
32
|
+
var codegen_1 = /* @__PURE__ */ requireCodegen();
|
|
33
|
+
Object.defineProperty(exports$1, "_", { enumerable: true, get: function() {
|
|
34
|
+
return codegen_1._;
|
|
35
|
+
} });
|
|
36
|
+
Object.defineProperty(exports$1, "str", { enumerable: true, get: function() {
|
|
37
|
+
return codegen_1.str;
|
|
38
|
+
} });
|
|
39
|
+
Object.defineProperty(exports$1, "stringify", { enumerable: true, get: function() {
|
|
40
|
+
return codegen_1.stringify;
|
|
41
|
+
} });
|
|
42
|
+
Object.defineProperty(exports$1, "nil", { enumerable: true, get: function() {
|
|
43
|
+
return codegen_1.nil;
|
|
44
|
+
} });
|
|
45
|
+
Object.defineProperty(exports$1, "Name", { enumerable: true, get: function() {
|
|
46
|
+
return codegen_1.Name;
|
|
47
|
+
} });
|
|
48
|
+
Object.defineProperty(exports$1, "CodeGen", { enumerable: true, get: function() {
|
|
49
|
+
return codegen_1.CodeGen;
|
|
50
|
+
} });
|
|
51
|
+
const validation_error_1 = /* @__PURE__ */ requireValidation_error();
|
|
52
|
+
const ref_error_1 = /* @__PURE__ */ requireRef_error();
|
|
53
|
+
const rules_1 = /* @__PURE__ */ requireRules();
|
|
54
|
+
const compile_1 = /* @__PURE__ */ requireCompile();
|
|
55
|
+
const codegen_2 = /* @__PURE__ */ requireCodegen();
|
|
56
|
+
const resolve_1 = /* @__PURE__ */ requireResolve();
|
|
57
|
+
const dataType_1 = /* @__PURE__ */ requireDataType();
|
|
58
|
+
const util_1 = /* @__PURE__ */ requireUtil();
|
|
59
|
+
const $dataRefSchema = require$$9;
|
|
60
|
+
const uri_1 = /* @__PURE__ */ requireUri();
|
|
61
|
+
const defaultRegExp = (str, flags) => new RegExp(str, flags);
|
|
62
|
+
defaultRegExp.code = "new RegExp";
|
|
63
|
+
const META_IGNORE_OPTIONS = ["removeAdditional", "useDefaults", "coerceTypes"];
|
|
64
|
+
const EXT_SCOPE_NAMES = /* @__PURE__ */ new Set([
|
|
65
|
+
"validate",
|
|
66
|
+
"serialize",
|
|
67
|
+
"parse",
|
|
68
|
+
"wrapper",
|
|
69
|
+
"root",
|
|
70
|
+
"schema",
|
|
71
|
+
"keyword",
|
|
72
|
+
"pattern",
|
|
73
|
+
"formats",
|
|
74
|
+
"validate$data",
|
|
75
|
+
"func",
|
|
76
|
+
"obj",
|
|
77
|
+
"Error"
|
|
78
|
+
]);
|
|
79
|
+
const removedOptions = {
|
|
80
|
+
errorDataPath: "",
|
|
81
|
+
format: "`validateFormats: false` can be used instead.",
|
|
82
|
+
nullable: '"nullable" keyword is supported by default.',
|
|
83
|
+
jsonPointers: "Deprecated jsPropertySyntax can be used instead.",
|
|
84
|
+
extendRefs: "Deprecated ignoreKeywordsWithRef can be used instead.",
|
|
85
|
+
missingRefs: "Pass empty schema with $id that should be ignored to ajv.addSchema.",
|
|
86
|
+
processCode: "Use option `code: {process: (code, schemaEnv: object) => string}`",
|
|
87
|
+
sourceCode: "Use option `code: {source: true}`",
|
|
88
|
+
strictDefaults: "It is default now, see option `strict`.",
|
|
89
|
+
strictKeywords: "It is default now, see option `strict`.",
|
|
90
|
+
uniqueItems: '"uniqueItems" keyword is always validated.',
|
|
91
|
+
unknownFormats: "Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",
|
|
92
|
+
cache: "Map is used as cache, schema object as key.",
|
|
93
|
+
serialize: "Map is used as cache, schema object as key.",
|
|
94
|
+
ajvErrors: "It is default now."
|
|
132
95
|
};
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
96
|
+
const deprecatedOptions = {
|
|
97
|
+
ignoreKeywordsWithRef: "",
|
|
98
|
+
jsPropertySyntax: "",
|
|
99
|
+
unicode: '"minLength"/"maxLength" account for unicode characters by default.'
|
|
100
|
+
};
|
|
101
|
+
const MAX_EXPRESSION = 200;
|
|
102
|
+
function requiredOptions(o) {
|
|
103
|
+
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;
|
|
104
|
+
const s = o.strict;
|
|
105
|
+
const _optz = (_a = o.code) === null || _a === void 0 ? void 0 : _a.optimize;
|
|
106
|
+
const optimize = _optz === true || _optz === void 0 ? 1 : _optz || 0;
|
|
107
|
+
const regExp = (_c = (_b = o.code) === null || _b === void 0 ? void 0 : _b.regExp) !== null && _c !== void 0 ? _c : defaultRegExp;
|
|
108
|
+
const uriResolver = (_d = o.uriResolver) !== null && _d !== void 0 ? _d : uri_1.default;
|
|
109
|
+
return {
|
|
110
|
+
strictSchema: (_f = (_e = o.strictSchema) !== null && _e !== void 0 ? _e : s) !== null && _f !== void 0 ? _f : true,
|
|
111
|
+
strictNumbers: (_h = (_g = o.strictNumbers) !== null && _g !== void 0 ? _g : s) !== null && _h !== void 0 ? _h : true,
|
|
112
|
+
strictTypes: (_k = (_j = o.strictTypes) !== null && _j !== void 0 ? _j : s) !== null && _k !== void 0 ? _k : "log",
|
|
113
|
+
strictTuples: (_m = (_l = o.strictTuples) !== null && _l !== void 0 ? _l : s) !== null && _m !== void 0 ? _m : "log",
|
|
114
|
+
strictRequired: (_p = (_o = o.strictRequired) !== null && _o !== void 0 ? _o : s) !== null && _p !== void 0 ? _p : false,
|
|
115
|
+
code: o.code ? { ...o.code, optimize, regExp } : { optimize, regExp },
|
|
116
|
+
loopRequired: (_q = o.loopRequired) !== null && _q !== void 0 ? _q : MAX_EXPRESSION,
|
|
117
|
+
loopEnum: (_r = o.loopEnum) !== null && _r !== void 0 ? _r : MAX_EXPRESSION,
|
|
118
|
+
meta: (_s = o.meta) !== null && _s !== void 0 ? _s : true,
|
|
119
|
+
messages: (_t = o.messages) !== null && _t !== void 0 ? _t : true,
|
|
120
|
+
inlineRefs: (_u = o.inlineRefs) !== null && _u !== void 0 ? _u : true,
|
|
121
|
+
schemaId: (_v = o.schemaId) !== null && _v !== void 0 ? _v : "$id",
|
|
122
|
+
addUsedSchema: (_w = o.addUsedSchema) !== null && _w !== void 0 ? _w : true,
|
|
123
|
+
validateSchema: (_x = o.validateSchema) !== null && _x !== void 0 ? _x : true,
|
|
124
|
+
validateFormats: (_y = o.validateFormats) !== null && _y !== void 0 ? _y : true,
|
|
125
|
+
unicodeRegExp: (_z = o.unicodeRegExp) !== null && _z !== void 0 ? _z : true,
|
|
126
|
+
int32range: (_0 = o.int32range) !== null && _0 !== void 0 ? _0 : true,
|
|
127
|
+
uriResolver
|
|
128
|
+
};
|
|
165
129
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
130
|
+
class Ajv {
|
|
131
|
+
constructor(opts = {}) {
|
|
132
|
+
this.schemas = {};
|
|
133
|
+
this.refs = {};
|
|
134
|
+
this.formats = {};
|
|
135
|
+
this._compilations = /* @__PURE__ */ new Set();
|
|
136
|
+
this._loading = {};
|
|
137
|
+
this._cache = /* @__PURE__ */ new Map();
|
|
138
|
+
opts = this.opts = { ...opts, ...requiredOptions(opts) };
|
|
139
|
+
const { es5, lines } = this.opts.code;
|
|
140
|
+
this.scope = new codegen_2.ValueScope({ scope: {}, prefixes: EXT_SCOPE_NAMES, es5, lines });
|
|
141
|
+
this.logger = getLogger(opts.logger);
|
|
142
|
+
const formatOpt = opts.validateFormats;
|
|
143
|
+
opts.validateFormats = false;
|
|
144
|
+
this.RULES = (0, rules_1.getRules)();
|
|
145
|
+
checkOptions.call(this, removedOptions, opts, "NOT SUPPORTED");
|
|
146
|
+
checkOptions.call(this, deprecatedOptions, opts, "DEPRECATED", "warn");
|
|
147
|
+
this._metaOpts = getMetaSchemaOptions.call(this);
|
|
148
|
+
if (opts.formats)
|
|
149
|
+
addInitialFormats.call(this);
|
|
150
|
+
this._addVocabularies();
|
|
151
|
+
this._addDefaultMetaSchema();
|
|
152
|
+
if (opts.keywords)
|
|
153
|
+
addInitialKeywords.call(this, opts.keywords);
|
|
154
|
+
if (typeof opts.meta == "object")
|
|
155
|
+
this.addMetaSchema(opts.meta);
|
|
156
|
+
addInitialSchemas.call(this);
|
|
157
|
+
opts.validateFormats = formatOpt;
|
|
173
158
|
}
|
|
174
|
-
|
|
175
|
-
this.
|
|
176
|
-
}
|
|
177
|
-
defaultMeta() {
|
|
178
|
-
const { meta, schemaId } = this.opts;
|
|
179
|
-
return this.opts.defaultMeta = typeof meta == "object" ? meta[schemaId] || meta : void 0;
|
|
180
|
-
}
|
|
181
|
-
validate(schemaKeyRef, data) {
|
|
182
|
-
let v;
|
|
183
|
-
if (typeof schemaKeyRef == "string") {
|
|
184
|
-
v = this.getSchema(schemaKeyRef);
|
|
185
|
-
if (!v)
|
|
186
|
-
throw new Error(`no schema with key or ref "${schemaKeyRef}"`);
|
|
187
|
-
} else {
|
|
188
|
-
v = this.compile(schemaKeyRef);
|
|
159
|
+
_addVocabularies() {
|
|
160
|
+
this.addKeyword("$async");
|
|
189
161
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
if (typeof this.opts.loadSchema != "function") {
|
|
201
|
-
throw new Error("options.loadSchema should be a function");
|
|
162
|
+
_addDefaultMetaSchema() {
|
|
163
|
+
const { $data, meta, schemaId } = this.opts;
|
|
164
|
+
let _dataRefSchema = $dataRefSchema;
|
|
165
|
+
if (schemaId === "id") {
|
|
166
|
+
_dataRefSchema = { ...$dataRefSchema };
|
|
167
|
+
_dataRefSchema.id = _dataRefSchema.$id;
|
|
168
|
+
delete _dataRefSchema.$id;
|
|
169
|
+
}
|
|
170
|
+
if (meta && $data)
|
|
171
|
+
this.addMetaSchema(_dataRefSchema, _dataRefSchema[schemaId], false);
|
|
202
172
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
await loadMetaSchema.call(this, _schema.$schema);
|
|
207
|
-
const sch = this._addSchema(_schema, _meta);
|
|
208
|
-
return sch.validate || _compileAsync.call(this, sch);
|
|
173
|
+
defaultMeta() {
|
|
174
|
+
const { meta, schemaId } = this.opts;
|
|
175
|
+
return this.opts.defaultMeta = typeof meta == "object" ? meta[schemaId] || meta : void 0;
|
|
209
176
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
177
|
+
validate(schemaKeyRef, data) {
|
|
178
|
+
let v;
|
|
179
|
+
if (typeof schemaKeyRef == "string") {
|
|
180
|
+
v = this.getSchema(schemaKeyRef);
|
|
181
|
+
if (!v)
|
|
182
|
+
throw new Error(`no schema with key or ref "${schemaKeyRef}"`);
|
|
183
|
+
} else {
|
|
184
|
+
v = this.compile(schemaKeyRef);
|
|
213
185
|
}
|
|
186
|
+
const valid = v(data);
|
|
187
|
+
if (!("$async" in v))
|
|
188
|
+
this.errors = v.errors;
|
|
189
|
+
return valid;
|
|
214
190
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
} catch (e) {
|
|
219
|
-
if (!(e instanceof ref_error_1.default))
|
|
220
|
-
throw e;
|
|
221
|
-
checkLoaded.call(this, e);
|
|
222
|
-
await loadMissingSchema.call(this, e.missingSchema);
|
|
223
|
-
return _compileAsync.call(this, sch);
|
|
224
|
-
}
|
|
191
|
+
compile(schema, _meta) {
|
|
192
|
+
const sch = this._addSchema(schema, _meta);
|
|
193
|
+
return sch.validate || this._compileSchemaEnv(sch);
|
|
225
194
|
}
|
|
226
|
-
|
|
227
|
-
if (this.
|
|
228
|
-
throw new Error(
|
|
195
|
+
compileAsync(schema, meta) {
|
|
196
|
+
if (typeof this.opts.loadSchema != "function") {
|
|
197
|
+
throw new Error("options.loadSchema should be a function");
|
|
229
198
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
if (!this.refs[ref])
|
|
199
|
+
const { loadSchema } = this.opts;
|
|
200
|
+
return runCompileAsync.call(this, schema, meta);
|
|
201
|
+
async function runCompileAsync(_schema, _meta) {
|
|
234
202
|
await loadMetaSchema.call(this, _schema.$schema);
|
|
235
|
-
|
|
236
|
-
|
|
203
|
+
const sch = this._addSchema(_schema, _meta);
|
|
204
|
+
return sch.validate || _compileAsync.call(this, sch);
|
|
205
|
+
}
|
|
206
|
+
async function loadMetaSchema($ref) {
|
|
207
|
+
if ($ref && !this.getSchema($ref)) {
|
|
208
|
+
await runCompileAsync.call(this, { $ref }, true);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
async function _compileAsync(sch) {
|
|
212
|
+
try {
|
|
213
|
+
return this._compileSchemaEnv(sch);
|
|
214
|
+
} catch (e) {
|
|
215
|
+
if (!(e instanceof ref_error_1.default))
|
|
216
|
+
throw e;
|
|
217
|
+
checkLoaded.call(this, e);
|
|
218
|
+
await loadMissingSchema.call(this, e.missingSchema);
|
|
219
|
+
return _compileAsync.call(this, sch);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
function checkLoaded({ missingSchema: ref, missingRef }) {
|
|
223
|
+
if (this.refs[ref]) {
|
|
224
|
+
throw new Error(`AnySchema ${ref} is loaded but ${missingRef} cannot be resolved`);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
async function loadMissingSchema(ref) {
|
|
228
|
+
const _schema = await _loadSchema.call(this, ref);
|
|
229
|
+
if (!this.refs[ref])
|
|
230
|
+
await loadMetaSchema.call(this, _schema.$schema);
|
|
231
|
+
if (!this.refs[ref])
|
|
232
|
+
this.addSchema(_schema, ref, meta);
|
|
233
|
+
}
|
|
234
|
+
async function _loadSchema(ref) {
|
|
235
|
+
const p = this._loading[ref];
|
|
236
|
+
if (p)
|
|
237
|
+
return p;
|
|
238
|
+
try {
|
|
239
|
+
return await (this._loading[ref] = loadSchema(ref));
|
|
240
|
+
} finally {
|
|
241
|
+
delete this._loading[ref];
|
|
242
|
+
}
|
|
243
|
+
}
|
|
237
244
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
if (
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
return
|
|
244
|
-
} finally {
|
|
245
|
-
delete this._loading[ref];
|
|
245
|
+
// Adds schema to the instance
|
|
246
|
+
addSchema(schema, key, _meta, _validateSchema = this.opts.validateSchema) {
|
|
247
|
+
if (Array.isArray(schema)) {
|
|
248
|
+
for (const sch of schema)
|
|
249
|
+
this.addSchema(sch, void 0, _meta, _validateSchema);
|
|
250
|
+
return this;
|
|
246
251
|
}
|
|
252
|
+
let id;
|
|
253
|
+
if (typeof schema === "object") {
|
|
254
|
+
const { schemaId } = this.opts;
|
|
255
|
+
id = schema[schemaId];
|
|
256
|
+
if (id !== void 0 && typeof id != "string") {
|
|
257
|
+
throw new Error(`schema ${schemaId} must be string`);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
key = (0, resolve_1.normalizeId)(key || id);
|
|
261
|
+
this._checkUnique(key);
|
|
262
|
+
this.schemas[key] = this._addSchema(schema, _meta, key, _validateSchema, true);
|
|
263
|
+
return this;
|
|
247
264
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
for (const sch of schema)
|
|
253
|
-
this.addSchema(sch, void 0, _meta, _validateSchema);
|
|
265
|
+
// Add schema that will be used to validate other schemas
|
|
266
|
+
// options in META_IGNORE_OPTIONS are alway set to false
|
|
267
|
+
addMetaSchema(schema, key, _validateSchema = this.opts.validateSchema) {
|
|
268
|
+
this.addSchema(schema, key, true, _validateSchema);
|
|
254
269
|
return this;
|
|
255
270
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
271
|
+
// Validate schema against its meta-schema
|
|
272
|
+
validateSchema(schema, throwOrLogError) {
|
|
273
|
+
if (typeof schema == "boolean")
|
|
274
|
+
return true;
|
|
275
|
+
let $schema;
|
|
276
|
+
$schema = schema.$schema;
|
|
277
|
+
if ($schema !== void 0 && typeof $schema != "string") {
|
|
278
|
+
throw new Error("$schema must be a string");
|
|
262
279
|
}
|
|
280
|
+
$schema = $schema || this.opts.defaultMeta || this.defaultMeta();
|
|
281
|
+
if (!$schema) {
|
|
282
|
+
this.logger.warn("meta-schema not available");
|
|
283
|
+
this.errors = null;
|
|
284
|
+
return true;
|
|
285
|
+
}
|
|
286
|
+
const valid = this.validate($schema, schema);
|
|
287
|
+
if (!valid && throwOrLogError) {
|
|
288
|
+
const message = "schema is invalid: " + this.errorsText();
|
|
289
|
+
if (this.opts.validateSchema === "log")
|
|
290
|
+
this.logger.error(message);
|
|
291
|
+
else
|
|
292
|
+
throw new Error(message);
|
|
293
|
+
}
|
|
294
|
+
return valid;
|
|
263
295
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
return
|
|
279
|
-
let $schema;
|
|
280
|
-
$schema = schema.$schema;
|
|
281
|
-
if ($schema !== void 0 && typeof $schema != "string") {
|
|
282
|
-
throw new Error("$schema must be a string");
|
|
283
|
-
}
|
|
284
|
-
$schema = $schema || this.opts.defaultMeta || this.defaultMeta();
|
|
285
|
-
if (!$schema) {
|
|
286
|
-
this.logger.warn("meta-schema not available");
|
|
287
|
-
this.errors = null;
|
|
288
|
-
return true;
|
|
289
|
-
}
|
|
290
|
-
const valid = this.validate($schema, schema);
|
|
291
|
-
if (!valid && throwOrLogError) {
|
|
292
|
-
const message = "schema is invalid: " + this.errorsText();
|
|
293
|
-
if (this.opts.validateSchema === "log")
|
|
294
|
-
this.logger.error(message);
|
|
295
|
-
else
|
|
296
|
-
throw new Error(message);
|
|
296
|
+
// Get compiled schema by `key` or `ref`.
|
|
297
|
+
// (`key` that was passed to `addSchema` or full schema reference - `schema.$id` or resolved id)
|
|
298
|
+
getSchema(keyRef) {
|
|
299
|
+
let sch;
|
|
300
|
+
while (typeof (sch = getSchEnv.call(this, keyRef)) == "string")
|
|
301
|
+
keyRef = sch;
|
|
302
|
+
if (sch === void 0) {
|
|
303
|
+
const { schemaId } = this.opts;
|
|
304
|
+
const root = new compile_1.SchemaEnv({ schema: {}, schemaId });
|
|
305
|
+
sch = compile_1.resolveSchema.call(this, root, keyRef);
|
|
306
|
+
if (!sch)
|
|
307
|
+
return;
|
|
308
|
+
this.refs[keyRef] = sch;
|
|
309
|
+
}
|
|
310
|
+
return sch.validate || this._compileSchemaEnv(sch);
|
|
297
311
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
312
|
+
// Remove cached schema(s).
|
|
313
|
+
// If no parameter is passed all schemas but meta-schemas are removed.
|
|
314
|
+
// If RegExp is passed all schemas with key/id matching pattern but meta-schemas are removed.
|
|
315
|
+
// Even if schema is referenced by other schemas it still can be removed as other schemas have local references.
|
|
316
|
+
removeSchema(schemaKeyRef) {
|
|
317
|
+
if (schemaKeyRef instanceof RegExp) {
|
|
318
|
+
this._removeAllSchemas(this.schemas, schemaKeyRef);
|
|
319
|
+
this._removeAllSchemas(this.refs, schemaKeyRef);
|
|
320
|
+
return this;
|
|
321
|
+
}
|
|
322
|
+
switch (typeof schemaKeyRef) {
|
|
323
|
+
case "undefined":
|
|
324
|
+
this._removeAllSchemas(this.schemas);
|
|
325
|
+
this._removeAllSchemas(this.refs);
|
|
326
|
+
this._cache.clear();
|
|
327
|
+
return this;
|
|
328
|
+
case "string": {
|
|
329
|
+
const sch = getSchEnv.call(this, schemaKeyRef);
|
|
330
|
+
if (typeof sch == "object")
|
|
331
|
+
this._cache.delete(sch.schema);
|
|
332
|
+
delete this.schemas[schemaKeyRef];
|
|
333
|
+
delete this.refs[schemaKeyRef];
|
|
334
|
+
return this;
|
|
335
|
+
}
|
|
336
|
+
case "object": {
|
|
337
|
+
const cacheKey = schemaKeyRef;
|
|
338
|
+
this._cache.delete(cacheKey);
|
|
339
|
+
let id = schemaKeyRef[this.opts.schemaId];
|
|
340
|
+
if (id) {
|
|
341
|
+
id = (0, resolve_1.normalizeId)(id);
|
|
342
|
+
delete this.schemas[id];
|
|
343
|
+
delete this.refs[id];
|
|
344
|
+
}
|
|
345
|
+
return this;
|
|
346
|
+
}
|
|
347
|
+
default:
|
|
348
|
+
throw new Error("ajv.removeSchema: invalid parameter");
|
|
349
|
+
}
|
|
313
350
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
// If RegExp is passed all schemas with key/id matching pattern but meta-schemas are removed.
|
|
319
|
-
// Even if schema is referenced by other schemas it still can be removed as other schemas have local references.
|
|
320
|
-
removeSchema(schemaKeyRef) {
|
|
321
|
-
if (schemaKeyRef instanceof RegExp) {
|
|
322
|
-
this._removeAllSchemas(this.schemas, schemaKeyRef);
|
|
323
|
-
this._removeAllSchemas(this.refs, schemaKeyRef);
|
|
351
|
+
// add "vocabulary" - a collection of keywords
|
|
352
|
+
addVocabulary(definitions) {
|
|
353
|
+
for (const def of definitions)
|
|
354
|
+
this.addKeyword(def);
|
|
324
355
|
return this;
|
|
325
356
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
const sch = getSchEnv.call(this, schemaKeyRef);
|
|
334
|
-
if (typeof sch == "object")
|
|
335
|
-
this._cache.delete(sch.schema);
|
|
336
|
-
delete this.schemas[schemaKeyRef];
|
|
337
|
-
delete this.refs[schemaKeyRef];
|
|
338
|
-
return this;
|
|
339
|
-
}
|
|
340
|
-
case "object": {
|
|
341
|
-
const cacheKey = schemaKeyRef;
|
|
342
|
-
this._cache.delete(cacheKey);
|
|
343
|
-
let id = schemaKeyRef[this.opts.schemaId];
|
|
344
|
-
if (id) {
|
|
345
|
-
id = (0, resolve_1.normalizeId)(id);
|
|
346
|
-
delete this.schemas[id];
|
|
347
|
-
delete this.refs[id];
|
|
357
|
+
addKeyword(kwdOrDef, def) {
|
|
358
|
+
let keyword;
|
|
359
|
+
if (typeof kwdOrDef == "string") {
|
|
360
|
+
keyword = kwdOrDef;
|
|
361
|
+
if (typeof def == "object") {
|
|
362
|
+
this.logger.warn("these parameters are deprecated, see docs for addKeyword");
|
|
363
|
+
def.keyword = keyword;
|
|
348
364
|
}
|
|
365
|
+
} else if (typeof kwdOrDef == "object" && def === void 0) {
|
|
366
|
+
def = kwdOrDef;
|
|
367
|
+
keyword = def.keyword;
|
|
368
|
+
if (Array.isArray(keyword) && !keyword.length) {
|
|
369
|
+
throw new Error("addKeywords: keyword must be string or non-empty array");
|
|
370
|
+
}
|
|
371
|
+
} else {
|
|
372
|
+
throw new Error("invalid addKeywords parameters");
|
|
373
|
+
}
|
|
374
|
+
checkKeyword.call(this, keyword, def);
|
|
375
|
+
if (!def) {
|
|
376
|
+
(0, util_1.eachItem)(keyword, (kwd) => addRule.call(this, kwd));
|
|
349
377
|
return this;
|
|
350
378
|
}
|
|
351
|
-
|
|
352
|
-
|
|
379
|
+
keywordMetaschema.call(this, def);
|
|
380
|
+
const definition = {
|
|
381
|
+
...def,
|
|
382
|
+
type: (0, dataType_1.getJSONTypes)(def.type),
|
|
383
|
+
schemaType: (0, dataType_1.getJSONTypes)(def.schemaType)
|
|
384
|
+
};
|
|
385
|
+
(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)));
|
|
386
|
+
return this;
|
|
353
387
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
def.keyword = keyword;
|
|
368
|
-
}
|
|
369
|
-
} else if (typeof kwdOrDef == "object" && def === void 0) {
|
|
370
|
-
def = kwdOrDef;
|
|
371
|
-
keyword = def.keyword;
|
|
372
|
-
if (Array.isArray(keyword) && !keyword.length) {
|
|
373
|
-
throw new Error("addKeywords: keyword must be string or non-empty array");
|
|
388
|
+
getKeyword(keyword) {
|
|
389
|
+
const rule = this.RULES.all[keyword];
|
|
390
|
+
return typeof rule == "object" ? rule.definition : !!rule;
|
|
391
|
+
}
|
|
392
|
+
// Remove keyword
|
|
393
|
+
removeKeyword(keyword) {
|
|
394
|
+
const { RULES } = this;
|
|
395
|
+
delete RULES.keywords[keyword];
|
|
396
|
+
delete RULES.all[keyword];
|
|
397
|
+
for (const group of RULES.rules) {
|
|
398
|
+
const i = group.rules.findIndex((rule) => rule.keyword === keyword);
|
|
399
|
+
if (i >= 0)
|
|
400
|
+
group.rules.splice(i, 1);
|
|
374
401
|
}
|
|
375
|
-
|
|
376
|
-
throw new Error("invalid addKeywords parameters");
|
|
402
|
+
return this;
|
|
377
403
|
}
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
404
|
+
// Add format
|
|
405
|
+
addFormat(name, format) {
|
|
406
|
+
if (typeof format == "string")
|
|
407
|
+
format = new RegExp(format);
|
|
408
|
+
this.formats[name] = format;
|
|
381
409
|
return this;
|
|
382
410
|
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
schemaType: (0, dataType_1.getJSONTypes)(def.schemaType)
|
|
388
|
-
};
|
|
389
|
-
(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)));
|
|
390
|
-
return this;
|
|
391
|
-
}
|
|
392
|
-
getKeyword(keyword) {
|
|
393
|
-
const rule = this.RULES.all[keyword];
|
|
394
|
-
return typeof rule == "object" ? rule.definition : !!rule;
|
|
395
|
-
}
|
|
396
|
-
// Remove keyword
|
|
397
|
-
removeKeyword(keyword) {
|
|
398
|
-
const { RULES } = this;
|
|
399
|
-
delete RULES.keywords[keyword];
|
|
400
|
-
delete RULES.all[keyword];
|
|
401
|
-
for (const group of RULES.rules) {
|
|
402
|
-
const i = group.rules.findIndex((rule) => rule.keyword === keyword);
|
|
403
|
-
if (i >= 0)
|
|
404
|
-
group.rules.splice(i, 1);
|
|
411
|
+
errorsText(errors = this.errors, { separator = ", ", dataVar = "data" } = {}) {
|
|
412
|
+
if (!errors || errors.length === 0)
|
|
413
|
+
return "No errors";
|
|
414
|
+
return errors.map((e) => `${dataVar}${e.instancePath} ${e.message}`).reduce((text, msg) => text + separator + msg);
|
|
405
415
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
for (const jsonPointer of keywordsJsonPointers) {
|
|
424
|
-
const segments = jsonPointer.split("/").slice(1);
|
|
425
|
-
let keywords = metaSchema;
|
|
426
|
-
for (const seg of segments)
|
|
427
|
-
keywords = keywords[seg];
|
|
428
|
-
for (const key in rules2) {
|
|
429
|
-
const rule = rules2[key];
|
|
430
|
-
if (typeof rule != "object")
|
|
431
|
-
continue;
|
|
432
|
-
const { $data } = rule.definition;
|
|
433
|
-
const schema = keywords[key];
|
|
434
|
-
if ($data && schema)
|
|
435
|
-
keywords[key] = schemaOrData(schema);
|
|
416
|
+
$dataMetaSchema(metaSchema, keywordsJsonPointers) {
|
|
417
|
+
const rules = this.RULES.all;
|
|
418
|
+
metaSchema = JSON.parse(JSON.stringify(metaSchema));
|
|
419
|
+
for (const jsonPointer of keywordsJsonPointers) {
|
|
420
|
+
const segments = jsonPointer.split("/").slice(1);
|
|
421
|
+
let keywords = metaSchema;
|
|
422
|
+
for (const seg of segments)
|
|
423
|
+
keywords = keywords[seg];
|
|
424
|
+
for (const key in rules) {
|
|
425
|
+
const rule = rules[key];
|
|
426
|
+
if (typeof rule != "object")
|
|
427
|
+
continue;
|
|
428
|
+
const { $data } = rule.definition;
|
|
429
|
+
const schema = keywords[key];
|
|
430
|
+
if ($data && schema)
|
|
431
|
+
keywords[key] = schemaOrData(schema);
|
|
432
|
+
}
|
|
436
433
|
}
|
|
434
|
+
return metaSchema;
|
|
437
435
|
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
delete schemas[keyRef];
|
|
436
|
+
_removeAllSchemas(schemas, regex) {
|
|
437
|
+
for (const keyRef in schemas) {
|
|
438
|
+
const sch = schemas[keyRef];
|
|
439
|
+
if (!regex || regex.test(keyRef)) {
|
|
440
|
+
if (typeof sch == "string") {
|
|
441
|
+
delete schemas[keyRef];
|
|
442
|
+
} else if (sch && !sch.meta) {
|
|
443
|
+
this._cache.delete(sch.schema);
|
|
444
|
+
delete schemas[keyRef];
|
|
445
|
+
}
|
|
449
446
|
}
|
|
450
447
|
}
|
|
451
448
|
}
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
449
|
+
_addSchema(schema, meta, baseId, validateSchema = this.opts.validateSchema, addSchema = this.opts.addUsedSchema) {
|
|
450
|
+
let id;
|
|
451
|
+
const { schemaId } = this.opts;
|
|
452
|
+
if (typeof schema == "object") {
|
|
453
|
+
id = schema[schemaId];
|
|
454
|
+
} else {
|
|
455
|
+
if (this.opts.jtd)
|
|
456
|
+
throw new Error("schema must be object");
|
|
457
|
+
else if (typeof schema != "boolean")
|
|
458
|
+
throw new Error("schema must be object or boolean");
|
|
459
|
+
}
|
|
460
|
+
let sch = this._cache.get(schema);
|
|
461
|
+
if (sch !== void 0)
|
|
462
|
+
return sch;
|
|
463
|
+
baseId = (0, resolve_1.normalizeId)(id || baseId);
|
|
464
|
+
const localRefs = resolve_1.getSchemaRefs.call(this, schema, baseId);
|
|
465
|
+
sch = new compile_1.SchemaEnv({ schema, schemaId, meta, baseId, localRefs });
|
|
466
|
+
this._cache.set(sch.schema, sch);
|
|
467
|
+
if (addSchema && !baseId.startsWith("#")) {
|
|
468
|
+
if (baseId)
|
|
469
|
+
this._checkUnique(baseId);
|
|
470
|
+
this.refs[baseId] = sch;
|
|
471
|
+
}
|
|
472
|
+
if (validateSchema)
|
|
473
|
+
this.validateSchema(schema, true);
|
|
466
474
|
return sch;
|
|
467
|
-
baseId = (0, resolve_1.normalizeId)(id || baseId);
|
|
468
|
-
const localRefs = resolve_1.getSchemaRefs.call(this, schema, baseId);
|
|
469
|
-
sch = new compile_1.SchemaEnv({ schema, schemaId, meta, baseId, localRefs });
|
|
470
|
-
this._cache.set(sch.schema, sch);
|
|
471
|
-
if (addSchema && !baseId.startsWith("#")) {
|
|
472
|
-
if (baseId)
|
|
473
|
-
this._checkUnique(baseId);
|
|
474
|
-
this.refs[baseId] = sch;
|
|
475
475
|
}
|
|
476
|
-
|
|
477
|
-
this.
|
|
478
|
-
|
|
476
|
+
_checkUnique(id) {
|
|
477
|
+
if (this.schemas[id] || this.refs[id]) {
|
|
478
|
+
throw new Error(`schema with key or id "${id}" already exists`);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
_compileSchemaEnv(sch) {
|
|
482
|
+
if (sch.meta)
|
|
483
|
+
this._compileMetaSchema(sch);
|
|
484
|
+
else
|
|
485
|
+
compile_1.compileSchema.call(this, sch);
|
|
486
|
+
if (!sch.validate)
|
|
487
|
+
throw new Error("ajv implementation error");
|
|
488
|
+
return sch.validate;
|
|
489
|
+
}
|
|
490
|
+
_compileMetaSchema(sch) {
|
|
491
|
+
const currentOpts = this.opts;
|
|
492
|
+
this.opts = this._metaOpts;
|
|
493
|
+
try {
|
|
494
|
+
compile_1.compileSchema.call(this, sch);
|
|
495
|
+
} finally {
|
|
496
|
+
this.opts = currentOpts;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
479
499
|
}
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
500
|
+
Ajv.ValidationError = validation_error_1.default;
|
|
501
|
+
Ajv.MissingRefError = ref_error_1.default;
|
|
502
|
+
exports$1.default = Ajv;
|
|
503
|
+
function checkOptions(checkOpts, options, msg, log = "error") {
|
|
504
|
+
for (const key in checkOpts) {
|
|
505
|
+
const opt = key;
|
|
506
|
+
if (opt in options)
|
|
507
|
+
this.logger[log](`${msg}: option ${key}. ${checkOpts[opt]}`);
|
|
483
508
|
}
|
|
484
509
|
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
510
|
+
function getSchEnv(keyRef) {
|
|
511
|
+
keyRef = (0, resolve_1.normalizeId)(keyRef);
|
|
512
|
+
return this.schemas[keyRef] || this.refs[keyRef];
|
|
513
|
+
}
|
|
514
|
+
function addInitialSchemas() {
|
|
515
|
+
const optsSchemas = this.opts.schemas;
|
|
516
|
+
if (!optsSchemas)
|
|
517
|
+
return;
|
|
518
|
+
if (Array.isArray(optsSchemas))
|
|
519
|
+
this.addSchema(optsSchemas);
|
|
488
520
|
else
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
throw new Error("ajv implementation error");
|
|
492
|
-
return sch.validate;
|
|
521
|
+
for (const key in optsSchemas)
|
|
522
|
+
this.addSchema(optsSchemas[key], key);
|
|
493
523
|
}
|
|
494
|
-
|
|
495
|
-
const
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
} finally {
|
|
500
|
-
this.opts = currentOpts;
|
|
524
|
+
function addInitialFormats() {
|
|
525
|
+
for (const name in this.opts.formats) {
|
|
526
|
+
const format = this.opts.formats[name];
|
|
527
|
+
if (format)
|
|
528
|
+
this.addFormat(name, format);
|
|
501
529
|
}
|
|
502
530
|
}
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
const
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
keyRef = (0, resolve_1.normalizeId)(keyRef);
|
|
516
|
-
return this.schemas[keyRef] || this.refs[keyRef];
|
|
517
|
-
}
|
|
518
|
-
function addInitialSchemas() {
|
|
519
|
-
const optsSchemas = this.opts.schemas;
|
|
520
|
-
if (!optsSchemas)
|
|
521
|
-
return;
|
|
522
|
-
if (Array.isArray(optsSchemas))
|
|
523
|
-
this.addSchema(optsSchemas);
|
|
524
|
-
else
|
|
525
|
-
for (const key in optsSchemas)
|
|
526
|
-
this.addSchema(optsSchemas[key], key);
|
|
527
|
-
}
|
|
528
|
-
function addInitialFormats() {
|
|
529
|
-
for (const name in this.opts.formats) {
|
|
530
|
-
const format = this.opts.formats[name];
|
|
531
|
-
if (format)
|
|
532
|
-
this.addFormat(name, format);
|
|
531
|
+
function addInitialKeywords(defs) {
|
|
532
|
+
if (Array.isArray(defs)) {
|
|
533
|
+
this.addVocabulary(defs);
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
this.logger.warn("keywords option as map is deprecated, pass array");
|
|
537
|
+
for (const keyword in defs) {
|
|
538
|
+
const def = defs[keyword];
|
|
539
|
+
if (!def.keyword)
|
|
540
|
+
def.keyword = keyword;
|
|
541
|
+
this.addKeyword(def);
|
|
542
|
+
}
|
|
533
543
|
}
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
return;
|
|
544
|
+
function getMetaSchemaOptions() {
|
|
545
|
+
const metaOpts = { ...this.opts };
|
|
546
|
+
for (const opt of META_IGNORE_OPTIONS)
|
|
547
|
+
delete metaOpts[opt];
|
|
548
|
+
return metaOpts;
|
|
539
549
|
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
550
|
+
const noLogs = { log() {
|
|
551
|
+
}, warn() {
|
|
552
|
+
}, error() {
|
|
553
|
+
} };
|
|
554
|
+
function getLogger(logger) {
|
|
555
|
+
if (logger === false)
|
|
556
|
+
return noLogs;
|
|
557
|
+
if (logger === void 0)
|
|
558
|
+
return console;
|
|
559
|
+
if (logger.log && logger.warn && logger.error)
|
|
560
|
+
return logger;
|
|
561
|
+
throw new Error("logger must implement log, warn and error methods");
|
|
546
562
|
}
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
if (logger === void 0)
|
|
562
|
-
return console;
|
|
563
|
-
if (logger.log && logger.warn && logger.error)
|
|
564
|
-
return logger;
|
|
565
|
-
throw new Error("logger must implement log, warn and error methods");
|
|
566
|
-
}
|
|
567
|
-
const KEYWORD_NAME = /^[a-z_$][a-z0-9_$:-]*$/i;
|
|
568
|
-
function checkKeyword(keyword, def) {
|
|
569
|
-
const { RULES } = this;
|
|
570
|
-
(0, util_1.eachItem)(keyword, (kwd) => {
|
|
571
|
-
if (RULES.keywords[kwd])
|
|
572
|
-
throw new Error(`Keyword ${kwd} is already defined`);
|
|
573
|
-
if (!KEYWORD_NAME.test(kwd))
|
|
574
|
-
throw new Error(`Keyword ${kwd} has invalid name`);
|
|
575
|
-
});
|
|
576
|
-
if (!def)
|
|
577
|
-
return;
|
|
578
|
-
if (def.$data && !("code" in def || "validate" in def)) {
|
|
579
|
-
throw new Error('$data keyword must have "code" or "validate" function');
|
|
563
|
+
const KEYWORD_NAME = /^[a-z_$][a-z0-9_$:-]*$/i;
|
|
564
|
+
function checkKeyword(keyword, def) {
|
|
565
|
+
const { RULES } = this;
|
|
566
|
+
(0, util_1.eachItem)(keyword, (kwd) => {
|
|
567
|
+
if (RULES.keywords[kwd])
|
|
568
|
+
throw new Error(`Keyword ${kwd} is already defined`);
|
|
569
|
+
if (!KEYWORD_NAME.test(kwd))
|
|
570
|
+
throw new Error(`Keyword ${kwd} has invalid name`);
|
|
571
|
+
});
|
|
572
|
+
if (!def)
|
|
573
|
+
return;
|
|
574
|
+
if (def.$data && !("code" in def || "validate" in def)) {
|
|
575
|
+
throw new Error('$data keyword must have "code" or "validate" function');
|
|
576
|
+
}
|
|
580
577
|
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
578
|
+
function addRule(keyword, definition, dataType) {
|
|
579
|
+
var _a;
|
|
580
|
+
const post = definition === null || definition === void 0 ? void 0 : definition.post;
|
|
581
|
+
if (dataType && post)
|
|
582
|
+
throw new Error('keyword with "post" flag cannot have "type"');
|
|
583
|
+
const { RULES } = this;
|
|
584
|
+
let ruleGroup = post ? RULES.post : RULES.rules.find(({ type: t }) => t === dataType);
|
|
585
|
+
if (!ruleGroup) {
|
|
586
|
+
ruleGroup = { type: dataType, rules: [] };
|
|
587
|
+
RULES.rules.push(ruleGroup);
|
|
588
|
+
}
|
|
589
|
+
RULES.keywords[keyword] = true;
|
|
590
|
+
if (!definition)
|
|
591
|
+
return;
|
|
592
|
+
const rule = {
|
|
593
|
+
keyword,
|
|
594
|
+
definition: {
|
|
595
|
+
...definition,
|
|
596
|
+
type: (0, dataType_1.getJSONTypes)(definition.type),
|
|
597
|
+
schemaType: (0, dataType_1.getJSONTypes)(definition.schemaType)
|
|
598
|
+
}
|
|
599
|
+
};
|
|
600
|
+
if (definition.before)
|
|
601
|
+
addBeforeRule.call(this, ruleGroup, rule, definition.before);
|
|
602
|
+
else
|
|
603
|
+
ruleGroup.rules.push(rule);
|
|
604
|
+
RULES.all[keyword] = rule;
|
|
605
|
+
(_a = definition.implements) === null || _a === void 0 ? void 0 : _a.forEach((kwd) => this.addKeyword(kwd));
|
|
592
606
|
}
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
type: (0, dataType_1.getJSONTypes)(definition.type),
|
|
601
|
-
schemaType: (0, dataType_1.getJSONTypes)(definition.schemaType)
|
|
607
|
+
function addBeforeRule(ruleGroup, rule, before) {
|
|
608
|
+
const i = ruleGroup.rules.findIndex((_rule) => _rule.keyword === before);
|
|
609
|
+
if (i >= 0) {
|
|
610
|
+
ruleGroup.rules.splice(i, 0, rule);
|
|
611
|
+
} else {
|
|
612
|
+
ruleGroup.rules.push(rule);
|
|
613
|
+
this.logger.warn(`rule ${before} is not defined`);
|
|
602
614
|
}
|
|
615
|
+
}
|
|
616
|
+
function keywordMetaschema(def) {
|
|
617
|
+
let { metaSchema } = def;
|
|
618
|
+
if (metaSchema === void 0)
|
|
619
|
+
return;
|
|
620
|
+
if (def.$data && this.opts.$data)
|
|
621
|
+
metaSchema = schemaOrData(metaSchema);
|
|
622
|
+
def.validateSchema = this.compile(metaSchema, true);
|
|
623
|
+
}
|
|
624
|
+
const $dataRef = {
|
|
625
|
+
$ref: "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"
|
|
603
626
|
};
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
else
|
|
607
|
-
ruleGroup.rules.push(rule);
|
|
608
|
-
RULES.all[keyword] = rule;
|
|
609
|
-
(_a = definition.implements) === null || _a === void 0 ? void 0 : _a.forEach((kwd) => this.addKeyword(kwd));
|
|
610
|
-
}
|
|
611
|
-
function addBeforeRule(ruleGroup, rule, before) {
|
|
612
|
-
const i = ruleGroup.rules.findIndex((_rule) => _rule.keyword === before);
|
|
613
|
-
if (i >= 0) {
|
|
614
|
-
ruleGroup.rules.splice(i, 0, rule);
|
|
615
|
-
} else {
|
|
616
|
-
ruleGroup.rules.push(rule);
|
|
617
|
-
this.logger.warn(`rule ${before} is not defined`);
|
|
627
|
+
function schemaOrData(schema) {
|
|
628
|
+
return { anyOf: [schema, $dataRef] };
|
|
618
629
|
}
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
metaSchema = schemaOrData(metaSchema);
|
|
626
|
-
def.validateSchema = this.compile(metaSchema, true);
|
|
627
|
-
}
|
|
628
|
-
const $dataRef = {
|
|
629
|
-
$ref: "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"
|
|
630
|
-
};
|
|
631
|
-
function schemaOrData(schema) {
|
|
632
|
-
return { anyOf: [schema, $dataRef] };
|
|
633
|
-
}
|
|
634
|
-
})(core);
|
|
630
|
+
})(core);
|
|
631
|
+
return core;
|
|
632
|
+
}
|
|
633
|
+
export {
|
|
634
|
+
requireCore as __require
|
|
635
|
+
};
|
|
635
636
|
//# sourceMappingURL=core.js.map
|