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