@fncts/schema 0.0.5 → 0.0.7

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/AST.d.ts +528 -0
  2. package/ASTAnnotation.d.ts +82 -0
  3. package/ASTAnnotationMap.d.ts +14 -0
  4. package/Gen.d.ts +15 -0
  5. package/InvalidInterpretationError.d.ts +5 -0
  6. package/ParseError.d.ts +107 -0
  7. package/ParseResult.d.ts +24 -0
  8. package/Parser/api.d.ts +42 -0
  9. package/Parser/definition.d.ts +22 -0
  10. package/Parser/interpreter.d.ts +6 -0
  11. package/Parser.d.ts +3 -0
  12. package/Schema/api/conc.d.ts +18 -0
  13. package/Schema/api/either.d.ts +19 -0
  14. package/Schema/api/hashMap.d.ts +21 -0
  15. package/Schema/api/immutableArray.d.ts +23 -0
  16. package/Schema/api/list.d.ts +23 -0
  17. package/Schema/api/maybe.d.ts +21 -0
  18. package/Schema/api.d.ts +243 -0
  19. package/Schema/definition.d.ts +29 -0
  20. package/Schema/derivations.d.ts +70 -0
  21. package/Schema.d.ts +9 -144
  22. package/_cjs/AST.cjs +1172 -0
  23. package/_cjs/AST.cjs.map +1 -0
  24. package/_cjs/ASTAnnotation.cjs +111 -0
  25. package/_cjs/ASTAnnotation.cjs.map +1 -0
  26. package/_cjs/ASTAnnotationMap.cjs +35 -0
  27. package/_cjs/ASTAnnotationMap.cjs.map +1 -0
  28. package/_cjs/Gen.cjs +182 -0
  29. package/_cjs/Gen.cjs.map +1 -0
  30. package/_cjs/InvalidInterpretationError.cjs +18 -0
  31. package/_cjs/InvalidInterpretationError.cjs.map +1 -0
  32. package/_cjs/ParseError.cjs +223 -0
  33. package/_cjs/ParseError.cjs.map +1 -0
  34. package/_cjs/{Decoder.cjs → ParseResult.cjs} +25 -22
  35. package/_cjs/ParseResult.cjs.map +1 -0
  36. package/_cjs/Parser/api.cjs +80 -0
  37. package/_cjs/Parser/api.cjs.map +1 -0
  38. package/_cjs/{Guard.cjs → Parser/definition.cjs} +17 -22
  39. package/_cjs/Parser/definition.cjs.map +1 -0
  40. package/_cjs/Parser/interpreter.cjs +410 -0
  41. package/_cjs/Parser/interpreter.cjs.map +1 -0
  42. package/_cjs/Parser.cjs +39 -0
  43. package/_cjs/Parser.cjs.map +1 -0
  44. package/_cjs/Schema/api/conc.cjs +84 -0
  45. package/_cjs/Schema/api/conc.cjs.map +1 -0
  46. package/_cjs/Schema/api/either.cjs +96 -0
  47. package/_cjs/Schema/api/either.cjs.map +1 -0
  48. package/_cjs/Schema/api/hashMap.cjs +161 -0
  49. package/_cjs/Schema/api/hashMap.cjs.map +1 -0
  50. package/_cjs/Schema/api/immutableArray.cjs +90 -0
  51. package/_cjs/Schema/api/immutableArray.cjs.map +1 -0
  52. package/_cjs/Schema/api/list.cjs +98 -0
  53. package/_cjs/Schema/api/list.cjs.map +1 -0
  54. package/_cjs/Schema/api/maybe.cjs +76 -0
  55. package/_cjs/Schema/api/maybe.cjs.map +1 -0
  56. package/_cjs/Schema/api.cjs +425 -0
  57. package/_cjs/Schema/api.cjs.map +1 -0
  58. package/_cjs/Schema/definition.cjs +26 -0
  59. package/_cjs/Schema/definition.cjs.map +1 -0
  60. package/_cjs/Schema/derivations.cjs +108 -0
  61. package/_cjs/Schema/derivations.cjs.map +1 -0
  62. package/_cjs/Schema.cjs +97 -237
  63. package/_cjs/Schema.cjs.map +1 -1
  64. package/_cjs/utils.cjs +52 -0
  65. package/_cjs/utils.cjs.map +1 -0
  66. package/_mjs/AST.mjs +1061 -0
  67. package/_mjs/AST.mjs.map +1 -0
  68. package/_mjs/ASTAnnotation.mjs +80 -0
  69. package/_mjs/ASTAnnotation.mjs.map +1 -0
  70. package/_mjs/ASTAnnotationMap.mjs +27 -0
  71. package/_mjs/ASTAnnotationMap.mjs.map +1 -0
  72. package/_mjs/Gen.mjs +173 -0
  73. package/_mjs/Gen.mjs.map +1 -0
  74. package/_mjs/InvalidInterpretationError.mjs +10 -0
  75. package/_mjs/InvalidInterpretationError.mjs.map +1 -0
  76. package/_mjs/ParseError.mjs +201 -0
  77. package/_mjs/ParseError.mjs.map +1 -0
  78. package/_mjs/ParseResult.mjs +22 -0
  79. package/_mjs/ParseResult.mjs.map +1 -0
  80. package/_mjs/Parser/api.mjs +67 -0
  81. package/_mjs/Parser/api.mjs.map +1 -0
  82. package/_mjs/Parser/definition.mjs +15 -0
  83. package/_mjs/Parser/definition.mjs.map +1 -0
  84. package/_mjs/Parser/interpreter.mjs +402 -0
  85. package/_mjs/Parser/interpreter.mjs.map +1 -0
  86. package/_mjs/Parser.mjs +5 -0
  87. package/_mjs/Parser.mjs.map +1 -0
  88. package/_mjs/Schema/api/conc.mjs +72 -0
  89. package/_mjs/Schema/api/conc.mjs.map +1 -0
  90. package/_mjs/Schema/api/either.mjs +85 -0
  91. package/_mjs/Schema/api/either.mjs.map +1 -0
  92. package/_mjs/Schema/api/hashMap.mjs +150 -0
  93. package/_mjs/Schema/api/hashMap.mjs.map +1 -0
  94. package/_mjs/Schema/api/immutableArray.mjs +79 -0
  95. package/_mjs/Schema/api/immutableArray.mjs.map +1 -0
  96. package/_mjs/Schema/api/list.mjs +87 -0
  97. package/_mjs/Schema/api/list.mjs.map +1 -0
  98. package/_mjs/Schema/api/maybe.mjs +65 -0
  99. package/_mjs/Schema/api/maybe.mjs.map +1 -0
  100. package/_mjs/Schema/api.mjs +368 -0
  101. package/_mjs/Schema/api.mjs.map +1 -0
  102. package/_mjs/Schema/definition.mjs +16 -0
  103. package/_mjs/Schema/definition.mjs.map +1 -0
  104. package/_mjs/Schema/derivations.mjs +94 -0
  105. package/_mjs/Schema/derivations.mjs.map +1 -0
  106. package/_mjs/Schema.mjs +12 -212
  107. package/_mjs/Schema.mjs.map +1 -1
  108. package/_mjs/utils.mjs +41 -0
  109. package/_mjs/utils.mjs.map +1 -0
  110. package/_src/AST.ts +1353 -0
  111. package/_src/ASTAnnotation.ts +98 -0
  112. package/_src/ASTAnnotationMap.ts +38 -0
  113. package/_src/Gen.ts +168 -0
  114. package/_src/InvalidInterpretationError.ts +6 -0
  115. package/_src/ParseError.ts +237 -0
  116. package/_src/ParseResult.ts +26 -0
  117. package/_src/Parser/api.ts +71 -0
  118. package/_src/Parser/definition.ts +24 -0
  119. package/_src/Parser/interpreter.ts +442 -0
  120. package/_src/Parser.ts +5 -0
  121. package/_src/Schema/api/conc.ts +78 -0
  122. package/_src/Schema/api/either.ts +96 -0
  123. package/_src/Schema/api/hashMap.ts +184 -0
  124. package/_src/Schema/api/immutableArray.ts +88 -0
  125. package/_src/Schema/api/list.ts +96 -0
  126. package/_src/Schema/api/maybe.ts +68 -0
  127. package/_src/Schema/api.ts +530 -0
  128. package/_src/Schema/definition.ts +32 -0
  129. package/_src/Schema/derivations.ts +185 -0
  130. package/_src/Schema.ts +14 -254
  131. package/_src/global.ts +53 -0
  132. package/_src/utils.ts +48 -0
  133. package/global.d.ts +52 -0
  134. package/package.json +2 -2
  135. package/utils.d.ts +8 -0
  136. package/Decoder.d.ts +0 -3
  137. package/Encoder.d.ts +0 -4
  138. package/Guard.d.ts +0 -3
  139. package/Schemable.d.ts +0 -39
  140. package/_cjs/Decoder.cjs.map +0 -1
  141. package/_cjs/Encoder.cjs +0 -45
  142. package/_cjs/Encoder.cjs.map +0 -1
  143. package/_cjs/Guard.cjs.map +0 -1
  144. package/_cjs/Schemable.cjs +0 -6
  145. package/_cjs/Schemable.cjs.map +0 -1
  146. package/_mjs/Decoder.mjs +0 -20
  147. package/_mjs/Decoder.mjs.map +0 -1
  148. package/_mjs/Encoder.mjs +0 -36
  149. package/_mjs/Encoder.mjs.map +0 -1
  150. package/_mjs/Guard.mjs +0 -20
  151. package/_mjs/Guard.mjs.map +0 -1
  152. package/_mjs/Schemable.mjs +0 -2
  153. package/_mjs/Schemable.mjs.map +0 -1
  154. package/_src/Decoder.ts +0 -20
  155. package/_src/Encoder.ts +0 -38
  156. package/_src/Guard.ts +0 -20
  157. package/_src/Schemable.ts +0 -46
package/_mjs/AST.mjs ADDED
@@ -0,0 +1,1061 @@
1
+ var _a;
2
+ const fileName_1 = "(@fncts/schema) src/AST.ts";
3
+ import * as tsplus_module_1 from "@fncts/schema/ASTAnnotation";
4
+ import * as tsplus_module_2 from "@fncts/base/collection/immutable/Vector/api";
5
+ import * as tsplus_module_3 from "@fncts/base/data/number/instances";
6
+ import * as tsplus_module_4 from "@fncts/base/data/Ord/api/contramap";
7
+ import * as tsplus_module_5 from "@fncts/base/data/Maybe/definition";
8
+ import * as tsplus_module_6 from "@fncts/base/data/Maybe/constructors";
9
+ import * as tsplus_module_7 from "@fncts/base/data/Maybe/destructors";
10
+ import * as tsplus_module_8 from "@fncts/base/collection/immutable/Vector/internal";
11
+ import * as tsplus_module_9 from "@fncts/base/data/Maybe/api";
12
+ export const createDeclaration = createDeclaration_1;
13
+ export const createLiteral = createLiteral_1;
14
+ export const isLiteral = isLiteral_1;
15
+ export const createUniqueSymbol = createUniqueSymbol_1;
16
+ export const isUniqueSymbol = isUniqueSymbol_1;
17
+ export const isStringKeyword = isStringKeyword_1;
18
+ export const isNumberKeyword = isNumberKeyword_1;
19
+ export const isSymbolKeyword = isSymbolKeyword_1;
20
+ export const createTemplateLiteral = createTemplateLiteral_1;
21
+ export const createElement = createElement_1;
22
+ export const createTuple = createTuple_1;
23
+ export const createPropertySignature = createPropertySignature_1;
24
+ export const createIndexSignature = createIndexSignature_1;
25
+ export const createTypeLiteral = createTypeLiteral_1;
26
+ export const createUnion = createUnion_1;
27
+ export const createLazy = createLazy_1;
28
+ export const createRefinement = createRefinement_1;
29
+ export const createTransform = createTransform_1;
30
+ export const getPropertySignatures = getPropertySignatures_1;
31
+ export const keysOf = keysOf_1;
32
+ export const partial = partial_1;
33
+ export const getFrom = getFrom_1;
34
+ export const getTo = getTo_1;
35
+ export const reverse = reverse_1;
36
+ import { show } from "@fncts/base/data/Showable";
37
+ import { memoize } from "@fncts/schema/utils";
38
+ import { ASTAnnotationMap } from "./ASTAnnotationMap.mjs";
39
+ export const ASTTypeId = /*#__PURE__*/Symbol.for("fncts.schema.AST");
40
+ export class Annotated {
41
+ constructor() {
42
+ this.annotations = ASTAnnotationMap.empty;
43
+ }
44
+ }
45
+ /**
46
+ * @tsplus type fncts.schema.AST
47
+ * @tsplus companion fncts.schema.ASTOps
48
+ */
49
+ export class AST extends Annotated {
50
+ constructor() {
51
+ super(...arguments);
52
+ this[_a] = ASTTypeId;
53
+ }
54
+ }
55
+ _a = ASTTypeId;
56
+ /**
57
+ * @tsplus static fncts.schema.ASTOps concrete
58
+ * @tsplus macro remove
59
+ */
60
+ export function concrete(_) {
61
+ //
62
+ }
63
+ export function getAnnotations(key) {
64
+ return self => {
65
+ return self.annotations.get(key);
66
+ };
67
+ }
68
+ /*
69
+ * Declaration
70
+ */
71
+ export class Declaration extends AST {
72
+ constructor(typeParameters, type, decode, annotations = ASTAnnotationMap.empty) {
73
+ super();
74
+ this.typeParameters = typeParameters;
75
+ this.type = type;
76
+ this.decode = decode;
77
+ this.annotations = annotations;
78
+ this._tag = 0 /* ASTTag.Declaration */;
79
+ }
80
+
81
+ clone(newProperties) {
82
+ return new Declaration(newProperties.typeParameters ?? this.typeParameters, newProperties.type ?? this.type, newProperties.decode ?? this.decode, newProperties.annotations ?? this.annotations);
83
+ }
84
+ }
85
+ /**
86
+ * @tsplus static fncts.schema.ASTOps createDeclaration
87
+ */
88
+ function createDeclaration_1(typeParameters, type, decode, annotations = ASTAnnotationMap.empty) {
89
+ return new Declaration(typeParameters, type, decode, annotations);
90
+ }
91
+ /**
92
+ * @tsplus fluent fncts.schema.AST isDeclaration
93
+ */
94
+ export function isDeclaration(self) {
95
+ void 0;
96
+ return self._tag === 0 /* ASTTag.Declaration */;
97
+ }
98
+
99
+ export class Literal extends AST {
100
+ constructor(literal, annotations = ASTAnnotationMap.empty) {
101
+ super();
102
+ this.literal = literal;
103
+ this.annotations = annotations;
104
+ this._tag = 1 /* ASTTag.Literal */;
105
+ }
106
+
107
+ clone(newProperties) {
108
+ return new Literal(newProperties.literal ?? this.literal, newProperties.annotations ?? this.annotations);
109
+ }
110
+ }
111
+ /**
112
+ * @tsplus static fncts.schema.ASTOps createLiteral
113
+ */
114
+ function createLiteral_1(literal, annotations = ASTAnnotationMap.empty) {
115
+ return new Literal(literal, annotations);
116
+ }
117
+ /**
118
+ * @tsplus fluent fncts.schema.AST isLiteral
119
+ */
120
+ function isLiteral_1(self) {
121
+ void 0;
122
+ return self._tag === 1 /* ASTTag.Literal */;
123
+ }
124
+ /*
125
+ * UniqueSymbol
126
+ */
127
+ export class UniqueSymbol extends AST {
128
+ constructor(symbol, annotations = ASTAnnotationMap.empty) {
129
+ super();
130
+ this.symbol = symbol;
131
+ this.annotations = annotations;
132
+ this._tag = 2 /* ASTTag.UniqueSymbol */;
133
+ }
134
+
135
+ clone(newProperties) {
136
+ return new UniqueSymbol(newProperties.symbol ?? this.symbol, newProperties.annotations ?? this.annotations);
137
+ }
138
+ }
139
+ /**
140
+ * @tsplus static fncts.schema.ASTOps createUniqueSymbol
141
+ */
142
+ function createUniqueSymbol_1(symbol, annotations = ASTAnnotationMap.empty) {
143
+ return new UniqueSymbol(symbol, annotations);
144
+ }
145
+ /**
146
+ * @tsplus fluent fncts.schema.AST isUniqueSymbol
147
+ */
148
+ function isUniqueSymbol_1(self) {
149
+ void 0;
150
+ return self._tag === 2 /* ASTTag.UniqueSymbol */;
151
+ }
152
+ /*
153
+ * UndefinedKeyword
154
+ */
155
+ export class UndefinedKeyword extends AST {
156
+ constructor(annotations = ASTAnnotationMap.empty) {
157
+ super();
158
+ this.annotations = annotations;
159
+ this._tag = 3 /* ASTTag.UndefinedKeyword */;
160
+ }
161
+
162
+ clone(newProperties) {
163
+ return new UndefinedKeyword(newProperties.annotations ?? this.annotations);
164
+ }
165
+ }
166
+ /**
167
+ * @tsplus static fncts.schema.ASTOps undefinedKeyword
168
+ */
169
+ const undefinedKeyword_1 = /*#__PURE__*/new UndefinedKeyword( /*#__PURE__*/ASTAnnotationMap.empty.annotate(tsplus_module_1.Title, "undefined"));
170
+ export const undefinedKeyword = undefinedKeyword_1;
171
+ /*
172
+ * VoidKeyword
173
+ */
174
+ export class VoidKeyword extends AST {
175
+ constructor(annotations = ASTAnnotationMap.empty) {
176
+ super();
177
+ this.annotations = annotations;
178
+ this._tag = 4 /* ASTTag.VoidKeyword */;
179
+ }
180
+
181
+ clone(newProperties) {
182
+ return new VoidKeyword(newProperties.annotations ?? this.annotations);
183
+ }
184
+ }
185
+ /**
186
+ * @tsplus static fncts.schema.ASTOps voidKeyword
187
+ */
188
+ export const voidKeyword = /*#__PURE__*/new VoidKeyword( /*#__PURE__*/ASTAnnotationMap.empty.annotate(tsplus_module_1.Title, "void"));
189
+ /*
190
+ * NeverKeyword
191
+ */
192
+ export class NeverKeyword extends AST {
193
+ constructor(annotations = ASTAnnotationMap.empty) {
194
+ super();
195
+ this.annotations = annotations;
196
+ this._tag = 5 /* ASTTag.NeverKeyword */;
197
+ }
198
+
199
+ clone(newProperties) {
200
+ return new NeverKeyword(newProperties.annotations ?? this.annotations);
201
+ }
202
+ }
203
+ /**
204
+ * @tsplus static fncts.schema.ASTOps neverKeyword
205
+ */
206
+ const neverKeyword_1 = /*#__PURE__*/new NeverKeyword( /*#__PURE__*/ASTAnnotationMap.empty.annotate(tsplus_module_1.Title, "never"));
207
+ export const neverKeyword = neverKeyword_1;
208
+ /*
209
+ * UnknownKeyword
210
+ */
211
+ export class UnknownKeyword extends AST {
212
+ constructor(annotations = ASTAnnotationMap.empty) {
213
+ super();
214
+ this.annotations = annotations;
215
+ this._tag = 6 /* ASTTag.UnknownKeyword */;
216
+ }
217
+
218
+ clone(newProperties) {
219
+ return new UnknownKeyword(newProperties.annotations ?? this.annotations);
220
+ }
221
+ }
222
+ /**
223
+ * @tsplus static fncts.schema.ASTOps unknownKeyword
224
+ */
225
+ export const unknownKeyword = /*#__PURE__*/new UnknownKeyword( /*#__PURE__*/ASTAnnotationMap.empty.annotate(tsplus_module_1.Title, "unknown"));
226
+ /*
227
+ * AnyKeyword
228
+ */
229
+ export class AnyKeyword extends AST {
230
+ constructor(annotations = ASTAnnotationMap.empty) {
231
+ super();
232
+ this.annotations = annotations;
233
+ this._tag = 7 /* ASTTag.AnyKeyword */;
234
+ }
235
+
236
+ clone(newProperties) {
237
+ return new AnyKeyword(newProperties.annotations ?? this.annotations);
238
+ }
239
+ }
240
+ /**
241
+ * @tsplus static fncts.schema.ASTOps anyKeyword
242
+ */
243
+ export const anyKeyword = /*#__PURE__*/new AnyKeyword( /*#__PURE__*/ASTAnnotationMap.empty.annotate(tsplus_module_1.Title, "any"));
244
+ /*
245
+ * StringKeyword
246
+ */
247
+ export class StringKeyword extends AST {
248
+ constructor(annotations = ASTAnnotationMap.empty) {
249
+ super();
250
+ this.annotations = annotations;
251
+ this._tag = 8 /* ASTTag.StringKeyword */;
252
+ }
253
+
254
+ clone(newProperties) {
255
+ return new StringKeyword(newProperties.annotations ?? this.annotations);
256
+ }
257
+ }
258
+ /**
259
+ * @tsplus static fncts.schema.ASTOps stringKeyword
260
+ */
261
+ const stringKeyword_1 = /*#__PURE__*/new StringKeyword( /*#__PURE__*/ASTAnnotationMap.empty.annotate(tsplus_module_1.Title, "string"));
262
+ export const stringKeyword = stringKeyword_1;
263
+ /**
264
+ * @tsplus fluent fncts.schema.AST isStringKeyword
265
+ */
266
+ function isStringKeyword_1(self) {
267
+ void 0;
268
+ return self._tag === 8 /* ASTTag.StringKeyword */;
269
+ }
270
+ /*
271
+ * NumberKeyword
272
+ */
273
+ export class NumberKeyword extends AST {
274
+ constructor(annotations = ASTAnnotationMap.empty) {
275
+ super();
276
+ this.annotations = annotations;
277
+ this._tag = 9 /* ASTTag.NumberKeyword */;
278
+ }
279
+
280
+ clone(newProperties) {
281
+ return new NumberKeyword(newProperties.annotations ?? this.annotations);
282
+ }
283
+ }
284
+ /**
285
+ * @tsplus static fncts.schema.ASTOps numberKeyword
286
+ */
287
+ const numberKeyword_1 = /*#__PURE__*/new NumberKeyword( /*#__PURE__*/ASTAnnotationMap.empty.annotate(tsplus_module_1.Title, "number"));
288
+ export const numberKeyword = numberKeyword_1;
289
+ /**
290
+ * @tsplus fluent fncts.schema.AST isNumberKeyword
291
+ */
292
+ function isNumberKeyword_1(self) {
293
+ void 0;
294
+ return self._tag === 9 /* ASTTag.NumberKeyword */;
295
+ }
296
+ /*
297
+ * BooleanKeyword
298
+ */
299
+ export class BooleanKeyword extends AST {
300
+ constructor(annotations = ASTAnnotationMap.empty) {
301
+ super();
302
+ this.annotations = annotations;
303
+ this._tag = 10 /* ASTTag.BooleanKeyword */;
304
+ }
305
+
306
+ clone(newProperties) {
307
+ return new BooleanKeyword(newProperties.annotations ?? this.annotations);
308
+ }
309
+ }
310
+ /**
311
+ * @tsplus static fncts.schema.ASTOps booleanKeyword
312
+ */
313
+ export const booleanKeyword = /*#__PURE__*/new BooleanKeyword( /*#__PURE__*/ASTAnnotationMap.empty.annotate(tsplus_module_1.Title, "boolean"));
314
+ /**
315
+ * @tsplus fluent fncts.schema.AST isBooleanKeyword
316
+ */
317
+ export function isBooleanKeyword(self) {
318
+ void 0;
319
+ return self._tag === 10 /* ASTTag.BooleanKeyword */;
320
+ }
321
+ /*
322
+ * BigIntKeyword
323
+ */
324
+ export class BigIntKeyword extends AST {
325
+ constructor(annotations = ASTAnnotationMap.empty) {
326
+ super();
327
+ this.annotations = annotations;
328
+ this._tag = 11 /* ASTTag.BigIntKeyword */;
329
+ }
330
+
331
+ clone(newProperties) {
332
+ return new BigIntKeyword(newProperties.annotations ?? this.annotations);
333
+ }
334
+ }
335
+ /**
336
+ * @tsplus static fncts.schema.ASTOps bigIntKeyword
337
+ */
338
+ export const bigIntKeyword = /*#__PURE__*/new BigIntKeyword( /*#__PURE__*/ASTAnnotationMap.empty.annotate(tsplus_module_1.Title, "bigint"));
339
+ /**
340
+ * @tsplus fluent fncts.schema.AST isBigIntKeyword
341
+ */
342
+ export function isBigIntKeyword(self) {
343
+ void 0;
344
+ return self._tag === 11 /* ASTTag.BigIntKeyword */;
345
+ }
346
+ /*
347
+ * SymbolKeyword
348
+ */
349
+ export class SymbolKeyword extends AST {
350
+ constructor(annotations = ASTAnnotationMap.empty) {
351
+ super();
352
+ this.annotations = annotations;
353
+ this._tag = 12 /* ASTTag.SymbolKeyword */;
354
+ }
355
+
356
+ clone(newProperties) {
357
+ return new SymbolKeyword(newProperties.annotations ?? this.annotations);
358
+ }
359
+ }
360
+ /**
361
+ * @tsplus static fncts.schema.ASTOps symbolKeyword
362
+ */
363
+ const symbolKeyword_1 = /*#__PURE__*/new SymbolKeyword( /*#__PURE__*/ASTAnnotationMap.empty.annotate(tsplus_module_1.Title, "symbol"));
364
+ export const symbolKeyword = symbolKeyword_1;
365
+ /**
366
+ * @tsplus fluent fncts.schema.AST isSymbolKeyword
367
+ */
368
+ function isSymbolKeyword_1(self) {
369
+ void 0;
370
+ return self._tag === 12 /* ASTTag.SymbolKeyword */;
371
+ }
372
+ /*
373
+ * ObjectKeyword
374
+ */
375
+ export class ObjectKeyword extends AST {
376
+ constructor(annotations = ASTAnnotationMap.empty) {
377
+ super();
378
+ this.annotations = annotations;
379
+ this._tag = 13 /* ASTTag.ObjectKeyword */;
380
+ }
381
+
382
+ clone(newProperties) {
383
+ return new ObjectKeyword(newProperties.annotations ?? this.annotations);
384
+ }
385
+ }
386
+ /**
387
+ * @tsplus static fncts.schema.ASTOps objectKeyword
388
+ */
389
+ export const objectKeyword = /*#__PURE__*/new ObjectKeyword( /*#__PURE__*/ASTAnnotationMap.empty.annotate(tsplus_module_1.Title, "object"));
390
+ /*
391
+ * Enum
392
+ */
393
+ export class Enum extends AST {
394
+ constructor(enums, annotations = ASTAnnotationMap.empty) {
395
+ super();
396
+ this.enums = enums;
397
+ this.annotations = annotations;
398
+ this._tag = 14 /* ASTTag.Enum */;
399
+ }
400
+
401
+ clone(newProperties) {
402
+ return new Enum(newProperties.enums ?? this.enums, newProperties.annotations ?? this.annotations);
403
+ }
404
+ }
405
+ /**
406
+ * @tsplus static fncts.schema.ASTOps createEnum
407
+ */
408
+ export function createEnum(enums, annotations = ASTAnnotationMap.empty) {
409
+ return new Enum(enums, annotations);
410
+ }
411
+ export class TemplateLiteralSpan {
412
+ constructor(type, literal) {
413
+ this.type = type;
414
+ this.literal = literal;
415
+ }
416
+ }
417
+ /*
418
+ * TemplateLiteral
419
+ */
420
+ export class TemplateLiteral extends AST {
421
+ constructor(head, spans, annotations = ASTAnnotationMap.empty) {
422
+ super();
423
+ this.head = head;
424
+ this.spans = spans;
425
+ this.annotations = annotations;
426
+ this._tag = 15 /* ASTTag.TemplateLiteral */;
427
+ }
428
+
429
+ clone(newProperties) {
430
+ return createTemplateLiteral_1(newProperties.head ?? this.head, newProperties.spans ?? this.spans, newProperties.annotations ?? this.annotations);
431
+ }
432
+ }
433
+ /**
434
+ * @tsplus static fncts.schema.ASTOps createTemplateLiteral
435
+ */
436
+ function createTemplateLiteral_1(head, spans, annotations = ASTAnnotationMap.empty) {
437
+ if (tsplus_module_2.isNonEmpty(spans)) {
438
+ return new TemplateLiteral(head, spans, annotations);
439
+ } else {
440
+ return createLiteral_1(head, annotations);
441
+ }
442
+ }
443
+ /*
444
+ * Element
445
+ */
446
+ export class Element {
447
+ constructor(type, isOptional) {
448
+ this.type = type;
449
+ this.isOptional = isOptional;
450
+ }
451
+ }
452
+ /**
453
+ * @tsplus static fncts.schema.ASTOps createElement
454
+ */
455
+ function createElement_1(type, isOptional) {
456
+ return new Element(type, isOptional);
457
+ }
458
+ /*
459
+ * Tuple
460
+ */
461
+ export class Tuple extends AST {
462
+ constructor(elements, rest, isReadonly, annotations = ASTAnnotationMap.empty) {
463
+ super();
464
+ this.elements = elements;
465
+ this.rest = rest;
466
+ this.isReadonly = isReadonly;
467
+ this.annotations = annotations;
468
+ this._tag = 16 /* ASTTag.Tuple */;
469
+ }
470
+
471
+ clone(newProperties) {
472
+ return new Tuple(newProperties.elements ?? this.elements, newProperties.rest ?? this.rest, newProperties.isReadonly ?? this.isReadonly, newProperties.annotations ?? this.annotations);
473
+ }
474
+ }
475
+ /**
476
+ * @tsplus static fncts.schema.ASTOps createTuple
477
+ */
478
+ function createTuple_1(elements, rest, isReadonly, annotations = ASTAnnotationMap.empty) {
479
+ return new Tuple(elements, rest, isReadonly, annotations);
480
+ }
481
+ /*
482
+ * PropertySignature
483
+ */
484
+ export class PropertySignature extends AST {
485
+ constructor(name, type, isOptional, isReadonly, annotations = ASTAnnotationMap.empty) {
486
+ super();
487
+ this.name = name;
488
+ this.type = type;
489
+ this.isOptional = isOptional;
490
+ this.isReadonly = isReadonly;
491
+ this.annotations = annotations;
492
+ }
493
+ clone(newProperties) {
494
+ return new PropertySignature(newProperties.name ?? this.name, newProperties.type ?? this.type, newProperties.isOptional ?? this.isOptional, newProperties.isReadonly ?? this.isReadonly, newProperties.annotations ?? this.annotations);
495
+ }
496
+ }
497
+ /**
498
+ * @tsplus static fncts.schema.ASTOps createPropertySignature
499
+ */
500
+ function createPropertySignature_1(name, type, isOptional, isReadonly, annotations = ASTAnnotationMap.empty) {
501
+ return new PropertySignature(name, type, isOptional, isReadonly, annotations);
502
+ }
503
+ /*
504
+ * IndexSignature
505
+ */
506
+ export class IndexSignature {
507
+ constructor(parameter, type, isReadonly) {
508
+ this.parameter = parameter;
509
+ this.type = type;
510
+ this.isReadonly = isReadonly;
511
+ }
512
+ }
513
+ /**
514
+ * @tsplus static fncts.schema.ASTOps createIndexSignature
515
+ */
516
+ function createIndexSignature_1(parameter, type, isReadonly) {
517
+ return new IndexSignature(parameter, type, isReadonly);
518
+ }
519
+ /*
520
+ * TypeLiteral
521
+ */
522
+ export class TypeLiteral extends AST {
523
+ constructor(propertySignatures, indexSignatures, annotations = ASTAnnotationMap.empty) {
524
+ super();
525
+ this.annotations = annotations;
526
+ this._tag = 17 /* ASTTag.TypeLiteral */;
527
+ this.propertySignatures = sortByAscendingCardinality(propertySignatures);
528
+ this.indexSignatures = sortByAscendingCardinality(indexSignatures);
529
+ }
530
+ clone(newProperties) {
531
+ return new TypeLiteral(newProperties.propertySignatures ?? this.propertySignatures, newProperties.indexSignatures ?? this.indexSignatures, newProperties.annotations ?? this.annotations);
532
+ }
533
+ }
534
+ /**
535
+ * @tsplus static fncts.schema.ASTOps isTypeLiteral
536
+ * @tsplus fluent fncts.schema.AST isTypeLiteral
537
+ */
538
+ export function isTypeLiteral(self) {
539
+ void 0;
540
+ return self._tag === 17 /* ASTTag.TypeLiteral */;
541
+ }
542
+ /**
543
+ * @tsplus static fncts.schema.ASTOps createTypeLiteral
544
+ */
545
+ function createTypeLiteral_1(propertySignatures, indexSignatures, annotations) {
546
+ return new TypeLiteral(propertySignatures, indexSignatures, annotations);
547
+ }
548
+ /*
549
+ * Union
550
+ */
551
+ export class Union extends AST {
552
+ constructor(types, annotations = ASTAnnotationMap.empty) {
553
+ super();
554
+ this.types = types;
555
+ this.annotations = annotations;
556
+ this._tag = 18 /* ASTTag.Union */;
557
+ }
558
+
559
+ clone(newProperties) {
560
+ return createUnion_1(newProperties.types ?? this.types, newProperties.annotations ?? this.annotations);
561
+ }
562
+ }
563
+ /**
564
+ * @tsplus fluent fncts.schema.AST isUnion
565
+ */
566
+ export function isUnion(self) {
567
+ void 0;
568
+ return self._tag === 18 /* ASTTag.Union */;
569
+ }
570
+ /**
571
+ * @tsplus static fncts.schema.ASTOps createUnion
572
+ */
573
+ function createUnion_1(candidates, annotations = ASTAnnotationMap.empty) {
574
+ const types = unify(candidates);
575
+ switch (types.length) {
576
+ case 0:
577
+ return neverKeyword_1;
578
+ case 1:
579
+ return tsplus_module_2.unsafeGet(0)(types);
580
+ default:
581
+ return new Union(sortByDescendingWeight(types), annotations);
582
+ }
583
+ }
584
+ /*
585
+ * Lazy
586
+ */
587
+ export class Lazy extends AST {
588
+ constructor(getAST, annotations = ASTAnnotationMap.empty) {
589
+ super();
590
+ this.getAST = getAST;
591
+ this.annotations = annotations;
592
+ this._tag = 19 /* ASTTag.Lazy */;
593
+ }
594
+
595
+ clone(newProperties) {
596
+ return new Lazy(newProperties.getAST ?? this.getAST, newProperties.annotations ?? this.annotations);
597
+ }
598
+ }
599
+ /**
600
+ * @tsplus static fncts.schema.ASTOps createLazy
601
+ */
602
+ function createLazy_1(getAST, annotations) {
603
+ return new Lazy(getAST, annotations);
604
+ }
605
+ /**
606
+ * @tsplus fluent fncts.schema.AST isLazy
607
+ */
608
+ export function isLazy(self) {
609
+ void 0;
610
+ return self._tag === 19 /* ASTTag.Lazy */;
611
+ }
612
+ /*
613
+ * Refinement
614
+ */
615
+ export class Refinement extends AST {
616
+ constructor(from, decode, isReversed, annotations = ASTAnnotationMap.empty) {
617
+ super();
618
+ this.from = from;
619
+ this.decode = decode;
620
+ this.isReversed = isReversed;
621
+ this.annotations = annotations;
622
+ this._tag = 20 /* ASTTag.Refinement */;
623
+ }
624
+
625
+ clone(newProperties) {
626
+ return new Refinement(newProperties.from ?? this.from, newProperties.decode ?? this.decode, newProperties.isReversed ?? this.isReversed, newProperties.annotations ?? this.annotations);
627
+ }
628
+ }
629
+ /**
630
+ * @tsplus static fncts.schema.ASTOps createRefinement
631
+ */
632
+ function createRefinement_1(from, decode, isReversed, annotations) {
633
+ return new Refinement(from, decode, isReversed, annotations);
634
+ }
635
+ export function isRefinement(self) {
636
+ void 0;
637
+ return self._tag === 20 /* ASTTag.Refinement */;
638
+ }
639
+ /*
640
+ * Transform
641
+ */
642
+ export class Transform extends AST {
643
+ constructor(from, to, decode, encode, isReversed, annotations = ASTAnnotationMap.empty) {
644
+ super();
645
+ this.from = from;
646
+ this.to = to;
647
+ this.decode = decode;
648
+ this.encode = encode;
649
+ this.isReversed = isReversed;
650
+ this.annotations = annotations;
651
+ this._tag = 21 /* ASTTag.Transform */;
652
+ }
653
+
654
+ clone(newProperties) {
655
+ return new Transform(newProperties.from ?? this.from, newProperties.to ?? this.to, newProperties.decode ?? this.decode, newProperties.encode ?? this.encode, newProperties.isReversed ?? this.isReversed, newProperties.annotations ?? this.annotations);
656
+ }
657
+ }
658
+ /**
659
+ * @tsplus static fncts.schema.ASTOps createTransform
660
+ */
661
+ function createTransform_1(from, to, decode, encode, isReversed, annotations) {
662
+ return new Transform(from, getTo_1(to), decode, encode, isReversed, annotations);
663
+ }
664
+ /*
665
+ * Validation
666
+ */
667
+ export class Validation extends AST {
668
+ constructor(from, validation, annotations = ASTAnnotationMap.empty) {
669
+ super();
670
+ this.from = from;
671
+ this.validation = validation;
672
+ this.annotations = annotations;
673
+ this._tag = 22 /* ASTTag.Validation */;
674
+ }
675
+
676
+ clone(newProperties) {
677
+ return new Validation(newProperties.from ?? this.from, newProperties.validation ?? this.validation, newProperties.annotations ?? this.annotations);
678
+ }
679
+ }
680
+ /**
681
+ * @tsplus static fncts.schema.ASTOps createValidation
682
+ */
683
+ export function createValidation(from, validation, annotations) {
684
+ return new Validation(from, validation, annotations);
685
+ }
686
+ /**
687
+ * @tsplus tailRec
688
+ */
689
+ export function getCardinality(ast) {
690
+ var ast_1 = ast;
691
+ var ast_2 = ast;
692
+ while (1) {
693
+ void 0;
694
+ switch (ast_1._tag) {
695
+ case 0 /* ASTTag.Declaration */:
696
+ ast_2 = ast_1.type;
697
+ ast_1 = ast_2;
698
+ continue;
699
+ case 5 /* ASTTag.NeverKeyword */:
700
+ return 0;
701
+ case 1 /* ASTTag.Literal */:
702
+ case 3 /* ASTTag.UndefinedKeyword */:
703
+ case 4 /* ASTTag.VoidKeyword */:
704
+ case 2 /* ASTTag.UniqueSymbol */:
705
+ return 1;
706
+ case 10 /* ASTTag.BooleanKeyword */:
707
+ return 2;
708
+ case 8 /* ASTTag.StringKeyword */:
709
+ case 9 /* ASTTag.NumberKeyword */:
710
+ case 11 /* ASTTag.BigIntKeyword */:
711
+ case 12 /* ASTTag.SymbolKeyword */:
712
+ return 3;
713
+ case 13 /* ASTTag.ObjectKeyword */:
714
+ return 4;
715
+ case 6 /* ASTTag.UnknownKeyword */:
716
+ case 7 /* ASTTag.AnyKeyword */:
717
+ return 6;
718
+ case 20 /* ASTTag.Refinement */:
719
+ ast_2 = ast_1.from;
720
+ ast_1 = ast_2;
721
+ continue;
722
+ case 21 /* ASTTag.Transform */:
723
+ ast_2 = ast_1.to;
724
+ ast_1 = ast_2;
725
+ continue;
726
+ default:
727
+ return 5;
728
+ }
729
+ }
730
+ }
731
+ function sortByAscendingCardinality(types) {
732
+ return tsplus_module_2.sort(tsplus_module_4.contramap(({
733
+ type
734
+ }) => getCardinality(type))(tsplus_module_3.Ord))(types);
735
+ }
736
+ export function getWeight(ast) {
737
+ void 0;
738
+ switch (ast._tag) {
739
+ case 0 /* ASTTag.Declaration */:
740
+ return getWeight(ast.type);
741
+ case 16 /* ASTTag.Tuple */:
742
+ return ast.elements.length + (tsplus_module_5.isJust(ast.rest) ? ast.rest.value.length : 0);
743
+ case 17 /* ASTTag.TypeLiteral */:
744
+ return ast.propertySignatures.length + ast.indexSignatures.length;
745
+ case 18 /* ASTTag.Union */:
746
+ return tsplus_module_2.foldLeft(0, (n, member) => n + getWeight(member))(ast.types);
747
+ case 19 /* ASTTag.Lazy */:
748
+ return 10;
749
+ case 20 /* ASTTag.Refinement */:
750
+ return getWeight(ast.from);
751
+ case 21 /* ASTTag.Transform */:
752
+ return getWeight(ast.to);
753
+ default:
754
+ return 0;
755
+ }
756
+ }
757
+ function sortByDescendingWeight(types) {
758
+ return tsplus_module_2.sort(tsplus_module_4.contramap(getWeight)(tsplus_module_3.Ord))(types);
759
+ }
760
+ function unify(candidates) {
761
+ let out = tsplus_module_2.flatMap(ast => {
762
+ void 0;
763
+ switch (ast._tag) {
764
+ case 5 /* ASTTag.NeverKeyword */:
765
+ return tsplus_module_2.empty();
766
+ case 18 /* ASTTag.Union */:
767
+ return ast.types;
768
+ default:
769
+ return tsplus_module_2.vector(ast);
770
+ }
771
+ })(candidates);
772
+ if (tsplus_module_2.some(isStringKeyword_1)(out)) {
773
+ out = tsplus_module_2.filter(m => !(isLiteral_1(m) && typeof m.literal === "string"))(out);
774
+ }
775
+ if (tsplus_module_2.some(isNumberKeyword_1)(out)) {
776
+ out = tsplus_module_2.filter(m => !(isLiteral_1(m) && typeof m.literal === "number"))(out);
777
+ }
778
+ if (tsplus_module_2.some(isSymbolKeyword_1)(out)) {
779
+ out = tsplus_module_2.filter(m => !isUniqueSymbol_1(m))(out);
780
+ }
781
+ return out;
782
+ }
783
+ /**
784
+ * @tsplus pipeable fncts.schema.AST combineAnnotations
785
+ */
786
+ export function combineAnnotations(annotations) {
787
+ return self => {
788
+ return self.clone({
789
+ annotations: self.annotations.combine(annotations)
790
+ });
791
+ };
792
+ }
793
+ /**
794
+ * @tsplus pipeable fncts.schema.AST setAnnotation
795
+ */
796
+ export function setAnnotation(annotation, value) {
797
+ return self => {
798
+ return self.clone({
799
+ annotations: self.annotations.annotate(annotation, value)
800
+ });
801
+ };
802
+ }
803
+ /**
804
+ * @tsplus pipeable fncts.schema.AST appendRestElement
805
+ */
806
+ export function appendRestElement(restElement) {
807
+ return self => {
808
+ if (tsplus_module_5.isJust(self.rest)) {
809
+ throw new Error("A rest element cannot follow another rest element. ts(1265)");
810
+ }
811
+ return createTuple_1(self.elements, tsplus_module_6.just(tsplus_module_2.vector(restElement), fileName_1 + ":1030:43"), self.isReadonly, self.annotations);
812
+ };
813
+ }
814
+ /**
815
+ * @tsplus pipeable fncts.schema.AST appendElement
816
+ */
817
+ export function appendElement(element) {
818
+ return self => {
819
+ if (tsplus_module_2.some(e => e.isOptional)(self.elements) && !element.isOptional) {
820
+ throw new Error("A required element cannot follow an optional element. ts(1257)");
821
+ }
822
+ return tsplus_module_7.match(() => createTuple_1(tsplus_module_2.append(element)(self.elements), tsplus_module_6.nothing(fileName_1 + ":1043:63"), self.isReadonly, self.annotations), rest => {
823
+ if (element.isOptional) {
824
+ throw new Error("A required element cannot follow an optional element. ts(1257)");
825
+ }
826
+ return createTuple_1(self.elements, tsplus_module_6.just(tsplus_module_2.append(element.type)(rest), fileName_1 + ":1048:47"), self.isReadonly, self.annotations);
827
+ })(self.rest);
828
+ };
829
+ }
830
+ export function getParameter(x) {
831
+ return isRefinement(x) ? getParameter(x.from) : x;
832
+ }
833
+ /**
834
+ * @tsplus getter fncts.schema.AST getPropertySignatures
835
+ */
836
+ function getPropertySignatures_1(self) {
837
+ void 0;
838
+ switch (self._tag) {
839
+ case 0 /* ASTTag.Declaration */:
840
+ return getPropertySignatures_1(self.type);
841
+ case 16 /* ASTTag.Tuple */:
842
+ return tsplus_module_2.mapWithIndex((i, element) => createPropertySignature_1(i, element.type, element.isOptional, self.isReadonly))(self.elements);
843
+ case 18 /* ASTTag.Union */:
844
+ {
845
+ const propertySignatures = tsplus_module_2.map(getPropertySignatures_1)(self.types);
846
+ return tsplus_module_2.filterMap(({
847
+ name
848
+ }) => {
849
+ if (tsplus_module_2.every(ps => tsplus_module_2.some(p => p.name === name)(ps))(propertySignatures)) {
850
+ const members = tsplus_module_2.flatMap(ps => tsplus_module_2.filter(p => p.name === name)(ps))(propertySignatures);
851
+ return tsplus_module_6.just(createPropertySignature_1(name, createUnion_1(tsplus_module_2.map(p => p.type)(members)), tsplus_module_2.some(p => p.isOptional)(members), tsplus_module_2.some(p => p.isReadonly)(members)), fileName_1 + ":1075:22");
852
+ }
853
+ return tsplus_module_6.nothing(fileName_1 + ":1084:23");
854
+ })(tsplus_module_2.unsafeGet(0)(propertySignatures));
855
+ }
856
+ case 19 /* ASTTag.Lazy */:
857
+ return getPropertySignatures_1(self.getAST());
858
+ case 20 /* ASTTag.Refinement */:
859
+ return getPropertySignatures_1(self.from);
860
+ case 21 /* ASTTag.Transform */:
861
+ return getPropertySignatures_1(self.to);
862
+ default:
863
+ return tsplus_module_2.empty();
864
+ }
865
+ }
866
+ /**
867
+ * @tsplus getter fncts.schema.AST keysof
868
+ */
869
+ function keysOf_1(ast) {
870
+ void 0;
871
+ switch (ast._tag) {
872
+ case 0 /* ASTTag.Declaration */:
873
+ return keysOf_1(ast.type);
874
+ case 5 /* ASTTag.NeverKeyword */:
875
+ case 7 /* ASTTag.AnyKeyword */:
876
+ return tsplus_module_2.vector(stringKeyword_1, numberKeyword_1, symbolKeyword_1);
877
+ case 8 /* ASTTag.StringKeyword */:
878
+ return tsplus_module_2.vector(createLiteral_1("length"));
879
+ case 17 /* ASTTag.TypeLiteral */:
880
+ return tsplus_module_2.concat(tsplus_module_2.map(is => getParameter(is.parameter))(ast.indexSignatures))(tsplus_module_2.map(p => typeof p.name === "symbol" ? createUniqueSymbol_1(p.name) : createLiteral_1(p.name))(ast.propertySignatures));
881
+ case 18 /* ASTTag.Union */:
882
+ return tsplus_module_2.map(p => typeof p.name === "symbol" ? createUniqueSymbol_1(p.name) : createLiteral_1(p.name))(getPropertySignatures_1(ast));
883
+ case 19 /* ASTTag.Lazy */:
884
+ return keysOf_1(ast.getAST());
885
+ case 20 /* ASTTag.Refinement */:
886
+ return keysOf_1(ast.from);
887
+ case 21 /* ASTTag.Transform */:
888
+ return keysOf_1(ast.to);
889
+ default:
890
+ return tsplus_module_2.empty();
891
+ }
892
+ }
893
+ /**
894
+ * @tsplus getter fncts.schema.AST keyof
895
+ */
896
+ export function keyof(self) {
897
+ return createUnion_1(keysOf_1(self));
898
+ }
899
+ /**
900
+ * @tsplus static fncts.schema.ASTOps createRecord
901
+ */
902
+ export function createRecord(key, value, isReadonly) {
903
+ const propertySignatures = tsplus_module_2.emptyPushable();
904
+ const indexSignatures = tsplus_module_2.emptyPushable();
905
+ function go(key) {
906
+ void 0;
907
+ switch (key._tag) {
908
+ case 0 /* ASTTag.Declaration */:
909
+ go(key.type);
910
+ break;
911
+ case 5 /* ASTTag.NeverKeyword */:
912
+ break;
913
+ case 8 /* ASTTag.StringKeyword */:
914
+ case 12 /* ASTTag.SymbolKeyword */:
915
+ case 15 /* ASTTag.TemplateLiteral */:
916
+ case 20 /* ASTTag.Refinement */:
917
+ tsplus_module_8.push(createIndexSignature_1(key, value, isReadonly))(indexSignatures);
918
+ break;
919
+ case 1 /* ASTTag.Literal */:
920
+ if (typeof key.literal === "string" || typeof key.literal === "number") {
921
+ tsplus_module_8.push(createPropertySignature_1(key.literal, value, false, isReadonly))(propertySignatures);
922
+ }
923
+ break;
924
+ case 2 /* ASTTag.UniqueSymbol */:
925
+ tsplus_module_8.push(createPropertySignature_1(key.symbol, value, false, isReadonly))(propertySignatures);
926
+ break;
927
+ case 18 /* ASTTag.Union */:
928
+ tsplus_module_2.forEach(go)(key.types);
929
+ break;
930
+ default:
931
+ throw new Error(`createRecord: Unsupported key\n${show(key)}`);
932
+ }
933
+ }
934
+ go(key);
935
+ return createTypeLiteral_1(propertySignatures, indexSignatures);
936
+ }
937
+ /**
938
+ * @tsplus pipeable fncts.schema.AST pick
939
+ */
940
+ export function pick(keys) {
941
+ return self => {
942
+ return createTypeLiteral_1(tsplus_module_2.filter(ps => tsplus_module_2.includes(ps.name)(keys))(getPropertySignatures_1(self)), tsplus_module_2.empty());
943
+ };
944
+ }
945
+ /**
946
+ * @tsplus pipeable fncts.schema.AST omit
947
+ */
948
+ export function omit(keys) {
949
+ return self => {
950
+ return createTypeLiteral_1(tsplus_module_2.filter(ps => !tsplus_module_2.includes(ps.name)(keys))(getPropertySignatures_1(self)), tsplus_module_2.empty());
951
+ };
952
+ }
953
+ /**
954
+ * @tsplus getter fncts.schema.AST partial
955
+ */
956
+ function partial_1(self) {
957
+ void 0;
958
+ switch (self._tag) {
959
+ case 0 /* ASTTag.Declaration */:
960
+ return partial_1(self.type);
961
+ case 16 /* ASTTag.Tuple */:
962
+ return createTuple_1(tsplus_module_2.map(e => createElement_1(e.type, true))(self.elements), tsplus_module_9.map(rest => tsplus_module_2.vector(createUnion_1(tsplus_module_2.append(undefinedKeyword_1)(rest))))(self.rest), self.isReadonly);
963
+ case 17 /* ASTTag.TypeLiteral */:
964
+ return createTypeLiteral_1(tsplus_module_2.map(f => createPropertySignature_1(f.name, f.type, true, f.isReadonly, f.annotations))(self.propertySignatures), self.indexSignatures);
965
+ case 18 /* ASTTag.Union */:
966
+ return createUnion_1(tsplus_module_2.map(partial_1)(self.types));
967
+ case 19 /* ASTTag.Lazy */:
968
+ return createLazy_1(() => partial_1(self.getAST()));
969
+ case 20 /* ASTTag.Refinement */:
970
+ return partial_1(self.from);
971
+ case 21 /* ASTTag.Transform */:
972
+ return partial_1(self.to);
973
+ default:
974
+ return self;
975
+ }
976
+ }
977
+ /**
978
+ * @tsplus static fncts.schema.AST createKey
979
+ */
980
+ export function createKey(key) {
981
+ return typeof key === "symbol" ? createUniqueSymbol_1(key) : createLiteral_1(key);
982
+ }
983
+ /**
984
+ * @tsplus getter fncts.schema.AST getFrom
985
+ */
986
+ function getFrom_1(ast) {
987
+ void 0;
988
+ switch (ast._tag) {
989
+ case 0 /* ASTTag.Declaration */:
990
+ return createDeclaration_1(tsplus_module_2.map(getFrom_1)(ast.typeParameters), ast.type, ast.decode, ast.annotations);
991
+ case 16 /* ASTTag.Tuple */:
992
+ return createTuple_1(tsplus_module_2.map(element => createElement_1(getFrom_1(element.type), element.isOptional))(ast.elements), tsplus_module_9.map(restElement => tsplus_module_2.map(getFrom_1)(restElement))(ast.rest), ast.isReadonly, ast.annotations);
993
+ case 17 /* ASTTag.TypeLiteral */:
994
+ return createTypeLiteral_1(tsplus_module_2.map(ps => createPropertySignature_1(ps.name, getFrom_1(ps.type), ps.isOptional, ps.isReadonly, ps.annotations))(ast.propertySignatures), tsplus_module_2.map(is => createIndexSignature_1(is.parameter, getFrom_1(is.type), is.isReadonly))(ast.indexSignatures), ast.annotations);
995
+ case 18 /* ASTTag.Union */:
996
+ return createUnion_1(tsplus_module_2.map(getFrom_1)(ast.types), ast.annotations);
997
+ case 19 /* ASTTag.Lazy */:
998
+ return createLazy_1(() => getFrom_1(ast.getAST()), ast.annotations);
999
+ case 20 /* ASTTag.Refinement */:
1000
+ case 21 /* ASTTag.Transform */:
1001
+ return getFrom_1(ast.from);
1002
+ }
1003
+ return ast;
1004
+ }
1005
+ /**
1006
+ * @tsplus getter fncts.schema.AST getTo
1007
+ */
1008
+ function getTo_1(ast) {
1009
+ void 0;
1010
+ switch (ast._tag) {
1011
+ case 0 /* ASTTag.Declaration */:
1012
+ return createDeclaration_1(tsplus_module_2.map(getTo_1)(ast.typeParameters), ast.type, ast.decode, ast.annotations);
1013
+ case 16 /* ASTTag.Tuple */:
1014
+ return createTuple_1(tsplus_module_2.map(element => createElement_1(getTo_1(element.type), element.isOptional))(ast.elements), tsplus_module_9.map(restElement => tsplus_module_2.map(getTo_1)(restElement))(ast.rest), ast.isReadonly, ast.annotations);
1015
+ case 17 /* ASTTag.TypeLiteral */:
1016
+ return createTypeLiteral_1(tsplus_module_2.map(ps => createPropertySignature_1(ps.name, getTo_1(ps.type), ps.isOptional, ps.isReadonly, ps.annotations))(ast.propertySignatures), tsplus_module_2.map(is => createIndexSignature_1(is.parameter, getTo_1(is.type), is.isReadonly))(ast.indexSignatures), ast.annotations);
1017
+ case 18 /* ASTTag.Union */:
1018
+ return createUnion_1(tsplus_module_2.map(getTo_1)(ast.types), ast.annotations);
1019
+ case 19 /* ASTTag.Lazy */:
1020
+ return createLazy_1(() => getTo_1(ast.getAST()), ast.annotations);
1021
+ case 20 /* ASTTag.Refinement */:
1022
+ return createRefinement_1(getTo_1(ast.from), ast.decode, false, ast.annotations);
1023
+ case 21 /* ASTTag.Transform */:
1024
+ return getTo_1(ast.to);
1025
+ }
1026
+ return ast;
1027
+ }
1028
+ /**
1029
+ * @tsplus getter fncts.schema.AST reverse
1030
+ */
1031
+ function reverse_1(ast) {
1032
+ void 0;
1033
+ switch (ast._tag) {
1034
+ case 0 /* ASTTag.Declaration */:
1035
+ return createDeclaration_1(tsplus_module_2.map(reverse_1)(ast.typeParameters), ast.type, ast.decode, ast.annotations);
1036
+ case 16 /* ASTTag.Tuple */:
1037
+ return createTuple_1(tsplus_module_2.map(element => createElement_1(reverse_1(element.type), element.isOptional))(ast.elements), tsplus_module_9.map(restElement => tsplus_module_2.map(reverse_1)(restElement))(ast.rest), ast.isReadonly, ast.annotations);
1038
+ case 17 /* ASTTag.TypeLiteral */:
1039
+ return createTypeLiteral_1(tsplus_module_2.map(ps => createPropertySignature_1(ps.name, reverse_1(ps.type), ps.isOptional, ps.isReadonly, ps.annotations))(ast.propertySignatures), tsplus_module_2.map(is => createIndexSignature_1(is.parameter, reverse_1(is.type), is.isReadonly))(ast.indexSignatures), ast.annotations);
1040
+ case 18 /* ASTTag.Union */:
1041
+ return createUnion_1(tsplus_module_2.map(reverse_1)(ast.types), ast.annotations);
1042
+ case 19 /* ASTTag.Lazy */:
1043
+ return createLazy_1(() => reverse_1(ast.getAST()), ast.annotations);
1044
+ case 20 /* ASTTag.Refinement */:
1045
+ return createRefinement_1(ast.from, ast.decode, !ast.isReversed, ast.annotations);
1046
+ case 21 /* ASTTag.Transform */:
1047
+ return createTransform_1(reverse_1(ast.from), ast.to, ast.decode, ast.encode, !ast.isReversed, ast.annotations);
1048
+ }
1049
+ return ast;
1050
+ }
1051
+ /**
1052
+ * @tsplus static fncts.schema.AST getCompiler
1053
+ */
1054
+ export function getCompiler(match) {
1055
+ const compile = memoize(ast => {
1056
+ void 0;
1057
+ return match[ast._tag](ast, compile);
1058
+ });
1059
+ return compile;
1060
+ }
1061
+ //# sourceMappingURL=AST.mjs.map