@fncts/schema 0.0.15 → 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 +12 -2
- package/Schema/derivations.d.ts +1 -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 +21 -3
- 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 +19 -3
- 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 +21 -3
- package/_src/Schema/derivations.ts +1 -1
- 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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ParseErrorFormatter.mjs","names":[],"sources":["../../_src/ParseError/ParseErrorFormatter.ts"],"sourcesContent":[null],"mappings":""}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import * as tsplus_module_1 from "@fncts/base/collection/Iterable/api";
|
|
2
|
+
import * as tsplus_module_2 from "@fncts/base/data/Maybe/destructors";
|
|
3
|
+
import { formatTypeError, getMessage } from "./TreeFormatter.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* @tsplus getter fncts.schema.ParseError flatten
|
|
6
|
+
*/
|
|
7
|
+
export function flatten(error) {
|
|
8
|
+
return go(error, []);
|
|
9
|
+
function go(error, path) {
|
|
10
|
+
switch (error._tag) {
|
|
11
|
+
case 10 /* ParseErrorTag.Tuple */:
|
|
12
|
+
{
|
|
13
|
+
return getFlattenedParseError(error, path, () => tsplus_module_1.toArray(tsplus_module_1.flatMap(error => go(error.error, path.concat(error.index)))(error.errors)));
|
|
14
|
+
}
|
|
15
|
+
case 11 /* ParseErrorTag.Union */:
|
|
16
|
+
{
|
|
17
|
+
return getFlattenedParseError(error, path, () => tsplus_module_1.toArray(tsplus_module_1.flatMap(error => {
|
|
18
|
+
if (error._tag === 6 /* ParseErrorTag.UnionMember */) {
|
|
19
|
+
return go(error.error, path);
|
|
20
|
+
} else {
|
|
21
|
+
return go(error, path);
|
|
22
|
+
}
|
|
23
|
+
})(error.errors)));
|
|
24
|
+
}
|
|
25
|
+
case 9 /* ParseErrorTag.TypeLiteral */:
|
|
26
|
+
{
|
|
27
|
+
return getFlattenedParseError(error, path, () => tsplus_module_1.toArray(tsplus_module_1.flatMap(key => go(key.error, path.concat(key.key)))(error.errors)));
|
|
28
|
+
}
|
|
29
|
+
case 4 /* ParseErrorTag.Missing */:
|
|
30
|
+
{
|
|
31
|
+
return [{
|
|
32
|
+
type: error._tag,
|
|
33
|
+
path: path,
|
|
34
|
+
message: "is missing"
|
|
35
|
+
}];
|
|
36
|
+
}
|
|
37
|
+
case 5 /* ParseErrorTag.Unexpected */:
|
|
38
|
+
{
|
|
39
|
+
return [{
|
|
40
|
+
type: error._tag,
|
|
41
|
+
path: path,
|
|
42
|
+
message: "is unexpected"
|
|
43
|
+
}];
|
|
44
|
+
}
|
|
45
|
+
case 1 /* ParseErrorTag.Type */:
|
|
46
|
+
{
|
|
47
|
+
return [{
|
|
48
|
+
type: error._tag,
|
|
49
|
+
path: path,
|
|
50
|
+
message: formatTypeError(error)
|
|
51
|
+
}];
|
|
52
|
+
}
|
|
53
|
+
case 0 /* ParseErrorTag.Declaration */:
|
|
54
|
+
case 8 /* ParseErrorTag.Transformation */:
|
|
55
|
+
case 7 /* ParseErrorTag.Refinement */:
|
|
56
|
+
{
|
|
57
|
+
return getFlattenedParseError(error, path, () => go(error.error, path));
|
|
58
|
+
}
|
|
59
|
+
case 12 /* ParseErrorTag.Iterable */:
|
|
60
|
+
{
|
|
61
|
+
return getFlattenedParseError(error, path, () => tsplus_module_1.toArray(tsplus_module_1.flatMap(error => {
|
|
62
|
+
switch (error._tag) {
|
|
63
|
+
case 3 /* ParseErrorTag.Key */:
|
|
64
|
+
{
|
|
65
|
+
return go(error.error, path.concat(error.key));
|
|
66
|
+
}
|
|
67
|
+
case 2 /* ParseErrorTag.Index */:
|
|
68
|
+
{
|
|
69
|
+
return go(error.error, path.concat(error.index));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
})(error.errors)));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function getFlattenedParseError(error, path, orElse) {
|
|
78
|
+
return tsplus_module_2.match(() => orElse(), message => {
|
|
79
|
+
return [{
|
|
80
|
+
type: error._tag,
|
|
81
|
+
path,
|
|
82
|
+
message
|
|
83
|
+
}];
|
|
84
|
+
})(getMessage(error));
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=PathFormatter.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PathFormatter.mjs","names":["formatTypeError","getMessage","flatten","error","go","path","_tag","getFlattenedParseError","tsplus_module_1","toArray","flatMap","concat","index","errors","key","type","message","orElse","tsplus_module_2","match"],"sources":["../../_src/ParseError/PathFormatter.ts"],"sourcesContent":[null],"mappings":";;AAGA,SAASA,eAAe,EAAEC,UAAU,QAAQ,qBAAoB;AAQhE;;;AAGA,OAAM,SAAUC,OAAOA,CAACC,KAAiB;EACvC,OAAOC,EAAE,CAACD,KAAK,EAAE,E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AE;WACD,CACX;QACH;MACA;QAAyB;UACvB,OAAO,CACL;YACED,IAAI,EAAEZ,KAAK,CAACG,IAAI;YAChBD,IAAI,EAAEA,IAAI;YACVW,OAAO,EAAEhB,eAAe,CAACG,KAAK;WACtB,CACX;QACH;MACA;MACA;MACA;QAA+B;UAC7B,OAAOI,sBAAsB,CAACJ,KAAK,EAAEE,IAAI,QAAED,EAAE,CAACD,KAAK,CAACA,KAAK,EAAEE,IAAI,CAAC,CAAC;QACnE;MACA;QAA6B;UAC3B,OAAOE,sBAAsB,CAC3BJ,KAAK,EACLE,IAAI,QAAAG,eAAA,CAAAC,OAAA,CACJD,eAAA,CAAAE,OAAA,CAAsBP,KAAK,IAAI;YAC7B,QAAQA,KAAK,CAACG,IAAI;cAChB;gBAAwB;kBACtB,OAAOF,EAAE,CAACD,KAAK,CAACA,KAAK,EAAEE,IAAI,CAACM,MAAM,CAACR,KAAK,CAACW,GAAG,CAAC,CAAC;gBAChD;cACA;gBAA0B;kBACxB,OAAOV,EAAE,CAACD,KAAK,CAACA,KAAK,EAAEE,IAAI,CAACM,MAAM,CAACR,KAAK,CAACS,KAAK,CAAC,CAAC;gBAClD;YACF;UACF,CAAC,EATDT,KAAK,CAACU,MAAM,CASV,EACH;QACH;IACF;EACF;AACF;AAEA,SAASN,sBAAsBA,CAC7BJ,KAAiB,EACjBE,IAAwB,EACxBY,MAAmC;EAEnC,OAAOC,eAAA,CAAAC,KAAA,CACL,MAAMF,MAAM,EAAE,EACbD,OAAO,IAAI;IACV,OAAO,CACL;MACED,IAAI,EAAEZ,KAAK,CAACG,IAAI;MAChBD,IAAI;MACJW;KACD,CACF;EACH,CAAC,EAVIf,UAAU,CAACE,KAAK,CAAC,CAWvB;AACH"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import * as tsplus_module_1 from "@fncts/base/collection/immutable/RoseTree/api";
|
|
2
|
+
import * as tsplus_module_2 from "@fncts/schema/ASTAnnotation";
|
|
3
|
+
import * as tsplus_module_3 from "@fncts/base/data/Maybe/api";
|
|
4
|
+
import * as tsplus_module_4 from "@fncts/base/collection/immutable/Vector/api";
|
|
5
|
+
import * as tsplus_module_5 from "@fncts/base/data/Maybe/destructors";
|
|
6
|
+
import { showWithOptions } from "@fncts/base/data/Showable";
|
|
7
|
+
/**
|
|
8
|
+
* @tsplus static fncts.schema.ParseErrorOps drawTree
|
|
9
|
+
* @tsplus getter fncts.schema.ParseError drawTree
|
|
10
|
+
*/
|
|
11
|
+
export function format(error) {
|
|
12
|
+
return tsplus_module_1.draw(go(error));
|
|
13
|
+
}
|
|
14
|
+
function formatActual(actual) {
|
|
15
|
+
return showWithOptions(actual, {
|
|
16
|
+
colors: false
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function formatRefinementKind(error) {
|
|
20
|
+
switch (error.kind) {
|
|
21
|
+
case "From":
|
|
22
|
+
{
|
|
23
|
+
return "From side refinement failure";
|
|
24
|
+
}
|
|
25
|
+
case "Predicate":
|
|
26
|
+
{
|
|
27
|
+
return "Predicate refinement failure";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function formatTransformationKind(error) {
|
|
32
|
+
switch (error.kind) {
|
|
33
|
+
case "Encoded":
|
|
34
|
+
{
|
|
35
|
+
return "Encoded side transformation failure";
|
|
36
|
+
}
|
|
37
|
+
case "Transformation":
|
|
38
|
+
{
|
|
39
|
+
return "Transformation process failure";
|
|
40
|
+
}
|
|
41
|
+
case "Type":
|
|
42
|
+
{
|
|
43
|
+
return "Type side transformation failure";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export function getMessage(error) {
|
|
48
|
+
return tsplus_module_3.map(f => f(error))(error.ast.annotations.get(tsplus_module_2.Message));
|
|
49
|
+
}
|
|
50
|
+
export function formatTypeError(error) {
|
|
51
|
+
return tsplus_module_3.getOrElse(() => `Expected ${error.ast.toString(true)}, actual ${formatActual(error.actual)}`)(getMessage(error));
|
|
52
|
+
}
|
|
53
|
+
function formatKeyErrors(errors) {
|
|
54
|
+
return tsplus_module_4.map(error => {
|
|
55
|
+
if (error._tag === 3 /* ParseErrorTag.Key */) {
|
|
56
|
+
return tsplus_module_1.make(`[${String(error.keyAST)}]`, tsplus_module_4.vector(go(error.error)));
|
|
57
|
+
} else {
|
|
58
|
+
return tsplus_module_1.make(`[${error.index}]`, tsplus_module_4.vector(go(error.error)));
|
|
59
|
+
}
|
|
60
|
+
})(errors);
|
|
61
|
+
}
|
|
62
|
+
function getRoseTree(error, orElse) {
|
|
63
|
+
return tsplus_module_5.match(() => orElse(), message => tsplus_module_1.make(message))(getMessage(error));
|
|
64
|
+
}
|
|
65
|
+
function go(error) {
|
|
66
|
+
switch (error._tag) {
|
|
67
|
+
case 1 /* ParseErrorTag.Type */:
|
|
68
|
+
return tsplus_module_1.make(formatTypeError(error));
|
|
69
|
+
case 0 /* ParseErrorTag.Declaration */:
|
|
70
|
+
return getRoseTree(error, () => {
|
|
71
|
+
const shouldSkipDefaultMessage = error.error._tag === 1 /* ParseErrorTag.Type */ && error.error.ast === error.ast;
|
|
72
|
+
if (shouldSkipDefaultMessage) {
|
|
73
|
+
return go(error.error);
|
|
74
|
+
} else {
|
|
75
|
+
return tsplus_module_1.make(error.ast.toString(true), tsplus_module_4.vector(go(error.error)));
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
case 5 /* ParseErrorTag.Unexpected */:
|
|
79
|
+
return tsplus_module_1.make("is unexpected");
|
|
80
|
+
case 4 /* ParseErrorTag.Missing */:
|
|
81
|
+
return tsplus_module_1.make("is missing");
|
|
82
|
+
case 9 /* ParseErrorTag.TypeLiteral */:
|
|
83
|
+
return getRoseTree(error, () => {
|
|
84
|
+
return tsplus_module_1.make(error.ast.toString(true), formatKeyErrors(error.errors));
|
|
85
|
+
});
|
|
86
|
+
case 10 /* ParseErrorTag.Tuple */:
|
|
87
|
+
return getRoseTree(error, () => {
|
|
88
|
+
return tsplus_module_1.make(error.ast.toString(true), formatKeyErrors(error.errors));
|
|
89
|
+
});
|
|
90
|
+
case 11 /* ParseErrorTag.Union */:
|
|
91
|
+
return tsplus_module_1.make(error.ast.toString(true), tsplus_module_4.map(error => {
|
|
92
|
+
switch (error._tag) {
|
|
93
|
+
case 6 /* ParseErrorTag.UnionMember */:
|
|
94
|
+
return tsplus_module_1.make("Union member", tsplus_module_4.vector(go(error.error)));
|
|
95
|
+
default:
|
|
96
|
+
return go(error);
|
|
97
|
+
}
|
|
98
|
+
})(error.errors));
|
|
99
|
+
case 7 /* ParseErrorTag.Refinement */:
|
|
100
|
+
return getRoseTree(error, () => {
|
|
101
|
+
return tsplus_module_1.make(formatRefinementKind(error), tsplus_module_4.vector(go(error.error)));
|
|
102
|
+
});
|
|
103
|
+
case 8 /* ParseErrorTag.Transformation */:
|
|
104
|
+
return getRoseTree(error, () => {
|
|
105
|
+
return tsplus_module_1.make(formatTransformationKind(error), tsplus_module_4.vector(go(error.error)));
|
|
106
|
+
});
|
|
107
|
+
case 12 /* ParseErrorTag.Iterable */:
|
|
108
|
+
return getRoseTree(error, () => {
|
|
109
|
+
return tsplus_module_1.make(error.ast.toString(true), formatKeyErrors(error.errors));
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=TreeFormatter.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeFormatter.mjs","names":["showWithOptions","format","error","tsplus_module_1","draw","go","formatActual","actual","colors","formatRefinementKind","kind","formatTransformationKind","getMessage","tsplus_module_3","map","f","ast","annotations","get","tsplus_module_2","Message","formatTypeError","getOrElse","toString","formatKeyErrors","errors","tsplus_module_4","_tag","make","String","keyAST","vector","index","getRoseTree","orElse","tsplus_module_5","match","message","shouldSkipDefaultMessage"],"sources":["../../_src/ParseError/TreeFormatter.ts"],"sourcesContent":[null],"mappings":";;;;;AAUA,SAASA,eAAe,QAAQ,2BAA2B;AAI3D;;;;AAIA,OAAM,SAA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wBAAwB,CAACT,KAAK,CAAC,EAAEwB,eAAA,CAAAK,MAAA,CAAO1B,EAAE,CAACH,KAAK,CAACA,KAAK,CAAC,CAAC,CAAC;MAC3E,CAAC,CAAC;IACJ;MACE,OAAO+B,WAAW,CAAC/B,KAAK,EAAE,MAAK;QAC7B,OAAOC,eAAA,CAAAyB,IAAA,CAAS1B,KAAK,CAACc,GAAG,CAACO,QAAQ,CAAC,IAAI,CAAC,EAAEC,eAAe,CAACtB,KAAK,CAACuB,MAAM,CAAC,CAAC;MAC1E,CAAC,CAAC;EACN;AACF"}
|
package/_mjs/ParseError.mjs
CHANGED
|
@@ -1,271 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import * as tsplus_module_6 from "@fncts/base/data/Maybe/api";
|
|
8
|
-
import { showWithOptions } from "@fncts/base/data/Showable";
|
|
9
|
-
import { concrete } from "@fncts/schema/AST";
|
|
10
|
-
/**
|
|
11
|
-
* @tsplus companion fncts.schema.ParseError.TypeError
|
|
12
|
-
*/
|
|
13
|
-
export class TypeError {
|
|
14
|
-
constructor(expected, actual) {
|
|
15
|
-
this.expected = expected;
|
|
16
|
-
this.actual = actual;
|
|
17
|
-
this._tag = 0 /* ParseErrorTag.Type */;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* @tsplus static fncts.schema.ParseError.TypeError __call
|
|
22
|
-
* @tsplus static fncts.schema.ParseErrorOps TypeError
|
|
23
|
-
*/
|
|
24
|
-
export function typeError(expected, actual) {
|
|
25
|
-
return new TypeError(expected, actual);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* @tsplus companion fncts.schema.ParseError.IndexError
|
|
29
|
-
*/
|
|
30
|
-
export class IndexError {
|
|
31
|
-
constructor(index, errors) {
|
|
32
|
-
this.index = index;
|
|
33
|
-
this.errors = errors;
|
|
34
|
-
this._tag = 1 /* ParseErrorTag.Index */;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* @tsplus static fncts.schema.ParseError.IndexError __call
|
|
39
|
-
* @tsplus static fncts.schema.ParseErrorOps IndexError
|
|
40
|
-
*/
|
|
41
|
-
export function indexError(index, errors) {
|
|
42
|
-
return new IndexError(index, errors);
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* @tsplus companion fncts.schema.ParseError.KeyError
|
|
46
|
-
*/
|
|
47
|
-
export class KeyError {
|
|
48
|
-
constructor(keyAST, key, errors) {
|
|
49
|
-
this.keyAST = keyAST;
|
|
50
|
-
this.key = key;
|
|
51
|
-
this.errors = errors;
|
|
52
|
-
this._tag = 2 /* ParseErrorTag.Key */;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* @tsplus static fncts.schema.ParseError.KeyError __call
|
|
57
|
-
* @tsplus static fncts.schema.ParseErrorOps KeyError
|
|
58
|
-
*/
|
|
59
|
-
export function keyError(keyAST, key, errors) {
|
|
60
|
-
return new KeyError(keyAST, key, errors);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* @tsplus companion fncts.schema.ParseError.MissingError
|
|
64
|
-
*/
|
|
65
|
-
export class MissingError {
|
|
66
|
-
constructor() {
|
|
67
|
-
this._tag = 3 /* ParseErrorTag.Missing */;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* @tsplus static fncts.schema.ParseErrorOps MissingError
|
|
72
|
-
*/
|
|
73
|
-
export const missingError = /*#__PURE__*/new MissingError();
|
|
74
|
-
/**
|
|
75
|
-
* @tsplus companion fncts.schema.ParseError.UnexpectedError
|
|
76
|
-
*/
|
|
77
|
-
export class UnexpectedError {
|
|
78
|
-
constructor(actual) {
|
|
79
|
-
this.actual = actual;
|
|
80
|
-
this._tag = 4 /* ParseErrorTag.Unexpected */;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* @tsplus static fncts.schema.ParseError.UnexpectedError __call
|
|
85
|
-
* @tsplus static fncts.schema.ParseErrorOps UnexpectedError
|
|
86
|
-
*/
|
|
87
|
-
export function unexpectedError(actual) {
|
|
88
|
-
return new UnexpectedError(actual);
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* @tsplus companion fncts.schema.ParseError.UnionMemberError
|
|
92
|
-
*/
|
|
93
|
-
export class UnionMemberError {
|
|
94
|
-
constructor(errors) {
|
|
95
|
-
this.errors = errors;
|
|
96
|
-
this._tag = 5 /* ParseErrorTag.UnionMember */;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* @tsplus static fncts.schema.ParseError.UnionMemberError __call
|
|
101
|
-
* @tsplus static fncts.schema.ParseErrorOps UnionMemberError
|
|
102
|
-
*/
|
|
103
|
-
export function unionMemberError(errors) {
|
|
104
|
-
return new UnionMemberError(errors);
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* @tsplus companion fncts.schema.ParseError.RefinementError
|
|
108
|
-
*/
|
|
109
|
-
export class RefinementError {
|
|
110
|
-
constructor(ast, actual, kind, errors) {
|
|
111
|
-
this.ast = ast;
|
|
112
|
-
this.actual = actual;
|
|
113
|
-
this.kind = kind;
|
|
114
|
-
this.errors = errors;
|
|
115
|
-
this._tag = 6 /* ParseErrorTag.Refinement */;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* @tsplus static fncts.schema.ParseError.RefinementError __call
|
|
120
|
-
* @tsplus static fncts.schema.ParseErrorOps RefinementError
|
|
121
|
-
*/
|
|
122
|
-
export function refinementError(ast, actual, kind, errors) {
|
|
123
|
-
return new RefinementError(ast, actual, kind, errors);
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* @tsplus companion fncts.schema.ParseError.TransformationError
|
|
127
|
-
*/
|
|
128
|
-
export class TransformationError {
|
|
129
|
-
constructor(ast, actual, kind, errors) {
|
|
130
|
-
this.ast = ast;
|
|
131
|
-
this.actual = actual;
|
|
132
|
-
this.kind = kind;
|
|
133
|
-
this.errors = errors;
|
|
134
|
-
this._tag = 7 /* ParseErrorTag.Transformation */;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* @tsplus static fncts.schema.ParseError.TransformationError __call
|
|
139
|
-
* @tsplus static fncts.schema.ParseErrorOps TransformationError
|
|
140
|
-
*/
|
|
141
|
-
export function transformationError(ast, actual, kind, errors) {
|
|
142
|
-
return new TransformationError(ast, actual, kind, errors);
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* @tsplus static fncts.schema.ParseErrorOps format
|
|
146
|
-
*/
|
|
147
|
-
export function format(errors) {
|
|
148
|
-
return tsplus_module_2.draw(tsplus_module_2.make(`${errors.length} error(s) found`, tsplus_module_1.map(go)(errors)));
|
|
149
|
-
}
|
|
150
|
-
function formatActual(actual) {
|
|
151
|
-
return showWithOptions(actual, {
|
|
152
|
-
colors: false
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
function formatTemplateLiteralSpan(span) {
|
|
156
|
-
switch (span.type._tag) {
|
|
157
|
-
case 8 /* ASTTag.StringKeyword */:
|
|
158
|
-
return "${string}";
|
|
159
|
-
case 9 /* ASTTag.NumberKeyword */:
|
|
160
|
-
return "${number}";
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
function formatTemplateLiteral(ast) {
|
|
164
|
-
return ast.head + tsplus_module_1.join("")(tsplus_module_1.map(span => formatTemplateLiteralSpan(span) + span.literal)(ast.spans));
|
|
165
|
-
}
|
|
166
|
-
function formatRefinementKind(error) {
|
|
167
|
-
switch (error.kind) {
|
|
168
|
-
case "From":
|
|
169
|
-
{
|
|
170
|
-
return "From side refinement failure";
|
|
171
|
-
}
|
|
172
|
-
case "Predicate":
|
|
173
|
-
{
|
|
174
|
-
return "Predicate refinement failure";
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
function formatTransformationKind(error) {
|
|
179
|
-
switch (error.kind) {
|
|
180
|
-
case "Encoded":
|
|
181
|
-
{
|
|
182
|
-
return "Encoded side transformation failure";
|
|
183
|
-
}
|
|
184
|
-
case "Transformation":
|
|
185
|
-
{
|
|
186
|
-
return "Transformation process failure";
|
|
187
|
-
}
|
|
188
|
-
case "Type":
|
|
189
|
-
{
|
|
190
|
-
return "Type side transformation failure";
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
function getExpected(ast) {
|
|
195
|
-
return tsplus_module_6.flatMap(title => tsplus_module_5.match(() => tsplus_module_3.just(title, fileName_1 + ":242:19"), description => tsplus_module_3.just(`${title} (${description})`, fileName_1 + ":243:30"))(ast.annotations.get(tsplus_module_4.Description)))(tsplus_module_6.orElse(() => ast.annotations.get(tsplus_module_4.Title))(ast.annotations.get(tsplus_module_4.Identifier)));
|
|
196
|
-
}
|
|
197
|
-
function getMissedBrands(ast) {
|
|
198
|
-
return tsplus_module_1.join(" & ")(tsplus_module_1.map(validation => validation.name)(ast.validation));
|
|
199
|
-
}
|
|
200
|
-
function formatExpected(ast) {
|
|
201
|
-
void 0;
|
|
202
|
-
switch (ast._tag) {
|
|
203
|
-
case 8 /* ASTTag.StringKeyword */:
|
|
204
|
-
return tsplus_module_6.getOrElse(() => "string")(getExpected(ast));
|
|
205
|
-
case 9 /* ASTTag.NumberKeyword */:
|
|
206
|
-
return tsplus_module_6.getOrElse(() => "number")(getExpected(ast));
|
|
207
|
-
case 10 /* ASTTag.BooleanKeyword */:
|
|
208
|
-
return tsplus_module_6.getOrElse(() => "boolean")(getExpected(ast));
|
|
209
|
-
case 11 /* ASTTag.BigIntKeyword */:
|
|
210
|
-
return tsplus_module_6.getOrElse(() => "bigint")(getExpected(ast));
|
|
211
|
-
case 3 /* ASTTag.UndefinedKeyword */:
|
|
212
|
-
return tsplus_module_6.getOrElse(() => "undefined")(getExpected(ast));
|
|
213
|
-
case 12 /* ASTTag.SymbolKeyword */:
|
|
214
|
-
return tsplus_module_6.getOrElse(() => "symbol")(getExpected(ast));
|
|
215
|
-
case 13 /* ASTTag.ObjectKeyword */:
|
|
216
|
-
return tsplus_module_6.getOrElse(() => "object")(getExpected(ast));
|
|
217
|
-
case 7 /* ASTTag.AnyKeyword */:
|
|
218
|
-
return tsplus_module_6.getOrElse(() => "any")(getExpected(ast));
|
|
219
|
-
case 6 /* ASTTag.UnknownKeyword */:
|
|
220
|
-
return tsplus_module_6.getOrElse(() => "unknown")(getExpected(ast));
|
|
221
|
-
case 4 /* ASTTag.VoidKeyword */:
|
|
222
|
-
return tsplus_module_6.getOrElse(() => "void")(getExpected(ast));
|
|
223
|
-
case 5 /* ASTTag.NeverKeyword */:
|
|
224
|
-
return tsplus_module_6.getOrElse(() => "never")(getExpected(ast));
|
|
225
|
-
case 1 /* ASTTag.Literal */:
|
|
226
|
-
return tsplus_module_6.getOrElse(() => formatActual(ast.literal))(getExpected(ast));
|
|
227
|
-
case 2 /* ASTTag.UniqueSymbol */:
|
|
228
|
-
return tsplus_module_6.getOrElse(() => formatActual(ast.symbol))(getExpected(ast));
|
|
229
|
-
case 18 /* ASTTag.Union */:
|
|
230
|
-
return tsplus_module_1.join(" or ")(tsplus_module_1.map(formatExpected)(ast.types));
|
|
231
|
-
case 20 /* ASTTag.Refinement */:
|
|
232
|
-
return tsplus_module_6.getOrElse(() => "refinement")(getExpected(ast));
|
|
233
|
-
case 15 /* ASTTag.TemplateLiteral */:
|
|
234
|
-
return tsplus_module_6.getOrElse(() => formatTemplateLiteral(ast))(getExpected(ast));
|
|
235
|
-
case 16 /* ASTTag.Tuple */:
|
|
236
|
-
return tsplus_module_6.getOrElse(() => "tuple or array")(getExpected(ast));
|
|
237
|
-
case 17 /* ASTTag.TypeLiteral */:
|
|
238
|
-
return tsplus_module_6.getOrElse(() => "type literal")(getExpected(ast));
|
|
239
|
-
case 14 /* ASTTag.Enum */:
|
|
240
|
-
return tsplus_module_6.getOrElse(() => tsplus_module_1.join(" | ")(tsplus_module_1.map(([_, value]) => JSON.stringify(value))(ast.enums)))(getExpected(ast));
|
|
241
|
-
case 19 /* ASTTag.Lazy */:
|
|
242
|
-
return tsplus_module_6.getOrElse(() => "<anonymous lazy schema>")(getExpected(ast));
|
|
243
|
-
case 0 /* ASTTag.Declaration */:
|
|
244
|
-
return tsplus_module_6.getOrElse(() => "<anonymous Declaration schema>")(getExpected(ast));
|
|
245
|
-
case 21 /* ASTTag.Transform */:
|
|
246
|
-
return `a parsable value from ${formatExpected(ast.from)} to ${formatExpected(ast.to)}`;
|
|
247
|
-
case 22 /* ASTTag.Validation */:
|
|
248
|
-
return tsplus_module_5.match(() => getMissedBrands(ast), expected => `${expected} with validation(s) ${getMissedBrands(ast)}`)(getExpected(ast));
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
function go(error) {
|
|
252
|
-
switch (error._tag) {
|
|
253
|
-
case 0 /* ParseErrorTag.Type */:
|
|
254
|
-
return tsplus_module_2.make(tsplus_module_6.getOrElse(() => `Expected ${formatExpected(error.expected)}, actual ${formatActual(error.actual)}`)(tsplus_module_6.map(f => f(error.actual))(error.expected.annotations.get(tsplus_module_4.Message))));
|
|
255
|
-
case 1 /* ParseErrorTag.Index */:
|
|
256
|
-
return tsplus_module_2.make(`index ${error.index}`, tsplus_module_1.map(go)(error.errors));
|
|
257
|
-
case 4 /* ParseErrorTag.Unexpected */:
|
|
258
|
-
return tsplus_module_2.make("is unexpected");
|
|
259
|
-
case 2 /* ParseErrorTag.Key */:
|
|
260
|
-
return tsplus_module_2.make(`key ${formatActual(error.key)}`, tsplus_module_1.map(go)(error.errors));
|
|
261
|
-
case 3 /* ParseErrorTag.Missing */:
|
|
262
|
-
return tsplus_module_2.make("is missing");
|
|
263
|
-
case 5 /* ParseErrorTag.UnionMember */:
|
|
264
|
-
return tsplus_module_2.make("union member", tsplus_module_1.map(go)(error.errors));
|
|
265
|
-
case 6 /* ParseErrorTag.Refinement */:
|
|
266
|
-
return tsplus_module_2.make(formatRefinementKind(error), tsplus_module_1.map(go)(error.errors));
|
|
267
|
-
case 7 /* ParseErrorTag.Transformation */:
|
|
268
|
-
return tsplus_module_2.make(formatTransformationKind(error), tsplus_module_1.map(go)(error.errors));
|
|
269
|
-
}
|
|
270
|
-
}
|
|
1
|
+
/* eslint-disable simple-import-sort/exports */
|
|
2
|
+
// codegen:start { preset: barrel, include: ./ParseError/*.ts }
|
|
3
|
+
export * from "./ParseError/TreeFormatter.mjs";
|
|
4
|
+
export * from "./ParseError/PathFormatter.mjs";
|
|
5
|
+
export * from "./ParseError/ParseErrorFormatter.mjs";
|
|
6
|
+
export * from "./ParseError/ParseError.mjs";
|
|
271
7
|
//# sourceMappingURL=ParseError.mjs.map
|
package/_mjs/ParseError.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParseError.mjs","names":[
|
|
1
|
+
{"version":3,"file":"ParseError.mjs","names":[],"sources":["../_src/ParseError.ts"],"sourcesContent":[null],"mappings":"AAAA;AACA;AACA,cAAc,gCAA+B;AAC7C,cAAc,gCAA+B;AAC7C,cAAc,sCAAqC;AACnD,cAAc,6BAA4B"}
|
package/_mjs/ParseResult.mjs
CHANGED
|
@@ -1,23 +1,15 @@
|
|
|
1
1
|
const fileName_1 = "(@fncts/schema) src/ParseResult.ts";
|
|
2
2
|
import * as tsplus_module_1 from "@fncts/base/data/Either/constructors";
|
|
3
|
-
import * as tsplus_module_2 from "@fncts/schema/ParseFailure";
|
|
4
|
-
import * as tsplus_module_3 from "@fncts/base/collection/immutable/Vector/api";
|
|
5
3
|
/**
|
|
6
4
|
* @tsplus static fncts.schema.ParseResultOps succeed
|
|
7
5
|
*/
|
|
8
6
|
export function succeed(value) {
|
|
9
7
|
return tsplus_module_1.right(value, fileName_1 + ":11:22");
|
|
10
8
|
}
|
|
11
|
-
/**
|
|
12
|
-
* @tsplus static fncts.schema.ParseResultOps failures
|
|
13
|
-
*/
|
|
14
|
-
export function failures(value) {
|
|
15
|
-
return tsplus_module_1.left(tsplus_module_2.make(value), fileName_1 + ":18:21");
|
|
16
|
-
}
|
|
17
9
|
/**
|
|
18
10
|
* @tsplus static fncts.schema.ParseResultOps fail
|
|
19
11
|
*/
|
|
20
12
|
export function fail(value) {
|
|
21
|
-
return tsplus_module_1.left(
|
|
13
|
+
return tsplus_module_1.left(value, fileName_1 + ":18:21");
|
|
22
14
|
}
|
|
23
15
|
//# sourceMappingURL=ParseResult.mjs.map
|
package/_mjs/ParseResult.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParseResult.mjs","names":["succeed","value","tsplus_module_1","right","fileName_1","
|
|
1
|
+
{"version":3,"file":"ParseResult.mjs","names":["succeed","value","tsplus_module_1","right","fileName_1","fail","left"],"sources":["../_src/ParseResult.ts"],"sourcesContent":[null],"mappings":";;AAMA;;;AAGA,OAAM,SAAUA,OAAOA,CAAIC,KAAQ;EACjC,OAAOC,eAAA,CAAAC,KAAA,CAAaF,KAAK,EAAAG,UAAA,YAAC;AAC5B;AAEA;;;AAGA,OAAM,SAAUC,IAAIA,CAAYJ,KAAiB;EAC/C,OAAOC,eAAA,CAAAI,IAAA,CAAYL,KAAK,EAAAG,UAAA,YAAC;AAC3B"}
|
package/_mjs/Parser/api.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as tsplus_module_1 from "@fncts/schema/AST";
|
|
2
2
|
import * as tsplus_module_2 from "@fncts/base/data/Either/api";
|
|
3
|
-
import * as tsplus_module_3 from "@fncts/schema/ParseError";
|
|
3
|
+
import * as tsplus_module_3 from "@fncts/schema/ParseError/TreeFormatter";
|
|
4
4
|
import * as tsplus_module_4 from "@fncts/base/data/function/api";
|
|
5
5
|
import * as tsplus_module_5 from "@fncts/base/data/Either/destructors";
|
|
6
6
|
export const encode = encode_1;
|
|
@@ -43,7 +43,7 @@ function parseOrThrow(ast) {
|
|
|
43
43
|
const parser = parserFor(ast, true);
|
|
44
44
|
return (input, options) => {
|
|
45
45
|
return tsplus_module_5.match(failure => {
|
|
46
|
-
throw new Error(tsplus_module_3.format(failure
|
|
46
|
+
throw new Error(tsplus_module_3.format(failure));
|
|
47
47
|
}, tsplus_module_4.identity)(parser(input, options));
|
|
48
48
|
};
|
|
49
49
|
}
|
package/_mjs/Parser/api.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.mjs","names":["encode","encode_1","parserFor","decode","schema","ast","decodeMaybe","parseMaybe","tsplus_module_1","getTo","encodeMaybe","input","options","tsplus_module_2","toMaybe","parse","parseOrThrow","parser","tsplus_module_5","match","failure","Error","tsplus_module_3","format","
|
|
1
|
+
{"version":3,"file":"api.mjs","names":["encode","encode_1","parserFor","decode","schema","ast","decodeMaybe","parseMaybe","tsplus_module_1","getTo","encodeMaybe","input","options","tsplus_module_2","toMaybe","parse","parseOrThrow","parser","tsplus_module_5","match","failure","Error","tsplus_module_3","format","tsplus_module_4","identity","asserts"],"sources":["../../_src/Parser/api.ts"],"sourcesContent":[null],"mappings":";;;;;aAwBgBA,MAAM,GAAAC,QAAA;AAtBtB,SAASC,SAAS,QAAQ,mBAAkB;AAE5C;;;;AAIA,OAAM,SAAUC,MAAMA,CAAIC,MAAiB;EACzC,OAAOF,SAAS,CAACE,MAAM,CAACC,GAAG,EAAE,IAAI,CAAC;AACpC;AAEA;;;;AAIA,OAAM,SAAUC,WAAWA,CAAIF,MAAiB;EAC9C,OAAOG,UAAU,CAAAC,eAAA,CAAAC,KAAA,CAACL,MAAM,CAACC,GAAG,EAAO;AACrC;AAEA;;;;AAIA,SAAAJ,SAA0BG,MAAiB;EACzC,OAAOF,SAAS,CAACE,MAAM,CAACC,GAAG,EAAE,KAAK,CAAC;AACrC;AAEA;;;;AAIA,OAAM,SAAUK,WAAWA,CAAIN,MAAiB;EAC9C,OAAO,CAACO,KAAK,EAAEC,OAAO,KAAIC,eAAA,CAAAC,OAAA,C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