@workclaw/openclaw-workclaw 1.0.339 → 1.0.340

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