baobox 0.1.0 → 0.1.1-rc.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 (214) hide show
  1. package/README.md +137 -89
  2. package/dist/compile/bun-fast-path.d.ts +1 -1
  3. package/dist/compile/bun-fast-path.d.ts.map +1 -1
  4. package/dist/compile/index.js +632 -505
  5. package/dist/compile/index.js.map +23 -23
  6. package/dist/error/collector/collections-basic.d.ts.map +1 -1
  7. package/dist/error/index.js +368 -288
  8. package/dist/error/index.js.map +14 -14
  9. package/dist/format/format.d.ts.map +1 -1
  10. package/dist/format/index.js +262 -89
  11. package/dist/format/index.js.map +9 -8
  12. package/dist/index.js +739 -609
  13. package/dist/index.js.map +39 -39
  14. package/dist/schema/core.d.ts.map +1 -1
  15. package/dist/schema/emitter.d.ts.map +1 -1
  16. package/dist/schema/engine.d.ts +2 -1
  17. package/dist/schema/engine.d.ts.map +1 -1
  18. package/dist/schema/index.js +343 -255
  19. package/dist/schema/index.js.map +13 -13
  20. package/dist/script/index.d.ts.map +1 -1
  21. package/dist/script/index.js +413 -324
  22. package/dist/script/index.js.map +18 -18
  23. package/dist/shared/bytes.d.ts.map +1 -1
  24. package/dist/shared/format-constants.d.ts +25 -0
  25. package/dist/shared/format-constants.d.ts.map +1 -1
  26. package/dist/shared/format-validators.d.ts +2 -2
  27. package/dist/shared/format-validators.d.ts.map +1 -1
  28. package/dist/shared/object-utils.d.ts.map +1 -1
  29. package/dist/shared/runtime-guards.d.ts +20 -0
  30. package/dist/shared/runtime-guards.d.ts.map +1 -1
  31. package/dist/shared/schema-access.d.ts +1 -1
  32. package/dist/shared/schema-access.d.ts.map +1 -1
  33. package/dist/shared/url-like.d.ts +16 -0
  34. package/dist/shared/url-like.d.ts.map +1 -0
  35. package/dist/shared/utils.d.ts +1 -1
  36. package/dist/shared/utils.d.ts.map +1 -1
  37. package/dist/shared/utils.js +254 -73
  38. package/dist/shared/utils.js.map +8 -7
  39. package/dist/standard/index.d.ts +2 -1
  40. package/dist/standard/index.d.ts.map +1 -1
  41. package/dist/standard/index.js +526 -422
  42. package/dist/standard/index.js.map +21 -21
  43. package/dist/system/index.js +363 -152
  44. package/dist/system/index.js.map +12 -11
  45. package/dist/system/system.d.ts.map +1 -1
  46. package/dist/type/codec-builtins.d.ts +3 -1
  47. package/dist/type/codec-builtins.d.ts.map +1 -1
  48. package/dist/type/extensions.d.ts +1 -0
  49. package/dist/type/extensions.d.ts.map +1 -1
  50. package/dist/type/index.d.ts +1 -1
  51. package/dist/type/index.d.ts.map +1 -1
  52. package/dist/type/index.js +389 -308
  53. package/dist/type/index.js.map +17 -17
  54. package/dist/type/instantiation.d.ts.map +1 -1
  55. package/dist/type/primitives.d.ts.map +1 -1
  56. package/dist/type/root-helpers.d.ts.map +1 -1
  57. package/dist/type/root-shared.d.ts +1 -1
  58. package/dist/type/root-shared.d.ts.map +1 -1
  59. package/dist/type/uint8array-codec.d.ts +8 -1
  60. package/dist/type/uint8array-codec.d.ts.map +1 -1
  61. package/dist/typebox.js +413 -324
  62. package/dist/typebox.js.map +18 -18
  63. package/dist/value/check.d.ts.map +1 -1
  64. package/dist/value/clean.d.ts.map +1 -1
  65. package/dist/value/convert.d.ts.map +1 -1
  66. package/dist/value/create.d.ts.map +1 -1
  67. package/dist/value/decode.d.ts.map +1 -1
  68. package/dist/value/default.d.ts.map +1 -1
  69. package/dist/value/diff.d.ts.map +1 -1
  70. package/dist/value/encode.d.ts.map +1 -1
  71. package/dist/value/equal.d.ts.map +1 -1
  72. package/dist/value/has-codec.d.ts.map +1 -1
  73. package/dist/value/hash.d.ts +0 -1
  74. package/dist/value/hash.d.ts.map +1 -1
  75. package/dist/value/index.js +666 -551
  76. package/dist/value/index.js.map +27 -27
  77. package/dist/value/mutate.d.ts.map +1 -1
  78. package/dist/value/patch.d.ts.map +1 -1
  79. package/dist/value/repair.d.ts.map +1 -1
  80. package/docs/package-contract.md +4 -0
  81. package/package.json +2 -4
  82. package/src/compile/bun-fast-path.ts +312 -0
  83. package/src/compile/emit.ts +166 -0
  84. package/src/compile/index.ts +317 -0
  85. package/src/error/catalog-types.ts +72 -0
  86. package/src/error/collector/advanced.ts +272 -0
  87. package/src/error/collector/collections-basic.ts +193 -0
  88. package/src/error/collector/collections-derived.ts +93 -0
  89. package/src/error/collector/collections-parameters.ts +74 -0
  90. package/src/error/collector/collections.ts +27 -0
  91. package/src/error/collector/primitives.ts +238 -0
  92. package/src/error/collector/shared.ts +15 -0
  93. package/src/error/collector.ts +28 -0
  94. package/src/error/errors.ts +53 -0
  95. package/src/error/index.ts +32 -0
  96. package/src/error/locales/de.ts +50 -0
  97. package/src/error/locales/en.ts +50 -0
  98. package/src/error/locales/es.ts +50 -0
  99. package/src/error/locales/fr.ts +50 -0
  100. package/src/error/locales/ja.ts +50 -0
  101. package/src/error/locales/ko.ts +50 -0
  102. package/src/error/locales/pt.ts +50 -0
  103. package/src/error/locales/shared.ts +9 -0
  104. package/src/error/locales/zh.ts +80 -0
  105. package/src/error/messages.ts +45 -0
  106. package/src/format/format.ts +132 -0
  107. package/src/format/index.ts +6 -0
  108. package/src/guard/guard.ts +274 -0
  109. package/src/guard/index.ts +8 -0
  110. package/src/index.ts +83 -0
  111. package/src/locale/index.ts +99 -0
  112. package/src/schema/build.ts +77 -0
  113. package/src/schema/check.ts +12 -0
  114. package/src/schema/compile.ts +47 -0
  115. package/src/schema/core-keywords.ts +272 -0
  116. package/src/schema/core.ts +112 -0
  117. package/src/schema/emitter-advanced.ts +22 -0
  118. package/src/schema/emitter-base.ts +91 -0
  119. package/src/schema/emitter-derived.ts +95 -0
  120. package/src/schema/emitter-reference.ts +66 -0
  121. package/src/schema/emitter-types.ts +10 -0
  122. package/src/schema/emitter-wrapper.ts +79 -0
  123. package/src/schema/emitter.ts +235 -0
  124. package/src/schema/engine.ts +240 -0
  125. package/src/schema/error-collector.ts +133 -0
  126. package/src/schema/errors.ts +14 -0
  127. package/src/schema/index.ts +5 -0
  128. package/src/schema/parse.ts +44 -0
  129. package/src/schema/pointer.ts +92 -0
  130. package/src/schema/predicates.ts +75 -0
  131. package/src/schema/resolve.ts +93 -0
  132. package/src/schema/runtime-keywords.ts +162 -0
  133. package/src/schema/schema.ts +13 -0
  134. package/src/schema/shared.ts +141 -0
  135. package/src/script/generic.ts +86 -0
  136. package/src/script/index.ts +125 -0
  137. package/src/script/literals.ts +75 -0
  138. package/src/script/shared.ts +94 -0
  139. package/src/shared/bytes.ts +74 -0
  140. package/src/shared/format-constants.ts +61 -0
  141. package/src/shared/format-validators.ts +133 -0
  142. package/src/shared/locale.ts +43 -0
  143. package/src/shared/object-utils.ts +159 -0
  144. package/src/shared/regex-json.ts +290 -0
  145. package/src/shared/registries.ts +83 -0
  146. package/src/shared/runtime-context.ts +196 -0
  147. package/src/shared/runtime-guards.ts +77 -0
  148. package/src/shared/schema-access.ts +149 -0
  149. package/src/shared/url-like.ts +15 -0
  150. package/src/shared/utils.ts +73 -0
  151. package/src/standard/index.ts +211 -0
  152. package/src/system/index.ts +6 -0
  153. package/src/system/system.ts +115 -0
  154. package/src/type/actions.ts +214 -0
  155. package/src/type/base-types.ts +5 -0
  156. package/src/type/codec-builtins.ts +31 -0
  157. package/src/type/combinator-core.ts +129 -0
  158. package/src/type/combinator-functions.ts +49 -0
  159. package/src/type/combinator-objects.ts +155 -0
  160. package/src/type/combinators.ts +34 -0
  161. package/src/type/composite-types.ts +46 -0
  162. package/src/type/containers-types.ts +56 -0
  163. package/src/type/containers.ts +64 -0
  164. package/src/type/extends.ts +156 -0
  165. package/src/type/extensions.ts +246 -0
  166. package/src/type/guards.ts +92 -0
  167. package/src/type/index.ts +245 -0
  168. package/src/type/instantiation.ts +307 -0
  169. package/src/type/kind.ts +75 -0
  170. package/src/type/narrow-types.ts +26 -0
  171. package/src/type/primitives-types.ts +116 -0
  172. package/src/type/primitives.ts +283 -0
  173. package/src/type/root-constants.ts +169 -0
  174. package/src/type/root-cyclic.ts +158 -0
  175. package/src/type/root-deferred.ts +77 -0
  176. package/src/type/root-guards.ts +91 -0
  177. package/src/type/root-helpers.ts +240 -0
  178. package/src/type/root-instantiate.ts +268 -0
  179. package/src/type/root-shared.ts +59 -0
  180. package/src/type/root-template.ts +206 -0
  181. package/src/type/schema.ts +81 -0
  182. package/src/type/static-const-types.ts +177 -0
  183. package/src/type/static-shared-types.ts +84 -0
  184. package/src/type/static-types.ts +226 -0
  185. package/src/type/string-action-types.ts +28 -0
  186. package/src/type/transform-types.ts +68 -0
  187. package/src/type/uint8array-codec.ts +55 -0
  188. package/src/type/wrapper-types.ts +89 -0
  189. package/src/typebox.ts +2 -0
  190. package/src/value/assert.ts +19 -0
  191. package/src/value/check-collections-derived.ts +198 -0
  192. package/src/value/check-collections.ts +130 -0
  193. package/src/value/check-extensions.ts +66 -0
  194. package/src/value/check-primitives.ts +132 -0
  195. package/src/value/check.ts +67 -0
  196. package/src/value/clean.ts +132 -0
  197. package/src/value/clone.ts +10 -0
  198. package/src/value/convert.ts +193 -0
  199. package/src/value/create.ts +167 -0
  200. package/src/value/decode.ts +146 -0
  201. package/src/value/default.ts +119 -0
  202. package/src/value/diff.ts +68 -0
  203. package/src/value/encode.ts +137 -0
  204. package/src/value/equal.ts +42 -0
  205. package/src/value/has-codec.ts +61 -0
  206. package/src/value/hash.ts +97 -0
  207. package/src/value/index.ts +149 -0
  208. package/src/value/mutate.ts +21 -0
  209. package/src/value/parse.ts +55 -0
  210. package/src/value/patch.ts +55 -0
  211. package/src/value/pipeline.ts +15 -0
  212. package/src/value/pointer.ts +169 -0
  213. package/src/value/repair.ts +183 -0
  214. package/src/value/result.ts +55 -0
package/README.md CHANGED
@@ -1,6 +1,32 @@
1
1
  # Baobox
2
2
 
3
- Baobox is a Bun-first, TypeScript-first schema library that targets TypeBox parity while leaving room for Bun-native improvements.
3
+ [![CI](https://github.com/d4551/baobox/actions/workflows/publish.yml/badge.svg)](https://github.com/d4551/baobox/actions/workflows/publish.yml)
4
+ [![License](https://img.shields.io/github/license/d4551/baobox)](https://github.com/d4551/baobox)
5
+ [![Bun](https://img.shields.io/badge/bun-%3E%3D1.3.11-black?logo=bun)](https://bun.sh)
6
+ [![TypeScript](https://img.shields.io/badge/typescript-%3E%3D6.0.0-3178C6?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
7
+
8
+ Baobox is a Bun-first, TypeScript-first schema library that keeps the familiar TypeBox-style authoring surface while adding result-first runtime APIs, scoped runtime contexts, compile caching, portable validator artifacts, and schema-interop helpers.
9
+
10
+ ## ELI5
11
+
12
+ - You describe what valid data looks like once.
13
+ - Baobox can then answer different questions with the same schema:
14
+ - Is this value valid: `Check`
15
+ - Can you clean and coerce it safely: `TryParse`
16
+ - What exactly failed: `Explain` or `Errors`
17
+ - Can I reuse this on a hot path: `CompileCached`
18
+ - Can another tool consume the same schema: `StandardSchemaV1`
19
+ - If you do not want exception-driven control flow, use the `Try*` family.
20
+
21
+ ## Why Baobox
22
+
23
+ - TypeBox-compatible root surface with baobox-only additions at the root entrypoint.
24
+ - Result-first runtime helpers: `TryParse`, `TryDecode`, `TryEncode`, `TryCreate`, and `TryRepair`.
25
+ - Scoped runtime contexts so locale catalogs, registries, settings, and compile caches do not have to be process-global.
26
+ - Compiled validators with cache reuse and portable `Validator.Artifact()` output.
27
+ - Standard Schema V1 adapters for typed baobox schemas and raw JSON-schema-style objects.
28
+ - Built-in codecs for common interop-heavy values: `Uint8Array`, `Date`, `URL`, and `bigint`.
29
+ - Localized validation errors with official bundles for every declared locale code through `baobox/locale`.
4
30
 
5
31
  ## Install
6
32
 
@@ -32,12 +58,14 @@ const User = Type.Object({
32
58
  }, { required: ['id', 'email', 'age'] })
33
59
 
34
60
  Check(User, { id: 'usr_1', email: 'ada@example.com', age: 37 })
61
+ // true
35
62
 
36
63
  TryParse(Type.Object({ count: Type.Number() }), { count: '5' })
37
64
  // { success: true, value: { count: 5 } }
38
65
 
39
66
  const validator = CompileCached(User)
40
67
  validator.Check({ id: 'usr_1', email: 'ada@example.com', age: 37 })
68
+ // true
41
69
 
42
70
  TryDecode(DateCodec(), '2024-01-01T00:00:00.000Z')
43
71
  // { success: true, value: new Date('2024-01-01T00:00:00.000Z') }
@@ -47,68 +75,102 @@ StandardUser['~standard'].validate({ id: 'usr_1', email: 'ada@example.com', age:
47
75
  // { value: { id: 'usr_1', email: 'ada@example.com', age: 37 } }
48
76
  ```
49
77
 
50
- ## Choose A Workflow
78
+ ## API Map
51
79
 
52
- - `Check(schema, value)` returns a boolean. Use it when you only need pass/fail validation.
53
- - `TryParse(schema, value)` runs the full normalization pipeline and returns `{ success, value | errors }`. Use it when the caller needs a non-throwing normalization path.
54
- - `TryDecode`, `TryEncode`, `TryCreate`, and `TryRepair` extend the same result-first contract to codecs, default generation, and repair flows.
55
- - `Parse(schema, value)` runs the full value pipeline: clone, default, convert, clean, then validate. It throws `ParseError` when validation still fails.
56
- - `Explain(schema, value)` returns raw issue metadata plus the localized message and active locale.
57
- - `Compile(schema)` creates a reusable validator for hot paths, now with per-context compile caching and portable `Validator.Artifact()` output. `Validator.Errors()` uses the same localized error messages as `Value.Errors()`.
80
+ | Problem | API | Result |
81
+ | --- | --- | --- |
82
+ | Fast pass/fail validation | `Check(schema, value)` | `boolean` |
83
+ | Normalize without exceptions | `TryParse(schema, value)` | `ParseResult<T>` |
84
+ | Throwing parity path | `Parse(schema, value)` | normalized value or `ParseError` |
85
+ | Codec decode without exceptions | `TryDecode(schema, value)` | `ParseResult<T>` |
86
+ | Codec encode without exceptions | `TryEncode(schema, value)` | `ParseResult<T>` |
87
+ | Default generation without exceptions | `TryCreate(schema)` | `ParseResult<T>` |
88
+ | Repair without exceptions | `TryRepair(schema, value)` | `ParseResult<T>` |
89
+ | Raw issue metadata plus localized messages | `Explain(schema, value)` | diagnostics array |
90
+ | Reusable hot-path validator | `Compile(schema)` or `CompileCached(schema)` | `Validator` |
91
+ | Reload a prebuilt validator body | `CompileFromArtifact(schema, artifact)` | `Validator` |
92
+ | Adapt to Standard Schema V1 | `StandardSchemaV1(schema)` | standard-compatible wrapper |
58
93
 
59
- ## Standard Schema Adapter
94
+ ## Result-First Runtime
60
95
 
61
- ```ts
62
- import { StandardSchemaV1, Type } from 'baobox'
63
-
64
- const User = StandardSchemaV1(Type.Object({
65
- name: Type.String(),
66
- age: Type.Number(),
67
- }, { required: ['name', 'age'] }))
96
+ Baobox keeps `Parse(schema, value)` as the upstream-style throwing path, but the default baobox direction is result-first:
68
97
 
69
- User['~standard'].validate({ name: 'Ada', age: '37' })
70
- // { value: { name: 'Ada', age: 37 } }
71
- ```
98
+ - `TryParse` runs `Clone -> Default -> Convert -> Clean -> Check`
99
+ - `TryDecode` and `TryEncode` apply codec transforms without exception control flow
100
+ - `TryCreate` and `TryRepair` make default-generation and corrective flows explicit
101
+ - `Explain` preserves issue codes, params, locale, and final message
72
102
 
73
- Baobox also ships the dedicated `baobox/standard` subpath for schema-agnostic integrations.
103
+ If you are writing request handling, config loading, env parsing, or service boundaries, the `Try*` APIs are usually the better fit.
74
104
 
75
- `ToStandardSchema()` is the generic alias when you already have either a baobox schema or a raw JSON schema object. `FromJsonSchema()` is the explicit raw-schema entry point.
105
+ ## Compiled Validators
76
106
 
77
- ## Localized Validation Errors
107
+ `Compile()` builds a reusable validator object. `CompileCached()` adds per-runtime-context cache reuse. `CompileFromArtifact()` reloads previously emitted validator code.
78
108
 
79
109
  ```ts
80
- import { Errors, String } from 'baobox'
81
- import { System } from 'baobox/system'
110
+ import { CompileCached, CompileFromArtifact, Number, Object } from 'baobox'
82
111
 
83
- System.Locale.Set(System.Locale.ko_KR)
112
+ const schema = Object({
113
+ count: Number({ minimum: 1 }),
114
+ }, { required: ['count'] })
84
115
 
85
- Errors(String(), 42)
86
- // [{ path: '/', code: 'INVALID_TYPE', message: 'string이어야 합니다. 현재 값 유형: number' }]
116
+ const validator = CompileCached(schema)
117
+ const artifact = validator.Artifact()
118
+ const loaded = CompileFromArtifact(schema, artifact)
119
+
120
+ loaded.TryParse({ count: '2' })
121
+ // { success: true, value: { count: 2 } }
87
122
  ```
88
123
 
89
- `en_US` is the default locale. Baobox now ships an official bundle for every declared locale code through `baobox/locale`, so declared locales no longer fall back through the registry lookup path. The translated catalog families currently include `de_DE`, `en_US`, the Spanish family (`es_419`, `es_AR`, `es_ES`, `es_MX`), the French family (`fr_CA`, `fr_FR`), `ja_JP`, `ko_KR`, the Portuguese family (`pt_BR`, `pt_PT`), and both Chinese packs (`zh_Hans`, `zh_Hant`). The remaining official bundles currently alias the English catalog until native translations are added.
124
+ Technical details:
125
+
126
+ - compile caching is scoped to the active runtime context
127
+ - artifacts let you ship emitted validator code instead of regenerating it at startup
128
+ - Bun-specific byte-oriented fast paths are used only when the schema shape makes that safe
90
129
 
91
- You can also register scoped or process-default catalogs directly:
130
+ ## Standard Schema Interop
131
+
132
+ Baobox can expose the same validation logic through the Standard Schema V1 contract.
92
133
 
93
134
  ```ts
94
- import { CreateRuntimeContext, LocaleCodes, String, Errors } from 'baobox'
135
+ import { FromJsonSchema, StandardSchemaV1, Type, ToStandardSchema } from 'baobox'
136
+
137
+ const typed = StandardSchemaV1(Type.Object({
138
+ name: Type.String(),
139
+ age: Type.Number(),
140
+ }, { required: ['name', 'age'] }))
95
141
 
96
- const context = CreateRuntimeContext()
97
- context.Locale.Register('en_TEST', {
98
- ...context.Locale.GetCatalog(LocaleCodes.en_US),
99
- INVALID_TYPE: () => 'yarrr-invalid-type',
142
+ const raw = FromJsonSchema({
143
+ type: 'object',
144
+ properties: {
145
+ name: { type: 'string' },
146
+ age: { type: 'number' },
147
+ },
148
+ required: ['name', 'age'],
100
149
  })
101
- context.Locale.Set('en_TEST')
102
150
 
103
- Errors(String(), 42, context)
104
- // [{ path: '/', code: 'INVALID_TYPE', message: 'yarrr-invalid-type' }]
151
+ ToStandardSchema(raw)['~standard'].validate({ name: 'Ada', age: 37 })
105
152
  ```
106
153
 
107
- If you want to seed a scoped runtime with one of the official bundles explicitly, import it from `baobox/locale`:
154
+ Use:
155
+
156
+ - `StandardSchemaV1()` when you want the canonical baobox adapter
157
+ - `ToStandardSchema()` when the input may already be typed or raw
158
+ - `FromJsonSchema()` when the source is explicitly a raw JSON-schema-style object
159
+
160
+ For schema-agnostic integrations, you can also import from `baobox/standard`.
161
+
162
+ ## Locales And Runtime Contexts
163
+
164
+ The default runtime context is preloaded with an official bundle for every declared locale code. Native translated catalogs currently ship for `de_DE`, `en_US`, the Spanish family, the French family, `ja_JP`, `ko_KR`, the Portuguese family, and both Chinese packs. Remaining official bundles currently alias the English catalog until native translations are added.
108
165
 
109
166
  ```ts
110
167
  import LocalePacks from 'baobox/locale'
111
168
  import { CreateRuntimeContext, Errors, LocaleCodes, String } from 'baobox'
169
+ import { System } from 'baobox/system'
170
+
171
+ System.Locale.Set(System.Locale.ko_KR)
172
+ Errors(String(), 42)
173
+ // [{ path: '/', code: 'INVALID_TYPE', message: 'string이어야 합니다. 현재 값 유형: number' }]
112
174
 
113
175
  const context = CreateRuntimeContext({ localeCatalogs: [] })
114
176
  context.Locale.Register(LocaleCodes.it_IT, LocalePacks.it_IT)
@@ -118,25 +180,42 @@ Errors(String(), 42, context)
118
180
  // [{ path: '/', code: 'INVALID_TYPE', message: 'Expected string, got number' }]
119
181
  ```
120
182
 
121
- ## Package Contract
122
-
123
- - Bun resolves public package entrypoints through the `bun` export condition to raw `src/*.ts` files.
124
- - Standard ESM consumers resolve to built `dist/*.js` files plus generated declarations.
125
- - The published JS layout is `dist/index.js`, `dist/value/index.js`, and matching subpath directories, which now aligns with the export map exactly.
126
- - Supported public entrypoints are:
127
- - `baobox`
128
- - `baobox/type`
129
- - `baobox/value`
130
- - `baobox/schema`
131
- - `baobox/error`
132
- - `baobox/compile`
133
- - `baobox/format`
134
- - `baobox/guard`
135
- - `baobox/system`
136
- - `baobox/script`
137
- - `baobox/locale`
138
- - `baobox/standard`
139
- - Direct `src/*` imports are used by this repository's tests and local development. They are not part of the published package contract.
183
+ Use runtime contexts when you need:
184
+
185
+ - per-test or per-worker isolation
186
+ - tenant-specific registries or locale catalogs
187
+ - explicit compile-cache boundaries
188
+ - non-global settings and type-policy changes
189
+
190
+ ## Built-In Codecs
191
+
192
+ Baobox ships codec helpers for common wire-format boundaries:
193
+
194
+ - `Uint8ArrayCodec()` for base64 JSON payloads and runtime byte arrays
195
+ - `DateCodec()` for ISO datetime strings to `Date`
196
+ - `URLCodec()` for string to `URL`
197
+ - `BigIntCodec()` for integer-string to `bigint`
198
+
199
+ These work with the same value and compile APIs as ordinary schemas.
200
+
201
+ ## Public Entrypoints
202
+
203
+ | Entrypoint | Purpose |
204
+ | --- | --- |
205
+ | `baobox` | Root builders, value helpers, compile helpers, and baobox additions |
206
+ | `baobox/type` | Type builders and static type exports |
207
+ | `baobox/value` | Runtime value operations such as `Check`, `Parse`, `Errors`, `Repair`, `Diff`, and `Patch` |
208
+ | `baobox/schema` | Raw schema runtime plus baobox schema-emitter helpers |
209
+ | `baobox/error` | Structured validation error surface |
210
+ | `baobox/compile` | `Compile`, `Code`, and `Validator` |
211
+ | `baobox/format` | Format registry and format helpers |
212
+ | `baobox/guard` | Guard namespaces aligned with the TypeBox-style guard surface |
213
+ | `baobox/system` | Runtime settings, locale, hashing, memory, and environment helpers |
214
+ | `baobox/script` | Script DSL helpers |
215
+ | `baobox/locale` | Official locale bundles for the declared locale registry |
216
+ | `baobox/standard` | Standard Schema V1 adapter helpers |
217
+
218
+ Published consumers should only rely on package entrypoints. Direct `src/*` imports are internal to this repository and its tests.
140
219
 
141
220
  ## Guides
142
221
 
@@ -146,21 +225,6 @@ Errors(String(), 42, context)
146
225
  - [Package contract and supported imports](docs/package-contract.md)
147
226
  - [Parity policy and baobox-only additions](docs/parity-and-extensions.md)
148
227
 
149
- ## Parity Policy
150
-
151
- - Root exports are maintained as an upstream-complete superset.
152
- - The `compile`, `error`, `format`, `guard`, `system`, and `value` subpaths are parity-tested against the installed `typebox` package.
153
- - `baobox/schema` intentionally combines a `typebox/schema`-style raw schema runtime with baobox's schema emitter helpers.
154
-
155
- ## Bun-Native Fast Paths
156
-
157
- - `Compile()` can specialize hot validation paths for Bun when the schema shape makes that safe.
158
- - `CompileCached()` is the root convenience wrapper for cached validators, and `CompileFromArtifact()` reloads portable artifacts without re-emitting code.
159
- - `Uint8ArrayCodec()` adds a Bun-first base64 codec surface for binary payloads and supports constant-payload specialization in compiled validators.
160
- - `DateCodec()`, `URLCodec()`, and `BigIntCodec()` provide built-in codec surfaces for common interop-heavy values.
161
- - Raw `Uint8Array` constant-byte comparisons can use a Bun `bun:ffi` memcmp fast path when the platform supports it.
162
- - Bun documents `bun:ffi` as experimental, so baobox keeps the fast path narrow and falls back to non-FFI compiled validation whenever the schema does not require native byte comparison.
163
-
164
228
  ## Repository Scripts
165
229
 
166
230
  ```bash
@@ -168,25 +232,9 @@ bun run build
168
232
  bun run typecheck
169
233
  bun test
170
234
  bun run bench
171
- bun run publish:dry-run
172
- ```
173
-
174
- `bun run bench` prints comparative validation and codec throughput against the installed `typebox` package so benchmark output stays tied to the current upstream implementation.
175
-
176
- ## Publishing
177
-
178
- Baobox is configured to publish to npm with `bun`.
179
-
180
- ```bash
181
- bun run publish:dry-run
182
- bun publish --access public
183
235
  ```
184
236
 
185
- - `prepublishOnly` runs `bun run verify`, so a live publish always rebuilds and reruns the test suite first.
186
- - GitHub Actions will attempt a publish on pushes to `main`, on published GitHub releases, and through manual workflow dispatch when `package.json` contains a version that is not already on npm.
187
- - The workflow configures the npm registry on the runner and then requires the repository secret `NPM_TOKEN` before attempting a live publish.
188
- - For a local first publish, authenticate once with `bunx npm login` before running `bun publish --access public`.
189
- - Local `.npmrc` files are gitignored so auth tokens do not end up in the repository.
237
+ `bun run bench` compares validation and codec throughput against the installed `typebox` package so performance numbers stay tied to the current upstream implementation.
190
238
 
191
239
  ## License
192
240
 
@@ -1,7 +1,7 @@
1
1
  import type { TSchema } from '../type/schema.js';
2
2
  import type { RuntimeContext } from '../shared/runtime-context.js';
3
3
  type FastCheck = (value: unknown) => boolean;
4
- type FastStrategy = 'bun-native' | 'bun-native-const' | 'bun-ffi';
4
+ type FastStrategy = 'bun-native' | 'bun-native-const';
5
5
  export interface BunFastPathResult {
6
6
  fn: FastCheck;
7
7
  code: string;
@@ -1 +1 @@
1
- {"version":3,"file":"bun-fast-path.d.ts","sourceRoot":"","sources":["../../src/compile/bun-fast-path.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAwBnE,KAAK,SAAS,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC;AAC7C,KAAK,YAAY,GAAG,YAAY,GAAG,kBAAkB,GAAG,SAAS,CAAC;AAElE,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,SAAS,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,YAAY,CAAC;CACxB;AAuPD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,OAAO,EACf,OAAO,EAAE,cAAc,GACtB,iBAAiB,GAAG,IAAI,CAc1B;AAED,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,OAAO,EACd,aAAa,CAAC,EAAE,MAAM,EACtB,aAAa,CAAC,EAAE,MAAM,EACtB,UAAU,CAAC,EAAE,UAAU,EACvB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAET"}
1
+ {"version":3,"file":"bun-fast-path.d.ts","sourceRoot":"","sources":["../../src/compile/bun-fast-path.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAGjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAyBnE,KAAK,SAAS,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC;AAC7C,KAAK,YAAY,GAAG,YAAY,GAAG,kBAAkB,CAAC;AAEtD,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,SAAS,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,YAAY,CAAC;CACxB;AAwPD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,OAAO,EACf,OAAO,EAAE,cAAc,GACtB,iBAAiB,GAAG,IAAI,CAc1B;AAED,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,OAAO,EACd,aAAa,CAAC,EAAE,MAAM,EACtB,aAAa,CAAC,EAAE,MAAM,EACtB,UAAU,CAAC,EAAE,UAAU,EACvB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAET"}