@fncts/schema 0.0.13 → 0.0.15
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 +29 -12
- package/Guard.d.ts +9 -0
- package/ParseError.d.ts +40 -3
- package/ParseFailure.d.ts +18 -0
- package/ParseResult.d.ts +2 -1
- package/Parser/api.d.ts +0 -6
- package/Parser/interpreter.d.ts +1 -2
- package/Show.d.ts +1 -1
- package/_cjs/AST.cjs +115 -65
- package/_cjs/AST.cjs.map +1 -1
- package/_cjs/Guard.cjs +278 -0
- package/_cjs/Guard.cjs.map +1 -0
- package/_cjs/ParseError.cjs +77 -3
- package/_cjs/ParseError.cjs.map +1 -1
- package/_cjs/ParseFailure.cjs +28 -0
- package/_cjs/ParseFailure.cjs.map +1 -0
- package/_cjs/ParseResult.cjs +4 -3
- package/_cjs/ParseResult.cjs.map +1 -1
- package/_cjs/Parser/api.cjs +11 -23
- package/_cjs/Parser/api.cjs.map +1 -1
- package/_cjs/Parser/interpreter.cjs +93 -141
- package/_cjs/Parser/interpreter.cjs.map +1 -1
- package/_cjs/Schema/api/conc.cjs +1 -1
- package/_cjs/Schema/api/conc.cjs.map +1 -1
- package/_cjs/Schema/api/hashMap.cjs +1 -1
- package/_cjs/Schema/api/hashMap.cjs.map +1 -1
- package/_cjs/Schema/api/immutableArray.cjs +1 -1
- package/_cjs/Schema/api/immutableArray.cjs.map +1 -1
- package/_cjs/Schema/api/list.cjs +1 -1
- package/_cjs/Schema/api/list.cjs.map +1 -1
- package/_cjs/Schema/api.cjs +27 -28
- package/_cjs/Schema/api.cjs.map +1 -1
- package/_cjs/Show.cjs +23 -12
- package/_cjs/Show.cjs.map +1 -1
- package/_mjs/AST.mjs +107 -61
- package/_mjs/AST.mjs.map +1 -1
- package/_mjs/Guard.mjs +269 -0
- package/_mjs/Guard.mjs.map +1 -0
- package/_mjs/ParseError.mjs +72 -2
- package/_mjs/ParseError.mjs.map +1 -1
- package/_mjs/ParseFailure.mjs +20 -0
- package/_mjs/ParseFailure.mjs.map +1 -0
- package/_mjs/ParseResult.mjs +4 -3
- package/_mjs/ParseResult.mjs.map +1 -1
- package/_mjs/Parser/api.mjs +10 -21
- package/_mjs/Parser/api.mjs.map +1 -1
- package/_mjs/Parser/interpreter.mjs +94 -142
- package/_mjs/Parser/interpreter.mjs.map +1 -1
- package/_mjs/Schema/api/conc.mjs +1 -1
- package/_mjs/Schema/api/conc.mjs.map +1 -1
- package/_mjs/Schema/api/hashMap.mjs +1 -1
- package/_mjs/Schema/api/hashMap.mjs.map +1 -1
- package/_mjs/Schema/api/immutableArray.mjs +1 -1
- package/_mjs/Schema/api/immutableArray.mjs.map +1 -1
- package/_mjs/Schema/api/list.mjs +1 -1
- package/_mjs/Schema/api/list.mjs.map +1 -1
- package/_mjs/Schema/api.mjs +27 -28
- package/_mjs/Schema/api.mjs.map +1 -1
- package/_mjs/Show.mjs +23 -12
- package/_mjs/Show.mjs.map +1 -1
- package/_src/AST.ts +96 -47
- package/_src/Guard.ts +268 -0
- package/_src/ParseError.ts +88 -4
- package/_src/ParseFailure.ts +18 -0
- package/_src/ParseResult.ts +3 -3
- package/_src/Parser/api.ts +8 -21
- package/_src/Parser/interpreter.ts +94 -128
- package/_src/Schema/api/conc.ts +1 -1
- package/_src/Schema/api/hashMap.ts +1 -1
- package/_src/Schema/api/immutableArray.ts +1 -1
- package/_src/Schema/api/list.ts +1 -1
- package/_src/Schema/api.ts +3 -10
- package/_src/Show.ts +28 -15
- package/_src/global.ts +4 -0
- package/global.d.ts +4 -0
- package/package.json +3 -3
package/AST.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Maybe } from "@fncts/base/data/Maybe/definition";
|
|
2
2
|
import { Vector } from "@fncts/base/collection/immutable/Vector";
|
|
3
3
|
import { ParseResult } from "@fncts/schema/ParseResult";
|
|
4
|
+
import { ParseError } from "@fncts/schema/ParseError";
|
|
4
5
|
import type { Validation as ValidationType } from "@fncts/base/data/Branded";
|
|
5
6
|
import { ASTAnnotation } from "./ASTAnnotation.js";
|
|
6
7
|
import { ASTAnnotationMap } from "./ASTAnnotationMap.js";
|
|
@@ -314,6 +315,11 @@ export declare class Tuple extends AST {
|
|
|
314
315
|
* @tsplus location "@fncts/schema/AST"
|
|
315
316
|
*/
|
|
316
317
|
export declare function createTuple(elements: Vector<Element>, rest: Maybe<Vector<AST>>, isReadonly: boolean, annotations?: ASTAnnotationMap): Tuple;
|
|
318
|
+
/**
|
|
319
|
+
* @tsplus static fncts.schema.ASTOps unknownArray
|
|
320
|
+
* @tsplus location "@fncts/schema/AST"
|
|
321
|
+
*/
|
|
322
|
+
export declare const unknownArray: Tuple;
|
|
317
323
|
export declare class PropertySignature extends AST {
|
|
318
324
|
readonly name: PropertyKey;
|
|
319
325
|
readonly type: AST;
|
|
@@ -358,6 +364,11 @@ export declare function isTypeLiteral(self: AST): self is TypeLiteral;
|
|
|
358
364
|
* @tsplus location "@fncts/schema/AST"
|
|
359
365
|
*/
|
|
360
366
|
export declare function createTypeLiteral(propertySignatures: Vector<PropertySignature>, indexSignatures: Vector<IndexSignature>, annotations?: ASTAnnotationMap): TypeLiteral;
|
|
367
|
+
/**
|
|
368
|
+
* @tsplus static fncts.schema.ASTOps unknownRecord
|
|
369
|
+
* @tsplus location "@fncts/schema/AST"
|
|
370
|
+
*/
|
|
371
|
+
export declare const unknownRecord: TypeLiteral;
|
|
361
372
|
export declare class Union extends AST {
|
|
362
373
|
readonly types: Vector<AST>;
|
|
363
374
|
readonly annotations: ASTAnnotationMap;
|
|
@@ -394,18 +405,18 @@ export declare function createLazy(getAST: () => AST, annotations?: ASTAnnotatio
|
|
|
394
405
|
export declare function isLazy(self: AST): self is Lazy;
|
|
395
406
|
export declare class Refinement extends AST {
|
|
396
407
|
readonly from: AST;
|
|
397
|
-
readonly
|
|
398
|
-
readonly isReversed: boolean;
|
|
408
|
+
readonly predicate: (input: any) => boolean;
|
|
399
409
|
readonly annotations: ASTAnnotationMap;
|
|
400
410
|
readonly _tag = ASTTag.Refinement;
|
|
401
|
-
constructor(from: AST,
|
|
411
|
+
constructor(from: AST, predicate: (input: any) => boolean, annotations?: ASTAnnotationMap);
|
|
412
|
+
decode(input: any, options?: ParseOptions): ParseResult<any>;
|
|
402
413
|
clone(newProperties: Partial<this>): AST;
|
|
403
414
|
}
|
|
404
415
|
/**
|
|
405
416
|
* @tsplus static fncts.schema.ASTOps createRefinement
|
|
406
417
|
* @tsplus location "@fncts/schema/AST"
|
|
407
418
|
*/
|
|
408
|
-
export declare function createRefinement(from: AST,
|
|
419
|
+
export declare function createRefinement(from: AST, predicate: (input: any) => boolean, annotations?: ASTAnnotationMap): Refinement;
|
|
409
420
|
export declare function isRefinement(self: AST): self is Refinement;
|
|
410
421
|
export interface ParseOptions {
|
|
411
422
|
readonly isUnexpectedAllowed?: boolean;
|
|
@@ -416,17 +427,16 @@ export declare class Transform extends AST {
|
|
|
416
427
|
readonly to: AST;
|
|
417
428
|
readonly decode: (input: any, options?: ParseOptions) => ParseResult<any>;
|
|
418
429
|
readonly encode: (input: any, options?: ParseOptions) => ParseResult<any>;
|
|
419
|
-
readonly isReversed: boolean;
|
|
420
430
|
readonly annotations: ASTAnnotationMap;
|
|
421
431
|
readonly _tag = ASTTag.Transform;
|
|
422
|
-
constructor(from: AST, to: AST, decode: (input: any, options?: ParseOptions) => ParseResult<any>, encode: (input: any, options?: ParseOptions) => ParseResult<any>,
|
|
432
|
+
constructor(from: AST, to: AST, decode: (input: any, options?: ParseOptions) => ParseResult<any>, encode: (input: any, options?: ParseOptions) => ParseResult<any>, annotations?: ASTAnnotationMap);
|
|
423
433
|
clone(newProperties: Partial<this>): AST;
|
|
424
434
|
}
|
|
425
435
|
/**
|
|
426
436
|
* @tsplus static fncts.schema.ASTOps createTransform
|
|
427
437
|
* @tsplus location "@fncts/schema/AST"
|
|
428
438
|
*/
|
|
429
|
-
export declare function createTransform(from: AST, to: AST, decode: (input: any, options?: ParseOptions) => ParseResult<any>, encode: (input: any, options?: ParseOptions) => ParseResult<any>,
|
|
439
|
+
export declare function createTransform(from: AST, to: AST, decode: (input: any, options?: ParseOptions) => ParseResult<any>, encode: (input: any, options?: ParseOptions) => ParseResult<any>, annotations?: ASTAnnotationMap): Transform;
|
|
430
440
|
export declare class Validation extends AST {
|
|
431
441
|
readonly from: AST;
|
|
432
442
|
readonly validation: Vector<ValidationType<any, string>>;
|
|
@@ -516,13 +526,20 @@ export declare function getFrom(ast: AST): AST;
|
|
|
516
526
|
* @tsplus location "@fncts/schema/AST"
|
|
517
527
|
*/
|
|
518
528
|
export declare function getTo(ast: AST): AST;
|
|
519
|
-
/**
|
|
520
|
-
* @tsplus getter fncts.schema.AST reverse
|
|
521
|
-
* @tsplus location "@fncts/schema/AST"
|
|
522
|
-
*/
|
|
523
|
-
export declare function reverse(ast: AST): AST;
|
|
524
529
|
/**
|
|
525
530
|
* @tsplus static fncts.schema.AST getCompiler
|
|
526
531
|
* @tsplus location "@fncts/schema/AST"
|
|
527
532
|
*/
|
|
528
533
|
export declare function getCompiler<A>(match: AST.Match<A>): AST.Compiler<A>;
|
|
534
|
+
export declare function getLiterals(ast: AST, isDecoding: boolean): ReadonlyArray<[PropertyKey, Literal]>;
|
|
535
|
+
export declare function getSearchTree(members: Vector<AST>, isDecoding: boolean): {
|
|
536
|
+
keys: {
|
|
537
|
+
readonly [key: PropertyKey]: {
|
|
538
|
+
buckets: {
|
|
539
|
+
[literal: string]: ReadonlyArray<AST>;
|
|
540
|
+
};
|
|
541
|
+
ast: AST;
|
|
542
|
+
};
|
|
543
|
+
};
|
|
544
|
+
otherwise: ReadonlyArray<AST>;
|
|
545
|
+
};
|
package/Guard.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Schema } from "@fncts/schema/Schema/definition";
|
|
2
|
+
import { Guard } from "@fncts/base/data/Guard";
|
|
3
|
+
import { AST } from "@fncts/schema/AST";
|
|
4
|
+
/**
|
|
5
|
+
* @tsplus getter fncts.schema.Schema is
|
|
6
|
+
* @tsplus location "@fncts/schema/Guard"
|
|
7
|
+
*/
|
|
8
|
+
export declare function is<A>(schema: Schema<A>): (input: unknown) => input is A;
|
|
9
|
+
export declare function guardFor<A>(schema: Schema<A>): Guard<A>;
|
package/ParseError.d.ts
CHANGED
|
@@ -2,19 +2,22 @@ import { AST } from "@fncts/schema/AST";
|
|
|
2
2
|
import { Vector } from "@fncts/base/collection/immutable/Vector";
|
|
3
3
|
import { Maybe } from "@fncts/base/data/Maybe/definition";
|
|
4
4
|
import { RoseTree } from "@fncts/base/collection/immutable/RoseTree";
|
|
5
|
+
import type { Refinement, Transform } from "@fncts/schema/AST";
|
|
5
6
|
export declare const enum ParseErrorTag {
|
|
6
7
|
Type = 0,
|
|
7
8
|
Index = 1,
|
|
8
9
|
Key = 2,
|
|
9
10
|
Missing = 3,
|
|
10
11
|
Unexpected = 4,
|
|
11
|
-
UnionMember = 5
|
|
12
|
+
UnionMember = 5,
|
|
13
|
+
Refinement = 6,
|
|
14
|
+
Transformation = 7
|
|
12
15
|
}
|
|
13
16
|
/**
|
|
14
17
|
* @tsplus type fncts.schema.ParseError
|
|
15
18
|
* @tsplus companion fncts.schema.ParseErrorOps
|
|
16
19
|
*/
|
|
17
|
-
export type ParseError = TypeError | IndexError | KeyError | MissingError | UnexpectedError |
|
|
20
|
+
export type ParseError = TypeError | IndexError | KeyError | MissingError | UnexpectedError | UnionMemberError | RefinementError | TransformationError;
|
|
18
21
|
/**
|
|
19
22
|
* @tsplus companion fncts.schema.ParseError.TypeError
|
|
20
23
|
*/
|
|
@@ -56,7 +59,7 @@ export declare class KeyError {
|
|
|
56
59
|
constructor(keyAST: AST, key: any, errors: Vector<ParseError>);
|
|
57
60
|
}
|
|
58
61
|
/**
|
|
59
|
-
* @tsplus static fncts.schema.ParseError.
|
|
62
|
+
* @tsplus static fncts.schema.ParseError.KeyError __call
|
|
60
63
|
* @tsplus static fncts.schema.ParseErrorOps KeyError
|
|
61
64
|
* @tsplus location "@fncts/schema/ParseError"
|
|
62
65
|
*/
|
|
@@ -100,6 +103,40 @@ export declare class UnionMemberError {
|
|
|
100
103
|
* @tsplus location "@fncts/schema/ParseError"
|
|
101
104
|
*/
|
|
102
105
|
export declare function unionMemberError(errors: Vector<ParseError>): ParseError;
|
|
106
|
+
/**
|
|
107
|
+
* @tsplus companion fncts.schema.ParseError.RefinementError
|
|
108
|
+
*/
|
|
109
|
+
export declare class RefinementError {
|
|
110
|
+
readonly ast: Refinement;
|
|
111
|
+
readonly actual: unknown;
|
|
112
|
+
readonly kind: "From" | "Predicate";
|
|
113
|
+
readonly errors: Vector<ParseError>;
|
|
114
|
+
readonly _tag = ParseErrorTag.Refinement;
|
|
115
|
+
constructor(ast: Refinement, actual: unknown, kind: "From" | "Predicate", errors: Vector<ParseError>);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* @tsplus static fncts.schema.ParseError.RefinementError __call
|
|
119
|
+
* @tsplus static fncts.schema.ParseErrorOps RefinementError
|
|
120
|
+
* @tsplus location "@fncts/schema/ParseError"
|
|
121
|
+
*/
|
|
122
|
+
export declare function refinementError(ast: Refinement, actual: unknown, kind: "From" | "Predicate", errors: Vector<ParseError>): ParseError;
|
|
123
|
+
/**
|
|
124
|
+
* @tsplus companion fncts.schema.ParseError.TransformationError
|
|
125
|
+
*/
|
|
126
|
+
export declare class TransformationError {
|
|
127
|
+
readonly ast: Transform;
|
|
128
|
+
readonly actual: unknown;
|
|
129
|
+
readonly kind: "Encoded" | "Transformation" | "Type";
|
|
130
|
+
readonly errors: Vector<ParseError>;
|
|
131
|
+
readonly _tag = ParseErrorTag.Transformation;
|
|
132
|
+
constructor(ast: Transform, actual: unknown, kind: "Encoded" | "Transformation" | "Type", errors: Vector<ParseError>);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* @tsplus static fncts.schema.ParseError.TransformationError __call
|
|
136
|
+
* @tsplus static fncts.schema.ParseErrorOps TransformationError
|
|
137
|
+
* @tsplus location "@fncts/schema/ParseError"
|
|
138
|
+
*/
|
|
139
|
+
export declare function transformationError(ast: Transform, actual: unknown, kind: "Encoded" | "Transformation" | "Type", errors: Vector<ParseError>): ParseError;
|
|
103
140
|
/**
|
|
104
141
|
* @tsplus static fncts.schema.ParseErrorOps format
|
|
105
142
|
* @tsplus location "@fncts/schema/ParseError"
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Vector } from "@fncts/base/collection/immutable/Vector";
|
|
2
|
+
import { ParseError } from "@fncts/schema/ParseError";
|
|
3
|
+
export declare const ParseFailureTypeId: unique symbol;
|
|
4
|
+
export type ParseFailureTypeId = typeof ParseFailureTypeId;
|
|
5
|
+
/**
|
|
6
|
+
* @tsplus type fncts.schema.ParseFailure
|
|
7
|
+
* @tsplus companion fncts.schema.ParseFailureOps
|
|
8
|
+
*/
|
|
9
|
+
export declare class ParseFailure {
|
|
10
|
+
readonly errors: Vector<ParseError>;
|
|
11
|
+
readonly [ParseFailureTypeId]: ParseFailureTypeId;
|
|
12
|
+
constructor(errors: Vector<ParseError>);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* @tsplus static fncts.schema.ParseFailureOps __call
|
|
16
|
+
* @tsplus location "@fncts/schema/ParseFailure"
|
|
17
|
+
*/
|
|
18
|
+
export declare function make(errors: Vector<ParseError>): ParseFailure;
|
package/ParseResult.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Either } from "@fncts/base/data/Either/definition";
|
|
2
|
+
import { ParseFailure } from "@fncts/schema/ParseFailure";
|
|
2
3
|
import { Vector } from "@fncts/base/collection/immutable/Vector";
|
|
3
4
|
import { ParseError } from "@fncts/schema/ParseError";
|
|
4
5
|
/**
|
|
5
6
|
* @tsplus type fncts.schema.ParseResult
|
|
6
7
|
* @tsplus companion fncts.schema.ParseResultOps
|
|
7
8
|
*/
|
|
8
|
-
export interface ParseResult<A> extends Either<
|
|
9
|
+
export interface ParseResult<A> extends Either<ParseFailure, A> {
|
|
9
10
|
}
|
|
10
11
|
/**
|
|
11
12
|
* @tsplus static fncts.schema.ParseResultOps succeed
|
package/Parser/api.d.ts
CHANGED
|
@@ -28,12 +28,6 @@ export declare function encode<A>(schema: Schema<A>): <A>(input: A, options?: Pa
|
|
|
28
28
|
* @tsplus location "@fncts/schema/Parser/api"
|
|
29
29
|
*/
|
|
30
30
|
export declare function encodeMaybe<A>(schema: Schema<A>): <A>(input: A, options?: ParseOptions) => Maybe<unknown>;
|
|
31
|
-
/**
|
|
32
|
-
* @tsplus getter fncts.schema.Schema is
|
|
33
|
-
* @tsplus getter fncts.schema.Parser is
|
|
34
|
-
* @tsplus location "@fncts/schema/Parser/api"
|
|
35
|
-
*/
|
|
36
|
-
export declare function is<A>(schema: Schema<A>): (input: unknown, options?: ParseOptions) => input is A;
|
|
37
31
|
/**
|
|
38
32
|
* @tsplus getter fncts.schema.Schema asserts
|
|
39
33
|
* @tsplus getter fncts.schema.Parser asserts
|
package/Parser/interpreter.d.ts
CHANGED
|
@@ -2,5 +2,4 @@ import { AST } from "@fncts/schema/AST";
|
|
|
2
2
|
import { Parser } from "@fncts/schema/Parser/definition";
|
|
3
3
|
import { ParseError } from "@fncts/schema/ParseError";
|
|
4
4
|
import { ParseResult } from "@fncts/schema/ParseResult";
|
|
5
|
-
|
|
6
|
-
export declare function parserFor(ast: AST): Parser<any>;
|
|
5
|
+
export declare function parserFor(ast: AST, isDecoding: boolean): Parser<any>;
|
package/Show.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Schema } from "@fncts/schema/Schema/definition";
|
|
2
1
|
import { AST } from "@fncts/schema/AST";
|
|
3
2
|
import { Eval } from "@fncts/base/control/Eval/definition";
|
|
3
|
+
import { Schema } from "@fncts/schema/Schema/definition";
|
|
4
4
|
/**
|
|
5
5
|
* @tsplus getter fncts.schema.Schema show
|
|
6
6
|
* @tsplus location "@fncts/schema/Show"
|
package/_cjs/AST.cjs
CHANGED
|
@@ -15,14 +15,19 @@ exports.createIndexSignature = void 0;
|
|
|
15
15
|
exports.createKey = createKey;
|
|
16
16
|
exports.createPropertySignature = exports.createLiteral = exports.createLazy = void 0;
|
|
17
17
|
exports.createRecord = createRecord;
|
|
18
|
-
exports.
|
|
18
|
+
exports.createTemplateLiteral = exports.createRefinement = void 0;
|
|
19
|
+
exports.createTransform = createTransform;
|
|
20
|
+
exports.createUniqueSymbol = exports.createUnion = exports.createTypeLiteral = exports.createTuple = void 0;
|
|
19
21
|
exports.createValidation = createValidation;
|
|
20
22
|
exports.getAnnotations = getAnnotations;
|
|
21
23
|
exports.getCardinality = getCardinality;
|
|
22
24
|
exports.getCompiler = getCompiler;
|
|
23
25
|
exports.getFrom = void 0;
|
|
26
|
+
exports.getLiterals = getLiterals;
|
|
24
27
|
exports.getParameter = getParameter;
|
|
25
|
-
exports.
|
|
28
|
+
exports.getPropertySignatures = void 0;
|
|
29
|
+
exports.getSearchTree = getSearchTree;
|
|
30
|
+
exports.getTo = void 0;
|
|
26
31
|
exports.getWeight = getWeight;
|
|
27
32
|
exports.isBigIntKeyword = isBigIntKeyword;
|
|
28
33
|
exports.isBooleanKeyword = isBooleanKeyword;
|
|
@@ -39,18 +44,19 @@ exports.objectKeyword = exports.numberKeyword = exports.neverKeyword = exports.k
|
|
|
39
44
|
exports.omit = omit;
|
|
40
45
|
exports.partial = void 0;
|
|
41
46
|
exports.pick = pick;
|
|
42
|
-
exports.reverse = void 0;
|
|
43
47
|
exports.setAnnotation = setAnnotation;
|
|
44
|
-
exports.voidKeyword = exports.unknownKeyword = exports.undefinedKeyword = exports.symbolKeyword = exports.stringKeyword = void 0;
|
|
48
|
+
exports.voidKeyword = exports.unknownRecord = exports.unknownKeyword = exports.unknownArray = exports.undefinedKeyword = exports.symbolKeyword = exports.stringKeyword = void 0;
|
|
45
49
|
var tsplus_module_1 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/schema/ASTAnnotation"));
|
|
46
50
|
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/
|
|
48
|
-
var tsplus_module_4 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/
|
|
49
|
-
var tsplus_module_5 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/
|
|
50
|
-
var tsplus_module_6 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/
|
|
51
|
-
var tsplus_module_7 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/
|
|
52
|
-
var tsplus_module_8 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/
|
|
53
|
-
var tsplus_module_9 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Maybe/
|
|
51
|
+
var tsplus_module_3 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Maybe/constructors"));
|
|
52
|
+
var tsplus_module_4 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/schema/ParseResult"));
|
|
53
|
+
var tsplus_module_5 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/schema/ParseError"));
|
|
54
|
+
var tsplus_module_6 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/number/instances"));
|
|
55
|
+
var tsplus_module_7 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Ord/api/contramap"));
|
|
56
|
+
var tsplus_module_8 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Maybe/definition"));
|
|
57
|
+
var tsplus_module_9 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Maybe/destructors"));
|
|
58
|
+
var tsplus_module_10 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/collection/immutable/Vector/internal"));
|
|
59
|
+
var tsplus_module_11 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Maybe/api"));
|
|
54
60
|
var _Showable = /*#__PURE__*/require("@fncts/base/data/Showable");
|
|
55
61
|
var _utils = /*#__PURE__*/require("@fncts/schema/utils");
|
|
56
62
|
var _ASTAnnotationMap = /*#__PURE__*/require("./ASTAnnotationMap.cjs");
|
|
@@ -75,13 +81,11 @@ const createTypeLiteral = exports.createTypeLiteral = createTypeLiteral_1;
|
|
|
75
81
|
const createUnion = exports.createUnion = createUnion_1;
|
|
76
82
|
const createLazy = exports.createLazy = createLazy_1;
|
|
77
83
|
const createRefinement = exports.createRefinement = createRefinement_1;
|
|
78
|
-
const createTransform = exports.createTransform = createTransform_1;
|
|
79
84
|
const getPropertySignatures = exports.getPropertySignatures = getPropertySignatures_1;
|
|
80
85
|
const keysOf = exports.keysOf = keysOf_1;
|
|
81
86
|
const partial = exports.partial = partial_1;
|
|
82
87
|
const getFrom = exports.getFrom = getFrom_1;
|
|
83
88
|
const getTo = exports.getTo = getTo_1;
|
|
84
|
-
const reverse = exports.reverse = reverse_1;
|
|
85
89
|
const ASTTypeId = exports.ASTTypeId = /*#__PURE__*/Symbol.for("fncts.schema.AST");
|
|
86
90
|
class Annotated {
|
|
87
91
|
constructor() {
|
|
@@ -269,7 +273,8 @@ class UnknownKeyword extends AST {
|
|
|
269
273
|
* @tsplus static fncts.schema.ASTOps unknownKeyword
|
|
270
274
|
*/
|
|
271
275
|
exports.UnknownKeyword = UnknownKeyword;
|
|
272
|
-
const
|
|
276
|
+
const unknownKeyword_1 = /*#__PURE__*/new UnknownKeyword( /*#__PURE__*/_ASTAnnotationMap.ASTAnnotationMap.empty.annotate(tsplus_module_1.Title, "unknown"));
|
|
277
|
+
const unknownKeyword = exports.unknownKeyword = unknownKeyword_1;
|
|
273
278
|
/*
|
|
274
279
|
* AnyKeyword
|
|
275
280
|
*/
|
|
@@ -527,6 +532,10 @@ exports.Tuple = Tuple;
|
|
|
527
532
|
function createTuple_1(elements, rest, isReadonly, annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
|
|
528
533
|
return new Tuple(elements, rest, isReadonly, annotations);
|
|
529
534
|
}
|
|
535
|
+
/**
|
|
536
|
+
* @tsplus static fncts.schema.ASTOps unknownArray
|
|
537
|
+
*/
|
|
538
|
+
const unknownArray = exports.unknownArray = /*#__PURE__*/createTuple_1( /*#__PURE__*/tsplus_module_2.empty(), /*#__PURE__*/tsplus_module_3.just( /*#__PURE__*/tsplus_module_2.vector(unknownKeyword_1), fileName_1 + ":629:65"), true);
|
|
530
539
|
/*
|
|
531
540
|
* PropertySignature
|
|
532
541
|
*/
|
|
@@ -597,6 +606,10 @@ function isTypeLiteral(self) {
|
|
|
597
606
|
function createTypeLiteral_1(propertySignatures, indexSignatures, annotations) {
|
|
598
607
|
return new TypeLiteral(propertySignatures, indexSignatures, annotations);
|
|
599
608
|
}
|
|
609
|
+
/**
|
|
610
|
+
* @tsplus static fncts.schema.ASTOps unknownRecord
|
|
611
|
+
*/
|
|
612
|
+
const unknownRecord = exports.unknownRecord = /*#__PURE__*/createTypeLiteral_1( /*#__PURE__*/tsplus_module_2.empty(), /*#__PURE__*/tsplus_module_2.vector( /*#__PURE__*/createIndexSignature_1(stringKeyword_1, unknownKeyword_1, true), /*#__PURE__*/createIndexSignature_1(symbolKeyword_1, unknownKeyword_1, true)));
|
|
600
613
|
/*
|
|
601
614
|
* Union
|
|
602
615
|
*/
|
|
@@ -665,24 +678,26 @@ function isLazy(self) {
|
|
|
665
678
|
* Refinement
|
|
666
679
|
*/
|
|
667
680
|
class Refinement extends AST {
|
|
668
|
-
constructor(from,
|
|
681
|
+
constructor(from, predicate, annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
|
|
669
682
|
super();
|
|
670
683
|
this.from = from;
|
|
671
|
-
this.
|
|
672
|
-
this.isReversed = isReversed;
|
|
684
|
+
this.predicate = predicate;
|
|
673
685
|
this.annotations = annotations;
|
|
674
686
|
this._tag = 20 /* ASTTag.Refinement */;
|
|
675
687
|
}
|
|
688
|
+
decode(input, options) {
|
|
689
|
+
return this.predicate(input) ? tsplus_module_4.succeed(input) : tsplus_module_4.fail(tsplus_module_5.typeError(this, input));
|
|
690
|
+
}
|
|
676
691
|
clone(newProperties) {
|
|
677
|
-
return new Refinement(newProperties.from ?? this.from, newProperties.
|
|
692
|
+
return new Refinement(newProperties.from ?? this.from, newProperties.predicate ?? this.predicate, newProperties.annotations ?? this.annotations);
|
|
678
693
|
}
|
|
679
694
|
}
|
|
680
695
|
/**
|
|
681
696
|
* @tsplus static fncts.schema.ASTOps createRefinement
|
|
682
697
|
*/
|
|
683
698
|
exports.Refinement = Refinement;
|
|
684
|
-
function createRefinement_1(from,
|
|
685
|
-
return new Refinement(from,
|
|
699
|
+
function createRefinement_1(from, predicate, annotations) {
|
|
700
|
+
return new Refinement(from, predicate, annotations);
|
|
686
701
|
}
|
|
687
702
|
function isRefinement(self) {
|
|
688
703
|
void 0;
|
|
@@ -692,26 +707,25 @@ function isRefinement(self) {
|
|
|
692
707
|
* Transform
|
|
693
708
|
*/
|
|
694
709
|
class Transform extends AST {
|
|
695
|
-
constructor(from, to, decode, encode,
|
|
710
|
+
constructor(from, to, decode, encode, annotations = _ASTAnnotationMap.ASTAnnotationMap.empty) {
|
|
696
711
|
super();
|
|
697
712
|
this.from = from;
|
|
698
713
|
this.to = to;
|
|
699
714
|
this.decode = decode;
|
|
700
715
|
this.encode = encode;
|
|
701
|
-
this.isReversed = isReversed;
|
|
702
716
|
this.annotations = annotations;
|
|
703
717
|
this._tag = 21 /* ASTTag.Transform */;
|
|
704
718
|
}
|
|
705
719
|
clone(newProperties) {
|
|
706
|
-
return new Transform(newProperties.from ?? this.from, newProperties.to ?? this.to, newProperties.decode ?? this.decode, newProperties.encode ?? this.encode, newProperties.
|
|
720
|
+
return new Transform(newProperties.from ?? this.from, newProperties.to ?? this.to, newProperties.decode ?? this.decode, newProperties.encode ?? this.encode, newProperties.annotations ?? this.annotations);
|
|
707
721
|
}
|
|
708
722
|
}
|
|
709
723
|
/**
|
|
710
724
|
* @tsplus static fncts.schema.ASTOps createTransform
|
|
711
725
|
*/
|
|
712
726
|
exports.Transform = Transform;
|
|
713
|
-
function
|
|
714
|
-
return new Transform(from, getTo_1(to), decode, encode,
|
|
727
|
+
function createTransform(from, to, decode, encode, annotations) {
|
|
728
|
+
return new Transform(from, getTo_1(to), decode, encode, annotations);
|
|
715
729
|
}
|
|
716
730
|
/*
|
|
717
731
|
* Validation
|
|
@@ -781,9 +795,9 @@ function getCardinality(ast) {
|
|
|
781
795
|
}
|
|
782
796
|
}
|
|
783
797
|
function sortByAscendingCardinality(types) {
|
|
784
|
-
return tsplus_module_2.sort(
|
|
798
|
+
return tsplus_module_2.sort(tsplus_module_7.contramap(({
|
|
785
799
|
type
|
|
786
|
-
}) => getCardinality(type))(
|
|
800
|
+
}) => getCardinality(type))(tsplus_module_6.Ord))(types);
|
|
787
801
|
}
|
|
788
802
|
function getWeight(ast) {
|
|
789
803
|
void 0;
|
|
@@ -791,7 +805,7 @@ function getWeight(ast) {
|
|
|
791
805
|
case 0 /* ASTTag.Declaration */:
|
|
792
806
|
return getWeight(ast.type);
|
|
793
807
|
case 16 /* ASTTag.Tuple */:
|
|
794
|
-
return ast.elements.length + (
|
|
808
|
+
return ast.elements.length + (tsplus_module_8.isJust(ast.rest) ? ast.rest.value.length : 0);
|
|
795
809
|
case 17 /* ASTTag.TypeLiteral */:
|
|
796
810
|
return ast.propertySignatures.length + ast.indexSignatures.length;
|
|
797
811
|
case 18 /* ASTTag.Union */:
|
|
@@ -807,7 +821,7 @@ function getWeight(ast) {
|
|
|
807
821
|
}
|
|
808
822
|
}
|
|
809
823
|
function sortByDescendingWeight(types) {
|
|
810
|
-
return tsplus_module_2.sort(
|
|
824
|
+
return tsplus_module_2.sort(tsplus_module_7.contramap(getWeight)(tsplus_module_6.Ord))(types);
|
|
811
825
|
}
|
|
812
826
|
function unify(candidates) {
|
|
813
827
|
let out = tsplus_module_2.flatMap(ast => {
|
|
@@ -857,10 +871,10 @@ function setAnnotation(annotation, value) {
|
|
|
857
871
|
*/
|
|
858
872
|
function appendRestElement(restElement) {
|
|
859
873
|
return self => {
|
|
860
|
-
if (
|
|
874
|
+
if (tsplus_module_8.isJust(self.rest)) {
|
|
861
875
|
throw new Error("A rest element cannot follow another rest element. ts(1265)");
|
|
862
876
|
}
|
|
863
|
-
return createTuple_1(self.elements,
|
|
877
|
+
return createTuple_1(self.elements, tsplus_module_3.just(tsplus_module_2.vector(restElement), fileName_1 + ":1062:43"), self.isReadonly, self.annotations);
|
|
864
878
|
};
|
|
865
879
|
}
|
|
866
880
|
/**
|
|
@@ -871,11 +885,11 @@ function appendElement(element) {
|
|
|
871
885
|
if (tsplus_module_2.some(e => e.isOptional)(self.elements) && !element.isOptional) {
|
|
872
886
|
throw new Error("A required element cannot follow an optional element. ts(1257)");
|
|
873
887
|
}
|
|
874
|
-
return
|
|
888
|
+
return tsplus_module_9.match(() => createTuple_1(tsplus_module_2.append(element)(self.elements), tsplus_module_3.nothing(fileName_1 + ":1075:63"), self.isReadonly, self.annotations), rest => {
|
|
875
889
|
if (element.isOptional) {
|
|
876
890
|
throw new Error("A required element cannot follow an optional element. ts(1257)");
|
|
877
891
|
}
|
|
878
|
-
return createTuple_1(self.elements,
|
|
892
|
+
return createTuple_1(self.elements, tsplus_module_3.just(tsplus_module_2.append(element.type)(rest), fileName_1 + ":1080:47"), self.isReadonly, self.annotations);
|
|
879
893
|
})(self.rest);
|
|
880
894
|
};
|
|
881
895
|
}
|
|
@@ -900,9 +914,9 @@ function getPropertySignatures_1(self) {
|
|
|
900
914
|
}) => {
|
|
901
915
|
if (tsplus_module_2.every(ps => tsplus_module_2.some(p => p.name === name)(ps))(propertySignatures)) {
|
|
902
916
|
const members = tsplus_module_2.flatMap(ps => tsplus_module_2.filter(p => p.name === name)(ps))(propertySignatures);
|
|
903
|
-
return
|
|
917
|
+
return tsplus_module_3.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 + ":1107:22");
|
|
904
918
|
}
|
|
905
|
-
return
|
|
919
|
+
return tsplus_module_3.nothing(fileName_1 + ":1116:23");
|
|
906
920
|
})(tsplus_module_2.unsafeGet(0)(propertySignatures));
|
|
907
921
|
}
|
|
908
922
|
case 19 /* ASTTag.Lazy */:
|
|
@@ -966,15 +980,15 @@ function createRecord(key, value, isReadonly) {
|
|
|
966
980
|
case 12 /* ASTTag.SymbolKeyword */:
|
|
967
981
|
case 15 /* ASTTag.TemplateLiteral */:
|
|
968
982
|
case 20 /* ASTTag.Refinement */:
|
|
969
|
-
|
|
983
|
+
tsplus_module_10.push(createIndexSignature_1(key, value, isReadonly))(indexSignatures);
|
|
970
984
|
break;
|
|
971
985
|
case 1 /* ASTTag.Literal */:
|
|
972
986
|
if (typeof key.literal === "string" || typeof key.literal === "number") {
|
|
973
|
-
|
|
987
|
+
tsplus_module_10.push(createPropertySignature_1(key.literal, value, false, isReadonly))(propertySignatures);
|
|
974
988
|
}
|
|
975
989
|
break;
|
|
976
990
|
case 2 /* ASTTag.UniqueSymbol */:
|
|
977
|
-
|
|
991
|
+
tsplus_module_10.push(createPropertySignature_1(key.symbol, value, false, isReadonly))(propertySignatures);
|
|
978
992
|
break;
|
|
979
993
|
case 18 /* ASTTag.Union */:
|
|
980
994
|
tsplus_module_2.forEach(go)(key.types);
|
|
@@ -1011,7 +1025,7 @@ function partial_1(self) {
|
|
|
1011
1025
|
case 0 /* ASTTag.Declaration */:
|
|
1012
1026
|
return partial_1(self.type);
|
|
1013
1027
|
case 16 /* ASTTag.Tuple */:
|
|
1014
|
-
return createTuple_1(tsplus_module_2.map(e => createElement_1(e.type, true))(self.elements),
|
|
1028
|
+
return createTuple_1(tsplus_module_2.map(e => createElement_1(e.type, true))(self.elements), tsplus_module_11.map(rest => tsplus_module_2.vector(createUnion_1(tsplus_module_2.append(undefinedKeyword_1)(rest))))(self.rest), self.isReadonly);
|
|
1015
1029
|
case 17 /* ASTTag.TypeLiteral */:
|
|
1016
1030
|
return createTypeLiteral_1(tsplus_module_2.map(f => createPropertySignature_1(f.name, f.type, true, f.isReadonly, f.annotations))(self.propertySignatures), self.indexSignatures);
|
|
1017
1031
|
case 18 /* ASTTag.Union */:
|
|
@@ -1041,7 +1055,7 @@ function getFrom_1(ast) {
|
|
|
1041
1055
|
case 0 /* ASTTag.Declaration */:
|
|
1042
1056
|
return createDeclaration_1(tsplus_module_2.map(getFrom_1)(ast.typeParameters), ast.type, ast.decode, ast.annotations);
|
|
1043
1057
|
case 16 /* ASTTag.Tuple */:
|
|
1044
|
-
return createTuple_1(tsplus_module_2.map(element => createElement_1(getFrom_1(element.type), element.isOptional))(ast.elements),
|
|
1058
|
+
return createTuple_1(tsplus_module_2.map(element => createElement_1(getFrom_1(element.type), element.isOptional))(ast.elements), tsplus_module_11.map(restElement => tsplus_module_2.map(getFrom_1)(restElement))(ast.rest), ast.isReadonly, ast.annotations);
|
|
1045
1059
|
case 17 /* ASTTag.TypeLiteral */:
|
|
1046
1060
|
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);
|
|
1047
1061
|
case 18 /* ASTTag.Union */:
|
|
@@ -1063,7 +1077,7 @@ function getTo_1(ast) {
|
|
|
1063
1077
|
case 0 /* ASTTag.Declaration */:
|
|
1064
1078
|
return createDeclaration_1(tsplus_module_2.map(getTo_1)(ast.typeParameters), ast.type, ast.decode, ast.annotations);
|
|
1065
1079
|
case 16 /* ASTTag.Tuple */:
|
|
1066
|
-
return createTuple_1(tsplus_module_2.map(element => createElement_1(getTo_1(element.type), element.isOptional))(ast.elements),
|
|
1080
|
+
return createTuple_1(tsplus_module_2.map(element => createElement_1(getTo_1(element.type), element.isOptional))(ast.elements), tsplus_module_11.map(restElement => tsplus_module_2.map(getTo_1)(restElement))(ast.rest), ast.isReadonly, ast.annotations);
|
|
1067
1081
|
case 17 /* ASTTag.TypeLiteral */:
|
|
1068
1082
|
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);
|
|
1069
1083
|
case 18 /* ASTTag.Union */:
|
|
@@ -1071,35 +1085,12 @@ function getTo_1(ast) {
|
|
|
1071
1085
|
case 19 /* ASTTag.Lazy */:
|
|
1072
1086
|
return createLazy_1(() => getTo_1(ast.getAST()), ast.annotations);
|
|
1073
1087
|
case 20 /* ASTTag.Refinement */:
|
|
1074
|
-
return createRefinement_1(getTo_1(ast.from), ast.
|
|
1088
|
+
return createRefinement_1(getTo_1(ast.from), ast.predicate, ast.annotations);
|
|
1075
1089
|
case 21 /* ASTTag.Transform */:
|
|
1076
1090
|
return getTo_1(ast.to);
|
|
1077
1091
|
}
|
|
1078
1092
|
return ast;
|
|
1079
1093
|
}
|
|
1080
|
-
/**
|
|
1081
|
-
* @tsplus getter fncts.schema.AST reverse
|
|
1082
|
-
*/
|
|
1083
|
-
function reverse_1(ast) {
|
|
1084
|
-
void 0;
|
|
1085
|
-
switch (ast._tag) {
|
|
1086
|
-
case 0 /* ASTTag.Declaration */:
|
|
1087
|
-
return createDeclaration_1(tsplus_module_2.map(reverse_1)(ast.typeParameters), ast.type, ast.decode, ast.annotations);
|
|
1088
|
-
case 16 /* ASTTag.Tuple */:
|
|
1089
|
-
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);
|
|
1090
|
-
case 17 /* ASTTag.TypeLiteral */:
|
|
1091
|
-
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);
|
|
1092
|
-
case 18 /* ASTTag.Union */:
|
|
1093
|
-
return createUnion_1(tsplus_module_2.map(reverse_1)(ast.types), ast.annotations);
|
|
1094
|
-
case 19 /* ASTTag.Lazy */:
|
|
1095
|
-
return createLazy_1(() => reverse_1(ast.getAST()), ast.annotations);
|
|
1096
|
-
case 20 /* ASTTag.Refinement */:
|
|
1097
|
-
return createRefinement_1(ast.from, ast.decode, !ast.isReversed, ast.annotations);
|
|
1098
|
-
case 21 /* ASTTag.Transform */:
|
|
1099
|
-
return createTransform_1(reverse_1(ast.from), ast.to, ast.decode, ast.encode, !ast.isReversed, ast.annotations);
|
|
1100
|
-
}
|
|
1101
|
-
return ast;
|
|
1102
|
-
}
|
|
1103
1094
|
/**
|
|
1104
1095
|
* @tsplus static fncts.schema.AST getCompiler
|
|
1105
1096
|
*/
|
|
@@ -1110,4 +1101,63 @@ function getCompiler(match) {
|
|
|
1110
1101
|
});
|
|
1111
1102
|
return compile;
|
|
1112
1103
|
}
|
|
1104
|
+
function getLiterals(ast, isDecoding) {
|
|
1105
|
+
void 0;
|
|
1106
|
+
switch (ast._tag) {
|
|
1107
|
+
case 0 /* ASTTag.Declaration */:
|
|
1108
|
+
return getLiterals(ast.type, isDecoding);
|
|
1109
|
+
case 17 /* ASTTag.TypeLiteral */:
|
|
1110
|
+
{
|
|
1111
|
+
const out = [];
|
|
1112
|
+
for (let i = 0; i < ast.propertySignatures.length; i++) {
|
|
1113
|
+
const propertySignature = tsplus_module_2.unsafeGet(i)(ast.propertySignatures);
|
|
1114
|
+
if (isLiteral_1(propertySignature.type) && !propertySignature.isOptional) {
|
|
1115
|
+
out.push([propertySignature.name, propertySignature.type]);
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
return out;
|
|
1119
|
+
}
|
|
1120
|
+
case 20 /* ASTTag.Refinement */:
|
|
1121
|
+
return getLiterals(ast.from, isDecoding);
|
|
1122
|
+
case 21 /* ASTTag.Transform */:
|
|
1123
|
+
return getLiterals(isDecoding ? ast.from : ast.to, isDecoding);
|
|
1124
|
+
}
|
|
1125
|
+
return [];
|
|
1126
|
+
}
|
|
1127
|
+
function getSearchTree(members, isDecoding) {
|
|
1128
|
+
const keys = {};
|
|
1129
|
+
const otherwise = [];
|
|
1130
|
+
for (let i = 0; i < members.length; i++) {
|
|
1131
|
+
const member = tsplus_module_2.unsafeGet(i)(members);
|
|
1132
|
+
const tags = getLiterals(member, isDecoding);
|
|
1133
|
+
if (tags.length > 0) {
|
|
1134
|
+
for (let j = 0; j < tags.length; j++) {
|
|
1135
|
+
const [key, literal] = tags[j];
|
|
1136
|
+
const hash = String(literal.literal);
|
|
1137
|
+
keys[key] || (keys[key] = {
|
|
1138
|
+
buckets: {},
|
|
1139
|
+
ast: neverKeyword_1
|
|
1140
|
+
});
|
|
1141
|
+
const buckets = keys[key].buckets;
|
|
1142
|
+
if (Object.prototype.hasOwnProperty.call(buckets, hash)) {
|
|
1143
|
+
if (j < tags.length - 1) {
|
|
1144
|
+
continue;
|
|
1145
|
+
}
|
|
1146
|
+
buckets[hash].push(member);
|
|
1147
|
+
keys[key].ast = createUnion_1(tsplus_module_2.vector(keys[key].ast, literal));
|
|
1148
|
+
} else {
|
|
1149
|
+
buckets[hash] = [member];
|
|
1150
|
+
keys[key].ast = createUnion_1(tsplus_module_2.vector(keys[key].ast, literal));
|
|
1151
|
+
break;
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
} else {
|
|
1155
|
+
otherwise.push(member);
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
return {
|
|
1159
|
+
keys,
|
|
1160
|
+
otherwise
|
|
1161
|
+
};
|
|
1162
|
+
}
|
|
1113
1163
|
//# sourceMappingURL=AST.cjs.map
|