@bastani/atomic-schema 0.0.0-stage → 0.9.88

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 (178) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/LICENSE +22 -0
  3. package/NOTICE.md +13 -0
  4. package/README.md +63 -2
  5. package/THIRD_PARTY_NOTICES/typebox-LICENSE +23 -0
  6. package/dist/annotations.d.ts +44 -0
  7. package/dist/annotations.d.ts.map +1 -0
  8. package/dist/annotations.js +193 -0
  9. package/dist/annotations.js.map +1 -0
  10. package/dist/builders.d.ts +143 -0
  11. package/dist/builders.d.ts.map +1 -0
  12. package/dist/builders.js +126 -0
  13. package/dist/builders.js.map +1 -0
  14. package/dist/checks.d.ts +114 -0
  15. package/dist/checks.d.ts.map +1 -0
  16. package/dist/checks.js +578 -0
  17. package/dist/checks.js.map +1 -0
  18. package/dist/coerce.d.ts +53 -0
  19. package/dist/coerce.d.ts.map +1 -0
  20. package/dist/coerce.js +624 -0
  21. package/dist/coerce.js.map +1 -0
  22. package/dist/compiler.d.ts +53 -0
  23. package/dist/compiler.d.ts.map +1 -0
  24. package/dist/compiler.js +551 -0
  25. package/dist/compiler.js.map +1 -0
  26. package/dist/explain.d.ts +29 -0
  27. package/dist/explain.d.ts.map +1 -0
  28. package/dist/explain.js +392 -0
  29. package/dist/explain.js.map +1 -0
  30. package/dist/formats/index.d.ts +7 -0
  31. package/dist/formats/index.d.ts.map +1 -0
  32. package/dist/formats/index.js +51 -0
  33. package/dist/formats/index.js.map +1 -0
  34. package/dist/formats/typebox/date.d.ts +7 -0
  35. package/dist/formats/typebox/date.d.ts.map +1 -0
  36. package/dist/formats/typebox/date.js +47 -0
  37. package/dist/formats/typebox/date.js.map +1 -0
  38. package/dist/formats/typebox/date_time.d.ts +7 -0
  39. package/dist/formats/typebox/date_time.d.ts.map +1 -0
  40. package/dist/formats/typebox/date_time.js +39 -0
  41. package/dist/formats/typebox/date_time.js.map +1 -0
  42. package/dist/formats/typebox/duration.d.ts +6 -0
  43. package/dist/formats/typebox/duration.d.ts.map +1 -0
  44. package/dist/formats/typebox/duration.js +36 -0
  45. package/dist/formats/typebox/duration.js.map +1 -0
  46. package/dist/formats/typebox/email.d.ts +6 -0
  47. package/dist/formats/typebox/email.d.ts.map +1 -0
  48. package/dist/formats/typebox/email.js +36 -0
  49. package/dist/formats/typebox/email.js.map +1 -0
  50. package/dist/formats/typebox/hostname.d.ts +8 -0
  51. package/dist/formats/typebox/hostname.d.ts.map +1 -0
  52. package/dist/formats/typebox/hostname.js +38 -0
  53. package/dist/formats/typebox/hostname.js.map +1 -0
  54. package/dist/formats/typebox/idn_email.d.ts +6 -0
  55. package/dist/formats/typebox/idn_email.d.ts.map +1 -0
  56. package/dist/formats/typebox/idn_email.js +36 -0
  57. package/dist/formats/typebox/idn_email.js.map +1 -0
  58. package/dist/formats/typebox/idn_hostname.d.ts +9 -0
  59. package/dist/formats/typebox/idn_hostname.d.ts.map +1 -0
  60. package/dist/formats/typebox/idn_hostname.js +39 -0
  61. package/dist/formats/typebox/idn_hostname.js.map +1 -0
  62. package/dist/formats/typebox/idna/format/bidi.d.ts +4 -0
  63. package/dist/formats/typebox/idna/format/bidi.d.ts.map +1 -0
  64. package/dist/formats/typebox/idna/format/bidi.js +132 -0
  65. package/dist/formats/typebox/idna/format/bidi.js.map +1 -0
  66. package/dist/formats/typebox/idna/format/puny.d.ts +4 -0
  67. package/dist/formats/typebox/idna/format/puny.d.ts.map +1 -0
  68. package/dist/formats/typebox/idna/format/puny.js +172 -0
  69. package/dist/formats/typebox/idna/format/puny.js.map +1 -0
  70. package/dist/formats/typebox/idna/hostname.d.ts +2 -0
  71. package/dist/formats/typebox/idna/hostname.d.ts.map +1 -0
  72. package/dist/formats/typebox/idna/hostname.js +43 -0
  73. package/dist/formats/typebox/idna/hostname.js.map +1 -0
  74. package/dist/formats/typebox/idna/idn-hostname.d.ts +2 -0
  75. package/dist/formats/typebox/idna/idn-hostname.d.ts.map +1 -0
  76. package/dist/formats/typebox/idna/idn-hostname.js +71 -0
  77. package/dist/formats/typebox/idna/idn-hostname.js.map +1 -0
  78. package/dist/formats/typebox/idna/index.d.ts +3 -0
  79. package/dist/formats/typebox/idna/index.d.ts.map +1 -0
  80. package/dist/formats/typebox/idna/index.js +30 -0
  81. package/dist/formats/typebox/idna/index.js.map +1 -0
  82. package/dist/formats/typebox/idna/label/ascii.d.ts +2 -0
  83. package/dist/formats/typebox/idna/label/ascii.d.ts.map +1 -0
  84. package/dist/formats/typebox/idna/label/ascii.js +37 -0
  85. package/dist/formats/typebox/idna/label/ascii.js.map +1 -0
  86. package/dist/formats/typebox/idna/label/puny.d.ts +2 -0
  87. package/dist/formats/typebox/idna/label/puny.d.ts.map +1 -0
  88. package/dist/formats/typebox/idna/label/puny.js +56 -0
  89. package/dist/formats/typebox/idna/label/puny.js.map +1 -0
  90. package/dist/formats/typebox/idna/label/unicode.d.ts +2 -0
  91. package/dist/formats/typebox/idna/label/unicode.d.ts.map +1 -0
  92. package/dist/formats/typebox/idna/label/unicode.js +134 -0
  93. package/dist/formats/typebox/idna/label/unicode.js.map +1 -0
  94. package/dist/formats/typebox/idna/pattern/pattern.d.ts +31 -0
  95. package/dist/formats/typebox/idna/pattern/pattern.d.ts.map +1 -0
  96. package/dist/formats/typebox/idna/pattern/pattern.js +98 -0
  97. package/dist/formats/typebox/idna/pattern/pattern.js.map +1 -0
  98. package/dist/formats/typebox/ipv4.d.ts +6 -0
  99. package/dist/formats/typebox/ipv4.d.ts.map +1 -0
  100. package/dist/formats/typebox/ipv4.js +36 -0
  101. package/dist/formats/typebox/ipv4.js.map +1 -0
  102. package/dist/formats/typebox/ipv6.d.ts +6 -0
  103. package/dist/formats/typebox/ipv6.d.ts.map +1 -0
  104. package/dist/formats/typebox/ipv6.js +36 -0
  105. package/dist/formats/typebox/ipv6.js.map +1 -0
  106. package/dist/formats/typebox/iri.d.ts +6 -0
  107. package/dist/formats/typebox/iri.d.ts.map +1 -0
  108. package/dist/formats/typebox/iri.js +63 -0
  109. package/dist/formats/typebox/iri.js.map +1 -0
  110. package/dist/formats/typebox/iri_reference.d.ts +6 -0
  111. package/dist/formats/typebox/iri_reference.d.ts.map +1 -0
  112. package/dist/formats/typebox/iri_reference.js +40 -0
  113. package/dist/formats/typebox/iri_reference.js.map +1 -0
  114. package/dist/formats/typebox/json_pointer.d.ts +7 -0
  115. package/dist/formats/typebox/json_pointer.d.ts.map +1 -0
  116. package/dist/formats/typebox/json_pointer.js +37 -0
  117. package/dist/formats/typebox/json_pointer.js.map +1 -0
  118. package/dist/formats/typebox/json_pointer_uri_fragment.d.ts +7 -0
  119. package/dist/formats/typebox/json_pointer_uri_fragment.d.ts.map +1 -0
  120. package/dist/formats/typebox/json_pointer_uri_fragment.js +37 -0
  121. package/dist/formats/typebox/json_pointer_uri_fragment.js.map +1 -0
  122. package/dist/formats/typebox/regex.d.ts +6 -0
  123. package/dist/formats/typebox/regex.d.ts.map +1 -0
  124. package/dist/formats/typebox/regex.js +41 -0
  125. package/dist/formats/typebox/regex.js.map +1 -0
  126. package/dist/formats/typebox/relative_json_pointer.d.ts +7 -0
  127. package/dist/formats/typebox/relative_json_pointer.d.ts.map +1 -0
  128. package/dist/formats/typebox/relative_json_pointer.js +37 -0
  129. package/dist/formats/typebox/relative_json_pointer.js.map +1 -0
  130. package/dist/formats/typebox/time.d.ts +6 -0
  131. package/dist/formats/typebox/time.d.ts.map +1 -0
  132. package/dist/formats/typebox/time.js +60 -0
  133. package/dist/formats/typebox/time.js.map +1 -0
  134. package/dist/formats/typebox/uri.d.ts +6 -0
  135. package/dist/formats/typebox/uri.d.ts.map +1 -0
  136. package/dist/formats/typebox/uri.js +36 -0
  137. package/dist/formats/typebox/uri.js.map +1 -0
  138. package/dist/formats/typebox/uri_reference.d.ts +6 -0
  139. package/dist/formats/typebox/uri_reference.d.ts.map +1 -0
  140. package/dist/formats/typebox/uri_reference.js +36 -0
  141. package/dist/formats/typebox/uri_reference.js.map +1 -0
  142. package/dist/formats/typebox/uri_template.d.ts +6 -0
  143. package/dist/formats/typebox/uri_template.d.ts.map +1 -0
  144. package/dist/formats/typebox/uri_template.js +37 -0
  145. package/dist/formats/typebox/uri_template.js.map +1 -0
  146. package/dist/formats/typebox/url.d.ts +7 -0
  147. package/dist/formats/typebox/url.d.ts.map +1 -0
  148. package/dist/formats/typebox/url.js +36 -0
  149. package/dist/formats/typebox/url.js.map +1 -0
  150. package/dist/formats/typebox/uuid.d.ts +7 -0
  151. package/dist/formats/typebox/uuid.d.ts.map +1 -0
  152. package/dist/formats/typebox/uuid.js +37 -0
  153. package/dist/formats/typebox/uuid.js.map +1 -0
  154. package/dist/index.d.ts +5 -0
  155. package/dist/index.d.ts.map +1 -0
  156. package/dist/index.js +6 -0
  157. package/dist/index.js.map +1 -0
  158. package/dist/resolver.d.ts +58 -0
  159. package/dist/resolver.d.ts.map +1 -0
  160. package/dist/resolver.js +209 -0
  161. package/dist/resolver.js.map +1 -0
  162. package/dist/shared.d.ts +9 -0
  163. package/dist/shared.d.ts.map +1 -0
  164. package/dist/shared.js +33 -0
  165. package/dist/shared.js.map +1 -0
  166. package/dist/typebox-static.d.ts +56 -0
  167. package/dist/typebox-static.d.ts.map +1 -0
  168. package/dist/typebox-static.js +7 -0
  169. package/dist/typebox-static.js.map +1 -0
  170. package/dist/types.d.ts +48 -0
  171. package/dist/types.d.ts.map +1 -0
  172. package/dist/types.js +3 -0
  173. package/dist/types.js.map +1 -0
  174. package/dist/validator.d.ts +48 -0
  175. package/dist/validator.d.ts.map +1 -0
  176. package/dist/validator.js +81 -0
  177. package/dist/validator.js.map +1 -0
  178. package/package.json +64 -4
package/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ # Changelog
2
+
3
+ This package is Atomic's fork of `@earendil-works/pi-schema`. Its history up to the fork point, pi `v1.5.2`, lives in [earendil-works/pi](https://github.com/earendil-works/pi/blob/v1.5.2/packages/schema/CHANGELOG.md).
4
+
5
+ ## [Unreleased]
6
+
7
+ ## [0.9.88] - 2026-11-16
8
+
9
+ ### Changed
10
+
11
+ - Forked `@earendil-works/pi-schema` 1.5.2 as `@bastani/atomic-schema`, published with every Atomic release at Atomic's version. Atomic's extension loader still resolves `@earendil-works/pi-schema` and `@mariozechner/pi-schema` imports to this package ([#5174](https://github.com/bastani-inc/atomic/issues/5174))
12
+
13
+ ## [0.9.88-alpha.1] - 2026-11-16
14
+
15
+ ### Changed
16
+
17
+ - Forked `@earendil-works/pi-schema` 1.5.2 as `@bastani/atomic-schema`, published with every Atomic release at Atomic's version. Atomic's extension loader still resolves `@earendil-works/pi-schema` and `@mariozechner/pi-schema` imports to this package ([#5174](https://github.com/bastani-inc/atomic/issues/5174))
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Mario Zechner
4
+ Copyright (c) 2026 Bastani, Inc.
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/NOTICE.md ADDED
@@ -0,0 +1,13 @@
1
+ # Notice
2
+
3
+ `@bastani/atomic-schema` is a hard fork of the `packages/schema` package from
4
+ [earendil-works/pi](https://github.com/earendil-works/pi). It lives in this
5
+ monorepo at `packages/schema` and publishes at the same version as `@bastani/atomic`.
6
+
7
+ - Upstream package: [`@earendil-works/pi-schema`](https://www.npmjs.com/package/@earendil-works/pi-schema)
8
+ - Fork point: `v1.5.2` (`earendil-works/pi@b4afdddf44e059c67ccf5097e5317d913521b470`). Atomic does not sync further upstream changes.
9
+
10
+ Original work is Copyright (c) 2025 Mario Zechner and is licensed under the MIT License.
11
+ Bastani modifications are Copyright (c) 2026 Bastani, Inc. and are also licensed under the MIT License.
12
+
13
+ Import from `@bastani/atomic-schema` instead of `@earendil-works/pi-schema`.
package/README.md CHANGED
@@ -1,3 +1,64 @@
1
- # Temporary Holding Version
1
+ <p align="center">
2
+ <a href="https://github.com/bastani-inc/atomic">
3
+ <img alt="Atomic" src="https://raw.githubusercontent.com/bastani-inc/atomic/main/packages/coding-agent/docs/logo.svg" width="324">
4
+ </a>
5
+ </p>
2
6
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
7
+ <p align="center">
8
+ <b>@bastani/atomic-schema</b><br>
9
+ JSON Schema builders and validation without eval.
10
+ </p>
11
+
12
+ <p align="center">
13
+ <a href="https://docs.bastani.ai/libraries/schema"><img alt="Docs" src="https://img.shields.io/badge/docs-atomic-blue?style=flat-square" /></a>
14
+ <a href="https://www.npmjs.com/package/@bastani/atomic-schema"><img alt="npm" src="https://img.shields.io/npm/v/@bastani/atomic-schema?style=flat-square" /></a>
15
+ <a href="https://github.com/bastani-inc/atomic"><img alt="GitHub" src="https://img.shields.io/badge/github-bastani--inc%2Fatomic-181717?style=flat-square&logo=github" /></a>
16
+ </p>
17
+
18
+ ---
19
+
20
+ Builders that return plain JSON Schema typed with the values it accepts, and a validator that compiles a schema once into plain closures: drafts 2020-12 and 7, no `eval`, so it works under a strict Content Security Policy. Atomic validates tool arguments with it.
21
+
22
+ [Atomic](https://github.com/bastani-inc/atomic), the verifiable coding agent runtime, is built on it, and it is published with every Atomic release at Atomic's version.
23
+
24
+ ## Install
25
+
26
+ ```bash
27
+ npm install @bastani/atomic-schema
28
+ ```
29
+
30
+ Inside an Atomic extension, import it without installing it: the running Atomic provides it. See [Libraries](https://docs.bastani.ai/libraries).
31
+
32
+ ## Quick start
33
+
34
+ ```typescript
35
+ import { compile, int, obj, oneOf, opt, type Static, str } from "@bastani/atomic-schema";
36
+
37
+ const Read = obj({
38
+ path: str({ description: "Path to the file", minLength: 1 }),
39
+ offset: opt(int({ minimum: 1 })),
40
+ mode: oneOf(["text", "binary"]),
41
+ });
42
+ type Read = Static<typeof Read>; // { path: string; mode: "text" | "binary"; offset?: number }
43
+
44
+ const read = compile(Read);
45
+ if (read.check(value)) value.path; // value: Read
46
+
47
+ read.errors({ offset: 0, extra: true });
48
+ // [
49
+ // { path: "/path", keyword: "required", message: "missing" },
50
+ // { path: "/mode", keyword: "required", message: "missing" },
51
+ // { path: "/offset", keyword: "minimum", message: "expected >= 1" },
52
+ // { path: "/extra", keyword: "additionalProperties", message: "unknown field" },
53
+ // ]
54
+ ```
55
+
56
+ ## Documentation
57
+
58
+ The full guide and API reference are in Atomic's docs: **[@bastani/atomic-schema](https://docs.bastani.ai/libraries/schema)**.
59
+
60
+ ## License
61
+
62
+ MIT. See [LICENSE](LICENSE).
63
+
64
+ Derived from pi by Mario Zechner and Earendil Works; see [NOTICE.md](NOTICE.md).
@@ -0,0 +1,23 @@
1
+ TypeBox
2
+
3
+ The MIT License (MIT)
4
+
5
+ Copyright (c) 2017-2026 Haydn Paterson
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in
15
+ all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ THE SOFTWARE.
@@ -0,0 +1,44 @@
1
+ import type { Check } from "./types.ts";
2
+ /** What a schema evaluated: property names (or all of them), the evaluated item prefix, items matched by `contains`. */
3
+ export interface Annotations {
4
+ props: Set<string> | null;
5
+ allProps: boolean;
6
+ items: number;
7
+ allItems: boolean;
8
+ indexes: Set<number> | null;
9
+ }
10
+ /** A check that records what it evaluated into `a` when it passes. */
11
+ export type AnnotatingCheck = (value: unknown, a: Annotations) => boolean;
12
+ /** Empty annotations. */
13
+ export declare function newAnnotations(): Annotations;
14
+ export declare const ANNOTATING_TRUE: AnnotatingCheck;
15
+ export declare const ANNOTATING_FALSE: AnnotatingCheck;
16
+ /** The indirection a recursive reference goes through. */
17
+ export declare function indirectAnnotating(slot: {
18
+ check: AnnotatingCheck | undefined;
19
+ }): AnnotatingCheck;
20
+ /** A plain check in annotating position: it evaluates nothing that unevaluated* sees. */
21
+ export declare function ignoreAnnotations(check: Check): AnnotatingCheck;
22
+ /** An annotating check run as a plain check, with fresh annotations. */
23
+ export declare function withFreshAnnotations(check: AnnotatingCheck): Check;
24
+ /** `check` with `uri` pushed onto the dynamic scope while it runs. */
25
+ export declare function scopedAnnotating(scope: string[], uri: string, check: AnnotatingCheck): AnnotatingCheck;
26
+ /** unevaluated* sees only the annotations of its own schema, never those of its siblings in the parent. */
27
+ export declare function isolateAnnotations(check: AnnotatingCheck): AnnotatingCheck;
28
+ /** The non-annotating keywords, then each annotating part in order. */
29
+ export declare function annotateAll(plain: Check, parts: readonly AnnotatingCheck[]): AnnotatingCheck;
30
+ /** `properties`, `patternProperties` and `additionalProperties`. */
31
+ export declare function annotateObject(props: readonly (readonly [string, Check])[], patterns: readonly (readonly [RegExp, Check])[], additional: Check | undefined): AnnotatingCheck;
32
+ /** `prefixItems`/`items`/`additionalItems` and `contains` with its bounds. */
33
+ export declare function annotateArray(prefix: readonly Check[], rest: Check | undefined, contains: Check | undefined, minContains: number, maxContains: number): AnnotatingCheck;
34
+ /** `anyOf` (or `oneOf` when `exactlyOne`): every passing branch contributes its annotations. */
35
+ export declare function annotateAny(branches: readonly AnnotatingCheck[], exactlyOne: boolean): AnnotatingCheck;
36
+ /** `if`, `then` and `else`: a passing `if` contributes its annotations even without `then`. */
37
+ export declare function annotateIf(cond: AnnotatingCheck, then: AnnotatingCheck | undefined, otherwise: AnnotatingCheck | undefined): AnnotatingCheck;
38
+ /** One `dependentSchemas` entry. */
39
+ export declare function annotateDependent(key: string, check: AnnotatingCheck): AnnotatingCheck;
40
+ /** `unevaluatedProperties`: every property no other keyword evaluated passes `check`. */
41
+ export declare function unevaluatedProperties(check: Check): AnnotatingCheck;
42
+ /** `unevaluatedItems`: every item no other keyword evaluated passes `check`. */
43
+ export declare function unevaluatedItems(check: Check): AnnotatingCheck;
44
+ //# sourceMappingURL=annotations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotations.d.ts","sourceRoot":"","sources":["../src/annotations.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,wHAAwH;AACxH,MAAM,WAAW,WAAW;IAC3B,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IAC1B,QAA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K,GAAG,SAAS,GAC3B,eAAe,CA2BjB;AAED,8EAA8E;AAC9E,wBAAgB,aAAa,CAC5B,MAAM,EAAE,SAAS,KAAK,EAAE,EACxB,IAAI,EAAE,KAAK,GAAG,SAAS,EACvB,QAAQ,EAAE,KAAK,GAAG,SAAS,EAC3B,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,GACjB,eAAe,CAsBjB;AAED,gGAAgG;AAChG,wBAAgB,WAAW,CAAC,QAAQ,EAAE,SAAS,eAAe,EAAE,EAAE,UAAU,EAAE,OAAO,GAAG,eAAe,CAYtG;AAED,+FAA+F;AAC/F,wBAAgB,UAAU,CACzB,IAAI,EAAE,eAAe,EACrB,IAAI,EAAE,eAAe,GAAG,SAAS,EACjC,SAAS,EAAE,eAAe,GAAG,SAAS,GACpC,eAAe,CASjB;AAED,oCAAoC;AACpC,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,GAAG,eAAe,CAEtF;AAED,yFAAyF;AACzF,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,KAAK,GAAG,eAAe,CAOnE;AAED,gFAAgF;AAChF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,eAAe,CAO9D"}
@@ -0,0 +1,193 @@
1
+ // Annotation tracking for `unevaluatedProperties` and `unevaluatedItems`: annotating checks record which
2
+ // properties and items a schema evaluated. Only schemas that use those keywords compile into these closures.
3
+ import { isObject } from "./checks.js";
4
+ /** Empty annotations. */
5
+ export function newAnnotations() {
6
+ return { props: null, allProps: false, items: 0, allItems: false, indexes: null };
7
+ }
8
+ function merge(a, b) {
9
+ if (b.props !== null)
10
+ for (const k of b.props)
11
+ addProp(a, k);
12
+ a.allProps ||= b.allProps;
13
+ if (b.items > a.items)
14
+ a.items = b.items;
15
+ a.allItems ||= b.allItems;
16
+ if (b.indexes !== null)
17
+ for (const i of b.indexes)
18
+ addIndex(a, i);
19
+ }
20
+ function addProp(a, key) {
21
+ if (a.props === null)
22
+ a.props = new Set();
23
+ a.props.add(key);
24
+ }
25
+ function addIndex(a, index) {
26
+ if (a.indexes === null)
27
+ a.indexes = new Set();
28
+ a.indexes.add(index);
29
+ }
30
+ export const ANNOTATING_TRUE = () => true;
31
+ export const ANNOTATING_FALSE = () => false;
32
+ /** The indirection a recursive reference goes through. */
33
+ export function indirectAnnotating(slot) {
34
+ return (v, a) => slot.check(v, a);
35
+ }
36
+ /** A plain check in annotating position: it evaluates nothing that unevaluated* sees. */
37
+ export function ignoreAnnotations(check) {
38
+ return (v) => check(v);
39
+ }
40
+ /** An annotating check run as a plain check, with fresh annotations. */
41
+ export function withFreshAnnotations(check) {
42
+ return (v) => check(v, newAnnotations());
43
+ }
44
+ /** `check` with `uri` pushed onto the dynamic scope while it runs. */
45
+ export function scopedAnnotating(scope, uri, check) {
46
+ return (v, a) => {
47
+ scope.push(uri);
48
+ const ok = check(v, a);
49
+ scope.pop();
50
+ return ok;
51
+ };
52
+ }
53
+ /** unevaluated* sees only the annotations of its own schema, never those of its siblings in the parent. */
54
+ export function isolateAnnotations(check) {
55
+ return (v, a) => {
56
+ const b = newAnnotations();
57
+ if (!check(v, b))
58
+ return false;
59
+ merge(a, b);
60
+ return true;
61
+ };
62
+ }
63
+ /** The non-annotating keywords, then each annotating part in order. */
64
+ export function annotateAll(plain, parts) {
65
+ return (v, a) => {
66
+ if (!plain(v))
67
+ return false;
68
+ for (let i = 0; i < parts.length; i++)
69
+ if (!parts[i](v, a))
70
+ return false;
71
+ return true;
72
+ };
73
+ }
74
+ /** `properties`, `patternProperties` and `additionalProperties`. */
75
+ export function annotateObject(props, patterns, additional) {
76
+ const declared = new Set(props.map(([k]) => k));
77
+ return (v, a) => {
78
+ if (!isObject(v))
79
+ return true;
80
+ const seen = [];
81
+ for (const [k, check] of props) {
82
+ if (!Object.hasOwn(v, k))
83
+ continue;
84
+ if (!check(v[k]))
85
+ return false;
86
+ seen.push(k);
87
+ }
88
+ for (const k of Object.keys(v)) {
89
+ let matched = declared.has(k);
90
+ for (const [re, check] of patterns) {
91
+ if (re.test(k)) {
92
+ if (!check(v[k]))
93
+ return false;
94
+ matched = true;
95
+ seen.push(k);
96
+ }
97
+ }
98
+ if (!matched && additional !== undefined) {
99
+ if (!additional(v[k]))
100
+ return false;
101
+ seen.push(k);
102
+ }
103
+ }
104
+ for (const k of seen)
105
+ addProp(a, k);
106
+ return true;
107
+ };
108
+ }
109
+ /** `prefixItems`/`items`/`additionalItems` and `contains` with its bounds. */
110
+ export function annotateArray(prefix, rest, contains, minContains, maxContains) {
111
+ return (v, a) => {
112
+ if (!Array.isArray(v))
113
+ return true;
114
+ const m = Math.min(v.length, prefix.length);
115
+ for (let i = 0; i < m; i++)
116
+ if (!prefix[i](v[i]))
117
+ return false;
118
+ if (rest !== undefined) {
119
+ for (let i = prefix.length; i < v.length; i++)
120
+ if (!rest(v[i]))
121
+ return false;
122
+ a.allItems = true;
123
+ }
124
+ if (m > a.items)
125
+ a.items = m;
126
+ if (contains !== undefined) {
127
+ let n = 0;
128
+ for (let i = 0; i < v.length; i++) {
129
+ if (contains(v[i])) {
130
+ n++;
131
+ addIndex(a, i);
132
+ }
133
+ }
134
+ if (n < minContains || n > maxContains)
135
+ return false;
136
+ }
137
+ return true;
138
+ };
139
+ }
140
+ /** `anyOf` (or `oneOf` when `exactlyOne`): every passing branch contributes its annotations. */
141
+ export function annotateAny(branches, exactlyOne) {
142
+ return (v, a) => {
143
+ let n = 0;
144
+ for (const branch of branches) {
145
+ const b = newAnnotations();
146
+ if (branch(v, b)) {
147
+ n++;
148
+ merge(a, b);
149
+ }
150
+ }
151
+ return exactlyOne ? n === 1 : n > 0;
152
+ };
153
+ }
154
+ /** `if`, `then` and `else`: a passing `if` contributes its annotations even without `then`. */
155
+ export function annotateIf(cond, then, otherwise) {
156
+ return (v, a) => {
157
+ const b = newAnnotations();
158
+ if (cond(v, b)) {
159
+ merge(a, b);
160
+ return then === undefined || then(v, a);
161
+ }
162
+ return otherwise === undefined || otherwise(v, a);
163
+ };
164
+ }
165
+ /** One `dependentSchemas` entry. */
166
+ export function annotateDependent(key, check) {
167
+ return (v, a) => !isObject(v) || !Object.hasOwn(v, key) || check(v, a);
168
+ }
169
+ /** `unevaluatedProperties`: every property no other keyword evaluated passes `check`. */
170
+ export function unevaluatedProperties(check) {
171
+ return (v, a) => {
172
+ if (!isObject(v) || a.allProps)
173
+ return true;
174
+ for (const k of Object.keys(v))
175
+ if (!(a.props?.has(k) ?? false) && !check(v[k]))
176
+ return false;
177
+ a.allProps = true;
178
+ return true;
179
+ };
180
+ }
181
+ /** `unevaluatedItems`: every item no other keyword evaluated passes `check`. */
182
+ export function unevaluatedItems(check) {
183
+ return (v, a) => {
184
+ if (!Array.isArray(v) || a.allItems)
185
+ return true;
186
+ for (let i = a.items; i < v.length; i++)
187
+ if (!(a.indexes?.has(i) ?? false) && !check(v[i]))
188
+ return false;
189
+ a.allItems = true;
190
+ return true;
191
+ };
192
+ }
193
+ //# sourceMappingURL=annotations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotations.js","sourceRoot":"","sources":["../src/annotations.ts"],"names":[],"mappings":"AAAA,yGAAyG;AACzG,6GAA6G;AAE7G,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAevC,yBAAyB;AACzB,MAAM,UAAU,cAAc;IAC7B,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACnF,CAAC;AAED,SAAS,KAAK,CAAC,CAAc,EAAE,CAAc;IAC5C,IAAI,CAAC,CAAC,KAAK,KAAK,IAAI;QAAE,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK;YAAE,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC7D,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,QAAQ,CAAC;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,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBAAE,OAAO,KAAK,CAAC;QACzG,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAC;QAClB,OAAO,IAAI,CAAC;IACb,CAAC,CAAC;AACH,CAAC","sourcesContent":["// Annotation tracking for `unevaluatedProperties` and `unevaluatedItems`: annotating checks record which\n// properties and items a schema evaluated. Only schemas that use those keywords compile into these closures.\n\nimport { isObject } from \"./checks.ts\";\nimport type { Check } from \"./types.ts\";\n\n/** What a schema evaluated: property names (or all of them), the evaluated item prefix, items matched by `contains`. */\nexport interface Annotations {\n\tprops: Set<string> | null;\n\tallProps: boolean;\n\titems: number;\n\tallItems: boolean;\n\tindexes: Set<number> | null;\n}\n\n/** A check that records what it evaluated into `a` when it passes. */\nexport type AnnotatingCheck = (value: unknown, a: Annotations) => boolean;\n\n/** Empty annotations. */\nexport function newAnnotations(): Annotations {\n\treturn { props: null, allProps: false, items: 0, allItems: false, indexes: null };\n}\n\nfunction merge(a: Annotations, b: Annotations): void {\n\tif (b.props !== null) for (const k of b.props) addProp(a, k);\n\ta.allProps ||= b.allProps;\n\tif (b.items > a.items) a.items = b.items;\n\ta.allItems ||= b.allItems;\n\tif (b.indexes !== null) for (const i of b.indexes) addIndex(a, i);\n}\n\nfunction addProp(a: Annotations, key: string): void {\n\tif (a.props === null) a.props = new Set();\n\ta.props.add(key);\n}\n\nfunction addIndex(a: Annotations, index: number): void {\n\tif (a.indexes === null) a.indexes = new Set();\n\ta.indexes.add(index);\n}\n\nexport const ANNOTATING_TRUE: AnnotatingCheck = () => true;\nexport const ANNOTATING_FALSE: AnnotatingCheck = () => false;\n\n/** The indirection a recursive reference goes through. */\nexport function indirectAnnotating(slot: { check: AnnotatingCheck | undefined }): AnnotatingCheck {\n\treturn (v, a) => (slot.check as AnnotatingCheck)(v, a);\n}\n\n/** A plain check in annotating position: it evaluates nothing that unevaluated* sees. */\nexport function ignoreAnnotations(check: Check): AnnotatingCheck {\n\treturn (v) => check(v);\n}\n\n/** An annotating check run as a plain check, with fresh annotations. */\nexport function withFreshAnnotations(check: AnnotatingCheck): Check {\n\treturn (v) => check(v, newAnnotations());\n}\n\n/** `check` with `uri` pushed onto the dynamic scope while it runs. */\nexport function scopedAnnotating(scope: string[], uri: string, check: AnnotatingCheck): AnnotatingCheck {\n\treturn (v, a) => {\n\t\tscope.push(uri);\n\t\tconst ok = check(v, a);\n\t\tscope.pop();\n\t\treturn ok;\n\t};\n}\n\n/** unevaluated* sees only the annotations of its own schema, never those of its siblings in the parent. */\nexport function isolateAnnotations(check: AnnotatingCheck): AnnotatingCheck {\n\treturn (v, a) => {\n\t\tconst b = newAnnotations();\n\t\tif (!check(v, b)) return false;\n\t\tmerge(a, b);\n\t\treturn true;\n\t};\n}\n\n/** The non-annotating keywords, then each annotating part in order. */\nexport function annotateAll(plain: Check, parts: readonly AnnotatingCheck[]): AnnotatingCheck {\n\treturn (v, a) => {\n\t\tif (!plain(v)) return false;\n\t\tfor (let i = 0; i < parts.length; i++) if (!parts[i](v, a)) return false;\n\t\treturn true;\n\t};\n}\n\n/** `properties`, `patternProperties` and `additionalProperties`. */\nexport function annotateObject(\n\tprops: readonly (readonly [string, Check])[],\n\tpatterns: readonly (readonly [RegExp, Check])[],\n\tadditional: Check | undefined,\n): AnnotatingCheck {\n\tconst declared = new Set(props.map(([k]) => k));\n\treturn (v, a) => {\n\t\tif (!isObject(v)) return true;\n\t\tconst seen: string[] = [];\n\t\tfor (const [k, check] of props) {\n\t\t\tif (!Object.hasOwn(v, k)) continue;\n\t\t\tif (!check(v[k])) return false;\n\t\t\tseen.push(k);\n\t\t}\n\t\tfor (const k of Object.keys(v)) {\n\t\t\tlet matched = declared.has(k);\n\t\t\tfor (const [re, check] of patterns) {\n\t\t\t\tif (re.test(k)) {\n\t\t\t\t\tif (!check(v[k])) return false;\n\t\t\t\t\tmatched = true;\n\t\t\t\t\tseen.push(k);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!matched && additional !== undefined) {\n\t\t\t\tif (!additional(v[k])) return false;\n\t\t\t\tseen.push(k);\n\t\t\t}\n\t\t}\n\t\tfor (const k of seen) addProp(a, k);\n\t\treturn true;\n\t};\n}\n\n/** `prefixItems`/`items`/`additionalItems` and `contains` with its bounds. */\nexport function annotateArray(\n\tprefix: readonly Check[],\n\trest: Check | undefined,\n\tcontains: Check | undefined,\n\tminContains: number,\n\tmaxContains: number,\n): AnnotatingCheck {\n\treturn (v, a) => {\n\t\tif (!Array.isArray(v)) return true;\n\t\tconst m = Math.min(v.length, prefix.length);\n\t\tfor (let i = 0; i < m; i++) if (!prefix[i](v[i])) return false;\n\t\tif (rest !== undefined) {\n\t\t\tfor (let i = prefix.length; i < v.length; i++) if (!rest(v[i])) return false;\n\t\t\ta.allItems = true;\n\t\t}\n\t\tif (m > a.items) a.items = m;\n\t\tif (contains !== undefined) {\n\t\t\tlet n = 0;\n\t\t\tfor (let i = 0; i < v.length; i++) {\n\t\t\t\tif (contains(v[i])) {\n\t\t\t\t\tn++;\n\t\t\t\t\taddIndex(a, i);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (n < minContains || n > maxContains) return false;\n\t\t}\n\t\treturn true;\n\t};\n}\n\n/** `anyOf` (or `oneOf` when `exactlyOne`): every passing branch contributes its annotations. */\nexport function annotateAny(branches: readonly AnnotatingCheck[], exactlyOne: boolean): AnnotatingCheck {\n\treturn (v, a) => {\n\t\tlet n = 0;\n\t\tfor (const branch of branches) {\n\t\t\tconst b = newAnnotations();\n\t\t\tif (branch(v, b)) {\n\t\t\t\tn++;\n\t\t\t\tmerge(a, b);\n\t\t\t}\n\t\t}\n\t\treturn exactlyOne ? n === 1 : n > 0;\n\t};\n}\n\n/** `if`, `then` and `else`: a passing `if` contributes its annotations even without `then`. */\nexport function annotateIf(\n\tcond: AnnotatingCheck,\n\tthen: AnnotatingCheck | undefined,\n\totherwise: AnnotatingCheck | undefined,\n): AnnotatingCheck {\n\treturn (v, a) => {\n\t\tconst b = newAnnotations();\n\t\tif (cond(v, b)) {\n\t\t\tmerge(a, b);\n\t\t\treturn then === undefined || then(v, a);\n\t\t}\n\t\treturn otherwise === undefined || otherwise(v, a);\n\t};\n}\n\n/** One `dependentSchemas` entry. */\nexport function annotateDependent(key: string, check: AnnotatingCheck): AnnotatingCheck {\n\treturn (v, a) => !isObject(v) || !Object.hasOwn(v, key) || check(v, a);\n}\n\n/** `unevaluatedProperties`: every property no other keyword evaluated passes `check`. */\nexport function unevaluatedProperties(check: Check): AnnotatingCheck {\n\treturn (v, a) => {\n\t\tif (!isObject(v) || a.allProps) return true;\n\t\tfor (const k of Object.keys(v)) if (!(a.props?.has(k) ?? false) && !check(v[k])) return false;\n\t\ta.allProps = true;\n\t\treturn true;\n\t};\n}\n\n/** `unevaluatedItems`: every item no other keyword evaluated passes `check`. */\nexport function unevaluatedItems(check: Check): AnnotatingCheck {\n\treturn (v, a) => {\n\t\tif (!Array.isArray(v) || a.allItems) return true;\n\t\tfor (let i = a.items; i < v.length; i++) if (!(a.indexes?.has(i) ?? false) && !check(v[i])) return false;\n\t\ta.allItems = true;\n\t\treturn true;\n\t};\n}\n"]}
@@ -0,0 +1,143 @@
1
+ import type { TypeBoxStatic } from "./typebox-static.ts";
2
+ declare const STATIC: unique symbol;
3
+ declare const OPTIONAL_TYPE: unique symbol;
4
+ /** A JSON Schema object whose valid values have type `T` (a type-level brand; nothing extra exists at run time). */
5
+ export type Schema<T = unknown> = {
6
+ readonly [keyword: string]: unknown;
7
+ } & {
8
+ readonly [STATIC]?: T;
9
+ };
10
+ /**
11
+ * The type of the values `S` accepts: the type a builder recorded; for a TypeBox schema (`'~kind'` or `'~unsafe'`),
12
+ * TypeBox's static type for the common kinds (see `TypeBoxStatic`); else `unknown`.
13
+ */
14
+ export type Static<S> = S extends {
15
+ readonly "~kind": unknown;
16
+ } | {
17
+ readonly "~unsafe": unknown;
18
+ } ? TypeBoxStatic<S> : S extends {
19
+ readonly [STATIC]?: infer T;
20
+ } ? unknown extends T ? unknown : T : unknown;
21
+ /** Annotations every builder accepts: they describe the schema and never change what it accepts. */
22
+ export interface Annotations<T = unknown> {
23
+ readonly title?: string;
24
+ readonly description?: string;
25
+ readonly examples?: readonly T[];
26
+ readonly deprecated?: boolean;
27
+ /** A default value, an annotation for tools and forms; validation never inserts it. */
28
+ readonly default?: T;
29
+ }
30
+ /** Length bounds of a string, an array or bytes. */
31
+ export interface LengthBounds {
32
+ readonly minLength?: number;
33
+ readonly maxLength?: number;
34
+ }
35
+ /** A string, with optional length bounds (in code points), pattern and format. */
36
+ export declare function str(options?: Annotations<string> & LengthBounds & {
37
+ readonly pattern?: string;
38
+ readonly format?: string;
39
+ }): Schema<string>;
40
+ /** Bounds of a number. */
41
+ export interface NumberBounds {
42
+ readonly minimum?: number;
43
+ readonly maximum?: number;
44
+ readonly exclusiveMinimum?: number;
45
+ readonly exclusiveMaximum?: number;
46
+ readonly multipleOf?: number;
47
+ }
48
+ /** A number within optional bounds. */
49
+ export declare function num(options?: Annotations<number> & NumberBounds): Schema<number>;
50
+ /** An integer within optional bounds. */
51
+ export declare function int(options?: Annotations<number> & NumberBounds): Schema<number>;
52
+ /** Bounds of a bigint: TypeBox's `Type.BigInt` options. */
53
+ export interface BigintBounds {
54
+ readonly minimum?: bigint;
55
+ readonly maximum?: bigint;
56
+ readonly exclusiveMinimum?: bigint;
57
+ readonly exclusiveMaximum?: bigint;
58
+ readonly multipleOf?: bigint;
59
+ }
60
+ /**
61
+ * A bigint within optional bounds (`{ type: "bigint" }`, as TypeBox's `Type.BigInt`): an extension of JSON Schema for
62
+ * values that never pass through JSON, such as 64-bit integers a Parquet reader decodes.
63
+ */
64
+ export declare function bigint(options?: Annotations<bigint> & BigintBounds): Schema<bigint>;
65
+ /** A boolean. */
66
+ export declare function bool(options?: Annotations<boolean>): Schema<boolean>;
67
+ /** `null`. */
68
+ export declare function nul(options?: Annotations<null>): Schema<null>;
69
+ /** Any value. */
70
+ export declare function unknown(options?: Annotations): Schema<unknown>;
71
+ /** Exactly `value` (a string, number, boolean or null). */
72
+ export declare function lit<const V extends string | number | boolean | null>(value: V, options?: Annotations<V>): Schema<V>;
73
+ /** One of the given values. */
74
+ export declare function oneOf<const V extends readonly (string | number | boolean | null)[]>(values: V, options?: Annotations<V[number]>): Schema<V[number]>;
75
+ /**
76
+ * Any of the given schemas. A union of objects tagged by a `lit()` property (`{ kind: lit("text"), ... }`) is checked
77
+ * by the tag: only the branch it selects runs, and its errors are the ones reported.
78
+ */
79
+ export declare function union<const S extends readonly Schema[]>(schemas: S, options?: Annotations<Static<S[number]>>): Schema<Static<S[number]>>;
80
+ /** `schema` or `null`. */
81
+ export declare function nullable<T>(schema: Schema<T>, options?: Annotations<T | null>): Schema<T | null>;
82
+ /** An array of `items`, with optional length bounds and unique items. */
83
+ export declare function arr<T>(items: Schema<T>, options?: Annotations<T[]> & {
84
+ readonly minItems?: number;
85
+ readonly maxItems?: number;
86
+ readonly uniqueItems?: boolean;
87
+ }): Schema<T[]>;
88
+ /** A fixed-length array whose items match `items` in order. */
89
+ export declare function tuple<const S extends readonly Schema[]>(items: S, options?: Annotations<{
90
+ -readonly [K in keyof S]: Static<S[K]>;
91
+ }>): Schema<{
92
+ -readonly [K in keyof S]: Static<S[K]>;
93
+ }>;
94
+ /** An object with string keys and values of `value` (a record). */
95
+ export declare function map<T>(value: Schema<T>, options?: Annotations<Record<string, T>>): Schema<Record<string, T>>;
96
+ /**
97
+ * `schema` typed as accepting `T`, for values the builders cannot express (a type checked elsewhere, a schema from
98
+ * another system). The schema is returned as it is: nothing checks that its values are `T`.
99
+ */
100
+ export declare function unsafe<T>(schema?: Schema): Schema<T>;
101
+ /**
102
+ * A schema that contains itself, as a tree's children are trees: `build` receives a reference to the schema it
103
+ * returns. TypeScript cannot infer a recursive type from the builders, so `T` is given:
104
+ * `recursive<Tree>("Tree", (tree) => obj({ name: str(), children: arr(tree) }))`. `id` becomes the schema's `$id`
105
+ * and the target of the reference, so it must be unique among the recursive schemas within one schema.
106
+ *
107
+ * The counterpart of TypeBox's `Type.Cyclic` + `Type.Ref`, with other JSON: an `$id` on the schema instead of `$defs`
108
+ * and a root `$ref`. It validates the same values. The JSON differs only where a schema is published, and its type is
109
+ * written once instead of inferred, which a recursive schema (a file tree) needs only once.
110
+ */
111
+ export declare function recursive<T>(id: string, build: (self: Schema<T>) => Schema<T>): Schema<T>;
112
+ /** A Uint8Array with optional length bounds (an extension of JSON Schema for values that never pass through JSON). */
113
+ export declare function bytes(options?: Annotations<Uint8Array> & LengthBounds): Schema<Uint8Array>;
114
+ /** An optional property of obj(): `{ name: opt(str()) }` may omit `name` or set it to undefined. */
115
+ export declare class Optional<S extends Schema = Schema> {
116
+ readonly [OPTIONAL_TYPE]?: S;
117
+ readonly schema: S;
118
+ constructor(schema: S);
119
+ }
120
+ /** Marks an obj() property as optional. */
121
+ export declare function opt<S extends Schema>(schema: S): Optional<S>;
122
+ /** The properties of obj(): a schema or an opt() schema per name. */
123
+ export type Properties = {
124
+ readonly [name: string]: Schema | Optional;
125
+ };
126
+ /** The value type of an obj() schema. */
127
+ export type StaticObject<P extends Properties> = Simplify<{
128
+ -readonly [K in keyof P as P[K] extends Optional ? never : K]: Static<P[K]>;
129
+ } & {
130
+ -readonly [K in keyof P as P[K] extends Optional ? K : never]?: P[K] extends Optional<infer S> ? Static<S> : never;
131
+ }>;
132
+ type Simplify<T> = {
133
+ [K in keyof T]: T[K];
134
+ } & {};
135
+ /**
136
+ * A closed object: the given properties (required unless opt()) and no others. `open: true` allows other
137
+ * properties, as tool schemas from other systems often do.
138
+ */
139
+ export declare function obj<const P extends Properties>(properties: P, options?: Annotations<StaticObject<P>> & {
140
+ readonly open?: boolean;
141
+ }): Schema<StaticObject<P>>;
142
+ export {};
143
+ //# sourceMappingURL=builders.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3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