typesea 0.2.0 → 0.3.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 (157) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +45 -11
  3. package/dist/aot/index.d.ts +1 -1
  4. package/dist/aot/index.d.ts.map +1 -1
  5. package/dist/aot/index.js +22 -3
  6. package/dist/builders/composite.d.ts +6 -3
  7. package/dist/builders/composite.d.ts.map +1 -1
  8. package/dist/builders/composite.js +22 -13
  9. package/dist/builders/index.d.ts +6 -5
  10. package/dist/builders/index.d.ts.map +1 -1
  11. package/dist/builders/index.js +5 -4
  12. package/dist/builders/modifier.d.ts +6 -0
  13. package/dist/builders/modifier.d.ts.map +1 -1
  14. package/dist/builders/modifier.js +14 -0
  15. package/dist/builders/object/guard.d.ts +54 -2
  16. package/dist/builders/object/guard.d.ts.map +1 -1
  17. package/dist/builders/object/guard.js +117 -7
  18. package/dist/builders/object/index.d.ts +2 -2
  19. package/dist/builders/object/index.d.ts.map +1 -1
  20. package/dist/builders/object/index.js +1 -1
  21. package/dist/builders/object/schema.d.ts +33 -2
  22. package/dist/builders/object/schema.d.ts.map +1 -1
  23. package/dist/builders/object/schema.js +198 -8
  24. package/dist/builders/object/types.d.ts +15 -0
  25. package/dist/builders/object/types.d.ts.map +1 -1
  26. package/dist/builders/runtime.d.ts +40 -0
  27. package/dist/builders/runtime.d.ts.map +1 -0
  28. package/dist/builders/runtime.js +150 -0
  29. package/dist/builders/scalar.d.ts +20 -1
  30. package/dist/builders/scalar.d.ts.map +1 -1
  31. package/dist/builders/scalar.js +54 -1
  32. package/dist/builders/table.d.ts +31 -5
  33. package/dist/builders/table.d.ts.map +1 -1
  34. package/dist/builders/table.js +31 -5
  35. package/dist/builders/types.d.ts +6 -0
  36. package/dist/builders/types.d.ts.map +1 -1
  37. package/dist/compile/check-composite.d.ts +3 -1
  38. package/dist/compile/check-composite.d.ts.map +1 -1
  39. package/dist/compile/check-composite.js +143 -11
  40. package/dist/compile/check-scalar.d.ts +10 -0
  41. package/dist/compile/check-scalar.d.ts.map +1 -1
  42. package/dist/compile/check-scalar.js +138 -2
  43. package/dist/compile/check.d.ts.map +1 -1
  44. package/dist/compile/check.js +25 -3
  45. package/dist/compile/context.d.ts.map +1 -1
  46. package/dist/compile/context.js +2 -0
  47. package/dist/compile/first.d.ts +26 -0
  48. package/dist/compile/first.d.ts.map +1 -0
  49. package/dist/compile/first.js +850 -0
  50. package/dist/compile/graph-predicate.d.ts.map +1 -1
  51. package/dist/compile/graph-predicate.js +389 -18
  52. package/dist/compile/guard.d.ts +2 -1
  53. package/dist/compile/guard.d.ts.map +1 -1
  54. package/dist/compile/guard.js +54 -8
  55. package/dist/compile/predicate.d.ts.map +1 -1
  56. package/dist/compile/predicate.js +156 -5
  57. package/dist/compile/runtime.d.ts +20 -1
  58. package/dist/compile/runtime.d.ts.map +1 -1
  59. package/dist/compile/runtime.js +31 -0
  60. package/dist/compile/source.d.ts.map +1 -1
  61. package/dist/compile/source.js +27 -3
  62. package/dist/compile/types.d.ts +2 -0
  63. package/dist/compile/types.d.ts.map +1 -1
  64. package/dist/decoder/index.d.ts +60 -0
  65. package/dist/decoder/index.d.ts.map +1 -1
  66. package/dist/decoder/index.js +164 -1
  67. package/dist/evaluate/check-composite.d.ts +52 -2
  68. package/dist/evaluate/check-composite.d.ts.map +1 -1
  69. package/dist/evaluate/check-composite.js +193 -6
  70. package/dist/evaluate/check-scalar.d.ts +9 -0
  71. package/dist/evaluate/check-scalar.d.ts.map +1 -1
  72. package/dist/evaluate/check-scalar.js +92 -3
  73. package/dist/evaluate/check.d.ts.map +1 -1
  74. package/dist/evaluate/check.js +19 -4
  75. package/dist/evaluate/shared.d.ts +19 -0
  76. package/dist/evaluate/shared.d.ts.map +1 -1
  77. package/dist/evaluate/shared.js +35 -0
  78. package/dist/guard/array.d.ts +48 -0
  79. package/dist/guard/array.d.ts.map +1 -0
  80. package/dist/guard/array.js +84 -0
  81. package/dist/guard/base.d.ts +32 -2
  82. package/dist/guard/base.d.ts.map +1 -1
  83. package/dist/guard/base.js +74 -3
  84. package/dist/guard/date.d.ts +34 -0
  85. package/dist/guard/date.d.ts.map +1 -0
  86. package/dist/guard/date.js +60 -0
  87. package/dist/guard/index.d.ts +2 -0
  88. package/dist/guard/index.d.ts.map +1 -1
  89. package/dist/guard/index.js +2 -0
  90. package/dist/guard/number.d.ts +60 -0
  91. package/dist/guard/number.d.ts.map +1 -1
  92. package/dist/guard/number.js +129 -0
  93. package/dist/guard/read.d.ts +53 -1
  94. package/dist/guard/read.d.ts.map +1 -1
  95. package/dist/guard/read.js +102 -0
  96. package/dist/guard/string.d.ts +82 -0
  97. package/dist/guard/string.d.ts.map +1 -1
  98. package/dist/guard/string.js +213 -0
  99. package/dist/guard/types.d.ts +18 -0
  100. package/dist/guard/types.d.ts.map +1 -1
  101. package/dist/index.d.ts +4 -4
  102. package/dist/index.d.ts.map +1 -1
  103. package/dist/index.js +4 -4
  104. package/dist/ir/builder.d.ts +3 -3
  105. package/dist/ir/builder.d.ts.map +1 -1
  106. package/dist/ir/builder.js +5 -2
  107. package/dist/ir/freeze.js +7 -0
  108. package/dist/ir/types.d.ts +4 -1
  109. package/dist/ir/types.d.ts.map +1 -1
  110. package/dist/ir/validate.d.ts.map +1 -1
  111. package/dist/ir/validate.js +35 -1
  112. package/dist/issue/index.d.ts +1 -1
  113. package/dist/issue/index.d.ts.map +1 -1
  114. package/dist/issue/index.js +4 -0
  115. package/dist/json-schema/emit-composite.d.ts +6 -2
  116. package/dist/json-schema/emit-composite.d.ts.map +1 -1
  117. package/dist/json-schema/emit-composite.js +66 -12
  118. package/dist/json-schema/emit-scalar.d.ts.map +1 -1
  119. package/dist/json-schema/emit-scalar.js +54 -1
  120. package/dist/json-schema/emit.d.ts.map +1 -1
  121. package/dist/json-schema/emit.js +11 -2
  122. package/dist/json-schema/types.d.ts +7 -1
  123. package/dist/json-schema/types.d.ts.map +1 -1
  124. package/dist/kind/index.d.ts +25 -0
  125. package/dist/kind/index.d.ts.map +1 -1
  126. package/dist/kind/index.js +26 -3
  127. package/dist/lower/index.d.ts.map +1 -1
  128. package/dist/lower/index.js +52 -3
  129. package/dist/message/index.d.ts +18 -0
  130. package/dist/message/index.d.ts.map +1 -1
  131. package/dist/message/index.js +67 -0
  132. package/dist/optimize/domain.js +6 -2
  133. package/dist/optimize/map-node.d.ts.map +1 -1
  134. package/dist/optimize/map-node.js +3 -0
  135. package/dist/plan/cache.js +13 -1
  136. package/dist/plan/predicate.d.ts.map +1 -1
  137. package/dist/plan/predicate.js +33 -3
  138. package/dist/plan/schema-predicate.d.ts.map +1 -1
  139. package/dist/plan/schema-predicate.js +267 -8
  140. package/dist/schema/freeze.js +22 -0
  141. package/dist/schema/index.d.ts +2 -2
  142. package/dist/schema/index.d.ts.map +1 -1
  143. package/dist/schema/index.js +1 -1
  144. package/dist/schema/types.d.ts +89 -4
  145. package/dist/schema/types.d.ts.map +1 -1
  146. package/dist/schema/types.js +8 -1
  147. package/dist/schema/undefined.d.ts.map +1 -1
  148. package/dist/schema/undefined.js +5 -0
  149. package/dist/schema/validate.d.ts.map +1 -1
  150. package/dist/schema/validate.js +111 -4
  151. package/docs/api.md +71 -8
  152. package/docs/engine-notes.md +4 -0
  153. package/docs/index.html +1340 -722
  154. package/docs/ko/api.md +375 -0
  155. package/docs/ko/engine-notes.md +156 -0
  156. package/docs/ko/readme.md +378 -0
  157. package/package.json +3 -2
@@ -0,0 +1,150 @@
1
+ /**
2
+ * @file runtime.ts
3
+ * @brief Runtime-object guard builders.
4
+ * @details These builders describe JavaScript object domains that JSON Schema
5
+ * and AOT source cannot faithfully serialize.
6
+ */
7
+ import { SchemaTag } from "../kind/index.js";
8
+ import { BaseGuard } from "../guard/index.js";
9
+ import { readGuardSchema } from "../internal/index.js";
10
+ /**
11
+ * @brief Build a guard backed by ordinary instanceof semantics.
12
+ * @param constructor Constructor function used as the instance domain.
13
+ * @returns Fresh guard accepting values whose prototype chain matches constructor.
14
+ * @throws TypeError when constructor is not callable.
15
+ */
16
+ export function instanceOf(constructor) {
17
+ const rawConstructor = constructor;
18
+ if (typeof rawConstructor !== "function") {
19
+ throw new TypeError("instanceOf constructor must be a function");
20
+ }
21
+ if (!hasObjectPrototype(rawConstructor)) {
22
+ throw new TypeError("instanceOf constructor must expose an object prototype");
23
+ }
24
+ const ctor = rawConstructor;
25
+ return new BaseGuard({
26
+ tag: SchemaTag.InstanceOf,
27
+ constructor: ctor,
28
+ name: readConstructorName(ctor)
29
+ });
30
+ }
31
+ /**
32
+ * @brief Require one own data property after a base guard succeeds.
33
+ * @param base Guard applied to the candidate value first.
34
+ * @param key Own string property key to inspect.
35
+ * @param value Guard applied to the property value.
36
+ * @returns Fresh guard preserving the base domain and recording the property type.
37
+ */
38
+ export function property(base, key, value) {
39
+ if (typeof key !== "string") {
40
+ throw new TypeError("property key must be a string");
41
+ }
42
+ return new BaseGuard({
43
+ tag: SchemaTag.Property,
44
+ base: readGuardSchema(base, "property base"),
45
+ key,
46
+ value: readGuardSchema(value, "property value")
47
+ });
48
+ }
49
+ /**
50
+ * @brief Build a recursive JSON-value guard.
51
+ * @returns Fresh guard accepting JSON-serializable values.
52
+ * @details The guard accepts finite numbers because TypeSea number semantics
53
+ * reject NaN and infinities. Object values are string-keyed records.
54
+ */
55
+ export function json() {
56
+ let cached;
57
+ const root = new BaseGuard({
58
+ tag: SchemaTag.Lazy,
59
+ get: () => {
60
+ cached ??= makeJsonSchema(root.schema);
61
+ return cached;
62
+ }
63
+ });
64
+ return root;
65
+ }
66
+ /**
67
+ * @brief Materialize the recursive JSON schema after the root guard exists.
68
+ * @param root Recursive root schema used by arrays and records.
69
+ * @returns Union schema for every JSON value variant.
70
+ */
71
+ function makeJsonSchema(root) {
72
+ return {
73
+ tag: SchemaTag.Union,
74
+ options: [
75
+ {
76
+ tag: SchemaTag.String,
77
+ checks: []
78
+ },
79
+ {
80
+ tag: SchemaTag.Number,
81
+ checks: []
82
+ },
83
+ {
84
+ tag: SchemaTag.Boolean
85
+ },
86
+ {
87
+ tag: SchemaTag.Literal,
88
+ value: null
89
+ },
90
+ {
91
+ tag: SchemaTag.Array,
92
+ item: root,
93
+ checks: []
94
+ },
95
+ {
96
+ tag: SchemaTag.Refine,
97
+ inner: {
98
+ tag: SchemaTag.Record,
99
+ value: root
100
+ },
101
+ predicate: isJsonObject,
102
+ name: "json_object"
103
+ }
104
+ ]
105
+ };
106
+ }
107
+ /**
108
+ * @brief Accept only JSON object containers.
109
+ * @param value Candidate value already checked as a record.
110
+ * @returns True for ordinary or null-prototype objects.
111
+ */
112
+ function isJsonObject(value) {
113
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
114
+ return false;
115
+ }
116
+ const prototype = Object.getPrototypeOf(value);
117
+ return prototype === Object.prototype || prototype === null;
118
+ }
119
+ /**
120
+ * @brief Read a stable diagnostic name from a constructor function.
121
+ * @param constructor Function supplied to instanceOf.
122
+ * @returns Constructor name or a generic fallback.
123
+ */
124
+ function readConstructorName(constructor) {
125
+ const descriptor = Object.getOwnPropertyDescriptor(constructor, "name");
126
+ const name = descriptor !== undefined && "value" in descriptor
127
+ ? descriptor.value
128
+ : undefined;
129
+ return descriptor !== undefined &&
130
+ "value" in descriptor &&
131
+ typeof name === "string" &&
132
+ name.length !== 0
133
+ ? name
134
+ : "constructor";
135
+ }
136
+ /**
137
+ * @brief Check that a function can participate in ordinary instance checks.
138
+ * @param constructor Function supplied to instanceOf.
139
+ * @returns True when the function exposes an object prototype slot.
140
+ */
141
+ function hasObjectPrototype(constructor) {
142
+ const descriptor = Object.getOwnPropertyDescriptor(constructor, "prototype");
143
+ if (descriptor === undefined ||
144
+ !("value" in descriptor)) {
145
+ return false;
146
+ }
147
+ const prototype = descriptor.value;
148
+ return (typeof prototype === "object" && prototype !== null) ||
149
+ typeof prototype === "function";
150
+ }
@@ -4,8 +4,9 @@
4
4
  * @details Builder helpers normalize user-facing fluent calls into immutable schema nodes
5
5
  * with stable metadata.
6
6
  */
7
- import { BaseGuard, NumberGuard, StringGuard } from "../guard/index.js";
7
+ import { BaseGuard, DateGuard, NumberGuard, StringGuard } from "../guard/index.js";
8
8
  import type { LiteralValue } from "../schema/index.js";
9
+ export type EnumValues = readonly [string, ...string[]];
9
10
  /**
10
11
  * @brief Shared string guard singleton.
11
12
  * @details Primitive guards are immutable, so exporting one instance avoids
@@ -30,6 +31,12 @@ export declare const neverGuard: BaseGuard<never, "required">;
30
31
  * with stable metadata.
31
32
  */
32
33
  export declare const numberGuard: NumberGuard<"required">;
34
+ /**
35
+ * @brief Shared valid Date guard singleton.
36
+ * @details Date validation accepts Date objects whose time value is finite.
37
+ * Invalid Date instances are rejected.
38
+ */
39
+ export declare const dateGuard: DateGuard<"required">;
33
40
  /**
34
41
  * @brief Shared bigint guard singleton.
35
42
  * @details Builder helpers normalize user-facing fluent calls into immutable schema nodes
@@ -48,6 +55,9 @@ export declare const symbolGuard: BaseGuard<symbol, "required">;
48
55
  * with stable metadata.
49
56
  */
50
57
  export declare const booleanGuard: BaseGuard<boolean, "required">;
58
+ export declare const nullGuard: BaseGuard<null, "required">;
59
+ export declare const undefinedGuard: BaseGuard<undefined, "required">;
60
+ export declare const voidGuard: BaseGuard<undefined, "required">;
51
61
  /**
52
62
  * @brief Build a literal guard after rejecting non-literal runtime values.
53
63
  * @details Builder helpers normalize user-facing fluent calls into immutable schema nodes
@@ -57,4 +67,13 @@ export declare const booleanGuard: BaseGuard<boolean, "required">;
57
67
  * @throws TypeError when the value cannot be represented as a TypeSea literal.
58
68
  */
59
69
  export declare function literal<const TValue extends LiteralValue>(value: TValue): BaseGuard<TValue>;
70
+ /**
71
+ * @brief Build a string literal enum guard.
72
+ * @param values Non-empty tuple of string literals.
73
+ * @returns Fresh guard accepting exactly one supplied enum member.
74
+ * @throws TypeError when values are empty, non-strings, or duplicated.
75
+ * @details The public export is aliased as `enum`; this internal name avoids
76
+ * spelling a reserved word as a local binding.
77
+ */
78
+ export declare function enumValues<const TValues extends EnumValues>(values: TValues): BaseGuard<TValues[number]>;
60
79
  //# sourceMappingURL=scalar.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"scalar.d.ts","sourceRoot":"","sources":["../../src/builders/scalar.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACH,SAAS,EACT,WAAW,EACX,WAAW,EACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD;;;;GAIG;AACH,eAAO,MAAM,WAAW,yBAGtB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,YAAY,gCAEvB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,UAAU,8BAErB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,WAAW,yBAGtB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,WAAW,+BAEtB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,WAAW,+BAEtB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,YAAY,gCAEvB,CAAC;AAEH;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,KAAK,CAAC,MAAM,SAAS,YAAY,EACrD,KAAK,EAAE,MAAM,GACd,SAAS,CAAC,MAAM,CAAC,CAYnB"}
1
+ {"version":3,"file":"scalar.d.ts","sourceRoot":"","sources":["../../src/builders/scalar.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACH,SAAS,EACT,SAAS,EACT,WAAW,EACX,WAAW,EACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,YAAY,EAAU,MAAM,oBAAoB,CAAC;AAG/D,MAAM,MAAM,UAAU,GAAG,SAAS,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;AAExD;;;;GAIG;AACH,eAAO,MAAM,WAAW,yBAGtB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,YAAY,gCAEvB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,UAAU,8BAErB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,WAAW,yBAGtB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,SAAS,uBAGpB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,WAAW,+BAEtB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,WAAW,+BAEtB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,YAAY,gCAEvB,CAAC;AAEH,eAAO,MAAM,SAAS,6BAGpB,CAAC;AAEH,eAAO,MAAM,cAAc,kCAGzB,CAAC;AAEH,eAAO,MAAM,SAAS,kCAAiB,CAAC;AAExC;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,KAAK,CAAC,MAAM,SAAS,YAAY,EACrD,KAAK,EAAE,MAAM,GACd,SAAS,CAAC,MAAM,CAAC,CAYnB;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,KAAK,CAAC,OAAO,SAAS,UAAU,EACvD,MAAM,EAAE,OAAO,GAChB,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CA0B5B"}
@@ -5,7 +5,7 @@
5
5
  * with stable metadata.
6
6
  */
7
7
  import { SchemaTag } from "../kind/index.js";
8
- import { BaseGuard, NumberGuard, StringGuard } from "../guard/index.js";
8
+ import { BaseGuard, DateGuard, NumberGuard, StringGuard } from "../guard/index.js";
9
9
  import { isLiteralValue } from "../schema/index.js";
10
10
  /**
11
11
  * @brief Shared string guard singleton.
@@ -41,6 +41,15 @@ export const numberGuard = new NumberGuard({
41
41
  tag: SchemaTag.Number,
42
42
  checks: []
43
43
  });
44
+ /**
45
+ * @brief Shared valid Date guard singleton.
46
+ * @details Date validation accepts Date objects whose time value is finite.
47
+ * Invalid Date instances are rejected.
48
+ */
49
+ export const dateGuard = new DateGuard({
50
+ tag: SchemaTag.Date,
51
+ checks: []
52
+ });
44
53
  /**
45
54
  * @brief Shared bigint guard singleton.
46
55
  * @details Builder helpers normalize user-facing fluent calls into immutable schema nodes
@@ -65,6 +74,15 @@ export const symbolGuard = new BaseGuard({
65
74
  export const booleanGuard = new BaseGuard({
66
75
  tag: SchemaTag.Boolean
67
76
  });
77
+ export const nullGuard = new BaseGuard({
78
+ tag: SchemaTag.Literal,
79
+ value: null
80
+ });
81
+ export const undefinedGuard = new BaseGuard({
82
+ tag: SchemaTag.Literal,
83
+ value: undefined
84
+ });
85
+ export const voidGuard = undefinedGuard;
68
86
  /**
69
87
  * @brief Build a literal guard after rejecting non-literal runtime values.
70
88
  * @details Builder helpers normalize user-facing fluent calls into immutable schema nodes
@@ -86,3 +104,38 @@ export function literal(value) {
86
104
  value
87
105
  });
88
106
  }
107
+ /**
108
+ * @brief Build a string literal enum guard.
109
+ * @param values Non-empty tuple of string literals.
110
+ * @returns Fresh guard accepting exactly one supplied enum member.
111
+ * @throws TypeError when values are empty, non-strings, or duplicated.
112
+ * @details The public export is aliased as `enum`; this internal name avoids
113
+ * spelling a reserved word as a local binding.
114
+ */
115
+ export function enumValues(values) {
116
+ const rawValues = values;
117
+ if (!Array.isArray(rawValues) || rawValues.length === 0) {
118
+ throw new TypeError("enum values must be a non-empty string array");
119
+ }
120
+ const checkedValues = rawValues;
121
+ const options = new Array(checkedValues.length);
122
+ for (let index = 0; index < checkedValues.length; index += 1) {
123
+ const value = checkedValues[index];
124
+ if (typeof value !== "string") {
125
+ throw new TypeError("enum values must be strings");
126
+ }
127
+ for (let seen = 0; seen < index; seen += 1) {
128
+ if (Object.is(checkedValues[seen], value)) {
129
+ throw new TypeError("enum values must be unique");
130
+ }
131
+ }
132
+ options[index] = {
133
+ tag: SchemaTag.Literal,
134
+ value
135
+ };
136
+ }
137
+ return new BaseGuard({
138
+ tag: SchemaTag.Union,
139
+ options
140
+ });
141
+ }
@@ -5,11 +5,12 @@
5
5
  * with stable metadata.
6
6
  */
7
7
  import { asyncDecoder, asyncPipe, asyncRefine, asyncTransform } from "../async/index.js";
8
- import { decoder, pipe, transform } from "../decoder/index.js";
9
- import { array, discriminatedUnion, intersect, record, tuple, union } from "./composite.js";
10
- import { lazy, nullable, optional, refine, undefinedable } from "./modifier.js";
11
- import { extend, object, omit, partial, pick, strictObject } from "./object/index.js";
12
- import { literal } from "./scalar.js";
8
+ import { catchValue, codec, decoder, defaultValue, pipe, prefault, transform } from "../decoder/index.js";
9
+ import { array, discriminatedUnion, intersect, map, record, set, tuple, union } from "./composite.js";
10
+ import { lazy, nullable, nullish, optional, refine, undefinedable } from "./modifier.js";
11
+ import { catchall, deepPartial, extend, merge, object, omit, partial, passthrough, pick, required, safeExtend, strict, strictObject, strip } from "./object/index.js";
12
+ import { enumValues, literal } from "./scalar.js";
13
+ import { instanceOf, json, property } from "./runtime.js";
13
14
  /**
14
15
  * @brief t.
15
16
  * @details Frozen namespace of all public builders. Freezing prevents accidental
@@ -20,26 +21,51 @@ export declare const t: Readonly<{
20
21
  readonly never: import("../index.js").BaseGuard<never, "required">;
21
22
  readonly string: import("../index.js").StringGuard<"required">;
22
23
  readonly number: import("../index.js").NumberGuard<"required">;
24
+ readonly date: import("../index.js").DateGuard<"required">;
23
25
  readonly bigint: import("../index.js").BaseGuard<bigint, "required">;
24
26
  readonly symbol: import("../index.js").BaseGuard<symbol, "required">;
25
27
  readonly boolean: import("../index.js").BaseGuard<boolean, "required">;
28
+ readonly null: import("../index.js").BaseGuard<null, "required">;
29
+ readonly undefined: import("../index.js").BaseGuard<undefined, "required">;
30
+ readonly void: import("../index.js").BaseGuard<undefined, "required">;
26
31
  readonly literal: typeof literal;
32
+ readonly enum: typeof enumValues;
33
+ readonly enumValues: typeof enumValues;
27
34
  readonly array: typeof array;
28
35
  readonly tuple: typeof tuple;
29
36
  readonly record: typeof record;
37
+ readonly map: typeof map;
38
+ readonly set: typeof set;
39
+ readonly instanceOf: typeof instanceOf;
40
+ readonly property: typeof property;
41
+ readonly json: typeof json;
30
42
  readonly decoder: typeof decoder;
43
+ readonly default: typeof defaultValue;
44
+ readonly defaultValue: typeof defaultValue;
45
+ readonly prefault: typeof prefault;
46
+ readonly catch: typeof catchValue;
47
+ readonly codec: typeof codec;
31
48
  readonly object: typeof object;
32
49
  readonly strictObject: typeof strictObject;
33
50
  readonly extend: typeof extend;
51
+ readonly merge: typeof merge;
34
52
  readonly pick: typeof pick;
35
53
  readonly omit: typeof omit;
36
54
  readonly partial: typeof partial;
55
+ readonly deepPartial: typeof deepPartial;
56
+ readonly required: typeof required;
57
+ readonly safeExtend: typeof safeExtend;
58
+ readonly strict: typeof strict;
59
+ readonly passthrough: typeof passthrough;
60
+ readonly strip: typeof strip;
61
+ readonly catchall: typeof catchall;
37
62
  readonly union: typeof union;
38
63
  readonly intersect: typeof intersect;
39
64
  readonly discriminatedUnion: typeof discriminatedUnion;
40
65
  readonly optional: typeof optional;
41
66
  readonly undefinedable: typeof undefinedable;
42
67
  readonly nullable: typeof nullable;
68
+ readonly nullish: typeof nullish;
43
69
  readonly lazy: typeof lazy;
44
70
  readonly refine: typeof refine;
45
71
  readonly transform: typeof transform;
@@ -1 +1 @@
1
- {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/builders/table.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACzF,OAAO,EAAU,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EACH,KAAK,EACL,kBAAkB,EAClB,SAAS,EACT,MAAM,EACN,KAAK,EACL,KAAK,EACR,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACH,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,aAAa,EAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EACH,MAAM,EACN,MAAM,EACN,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,YAAY,EACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAGH,OAAO,EAMV,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,eAAO,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkCH,CAAC"}
1
+ {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/builders/table.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACzF,OAAO,EACH,UAAU,EACV,KAAK,EAEL,OAAO,EACP,YAAY,EACZ,IAAI,EACJ,QAAQ,EACR,SAAS,EACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACH,KAAK,EACL,kBAAkB,EAClB,SAAS,EACT,GAAG,EACH,MAAM,EACN,GAAG,EACH,KAAK,EACL,KAAK,EACR,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACH,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,MAAM,EACN,aAAa,EAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EACH,QAAQ,EACR,WAAW,EACX,MAAM,EACN,KAAK,EACL,MAAM,EACN,IAAI,EACJ,OAAO,EACP,WAAW,EACX,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,MAAM,EACN,YAAY,EACZ,KAAK,EACR,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAIH,UAAU,EACV,OAAO,EASV,MAAM,aAAa,CAAC;AACrB,OAAO,EACH,UAAU,EACV,IAAI,EACJ,QAAQ,EACX,MAAM,cAAc,CAAC;AAEtB;;;;GAIG;AACH,eAAO,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2DH,CAAC"}
@@ -5,11 +5,12 @@
5
5
  * with stable metadata.
6
6
  */
7
7
  import { asyncDecoder, asyncPipe, asyncRefine, asyncTransform } from "../async/index.js";
8
- import { coerce, decoder, pipe, transform } from "../decoder/index.js";
9
- import { array, discriminatedUnion, intersect, record, tuple, union } from "./composite.js";
10
- import { lazy, nullable, optional, refine, undefinedable } from "./modifier.js";
11
- import { extend, object, omit, partial, pick, strictObject } from "./object/index.js";
12
- import { bigintGuard, booleanGuard, literal, neverGuard, numberGuard, stringGuard, symbolGuard, unknownGuard } from "./scalar.js";
8
+ import { catchValue, codec, coerce, decoder, defaultValue, pipe, prefault, transform } from "../decoder/index.js";
9
+ import { array, discriminatedUnion, intersect, map, record, set, tuple, union } from "./composite.js";
10
+ import { lazy, nullable, nullish, optional, refine, undefinedable } from "./modifier.js";
11
+ import { catchall, deepPartial, extend, merge, object, omit, partial, passthrough, pick, required, safeExtend, strict, strictObject, strip } from "./object/index.js";
12
+ import { bigintGuard, booleanGuard, dateGuard, enumValues, literal, neverGuard, nullGuard, numberGuard, stringGuard, symbolGuard, unknownGuard, undefinedGuard, voidGuard } from "./scalar.js";
13
+ import { instanceOf, json, property } from "./runtime.js";
13
14
  /**
14
15
  * @brief t.
15
16
  * @details Frozen namespace of all public builders. Freezing prevents accidental
@@ -20,26 +21,51 @@ export const t = Object.freeze({
20
21
  never: neverGuard,
21
22
  string: stringGuard,
22
23
  number: numberGuard,
24
+ date: dateGuard,
23
25
  bigint: bigintGuard,
24
26
  symbol: symbolGuard,
25
27
  boolean: booleanGuard,
28
+ null: nullGuard,
29
+ undefined: undefinedGuard,
30
+ void: voidGuard,
26
31
  literal,
32
+ enum: enumValues,
33
+ enumValues,
27
34
  array,
28
35
  tuple,
29
36
  record,
37
+ map,
38
+ set,
39
+ instanceOf,
40
+ property,
41
+ json,
30
42
  decoder,
43
+ default: defaultValue,
44
+ defaultValue,
45
+ prefault,
46
+ catch: catchValue,
47
+ codec,
31
48
  object,
32
49
  strictObject,
33
50
  extend,
51
+ merge,
34
52
  pick,
35
53
  omit,
36
54
  partial,
55
+ deepPartial,
56
+ required,
57
+ safeExtend,
58
+ strict,
59
+ passthrough,
60
+ strip,
61
+ catchall,
37
62
  union,
38
63
  intersect,
39
64
  discriminatedUnion,
40
65
  optional,
41
66
  undefinedable,
42
67
  nullable,
68
+ nullish,
43
69
  lazy,
44
70
  refine,
45
71
  transform,
@@ -19,6 +19,12 @@ export type TupleShape = readonly Guard<unknown, Presence>[];
19
19
  export type InferTuple<TShape extends TupleShape> = {
20
20
  readonly [TKey in keyof TShape]: Infer<TShape[TKey]>;
21
21
  };
22
+ export type InferTupleWithRest<TShape extends TupleShape, TRest extends Guard<unknown, Presence>> = readonly [
23
+ ...{
24
+ [TKey in keyof TShape]: Infer<TShape[TKey]>;
25
+ },
26
+ ...Infer<TRest>[]
27
+ ];
22
28
  /**
23
29
  * @brief Non-empty union builder input.
24
30
  * @details Builder helpers normalize user-facing fluent calls into immutable schema nodes
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/builders/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACR,KAAK,EACL,KAAK,EACL,QAAQ,EACX,MAAM,mBAAmB,CAAC;AAE3B;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC;AAE7D;;;;GAIG;AACH,MAAM,MAAM,UAAU,CAAC,MAAM,SAAS,UAAU,IAAI;IAChD,QAAQ,EAAE,IAAI,IAAI,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;CACvD,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAClB,SAAS,CAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC;AAEvE;;;;GAIG;AACH,MAAM,MAAM,uBAAuB,CAC/B,IAAI,SAAS,MAAM,EACnB,MAAM,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,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,CAC/B,IAAI,SAAS,MAAM,EACnB,MAAM,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,IACjE,MAAM,SAAS,IAAI,GACjB,MAAM,GACN;IACM,QAAQ,EAAE,KAAK,IAAI,MAAM,MAAM,GAAG,KAAK,SAAS,MAAM,GAChD,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,GACtD,MAAM,CAAC,KAAK,CAAC,GACb,KAAK,GACb,KAAK;CACV,CAAC"}
@@ -25,7 +25,9 @@ export type CheckFunctionEmitter = (schema: Schema, context: EmitContext) => str
25
25
  * @param emitChild Fallback emitter for non-leaf child validators.
26
26
  * @returns JavaScript source for array diagnostics.
27
27
  */
28
- export declare function emitArrayCheck(item: Schema, value: string, path: string, issues: string, context: EmitContext, emitChild: CheckFunctionEmitter): string;
28
+ export declare function emitArrayCheck(schema: Extract<Schema, {
29
+ readonly tag: typeof SchemaTag.Array;
30
+ }>, value: string, path: string, issues: string, context: EmitContext, emitChild: CheckFunctionEmitter): string;
29
31
  /**
30
32
  * @brief emit tuple check.
31
33
  * @details Generated-source helpers keep the side-table ABI and JavaScript source shape
@@ -1 +1 @@
1
- {"version":3,"file":"check-composite.d.ts","sourceRoot":"","sources":["../../src/compile/check-composite.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAGH,SAAS,EACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEH,KAAK,sBAAsB,EAC3B,KAAK,MAAM,EACd,MAAM,oBAAoB,CAAC;AAkB5B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAC/B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,WAAW,KACnB,MAAM,CAAC;AAEZ;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAC1B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,oBAAoB,GAChC,MAAM,CAgFR;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC1B,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,oBAAoB,GAChC,MAAM,CAoER;AA+ZD;;;;GAIG;AACH,wBAAgB,eAAe,CAC3B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,oBAAoB,GAChC,MAAM,CA2CR;AAmKD;;;;GAIG;AACH,wBAAgB,eAAe,CAC3B,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE;IAAE,QAAQ,CAAC,GAAG,EAAE,OAAO,SAAS,CAAC,MAAM,CAAA;CAAE,CAAC,EAClE,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,oBAAoB,GAChC,MAAM,CAiGR;AA0KD;;;;GAIG;AACH,wBAAgB,2BAA2B,CACvC,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,SAAS,sBAAsB,EAAE,EACxC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,oBAAoB,GAChC,MAAM,CA4DR"}
1
+ {"version":3,"file":"check-composite.d.ts","sourceRoot":"","sources":["../../src/compile/check-composite.ts"],"names":[],"mappings":"AAAA;;;;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