@fncts/schema 0.0.4 → 0.0.6

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 (151) 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 +2 -0
  12. package/Schema/api/conc.d.ts +18 -0
  13. package/Schema/api/hashMap.d.ts +21 -0
  14. package/Schema/api/immutableArray.d.ts +23 -0
  15. package/Schema/api/list.d.ts +23 -0
  16. package/Schema/api/maybe.d.ts +21 -0
  17. package/Schema/api.d.ts +243 -0
  18. package/Schema/definition.d.ts +29 -0
  19. package/Schema/derivations.d.ts +70 -0
  20. package/Schema.d.ts +2 -144
  21. package/_cjs/AST.cjs +1171 -0
  22. package/_cjs/AST.cjs.map +1 -0
  23. package/_cjs/ASTAnnotation.cjs +111 -0
  24. package/_cjs/ASTAnnotation.cjs.map +1 -0
  25. package/_cjs/ASTAnnotationMap.cjs +35 -0
  26. package/_cjs/ASTAnnotationMap.cjs.map +1 -0
  27. package/_cjs/Gen.cjs +185 -0
  28. package/_cjs/Gen.cjs.map +1 -0
  29. package/_cjs/InvalidInterpretationError.cjs +18 -0
  30. package/_cjs/InvalidInterpretationError.cjs.map +1 -0
  31. package/_cjs/ParseError.cjs +222 -0
  32. package/_cjs/ParseError.cjs.map +1 -0
  33. package/_cjs/{Decoder.cjs → ParseResult.cjs} +24 -22
  34. package/_cjs/ParseResult.cjs.map +1 -0
  35. package/_cjs/Parser/api.cjs +80 -0
  36. package/_cjs/Parser/api.cjs.map +1 -0
  37. package/_cjs/{Guard.cjs → Parser/definition.cjs} +17 -22
  38. package/_cjs/Parser/definition.cjs.map +1 -0
  39. package/_cjs/Parser/interpreter.cjs +409 -0
  40. package/_cjs/Parser/interpreter.cjs.map +1 -0
  41. package/_cjs/Parser.cjs +28 -0
  42. package/_cjs/Parser.cjs.map +1 -0
  43. package/_cjs/Schema/api/conc.cjs +84 -0
  44. package/_cjs/Schema/api/conc.cjs.map +1 -0
  45. package/_cjs/Schema/api/hashMap.cjs +161 -0
  46. package/_cjs/Schema/api/hashMap.cjs.map +1 -0
  47. package/_cjs/Schema/api/immutableArray.cjs +90 -0
  48. package/_cjs/Schema/api/immutableArray.cjs.map +1 -0
  49. package/_cjs/Schema/api/list.cjs +98 -0
  50. package/_cjs/Schema/api/list.cjs.map +1 -0
  51. package/_cjs/Schema/api/maybe.cjs +75 -0
  52. package/_cjs/Schema/api/maybe.cjs.map +1 -0
  53. package/_cjs/Schema/api.cjs +424 -0
  54. package/_cjs/Schema/api.cjs.map +1 -0
  55. package/_cjs/Schema/definition.cjs +26 -0
  56. package/_cjs/Schema/definition.cjs.map +1 -0
  57. package/_cjs/Schema/derivations.cjs +108 -0
  58. package/_cjs/Schema/derivations.cjs.map +1 -0
  59. package/_cjs/Schema.cjs +20 -237
  60. package/_cjs/Schema.cjs.map +1 -1
  61. package/_cjs/utils.cjs +52 -0
  62. package/_cjs/utils.cjs.map +1 -0
  63. package/_mjs/AST.mjs +1060 -0
  64. package/_mjs/AST.mjs.map +1 -0
  65. package/_mjs/ASTAnnotation.mjs +80 -0
  66. package/_mjs/ASTAnnotation.mjs.map +1 -0
  67. package/_mjs/ASTAnnotationMap.mjs +27 -0
  68. package/_mjs/ASTAnnotationMap.mjs.map +1 -0
  69. package/_mjs/Gen.mjs +176 -0
  70. package/_mjs/Gen.mjs.map +1 -0
  71. package/_mjs/InvalidInterpretationError.mjs +10 -0
  72. package/_mjs/InvalidInterpretationError.mjs.map +1 -0
  73. package/_mjs/ParseError.mjs +200 -0
  74. package/_mjs/ParseError.mjs.map +1 -0
  75. package/_mjs/ParseResult.mjs +21 -0
  76. package/_mjs/ParseResult.mjs.map +1 -0
  77. package/_mjs/Parser/api.mjs +67 -0
  78. package/_mjs/Parser/api.mjs.map +1 -0
  79. package/_mjs/Parser/definition.mjs +15 -0
  80. package/_mjs/Parser/definition.mjs.map +1 -0
  81. package/_mjs/Parser/interpreter.mjs +401 -0
  82. package/_mjs/Parser/interpreter.mjs.map +1 -0
  83. package/_mjs/Parser.mjs +4 -0
  84. package/_mjs/Parser.mjs.map +1 -0
  85. package/_mjs/Schema/api/conc.mjs +72 -0
  86. package/_mjs/Schema/api/conc.mjs.map +1 -0
  87. package/_mjs/Schema/api/hashMap.mjs +150 -0
  88. package/_mjs/Schema/api/hashMap.mjs.map +1 -0
  89. package/_mjs/Schema/api/immutableArray.mjs +79 -0
  90. package/_mjs/Schema/api/immutableArray.mjs.map +1 -0
  91. package/_mjs/Schema/api/list.mjs +87 -0
  92. package/_mjs/Schema/api/list.mjs.map +1 -0
  93. package/_mjs/Schema/api/maybe.mjs +64 -0
  94. package/_mjs/Schema/api/maybe.mjs.map +1 -0
  95. package/_mjs/Schema/api.mjs +367 -0
  96. package/_mjs/Schema/api.mjs.map +1 -0
  97. package/_mjs/Schema/definition.mjs +16 -0
  98. package/_mjs/Schema/definition.mjs.map +1 -0
  99. package/_mjs/Schema/derivations.mjs +94 -0
  100. package/_mjs/Schema/derivations.mjs.map +1 -0
  101. package/_mjs/Schema.mjs +3 -212
  102. package/_mjs/Schema.mjs.map +1 -1
  103. package/_mjs/utils.mjs +41 -0
  104. package/_mjs/utils.mjs.map +1 -0
  105. package/_src/AST.ts +1353 -0
  106. package/_src/ASTAnnotation.ts +98 -0
  107. package/_src/ASTAnnotationMap.ts +38 -0
  108. package/_src/Gen.ts +171 -0
  109. package/_src/InvalidInterpretationError.ts +6 -0
  110. package/_src/ParseError.ts +237 -0
  111. package/_src/ParseResult.ts +26 -0
  112. package/_src/Parser/api.ts +71 -0
  113. package/_src/Parser/definition.ts +24 -0
  114. package/_src/Parser/interpreter.ts +442 -0
  115. package/_src/Parser.ts +4 -0
  116. package/_src/Schema/api/conc.ts +78 -0
  117. package/_src/Schema/api/hashMap.ts +184 -0
  118. package/_src/Schema/api/immutableArray.ts +88 -0
  119. package/_src/Schema/api/list.ts +96 -0
  120. package/_src/Schema/api/maybe.ts +68 -0
  121. package/_src/Schema/api.ts +530 -0
  122. package/_src/Schema/definition.ts +32 -0
  123. package/_src/Schema/derivations.ts +185 -0
  124. package/_src/Schema.ts +4 -254
  125. package/_src/global.ts +53 -0
  126. package/_src/utils.ts +48 -0
  127. package/global.d.ts +52 -0
  128. package/package.json +2 -2
  129. package/utils.d.ts +8 -0
  130. package/Decoder.d.ts +0 -3
  131. package/Encoder.d.ts +0 -4
  132. package/Guard.d.ts +0 -3
  133. package/Schemable.d.ts +0 -39
  134. package/_cjs/Decoder.cjs.map +0 -1
  135. package/_cjs/Encoder.cjs +0 -45
  136. package/_cjs/Encoder.cjs.map +0 -1
  137. package/_cjs/Guard.cjs.map +0 -1
  138. package/_cjs/Schemable.cjs +0 -6
  139. package/_cjs/Schemable.cjs.map +0 -1
  140. package/_mjs/Decoder.mjs +0 -20
  141. package/_mjs/Decoder.mjs.map +0 -1
  142. package/_mjs/Encoder.mjs +0 -36
  143. package/_mjs/Encoder.mjs.map +0 -1
  144. package/_mjs/Guard.mjs +0 -20
  145. package/_mjs/Guard.mjs.map +0 -1
  146. package/_mjs/Schemable.mjs +0 -2
  147. package/_mjs/Schemable.mjs.map +0 -1
  148. package/_src/Decoder.ts +0 -20
  149. package/_src/Encoder.ts +0 -38
  150. package/_src/Guard.ts +0 -20
  151. package/_src/Schemable.ts +0 -46
@@ -0,0 +1,367 @@
1
+ import * as tsplus_module_1 from "@fncts/schema/Schema/definition";
2
+ import * as tsplus_module_2 from "@fncts/base/collection/immutable/Vector/api";
3
+ import * as tsplus_module_3 from "@fncts/schema/AST";
4
+ import * as tsplus_module_4 from "@fncts/schema/ParseResult";
5
+ import * as tsplus_module_5 from "@fncts/schema/ParseError";
6
+ import * as tsplus_module_6 from "@fncts/schema/ASTAnnotation";
7
+ import * as tsplus_module_7 from "@fncts/base/data/Maybe/api";
8
+ import * as tsplus_module_8 from "@fncts/schema/Schema/api/maybe";
9
+ import * as tsplus_module_9 from "@fncts/base/data/Maybe/constructors";
10
+ import * as tsplus_module_10 from "@fncts/base/data/Maybe/definition";
11
+ export const make = make_1;
12
+ export const annotate = annotate_1;
13
+ export const filter = filter_1;
14
+ export const union = union_1;
15
+ export const isOptional = isOptional_1;
16
+ export const isParseOptional = isParseOptional_1;
17
+ export const enum_ = enum_1;
18
+ export const transformOrFail = transformOrFail_1;
19
+ export const transform = transform_1;
20
+ import { show } from "@fncts/base/data/Showable";
21
+ import { getParameter } from "../AST.mjs";
22
+ import { concrete, TemplateLiteralSpan } from "../AST.mjs";
23
+ import { ownKeys } from "../utils.mjs";
24
+ /**
25
+ * @tsplus static fncts.schema.SchemaOps fromAST
26
+ */
27
+ function make_1(ast) {
28
+ return new tsplus_module_1.Schema(ast);
29
+ }
30
+ /**
31
+ * @tsplus pipeable fncts.schema.Schema annotate
32
+ */
33
+ function annotate_1(annotation, value) {
34
+ return self => {
35
+ return make_1(self.ast.clone({
36
+ annotations: self.ast.annotations.annotate(annotation, value)
37
+ }));
38
+ };
39
+ }
40
+ /**
41
+ * @tsplus static fncts.schema.SchemaOps declaration
42
+ */
43
+ export function declaration(typeParameters, type, decode, annotations) {
44
+ return make_1(tsplus_module_3.createDeclaration(tsplus_module_2.map(tp => tp.ast)(typeParameters), type.ast, (...typeParameters) => decode(...typeParameters.map(make_1)), annotations));
45
+ }
46
+ function filter_1(predicate) {
47
+ return self => {
48
+ 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);
49
+ return make_1(ast);
50
+ };
51
+ }
52
+ /**
53
+ * @tsplus pipeable fncts.schema.Schema brand
54
+ */
55
+ export function brand(validation) {
56
+ return self => {
57
+ 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)));
58
+ return make_1(ast);
59
+ };
60
+ }
61
+ function makeLiteral(value) {
62
+ return make_1(tsplus_module_3.createLiteral(value));
63
+ }
64
+ /**
65
+ * @tsplus static fncts.schema.SchemaOps literal
66
+ */
67
+ export function literal(...literals) {
68
+ return union_1(...literals.map(makeLiteral));
69
+ }
70
+ /**
71
+ * @tsplus static fncts.schema.SchemaOps never
72
+ * @tsplus implicit
73
+ */
74
+ export const never = /*#__PURE__*/make_1(tsplus_module_3.neverKeyword);
75
+ /**
76
+ * @tsplus static fncts.schema.SchemaOps unknown
77
+ * @tsplus implicit
78
+ */
79
+ export const unknown = /*#__PURE__*/make_1(tsplus_module_3.unknownKeyword);
80
+ /**
81
+ * @tsplus static fncts.schema.SchemaOps any
82
+ */
83
+ export const any = /*#__PURE__*/make_1(tsplus_module_3.anyKeyword);
84
+ /**
85
+ * @tsplus static fncts.schema.SchemaOps undefined
86
+ * @tsplus implicit
87
+ */
88
+ const _undefined_1 = /*#__PURE__*/make_1(tsplus_module_3.undefinedKeyword);
89
+ export const _undefined = _undefined_1;
90
+ export { _undefined_1 as undefined };
91
+ /**
92
+ * @tsplus static fncts.schema.SchemaOps null
93
+ * @tsplus implicit
94
+ */
95
+ const _null_1 = /*#__PURE__*/make_1( /*#__PURE__*/tsplus_module_3.createLiteral(null));
96
+ export const _null = _null_1;
97
+ export { _null_1 as null };
98
+ /**
99
+ * @tsplus static fncts.schema.SchemaOps void
100
+ * @tsplus implicit
101
+ */
102
+ const _void_1 = /*#__PURE__*/make_1(tsplus_module_3.voidKeyword);
103
+ export const _void = _void_1;
104
+ export { _void_1 as void };
105
+ /**
106
+ * @tsplus static fncts.schema.SchemaOps string
107
+ * @tsplus implicit
108
+ */
109
+ export const string = /*#__PURE__*/make_1(tsplus_module_3.stringKeyword);
110
+ /**
111
+ * @tsplus static fncts.schema.SchemaOps number
112
+ * @tsplus implicit
113
+ */
114
+ export const number = /*#__PURE__*/make_1(tsplus_module_3.numberKeyword);
115
+ /**
116
+ * @tsplus static fncts.schema.SchemaOps boolean
117
+ * @tsplus implicit
118
+ */
119
+ export const boolean = /*#__PURE__*/make_1(tsplus_module_3.booleanKeyword);
120
+ /**
121
+ * @tsplus static fncts.schema.SchemaOps bigint
122
+ * @tsplus implicit
123
+ */
124
+ export const bigint = /*#__PURE__*/make_1(tsplus_module_3.bigIntKeyword);
125
+ /**
126
+ * @tsplus static fncts.schema.SchemaOps symbol
127
+ * @tsplus implicit
128
+ */
129
+ export const symbol = /*#__PURE__*/make_1(tsplus_module_3.symbolKeyword);
130
+ /**
131
+ * @tsplus static fncts.schema.SchemaOps object
132
+ * @tsplus implicit
133
+ */
134
+ export const object = /*#__PURE__*/make_1(tsplus_module_3.objectKeyword);
135
+ /**
136
+ * @tsplus static fncts.schema.SchemaOps union
137
+ * @tsplus derive fncts.schema.Schema<|> 30
138
+ */
139
+ function union_1(...members) {
140
+ return make_1(tsplus_module_3.createUnion(tsplus_module_2.from(members.map(m => m.ast))));
141
+ }
142
+ /**
143
+ * @tsplus getter fncts.schema.Schema nullable
144
+ */
145
+ export function nullable(self) {
146
+ return union_1(_null_1, self);
147
+ }
148
+ /**
149
+ * @tsplus static fncts.schema.SchemaOps uniqueSymbol
150
+ */
151
+ export function uniqueSymbol(symbol, annotations) {
152
+ return make_1(tsplus_module_3.createUniqueSymbol(symbol, annotations));
153
+ }
154
+ /**
155
+ * @tsplus getter fncts.schema.Schema optional
156
+ */
157
+ export function optional(self) {
158
+ return make_1(self.ast.clone({
159
+ annotations: self.ast.annotations.annotate(tsplus_module_6.Optional, true)
160
+ }));
161
+ }
162
+ /**
163
+ * @tsplus fluent fncts.schema.Schema isOptional
164
+ */
165
+ function isOptional_1(self) {
166
+ return tsplus_module_7.getOrElse(() => false)(self.ast.annotations.get(tsplus_module_6.Optional));
167
+ }
168
+ /**
169
+ * @tsplus getter fncts.schema.Schema parseOptional
170
+ */
171
+ export function parseOptional(self) {
172
+ return make_1(self.ast.clone({
173
+ annotations: self.ast.annotations.annotate(tsplus_module_6.ParseOptional, true)
174
+ }));
175
+ }
176
+ /**
177
+ * @tsplus fluent fncts.schema.Schema isParseOptional
178
+ */
179
+ function isParseOptional_1(self) {
180
+ return tsplus_module_7.getOrElse(() => false)(self.ast.annotations.get(tsplus_module_6.ParseOptional));
181
+ }
182
+ /**
183
+ * @tsplus static fncts.schema.SchemaOps struct
184
+ */
185
+ export function struct(fields) {
186
+ const parseOptionalKeys = tsplus_module_2.filter(key => isParseOptional_1(fields[key]))(ownKeys(fields));
187
+ 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()));
188
+ if (tsplus_module_2.isEmpty(parseOptionalKeys)) {
189
+ return struct;
190
+ }
191
+ const propertySignatures = struct.ast.propertySignatures;
192
+ 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()));
193
+ const to = make_1(tsplus_module_3.createTypeLiteral(tsplus_module_2.map(p => {
194
+ if (tsplus_module_2.includes(p.name)(parseOptionalKeys)) {
195
+ if (tsplus_module_3.isLazy(fields[p.name].ast)) {
196
+ return tsplus_module_3.createPropertySignature(p.name, tsplus_module_3.createLazy(() => tsplus_module_8.maybe(fields[p.name]).ast), true, p.isReadonly);
197
+ }
198
+ return tsplus_module_3.createPropertySignature(p.name, tsplus_module_8.maybe(fields[p.name]).ast, true, p.isReadonly);
199
+ }
200
+ return p;
201
+ })(propertySignatures), tsplus_module_2.empty()));
202
+ return transform_1(to, input => {
203
+ const output = {
204
+ ...input
205
+ };
206
+ for (const key of parseOptionalKeys) {
207
+ output[key] = tsplus_module_9.fromNullable(input[key]);
208
+ }
209
+ return output;
210
+ }, input => {
211
+ const output = {
212
+ ...input
213
+ };
214
+ for (const key of parseOptionalKeys) {
215
+ const value = input[key];
216
+ if (tsplus_module_10.isNothing(value)) {
217
+ delete output[key];
218
+ continue;
219
+ }
220
+ output[key] = tsplus_module_7.toUndefined(value);
221
+ }
222
+ return output;
223
+ })(from);
224
+ }
225
+ /**
226
+ * @tsplus static fncts.schema.SchemaOps tuple
227
+ */
228
+ export function tuple(...elements) {
229
+ 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(), true));
230
+ }
231
+ /**
232
+ * @tsplus static fncts.schema.SchemaOps lazy
233
+ */
234
+ export function lazy(f, annotations) {
235
+ return make_1(tsplus_module_3.createLazy(() => f().ast, annotations));
236
+ }
237
+ /**
238
+ * @tsplus static fncts.schema.SchemaOps array
239
+ * @tsplus getter fncts.schema.Schema array
240
+ */
241
+ export function array(item) {
242
+ return make_1(tsplus_module_3.createTuple(tsplus_module_2.empty(), tsplus_module_9.just(tsplus_module_2.vector(item.ast)), true));
243
+ }
244
+ /**
245
+ * @tsplus static fncts.schema.SchemaOps mutableArray
246
+ * @tsplus getter fncts.schema.Schema mutableArray
247
+ */
248
+ export function mutableArray(item) {
249
+ return make_1(tsplus_module_3.createTuple(tsplus_module_2.empty(), tsplus_module_9.just(tsplus_module_2.vector(item.ast)), false));
250
+ }
251
+ /**
252
+ * @tsplus static fncts.schema.SchemaOps record
253
+ */
254
+ export function record(key, value) {
255
+ return make_1(tsplus_module_3.createRecord(key.ast, value.ast, true));
256
+ }
257
+ /**
258
+ * @tsplus static fncts.schema.SchemaOps enum
259
+ */
260
+ function enum_1(enums) {
261
+ 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]]))));
262
+ }
263
+ export { enum_1 as enum };
264
+ function getTemplateLiterals(ast) {
265
+ void 0;
266
+ switch (ast._tag) {
267
+ case 1 /* ASTTag.Literal */:
268
+ return tsplus_module_2.vector(ast);
269
+ case 9 /* ASTTag.NumberKeyword */:
270
+ case 8 /* ASTTag.StringKeyword */:
271
+ return tsplus_module_2.vector(tsplus_module_3.createTemplateLiteral("", tsplus_module_2.vector(new TemplateLiteralSpan(ast, ""))));
272
+ case 18 /* ASTTag.Union */:
273
+ return tsplus_module_2.flatMap(getTemplateLiterals)(ast.types);
274
+ default:
275
+ throw new Error(`Unsupported template literal span ${show(ast)}`);
276
+ }
277
+ }
278
+ function combineTemplateLiterals(a, b) {
279
+ if (tsplus_module_3.isLiteral(a)) {
280
+ 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);
281
+ }
282
+ if (tsplus_module_3.isLiteral(b)) {
283
+ if (!tsplus_module_2.isNonEmpty(a.spans)) {
284
+ throw new Error("Invalid template literal");
285
+ }
286
+ const last = tsplus_module_2.unsafeLast(a.spans);
287
+ 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)));
288
+ }
289
+ if (!tsplus_module_2.isNonEmpty(a.spans)) {
290
+ throw new Error("Invalid template literal");
291
+ }
292
+ const last = tsplus_module_2.unsafeLast(a.spans);
293
+ 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))));
294
+ }
295
+ /**
296
+ * @tsplus static fncts.schema.SchemaOps templateLiteral
297
+ */
298
+ export function templateLiteral(...[head, ...tail]) {
299
+ let types = getTemplateLiterals(head.ast);
300
+ for (const span of tail) {
301
+ types = tsplus_module_2.flatMap(a => tsplus_module_2.map(b => combineTemplateLiterals(a, b))(getTemplateLiterals(span.ast)))(types);
302
+ }
303
+ return make_1(tsplus_module_3.createUnion(types));
304
+ }
305
+ /**
306
+ * @tsplus static fncts.schema.SchemaOps keyof
307
+ * @tsplus getter fncts.schema.Schema keyof
308
+ */
309
+ export function keyof(self) {
310
+ return make_1(tsplus_module_3.keyof(self.ast));
311
+ }
312
+ function isOverlappingPropertySignatures(x, y) {
313
+ return tsplus_module_2.some(px => tsplus_module_2.some(py => px.name === py.name)(y.propertySignatures))(x.propertySignatures);
314
+ }
315
+ function isOverlappingIndexSignatures(x, y) {
316
+ return tsplus_module_2.some(ix => tsplus_module_2.some(iy => {
317
+ const bx = getParameter(ix.parameter);
318
+ const by = getParameter(iy.parameter);
319
+ return tsplus_module_3.isStringKeyword(bx) && tsplus_module_3.isStringKeyword(by) || tsplus_module_3.isSymbolKeyword(bx) && tsplus_module_3.isSymbolKeyword(by);
320
+ })(y.indexSignatures))(x.indexSignatures);
321
+ }
322
+ /**
323
+ * @tsplus pipeable fncts.schema.Schema extend
324
+ */
325
+ export function extend(that) {
326
+ return self => {
327
+ const selfTypes = tsplus_module_3.isUnion(self.ast) ? self.ast.types : tsplus_module_2.vector(self.ast);
328
+ const thatTypes = tsplus_module_3.isUnion(that.ast) ? that.ast.types : tsplus_module_2.vector(that.ast);
329
+ if (tsplus_module_2.every(tsplus_module_3.isTypeLiteral)(selfTypes) && tsplus_module_2.every(tsplus_module_3.isTypeLiteral)(thatTypes)) {
330
+ return make_1(tsplus_module_3.createUnion(tsplus_module_2.flatMap(x => tsplus_module_2.map(y => {
331
+ if (isOverlappingPropertySignatures(x, y)) {
332
+ throw new Error("`extend` cannot handle overlapping property signatures");
333
+ }
334
+ if (isOverlappingIndexSignatures(x, y)) {
335
+ throw new Error("`extend` cannot handle overlapping index signatures");
336
+ }
337
+ return tsplus_module_3.createTypeLiteral(tsplus_module_2.concat(y.propertySignatures)(x.propertySignatures), tsplus_module_2.concat(y.indexSignatures)(x.indexSignatures));
338
+ })(thatTypes))(selfTypes)));
339
+ }
340
+ throw new Error("`extend can only handle type literals or unions of type literals`");
341
+ };
342
+ }
343
+ /**
344
+ * @tsplus pipeable fncts.schema.Schema instanceOf
345
+ */
346
+ export function instanceOf(constructor) {
347
+ return self => {
348
+ return annotate_1(tsplus_module_6.Description, `an instance of ${constructor.name}`)(filter_1(value => value instanceof constructor)(self));
349
+ };
350
+ }
351
+ /**
352
+ * @tsplus pipeable fncts.schema.Schema transformOrFail
353
+ */
354
+ function transformOrFail_1(to, decode, encode) {
355
+ return from => {
356
+ return make_1(tsplus_module_3.createTransform(from.ast, to.ast, decode, encode, false));
357
+ };
358
+ }
359
+ /**
360
+ * @tsplus pipeable fncts.schema.Schema transform
361
+ */
362
+ function transform_1(to, decode, encode) {
363
+ return from => {
364
+ return transformOrFail_1(to, (input, options) => tsplus_module_4.succeed(decode(input, options)), (input, options) => tsplus_module_4.succeed(encode(input, options)))(from);
365
+ };
366
+ }
367
+ //# 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;AAhgBzB,SAASC,IAAI,QAAQ,2BAA2B;AAEhD,SAASC,YAAY,QAAQ,YAAW;AACxC,SAAiBC,QAAQ,EAAEC,mBAAmB,QAAQ,YAAW;AACjE,SAASC,OAAO,QAAQ,cAAa;AAErC;;;AAGA,gBAAwBC,GAAQ;EAC9B,OAAO,oBAAIC,MAAM,CAACD,GAAG,CAAC;AACxB;AAEA;;;AAGA,oBAA4BE,UAA4B,EAAEC,KAAQ;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,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;EA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I,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]}