typia 9.7.2 → 10.0.0-dev.20251107

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 (116) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +153 -153
  3. package/lib/factories/ProtobufFactory.js +1 -1
  4. package/lib/factories/ProtobufFactory.mjs +1 -1
  5. package/lib/programmers/internal/json_schema_station.d.mts +2 -2
  6. package/lib/programmers/internal/json_schema_station.d.ts +2 -2
  7. package/lib/programmers/llm/LlmApplicationProgrammer.js +5 -1
  8. package/lib/programmers/llm/LlmApplicationProgrammer.js.map +1 -1
  9. package/lib/programmers/llm/LlmApplicationProgrammer.mjs +5 -1
  10. package/lib/programmers/llm/LlmSchemaProgrammer.js +1 -4
  11. package/lib/programmers/llm/LlmSchemaProgrammer.js.map +1 -1
  12. package/lib/programmers/llm/LlmSchemaProgrammer.mjs +1 -35
  13. package/package.json +121 -121
  14. package/src/AssertionGuard.ts +41 -41
  15. package/src/CamelCase.ts +75 -75
  16. package/src/IRandomGenerator.ts +337 -337
  17. package/src/IReadableURLSearchParams.ts +9 -9
  18. package/src/PascalCase.ts +71 -71
  19. package/src/Primitive.ts +90 -90
  20. package/src/Resolved.ts +72 -72
  21. package/src/SnakeCase.ts +127 -127
  22. package/src/TypeGuardError.ts +216 -216
  23. package/src/factories/MetadataCollection.ts +270 -270
  24. package/src/factories/MetadataCommentTagFactory.ts +632 -632
  25. package/src/factories/MetadataFactory.ts +402 -402
  26. package/src/factories/ProtobufFactory.ts +873 -873
  27. package/src/functional.ts +705 -705
  28. package/src/http.ts +972 -972
  29. package/src/internal/_ProtobufReader.ts +188 -188
  30. package/src/internal/_ProtobufSizer.ts +137 -137
  31. package/src/internal/_ProtobufWriter.ts +135 -135
  32. package/src/internal/_jsonStringifyString.ts +42 -42
  33. package/src/json.ts +643 -643
  34. package/src/llm.ts +615 -615
  35. package/src/misc.ts +594 -594
  36. package/src/module.ts +889 -889
  37. package/src/notations.ts +751 -751
  38. package/src/programmers/FeatureProgrammer.ts +605 -605
  39. package/src/programmers/ImportProgrammer.ts +179 -179
  40. package/src/programmers/RandomProgrammer.ts +1195 -1195
  41. package/src/programmers/helpers/ProtobufWire.ts +34 -34
  42. package/src/programmers/internal/check_array_length.ts +43 -43
  43. package/src/programmers/internal/check_bigint.ts +46 -46
  44. package/src/programmers/internal/check_dynamic_key.ts +197 -197
  45. package/src/programmers/internal/check_dynamic_properties.ts +231 -231
  46. package/src/programmers/internal/check_everything.ts +21 -21
  47. package/src/programmers/internal/check_native.ts +23 -23
  48. package/src/programmers/internal/check_number.ts +108 -108
  49. package/src/programmers/internal/check_object.ts +72 -72
  50. package/src/programmers/internal/check_string.ts +46 -46
  51. package/src/programmers/internal/check_template.ts +46 -46
  52. package/src/programmers/internal/check_union_array_like.ts +331 -331
  53. package/src/programmers/internal/decode_union_object.ts +110 -110
  54. package/src/programmers/internal/feature_object_entries.ts +59 -59
  55. package/src/programmers/internal/json_schema_escaped.ts +78 -78
  56. package/src/programmers/internal/json_schema_object.ts +150 -150
  57. package/src/programmers/internal/json_schema_station.ts +2 -2
  58. package/src/programmers/internal/metadata_to_pattern.ts +40 -40
  59. package/src/programmers/internal/postfix_of_tuple.ts +3 -3
  60. package/src/programmers/internal/prune_object_properties.ts +69 -69
  61. package/src/programmers/internal/stringify_dynamic_properties.ts +158 -158
  62. package/src/programmers/internal/stringify_native.ts +5 -5
  63. package/src/programmers/internal/stringify_regular_properties.ts +77 -77
  64. package/src/programmers/internal/template_to_pattern.ts +21 -21
  65. package/src/programmers/internal/wrap_metadata_rest_tuple.ts +21 -21
  66. package/src/programmers/json/JsonStringifyProgrammer.ts +1124 -1124
  67. package/src/programmers/llm/LlmApplicationProgrammer.ts +10 -1
  68. package/src/programmers/llm/LlmSchemaProgrammer.ts +2 -7
  69. package/src/protobuf.ts +820 -820
  70. package/src/reflect.ts +46 -46
  71. package/src/schemas/json/IJsonApplication.ts +77 -77
  72. package/src/schemas/json/IJsonSchemaCollection.ts +212 -212
  73. package/src/schemas/json/IJsonSchemaUnit.ts +263 -263
  74. package/src/schemas/metadata/IMetadataTypeTag.ts +14 -14
  75. package/src/schemas/metadata/Metadata.ts +669 -669
  76. package/src/schemas/metadata/MetadataAliasType.ts +57 -57
  77. package/src/schemas/metadata/MetadataApplication.ts +40 -40
  78. package/src/schemas/metadata/MetadataArray.ts +47 -47
  79. package/src/schemas/metadata/MetadataArrayType.ts +51 -51
  80. package/src/schemas/metadata/MetadataAtomic.ts +85 -85
  81. package/src/schemas/metadata/MetadataEscaped.ts +45 -45
  82. package/src/schemas/metadata/MetadataFunction.ts +45 -45
  83. package/src/schemas/metadata/MetadataObject.ts +46 -46
  84. package/src/schemas/metadata/MetadataObjectType.ts +137 -137
  85. package/src/schemas/metadata/MetadataParameter.ts +52 -52
  86. package/src/schemas/metadata/MetadataProperty.ts +53 -53
  87. package/src/schemas/metadata/MetadataTemplate.ts +78 -78
  88. package/src/schemas/metadata/MetadataTuple.ts +28 -28
  89. package/src/schemas/metadata/MetadataTupleType.ts +61 -61
  90. package/src/tags/Constant.ts +47 -47
  91. package/src/tags/ContentMediaType.ts +27 -27
  92. package/src/tags/Default.ts +52 -52
  93. package/src/tags/Example.ts +56 -56
  94. package/src/tags/Examples.ts +56 -56
  95. package/src/tags/ExclusiveMaximum.ts +44 -44
  96. package/src/tags/ExclusiveMinimum.ts +44 -44
  97. package/src/tags/Format.ts +78 -78
  98. package/src/tags/JsonSchemaPlugin.ts +36 -36
  99. package/src/tags/MaxItems.ts +31 -31
  100. package/src/tags/MaxLength.ts +25 -25
  101. package/src/tags/Maximum.ts +39 -39
  102. package/src/tags/MinItems.ts +31 -31
  103. package/src/tags/MinLength.ts +25 -25
  104. package/src/tags/Minimum.ts +39 -39
  105. package/src/tags/MultipleOf.ts +42 -42
  106. package/src/tags/Pattern.ts +49 -49
  107. package/src/tags/Sequence.ts +37 -37
  108. package/src/tags/TagBase.ts +102 -102
  109. package/src/tags/Type.ts +64 -64
  110. package/src/tags/UniqueItems.ts +34 -34
  111. package/src/tags/internal/FormatCheatSheet.ts +71 -71
  112. package/src/transformers/ITransformOptions.ts +70 -70
  113. package/src/transformers/ImportTransformer.ts +253 -253
  114. package/src/transformers/NoTransformConfigurationError.ts +16 -16
  115. package/src/transformers/features/llm/LlmApplicationTransformer.ts +224 -224
  116. package/src/typings/Equal.ts +18 -18
@@ -1,34 +1,34 @@
1
- export const enum ProtobufWire {
2
- /**
3
- * - Integers
4
- * - Bool
5
- * - Enum
6
- */
7
- VARIANT = 0,
8
-
9
- /**
10
- * - Fixed64
11
- * - Sfixed64
12
- * - Double
13
- */
14
- I64 = 1,
15
-
16
- /**
17
- * - String
18
- * - Bytes
19
- * - Mebedded messages
20
- * - Packed repeated fields
21
- */
22
- LEN = 2,
23
-
24
- START_GROUP = 3,
25
-
26
- END_GROUP = 4,
27
-
28
- /**
29
- * - Fixed
30
- * - Sfixed32
31
- * - Float
32
- */
33
- I32 = 5,
34
- }
1
+ export const enum ProtobufWire {
2
+ /**
3
+ * - Integers
4
+ * - Bool
5
+ * - Enum
6
+ */
7
+ VARIANT = 0,
8
+
9
+ /**
10
+ * - Fixed64
11
+ * - Sfixed64
12
+ * - Double
13
+ */
14
+ I64 = 1,
15
+
16
+ /**
17
+ * - String
18
+ * - Bytes
19
+ * - Mebedded messages
20
+ * - Packed repeated fields
21
+ */
22
+ LEN = 2,
23
+
24
+ START_GROUP = 3,
25
+
26
+ END_GROUP = 4,
27
+
28
+ /**
29
+ * - Fixed
30
+ * - Sfixed32
31
+ * - Float
32
+ */
33
+ I32 = 5,
34
+ }
@@ -1,43 +1,43 @@
1
- import ts from "typescript";
2
-
3
- import { ExpressionFactory } from "../../factories/ExpressionFactory";
4
-
5
- import { MetadataArray } from "../../schemas/metadata/MetadataArray";
6
-
7
- import { ITypiaContext } from "../../transformers/ITypiaContext";
8
-
9
- import { ICheckEntry } from "../helpers/ICheckEntry";
10
-
11
- /** @internal */
12
- export const check_array_length = (props: {
13
- context: ITypiaContext;
14
- array: MetadataArray;
15
- input: ts.Expression;
16
- }): ICheckEntry => {
17
- const conditions: ICheckEntry.ICondition[][] = check_array_type_tags(props);
18
- return {
19
- expected: props.array.getName(),
20
- expression: null,
21
- conditions,
22
- };
23
- };
24
-
25
- /** @internal */
26
- const check_array_type_tags = (props: {
27
- context: ITypiaContext;
28
- array: MetadataArray;
29
- input: ts.Expression;
30
- }): ICheckEntry.ICondition[][] =>
31
- props.array.tags
32
- .map((row) => row.filter((tag) => !!tag.validate))
33
- .filter((row) => !!row.length)
34
- .map((row) =>
35
- row.map((tag) => ({
36
- expected: `Array<> & ${tag.name}`,
37
- expression: ExpressionFactory.transpile({
38
- transformer: props.context.transformer,
39
- importer: props.context.importer,
40
- script: tag.validate!,
41
- })(props.input),
42
- })),
43
- );
1
+ import ts from "typescript";
2
+
3
+ import { ExpressionFactory } from "../../factories/ExpressionFactory";
4
+
5
+ import { MetadataArray } from "../../schemas/metadata/MetadataArray";
6
+
7
+ import { ITypiaContext } from "../../transformers/ITypiaContext";
8
+
9
+ import { ICheckEntry } from "../helpers/ICheckEntry";
10
+
11
+ /** @internal */
12
+ export const check_array_length = (props: {
13
+ context: ITypiaContext;
14
+ array: MetadataArray;
15
+ input: ts.Expression;
16
+ }): ICheckEntry => {
17
+ const conditions: ICheckEntry.ICondition[][] = check_array_type_tags(props);
18
+ return {
19
+ expected: props.array.getName(),
20
+ expression: null,
21
+ conditions,
22
+ };
23
+ };
24
+
25
+ /** @internal */
26
+ const check_array_type_tags = (props: {
27
+ context: ITypiaContext;
28
+ array: MetadataArray;
29
+ input: ts.Expression;
30
+ }): ICheckEntry.ICondition[][] =>
31
+ props.array.tags
32
+ .map((row) => row.filter((tag) => !!tag.validate))
33
+ .filter((row) => !!row.length)
34
+ .map((row) =>
35
+ row.map((tag) => ({
36
+ expected: `Array<> & ${tag.name}`,
37
+ expression: ExpressionFactory.transpile({
38
+ transformer: props.context.transformer,
39
+ importer: props.context.importer,
40
+ script: tag.validate!,
41
+ })(props.input),
42
+ })),
43
+ );
@@ -1,46 +1,46 @@
1
- import ts from "typescript";
2
-
3
- import { ExpressionFactory } from "../../factories/ExpressionFactory";
4
-
5
- import { MetadataAtomic } from "../../schemas/metadata/MetadataAtomic";
6
-
7
- import { ITypiaContext } from "../../transformers/ITypiaContext";
8
-
9
- import { ICheckEntry } from "../helpers/ICheckEntry";
10
-
11
- /** @internal */
12
- export const check_bigint = (props: {
13
- context: ITypiaContext;
14
- atomic: MetadataAtomic;
15
- input: ts.Expression;
16
- }): ICheckEntry => {
17
- const conditions: ICheckEntry.ICondition[][] = check_bigint_type_tags(props);
18
- return {
19
- expected: props.atomic.getName(),
20
- expression: ts.factory.createStrictEquality(
21
- ts.factory.createStringLiteral("bigint"),
22
- ts.factory.createTypeOfExpression(props.input),
23
- ),
24
- conditions,
25
- };
26
- };
27
-
28
- /** @internal */
29
- const check_bigint_type_tags = (props: {
30
- context: ITypiaContext;
31
- atomic: MetadataAtomic;
32
- input: ts.Expression;
33
- }): ICheckEntry.ICondition[][] =>
34
- props.atomic.tags
35
- .map((row) => row.filter((tag) => !!tag.validate))
36
- .filter((row) => !!row.length)
37
- .map((row) =>
38
- row.map((tag) => ({
39
- expected: `bigint & ${tag.name}`,
40
- expression: ExpressionFactory.transpile({
41
- transformer: props.context.transformer,
42
- importer: props.context.importer,
43
- script: tag.validate!,
44
- })(props.input),
45
- })),
46
- );
1
+ import ts from "typescript";
2
+
3
+ import { ExpressionFactory } from "../../factories/ExpressionFactory";
4
+
5
+ import { MetadataAtomic } from "../../schemas/metadata/MetadataAtomic";
6
+
7
+ import { ITypiaContext } from "../../transformers/ITypiaContext";
8
+
9
+ import { ICheckEntry } from "../helpers/ICheckEntry";
10
+
11
+ /** @internal */
12
+ export const check_bigint = (props: {
13
+ context: ITypiaContext;
14
+ atomic: MetadataAtomic;
15
+ input: ts.Expression;
16
+ }): ICheckEntry => {
17
+ const conditions: ICheckEntry.ICondition[][] = check_bigint_type_tags(props);
18
+ return {
19
+ expected: props.atomic.getName(),
20
+ expression: ts.factory.createStrictEquality(
21
+ ts.factory.createStringLiteral("bigint"),
22
+ ts.factory.createTypeOfExpression(props.input),
23
+ ),
24
+ conditions,
25
+ };
26
+ };
27
+
28
+ /** @internal */
29
+ const check_bigint_type_tags = (props: {
30
+ context: ITypiaContext;
31
+ atomic: MetadataAtomic;
32
+ input: ts.Expression;
33
+ }): ICheckEntry.ICondition[][] =>
34
+ props.atomic.tags
35
+ .map((row) => row.filter((tag) => !!tag.validate))
36
+ .filter((row) => !!row.length)
37
+ .map((row) =>
38
+ row.map((tag) => ({
39
+ expected: `bigint & ${tag.name}`,
40
+ expression: ExpressionFactory.transpile({
41
+ transformer: props.context.transformer,
42
+ importer: props.context.importer,
43
+ script: tag.validate!,
44
+ })(props.input),
45
+ })),
46
+ );
@@ -1,197 +1,197 @@
1
- import ts from "typescript";
2
-
3
- import { Metadata } from "../../schemas/metadata/Metadata";
4
-
5
- import { ITypiaContext } from "../../transformers/ITypiaContext";
6
-
7
- import { ICheckEntry } from "../helpers/ICheckEntry";
8
- import { check_bigint } from "./check_bigint";
9
- import { check_number } from "./check_number";
10
- import { check_string } from "./check_string";
11
- import { check_template } from "./check_template";
12
-
13
- /** @internal */
14
- export const check_dynamic_key = (props: {
15
- context: ITypiaContext;
16
- metadata: Metadata;
17
- input: ts.Expression;
18
- }): ts.Expression => {
19
- // IF PURE STRING EXISTS, THEN SKIP VALIDATION
20
- if (
21
- (props.metadata.atomics.length !== 0 &&
22
- props.metadata.atomics.some(
23
- (a) =>
24
- a.type === "string" &&
25
- a.tags.filter((row) => row.every((t) => t.validate !== undefined))
26
- .length === 0,
27
- )) ||
28
- (props.metadata.natives.length !== 0 &&
29
- props.metadata.natives.some((native) => native.name === "String"))
30
- )
31
- return ts.factory.createTrue();
32
-
33
- const conditions: ts.Expression[] = [];
34
-
35
- // NULLISH COALESCING
36
- if (props.metadata.nullable === true)
37
- conditions.push(
38
- ts.factory.createStrictEquality(
39
- ts.factory.createStringLiteral("null"),
40
- props.input,
41
- ),
42
- );
43
- if (props.metadata.isRequired() === false)
44
- conditions.push(
45
- ts.factory.createStrictEquality(
46
- ts.factory.createStringLiteral("undefined"),
47
- props.input,
48
- ),
49
- );
50
-
51
- // ATOMICS
52
- for (const atom of props.metadata.atomics)
53
- if (atom.type === "boolean")
54
- conditions.push(
55
- ts.factory.createLogicalOr(
56
- ts.factory.createStrictEquality(
57
- ts.factory.createStringLiteral("false"),
58
- props.input,
59
- ),
60
- ts.factory.createStrictEquality(
61
- ts.factory.createStringLiteral("true"),
62
- props.input,
63
- ),
64
- ),
65
- );
66
- else if (atom.type === "bigint")
67
- conditions.push(
68
- ts.factory.createLogicalAnd(
69
- ts.factory.createCallExpression(
70
- props.context.importer.internal("isBigintString"),
71
- undefined,
72
- [props.input],
73
- ),
74
- atomist(
75
- check_bigint({
76
- context: props.context,
77
- atomic: atom,
78
- input: ts.factory.createCallExpression(
79
- ts.factory.createIdentifier("BigInt"),
80
- undefined,
81
- [props.input],
82
- ),
83
- }),
84
- ),
85
- ),
86
- );
87
- else if (atom.type === "number")
88
- conditions.push(
89
- atomist(
90
- check_number({
91
- context: props.context,
92
- numeric: true,
93
- atomic: atom,
94
- input: ts.factory.createCallExpression(
95
- ts.factory.createIdentifier("Number"),
96
- undefined,
97
- [props.input],
98
- ),
99
- }),
100
- ),
101
- );
102
- else
103
- conditions.push(
104
- atomist(
105
- check_string({
106
- context: props.context,
107
- atomic: atom,
108
- input: props.input,
109
- }),
110
- ),
111
- );
112
-
113
- // CONSTANTS
114
- for (const constant of props.metadata.constants)
115
- for (const { value } of constant.values)
116
- conditions.push(
117
- ts.factory.createStrictEquality(
118
- ts.factory.createStringLiteral(String(value)),
119
- props.input,
120
- ),
121
- );
122
-
123
- // TEMPLATES
124
- if (!!props.metadata.templates.length)
125
- conditions.push(
126
- atomist(
127
- check_template({
128
- templates: props.metadata.templates,
129
- input: props.input,
130
- }),
131
- ),
132
- );
133
-
134
- // NATIVES
135
- for (const native of props.metadata.natives)
136
- if (native.name === "Boolean")
137
- conditions.push(
138
- ts.factory.createLogicalOr(
139
- ts.factory.createStrictEquality(
140
- ts.factory.createStringLiteral("false"),
141
- props.input,
142
- ),
143
- ts.factory.createStrictEquality(
144
- ts.factory.createStringLiteral("true"),
145
- props.input,
146
- ),
147
- ),
148
- );
149
- else if (native.name === "BigInt")
150
- conditions.push(
151
- ts.factory.createCallExpression(
152
- props.context.importer.internal("isBigintString"),
153
- undefined,
154
- [props.input],
155
- ),
156
- );
157
- else if (native.name === "Number")
158
- conditions.push(
159
- ts.factory.createStrictEquality(
160
- ts.factory.createFalse(),
161
- ts.factory.createCallExpression(
162
- ts.factory.createIdentifier("Number.isNaN"),
163
- undefined,
164
- [
165
- ts.factory.createCallExpression(
166
- ts.factory.createIdentifier("Number"),
167
- undefined,
168
- [props.input],
169
- ),
170
- ],
171
- ),
172
- ),
173
- );
174
-
175
- return conditions.length === 0
176
- ? ts.factory.createTrue()
177
- : conditions.length === 1
178
- ? conditions[0]!
179
- : conditions.reduce(ts.factory.createLogicalOr);
180
- };
181
-
182
- /** @internal */
183
- const atomist = (entry: ICheckEntry) =>
184
- [
185
- ...(entry.expression ? [entry.expression] : []),
186
- ...(entry.conditions.length === 0
187
- ? []
188
- : [
189
- entry.conditions
190
- .map((set) =>
191
- set
192
- .map((s) => s.expression)
193
- .reduce((a, b) => ts.factory.createLogicalAnd(a, b)),
194
- )
195
- .reduce((a, b) => ts.factory.createLogicalOr(a, b)),
196
- ]),
197
- ].reduce((x, y) => ts.factory.createLogicalAnd(x, y));
1
+ import ts from "typescript";
2
+
3
+ import { Metadata } from "../../schemas/metadata/Metadata";
4
+
5
+ import { ITypiaContext } from "../../transformers/ITypiaContext";
6
+
7
+ import { ICheckEntry } from "../helpers/ICheckEntry";
8
+ import { check_bigint } from "./check_bigint";
9
+ import { check_number } from "./check_number";
10
+ import { check_string } from "./check_string";
11
+ import { check_template } from "./check_template";
12
+
13
+ /** @internal */
14
+ export const check_dynamic_key = (props: {
15
+ context: ITypiaContext;
16
+ metadata: Metadata;
17
+ input: ts.Expression;
18
+ }): ts.Expression => {
19
+ // IF PURE STRING EXISTS, THEN SKIP VALIDATION
20
+ if (
21
+ (props.metadata.atomics.length !== 0 &&
22
+ props.metadata.atomics.some(
23
+ (a) =>
24
+ a.type === "string" &&
25
+ a.tags.filter((row) => row.every((t) => t.validate !== undefined))
26
+ .length === 0,
27
+ )) ||
28
+ (props.metadata.natives.length !== 0 &&
29
+ props.metadata.natives.some((native) => native.name === "String"))
30
+ )
31
+ return ts.factory.createTrue();
32
+
33
+ const conditions: ts.Expression[] = [];
34
+
35
+ // NULLISH COALESCING
36
+ if (props.metadata.nullable === true)
37
+ conditions.push(
38
+ ts.factory.createStrictEquality(
39
+ ts.factory.createStringLiteral("null"),
40
+ props.input,
41
+ ),
42
+ );
43
+ if (props.metadata.isRequired() === false)
44
+ conditions.push(
45
+ ts.factory.createStrictEquality(
46
+ ts.factory.createStringLiteral("undefined"),
47
+ props.input,
48
+ ),
49
+ );
50
+
51
+ // ATOMICS
52
+ for (const atom of props.metadata.atomics)
53
+ if (atom.type === "boolean")
54
+ conditions.push(
55
+ ts.factory.createLogicalOr(
56
+ ts.factory.createStrictEquality(
57
+ ts.factory.createStringLiteral("false"),
58
+ props.input,
59
+ ),
60
+ ts.factory.createStrictEquality(
61
+ ts.factory.createStringLiteral("true"),
62
+ props.input,
63
+ ),
64
+ ),
65
+ );
66
+ else if (atom.type === "bigint")
67
+ conditions.push(
68
+ ts.factory.createLogicalAnd(
69
+ ts.factory.createCallExpression(
70
+ props.context.importer.internal("isBigintString"),
71
+ undefined,
72
+ [props.input],
73
+ ),
74
+ atomist(
75
+ check_bigint({
76
+ context: props.context,
77
+ atomic: atom,
78
+ input: ts.factory.createCallExpression(
79
+ ts.factory.createIdentifier("BigInt"),
80
+ undefined,
81
+ [props.input],
82
+ ),
83
+ }),
84
+ ),
85
+ ),
86
+ );
87
+ else if (atom.type === "number")
88
+ conditions.push(
89
+ atomist(
90
+ check_number({
91
+ context: props.context,
92
+ numeric: true,
93
+ atomic: atom,
94
+ input: ts.factory.createCallExpression(
95
+ ts.factory.createIdentifier("Number"),
96
+ undefined,
97
+ [props.input],
98
+ ),
99
+ }),
100
+ ),
101
+ );
102
+ else
103
+ conditions.push(
104
+ atomist(
105
+ check_string({
106
+ context: props.context,
107
+ atomic: atom,
108
+ input: props.input,
109
+ }),
110
+ ),
111
+ );
112
+
113
+ // CONSTANTS
114
+ for (const constant of props.metadata.constants)
115
+ for (const { value } of constant.values)
116
+ conditions.push(
117
+ ts.factory.createStrictEquality(
118
+ ts.factory.createStringLiteral(String(value)),
119
+ props.input,
120
+ ),
121
+ );
122
+
123
+ // TEMPLATES
124
+ if (!!props.metadata.templates.length)
125
+ conditions.push(
126
+ atomist(
127
+ check_template({
128
+ templates: props.metadata.templates,
129
+ input: props.input,
130
+ }),
131
+ ),
132
+ );
133
+
134
+ // NATIVES
135
+ for (const native of props.metadata.natives)
136
+ if (native.name === "Boolean")
137
+ conditions.push(
138
+ ts.factory.createLogicalOr(
139
+ ts.factory.createStrictEquality(
140
+ ts.factory.createStringLiteral("false"),
141
+ props.input,
142
+ ),
143
+ ts.factory.createStrictEquality(
144
+ ts.factory.createStringLiteral("true"),
145
+ props.input,
146
+ ),
147
+ ),
148
+ );
149
+ else if (native.name === "BigInt")
150
+ conditions.push(
151
+ ts.factory.createCallExpression(
152
+ props.context.importer.internal("isBigintString"),
153
+ undefined,
154
+ [props.input],
155
+ ),
156
+ );
157
+ else if (native.name === "Number")
158
+ conditions.push(
159
+ ts.factory.createStrictEquality(
160
+ ts.factory.createFalse(),
161
+ ts.factory.createCallExpression(
162
+ ts.factory.createIdentifier("Number.isNaN"),
163
+ undefined,
164
+ [
165
+ ts.factory.createCallExpression(
166
+ ts.factory.createIdentifier("Number"),
167
+ undefined,
168
+ [props.input],
169
+ ),
170
+ ],
171
+ ),
172
+ ),
173
+ );
174
+
175
+ return conditions.length === 0
176
+ ? ts.factory.createTrue()
177
+ : conditions.length === 1
178
+ ? conditions[0]!
179
+ : conditions.reduce(ts.factory.createLogicalOr);
180
+ };
181
+
182
+ /** @internal */
183
+ const atomist = (entry: ICheckEntry) =>
184
+ [
185
+ ...(entry.expression ? [entry.expression] : []),
186
+ ...(entry.conditions.length === 0
187
+ ? []
188
+ : [
189
+ entry.conditions
190
+ .map((set) =>
191
+ set
192
+ .map((s) => s.expression)
193
+ .reduce((a, b) => ts.factory.createLogicalAnd(a, b)),
194
+ )
195
+ .reduce((a, b) => ts.factory.createLogicalOr(a, b)),
196
+ ]),
197
+ ].reduce((x, y) => ts.factory.createLogicalAnd(x, y));