@spotlightjs/spotlight 4.11.2 → 4.11.4
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/index.js +3 -3
- 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/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/index.js +3 -3
- package/dist/node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/limit.js +2 -2
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/ajv.js +7 -9
- 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/index.js +2 -2
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/errors.js +2 -2
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/index.js +18 -20
- 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 +2 -2
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/util.js +2 -2
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/boolSchema.js +50 -44
- 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 +2 -2
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/defaults.js +35 -29
- 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 +467 -465
- 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 +110 -104
- 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 +80 -74
- 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 +7 -9
- 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/runtime/uri.js +2 -2
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/validation_error.js +17 -8
- 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 +2 -2
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +2 -2
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/contains.js +2 -2
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +2 -2
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/if.js +2 -2
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/index.js +2 -2
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/items.js +2 -2
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/items2020.js +2 -2
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +2 -2
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +2 -2
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/properties.js +3 -4
- 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 +2 -2
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/code.js +2 -2
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/index.js +2 -2
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/ref.js +3 -3
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/discriminator/index.js +4 -4
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/draft7.js +5 -5
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/format/format.js +2 -2
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/format/index.js +2 -2
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/const.js +2 -2
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/enum.js +2 -2
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/index.js +2 -2
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitItems.js +2 -2
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitLength.js +2 -2
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +2 -2
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +2 -2
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +2 -2
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/pattern.js +2 -2
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/required.js +2 -2
- package/dist/node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +2 -2
- package/dist/node_modules/.pnpm/{fast-uri@3.1.0 → fast-uri@3.1.2}/node_modules/fast-uri/index.js +54 -23
- package/dist/node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/index.js.map +1 -0
- package/dist/node_modules/.pnpm/{fast-uri@3.1.0 → fast-uri@3.1.2}/node_modules/fast-uri/lib/schemes.js.map +1 -1
- package/dist/node_modules/.pnpm/{fast-uri@3.1.0 → fast-uri@3.1.2}/node_modules/fast-uri/lib/utils.js +76 -20
- package/dist/node_modules/.pnpm/fast-uri@3.1.2/node_modules/fast-uri/lib/utils.js.map +1 -0
- package/dist/node_modules/.pnpm/hono@4.12.18/node_modules/hono/dist/helper/streaming/sse.js.map +1 -0
- package/dist/node_modules/.pnpm/{hono@4.12.8 → hono@4.12.18}/node_modules/hono/dist/middleware/cors/index.js +8 -8
- package/dist/node_modules/.pnpm/hono@4.12.18/node_modules/hono/dist/middleware/cors/index.js.map +1 -0
- package/dist/node_modules/.pnpm/hono@4.12.18/node_modules/hono/dist/utils/html.js.map +1 -0
- package/dist/node_modules/.pnpm/hono@4.12.18/node_modules/hono/dist/utils/stream.js.map +1 -0
- 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/main.js +2 -2
- package/dist/server/mcp/mcp.js +2 -2
- package/dist/server/routes/stream/streaming.js +2 -2
- package/dist/ui/assets/instrumentation.js +2 -2
- package/package.json +6 -6
- package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/index.js.map +0 -1
- package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/utils.js.map +0 -1
- package/dist/node_modules/.pnpm/hono@4.12.8/node_modules/hono/dist/helper/streaming/sse.js.map +0 -1
- package/dist/node_modules/.pnpm/hono@4.12.8/node_modules/hono/dist/middleware/cors/index.js.map +0 -1
- package/dist/node_modules/.pnpm/hono@4.12.8/node_modules/hono/dist/utils/html.js.map +0 -1
- package/dist/node_modules/.pnpm/hono@4.12.8/node_modules/hono/dist/utils/stream.js.map +0 -1
- /package/dist/node_modules/.pnpm/{fast-uri@3.1.0 → fast-uri@3.1.2}/node_modules/fast-uri/lib/schemes.js +0 -0
- /package/dist/node_modules/.pnpm/{hono@4.12.8 → hono@4.12.18}/node_modules/hono/dist/helper/streaming/sse.js +0 -0
- /package/dist/node_modules/.pnpm/{hono@4.12.8 → hono@4.12.18}/node_modules/hono/dist/utils/html.js +0 -0
- /package/dist/node_modules/.pnpm/{hono@4.12.8 → hono@4.12.18}/node_modules/hono/dist/utils/stream.js +0 -0
|
@@ -2,534 +2,536 @@
|
|
|
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] = "81968ed3-cf3e-4047-8e36-b7b7d8b17b22", e._sentryDebugIdIdentifier = "sentry-dbid-81968ed3-cf3e-4047-8e36-b7b7d8b17b22");
|
|
6
6
|
} catch (e2) {
|
|
7
7
|
}
|
|
8
8
|
})();
|
|
9
|
-
import { __exports as validate } from "../../../../../../../../_virtual/
|
|
10
|
-
import "./boolSchema.js";
|
|
9
|
+
import { __exports as validate } from "../../../../../../../../_virtual/index9.js";
|
|
10
|
+
import { __require as requireBoolSchema } from "./boolSchema.js";
|
|
11
11
|
import "./dataType.js";
|
|
12
12
|
import "./applicability.js";
|
|
13
|
-
import "./defaults.js";
|
|
14
|
-
import "./keyword.js";
|
|
15
|
-
import "./subschema.js";
|
|
13
|
+
import { __require as requireDefaults } from "./defaults.js";
|
|
14
|
+
import { __require as requireKeyword } from "./keyword.js";
|
|
15
|
+
import { __require as requireSubschema } from "./subschema.js";
|
|
16
16
|
import "../codegen/index.js";
|
|
17
17
|
import "../names.js";
|
|
18
18
|
import "../resolve.js";
|
|
19
19
|
import "../util.js";
|
|
20
20
|
import "../errors.js";
|
|
21
|
-
import { __exports as keyword } from "../../../../../../../../_virtual/keyword.js";
|
|
22
21
|
import { __exports as util } from "../../../../../../../../_virtual/util.js";
|
|
23
22
|
import { __exports as names } from "../../../../../../../../_virtual/names.js";
|
|
24
|
-
import { __exports as codegen } from "../../../../../../../../_virtual/
|
|
23
|
+
import { __exports as codegen } from "../../../../../../../../_virtual/index.js";
|
|
25
24
|
import { __exports as errors } from "../../../../../../../../_virtual/errors.js";
|
|
26
25
|
import { __exports as dataType } from "../../../../../../../../_virtual/dataType.js";
|
|
27
|
-
import { __exports as subschema } from "../../../../../../../../_virtual/subschema.js";
|
|
28
|
-
import { __exports as boolSchema } from "../../../../../../../../_virtual/boolSchema.js";
|
|
29
26
|
import { __exports as resolve } from "../../../../../../../../_virtual/resolve.js";
|
|
30
27
|
import { __exports as applicability } from "../../../../../../../../_virtual/applicability.js";
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
28
|
+
var hasRequiredValidate;
|
|
29
|
+
function requireValidate() {
|
|
30
|
+
if (hasRequiredValidate) return validate;
|
|
31
|
+
hasRequiredValidate = 1;
|
|
32
|
+
Object.defineProperty(validate, "__esModule", { value: true });
|
|
33
|
+
validate.getData = validate.KeywordCxt = validate.validateFunctionCode = void 0;
|
|
34
|
+
const boolSchema_1 = requireBoolSchema();
|
|
35
|
+
const dataType_1 = dataType;
|
|
36
|
+
const applicability_1 = applicability;
|
|
37
|
+
const dataType_2 = dataType;
|
|
38
|
+
const defaults_1 = requireDefaults();
|
|
39
|
+
const keyword_1 = requireKeyword();
|
|
40
|
+
const subschema_1 = requireSubschema();
|
|
41
|
+
const codegen_1 = codegen;
|
|
42
|
+
const names_1 = names;
|
|
43
|
+
const resolve_1 = resolve;
|
|
44
|
+
const util_1 = util;
|
|
45
|
+
const errors_1 = errors;
|
|
46
|
+
function validateFunctionCode(it) {
|
|
47
|
+
if (isSchemaObj(it)) {
|
|
48
|
+
checkKeywords(it);
|
|
49
|
+
if (schemaCxtHasRules(it)) {
|
|
50
|
+
topSchemaObjCode(it);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
|
|
55
|
+
}
|
|
56
|
+
validate.validateFunctionCode = validateFunctionCode;
|
|
57
|
+
function validateFunction({ gen, validateName, schema, schemaEnv, opts }, body) {
|
|
58
|
+
if (opts.code.es5) {
|
|
59
|
+
gen.func(validateName, (0, codegen_1._)`${names_1.default.data}, ${names_1.default.valCxt}`, schemaEnv.$async, () => {
|
|
60
|
+
gen.code((0, codegen_1._)`"use strict"; ${funcSourceUrl(schema, opts)}`);
|
|
61
|
+
destructureValCxtES5(gen, opts);
|
|
62
|
+
gen.code(body);
|
|
63
|
+
});
|
|
64
|
+
} else {
|
|
65
|
+
gen.func(validateName, (0, codegen_1._)`${names_1.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
|
|
52
66
|
}
|
|
53
67
|
}
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
gen.
|
|
61
|
-
|
|
62
|
-
gen.
|
|
68
|
+
function destructureValCxt(opts) {
|
|
69
|
+
return (0, codegen_1._)`{${names_1.default.instancePath}="", ${names_1.default.parentData}, ${names_1.default.parentDataProperty}, ${names_1.default.rootData}=${names_1.default.data}${opts.dynamicRef ? (0, codegen_1._)`, ${names_1.default.dynamicAnchors}={}` : codegen_1.nil}}={}`;
|
|
70
|
+
}
|
|
71
|
+
function destructureValCxtES5(gen, opts) {
|
|
72
|
+
gen.if(names_1.default.valCxt, () => {
|
|
73
|
+
gen.var(names_1.default.instancePath, (0, codegen_1._)`${names_1.default.valCxt}.${names_1.default.instancePath}`);
|
|
74
|
+
gen.var(names_1.default.parentData, (0, codegen_1._)`${names_1.default.valCxt}.${names_1.default.parentData}`);
|
|
75
|
+
gen.var(names_1.default.parentDataProperty, (0, codegen_1._)`${names_1.default.valCxt}.${names_1.default.parentDataProperty}`);
|
|
76
|
+
gen.var(names_1.default.rootData, (0, codegen_1._)`${names_1.default.valCxt}.${names_1.default.rootData}`);
|
|
77
|
+
if (opts.dynamicRef)
|
|
78
|
+
gen.var(names_1.default.dynamicAnchors, (0, codegen_1._)`${names_1.default.valCxt}.${names_1.default.dynamicAnchors}`);
|
|
79
|
+
}, () => {
|
|
80
|
+
gen.var(names_1.default.instancePath, (0, codegen_1._)`""`);
|
|
81
|
+
gen.var(names_1.default.parentData, (0, codegen_1._)`undefined`);
|
|
82
|
+
gen.var(names_1.default.parentDataProperty, (0, codegen_1._)`undefined`);
|
|
83
|
+
gen.var(names_1.default.rootData, names_1.default.data);
|
|
84
|
+
if (opts.dynamicRef)
|
|
85
|
+
gen.var(names_1.default.dynamicAnchors, (0, codegen_1._)`{}`);
|
|
63
86
|
});
|
|
64
|
-
} else {
|
|
65
|
-
gen.func(validateName, (0, codegen_1._)`${names_1.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
|
|
66
87
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
gen
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
function
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
returnResults(it);
|
|
100
|
-
});
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
function resetEvaluated(it) {
|
|
104
|
-
const { gen, validateName } = it;
|
|
105
|
-
it.evaluated = gen.const("evaluated", (0, codegen_1._)`${validateName}.evaluated`);
|
|
106
|
-
gen.if((0, codegen_1._)`${it.evaluated}.dynamicProps`, () => gen.assign((0, codegen_1._)`${it.evaluated}.props`, (0, codegen_1._)`undefined`));
|
|
107
|
-
gen.if((0, codegen_1._)`${it.evaluated}.dynamicItems`, () => gen.assign((0, codegen_1._)`${it.evaluated}.items`, (0, codegen_1._)`undefined`));
|
|
108
|
-
}
|
|
109
|
-
function funcSourceUrl(schema, opts) {
|
|
110
|
-
const schId = typeof schema == "object" && schema[opts.schemaId];
|
|
111
|
-
return schId && (opts.code.source || opts.code.process) ? (0, codegen_1._)`/*# sourceURL=${schId} */` : codegen_1.nil;
|
|
112
|
-
}
|
|
113
|
-
function subschemaCode(it, valid) {
|
|
114
|
-
if (isSchemaObj(it)) {
|
|
115
|
-
checkKeywords(it);
|
|
116
|
-
if (schemaCxtHasRules(it)) {
|
|
117
|
-
subSchemaObjCode(it, valid);
|
|
118
|
-
return;
|
|
88
|
+
function topSchemaObjCode(it) {
|
|
89
|
+
const { schema, opts, gen } = it;
|
|
90
|
+
validateFunction(it, () => {
|
|
91
|
+
if (opts.$comment && schema.$comment)
|
|
92
|
+
commentKeyword(it);
|
|
93
|
+
checkNoDefault(it);
|
|
94
|
+
gen.let(names_1.default.vErrors, null);
|
|
95
|
+
gen.let(names_1.default.errors, 0);
|
|
96
|
+
if (opts.unevaluated)
|
|
97
|
+
resetEvaluated(it);
|
|
98
|
+
typeAndKeywords(it);
|
|
99
|
+
returnResults(it);
|
|
100
|
+
});
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
function resetEvaluated(it) {
|
|
104
|
+
const { gen, validateName } = it;
|
|
105
|
+
it.evaluated = gen.const("evaluated", (0, codegen_1._)`${validateName}.evaluated`);
|
|
106
|
+
gen.if((0, codegen_1._)`${it.evaluated}.dynamicProps`, () => gen.assign((0, codegen_1._)`${it.evaluated}.props`, (0, codegen_1._)`undefined`));
|
|
107
|
+
gen.if((0, codegen_1._)`${it.evaluated}.dynamicItems`, () => gen.assign((0, codegen_1._)`${it.evaluated}.items`, (0, codegen_1._)`undefined`));
|
|
108
|
+
}
|
|
109
|
+
function funcSourceUrl(schema, opts) {
|
|
110
|
+
const schId = typeof schema == "object" && schema[opts.schemaId];
|
|
111
|
+
return schId && (opts.code.source || opts.code.process) ? (0, codegen_1._)`/*# sourceURL=${schId} */` : codegen_1.nil;
|
|
112
|
+
}
|
|
113
|
+
function subschemaCode(it, valid) {
|
|
114
|
+
if (isSchemaObj(it)) {
|
|
115
|
+
checkKeywords(it);
|
|
116
|
+
if (schemaCxtHasRules(it)) {
|
|
117
|
+
subSchemaObjCode(it, valid);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
119
120
|
}
|
|
121
|
+
(0, boolSchema_1.boolOrEmptySchema)(it, valid);
|
|
120
122
|
}
|
|
121
|
-
(
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
return true;
|
|
129
|
-
return false;
|
|
130
|
-
}
|
|
131
|
-
function isSchemaObj(it) {
|
|
132
|
-
return typeof it.schema != "boolean";
|
|
133
|
-
}
|
|
134
|
-
function subSchemaObjCode(it, valid) {
|
|
135
|
-
const { schema, gen, opts } = it;
|
|
136
|
-
if (opts.$comment && schema.$comment)
|
|
137
|
-
commentKeyword(it);
|
|
138
|
-
updateContext(it);
|
|
139
|
-
checkAsyncSchema(it);
|
|
140
|
-
const errsCount = gen.const("_errs", names_1.default.errors);
|
|
141
|
-
typeAndKeywords(it, errsCount);
|
|
142
|
-
gen.var(valid, (0, codegen_1._)`${errsCount} === ${names_1.default.errors}`);
|
|
143
|
-
}
|
|
144
|
-
function checkKeywords(it) {
|
|
145
|
-
(0, util_1.checkUnknownRules)(it);
|
|
146
|
-
checkRefsAndKeywords(it);
|
|
147
|
-
}
|
|
148
|
-
function typeAndKeywords(it, errsCount) {
|
|
149
|
-
if (it.opts.jtd)
|
|
150
|
-
return schemaKeywords(it, [], false, errsCount);
|
|
151
|
-
const types = (0, dataType_1.getSchemaTypes)(it.schema);
|
|
152
|
-
const checkedTypes = (0, dataType_1.coerceAndCheckDataType)(it, types);
|
|
153
|
-
schemaKeywords(it, types, !checkedTypes, errsCount);
|
|
154
|
-
}
|
|
155
|
-
function checkRefsAndKeywords(it) {
|
|
156
|
-
const { schema, errSchemaPath, opts, self: self2 } = it;
|
|
157
|
-
if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_1.schemaHasRulesButRef)(schema, self2.RULES)) {
|
|
158
|
-
self2.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
|
|
123
|
+
function schemaCxtHasRules({ schema, self: self2 }) {
|
|
124
|
+
if (typeof schema == "boolean")
|
|
125
|
+
return !schema;
|
|
126
|
+
for (const key in schema)
|
|
127
|
+
if (self2.RULES.all[key])
|
|
128
|
+
return true;
|
|
129
|
+
return false;
|
|
159
130
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
const { schema, opts } = it;
|
|
163
|
-
if (schema.default !== void 0 && opts.useDefaults && opts.strictSchema) {
|
|
164
|
-
(0, util_1.checkStrictMode)(it, "default is ignored in the schema root");
|
|
131
|
+
function isSchemaObj(it) {
|
|
132
|
+
return typeof it.schema != "boolean";
|
|
165
133
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
function
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
134
|
+
function subSchemaObjCode(it, valid) {
|
|
135
|
+
const { schema, gen, opts } = it;
|
|
136
|
+
if (opts.$comment && schema.$comment)
|
|
137
|
+
commentKeyword(it);
|
|
138
|
+
updateContext(it);
|
|
139
|
+
checkAsyncSchema(it);
|
|
140
|
+
const errsCount = gen.const("_errs", names_1.default.errors);
|
|
141
|
+
typeAndKeywords(it, errsCount);
|
|
142
|
+
gen.var(valid, (0, codegen_1._)`${errsCount} === ${names_1.default.errors}`);
|
|
143
|
+
}
|
|
144
|
+
function checkKeywords(it) {
|
|
145
|
+
(0, util_1.checkUnknownRules)(it);
|
|
146
|
+
checkRefsAndKeywords(it);
|
|
147
|
+
}
|
|
148
|
+
function typeAndKeywords(it, errsCount) {
|
|
149
|
+
if (it.opts.jtd)
|
|
150
|
+
return schemaKeywords(it, [], false, errsCount);
|
|
151
|
+
const types = (0, dataType_1.getSchemaTypes)(it.schema);
|
|
152
|
+
const checkedTypes = (0, dataType_1.coerceAndCheckDataType)(it, types);
|
|
153
|
+
schemaKeywords(it, types, !checkedTypes, errsCount);
|
|
154
|
+
}
|
|
155
|
+
function checkRefsAndKeywords(it) {
|
|
156
|
+
const { schema, errSchemaPath, opts, self: self2 } = it;
|
|
157
|
+
if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_1.schemaHasRulesButRef)(schema, self2.RULES)) {
|
|
158
|
+
self2.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
|
|
159
|
+
}
|
|
184
160
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
} else {
|
|
191
|
-
gen.assign((0, codegen_1._)`${validateName}.errors`, names_1.default.vErrors);
|
|
192
|
-
if (opts.unevaluated)
|
|
193
|
-
assignEvaluated(it);
|
|
194
|
-
gen.return((0, codegen_1._)`${names_1.default.errors} === 0`);
|
|
161
|
+
function checkNoDefault(it) {
|
|
162
|
+
const { schema, opts } = it;
|
|
163
|
+
if (schema.default !== void 0 && opts.useDefaults && opts.strictSchema) {
|
|
164
|
+
(0, util_1.checkStrictMode)(it, "default is ignored in the schema root");
|
|
165
|
+
}
|
|
195
166
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
167
|
+
function updateContext(it) {
|
|
168
|
+
const schId = it.schema[it.opts.schemaId];
|
|
169
|
+
if (schId)
|
|
170
|
+
it.baseId = (0, resolve_1.resolveUrl)(it.opts.uriResolver, it.baseId, schId);
|
|
171
|
+
}
|
|
172
|
+
function checkAsyncSchema(it) {
|
|
173
|
+
if (it.schema.$async && !it.schemaEnv.$async)
|
|
174
|
+
throw new Error("async schema in sync schema");
|
|
175
|
+
}
|
|
176
|
+
function commentKeyword({ gen, schemaEnv, schema, errSchemaPath, opts }) {
|
|
177
|
+
const msg = schema.$comment;
|
|
178
|
+
if (opts.$comment === true) {
|
|
179
|
+
gen.code((0, codegen_1._)`${names_1.default.self}.logger.log(${msg})`);
|
|
180
|
+
} else if (typeof opts.$comment == "function") {
|
|
181
|
+
const schemaPath = (0, codegen_1.str)`${errSchemaPath}/$comment`;
|
|
182
|
+
const rootName = gen.scopeValue("root", { ref: schemaEnv.root });
|
|
183
|
+
gen.code((0, codegen_1._)`${names_1.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`);
|
|
184
|
+
}
|
|
209
185
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
186
|
+
function returnResults(it) {
|
|
187
|
+
const { gen, schemaEnv, validateName, ValidationError, opts } = it;
|
|
188
|
+
if (schemaEnv.$async) {
|
|
189
|
+
gen.if((0, codegen_1._)`${names_1.default.errors} === 0`, () => gen.return(names_1.default.data), () => gen.throw((0, codegen_1._)`new ${ValidationError}(${names_1.default.vErrors})`));
|
|
190
|
+
} else {
|
|
191
|
+
gen.assign((0, codegen_1._)`${validateName}.errors`, names_1.default.vErrors);
|
|
192
|
+
if (opts.unevaluated)
|
|
193
|
+
assignEvaluated(it);
|
|
194
|
+
gen.return((0, codegen_1._)`${names_1.default.errors} === 0`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
function assignEvaluated({ gen, evaluated, props, items }) {
|
|
198
|
+
if (props instanceof codegen_1.Name)
|
|
199
|
+
gen.assign((0, codegen_1._)`${evaluated}.props`, props);
|
|
200
|
+
if (items instanceof codegen_1.Name)
|
|
201
|
+
gen.assign((0, codegen_1._)`${evaluated}.items`, items);
|
|
202
|
+
}
|
|
203
|
+
function schemaKeywords(it, types, typeErrors, errsCount) {
|
|
204
|
+
const { gen, schema, data, allErrors, opts, self: self2 } = it;
|
|
205
|
+
const { RULES } = self2;
|
|
206
|
+
if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1.schemaHasRulesButRef)(schema, RULES))) {
|
|
207
|
+
gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
|
|
219
208
|
return;
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
(
|
|
209
|
+
}
|
|
210
|
+
if (!opts.jtd)
|
|
211
|
+
checkStrictTypes(it, types);
|
|
212
|
+
gen.block(() => {
|
|
213
|
+
for (const group of RULES.rules)
|
|
214
|
+
groupKeywords(group);
|
|
215
|
+
groupKeywords(RULES.post);
|
|
216
|
+
});
|
|
217
|
+
function groupKeywords(group) {
|
|
218
|
+
if (!(0, applicability_1.shouldUseGroup)(schema, group))
|
|
219
|
+
return;
|
|
220
|
+
if (group.type) {
|
|
221
|
+
gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers));
|
|
222
|
+
iterateKeywords(it, group);
|
|
223
|
+
if (types.length === 1 && types[0] === group.type && typeErrors) {
|
|
224
|
+
gen.else();
|
|
225
|
+
(0, dataType_2.reportTypeError)(it);
|
|
226
|
+
}
|
|
227
|
+
gen.endIf();
|
|
228
|
+
} else {
|
|
229
|
+
iterateKeywords(it, group);
|
|
226
230
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
iterateKeywords(it, group);
|
|
231
|
+
if (!allErrors)
|
|
232
|
+
gen.if((0, codegen_1._)`${names_1.default.errors} === ${errsCount || 0}`);
|
|
230
233
|
}
|
|
231
|
-
if (!allErrors)
|
|
232
|
-
gen.if((0, codegen_1._)`${names_1.default.errors} === ${errsCount || 0}`);
|
|
233
234
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
(
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
235
|
+
function iterateKeywords(it, group) {
|
|
236
|
+
const { gen, schema, opts: { useDefaults } } = it;
|
|
237
|
+
if (useDefaults)
|
|
238
|
+
(0, defaults_1.assignDefaults)(it, group.type);
|
|
239
|
+
gen.block(() => {
|
|
240
|
+
for (const rule of group.rules) {
|
|
241
|
+
if ((0, applicability_1.shouldUseRule)(schema, rule)) {
|
|
242
|
+
keywordCode(it, rule.keyword, rule.definition, group.type);
|
|
243
|
+
}
|
|
243
244
|
}
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
function checkStrictTypes(it, types) {
|
|
248
|
+
if (it.schemaEnv.meta || !it.opts.strictTypes)
|
|
249
|
+
return;
|
|
250
|
+
checkContextTypes(it, types);
|
|
251
|
+
if (!it.opts.allowUnionTypes)
|
|
252
|
+
checkMultipleTypes(it, types);
|
|
253
|
+
checkKeywordTypes(it, it.dataTypes);
|
|
254
|
+
}
|
|
255
|
+
function checkContextTypes(it, types) {
|
|
256
|
+
if (!types.length)
|
|
257
|
+
return;
|
|
258
|
+
if (!it.dataTypes.length) {
|
|
259
|
+
it.dataTypes = types;
|
|
260
|
+
return;
|
|
244
261
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
if (!it.opts.allowUnionTypes)
|
|
252
|
-
checkMultipleTypes(it, types);
|
|
253
|
-
checkKeywordTypes(it, it.dataTypes);
|
|
254
|
-
}
|
|
255
|
-
function checkContextTypes(it, types) {
|
|
256
|
-
if (!types.length)
|
|
257
|
-
return;
|
|
258
|
-
if (!it.dataTypes.length) {
|
|
259
|
-
it.dataTypes = types;
|
|
260
|
-
return;
|
|
262
|
+
types.forEach((t) => {
|
|
263
|
+
if (!includesType(it.dataTypes, t)) {
|
|
264
|
+
strictTypesError(it, `type "${t}" not allowed by context "${it.dataTypes.join(",")}"`);
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
narrowSchemaTypes(it, types);
|
|
261
268
|
}
|
|
262
|
-
|
|
263
|
-
if (!
|
|
264
|
-
strictTypesError(it,
|
|
269
|
+
function checkMultipleTypes(it, ts) {
|
|
270
|
+
if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
|
|
271
|
+
strictTypesError(it, "use allowUnionTypes to allow union type keyword");
|
|
265
272
|
}
|
|
266
|
-
});
|
|
267
|
-
narrowSchemaTypes(it, types);
|
|
268
|
-
}
|
|
269
|
-
function checkMultipleTypes(it, ts) {
|
|
270
|
-
if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
|
|
271
|
-
strictTypesError(it, "use allowUnionTypes to allow union type keyword");
|
|
272
273
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
274
|
+
function checkKeywordTypes(it, ts) {
|
|
275
|
+
const rules = it.self.RULES.all;
|
|
276
|
+
for (const keyword in rules) {
|
|
277
|
+
const rule = rules[keyword];
|
|
278
|
+
if (typeof rule == "object" && (0, applicability_1.shouldUseRule)(it.schema, rule)) {
|
|
279
|
+
const { type } = rule.definition;
|
|
280
|
+
if (type.length && !type.some((t) => hasApplicableType(ts, t))) {
|
|
281
|
+
strictTypesError(it, `missing type "${type.join(",")}" for keyword "${keyword}"`);
|
|
282
|
+
}
|
|
282
283
|
}
|
|
283
284
|
}
|
|
284
285
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
286
|
+
function hasApplicableType(schTs, kwdT) {
|
|
287
|
+
return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer");
|
|
288
|
+
}
|
|
289
|
+
function includesType(ts, t) {
|
|
290
|
+
return ts.includes(t) || t === "integer" && ts.includes("number");
|
|
291
|
+
}
|
|
292
|
+
function narrowSchemaTypes(it, withTypes) {
|
|
293
|
+
const ts = [];
|
|
294
|
+
for (const t of it.dataTypes) {
|
|
295
|
+
if (includesType(withTypes, t))
|
|
296
|
+
ts.push(t);
|
|
297
|
+
else if (withTypes.includes("integer") && t === "number")
|
|
298
|
+
ts.push("integer");
|
|
299
|
+
}
|
|
300
|
+
it.dataTypes = ts;
|
|
301
|
+
}
|
|
302
|
+
function strictTypesError(it, msg) {
|
|
303
|
+
const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
|
|
304
|
+
msg += ` at "${schemaPath}" (strictTypes)`;
|
|
305
|
+
(0, util_1.checkStrictMode)(it, msg, it.opts.strictTypes);
|
|
306
|
+
}
|
|
307
|
+
class KeywordCxt {
|
|
308
|
+
constructor(it, def, keyword) {
|
|
309
|
+
(0, keyword_1.validateKeywordUsage)(it, def, keyword);
|
|
310
|
+
this.gen = it.gen;
|
|
311
|
+
this.allErrors = it.allErrors;
|
|
312
|
+
this.keyword = keyword;
|
|
313
|
+
this.data = it.data;
|
|
314
|
+
this.schema = it.schema[keyword];
|
|
315
|
+
this.$data = def.$data && it.opts.$data && this.schema && this.schema.$data;
|
|
316
|
+
this.schemaValue = (0, util_1.schemaRefOrVal)(it, this.schema, keyword, this.$data);
|
|
317
|
+
this.schemaType = def.schemaType;
|
|
318
|
+
this.parentSchema = it.schema;
|
|
319
|
+
this.params = {};
|
|
320
|
+
this.it = it;
|
|
321
|
+
this.def = def;
|
|
322
|
+
if (this.$data) {
|
|
323
|
+
this.schemaCode = it.gen.const("vSchema", getData(this.$data, it));
|
|
324
|
+
} else {
|
|
325
|
+
this.schemaCode = this.schemaValue;
|
|
326
|
+
if (!(0, keyword_1.validSchemaType)(this.schema, def.schemaType, def.allowUndefined)) {
|
|
327
|
+
throw new Error(`${keyword} value must be ${JSON.stringify(def.schemaType)}`);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
if ("code" in def ? def.trackErrors : def.errors !== false) {
|
|
331
|
+
this.errsCount = it.gen.const("_errs", names_1.default.errors);
|
|
328
332
|
}
|
|
329
333
|
}
|
|
330
|
-
|
|
331
|
-
this.
|
|
334
|
+
result(condition, successAction, failAction) {
|
|
335
|
+
this.failResult((0, codegen_1.not)(condition), successAction, failAction);
|
|
332
336
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
337
|
+
failResult(condition, successAction, failAction) {
|
|
338
|
+
this.gen.if(condition);
|
|
339
|
+
if (failAction)
|
|
340
|
+
failAction();
|
|
341
|
+
else
|
|
342
|
+
this.error();
|
|
343
|
+
if (successAction) {
|
|
344
|
+
this.gen.else();
|
|
345
|
+
successAction();
|
|
346
|
+
if (this.allErrors)
|
|
347
|
+
this.gen.endIf();
|
|
348
|
+
} else {
|
|
349
|
+
if (this.allErrors)
|
|
350
|
+
this.gen.endIf();
|
|
351
|
+
else
|
|
352
|
+
this.gen.else();
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
pass(condition, failAction) {
|
|
356
|
+
this.failResult((0, codegen_1.not)(condition), void 0, failAction);
|
|
357
|
+
}
|
|
358
|
+
fail(condition) {
|
|
359
|
+
if (condition === void 0) {
|
|
360
|
+
this.error();
|
|
361
|
+
if (!this.allErrors)
|
|
362
|
+
this.gen.if(false);
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
this.gen.if(condition);
|
|
342
366
|
this.error();
|
|
343
|
-
if (successAction) {
|
|
344
|
-
this.gen.else();
|
|
345
|
-
successAction();
|
|
346
|
-
if (this.allErrors)
|
|
347
|
-
this.gen.endIf();
|
|
348
|
-
} else {
|
|
349
367
|
if (this.allErrors)
|
|
350
368
|
this.gen.endIf();
|
|
351
369
|
else
|
|
352
370
|
this.gen.else();
|
|
353
371
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
if (condition === void 0) {
|
|
360
|
-
this.error();
|
|
361
|
-
if (!this.allErrors)
|
|
362
|
-
this.gen.if(false);
|
|
363
|
-
return;
|
|
372
|
+
fail$data(condition) {
|
|
373
|
+
if (!this.$data)
|
|
374
|
+
return this.fail(condition);
|
|
375
|
+
const { schemaCode } = this;
|
|
376
|
+
this.fail((0, codegen_1._)`${schemaCode} !== undefined && (${(0, codegen_1.or)(this.invalid$data(), condition)})`);
|
|
364
377
|
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
fail$data(condition) {
|
|
373
|
-
if (!this.$data)
|
|
374
|
-
return this.fail(condition);
|
|
375
|
-
const { schemaCode } = this;
|
|
376
|
-
this.fail((0, codegen_1._)`${schemaCode} !== undefined && (${(0, codegen_1.or)(this.invalid$data(), condition)})`);
|
|
377
|
-
}
|
|
378
|
-
error(append, errorParams, errorPaths) {
|
|
379
|
-
if (errorParams) {
|
|
380
|
-
this.setParams(errorParams);
|
|
378
|
+
error(append, errorParams, errorPaths) {
|
|
379
|
+
if (errorParams) {
|
|
380
|
+
this.setParams(errorParams);
|
|
381
|
+
this._error(append, errorPaths);
|
|
382
|
+
this.setParams({});
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
381
385
|
this._error(append, errorPaths);
|
|
382
|
-
this.setParams({});
|
|
383
|
-
return;
|
|
384
386
|
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
(
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
(
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
(
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
const { gen, schemaCode, schemaType, def } = this;
|
|
418
|
-
gen.if((0, codegen_1.or)((0, codegen_1._)`${schemaCode} === undefined`, $dataValid));
|
|
419
|
-
if (valid !== codegen_1.nil)
|
|
420
|
-
gen.assign(valid, true);
|
|
421
|
-
if (schemaType.length || def.validateSchema) {
|
|
422
|
-
gen.elseIf(this.invalid$data());
|
|
423
|
-
this.$dataError();
|
|
387
|
+
_error(append, errorPaths) {
|
|
388
|
+
(append ? errors_1.reportExtraError : errors_1.reportError)(this, this.def.error, errorPaths);
|
|
389
|
+
}
|
|
390
|
+
$dataError() {
|
|
391
|
+
(0, errors_1.reportError)(this, this.def.$dataError || errors_1.keyword$DataError);
|
|
392
|
+
}
|
|
393
|
+
reset() {
|
|
394
|
+
if (this.errsCount === void 0)
|
|
395
|
+
throw new Error('add "trackErrors" to keyword definition');
|
|
396
|
+
(0, errors_1.resetErrorsCount)(this.gen, this.errsCount);
|
|
397
|
+
}
|
|
398
|
+
ok(cond) {
|
|
399
|
+
if (!this.allErrors)
|
|
400
|
+
this.gen.if(cond);
|
|
401
|
+
}
|
|
402
|
+
setParams(obj, assign) {
|
|
403
|
+
if (assign)
|
|
404
|
+
Object.assign(this.params, obj);
|
|
405
|
+
else
|
|
406
|
+
this.params = obj;
|
|
407
|
+
}
|
|
408
|
+
block$data(valid, codeBlock, $dataValid = codegen_1.nil) {
|
|
409
|
+
this.gen.block(() => {
|
|
410
|
+
this.check$data(valid, $dataValid);
|
|
411
|
+
codeBlock();
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
check$data(valid = codegen_1.nil, $dataValid = codegen_1.nil) {
|
|
415
|
+
if (!this.$data)
|
|
416
|
+
return;
|
|
417
|
+
const { gen, schemaCode, schemaType, def } = this;
|
|
418
|
+
gen.if((0, codegen_1.or)((0, codegen_1._)`${schemaCode} === undefined`, $dataValid));
|
|
424
419
|
if (valid !== codegen_1.nil)
|
|
425
|
-
gen.assign(valid,
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
return (0, codegen_1.or)(wrong$DataType(), invalid$DataSchema());
|
|
432
|
-
function wrong$DataType() {
|
|
433
|
-
if (schemaType.length) {
|
|
434
|
-
if (!(schemaCode instanceof codegen_1.Name))
|
|
435
|
-
throw new Error("ajv implementation error");
|
|
436
|
-
const st = Array.isArray(schemaType) ? schemaType : [schemaType];
|
|
437
|
-
return (0, codegen_1._)`${(0, dataType_2.checkDataTypes)(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)}`;
|
|
420
|
+
gen.assign(valid, true);
|
|
421
|
+
if (schemaType.length || def.validateSchema) {
|
|
422
|
+
gen.elseIf(this.invalid$data());
|
|
423
|
+
this.$dataError();
|
|
424
|
+
if (valid !== codegen_1.nil)
|
|
425
|
+
gen.assign(valid, false);
|
|
438
426
|
}
|
|
439
|
-
|
|
427
|
+
gen.else();
|
|
440
428
|
}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
429
|
+
invalid$data() {
|
|
430
|
+
const { gen, schemaCode, schemaType, def, it } = this;
|
|
431
|
+
return (0, codegen_1.or)(wrong$DataType(), invalid$DataSchema());
|
|
432
|
+
function wrong$DataType() {
|
|
433
|
+
if (schemaType.length) {
|
|
434
|
+
if (!(schemaCode instanceof codegen_1.Name))
|
|
435
|
+
throw new Error("ajv implementation error");
|
|
436
|
+
const st = Array.isArray(schemaType) ? schemaType : [schemaType];
|
|
437
|
+
return (0, codegen_1._)`${(0, dataType_2.checkDataTypes)(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)}`;
|
|
438
|
+
}
|
|
439
|
+
return codegen_1.nil;
|
|
440
|
+
}
|
|
441
|
+
function invalid$DataSchema() {
|
|
442
|
+
if (def.validateSchema) {
|
|
443
|
+
const validateSchemaRef = gen.scopeValue("validate$data", { ref: def.validateSchema });
|
|
444
|
+
return (0, codegen_1._)`!${validateSchemaRef}(${schemaCode})`;
|
|
445
|
+
}
|
|
446
|
+
return codegen_1.nil;
|
|
445
447
|
}
|
|
446
|
-
return codegen_1.nil;
|
|
447
448
|
}
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
449
|
+
subschema(appl, valid) {
|
|
450
|
+
const subschema = (0, subschema_1.getSubschema)(this.it, appl);
|
|
451
|
+
(0, subschema_1.extendSubschemaData)(subschema, this.it, appl);
|
|
452
|
+
(0, subschema_1.extendSubschemaMode)(subschema, appl);
|
|
453
|
+
const nextContext = { ...this.it, ...subschema, items: void 0, props: void 0 };
|
|
454
|
+
subschemaCode(nextContext, valid);
|
|
455
|
+
return nextContext;
|
|
456
|
+
}
|
|
457
|
+
mergeEvaluated(schemaCxt, toName) {
|
|
458
|
+
const { it, gen } = this;
|
|
459
|
+
if (!it.opts.unevaluated)
|
|
460
|
+
return;
|
|
461
|
+
if (it.props !== true && schemaCxt.props !== void 0) {
|
|
462
|
+
it.props = util_1.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
|
|
463
|
+
}
|
|
464
|
+
if (it.items !== true && schemaCxt.items !== void 0) {
|
|
465
|
+
it.items = util_1.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName);
|
|
466
|
+
}
|
|
463
467
|
}
|
|
464
|
-
|
|
465
|
-
|
|
468
|
+
mergeValidEvaluated(schemaCxt, valid) {
|
|
469
|
+
const { it, gen } = this;
|
|
470
|
+
if (it.opts.unevaluated && (it.props !== true || it.items !== true)) {
|
|
471
|
+
gen.if(valid, () => this.mergeEvaluated(schemaCxt, codegen_1.Name));
|
|
472
|
+
return true;
|
|
473
|
+
}
|
|
466
474
|
}
|
|
467
475
|
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
476
|
+
validate.KeywordCxt = KeywordCxt;
|
|
477
|
+
function keywordCode(it, keyword, def, ruleType) {
|
|
478
|
+
const cxt = new KeywordCxt(it, def, keyword);
|
|
479
|
+
if ("code" in def) {
|
|
480
|
+
def.code(cxt, ruleType);
|
|
481
|
+
} else if (cxt.$data && def.validate) {
|
|
482
|
+
(0, keyword_1.funcKeywordCode)(cxt, def);
|
|
483
|
+
} else if ("macro" in def) {
|
|
484
|
+
(0, keyword_1.macroKeywordCode)(cxt, def);
|
|
485
|
+
} else if (def.compile || def.validate) {
|
|
486
|
+
(0, keyword_1.funcKeywordCode)(cxt, def);
|
|
473
487
|
}
|
|
474
488
|
}
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
function
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
(0
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
const
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
return data;
|
|
517
|
-
}
|
|
518
|
-
let expr = data;
|
|
519
|
-
const segments = jsonPointer.split("/");
|
|
520
|
-
for (const segment of segments) {
|
|
521
|
-
if (segment) {
|
|
522
|
-
data = (0, codegen_1._)`${data}${(0, codegen_1.getProperty)((0, util_1.unescapeJsonPointer)(segment))}`;
|
|
523
|
-
expr = (0, codegen_1._)`${expr} && ${data}`;
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
return expr;
|
|
527
|
-
function errorMsg(pointerType, up) {
|
|
528
|
-
return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`;
|
|
489
|
+
const JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
|
|
490
|
+
const RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
|
|
491
|
+
function getData($data, { dataLevel, dataNames, dataPathArr }) {
|
|
492
|
+
let jsonPointer;
|
|
493
|
+
let data;
|
|
494
|
+
if ($data === "")
|
|
495
|
+
return names_1.default.rootData;
|
|
496
|
+
if ($data[0] === "/") {
|
|
497
|
+
if (!JSON_POINTER.test($data))
|
|
498
|
+
throw new Error(`Invalid JSON-pointer: ${$data}`);
|
|
499
|
+
jsonPointer = $data;
|
|
500
|
+
data = names_1.default.rootData;
|
|
501
|
+
} else {
|
|
502
|
+
const matches = RELATIVE_JSON_POINTER.exec($data);
|
|
503
|
+
if (!matches)
|
|
504
|
+
throw new Error(`Invalid JSON-pointer: ${$data}`);
|
|
505
|
+
const up = +matches[1];
|
|
506
|
+
jsonPointer = matches[2];
|
|
507
|
+
if (jsonPointer === "#") {
|
|
508
|
+
if (up >= dataLevel)
|
|
509
|
+
throw new Error(errorMsg("property/index", up));
|
|
510
|
+
return dataPathArr[dataLevel - up];
|
|
511
|
+
}
|
|
512
|
+
if (up > dataLevel)
|
|
513
|
+
throw new Error(errorMsg("data", up));
|
|
514
|
+
data = dataNames[dataLevel - up];
|
|
515
|
+
if (!jsonPointer)
|
|
516
|
+
return data;
|
|
517
|
+
}
|
|
518
|
+
let expr = data;
|
|
519
|
+
const segments = jsonPointer.split("/");
|
|
520
|
+
for (const segment of segments) {
|
|
521
|
+
if (segment) {
|
|
522
|
+
data = (0, codegen_1._)`${data}${(0, codegen_1.getProperty)((0, util_1.unescapeJsonPointer)(segment))}`;
|
|
523
|
+
expr = (0, codegen_1._)`${expr} && ${data}`;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
return expr;
|
|
527
|
+
function errorMsg(pointerType, up) {
|
|
528
|
+
return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`;
|
|
529
|
+
}
|
|
529
530
|
}
|
|
531
|
+
validate.getData = getData;
|
|
532
|
+
return validate;
|
|
530
533
|
}
|
|
531
|
-
validate.getData = getData;
|
|
532
534
|
export {
|
|
533
|
-
|
|
535
|
+
requireValidate as __require
|
|
534
536
|
};
|
|
535
537
|
//# sourceMappingURL=index.js.map
|