@fncts/schema 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/AST.d.ts +528 -0
  2. package/ASTAnnotation.d.ts +82 -0
  3. package/ASTAnnotationMap.d.ts +14 -0
  4. package/Gen.d.ts +15 -0
  5. package/InvalidInterpretationError.d.ts +5 -0
  6. package/ParseError.d.ts +107 -0
  7. package/ParseResult.d.ts +24 -0
  8. package/Parser/api.d.ts +42 -0
  9. package/Parser/definition.d.ts +22 -0
  10. package/Parser/interpreter.d.ts +6 -0
  11. package/Parser.d.ts +3 -0
  12. package/Schema/api/conc.d.ts +18 -0
  13. package/Schema/api/either.d.ts +19 -0
  14. package/Schema/api/hashMap.d.ts +21 -0
  15. package/Schema/api/immutableArray.d.ts +23 -0
  16. package/Schema/api/list.d.ts +23 -0
  17. package/Schema/api/maybe.d.ts +21 -0
  18. package/Schema/api.d.ts +243 -0
  19. package/Schema/definition.d.ts +29 -0
  20. package/Schema/derivations.d.ts +70 -0
  21. package/Schema.d.ts +9 -144
  22. package/_cjs/AST.cjs +1172 -0
  23. package/_cjs/AST.cjs.map +1 -0
  24. package/_cjs/ASTAnnotation.cjs +111 -0
  25. package/_cjs/ASTAnnotation.cjs.map +1 -0
  26. package/_cjs/ASTAnnotationMap.cjs +35 -0
  27. package/_cjs/ASTAnnotationMap.cjs.map +1 -0
  28. package/_cjs/Gen.cjs +182 -0
  29. package/_cjs/Gen.cjs.map +1 -0
  30. package/_cjs/InvalidInterpretationError.cjs +18 -0
  31. package/_cjs/InvalidInterpretationError.cjs.map +1 -0
  32. package/_cjs/ParseError.cjs +223 -0
  33. package/_cjs/ParseError.cjs.map +1 -0
  34. package/_cjs/{Decoder.cjs → ParseResult.cjs} +25 -22
  35. package/_cjs/ParseResult.cjs.map +1 -0
  36. package/_cjs/Parser/api.cjs +80 -0
  37. package/_cjs/Parser/api.cjs.map +1 -0
  38. package/_cjs/{Guard.cjs → Parser/definition.cjs} +17 -22
  39. package/_cjs/Parser/definition.cjs.map +1 -0
  40. package/_cjs/Parser/interpreter.cjs +410 -0
  41. package/_cjs/Parser/interpreter.cjs.map +1 -0
  42. package/_cjs/Parser.cjs +39 -0
  43. package/_cjs/Parser.cjs.map +1 -0
  44. package/_cjs/Schema/api/conc.cjs +84 -0
  45. package/_cjs/Schema/api/conc.cjs.map +1 -0
  46. package/_cjs/Schema/api/either.cjs +96 -0
  47. package/_cjs/Schema/api/either.cjs.map +1 -0
  48. package/_cjs/Schema/api/hashMap.cjs +161 -0
  49. package/_cjs/Schema/api/hashMap.cjs.map +1 -0
  50. package/_cjs/Schema/api/immutableArray.cjs +90 -0
  51. package/_cjs/Schema/api/immutableArray.cjs.map +1 -0
  52. package/_cjs/Schema/api/list.cjs +98 -0
  53. package/_cjs/Schema/api/list.cjs.map +1 -0
  54. package/_cjs/Schema/api/maybe.cjs +76 -0
  55. package/_cjs/Schema/api/maybe.cjs.map +1 -0
  56. package/_cjs/Schema/api.cjs +425 -0
  57. package/_cjs/Schema/api.cjs.map +1 -0
  58. package/_cjs/Schema/definition.cjs +26 -0
  59. package/_cjs/Schema/definition.cjs.map +1 -0
  60. package/_cjs/Schema/derivations.cjs +108 -0
  61. package/_cjs/Schema/derivations.cjs.map +1 -0
  62. package/_cjs/Schema.cjs +97 -237
  63. package/_cjs/Schema.cjs.map +1 -1
  64. package/_cjs/utils.cjs +52 -0
  65. package/_cjs/utils.cjs.map +1 -0
  66. package/_mjs/AST.mjs +1061 -0
  67. package/_mjs/AST.mjs.map +1 -0
  68. package/_mjs/ASTAnnotation.mjs +80 -0
  69. package/_mjs/ASTAnnotation.mjs.map +1 -0
  70. package/_mjs/ASTAnnotationMap.mjs +27 -0
  71. package/_mjs/ASTAnnotationMap.mjs.map +1 -0
  72. package/_mjs/Gen.mjs +173 -0
  73. package/_mjs/Gen.mjs.map +1 -0
  74. package/_mjs/InvalidInterpretationError.mjs +10 -0
  75. package/_mjs/InvalidInterpretationError.mjs.map +1 -0
  76. package/_mjs/ParseError.mjs +201 -0
  77. package/_mjs/ParseError.mjs.map +1 -0
  78. package/_mjs/ParseResult.mjs +22 -0
  79. package/_mjs/ParseResult.mjs.map +1 -0
  80. package/_mjs/Parser/api.mjs +67 -0
  81. package/_mjs/Parser/api.mjs.map +1 -0
  82. package/_mjs/Parser/definition.mjs +15 -0
  83. package/_mjs/Parser/definition.mjs.map +1 -0
  84. package/_mjs/Parser/interpreter.mjs +402 -0
  85. package/_mjs/Parser/interpreter.mjs.map +1 -0
  86. package/_mjs/Parser.mjs +5 -0
  87. package/_mjs/Parser.mjs.map +1 -0
  88. package/_mjs/Schema/api/conc.mjs +72 -0
  89. package/_mjs/Schema/api/conc.mjs.map +1 -0
  90. package/_mjs/Schema/api/either.mjs +85 -0
  91. package/_mjs/Schema/api/either.mjs.map +1 -0
  92. package/_mjs/Schema/api/hashMap.mjs +150 -0
  93. package/_mjs/Schema/api/hashMap.mjs.map +1 -0
  94. package/_mjs/Schema/api/immutableArray.mjs +79 -0
  95. package/_mjs/Schema/api/immutableArray.mjs.map +1 -0
  96. package/_mjs/Schema/api/list.mjs +87 -0
  97. package/_mjs/Schema/api/list.mjs.map +1 -0
  98. package/_mjs/Schema/api/maybe.mjs +65 -0
  99. package/_mjs/Schema/api/maybe.mjs.map +1 -0
  100. package/_mjs/Schema/api.mjs +368 -0
  101. package/_mjs/Schema/api.mjs.map +1 -0
  102. package/_mjs/Schema/definition.mjs +16 -0
  103. package/_mjs/Schema/definition.mjs.map +1 -0
  104. package/_mjs/Schema/derivations.mjs +94 -0
  105. package/_mjs/Schema/derivations.mjs.map +1 -0
  106. package/_mjs/Schema.mjs +12 -212
  107. package/_mjs/Schema.mjs.map +1 -1
  108. package/_mjs/utils.mjs +41 -0
  109. package/_mjs/utils.mjs.map +1 -0
  110. package/_src/AST.ts +1353 -0
  111. package/_src/ASTAnnotation.ts +98 -0
  112. package/_src/ASTAnnotationMap.ts +38 -0
  113. package/_src/Gen.ts +168 -0
  114. package/_src/InvalidInterpretationError.ts +6 -0
  115. package/_src/ParseError.ts +237 -0
  116. package/_src/ParseResult.ts +26 -0
  117. package/_src/Parser/api.ts +71 -0
  118. package/_src/Parser/definition.ts +24 -0
  119. package/_src/Parser/interpreter.ts +442 -0
  120. package/_src/Parser.ts +5 -0
  121. package/_src/Schema/api/conc.ts +78 -0
  122. package/_src/Schema/api/either.ts +96 -0
  123. package/_src/Schema/api/hashMap.ts +184 -0
  124. package/_src/Schema/api/immutableArray.ts +88 -0
  125. package/_src/Schema/api/list.ts +96 -0
  126. package/_src/Schema/api/maybe.ts +68 -0
  127. package/_src/Schema/api.ts +530 -0
  128. package/_src/Schema/definition.ts +32 -0
  129. package/_src/Schema/derivations.ts +185 -0
  130. package/_src/Schema.ts +14 -254
  131. package/_src/global.ts +53 -0
  132. package/_src/utils.ts +48 -0
  133. package/global.d.ts +52 -0
  134. package/package.json +2 -2
  135. package/utils.d.ts +8 -0
  136. package/Decoder.d.ts +0 -3
  137. package/Encoder.d.ts +0 -4
  138. package/Guard.d.ts +0 -3
  139. package/Schemable.d.ts +0 -39
  140. package/_cjs/Decoder.cjs.map +0 -1
  141. package/_cjs/Encoder.cjs +0 -45
  142. package/_cjs/Encoder.cjs.map +0 -1
  143. package/_cjs/Guard.cjs.map +0 -1
  144. package/_cjs/Schemable.cjs +0 -6
  145. package/_cjs/Schemable.cjs.map +0 -1
  146. package/_mjs/Decoder.mjs +0 -20
  147. package/_mjs/Decoder.mjs.map +0 -1
  148. package/_mjs/Encoder.mjs +0 -36
  149. package/_mjs/Encoder.mjs.map +0 -1
  150. package/_mjs/Guard.mjs +0 -20
  151. package/_mjs/Guard.mjs.map +0 -1
  152. package/_mjs/Schemable.mjs +0 -2
  153. package/_mjs/Schemable.mjs.map +0 -1
  154. package/_src/Decoder.ts +0 -20
  155. package/_src/Encoder.ts +0 -38
  156. package/_src/Guard.ts +0 -20
  157. package/_src/Schemable.ts +0 -46
@@ -0,0 +1,107 @@
1
+ import { AST } from "@fncts/schema/AST";
2
+ import { Vector } from "@fncts/base/collection/immutable/Vector";
3
+ import { Maybe } from "@fncts/base/data/Maybe/definition";
4
+ import { RoseTree } from "@fncts/base/collection/immutable/RoseTree";
5
+ export declare const enum ParseErrorTag {
6
+ Type = 0,
7
+ Index = 1,
8
+ Key = 2,
9
+ Missing = 3,
10
+ Unexpected = 4,
11
+ UnionMember = 5
12
+ }
13
+ /**
14
+ * @tsplus type fncts.schema.ParseError
15
+ * @tsplus companion fncts.schema.ParseErrorOps
16
+ */
17
+ export type ParseError = TypeError | IndexError | KeyError | MissingError | UnexpectedError | UnexpectedError | UnionMemberError;
18
+ /**
19
+ * @tsplus companion fncts.schema.ParseError.TypeError
20
+ */
21
+ export declare class TypeError {
22
+ readonly expected: AST;
23
+ readonly actual: unknown;
24
+ readonly _tag = ParseErrorTag.Type;
25
+ constructor(expected: AST, actual: unknown);
26
+ }
27
+ /**
28
+ * @tsplus static fncts.schema.ParseError.TypeError __call
29
+ * @tsplus static fncts.schema.ParseErrorOps TypeError
30
+ * @tsplus location "@fncts/schema/ParseError"
31
+ */
32
+ export declare function typeError(expected: AST, actual: unknown): ParseError;
33
+ /**
34
+ * @tsplus companion fncts.schema.ParseError.IndexError
35
+ */
36
+ export declare class IndexError {
37
+ readonly index: number;
38
+ readonly errors: Vector<ParseError>;
39
+ readonly _tag = ParseErrorTag.Index;
40
+ constructor(index: number, errors: Vector<ParseError>);
41
+ }
42
+ /**
43
+ * @tsplus static fncts.schema.ParseError.IndexError __call
44
+ * @tsplus static fncts.schema.ParseErrorOps IndexError
45
+ * @tsplus location "@fncts/schema/ParseError"
46
+ */
47
+ export declare function indexError(index: number, errors: Vector<ParseError>): ParseError;
48
+ /**
49
+ * @tsplus companion fncts.schema.ParseError.KeyError
50
+ */
51
+ export declare class KeyError {
52
+ readonly keyAST: AST;
53
+ readonly key: any;
54
+ readonly errors: Vector<ParseError>;
55
+ readonly _tag = ParseErrorTag.Key;
56
+ constructor(keyAST: AST, key: any, errors: Vector<ParseError>);
57
+ }
58
+ /**
59
+ * @tsplus static fncts.schema.ParseError.IndexError __call
60
+ * @tsplus static fncts.schema.ParseErrorOps KeyError
61
+ * @tsplus location "@fncts/schema/ParseError"
62
+ */
63
+ export declare function keyError(keyAST: AST, key: any, errors: Vector<ParseError>): ParseError;
64
+ /**
65
+ * @tsplus companion fncts.schema.ParseError.MissingError
66
+ */
67
+ export declare class MissingError {
68
+ readonly _tag = ParseErrorTag.Missing;
69
+ }
70
+ /**
71
+ * @tsplus static fncts.schema.ParseErrorOps MissingError
72
+ * @tsplus location "@fncts/schema/ParseError"
73
+ */
74
+ export declare const missingError: MissingError;
75
+ /**
76
+ * @tsplus companion fncts.schema.ParseError.UnexpectedError
77
+ */
78
+ export declare class UnexpectedError {
79
+ readonly actual: unknown;
80
+ readonly _tag = ParseErrorTag.Unexpected;
81
+ constructor(actual: unknown);
82
+ }
83
+ /**
84
+ * @tsplus static fncts.schema.ParseError.UnexpectedError __call
85
+ * @tsplus static fncts.schema.ParseErrorOps UnexpectedError
86
+ * @tsplus location "@fncts/schema/ParseError"
87
+ */
88
+ export declare function unexpectedError(actual: unknown): ParseError;
89
+ /**
90
+ * @tsplus companion fncts.schema.ParseError.UnionMemberError
91
+ */
92
+ export declare class UnionMemberError {
93
+ readonly errors: Vector<ParseError>;
94
+ readonly _tag = ParseErrorTag.UnionMember;
95
+ constructor(errors: Vector<ParseError>);
96
+ }
97
+ /**
98
+ * @tsplus static fncts.schema.ParseError.UnionMemberError __call
99
+ * @tsplus static fncts.schema.ParseErrorOps UnionMemberError
100
+ * @tsplus location "@fncts/schema/ParseError"
101
+ */
102
+ export declare function unionMemberError(errors: Vector<ParseError>): ParseError;
103
+ /**
104
+ * @tsplus static fncts.schema.ParseErrorOps format
105
+ * @tsplus location "@fncts/schema/ParseError"
106
+ */
107
+ export declare function format(errors: Vector<ParseError>): string;
@@ -0,0 +1,24 @@
1
+ import { Either } from "@fncts/base/data/Either/definition";
2
+ import { Vector } from "@fncts/base/collection/immutable/Vector";
3
+ import { ParseError } from "@fncts/schema/ParseError";
4
+ /**
5
+ * @tsplus type fncts.schema.ParseResult
6
+ * @tsplus companion fncts.schema.ParseResultOps
7
+ */
8
+ export interface ParseResult<A> extends Either<Vector<ParseError>, A> {
9
+ }
10
+ /**
11
+ * @tsplus static fncts.schema.ParseResultOps succeed
12
+ * @tsplus location "@fncts/schema/ParseResult"
13
+ */
14
+ export declare function succeed<A>(value: A): ParseResult<A>;
15
+ /**
16
+ * @tsplus static fncts.schema.ParseResultOps failures
17
+ * @tsplus location "@fncts/schema/ParseResult"
18
+ */
19
+ export declare function failures<A = never>(value: Vector<ParseError>): ParseResult<A>;
20
+ /**
21
+ * @tsplus static fncts.schema.ParseResultOps fail
22
+ * @tsplus location "@fncts/schema/ParseResult"
23
+ */
24
+ export declare function fail<A = never>(value: ParseError): ParseResult<A>;
@@ -0,0 +1,42 @@
1
+ import { Schema } from "@fncts/schema/Schema/definition";
2
+ import { Parser } from "@fncts/schema/Parser/definition";
3
+ import { Maybe } from "@fncts/base/data/Maybe/definition";
4
+ import { ParseResult } from "@fncts/schema/ParseResult";
5
+ import { AST } from "@fncts/schema/AST";
6
+ import type { ParseOptions } from "../AST.js";
7
+ /**
8
+ * @tsplus getter fncts.schema.Schema decode
9
+ * @tsplus getter fncts.schema.Parser decode
10
+ * @tsplus location "@fncts/schema/Parser/api"
11
+ */
12
+ export declare function decode<A>(schema: Schema<A>): Parser<A>;
13
+ /**
14
+ * @tsplus getter fncts.schema.Schema decodeMaybe
15
+ * @tsplus getter fncts.schema.Parser decodeMaybe
16
+ * @tsplus location "@fncts/schema/Parser/api"
17
+ */
18
+ export declare function decodeMaybe<A>(schema: Schema<A>): <A>(input: A, options?: ParseOptions) => Maybe<A>;
19
+ /**
20
+ * @tsplus getter fncts.schema.Schema encode
21
+ * @tsplus getter fncts.schema.Parser encode
22
+ * @tsplus location "@fncts/schema/Parser/api"
23
+ */
24
+ export declare function encode<A>(schema: Schema<A>): <A>(input: A, options?: ParseOptions) => ParseResult<unknown>;
25
+ /**
26
+ * @tsplus getter fncts.schema.Schema encodeMaybe
27
+ * @tsplus getter fncts.schema.Parser encodeMaybe
28
+ * @tsplus location "@fncts/schema/Parser/api"
29
+ */
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
+ /**
38
+ * @tsplus getter fncts.schema.Schema asserts
39
+ * @tsplus getter fncts.schema.Parser asserts
40
+ * @tsplus location "@fncts/schema/Parser/api"
41
+ */
42
+ export declare function asserts<A>(schema: Schema<A>): (input: unknown, options?: ParseOptions) => asserts input is A;
@@ -0,0 +1,22 @@
1
+ import { ParseResult } from "@fncts/schema/ParseResult";
2
+ import { AST } from "@fncts/schema/AST";
3
+ import { Refinement } from "@fncts/base/data/Refinement/definition";
4
+ import type { ParseOptions } from "../AST.js";
5
+ /**
6
+ * @tsplus type fncts.schema.Parser
7
+ * @tsplus companion fncts.schema.ParserOps
8
+ * @tsplus no-inherit fncts.schema.Schema fncts.schema.SchemaOps
9
+ */
10
+ export interface Parser<in out A> {
11
+ (input: unknown, options?: ParseOptions): ParseResult<A>;
12
+ }
13
+ /**
14
+ * @tsplus static fncts.schema.ParserOps make
15
+ * @tsplus location "@fncts/schema/Parser/definition"
16
+ */
17
+ export declare function make<A>(parse: Parser<A>): Parser<A>;
18
+ /**
19
+ * @tsplus static fncts.schema.ParserOps fromRefinement
20
+ * @tsplus location "@fncts/schema/Parser/definition"
21
+ */
22
+ export declare function fromRefinement<A>(ast: AST, refinement: Refinement<unknown, A>): Parser<A>;
@@ -0,0 +1,6 @@
1
+ import { AST } from "@fncts/schema/AST";
2
+ import { Parser } from "@fncts/schema/Parser/definition";
3
+ import { ParseError } from "@fncts/schema/ParseError";
4
+ import { ParseResult } from "@fncts/schema/ParseResult";
5
+ import { Vector } from "@fncts/base/collection/immutable/Vector";
6
+ export declare function parserFor(ast: AST): Parser<any>;
package/Parser.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from "./Parser/api.js";
2
+ export * from "./Parser/definition.js";
3
+ export * from "./Parser/interpreter.js";
@@ -0,0 +1,18 @@
1
+ import { Schema } from "@fncts/schema/Schema/definition";
2
+ import { Conc } from "@fncts/base/collection/immutable/Conc";
3
+ import { Check } from "@fncts/typelevel";
4
+ import { Parser } from "@fncts/schema/Parser/definition";
5
+ import { ParseError } from "@fncts/schema/ParseError";
6
+ import { Gen } from "@fncts/test/control/Gen";
7
+ export declare function conc<A>(value: Schema<A>): Schema<Conc<A>>;
8
+ /**
9
+ * @tsplus static fncts.schema.SchemaOps concFromArray
10
+ * @tsplus location "@fncts/schema/Schema/api/conc"
11
+ */
12
+ export declare function concFromArray<A>(value: Schema<A>): Schema<Conc<A>>;
13
+ /**
14
+ * @tsplus derive fncts.schema.Schema[fncts.Conc]<_> 10
15
+ * @tsplus location "@fncts/schema/Schema/api/conc"
16
+ */
17
+ export declare function deriveConc<A extends Conc<any>>(...[value]: [A] extends [Conc<infer _A>] ? Check<Check.IsEqual<A, Conc<_A>>> extends Check.True ? [value: Schema<_A>] : never : never): Schema<A>;
18
+ export declare function concParser<A>(value: Schema<A>): Parser<Conc<A>>;
@@ -0,0 +1,19 @@
1
+ import { Schema } from "@fncts/schema/Schema/definition";
2
+ import { Either } from "@fncts/base/data/Either/definition";
3
+ import { Check } from "@fncts/typelevel";
4
+ import { Parser } from "@fncts/schema/Parser/definition";
5
+ /**
6
+ * @tsplus static fncts.schema.SchemaOps either
7
+ * @tsplus location "@fncts/schema/Schema/api/either"
8
+ */
9
+ export declare function either<E, A>(left: Schema<E>, right: Schema<A>): Schema<Either<E, A>>;
10
+ /**
11
+ * @tsplus static fncts.schema.SchemaOps eitherFromJson
12
+ * @tsplus location "@fncts/schema/Schema/api/either"
13
+ */
14
+ export declare function eitherFromJson<E, A>(left: Schema<E>, right: Schema<A>): Schema<Either<E, A>>;
15
+ /**
16
+ * @tsplus derive fncts.schema.Schema[fncts.Either]<_> 10
17
+ * @tsplus location "@fncts/schema/Schema/api/either"
18
+ */
19
+ export declare function deriveEither<A extends Either<any, any>>(...[left, right]: [A] extends [Either<infer _E, infer _A>] ? Check<Check.IsEqual<A, Either<_E, _A>>> extends Check.True ? [left: Schema<_E>, right: Schema<_A>] : never : never): Schema<A>;
@@ -0,0 +1,21 @@
1
+ import { Schema } from "@fncts/schema/Schema/definition";
2
+ import { Parser } from "@fncts/schema/Parser/definition";
3
+ import { ParseError } from "@fncts/schema/ParseError";
4
+ import { Gen } from "@fncts/test/control/Gen";
5
+ import type { Check } from "@fncts/typelevel";
6
+ import { HashMap } from "@fncts/base/collection/immutable/HashMap";
7
+ /**
8
+ * @tsplus static fncts.schema.SchemaOps hashMap
9
+ * @tsplus location "@fncts/schema/Schema/api/hashMap"
10
+ */
11
+ export declare function hashMap<K, V>(key: Schema<K>, value: Schema<V>): Schema<HashMap<K, V>>;
12
+ /**
13
+ * @tsplus static fncts.schema.SchemaOps hashMapFromRecord
14
+ * @tsplus location "@fncts/schema/Schema/api/hashMap"
15
+ */
16
+ export declare function hashMapFromRecord<K extends string | symbol, V>(key: Schema<K>, value: Schema<V>): Schema<HashMap<K, V>>;
17
+ /**
18
+ * @tsplus derive fncts.schema.Schema[fncts.HashMap]<_> 10
19
+ * @tsplus location "@fncts/schema/Schema/api/hashMap"
20
+ */
21
+ export declare function deriveHashMap<A extends HashMap<any, any>>(...[key, value]: [A] extends [HashMap<infer K, infer V>] ? Check<Check.IsEqual<A, HashMap<K, V>> & Check.Extends<K, string | symbol>> extends Check.True ? [key: Schema<K>, value: Schema<V>] : never : never): Schema<A>;
@@ -0,0 +1,23 @@
1
+ import { Schema } from "@fncts/schema/Schema/definition";
2
+ import { Check } from "@fncts/typelevel";
3
+ import { Parser } from "@fncts/schema/Parser/definition";
4
+ import { ParseError } from "@fncts/schema/ParseError";
5
+ import { Gen } from "@fncts/test/control/Gen";
6
+ import { ImmutableArray } from "@fncts/base/collection/immutable/ImmutableArray";
7
+ /**
8
+ * @tsplus getter fncts.schema.Schema immutableArray
9
+ * @tsplus static fncts.schema.SchemaOps immutableArray
10
+ * @tsplus location "@fncts/schema/Schema/api/immutableArray"
11
+ */
12
+ export declare function immutableArray<A>(value: Schema<A>): Schema<ImmutableArray<A>>;
13
+ /**
14
+ * @tsplus getter fncts.schema.Schema immutableArrayFromArray
15
+ * @tsplus static fncts.schema.SchemaOps immutableArrayFromArray
16
+ * @tsplus location "@fncts/schema/Schema/api/immutableArray"
17
+ */
18
+ export declare function immutableArrayFromArray<A>(value: Schema<A>): Schema<ImmutableArray<A>>;
19
+ /**
20
+ * @tsplus derive fncts.schema.Schema[fncts.ImmutableArray]<_> 10
21
+ * @tsplus location "@fncts/schema/Schema/api/immutableArray"
22
+ */
23
+ export declare function deriveImmutableArray<A extends ImmutableArray<any>>(...[value]: [A] extends [ImmutableArray<infer _A>] ? Check<Check.IsEqual<A, ImmutableArray<_A>>> extends Check.True ? [value: Schema<_A>] : never : never): Schema<A>;
@@ -0,0 +1,23 @@
1
+ import { Schema } from "@fncts/schema/Schema/definition";
2
+ import { List, Nil, Cons } from "@fncts/base/collection/immutable/List/definition";
3
+ import { Check } from "@fncts/typelevel";
4
+ import { Parser } from "@fncts/schema/Parser/definition";
5
+ import { ParseError } from "@fncts/schema/ParseError";
6
+ import { Gen } from "@fncts/test/control/Gen";
7
+ /**
8
+ * @tsplus static fncts.schema.SchemaOps list
9
+ * @tsplus getter fncts.Schema.Schema list
10
+ * @tsplus location "@fncts/schema/Schema/api/list"
11
+ */
12
+ export declare function list<A>(value: Schema<A>): Schema<List<A>>;
13
+ /**
14
+ * @tsplus static fncts.schema.SchemaOps listFromArray
15
+ * @tsplus getter fncts.Schema.Schema listFromArray
16
+ * @tsplus location "@fncts/schema/Schema/api/list"
17
+ */
18
+ export declare function listFromArray<A>(value: Schema<A>): Schema<List<A>>;
19
+ /**
20
+ * @tsplus derive fncts.schema.Schema[fncts.List]<_> 10
21
+ * @tsplus location "@fncts/schema/Schema/api/list"
22
+ */
23
+ export declare function deriveList<A extends List<any>>(...[value]: [A] extends [List<infer _A>] ? Check<Check.IsEqual<A, List<_A>>> extends Check.True ? [value: Schema<_A>] : never : never): Schema<A>;
@@ -0,0 +1,21 @@
1
+ import { Schema } from "@fncts/schema/Schema/definition";
2
+ import { Maybe } from "@fncts/base/data/Maybe/definition";
3
+ import { Parser } from "@fncts/schema/Parser/definition";
4
+ import type { Check } from "@fncts/typelevel";
5
+ /**
6
+ * @tsplus static fncts.schema.SchemaOps maybe
7
+ * @tsplus getter fncts.schema.Schema maybe
8
+ * @tsplus location "@fncts/schema/Schema/api/maybe"
9
+ */
10
+ export declare function maybe<A>(value: Schema<A>): Schema<Maybe<A>>;
11
+ /**
12
+ * @tsplus static fncts.schema.SchemaOps maybeFromNullable
13
+ * @tsplus getter fncts.schema.Schema maybeFromNullable
14
+ * @tsplus location "@fncts/schema/Schema/api/maybe"
15
+ */
16
+ export declare function maybeFromNullable<A>(value: Schema<A>): Schema<Maybe<A>>;
17
+ /**
18
+ * @tsplus derive fncts.schema.Schema[fncts.Maybe]<_> 10
19
+ * @tsplus location "@fncts/schema/Schema/api/maybe"
20
+ */
21
+ export declare function deriveMaybe<A extends Maybe<any>>(...[value]: [A] extends [Maybe<infer _A>] ? Check<Check.IsEqual<A, Maybe<_A>>> extends Check.True ? [value: Schema<_A>] : never : never): Schema<A>;
@@ -0,0 +1,243 @@
1
+ import { AST, LiteralValue } from "@fncts/schema/AST";
2
+ import { Schema, OptionalSchema } from "@fncts/schema/Schema/definition";
3
+ import { ASTAnnotation } from "@fncts/schema/ASTAnnotation";
4
+ import { Vector } from "@fncts/base/collection/immutable/Vector";
5
+ import { Parser } from "@fncts/schema/Parser/definition";
6
+ import { ASTAnnotationMap } from "@fncts/schema/ASTAnnotationMap";
7
+ import { Refinement } from "@fncts/base/data/Refinement/definition";
8
+ import { Predicate } from "@fncts/base/data/Predicate/definition";
9
+ import { Maybe } from "@fncts/base/data/Maybe/definition";
10
+ import { ParseResult } from "@fncts/schema/ParseResult";
11
+ import type { ParseOptions } from "../AST.js";
12
+ import type { Brand, Validation } from "@fncts/base/data/Branded";
13
+ /**
14
+ * @tsplus static fncts.schema.SchemaOps fromAST
15
+ * @tsplus location "@fncts/schema/Schema/api"
16
+ */
17
+ export declare function make<A>(ast: AST): Schema<A>;
18
+ /**
19
+ * @tsplus pipeable fncts.schema.Schema annotate
20
+ * @tsplus location "@fncts/schema/Schema/api"
21
+ */
22
+ export declare function annotate<V>(annotation: ASTAnnotation<V>, value: V): <A>(self: import("./definition.js").Schema<A>) => import("./definition.js").Schema<A>;
23
+ /**
24
+ * @tsplus static fncts.schema.SchemaOps declaration
25
+ * @tsplus location "@fncts/schema/Schema/api"
26
+ */
27
+ export declare function declaration(typeParameters: Vector<Schema<any>>, type: Schema<any>, decode: (...typeParameters: ReadonlyArray<Schema<any>>) => Parser<any>, annotations?: ASTAnnotationMap): Schema<any>;
28
+ /**
29
+ * @tsplus pipeable fncts.schema.Schema filter
30
+ * @tsplus location "@fncts/schema/Schema/api"
31
+ */
32
+ export declare function filter<A, B extends A>(refinement: Refinement<A, B>): (self: Schema<A>) => Schema<B>;
33
+ export declare function filter<A>(predicate: Predicate<A>): (self: Schema<A>) => Schema<A>;
34
+ /**
35
+ * @tsplus pipeable fncts.schema.Schema brand
36
+ * @tsplus location "@fncts/schema/Schema/api"
37
+ */
38
+ export declare function brand<A, K extends string>(validation: Validation<A, K>): (self: Schema<A>) => Schema<A & Brand.Valid<A, K>>;
39
+ /**
40
+ * @tsplus static fncts.schema.SchemaOps literal
41
+ * @tsplus location "@fncts/schema/Schema/api"
42
+ */
43
+ export declare function literal<Literals extends ReadonlyArray<LiteralValue>>(...literals: Literals): Schema<Literals[number]>;
44
+ /**
45
+ * @tsplus static fncts.schema.SchemaOps never
46
+ * @tsplus implicit
47
+ * @tsplus location "@fncts/schema/Schema/api"
48
+ */
49
+ export declare const never: Schema<never>;
50
+ /**
51
+ * @tsplus static fncts.schema.SchemaOps unknown
52
+ * @tsplus implicit
53
+ * @tsplus location "@fncts/schema/Schema/api"
54
+ */
55
+ export declare const unknown: Schema<unknown>;
56
+ /**
57
+ * @tsplus static fncts.schema.SchemaOps any
58
+ * @tsplus location "@fncts/schema/Schema/api"
59
+ */
60
+ export declare const any: Schema<any>;
61
+ /**
62
+ * @tsplus static fncts.schema.SchemaOps undefined
63
+ * @tsplus implicit
64
+ * @tsplus location "@fncts/schema/Schema/api"
65
+ */
66
+ export declare const _undefined: Schema<undefined>;
67
+ export { _undefined as undefined };
68
+ /**
69
+ * @tsplus static fncts.schema.SchemaOps null
70
+ * @tsplus implicit
71
+ * @tsplus location "@fncts/schema/Schema/api"
72
+ */
73
+ export declare const _null: Schema<null>;
74
+ export { _null as null };
75
+ /**
76
+ * @tsplus static fncts.schema.SchemaOps void
77
+ * @tsplus implicit
78
+ * @tsplus location "@fncts/schema/Schema/api"
79
+ */
80
+ export declare const _void: Schema<void>;
81
+ export { _void as void };
82
+ /**
83
+ * @tsplus static fncts.schema.SchemaOps string
84
+ * @tsplus implicit
85
+ * @tsplus location "@fncts/schema/Schema/api"
86
+ */
87
+ export declare const string: Schema<string>;
88
+ /**
89
+ * @tsplus static fncts.schema.SchemaOps number
90
+ * @tsplus implicit
91
+ * @tsplus location "@fncts/schema/Schema/api"
92
+ */
93
+ export declare const number: Schema<number>;
94
+ /**
95
+ * @tsplus static fncts.schema.SchemaOps boolean
96
+ * @tsplus implicit
97
+ * @tsplus location "@fncts/schema/Schema/api"
98
+ */
99
+ export declare const boolean: Schema<boolean>;
100
+ /**
101
+ * @tsplus static fncts.schema.SchemaOps bigint
102
+ * @tsplus implicit
103
+ * @tsplus location "@fncts/schema/Schema/api"
104
+ */
105
+ export declare const bigint: Schema<bigint>;
106
+ /**
107
+ * @tsplus static fncts.schema.SchemaOps symbol
108
+ * @tsplus implicit
109
+ * @tsplus location "@fncts/schema/Schema/api"
110
+ */
111
+ export declare const symbol: Schema<symbol>;
112
+ /**
113
+ * @tsplus static fncts.schema.SchemaOps object
114
+ * @tsplus implicit
115
+ * @tsplus location "@fncts/schema/Schema/api"
116
+ */
117
+ export declare const object: Schema<object>;
118
+ /**
119
+ * @tsplus static fncts.schema.SchemaOps union
120
+ * @tsplus derive fncts.schema.Schema<|> 30
121
+ * @tsplus location "@fncts/schema/Schema/api"
122
+ */
123
+ export declare function union<A extends ReadonlyArray<unknown>>(...members: {
124
+ [K in keyof A]: Schema<A[K]>;
125
+ }): Schema<A[number]>;
126
+ /**
127
+ * @tsplus getter fncts.schema.Schema nullable
128
+ * @tsplus location "@fncts/schema/Schema/api"
129
+ */
130
+ export declare function nullable<A>(self: Schema<A>): Schema<A | null>;
131
+ /**
132
+ * @tsplus static fncts.schema.SchemaOps uniqueSymbol
133
+ * @tsplus location "@fncts/schema/Schema/api"
134
+ */
135
+ export declare function uniqueSymbol<S extends symbol>(symbol: S, annotations?: ASTAnnotationMap): Schema<S>;
136
+ /**
137
+ * @tsplus getter fncts.schema.Schema optional
138
+ * @tsplus location "@fncts/schema/Schema/api"
139
+ */
140
+ export declare function optional<A>(self: Schema<A>): OptionalSchema<A>;
141
+ /**
142
+ * @tsplus fluent fncts.schema.Schema isOptional
143
+ * @tsplus location "@fncts/schema/Schema/api"
144
+ */
145
+ export declare function isOptional<A>(self: Schema<A>): self is OptionalSchema<A>;
146
+ export type OptionalSchemaKeys<T> = {
147
+ [K in keyof T]: T[K] extends OptionalSchema<any> ? K : never;
148
+ }[keyof T];
149
+ /**
150
+ * @tsplus getter fncts.schema.Schema parseOptional
151
+ * @tsplus location "@fncts/schema/Schema/api"
152
+ */
153
+ export declare function parseOptional<A>(self: Schema<A>): Schema<Maybe<A>>;
154
+ /**
155
+ * @tsplus fluent fncts.schema.Schema isParseOptional
156
+ * @tsplus location "@fncts/schema/Schema/api"
157
+ */
158
+ export declare function isParseOptional<A>(self: Schema<A>): boolean;
159
+ export type Spread<A> = {
160
+ [K in keyof A]: A[K];
161
+ } extends infer B ? B : never;
162
+ /**
163
+ * @tsplus static fncts.schema.SchemaOps struct
164
+ * @tsplus location "@fncts/schema/Schema/api"
165
+ */
166
+ export declare function struct<Fields extends Record<PropertyKey, Schema<any>>>(fields: Fields): Schema<Spread<{
167
+ readonly [K in Exclude<keyof Fields, OptionalSchemaKeys<Fields>>]: Schema.Infer<Fields[K]>;
168
+ } & {
169
+ readonly [K in OptionalSchemaKeys<Fields>]?: Schema.Infer<Fields[K]>;
170
+ }>>;
171
+ /**
172
+ * @tsplus static fncts.schema.SchemaOps tuple
173
+ * @tsplus location "@fncts/schema/Schema/api"
174
+ */
175
+ export declare function tuple<Elements extends ReadonlyArray<Schema<any>>>(...elements: Elements): Schema<{
176
+ readonly [K in keyof Elements]: Schema.Infer<Elements[K]>;
177
+ }>;
178
+ /**
179
+ * @tsplus static fncts.schema.SchemaOps lazy
180
+ * @tsplus location "@fncts/schema/Schema/api"
181
+ */
182
+ export declare function lazy<A>(f: () => Schema<A>, annotations?: ASTAnnotationMap): Schema<A>;
183
+ /**
184
+ * @tsplus static fncts.schema.SchemaOps array
185
+ * @tsplus getter fncts.schema.Schema array
186
+ * @tsplus location "@fncts/schema/Schema/api"
187
+ */
188
+ export declare function array<A>(item: Schema<A>): Schema<ReadonlyArray<A>>;
189
+ /**
190
+ * @tsplus static fncts.schema.SchemaOps mutableArray
191
+ * @tsplus getter fncts.schema.Schema mutableArray
192
+ * @tsplus location "@fncts/schema/Schema/api"
193
+ */
194
+ export declare function mutableArray<A>(item: Schema<A>): Schema<Array<A>>;
195
+ /**
196
+ * @tsplus static fncts.schema.SchemaOps record
197
+ * @tsplus location "@fncts/schema/Schema/api"
198
+ */
199
+ export declare function record<K extends string | symbol, V>(key: Schema<K>, value: Schema<V>): Schema<{
200
+ readonly [k in K]: V;
201
+ }>;
202
+ /**
203
+ * @tsplus static fncts.schema.SchemaOps enum
204
+ * @tsplus location "@fncts/schema/Schema/api"
205
+ */
206
+ export declare function enum_<A extends {
207
+ [x: string]: string | number;
208
+ }>(enums: A): Schema<A[keyof A]>;
209
+ export { enum_ as enum };
210
+ type Join<T> = T extends [infer Head, ...infer Tail] ? `${Head & (string | number | bigint | boolean | null | undefined)}${Tail extends [] ? "" : Join<Tail>}` : never;
211
+ /**
212
+ * @tsplus static fncts.schema.SchemaOps templateLiteral
213
+ * @tsplus location "@fncts/schema/Schema/api"
214
+ */
215
+ export declare function templateLiteral<T extends [Schema<any>, ...Array<Schema<any>>]>(...[head, ...tail]: T): Schema<Join<{
216
+ [K in keyof T]: Schema.Infer<T[K]>;
217
+ }>>;
218
+ /**
219
+ * @tsplus static fncts.schema.SchemaOps keyof
220
+ * @tsplus getter fncts.schema.Schema keyof
221
+ * @tsplus location "@fncts/schema/Schema/api"
222
+ */
223
+ export declare function keyof<A>(self: Schema<A>): Schema<keyof A>;
224
+ /**
225
+ * @tsplus pipeable fncts.schema.Schema extend
226
+ * @tsplus location "@fncts/schema/Schema/api"
227
+ */
228
+ export declare function extend<B>(that: Schema<B>): <A>(self: import("./definition.js").Schema<A>) => import("./definition.js").Schema<Spread<A & B>>;
229
+ /**
230
+ * @tsplus pipeable fncts.schema.Schema instanceOf
231
+ * @tsplus location "@fncts/schema/Schema/api"
232
+ */
233
+ export declare function instanceOf<A extends abstract new (...args: any) => any>(constructor: A): (self: Schema<object>) => Schema<InstanceType<A>>;
234
+ /**
235
+ * @tsplus pipeable fncts.schema.Schema transformOrFail
236
+ * @tsplus location "@fncts/schema/Schema/api"
237
+ */
238
+ export declare function transformOrFail<A, B>(to: Schema<B>, decode: (input: A, options?: ParseOptions) => ParseResult<B>, encode: (input: B, options?: ParseOptions) => ParseResult<A>): (from: Schema<A>) => Schema<B>;
239
+ /**
240
+ * @tsplus pipeable fncts.schema.Schema transform
241
+ * @tsplus location "@fncts/schema/Schema/api"
242
+ */
243
+ export declare function transform<A, B>(to: Schema<B>, decode: (input: A, options?: ParseOptions) => B, encode: (input: B, options?: ParseOptions) => A): (from: Schema<A>) => Schema<B>;
@@ -0,0 +1,29 @@
1
+ import { HKT } from "@fncts/typelevel/HKT";
2
+ import { AST } from "@fncts/schema/AST";
3
+ export declare const SchemaVariance: unique symbol;
4
+ export type SchemaVariance = typeof SchemaVariance;
5
+ export declare const SchemaTypeId: unique symbol;
6
+ export type SchemaTypeId = typeof SchemaTypeId;
7
+ export declare const OptionalSchemaSymbol: unique symbol;
8
+ export type OptionalSchemaSymbol = typeof OptionalSchemaSymbol;
9
+ export interface SchemaF extends HKT {
10
+ readonly type: Schema<this["A"]>;
11
+ }
12
+ /**
13
+ * @tsplus type fncts.schema.Schema
14
+ * @tsplus companion fncts.schema.SchemaOps
15
+ */
16
+ export declare class Schema<in out A> {
17
+ readonly ast: AST;
18
+ readonly [SchemaTypeId]: SchemaTypeId;
19
+ [SchemaVariance]: {
20
+ _A: (_: A) => A;
21
+ };
22
+ constructor(ast: AST);
23
+ }
24
+ export interface OptionalSchema<in out A> extends Schema<A> {
25
+ [OptionalSchemaSymbol]: OptionalSchemaSymbol;
26
+ }
27
+ export declare namespace Schema {
28
+ type Infer<S extends Schema<any>> = Parameters<S[SchemaVariance]["_A"]>[0];
29
+ }