better-effect 0.4.0 → 0.5.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/README.md +32 -5
- package/dist/adapters/iti.d.mts +11 -3
- package/dist/adapters/iti.d.mts.map +1 -1
- package/dist/adapters/iti.mjs +34 -14
- package/dist/adapters/iti.mjs.map +1 -1
- package/dist/errors-GR3K_nRu.mjs +74 -0
- package/dist/errors-GR3K_nRu.mjs.map +1 -0
- package/dist/index-D77AvuBl.d.mts +510 -0
- package/dist/index-D77AvuBl.d.mts.map +1 -0
- package/dist/index.d.mts +217 -20
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +429 -153
- package/dist/index.mjs.map +1 -1
- package/dist/internal-identity-BnZC3Au-.mjs +26 -0
- package/dist/internal-identity-BnZC3Au-.mjs.map +1 -0
- package/dist/testing.d.mts +11 -2
- package/dist/testing.d.mts.map +1 -1
- package/dist/testing.mjs +33 -12
- package/dist/testing.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/errors-DlHCwICc.mjs +0 -67
- package/dist/errors-DlHCwICc.mjs.map +0 -1
- package/dist/index-BYQKfyeJ.d.mts +0 -235
- package/dist/index-BYQKfyeJ.d.mts.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,19 +1,35 @@
|
|
|
1
|
-
import { A as ServiceResolver, B as ServiceRequirement, C as ScopeOutcome, D as ScopeRuntimeNotConfiguredError, E as ScopeClosedError, F as EffectFromGenerator, G as
|
|
1
|
+
import { A as ServiceResolver, B as ServiceRequirement, C as ScopeOutcome, D as ScopeRuntimeNotConfiguredError, E as ScopeClosedError, F as EffectFromGenerator, G as ServiceTag, H as ServiceClass, I as EffectRequirements, K as ServiceToken, L as EffectResult, M as Service, N as AnyEffectResult, O as ServiceNotFoundError, P as EffectError, R as EffectSuccess, S as ScopeFinalizer, T as ScopeCloseError, U as ServiceInstance, V as AnyServiceToken, W as ServiceRequirements, _ as LayerSpecs, a as DuplicateServiceError, b as DisposableResource, c as LayerRegistrationError, d as AnyLayer, f as CompleteExecution, g as LayerRawRequired, h as LayerProvided, i as RuntimeShutdownDiagnostic, j as ServiceRuntime, k as ServiceRuntimeNotConfiguredError, l as ServiceTagCollisionError, m as LayerMissing, n as CleanupFailureObserver, o as LayerDisposeError, p as CompleteLayer, r as RuntimeOptions, s as LayerGeneratorYieldError, t as LayerBackend, u as Layer, v as LayerRegistration, w as ResourceNotDisposableError, x as MaybePromise$1, y as CleanupFailureDiagnostic, z as EffectYield } from "./index-D77AvuBl.mjs";
|
|
2
2
|
import { Err, Result, UnhandledException } from "better-result";
|
|
3
3
|
//#region src/scope/scope.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Non-owning lifecycle context for finalizers and child Scopes.
|
|
6
|
+
*
|
|
7
|
+
* A Scope can register cleanup and create children, but it cannot close
|
|
8
|
+
* itself. Use `Scope.make()` or `Scope.run()` when your code owns the Scope.
|
|
9
|
+
*/
|
|
4
10
|
interface Scope {
|
|
11
|
+
/** Register a finalizer that runs when the owning Scope closes. */
|
|
5
12
|
addFinalizer(finalizer: ScopeFinalizer): void;
|
|
13
|
+
/** Acquire a resource and register its outcome-aware release callback. */
|
|
6
14
|
acquire<R>(acquire: () => MaybePromise$1<R>, release: (resource: R, outcome: ScopeOutcome) => MaybePromise$1<void>): Promise<R>;
|
|
15
|
+
/** Register an already-acquired disposable resource. */
|
|
7
16
|
add<R extends DisposableResource>(resource: R): Promise<R>;
|
|
17
|
+
/** Create a child Scope owned by this Scope. */
|
|
8
18
|
fork(): CloseableScope;
|
|
9
19
|
}
|
|
20
|
+
/** A Scope whose owner is responsible for calling `close()`. */
|
|
10
21
|
interface CloseableScope extends Scope {
|
|
22
|
+
/** Close the Scope and run children and finalizers in child-first LIFO order. */
|
|
11
23
|
close(outcome?: ScopeOutcome): Promise<void>;
|
|
12
24
|
}
|
|
13
25
|
declare const Scope: {
|
|
26
|
+
/** Create an owned, initially open Scope. */
|
|
14
27
|
readonly make: () => CloseableScope;
|
|
28
|
+
/** Return the non-owning Scope available in the current execution context. */
|
|
15
29
|
readonly current: () => Scope;
|
|
30
|
+
/** Run a callback with an existing Scope supplied as the current context. */
|
|
16
31
|
readonly provide: <A>(scope: Scope, program: () => A) => A;
|
|
32
|
+
/** Resolve the current Scope through `yield* Scope` inside an Effect. */
|
|
17
33
|
readonly [Symbol.iterator]: () => Generator<never, Scope, unknown>;
|
|
18
34
|
/**
|
|
19
35
|
* Run a program in a newly owned Scope.
|
|
@@ -21,6 +37,14 @@ declare const Scope: {
|
|
|
21
37
|
* Scope is independent from `better-result`, so returned values—including
|
|
22
38
|
* `Result.err`—close this Scope with a successful outcome. Result-aware
|
|
23
39
|
* outcome classification belongs to `Runtime.run`.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* await Scope.run(async (scope) => {
|
|
44
|
+
* const connection = await scope.acquire(connect, (connection) => connection.close())
|
|
45
|
+
* return connection.query()
|
|
46
|
+
* })
|
|
47
|
+
* ```
|
|
24
48
|
*/
|
|
25
49
|
readonly run: <A>(program: (scope: Scope) => A | PromiseLike<A>) => Promise<Awaited<A>>;
|
|
26
50
|
};
|
|
@@ -28,11 +52,14 @@ declare const Scope: {
|
|
|
28
52
|
//#region src/effect/combinators.d.ts
|
|
29
53
|
type EffectInput<A, E, Requirements> = EffectResult<A, E, Requirements> | PromiseLike<EffectResult<A, E, Requirements>>;
|
|
30
54
|
type AnyEffectInput = EffectInput<any, any, any>;
|
|
55
|
+
type AnyEffectResult$1 = EffectResult<any, any, any>;
|
|
56
|
+
type AnyAsyncEffectInput = PromiseLike<AnyEffectResult$1>;
|
|
31
57
|
type PreserveAsync<Input, Output> = Input extends PromiseLike<unknown> ? Promise<Output> : Output;
|
|
32
58
|
type MappedResult<Input, B> = EffectResult<B, EffectError<Input>, EffectRequirements<Input>>;
|
|
33
59
|
type ErrorMappedResult<Input, E2> = EffectResult<EffectSuccess<Input>, E2, EffectRequirements<Input>>;
|
|
34
60
|
type ChainedResult<First, Next> = EffectResult<EffectSuccess<Next>, EffectError<First> | EffectError<Next>, EffectRequirements<First> | EffectRequirements<Next>>;
|
|
35
|
-
type ChainedOutput<First, Next> =
|
|
61
|
+
type ChainedOutput<First, Next> = ChainedResult<First, Next>;
|
|
62
|
+
type AsyncChainedOutput<First, Next> = Promise<ChainedResult<First, Next>>;
|
|
36
63
|
type MapOperation<A, B> = {
|
|
37
64
|
<Input>(effect: Input & EffectInput<A, any, any>): PreserveAsync<Input, MappedResult<Input, B>>;
|
|
38
65
|
};
|
|
@@ -40,20 +67,82 @@ type MapErrorOperation<E1, E2> = {
|
|
|
40
67
|
<Input>(effect: Input & EffectInput<any, E1, any>): PreserveAsync<Input, ErrorMappedResult<Input, E2>>;
|
|
41
68
|
};
|
|
42
69
|
type AndThenOperation<A, Next> = {
|
|
43
|
-
<Input>(effect: Input &
|
|
70
|
+
<Input>(effect: Input & EffectResult<A, any, any>): ChainedOutput<Input, Next>;
|
|
44
71
|
};
|
|
72
|
+
type AndThenAsyncOperation<A, Next> = {
|
|
73
|
+
<Input>(effect: Input & EffectInput<A, any, any>): AsyncChainedOutput<Input, Next>;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Map the successful value of a Result or Effect result.
|
|
77
|
+
*
|
|
78
|
+
* Supports both data-first and data-last forms and preserves asynchronous
|
|
79
|
+
* results and phantom Service requirements.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* const doubled = Effect.map(Result.ok(2), (value) => value * 2)
|
|
84
|
+
* const toLabel = Effect.map((value: number) => `#${value}`)
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
45
87
|
declare function map<A, B>(fn: (value: A) => B): MapOperation<A, B>;
|
|
46
88
|
declare function map<Input, B>(effect: Input & AnyEffectInput, fn: (value: EffectSuccess<Input>) => B): PreserveAsync<Input, MappedResult<Input, B>>;
|
|
89
|
+
/**
|
|
90
|
+
* Map the error value of a Result or Effect result while preserving its
|
|
91
|
+
* successful value, asynchronous shape, and Service requirements.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```ts
|
|
95
|
+
* const labelled = Effect.mapError(Result.err('missing'), (error) => ({ error }))
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
47
98
|
declare function mapError<E1, E2>(fn: (error: E1) => E2): MapErrorOperation<E1, E2>;
|
|
48
99
|
declare function mapError<Input, E2>(effect: Input & AnyEffectInput, fn: (error: EffectError<Input>) => E2): PreserveAsync<Input, ErrorMappedResult<Input, E2>>;
|
|
49
|
-
|
|
50
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Chain a synchronous Result-producing operation after a successful result.
|
|
102
|
+
*
|
|
103
|
+
* The next operation is skipped when the input is an error. Both error types
|
|
104
|
+
* and both sets of Service requirements are preserved in the output.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* const user = Effect.andThen(Result.ok('u1'), (id) => repository.find(id))
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
declare function andThen<A, Next extends AnyEffectResult$1>(next: (value: A) => Next): AndThenOperation<A, Next>;
|
|
112
|
+
declare function andThen<Input, Next extends AnyEffectResult$1>(effect: Input & AnyEffectResult$1, next: (value: EffectSuccess<Input>) => Next): ChainedOutput<Input, Next>;
|
|
113
|
+
/**
|
|
114
|
+
* Chain an asynchronous Result-producing operation after a successful result.
|
|
115
|
+
*
|
|
116
|
+
* The returned value is always a Promise and retains both operations' error
|
|
117
|
+
* and Service-requirement metadata.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```ts
|
|
121
|
+
* const user = Effect.andThenAsync(loadUser(), (user) => fetchProfile(user.id))
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
declare function andThenAsync<A, Next extends AnyAsyncEffectInput>(next: (value: A) => Next): AndThenAsyncOperation<A, Next>;
|
|
125
|
+
declare function andThenAsync<Input, Next extends AnyAsyncEffectInput>(effect: Input & AnyEffectInput, next: (value: EffectSuccess<Input>) => Next): AsyncChainedOutput<Input, Next>;
|
|
51
126
|
//#endregion
|
|
52
127
|
//#region src/effect/effect.d.ts
|
|
53
128
|
type AnyResult = Result<any, any>;
|
|
54
129
|
/**
|
|
55
|
-
* Compose better-result operations while preserving Service requirements in
|
|
130
|
+
* Compose `better-result` operations while preserving Service requirements in
|
|
56
131
|
* a phantom type channel.
|
|
132
|
+
*
|
|
133
|
+
* A generator may yield Service tokens and Result operations. It must return a
|
|
134
|
+
* `Result` as its final value; Service yields are resolved by the active
|
|
135
|
+
* Runtime and do not add runtime values to the Result stream.
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```ts
|
|
139
|
+
* const loadUser = Effect.gen(async function* () {
|
|
140
|
+
* const database = yield* Database
|
|
141
|
+
* const user = yield* Result.await(database.findUser('u1'))
|
|
142
|
+
*
|
|
143
|
+
* return Result.ok(user)
|
|
144
|
+
* })
|
|
145
|
+
* ```
|
|
57
146
|
*/
|
|
58
147
|
declare function gen<Yield extends EffectYield, Returned extends AnyResult>(body: () => Generator<Yield, Returned, unknown>): EffectFromGenerator<Yield, Returned>;
|
|
59
148
|
declare function gen<Yield extends EffectYield, Returned extends AnyResult>(body: () => AsyncGenerator<Yield, Returned, unknown>): Promise<EffectFromGenerator<Yield, Returned>>;
|
|
@@ -61,28 +150,71 @@ declare function gen<Yield extends EffectYield, Returned extends AnyResult>(body
|
|
|
61
150
|
* Acquire a resource in the current Scope and register its release callback.
|
|
62
151
|
*
|
|
63
152
|
* Acquisition failures are represented in the Effect Result error channel;
|
|
64
|
-
* release failures remain owned by Scope cleanup.
|
|
153
|
+
* release failures remain owned by Scope cleanup. The release callback
|
|
154
|
+
* receives the final outcome chosen by the enclosing execution boundary.
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```ts
|
|
158
|
+
* const connection = yield* Effect.acquireRelease(
|
|
159
|
+
* () => pool.connect(),
|
|
160
|
+
* (connection, outcome) => connection.close(outcome)
|
|
161
|
+
* )
|
|
162
|
+
* ```
|
|
65
163
|
*/
|
|
66
164
|
declare function acquireRelease<R>(acquire: () => MaybePromise$1<R>, release: (resource: R, outcome: ScopeOutcome) => MaybePromise$1<void>): AsyncGenerator<Err<never, UnhandledException>, R, unknown>;
|
|
67
165
|
/**
|
|
68
166
|
* Register an already-acquired disposable resource in the current Scope.
|
|
69
167
|
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
168
|
+
* The resource is not acquired by this helper. Registration failures are
|
|
169
|
+
* represented in the Effect Result error channel; disposal failures remain
|
|
170
|
+
* owned by Scope cleanup.
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```ts
|
|
174
|
+
* const file = yield* Effect.add(await openFile('notes.txt'))
|
|
175
|
+
* ```
|
|
72
176
|
*/
|
|
73
177
|
declare function add<R extends DisposableResource>(resource: R): AsyncGenerator<Err<never, UnhandledException>, R, unknown>;
|
|
178
|
+
/**
|
|
179
|
+
* Effect namespace containing generator, resource, and Result combinators.
|
|
180
|
+
*
|
|
181
|
+
* Prefer these helpers when a program needs typed Service requirements or
|
|
182
|
+
* Scope-aware acquisition and cleanup.
|
|
183
|
+
*/
|
|
74
184
|
declare const Effect: {
|
|
185
|
+
/** Compose a generator-based Effect program. */
|
|
75
186
|
readonly gen: typeof gen;
|
|
187
|
+
/** Acquire and register a resource in the current Scope. */
|
|
76
188
|
readonly acquireRelease: typeof acquireRelease;
|
|
189
|
+
/** Register an already-acquired disposable in the current Scope. */
|
|
77
190
|
readonly add: typeof add;
|
|
191
|
+
/** Map a successful Effect result. */
|
|
78
192
|
readonly map: typeof map;
|
|
193
|
+
/** Map an Effect error. */
|
|
79
194
|
readonly mapError: typeof mapError;
|
|
195
|
+
/** Chain a synchronous Effect result. */
|
|
80
196
|
readonly andThen: typeof andThen;
|
|
197
|
+
/** Chain an asynchronous Effect result. */
|
|
198
|
+
readonly andThenAsync: typeof andThenAsync;
|
|
81
199
|
};
|
|
82
200
|
//#endregion
|
|
83
201
|
//#region src/function/pipe.d.ts
|
|
84
202
|
type Unary<A, B> = (value: A) => B;
|
|
85
|
-
/**
|
|
203
|
+
/**
|
|
204
|
+
* Compose a value through a sequence of unary functions.
|
|
205
|
+
*
|
|
206
|
+
* `pipe` is deliberately independent of Effect, Result, Promise, Scope, and
|
|
207
|
+
* Service metadata.
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```ts
|
|
211
|
+
* const label = pipe(
|
|
212
|
+
* 'alice',
|
|
213
|
+
* (name) => name.trim(),
|
|
214
|
+
* (name) => name.toUpperCase()
|
|
215
|
+
* )
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
86
218
|
declare function pipe<A>(value: A): A;
|
|
87
219
|
declare function pipe<A, B>(value: A, ab: Unary<A, B>): B;
|
|
88
220
|
declare function pipe<A, B, C>(value: A, ab: Unary<A, B>, bc: Unary<B, C>): C;
|
|
@@ -97,6 +229,7 @@ declare function pipe<A, B, C, D, E, F, G, H, I, J, K>(value: A, ab: Unary<A, B>
|
|
|
97
229
|
//#endregion
|
|
98
230
|
//#region src/resource/errors.d.ts
|
|
99
231
|
declare const ResourceReleaseFailure_base: import("better-result").TaggedErrorClass<"ResourceReleaseFailure">;
|
|
232
|
+
/** Describes a failure encountered while releasing a Resource. */
|
|
100
233
|
declare class ResourceReleaseFailure extends ResourceReleaseFailure_base<{
|
|
101
234
|
readonly resource: string;
|
|
102
235
|
readonly cause: unknown;
|
|
@@ -104,38 +237,94 @@ declare class ResourceReleaseFailure extends ResourceReleaseFailure_base<{
|
|
|
104
237
|
}> {}
|
|
105
238
|
//#endregion
|
|
106
239
|
//#region src/resource/types.d.ts
|
|
240
|
+
/** A value that may be delivered synchronously or through a thenable. */
|
|
107
241
|
type MaybePromise<T> = T | PromiseLike<T>;
|
|
242
|
+
/** A synchronous or asynchronous better-result Result operation. */
|
|
108
243
|
type AsyncResult<T, E> = MaybePromise<Result<T, E>>;
|
|
244
|
+
/** The allowed return value of a custom Resource release callback. */
|
|
109
245
|
type ReleaseOutcome = void | Result<void, unknown>;
|
|
246
|
+
/** Receives release failures for diagnostics without changing error precedence. */
|
|
110
247
|
type ReleaseFailureObserver = (failure: ResourceReleaseFailure) => MaybePromise<void>;
|
|
248
|
+
/** Options controlling `Resource.acquireUseRelease`. */
|
|
111
249
|
type AcquireUseReleaseOptions<R, A, AcquireError, UseError> = {
|
|
250
|
+
/** Human-readable name included in release failures. */
|
|
112
251
|
readonly name: string;
|
|
252
|
+
/** Acquire the resource. A failure skips use and release. */
|
|
113
253
|
readonly acquire: () => AsyncResult<R, AcquireError>;
|
|
254
|
+
/** Use the acquired resource. Release is attempted afterward. */
|
|
114
255
|
readonly use: (resource: R) => AsyncResult<A, UseError>;
|
|
256
|
+
/** Release the resource, or omit it to use its disposal protocol. */
|
|
115
257
|
readonly release?: (resource: R) => MaybePromise<ReleaseOutcome>;
|
|
116
258
|
/**
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
* Útil principalmente quando use
|
|
121
|
-
* e release falham juntos.
|
|
259
|
+
* Observe cleanup failures without changing error precedence. This is most
|
|
260
|
+
* useful when both `use` and `release` can fail.
|
|
122
261
|
*/
|
|
123
262
|
readonly onReleaseFailure?: ReleaseFailureObserver;
|
|
124
263
|
};
|
|
125
264
|
//#endregion
|
|
126
265
|
//#region src/resource/resource.d.ts
|
|
266
|
+
/**
|
|
267
|
+
* Acquire a resource, use it, and always attempt release afterward.
|
|
268
|
+
*
|
|
269
|
+
* Acquisition, use, and release may be synchronous or asynchronous Result
|
|
270
|
+
* operations. If both use and release fail, the use error remains primary and
|
|
271
|
+
* `onReleaseFailure` receives the cleanup failure as a diagnostic.
|
|
272
|
+
*
|
|
273
|
+
* When `release` is omitted, `Symbol.asyncDispose` is preferred over
|
|
274
|
+
* `Symbol.dispose`.
|
|
275
|
+
*
|
|
276
|
+
* @example
|
|
277
|
+
* ```ts
|
|
278
|
+
* const result = await Resource.acquireUseRelease({
|
|
279
|
+
* name: 'database connection',
|
|
280
|
+
* acquire: () => connect(),
|
|
281
|
+
* use: (connection) => query(connection),
|
|
282
|
+
* release: (connection) => connection.close()
|
|
283
|
+
* })
|
|
284
|
+
* ```
|
|
285
|
+
*/
|
|
127
286
|
declare const acquireUseRelease: <R, A, AcquireError, UseError>({ name, acquire, use, release, onReleaseFailure }: AcquireUseReleaseOptions<R, A, AcquireError, UseError>) => Promise<Result<A, AcquireError | UseError | UnhandledException | ResourceReleaseFailure>>;
|
|
128
287
|
declare const Resource: {
|
|
288
|
+
/** Acquire, use, and release a resource with deterministic error precedence. */
|
|
129
289
|
readonly acquireUseRelease: typeof acquireUseRelease;
|
|
130
290
|
};
|
|
131
291
|
//#endregion
|
|
132
292
|
//#region src/runtime/runtime.d.ts
|
|
293
|
+
/**
|
|
294
|
+
* Long-lived execution environment backed by a complete Layer.
|
|
295
|
+
*
|
|
296
|
+
* A Runtime owns Layer resources until `dispose()` is called. Each `run()` is
|
|
297
|
+
* isolated in a child Scope, while Layer-scoped resources remain shared.
|
|
298
|
+
*
|
|
299
|
+
* @example
|
|
300
|
+
* ```ts
|
|
301
|
+
* const runtime = await Runtime.make(AppLive, new MemoryLayerBackend())
|
|
302
|
+
* const result = await runtime.run(loadUser('u1'))
|
|
303
|
+
* await runtime.dispose()
|
|
304
|
+
* ```
|
|
305
|
+
*
|
|
306
|
+
* @typeParam Provided The Service constructors supplied by the Layer.
|
|
307
|
+
*/
|
|
133
308
|
declare class Runtime<Provided extends AnyServiceToken = AnyServiceToken> {
|
|
134
|
-
private readonly
|
|
309
|
+
private readonly handle;
|
|
135
310
|
private constructor();
|
|
136
|
-
/**
|
|
311
|
+
/**
|
|
312
|
+
* Create a long-lived Runtime that owns its Layer resources.
|
|
313
|
+
*
|
|
314
|
+
* @example
|
|
315
|
+
* ```ts
|
|
316
|
+
* const runtime = await Runtime.make(AppLive, backend)
|
|
317
|
+
* const result = await runtime.run(program)
|
|
318
|
+
* await runtime.dispose()
|
|
319
|
+
* ```
|
|
320
|
+
*/
|
|
137
321
|
static make<L extends AnyLayer>(layer: CompleteLayer<L>, backend: LayerBackend, options?: RuntimeOptions): Promise<Runtime<LayerProvided<L>>>;
|
|
138
|
-
/**
|
|
322
|
+
/**
|
|
323
|
+
* Run one program and dispose its Layer resources before resolving.
|
|
324
|
+
*
|
|
325
|
+
* This is convenient for request-style or command-style execution where a
|
|
326
|
+
* Runtime should not outlive the operation.
|
|
327
|
+
*/
|
|
139
328
|
static run<A, L extends AnyLayer>(layer: CompleteLayer<L>, backend: LayerBackend, program: CompleteExecution<LayerProvided<L>, A>, options?: RuntimeOptions): Promise<Awaited<A>>;
|
|
140
329
|
/** Run one execution in this Runtime's child Scope. */
|
|
141
330
|
run<A>(program: CompleteExecution<Provided, A>): Promise<Awaited<A>>;
|
|
@@ -146,8 +335,16 @@ declare class Runtime<Provided extends AnyServiceToken = AnyServiceToken> {
|
|
|
146
335
|
}
|
|
147
336
|
//#endregion
|
|
148
337
|
//#region src/runtime/types.d.ts
|
|
149
|
-
/**
|
|
338
|
+
/**
|
|
339
|
+
* Name a Runtime type from a concrete Layer without repeating its provided
|
|
340
|
+
* Service constructor union.
|
|
341
|
+
*
|
|
342
|
+
* @example
|
|
343
|
+
* ```ts
|
|
344
|
+
* type AppRuntime = RuntimeFor<typeof AppLive>
|
|
345
|
+
* ```
|
|
346
|
+
*/
|
|
150
347
|
type RuntimeFor<L extends AnyLayer> = Runtime<LayerProvided<L>>;
|
|
151
348
|
//#endregion
|
|
152
|
-
export { type AcquireUseReleaseOptions, type AnyEffectResult, type AnyServiceToken, type AsyncResult,
|
|
349
|
+
export { type AcquireUseReleaseOptions, type AnyEffectResult, type AnyServiceToken, type AsyncResult, type CleanupFailureDiagnostic, type CleanupFailureObserver, type CloseableScope, type DisposableResource, DuplicateServiceError, Effect, type EffectError, type EffectRequirements, type EffectResult, type EffectSuccess, type EffectYield, Layer, type LayerBackend, LayerDisposeError, LayerGeneratorYieldError, type LayerMissing, type LayerProvided, type LayerRawRequired, type LayerRegistration, LayerRegistrationError, type LayerSpecs, type ReleaseFailureObserver, type ReleaseOutcome, Resource, ResourceNotDisposableError, ResourceReleaseFailure, Runtime, type RuntimeFor, type RuntimeOptions, type RuntimeShutdownDiagnostic, Scope, ScopeCloseError, ScopeClosedError, type ScopeFinalizer, type ScopeOutcome, ScopeRuntimeNotConfiguredError, Service, type ServiceClass, type ServiceInstance, ServiceNotFoundError, type ServiceRequirement, type ServiceRequirements, type ServiceResolver, ServiceRuntime, ServiceRuntimeNotConfiguredError, type ServiceTag, ServiceTagCollisionError, type ServiceToken, pipe };
|
|
153
350
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/scope/scope.ts","../src/effect/combinators.ts","../src/effect/effect.ts","../src/function/pipe.ts","../src/resource/errors.ts","../src/resource/types.ts","../src/resource/resource.ts","../src/runtime/runtime.ts","../src/runtime/types.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/scope/scope.ts","../src/effect/combinators.ts","../src/effect/effect.ts","../src/function/pipe.ts","../src/resource/errors.ts","../src/resource/types.ts","../src/resource/resource.ts","../src/runtime/runtime.ts","../src/runtime/types.ts"],"mappings":";;;;;;;;;UAgBiB;;EAEf,aAAa,WAAW;;EAGxB,QAAQ,GACN,eAAe,eAAa,IAC5B,UAAU,UAAU,GAAG,SAAS,iBAAiB,uBAChD,QAAQ;;EAGX,IAAI,UAAU,oBAAoB,UAAU,IAAI,QAAQ;;EAGxD,QAAQ;;;UAIO,uBAAuB;;EAEtC,MAAM,UAAU,eAAe;;cAgKpB;;WAEH,YAAA;;WAKG,eAAA;;WAKH,UAAA,GAAC,OAAS,OAAK,eAAiB,MAAI;;YAMtB,OAAA,iBAAA,iBAAiB;;;;;;;;;;;;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