@kubb/agent 5.0.0-beta.4 → 5.0.0-beta.6

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 (146) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/server/chunks/nitro/nitro.mjs +61 -38
  3. package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
  4. package/.output/server/chunks/routes/api/health.get.mjs +1 -1
  5. package/.output/server/index.mjs +1 -1
  6. package/.output/server/node_modules/ajv/dist/2019.d.ts +1 -1
  7. package/.output/server/node_modules/ajv/dist/2019.js.map +1 -1
  8. package/.output/server/node_modules/ajv/dist/2020.d.ts +1 -1
  9. package/.output/server/node_modules/ajv/dist/2020.js.map +1 -1
  10. package/.output/server/node_modules/ajv/dist/ajv.d.ts +1 -1
  11. package/.output/server/node_modules/ajv/dist/ajv.js.map +1 -1
  12. package/.output/server/node_modules/ajv/dist/compile/index.d.ts +2 -1
  13. package/.output/server/node_modules/ajv/dist/compile/index.js +10 -3
  14. package/.output/server/node_modules/ajv/dist/compile/index.js.map +1 -1
  15. package/.output/server/node_modules/ajv/dist/compile/jtd/parse.js +1 -1
  16. package/.output/server/node_modules/ajv/dist/compile/jtd/parse.js.map +1 -1
  17. package/.output/server/node_modules/ajv/dist/compile/jtd/serialize.js +1 -1
  18. package/.output/server/node_modules/ajv/dist/compile/jtd/serialize.js.map +1 -1
  19. package/.output/server/node_modules/ajv/dist/compile/names.d.ts +1 -0
  20. package/.output/server/node_modules/ajv/dist/compile/names.js +1 -0
  21. package/.output/server/node_modules/ajv/dist/compile/names.js.map +1 -1
  22. package/.output/server/node_modules/ajv/dist/compile/validate/index.d.ts +1 -1
  23. package/.output/server/node_modules/ajv/dist/compile/validate/index.js +18 -4
  24. package/.output/server/node_modules/ajv/dist/compile/validate/index.js.map +1 -1
  25. package/.output/server/node_modules/ajv/dist/core.d.ts +4 -0
  26. package/.output/server/node_modules/ajv/dist/core.js +15 -1
  27. package/.output/server/node_modules/ajv/dist/core.js.map +1 -1
  28. package/.output/server/node_modules/ajv/dist/draft4.d.ts +19 -0
  29. package/.output/server/node_modules/ajv/dist/draft4.js +57 -0
  30. package/.output/server/node_modules/ajv/dist/draft4.js.map +1 -0
  31. package/.output/server/node_modules/ajv/dist/refs/json-schema-draft-04.json +138 -0
  32. package/.output/server/node_modules/ajv/dist/types/index.d.ts +3 -0
  33. package/.output/server/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +2 -1
  34. package/.output/server/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js.map +1 -1
  35. package/.output/server/node_modules/ajv/dist/vocabularies/applicator/allOf.js +1 -1
  36. package/.output/server/node_modules/ajv/dist/vocabularies/applicator/allOf.js.map +1 -1
  37. package/.output/server/node_modules/ajv/dist/vocabularies/applicator/properties.js +2 -1
  38. package/.output/server/node_modules/ajv/dist/vocabularies/applicator/properties.js.map +1 -1
  39. package/.output/server/node_modules/ajv/dist/vocabularies/code.d.ts +1 -1
  40. package/.output/server/node_modules/ajv/dist/vocabularies/code.js +10 -3
  41. package/.output/server/node_modules/ajv/dist/vocabularies/code.js.map +1 -1
  42. package/.output/server/node_modules/ajv/dist/vocabularies/core/ref.js +12 -2
  43. package/.output/server/node_modules/ajv/dist/vocabularies/core/ref.js.map +1 -1
  44. package/.output/server/node_modules/ajv/dist/vocabularies/discriminator/index.js +56 -21
  45. package/.output/server/node_modules/ajv/dist/vocabularies/discriminator/index.js.map +1 -1
  46. package/.output/server/node_modules/ajv/dist/vocabularies/draft4.d.ts +3 -0
  47. package/.output/server/node_modules/ajv/dist/vocabularies/draft4.js +29 -0
  48. package/.output/server/node_modules/ajv/dist/vocabularies/draft4.js.map +1 -0
  49. package/.output/server/node_modules/ajv/dist/vocabularies/metadata.js +10 -2
  50. package/.output/server/node_modules/ajv/dist/vocabularies/metadata.js.map +1 -1
  51. package/.output/server/node_modules/ajv/dist/vocabularies/oasContext.d.ts +3 -0
  52. package/.output/server/node_modules/ajv/dist/vocabularies/oasContext.js +26 -0
  53. package/.output/server/node_modules/ajv/dist/vocabularies/oasContext.js.map +1 -0
  54. package/.output/server/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.js +22 -3
  55. package/.output/server/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.js.map +1 -1
  56. package/.output/server/node_modules/ajv/dist/vocabularies/validation/draft04/limitNumber.d.ts +12 -0
  57. package/.output/server/node_modules/ajv/dist/vocabularies/validation/draft04/limitNumber.js +43 -0
  58. package/.output/server/node_modules/ajv/dist/vocabularies/validation/draft04/limitNumber.js.map +1 -0
  59. package/.output/server/node_modules/ajv/dist/vocabularies/validation/draft04/limitNumberExclusive.d.ts +3 -0
  60. package/.output/server/node_modules/ajv/dist/vocabularies/validation/draft04/limitNumberExclusive.js +19 -0
  61. package/.output/server/node_modules/ajv/dist/vocabularies/validation/draft04/limitNumberExclusive.js.map +1 -0
  62. package/.output/server/node_modules/ajv/dist/vocabularies/validation/index.js +4 -0
  63. package/.output/server/node_modules/ajv/dist/vocabularies/validation/index.js.map +1 -1
  64. package/.output/server/node_modules/ajv/dist/vocabularies/validation/readOnly.d.ts +3 -0
  65. package/.output/server/node_modules/ajv/dist/vocabularies/validation/readOnly.js +20 -0
  66. package/.output/server/node_modules/ajv/dist/vocabularies/validation/readOnly.js.map +1 -0
  67. package/.output/server/node_modules/ajv/dist/vocabularies/validation/required.js +8 -1
  68. package/.output/server/node_modules/ajv/dist/vocabularies/validation/required.js.map +1 -1
  69. package/.output/server/node_modules/ajv/dist/vocabularies/validation/writeOnly.d.ts +3 -0
  70. package/.output/server/node_modules/ajv/dist/vocabularies/validation/writeOnly.js +20 -0
  71. package/.output/server/node_modules/ajv/dist/vocabularies/validation/writeOnly.js.map +1 -0
  72. package/.output/server/node_modules/ajv/lib/2019.ts +1 -0
  73. package/.output/server/node_modules/ajv/lib/2020.ts +1 -0
  74. package/.output/server/node_modules/ajv/lib/ajv.ts +1 -0
  75. package/.output/server/node_modules/ajv/lib/compile/index.ts +16 -3
  76. package/.output/server/node_modules/ajv/lib/compile/jtd/parse.ts +3 -1
  77. package/.output/server/node_modules/ajv/lib/compile/jtd/serialize.ts +3 -1
  78. package/.output/server/node_modules/ajv/lib/compile/names.ts +1 -0
  79. package/.output/server/node_modules/ajv/lib/compile/validate/index.ts +21 -4
  80. package/.output/server/node_modules/ajv/lib/core.ts +20 -1
  81. package/.output/server/node_modules/ajv/lib/draft4.ts +79 -0
  82. package/.output/server/node_modules/ajv/lib/refs/json-schema-draft-04.json +138 -0
  83. package/.output/server/node_modules/ajv/lib/types/index.ts +4 -0
  84. package/.output/server/node_modules/ajv/lib/vocabularies/applicator/additionalProperties.ts +2 -1
  85. package/.output/server/node_modules/ajv/lib/vocabularies/applicator/allOf.ts +1 -1
  86. package/.output/server/node_modules/ajv/lib/vocabularies/applicator/properties.ts +4 -1
  87. package/.output/server/node_modules/ajv/lib/vocabularies/code.ts +10 -3
  88. package/.output/server/node_modules/ajv/lib/vocabularies/core/ref.ts +21 -5
  89. package/.output/server/node_modules/ajv/lib/vocabularies/discriminator/index.ts +69 -19
  90. package/.output/server/node_modules/ajv/lib/vocabularies/draft4.ts +32 -0
  91. package/.output/server/node_modules/ajv/lib/vocabularies/metadata.ts +10 -2
  92. package/.output/server/node_modules/ajv/lib/vocabularies/oasContext.ts +27 -0
  93. package/.output/server/node_modules/ajv/lib/vocabularies/unevaluated/unevaluatedProperties.ts +29 -7
  94. package/.output/server/node_modules/ajv/lib/vocabularies/validation/draft04/limitNumber.ts +75 -0
  95. package/.output/server/node_modules/ajv/lib/vocabularies/validation/draft04/limitNumberExclusive.ts +26 -0
  96. package/.output/server/node_modules/ajv/lib/vocabularies/validation/index.ts +4 -0
  97. package/.output/server/node_modules/ajv/lib/vocabularies/validation/readOnly.ts +23 -0
  98. package/.output/server/node_modules/ajv/lib/vocabularies/validation/required.ts +7 -1
  99. package/.output/server/node_modules/ajv/lib/vocabularies/validation/writeOnly.ts +22 -0
  100. package/.output/server/node_modules/ajv/package.json +9 -6
  101. package/.output/server/node_modules/jiti/LICENSE +21 -0
  102. package/.output/server/node_modules/jiti/README.md +258 -0
  103. package/.output/server/node_modules/jiti/dist/babel.cjs +257 -0
  104. package/.output/server/node_modules/jiti/dist/jiti.cjs +1 -0
  105. package/.output/server/node_modules/jiti/lib/jiti-cli.mjs +34 -0
  106. package/.output/server/node_modules/jiti/lib/jiti-hooks.mjs +124 -0
  107. package/.output/server/node_modules/jiti/lib/jiti-native.mjs +121 -0
  108. package/.output/server/node_modules/jiti/lib/jiti-register.d.mts +1 -0
  109. package/.output/server/node_modules/jiti/lib/jiti-register.mjs +4 -0
  110. package/.output/server/node_modules/jiti/lib/jiti-static.mjs +23 -0
  111. package/.output/server/node_modules/jiti/lib/jiti.cjs +30 -0
  112. package/.output/server/node_modules/jiti/lib/jiti.d.cts +8 -0
  113. package/.output/server/node_modules/jiti/lib/jiti.d.mts +8 -0
  114. package/.output/server/node_modules/jiti/lib/jiti.mjs +29 -0
  115. package/.output/server/node_modules/jiti/lib/types.d.ts +420 -0
  116. package/.output/server/node_modules/jiti/package.json +146 -0
  117. package/.output/server/package.json +2 -5
  118. package/README.md +2 -2
  119. package/package.json +9 -8
  120. package/.output/server/node_modules/@rolldown/binding-linux-x64-gnu/package.json +0 -40
  121. package/.output/server/node_modules/@rolldown/binding-linux-x64-gnu/rolldown-binding.linux-x64-gnu.node +0 -0
  122. package/.output/server/node_modules/@rolldown/pluginutils/dist/filter/composable-filters.js +0 -256
  123. package/.output/server/node_modules/@rolldown/pluginutils/dist/filter/filter-vite-plugins.js +0 -75
  124. package/.output/server/node_modules/@rolldown/pluginutils/dist/filter/index.js +0 -3
  125. package/.output/server/node_modules/@rolldown/pluginutils/dist/filter/simple-filters.js +0 -70
  126. package/.output/server/node_modules/@rolldown/pluginutils/dist/index.js +0 -1
  127. package/.output/server/node_modules/@rolldown/pluginutils/dist/utils.js +0 -17
  128. package/.output/server/node_modules/@rolldown/pluginutils/package.json +0 -37
  129. package/.output/server/node_modules/rolldown/dist/index.mjs +0 -50
  130. package/.output/server/node_modules/rolldown/dist/parse-ast-index.mjs +0 -60
  131. package/.output/server/node_modules/rolldown/dist/shared/binding-BeU_1iEk.mjs +0 -582
  132. package/.output/server/node_modules/rolldown/dist/shared/bindingify-input-options-DbbBhzky.mjs +0 -2211
  133. package/.output/server/node_modules/rolldown/dist/shared/define-config-DJOr6Iwt.mjs +0 -6
  134. package/.output/server/node_modules/rolldown/dist/shared/error-DL-e8-oE.mjs +0 -85
  135. package/.output/server/node_modules/rolldown/dist/shared/logs-D80CXhvg.mjs +0 -180
  136. package/.output/server/node_modules/rolldown/dist/shared/misc-DJYbNKZX.mjs +0 -21
  137. package/.output/server/node_modules/rolldown/dist/shared/normalize-string-or-regex-CbQQ69gT.mjs +0 -66
  138. package/.output/server/node_modules/rolldown/dist/shared/parse-B_ZnWxLZ.mjs +0 -74
  139. package/.output/server/node_modules/rolldown/dist/shared/prompt-U5ajztzG.mjs +0 -847
  140. package/.output/server/node_modules/rolldown/dist/shared/rolldown-D3JZ9rMt.mjs +0 -40
  141. package/.output/server/node_modules/rolldown/dist/shared/rolldown-build-DSxL8qiP.mjs +0 -3325
  142. package/.output/server/node_modules/rolldown/dist/shared/watch-Bd8v9ewv.mjs +0 -374
  143. package/.output/server/node_modules/rolldown/package.json +0 -153
  144. package/.output/server/node_modules/unrun/dist/index.mjs +0 -2
  145. package/.output/server/node_modules/unrun/dist/src-GU5PtktT.mjs +0 -887
  146. package/.output/server/node_modules/unrun/package.json +0 -125
@@ -11,10 +11,12 @@ const def = {
11
11
  keyword: "unevaluatedProperties",
12
12
  type: "object",
13
13
  schemaType: ["boolean", "object"],
14
+ allowUndefined: true,
14
15
  trackErrors: true,
15
16
  error,
16
17
  code(cxt) {
17
- const { gen, schema, data, errsCount, it } = cxt;
18
+ const { gen, schema = cxt.it.opts.defaultUnevaluatedProperties, data, errsCount, it } = cxt;
19
+ const isForced = cxt.schema === undefined && cxt.it.opts.defaultUnevaluatedProperties === false;
18
20
  /* istanbul ignore if */
19
21
  if (!errsCount)
20
22
  throw new Error("ajv implementation error");
@@ -23,11 +25,28 @@ const def = {
23
25
  gen.if((0, codegen_1._) `${props} !== true`, () => gen.forIn("key", data, (key) => gen.if(unevaluatedDynamic(props, key), () => unevaluatedPropCode(key))));
24
26
  }
25
27
  else if (props !== true) {
26
- gen.forIn("key", data, (key) => props === undefined
28
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
29
+ const staticCheck = () => gen.forIn("key", data, (key) => props === undefined
27
30
  ? unevaluatedPropCode(key)
28
31
  : gen.if(unevaluatedStatic(props, key), () => unevaluatedPropCode(key)));
32
+ if (isForced && it.errorPath.emptyStr() && !it.compositeRule) {
33
+ // $refs are compiled into functions
34
+ // We need to check in runtime if function was called from allOf.
35
+ // We need to check only on the top level of the function:
36
+ // it is ensured with `it.errorPath.emptyStr()` check
37
+ gen.if((0, codegen_1._) `${names_1.default.isAllOfVariant} === 0`, staticCheck);
38
+ }
39
+ else {
40
+ if (!it.compositeRule || cxt.schema !== undefined) {
41
+ staticCheck();
42
+ }
43
+ }
44
+ }
45
+ if (!isForced) {
46
+ // disable shot-circut for forced unevaluatedProperties=false
47
+ // we may run or not the check in runtime so we can't short-circuit in compile-time
48
+ it.props = true;
29
49
  }
30
- it.props = true;
31
50
  cxt.ok((0, codegen_1._) `${errsCount} === ${names_1.default.errors}`);
32
51
  function unevaluatedPropCode(key) {
33
52
  if (schema === false) {
@@ -1 +1 @@
1
- {"version":3,"file":"unevaluatedProperties.js","sourceRoot":"","sources":["../../../lib/vocabularies/unevaluated/unevaluatedProperties.ts"],"names":[],"mappings":";;AAMA,mDAA6D;AAC7D,6CAA0D;AAC1D,+CAAmC;AAQnC,MAAM,KAAK,GAA2B;IACpC,OAAO,EAAE,sCAAsC;IAC/C,MAAM,EAAE,CAAC,EAAC,MAAM,EAAC,EAAE,EAAE,CAAC,IAAA,WAAC,EAAA,yBAAyB,MAAM,CAAC,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AC,CAAA;QACnB,CAAC;IACH,CAAC;CACF,CAAA;AAED,kBAAe,GAAG,CAAA"}
@@ -0,0 +1,12 @@
1
+ import type { CodeKeywordDefinition, ErrorObject } from "../../../types";
2
+ export type LimitKwd = "maximum" | "minimum";
3
+ export type ExclusiveLimitKwd = "exclusiveMaximum" | "exclusiveMinimum";
4
+ type Comparison = "<=" | ">=" | "<" | ">";
5
+ export type LimitNumberError = ErrorObject<LimitKwd, {
6
+ limit: number;
7
+ comparison: Comparison;
8
+ }, number | {
9
+ $data: string;
10
+ }>;
11
+ declare const def: CodeKeywordDefinition;
12
+ export default def;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const codegen_1 = require("../../../compile/codegen");
4
+ const ops = codegen_1.operators;
5
+ const KWDs = {
6
+ maximum: {
7
+ exclusive: "exclusiveMaximum",
8
+ ops: [
9
+ { okStr: "<=", ok: ops.LTE, fail: ops.GT },
10
+ { okStr: "<", ok: ops.LT, fail: ops.GTE },
11
+ ],
12
+ },
13
+ minimum: {
14
+ exclusive: "exclusiveMinimum",
15
+ ops: [
16
+ { okStr: ">=", ok: ops.GTE, fail: ops.LT },
17
+ { okStr: ">", ok: ops.GT, fail: ops.LTE },
18
+ ],
19
+ },
20
+ };
21
+ const error = {
22
+ message: (cxt) => (0, codegen_1.str) `must be ${kwdOp(cxt).okStr} ${cxt.schemaCode}`,
23
+ params: (cxt) => (0, codegen_1._) `{comparison: ${kwdOp(cxt).okStr}, limit: ${cxt.schemaCode}}`,
24
+ };
25
+ const def = {
26
+ keyword: Object.keys(KWDs),
27
+ type: "number",
28
+ schemaType: "number",
29
+ $data: true,
30
+ error,
31
+ code(cxt) {
32
+ const { data, schemaCode } = cxt;
33
+ cxt.fail$data((0, codegen_1._) `${data} ${kwdOp(cxt).fail} ${schemaCode} || isNaN(${data})`);
34
+ },
35
+ };
36
+ function kwdOp(cxt) {
37
+ var _a;
38
+ const keyword = cxt.keyword;
39
+ const opsIdx = ((_a = cxt.parentSchema) === null || _a === void 0 ? void 0 : _a[KWDs[keyword].exclusive]) ? 1 : 0;
40
+ return KWDs[keyword].ops[opsIdx];
41
+ }
42
+ exports.default = def;
43
+ //# sourceMappingURL=limitNumber.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limitNumber.js","sourceRoot":"","sources":["../../../../lib/vocabularies/validation/draft04/limitNumber.ts"],"names":[],"mappings":";;AAOA,sDAAgE;AAEhE,MAAM,GAAG,GAAG,mBAAS,CAAA;AAmBrB,MAAM,IAAI,GAA8B;IACtC,OAAO,EAAE;QACP,SAAS,EAAE,kBAAkB;QAC7B,GAAG,EAAE;YACH,EAAC,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,EAAE,EAAC;YACxC,EAAC,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,GAAG,CAAC,GAAG,EAAC;SACxC;KACF;IACD,OAAO,EAAE;QACP,SAAS,EAAE,kBAAkB;QAC7B,GAAG,EAAE;YACH,EAAC,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,EAAE,EAAC;YACxC,EAAC,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,GAAG,CAAC,GAAG,EAAC;SACxC;KACF;CACF,CAAA;AAQD,MAAM,KAAK,GAA2B;IACpC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAA,aAAG,EAAA,WAAW,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,GAAG,CAAC,UAAU,EAAE;IACpE,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAA,WAAC,EAAA,gBAAgB,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,YAAY,GAAG,CAAC,UAAU,GAAG;CAChF,CAAA;AAED,MAAM,GAAG,GAA0B;IACjC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;IAC1B,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE,QAAQ;IACpB,KAAK,EAAE,IAAI;IACX,KAAK;IACL,IAAI,CAAC,GAAe;QAClB,MAAM,EAAC,IAAI,EAAE,UAAU,EAAC,GAAG,GAAG,CAAA;QAC9B,GAAG,CAAC,SAAS,CAAC,IAAA,WAAC,EAAA,GAAG,IAAI,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,UAAU,aAAa,IAAI,GAAG,CAAC,CAAA;IAC9E,CAAC;CACF,CAAA;AAED,SAAS,KAAK,CAAC,GAAoB;;IACjC,MAAM,OAAO,GAAG,GAAG,CAAC,OAAmB,CAAA;IACvC,MAAM,MAAM,GAAG,CAAA,MAAA,GAAG,CAAC,YAAY,0CAAG,IAAI,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAClE,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;AAClC,CAAC;AAED,kBAAe,GAAG,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { CodeKeywordDefinition } from "../../../types";
2
+ declare const def: CodeKeywordDefinition;
3
+ export default def;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const KWDs = {
4
+ exclusiveMaximum: "maximum",
5
+ exclusiveMinimum: "minimum",
6
+ };
7
+ const def = {
8
+ keyword: Object.keys(KWDs),
9
+ type: "number",
10
+ schemaType: "boolean",
11
+ code({ keyword, parentSchema }) {
12
+ const limitKwd = KWDs[keyword];
13
+ if (parentSchema[limitKwd] === undefined) {
14
+ throw new Error(`${keyword} can only be used with ${limitKwd}`);
15
+ }
16
+ },
17
+ };
18
+ exports.default = def;
19
+ //# sourceMappingURL=limitNumberExclusive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limitNumberExclusive.js","sourceRoot":"","sources":["../../../../lib/vocabularies/validation/draft04/limitNumberExclusive.ts"],"names":[],"mappings":";;AAQA,MAAM,IAAI,GAAyC;IACjD,gBAAgB,EAAE,SAAS;IAC3B,gBAAgB,EAAE,SAAS;CAC5B,CAAA;AAED,MAAM,GAAG,GAA0B;IACjC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;IAC1B,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE,SAAS;IACrB,IAAI,CAAC,EAAC,OAAO,EAAE,YAAY,EAAa;QACtC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAA4B,CAAC,CAAA;QACnD,IAAI,YAAY,CAAC,QAAQ,CAAC,KAAK,SAAS,EAAE,CAAC;YACzC,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,0BAA0B,QAAQ,EAAE,CAAC,CAAA;QACjE,CAAC;IACH,CAAC;CACF,CAAA;AAED,kBAAe,GAAG,CAAA"}
@@ -6,6 +6,8 @@ const limitLength_1 = require("./limitLength");
6
6
  const pattern_1 = require("./pattern");
7
7
  const limitProperties_1 = require("./limitProperties");
8
8
  const required_1 = require("./required");
9
+ const readOnly_1 = require("./readOnly");
10
+ const writeOnly_1 = require("./writeOnly");
9
11
  const limitItems_1 = require("./limitItems");
10
12
  const uniqueItems_1 = require("./uniqueItems");
11
13
  const const_1 = require("./const");
@@ -20,6 +22,8 @@ const validation = [
20
22
  // object
21
23
  limitProperties_1.default,
22
24
  required_1.default,
25
+ readOnly_1.default,
26
+ writeOnly_1.default,
23
27
  // array
24
28
  limitItems_1.default,
25
29
  uniqueItems_1.default,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/vocabularies/validation/index.ts"],"names":[],"mappings":";;AACA,+CAA2D;AAC3D,6CAAwD;AACxD,+CAAuC;AACvC,uCAA+C;AAC/C,uDAA+C;AAC/C,yCAAkD;AAClD,6CAAqC;AACrC,+CAA2D;AAC3D,mCAAgD;AAChD,iCAA6C;AAE7C,MAAM,UAAU,GAAe;IAC7B,SAAS;IACT,qBAAW;IACX,oBAAU;IACV,SAAS;IACT,qBAAW;IACX,iBAAO;IACP,SAAS;IACT,yBAAe;IACf,kBAAQ;IACR,QAAQ;IACR,oBAAU;IACV,qBAAW;IACX,MAAM;IACN,EAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAC;IAClD,EAAC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAC;IAC5C,eAAY;IACZ,cAAW;CACZ,CAAA;AAED,kBAAe,UAAU,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/vocabularies/validation/index.ts"],"names":[],"mappings":";;AACA,+CAA2D;AAC3D,6CAAwD;AACxD,+CAAuC;AACvC,uCAA+C;AAC/C,uDAA+C;AAC/C,yCAAkD;AAClD,yCAAwC;AACxC,2CAA0C;AAC1C,6CAAqC;AACrC,+CAA2D;AAC3D,mCAAgD;AAChD,iCAA6C;AAE7C,MAAM,UAAU,GAAe;IAC7B,SAAS;IACT,qBAAW;IACX,oBAAU;IACV,SAAS;IACT,qBAAW;IACX,iBAAO;IACP,SAAS;IACT,yBAAe;IACf,kBAAQ;IACR,kBAAe;IACf,mBAAgB;IAChB,QAAQ;IACR,oBAAU;IACV,qBAAW;IACX,MAAM;IACN,EAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAC;IAClD,EAAC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAC;IAC5C,eAAY;IACZ,cAAW;CACZ,CAAA;AAED,kBAAe,UAAU,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { CodeKeywordDefinition } from "../../types";
2
+ declare const def: CodeKeywordDefinition;
3
+ export default def;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const codegen_1 = require("../../compile/codegen");
4
+ const names_1 = require("../../compile/names");
5
+ const error = {
6
+ message: () => (0, codegen_1.str) `must NOT be present in request context`,
7
+ };
8
+ const def = {
9
+ keyword: "readOnly",
10
+ schemaType: "boolean",
11
+ error,
12
+ code(cxt) {
13
+ if (cxt.schema !== true)
14
+ return;
15
+ const apiContext = (0, codegen_1._) `(${names_1.default.this} && ${names_1.default.this}.apiContext)`;
16
+ cxt.fail((0, codegen_1._) `${apiContext} === "request"`);
17
+ },
18
+ };
19
+ exports.default = def;
20
+ //# sourceMappingURL=readOnly.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readOnly.js","sourceRoot":"","sources":["../../../lib/vocabularies/validation/readOnly.ts"],"names":[],"mappings":";;AAEA,mDAA4C;AAC5C,+CAAmC;AAEnC,MAAM,KAAK,GAA2B;IACpC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAA,aAAG,EAAA,wCAAwC;CAC3D,CAAA;AAED,MAAM,GAAG,GAA0B;IACjC,OAAO,EAAE,UAAU;IACnB,UAAU,EAAE,SAAS;IACrB,KAAK;IACL,IAAI,CAAC,GAAe;QAClB,IAAI,GAAG,CAAC,MAAM,KAAK,IAAI;YAAE,OAAM;QAE/B,MAAM,UAAU,GAAG,IAAA,WAAC,EAAA,IAAI,eAAC,CAAC,IAAI,OAAO,eAAC,CAAC,IAAI,cAAc,CAAA;QAEzD,GAAG,CAAC,IAAI,CAAC,IAAA,WAAC,EAAA,GAAG,UAAU,gBAAgB,CAAC,CAAA;IAC1C,CAAC;CACF,CAAA;AAED,kBAAe,GAAG,CAAA"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const code_1 = require("../code");
4
+ const oasContext_1 = require("../oasContext");
4
5
  const codegen_1 = require("../../compile/codegen");
5
6
  const util_1 = require("../../compile/util");
6
7
  const error = {
@@ -35,12 +36,18 @@ const def = {
35
36
  }
36
37
  }
37
38
  function allErrorsMode() {
39
+ var _a;
38
40
  if (useLoop || $data) {
39
41
  cxt.block$data(codegen_1.nil, loopAllRequired);
40
42
  }
41
43
  else {
42
44
  for (const prop of schema) {
43
- (0, code_1.checkReportMissingProp)(cxt, prop);
45
+ const skip = (_a = (0, oasContext_1.getSkipCondition)(cxt.parentSchema, prop)) !== null && _a !== void 0 ? _a : (0, codegen_1._) `false`;
46
+ /**
47
+ * Generate a runtime check: validate `required` only when this property
48
+ * should NOT be skipped in the current context (readOnly/writeOnly).
49
+ */
50
+ gen.if((0, codegen_1.not)(skip), () => (0, code_1.checkReportMissingProp)(cxt, prop));
44
51
  }
45
52
  }
46
53
  }
@@ -1 +1 @@
1
- {"version":3,"file":"required.js","sourceRoot":"","sources":["../../../lib/vocabularies/validation/required.ts"],"names":[],"mappings":";;AAEA,kCAMgB;AAChB,mDAAkE;AAClE,6CAAkD;AAQlD,MAAM,KAAK,GAA2B;IACpC,OAAO,EAAE,CAAC,EAAC,MAAM,EAAE,EAAC,eAAe,EAAC,EAAC,EAAE,EAAE,CAAC,IAAA,aAAG,EAAA,gCAAgC,eAAe,GAAG;IAC/F,MAAM,EAAE,CAAC,EAAC,MAAM,EAAE,EAAC,eAAe,EAAC,EAAC,EAAE,EAAE,CAAC,IAAA,WAAC,EAAA,qBAAqB,eAAe,GAAG;CAClF,CAAA;AAED,MAAM,GAAG,GAA0B;IACjC,OAAO,EAAE,UAAU;IACnB,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE,OAAO;IACnB,KAAK,EAAE,IAAI;IACX,KAAK;IACL,IAAI,CAAC,GAAe;QAClB,MAAM,EAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAC,GAAG,GAAG,CAAA;QACtD,MAAM,EAAC,IAAI,EAAC,GAAG,EAAE,CAAA;QACjB,IAAI,CAAC,KAAK,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EAAC,KAAK,CAAC,EAAE,GAAG,EAAE;oBACtB,GAAG,CAAC,KAAK,EAAE,CAAA;oBACX,GAAG,CAAC,KAAK,EAAE,CAAA;gBACb,CAAC,CAAC,CAAA;YACJ,CAAC,EACD,aAAG,CACJ,CAAA;QACH,CAAC;IACH,CAAC;CACF,CAAA;AAED,kBAAe,GAAG,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { CodeKeywordDefinition } from "../../types";
2
+ declare const def: CodeKeywordDefinition;
3
+ export default def;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const codegen_1 = require("../../compile/codegen");
4
+ const names_1 = require("../../compile/names");
5
+ const error = {
6
+ message: () => (0, codegen_1.str) `must NOT be present in response context`,
7
+ };
8
+ const def = {
9
+ keyword: "writeOnly",
10
+ schemaType: "boolean",
11
+ error,
12
+ code(cxt) {
13
+ if (cxt.schema !== true)
14
+ return;
15
+ const apiContext = (0, codegen_1._) `(${names_1.default.this} && ${names_1.default.this}.apiContext)`;
16
+ cxt.fail((0, codegen_1._) `${apiContext} === "response"`);
17
+ },
18
+ };
19
+ exports.default = def;
20
+ //# sourceMappingURL=writeOnly.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writeOnly.js","sourceRoot":"","sources":["../../../lib/vocabularies/validation/writeOnly.ts"],"names":[],"mappings":";;AAEA,mDAA4C;AAC5C,+CAAmC;AAEnC,MAAM,KAAK,GAA2B;IACpC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAA,aAAG,EAAA,yCAAyC;CAC5D,CAAA;AAED,MAAM,GAAG,GAA0B;IACjC,OAAO,EAAE,WAAW;IACpB,UAAU,EAAE,SAAS;IACrB,KAAK;IACL,IAAI,CAAC,GAAe;QAClB,IAAI,GAAG,CAAC,MAAM,KAAK,IAAI;YAAE,OAAM;QAC/B,MAAM,UAAU,GAAG,IAAA,WAAC,EAAA,IAAI,eAAC,CAAC,IAAI,OAAO,eAAC,CAAC,IAAI,cAAc,CAAA;QAEzD,GAAG,CAAC,IAAI,CAAC,IAAA,WAAC,EAAA,GAAG,UAAU,iBAAiB,CAAC,CAAA;IAC3C,CAAC;CACF,CAAA;AAED,kBAAe,GAAG,CAAA"}
@@ -68,6 +68,7 @@ export {
68
68
  AsyncValidateFunction,
69
69
  ErrorObject,
70
70
  ErrorNoParams,
71
+ Context,
71
72
  } from "./types"
72
73
 
73
74
  export {Plugin, Options, CodeOptions, InstanceOptions, Logger, ErrorsTextOptions} from "./core"
@@ -62,6 +62,7 @@ export {
62
62
  AsyncValidateFunction,
63
63
  ErrorObject,
64
64
  ErrorNoParams,
65
+ Context,
65
66
  } from "./types"
66
67
 
67
68
  export {Plugin, Options, CodeOptions, InstanceOptions, Logger, ErrorsTextOptions} from "./core"
@@ -57,6 +57,7 @@ export {
57
57
  SchemaValidateFunction,
58
58
  ErrorObject,
59
59
  ErrorNoParams,
60
+ Context,
60
61
  } from "./types"
61
62
 
62
63
  export {Plugin, Options, CodeOptions, InstanceOptions, Logger, ErrorsTextOptions} from "./core"
@@ -56,6 +56,7 @@ export interface SchemaCxt {
56
56
  readonly createErrors?: boolean
57
57
  readonly opts: InstanceOptions // Ajv instance option.
58
58
  readonly self: Ajv // current Ajv instance
59
+ readonly isAllOfVariant?: boolean // if the current schema is direct child of allOf
59
60
  }
60
61
 
61
62
  export interface SchemaObjCxt extends SchemaCxt {
@@ -116,6 +117,7 @@ export function compileSchema(this: Ajv, sch: SchemaEnv): SchemaEnv {
116
117
  const {es5, lines} = this.opts.code
117
118
  const {ownProperties} = this.opts
118
119
  const gen = new CodeGen(this.scope, {es5, lines, ownProperties})
120
+
119
121
  let _ValidationError
120
122
  if (sch.$async) {
121
123
  _ValidationError = gen.scopeValue("Error", {
@@ -164,7 +166,9 @@ export function compileSchema(this: Ajv, sch: SchemaEnv): SchemaEnv {
164
166
  gen.optimize(this.opts.code.optimize)
165
167
  // gen.optimize(1)
166
168
  const validateCode = gen.toString()
167
- sourceCode = `${gen.scopeRefs(N.scope)}return ${validateCode}`
169
+ sourceCode = `const visitedNodesForRef = new WeakMap(); ${gen.scopeRefs(
170
+ N.scope
171
+ )}return ${validateCode}`
168
172
  // console.log((codeSize += sourceCode.length), (nodeCount += gen.nodeCount))
169
173
  if (this.opts.code.process) sourceCode = this.opts.code.process(sourceCode, sch)
170
174
  // console.log("\n\n\n *** \n", sourceCode)
@@ -206,9 +210,9 @@ export function resolveRef(
206
210
  this: Ajv,
207
211
  root: SchemaEnv,
208
212
  baseId: string,
209
- ref: string
213
+ origRef: string
210
214
  ): AnySchema | SchemaEnv | undefined {
211
- ref = resolveUrl(this.opts.uriResolver, baseId, ref)
215
+ const ref = resolveUrl(this.opts.uriResolver, baseId, origRef)
212
216
  const schOrFunc = root.refs[ref]
213
217
  if (schOrFunc) return schOrFunc
214
218
 
@@ -219,6 +223,15 @@ export function resolveRef(
219
223
  if (schema) _sch = new SchemaEnv({schema, schemaId, root, baseId})
220
224
  }
221
225
 
226
+ if (_sch === undefined && this.opts.loadSchemaSync) {
227
+ const remoteSchema = this.opts.loadSchemaSync(baseId, origRef, ref)
228
+
229
+ if (remoteSchema && !(this.refs[ref] || this.schemas[ref])) {
230
+ this.addSchema(remoteSchema, ref, undefined)
231
+ _sch = resolve.call(this, root, ref)
232
+ }
233
+ }
234
+
222
235
  if (_sch === undefined) return
223
236
  return (root.refs[ref] = inlineOrCompile.call(this, _sch))
224
237
  }
@@ -65,7 +65,9 @@ export default function compileParser(
65
65
  parserFunction(cxt)
66
66
  gen.optimize(this.opts.code.optimize)
67
67
  const parseFuncCode = gen.toString()
68
- sourceCode = `${gen.scopeRefs(N.scope)}return ${parseFuncCode}`
68
+ sourceCode = `const visitedNodesForRef = new WeakMap(); ${gen.scopeRefs(
69
+ N.scope
70
+ )}return ${parseFuncCode}`
69
71
  const makeParse = new Function(`${N.scope}`, sourceCode)
70
72
  const parse: (json: string) => unknown = makeParse(this.scope.get())
71
73
  this.scope.value(parseName, {ref: parse})
@@ -61,7 +61,9 @@ export default function compileSerializer(
61
61
  })
62
62
  gen.optimize(this.opts.code.optimize)
63
63
  const serializeFuncCode = gen.toString()
64
- sourceCode = `${gen.scopeRefs(N.scope)}return ${serializeFuncCode}`
64
+ sourceCode = `const visitedNodesForRef = new WeakMap(); ${gen.scopeRefs(
65
+ N.scope
66
+ )}return ${serializeFuncCode}`
65
67
  const makeSerialize = new Function(`${N.scope}`, sourceCode)
66
68
  const serialize: (data: unknown) => string = makeSerialize(this.scope.get())
67
69
  this.scope.value(serializeName, {ref: serialize})
@@ -10,6 +10,7 @@ const names = {
10
10
  parentDataProperty: new Name("parentDataProperty"),
11
11
  rootData: new Name("rootData"), // root data - same as the data passed to the first/top validation function
12
12
  dynamicAnchors: new Name("dynamicAnchors"), // used to support recursiveRef and dynamicRef
13
+ isAllOfVariant: new Name("isAllOfVariant"), // used to check in runtime if the current function (ref) is called from allOf
13
14
  // function scoped variables
14
15
  vErrors: new Name("vErrors"), // null or array of validation errors
15
16
  errors: new Name("errors"), // counter of validation errors
@@ -66,7 +66,7 @@ function validateFunction(
66
66
  function destructureValCxt(opts: InstanceOptions): Code {
67
67
  return _`{${N.instancePath}="", ${N.parentData}, ${N.parentDataProperty}, ${N.rootData}=${
68
68
  N.data
69
- }${opts.dynamicRef ? _`, ${N.dynamicAnchors}={}` : nil}}={}`
69
+ }${opts.dynamicRef ? _`, ${N.dynamicAnchors}={}` : nil}, ${N.isAllOfVariant} = 0}={}`
70
70
  }
71
71
 
72
72
  function destructureValCxtES5(gen: CodeGen, opts: InstanceOptions): void {
@@ -77,6 +77,7 @@ function destructureValCxtES5(gen: CodeGen, opts: InstanceOptions): void {
77
77
  gen.var(N.parentData, _`${N.valCxt}.${N.parentData}`)
78
78
  gen.var(N.parentDataProperty, _`${N.valCxt}.${N.parentDataProperty}`)
79
79
  gen.var(N.rootData, _`${N.valCxt}.${N.rootData}`)
80
+ gen.var(N.isAllOfVariant, _`${N.valCxt}.${N.isAllOfVariant}`)
80
81
  if (opts.dynamicRef) gen.var(N.dynamicAnchors, _`${N.valCxt}.${N.dynamicAnchors}`)
81
82
  },
82
83
  () => {
@@ -84,6 +85,7 @@ function destructureValCxtES5(gen: CodeGen, opts: InstanceOptions): void {
84
85
  gen.var(N.parentData, _`undefined`)
85
86
  gen.var(N.parentDataProperty, _`undefined`)
86
87
  gen.var(N.rootData, N.data)
88
+ gen.var(N.isAllOfVariant, _`0`)
87
89
  if (opts.dynamicRef) gen.var(N.dynamicAnchors, _`{}`)
88
90
  }
89
91
  )
@@ -261,11 +263,20 @@ function iterateKeywords(it: SchemaObjCxt, group: RuleGroup): void {
261
263
  if (useDefaults) assignDefaults(it, group.type)
262
264
  gen.block(() => {
263
265
  for (const rule of group.rules) {
264
- if (shouldUseRule(schema, rule)) {
266
+ if (shouldUseRule(schema, rule) || shouldForceUnevaluatedProperties(schema, rule)) {
265
267
  keywordCode(it, rule.keyword, rule.definition, group.type)
266
268
  }
267
269
  }
268
270
  })
271
+
272
+ function shouldForceUnevaluatedProperties(schemaObj: AnySchemaObject, rule: Rule): boolean {
273
+ return !!(
274
+ rule.keyword === "unevaluatedProperties" &&
275
+ (schemaObj.properties || schemaObj.patternProperties) &&
276
+ !it.isAllOfVariant &&
277
+ it.opts.defaultUnevaluatedProperties === false
278
+ )
279
+ }
269
280
  }
270
281
 
271
282
  function checkStrictTypes(it: SchemaObjCxt, types: JSONType[]): void {
@@ -492,11 +503,17 @@ export class KeywordCxt implements KeywordErrorCxt {
492
503
  }
493
504
  }
494
505
 
495
- subschema(appl: SubschemaArgs, valid: Name): SchemaCxt {
506
+ subschema(appl: SubschemaArgs, valid: Name, isAllOfVariant?: boolean): SchemaCxt {
496
507
  const subschema = getSubschema(this.it, appl)
497
508
  extendSubschemaData(subschema, this.it, appl)
498
509
  extendSubschemaMode(subschema, appl)
499
- const nextContext = {...this.it, ...subschema, items: undefined, props: undefined}
510
+ const nextContext = {
511
+ ...this.it,
512
+ ...subschema,
513
+ items: undefined,
514
+ props: undefined,
515
+ isAllOfVariant,
516
+ }
500
517
  subschemaCode(nextContext, valid)
501
518
  return nextContext
502
519
  }
@@ -68,7 +68,13 @@ import DefaultUriResolver from "./runtime/uri"
68
68
  const defaultRegExp: RegExpEngine = (str, flags) => new RegExp(str, flags)
69
69
  defaultRegExp.code = "new RegExp"
70
70
 
71
- const META_IGNORE_OPTIONS: (keyof Options)[] = ["removeAdditional", "useDefaults", "coerceTypes"]
71
+ const META_IGNORE_OPTIONS: (keyof Options)[] = [
72
+ "removeAdditional",
73
+ "useDefaults",
74
+ "coerceTypes",
75
+ "defaultUnevaluatedProperties",
76
+ "defaultAdditionalProperties",
77
+ ]
72
78
  const EXT_SCOPE_NAMES = new Set([
73
79
  "validate",
74
80
  "serialize",
@@ -116,8 +122,12 @@ export interface CurrentOptions {
116
122
  schemas?: AnySchema[] | {[Key in string]?: AnySchema}
117
123
  logger?: Logger | false
118
124
  loadSchema?: (uri: string) => Promise<AnySchemaObject>
125
+ loadSchemaSync?: (base: string, $ref: string, id: string) => AnySchemaObject | boolean
119
126
  // options to modify validated data:
120
127
  removeAdditional?: boolean | "all" | "failing"
128
+ defaultUnevaluatedProperties?: boolean
129
+ defaultAdditionalProperties?: boolean // @deprecated
130
+
121
131
  useDefaults?: boolean | "empty"
122
132
  coerceTypes?: boolean | "array"
123
133
  // advanced options:
@@ -334,6 +344,15 @@ export default class Ajv {
334
344
  return (this.opts.defaultMeta = typeof meta == "object" ? meta[schemaId] || meta : undefined)
335
345
  }
336
346
 
347
+ // Set the defaultUnevaluatedProperties option.
348
+ // WARNING: This only affects schemas compiled AFTER this method is called.
349
+ // Already-compiled schemas in the cache will NOT be affected.
350
+ // Consider clearing the cache or creating a new Ajv instance if you need
351
+ // different behavior for the same schemas.
352
+ setDefaultUnevaluatedProperties(value: boolean): void {
353
+ this.opts.defaultUnevaluatedProperties = value
354
+ }
355
+
337
356
  // Validate data using schema
338
357
  // AnySchema will be compiled and cached using schema itself as a key for Map
339
358
  validate(schema: Schema | string, data: unknown): boolean
@@ -0,0 +1,79 @@
1
+ import type {AnySchemaObject, Options} from "./core"
2
+ import AjvCore from "./core"
3
+ import draft4Vocabularies from "./vocabularies/draft4"
4
+ import discriminator from "./vocabularies/discriminator"
5
+ import * as draft4MetaSchema from "./refs/json-schema-draft-04.json"
6
+
7
+ const META_SUPPORT_DATA = ["/properties"]
8
+
9
+ const META_SCHEMA_ID = "http://json-schema.org/draft-04/schema"
10
+
11
+ export class Ajv extends AjvCore {
12
+ constructor(opts: Options = {}) {
13
+ super({
14
+ ...opts,
15
+ schemaId: "id",
16
+ dynamicRef: true,
17
+ unevaluated: true,
18
+ })
19
+ }
20
+
21
+ _addVocabularies(): void {
22
+ super._addVocabularies()
23
+ draft4Vocabularies.forEach((v) => this.addVocabulary(v))
24
+ if (this.opts.discriminator) this.addKeyword(discriminator)
25
+ }
26
+
27
+ _addDefaultMetaSchema(): void {
28
+ super._addDefaultMetaSchema()
29
+ if (!this.opts.meta) return
30
+ const metaSchema = this.opts.$data
31
+ ? this.$dataMetaSchema(draft4MetaSchema, META_SUPPORT_DATA)
32
+ : draft4MetaSchema
33
+ this.addMetaSchema(metaSchema, META_SCHEMA_ID, false)
34
+ this.refs["http://json-schema.org/schema"] = META_SCHEMA_ID
35
+ }
36
+
37
+ defaultMeta(): string | AnySchemaObject | undefined {
38
+ return (this.opts.defaultMeta =
39
+ super.defaultMeta() || (this.getSchema(META_SCHEMA_ID) ? META_SCHEMA_ID : undefined))
40
+ }
41
+ }
42
+
43
+ module.exports = exports = Ajv
44
+ Object.defineProperty(exports, "__esModule", {value: true})
45
+
46
+ export default Ajv
47
+
48
+ export {
49
+ Format,
50
+ FormatDefinition,
51
+ AsyncFormatDefinition,
52
+ KeywordDefinition,
53
+ KeywordErrorDefinition,
54
+ CodeKeywordDefinition,
55
+ MacroKeywordDefinition,
56
+ FuncKeywordDefinition,
57
+ Vocabulary,
58
+ Schema,
59
+ SchemaObject,
60
+ AnySchemaObject,
61
+ AsyncSchema,
62
+ AnySchema,
63
+ ValidateFunction,
64
+ AsyncValidateFunction,
65
+ SchemaValidateFunction,
66
+ ErrorObject,
67
+ ErrorNoParams,
68
+ Context,
69
+ } from "./types"
70
+
71
+ export {Plugin, Options, CodeOptions, InstanceOptions, Logger, ErrorsTextOptions} from "./core"
72
+ export {SchemaCxt, SchemaObjCxt} from "./compile"
73
+ export {KeywordCxt} from "./compile/validate"
74
+ export {DefinedError} from "./vocabularies/errors"
75
+ export {JSONType} from "./compile/rules"
76
+ export {JSONSchemaType} from "./types/json-schema"
77
+ export {_, str, stringify, nil, Name, Code, CodeGen, CodeGenOptions} from "./compile/codegen"
78
+ export {default as ValidationError} from "./runtime/validation_error"
79
+ export {default as MissingRefError} from "./compile/ref_error"