@spotlightjs/spotlight 4.11.4 → 4.11.5

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