@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.
- package/AST.d.ts +528 -0
- package/ASTAnnotation.d.ts +82 -0
- package/ASTAnnotationMap.d.ts +14 -0
- package/Gen.d.ts +15 -0
- package/InvalidInterpretationError.d.ts +5 -0
- package/ParseError.d.ts +107 -0
- package/ParseResult.d.ts +24 -0
- package/Parser/api.d.ts +42 -0
- package/Parser/definition.d.ts +22 -0
- package/Parser/interpreter.d.ts +6 -0
- package/Parser.d.ts +3 -0
- package/Schema/api/conc.d.ts +18 -0
- package/Schema/api/either.d.ts +19 -0
- package/Schema/api/hashMap.d.ts +21 -0
- package/Schema/api/immutableArray.d.ts +23 -0
- package/Schema/api/list.d.ts +23 -0
- package/Schema/api/maybe.d.ts +21 -0
- package/Schema/api.d.ts +243 -0
- package/Schema/definition.d.ts +29 -0
- package/Schema/derivations.d.ts +70 -0
- package/Schema.d.ts +9 -144
- package/_cjs/AST.cjs +1172 -0
- package/_cjs/AST.cjs.map +1 -0
- package/_cjs/ASTAnnotation.cjs +111 -0
- package/_cjs/ASTAnnotation.cjs.map +1 -0
- package/_cjs/ASTAnnotationMap.cjs +35 -0
- package/_cjs/ASTAnnotationMap.cjs.map +1 -0
- package/_cjs/Gen.cjs +182 -0
- package/_cjs/Gen.cjs.map +1 -0
- package/_cjs/InvalidInterpretationError.cjs +18 -0
- package/_cjs/InvalidInterpretationError.cjs.map +1 -0
- package/_cjs/ParseError.cjs +223 -0
- package/_cjs/ParseError.cjs.map +1 -0
- package/_cjs/{Decoder.cjs → ParseResult.cjs} +25 -22
- package/_cjs/ParseResult.cjs.map +1 -0
- package/_cjs/Parser/api.cjs +80 -0
- package/_cjs/Parser/api.cjs.map +1 -0
- package/_cjs/{Guard.cjs → Parser/definition.cjs} +17 -22
- package/_cjs/Parser/definition.cjs.map +1 -0
- package/_cjs/Parser/interpreter.cjs +410 -0
- package/_cjs/Parser/interpreter.cjs.map +1 -0
- package/_cjs/Parser.cjs +39 -0
- package/_cjs/Parser.cjs.map +1 -0
- package/_cjs/Schema/api/conc.cjs +84 -0
- package/_cjs/Schema/api/conc.cjs.map +1 -0
- package/_cjs/Schema/api/either.cjs +96 -0
- package/_cjs/Schema/api/either.cjs.map +1 -0
- package/_cjs/Schema/api/hashMap.cjs +161 -0
- package/_cjs/Schema/api/hashMap.cjs.map +1 -0
- package/_cjs/Schema/api/immutableArray.cjs +90 -0
- package/_cjs/Schema/api/immutableArray.cjs.map +1 -0
- package/_cjs/Schema/api/list.cjs +98 -0
- package/_cjs/Schema/api/list.cjs.map +1 -0
- package/_cjs/Schema/api/maybe.cjs +76 -0
- package/_cjs/Schema/api/maybe.cjs.map +1 -0
- package/_cjs/Schema/api.cjs +425 -0
- package/_cjs/Schema/api.cjs.map +1 -0
- package/_cjs/Schema/definition.cjs +26 -0
- package/_cjs/Schema/definition.cjs.map +1 -0
- package/_cjs/Schema/derivations.cjs +108 -0
- package/_cjs/Schema/derivations.cjs.map +1 -0
- package/_cjs/Schema.cjs +97 -237
- package/_cjs/Schema.cjs.map +1 -1
- package/_cjs/utils.cjs +52 -0
- package/_cjs/utils.cjs.map +1 -0
- package/_mjs/AST.mjs +1061 -0
- package/_mjs/AST.mjs.map +1 -0
- package/_mjs/ASTAnnotation.mjs +80 -0
- package/_mjs/ASTAnnotation.mjs.map +1 -0
- package/_mjs/ASTAnnotationMap.mjs +27 -0
- package/_mjs/ASTAnnotationMap.mjs.map +1 -0
- package/_mjs/Gen.mjs +173 -0
- package/_mjs/Gen.mjs.map +1 -0
- package/_mjs/InvalidInterpretationError.mjs +10 -0
- package/_mjs/InvalidInterpretationError.mjs.map +1 -0
- package/_mjs/ParseError.mjs +201 -0
- package/_mjs/ParseError.mjs.map +1 -0
- package/_mjs/ParseResult.mjs +22 -0
- package/_mjs/ParseResult.mjs.map +1 -0
- package/_mjs/Parser/api.mjs +67 -0
- package/_mjs/Parser/api.mjs.map +1 -0
- package/_mjs/Parser/definition.mjs +15 -0
- package/_mjs/Parser/definition.mjs.map +1 -0
- package/_mjs/Parser/interpreter.mjs +402 -0
- package/_mjs/Parser/interpreter.mjs.map +1 -0
- package/_mjs/Parser.mjs +5 -0
- package/_mjs/Parser.mjs.map +1 -0
- package/_mjs/Schema/api/conc.mjs +72 -0
- package/_mjs/Schema/api/conc.mjs.map +1 -0
- package/_mjs/Schema/api/either.mjs +85 -0
- package/_mjs/Schema/api/either.mjs.map +1 -0
- package/_mjs/Schema/api/hashMap.mjs +150 -0
- package/_mjs/Schema/api/hashMap.mjs.map +1 -0
- package/_mjs/Schema/api/immutableArray.mjs +79 -0
- package/_mjs/Schema/api/immutableArray.mjs.map +1 -0
- package/_mjs/Schema/api/list.mjs +87 -0
- package/_mjs/Schema/api/list.mjs.map +1 -0
- package/_mjs/Schema/api/maybe.mjs +65 -0
- package/_mjs/Schema/api/maybe.mjs.map +1 -0
- package/_mjs/Schema/api.mjs +368 -0
- package/_mjs/Schema/api.mjs.map +1 -0
- package/_mjs/Schema/definition.mjs +16 -0
- package/_mjs/Schema/definition.mjs.map +1 -0
- package/_mjs/Schema/derivations.mjs +94 -0
- package/_mjs/Schema/derivations.mjs.map +1 -0
- package/_mjs/Schema.mjs +12 -212
- package/_mjs/Schema.mjs.map +1 -1
- package/_mjs/utils.mjs +41 -0
- package/_mjs/utils.mjs.map +1 -0
- package/_src/AST.ts +1353 -0
- package/_src/ASTAnnotation.ts +98 -0
- package/_src/ASTAnnotationMap.ts +38 -0
- package/_src/Gen.ts +168 -0
- package/_src/InvalidInterpretationError.ts +6 -0
- package/_src/ParseError.ts +237 -0
- package/_src/ParseResult.ts +26 -0
- package/_src/Parser/api.ts +71 -0
- package/_src/Parser/definition.ts +24 -0
- package/_src/Parser/interpreter.ts +442 -0
- package/_src/Parser.ts +5 -0
- package/_src/Schema/api/conc.ts +78 -0
- package/_src/Schema/api/either.ts +96 -0
- package/_src/Schema/api/hashMap.ts +184 -0
- package/_src/Schema/api/immutableArray.ts +88 -0
- package/_src/Schema/api/list.ts +96 -0
- package/_src/Schema/api/maybe.ts +68 -0
- package/_src/Schema/api.ts +530 -0
- package/_src/Schema/definition.ts +32 -0
- package/_src/Schema/derivations.ts +185 -0
- package/_src/Schema.ts +14 -254
- package/_src/global.ts +53 -0
- package/_src/utils.ts +48 -0
- package/global.d.ts +52 -0
- package/package.json +2 -2
- package/utils.d.ts +8 -0
- package/Decoder.d.ts +0 -3
- package/Encoder.d.ts +0 -4
- package/Guard.d.ts +0 -3
- package/Schemable.d.ts +0 -39
- package/_cjs/Decoder.cjs.map +0 -1
- package/_cjs/Encoder.cjs +0 -45
- package/_cjs/Encoder.cjs.map +0 -1
- package/_cjs/Guard.cjs.map +0 -1
- package/_cjs/Schemable.cjs +0 -6
- package/_cjs/Schemable.cjs.map +0 -1
- package/_mjs/Decoder.mjs +0 -20
- package/_mjs/Decoder.mjs.map +0 -1
- package/_mjs/Encoder.mjs +0 -36
- package/_mjs/Encoder.mjs.map +0 -1
- package/_mjs/Guard.mjs +0 -20
- package/_mjs/Guard.mjs.map +0 -1
- package/_mjs/Schemable.mjs +0 -2
- package/_mjs/Schemable.mjs.map +0 -1
- package/_src/Decoder.ts +0 -20
- package/_src/Encoder.ts +0 -38
- package/_src/Guard.ts +0 -20
- package/_src/Schemable.ts +0 -46
package/_cjs/Decoder.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Decoder.cjs","mappings":";;;;;;;;;;AAGO,MAAMA,SAAS,GAAgB;EACpCC,OAAO,yBAAiB;EACxBC,MAAM,wBAAU;EAChBC,MAAM,wBAAU;EAChBC,OAAO,yBAAU;EACjBC,MAAM,wBAAU;EAChBC,OAAO,yBAAiB;EACxBC,QAAQ,0BAAkB;EAC1BC,MAAM,wBAAgB;EACtBC,OAAO,yBAAiB;EACxBC,KAAK,+BAAuB;EAC5BC,MAAM,wBAAgB;EACtBC,KAAK,uBAA6B;EAClCC,IAAI,4BAAc;EAClBC,UAAU,4BAAkC;EAC5CC,KAAK,EAAGC,OAAO,IAAKC,sBAAc,GAAGD,OAAO;CAC7C;AAAC","names":["Schemable","unknown","string","number","boolean","bigint","literal","nullable","struct","partial","array","record","tuple","lazy","validation","union","members","tsplus_module_1"],"sourceRoot":"","sources":["../_src/Decoder.ts"],"sourcesContent":[null]}
|
package/_cjs/Encoder.cjs
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Schemable = void 0;
|
|
7
|
-
var tsplus_module_1 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/Encoder/api"));
|
|
8
|
-
var tsplus_module_2 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@fncts/base/data/function/api"));
|
|
9
|
-
var _Schema = /*#__PURE__*/require("@fncts/schema/Schema");
|
|
10
|
-
var G = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("./Guard.cjs"));
|
|
11
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
13
|
-
const Schemable = {
|
|
14
|
-
unknown: tsplus_module_1.unknown,
|
|
15
|
-
string: tsplus_module_1.string,
|
|
16
|
-
number: tsplus_module_1.number,
|
|
17
|
-
boolean: tsplus_module_1.boolean,
|
|
18
|
-
bigint: tsplus_module_1.bigint,
|
|
19
|
-
literal: tsplus_module_1.literal,
|
|
20
|
-
nullable: tsplus_module_1.nullable,
|
|
21
|
-
struct: tsplus_module_1.struct,
|
|
22
|
-
partial: tsplus_module_1.partial,
|
|
23
|
-
array: tsplus_module_1.readonlyArray,
|
|
24
|
-
record: tsplus_module_1.record,
|
|
25
|
-
tuple: tsplus_module_1.tuple,
|
|
26
|
-
lazy: tsplus_module_1.deriveLazy,
|
|
27
|
-
validation: tsplus_module_1.validation,
|
|
28
|
-
union: (members, schema) => {
|
|
29
|
-
const guards = schema.members.map((0, _Schema.interpret)(G.Schemable));
|
|
30
|
-
return tsplus_module_1.makeEncoder(inp => {
|
|
31
|
-
let encoder;
|
|
32
|
-
for (let i = 0; i < guards.length; i++) {
|
|
33
|
-
if (guards[i].is(inp)) {
|
|
34
|
-
encoder = members[i];
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
if (!encoder) {
|
|
38
|
-
throw new Error("BUG: Encoder not found for union");
|
|
39
|
-
}
|
|
40
|
-
return encoder.encode(inp);
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
exports.Schemable = Schemable;
|
|
45
|
-
//# sourceMappingURL=Encoder.cjs.map
|
package/_cjs/Encoder.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Encoder.cjs","mappings":";;;;;;;;AAGA;AAEA;AAAgC;AAAA;AAEzB,MAAMA,SAAS,GAAgB;EACpCC,OAAO,yBAAiB;EACxBC,MAAM,wBAAU;EAChBC,MAAM,wBAAU;EAChBC,OAAO,yBAAU;EACjBC,MAAM,wBAAU;EAChBC,OAAO,yBAAiB;EACxBC,QAAQ,0BAAkB;EAC1BC,MAAM,wBAAgB;EACtBC,OAAO,yBAAiB;EACxBC,KAAK,+BAAuB;EAC5BC,MAAM,wBAAgB;EACtBC,KAAK,uBAA6B;EAClCC,IAAI,4BAAc;EAClBC,UAAU,4BAAkC;EAC5CC,KAAK,EAAE,CAACC,OAAO,EAAEC,MAAM,KAAI;IACzB,MAAMC,MAAM,GAAGD,MAAM,CAACD,OAAO,CAACG,GAAG,CAAC,qBAAS,EAACC,CAAC,CAACpB,SAAS,CAAC,CAAC;IACzD,OAAOqB,4BAASC,GAAG,IAAI;MACrB,IAAIC,OAAiC;MACrC,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGN,MAAM,CAACO,MAAM,EAAED,CAAC,EAAE,EAAE;QACtC,IAAIN,MAAM,CAACM,CAAC,CAAE,CAACE,EAAE,CAACJ,GAAG,CAAC,EAAE;UACtBC,OAAO,GAAGP,OAAO,CAACQ,CAAC,CAAE;;;MAGzB,IAAI,CAACD,OAAO,EAAE;QACZ,MAAM,IAAII,KAAK,CAAC,kCAAkC,CAAC;;MAErD,OAAOJ,OAAO,CAACK,MAAM,CAACN,GAAG,CAAC;IAC5B,CAAC,CAAC;EACJ;CACD;AAAC","names":["Schemable","unknown","string","number","boolean","bigint","literal","nullable","struct","partial","array","record","tuple","lazy","validation","union","members","schema","guards","map","G","tsplus_module_1","inp","encoder","i","length","is","Error","encode"],"sourceRoot":"","sources":["../_src/Encoder.ts"],"sourcesContent":[null]}
|
package/_cjs/Guard.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Guard.cjs","mappings":";;;;;;;;;;AAGO,MAAMA,SAAS,GAAc;EAClCC,OAAO,yBAAe;EACtBC,MAAM,wBAAU;EAChBC,MAAM,wBAAU;EAChBC,OAAO,yBAAU;EACjBC,MAAM,wBAAU;EAChBC,OAAO,yBAAe;EACtBC,QAAQ,0BAAgB;EACxBC,MAAM,wBAAc;EACpBC,OAAO,yBAAe;EACtBC,KAAK,+BAAqB;EAC1BC,MAAM,wBAAc;EACpBC,KAAK,uBAA2B;EAChCC,IAAI,4BAAY;EAChBC,UAAU,4BAAgC;EAC1CC,KAAK,EAAGC,OAAO,IAAKC,4BAAY,GAAGD,OAAO;CAC3C;AAAC","names":["Schemable","unknown","string","number","boolean","bigint","literal","nullable","struct","partial","array","record","tuple","lazy","validation","union","members","tsplus_module_1"],"sourceRoot":"","sources":["../_src/Guard.ts"],"sourcesContent":[null]}
|
package/_cjs/Schemable.cjs
DELETED
package/_cjs/Schemable.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Schemable.cjs","mappings":"","names":[],"sourceRoot":"","sources":[],"sourcesContent":[]}
|
package/_mjs/Decoder.mjs
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as tsplus_module_1 from "@fncts/base/data/Decoder/api";
|
|
2
|
-
import * as tsplus_module_2 from "@fncts/base/data/function/api";
|
|
3
|
-
export const Schemable = {
|
|
4
|
-
unknown: tsplus_module_1.unknown,
|
|
5
|
-
string: tsplus_module_1.string,
|
|
6
|
-
number: tsplus_module_1.number,
|
|
7
|
-
boolean: tsplus_module_1.boolean,
|
|
8
|
-
bigint: tsplus_module_1.bigint,
|
|
9
|
-
literal: tsplus_module_1.literal,
|
|
10
|
-
nullable: tsplus_module_1.nullable,
|
|
11
|
-
struct: tsplus_module_1.struct,
|
|
12
|
-
partial: tsplus_module_1.partial,
|
|
13
|
-
array: tsplus_module_1.readonlyArray,
|
|
14
|
-
record: tsplus_module_1.record,
|
|
15
|
-
tuple: tsplus_module_1.tuple,
|
|
16
|
-
lazy: tsplus_module_1.deriveLazy,
|
|
17
|
-
validation: tsplus_module_1.validation,
|
|
18
|
-
union: members => tsplus_module_1.union(...members)
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=Decoder.mjs.map
|
package/_mjs/Decoder.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Decoder.mjs","mappings":";;AAGA,OAAO,MAAMA,SAAS,GAAgB;EACpCC,OAAO,yBAAiB;EACxBC,MAAM,wBAAU;EAChBC,MAAM,wBAAU;EAChBC,OAAO,yBAAU;EACjBC,MAAM,wBAAU;EAChBC,OAAO,yBAAiB;EACxBC,QAAQ,0BAAkB;EAC1BC,MAAM,wBAAgB;EACtBC,OAAO,yBAAiB;EACxBC,KAAK,+BAAuB;EAC5BC,MAAM,wBAAgB;EACtBC,KAAK,uBAA6B;EAClCC,IAAI,4BAAc;EAClBC,UAAU,4BAAkC;EAC5CC,KAAK,EAAGC,OAAO,IAAKC,sBAAc,GAAGD,OAAO;CAC7C","names":["Schemable","unknown","string","number","boolean","bigint","literal","nullable","struct","partial","array","record","tuple","lazy","validation","union","members","tsplus_module_1"],"sourceRoot":"","sources":["../_src/Decoder.ts"],"sourcesContent":[null]}
|
package/_mjs/Encoder.mjs
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import * as tsplus_module_1 from "@fncts/base/data/Encoder/api";
|
|
2
|
-
import * as tsplus_module_2 from "@fncts/base/data/function/api";
|
|
3
|
-
import { interpret } from "@fncts/schema/Schema";
|
|
4
|
-
import * as G from "./Guard.mjs";
|
|
5
|
-
export const Schemable = {
|
|
6
|
-
unknown: tsplus_module_1.unknown,
|
|
7
|
-
string: tsplus_module_1.string,
|
|
8
|
-
number: tsplus_module_1.number,
|
|
9
|
-
boolean: tsplus_module_1.boolean,
|
|
10
|
-
bigint: tsplus_module_1.bigint,
|
|
11
|
-
literal: tsplus_module_1.literal,
|
|
12
|
-
nullable: tsplus_module_1.nullable,
|
|
13
|
-
struct: tsplus_module_1.struct,
|
|
14
|
-
partial: tsplus_module_1.partial,
|
|
15
|
-
array: tsplus_module_1.readonlyArray,
|
|
16
|
-
record: tsplus_module_1.record,
|
|
17
|
-
tuple: tsplus_module_1.tuple,
|
|
18
|
-
lazy: tsplus_module_1.deriveLazy,
|
|
19
|
-
validation: tsplus_module_1.validation,
|
|
20
|
-
union: (members, schema) => {
|
|
21
|
-
const guards = schema.members.map(interpret(G.Schemable));
|
|
22
|
-
return tsplus_module_1.makeEncoder(inp => {
|
|
23
|
-
let encoder;
|
|
24
|
-
for (let i = 0; i < guards.length; i++) {
|
|
25
|
-
if (guards[i].is(inp)) {
|
|
26
|
-
encoder = members[i];
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
if (!encoder) {
|
|
30
|
-
throw new Error("BUG: Encoder not found for union");
|
|
31
|
-
}
|
|
32
|
-
return encoder.encode(inp);
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
//# sourceMappingURL=Encoder.mjs.map
|
package/_mjs/Encoder.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Encoder.mjs","mappings":";;AAGA,SAASA,SAAS,QAAQ,sBAAsB;AAEhD,OAAO,KAAKC,CAAC,MAAM,aAAY;AAE/B,OAAO,MAAMC,SAAS,GAAgB;EACpCC,OAAO,yBAAiB;EACxBC,MAAM,wBAAU;EAChBC,MAAM,wBAAU;EAChBC,OAAO,yBAAU;EACjBC,MAAM,wBAAU;EAChBC,OAAO,yBAAiB;EACxBC,QAAQ,0BAAkB;EAC1BC,MAAM,wBAAgB;EACtBC,OAAO,yBAAiB;EACxBC,KAAK,+BAAuB;EAC5BC,MAAM,wBAAgB;EACtBC,KAAK,uBAA6B;EAClCC,IAAI,4BAAc;EAClBC,UAAU,4BAAkC;EAC5CC,KAAK,EAAE,CAACC,OAAO,EAAEC,MAAM,KAAI;IACzB,MAAMC,MAAM,GAAGD,MAAM,CAACD,OAAO,CAACG,GAAG,CAACrB,SAAS,CAACC,CAAC,CAACC,SAAS,CAAC,CAAC;IACzD,OAAOoB,4BAASC,GAAG,IAAI;MACrB,IAAIC,OAAiC;MACrC,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGL,MAAM,CAACM,MAAM,EAAED,CAAC,EAAE,EAAE;QACtC,IAAIL,MAAM,CAACK,CAAC,CAAE,CAACE,EAAE,CAACJ,GAAG,CAAC,EAAE;UACtBC,OAAO,GAAGN,OAAO,CAACO,CAAC,CAAE;;;MAGzB,IAAI,CAACD,OAAO,EAAE;QACZ,MAAM,IAAII,KAAK,CAAC,kCAAkC,CAAC;;MAErD,OAAOJ,OAAO,CAACK,MAAM,CAACN,GAAG,CAAC;IAC5B,CAAC,CAAC;EACJ;CACD","names":["interpret","G","Schemable","unknown","string","number","boolean","bigint","literal","nullable","struct","partial","array","record","tuple","lazy","validation","union","members","schema","guards","map","tsplus_module_1","inp","encoder","i","length","is","Error","encode"],"sourceRoot":"","sources":["../_src/Encoder.ts"],"sourcesContent":[null]}
|
package/_mjs/Guard.mjs
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as tsplus_module_1 from "@fncts/base/data/Guard/api";
|
|
2
|
-
import * as tsplus_module_2 from "@fncts/base/data/function/api";
|
|
3
|
-
export const Schemable = {
|
|
4
|
-
unknown: tsplus_module_1.unknown,
|
|
5
|
-
string: tsplus_module_1.string,
|
|
6
|
-
number: tsplus_module_1.number,
|
|
7
|
-
boolean: tsplus_module_1.boolean,
|
|
8
|
-
bigint: tsplus_module_1.bigint,
|
|
9
|
-
literal: tsplus_module_1.literal,
|
|
10
|
-
nullable: tsplus_module_1.nullable,
|
|
11
|
-
struct: tsplus_module_1.struct,
|
|
12
|
-
partial: tsplus_module_1.partial,
|
|
13
|
-
array: tsplus_module_1.readonlyArray,
|
|
14
|
-
record: tsplus_module_1.record,
|
|
15
|
-
tuple: tsplus_module_1.tuple,
|
|
16
|
-
lazy: tsplus_module_1.deriveLazy,
|
|
17
|
-
validation: tsplus_module_1.validation,
|
|
18
|
-
union: members => tsplus_module_1.deriveUnion(...members)
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=Guard.mjs.map
|
package/_mjs/Guard.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Guard.mjs","mappings":";;AAGA,OAAO,MAAMA,SAAS,GAAc;EAClCC,OAAO,yBAAe;EACtBC,MAAM,wBAAU;EAChBC,MAAM,wBAAU;EAChBC,OAAO,yBAAU;EACjBC,MAAM,wBAAU;EAChBC,OAAO,yBAAe;EACtBC,QAAQ,0BAAgB;EACxBC,MAAM,wBAAc;EACpBC,OAAO,yBAAe;EACtBC,KAAK,+BAAqB;EAC1BC,MAAM,wBAAc;EACpBC,KAAK,uBAA2B;EAChCC,IAAI,4BAAY;EAChBC,UAAU,4BAAgC;EAC1CC,KAAK,EAAGC,OAAO,IAAKC,4BAAY,GAAGD,OAAO;CAC3C","names":["Schemable","unknown","string","number","boolean","bigint","literal","nullable","struct","partial","array","record","tuple","lazy","validation","union","members","tsplus_module_1"],"sourceRoot":"","sources":["../_src/Guard.ts"],"sourcesContent":[null]}
|
package/_mjs/Schemable.mjs
DELETED
package/_mjs/Schemable.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Schemable.mjs","mappings":"","names":[],"sourceRoot":"","sources":[],"sourcesContent":[]}
|
package/_src/Decoder.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { DecoderF } from "@fncts/base/data/Decoder";
|
|
2
|
-
import type { Schemable as S } from "@fncts/schema/Schemable";
|
|
3
|
-
|
|
4
|
-
export const Schemable: S<DecoderF> = {
|
|
5
|
-
unknown: Decoder.unknown,
|
|
6
|
-
string: Derive(),
|
|
7
|
-
number: Derive(),
|
|
8
|
-
boolean: Derive(),
|
|
9
|
-
bigint: Derive(),
|
|
10
|
-
literal: Decoder.literal,
|
|
11
|
-
nullable: Decoder.nullable,
|
|
12
|
-
struct: Decoder.struct,
|
|
13
|
-
partial: Decoder.partial,
|
|
14
|
-
array: Decoder.readonlyArray,
|
|
15
|
-
record: Decoder.record,
|
|
16
|
-
tuple: unsafeCoerce(Decoder.tuple),
|
|
17
|
-
lazy: Decoder.lazy,
|
|
18
|
-
validation: unsafeCoerce(Decoder.validation),
|
|
19
|
-
union: (members) => Decoder.union(...members),
|
|
20
|
-
};
|
package/_src/Encoder.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { EncoderF } from "@fncts/base/data/Encoder";
|
|
2
|
-
import type { Schemable as S } from "@fncts/schema/Schemable";
|
|
3
|
-
|
|
4
|
-
import { interpret } from "@fncts/schema/Schema";
|
|
5
|
-
|
|
6
|
-
import * as G from "./Guard.js";
|
|
7
|
-
|
|
8
|
-
export const Schemable: S<EncoderF> = {
|
|
9
|
-
unknown: Encoder.unknown,
|
|
10
|
-
string: Derive(),
|
|
11
|
-
number: Derive(),
|
|
12
|
-
boolean: Derive(),
|
|
13
|
-
bigint: Derive(),
|
|
14
|
-
literal: Encoder.literal,
|
|
15
|
-
nullable: Encoder.nullable,
|
|
16
|
-
struct: Encoder.struct,
|
|
17
|
-
partial: Encoder.partial,
|
|
18
|
-
array: Encoder.readonlyArray,
|
|
19
|
-
record: Encoder.record,
|
|
20
|
-
tuple: unsafeCoerce(Encoder.tuple),
|
|
21
|
-
lazy: Encoder.lazy,
|
|
22
|
-
validation: unsafeCoerce(Encoder.validation),
|
|
23
|
-
union: (members, schema) => {
|
|
24
|
-
const guards = schema.members.map(interpret(G.Schemable));
|
|
25
|
-
return Encoder((inp) => {
|
|
26
|
-
let encoder: Encoder<any> | undefined;
|
|
27
|
-
for (let i = 0; i < guards.length; i++) {
|
|
28
|
-
if (guards[i]!.is(inp)) {
|
|
29
|
-
encoder = members[i]!;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
if (!encoder) {
|
|
33
|
-
throw new Error("BUG: Encoder not found for union");
|
|
34
|
-
}
|
|
35
|
-
return encoder.encode(inp);
|
|
36
|
-
});
|
|
37
|
-
},
|
|
38
|
-
};
|
package/_src/Guard.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { GuardF } from "@fncts/base/data/Guard";
|
|
2
|
-
import type { Schemable as S } from "@fncts/schema/Schemable";
|
|
3
|
-
|
|
4
|
-
export const Schemable: S<GuardF> = {
|
|
5
|
-
unknown: Guard.unknown,
|
|
6
|
-
string: Derive(),
|
|
7
|
-
number: Derive(),
|
|
8
|
-
boolean: Derive(),
|
|
9
|
-
bigint: Derive(),
|
|
10
|
-
literal: Guard.literal,
|
|
11
|
-
nullable: Guard.nullable,
|
|
12
|
-
struct: Guard.struct,
|
|
13
|
-
partial: Guard.partial,
|
|
14
|
-
array: Guard.readonlyArray,
|
|
15
|
-
record: Guard.record,
|
|
16
|
-
tuple: unsafeCoerce(Guard.tuple),
|
|
17
|
-
lazy: Guard.lazy,
|
|
18
|
-
validation: unsafeCoerce(Guard.validation),
|
|
19
|
-
union: (members) => Guard.union(...members),
|
|
20
|
-
};
|
package/_src/Schemable.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { Brand, Validation } from "@fncts/base/data/Branded";
|
|
2
|
-
import type { UnionSchema } from "@fncts/schema/Schema";
|
|
3
|
-
import type { Literal } from "@fncts/typelevel/Any";
|
|
4
|
-
|
|
5
|
-
export type SchemableKind<F extends HKT, A> = F extends { readonly type: unknown }
|
|
6
|
-
? (F & { readonly A: A })["type"]
|
|
7
|
-
: {
|
|
8
|
-
readonly _F: F;
|
|
9
|
-
readonly _A: A;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export interface Schemable<F extends HKT> {
|
|
13
|
-
readonly unknown: SchemableKind<F, unknown>;
|
|
14
|
-
readonly string: SchemableKind<F, string>;
|
|
15
|
-
readonly number: SchemableKind<F, number>;
|
|
16
|
-
readonly boolean: SchemableKind<F, boolean>;
|
|
17
|
-
readonly bigint: SchemableKind<F, bigint>;
|
|
18
|
-
readonly literal: <A extends Literal>(literal: A) => SchemableKind<F, A>;
|
|
19
|
-
readonly nullable: <A>(or: SchemableKind<F, A>) => SchemableKind<F, A | null | undefined>;
|
|
20
|
-
readonly struct: <P extends Record<string, any>>(properties: {
|
|
21
|
-
[K in keyof P]: SchemableKind<F, P[K]>;
|
|
22
|
-
}) => SchemableKind<F, P>;
|
|
23
|
-
readonly partial: <P extends Record<string, any>>(properties: {
|
|
24
|
-
[K in keyof P]: SchemableKind<F, P[K]>;
|
|
25
|
-
}) => SchemableKind<F, Partial<P>>;
|
|
26
|
-
readonly array: <A>(item: SchemableKind<F, A>) => SchemableKind<F, ReadonlyArray<A>>;
|
|
27
|
-
readonly record: <A>(codomain: SchemableKind<F, A>) => SchemableKind<F, Record<string, A>>;
|
|
28
|
-
readonly tuple: <C extends ReadonlyArray<any>>(
|
|
29
|
-
...components: {
|
|
30
|
-
[K in keyof C]: SchemableKind<F, C[K]>;
|
|
31
|
-
}
|
|
32
|
-
) => SchemableKind<F, C>;
|
|
33
|
-
readonly lazy: <A>(f: () => SchemableKind<F, A>) => SchemableKind<F, A>;
|
|
34
|
-
readonly validation: <A, B extends ReadonlyArray<Validation<A, any>>>(
|
|
35
|
-
...validations: B
|
|
36
|
-
) => (
|
|
37
|
-
base: SchemableKind<F, A>,
|
|
38
|
-
) => SchemableKind<
|
|
39
|
-
F,
|
|
40
|
-
A & { [K in keyof B]: B[K] extends Validation<any, infer S> ? Brand.Valid<A, S> : never }[number]
|
|
41
|
-
>;
|
|
42
|
-
readonly union: <A extends ReadonlyArray<any>>(
|
|
43
|
-
members: { [K in keyof A]: SchemableKind<F, A[K]> },
|
|
44
|
-
schema: UnionSchema<A>,
|
|
45
|
-
) => SchemableKind<F, A[number]>;
|
|
46
|
-
}
|