@versionzero/schema 1.0.0

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 (401) hide show
  1. package/LICENSE +177 -0
  2. package/README.md +246 -0
  3. package/package.json +84 -0
  4. package/src/compilation/handler-compilation.js +28 -0
  5. package/src/compilation/metadata-compilation.js +35 -0
  6. package/src/compilation/schema-compilation.js +142 -0
  7. package/src/compilation/selection-compilation.js +84 -0
  8. package/src/compilation/union-compilation.js +510 -0
  9. package/src/compilation/values-compilation.js +35 -0
  10. package/src/compiled-schema.js +1709 -0
  11. package/src/constants.js +1 -0
  12. package/src/core-library/index.js +32 -0
  13. package/src/core-library/processors/aggregation-operators.js +75 -0
  14. package/src/core-library/processors/alpha-constraint.js +20 -0
  15. package/src/core-library/processors/alphanum-constraint.js +20 -0
  16. package/src/core-library/processors/array-operator.js +51 -0
  17. package/src/core-library/processors/assert-constraint.js +75 -0
  18. package/src/core-library/processors/base64-constraint.js +26 -0
  19. package/src/core-library/processors/camel-case-operator.js +24 -0
  20. package/src/core-library/processors/capitalize-operator.js +16 -0
  21. package/src/core-library/processors/cardnum-constraint.js +193 -0
  22. package/src/core-library/processors/ceil-operator.js +44 -0
  23. package/src/core-library/processors/collapse-operator.js +29 -0
  24. package/src/core-library/processors/compact-operator.js +34 -0
  25. package/src/core-library/processors/compile-operator.js +65 -0
  26. package/src/core-library/processors/concat-operator.js +51 -0
  27. package/src/core-library/processors/conditional-operators.js +301 -0
  28. package/src/core-library/processors/constant-case-operator.js +16 -0
  29. package/src/core-library/processors/data-size-operator.js +86 -0
  30. package/src/core-library/processors/date-object-operator.js +54 -0
  31. package/src/core-library/processors/date-operator.js +67 -0
  32. package/src/core-library/processors/date-range-constraint.js +76 -0
  33. package/src/core-library/processors/defined-constraint.js +30 -0
  34. package/src/core-library/processors/each-operator.js +57 -0
  35. package/src/core-library/processors/email-constraint.js +112 -0
  36. package/src/core-library/processors/entries-operator.js +25 -0
  37. package/src/core-library/processors/eq-constraint.js +37 -0
  38. package/src/core-library/processors/filter-operator.js +74 -0
  39. package/src/core-library/processors/find-schema-operator.js +45 -0
  40. package/src/core-library/processors/flatten-operator.js +40 -0
  41. package/src/core-library/processors/floor-operator.js +47 -0
  42. package/src/core-library/processors/get-operator.js +44 -0
  43. package/src/core-library/processors/group-by-operator.js +84 -0
  44. package/src/core-library/processors/has-prefix-constraint.js +37 -0
  45. package/src/core-library/processors/has-suffix-constraint.js +35 -0
  46. package/src/core-library/processors/hex-constraint.js +20 -0
  47. package/src/core-library/processors/hostname-constraint.js +22 -0
  48. package/src/core-library/processors/http-url-constraint.js +27 -0
  49. package/src/core-library/processors/in-constraint.js +66 -0
  50. package/src/core-library/processors/index-by-operator.js +98 -0
  51. package/src/core-library/processors/index.js +131 -0
  52. package/src/core-library/processors/input-operator.js +23 -0
  53. package/src/core-library/processors/instanceof-constraint.js +38 -0
  54. package/src/core-library/processors/integer-constraint.js +22 -0
  55. package/src/core-library/processors/invoke-operator.js +33 -0
  56. package/src/core-library/processors/ipv4-constraint.js +188 -0
  57. package/src/core-library/processors/ipv6-constraint.js +205 -0
  58. package/src/core-library/processors/is-array-constraint.js +21 -0
  59. package/src/core-library/processors/is-date-constraint.js +22 -0
  60. package/src/core-library/processors/is-number-constraint.js +21 -0
  61. package/src/core-library/processors/is-object-constraint.js +21 -0
  62. package/src/core-library/processors/is-string-constraint.js +21 -0
  63. package/src/core-library/processors/join-operator.js +41 -0
  64. package/src/core-library/processors/json-constraint.js +22 -0
  65. package/src/core-library/processors/json-decode-operator.js +25 -0
  66. package/src/core-library/processors/json-encode-operator.js +35 -0
  67. package/src/core-library/processors/kebab-case-operator.js +23 -0
  68. package/src/core-library/processors/keys-operator.js +20 -0
  69. package/src/core-library/processors/length-constraint.js +85 -0
  70. package/src/core-library/processors/lookup-operator.js +84 -0
  71. package/src/core-library/processors/lowercase-operator.js +14 -0
  72. package/src/core-library/processors/map-operator.js +84 -0
  73. package/src/core-library/processors/match-operator.js +64 -0
  74. package/src/core-library/processors/matches-constraint.js +54 -0
  75. package/src/core-library/processors/math-operators.js +151 -0
  76. package/src/core-library/processors/merge-deep-operator.js +61 -0
  77. package/src/core-library/processors/merge-operator.js +54 -0
  78. package/src/core-library/processors/metadata-operator.js +100 -0
  79. package/src/core-library/processors/negative-constraint.js +23 -0
  80. package/src/core-library/processors/never-constraint.js +69 -0
  81. package/src/core-library/processors/non-empty-constraint.js +59 -0
  82. package/src/core-library/processors/not-constraint.js +71 -0
  83. package/src/core-library/processors/number-operator.js +24 -0
  84. package/src/core-library/processors/numeric-constraint.js +22 -0
  85. package/src/core-library/processors/object-operator.js +38 -0
  86. package/src/core-library/processors/omit-operator.js +57 -0
  87. package/src/core-library/processors/parallel-operator.js +64 -0
  88. package/src/core-library/processors/pascal-case-operator.js +16 -0
  89. package/src/core-library/processors/phone-constraint.js +235 -0
  90. package/src/core-library/processors/pick-operator.js +62 -0
  91. package/src/core-library/processors/pipeline-operator.js +63 -0
  92. package/src/core-library/processors/port-constraint.js +22 -0
  93. package/src/core-library/processors/positive-constraint.js +23 -0
  94. package/src/core-library/processors/process-operator.js +55 -0
  95. package/src/core-library/processors/property-operator.js +49 -0
  96. package/src/core-library/processors/range-constraint.js +72 -0
  97. package/src/core-library/processors/reference-operator.js +79 -0
  98. package/src/core-library/processors/require-constraint.js +74 -0
  99. package/src/core-library/processors/reverse-operator.js +20 -0
  100. package/src/core-library/processors/round-operator.js +53 -0
  101. package/src/core-library/processors/schema-handler-operators.js +54 -0
  102. package/src/core-library/processors/semver-constraint.js +282 -0
  103. package/src/core-library/processors/sequence-processors.js +406 -0
  104. package/src/core-library/processors/sort-operator.js +52 -0
  105. package/src/core-library/processors/split-operator.js +43 -0
  106. package/src/core-library/processors/string-extra-operators.js +141 -0
  107. package/src/core-library/processors/string-operator.js +34 -0
  108. package/src/core-library/processors/target-operator.js +30 -0
  109. package/src/core-library/processors/template-operator.js +60 -0
  110. package/src/core-library/processors/title-case-operator.js +17 -0
  111. package/src/core-library/processors/trim-operator.js +14 -0
  112. package/src/core-library/processors/truthy-constraint.js +35 -0
  113. package/src/core-library/processors/type-operator.js +24 -0
  114. package/src/core-library/processors/unique-operator.js +21 -0
  115. package/src/core-library/processors/uppercase-operator.js +14 -0
  116. package/src/core-library/processors/url-constraint.js +31 -0
  117. package/src/core-library/processors/url-decode-operator.js +50 -0
  118. package/src/core-library/processors/url-encode-operator.js +44 -0
  119. package/src/core-library/processors/uuid-constraint.js +31 -0
  120. package/src/core-library/processors/values-operator.js +20 -0
  121. package/src/core-library/schemas/any-schema.js +23 -0
  122. package/src/core-library/schemas/array-schema.js +8 -0
  123. package/src/core-library/schemas/boolean-schema.js +10 -0
  124. package/src/core-library/schemas/date-schema.js +12 -0
  125. package/src/core-library/schemas/function-schema.js +40 -0
  126. package/src/core-library/schemas/number-schema.js +9 -0
  127. package/src/core-library/schemas/object-schema.js +10 -0
  128. package/src/core-library/schemas/root-schema.js +21 -0
  129. package/src/core-library/schemas/string-schema.js +9 -0
  130. package/src/core-library-node/index.js +47 -0
  131. package/src/core-library-node/processors/base64-decode-operator.js +20 -0
  132. package/src/core-library-node/processors/base64-encode-operator.js +20 -0
  133. package/src/core-library-node/processors/buffer-operator.js +39 -0
  134. package/src/core-library-node/processors/directory-constraint.js +35 -0
  135. package/src/core-library-node/processors/executable-constraint.js +34 -0
  136. package/src/core-library-node/processors/file-constraint.js +34 -0
  137. package/src/core-library-node/processors/file-size-constraint.js +94 -0
  138. package/src/core-library-node/processors/is-buffer-constraint.js +21 -0
  139. package/src/core-library-node/processors/reachable-constraint.js +28 -0
  140. package/src/core-library-node/processors/readable-constraint.js +34 -0
  141. package/src/core-library-node/processors/writable-constraint.js +59 -0
  142. package/src/core-library-node/schemas/buffer-schema.js +10 -0
  143. package/src/errors.js +209 -0
  144. package/src/executor/array-executor.js +78 -0
  145. package/src/executor/conditional-executor.js +134 -0
  146. package/src/executor/each-executor.js +68 -0
  147. package/src/executor/executor.js +123 -0
  148. package/src/executor/object-executor.js +98 -0
  149. package/src/executor/parallel-executor.js +43 -0
  150. package/src/executor/pipeline-executor.js +65 -0
  151. package/src/executor/sequence-executor.js +206 -0
  152. package/src/executor/serial-executor.js +24 -0
  153. package/src/executor/step-executor.js +68 -0
  154. package/src/helpers/case.js +124 -0
  155. package/src/helpers/data-size.js +144 -0
  156. package/src/helpers/debug-sink.js +15 -0
  157. package/src/helpers/deep.js +280 -0
  158. package/src/helpers/format.js +121 -0
  159. package/src/helpers/has-string-properties.js +30 -0
  160. package/src/helpers/index.js +16 -0
  161. package/src/helpers/object.js +115 -0
  162. package/src/helpers/parse-date.js +75 -0
  163. package/src/helpers/path.js +28 -0
  164. package/src/helpers/regex.js +18 -0
  165. package/src/helpers/stringify.js +309 -0
  166. package/src/helpers/to-data.js +64 -0
  167. package/src/helpers/truthy.js +55 -0
  168. package/src/index.js +29 -0
  169. package/src/schema-compiler.js +531 -0
  170. package/src/schema-location.js +200 -0
  171. package/src/schema-resolver.js +546 -0
  172. package/src/schema.js +1182 -0
  173. package/src/traversal/executors/check-condition.js +42 -0
  174. package/src/traversal/executors/check-input.js +27 -0
  175. package/src/traversal/executors/check-required.js +19 -0
  176. package/src/traversal/executors/check-schema.js +45 -0
  177. package/src/traversal/executors/defaults.js +21 -0
  178. package/src/traversal/executors/enter-existing.js +25 -0
  179. package/src/traversal/executors/enter-input.js +25 -0
  180. package/src/traversal/executors/enter.js +37 -0
  181. package/src/traversal/executors/exit.js +74 -0
  182. package/src/traversal/executors/finalize.js +64 -0
  183. package/src/traversal/executors/index.js +42 -0
  184. package/src/traversal/executors/normalize.js +38 -0
  185. package/src/traversal/executors/prepare-existing.js +27 -0
  186. package/src/traversal/executors/prepare-pending.js +54 -0
  187. package/src/traversal/executors/resolve-union.js +50 -0
  188. package/src/traversal/executors/serialize.js +48 -0
  189. package/src/traversal/executors/transform-early.js +51 -0
  190. package/src/traversal/executors/transform.js +68 -0
  191. package/src/traversal/executors/traversal-state-executor.js +46 -0
  192. package/src/traversal/executors/validate.js +63 -0
  193. package/src/traversal/traversal-context.js +231 -0
  194. package/src/traversal/traversal-state.js +809 -0
  195. package/src/types.js +102 -0
  196. package/src/value-processor/composed-value-processor.js +43 -0
  197. package/src/value-processor/defined-value-processor.js +72 -0
  198. package/src/value-processor/function-value-processor.js +68 -0
  199. package/src/value-processor/parameterized-value-processor.js +45 -0
  200. package/src/value-processor/parameters-value-processor.js +178 -0
  201. package/src/value-processor/spec.js +89 -0
  202. package/src/value-processor/value-processor.js +105 -0
  203. package/types/compilation/handler-compilation.d.ts +13 -0
  204. package/types/compilation/metadata-compilation.d.ts +6 -0
  205. package/types/compilation/schema-compilation.d.ts +32 -0
  206. package/types/compilation/selection-compilation.d.ts +9 -0
  207. package/types/compilation/union-compilation.d.ts +42 -0
  208. package/types/compilation/values-compilation.d.ts +12 -0
  209. package/types/compiled-schema.d.ts +883 -0
  210. package/types/constants.d.ts +1 -0
  211. package/types/core-library/index.d.ts +7 -0
  212. package/types/core-library/processors/aggregation-operators.d.ts +24 -0
  213. package/types/core-library/processors/alpha-constraint.d.ts +9 -0
  214. package/types/core-library/processors/alphanum-constraint.d.ts +9 -0
  215. package/types/core-library/processors/array-operator.d.ts +12 -0
  216. package/types/core-library/processors/assert-constraint.d.ts +30 -0
  217. package/types/core-library/processors/base64-constraint.d.ts +11 -0
  218. package/types/core-library/processors/camel-case-operator.d.ts +17 -0
  219. package/types/core-library/processors/capitalize-operator.d.ts +11 -0
  220. package/types/core-library/processors/cardnum-constraint.d.ts +51 -0
  221. package/types/core-library/processors/ceil-operator.d.ts +30 -0
  222. package/types/core-library/processors/collapse-operator.d.ts +24 -0
  223. package/types/core-library/processors/compact-operator.d.ts +29 -0
  224. package/types/core-library/processors/compile-operator.d.ts +34 -0
  225. package/types/core-library/processors/concat-operator.d.ts +23 -0
  226. package/types/core-library/processors/conditional-operators.d.ts +219 -0
  227. package/types/core-library/processors/constant-case-operator.d.ts +9 -0
  228. package/types/core-library/processors/data-size-operator.d.ts +31 -0
  229. package/types/core-library/processors/date-object-operator.d.ts +16 -0
  230. package/types/core-library/processors/date-operator.d.ts +21 -0
  231. package/types/core-library/processors/date-range-constraint.d.ts +26 -0
  232. package/types/core-library/processors/defined-constraint.d.ts +20 -0
  233. package/types/core-library/processors/each-operator.d.ts +34 -0
  234. package/types/core-library/processors/email-constraint.d.ts +54 -0
  235. package/types/core-library/processors/entries-operator.d.ts +13 -0
  236. package/types/core-library/processors/eq-constraint.d.ts +20 -0
  237. package/types/core-library/processors/filter-operator.d.ts +35 -0
  238. package/types/core-library/processors/find-schema-operator.d.ts +28 -0
  239. package/types/core-library/processors/flatten-operator.d.ts +26 -0
  240. package/types/core-library/processors/floor-operator.d.ts +33 -0
  241. package/types/core-library/processors/get-operator.d.ts +31 -0
  242. package/types/core-library/processors/group-by-operator.d.ts +36 -0
  243. package/types/core-library/processors/has-prefix-constraint.d.ts +22 -0
  244. package/types/core-library/processors/has-suffix-constraint.d.ts +20 -0
  245. package/types/core-library/processors/hex-constraint.d.ts +9 -0
  246. package/types/core-library/processors/hostname-constraint.d.ts +11 -0
  247. package/types/core-library/processors/http-url-constraint.d.ts +9 -0
  248. package/types/core-library/processors/in-constraint.d.ts +27 -0
  249. package/types/core-library/processors/index-by-operator.d.ts +26 -0
  250. package/types/core-library/processors/index.d.ts +8 -0
  251. package/types/core-library/processors/input-operator.d.ts +20 -0
  252. package/types/core-library/processors/instanceof-constraint.d.ts +23 -0
  253. package/types/core-library/processors/integer-constraint.d.ts +9 -0
  254. package/types/core-library/processors/invoke-operator.d.ts +12 -0
  255. package/types/core-library/processors/ipv4-constraint.d.ts +37 -0
  256. package/types/core-library/processors/ipv6-constraint.d.ts +34 -0
  257. package/types/core-library/processors/is-array-constraint.d.ts +10 -0
  258. package/types/core-library/processors/is-date-constraint.d.ts +10 -0
  259. package/types/core-library/processors/is-number-constraint.d.ts +10 -0
  260. package/types/core-library/processors/is-object-constraint.d.ts +10 -0
  261. package/types/core-library/processors/is-string-constraint.d.ts +10 -0
  262. package/types/core-library/processors/join-operator.d.ts +29 -0
  263. package/types/core-library/processors/json-constraint.d.ts +10 -0
  264. package/types/core-library/processors/json-decode-operator.d.ts +9 -0
  265. package/types/core-library/processors/json-encode-operator.d.ts +27 -0
  266. package/types/core-library/processors/kebab-case-operator.d.ts +16 -0
  267. package/types/core-library/processors/keys-operator.d.ts +9 -0
  268. package/types/core-library/processors/length-constraint.d.ts +34 -0
  269. package/types/core-library/processors/lookup-operator.d.ts +36 -0
  270. package/types/core-library/processors/lowercase-operator.d.ts +9 -0
  271. package/types/core-library/processors/map-operator.d.ts +38 -0
  272. package/types/core-library/processors/match-operator.d.ts +34 -0
  273. package/types/core-library/processors/matches-constraint.d.ts +29 -0
  274. package/types/core-library/processors/math-operators.d.ts +91 -0
  275. package/types/core-library/processors/merge-deep-operator.d.ts +32 -0
  276. package/types/core-library/processors/merge-operator.d.ts +26 -0
  277. package/types/core-library/processors/metadata-operator.d.ts +56 -0
  278. package/types/core-library/processors/negative-constraint.d.ts +13 -0
  279. package/types/core-library/processors/never-constraint.d.ts +26 -0
  280. package/types/core-library/processors/non-empty-constraint.d.ts +28 -0
  281. package/types/core-library/processors/not-constraint.d.ts +28 -0
  282. package/types/core-library/processors/number-operator.d.ts +9 -0
  283. package/types/core-library/processors/numeric-constraint.d.ts +10 -0
  284. package/types/core-library/processors/object-operator.d.ts +10 -0
  285. package/types/core-library/processors/omit-operator.d.ts +24 -0
  286. package/types/core-library/processors/parallel-operator.d.ts +41 -0
  287. package/types/core-library/processors/pascal-case-operator.d.ts +9 -0
  288. package/types/core-library/processors/phone-constraint.d.ts +65 -0
  289. package/types/core-library/processors/pick-operator.d.ts +27 -0
  290. package/types/core-library/processors/pipeline-operator.d.ts +40 -0
  291. package/types/core-library/processors/port-constraint.d.ts +11 -0
  292. package/types/core-library/processors/positive-constraint.d.ts +13 -0
  293. package/types/core-library/processors/process-operator.d.ts +37 -0
  294. package/types/core-library/processors/property-operator.d.ts +34 -0
  295. package/types/core-library/processors/range-constraint.d.ts +30 -0
  296. package/types/core-library/processors/reference-operator.d.ts +38 -0
  297. package/types/core-library/processors/require-constraint.d.ts +29 -0
  298. package/types/core-library/processors/reverse-operator.d.ts +9 -0
  299. package/types/core-library/processors/round-operator.d.ts +34 -0
  300. package/types/core-library/processors/schema-handler-operators.d.ts +28 -0
  301. package/types/core-library/processors/semver-constraint.d.ts +43 -0
  302. package/types/core-library/processors/sequence-processors.d.ts +213 -0
  303. package/types/core-library/processors/sort-operator.d.ts +31 -0
  304. package/types/core-library/processors/split-operator.d.ts +33 -0
  305. package/types/core-library/processors/string-extra-operators.d.ts +83 -0
  306. package/types/core-library/processors/string-operator.d.ts +10 -0
  307. package/types/core-library/processors/target-operator.d.ts +27 -0
  308. package/types/core-library/processors/template-operator.d.ts +31 -0
  309. package/types/core-library/processors/title-case-operator.d.ts +12 -0
  310. package/types/core-library/processors/trim-operator.d.ts +9 -0
  311. package/types/core-library/processors/truthy-constraint.d.ts +23 -0
  312. package/types/core-library/processors/type-operator.d.ts +11 -0
  313. package/types/core-library/processors/unique-operator.d.ts +10 -0
  314. package/types/core-library/processors/uppercase-operator.d.ts +9 -0
  315. package/types/core-library/processors/url-constraint.d.ts +20 -0
  316. package/types/core-library/processors/url-decode-operator.d.ts +31 -0
  317. package/types/core-library/processors/url-encode-operator.d.ts +36 -0
  318. package/types/core-library/processors/uuid-constraint.d.ts +20 -0
  319. package/types/core-library/processors/values-operator.d.ts +9 -0
  320. package/types/core-library/schemas/any-schema.d.ts +2 -0
  321. package/types/core-library/schemas/array-schema.d.ts +2 -0
  322. package/types/core-library/schemas/boolean-schema.d.ts +2 -0
  323. package/types/core-library/schemas/date-schema.d.ts +2 -0
  324. package/types/core-library/schemas/function-schema.d.ts +2 -0
  325. package/types/core-library/schemas/number-schema.d.ts +2 -0
  326. package/types/core-library/schemas/object-schema.d.ts +2 -0
  327. package/types/core-library/schemas/root-schema.d.ts +2 -0
  328. package/types/core-library/schemas/string-schema.d.ts +2 -0
  329. package/types/core-library-node/index.d.ts +12 -0
  330. package/types/core-library-node/processors/base64-decode-operator.d.ts +9 -0
  331. package/types/core-library-node/processors/base64-encode-operator.d.ts +9 -0
  332. package/types/core-library-node/processors/buffer-operator.d.ts +15 -0
  333. package/types/core-library-node/processors/directory-constraint.d.ts +14 -0
  334. package/types/core-library-node/processors/executable-constraint.d.ts +17 -0
  335. package/types/core-library-node/processors/file-constraint.d.ts +13 -0
  336. package/types/core-library-node/processors/file-size-constraint.d.ts +43 -0
  337. package/types/core-library-node/processors/is-buffer-constraint.d.ts +10 -0
  338. package/types/core-library-node/processors/reachable-constraint.d.ts +13 -0
  339. package/types/core-library-node/processors/readable-constraint.d.ts +17 -0
  340. package/types/core-library-node/processors/writable-constraint.d.ts +18 -0
  341. package/types/core-library-node/schemas/buffer-schema.d.ts +2 -0
  342. package/types/errors.d.ts +58 -0
  343. package/types/executor/array-executor.d.ts +17 -0
  344. package/types/executor/conditional-executor.d.ts +45 -0
  345. package/types/executor/each-executor.d.ts +15 -0
  346. package/types/executor/executor.d.ts +84 -0
  347. package/types/executor/object-executor.d.ts +14 -0
  348. package/types/executor/parallel-executor.d.ts +27 -0
  349. package/types/executor/pipeline-executor.d.ts +11 -0
  350. package/types/executor/sequence-executor.d.ts +32 -0
  351. package/types/executor/serial-executor.d.ts +16 -0
  352. package/types/executor/step-executor.d.ts +14 -0
  353. package/types/helpers/case.d.ts +30 -0
  354. package/types/helpers/data-size.d.ts +25 -0
  355. package/types/helpers/debug-sink.d.ts +9 -0
  356. package/types/helpers/deep.d.ts +33 -0
  357. package/types/helpers/format.d.ts +14 -0
  358. package/types/helpers/has-string-properties.d.ts +5 -0
  359. package/types/helpers/index.d.ts +13 -0
  360. package/types/helpers/object.d.ts +46 -0
  361. package/types/helpers/parse-date.d.ts +6 -0
  362. package/types/helpers/path.d.ts +13 -0
  363. package/types/helpers/regex.d.ts +7 -0
  364. package/types/helpers/stringify.d.ts +33 -0
  365. package/types/helpers/to-data.d.ts +13 -0
  366. package/types/helpers/truthy.d.ts +26 -0
  367. package/types/index.d.ts +6 -0
  368. package/types/schema-compiler.d.ts +49 -0
  369. package/types/schema-location.d.ts +64 -0
  370. package/types/schema-resolver.d.ts +145 -0
  371. package/types/schema.d.ts +586 -0
  372. package/types/traversal/executors/check-condition.d.ts +8 -0
  373. package/types/traversal/executors/check-input.d.ts +6 -0
  374. package/types/traversal/executors/check-required.d.ts +6 -0
  375. package/types/traversal/executors/check-schema.d.ts +7 -0
  376. package/types/traversal/executors/defaults.d.ts +8 -0
  377. package/types/traversal/executors/enter-existing.d.ts +6 -0
  378. package/types/traversal/executors/enter-input.d.ts +8 -0
  379. package/types/traversal/executors/enter.d.ts +7 -0
  380. package/types/traversal/executors/exit.d.ts +6 -0
  381. package/types/traversal/executors/finalize.d.ts +6 -0
  382. package/types/traversal/executors/index.d.ts +15 -0
  383. package/types/traversal/executors/normalize.d.ts +7 -0
  384. package/types/traversal/executors/prepare-existing.d.ts +6 -0
  385. package/types/traversal/executors/prepare-pending.d.ts +6 -0
  386. package/types/traversal/executors/resolve-union.d.ts +6 -0
  387. package/types/traversal/executors/serialize.d.ts +11 -0
  388. package/types/traversal/executors/transform-early.d.ts +6 -0
  389. package/types/traversal/executors/transform.d.ts +6 -0
  390. package/types/traversal/executors/traversal-state-executor.d.ts +19 -0
  391. package/types/traversal/executors/validate.d.ts +6 -0
  392. package/types/traversal/traversal-context.d.ts +67 -0
  393. package/types/traversal/traversal-state.d.ts +97 -0
  394. package/types/types.d.ts +218 -0
  395. package/types/value-processor/composed-value-processor.d.ts +17 -0
  396. package/types/value-processor/defined-value-processor.d.ts +16 -0
  397. package/types/value-processor/function-value-processor.d.ts +15 -0
  398. package/types/value-processor/parameterized-value-processor.d.ts +14 -0
  399. package/types/value-processor/parameters-value-processor.d.ts +28 -0
  400. package/types/value-processor/spec.d.ts +22 -0
  401. package/types/value-processor/value-processor.d.ts +92 -0
@@ -0,0 +1,28 @@
1
+ /**
2
+ * ## $not
3
+ *
4
+ * Inverts a processor result - returns true if the wrapped processor throws or returns a falsey value.
5
+ * Throw a constraint error if the wrapped processor returns a truthy value.
6
+ *
7
+ * This is useful for expressing negative constraints (e.g., "must not be a hostname").
8
+ *
9
+ * See `$never` to require the processor returns undefined or throws an exception.
10
+ *
11
+ * ### Parameters
12
+ * - `value` (ProcessorSpec, required): The processor specification to negate.
13
+ *
14
+ * ### Example
15
+ * ```js
16
+ * // Reject anything that looks like an IP address (accept hostnames only)
17
+ * new Schema('string').validator({$not: '$ipv4'})
18
+ *
19
+ * // Ensure a string is not a reserved word
20
+ * new Schema('string').validator({$not: {$in: ['admin', 'root', 'system']}})
21
+ *
22
+ * // Require a URL that is NOT an HTTP URL (i.e., must be HTTPS or another scheme)
23
+ * new Schema('string').validator({$not: '$http-url'}).validator('$url')
24
+ * ```
25
+ *
26
+ * @type {import('../../value-processor/value-processor.js').ValueProcessorDefinition}*
27
+ */
28
+ export const NOT_CONSTRAINT: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * ## $number
3
+ *
4
+ * Validates and coerces values to numbers. Accepts numeric strings, integers, and floats.
5
+ * Rejects NaN, Infinity, and non-numeric values.
6
+ *
7
+ * @type {import("../../value-processor/value-processor.js").ValueProcessorDefinition}
8
+ */
9
+ export const NUMBER_OPERATOR: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * ## $numeric
3
+ *
4
+ * Validates that a string contains only numeric digits (0-9).
5
+ * The value is coerced to a string before validation, so numbers are accepted
6
+ * but must not contain decimal points, signs, or scientific notation.
7
+ *
8
+ * @type {import("../../value-processor/value-processor.js").ValueProcessorDefinition}
9
+ */
10
+ export const NUMERIC_CONSTRAINT: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * ## $object
3
+ *
4
+ * Attempts to normalize the input value as an object.
5
+ *
6
+ * See `$is-object` for strict object validation.
7
+ *
8
+ * @type {import("../../value-processor/value-processor.js").ValueProcessorDefinition}
9
+ */
10
+ export const OBJECT_OPERATOR: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * ## $omit
3
+ *
4
+ * Returns a new object or dense array with the specified keys/indices removed.
5
+ * Keys not present in the input are silently ignored.
6
+ * For arrays, numeric indices are excluded and the result is a dense (packed) array.
7
+ *
8
+ * ### Parameters
9
+ * - Array of key names or indices (string[]|number[], required): The keys/indices to exclude.
10
+ *
11
+ * ### Example
12
+ * ```js
13
+ * // Remove internal fields before returning a user object
14
+ * new Schema('object').transformer({$omit: ['password', 'salt', '_internalId']})
15
+ * // {id: 1, name: 'Alice', password: '...', _internalId: 42} → {id: 1, name: 'Alice'}
16
+ *
17
+ * // Remove the first element from an array
18
+ * new Schema('array').transformer({$omit: [0]})
19
+ * // ['header', 'row1', 'row2'] → ['row1', 'row2']
20
+ * ```
21
+ *
22
+ * @type {import('../../value-processor/value-processor.js').ValueProcessorDefinition}
23
+ */
24
+ export const OMIT_OPERATOR: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
@@ -0,0 +1,41 @@
1
+ /** @import {ValueProcessorDefinition} from '../../value-processor/value-processor.js' */
2
+ /**
3
+ * ## $parallel
4
+ *
5
+ * Applies an array of processors concurrently to the same input value, returning an array
6
+ * of all results in the same order as the processors.
7
+ *
8
+ * When all processors are synchronous, execution is sequential and the result is a plain array.
9
+ * When any processor is asynchronous, all are run via `Promise.all`, giving true concurrent
10
+ * execution — useful for I/O-bound processors such as HTTP fetches or secret lookups.
11
+ *
12
+ * Errors propagate immediately (fail-fast). Wrap individual processors in `$gate` or `$try`
13
+ * to trap errors and return a fallback instead.
14
+ *
15
+ * ### Parameters
16
+ * - `processors` (Array, required): Array of processor specifications to run concurrently.
17
+ *
18
+ * ### Example
19
+ * ```js
20
+ * // Fan out to two transforms and collect both results
21
+ * new Schema('string').transformer({$parallel: ['$uppercase', '$trim']})
22
+ * // ' hello ' → ['HELLO', 'hello']
23
+ *
24
+ * // Concurrent async lookups (both execute at the same time via Promise.all)
25
+ * new Schema('string').transformer({$parallel: [fetchUserFlags, fetchUserPermissions]})
26
+ * // → [flagsResult, permissionsResult]
27
+ *
28
+ * // Fan out validation across multiple schemas and collect results
29
+ * new Schema('object').transformer({
30
+ * $parallel: [
31
+ * {$get: 'id'},
32
+ * {$get: 'name'},
33
+ * {$get: 'email'},
34
+ * ]
35
+ * })
36
+ * ```
37
+ *
38
+ * @type {ValueProcessorDefinition}
39
+ */
40
+ export const PARALLEL_OPERATOR: ValueProcessorDefinition;
41
+ import type { ValueProcessorDefinition } from '../../value-processor/value-processor.js';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * ## $pascal-case
3
+ *
4
+ * Converts a string value to PascalCase format (first letter of each word capitalized, no separators).
5
+ * Safe to use in normalize phase (non-throwing).
6
+ *
7
+ * @type {import("../../value-processor/value-processor.js").ValueProcessorDefinition}
8
+ */
9
+ export const PASCAL_CASE_OPERATOR: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
@@ -0,0 +1,65 @@
1
+ /**
2
+ * ## $phone
3
+ *
4
+ * Validates and normalizes a phone number string.
5
+ *
6
+ * Strips common formatting (spaces, dashes, dots, parentheses, slashes) and
7
+ * validates the remaining digits against country-specific rules when available,
8
+ * or generic E.164 length rules otherwise.
9
+ *
10
+ * **Output format** is controlled by the `international` parameter:
11
+ * - When `false` (default): national format for the default country
12
+ * (e.g. `(212) 555-1234` for country code `1`).
13
+ * - When `true`: international format with country code prefix
14
+ * (e.g. `+1 212 555 1234`).
15
+ *
16
+ * Numbers without a `+` prefix are assumed to belong to the default `country`.
17
+ * A leading country code without `+` is recognized when it produces a valid
18
+ * subscriber length (e.g. `12125551234` is treated as `+1 2125551234`).
19
+ *
20
+ * **NANP validation (country code `1`):** area codes and exchanges must not
21
+ * start with `0` or `1`, matching North American Numbering Plan rules.
22
+ *
23
+ * **Not supported:** extensions, vanity letters (1-800-FLOWERS), international
24
+ * dialing prefixes (`00`, `011`), short codes, or emergency numbers. This
25
+ * processor targets typical subscriber phone numbers as entered in forms or
26
+ * configuration files.
27
+ *
28
+ * ### Parameters
29
+ * - `international` (boolean, default `false`): When `false`, only numbers
30
+ * matching the default `country` code are accepted, and output uses the
31
+ * national format. When `true`, any valid international number is accepted,
32
+ * and output uses the international format with `+CC` prefix.
33
+ * - `country` (string, default `'1'`): Default country calling code applied
34
+ * to numbers entered without a `+` prefix.
35
+ * - `countries` (object, default `null`): Optional map of country calling
36
+ * codes to rule objects, merged over the built-in rules. Each rule object
37
+ * may contain:
38
+ * - `lengths` (number[]) — accepted subscriber digit counts
39
+ * - `validate` (RegExp, optional) — pattern the subscriber digits must match
40
+ * - `national` (string) — `#`-template for national formatting
41
+ * - `international` (string) — `#`-template for international formatting
42
+ *
43
+ * ### Example
44
+ * ```js
45
+ * // Basic US number validation and national formatting
46
+ * new Schema('string').validator('$phone')
47
+ *
48
+ * // Accept international numbers
49
+ * new Schema('string').validator({'$phone': {international: true}})
50
+ *
51
+ * // Default to UK numbers
52
+ * new Schema('string').validator({'$phone': {
53
+ * country: '44',
54
+ * countries: {
55
+ * '44': {lengths: [10], national: '#### ### ####', international: '#### ### ####'}
56
+ * }
57
+ * }})
58
+ *
59
+ * // Compact storage: compose with space/punctuation stripping
60
+ * new Schema('string').normalizer({$pipeline: ['$trim', '$phone']})
61
+ * ```
62
+ *
63
+ * @type {import("../../value-processor/value-processor.js").ValueProcessorDefinition}
64
+ */
65
+ export const PHONE_CONSTRAINT: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * ## $pick
3
+ *
4
+ * Returns a new object or dense array containing only the specified keys/indices from the input.
5
+ * Keys not present in the input are silently omitted from the result.
6
+ * For arrays, numeric indices are selected and the result is a dense (packed) array.
7
+ *
8
+ * ### Parameters
9
+ * - Array of key names or indices (string[]|number[], required): The keys/indices to retain.
10
+ *
11
+ * ### Example
12
+ * ```js
13
+ * // Retain only 'id' and 'name' from an object
14
+ * new Schema('object').transformer({$pick: ['id', 'name']})
15
+ * // {id: 1, name: 'Alice', secret: 'xyz'} → {id: 1, name: 'Alice'}
16
+ *
17
+ * // Select the first and third elements from an array
18
+ * new Schema('array').transformer({$pick: [0, 2]})
19
+ * // ['a', 'b', 'c', 'd'] → ['a', 'c']
20
+ *
21
+ * // Strip sensitive fields from a user record before returning
22
+ * new Schema('object').transformer({$pick: ['id', 'username', 'email', 'role']})
23
+ * ```
24
+ *
25
+ * @type {import('../../value-processor/value-processor.js').ValueProcessorDefinition}
26
+ */
27
+ export const PICK_OPERATOR: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @import {ValueProcessorDefinition} from '../../value-processor/value-processor.js'
3
+ */
4
+ /**
5
+ * ## $pipeline
6
+ *
7
+ * Executes a sequence of processors in order, passing the output of each processor
8
+ * as input to the next. The final processor's output becomes the result.
9
+ *
10
+ * **Note**: Handler arrays (normalizers, validators, etc.) implicitly create pipelines,
11
+ * so this processor is rarely used directly. It's primarily used internally by the
12
+ * schema compiler to aggregate handler arrays into single compiled processors.
13
+ *
14
+ * ### Parameters
15
+ * - `processors` (`Array<ProcessorSpec>`, required): Array of processor specifications to execute in sequence.
16
+ * Each element can be a string keyword (e.g., `'$trim'`), a parameterized processor object
17
+ * (e.g., `{$range: {min: 0}}`), a RegExp, or a function.
18
+ *
19
+ * **Behavior**: Processors execute left-to-right. If any processor throws an error, the pipeline
20
+ * stops and the error propagates. Each processor receives the output of the previous processor
21
+ * as its input value.
22
+ *
23
+ * ### Example
24
+ * ```js
25
+ * // Explicit pipeline (equivalent to passing an array to .normalizer())
26
+ * new Schema('string').normalizer({$pipeline: ['$trim', '$lowercase', '$alphanum']})
27
+ *
28
+ * // Use $pipeline inside a conditional to chain processors on a branch
29
+ * new Schema('string').transformer({
30
+ * $if: [
31
+ * '$numeric',
32
+ * {$pipeline: ['$number', {$clamp: {min: 0, max: 100}}]},
33
+ * ]
34
+ * })
35
+ * ```
36
+ *
37
+ * @type {ValueProcessorDefinition}
38
+ */
39
+ export const PIPELINE_OPERATOR: ValueProcessorDefinition;
40
+ import type { ValueProcessorDefinition } from '../../value-processor/value-processor.js';
@@ -0,0 +1,11 @@
1
+ /**
2
+ * ## $port
3
+ *
4
+ * Validates that a value is a valid TCP/UDP port number (1-65535).
5
+ * Accepts numeric values or strings that can be converted to numbers.
6
+ * Returns the value as a number or a string, depending on the underlying schema.
7
+ * (defaults to a number).
8
+ *
9
+ * @type {import("../../value-processor/value-processor.js").ValueProcessorDefinition}
10
+ */
11
+ export const PORT_CONSTRAINT: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * ## $positive
3
+ *
4
+ * Validates that a numeric value is positive (greater than 0).
5
+ * Input must already be a number; use `$number` in a prior normalizer if coercion from string is needed.
6
+ *
7
+ * See also:
8
+ * - `$negative` to enforce the opposite constraint
9
+ * - `$range` if you want "non-negative" ( greater than or equal to 0) semantics.
10
+ *
11
+ * @type {import("../../value-processor/value-processor.js").ValueProcessorDefinition}
12
+ */
13
+ export const POSITIVE_CONSTRAINT: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * ## $process
3
+ *
4
+ * Process the incoming value according to the provided schema
5
+ *
6
+ * Important note: the provided schema is run in isolation in a private local context, which means
7
+ * that it (and its handlers) have no access to the outer schema or the global target value, and all
8
+ * paths are relative to the root of the provided schema.
9
+ *
10
+ * ### Parameters
11
+ * - `schema` (CompiledSchema, required): the compiled schema to apply to the input value.
12
+ * Any `Schema` found in a handler pipeline will be automatically compiled;
13
+ * Use `$compile` to produce a `CompiledSchema` from a `Schema` literal value.
14
+ *
15
+ * ### Example
16
+ * ```js
17
+ * import { Schema, SchemaResolver } from '@versionzero/schema';
18
+ *
19
+ * // Compile a reusable sub-schema and run values through it
20
+ * const resolver = new SchemaResolver();
21
+ * const portSchema = await resolver.compile(
22
+ * new Schema('number').validator({$range: {min: 1, max: 65535}})
23
+ * );
24
+ *
25
+ * // portSchema is automatically compiled:
26
+ * new Schema('object', {
27
+ * port: new Schema('any').validator({$process: {schema: portSchema}}),
28
+ * })
29
+ *
30
+ * // Use $compile inline to compile-then-process in a single pipeline
31
+ * const mySchema = new Schema('string').validator('$non-empty');
32
+ * new Schema('any').normalizer([{$compile: {$literal: mySchema}}, '$process'])
33
+ * ```
34
+ *
35
+ * @type {import('../../value-processor/value-processor.js').ValueProcessorDefinition}
36
+ */
37
+ export const PROCESS_OPERATOR: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * ## $property
3
+ *
4
+ * Extracts a named property value from an object. This operator is useful for accessing
5
+ * nested properties or extracting specific fields during processing pipelines.
6
+ *
7
+ * Returns `undefined` if the current value is not an object or if the property doesn't exist.
8
+ * Throws a `SchemaError` if the specified property name is not defined in the schema.
9
+ *
10
+ * ### Parameters
11
+ * - `name` (string, required): The name of the schema-defined property to extract from the input object.
12
+ * The property must be declared in the current schema; use `$get` for arbitrary path access without
13
+ * schema awareness.
14
+ *
15
+ * ### Example
16
+ * ```js
17
+ * // Conditionally require 'apiKey' only when 'useApiKey' is true
18
+ * new Schema('object', {
19
+ * useApiKey: new Schema('boolean'),
20
+ * apiKey: new Schema('string').validator({
21
+ * $if: [{$property: 'useApiKey'}, '$non-empty']
22
+ * }),
23
+ * })
24
+ *
25
+ * // Discriminate a union using a schema property value
26
+ * new Schema('object', {
27
+ * type: new Schema('string'),
28
+ * config: new Schema('any'),
29
+ * }).discriminator({$property: 'type'})
30
+ * ```
31
+ *
32
+ * @type {import("../../value-processor/value-processor.js").ValueProcessorDefinition}
33
+ */
34
+ export const PROPERTY_OPERATOR: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * ## $range
3
+ *
4
+ * Validates that a numeric value falls within the specified range (inclusive).
5
+ * Can specify minimum, maximum, or both bounds.
6
+ *
7
+ * ### Parameters
8
+ * - `min` (number, optional): Minimum value (inclusive). If omitted, no lower bound.
9
+ * - `max` (number, optional): Maximum value (inclusive). If omitted, no upper bound.
10
+ *
11
+ * ### Example
12
+ * ```js
13
+ * // Object form with named parameters
14
+ * new Schema('number').validator({$range: {min: 1, max: 100}})
15
+ *
16
+ * // Array form [min, max]
17
+ * new Schema('number').validator({$range: [1, 65535]})
18
+ *
19
+ * // Only a lower bound (percentage, must be non-negative)
20
+ * new Schema('number').validator({$range: {min: 0}})
21
+ *
22
+ * // Only an upper bound
23
+ * new Schema('number').validator({$range: {max: 255}})
24
+ * ```
25
+ *
26
+ * See also: `$positive` and `$negative` for common named ranges.
27
+ *
28
+ * @type {import("../../value-processor/value-processor.js").ValueProcessorDefinition}
29
+ */
30
+ export const RANGE_CONSTRAINT: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * ## $reference
3
+ *
4
+ * Returns the value at the referenced path (relative to the current schema) in the target data, or undefined if not set.
5
+ *
6
+ * Throws a `SchemaError` if the specified path is not defined in the schema.
7
+ *
8
+ * ### Parameters
9
+ * - `path` (string, required): path from the current schema into the top-level target object; must be a valid
10
+ * schema path (dot-separated, supports / for absolute or ^ for parents).
11
+ * - `pending` (boolean, optional, default: false): If true will fall back to any pending value not yet in the target data.
12
+ * - `completed` (boolean, optional, default: false): If true, will only return a value if the reference is completed (useful for checking if all children are handled).
13
+ *
14
+ * ### Example
15
+ * ```js
16
+ * // Validate 'port' is within range only when 'ssl' is enabled at the top level
17
+ * new Schema('object', {
18
+ * ssl: new Schema('boolean'),
19
+ * port: new Schema('number').validator({
20
+ * $if: [{$reference: 'ssl'}, {$range: {min: 443, max: 443}}]
21
+ * }),
22
+ * })
23
+ *
24
+ * // Cross-field consistency: confirm 'passwordConfirm' matches 'password'
25
+ * new Schema('object', {
26
+ * password: new Schema('string'),
27
+ * passwordConfirm: new Schema('string').validator(
28
+ * (value, target) => value === target.password || undefined
29
+ * ),
30
+ * })
31
+ * ```
32
+ * ### See Also
33
+ * - Use `$property` for getting a named child value.
34
+ * - Use `$get` for getting values under the input value (without the path needing to be in the schema.)
35
+ *
36
+ * @type {import("../../value-processor/value-processor.js").ValueProcessorDefinition}
37
+ */
38
+ export const REFERENCE_OPERATOR: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * ## $require
3
+ *
4
+ * Require that the provided processor returns a defined value; return the original input if so.
5
+ * Throws a constraint error if the processor does not return a defined value.
6
+ *
7
+ * May be used inline in a pipeline without parameters, or can have a single processor argument.
8
+ *
9
+ * ### Parameters
10
+ * - `processor` (ProcessorSpec, optional): Processor specification to check for a defined return value.
11
+ * If omitted, the input value itself is checked for defined-ness.
12
+ *
13
+ * ### Example
14
+ * ```js
15
+ * // Require the input to be defined (not undefined)
16
+ * new Schema('any').validator('$require')
17
+ *
18
+ * // Require a lookup to succeed (key must exist in the table)
19
+ * new Schema('string').validator({
20
+ * $require: {$lookup: {$literal: {admin: 1, user: 2, guest: 3}}}
21
+ * })
22
+ *
23
+ * // Require a nested path to resolve
24
+ * new Schema('object').validator({$require: {$get: 'metadata.version'}})
25
+ * ```
26
+ *
27
+ * @type {import('../../value-processor/value-processor.js').ValueProcessorDefinition}
28
+ */
29
+ export const REQUIRE_CONSTRAINT: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * ## $reverse
3
+ *
4
+ * Returns a new array with elements in reverse order. Non-mutating.
5
+ * Throws if the input is not an array.
6
+ *
7
+ * @type {import('../../value-processor/value-processor.js').ValueProcessorDefinition}
8
+ */
9
+ export const REVERSE_OPERATOR: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * ## $round
3
+ *
4
+ * Rounds a numeric value to the nearest integer or to a specified number of decimal places.
5
+ * Safe to use in normalize phase (non-throwing). Non-numeric values pass through unchanged.
6
+ *
7
+ * ### Parameters
8
+ * - `precision` (number, optional): Number of decimal places. Defaults to 0 (integer rounding).
9
+ *
10
+ * **Examples**:
11
+ * - `3.7` with precision 0 → `4`
12
+ * - `3.14159` with precision 2 → `3.14`
13
+ * - `123.456` with precision 1 → `123.5`
14
+ * - `"not a number"` → `"not a number"` (passes through unchanged)
15
+ *
16
+ * ### Example
17
+ * ```js
18
+ * // Round to nearest integer
19
+ * new Schema('number').transformer('$round')
20
+ * // 3.5 → 4, 3.4 → 3
21
+ *
22
+ * // Round a price to 2 decimal places
23
+ * new Schema('number').transformer({$round: {precision: 2}})
24
+ * // 9.9950 → 9.99, 9.9951 → 10.00
25
+ *
26
+ * // Round a sensor reading to 1 decimal place
27
+ * new Schema('object', {
28
+ * temperature: new Schema('number').transformer({$round: {precision: 1}}),
29
+ * })
30
+ * ```
31
+ *
32
+ * @type {import("../../value-processor/value-processor.js").ValueProcessorDefinition}
33
+ */
34
+ export const ROUND_OPERATOR: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * ## $normalize
3
+ *
4
+ * Normalize the incoming value according using the provided schema
5
+ *
6
+ * ### Parameters
7
+ * - `schema` (CompiledSchema, required): the compiled schema to apply to the input value.
8
+ * Any `Schema` found in a handler pipeline will be automatically compiled;
9
+ * Use `$compile` to produce a `CompiledSchema` from a `Schema` literal value.
10
+ *
11
+ * ### Example
12
+ * ```js
13
+ * import { Schema, SchemaResolver } from '@versionzero/schema';
14
+ *
15
+ * const resolver = new SchemaResolver();
16
+ *
17
+ * const = await resolver.compile(
18
+ * new Schema('object')
19
+ * .property('collection', new Schema('array')
20
+ * .property('*', new Schema('string').normalizer('$trim').normalizer('$lowercase'))
21
+ * .property('chosen', new Schema('string').normalizer({$normalize: {'$find-schema': '^.collection.*'}})
22
+ * );
23
+ *
24
+ * ```
25
+ *
26
+ * @type {import('../../value-processor/value-processor.js').ValueProcessorDefinition}
27
+ */
28
+ export const NORMALIZE_OPERATOR: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * ## $semver
3
+ *
4
+ * Validates that a string is a valid semantic version per the semver 2.0.0 spec.
5
+ *
6
+ * ### Parameters
7
+ * - `in` (string, optional): Semver range expression. Supports comparators
8
+ * (`>=1.0.0`, `<2.0.0`), caret (`^1.2.3`), tilde (`~1.2.3`), and
9
+ * space-separated AND (`>=1.0.0 <2.0.0`).
10
+ * - `min` (string, optional): Minimum version (inclusive).
11
+ * - `max` (string, optional): Maximum version (inclusive).
12
+ *
13
+ * Use either `in` OR `min`/`max`, not both.
14
+ *
15
+ * ### Example
16
+ * ```js
17
+ * // Format-only validation
18
+ * new Schema('string').validator('$semver')
19
+ *
20
+ * // Caret range (positional `in`)
21
+ * new Schema('string').validator({$semver: '^1.2.0'})
22
+ *
23
+ * // Tilde range
24
+ * new Schema('string').validator({$semver: '~1.2.0'})
25
+ *
26
+ * // Comparator range
27
+ * new Schema('string').validator({$semver: '>=1.0.0 <2.0.0'})
28
+ *
29
+ * // Explicit min/max (inclusive)
30
+ * new Schema('string').validator({$semver: {min: '1.0.0', max: '2.0.0'}})
31
+ * ```
32
+ *
33
+ * @type {import("../../value-processor/value-processor.js").ValueProcessorDefinition}
34
+ */
35
+ export const SEMVER_CONSTRAINT: import("../../value-processor/value-processor.js").ValueProcessorDefinition;
36
+ export type SemVer = {
37
+ major: number;
38
+ minor: number;
39
+ patch: number;
40
+ prerelease: string[];
41
+ build: string[];
42
+ };
43
+ export type SemVerPredicate = (v: SemVer) => boolean;