@evolu/common 8.2.0 → 8.3.1
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/dist/src/Function.d.ts +1 -0
- package/dist/src/Function.d.ts.map +1 -1
- package/dist/src/Http.d.ts +9 -0
- package/dist/src/Http.d.ts.map +1 -1
- package/dist/src/Object.d.ts +1 -0
- package/dist/src/Object.d.ts.map +1 -1
- package/dist/src/RefCount.d.ts +1 -0
- package/dist/src/RefCount.d.ts.map +1 -1
- package/dist/src/Relation.d.ts +2 -0
- package/dist/src/Relation.d.ts.map +1 -1
- package/dist/src/Resource.d.ts +1 -0
- package/dist/src/Resource.d.ts.map +1 -1
- package/dist/src/Result.d.ts +383 -548
- package/dist/src/Result.d.ts.map +1 -1
- package/dist/src/Result.js +296 -46
- package/dist/src/StackTrace.d.ts +1 -0
- package/dist/src/StackTrace.d.ts.map +1 -1
- package/dist/src/Task.d.ts +985 -1069
- package/dist/src/Task.d.ts.map +1 -1
- package/dist/src/Task.js +1007 -156
- package/dist/src/Time.d.ts +1 -0
- package/dist/src/Time.d.ts.map +1 -1
- package/dist/src/Type.d.ts +1322 -793
- package/dist/src/Type.d.ts.map +1 -1
- package/dist/src/Type.js +1192 -244
- package/dist/src/intl/_en.d.ts +126 -0
- package/dist/src/intl/_en.d.ts.map +1 -0
- package/dist/src/intl/_en.js +267 -0
- package/dist/src/intl/ar.d.ts +117 -0
- package/dist/src/intl/ar.d.ts.map +1 -0
- package/dist/src/intl/ar.js +245 -0
- package/dist/src/intl/bn.d.ts +117 -0
- package/dist/src/intl/bn.d.ts.map +1 -0
- package/dist/src/intl/bn.js +258 -0
- package/dist/src/intl/ca.d.ts +117 -0
- package/dist/src/intl/ca.d.ts.map +1 -0
- package/dist/src/intl/ca.js +258 -0
- package/dist/src/intl/cs.d.ts +20 -7
- package/dist/src/intl/cs.d.ts.map +1 -1
- package/dist/src/intl/cs.js +54 -27
- package/dist/src/intl/da.d.ts +117 -0
- package/dist/src/intl/da.d.ts.map +1 -0
- package/dist/src/intl/da.js +258 -0
- package/dist/src/intl/de.d.ts +117 -0
- package/dist/src/intl/de.d.ts.map +1 -0
- package/dist/src/intl/de.js +258 -0
- package/dist/src/intl/el.d.ts +117 -0
- package/dist/src/intl/el.d.ts.map +1 -0
- package/dist/src/intl/el.js +265 -0
- package/dist/src/intl/es.d.ts +117 -0
- package/dist/src/intl/es.d.ts.map +1 -0
- package/dist/src/intl/es.js +258 -0
- package/dist/src/intl/fa.d.ts +117 -0
- package/dist/src/intl/fa.d.ts.map +1 -0
- package/dist/src/intl/fa.js +258 -0
- package/dist/src/intl/fi.d.ts +117 -0
- package/dist/src/intl/fi.d.ts.map +1 -0
- package/dist/src/intl/fi.js +258 -0
- package/dist/src/intl/fil.d.ts +117 -0
- package/dist/src/intl/fil.d.ts.map +1 -0
- package/dist/src/intl/fil.js +258 -0
- package/dist/src/intl/fr.d.ts +117 -0
- package/dist/src/intl/fr.d.ts.map +1 -0
- package/dist/src/intl/fr.js +258 -0
- package/dist/src/intl/he.d.ts +117 -0
- package/dist/src/intl/he.d.ts.map +1 -0
- package/dist/src/intl/he.js +258 -0
- package/dist/src/intl/hi.d.ts +117 -0
- package/dist/src/intl/hi.d.ts.map +1 -0
- package/dist/src/intl/hi.js +258 -0
- package/dist/src/intl/hr.d.ts +117 -0
- package/dist/src/intl/hr.d.ts.map +1 -0
- package/dist/src/intl/hr.js +265 -0
- package/dist/src/intl/hu.d.ts +63 -0
- package/dist/src/intl/hu.d.ts.map +1 -0
- package/dist/src/intl/hu.js +204 -0
- package/dist/src/intl/id.d.ts +117 -0
- package/dist/src/intl/id.d.ts.map +1 -0
- package/dist/src/intl/id.js +258 -0
- package/dist/src/intl/index.d.ts +42 -0
- package/dist/src/intl/index.d.ts.map +1 -1
- package/dist/src/intl/index.js +42 -0
- package/dist/src/intl/it.d.ts +117 -0
- package/dist/src/intl/it.d.ts.map +1 -0
- package/dist/src/intl/it.js +258 -0
- package/dist/src/intl/ja.d.ts +117 -0
- package/dist/src/intl/ja.d.ts.map +1 -0
- package/dist/src/intl/ja.js +258 -0
- package/dist/src/intl/ko.d.ts +117 -0
- package/dist/src/intl/ko.d.ts.map +1 -0
- package/dist/src/intl/ko.js +258 -0
- package/dist/src/intl/ml.d.ts +117 -0
- package/dist/src/intl/ml.d.ts.map +1 -0
- package/dist/src/intl/ml.js +258 -0
- package/dist/src/intl/mr.d.ts +117 -0
- package/dist/src/intl/mr.d.ts.map +1 -0
- package/dist/src/intl/mr.js +258 -0
- package/dist/src/intl/ms.d.ts +117 -0
- package/dist/src/intl/ms.d.ts.map +1 -0
- package/dist/src/intl/ms.js +245 -0
- package/dist/src/intl/nb.d.ts +63 -0
- package/dist/src/intl/nb.d.ts.map +1 -0
- package/dist/src/intl/nb.js +191 -0
- package/dist/src/intl/nl.d.ts +117 -0
- package/dist/src/intl/nl.d.ts.map +1 -0
- package/dist/src/intl/nl.js +258 -0
- package/dist/src/intl/pa.d.ts +117 -0
- package/dist/src/intl/pa.d.ts.map +1 -0
- package/dist/src/intl/pa.js +258 -0
- package/dist/src/intl/pl.d.ts +117 -0
- package/dist/src/intl/pl.d.ts.map +1 -0
- package/dist/src/intl/pl.js +242 -0
- package/dist/src/intl/pt-BR.d.ts +117 -0
- package/dist/src/intl/pt-BR.d.ts.map +1 -0
- package/dist/src/intl/pt-BR.js +258 -0
- package/dist/src/intl/pt.d.ts +117 -0
- package/dist/src/intl/pt.d.ts.map +1 -0
- package/dist/src/intl/pt.js +246 -0
- package/dist/src/intl/ro.d.ts +117 -0
- package/dist/src/intl/ro.d.ts.map +1 -0
- package/dist/src/intl/ro.js +258 -0
- package/dist/src/intl/sk.d.ts +117 -0
- package/dist/src/intl/sk.d.ts.map +1 -0
- package/dist/src/intl/sk.js +244 -0
- package/dist/src/intl/sl.d.ts +117 -0
- package/dist/src/intl/sl.d.ts.map +1 -0
- package/dist/src/intl/sl.js +258 -0
- package/dist/src/intl/sv.d.ts +117 -0
- package/dist/src/intl/sv.d.ts.map +1 -0
- package/dist/src/intl/sv.js +258 -0
- package/dist/src/intl/sw.d.ts +63 -0
- package/dist/src/intl/sw.d.ts.map +1 -0
- package/dist/src/intl/sw.js +191 -0
- package/dist/src/intl/ta.d.ts +117 -0
- package/dist/src/intl/ta.d.ts.map +1 -0
- package/dist/src/intl/ta.js +258 -0
- package/dist/src/intl/te.d.ts +117 -0
- package/dist/src/intl/te.d.ts.map +1 -0
- package/dist/src/intl/te.js +258 -0
- package/dist/src/intl/th.d.ts +117 -0
- package/dist/src/intl/th.d.ts.map +1 -0
- package/dist/src/intl/th.js +258 -0
- package/dist/src/intl/tr.d.ts +117 -0
- package/dist/src/intl/tr.d.ts.map +1 -0
- package/dist/src/intl/tr.js +255 -0
- package/dist/src/intl/uk.d.ts +117 -0
- package/dist/src/intl/uk.d.ts.map +1 -0
- package/dist/src/intl/uk.js +258 -0
- package/dist/src/intl/ur.d.ts +117 -0
- package/dist/src/intl/ur.d.ts.map +1 -0
- package/dist/src/intl/ur.js +245 -0
- package/dist/src/intl/vi.d.ts +117 -0
- package/dist/src/intl/vi.d.ts.map +1 -0
- package/dist/src/intl/vi.js +255 -0
- package/dist/src/intl/zh-CN.d.ts +117 -0
- package/dist/src/intl/zh-CN.d.ts.map +1 -0
- package/dist/src/intl/zh-CN.js +258 -0
- package/dist/src/intl/zh-TW.d.ts +117 -0
- package/dist/src/intl/zh-TW.d.ts.map +1 -0
- package/dist/src/intl/zh-TW.js +258 -0
- package/dist/src/local-first/Owner.d.ts +156 -62
- package/dist/src/local-first/Owner.d.ts.map +1 -1
- package/dist/src/local-first/Owner.js +119 -20
- package/package.json +1 -1
- package/src/Function.ts +2 -0
- package/src/Http.ts +9 -0
- package/src/Object.ts +2 -0
- package/src/RefCount.ts +2 -0
- package/src/Relation.ts +4 -0
- package/src/Resource.ts +2 -0
- package/src/Result.ts +397 -560
- package/src/StackTrace.ts +2 -0
- package/src/Task.ts +1143 -1222
- package/src/Time.ts +2 -0
- package/src/Type.ts +1759 -794
- package/src/intl/_en.ts +497 -0
- package/src/intl/ar.ts +417 -0
- package/src/intl/bn.ts +486 -0
- package/src/intl/ca.ts +488 -0
- package/src/intl/cs.ts +95 -31
- package/src/intl/da.ts +488 -0
- package/src/intl/de.ts +488 -0
- package/src/intl/el.ts +494 -0
- package/src/intl/es.ts +488 -0
- package/src/intl/fa.ts +487 -0
- package/src/intl/fi.ts +487 -0
- package/src/intl/fil.ts +488 -0
- package/src/intl/fr.ts +488 -0
- package/src/intl/he.ts +486 -0
- package/src/intl/hi.ts +487 -0
- package/src/intl/hr.ts +494 -0
- package/src/intl/hu.ts +387 -0
- package/src/intl/id.ts +487 -0
- package/src/intl/index.ts +42 -0
- package/src/intl/it.ts +488 -0
- package/src/intl/ja.ts +488 -0
- package/src/intl/ko.ts +487 -0
- package/src/intl/ml.ts +487 -0
- package/src/intl/mr.ts +487 -0
- package/src/intl/ms.ts +410 -0
- package/src/intl/nb.ts +364 -0
- package/src/intl/nl.ts +488 -0
- package/src/intl/pa.ts +487 -0
- package/src/intl/pl.ts +450 -0
- package/src/intl/pt-BR.ts +487 -0
- package/src/intl/pt.ts +424 -0
- package/src/intl/ro.ts +488 -0
- package/src/intl/sk.ts +412 -0
- package/src/intl/sl.ts +487 -0
- package/src/intl/sv.ts +488 -0
- package/src/intl/sw.ts +324 -0
- package/src/intl/ta.ts +487 -0
- package/src/intl/te.ts +487 -0
- package/src/intl/th.ts +484 -0
- package/src/intl/tr.ts +487 -0
- package/src/intl/uk.ts +488 -0
- package/src/intl/ur.ts +410 -0
- package/src/intl/vi.ts +435 -0
- package/src/intl/zh-CN.ts +482 -0
- package/src/intl/zh-TW.ts +482 -0
- package/src/local-first/Owner.ts +156 -62
package/dist/src/Result.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Result.d.ts","sourceRoot":"","sources":["../../src/Result.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Result.d.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,EAAE,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/src/Result.js
CHANGED
|
@@ -1,5 +1,190 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* ## Intro
|
|
3
|
+
*
|
|
4
|
+
* Type-safe error handling with {@link Result}.
|
|
5
|
+
*
|
|
6
|
+
* The problem with exceptions in JavaScript is that a caught value is always of
|
|
7
|
+
* unknown type. We can't be sure all errors have been handled because the
|
|
8
|
+
* TypeScript compiler can't tell us what might be thrown — we can't use
|
|
9
|
+
* {@link exhaustiveCheck}.
|
|
10
|
+
*
|
|
11
|
+
* Languages like Rust and Haskell model recoverable failures with types such as
|
|
12
|
+
* `Result` and `Either`, making errors part of the return type.
|
|
13
|
+
*
|
|
14
|
+
* TypeScript can express the same pattern with discriminated unions of plain
|
|
15
|
+
* objects. In Evolu, domain error interfaces extend {@link Typed} to avoid
|
|
16
|
+
* repeating the literal `type` discriminant.
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* import {
|
|
20
|
+
* err,
|
|
21
|
+
* exhaustiveCheck,
|
|
22
|
+
* type Result,
|
|
23
|
+
* type Typed,
|
|
24
|
+
* } from "@evolu/common";
|
|
25
|
+
*
|
|
26
|
+
* // TypeScript can't know what was thrown.
|
|
27
|
+
* try {
|
|
28
|
+
* throw new Error("Not found");
|
|
29
|
+
* } catch (error) {
|
|
30
|
+
* expectTypeOf(error).toEqualTypeOf<unknown>();
|
|
31
|
+
* }
|
|
32
|
+
*
|
|
33
|
+
* // With Result, errors are part of the return type.
|
|
34
|
+
* const doSomething = (): Result<
|
|
35
|
+
* number,
|
|
36
|
+
* InvalidInputError | NotFoundError
|
|
37
|
+
* > => err({ type: "NotFound" });
|
|
38
|
+
*
|
|
39
|
+
* interface InvalidInputError extends Typed<"InvalidInput"> {}
|
|
40
|
+
*
|
|
41
|
+
* interface NotFoundError extends Typed<"NotFound"> {}
|
|
42
|
+
*
|
|
43
|
+
* // With Result, the error type is known and exhaustiveCheck works.
|
|
44
|
+
* // If we add another error type, TypeScript tells us it isn't handled.
|
|
45
|
+
* const result = doSomething();
|
|
46
|
+
* if (!result.ok) {
|
|
47
|
+
* switch (result.error.type) {
|
|
48
|
+
* case "NotFound":
|
|
49
|
+
* expect(result.error).toEqual({ type: "NotFound" });
|
|
50
|
+
* break;
|
|
51
|
+
* case "InvalidInput":
|
|
52
|
+
* expect(result.error).toEqual({ type: "InvalidInput" });
|
|
53
|
+
* break;
|
|
54
|
+
* default:
|
|
55
|
+
* exhaustiveCheck(result.error);
|
|
56
|
+
* }
|
|
57
|
+
* }
|
|
58
|
+
* expectErr(result, { type: "NotFound" });
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* A `Result` is either {@link Ok} (success with a value) or {@link Err} (failure
|
|
62
|
+
* with an error). Create them with {@link ok} and {@link err}.
|
|
63
|
+
*
|
|
64
|
+
* ```ts
|
|
65
|
+
* type Result<T, E = never> = Ok<T> | Err<E>;
|
|
66
|
+
*
|
|
67
|
+
* interface Ok<T> {
|
|
68
|
+
* readonly ok: true;
|
|
69
|
+
* readonly value: T;
|
|
70
|
+
* }
|
|
71
|
+
*
|
|
72
|
+
* interface Err<E> {
|
|
73
|
+
* readonly ok: false;
|
|
74
|
+
* readonly error: E;
|
|
75
|
+
* }
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* Use {@link trySync} and {@link tryAsync} to intentionally convert thrown values
|
|
79
|
+
* and Promise rejections into typed, recoverable errors represented by
|
|
80
|
+
* `Result`.
|
|
81
|
+
*
|
|
82
|
+
* Do not wrap every API that throws or rejects in `Result`. If an error is
|
|
83
|
+
* unrecoverable and the caller has no meaningful fallback, let it propagate.
|
|
84
|
+
*
|
|
85
|
+
* Since `Result` is a plain object, imperative code works naturally.
|
|
86
|
+
*
|
|
87
|
+
* ```ts
|
|
88
|
+
* import { ok, type Result, type Typed } from "@evolu/common";
|
|
89
|
+
*
|
|
90
|
+
* interface User {
|
|
91
|
+
* readonly id: string;
|
|
92
|
+
* }
|
|
93
|
+
*
|
|
94
|
+
* const getUser = (): Result<User, UserNotFoundError> =>
|
|
95
|
+
* ok({ id: "user-1" });
|
|
96
|
+
*
|
|
97
|
+
* interface UserNotFoundError extends Typed<"UserNotFound"> {}
|
|
98
|
+
*
|
|
99
|
+
* interface Profile {
|
|
100
|
+
* readonly userId: string;
|
|
101
|
+
* }
|
|
102
|
+
*
|
|
103
|
+
* const getProfile = (
|
|
104
|
+
* userId: string,
|
|
105
|
+
* ): Result<Profile, ProfileNotFoundError> => ok({ userId });
|
|
106
|
+
*
|
|
107
|
+
* interface ProfileNotFoundError extends Typed<"ProfileNotFound"> {}
|
|
108
|
+
*
|
|
109
|
+
* const getCurrentProfile = (): Result<
|
|
110
|
+
* Profile,
|
|
111
|
+
* UserNotFoundError | ProfileNotFoundError
|
|
112
|
+
* > => {
|
|
113
|
+
* const user = getUser();
|
|
114
|
+
* if (!user.ok) return user;
|
|
115
|
+
*
|
|
116
|
+
* return getProfile(user.value.id);
|
|
117
|
+
* };
|
|
118
|
+
*
|
|
119
|
+
* const profile = getCurrentProfile();
|
|
120
|
+
* expectTypeOf(profile).toEqualTypeOf<
|
|
121
|
+
* Result<Profile, UserNotFoundError | ProfileNotFoundError>
|
|
122
|
+
* >();
|
|
123
|
+
* expectOk(profile, { userId: "user-1" });
|
|
124
|
+
* ```
|
|
125
|
+
*
|
|
126
|
+
* Note `user` and `profile` are named after their success values, not after the
|
|
127
|
+
* Result (`userResult`, `profileResult`).
|
|
128
|
+
*
|
|
129
|
+
* If a Result has no success value, name it `result`. For several such
|
|
130
|
+
* operations, use {@link allResult} with `{ collect: false }`.
|
|
131
|
+
*
|
|
132
|
+
* ## Unrecoverable errors
|
|
133
|
+
*
|
|
134
|
+
* Unrecoverable errors are failures the application can't handle meaningfully.
|
|
135
|
+
* For example, a database failure is unrecoverable when the application has no
|
|
136
|
+
* useful fallback, retry, or degraded mode.
|
|
137
|
+
*
|
|
138
|
+
* Do not turn such failures into `Result` merely because the underlying API
|
|
139
|
+
* throws or rejects. Let the exception or Promise rejection propagate to the
|
|
140
|
+
* top-level handler so the application stops instead of continuing in a
|
|
141
|
+
* potentially invalid state.
|
|
142
|
+
*
|
|
143
|
+
* In Evolu apps, the root {@link Run} reports defects and the platform lifecycle
|
|
144
|
+
* API owns application shutdown. For example, `@evolu/nodejs` provides
|
|
145
|
+
* {@link @evolu/nodejs!runMain | runMain}.
|
|
146
|
+
*
|
|
147
|
+
* ## FAQ
|
|
148
|
+
*
|
|
149
|
+
* ### Is Result expensive?
|
|
150
|
+
*
|
|
151
|
+
* Wrapping a value in Result creates one small plain object and is very cheap.
|
|
152
|
+
* Its cost is usually worth considering only when a performance-critical loop
|
|
153
|
+
* creates millions of Results. Use Result by default; if profiling identifies
|
|
154
|
+
* such a loop as a bottleneck, benchmark the complete workload before
|
|
155
|
+
* optimizing it.
|
|
156
|
+
*
|
|
157
|
+
* ### Why not generators?
|
|
158
|
+
*
|
|
159
|
+
* Generator-based APIs make sequential workflows more concise: `yield*`
|
|
160
|
+
* combines error propagation (roughly replacing `if (!result.ok) return
|
|
161
|
+
* result`) with unwrapping the success value. That doesn't come for free.
|
|
162
|
+
* Supporting direct `yield*` requires adding iterator behavior to every Result;
|
|
163
|
+
* otherwise every use needs an adapter. That makes Result more than plain
|
|
164
|
+
* structural data: after serialization, its iterator behavior must be restored
|
|
165
|
+
* before direct `yield*` works. Generator machinery also makes control flow,
|
|
166
|
+
* debugger stepping, and stack traces less direct while adding runtime
|
|
167
|
+
* overhead. Evolu instead keeps Result as plain data and makes error
|
|
168
|
+
* propagation explicit. With AI, explicit checks are cheap to write.
|
|
169
|
+
*
|
|
170
|
+
* Generators do not make accidental omission impossible: a function returning a
|
|
171
|
+
* lazy operation can be called without composing the returned value with
|
|
172
|
+
* `yield*`, leaving the operation out of the workflow, just as a
|
|
173
|
+
* Result-returning function can be called and its Result ignored. Dedicated
|
|
174
|
+
* tooling can detect these omissions, but that safety comes from the tooling,
|
|
175
|
+
* not generator syntax itself.
|
|
176
|
+
*
|
|
177
|
+
* The intended way to write Evolu code is with test-driven development (TDD).
|
|
178
|
+
* Tests document the intended behavior and serve as its runnable specification,
|
|
179
|
+
* including failure paths. AI makes writing and maintaining those tests cheap.
|
|
180
|
+
* {@link exhaustiveCheck} complements tests by having TypeScript report newly
|
|
181
|
+
* added error variants.
|
|
182
|
+
*
|
|
183
|
+
* ### What if a function doesn't return a value on success?
|
|
184
|
+
*
|
|
185
|
+
* Use `Result<void, E>` and return `ok()` (no argument). Don't return
|
|
186
|
+
* `ok(true)`, `ok("success")`, or `ok("done")` — `ok()` already signals
|
|
187
|
+
* success; redundant values add noise.
|
|
3
188
|
*
|
|
4
189
|
* @module
|
|
5
190
|
*/
|
|
@@ -14,14 +199,71 @@ export function ok(value) {
|
|
|
14
199
|
}
|
|
15
200
|
/** Cache ok() and ok(undefined) to avoid repeated allocations. */
|
|
16
201
|
const okVoid = { ok: true, value: undefined };
|
|
17
|
-
/**
|
|
202
|
+
/**
|
|
203
|
+
* Creates an {@link Err} result.
|
|
204
|
+
*
|
|
205
|
+
* @group Core
|
|
206
|
+
*/
|
|
18
207
|
export const err = (error) => ({ ok: false, error });
|
|
19
|
-
/**
|
|
208
|
+
/**
|
|
209
|
+
* Type guard for {@link Ok} results.
|
|
210
|
+
*
|
|
211
|
+
* ### Example
|
|
212
|
+
*
|
|
213
|
+
* ```ts
|
|
214
|
+
* import {
|
|
215
|
+
* isOk,
|
|
216
|
+
* ok,
|
|
217
|
+
* type Ok,
|
|
218
|
+
* type Result,
|
|
219
|
+
* type Typed,
|
|
220
|
+
* } from "@evolu/common";
|
|
221
|
+
*
|
|
222
|
+
* const getCount = (): Result<number, CountUnavailableError> => ok(2);
|
|
223
|
+
*
|
|
224
|
+
* interface CountUnavailableError extends Typed<"CountUnavailable"> {}
|
|
225
|
+
*
|
|
226
|
+
* const count = getCount();
|
|
227
|
+
* if (isOk(count)) {
|
|
228
|
+
* expectTypeOf(count).toEqualTypeOf<Ok<number>>();
|
|
229
|
+
* expect(count.value).toBe(2);
|
|
230
|
+
* }
|
|
231
|
+
* ```
|
|
232
|
+
*
|
|
233
|
+
* @group Guards
|
|
234
|
+
*/
|
|
20
235
|
export const isOk = (result) => result.ok;
|
|
21
|
-
/**
|
|
236
|
+
/**
|
|
237
|
+
* Type guard for {@link Err} results.
|
|
238
|
+
*
|
|
239
|
+
* ### Example
|
|
240
|
+
*
|
|
241
|
+
* ```ts
|
|
242
|
+
* import {
|
|
243
|
+
* err,
|
|
244
|
+
* isErr,
|
|
245
|
+
* type Err,
|
|
246
|
+
* type Result,
|
|
247
|
+
* type Typed,
|
|
248
|
+
* } from "@evolu/common";
|
|
249
|
+
*
|
|
250
|
+
* const getCount = (): Result<number, CountUnavailableError> =>
|
|
251
|
+
* err({ type: "CountUnavailable" });
|
|
252
|
+
*
|
|
253
|
+
* interface CountUnavailableError extends Typed<"CountUnavailable"> {}
|
|
254
|
+
*
|
|
255
|
+
* const count = getCount();
|
|
256
|
+
* if (isErr(count)) {
|
|
257
|
+
* expectTypeOf(count).toEqualTypeOf<Err<CountUnavailableError>>();
|
|
258
|
+
* expect(count.error).toEqual({ type: "CountUnavailable" });
|
|
259
|
+
* }
|
|
260
|
+
* ```
|
|
261
|
+
*
|
|
262
|
+
* @group Guards
|
|
263
|
+
*/
|
|
22
264
|
export const isErr = (result) => !result.ok;
|
|
23
265
|
/**
|
|
24
|
-
* Gets the value from an
|
|
266
|
+
* Gets the value from an {@link Ok}, or throws for an {@link Err}.
|
|
25
267
|
*
|
|
26
268
|
* Use this where failure should crash the current flow instead of being handled
|
|
27
269
|
* locally.
|
|
@@ -29,8 +271,8 @@ export const isErr = (result) => !result.ok;
|
|
|
29
271
|
* **When to use:**
|
|
30
272
|
*
|
|
31
273
|
* - Application startup or composition-root setup where errors must stop the
|
|
32
|
-
* program immediately. In Evolu apps, the root Run reports the defect
|
|
33
|
-
* platform lifecycle API handles shutdown.
|
|
274
|
+
* program immediately. In Evolu apps, the root {@link Run} reports the defect
|
|
275
|
+
* and the platform lifecycle API handles shutdown.
|
|
34
276
|
* - Module-level constants
|
|
35
277
|
* - Test setup with values that are expected to be valid
|
|
36
278
|
*
|
|
@@ -40,33 +282,41 @@ export const isErr = (result) => !result.ok;
|
|
|
40
282
|
* ### Example
|
|
41
283
|
*
|
|
42
284
|
* ```ts
|
|
43
|
-
* import {
|
|
285
|
+
* import {
|
|
286
|
+
* err,
|
|
287
|
+
* getOrThrow,
|
|
288
|
+
* ok,
|
|
289
|
+
* type Result,
|
|
290
|
+
* type Typed,
|
|
291
|
+
* } from "@evolu/common";
|
|
44
292
|
*
|
|
45
293
|
* interface Config {
|
|
46
294
|
* readonly port: number;
|
|
47
295
|
* }
|
|
48
|
-
*
|
|
49
|
-
* readonly type: "InvalidConfigError";
|
|
50
|
-
* }
|
|
296
|
+
*
|
|
51
297
|
* const loadConfig = (): Result<Config, InvalidConfigError> =>
|
|
52
298
|
* ok({ port: 3000 });
|
|
53
299
|
*
|
|
300
|
+
* interface InvalidConfigError extends Typed<"InvalidConfig"> {}
|
|
301
|
+
*
|
|
54
302
|
* // At app startup, crash if the config is invalid.
|
|
55
303
|
* const config = getOrThrow(loadConfig());
|
|
56
304
|
* expectTypeOf(config).toEqualTypeOf<Config>();
|
|
57
305
|
* expect(config).toEqual({ port: 3000 });
|
|
58
306
|
*
|
|
59
307
|
* try {
|
|
60
|
-
* getOrThrow(err({ type: "
|
|
308
|
+
* getOrThrow(err({ type: "InvalidConfig" }));
|
|
61
309
|
* assert.fail("Expected getOrThrow to throw");
|
|
62
310
|
* } catch (error) {
|
|
63
311
|
* assert(error instanceof Error);
|
|
64
312
|
* expect(error.message).toBe("getOrThrow");
|
|
65
|
-
* expect(error.cause).toEqual({ type: "
|
|
313
|
+
* expect(error.cause).toEqual({ type: "InvalidConfig" });
|
|
66
314
|
* }
|
|
67
315
|
* ```
|
|
68
316
|
*
|
|
69
317
|
* Throws: `Error` with the original error attached as `cause`.
|
|
318
|
+
*
|
|
319
|
+
* @group Unwrapping
|
|
70
320
|
*/
|
|
71
321
|
export const getOrThrow = (result) => {
|
|
72
322
|
if (result.ok) {
|
|
@@ -77,8 +327,7 @@ export const getOrThrow = (result) => {
|
|
|
77
327
|
}
|
|
78
328
|
};
|
|
79
329
|
/**
|
|
80
|
-
* Gets the value from an
|
|
81
|
-
* `Err`.
|
|
330
|
+
* Gets the value from an {@link Ok}, or returns `null` for an {@link Err}.
|
|
82
331
|
*
|
|
83
332
|
* **Intended usage:**
|
|
84
333
|
*
|
|
@@ -89,16 +338,22 @@ export const getOrThrow = (result) => {
|
|
|
89
338
|
* ### Example
|
|
90
339
|
*
|
|
91
340
|
* ```ts
|
|
92
|
-
* import {
|
|
341
|
+
* import {
|
|
342
|
+
* err,
|
|
343
|
+
* getOrNull,
|
|
344
|
+
* ok,
|
|
345
|
+
* type Result,
|
|
346
|
+
* type Typed,
|
|
347
|
+
* } from "@evolu/common";
|
|
93
348
|
*
|
|
94
349
|
* interface User {
|
|
95
350
|
* readonly id: string;
|
|
96
351
|
* }
|
|
97
|
-
*
|
|
98
|
-
* readonly type: "UserNotFoundError";
|
|
99
|
-
* }
|
|
352
|
+
*
|
|
100
353
|
* const findUser = (id: string): Result<User, UserNotFoundError> =>
|
|
101
|
-
* id === "user-1" ? ok({ id }) : err({ type: "
|
|
354
|
+
* id === "user-1" ? ok({ id }) : err({ type: "UserNotFound" });
|
|
355
|
+
*
|
|
356
|
+
* interface UserNotFoundError extends Typed<"UserNotFound"> {}
|
|
102
357
|
*
|
|
103
358
|
* // For APIs that expect T | null.
|
|
104
359
|
* const user = getOrNull(findUser("user-1"));
|
|
@@ -108,6 +363,8 @@ export const getOrThrow = (result) => {
|
|
|
108
363
|
* expect(user).toEqual({ id: "user-1" });
|
|
109
364
|
* expect(missingUser).toBeNull();
|
|
110
365
|
* ```
|
|
366
|
+
*
|
|
367
|
+
* @group Unwrapping
|
|
111
368
|
*/
|
|
112
369
|
export const getOrNull = (result) => result.ok ? result.value : null;
|
|
113
370
|
/**
|
|
@@ -127,6 +384,8 @@ export const getOrNull = (result) => result.ok ? result.value : null;
|
|
|
127
384
|
* expectTypeOf(count).toEqualTypeOf<number>();
|
|
128
385
|
* expect(count).toBe(2);
|
|
129
386
|
* ```
|
|
387
|
+
*
|
|
388
|
+
* @group Unwrapping
|
|
130
389
|
*/
|
|
131
390
|
export const getOk = (result) => {
|
|
132
391
|
assert(result.ok, "Expected Ok result.");
|
|
@@ -166,44 +425,35 @@ export function done(value) {
|
|
|
166
425
|
* ### Example
|
|
167
426
|
*
|
|
168
427
|
* ```ts
|
|
169
|
-
* import {
|
|
428
|
+
* import {
|
|
429
|
+
* flatMapResult,
|
|
430
|
+
* ok,
|
|
431
|
+
* type Result,
|
|
432
|
+
* type Typed,
|
|
433
|
+
* } from "@evolu/common";
|
|
170
434
|
*
|
|
171
435
|
* interface User {
|
|
172
436
|
* readonly id: string;
|
|
173
437
|
* }
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
* }
|
|
438
|
+
*
|
|
439
|
+
* interface UserNotFoundError extends Typed<"UserNotFound"> {}
|
|
177
440
|
*
|
|
178
441
|
* interface Profile {
|
|
179
442
|
* readonly userId: string;
|
|
180
443
|
* }
|
|
181
|
-
* interface ProfileError {
|
|
182
|
-
* readonly type: "ProfileError";
|
|
183
|
-
* }
|
|
184
|
-
* const getProfile = (userId: string): Result<Profile, ProfileError> =>
|
|
185
|
-
* ok({ userId });
|
|
186
|
-
*
|
|
187
|
-
* let getProfileCalls = 0;
|
|
188
|
-
* const getProfileForUser = (
|
|
189
|
-
* user: User,
|
|
190
|
-
* ): Result<Profile, ProfileError> => {
|
|
191
|
-
* getProfileCalls++;
|
|
192
|
-
* return getProfile(user.id);
|
|
193
|
-
* };
|
|
194
444
|
*
|
|
195
|
-
* const
|
|
196
|
-
*
|
|
445
|
+
* const getProfile = (
|
|
446
|
+
* userId: string,
|
|
447
|
+
* ): Result<Profile, ProfileNotFoundError> => ok({ userId });
|
|
448
|
+
*
|
|
449
|
+
* interface ProfileNotFoundError extends Typed<"ProfileNotFound"> {}
|
|
450
|
+
*
|
|
451
|
+
* const user: Result<User, UserNotFoundError> = ok({ id: "user-1" });
|
|
452
|
+
* const profile = flatMapResult(user, ({ id }) => getProfile(id));
|
|
197
453
|
* expectTypeOf(profile).toEqualTypeOf<
|
|
198
|
-
* Result<Profile,
|
|
454
|
+
* Result<Profile, UserNotFoundError | ProfileNotFoundError>
|
|
199
455
|
* >();
|
|
200
456
|
* expectOk(profile, { userId: "user-1" });
|
|
201
|
-
* expect(getProfileCalls).toBe(1);
|
|
202
|
-
*
|
|
203
|
-
* const missingUser: Result<User, UserError> = err({ type: "UserError" });
|
|
204
|
-
* const missingProfile = flatMapResult(missingUser, getProfileForUser);
|
|
205
|
-
* expectErr(missingProfile, { type: "UserError" });
|
|
206
|
-
* expect(getProfileCalls).toBe(1);
|
|
207
457
|
* ```
|
|
208
458
|
*
|
|
209
459
|
* @group Composition
|
package/dist/src/StackTrace.d.ts
CHANGED
|
@@ -36,5 +36,6 @@ export interface StackTraceOptions {
|
|
|
36
36
|
* similar assertions that need stable, cross-engine stack evidence.
|
|
37
37
|
*/
|
|
38
38
|
export declare function parseStackTrace(stack: string | undefined, options?: StackTraceOptions): StackTrace;
|
|
39
|
+
/** Runs an async callback and parses the stack of the error it throws. */
|
|
39
40
|
export declare function parseStackTrace(run: () => Promise<never>, options?: StackTraceOptions): Promise<StackTrace>;
|
|
40
41
|
//# sourceMappingURL=StackTrace.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StackTrace.d.ts","sourceRoot":"","sources":["../../src/StackTrace.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,eAAe;IAC9B,oEAAoE;IACpE,QAAQ,C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