effect-app 0.202.1 → 0.203.0
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/CHANGELOG.md +12 -0
- package/_cjs/Operations.cjs +15 -14
- package/_cjs/Operations.cjs.map +1 -1
- package/_cjs/client/errors.cjs +10 -10
- package/_cjs/client/errors.cjs.map +1 -1
- package/_cjs/schema.cjs +10 -9
- package/_cjs/schema.cjs.map +1 -1
- package/dist/Operations.d.ts +42 -41
- package/dist/Operations.d.ts.map +1 -1
- package/dist/Operations.js +16 -15
- package/dist/client/errors.d.ts +25 -25
- package/dist/client/errors.js +10 -10
- package/dist/schema.d.ts +2 -2
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +6 -5
- package/package.json +7 -7
- package/src/Operations.ts +16 -15
- package/src/client/errors.ts +10 -10
- package/src/schema.ts +8 -7
- package/test/schema.test.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @effect-app/prelude
|
|
2
2
|
|
|
3
|
+
## 0.203.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 0d1b378: update to latest schema
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [0d1b378]
|
|
12
|
+
- @effect-app/schema@0.221.0
|
|
13
|
+
- @effect-app/core@0.170.0
|
|
14
|
+
|
|
3
15
|
## 0.202.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/_cjs/Operations.cjs
CHANGED
|
@@ -4,31 +4,32 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Success = exports.OperationResult = exports.OperationProgress = exports.OperationId = exports.Operation = exports.Failure = void 0;
|
|
7
|
-
var S = _interopRequireWildcard(require("
|
|
7
|
+
var S = _interopRequireWildcard(require("@effect/Schema/Schema"));
|
|
8
|
+
var S2 = _interopRequireWildcard(require("./schema.cjs"));
|
|
8
9
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
9
10
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
10
|
-
const OperationId = exports.OperationId =
|
|
11
|
-
class OperationProgress extends
|
|
12
|
-
completed:
|
|
13
|
-
total:
|
|
11
|
+
const OperationId = exports.OperationId = S2.StringId;
|
|
12
|
+
class OperationProgress extends S2.ExtendedClass()({
|
|
13
|
+
completed: S2.NonNegativeInt,
|
|
14
|
+
total: S2.NonNegativeInt
|
|
14
15
|
}) {}
|
|
15
16
|
exports.OperationProgress = OperationProgress;
|
|
16
|
-
class Success extends
|
|
17
|
-
message:
|
|
17
|
+
class Success extends S2.ExtendedTaggedClass()("Success", {
|
|
18
|
+
message: S2.NullOr(S2.NonEmptyString2k).withDefault
|
|
18
19
|
}) {}
|
|
19
20
|
exports.Success = Success;
|
|
20
|
-
class Failure extends
|
|
21
|
-
message:
|
|
21
|
+
class Failure extends S2.ExtendedTaggedClass()("Failure", {
|
|
22
|
+
message: S2.NullOr(S2.NonEmptyString2k).withDefault
|
|
22
23
|
}) {}
|
|
23
24
|
exports.Failure = Failure;
|
|
24
|
-
const OperationResult = exports.OperationResult =
|
|
25
|
-
class Operation extends
|
|
25
|
+
const OperationResult = exports.OperationResult = S2.ExtendTaggedUnion(S.Union(Success, Failure));
|
|
26
|
+
class Operation extends S2.ExtendedClass()({
|
|
26
27
|
id: OperationId,
|
|
27
|
-
title:
|
|
28
|
+
title: S2.NonEmptyString2k,
|
|
28
29
|
progress: S.optional(OperationProgress),
|
|
29
30
|
result: S.optional(OperationResult),
|
|
30
|
-
createdAt:
|
|
31
|
-
updatedAt:
|
|
31
|
+
createdAt: S2.Date.withDefault,
|
|
32
|
+
updatedAt: S2.NullOr(S.Date).withDefault
|
|
32
33
|
}) {}
|
|
33
34
|
/* eslint-enable */
|
|
34
35
|
//
|
package/_cjs/Operations.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Operations.cjs","names":["S","_interopRequireWildcard","require","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","OperationId","exports","StringId","OperationProgress","ExtendedClass","completed","NonNegativeInt","total","Success","ExtendedTaggedClass","message","
|
|
1
|
+
{"version":3,"file":"Operations.cjs","names":["S","_interopRequireWildcard","require","S2","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","OperationId","exports","StringId","OperationProgress","ExtendedClass","completed","NonNegativeInt","total","Success","ExtendedTaggedClass","message","NullOr","NonEmptyString2k","withDefault","Failure","OperationResult","ExtendTaggedUnion","Union","Operation","id","title","progress","optional","result","createdAt","Date","updatedAt"],"sources":["../src/Operations.ts"],"sourcesContent":[null],"mappings":";;;;;;AAAA,IAAAA,CAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,EAAA,GAAAF,uBAAA,CAAAC,OAAA;AAAiC,SAAAE,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,C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,SAAS,EAAE;EACtFC,OAAO,EAAE/B,EAAE,CAACgC,MAAM,CAAChC,EAAE,CAACiC,gBAAgB,CAAC,CAACC;CACzC,CAAC;AAAGZ,OAAA,CAAAO,OAAA,GAAAA,OAAA;AAEC,MAAOM,OAAQ,SAAQnC,EAAE,CAAC8B,mBAAmB,EAAyB,CAAC,SAAS,EAAE;EACtFC,OAAO,EAAE/B,EAAE,CAACgC,MAAM,CAAChC,EAAE,CAACiC,gBAAgB,CAAC,CAACC;CACzC,CAAC;AAAGZ,OAAA,CAAAa,OAAA,GAAAA,OAAA;AAEE,MAAMC,eAAe,GAAAd,OAAA,CAAAc,eAAA,GAAGpC,EAAE,CAACqC,iBAAiB,CAACxC,CAAC,CAACyC,KAAK,CAACT,OAAO,EAAEM,OAAO,CAAC,CAAC;AAGxE,MAAOI,SAAU,SAAQvC,EAAE,CAACyB,aAAa,EAA6B,CAAC;EAC3Ee,EAAE,EAAEnB,WAAW;EACfoB,KAAK,EAAEzC,EAAE,CAACiC,gBAAgB;EAC1BS,QAAQ,EAAE7C,CAAC,CAAC8C,QAAQ,CAACnB,iBAAiB,CAAC;EACvCoB,MAAM,EAAE/C,CAAC,CAAC8C,QAAQ,CAACP,eAAe,CAAC;EACnCS,SAAS,EAAE7C,EAAE,CAAC8C,IAAI,CAACZ,WAAW;EAC9Ba,SAAS,EAAE/C,EAAE,CAACgC,MAAM,CAACnC,CAAC,CAACiD,IAAI,CAAC,CAACZ;CAC9B,CAAC;AAiBF;AACA;AACA;AAAAZ,OAAA,CAAAiB,SAAA,GAAAA,SAAA","ignoreList":[]}
|
package/_cjs/client/errors.cjs
CHANGED
|
@@ -10,8 +10,8 @@ var _lib = require("../lib.cjs");
|
|
|
10
10
|
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
11
11
|
// @ts-expect-error type not used
|
|
12
12
|
class NotFoundError extends (0, _schema.TaggedError)()("NotFoundError", {
|
|
13
|
-
type: _lib.S.
|
|
14
|
-
id: _lib.S.
|
|
13
|
+
type: _lib.S.String,
|
|
14
|
+
id: _lib.S.Unknown
|
|
15
15
|
}) {
|
|
16
16
|
get message() {
|
|
17
17
|
return `Didn't find ${this.type}#${JSON.stringify(this.id)}`;
|
|
@@ -20,7 +20,7 @@ class NotFoundError extends (0, _schema.TaggedError)()("NotFoundError", {
|
|
|
20
20
|
/** @tsplus type InvalidStateError */
|
|
21
21
|
exports.NotFoundError = NotFoundError;
|
|
22
22
|
class InvalidStateError extends (0, _schema.TaggedError)()("InvalidStateError", {
|
|
23
|
-
message: _lib.S.
|
|
23
|
+
message: _lib.S.String
|
|
24
24
|
}) {
|
|
25
25
|
constructor(messageOrObject, disableValidation) {
|
|
26
26
|
super(typeof messageOrObject === "object" ? messageOrObject : {
|
|
@@ -31,7 +31,7 @@ class InvalidStateError extends (0, _schema.TaggedError)()("InvalidStateError",
|
|
|
31
31
|
/** @tsplus type ServiceUnavailableError */
|
|
32
32
|
exports.InvalidStateError = InvalidStateError;
|
|
33
33
|
class ServiceUnavailableError extends (0, _schema.TaggedError)()("ServiceUnavailableError", {
|
|
34
|
-
message: _lib.S.
|
|
34
|
+
message: _lib.S.String
|
|
35
35
|
}) {
|
|
36
36
|
constructor(messageOrObject, disableValidation) {
|
|
37
37
|
super(typeof messageOrObject === "object" ? messageOrObject : {
|
|
@@ -42,7 +42,7 @@ class ServiceUnavailableError extends (0, _schema.TaggedError)()("ServiceUnavail
|
|
|
42
42
|
/** @tsplus type ValidationError */
|
|
43
43
|
exports.ServiceUnavailableError = ServiceUnavailableError;
|
|
44
44
|
class ValidationError extends (0, _schema.TaggedError)()("ValidationError", {
|
|
45
|
-
errors: _lib.S.
|
|
45
|
+
errors: _lib.S.Array(_lib.S.Unknown)
|
|
46
46
|
}) {
|
|
47
47
|
get message() {
|
|
48
48
|
return `Validation failed: ${this.errors.map(e => JSON.stringify(e)).join(", ")}`;
|
|
@@ -51,7 +51,7 @@ class ValidationError extends (0, _schema.TaggedError)()("ValidationError", {
|
|
|
51
51
|
/** @tsplus type NotLoggedInError */
|
|
52
52
|
exports.ValidationError = ValidationError;
|
|
53
53
|
class NotLoggedInError extends (0, _schema.TaggedError)()("NotLoggedInError", {
|
|
54
|
-
message: _lib.S.optional(_lib.S.
|
|
54
|
+
message: _lib.S.optional(_lib.S.String)
|
|
55
55
|
}) {
|
|
56
56
|
constructor(messageOrObject, disableValidation) {
|
|
57
57
|
super(typeof messageOrObject === "object" ? messageOrObject : {
|
|
@@ -65,7 +65,7 @@ class NotLoggedInError extends (0, _schema.TaggedError)()("NotLoggedInError", {
|
|
|
65
65
|
/** @tsplus type LoginError */
|
|
66
66
|
exports.NotLoggedInError = NotLoggedInError;
|
|
67
67
|
class LoginError extends (0, _schema.TaggedError)()("NotLoggedInError", {
|
|
68
|
-
message: _lib.S.optional(_lib.S.
|
|
68
|
+
message: _lib.S.optional(_lib.S.String)
|
|
69
69
|
}) {
|
|
70
70
|
constructor(messageOrObject, disableValidation) {
|
|
71
71
|
super(typeof messageOrObject === "object" ? messageOrObject : {
|
|
@@ -76,7 +76,7 @@ class LoginError extends (0, _schema.TaggedError)()("NotLoggedInError", {
|
|
|
76
76
|
/** @tsplus type UnauthorizedError */
|
|
77
77
|
exports.LoginError = LoginError;
|
|
78
78
|
class UnauthorizedError extends (0, _schema.TaggedError)()("UnauthorizedError", {
|
|
79
|
-
message: _lib.S.optional(_lib.S.
|
|
79
|
+
message: _lib.S.optional(_lib.S.String)
|
|
80
80
|
}) {
|
|
81
81
|
constructor(messageOrObject, disableValidation) {
|
|
82
82
|
super(typeof messageOrObject === "object" ? messageOrObject : {
|
|
@@ -87,7 +87,7 @@ class UnauthorizedError extends (0, _schema.TaggedError)()("UnauthorizedError",
|
|
|
87
87
|
/** @tsplus type OptimisticConcurrencyException */
|
|
88
88
|
exports.UnauthorizedError = UnauthorizedError;
|
|
89
89
|
class OptimisticConcurrencyException extends (0, _schema.TaggedError)()("OptimisticConcurrencyException", {
|
|
90
|
-
message: _lib.S.
|
|
90
|
+
message: _lib.S.String
|
|
91
91
|
}) {
|
|
92
92
|
details;
|
|
93
93
|
constructor(args, disableValidation) {
|
|
@@ -102,7 +102,7 @@ class OptimisticConcurrencyException extends (0, _schema.TaggedError)()("Optimis
|
|
|
102
102
|
exports.OptimisticConcurrencyException = OptimisticConcurrencyException;
|
|
103
103
|
const MutationOnlyErrors = [InvalidStateError, OptimisticConcurrencyException];
|
|
104
104
|
const GeneralErrors = [NotFoundError, NotLoggedInError, LoginError, UnauthorizedError, ValidationError, ServiceUnavailableError];
|
|
105
|
-
const SupportedErrors = exports.SupportedErrors = _lib.S.
|
|
105
|
+
const SupportedErrors = exports.SupportedErrors = _lib.S.Union(...MutationOnlyErrors, ...GeneralErrors);
|
|
106
106
|
// ideal?
|
|
107
107
|
// export const QueryErrors = union({ ...GeneralErrors })
|
|
108
108
|
// .pipe(named("QueryErrors"))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.cjs","names":["_schema","require","_lib","NotFoundError","TaggedError","type","S","
|
|
1
|
+
{"version":3,"file":"errors.cjs","names":["_schema","require","_lib","NotFoundError","TaggedError","type","S","String","id","Unknown","message","JSON","stringify","exports","InvalidStateError","constructor","messageOrObject","disableValidation","ServiceUnavailableError","ValidationError","errors","Array","map","e","join","NotLoggedInError","optional","LoginError","UnauthorizedError","OptimisticConcurrencyException","details","args","MutationOnlyErrors","GeneralErrors","SupportedErrors","Union","MutationErrors","QueryErrors"],"sources":["../../src/client/errors.ts"],"sourcesContent":[null],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACM,MAAOE,aAAiC,SAAQ,IAAAC,mBAAW,GAA2B,CAAC,eAAe,EAAE;EAC5GC,IAAI,EAAEC,MAAC,CAACC,MAAM;EACdC,EAAE,EAAEF,MAAC,CAACG;CACP,CAAC;EACA,IAAaC,OAAOA,CAAA;IAClB,OAAO,eAAe,IAAI,CAACL,IAAI,IAAIM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AG;MAAErB,OAAO,EAAE,YAAYqB,IAAI,CAAC1B,IAAI,IAAI0B,IAAI,CAACvB,EAAE;IAAiB,CAAE,EAAES,iBAAiB,CAAC;IACnH,IAAI,EAAE,SAAS,IAAIc,IAAI,CAAC,EAAE;MACxB,IAAI,CAACD,OAAO,GAAGC,IAAI;IACrB;EACF;;AACDlB,OAAA,CAAAgB,8BAAA,GAAAA,8BAAA;AAED,MAAMG,kBAAkB,GAAG,CACzBlB,iBAAiB,EACjBe,8BAA8B,CACtB;AAEV,MAAMI,aAAa,GAAG,CACpB9B,aAAa,EACbsB,gBAAgB,EAChBE,UAAU,EACVC,iBAAiB,EACjBT,eAAe,EACfD,uBAAuB,CACf;AAEH,MAAMgB,eAAe,GAAArB,OAAA,CAAAqB,eAAA,GAAG5B,MAAC,CAAC6B,KAAK,CACpC,GAAGH,kBAAkB,EACrB,GAAGC,aAAa,CACjB;AAKD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEO,MAAMG,cAAc,GAAAvB,OAAA,CAAAuB,cAAA,GAAGF,eAAe;AACtC,MAAMG,WAAW,GAAAxB,OAAA,CAAAwB,WAAA,GAAGH,eAAe","ignoreList":[]}
|
package/_cjs/schema.cjs
CHANGED
|
@@ -8,10 +8,10 @@ var _exportNames = {
|
|
|
8
8
|
PhoneNumber: true,
|
|
9
9
|
makeIs: true,
|
|
10
10
|
makeIsAnyOf: true,
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
ExtendTaggedUnion: true,
|
|
12
|
+
TaggedUnion: true
|
|
13
13
|
};
|
|
14
|
-
exports.
|
|
14
|
+
exports.makeIsAnyOf = exports.makeIs = exports.TaggedUnion = exports.PhoneNumber = exports.ExtendTaggedUnion = exports.Email = void 0;
|
|
15
15
|
var _core = require("@effect-app/core");
|
|
16
16
|
var S = _interopRequireWildcard(require("@effect-app/schema"));
|
|
17
17
|
Object.keys(S).forEach(function (key) {
|
|
@@ -34,13 +34,14 @@ const Email = exports.Email = S.Email.pipe(S.annotations({
|
|
|
34
34
|
arbitrary: () => fc => (0, _faker.fakerArb)(faker => faker.internet.exampleEmail)(fc).map(Email)
|
|
35
35
|
}), S.withDefaults);
|
|
36
36
|
const PhoneNumber = exports.PhoneNumber = S.PhoneNumber.pipe(S.annotations({
|
|
37
|
+
arbitrary: () => fc =>
|
|
37
38
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
38
|
-
|
|
39
|
+
(0, _faker.fakerArb)(faker => faker.phone.number)(fc).map(PhoneNumber)
|
|
39
40
|
}), S.withDefaults);
|
|
40
41
|
const makeIs = schema => {
|
|
41
42
|
if (S.AST.isUnion(schema.ast)) {
|
|
42
43
|
return schema.ast.types.reduce((acc, t) => {
|
|
43
|
-
if (S.AST.
|
|
44
|
+
if (S.AST.isTransformation(t)) {
|
|
44
45
|
if (S.AST.isDeclaration(t.to)) {
|
|
45
46
|
t = t.from;
|
|
46
47
|
} else {
|
|
@@ -74,14 +75,14 @@ const makeIsAnyOf = schema => {
|
|
|
74
75
|
throw new Error("Unsupported");
|
|
75
76
|
};
|
|
76
77
|
exports.makeIsAnyOf = makeIsAnyOf;
|
|
77
|
-
const
|
|
78
|
+
const ExtendTaggedUnion = schema => (0, _utils.extendM)(schema, _ => ({
|
|
78
79
|
is: makeIs(_),
|
|
79
80
|
isAnyOf: makeIsAnyOf(_)
|
|
80
81
|
}));
|
|
81
|
-
exports.
|
|
82
|
-
const
|
|
82
|
+
exports.ExtendTaggedUnion = ExtendTaggedUnion;
|
|
83
|
+
const TaggedUnion = (...a) => (0, _core.pipe)(S.Union(...a), _ => (0, _utils.extendM)(_, _ => ({
|
|
83
84
|
is: makeIs(_),
|
|
84
85
|
isAnyOf: makeIsAnyOf(_)
|
|
85
86
|
})));
|
|
86
|
-
exports.
|
|
87
|
+
exports.TaggedUnion = TaggedUnion;
|
|
87
88
|
//# sourceMappingURL=schema.cjs.map
|
package/_cjs/schema.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.cjs","names":["_core","require","S","_interopRequireWildcard","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_faker","_utils","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","n","__proto__","a","getOwnPropertyDescriptor","u","i","set","Email","pipe","annotations","arbitrary","fc","fakerArb","faker","internet","exampleEmail","map","withDefaults","PhoneNumber","phone","number","makeIs","schema","AST","isUnion","ast","types","reduce","acc","
|
|
1
|
+
{"version":3,"file":"schema.cjs","names":["_core","require","S","_interopRequireWildcard","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_faker","_utils","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","n","__proto__","a","getOwnPropertyDescriptor","u","i","set","Email","pipe","annotations","arbitrary","fc","fakerArb","faker","internet","exampleEmail","map","withDefaults","PhoneNumber","phone","number","makeIs","schema","AST","isUnion","ast","types","reduce","acc","isTransformation","isDeclaration","to","from","isTypeLiteral","tag","ReadonlyArray","findFirst","propertySignatures","_","name","isLiteral","type","Option","some","none","getOrUndefined","String","literal","x","_tag","Error","makeIsAnyOf","includes","ExtendTaggedUnion","extendM","is","isAnyOf","TaggedUnion","Union"],"sources":["../src/schema.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAEA,IAAAC,CAAA,GAAAC,uBAAA,CAAAF,OAAA;AAIAG,MAAA,CAAAC,IAAA,CAAAH,CAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAL,CAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAA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AO,EAAEL,WAAW,CAACb,CAAC;AAAC,CAAE,CAAC,CAAC;AAAApD,OAAA,CAAAmE,iBAAA,GAAAA,iBAAA;AASlE,MAAMI,WAAW,GAAGA,CAAkE,GAAGvD,CAAU,KACxG,IAAAM,UAAI,EAAChC,CAAC,CAACkF,KAAK,CAAC,GAAGxD,CAAC,CAAC,EAAGoC,CAAC,IAAK,IAAAgB,cAAO,EAAChB,CAAC,EAAGA,CAAC,KAAM;EAAEiB,EAAE,EAAElC,MAAM,CAACiB,CAAC,CAAC;EAAEkB,OAAO,EAAEL,WAAW,CAACb,CAAC;AAAC,CAAE,CAAC,CAAC,CAAC;AAAApD,OAAA,CAAAuE,WAAA,GAAAA,WAAA","ignoreList":[]}
|
package/dist/Operations.d.ts
CHANGED
|
@@ -1,80 +1,81 @@
|
|
|
1
|
-
import * as S from "
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import * as S from "@effect/Schema/Schema";
|
|
2
|
+
import * as S2 from "./schema.js";
|
|
3
|
+
export type OperationId = S2.StringId;
|
|
4
|
+
export declare const OperationId: S2.WithDefaults<S.Schema<string & S2.StringIdBrand, string, never> & {
|
|
5
|
+
make: () => S2.StringId;
|
|
6
|
+
withDefault: S.PropertySignature<":", S2.StringId, never, ":", string, true, never>;
|
|
7
|
+
}> & S.Schema<string & S2.StringIdBrand, string, never> & {
|
|
8
|
+
make: () => S2.StringId;
|
|
9
|
+
withDefault: S.PropertySignature<":", S2.StringId, never, ":", string, true, never>;
|
|
9
10
|
};
|
|
10
|
-
declare const OperationProgress_base:
|
|
11
|
-
completed:
|
|
12
|
-
withDefault: S.PropertySignature<":", number &
|
|
11
|
+
declare const OperationProgress_base: S2.EnhancedClass<OperationProgress, {
|
|
12
|
+
completed: S2.WithDefaults<S.Schema<number & S2.NonNegativeIntBrand, number, never>> & S.Schema<number & S2.NonNegativeIntBrand, number, never> & {
|
|
13
|
+
withDefault: S.PropertySignature<":", number & S2.NonNegativeIntBrand, never, ":", number, true, never>;
|
|
13
14
|
};
|
|
14
|
-
total:
|
|
15
|
-
withDefault: S.PropertySignature<":", number &
|
|
15
|
+
total: S2.WithDefaults<S.Schema<number & S2.NonNegativeIntBrand, number, never>> & S.Schema<number & S2.NonNegativeIntBrand, number, never> & {
|
|
16
|
+
withDefault: S.PropertySignature<":", number & S2.NonNegativeIntBrand, never, ":", number, true, never>;
|
|
16
17
|
};
|
|
17
18
|
}, {
|
|
18
|
-
readonly completed: number &
|
|
19
|
-
readonly total: number &
|
|
19
|
+
readonly completed: number & S2.NonNegativeIntBrand;
|
|
20
|
+
readonly total: number & S2.NonNegativeIntBrand;
|
|
20
21
|
}, OperationProgress.From, never, {
|
|
21
|
-
readonly completed: number &
|
|
22
|
-
readonly total: number &
|
|
22
|
+
readonly completed: number & S2.NonNegativeIntBrand;
|
|
23
|
+
readonly total: number & S2.NonNegativeIntBrand;
|
|
23
24
|
}, {}, {}>;
|
|
24
25
|
export declare class OperationProgress extends OperationProgress_base {
|
|
25
26
|
}
|
|
26
|
-
declare const Success_base:
|
|
27
|
-
readonly _tag:
|
|
27
|
+
declare const Success_base: S2.EnhancedClass<Success, {
|
|
28
|
+
readonly _tag: S.Literal<["Success"]>;
|
|
28
29
|
} & {
|
|
29
|
-
message: S.PropertySignature<":", (string &
|
|
30
|
+
message: S.PropertySignature<":", (string & S2.NonEmptyString2kBrand) | null, never, ":", string | null, true, never>;
|
|
30
31
|
}, {
|
|
31
32
|
readonly _tag: "Success";
|
|
32
|
-
readonly message: (string &
|
|
33
|
+
readonly message: (string & S2.NonEmptyString2kBrand) | null;
|
|
33
34
|
}, Success.From, never, {
|
|
34
|
-
readonly message?: (string &
|
|
35
|
+
readonly message?: (string & S2.NonEmptyString2kBrand) | null;
|
|
35
36
|
}, {}, {}>;
|
|
36
37
|
export declare class Success extends Success_base {
|
|
37
38
|
}
|
|
38
|
-
declare const Failure_base:
|
|
39
|
-
readonly _tag:
|
|
39
|
+
declare const Failure_base: S2.EnhancedClass<Failure, {
|
|
40
|
+
readonly _tag: S.Literal<["Failure"]>;
|
|
40
41
|
} & {
|
|
41
|
-
message: S.PropertySignature<":", (string &
|
|
42
|
+
message: S.PropertySignature<":", (string & S2.NonEmptyString2kBrand) | null, never, ":", string | null, true, never>;
|
|
42
43
|
}, {
|
|
43
44
|
readonly _tag: "Failure";
|
|
44
|
-
readonly message: (string &
|
|
45
|
+
readonly message: (string & S2.NonEmptyString2kBrand) | null;
|
|
45
46
|
}, Failure.From, never, {
|
|
46
|
-
readonly message?: (string &
|
|
47
|
+
readonly message?: (string & S2.NonEmptyString2kBrand) | null;
|
|
47
48
|
}, {}, {}>;
|
|
48
49
|
export declare class Failure extends Failure_base {
|
|
49
50
|
}
|
|
50
51
|
export declare const OperationResult: S.Schema<Success | Failure, Success.From | Failure.From, never> & {
|
|
51
|
-
is:
|
|
52
|
-
isAnyOf:
|
|
52
|
+
is: S2.Is<Success | Failure>;
|
|
53
|
+
isAnyOf: S2.IsAny<Success | Failure>;
|
|
53
54
|
};
|
|
54
55
|
export type OperationResult = S.Schema.Type<typeof OperationResult>;
|
|
55
|
-
declare const Operation_base:
|
|
56
|
-
id:
|
|
57
|
-
make: () =>
|
|
58
|
-
withDefault: S.PropertySignature<":",
|
|
59
|
-
}> & S.Schema<string &
|
|
60
|
-
make: () =>
|
|
61
|
-
withDefault: S.PropertySignature<":",
|
|
56
|
+
declare const Operation_base: S2.EnhancedClass<Operation, {
|
|
57
|
+
id: S2.WithDefaults<S.Schema<string & S2.StringIdBrand, string, never> & {
|
|
58
|
+
make: () => S2.StringId;
|
|
59
|
+
withDefault: S.PropertySignature<":", S2.StringId, never, ":", string, true, never>;
|
|
60
|
+
}> & S.Schema<string & S2.StringIdBrand, string, never> & {
|
|
61
|
+
make: () => S2.StringId;
|
|
62
|
+
withDefault: S.PropertySignature<":", S2.StringId, never, ":", string, true, never>;
|
|
62
63
|
};
|
|
63
|
-
title:
|
|
64
|
+
title: S2.WithDefaults<S.Schema<string & S2.NonEmptyString2kBrand, string, never>> & S.Schema<string & S2.NonEmptyString2kBrand, string, never>;
|
|
64
65
|
progress: S.PropertySignature<"?:", OperationProgress | undefined, never, "?:", OperationProgress.From | undefined, false, never>;
|
|
65
66
|
result: S.PropertySignature<"?:", Success | Failure | undefined, never, "?:", Success.From | Failure.From | undefined, false, never>;
|
|
66
67
|
createdAt: S.PropertySignature<":", Date, never, ":", string, true, never>;
|
|
67
68
|
updatedAt: S.PropertySignature<":", Date | null, never, ":", string | null, true, never>;
|
|
68
69
|
}, {
|
|
69
|
-
readonly id: string &
|
|
70
|
-
readonly title: string &
|
|
70
|
+
readonly id: string & S2.StringIdBrand;
|
|
71
|
+
readonly title: string & S2.NonEmptyString2kBrand;
|
|
71
72
|
readonly progress?: OperationProgress | undefined;
|
|
72
73
|
readonly result?: Success | Failure | undefined;
|
|
73
74
|
readonly createdAt: Date;
|
|
74
75
|
readonly updatedAt: Date | null;
|
|
75
76
|
}, Operation.From, never, {
|
|
76
|
-
readonly id: string &
|
|
77
|
-
readonly title: string &
|
|
77
|
+
readonly id: string & S2.StringIdBrand;
|
|
78
|
+
readonly title: string & S2.NonEmptyString2kBrand;
|
|
78
79
|
readonly progress?: OperationProgress | undefined;
|
|
79
80
|
readonly result?: Success | Failure | undefined;
|
|
80
81
|
readonly createdAt?: Date;
|
package/dist/Operations.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Operations.d.ts","sourceRoot":"","sources":["../src/Operations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"Operations.d.ts","sourceRoot":"","sources":["../src/Operations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,uBAAuB,CAAA;AAC1C,OAAO,KAAK,EAAE,MAAM,aAAa,CAAA;AAEjC,MAAM,MAAM,WAAW,GAAG,EAAE,CAAC,QAAQ,CAAA;AACrC,eAAO,MAAM,WAAW;;;;;;CAAc,CAAA;;;;;;;;;;;;;;;AAEtC,qBAAa,iBAAkB,SAAQ,sBAMrC;CAAG;;;;;;;;;;;AAEL,qBAAa,OAAQ,SAAQ,YAE3B;CAAG;;;;;;;;;;;AAEL,qBAAa,OAAQ,SAAQ,YAE3B;CAAG;AAEL,eAAO,MAAM,eAAe;;;CAAkD,CAAA;AAC9E,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,eAAe,CAAC,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEnE,qBAAa,SAAU,SAAQ,cAO7B;CAAG;AAKL,yBAAiB,iBAAiB,CAAC;IACjC,UAAiB,IAAK,SAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,iBAAiB,CAAC,QAAQ,CAAC,CAAC;KAAG;CACtF;AACD,yBAAiB,OAAO,CAAC;IACvB,UAAiB,IAAK,SAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC;KAAG;CAC5E;AACD,yBAAiB,OAAO,CAAC;IACvB,UAAiB,IAAK,SAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC;KAAG;CAC5E;AACD,yBAAiB,SAAS,CAAC;IACzB,UAAiB,IAAK,SAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,SAAS,CAAC,QAAQ,CAAC,CAAC;KAAG;CAC9E"}
|
package/dist/Operations.js
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
import * as S from "
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import * as S from "@effect/Schema/Schema";
|
|
2
|
+
import * as S2 from "./schema.js";
|
|
3
|
+
export const OperationId = S2.StringId;
|
|
4
|
+
export class OperationProgress extends S2.ExtendedClass()({
|
|
5
|
+
completed: S2.NonNegativeInt,
|
|
6
|
+
total: S2.NonNegativeInt
|
|
6
7
|
}) {
|
|
7
8
|
}
|
|
8
|
-
export class Success extends
|
|
9
|
-
message:
|
|
9
|
+
export class Success extends S2.ExtendedTaggedClass()("Success", {
|
|
10
|
+
message: S2.NullOr(S2.NonEmptyString2k).withDefault
|
|
10
11
|
}) {
|
|
11
12
|
}
|
|
12
|
-
export class Failure extends
|
|
13
|
-
message:
|
|
13
|
+
export class Failure extends S2.ExtendedTaggedClass()("Failure", {
|
|
14
|
+
message: S2.NullOr(S2.NonEmptyString2k).withDefault
|
|
14
15
|
}) {
|
|
15
16
|
}
|
|
16
|
-
export const OperationResult =
|
|
17
|
-
export class Operation extends
|
|
17
|
+
export const OperationResult = S2.ExtendTaggedUnion(S.Union(Success, Failure));
|
|
18
|
+
export class Operation extends S2.ExtendedClass()({
|
|
18
19
|
id: OperationId,
|
|
19
|
-
title:
|
|
20
|
+
title: S2.NonEmptyString2k,
|
|
20
21
|
progress: S.optional(OperationProgress),
|
|
21
22
|
result: S.optional(OperationResult),
|
|
22
|
-
createdAt:
|
|
23
|
-
updatedAt:
|
|
23
|
+
createdAt: S2.Date.withDefault,
|
|
24
|
+
updatedAt: S2.NullOr(S.Date).withDefault
|
|
24
25
|
}) {
|
|
25
26
|
}
|
|
26
27
|
/* eslint-enable */
|
|
27
28
|
//
|
|
28
29
|
// codegen:end
|
|
29
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
30
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiT3BlcmF0aW9ucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9PcGVyYXRpb25zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxDQUFDLE1BQU0sdUJBQXVCLENBQUE7QUFDMUMsT0FBTyxLQUFLLEVB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FFBQVEsQ0FBQyxlQUFlLENBQUM7SUFDbkMsU0FBUyxFQUFFLEVBQUUsQ0FBQyxJQUFJLENBQUMsV0FBVztJQUM5QixTQUFTLEVBQUUsRUFBRSxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUMsSUFBSSxDQUFDLENBQUMsV0FBVztDQUN6QyxDQUFDO0NBQUc7QUFpQkwsbUJBQW1CO0FBQ25CLEVBQUU7QUFDRixjQUFjIn0=
|
package/dist/client/errors.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { S } from "../lib.js";
|
|
2
|
-
declare const NotFoundError_base: import("@effect/
|
|
3
|
-
readonly _tag:
|
|
2
|
+
declare const NotFoundError_base: import("@effect/Schema/Schema").Class<NotFoundError<ItemType>, {
|
|
3
|
+
readonly _tag: S.Literal<["NotFoundError"]>;
|
|
4
4
|
} & {
|
|
5
|
-
type: S.$
|
|
6
|
-
id: S
|
|
5
|
+
type: S.$String;
|
|
6
|
+
id: S.Unknown;
|
|
7
7
|
}, {
|
|
8
8
|
readonly _tag: "NotFoundError";
|
|
9
9
|
readonly type: string;
|
|
@@ -20,10 +20,10 @@ declare const NotFoundError_base: import("@effect/schema/Schema").Class<NotFound
|
|
|
20
20
|
export declare class NotFoundError<ItemType = string> extends NotFoundError_base {
|
|
21
21
|
get message(): string;
|
|
22
22
|
}
|
|
23
|
-
declare const InvalidStateError_base: import("@effect/
|
|
24
|
-
readonly _tag:
|
|
23
|
+
declare const InvalidStateError_base: import("@effect/Schema/Schema").Class<InvalidStateError, {
|
|
24
|
+
readonly _tag: S.Literal<["InvalidStateError"]>;
|
|
25
25
|
} & {
|
|
26
|
-
message: S.$
|
|
26
|
+
message: S.$String;
|
|
27
27
|
}, {
|
|
28
28
|
readonly _tag: "InvalidStateError";
|
|
29
29
|
readonly message: string;
|
|
@@ -39,10 +39,10 @@ export declare class InvalidStateError extends InvalidStateError_base {
|
|
|
39
39
|
message: string;
|
|
40
40
|
}, disableValidation?: boolean);
|
|
41
41
|
}
|
|
42
|
-
declare const ServiceUnavailableError_base: import("@effect/
|
|
43
|
-
readonly _tag:
|
|
42
|
+
declare const ServiceUnavailableError_base: import("@effect/Schema/Schema").Class<ServiceUnavailableError, {
|
|
43
|
+
readonly _tag: S.Literal<["ServiceUnavailableError"]>;
|
|
44
44
|
} & {
|
|
45
|
-
message: S.$
|
|
45
|
+
message: S.$String;
|
|
46
46
|
}, {
|
|
47
47
|
readonly _tag: "ServiceUnavailableError";
|
|
48
48
|
readonly message: string;
|
|
@@ -58,10 +58,10 @@ export declare class ServiceUnavailableError extends ServiceUnavailableError_bas
|
|
|
58
58
|
message: string;
|
|
59
59
|
}, disableValidation?: boolean);
|
|
60
60
|
}
|
|
61
|
-
declare const ValidationError_base: import("@effect/
|
|
62
|
-
readonly _tag:
|
|
61
|
+
declare const ValidationError_base: import("@effect/Schema/Schema").Class<ValidationError, {
|
|
62
|
+
readonly _tag: S.Literal<["ValidationError"]>;
|
|
63
63
|
} & {
|
|
64
|
-
errors:
|
|
64
|
+
errors: S.$Array<S.Unknown> & {
|
|
65
65
|
withDefault: S.PropertySignature<":", readonly unknown[], never, ":", readonly unknown[], true, never>;
|
|
66
66
|
};
|
|
67
67
|
}, {
|
|
@@ -77,8 +77,8 @@ declare const ValidationError_base: import("@effect/schema/Schema").Class<Valida
|
|
|
77
77
|
export declare class ValidationError extends ValidationError_base {
|
|
78
78
|
get message(): string;
|
|
79
79
|
}
|
|
80
|
-
declare const NotLoggedInError_base: import("@effect/
|
|
81
|
-
readonly _tag:
|
|
80
|
+
declare const NotLoggedInError_base: import("@effect/Schema/Schema").Class<NotLoggedInError, {
|
|
81
|
+
readonly _tag: S.Literal<["NotLoggedInError"]>;
|
|
82
82
|
} & {
|
|
83
83
|
message: S.PropertySignature<"?:", string | undefined, never, "?:", string | undefined, false, never>;
|
|
84
84
|
}, {
|
|
@@ -96,8 +96,8 @@ export declare class NotLoggedInError extends NotLoggedInError_base {
|
|
|
96
96
|
message?: string;
|
|
97
97
|
}, disableValidation?: boolean);
|
|
98
98
|
}
|
|
99
|
-
declare const LoginError_base: import("@effect/
|
|
100
|
-
readonly _tag:
|
|
99
|
+
declare const LoginError_base: import("@effect/Schema/Schema").Class<LoginError, {
|
|
100
|
+
readonly _tag: S.Literal<["NotLoggedInError"]>;
|
|
101
101
|
} & {
|
|
102
102
|
message: S.PropertySignature<"?:", string | undefined, never, "?:", string | undefined, false, never>;
|
|
103
103
|
}, {
|
|
@@ -118,8 +118,8 @@ export declare class LoginError extends LoginError_base {
|
|
|
118
118
|
message?: string;
|
|
119
119
|
}, disableValidation?: boolean);
|
|
120
120
|
}
|
|
121
|
-
declare const UnauthorizedError_base: import("@effect/
|
|
122
|
-
readonly _tag:
|
|
121
|
+
declare const UnauthorizedError_base: import("@effect/Schema/Schema").Class<UnauthorizedError, {
|
|
122
|
+
readonly _tag: S.Literal<["UnauthorizedError"]>;
|
|
123
123
|
} & {
|
|
124
124
|
message: S.PropertySignature<"?:", string | undefined, never, "?:", string | undefined, false, never>;
|
|
125
125
|
}, {
|
|
@@ -143,10 +143,10 @@ type OptimisticConcurrencyDetails = {
|
|
|
143
143
|
readonly current?: string | undefined;
|
|
144
144
|
readonly found?: string | undefined;
|
|
145
145
|
};
|
|
146
|
-
declare const OptimisticConcurrencyException_base: import("@effect/
|
|
147
|
-
readonly _tag:
|
|
146
|
+
declare const OptimisticConcurrencyException_base: import("@effect/Schema/Schema").Class<OptimisticConcurrencyException, {
|
|
147
|
+
readonly _tag: S.Literal<["OptimisticConcurrencyException"]>;
|
|
148
148
|
} & {
|
|
149
|
-
message: S.$
|
|
149
|
+
message: S.$String;
|
|
150
150
|
}, {
|
|
151
151
|
readonly _tag: "OptimisticConcurrencyException";
|
|
152
152
|
readonly message: string;
|
|
@@ -163,10 +163,10 @@ export declare class OptimisticConcurrencyException extends OptimisticConcurrenc
|
|
|
163
163
|
message: string;
|
|
164
164
|
}, disableValidation?: boolean);
|
|
165
165
|
}
|
|
166
|
-
export declare const SupportedErrors: S.
|
|
166
|
+
export declare const SupportedErrors: S.Union<[typeof InvalidStateError, typeof OptimisticConcurrencyException, typeof NotFoundError, typeof NotLoggedInError, typeof LoginError, typeof UnauthorizedError, typeof ValidationError, typeof ServiceUnavailableError]>;
|
|
167
167
|
export type SupportedErrors = S.Schema.Type<typeof SupportedErrors>;
|
|
168
|
-
export declare const MutationErrors: S.
|
|
169
|
-
export declare const QueryErrors: S.
|
|
168
|
+
export declare const MutationErrors: S.Union<[typeof InvalidStateError, typeof OptimisticConcurrencyException, typeof NotFoundError, typeof NotLoggedInError, typeof LoginError, typeof UnauthorizedError, typeof ValidationError, typeof ServiceUnavailableError]>;
|
|
169
|
+
export declare const QueryErrors: S.Union<[typeof InvalidStateError, typeof OptimisticConcurrencyException, typeof NotFoundError, typeof NotLoggedInError, typeof LoginError, typeof UnauthorizedError, typeof ValidationError, typeof ServiceUnavailableError]>;
|
|
170
170
|
export type MutationErrors = S.Schema.Type<typeof MutationErrors>;
|
|
171
171
|
export type QueryErrors = S.Schema.Type<typeof QueryErrors>;
|
|
172
172
|
export {};
|
package/dist/client/errors.js
CHANGED
|
@@ -4,8 +4,8 @@ import { S } from "../lib.js";
|
|
|
4
4
|
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
5
5
|
// @ts-expect-error type not used
|
|
6
6
|
export class NotFoundError extends TaggedError()("NotFoundError", {
|
|
7
|
-
type: S.
|
|
8
|
-
id: S.
|
|
7
|
+
type: S.String,
|
|
8
|
+
id: S.Unknown
|
|
9
9
|
}) {
|
|
10
10
|
get message() {
|
|
11
11
|
return `Didn't find ${this.type}#${JSON.stringify(this.id)}`;
|
|
@@ -13,7 +13,7 @@ export class NotFoundError extends TaggedError()("NotFoundError", {
|
|
|
13
13
|
}
|
|
14
14
|
/** @tsplus type InvalidStateError */
|
|
15
15
|
export class InvalidStateError extends TaggedError()("InvalidStateError", {
|
|
16
|
-
message: S.
|
|
16
|
+
message: S.String
|
|
17
17
|
}) {
|
|
18
18
|
constructor(messageOrObject, disableValidation) {
|
|
19
19
|
super(typeof messageOrObject === "object" ? messageOrObject : { message: messageOrObject }, disableValidation);
|
|
@@ -21,7 +21,7 @@ export class InvalidStateError extends TaggedError()("InvalidStateError", {
|
|
|
21
21
|
}
|
|
22
22
|
/** @tsplus type ServiceUnavailableError */
|
|
23
23
|
export class ServiceUnavailableError extends TaggedError()("ServiceUnavailableError", {
|
|
24
|
-
message: S.
|
|
24
|
+
message: S.String
|
|
25
25
|
}) {
|
|
26
26
|
constructor(messageOrObject, disableValidation) {
|
|
27
27
|
super(typeof messageOrObject === "object" ? messageOrObject : { message: messageOrObject }, disableValidation);
|
|
@@ -29,7 +29,7 @@ export class ServiceUnavailableError extends TaggedError()("ServiceUnavailableEr
|
|
|
29
29
|
}
|
|
30
30
|
/** @tsplus type ValidationError */
|
|
31
31
|
export class ValidationError extends TaggedError()("ValidationError", {
|
|
32
|
-
errors: S.
|
|
32
|
+
errors: S.Array(S.Unknown)
|
|
33
33
|
}) {
|
|
34
34
|
get message() {
|
|
35
35
|
return `Validation failed: ${this.errors.map((e) => JSON.stringify(e)).join(", ")}`;
|
|
@@ -37,7 +37,7 @@ export class ValidationError extends TaggedError()("ValidationError", {
|
|
|
37
37
|
}
|
|
38
38
|
/** @tsplus type NotLoggedInError */
|
|
39
39
|
export class NotLoggedInError extends TaggedError()("NotLoggedInError", {
|
|
40
|
-
message: S.optional(S.
|
|
40
|
+
message: S.optional(S.String)
|
|
41
41
|
}) {
|
|
42
42
|
constructor(messageOrObject, disableValidation) {
|
|
43
43
|
super(typeof messageOrObject === "object" ? messageOrObject : { message: messageOrObject }, disableValidation);
|
|
@@ -48,7 +48,7 @@ export class NotLoggedInError extends TaggedError()("NotLoggedInError", {
|
|
|
48
48
|
*/
|
|
49
49
|
/** @tsplus type LoginError */
|
|
50
50
|
export class LoginError extends TaggedError()("NotLoggedInError", {
|
|
51
|
-
message: S.optional(S.
|
|
51
|
+
message: S.optional(S.String)
|
|
52
52
|
}) {
|
|
53
53
|
constructor(messageOrObject, disableValidation) {
|
|
54
54
|
super(typeof messageOrObject === "object" ? messageOrObject : { message: messageOrObject }, disableValidation);
|
|
@@ -56,14 +56,14 @@ export class LoginError extends TaggedError()("NotLoggedInError", {
|
|
|
56
56
|
}
|
|
57
57
|
/** @tsplus type UnauthorizedError */
|
|
58
58
|
export class UnauthorizedError extends TaggedError()("UnauthorizedError", {
|
|
59
|
-
message: S.optional(S.
|
|
59
|
+
message: S.optional(S.String)
|
|
60
60
|
}) {
|
|
61
61
|
constructor(messageOrObject, disableValidation) {
|
|
62
62
|
super(typeof messageOrObject === "object" ? messageOrObject : { message: messageOrObject }, disableValidation);
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
/** @tsplus type OptimisticConcurrencyException */
|
|
66
|
-
export class OptimisticConcurrencyException extends TaggedError()("OptimisticConcurrencyException", { message: S.
|
|
66
|
+
export class OptimisticConcurrencyException extends TaggedError()("OptimisticConcurrencyException", { message: S.String }) {
|
|
67
67
|
details;
|
|
68
68
|
constructor(args, disableValidation) {
|
|
69
69
|
super("message" in args ? args : { message: `Existing ${args.type} ${args.id} record changed` }, disableValidation);
|
|
@@ -84,7 +84,7 @@ const GeneralErrors = [
|
|
|
84
84
|
ValidationError,
|
|
85
85
|
ServiceUnavailableError
|
|
86
86
|
];
|
|
87
|
-
export const SupportedErrors = S.
|
|
87
|
+
export const SupportedErrors = S.Union(...MutationOnlyErrors, ...GeneralErrors);
|
|
88
88
|
// ideal?
|
|
89
89
|
// export const QueryErrors = union({ ...GeneralErrors })
|
|
90
90
|
// .pipe(named("QueryErrors"))
|
package/dist/schema.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare const makeIs: <A extends {
|
|
|
10
10
|
export declare const makeIsAnyOf: <A extends {
|
|
11
11
|
_tag: string;
|
|
12
12
|
}, I, R>(schema: S.Schema<A, I, R>) => IsAny<A>;
|
|
13
|
-
export declare const
|
|
13
|
+
export declare const ExtendTaggedUnion: <A extends {
|
|
14
14
|
_tag: string;
|
|
15
15
|
}, I, R>(schema: S.Schema<A, I, R>) => S.Schema<A, I, R> & {
|
|
16
16
|
is: Is<A>;
|
|
@@ -30,7 +30,7 @@ export interface IsAny<A extends {
|
|
|
30
30
|
}> {
|
|
31
31
|
<Keys extends A["_tag"][]>(...keys: Keys): (a: A) => a is ExtractUnion<A, ElemType<Keys>>;
|
|
32
32
|
}
|
|
33
|
-
export declare const
|
|
33
|
+
export declare const TaggedUnion: <Members extends readonly S.Schema<{
|
|
34
34
|
_tag: string;
|
|
35
35
|
}, any, any>[]>(...a: Members) => S.Schema<S.Schema.Type<[...Members][number]>, S.Schema.Encoded<[...Members][number]>, S.Schema.Context<[...Members][number]>> & {
|
|
36
36
|
is: Is<S.Schema.Type<[...Members][number]>>;
|
package/dist/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,KAAK,KAAK,IAAI,MAAM,EAAE,KAAK,WAAW,IAAI,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACnG,OAAO,KAAK,CAAC,MAAM,oBAAoB,CAAA;AAIvC,cAAc,oBAAoB,CAAA;AAElC,eAAO,MAAM,KAAK,iHAQf,CAAA;AAEH,MAAM,MAAM,KAAK,GAAG,MAAM,CAAA;AAE1B,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,KAAK,KAAK,IAAI,MAAM,EAAE,KAAK,WAAW,IAAI,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACnG,OAAO,KAAK,CAAC,MAAM,oBAAoB,CAAA;AAIvC,cAAc,oBAAoB,CAAA;AAElC,eAAO,MAAM,KAAK,iHAQf,CAAA;AAEH,MAAM,MAAM,KAAK,GAAG,MAAM,CAAA;AAE1B,eAAO,M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O;;;CACb,CAAA;AAE7F,MAAM,MAAM,WAAW,GAAG,YAAY,CAAA"}
|
package/dist/schema.js
CHANGED
|
@@ -12,13 +12,14 @@ export const Email = S
|
|
|
12
12
|
export const PhoneNumber = S
|
|
13
13
|
.PhoneNumber
|
|
14
14
|
.pipe(S.annotations({
|
|
15
|
+
arbitrary: () => (fc) =>
|
|
15
16
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
16
|
-
|
|
17
|
+
fakerArb((faker) => faker.phone.number)(fc).map(PhoneNumber)
|
|
17
18
|
}), S.withDefaults);
|
|
18
19
|
export const makeIs = (schema) => {
|
|
19
20
|
if (S.AST.isUnion(schema.ast)) {
|
|
20
21
|
return schema.ast.types.reduce((acc, t) => {
|
|
21
|
-
if (S.AST.
|
|
22
|
+
if (S.AST.isTransformation(t)) {
|
|
22
23
|
if (S.AST.isDeclaration(t.to)) {
|
|
23
24
|
t = t.from;
|
|
24
25
|
}
|
|
@@ -52,6 +53,6 @@ export const makeIsAnyOf = (schema) => {
|
|
|
52
53
|
}
|
|
53
54
|
throw new Error("Unsupported");
|
|
54
55
|
};
|
|
55
|
-
export const
|
|
56
|
-
export const
|
|
57
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
56
|
+
export const ExtendTaggedUnion = (schema) => extendM(schema, (_) => ({ is: makeIs(_), isAnyOf: makeIsAnyOf(_) }));
|
|
57
|
+
export const TaggedUnion = (...a) => pipe(S.Union(...a), (_) => extendM(_, (_) => ({ is: makeIs(_), isAnyOf: makeIsAnyOf(_) })));
|
|
58
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2NoZW1hLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3NjaGVtYS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsTUFBTSxFQUFFLElBQUksRUFBRSxhQUFhLEVBQUUsTUFBTSxrQkFBa0Is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UMsRUFBRSxFQUFFLENBQUMsQ0FBQyxFQUFFLEVBQUUsRUFBRSxNQUFNLENBQUMsQ0FBQyxDQUFDLEVBQUUsT0FBTyxFQUFFLFdBQVcsQ0FBQyxDQUFDLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQTtBQVN6RSxNQUFNLENBQUMsTUFBTSxXQUFXLEdBQUcsQ0FBa0UsR0FBRyxDQUFVLEVBQUUsRUFBRSxDQUM1RyxJQUFJLENBQUMsQ0FBQyxDQUFDLEtBQUssQ0FBQyxHQUFHLENBQUMsQ0FBQyxFQUFFLENBQUMsQ0FBQyxFQUFFLEVBQUUsQ0FBQyxPQUFPLENBQUMsQ0FBQyxFQUFFLENBQUMsQ0FBQyxFQUFFLEVBQUUsQ0FBQyxDQUFDLEVBQUUsRUFBRSxFQUFFLE1BQU0sQ0FBQyxDQUFDLENBQUMsRUFBRSxPQUFPLEVBQUUsV0FBVyxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFDLENBQUEifQ==
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "effect-app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.203.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"ts-pattern": "^5.1.1",
|
|
13
13
|
"uuid": "^9.0.1",
|
|
14
14
|
"validator": "^13.11.0",
|
|
15
|
-
"@effect-app/core": "0.
|
|
16
|
-
"@effect-app/schema": "0.
|
|
15
|
+
"@effect-app/core": "0.170.0",
|
|
16
|
+
"@effect-app/schema": "0.221.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@babel/cli": "^7.24.1",
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
"fast-check": "~3.17.1",
|
|
25
25
|
"ts-node": "^10.9.2",
|
|
26
26
|
"typescript": "^5.4.5",
|
|
27
|
-
"vitest": "^1.
|
|
27
|
+
"vitest": "^1.5.0"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@effect/platform": "^0.48.
|
|
31
|
-
"effect": "^2.4.
|
|
32
|
-
"@effect/schema": "^0.
|
|
30
|
+
"@effect/platform": "^0.48.28",
|
|
31
|
+
"effect": "^2.4.19",
|
|
32
|
+
"@effect/schema": "^0.65.0"
|
|
33
33
|
},
|
|
34
34
|
"typesVersions": {
|
|
35
35
|
"*": {
|
package/src/Operations.ts
CHANGED
|
@@ -1,34 +1,35 @@
|
|
|
1
|
-
import * as S from "
|
|
1
|
+
import * as S from "@effect/Schema/Schema"
|
|
2
|
+
import * as S2 from "./schema.js"
|
|
2
3
|
|
|
3
|
-
export type OperationId =
|
|
4
|
-
export const OperationId =
|
|
4
|
+
export type OperationId = S2.StringId
|
|
5
|
+
export const OperationId = S2.StringId
|
|
5
6
|
|
|
6
|
-
export class OperationProgress extends
|
|
7
|
+
export class OperationProgress extends S2.ExtendedClass<
|
|
7
8
|
OperationProgress,
|
|
8
9
|
OperationProgress.From
|
|
9
10
|
>()({
|
|
10
|
-
completed:
|
|
11
|
-
total:
|
|
11
|
+
completed: S2.NonNegativeInt,
|
|
12
|
+
total: S2.NonNegativeInt
|
|
12
13
|
}) {}
|
|
13
14
|
|
|
14
|
-
export class Success extends
|
|
15
|
-
message:
|
|
15
|
+
export class Success extends S2.ExtendedTaggedClass<Success, Success.From>()("Success", {
|
|
16
|
+
message: S2.NullOr(S2.NonEmptyString2k).withDefault
|
|
16
17
|
}) {}
|
|
17
18
|
|
|
18
|
-
export class Failure extends
|
|
19
|
-
message:
|
|
19
|
+
export class Failure extends S2.ExtendedTaggedClass<Failure, Failure.From>()("Failure", {
|
|
20
|
+
message: S2.NullOr(S2.NonEmptyString2k).withDefault
|
|
20
21
|
}) {}
|
|
21
22
|
|
|
22
|
-
export const OperationResult =
|
|
23
|
+
export const OperationResult = S2.ExtendTaggedUnion(S.Union(Success, Failure))
|
|
23
24
|
export type OperationResult = S.Schema.Type<typeof OperationResult>
|
|
24
25
|
|
|
25
|
-
export class Operation extends
|
|
26
|
+
export class Operation extends S2.ExtendedClass<Operation, Operation.From>()({
|
|
26
27
|
id: OperationId,
|
|
27
|
-
title:
|
|
28
|
+
title: S2.NonEmptyString2k,
|
|
28
29
|
progress: S.optional(OperationProgress),
|
|
29
30
|
result: S.optional(OperationResult),
|
|
30
|
-
createdAt:
|
|
31
|
-
updatedAt:
|
|
31
|
+
createdAt: S2.Date.withDefault,
|
|
32
|
+
updatedAt: S2.NullOr(S.Date).withDefault
|
|
32
33
|
}) {}
|
|
33
34
|
|
|
34
35
|
// codegen:start {preset: model}
|
package/src/client/errors.ts
CHANGED
|
@@ -5,8 +5,8 @@ import { S } from "../lib.js"
|
|
|
5
5
|
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
6
6
|
// @ts-expect-error type not used
|
|
7
7
|
export class NotFoundError<ItemType = string> extends TaggedError<NotFoundError<ItemType>>()("NotFoundError", {
|
|
8
|
-
type: S.
|
|
9
|
-
id: S.
|
|
8
|
+
type: S.String,
|
|
9
|
+
id: S.Unknown
|
|
10
10
|
}) {
|
|
11
11
|
override get message() {
|
|
12
12
|
return `Didn't find ${this.type}#${JSON.stringify(this.id)}`
|
|
@@ -15,7 +15,7 @@ export class NotFoundError<ItemType = string> extends TaggedError<NotFoundError<
|
|
|
15
15
|
|
|
16
16
|
/** @tsplus type InvalidStateError */
|
|
17
17
|
export class InvalidStateError extends TaggedError<InvalidStateError>()("InvalidStateError", {
|
|
18
|
-
message: S.
|
|
18
|
+
message: S.String
|
|
19
19
|
}) {
|
|
20
20
|
constructor(messageOrObject: string | { message: string }, disableValidation?: boolean) {
|
|
21
21
|
super(typeof messageOrObject === "object" ? messageOrObject : { message: messageOrObject }, disableValidation)
|
|
@@ -24,7 +24,7 @@ export class InvalidStateError extends TaggedError<InvalidStateError>()("Invalid
|
|
|
24
24
|
|
|
25
25
|
/** @tsplus type ServiceUnavailableError */
|
|
26
26
|
export class ServiceUnavailableError extends TaggedError<ServiceUnavailableError>()("ServiceUnavailableError", {
|
|
27
|
-
message: S.
|
|
27
|
+
message: S.String
|
|
28
28
|
}) {
|
|
29
29
|
constructor(messageOrObject: string | { message: string }, disableValidation?: boolean) {
|
|
30
30
|
super(typeof messageOrObject === "object" ? messageOrObject : { message: messageOrObject }, disableValidation)
|
|
@@ -33,7 +33,7 @@ export class ServiceUnavailableError extends TaggedError<ServiceUnavailableError
|
|
|
33
33
|
|
|
34
34
|
/** @tsplus type ValidationError */
|
|
35
35
|
export class ValidationError extends TaggedError<ValidationError>()("ValidationError", {
|
|
36
|
-
errors: S.
|
|
36
|
+
errors: S.Array(S.Unknown)
|
|
37
37
|
}) {
|
|
38
38
|
override get message() {
|
|
39
39
|
return `Validation failed: ${this.errors.map((e) => JSON.stringify(e)).join(", ")}`
|
|
@@ -42,7 +42,7 @@ export class ValidationError extends TaggedError<ValidationError>()("ValidationE
|
|
|
42
42
|
|
|
43
43
|
/** @tsplus type NotLoggedInError */
|
|
44
44
|
export class NotLoggedInError extends TaggedError<NotLoggedInError>()("NotLoggedInError", {
|
|
45
|
-
message: S.optional(S.
|
|
45
|
+
message: S.optional(S.String)
|
|
46
46
|
}) {
|
|
47
47
|
constructor(messageOrObject?: string | { message?: string }, disableValidation?: boolean) {
|
|
48
48
|
super(typeof messageOrObject === "object" ? messageOrObject : { message: messageOrObject }, disableValidation)
|
|
@@ -54,7 +54,7 @@ export class NotLoggedInError extends TaggedError<NotLoggedInError>()("NotLogged
|
|
|
54
54
|
*/
|
|
55
55
|
/** @tsplus type LoginError */
|
|
56
56
|
export class LoginError extends TaggedError<LoginError>()("NotLoggedInError", {
|
|
57
|
-
message: S.optional(S.
|
|
57
|
+
message: S.optional(S.String)
|
|
58
58
|
}) {
|
|
59
59
|
constructor(messageOrObject?: string | { message?: string }, disableValidation?: boolean) {
|
|
60
60
|
super(typeof messageOrObject === "object" ? messageOrObject : { message: messageOrObject }, disableValidation)
|
|
@@ -63,7 +63,7 @@ export class LoginError extends TaggedError<LoginError>()("NotLoggedInError", {
|
|
|
63
63
|
|
|
64
64
|
/** @tsplus type UnauthorizedError */
|
|
65
65
|
export class UnauthorizedError extends TaggedError<UnauthorizedError>()("UnauthorizedError", {
|
|
66
|
-
message: S.optional(S.
|
|
66
|
+
message: S.optional(S.String)
|
|
67
67
|
}) {
|
|
68
68
|
constructor(messageOrObject?: string | { message?: string }, disableValidation?: boolean) {
|
|
69
69
|
super(typeof messageOrObject === "object" ? messageOrObject : { message: messageOrObject }, disableValidation)
|
|
@@ -80,7 +80,7 @@ type OptimisticConcurrencyDetails = {
|
|
|
80
80
|
/** @tsplus type OptimisticConcurrencyException */
|
|
81
81
|
export class OptimisticConcurrencyException extends TaggedError<OptimisticConcurrencyException>()(
|
|
82
82
|
"OptimisticConcurrencyException",
|
|
83
|
-
{ message: S.
|
|
83
|
+
{ message: S.String }
|
|
84
84
|
) {
|
|
85
85
|
readonly details?: OptimisticConcurrencyDetails
|
|
86
86
|
constructor(
|
|
@@ -108,7 +108,7 @@ const GeneralErrors = [
|
|
|
108
108
|
ServiceUnavailableError
|
|
109
109
|
] as const
|
|
110
110
|
|
|
111
|
-
export const SupportedErrors = S.
|
|
111
|
+
export const SupportedErrors = S.Union(
|
|
112
112
|
...MutationOnlyErrors,
|
|
113
113
|
...GeneralErrors
|
|
114
114
|
)
|
package/src/schema.ts
CHANGED
|
@@ -11,7 +11,7 @@ export const Email = S
|
|
|
11
11
|
.pipe(
|
|
12
12
|
S.annotations({
|
|
13
13
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
14
|
-
arbitrary: (): A.
|
|
14
|
+
arbitrary: (): A.LazyArbitrary<Email> => (fc) => fakerArb((faker) => faker.internet.exampleEmail)(fc).map(Email)
|
|
15
15
|
}),
|
|
16
16
|
S.withDefaults
|
|
17
17
|
)
|
|
@@ -22,8 +22,9 @@ export const PhoneNumber = S
|
|
|
22
22
|
.PhoneNumber
|
|
23
23
|
.pipe(
|
|
24
24
|
S.annotations({
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
arbitrary: (): A.LazyArbitrary<PhoneNumber> => (fc) =>
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
27
|
+
fakerArb((faker) => faker.phone.number)(fc).map(PhoneNumber)
|
|
27
28
|
}),
|
|
28
29
|
S.withDefaults
|
|
29
30
|
)
|
|
@@ -33,7 +34,7 @@ export const makeIs = <A extends { _tag: string }, I, R>(
|
|
|
33
34
|
) => {
|
|
34
35
|
if (S.AST.isUnion(schema.ast)) {
|
|
35
36
|
return schema.ast.types.reduce((acc, t) => {
|
|
36
|
-
if (S.AST.
|
|
37
|
+
if (S.AST.isTransformation(t)) {
|
|
37
38
|
if (S.AST.isDeclaration(t.to)) {
|
|
38
39
|
t = t.from
|
|
39
40
|
} else {
|
|
@@ -70,7 +71,7 @@ export const makeIsAnyOf = <A extends { _tag: string }, I, R>(
|
|
|
70
71
|
throw new Error("Unsupported")
|
|
71
72
|
}
|
|
72
73
|
|
|
73
|
-
export const
|
|
74
|
+
export const ExtendTaggedUnion = <A extends { _tag: string }, I, R>(
|
|
74
75
|
schema: S.Schema<A, I, R>
|
|
75
76
|
) => extendM(schema, (_) => ({ is: makeIs(_), isAnyOf: makeIsAnyOf(_) }))
|
|
76
77
|
|
|
@@ -81,7 +82,7 @@ export interface IsAny<A extends { _tag: string }> {
|
|
|
81
82
|
<Keys extends A["_tag"][]>(...keys: Keys): (a: A) => a is ExtractUnion<A, ElemType<Keys>>
|
|
82
83
|
}
|
|
83
84
|
|
|
84
|
-
export const
|
|
85
|
-
pipe(S.
|
|
85
|
+
export const TaggedUnion = <Members extends readonly S.Schema<{ _tag: string }, any, any>[]>(...a: Members) =>
|
|
86
|
+
pipe(S.Union(...a), (_) => extendM(_, (_) => ({ is: makeIs(_), isAnyOf: makeIsAnyOf(_) })))
|
|
86
87
|
|
|
87
88
|
export type PhoneNumber = PhoneNumberT
|
package/test/schema.test.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { JSONSchema } from "@effect/schema"
|
|
|
3
3
|
import { ReadonlyArray, S } from "effect-app"
|
|
4
4
|
import { test } from "vitest"
|
|
5
5
|
|
|
6
|
-
const A = S.
|
|
6
|
+
const A = S.Struct({ a: S.NonEmptyString255, email: S.NullOr(S.Email) })
|
|
7
7
|
test("works", () => {
|
|
8
8
|
console.log(S.StringId.make())
|
|
9
9
|
// console.log(generateFromArbitrary(S.A.make(A)).value)
|