@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,368 @@
1
+ const fileName_1 = "(@fncts/schema) src/Schema/api.ts";
2
+ import * as tsplus_module_1 from "@fncts/schema/Schema/definition";
3
+ import * as tsplus_module_2 from "@fncts/base/collection/immutable/Vector/api";
4
+ import * as tsplus_module_3 from "@fncts/schema/AST";
5
+ import * as tsplus_module_4 from "@fncts/schema/ParseResult";
6
+ import * as tsplus_module_5 from "@fncts/schema/ParseError";
7
+ import * as tsplus_module_6 from "@fncts/schema/ASTAnnotation";
8
+ import * as tsplus_module_7 from "@fncts/base/data/Maybe/api";
9
+ import * as tsplus_module_8 from "@fncts/schema/Schema/api/maybe";
10
+ import * as tsplus_module_9 from "@fncts/base/data/Maybe/constructors";
11
+ import * as tsplus_module_10 from "@fncts/base/data/Maybe/definition";
12
+ export const make = make_1;
13
+ export const annotate = annotate_1;
14
+ export const filter = filter_1;
15
+ export const union = union_1;
16
+ export const isOptional = isOptional_1;
17
+ export const isParseOptional = isParseOptional_1;
18
+ export const enum_ = enum_1;
19
+ export const transformOrFail = transformOrFail_1;
20
+ export const transform = transform_1;
21
+ import { show } from "@fncts/base/data/Showable";
22
+ import { getParameter } from "../AST.mjs";
23
+ import { concrete, TemplateLiteralSpan } from "../AST.mjs";
24
+ import { ownKeys } from "../utils.mjs";
25
+ /**
26
+ * @tsplus static fncts.schema.SchemaOps fromAST
27
+ */
28
+ function make_1(ast) {
29
+ return new tsplus_module_1.Schema(ast);
30
+ }
31
+ /**
32
+ * @tsplus pipeable fncts.schema.Schema annotate
33
+ */
34
+ function annotate_1(annotation, value) {
35
+ return self => {
36
+ return make_1(self.ast.clone({
37
+ annotations: self.ast.annotations.annotate(annotation, value)
38
+ }));
39
+ };
40
+ }
41
+ /**
42
+ * @tsplus static fncts.schema.SchemaOps declaration
43
+ */
44
+ export function declaration(typeParameters, type, decode, annotations) {
45
+ return make_1(tsplus_module_3.createDeclaration(tsplus_module_2.map(tp => tp.ast)(typeParameters), type.ast, (...typeParameters) => decode(...typeParameters.map(make_1)), annotations));
46
+ }
47
+ function filter_1(predicate) {
48
+ return self => {
49
+ const ast = tsplus_module_3.createRefinement(self.ast, a => predicate(a) ? tsplus_module_4.succeed(a) : tsplus_module_4.fail(tsplus_module_5.typeError(ast, a)), false);
50
+ return make_1(ast);
51
+ };
52
+ }
53
+ /**
54
+ * @tsplus pipeable fncts.schema.Schema brand
55
+ */
56
+ export function brand(validation) {
57
+ return self => {
58
+ const ast = tsplus_module_3.createRefinement(self.ast, a => validation.validate(a) ? tsplus_module_4.succeed(a) : tsplus_module_4.fail(tsplus_module_5.typeError(ast, a)), false, self.ast.annotations.annotate(tsplus_module_6.Brand, tsplus_module_2.vector(validation)));
59
+ return make_1(ast);
60
+ };
61
+ }
62
+ function makeLiteral(value) {
63
+ return make_1(tsplus_module_3.createLiteral(value));
64
+ }
65
+ /**
66
+ * @tsplus static fncts.schema.SchemaOps literal
67
+ */
68
+ export function literal(...literals) {
69
+ return union_1(...literals.map(makeLiteral));
70
+ }
71
+ /**
72
+ * @tsplus static fncts.schema.SchemaOps never
73
+ * @tsplus implicit
74
+ */
75
+ export const never = /*#__PURE__*/make_1(tsplus_module_3.neverKeyword);
76
+ /**
77
+ * @tsplus static fncts.schema.SchemaOps unknown
78
+ * @tsplus implicit
79
+ */
80
+ export const unknown = /*#__PURE__*/make_1(tsplus_module_3.unknownKeyword);
81
+ /**
82
+ * @tsplus static fncts.schema.SchemaOps any
83
+ */
84
+ export const any = /*#__PURE__*/make_1(tsplus_module_3.anyKeyword);
85
+ /**
86
+ * @tsplus static fncts.schema.SchemaOps undefined
87
+ * @tsplus implicit
88
+ */
89
+ const _undefined_1 = /*#__PURE__*/make_1(tsplus_module_3.undefinedKeyword);
90
+ export const _undefined = _undefined_1;
91
+ export { _undefined_1 as undefined };
92
+ /**
93
+ * @tsplus static fncts.schema.SchemaOps null
94
+ * @tsplus implicit
95
+ */
96
+ const _null_1 = /*#__PURE__*/make_1( /*#__PURE__*/tsplus_module_3.createLiteral(null));
97
+ export const _null = _null_1;
98
+ export { _null_1 as null };
99
+ /**
100
+ * @tsplus static fncts.schema.SchemaOps void
101
+ * @tsplus implicit
102
+ */
103
+ const _void_1 = /*#__PURE__*/make_1(tsplus_module_3.voidKeyword);
104
+ export const _void = _void_1;
105
+ export { _void_1 as void };
106
+ /**
107
+ * @tsplus static fncts.schema.SchemaOps string
108
+ * @tsplus implicit
109
+ */
110
+ export const string = /*#__PURE__*/make_1(tsplus_module_3.stringKeyword);
111
+ /**
112
+ * @tsplus static fncts.schema.SchemaOps number
113
+ * @tsplus implicit
114
+ */
115
+ export const number = /*#__PURE__*/make_1(tsplus_module_3.numberKeyword);
116
+ /**
117
+ * @tsplus static fncts.schema.SchemaOps boolean
118
+ * @tsplus implicit
119
+ */
120
+ export const boolean = /*#__PURE__*/make_1(tsplus_module_3.booleanKeyword);
121
+ /**
122
+ * @tsplus static fncts.schema.SchemaOps bigint
123
+ * @tsplus implicit
124
+ */
125
+ export const bigint = /*#__PURE__*/make_1(tsplus_module_3.bigIntKeyword);
126
+ /**
127
+ * @tsplus static fncts.schema.SchemaOps symbol
128
+ * @tsplus implicit
129
+ */
130
+ export const symbol = /*#__PURE__*/make_1(tsplus_module_3.symbolKeyword);
131
+ /**
132
+ * @tsplus static fncts.schema.SchemaOps object
133
+ * @tsplus implicit
134
+ */
135
+ export const object = /*#__PURE__*/make_1(tsplus_module_3.objectKeyword);
136
+ /**
137
+ * @tsplus static fncts.schema.SchemaOps union
138
+ * @tsplus derive fncts.schema.Schema<|> 30
139
+ */
140
+ function union_1(...members) {
141
+ return make_1(tsplus_module_3.createUnion(tsplus_module_2.from(members.map(m => m.ast))));
142
+ }
143
+ /**
144
+ * @tsplus getter fncts.schema.Schema nullable
145
+ */
146
+ export function nullable(self) {
147
+ return union_1(_null_1, self);
148
+ }
149
+ /**
150
+ * @tsplus static fncts.schema.SchemaOps uniqueSymbol
151
+ */
152
+ export function uniqueSymbol(symbol, annotations) {
153
+ return make_1(tsplus_module_3.createUniqueSymbol(symbol, annotations));
154
+ }
155
+ /**
156
+ * @tsplus getter fncts.schema.Schema optional
157
+ */
158
+ export function optional(self) {
159
+ return make_1(self.ast.clone({
160
+ annotations: self.ast.annotations.annotate(tsplus_module_6.Optional, true)
161
+ }));
162
+ }
163
+ /**
164
+ * @tsplus fluent fncts.schema.Schema isOptional
165
+ */
166
+ function isOptional_1(self) {
167
+ return tsplus_module_7.getOrElse(() => false)(self.ast.annotations.get(tsplus_module_6.Optional));
168
+ }
169
+ /**
170
+ * @tsplus getter fncts.schema.Schema parseOptional
171
+ */
172
+ export function parseOptional(self) {
173
+ return make_1(self.ast.clone({
174
+ annotations: self.ast.annotations.annotate(tsplus_module_6.ParseOptional, true)
175
+ }));
176
+ }
177
+ /**
178
+ * @tsplus fluent fncts.schema.Schema isParseOptional
179
+ */
180
+ function isParseOptional_1(self) {
181
+ return tsplus_module_7.getOrElse(() => false)(self.ast.annotations.get(tsplus_module_6.ParseOptional));
182
+ }
183
+ /**
184
+ * @tsplus static fncts.schema.SchemaOps struct
185
+ */
186
+ export function struct(fields) {
187
+ const parseOptionalKeys = tsplus_module_2.filter(key => isParseOptional_1(fields[key]))(ownKeys(fields));
188
+ const struct = make_1(tsplus_module_3.createTypeLiteral(tsplus_module_2.map(key => tsplus_module_3.createPropertySignature(key, fields[key].ast, isOptional_1(fields[key]), true))(ownKeys(fields)), tsplus_module_2.empty()));
189
+ if (tsplus_module_2.isEmpty(parseOptionalKeys)) {
190
+ return struct;
191
+ }
192
+ const propertySignatures = struct.ast.propertySignatures;
193
+ const from = make_1(tsplus_module_3.createTypeLiteral(tsplus_module_2.map(p => tsplus_module_2.includes(p.name)(parseOptionalKeys) ? tsplus_module_3.createPropertySignature(p.name, tsplus_module_3.createUnion(tsplus_module_2.vector(tsplus_module_3.undefinedKeyword, tsplus_module_3.createLiteral(null), p.type)), true, p.isReadonly) : p)(propertySignatures), tsplus_module_2.empty()));
194
+ const to = make_1(tsplus_module_3.createTypeLiteral(tsplus_module_2.map(p => {
195
+ if (tsplus_module_2.includes(p.name)(parseOptionalKeys)) {
196
+ if (tsplus_module_3.isLazy(fields[p.name].ast)) {
197
+ return tsplus_module_3.createPropertySignature(p.name, tsplus_module_3.createLazy(() => tsplus_module_8.maybe(fields[p.name]).ast), true, p.isReadonly);
198
+ }
199
+ return tsplus_module_3.createPropertySignature(p.name, tsplus_module_8.maybe(fields[p.name]).ast, true, p.isReadonly);
200
+ }
201
+ return p;
202
+ })(propertySignatures), tsplus_module_2.empty()));
203
+ return transform_1(to, input => {
204
+ const output = {
205
+ ...input
206
+ };
207
+ for (const key of parseOptionalKeys) {
208
+ output[key] = tsplus_module_9.fromNullable(input[key]);
209
+ }
210
+ return output;
211
+ }, input => {
212
+ const output = {
213
+ ...input
214
+ };
215
+ for (const key of parseOptionalKeys) {
216
+ const value = input[key];
217
+ if (tsplus_module_10.isNothing(value)) {
218
+ delete output[key];
219
+ continue;
220
+ }
221
+ output[key] = tsplus_module_7.toUndefined(value);
222
+ }
223
+ return output;
224
+ })(from);
225
+ }
226
+ /**
227
+ * @tsplus static fncts.schema.SchemaOps tuple
228
+ */
229
+ export function tuple(...elements) {
230
+ return make_1(tsplus_module_3.createTuple(tsplus_module_2.from(elements.map(schema => tsplus_module_3.createElement(schema.ast, false))), tsplus_module_9.nothing(fileName_1 + ":320:105"), true));
231
+ }
232
+ /**
233
+ * @tsplus static fncts.schema.SchemaOps lazy
234
+ */
235
+ export function lazy(f, annotations) {
236
+ return make_1(tsplus_module_3.createLazy(() => f().ast, annotations));
237
+ }
238
+ /**
239
+ * @tsplus static fncts.schema.SchemaOps array
240
+ * @tsplus getter fncts.schema.Schema array
241
+ */
242
+ export function array(item) {
243
+ return make_1(tsplus_module_3.createTuple(tsplus_module_2.empty(), tsplus_module_9.just(tsplus_module_2.vector(item.ast), fileName_1 + ":336:61"), true));
244
+ }
245
+ /**
246
+ * @tsplus static fncts.schema.SchemaOps mutableArray
247
+ * @tsplus getter fncts.schema.Schema mutableArray
248
+ */
249
+ export function mutableArray(item) {
250
+ return make_1(tsplus_module_3.createTuple(tsplus_module_2.empty(), tsplus_module_9.just(tsplus_module_2.vector(item.ast), fileName_1 + ":344:61"), false));
251
+ }
252
+ /**
253
+ * @tsplus static fncts.schema.SchemaOps record
254
+ */
255
+ export function record(key, value) {
256
+ return make_1(tsplus_module_3.createRecord(key.ast, value.ast, true));
257
+ }
258
+ /**
259
+ * @tsplus static fncts.schema.SchemaOps enum
260
+ */
261
+ function enum_1(enums) {
262
+ return make_1(tsplus_module_3.createEnum(tsplus_module_2.from(Object.keys(enums).filter(key => typeof enums[enums[key]] !== "number").map(key => [key, enums[key]]))));
263
+ }
264
+ export { enum_1 as enum };
265
+ function getTemplateLiterals(ast) {
266
+ void 0;
267
+ switch (ast._tag) {
268
+ case 1 /* ASTTag.Literal */:
269
+ return tsplus_module_2.vector(ast);
270
+ case 9 /* ASTTag.NumberKeyword */:
271
+ case 8 /* ASTTag.StringKeyword */:
272
+ return tsplus_module_2.vector(tsplus_module_3.createTemplateLiteral("", tsplus_module_2.vector(new TemplateLiteralSpan(ast, ""))));
273
+ case 18 /* ASTTag.Union */:
274
+ return tsplus_module_2.flatMap(getTemplateLiterals)(ast.types);
275
+ default:
276
+ throw new Error(`Unsupported template literal span ${show(ast)}`);
277
+ }
278
+ }
279
+ function combineTemplateLiterals(a, b) {
280
+ if (tsplus_module_3.isLiteral(a)) {
281
+ return tsplus_module_3.isLiteral(b) ? tsplus_module_3.createLiteral(String(a.literal) + String(b.literal)) : tsplus_module_3.createTemplateLiteral(String(a.literal) + b.head, b.spans);
282
+ }
283
+ if (tsplus_module_3.isLiteral(b)) {
284
+ if (!tsplus_module_2.isNonEmpty(a.spans)) {
285
+ throw new Error("Invalid template literal");
286
+ }
287
+ const last = tsplus_module_2.unsafeLast(a.spans);
288
+ return tsplus_module_3.createTemplateLiteral(a.head, tsplus_module_2.append(new TemplateLiteralSpan(last.type, last.literal + String(b.literal)))(tsplus_module_2.slice(0, -1)(a.spans)));
289
+ }
290
+ if (!tsplus_module_2.isNonEmpty(a.spans)) {
291
+ throw new Error("Invalid template literal");
292
+ }
293
+ const last = tsplus_module_2.unsafeLast(a.spans);
294
+ return tsplus_module_3.createTemplateLiteral(a.head, tsplus_module_2.concat(b.spans)(tsplus_module_2.append(new TemplateLiteralSpan(last.type, last.literal + String(b.head)))(tsplus_module_2.slice(0, -1)(a.spans))));
295
+ }
296
+ /**
297
+ * @tsplus static fncts.schema.SchemaOps templateLiteral
298
+ */
299
+ export function templateLiteral(...[head, ...tail]) {
300
+ let types = getTemplateLiterals(head.ast);
301
+ for (const span of tail) {
302
+ types = tsplus_module_2.flatMap(a => tsplus_module_2.map(b => combineTemplateLiterals(a, b))(getTemplateLiterals(span.ast)))(types);
303
+ }
304
+ return make_1(tsplus_module_3.createUnion(types));
305
+ }
306
+ /**
307
+ * @tsplus static fncts.schema.SchemaOps keyof
308
+ * @tsplus getter fncts.schema.Schema keyof
309
+ */
310
+ export function keyof(self) {
311
+ return make_1(tsplus_module_3.keyof(self.ast));
312
+ }
313
+ function isOverlappingPropertySignatures(x, y) {
314
+ return tsplus_module_2.some(px => tsplus_module_2.some(py => px.name === py.name)(y.propertySignatures))(x.propertySignatures);
315
+ }
316
+ function isOverlappingIndexSignatures(x, y) {
317
+ return tsplus_module_2.some(ix => tsplus_module_2.some(iy => {
318
+ const bx = getParameter(ix.parameter);
319
+ const by = getParameter(iy.parameter);
320
+ return tsplus_module_3.isStringKeyword(bx) && tsplus_module_3.isStringKeyword(by) || tsplus_module_3.isSymbolKeyword(bx) && tsplus_module_3.isSymbolKeyword(by);
321
+ })(y.indexSignatures))(x.indexSignatures);
322
+ }
323
+ /**
324
+ * @tsplus pipeable fncts.schema.Schema extend
325
+ */
326
+ export function extend(that) {
327
+ return self => {
328
+ const selfTypes = tsplus_module_3.isUnion(self.ast) ? self.ast.types : tsplus_module_2.vector(self.ast);
329
+ const thatTypes = tsplus_module_3.isUnion(that.ast) ? that.ast.types : tsplus_module_2.vector(that.ast);
330
+ if (tsplus_module_2.every(tsplus_module_3.isTypeLiteral)(selfTypes) && tsplus_module_2.every(tsplus_module_3.isTypeLiteral)(thatTypes)) {
331
+ return make_1(tsplus_module_3.createUnion(tsplus_module_2.flatMap(x => tsplus_module_2.map(y => {
332
+ if (isOverlappingPropertySignatures(x, y)) {
333
+ throw new Error("`extend` cannot handle overlapping property signatures");
334
+ }
335
+ if (isOverlappingIndexSignatures(x, y)) {
336
+ throw new Error("`extend` cannot handle overlapping index signatures");
337
+ }
338
+ return tsplus_module_3.createTypeLiteral(tsplus_module_2.concat(y.propertySignatures)(x.propertySignatures), tsplus_module_2.concat(y.indexSignatures)(x.indexSignatures));
339
+ })(thatTypes))(selfTypes)));
340
+ }
341
+ throw new Error("`extend can only handle type literals or unions of type literals`");
342
+ };
343
+ }
344
+ /**
345
+ * @tsplus pipeable fncts.schema.Schema instanceOf
346
+ */
347
+ export function instanceOf(constructor) {
348
+ return self => {
349
+ return annotate_1(tsplus_module_6.Description, `an instance of ${constructor.name}`)(filter_1(value => value instanceof constructor)(self));
350
+ };
351
+ }
352
+ /**
353
+ * @tsplus pipeable fncts.schema.Schema transformOrFail
354
+ */
355
+ function transformOrFail_1(to, decode, encode) {
356
+ return from => {
357
+ return make_1(tsplus_module_3.createTransform(from.ast, to.ast, decode, encode, false));
358
+ };
359
+ }
360
+ /**
361
+ * @tsplus pipeable fncts.schema.Schema transform
362
+ */
363
+ function transform_1(to, decode, encode) {
364
+ return from => {
365
+ return transformOrFail_1(to, (input, options) => tsplus_module_4.succeed(decode(input, options)), (input, options) => tsplus_module_4.succeed(encode(input, options)))(from);
366
+ };
367
+ }
368
+ //# sourceMappingURL=api.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.mjs","mappings":";;;;;;;;;;;aAcgBA,IAAI;aAOJC,QAAQ;aA8BRC,MAAM;aAsHNC,KAAK;aAkCLC,UAAU;aAkBVC,eAAe;aA0IfC,KAAK;aAiJLC,eAAe;aAafC,SAAS;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,WAAW,CAACtD,IAAI,EAAE,EAFpEwD,SACInH,KAAK,IAA+BA,KAAK,YAAYiH,WAAW,EADpEhH,IAAI,CACiE,CACA;EAC9E,CAAC;AACH;AAEA;;;AAGA,2BACE4D,EAAa,EACbrD,MAA4D,EAC5D4G,MAA4D;EAE5D,OAAQ3D,IAAe,IAAe;IACpC,OAAOvD,OAAeO,gCAAoBgD,IAAI,CAAC5D,GAAG,EAAEgE,EAAE,CAAChE,GAAG,EAAEW,MAAM,EAAE4G,MAAM,EAAE,KAAK,CAAC,CAAC;EACrF,CAAC;AACH;AAEA;;;AAGA,qBACEvD,EAAa,EACbrD,MAA+C,EAC/C4G,MAA+C;EAE/C,OAAQ3D,IAAe,IAAe;IACpC,OAAO4D,kBACLxD,EAAE,EACF,CAACG,KAAK,EAAEsD,OAAO,KAAKvG,wBAAoBP,MAAM,CAACwD,KAAK,EAAEsD,OAAO,CAAC,CAAC,EAC/D,CAACtD,KAAK,EAAEsD,OAAO,KAAKvG,wBAAoBqG,MAAM,CAACpD,KAAK,EAAEsD,OAAO,CAAC,CAAC,EAH1D7D,IAAI,CAIV;EACH,CAAC;AACH","names":["make","annotate","filter","union","isOptional","isParseOptional","enum_","transformOrFail","transform","show","getParameter","concrete","TemplateLiteralSpan","ownKeys","ast","Schema","annotation","value","self","make_1","clone","annotations","declaration","typeParameters","type","decode","tsplus_module_3","tsplus_module_2","tp","map","predicate","a","tsplus_module_4","tsplus_module_5","brand","validation","validate","makeLiteral","literal","literals","union_1","never","unknown","any","_undefined_1","_undefined","undefined","_null_1","_null","null","_void_1","_void","void","string","number","boolean","bigint","symbol","object","members","m","nullable","uniqueSymbol","optional","tsplus_module_7","get","parseOptional","struct","fields","parseOptionalKeys","key","isParseOptional_1","isOptional_1","propertySignatures","from","p","name","isReadonly","to","tsplus_module_8","transform_1","input","output","tsplus_module_9","tsplus_module_10","tuple","elements","schema","lazy","f","array","item","mutableArray","record","enums","Object","keys","enum_1","enum","getTemplateLiterals","_tag","types","Error","combineTemplateLiterals","b","String","head","spans","last","templateLiteral","tail","span","keyof","isOverlappingPropertySignatures","x","y","px","py","isOverlappingIndexSignatures","ix","iy","bx","parameter","by","indexSignatures","extend","that","selfTypes","thatTypes","instanceOf","constructor","annotate_1","filter_1","encode","transformOrFail_1","options"],"sourceRoot":"","sources":["../../_src/Schema/api.ts"],"sourcesContent":[null]}
@@ -0,0 +1,16 @@
1
+ var _a;
2
+ export const SchemaVariance = /*#__PURE__*/Symbol.for("fncts.schema.Schema.Variance");
3
+ export const SchemaTypeId = /*#__PURE__*/Symbol.for("fncts.schema.Schema");
4
+ export const OptionalSchemaSymbol = /*#__PURE__*/Symbol.for("fncts.schema.Schema.OptionalSchema");
5
+ /**
6
+ * @tsplus type fncts.schema.Schema
7
+ * @tsplus companion fncts.schema.SchemaOps
8
+ */
9
+ export class Schema {
10
+ constructor(ast) {
11
+ this.ast = ast;
12
+ this[_a] = SchemaTypeId;
13
+ }
14
+ }
15
+ _a = SchemaTypeId;
16
+ //# sourceMappingURL=definition.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definition.mjs","mappings":";AAAA,OAAO,MAAMA,cAAc,gBAAGC,MAAM,CAACC,GAAG,CAAC,8BAA8B,CAAC;AAGxE,OAAO,MAAMC,YAAY,gBAAGF,MAAM,CAACC,GAAG,CAAC,qBAAqB,CAAC;AAG7D,OAAO,MAAME,oBAAoB,gBAAGH,MAAM,CAACC,GAAG,CAAC,oCAAoC,CAAC;AAOpF;;;;AAIA,OAAM,MAAOG,MAAM;EAKjBC,YAAqBC,GAAQ;IAAR,QAAG,GAAHA,GAAG;IAJf,QAAc,GAAiBJ,YAAY;EAIpB;;KAJtBA,YAAY","names":["SchemaVariance","Symbol","for","SchemaTypeId","OptionalSchemaSymbol","Schema","constructor","ast"],"sourceRoot":"","sources":["../../_src/Schema/definition.ts"],"sourcesContent":[null]}
@@ -0,0 +1,94 @@
1
+ import * as tsplus_module_1 from "@fncts/base/collection/immutable/Vector/api";
2
+ import * as tsplus_module_2 from "@fncts/schema/ASTAnnotation";
3
+ import * as tsplus_module_3 from "@fncts/schema/AST";
4
+ import * as tsplus_module_4 from "@fncts/schema/Schema/api";
5
+ import * as tsplus_module_5 from "@fncts/schema/Schema/api/maybe";
6
+ import * as tsplus_module_6 from "@fncts/base/data/Maybe/constructors";
7
+ import * as tsplus_module_7 from "@fncts/base/data/Maybe/definition";
8
+ import * as tsplus_module_8 from "@fncts/base/data/Maybe/api";
9
+ import * as tsplus_module_9 from "@fncts/base/data/function/api";
10
+ import { ownKeys } from "@fncts/schema/utils";
11
+ /**
12
+ * @tsplus derive fncts.schema.Schema<_> 10
13
+ */
14
+ export function deriveValidation(...[base, brands]) {
15
+ return tsplus_module_4.make(tsplus_module_3.createValidation(base.ast, tsplus_module_1.from(Object.values(brands)), base.ast.annotations.annotate(tsplus_module_2.Brand, tsplus_module_1.from(Object.values(brands)))));
16
+ }
17
+ /**
18
+ * @tsplus derive fncts.schema.Schema<_> 20
19
+ */
20
+ export function deriveLiteral(...[value]) {
21
+ return tsplus_module_4.literal(value);
22
+ }
23
+ /**
24
+ * @tsplus derive fncts.schema.Schema<_> 20
25
+ */
26
+ export function deriveStruct(...[requiredFields, optionalFields, maybeFields]) {
27
+ const maybeFieldsKeys = ownKeys(maybeFields);
28
+ let propertySignatures = tsplus_module_1.map(key => tsplus_module_3.createPropertySignature(key, requiredFields[key].ast, false, true))(ownKeys(requiredFields));
29
+ if (optionalFields) {
30
+ propertySignatures = tsplus_module_1.concat(tsplus_module_1.map(key => tsplus_module_3.createPropertySignature(key, optionalFields[key].ast, true, true))(ownKeys(optionalFields)))(propertySignatures);
31
+ }
32
+ const struct = tsplus_module_4.make(tsplus_module_3.createTypeLiteral(propertySignatures, tsplus_module_1.empty()));
33
+ if (tsplus_module_1.isEmpty(maybeFieldsKeys)) {
34
+ return struct;
35
+ }
36
+ propertySignatures = struct.ast.propertySignatures;
37
+ const from = tsplus_module_4.make(tsplus_module_3.createTypeLiteral(tsplus_module_1.concat(tsplus_module_1.map(key => tsplus_module_3.createPropertySignature(key, tsplus_module_3.createUnion(tsplus_module_1.vector(tsplus_module_3.undefinedKeyword, tsplus_module_3.createLiteral(null), maybeFields[key].ast)), true, true))(maybeFieldsKeys))(propertySignatures), tsplus_module_1.empty()));
38
+ const to = tsplus_module_4.make(tsplus_module_3.createTypeLiteral(tsplus_module_1.concat(tsplus_module_1.map(key => tsplus_module_3.createPropertySignature(key, tsplus_module_5.maybe(maybeFields[key]).ast, true, true))(maybeFieldsKeys))(propertySignatures), tsplus_module_1.empty()));
39
+ return tsplus_module_4.transform(to, input => {
40
+ const output = {
41
+ ...input
42
+ };
43
+ for (const key of maybeFieldsKeys) {
44
+ output[key] = tsplus_module_6.fromNullable(input[key]);
45
+ }
46
+ return output;
47
+ }, input => {
48
+ const output = {
49
+ ...input
50
+ };
51
+ for (const key of maybeFieldsKeys) {
52
+ const value = input[key];
53
+ if (tsplus_module_7.isNothing(value)) {
54
+ delete output[key];
55
+ continue;
56
+ }
57
+ output[key] = tsplus_module_8.toUndefined(value);
58
+ }
59
+ return output;
60
+ })(from);
61
+ }
62
+ /**
63
+ * @tsplus derive fncts.schema.Schema<_> 10
64
+ */
65
+ export function deriveTuple(...[components]) {
66
+ return tsplus_module_4.tuple(...components);
67
+ }
68
+ /**
69
+ * @tsplus derive fncts.schema.Schema lazy
70
+ */
71
+ export function deriveLazy(f) {
72
+ let cached;
73
+ const ast = tsplus_module_3.createLazy(() => {
74
+ if (!cached) {
75
+ cached = f(tsplus_module_4.make(ast)).ast;
76
+ }
77
+ return cached;
78
+ });
79
+ return tsplus_module_4.make(ast);
80
+ }
81
+ /**
82
+ * @tsplus derive fncts.schema.Schema[fncts.Array]<_> 10
83
+ * @tsplus derive fncts.schema.Schema[fncts.ReadonlyArray]<_> 10
84
+ */
85
+ export function deriveArray(...[element]) {
86
+ return tsplus_module_4.array(element);
87
+ }
88
+ /**
89
+ * @tsplus derive fncts.schema.Schema<_> 15
90
+ */
91
+ export function deriveRecord(...[keySchema, valueSchema]) {
92
+ return tsplus_module_4.record(keySchema, valueSchema);
93
+ }
94
+ //# sourceMappingURL=derivations.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"derivations.mjs","mappings":";;;;;;;;;AAGA,SAASA,OAAO,QAAQ,qBAAqB;AAE7C;;;AAGA,OAAM,SAAUC,gBAAgB,CAC9B,GAAG,CAACC,IAAI,EAAEC,MAAM,CAOP;EAET,OAAOC,qBACLC,iCACEH,IAAI,CAACI,GAAG,EACRC,qBAAYC,MAAM,CAACC,MAAM,CAACN,MAAM,CAAC,CAAC,EAClCD,IAAI,CAACI,GAAG,CAACI,WAAW,CAACC,QAAQ,wBAAsBJ,qBAAYC,MAAM,CAACC,MAAM,CAACN,MAAM,CAAC,CAAC,CAAC,CACvF,CACF;AACH;AAEA;;;AAGA,OAAM,SAAUS,aAAa,CAC3B,GAAG,CAACC,KAAK,CAAkG;EAE3G,OAAOT,wBAAeS,KAAK,CAAC;AAC9B;AAIA;;;AAGA,OAAM,SAAUC,YAAY,CAC1B,GAAG,CAACC,cAAc,EAAEC,cAAc,EAAEC,WAAW,CAsBtC;EAET,MAAMC,eAAe,GAAwBlB,OAAO,CAACiB,WAAW,CAAC;EACjE,IAAIE,kBAAkB,GAAuBZ,oBAA6Ba,GAAG,IAC3Ef,wCAA4Be,GAAG,EAAEL,cAAc,CAACK,GAAG,CAAE,CAACd,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,EAD5BN,OAAO,CAACe,cAAc,CAAC,CAEnE;EAED,IAAIC,cAAc,EAAE;IAClBG,kBAAkB,GAAGZ,uBACnBA,oBAA6Ba,GAAG,IAAKf,wCAA4Be,GAAG,EAAEJ,cAAc,CAACI,GAAG,CAAE,CAACd,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,EAA3GN,OAAO,CAACgB,cAAc,CAAC,CAAqF,EADzFG,kBAAkB,CAEtC;;EAGH,MAAME,MAAM,GAAGjB,qBAAeC,kCAA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,MAAM;EACf,CAAC,EApBIJ,IAAI,CAqBV;AACH;AAEA;;;AAGA,OAAM,SAAUO,WAAW,CACzB,GAAG,CAACC,UAAU,CAAsG;EAEpH,OAAoB1B,sBAAa,GAAG0B,UAAU,CAAC;AACjD;AAEA;;;AAGA,OAAM,SAAUC,UAAU,CAAIC,CAA8B;EAC1D,IAAIC,MAAuB;EAC3B,MAAM3B,GAAG,GAAGD,2BAAe,MAAK;IAC9B,IAAI,CAAC4B,MAAM,EAAE;MACXA,MAAM,GAAGD,CAAC,CAAC5B,qBAAeE,GAAG,CAAC,CAAC,CAACA,GAAG;;IAErC,OAAO2B,MAAM;EACf,CAAC,CAAC;EACF,OAAO7B,qBAAeE,GAAG,CAAC;AAC5B;AAEA;;;;AAIA,OAAM,SAAU4B,WAAW,CACzB,GAAG,CAACC,OAAO,CAIF;EAET,OAAO/B,sBAAa+B,OAAO,CAAyB;AACtD;AAEA;;;AAGA,OAAM,SAAUC,YAAY,CAC1B,GAAG,CAACC,SAAS,EAAEC,WAAW,CAIjB;EAET,OAAOlC,uBAAciC,SAAoC,EAAEC,WAAW,CAAc;AACtF","names":["ownKeys","deriveValidation","base","brands","tsplus_module_4","tsplus_module_3","ast","tsplus_module_1","Object","values","annotations","annotate","deriveLiteral","value","deriveStruct","requiredFields","optionalFields","maybeFields","maybeFieldsKeys","propertySignatures","key","struct","from","to","tsplus_module_5","input","output","tsplus_module_6","tsplus_module_7","deriveTuple","components","deriveLazy","f","cached","deriveArray","element","deriveRecord","keySchema","valueSchema"],"sourceRoot":"","sources":["../../_src/Schema/derivations.ts"],"sourcesContent":[null]}