@fncts/schema 0.0.16 → 0.0.17
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.
- package/AST.d.ts +19 -6
- package/ASTAnnotation.d.ts +10 -2
- package/ParseError/ParseError.d.ts +231 -0
- package/ParseError/ParseErrorFormatter.d.ts +2 -0
- package/ParseError/PathFormatter.d.ts +13 -0
- package/ParseError/TreeFormatter.d.ts +14 -0
- package/ParseError.d.ts +4 -144
- package/ParseResult.d.ts +1 -8
- package/Parser/interpreter.d.ts +0 -1
- package/Schema/api/conc.d.ts +0 -2
- package/Schema/api/hashMap.d.ts +0 -1
- package/Schema/api/hashSet.d.ts +0 -1
- package/Schema/api/immutableArray.d.ts +0 -1
- package/Schema/api/list.d.ts +1 -2
- package/Schema/api/map.d.ts +19 -0
- package/Schema/api/set.d.ts +19 -0
- package/Schema/api.d.ts +11 -1
- package/Schema.d.ts +2 -0
- package/Show.d.ts +7 -3
- package/_cjs/AST.cjs +180 -113
- package/_cjs/AST.cjs.map +1 -1
- package/_cjs/ASTAnnotation.cjs +6 -1
- package/_cjs/ASTAnnotation.cjs.map +1 -1
- package/_cjs/Gen.cjs +24 -24
- package/_cjs/Gen.cjs.map +1 -1
- package/_cjs/ParseError/ParseError.cjs +260 -0
- package/_cjs/ParseError/ParseError.cjs.map +1 -0
- package/_cjs/ParseError/ParseErrorFormatter.cjs +6 -0
- package/_cjs/ParseError/ParseErrorFormatter.cjs.map +1 -0
- package/_cjs/ParseError/PathFormatter.cjs +94 -0
- package/_cjs/ParseError/PathFormatter.cjs.map +1 -0
- package/_cjs/ParseError/TreeFormatter.cjs +123 -0
- package/_cjs/ParseError/TreeFormatter.cjs.map +1 -0
- package/_cjs/ParseError.cjs +43 -289
- package/_cjs/ParseError.cjs.map +1 -1
- package/_cjs/ParseResult.cjs +1 -10
- package/_cjs/ParseResult.cjs.map +1 -1
- package/_cjs/Parser/api.cjs +2 -2
- package/_cjs/Parser/api.cjs.map +1 -1
- package/_cjs/Parser/definition.cjs +1 -1
- package/_cjs/Parser/interpreter.cjs +121 -117
- package/_cjs/Parser/interpreter.cjs.map +1 -1
- package/_cjs/Schema/api/conc.cjs +35 -45
- package/_cjs/Schema/api/conc.cjs.map +1 -1
- package/_cjs/Schema/api/either.cjs +24 -30
- package/_cjs/Schema/api/either.cjs.map +1 -1
- package/_cjs/Schema/api/hashMap.cjs +41 -101
- package/_cjs/Schema/api/hashMap.cjs.map +1 -1
- package/_cjs/Schema/api/hashSet.cjs +46 -106
- package/_cjs/Schema/api/hashSet.cjs.map +1 -1
- package/_cjs/Schema/api/immutableArray.cjs +22 -48
- package/_cjs/Schema/api/immutableArray.cjs.map +1 -1
- package/_cjs/Schema/api/list.cjs +35 -52
- package/_cjs/Schema/api/list.cjs.map +1 -1
- package/_cjs/Schema/api/map.cjs +97 -0
- package/_cjs/Schema/api/map.cjs.map +1 -0
- package/_cjs/Schema/api/maybe.cjs +24 -35
- package/_cjs/Schema/api/maybe.cjs.map +1 -1
- package/_cjs/Schema/api/set.cjs +76 -0
- package/_cjs/Schema/api/set.cjs.map +1 -0
- package/_cjs/Schema/api.cjs +20 -2
- package/_cjs/Schema/api.cjs.map +1 -1
- package/_cjs/Schema.cjs +22 -0
- package/_cjs/Schema.cjs.map +1 -1
- package/_cjs/Show.cjs +106 -89
- package/_cjs/Show.cjs.map +1 -1
- package/_cjs/utils.cjs +5 -0
- package/_cjs/utils.cjs.map +1 -1
- package/_mjs/AST.mjs +177 -112
- package/_mjs/AST.mjs.map +1 -1
- package/_mjs/ASTAnnotation.mjs +5 -0
- package/_mjs/ASTAnnotation.mjs.map +1 -1
- package/_mjs/Gen.mjs +24 -24
- package/_mjs/Gen.mjs.map +1 -1
- package/_mjs/ParseError/ParseError.mjs +228 -0
- package/_mjs/ParseError/ParseError.mjs.map +1 -0
- package/_mjs/ParseError/ParseErrorFormatter.mjs +2 -0
- package/_mjs/ParseError/ParseErrorFormatter.mjs.map +1 -0
- package/_mjs/ParseError/PathFormatter.mjs +86 -0
- package/_mjs/ParseError/PathFormatter.mjs.map +1 -0
- package/_mjs/ParseError/TreeFormatter.mjs +113 -0
- package/_mjs/ParseError/TreeFormatter.mjs.map +1 -0
- package/_mjs/ParseError.mjs +6 -270
- package/_mjs/ParseError.mjs.map +1 -1
- package/_mjs/ParseResult.mjs +1 -9
- package/_mjs/ParseResult.mjs.map +1 -1
- package/_mjs/Parser/api.mjs +2 -2
- package/_mjs/Parser/api.mjs.map +1 -1
- package/_mjs/Parser/definition.mjs +1 -1
- package/_mjs/Parser/interpreter.mjs +121 -117
- package/_mjs/Parser/interpreter.mjs.map +1 -1
- package/_mjs/Schema/api/conc.mjs +35 -44
- package/_mjs/Schema/api/conc.mjs.map +1 -1
- package/_mjs/Schema/api/either.mjs +24 -30
- package/_mjs/Schema/api/either.mjs.map +1 -1
- package/_mjs/Schema/api/hashMap.mjs +41 -101
- package/_mjs/Schema/api/hashMap.mjs.map +1 -1
- package/_mjs/Schema/api/hashSet.mjs +46 -106
- package/_mjs/Schema/api/hashSet.mjs.map +1 -1
- package/_mjs/Schema/api/immutableArray.mjs +23 -49
- package/_mjs/Schema/api/immutableArray.mjs.map +1 -1
- package/_mjs/Schema/api/list.mjs +35 -52
- package/_mjs/Schema/api/list.mjs.map +1 -1
- package/_mjs/Schema/api/map.mjs +88 -0
- package/_mjs/Schema/api/map.mjs.map +1 -0
- package/_mjs/Schema/api/maybe.mjs +24 -35
- package/_mjs/Schema/api/maybe.mjs.map +1 -1
- package/_mjs/Schema/api/set.mjs +67 -0
- package/_mjs/Schema/api/set.mjs.map +1 -0
- package/_mjs/Schema/api.mjs +18 -2
- package/_mjs/Schema/api.mjs.map +1 -1
- package/_mjs/Schema.mjs +2 -0
- package/_mjs/Schema.mjs.map +1 -1
- package/_mjs/Show.mjs +106 -90
- package/_mjs/Show.mjs.map +1 -1
- package/_mjs/utils.mjs +4 -0
- package/_mjs/utils.mjs.map +1 -1
- package/_src/AST.ts +144 -43
- package/_src/ASTAnnotation.ts +8 -1
- package/_src/Gen.ts +12 -9
- package/_src/ParseError/ParseError.ts +304 -0
- package/_src/ParseError/ParseErrorFormatter.ts +1 -0
- package/_src/ParseError/PathFormatter.ts +117 -0
- package/_src/ParseError/TreeFormatter.ts +127 -0
- package/_src/ParseError.ts +7 -331
- package/_src/ParseResult.ts +2 -9
- package/_src/Parser/api.ts +1 -1
- package/_src/Parser/interpreter.ts +98 -75
- package/_src/Schema/api/conc.ts +33 -42
- package/_src/Schema/api/either.ts +20 -30
- package/_src/Schema/api/hashMap.ts +40 -124
- package/_src/Schema/api/hashSet.ts +31 -117
- package/_src/Schema/api/immutableArray.ts +15 -45
- package/_src/Schema/api/list.ts +32 -55
- package/_src/Schema/api/map.ts +93 -0
- package/_src/Schema/api/maybe.ts +19 -34
- package/_src/Schema/api/set.ts +74 -0
- package/_src/Schema/api.ts +20 -2
- package/_src/Schema.ts +2 -0
- package/_src/Show.ts +156 -128
- package/_src/global.ts +0 -4
- package/_src/utils.ts +5 -0
- package/global.d.ts +0 -4
- package/package.json +2 -2
- package/utils.d.ts +1 -0
- package/ParseFailure.d.ts +0 -18
- package/_cjs/ParseFailure.cjs +0 -28
- package/_cjs/ParseFailure.cjs.map +0 -1
- package/_mjs/ParseFailure.mjs +0 -20
- package/_mjs/ParseFailure.mjs.map +0 -1
- package/_src/ParseFailure.ts +0 -18
package/_cjs/AST.cjs
CHANGED
|
@@ -9,7 +9,8 @@ exports.appendRestElement = appendRestElement;
|
|
|
9
9
|
exports.booleanKeyword = exports.bigIntKeyword = void 0;
|
|
10
10
|
exports.combineAnnotations = combineAnnotations;
|
|
11
11
|
exports.concrete = concrete;
|
|
12
|
-
exports.
|
|
12
|
+
exports.createDeclaration = createDeclaration;
|
|
13
|
+
exports.createElement = void 0;
|
|
13
14
|
exports.createEnum = createEnum;
|
|
14
15
|
exports.createIndexSignature = void 0;
|
|
15
16
|
exports.createKey = createKey;
|
|
@@ -22,6 +23,7 @@ exports.createValidation = createValidation;
|
|
|
22
23
|
exports.getAnnotations = getAnnotations;
|
|
23
24
|
exports.getCardinality = getCardinality;
|
|
24
25
|
exports.getCompiler = getCompiler;
|
|
26
|
+
exports.getFormattedExpected = getFormattedExpected;
|
|
25
27
|
exports.getFrom = void 0;
|
|
26
28
|
exports.getLiterals = getLiterals;
|
|
27
29
|
exports.getParameter = getParameter;
|
|
@@ -46,17 +48,21 @@ exports.partial = void 0;
|
|
|
46
48
|
exports.pick = pick;
|
|
47
49
|
exports.setAnnotation = setAnnotation;
|
|
48
50
|
exports.voidKeyword = exports.unknownRecord = exports.unknownKeyword = exports.unknownArray = exports.undefinedKeyword = exports.symbolKeyword = exports.stringKeyword = void 0;
|
|
49
|
-
var tsplus_module_1 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/schema/
|
|
50
|
-
var tsplus_module_2 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/
|
|
51
|
-
var tsplus_module_3 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/
|
|
52
|
-
var tsplus_module_4 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/
|
|
53
|
-
var tsplus_module_5 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/schema/
|
|
54
|
-
var tsplus_module_6 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/
|
|
55
|
-
var tsplus_module_7 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/
|
|
56
|
-
var tsplus_module_8 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/
|
|
57
|
-
var tsplus_module_9 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/
|
|
58
|
-
var tsplus_module_10 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/
|
|
59
|
-
var tsplus_module_11 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/
|
|
51
|
+
var tsplus_module_1 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/schema/Show"));
|
|
52
|
+
var tsplus_module_2 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/schema/ASTAnnotation"));
|
|
53
|
+
var tsplus_module_3 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/collection/immutable/Vector/api"));
|
|
54
|
+
var tsplus_module_4 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Maybe/constructors"));
|
|
55
|
+
var tsplus_module_5 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/schema/ParseResult"));
|
|
56
|
+
var tsplus_module_6 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/schema/ParseError/ParseError"));
|
|
57
|
+
var tsplus_module_7 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/number/instances"));
|
|
58
|
+
var tsplus_module_8 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Ord/api/contramap"));
|
|
59
|
+
var tsplus_module_9 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Ord/api"));
|
|
60
|
+
var tsplus_module_10 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Ord/api/max"));
|
|
61
|
+
var tsplus_module_11 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/collection/Iterable/api"));
|
|
62
|
+
var tsplus_module_12 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Maybe/destructors"));
|
|
63
|
+
var tsplus_module_13 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Maybe/definition"));
|
|
64
|
+
var tsplus_module_14 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/collection/immutable/Vector/internal"));
|
|
65
|
+
var tsplus_module_15 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Maybe/api"));
|
|
60
66
|
var _Showable = /*#__PURE__*/require("@fncts/base/data/Showable");
|
|
61
67
|
var _utils = /*#__PURE__*/require("@fncts/schema/utils");
|
|
62
68
|
var _ASTAnnotationMap = /*#__PURE__*/require("./ASTAnnotationMap.cjs");
|
|
@@ -64,7 +70,6 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
64
70
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
65
71
|
var _a;
|
|
66
72
|
const fileName_1 = "(@fncts/schema) src/AST.ts";
|
|
67
|
-
const createDeclaration = exports.createDeclaration = createDeclaration_1;
|
|
68
73
|
const createLiteral = exports.createLiteral = createLiteral_1;
|
|
69
74
|
const isLiteral = exports.isLiteral = isLiteral_1;
|
|
70
75
|
const createUniqueSymbol = exports.createUniqueSymbol = createUniqueSymbol_1;
|
|
@@ -102,6 +107,9 @@ class AST extends Annotated {
|
|
|
102
107
|
super(...arguments);
|
|
103
108
|
this[_a] = ASTTypeId;
|
|
104
109
|
}
|
|
110
|
+
toString(verbose = false) {
|
|
111
|
+
return tsplus_module_1.showAST(verbose)(this);
|
|
112
|
+
}
|
|
105
113
|
}
|
|
106
114
|
exports.AST = AST;
|
|
107
115
|
_a = ASTTypeId;
|
|
@@ -120,25 +128,28 @@ function getAnnotations(key) {
|
|
|
120
128
|
/*
|
|
121
129
|
* Declaration
|
|
122
130
|
*/
|
|
131
|
+
/**
|
|
132
|
+
* @tsplus type fncts.schema.AST.Declaration
|
|
133
|
+
*/
|
|
123
134
|
class Declaration extends AST {
|
|
124
|
-
constructor(typeParameters,
|
|
135
|
+
constructor(typeParameters, decode, encode, annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
|
|
125
136
|
super();
|
|
126
137
|
this.typeParameters = typeParameters;
|
|
127
|
-
this.type = type;
|
|
128
138
|
this.decode = decode;
|
|
139
|
+
this.encode = encode;
|
|
129
140
|
this.annotations = annotations;
|
|
130
141
|
this._tag = 0 /* ASTTag.Declaration */;
|
|
131
142
|
}
|
|
132
143
|
clone(newProperties) {
|
|
133
|
-
return new Declaration(newProperties.typeParameters ?? this.typeParameters, newProperties.
|
|
144
|
+
return new Declaration(newProperties.typeParameters ?? this.typeParameters, newProperties.decode ?? this.decode, newProperties.encode ?? this.encode, newProperties.annotations ?? this.annotations);
|
|
134
145
|
}
|
|
135
146
|
}
|
|
136
147
|
/**
|
|
137
148
|
* @tsplus static fncts.schema.ASTOps createDeclaration
|
|
138
149
|
*/
|
|
139
150
|
exports.Declaration = Declaration;
|
|
140
|
-
function
|
|
141
|
-
return new Declaration(typeParameters,
|
|
151
|
+
function createDeclaration(typeParameters, decode, encode, annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
|
|
152
|
+
return new Declaration(typeParameters, decode, encode, annotations);
|
|
142
153
|
}
|
|
143
154
|
/**
|
|
144
155
|
* @tsplus fluent fncts.schema.AST isDeclaration
|
|
@@ -217,7 +228,7 @@ class UndefinedKeyword extends AST {
|
|
|
217
228
|
* @tsplus static fncts.schema.ASTOps undefinedKeyword
|
|
218
229
|
*/
|
|
219
230
|
exports.UndefinedKeyword = UndefinedKeyword;
|
|
220
|
-
const undefinedKeyword_1 = /*#__PURE__*/new UndefinedKeyword( /*#__PURE__*/_ASTAnnotationMap.ASTAnnotationMap.empty.annotate(
|
|
231
|
+
const undefinedKeyword_1 = /*#__PURE__*/new UndefinedKeyword( /*#__PURE__*/_ASTAnnotationMap.ASTAnnotationMap.empty.annotate(tsplus_module_2.Title, "undefined"));
|
|
221
232
|
const undefinedKeyword = exports.undefinedKeyword = undefinedKeyword_1;
|
|
222
233
|
/*
|
|
223
234
|
* VoidKeyword
|
|
@@ -236,7 +247,7 @@ class VoidKeyword extends AST {
|
|
|
236
247
|
* @tsplus static fncts.schema.ASTOps voidKeyword
|
|
237
248
|
*/
|
|
238
249
|
exports.VoidKeyword = VoidKeyword;
|
|
239
|
-
const voidKeyword = exports.voidKeyword = /*#__PURE__*/new VoidKeyword( /*#__PURE__*/_ASTAnnotationMap.ASTAnnotationMap.empty.annotate(
|
|
250
|
+
const voidKeyword = exports.voidKeyword = /*#__PURE__*/new VoidKeyword( /*#__PURE__*/_ASTAnnotationMap.ASTAnnotationMap.empty.annotate(tsplus_module_2.Title, "void"));
|
|
240
251
|
/*
|
|
241
252
|
* NeverKeyword
|
|
242
253
|
*/
|
|
@@ -254,7 +265,7 @@ class NeverKeyword extends AST {
|
|
|
254
265
|
* @tsplus static fncts.schema.ASTOps neverKeyword
|
|
255
266
|
*/
|
|
256
267
|
exports.NeverKeyword = NeverKeyword;
|
|
257
|
-
const neverKeyword_1 = /*#__PURE__*/new NeverKeyword( /*#__PURE__*/_ASTAnnotationMap.ASTAnnotationMap.empty.annotate(
|
|
268
|
+
const neverKeyword_1 = /*#__PURE__*/new NeverKeyword( /*#__PURE__*/_ASTAnnotationMap.ASTAnnotationMap.empty.annotate(tsplus_module_2.Title, "never"));
|
|
258
269
|
const neverKeyword = exports.neverKeyword = neverKeyword_1;
|
|
259
270
|
/*
|
|
260
271
|
* UnknownKeyword
|
|
@@ -273,7 +284,7 @@ class UnknownKeyword extends AST {
|
|
|
273
284
|
* @tsplus static fncts.schema.ASTOps unknownKeyword
|
|
274
285
|
*/
|
|
275
286
|
exports.UnknownKeyword = UnknownKeyword;
|
|
276
|
-
const unknownKeyword_1 = /*#__PURE__*/new UnknownKeyword( /*#__PURE__*/_ASTAnnotationMap.ASTAnnotationMap.empty.annotate(
|
|
287
|
+
const unknownKeyword_1 = /*#__PURE__*/new UnknownKeyword( /*#__PURE__*/_ASTAnnotationMap.ASTAnnotationMap.empty.annotate(tsplus_module_2.Title, "unknown"));
|
|
277
288
|
const unknownKeyword = exports.unknownKeyword = unknownKeyword_1;
|
|
278
289
|
/*
|
|
279
290
|
* AnyKeyword
|
|
@@ -292,7 +303,7 @@ class AnyKeyword extends AST {
|
|
|
292
303
|
* @tsplus static fncts.schema.ASTOps anyKeyword
|
|
293
304
|
*/
|
|
294
305
|
exports.AnyKeyword = AnyKeyword;
|
|
295
|
-
const anyKeyword = exports.anyKeyword = /*#__PURE__*/new AnyKeyword( /*#__PURE__*/_ASTAnnotationMap.ASTAnnotationMap.empty.annotate(
|
|
306
|
+
const anyKeyword = exports.anyKeyword = /*#__PURE__*/new AnyKeyword( /*#__PURE__*/_ASTAnnotationMap.ASTAnnotationMap.empty.annotate(tsplus_module_2.Title, "any"));
|
|
296
307
|
/*
|
|
297
308
|
* StringKeyword
|
|
298
309
|
*/
|
|
@@ -310,7 +321,7 @@ class StringKeyword extends AST {
|
|
|
310
321
|
* @tsplus static fncts.schema.ASTOps stringKeyword
|
|
311
322
|
*/
|
|
312
323
|
exports.StringKeyword = StringKeyword;
|
|
313
|
-
const stringKeyword_1 = /*#__PURE__*/new StringKeyword( /*#__PURE__*/_ASTAnnotationMap.ASTAnnotationMap.empty.annotate(
|
|
324
|
+
const stringKeyword_1 = /*#__PURE__*/new StringKeyword( /*#__PURE__*/_ASTAnnotationMap.ASTAnnotationMap.empty.annotate(tsplus_module_2.Title, "string"));
|
|
314
325
|
const stringKeyword = exports.stringKeyword = stringKeyword_1;
|
|
315
326
|
/**
|
|
316
327
|
* @tsplus fluent fncts.schema.AST isStringKeyword
|
|
@@ -336,7 +347,7 @@ class NumberKeyword extends AST {
|
|
|
336
347
|
* @tsplus static fncts.schema.ASTOps numberKeyword
|
|
337
348
|
*/
|
|
338
349
|
exports.NumberKeyword = NumberKeyword;
|
|
339
|
-
const numberKeyword_1 = /*#__PURE__*/new NumberKeyword( /*#__PURE__*/_ASTAnnotationMap.ASTAnnotationMap.empty.annotate(
|
|
350
|
+
const numberKeyword_1 = /*#__PURE__*/new NumberKeyword( /*#__PURE__*/_ASTAnnotationMap.ASTAnnotationMap.empty.annotate(tsplus_module_2.Title, "number"));
|
|
340
351
|
const numberKeyword = exports.numberKeyword = numberKeyword_1;
|
|
341
352
|
/**
|
|
342
353
|
* @tsplus fluent fncts.schema.AST isNumberKeyword
|
|
@@ -362,7 +373,7 @@ class BooleanKeyword extends AST {
|
|
|
362
373
|
* @tsplus static fncts.schema.ASTOps booleanKeyword
|
|
363
374
|
*/
|
|
364
375
|
exports.BooleanKeyword = BooleanKeyword;
|
|
365
|
-
const booleanKeyword = exports.booleanKeyword = /*#__PURE__*/new BooleanKeyword( /*#__PURE__*/_ASTAnnotationMap.ASTAnnotationMap.empty.annotate(
|
|
376
|
+
const booleanKeyword = exports.booleanKeyword = /*#__PURE__*/new BooleanKeyword( /*#__PURE__*/_ASTAnnotationMap.ASTAnnotationMap.empty.annotate(tsplus_module_2.Title, "boolean"));
|
|
366
377
|
/**
|
|
367
378
|
* @tsplus fluent fncts.schema.AST isBooleanKeyword
|
|
368
379
|
*/
|
|
@@ -387,7 +398,7 @@ class BigIntKeyword extends AST {
|
|
|
387
398
|
* @tsplus static fncts.schema.ASTOps bigIntKeyword
|
|
388
399
|
*/
|
|
389
400
|
exports.BigIntKeyword = BigIntKeyword;
|
|
390
|
-
const bigIntKeyword = exports.bigIntKeyword = /*#__PURE__*/new BigIntKeyword( /*#__PURE__*/_ASTAnnotationMap.ASTAnnotationMap.empty.annotate(
|
|
401
|
+
const bigIntKeyword = exports.bigIntKeyword = /*#__PURE__*/new BigIntKeyword( /*#__PURE__*/_ASTAnnotationMap.ASTAnnotationMap.empty.annotate(tsplus_module_2.Title, "bigint"));
|
|
391
402
|
/**
|
|
392
403
|
* @tsplus fluent fncts.schema.AST isBigIntKeyword
|
|
393
404
|
*/
|
|
@@ -412,7 +423,7 @@ class SymbolKeyword extends AST {
|
|
|
412
423
|
* @tsplus static fncts.schema.ASTOps symbolKeyword
|
|
413
424
|
*/
|
|
414
425
|
exports.SymbolKeyword = SymbolKeyword;
|
|
415
|
-
const symbolKeyword_1 = /*#__PURE__*/new SymbolKeyword( /*#__PURE__*/_ASTAnnotationMap.ASTAnnotationMap.empty.annotate(
|
|
426
|
+
const symbolKeyword_1 = /*#__PURE__*/new SymbolKeyword( /*#__PURE__*/_ASTAnnotationMap.ASTAnnotationMap.empty.annotate(tsplus_module_2.Title, "symbol"));
|
|
416
427
|
const symbolKeyword = exports.symbolKeyword = symbolKeyword_1;
|
|
417
428
|
/**
|
|
418
429
|
* @tsplus fluent fncts.schema.AST isSymbolKeyword
|
|
@@ -438,7 +449,7 @@ class ObjectKeyword extends AST {
|
|
|
438
449
|
* @tsplus static fncts.schema.ASTOps objectKeyword
|
|
439
450
|
*/
|
|
440
451
|
exports.ObjectKeyword = ObjectKeyword;
|
|
441
|
-
const objectKeyword = exports.objectKeyword = /*#__PURE__*/new ObjectKeyword( /*#__PURE__*/_ASTAnnotationMap.ASTAnnotationMap.empty.annotate(
|
|
452
|
+
const objectKeyword = exports.objectKeyword = /*#__PURE__*/new ObjectKeyword( /*#__PURE__*/_ASTAnnotationMap.ASTAnnotationMap.empty.annotate(tsplus_module_2.Title, "object"));
|
|
442
453
|
/*
|
|
443
454
|
* Enum
|
|
444
455
|
*/
|
|
@@ -465,6 +476,14 @@ class TemplateLiteralSpan {
|
|
|
465
476
|
this.type = type;
|
|
466
477
|
this.literal = literal;
|
|
467
478
|
}
|
|
479
|
+
toString() {
|
|
480
|
+
switch (this.type._tag) {
|
|
481
|
+
case 8 /* ASTTag.StringKeyword */:
|
|
482
|
+
return "${string}";
|
|
483
|
+
case 9 /* ASTTag.NumberKeyword */:
|
|
484
|
+
return "${number}";
|
|
485
|
+
}
|
|
486
|
+
}
|
|
468
487
|
}
|
|
469
488
|
/*
|
|
470
489
|
* TemplateLiteral
|
|
@@ -487,7 +506,7 @@ class TemplateLiteral extends AST {
|
|
|
487
506
|
*/
|
|
488
507
|
exports.TemplateLiteral = TemplateLiteral;
|
|
489
508
|
function createTemplateLiteral_1(head, spans, annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
|
|
490
|
-
if (
|
|
509
|
+
if (tsplus_module_3.isNonEmpty(spans)) {
|
|
491
510
|
return new TemplateLiteral(head, spans, annotations);
|
|
492
511
|
} else {
|
|
493
512
|
return createLiteral_1(head, annotations);
|
|
@@ -501,6 +520,9 @@ class Element {
|
|
|
501
520
|
this.type = type;
|
|
502
521
|
this.isOptional = isOptional;
|
|
503
522
|
}
|
|
523
|
+
toString() {
|
|
524
|
+
return String(this.type) + (this.isOptional ? "?" : "");
|
|
525
|
+
}
|
|
504
526
|
}
|
|
505
527
|
/**
|
|
506
528
|
* @tsplus static fncts.schema.ASTOps createElement
|
|
@@ -535,13 +557,12 @@ function createTuple_1(elements, rest, isReadonly, annotations = _ASTAnnotationM
|
|
|
535
557
|
/**
|
|
536
558
|
* @tsplus static fncts.schema.ASTOps unknownArray
|
|
537
559
|
*/
|
|
538
|
-
const unknownArray = exports.unknownArray = /*#__PURE__*/createTuple_1( /*#__PURE__*/
|
|
560
|
+
const unknownArray = exports.unknownArray = /*#__PURE__*/createTuple_1( /*#__PURE__*/tsplus_module_3.empty(), /*#__PURE__*/tsplus_module_4.just( /*#__PURE__*/tsplus_module_3.vector(unknownKeyword_1), fileName_1 + ":651:65"), true);
|
|
539
561
|
/*
|
|
540
562
|
* PropertySignature
|
|
541
563
|
*/
|
|
542
|
-
class PropertySignature
|
|
564
|
+
class PropertySignature {
|
|
543
565
|
constructor(name, type, isOptional, isReadonly, annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
|
|
544
|
-
super();
|
|
545
566
|
this.name = name;
|
|
546
567
|
this.type = type;
|
|
547
568
|
this.isOptional = isOptional;
|
|
@@ -609,7 +630,7 @@ function createTypeLiteral_1(propertySignatures, indexSignatures, annotations) {
|
|
|
609
630
|
/**
|
|
610
631
|
* @tsplus static fncts.schema.ASTOps unknownRecord
|
|
611
632
|
*/
|
|
612
|
-
const unknownRecord = exports.unknownRecord = /*#__PURE__*/createTypeLiteral_1( /*#__PURE__*/
|
|
633
|
+
const unknownRecord = exports.unknownRecord = /*#__PURE__*/createTypeLiteral_1( /*#__PURE__*/tsplus_module_3.empty(), /*#__PURE__*/tsplus_module_3.vector( /*#__PURE__*/createIndexSignature_1(stringKeyword_1, unknownKeyword_1, true), /*#__PURE__*/createIndexSignature_1(symbolKeyword_1, unknownKeyword_1, true)));
|
|
613
634
|
/*
|
|
614
635
|
* Union
|
|
615
636
|
*/
|
|
@@ -641,7 +662,7 @@ function createUnion_1(candidates, annotations = _ASTAnnotationMap.ASTAnnotation
|
|
|
641
662
|
case 0:
|
|
642
663
|
return neverKeyword_1;
|
|
643
664
|
case 1:
|
|
644
|
-
return
|
|
665
|
+
return tsplus_module_3.unsafeGet(0)(types);
|
|
645
666
|
default:
|
|
646
667
|
return new Union(sortByDescendingWeight(types), annotations);
|
|
647
668
|
}
|
|
@@ -686,7 +707,7 @@ class Refinement extends AST {
|
|
|
686
707
|
this._tag = 20 /* ASTTag.Refinement */;
|
|
687
708
|
}
|
|
688
709
|
decode(input, options) {
|
|
689
|
-
return this.predicate(input) ?
|
|
710
|
+
return this.predicate(input) ? tsplus_module_5.succeed(input) : tsplus_module_5.fail(tsplus_module_6.typeError(this, input));
|
|
690
711
|
}
|
|
691
712
|
clone(newProperties) {
|
|
692
713
|
return new Refinement(newProperties.from ?? this.from, newProperties.predicate ?? this.predicate, newProperties.annotations ?? this.annotations);
|
|
@@ -758,10 +779,6 @@ function getCardinality(ast) {
|
|
|
758
779
|
while (1) {
|
|
759
780
|
void 0;
|
|
760
781
|
switch (ast_1._tag) {
|
|
761
|
-
case 0 /* ASTTag.Declaration */:
|
|
762
|
-
ast_2 = ast_1.type;
|
|
763
|
-
ast_1 = ast_2;
|
|
764
|
-
continue;
|
|
765
782
|
case 5 /* ASTTag.NeverKeyword */:
|
|
766
783
|
return 0;
|
|
767
784
|
case 1 /* ASTTag.Literal */:
|
|
@@ -777,7 +794,7 @@ function getCardinality(ast) {
|
|
|
777
794
|
case 12 /* ASTTag.SymbolKeyword */:
|
|
778
795
|
return 3;
|
|
779
796
|
case 13 /* ASTTag.ObjectKeyword */:
|
|
780
|
-
return
|
|
797
|
+
return 5;
|
|
781
798
|
case 6 /* ASTTag.UnknownKeyword */:
|
|
782
799
|
case 7 /* ASTTag.AnyKeyword */:
|
|
783
800
|
return 6;
|
|
@@ -790,59 +807,78 @@ function getCardinality(ast) {
|
|
|
790
807
|
ast_1 = ast_2;
|
|
791
808
|
continue;
|
|
792
809
|
default:
|
|
793
|
-
return
|
|
810
|
+
return 4;
|
|
794
811
|
}
|
|
795
812
|
}
|
|
796
813
|
}
|
|
797
814
|
function sortByAscendingCardinality(types) {
|
|
798
|
-
return
|
|
815
|
+
return tsplus_module_3.sort(tsplus_module_8.contramap(({
|
|
799
816
|
type
|
|
800
|
-
}) => getCardinality(type))(
|
|
817
|
+
}) => getCardinality(type))(tsplus_module_7.Ord))(types);
|
|
818
|
+
}
|
|
819
|
+
const OrdWeight = /*#__PURE__*/tsplus_module_9.tuple(tsplus_module_7.Ord, tsplus_module_7.Ord, tsplus_module_7.Ord);
|
|
820
|
+
const maxWeight = /*#__PURE__*/tsplus_module_10.max(OrdWeight);
|
|
821
|
+
function maxWeightAll(weights) {
|
|
822
|
+
return tsplus_module_11.foldLeft(emptyWeight, (b, a) => maxWeight(b)(a))(weights);
|
|
801
823
|
}
|
|
824
|
+
const emptyWeight = [0, 0, 0];
|
|
802
825
|
function getWeight(ast) {
|
|
803
826
|
void 0;
|
|
804
827
|
switch (ast._tag) {
|
|
805
828
|
case 0 /* ASTTag.Declaration */:
|
|
806
|
-
return
|
|
829
|
+
return tsplus_module_12.match(() => [6, 0, 0], ast => {
|
|
830
|
+
const [_, y, z] = getWeight(ast);
|
|
831
|
+
return [6, y, z];
|
|
832
|
+
})(ast.annotations.get(tsplus_module_2.Surrogate));
|
|
807
833
|
case 16 /* ASTTag.Tuple */:
|
|
808
|
-
return ast.elements.length
|
|
834
|
+
return [2, ast.elements.length, tsplus_module_12.match(() => 0, rest => rest.length)(ast.rest)];
|
|
809
835
|
case 17 /* ASTTag.TypeLiteral */:
|
|
810
|
-
|
|
836
|
+
{
|
|
837
|
+
const y = ast.propertySignatures.length;
|
|
838
|
+
const z = ast.indexSignatures.length;
|
|
839
|
+
return y + z === 0 ? [-4, 0, 0] : [4, y, z];
|
|
840
|
+
}
|
|
811
841
|
case 18 /* ASTTag.Union */:
|
|
812
|
-
return
|
|
842
|
+
return maxWeightAll(tsplus_module_3.map(getWeight)(ast.types));
|
|
813
843
|
case 19 /* ASTTag.Lazy */:
|
|
814
|
-
return
|
|
844
|
+
return [8, 0, 0];
|
|
815
845
|
case 20 /* ASTTag.Refinement */:
|
|
816
|
-
|
|
846
|
+
const [x, y, z] = getWeight(ast.from);
|
|
847
|
+
return [x + 1, y, z];
|
|
817
848
|
case 21 /* ASTTag.Transform */:
|
|
818
|
-
return getWeight(ast.
|
|
849
|
+
return getWeight(ast.from);
|
|
850
|
+
case 13 /* ASTTag.ObjectKeyword */:
|
|
851
|
+
return [-2, 0, 0];
|
|
852
|
+
case 6 /* ASTTag.UnknownKeyword */:
|
|
853
|
+
case 7 /* ASTTag.AnyKeyword */:
|
|
854
|
+
return [-4, 0, 0];
|
|
819
855
|
default:
|
|
820
|
-
return
|
|
856
|
+
return emptyWeight;
|
|
821
857
|
}
|
|
822
858
|
}
|
|
823
859
|
function sortByDescendingWeight(types) {
|
|
824
|
-
return
|
|
860
|
+
return tsplus_module_3.sort(tsplus_module_8.contramap(getWeight)(OrdWeight))(types);
|
|
825
861
|
}
|
|
826
862
|
function unify(candidates) {
|
|
827
|
-
let out =
|
|
863
|
+
let out = tsplus_module_3.flatMap(ast => {
|
|
828
864
|
void 0;
|
|
829
865
|
switch (ast._tag) {
|
|
830
866
|
case 5 /* ASTTag.NeverKeyword */:
|
|
831
|
-
return
|
|
867
|
+
return tsplus_module_3.empty();
|
|
832
868
|
case 18 /* ASTTag.Union */:
|
|
833
869
|
return ast.types;
|
|
834
870
|
default:
|
|
835
|
-
return
|
|
871
|
+
return tsplus_module_3.vector(ast);
|
|
836
872
|
}
|
|
837
873
|
})(candidates);
|
|
838
|
-
if (
|
|
839
|
-
out =
|
|
874
|
+
if (tsplus_module_3.some(isStringKeyword_1)(out)) {
|
|
875
|
+
out = tsplus_module_3.filter(m => !(isLiteral_1(m) && typeof m.literal === "string"))(out);
|
|
840
876
|
}
|
|
841
|
-
if (
|
|
842
|
-
out =
|
|
877
|
+
if (tsplus_module_3.some(isNumberKeyword_1)(out)) {
|
|
878
|
+
out = tsplus_module_3.filter(m => !(isLiteral_1(m) && typeof m.literal === "number"))(out);
|
|
843
879
|
}
|
|
844
|
-
if (
|
|
845
|
-
out =
|
|
880
|
+
if (tsplus_module_3.some(isSymbolKeyword_1)(out)) {
|
|
881
|
+
out = tsplus_module_3.filter(m => !isUniqueSymbol_1(m))(out);
|
|
846
882
|
}
|
|
847
883
|
return out;
|
|
848
884
|
}
|
|
@@ -871,10 +907,10 @@ function setAnnotation(annotation, value) {
|
|
|
871
907
|
*/
|
|
872
908
|
function appendRestElement(restElement) {
|
|
873
909
|
return self => {
|
|
874
|
-
if (
|
|
910
|
+
if (tsplus_module_13.isJust(self.rest)) {
|
|
875
911
|
throw new Error("A rest element cannot follow another rest element. ts(1265)");
|
|
876
912
|
}
|
|
877
|
-
return createTuple_1(self.elements,
|
|
913
|
+
return createTuple_1(self.elements, tsplus_module_4.just(tsplus_module_3.vector(restElement), fileName_1 + ":1115:43"), self.isReadonly, self.annotations);
|
|
878
914
|
};
|
|
879
915
|
}
|
|
880
916
|
/**
|
|
@@ -882,14 +918,14 @@ function appendRestElement(restElement) {
|
|
|
882
918
|
*/
|
|
883
919
|
function appendElement(element) {
|
|
884
920
|
return self => {
|
|
885
|
-
if (
|
|
921
|
+
if (tsplus_module_3.some(e => e.isOptional)(self.elements) && !element.isOptional) {
|
|
886
922
|
throw new Error("A required element cannot follow an optional element. ts(1257)");
|
|
887
923
|
}
|
|
888
|
-
return
|
|
924
|
+
return tsplus_module_12.match(() => createTuple_1(tsplus_module_3.append(element)(self.elements), tsplus_module_4.nothing(fileName_1 + ":1128:63"), self.isReadonly, self.annotations), rest => {
|
|
889
925
|
if (element.isOptional) {
|
|
890
926
|
throw new Error("A required element cannot follow an optional element. ts(1257)");
|
|
891
927
|
}
|
|
892
|
-
return createTuple_1(self.elements,
|
|
928
|
+
return createTuple_1(self.elements, tsplus_module_4.just(tsplus_module_3.append(element.type)(rest), fileName_1 + ":1133:47"), self.isReadonly, self.annotations);
|
|
893
929
|
})(self.rest);
|
|
894
930
|
};
|
|
895
931
|
}
|
|
@@ -903,22 +939,24 @@ function getPropertySignatures_1(self) {
|
|
|
903
939
|
void 0;
|
|
904
940
|
switch (self._tag) {
|
|
905
941
|
case 0 /* ASTTag.Declaration */:
|
|
906
|
-
return getPropertySignatures_1(self.
|
|
942
|
+
return tsplus_module_12.match(() => tsplus_module_3.empty(), surrogate => getPropertySignatures_1(surrogate))(self.annotations.get(tsplus_module_2.Surrogate));
|
|
907
943
|
case 16 /* ASTTag.Tuple */:
|
|
908
|
-
return
|
|
944
|
+
return tsplus_module_3.mapWithIndex((i, element) => createPropertySignature_1(i, element.type, element.isOptional, self.isReadonly))(self.elements);
|
|
909
945
|
case 18 /* ASTTag.Union */:
|
|
910
946
|
{
|
|
911
|
-
const propertySignatures =
|
|
912
|
-
return
|
|
947
|
+
const propertySignatures = tsplus_module_3.map(getPropertySignatures_1)(self.types);
|
|
948
|
+
return tsplus_module_3.filterMap(({
|
|
913
949
|
name
|
|
914
950
|
}) => {
|
|
915
|
-
if (
|
|
916
|
-
const members =
|
|
917
|
-
return
|
|
951
|
+
if (tsplus_module_3.every(ps => tsplus_module_3.some(p => p.name === name)(ps))(propertySignatures)) {
|
|
952
|
+
const members = tsplus_module_3.flatMap(ps => tsplus_module_3.filter(p => p.name === name)(ps))(propertySignatures);
|
|
953
|
+
return tsplus_module_4.just(createPropertySignature_1(name, createUnion_1(tsplus_module_3.map(p => p.type)(members)), tsplus_module_3.some(p => p.isOptional)(members), tsplus_module_3.some(p => p.isReadonly)(members)), fileName_1 + ":1163:22");
|
|
918
954
|
}
|
|
919
|
-
return
|
|
920
|
-
})(
|
|
955
|
+
return tsplus_module_4.nothing(fileName_1 + ":1172:23");
|
|
956
|
+
})(tsplus_module_3.unsafeGet(0)(propertySignatures));
|
|
921
957
|
}
|
|
958
|
+
case 17 /* ASTTag.TypeLiteral */:
|
|
959
|
+
return self.propertySignatures;
|
|
922
960
|
case 19 /* ASTTag.Lazy */:
|
|
923
961
|
return getPropertySignatures_1(self.getAST());
|
|
924
962
|
case 20 /* ASTTag.Refinement */:
|
|
@@ -926,7 +964,7 @@ function getPropertySignatures_1(self) {
|
|
|
926
964
|
case 21 /* ASTTag.Transform */:
|
|
927
965
|
return getPropertySignatures_1(self.to);
|
|
928
966
|
default:
|
|
929
|
-
return
|
|
967
|
+
return tsplus_module_3.empty();
|
|
930
968
|
}
|
|
931
969
|
}
|
|
932
970
|
/**
|
|
@@ -936,16 +974,16 @@ function keysOf_1(ast) {
|
|
|
936
974
|
void 0;
|
|
937
975
|
switch (ast._tag) {
|
|
938
976
|
case 0 /* ASTTag.Declaration */:
|
|
939
|
-
return keysOf_1(ast.
|
|
977
|
+
return tsplus_module_12.match(() => tsplus_module_3.empty(), surrogate => keysOf_1(surrogate))(ast.annotations.get(tsplus_module_2.Surrogate));
|
|
940
978
|
case 5 /* ASTTag.NeverKeyword */:
|
|
941
979
|
case 7 /* ASTTag.AnyKeyword */:
|
|
942
|
-
return
|
|
980
|
+
return tsplus_module_3.vector(stringKeyword_1, numberKeyword_1, symbolKeyword_1);
|
|
943
981
|
case 8 /* ASTTag.StringKeyword */:
|
|
944
|
-
return
|
|
982
|
+
return tsplus_module_3.vector(createLiteral_1("length"));
|
|
945
983
|
case 17 /* ASTTag.TypeLiteral */:
|
|
946
|
-
return
|
|
984
|
+
return tsplus_module_3.concat(tsplus_module_3.map(is => getParameter(is.parameter))(ast.indexSignatures))(tsplus_module_3.map(p => typeof p.name === "symbol" ? createUniqueSymbol_1(p.name) : createLiteral_1(p.name))(ast.propertySignatures));
|
|
947
985
|
case 18 /* ASTTag.Union */:
|
|
948
|
-
return
|
|
986
|
+
return tsplus_module_3.map(p => typeof p.name === "symbol" ? createUniqueSymbol_1(p.name) : createLiteral_1(p.name))(getPropertySignatures_1(ast));
|
|
949
987
|
case 19 /* ASTTag.Lazy */:
|
|
950
988
|
return keysOf_1(ast.getAST());
|
|
951
989
|
case 20 /* ASTTag.Refinement */:
|
|
@@ -953,7 +991,7 @@ function keysOf_1(ast) {
|
|
|
953
991
|
case 21 /* ASTTag.Transform */:
|
|
954
992
|
return keysOf_1(ast.to);
|
|
955
993
|
default:
|
|
956
|
-
return
|
|
994
|
+
return tsplus_module_3.empty();
|
|
957
995
|
}
|
|
958
996
|
}
|
|
959
997
|
/**
|
|
@@ -966,32 +1004,29 @@ function keyof(self) {
|
|
|
966
1004
|
* @tsplus static fncts.schema.ASTOps createRecord
|
|
967
1005
|
*/
|
|
968
1006
|
function createRecord(key, value, isReadonly) {
|
|
969
|
-
const propertySignatures =
|
|
970
|
-
const indexSignatures =
|
|
1007
|
+
const propertySignatures = tsplus_module_3.emptyPushable();
|
|
1008
|
+
const indexSignatures = tsplus_module_3.emptyPushable();
|
|
971
1009
|
function go(key) {
|
|
972
1010
|
void 0;
|
|
973
1011
|
switch (key._tag) {
|
|
974
|
-
case 0 /* ASTTag.Declaration */:
|
|
975
|
-
go(key.type);
|
|
976
|
-
break;
|
|
977
1012
|
case 5 /* ASTTag.NeverKeyword */:
|
|
978
1013
|
break;
|
|
979
1014
|
case 8 /* ASTTag.StringKeyword */:
|
|
980
1015
|
case 12 /* ASTTag.SymbolKeyword */:
|
|
981
1016
|
case 15 /* ASTTag.TemplateLiteral */:
|
|
982
1017
|
case 20 /* ASTTag.Refinement */:
|
|
983
|
-
|
|
1018
|
+
tsplus_module_14.push(createIndexSignature_1(key, value, isReadonly))(indexSignatures);
|
|
984
1019
|
break;
|
|
985
1020
|
case 1 /* ASTTag.Literal */:
|
|
986
1021
|
if (typeof key.literal === "string" || typeof key.literal === "number") {
|
|
987
|
-
|
|
1022
|
+
tsplus_module_14.push(createPropertySignature_1(key.literal, value, false, isReadonly))(propertySignatures);
|
|
988
1023
|
}
|
|
989
1024
|
break;
|
|
990
1025
|
case 2 /* ASTTag.UniqueSymbol */:
|
|
991
|
-
|
|
1026
|
+
tsplus_module_14.push(createPropertySignature_1(key.symbol, value, false, isReadonly))(propertySignatures);
|
|
992
1027
|
break;
|
|
993
1028
|
case 18 /* ASTTag.Union */:
|
|
994
|
-
|
|
1029
|
+
tsplus_module_3.forEach(go)(key.types);
|
|
995
1030
|
break;
|
|
996
1031
|
default:
|
|
997
1032
|
throw new Error(`createRecord: Unsupported key\n${(0, _Showable.show)(key)}`);
|
|
@@ -1005,7 +1040,7 @@ function createRecord(key, value, isReadonly) {
|
|
|
1005
1040
|
*/
|
|
1006
1041
|
function pick(keys) {
|
|
1007
1042
|
return self => {
|
|
1008
|
-
return createTypeLiteral_1(
|
|
1043
|
+
return createTypeLiteral_1(tsplus_module_3.filter(ps => tsplus_module_3.includes(ps.name)(keys))(getPropertySignatures_1(self)), tsplus_module_3.empty());
|
|
1009
1044
|
};
|
|
1010
1045
|
}
|
|
1011
1046
|
/**
|
|
@@ -1013,7 +1048,7 @@ function pick(keys) {
|
|
|
1013
1048
|
*/
|
|
1014
1049
|
function omit(keys) {
|
|
1015
1050
|
return self => {
|
|
1016
|
-
return createTypeLiteral_1(
|
|
1051
|
+
return createTypeLiteral_1(tsplus_module_3.filter(ps => !tsplus_module_3.includes(ps.name)(keys))(getPropertySignatures_1(self)), tsplus_module_3.empty());
|
|
1017
1052
|
};
|
|
1018
1053
|
}
|
|
1019
1054
|
/**
|
|
@@ -1022,14 +1057,12 @@ function omit(keys) {
|
|
|
1022
1057
|
function partial_1(self) {
|
|
1023
1058
|
void 0;
|
|
1024
1059
|
switch (self._tag) {
|
|
1025
|
-
case 0 /* ASTTag.Declaration */:
|
|
1026
|
-
return partial_1(self.type);
|
|
1027
1060
|
case 16 /* ASTTag.Tuple */:
|
|
1028
|
-
return createTuple_1(
|
|
1061
|
+
return createTuple_1(tsplus_module_3.map(e => createElement_1(e.type, true))(self.elements), tsplus_module_15.map(rest => tsplus_module_3.vector(createUnion_1(tsplus_module_3.append(undefinedKeyword_1)(rest))))(self.rest), self.isReadonly);
|
|
1029
1062
|
case 17 /* ASTTag.TypeLiteral */:
|
|
1030
|
-
return createTypeLiteral_1(
|
|
1063
|
+
return createTypeLiteral_1(tsplus_module_3.map(f => createPropertySignature_1(f.name, f.type, true, f.isReadonly, f.annotations))(self.propertySignatures), self.indexSignatures);
|
|
1031
1064
|
case 18 /* ASTTag.Union */:
|
|
1032
|
-
return createUnion_1(
|
|
1065
|
+
return createUnion_1(tsplus_module_3.map(partial_1)(self.types));
|
|
1033
1066
|
case 19 /* ASTTag.Lazy */:
|
|
1034
1067
|
return createLazy_1(() => partial_1(self.getAST()));
|
|
1035
1068
|
case 20 /* ASTTag.Refinement */:
|
|
@@ -1053,13 +1086,19 @@ function getFrom_1(ast) {
|
|
|
1053
1086
|
void 0;
|
|
1054
1087
|
switch (ast._tag) {
|
|
1055
1088
|
case 0 /* ASTTag.Declaration */:
|
|
1056
|
-
|
|
1089
|
+
{
|
|
1090
|
+
const surrogate = ast.annotations.get(tsplus_module_2.Surrogate);
|
|
1091
|
+
if (tsplus_module_13.isJust(surrogate)) {
|
|
1092
|
+
return getFrom_1(surrogate.value);
|
|
1093
|
+
}
|
|
1094
|
+
break;
|
|
1095
|
+
}
|
|
1057
1096
|
case 16 /* ASTTag.Tuple */:
|
|
1058
|
-
return createTuple_1(
|
|
1097
|
+
return createTuple_1(tsplus_module_3.map(element => createElement_1(getFrom_1(element.type), element.isOptional))(ast.elements), tsplus_module_15.map(restElement => tsplus_module_3.map(getFrom_1)(restElement))(ast.rest), ast.isReadonly, ast.annotations);
|
|
1059
1098
|
case 17 /* ASTTag.TypeLiteral */:
|
|
1060
|
-
return createTypeLiteral_1(
|
|
1099
|
+
return createTypeLiteral_1(tsplus_module_3.map(ps => createPropertySignature_1(ps.name, getFrom_1(ps.type), ps.isOptional, ps.isReadonly, ps.annotations))(ast.propertySignatures), tsplus_module_3.map(is => createIndexSignature_1(is.parameter, getFrom_1(is.type), is.isReadonly))(ast.indexSignatures), ast.annotations);
|
|
1061
1100
|
case 18 /* ASTTag.Union */:
|
|
1062
|
-
return createUnion_1(
|
|
1101
|
+
return createUnion_1(tsplus_module_3.map(getFrom_1)(ast.types), ast.annotations);
|
|
1063
1102
|
case 19 /* ASTTag.Lazy */:
|
|
1064
1103
|
return createLazy_1(() => getFrom_1(ast.getAST()), ast.annotations);
|
|
1065
1104
|
case 20 /* ASTTag.Refinement */:
|
|
@@ -1075,13 +1114,19 @@ function getTo_1(ast) {
|
|
|
1075
1114
|
void 0;
|
|
1076
1115
|
switch (ast._tag) {
|
|
1077
1116
|
case 0 /* ASTTag.Declaration */:
|
|
1078
|
-
|
|
1117
|
+
{
|
|
1118
|
+
const surrogate = ast.annotations.get(tsplus_module_2.Surrogate);
|
|
1119
|
+
if (tsplus_module_13.isJust(surrogate)) {
|
|
1120
|
+
return getTo_1(surrogate.value);
|
|
1121
|
+
}
|
|
1122
|
+
break;
|
|
1123
|
+
}
|
|
1079
1124
|
case 16 /* ASTTag.Tuple */:
|
|
1080
|
-
return createTuple_1(
|
|
1125
|
+
return createTuple_1(tsplus_module_3.map(element => createElement_1(getTo_1(element.type), element.isOptional))(ast.elements), tsplus_module_15.map(restElement => tsplus_module_3.map(getTo_1)(restElement))(ast.rest), ast.isReadonly, ast.annotations);
|
|
1081
1126
|
case 17 /* ASTTag.TypeLiteral */:
|
|
1082
|
-
return createTypeLiteral_1(
|
|
1127
|
+
return createTypeLiteral_1(tsplus_module_3.map(ps => createPropertySignature_1(ps.name, getTo_1(ps.type), ps.isOptional, ps.isReadonly, ps.annotations))(ast.propertySignatures), tsplus_module_3.map(is => createIndexSignature_1(is.parameter, getTo_1(is.type), is.isReadonly))(ast.indexSignatures), ast.annotations);
|
|
1083
1128
|
case 18 /* ASTTag.Union */:
|
|
1084
|
-
return createUnion_1(
|
|
1129
|
+
return createUnion_1(tsplus_module_3.map(getTo_1)(ast.types), ast.annotations);
|
|
1085
1130
|
case 19 /* ASTTag.Lazy */:
|
|
1086
1131
|
return createLazy_1(() => getTo_1(ast.getAST()), ast.annotations);
|
|
1087
1132
|
case 20 /* ASTTag.Refinement */:
|
|
@@ -1105,12 +1150,18 @@ function getLiterals(ast, isDecoding) {
|
|
|
1105
1150
|
void 0;
|
|
1106
1151
|
switch (ast._tag) {
|
|
1107
1152
|
case 0 /* ASTTag.Declaration */:
|
|
1108
|
-
|
|
1153
|
+
{
|
|
1154
|
+
const surrogate = ast.annotations.get(tsplus_module_2.Surrogate);
|
|
1155
|
+
if (tsplus_module_13.isJust(surrogate)) {
|
|
1156
|
+
return getLiterals(surrogate.value, isDecoding);
|
|
1157
|
+
}
|
|
1158
|
+
break;
|
|
1159
|
+
}
|
|
1109
1160
|
case 17 /* ASTTag.TypeLiteral */:
|
|
1110
1161
|
{
|
|
1111
1162
|
const out = [];
|
|
1112
1163
|
for (let i = 0; i < ast.propertySignatures.length; i++) {
|
|
1113
|
-
const propertySignature =
|
|
1164
|
+
const propertySignature = tsplus_module_3.unsafeGet(i)(ast.propertySignatures);
|
|
1114
1165
|
if (isLiteral_1(propertySignature.type) && !propertySignature.isOptional) {
|
|
1115
1166
|
out.push([propertySignature.name, propertySignature.type]);
|
|
1116
1167
|
}
|
|
@@ -1128,7 +1179,7 @@ function getSearchTree(members, isDecoding) {
|
|
|
1128
1179
|
const keys = {};
|
|
1129
1180
|
const otherwise = [];
|
|
1130
1181
|
for (let i = 0; i < members.length; i++) {
|
|
1131
|
-
const member =
|
|
1182
|
+
const member = tsplus_module_3.unsafeGet(i)(members);
|
|
1132
1183
|
const tags = getLiterals(member, isDecoding);
|
|
1133
1184
|
if (tags.length > 0) {
|
|
1134
1185
|
for (let j = 0; j < tags.length; j++) {
|
|
@@ -1136,7 +1187,8 @@ function getSearchTree(members, isDecoding) {
|
|
|
1136
1187
|
const hash = String(literal.literal);
|
|
1137
1188
|
keys[key] || (keys[key] = {
|
|
1138
1189
|
buckets: {},
|
|
1139
|
-
ast: neverKeyword_1
|
|
1190
|
+
ast: neverKeyword_1,
|
|
1191
|
+
literals: []
|
|
1140
1192
|
});
|
|
1141
1193
|
const buckets = keys[key].buckets;
|
|
1142
1194
|
if (Object.prototype.hasOwnProperty.call(buckets, hash)) {
|
|
@@ -1144,10 +1196,12 @@ function getSearchTree(members, isDecoding) {
|
|
|
1144
1196
|
continue;
|
|
1145
1197
|
}
|
|
1146
1198
|
buckets[hash].push(member);
|
|
1147
|
-
keys[key].ast = createUnion_1(
|
|
1199
|
+
keys[key].ast = createUnion_1(tsplus_module_3.vector(keys[key].ast, literal));
|
|
1200
|
+
keys[key].literals.push(literal);
|
|
1148
1201
|
} else {
|
|
1149
1202
|
buckets[hash] = [member];
|
|
1150
|
-
keys[key].ast = createUnion_1(
|
|
1203
|
+
keys[key].ast = createUnion_1(tsplus_module_3.vector(keys[key].ast, literal));
|
|
1204
|
+
keys[key].literals.push(literal);
|
|
1151
1205
|
break;
|
|
1152
1206
|
}
|
|
1153
1207
|
}
|
|
@@ -1160,4 +1214,17 @@ function getSearchTree(members, isDecoding) {
|
|
|
1160
1214
|
otherwise
|
|
1161
1215
|
};
|
|
1162
1216
|
}
|
|
1217
|
+
/**
|
|
1218
|
+
* @tsplus pipeable fncts.schema.AST getFormattedExpected
|
|
1219
|
+
*/
|
|
1220
|
+
function getFormattedExpected(verbose = false) {
|
|
1221
|
+
return self => {
|
|
1222
|
+
if (verbose) {
|
|
1223
|
+
const description = tsplus_module_15.orElse(() => self.annotations.get(tsplus_module_2.Title))(self.annotations.get(tsplus_module_2.Description));
|
|
1224
|
+
return tsplus_module_12.match(() => description, identifier => tsplus_module_12.match(() => tsplus_module_4.just(identifier, fileName_1 + ":1510:23"), description => tsplus_module_4.just(`${identifier} (${description})`, fileName_1 + ":1511:34"))(description))(self.annotations.get(tsplus_module_2.Identifier));
|
|
1225
|
+
} else {
|
|
1226
|
+
return tsplus_module_15.orElse(() => self.annotations.get(tsplus_module_2.Description))(tsplus_module_15.orElse(() => self.annotations.get(tsplus_module_2.Title))(self.annotations.get(tsplus_module_2.Identifier)));
|
|
1227
|
+
}
|
|
1228
|
+
};
|
|
1229
|
+
}
|
|
1163
1230
|
//# sourceMappingURL=AST.cjs.map
|