typesea 0.1.0 → 0.2.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 (285) hide show
  1. package/CHANGELOG.md +67 -6
  2. package/README.md +98 -17
  3. package/dist/adapters/index.d.ts +50 -8
  4. package/dist/adapters/index.d.ts.map +1 -1
  5. package/dist/adapters/index.js +169 -48
  6. package/dist/aot/index.d.ts +18 -2
  7. package/dist/aot/index.d.ts.map +1 -1
  8. package/dist/aot/index.js +93 -14
  9. package/dist/async/index.d.ts +28 -56
  10. package/dist/async/index.d.ts.map +1 -1
  11. package/dist/async/index.js +94 -37
  12. package/dist/builders/composite.d.ts +37 -6
  13. package/dist/builders/composite.d.ts.map +1 -1
  14. package/dist/builders/composite.js +84 -10
  15. package/dist/builders/index.d.ts +2 -0
  16. package/dist/builders/index.d.ts.map +1 -1
  17. package/dist/builders/index.js +2 -0
  18. package/dist/builders/modifier.d.ts +30 -5
  19. package/dist/builders/modifier.d.ts.map +1 -1
  20. package/dist/builders/modifier.js +38 -5
  21. package/dist/builders/object/guard.d.ts +18 -22
  22. package/dist/builders/object/guard.d.ts.map +1 -1
  23. package/dist/builders/object/guard.js +26 -26
  24. package/dist/builders/object/index.d.ts +2 -0
  25. package/dist/builders/object/index.d.ts.map +1 -1
  26. package/dist/builders/object/index.js +2 -0
  27. package/dist/builders/object/schema.d.ts +55 -9
  28. package/dist/builders/object/schema.d.ts.map +1 -1
  29. package/dist/builders/object/schema.js +92 -15
  30. package/dist/builders/object/types.d.ts +5 -31
  31. package/dist/builders/object/types.d.ts.map +1 -1
  32. package/dist/builders/object/types.js +2 -0
  33. package/dist/builders/scalar.d.ts +29 -8
  34. package/dist/builders/scalar.d.ts.map +1 -1
  35. package/dist/builders/scalar.js +33 -8
  36. package/dist/builders/table.d.ts +4 -0
  37. package/dist/builders/table.d.ts.map +1 -1
  38. package/dist/builders/table.js +4 -0
  39. package/dist/builders/types.d.ts +14 -4
  40. package/dist/builders/types.d.ts.map +1 -1
  41. package/dist/builders/types.js +2 -0
  42. package/dist/compile/check-composite.d.ts +22 -1
  43. package/dist/compile/check-composite.d.ts.map +1 -1
  44. package/dist/compile/check-composite.js +564 -24
  45. package/dist/compile/check-scalar.d.ts +78 -0
  46. package/dist/compile/check-scalar.d.ts.map +1 -1
  47. package/dist/compile/check-scalar.js +432 -1
  48. package/dist/compile/check.d.ts +12 -0
  49. package/dist/compile/check.d.ts.map +1 -1
  50. package/dist/compile/check.js +37 -0
  51. package/dist/compile/context.d.ts +47 -9
  52. package/dist/compile/context.d.ts.map +1 -1
  53. package/dist/compile/context.js +51 -8
  54. package/dist/compile/graph-predicate.d.ts +4 -2
  55. package/dist/compile/graph-predicate.d.ts.map +1 -1
  56. package/dist/compile/graph-predicate.js +1907 -171
  57. package/dist/compile/guard.d.ts +15 -24
  58. package/dist/compile/guard.d.ts.map +1 -1
  59. package/dist/compile/guard.js +158 -74
  60. package/dist/compile/index.d.ts +3 -1
  61. package/dist/compile/index.d.ts.map +1 -1
  62. package/dist/compile/index.js +2 -0
  63. package/dist/compile/issue.d.ts +110 -0
  64. package/dist/compile/issue.d.ts.map +1 -1
  65. package/dist/compile/issue.js +184 -1
  66. package/dist/compile/names.d.ts +12 -2
  67. package/dist/compile/names.d.ts.map +1 -1
  68. package/dist/compile/names.js +19 -3
  69. package/dist/compile/predicate.d.ts +24 -0
  70. package/dist/compile/predicate.d.ts.map +1 -1
  71. package/dist/compile/predicate.js +131 -5
  72. package/dist/compile/runtime.d.ts +80 -12
  73. package/dist/compile/runtime.d.ts.map +1 -1
  74. package/dist/compile/runtime.js +25 -6
  75. package/dist/compile/source.d.ts +10 -2
  76. package/dist/compile/source.d.ts.map +1 -1
  77. package/dist/compile/source.js +361 -26
  78. package/dist/compile/types.d.ts +20 -0
  79. package/dist/compile/types.d.ts.map +1 -1
  80. package/dist/compile/types.js +2 -0
  81. package/dist/decoder/index.d.ts +32 -46
  82. package/dist/decoder/index.d.ts.map +1 -1
  83. package/dist/decoder/index.js +102 -38
  84. package/dist/evaluate/check-composite.d.ts +59 -0
  85. package/dist/evaluate/check-composite.d.ts.map +1 -1
  86. package/dist/evaluate/check-composite.js +151 -3
  87. package/dist/evaluate/check-scalar.d.ts +16 -0
  88. package/dist/evaluate/check-scalar.d.ts.map +1 -1
  89. package/dist/evaluate/check-scalar.js +32 -0
  90. package/dist/evaluate/check.d.ts +7 -0
  91. package/dist/evaluate/check.d.ts.map +1 -1
  92. package/dist/evaluate/check.js +43 -0
  93. package/dist/evaluate/index.d.ts +2 -0
  94. package/dist/evaluate/index.d.ts.map +1 -1
  95. package/dist/evaluate/index.js +2 -0
  96. package/dist/evaluate/issue.d.ts +11 -1
  97. package/dist/evaluate/issue.d.ts.map +1 -1
  98. package/dist/evaluate/issue.js +15 -1
  99. package/dist/evaluate/predicate.d.ts +16 -5
  100. package/dist/evaluate/predicate.d.ts.map +1 -1
  101. package/dist/evaluate/predicate.js +20 -5
  102. package/dist/evaluate/shared.d.ts +59 -13
  103. package/dist/evaluate/shared.d.ts.map +1 -1
  104. package/dist/evaluate/shared.js +66 -8
  105. package/dist/evaluate/state.d.ts +35 -13
  106. package/dist/evaluate/state.d.ts.map +1 -1
  107. package/dist/evaluate/state.js +35 -2
  108. package/dist/guard/base.d.ts +79 -29
  109. package/dist/guard/base.d.ts.map +1 -1
  110. package/dist/guard/base.js +91 -29
  111. package/dist/guard/error.d.ts +10 -5
  112. package/dist/guard/error.d.ts.map +1 -1
  113. package/dist/guard/error.js +10 -5
  114. package/dist/guard/index.d.ts +2 -0
  115. package/dist/guard/index.d.ts.map +1 -1
  116. package/dist/guard/index.js +2 -0
  117. package/dist/guard/number.d.ts +26 -11
  118. package/dist/guard/number.d.ts.map +1 -1
  119. package/dist/guard/number.js +30 -11
  120. package/dist/guard/props.d.ts +27 -3
  121. package/dist/guard/props.d.ts.map +1 -1
  122. package/dist/guard/props.js +27 -3
  123. package/dist/guard/read.d.ts +62 -9
  124. package/dist/guard/read.d.ts.map +1 -1
  125. package/dist/guard/read.js +83 -10
  126. package/dist/guard/registry.d.ts +12 -2
  127. package/dist/guard/registry.d.ts.map +1 -1
  128. package/dist/guard/registry.js +15 -3
  129. package/dist/guard/string.d.ts +33 -13
  130. package/dist/guard/string.d.ts.map +1 -1
  131. package/dist/guard/string.js +37 -13
  132. package/dist/guard/types.d.ts +92 -40
  133. package/dist/guard/types.d.ts.map +1 -1
  134. package/dist/guard/types.js +2 -0
  135. package/dist/index.d.ts +1 -1
  136. package/dist/index.d.ts.map +1 -1
  137. package/dist/internal/index.d.ts +42 -6
  138. package/dist/internal/index.d.ts.map +1 -1
  139. package/dist/internal/index.js +51 -8
  140. package/dist/ir/builder.d.ts +16 -126
  141. package/dist/ir/builder.d.ts.map +1 -1
  142. package/dist/ir/builder.js +77 -137
  143. package/dist/ir/freeze.d.ts +4 -0
  144. package/dist/ir/freeze.d.ts.map +1 -1
  145. package/dist/ir/freeze.js +59 -0
  146. package/dist/ir/index.d.ts +3 -1
  147. package/dist/ir/index.d.ts.map +1 -1
  148. package/dist/ir/index.js +2 -0
  149. package/dist/ir/regexp.d.ts +2 -0
  150. package/dist/ir/regexp.d.ts.map +1 -1
  151. package/dist/ir/regexp.js +2 -0
  152. package/dist/ir/types.d.ts +90 -55
  153. package/dist/ir/types.d.ts.map +1 -1
  154. package/dist/ir/types.js +2 -0
  155. package/dist/ir/validate.d.ts +8 -1
  156. package/dist/ir/validate.d.ts.map +1 -1
  157. package/dist/ir/validate.js +477 -61
  158. package/dist/issue/index.d.ts +41 -9
  159. package/dist/issue/index.d.ts.map +1 -1
  160. package/dist/issue/index.js +61 -11
  161. package/dist/json-schema/emit-combinator.d.ts +44 -4
  162. package/dist/json-schema/emit-combinator.d.ts.map +1 -1
  163. package/dist/json-schema/emit-combinator.js +44 -4
  164. package/dist/json-schema/emit-composite.d.ts +10 -0
  165. package/dist/json-schema/emit-composite.d.ts.map +1 -1
  166. package/dist/json-schema/emit-composite.js +15 -1
  167. package/dist/json-schema/emit-scalar.d.ts +26 -3
  168. package/dist/json-schema/emit-scalar.d.ts.map +1 -1
  169. package/dist/json-schema/emit-scalar.js +70 -9
  170. package/dist/json-schema/emit-types.d.ts +11 -1
  171. package/dist/json-schema/emit-types.d.ts.map +1 -1
  172. package/dist/json-schema/emit-types.js +2 -0
  173. package/dist/json-schema/emit.d.ts +12 -1
  174. package/dist/json-schema/emit.d.ts.map +1 -1
  175. package/dist/json-schema/emit.js +12 -1
  176. package/dist/json-schema/freeze.d.ts +13 -2
  177. package/dist/json-schema/freeze.d.ts.map +1 -1
  178. package/dist/json-schema/freeze.js +41 -8
  179. package/dist/json-schema/index.d.ts +16 -2
  180. package/dist/json-schema/index.d.ts.map +1 -1
  181. package/dist/json-schema/index.js +23 -3
  182. package/dist/json-schema/issue.d.ts +4 -1
  183. package/dist/json-schema/issue.d.ts.map +1 -1
  184. package/dist/json-schema/issue.js +4 -1
  185. package/dist/json-schema/read.d.ts +24 -3
  186. package/dist/json-schema/read.d.ts.map +1 -1
  187. package/dist/json-schema/read.js +59 -12
  188. package/dist/json-schema/types.d.ts +38 -15
  189. package/dist/json-schema/types.d.ts.map +1 -1
  190. package/dist/json-schema/types.js +2 -0
  191. package/dist/kind/index.d.ts +15 -28
  192. package/dist/kind/index.d.ts.map +1 -1
  193. package/dist/kind/index.js +15 -10
  194. package/dist/lower/index.d.ts +6 -1
  195. package/dist/lower/index.d.ts.map +1 -1
  196. package/dist/lower/index.js +411 -44
  197. package/dist/message/index.d.ts +46 -10
  198. package/dist/message/index.d.ts.map +1 -1
  199. package/dist/message/index.js +88 -17
  200. package/dist/optimize/algebraic.d.ts +54 -0
  201. package/dist/optimize/algebraic.d.ts.map +1 -0
  202. package/dist/optimize/algebraic.js +314 -0
  203. package/dist/optimize/compact.d.ts +8 -1
  204. package/dist/optimize/compact.d.ts.map +1 -1
  205. package/dist/optimize/compact.js +13 -2
  206. package/dist/optimize/domain.d.ts +16 -0
  207. package/dist/optimize/domain.d.ts.map +1 -0
  208. package/dist/optimize/domain.js +615 -0
  209. package/dist/optimize/fold-boolean.d.ts +17 -2
  210. package/dist/optimize/fold-boolean.d.ts.map +1 -1
  211. package/dist/optimize/fold-boolean.js +59 -14
  212. package/dist/optimize/fold-common.d.ts +43 -8
  213. package/dist/optimize/fold-common.d.ts.map +1 -1
  214. package/dist/optimize/fold-common.js +37 -6
  215. package/dist/optimize/fold-constraints.d.ts +33 -0
  216. package/dist/optimize/fold-constraints.d.ts.map +1 -0
  217. package/dist/optimize/fold-constraints.js +484 -0
  218. package/dist/optimize/fold-scalar.d.ts +98 -13
  219. package/dist/optimize/fold-scalar.d.ts.map +1 -1
  220. package/dist/optimize/fold-scalar.js +98 -13
  221. package/dist/optimize/fold.d.ts +8 -1
  222. package/dist/optimize/fold.d.ts.map +1 -1
  223. package/dist/optimize/fold.js +22 -2
  224. package/dist/optimize/index.d.ts +9 -1
  225. package/dist/optimize/index.d.ts.map +1 -1
  226. package/dist/optimize/index.js +18 -3
  227. package/dist/optimize/map-node.d.ts +3 -1
  228. package/dist/optimize/map-node.d.ts.map +1 -1
  229. package/dist/optimize/map-node.js +45 -3
  230. package/dist/optimize/peephole.d.ts +16 -0
  231. package/dist/optimize/peephole.d.ts.map +1 -0
  232. package/dist/optimize/peephole.js +254 -0
  233. package/dist/optimize/remap.d.ts +2 -0
  234. package/dist/optimize/remap.d.ts.map +1 -1
  235. package/dist/optimize/remap.js +2 -0
  236. package/dist/optimize/rewrite.d.ts +13 -8
  237. package/dist/optimize/rewrite.d.ts.map +1 -1
  238. package/dist/optimize/rewrite.js +13 -8
  239. package/dist/plan/cache.d.ts +9 -3
  240. package/dist/plan/cache.d.ts.map +1 -1
  241. package/dist/plan/cache.js +21 -5
  242. package/dist/plan/index.d.ts +2 -0
  243. package/dist/plan/index.d.ts.map +1 -1
  244. package/dist/plan/index.js +2 -0
  245. package/dist/plan/predicate.d.ts +2 -0
  246. package/dist/plan/predicate.d.ts.map +1 -1
  247. package/dist/plan/predicate.js +268 -29
  248. package/dist/plan/schema-predicate.d.ts +6 -0
  249. package/dist/plan/schema-predicate.d.ts.map +1 -1
  250. package/dist/plan/schema-predicate.js +117 -13
  251. package/dist/plan/types.d.ts +2 -0
  252. package/dist/plan/types.d.ts.map +1 -1
  253. package/dist/plan/types.js +2 -0
  254. package/dist/result/index.d.ts +19 -5
  255. package/dist/result/index.d.ts.map +1 -1
  256. package/dist/result/index.js +10 -2
  257. package/dist/schema/common.d.ts +69 -6
  258. package/dist/schema/common.d.ts.map +1 -1
  259. package/dist/schema/common.js +104 -10
  260. package/dist/schema/freeze.d.ts +4 -0
  261. package/dist/schema/freeze.d.ts.map +1 -1
  262. package/dist/schema/freeze.js +18 -0
  263. package/dist/schema/index.d.ts +3 -0
  264. package/dist/schema/index.d.ts.map +1 -1
  265. package/dist/schema/index.js +3 -0
  266. package/dist/schema/lazy.d.ts +4 -0
  267. package/dist/schema/lazy.d.ts.map +1 -1
  268. package/dist/schema/lazy.js +4 -0
  269. package/dist/schema/literal.d.ts +7 -1
  270. package/dist/schema/literal.d.ts.map +1 -1
  271. package/dist/schema/literal.js +7 -1
  272. package/dist/schema/types.d.ts +20 -96
  273. package/dist/schema/types.d.ts.map +1 -1
  274. package/dist/schema/types.js +5 -1
  275. package/dist/schema/undefined.d.ts +17 -0
  276. package/dist/schema/undefined.d.ts.map +1 -0
  277. package/dist/schema/undefined.js +72 -0
  278. package/dist/schema/validate.d.ts +8 -1
  279. package/dist/schema/validate.d.ts.map +1 -1
  280. package/dist/schema/validate.js +146 -55
  281. package/docs/api.md +57 -0
  282. package/docs/assets/benchmark-headline.svg +163 -0
  283. package/docs/engine-notes.md +58 -15
  284. package/docs/index.html +130 -110
  285. package/package.json +65 -65
@@ -1,12 +1,16 @@
1
1
  /**
2
2
  * @file schema-predicate.ts
3
3
  * @brief Schema-specialized predicate kernels for validation plans.
4
+ * @details Plan helpers keep schema-specialized execution aligned with optimized IR while
5
+ * preserving interpreter parity.
4
6
  */
5
7
  import { NumberCheckTag, ObjectModeTag, PresenceTag, SchemaTag, StringCheckTag } from "../kind/index.js";
6
- import { UUID_PATTERN, resolveLazySchema } from "../schema/index.js";
7
- import { findDiscriminatedUnionCase, hasObjectKey, isDataPropertyDescriptor, isPlainRecord, readOwnDataProperty } from "../evaluate/shared.js";
8
+ import { UUID_PATTERN, resolveLazySchema, schemaCanAcceptUndefined } from "../schema/index.js";
9
+ import { findDiscriminatedUnionCase, hasObjectKey, isArrayIndexKey, isDataPropertyDescriptor, isPlainRecord, readOwnDataProperty } from "../evaluate/shared.js";
8
10
  /**
9
11
  * @brief execute schema kernel.
12
+ * @details Plan helpers keep schema-specialized execution aligned with optimized IR while
13
+ * preserving interpreter parity.
10
14
  */
11
15
  export function executeSchemaKernel(schema, value, state, runChild) {
12
16
  switch (schema.tag) {
@@ -56,7 +60,12 @@ export function executeSchemaKernel(schema, value, state, runChild) {
56
60
  }
57
61
  }
58
62
  /**
59
- * @brief is string schema.
63
+ * @brief Execute a string schema against one runtime value.
64
+ * @param schema String schema with normalized checks.
65
+ * @param value Candidate runtime value.
66
+ * @returns True when the value is a string and every string check passes.
67
+ * @details Regex state is reset around each test so global or sticky patterns do
68
+ * not leak `lastIndex` across validation calls.
60
69
  */
61
70
  function isStringSchema(schema, value) {
62
71
  if (typeof value !== "string") {
@@ -98,7 +107,12 @@ function isStringSchema(schema, value) {
98
107
  return true;
99
108
  }
100
109
  /**
101
- * @brief is number schema.
110
+ * @brief Execute a number schema against one runtime value.
111
+ * @details Plan helpers keep schema-specialized execution aligned with optimized IR while
112
+ * preserving interpreter parity.
113
+ * @param schema Number schema with normalized checks.
114
+ * @param value Candidate runtime value.
115
+ * @returns True when the value is finite and satisfies every numeric check.
102
116
  */
103
117
  function isNumberSchema(schema, value) {
104
118
  if (typeof value !== "number" || !Number.isFinite(value)) {
@@ -131,12 +145,26 @@ function isNumberSchema(schema, value) {
131
145
  return true;
132
146
  }
133
147
  /**
134
- * @brief is array schema.
148
+ * @brief Execute array validation with sparse-slot semantics.
149
+ * @details Plan helpers keep schema-specialized execution aligned with optimized IR while
150
+ * preserving interpreter parity.
151
+ * @param item Schema applied to each logical array slot.
152
+ * @param value Candidate value supplied by the caller.
153
+ * @param state Shared recursion and cycle state.
154
+ * @param runChild Dispatcher for nested schema predicates.
155
+ * @returns True when the value satisfies the array schema.
135
156
  */
136
157
  function isArraySchema(item, value, state, runChild) {
137
158
  if (!Array.isArray(value)) {
138
159
  return false;
139
160
  }
161
+ if (schemaCanAcceptUndefined(item)) {
162
+ /*
163
+ * Undefined-valid item schemas make holes valid. Use the present-index
164
+ * walker so sparse arrays do not pay for absent slots.
165
+ */
166
+ return isPresentArraySchema(item, value, state, runChild);
167
+ }
140
168
  for (let index = 0; index < value.length; index += 1) {
141
169
  const property = readArrayIndexDataProperty(value, index);
142
170
  if (property === null ||
@@ -147,7 +175,42 @@ function isArraySchema(item, value, state, runChild) {
147
175
  return true;
148
176
  }
149
177
  /**
150
- * @brief is tuple schema.
178
+ * @brief Validate only present indexes for undefined-accepting item schemas.
179
+ * @details Skips holes only when `undefined` is already accepted by the item schema.
180
+ * @param item Schema applied to each present own index.
181
+ * @param value Array already proven by the caller.
182
+ * @param state Shared recursion and cycle state.
183
+ * @param runChild Dispatcher for nested schema predicates.
184
+ * @returns True when every present own index satisfies the item schema.
185
+ */
186
+ function isPresentArraySchema(item, value, state, runChild) {
187
+ const keys = Object.getOwnPropertyNames(value);
188
+ for (let keyIndex = 0; keyIndex < keys.length; keyIndex += 1) {
189
+ const key = keys[keyIndex];
190
+ if (key === undefined || !isArrayIndexKey(key, value.length)) {
191
+ continue;
192
+ }
193
+ /*
194
+ * Accessor-backed present indexes are rejected here because reading them
195
+ * would run user code and break the safe validation boundary.
196
+ */
197
+ const property = readArrayKeyDataProperty(value, key);
198
+ if (property === null ||
199
+ (property !== undefined && !runChild(item, property.value, state))) {
200
+ return false;
201
+ }
202
+ }
203
+ return true;
204
+ }
205
+ /**
206
+ * @brief Execute fixed-arity tuple validation.
207
+ * @details Plan helpers keep schema-specialized execution aligned with optimized IR while
208
+ * preserving interpreter parity.
209
+ * @param items Schema for each tuple index.
210
+ * @param value Candidate runtime value.
211
+ * @param state Shared recursion and cycle state.
212
+ * @param runChild Dispatcher for nested schema predicates.
213
+ * @returns True when length and every indexed item match exactly.
151
214
  */
152
215
  function isTupleSchema(items, value, state, runChild) {
153
216
  if (!Array.isArray(value) || value.length !== items.length) {
@@ -165,10 +228,26 @@ function isTupleSchema(items, value, state, runChild) {
165
228
  return true;
166
229
  }
167
230
  /**
168
- * @brief read array index data property.
231
+ * @brief Read one tuple or dense-array index through a descriptor.
232
+ * @details Plan helpers keep schema-specialized execution aligned with optimized IR while
233
+ * preserving interpreter parity.
234
+ * @param value Array being inspected.
235
+ * @param index Numeric index.
236
+ * @returns Data descriptor, undefined for a hole, or null for an accessor slot.
169
237
  */
170
238
  function readArrayIndexDataProperty(value, index) {
171
- const descriptor = Object.getOwnPropertyDescriptor(value, String(index));
239
+ return readArrayKeyDataProperty(value, String(index));
240
+ }
241
+ /**
242
+ * @brief Read one canonical array index key without executing accessors.
243
+ * @details Plan helpers keep schema-specialized execution aligned with optimized IR while
244
+ * preserving interpreter parity.
245
+ * @param value Array being inspected.
246
+ * @param key Canonical array index key.
247
+ * @returns Data descriptor, undefined for a hole, or null for an accessor slot.
248
+ */
249
+ function readArrayKeyDataProperty(value, key) {
250
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
172
251
  if (descriptor === undefined) {
173
252
  return undefined;
174
253
  }
@@ -178,7 +257,8 @@ function readArrayIndexDataProperty(value, index) {
178
257
  return descriptor;
179
258
  }
180
259
  /**
181
- * @brief is record schema.
260
+ * @brief Check record schema.
261
+ * @details This helper keeps a local invariant explicit at the module boundary.
182
262
  */
183
263
  function isRecordSchema(item, value, state, runChild) {
184
264
  if (!isPlainRecord(value)) {
@@ -198,7 +278,15 @@ function isRecordSchema(item, value, state, runChild) {
198
278
  return true;
199
279
  }
200
280
  /**
201
- * @brief is object schema.
281
+ * @brief Execute object schema validation.
282
+ * @param schema Object schema with ordered entries and strict-mode lookup.
283
+ * @param value Candidate runtime value.
284
+ * @param state Shared recursion and cycle state.
285
+ * @param runChild Dispatcher for nested property schemas.
286
+ * @returns True when required/optional fields and strict-key rules pass.
287
+ * @details Required properties are read through descriptors. In strict mode, the
288
+ * all-required path can compare own key counts; optional shapes must inspect
289
+ * each key so extra symbol or undeclared string keys fail closed.
202
290
  */
203
291
  function isObjectSchema(schema, value, state, runChild) {
204
292
  if (!isPlainRecord(value)) {
@@ -243,7 +331,14 @@ function isObjectSchema(schema, value, state, runChild) {
243
331
  return true;
244
332
  }
245
333
  /**
246
- * @brief is union schema.
334
+ * @brief Execute a general union by probing options in order.
335
+ * @details Plan helpers keep schema-specialized execution aligned with optimized IR while
336
+ * preserving interpreter parity.
337
+ * @param options Union option schemas.
338
+ * @param value Candidate runtime value.
339
+ * @param state Shared recursion and cycle state.
340
+ * @param runChild Dispatcher for nested option schemas.
341
+ * @returns True when at least one option accepts the value.
247
342
  */
248
343
  function isUnionSchema(options, value, state, runChild) {
249
344
  for (let index = 0; index < options.length; index += 1) {
@@ -255,7 +350,15 @@ function isUnionSchema(options, value, state, runChild) {
255
350
  return false;
256
351
  }
257
352
  /**
258
- * @brief is discriminated union schema.
353
+ * @brief Execute a discriminated union through its tag field.
354
+ * @details Plan helpers keep schema-specialized execution aligned with optimized IR while
355
+ * preserving interpreter parity.
356
+ * @param key Discriminant property name.
357
+ * @param cases Closed case table.
358
+ * @param value Candidate runtime value.
359
+ * @param state Shared recursion and cycle state.
360
+ * @param runChild Dispatcher for selected case schema.
361
+ * @returns True when the discriminant is a string and the selected case passes.
259
362
  */
260
363
  function isDiscriminatedUnionSchema(key, cases, value, state, runChild) {
261
364
  if (!isPlainRecord(value)) {
@@ -270,7 +373,8 @@ function isDiscriminatedUnionSchema(key, cases, value, state, runChild) {
270
373
  return selected !== undefined && runChild(selected, value, state);
271
374
  }
272
375
  /**
273
- * @brief is strict true.
376
+ * @brief Check strict true.
377
+ * @details This helper keeps a local invariant explicit at the module boundary.
274
378
  */
275
379
  function isStrictTrue(value) {
276
380
  return value === true;
@@ -1,6 +1,8 @@
1
1
  /**
2
2
  * @file types.ts
3
3
  * @brief Optimized validation plan contracts.
4
+ * @details Plan helpers keep schema-specialized execution aligned with optimized IR while
5
+ * preserving interpreter parity.
4
6
  */
5
7
  import type { Graph } from "../ir/index.js";
6
8
  import type { Schema } from "../schema/index.js";
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/plan/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;CACnC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/plan/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;CACrC"}
@@ -1,5 +1,7 @@
1
1
  /**
2
2
  * @file types.ts
3
3
  * @brief Optimized validation plan contracts.
4
+ * @details Plan helpers keep schema-specialized execution aligned with optimized IR while
5
+ * preserving interpreter parity.
4
6
  */
5
7
  export {};
@@ -1,27 +1,41 @@
1
1
  /**
2
- * @brief result.
2
+ * @brief Explicit success-or-failure value used instead of implicit exceptions.
3
+ * @details Public validators return Result so failure is visible in the type
4
+ * system and callers must handle diagnostics deliberately.
3
5
  */
4
6
  export type Result<TValue, TError> = Ok<TValue> | Err<TError>;
5
7
  /**
6
- * @brief ok.
8
+ * @brief Successful Result variant.
9
+ * @details The payload is named `value` so consumers can destructure success
10
+ * without colliding with the failure-side `error` field.
7
11
  */
8
12
  export interface Ok<TValue> {
9
13
  readonly ok: true;
10
14
  readonly value: TValue;
11
15
  }
12
16
  /**
13
- * @brief err.
17
+ * @brief Failed Result variant.
18
+ * @details Errors remain typed payloads rather than thrown control flow, which
19
+ * keeps validation and decoding APIs predictable under composition.
14
20
  */
15
21
  export interface Err<TError> {
16
22
  readonly ok: false;
17
23
  readonly error: TError;
18
24
  }
19
25
  /**
20
- * @brief ok.
26
+ * @brief Construct a frozen successful Result.
27
+ * @details Result helpers keep success and failure explicit in value space instead of
28
+ * relying on implicit control flow.
29
+ * @param value Value produced by a successful operation.
30
+ * @returns Immutable success variant.
21
31
  */
22
32
  export declare function ok<TValue>(value: TValue): Result<TValue, never>;
23
33
  /**
24
- * @brief err.
34
+ * @brief Construct a frozen failed Result.
35
+ * @details Result helpers keep success and failure explicit in value space instead of
36
+ * relying on implicit control flow.
37
+ * @param error Typed failure payload.
38
+ * @returns Immutable failure variant.
25
39
  */
26
40
  export declare function err<TError>(error: TError): Result<never, TError>;
27
41
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/result/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,IAC7B,EAAE,CAAC,MAAM,CAAC,GACV,GAAG,CAAC,MAAM,CAAC,CAAC;AAEhB;;GAEG;AACH,MAAM,WAAW,EAAE,CAAC,MAAM;IACxB,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAClB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,GAAG,CAAC,MAAM;IACzB,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,wBAAgB,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAM/D;AAED;;GAEG;AACH,wBAAgB,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAMhE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/result/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,IAC3B,EAAE,CAAC,MAAM,CAAC,GACV,GAAG,CAAC,MAAM,CAAC,CAAC;AAElB;;;;GAIG;AACH,MAAM,WAAW,EAAE,CAAC,MAAM;IACtB,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAClB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CAC1B;AAED;;;;GAIG;AACH,MAAM,WAAW,GAAG,CAAC,MAAM;IACvB,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,wBAAgB,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAM/D;AAED;;;;;;GAMG;AACH,wBAAgB,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAMhE"}
@@ -1,5 +1,9 @@
1
1
  /**
2
- * @brief ok.
2
+ * @brief Construct a frozen successful Result.
3
+ * @details Result helpers keep success and failure explicit in value space instead of
4
+ * relying on implicit control flow.
5
+ * @param value Value produced by a successful operation.
6
+ * @returns Immutable success variant.
3
7
  */
4
8
  export function ok(value) {
5
9
  const result = {
@@ -9,7 +13,11 @@ export function ok(value) {
9
13
  return Object.freeze(result);
10
14
  }
11
15
  /**
12
- * @brief err.
16
+ * @brief Construct a frozen failed Result.
17
+ * @details Result helpers keep success and failure explicit in value space instead of
18
+ * relying on implicit control flow.
19
+ * @param error Typed failure payload.
20
+ * @returns Immutable failure variant.
13
21
  */
14
22
  export function err(error) {
15
23
  const result = {
@@ -1,30 +1,93 @@
1
1
  /**
2
2
  * @file schema/common.ts
3
3
  * @brief Private schema shape predicates.
4
+ * @details Schema helpers enforce construction-time invariants before values reach
5
+ * validation, compilation, or export.
4
6
  */
5
7
  import type { ObjectKeyLookup } from "./types.js";
6
8
  /**
7
- * @brief is record.
9
+ * @brief Sentinel for a missing own data slot.
10
+ * @details `undefined` is a valid schema literal, so absence needs a distinct
11
+ * value that cannot collide with user-authored schema data.
12
+ */
13
+ declare const missingDataProperty: unique symbol;
14
+ /**
15
+ * @brief Test whether a schema field read observed the sentinel.
16
+ * @details Schema helpers enforce construction-time invariants before values reach
17
+ * validation, compilation, or export.
18
+ * @param value Candidate field value returned by readOwnDataProperty.
19
+ * @returns True when the caller must treat the schema field as absent.
20
+ */
21
+ export declare function isMissingDataProperty(value: unknown): value is typeof missingDataProperty;
22
+ /**
23
+ * @brief Check that an object owns a concrete data descriptor.
24
+ * @param value Object whose descriptor table is being inspected.
25
+ * @param key Field name or symbol.
26
+ * @returns True only when the field exists directly on the object as data.
27
+ * @details Schema records are consumed across public boundaries. Descriptor
28
+ * reads avoid invoking accessors and avoid accepting prototype-backed fields.
29
+ */
30
+ export declare function hasOwnDataProperty(value: object, key: PropertyKey): boolean;
31
+ /**
32
+ * @brief Read one own schema data slot without consulting the prototype chain.
33
+ * @param value Object carrying a schema record.
34
+ * @param key Field name or symbol to read.
35
+ * @returns The stored value, or the missing-data sentinel.
36
+ * @details Callers must not use bracket reads on untrusted schema-like objects:
37
+ * a forged prototype getter could execute code or change validation meaning.
38
+ */
39
+ export declare function readOwnDataProperty(value: object, key: PropertyKey): unknown;
40
+ /**
41
+ * @brief Accept object records suitable for schema metadata traversal.
42
+ * @details Schema helpers enforce construction-time invariants before values reach
43
+ * validation, compilation, or export.
44
+ * @param value Candidate schema record.
45
+ * @returns True for non-array objects whose own fields are all data slots.
8
46
  */
9
47
  export declare function isRecord(value: unknown): value is Readonly<Record<string, unknown>>;
10
48
  /**
11
- * @brief is unknown array.
49
+ * @brief Accept dense arrays whose slots can be read without side effects.
50
+ * @param value Candidate schema vector.
51
+ * @returns True for arrays with only own data descriptors and no holes.
52
+ * @details Schema vectors such as `checks`, `entries`, and `options` are arena
53
+ * metadata. Holes and inherited slots would make validation depend on array
54
+ * prototype state, so they are rejected at the boundary.
12
55
  */
13
56
  export declare function isUnknownArray(value: unknown): value is readonly unknown[];
14
57
  /**
15
- * @brief is plain reg exp.
58
+ * @brief Accept only unmodified RegExp instances in schema records.
59
+ * @param value Candidate pattern object.
60
+ * @returns True for a plain RegExp with no own behavioral overrides.
61
+ * @details Regex checks are copied into generated and interpreted validators.
62
+ * Rejecting own overrides prevents later mutation of `exec`, `test`, `source`,
63
+ * or `flags` from changing stored schema behavior.
16
64
  */
17
65
  export declare function isPlainRegExp(value: unknown): value is RegExp;
18
66
  /**
19
- * @brief is string array.
67
+ * @brief Validate a dense vector of object shape keys.
68
+ * @details Schema helpers enforce construction-time invariants before values reach
69
+ * validation, compilation, or export.
70
+ * @param value Candidate key vector.
71
+ * @returns True when every slot is a string.
20
72
  */
21
73
  export declare function isStringArray(value: unknown): value is readonly string[];
22
74
  /**
23
- * @brief is object key lookup.
75
+ * @brief Validate the O(1) lookup table paired with object schema keys.
76
+ * @param value Candidate null or plain object lookup.
77
+ * @param keys Ordered key vector from the same object schema.
78
+ * @returns True when the lookup contains exactly the listed keys mapped to true.
79
+ * @details The lookup and key vector must agree so strict-object validation can
80
+ * reject extra keys without rebuilding a membership set at runtime.
24
81
  */
25
82
  export declare function isObjectKeyLookup(value: unknown, keys: readonly string[]): value is ObjectKeyLookup;
26
83
  /**
27
- * @brief includes string.
84
+ * @brief Linear membership check for short schema-owned string vectors.
85
+ * @param values Trusted frozen vector.
86
+ * @param value Candidate string.
87
+ * @returns True when the candidate appears in the vector.
88
+ * @details These vectors are small and validation-time only; a loop avoids
89
+ * allocating transient Set objects while preserving deterministic order.
28
90
  */
29
91
  export declare function includesString(values: readonly string[], value: string): boolean;
92
+ export {};
30
93
  //# sourceMappingURL=common.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/schema/common.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;GAEG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAKnF;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,OAAO,EAAE,CAE1E;AAyBD;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAO7D;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,MAAM,EAAE,CAUxE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,SAAS,MAAM,EAAE,GACtB,KAAK,IAAI,eAAe,CAqB1B;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAOhF"}
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/schema/common.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;;;GAIG;AACH,QAAA,MAAM,mBAAmB,eAAwC,CAAC;AAElE;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACjC,KAAK,EAAE,OAAO,GACf,KAAK,IAAI,OAAO,mBAAmB,CAErC;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAC9B,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,WAAW,GACjB,OAAO,CAIT;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAC/B,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,WAAW,GACjB,OAAO,CAOT;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAKnF;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,OAAO,EAAE,CAI1E;AA2CD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAO7D;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,MAAM,EAAE,CAUxE;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC7B,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,SAAS,MAAM,EAAE,GACxB,KAAK,IAAI,eAAe,CAqB1B;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAOhF"}
@@ -1,9 +1,60 @@
1
1
  /**
2
2
  * @file schema/common.ts
3
3
  * @brief Private schema shape predicates.
4
+ * @details Schema helpers enforce construction-time invariants before values reach
5
+ * validation, compilation, or export.
4
6
  */
5
7
  /**
6
- * @brief is record.
8
+ * @brief Sentinel for a missing own data slot.
9
+ * @details `undefined` is a valid schema literal, so absence needs a distinct
10
+ * value that cannot collide with user-authored schema data.
11
+ */
12
+ const missingDataProperty = Symbol("typesea.missingDataProperty");
13
+ /**
14
+ * @brief Test whether a schema field read observed the sentinel.
15
+ * @details Schema helpers enforce construction-time invariants before values reach
16
+ * validation, compilation, or export.
17
+ * @param value Candidate field value returned by readOwnDataProperty.
18
+ * @returns True when the caller must treat the schema field as absent.
19
+ */
20
+ export function isMissingDataProperty(value) {
21
+ return value === missingDataProperty;
22
+ }
23
+ /**
24
+ * @brief Check that an object owns a concrete data descriptor.
25
+ * @param value Object whose descriptor table is being inspected.
26
+ * @param key Field name or symbol.
27
+ * @returns True only when the field exists directly on the object as data.
28
+ * @details Schema records are consumed across public boundaries. Descriptor
29
+ * reads avoid invoking accessors and avoid accepting prototype-backed fields.
30
+ */
31
+ export function hasOwnDataProperty(value, key) {
32
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
33
+ return descriptor !== undefined &&
34
+ Object.prototype.hasOwnProperty.call(descriptor, "value");
35
+ }
36
+ /**
37
+ * @brief Read one own schema data slot without consulting the prototype chain.
38
+ * @param value Object carrying a schema record.
39
+ * @param key Field name or symbol to read.
40
+ * @returns The stored value, or the missing-data sentinel.
41
+ * @details Callers must not use bracket reads on untrusted schema-like objects:
42
+ * a forged prototype getter could execute code or change validation meaning.
43
+ */
44
+ export function readOwnDataProperty(value, key) {
45
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
46
+ if (descriptor === undefined ||
47
+ !Object.prototype.hasOwnProperty.call(descriptor, "value")) {
48
+ return missingDataProperty;
49
+ }
50
+ return descriptor.value;
51
+ }
52
+ /**
53
+ * @brief Accept object records suitable for schema metadata traversal.
54
+ * @details Schema helpers enforce construction-time invariants before values reach
55
+ * validation, compilation, or export.
56
+ * @param value Candidate schema record.
57
+ * @returns True for non-array objects whose own fields are all data slots.
7
58
  */
8
59
  export function isRecord(value) {
9
60
  return typeof value === "object" &&
@@ -12,14 +63,23 @@ export function isRecord(value) {
12
63
  hasOnlyDataProperties(value);
13
64
  }
14
65
  /**
15
- * @brief is unknown array.
66
+ * @brief Accept dense arrays whose slots can be read without side effects.
67
+ * @param value Candidate schema vector.
68
+ * @returns True for arrays with only own data descriptors and no holes.
69
+ * @details Schema vectors such as `checks`, `entries`, and `options` are arena
70
+ * metadata. Holes and inherited slots would make validation depend on array
71
+ * prototype state, so they are rejected at the boundary.
16
72
  */
17
73
  export function isUnknownArray(value) {
18
- return Array.isArray(value) && hasOnlyDataProperties(value);
74
+ return Array.isArray(value) &&
75
+ hasOnlyDataProperties(value) &&
76
+ hasDenseDataSlots(value);
19
77
  }
20
78
  /**
21
- * @brief has only data properties.
22
- * @details Rejects accessor descriptors before schema internals read fields by key.
79
+ * @brief Reject accessor descriptors before schema internals read fields.
80
+ * @details Schema helpers enforce construction-time invariants before values reach
81
+ * validation, compilation, or export.
82
+ * @param value Object whose own descriptor table is inspected.
23
83
  * @returns True when every own property is backed by a data slot.
24
84
  */
25
85
  function hasOnlyDataProperties(value) {
@@ -40,7 +100,27 @@ function hasOnlyDataProperties(value) {
40
100
  return true;
41
101
  }
42
102
  /**
43
- * @brief is plain reg exp.
103
+ * @brief Require array indexes from 0 to length - 1 to be own data slots.
104
+ * @details Schema helpers enforce construction-time invariants before values reach
105
+ * validation, compilation, or export.
106
+ * @param value Candidate schema vector.
107
+ * @returns True when no sparse or prototype-backed index is present.
108
+ */
109
+ function hasDenseDataSlots(value) {
110
+ for (let index = 0; index < value.length; index += 1) {
111
+ if (!hasOwnDataProperty(value, String(index))) {
112
+ return false;
113
+ }
114
+ }
115
+ return true;
116
+ }
117
+ /**
118
+ * @brief Accept only unmodified RegExp instances in schema records.
119
+ * @param value Candidate pattern object.
120
+ * @returns True for a plain RegExp with no own behavioral overrides.
121
+ * @details Regex checks are copied into generated and interpreted validators.
122
+ * Rejecting own overrides prevents later mutation of `exec`, `test`, `source`,
123
+ * or `flags` from changing stored schema behavior.
44
124
  */
45
125
  export function isPlainRegExp(value) {
46
126
  return value instanceof RegExp &&
@@ -51,7 +131,11 @@ export function isPlainRegExp(value) {
51
131
  !Object.prototype.hasOwnProperty.call(value, "flags");
52
132
  }
53
133
  /**
54
- * @brief is string array.
134
+ * @brief Validate a dense vector of object shape keys.
135
+ * @details Schema helpers enforce construction-time invariants before values reach
136
+ * validation, compilation, or export.
137
+ * @param value Candidate key vector.
138
+ * @returns True when every slot is a string.
55
139
  */
56
140
  export function isStringArray(value) {
57
141
  if (!isUnknownArray(value)) {
@@ -65,7 +149,12 @@ export function isStringArray(value) {
65
149
  return true;
66
150
  }
67
151
  /**
68
- * @brief is object key lookup.
152
+ * @brief Validate the O(1) lookup table paired with object schema keys.
153
+ * @param value Candidate null or plain object lookup.
154
+ * @param keys Ordered key vector from the same object schema.
155
+ * @returns True when the lookup contains exactly the listed keys mapped to true.
156
+ * @details The lookup and key vector must agree so strict-object validation can
157
+ * reject extra keys without rebuilding a membership set at runtime.
69
158
  */
70
159
  export function isObjectKeyLookup(value, keys) {
71
160
  if (!isRecord(value)) {
@@ -77,7 +166,7 @@ export function isObjectKeyLookup(value, keys) {
77
166
  }
78
167
  for (let index = 0; index < keys.length; index += 1) {
79
168
  const key = keys[index];
80
- if (key === undefined || value[key] !== true) {
169
+ if (key === undefined || readOwnDataProperty(value, key) !== true) {
81
170
  return false;
82
171
  }
83
172
  }
@@ -90,7 +179,12 @@ export function isObjectKeyLookup(value, keys) {
90
179
  return true;
91
180
  }
92
181
  /**
93
- * @brief includes string.
182
+ * @brief Linear membership check for short schema-owned string vectors.
183
+ * @param values Trusted frozen vector.
184
+ * @param value Candidate string.
185
+ * @returns True when the candidate appears in the vector.
186
+ * @details These vectors are small and validation-time only; a loop avoids
187
+ * allocating transient Set objects while preserving deterministic order.
94
188
  */
95
189
  export function includesString(values, value) {
96
190
  for (let index = 0; index < values.length; index += 1) {
@@ -1,10 +1,14 @@
1
1
  /**
2
2
  * @file schema/freeze.ts
3
3
  * @brief Schema freezing and collection hardening.
4
+ * @details Freezing hardens builder output before execution engines or exporters rely on
5
+ * schema identity and shape stability.
4
6
  */
5
7
  import type { Schema } from "./types.js";
6
8
  /**
7
9
  * @brief freeze schema.
10
+ * @details Freezing hardens builder output before execution engines or exporters rely on
11
+ * schema identity and shape stability.
8
12
  */
9
13
  export declare function freezeSchema(schema: Schema): Schema;
10
14
  //# sourceMappingURL=freeze.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"freeze.d.ts","sourceRoot":"","sources":["../../src/schema/freeze.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAGV,MAAM,EAGP,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEnD"}
1
+ {"version":3,"file":"freeze.d.ts","sourceRoot":"","sources":["../../src/schema/freeze.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAGR,MAAM,EAGT,MAAM,YAAY,CAAC;AAEpB;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEnD"}