better-effect 0.11.0 → 0.12.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 +220 -6
- package/dist/adapters/iti.d.mts +2 -1
- package/dist/adapters/iti.d.mts.map +1 -1
- package/dist/adapters/iti.mjs +11 -10
- package/dist/adapters/iti.mjs.map +1 -1
- package/dist/{effect-2ZcGZI8A.mjs → effect-CK4YZaX0.mjs} +56 -10
- package/dist/effect-CK4YZaX0.mjs.map +1 -0
- package/dist/hono.d.mts +3 -3
- package/dist/hono.mjs +3 -3
- package/dist/{index-DStz0JMN.d.mts → index-B1nH4luq.d.mts} +73 -6
- package/dist/index-B1nH4luq.d.mts.map +1 -0
- package/dist/index-BMdU_Z72.d.mts +18 -0
- package/dist/index-BMdU_Z72.d.mts.map +1 -0
- package/dist/{index-C7Qild0_.d.mts → index-CX6iAoCB.d.mts} +15 -151
- package/dist/index-CX6iAoCB.d.mts.map +1 -0
- package/dist/index-GYJ4qm9K.d.mts +179 -0
- package/dist/index-GYJ4qm9K.d.mts.map +1 -0
- package/dist/index-heuaRmXR.d.mts.map +1 -1
- package/dist/index.d.mts +5 -3
- package/dist/index.mjs +6 -5
- package/dist/index.mjs.map +1 -1
- package/dist/{internal-identity-DmUpBeeL.mjs → internal-identity-CbXoZIfw.mjs} +3 -3
- package/dist/internal-identity-CbXoZIfw.mjs.map +1 -0
- package/dist/{signal-B97cs85Z.mjs → layer-D56fRdLt.mjs} +30 -111
- package/dist/layer-D56fRdLt.mjs.map +1 -0
- package/dist/node-context-DWsCUBRa.d.mts +12 -0
- package/dist/node-context-DWsCUBRa.d.mts.map +1 -0
- package/dist/node-context-lggRF4bR.mjs +25 -0
- package/dist/node-context-lggRF4bR.mjs.map +1 -0
- package/dist/node.d.mts +51 -0
- package/dist/node.d.mts.map +1 -0
- package/dist/node.mjs +233 -0
- package/dist/node.mjs.map +1 -0
- package/dist/{index-rQhZk3Nt.d.mts → outcome-CB43bnFW.d.mts} +29 -19
- package/dist/outcome-CB43bnFW.d.mts.map +1 -0
- package/dist/{scope-GGnmTQck.mjs → program-metadata-DhQCCirO.mjs} +18 -3
- package/dist/program-metadata-DhQCCirO.mjs.map +1 -0
- package/dist/registration-drnZk0SY.mjs +182 -0
- package/dist/registration-drnZk0SY.mjs.map +1 -0
- package/dist/runtime/node.d.mts +2 -11
- package/dist/runtime/node.mjs +2 -24
- package/dist/{runtime-DnMn0X0X.mjs → runtime-CBMrX8Wl.mjs} +210 -47
- package/dist/runtime-CBMrX8Wl.mjs.map +1 -0
- package/dist/signal-D2UTcaaG.mjs +105 -0
- package/dist/signal-D2UTcaaG.mjs.map +1 -0
- package/dist/{standard-services-BFBq-4lo.mjs → standard-services-GBZ32tll.mjs} +200 -16
- package/dist/standard-services-GBZ32tll.mjs.map +1 -0
- package/dist/standard-services.d.mts +3 -3
- package/dist/standard-services.mjs +3 -3
- package/dist/testing.d.mts +65 -6
- package/dist/testing.d.mts.map +1 -1
- package/dist/testing.mjs +191 -8
- package/dist/testing.mjs.map +1 -1
- package/package.json +8 -3
- package/dist/effect-2ZcGZI8A.mjs.map +0 -1
- package/dist/errors-Dnjhzbt0.mjs +0 -99
- package/dist/errors-Dnjhzbt0.mjs.map +0 -1
- package/dist/index-C7Qild0_.d.mts.map +0 -1
- package/dist/index-DStz0JMN.d.mts.map +0 -1
- package/dist/index-rQhZk3Nt.d.mts.map +0 -1
- package/dist/internal-identity-DmUpBeeL.mjs.map +0 -1
- package/dist/runtime/node.d.mts.map +0 -1
- package/dist/runtime/node.mjs.map +0 -1
- package/dist/runtime-DnMn0X0X.mjs.map +0 -1
- package/dist/scope-GGnmTQck.mjs.map +0 -1
- package/dist/signal-B97cs85Z.mjs.map +0 -1
- package/dist/standard-services-BFBq-4lo.mjs.map +0 -1
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { M as AnyService, h as ScopeOutcome } from "./index-heuaRmXR.mjs";
|
|
2
|
+
import { C as CompleteExecution, D as LayerInput, M as ProvidedEnvironment, T as CompleteInput, a as RuntimeShutdownDiagnostic, i as RuntimeRunOptions, n as RuntimeDisposeOptions, r as RuntimeOptions, w as CompleteExecutionLayer, x as Layer, y as LayerBackend } from "./outcome-CB43bnFW.mjs";
|
|
3
|
+
import "./index-BMdU_Z72.mjs";
|
|
4
|
+
import "./index-CX6iAoCB.mjs";
|
|
5
|
+
import { Result, UnhandledException } from "better-result";
|
|
6
|
+
//#region src/runtime/types.d.ts
|
|
7
|
+
/** A detached diagnostic view of one active Runtime execution. */
|
|
8
|
+
type RuntimeExecutionInspection = {
|
|
9
|
+
readonly executionId: string;
|
|
10
|
+
readonly name?: string;
|
|
11
|
+
readonly startedAt: number;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* A detached, immutable diagnostic view of a Runtime.
|
|
15
|
+
*
|
|
16
|
+
* Inspection never exposes Service instances, providers, Scopes or arbitrary
|
|
17
|
+
* execution attributes. It is informational only and is not a synchronization
|
|
18
|
+
* primitive or readiness guarantee.
|
|
19
|
+
*/
|
|
20
|
+
type RuntimeInspection = {
|
|
21
|
+
readonly state: 'active' | 'disposing' | 'disposed';
|
|
22
|
+
readonly warmup: 'idle' | 'running' | 'completed' | 'failed';
|
|
23
|
+
readonly activeExecutions: number;
|
|
24
|
+
readonly executions: readonly RuntimeExecutionInspection[];
|
|
25
|
+
readonly services: readonly string[];
|
|
26
|
+
readonly shutdownSignalAborted: boolean;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Name a Runtime type from a concrete Layer without repeating its provided
|
|
30
|
+
* branded Service instance union.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* type AppRuntime = RuntimeFor<typeof AppLive>
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
type RuntimeFor<L extends LayerInput> = Runtime<Layer.Provided<L>>;
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/runtime/runtime.d.ts
|
|
40
|
+
type RuntimeOptionsInput = RuntimeOptions & RuntimeRunOptions;
|
|
41
|
+
/**
|
|
42
|
+
* Long-lived execution environment backed by a complete Layer.
|
|
43
|
+
*
|
|
44
|
+
* A Runtime owns Layer resources until `dispose()` is called. Each `run()` is
|
|
45
|
+
* isolated in a child Scope, while Layer-scoped resources remain shared.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* const runtime = await Runtime.make(AppLive)
|
|
50
|
+
* const result = await runtime.run(loadUser('u1'))
|
|
51
|
+
* await runtime.dispose()
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* @typeParam Provided The branded Service instances supplied by the Layer.
|
|
55
|
+
*/
|
|
56
|
+
declare class Runtime<Provided extends AnyService = any> {
|
|
57
|
+
private readonly handle;
|
|
58
|
+
private constructor();
|
|
59
|
+
/**
|
|
60
|
+
* Create a long-lived Runtime that owns its Layer resources.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* const runtime = await Runtime.make(AppLive)
|
|
65
|
+
* const result = await runtime.run(program)
|
|
66
|
+
* await runtime.dispose()
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
static make<L extends LayerInput>(layer: L & CompleteInput<L>, backend: LayerBackend, options?: RuntimeOptions): Promise<Runtime<ProvidedEnvironment<L>>>;
|
|
70
|
+
static make<L extends LayerInput>(layer: L & CompleteInput<L>, options?: RuntimeOptions): Promise<Runtime<ProvidedEnvironment<L>>>;
|
|
71
|
+
/**
|
|
72
|
+
* Run one program and dispose its Layer resources before resolving.
|
|
73
|
+
*
|
|
74
|
+
* This is convenient for request-style or command-style execution where a
|
|
75
|
+
* Runtime should not outlive the operation.
|
|
76
|
+
*/
|
|
77
|
+
static run<A, L extends LayerInput>(layer: L & CompleteInput<L>, backend: LayerBackend, program: CompleteExecution<ProvidedEnvironment<L>, A>, options?: RuntimeOptionsInput): Promise<Awaited<A>>;
|
|
78
|
+
static run<A, L extends LayerInput>(layer: L & CompleteInput<L>, program: CompleteExecution<ProvidedEnvironment<L>, A>, options?: RuntimeOptionsInput): Promise<Awaited<A>>;
|
|
79
|
+
static run<A, L extends LayerInput>(layer: L & CompleteInput<L>, options: RuntimeOptionsInput, program: CompleteExecution<ProvidedEnvironment<L>, A>): Promise<Awaited<A>>;
|
|
80
|
+
/** Run a callback with a managed Runtime and always dispose it afterward. */
|
|
81
|
+
static use<A, L extends LayerInput>(layer: L & CompleteInput<L>, use: (runtime: Runtime<ProvidedEnvironment<L>>) => A | PromiseLike<A>, options?: RuntimeOptions): Promise<Awaited<A>>;
|
|
82
|
+
/** Resolve every Layer provider and dispose the Runtime if warmup fails. */
|
|
83
|
+
warmup(): Promise<void>;
|
|
84
|
+
/** Return a detached diagnostic snapshot without changing Runtime state. */
|
|
85
|
+
inspect(): RuntimeInspection;
|
|
86
|
+
/** Run one execution in this Runtime's child Scope. */
|
|
87
|
+
run<A>(program: CompleteExecution<Provided, A>, options?: RuntimeRunOptions): Promise<Awaited<A>>;
|
|
88
|
+
/** Run one execution with a Layer owned by that execution's child Scope. */
|
|
89
|
+
runWith<Request extends LayerInput, A>(layer: Request & CompleteExecutionLayer<Provided, Request>, program: CompleteExecution<Provided | ProvidedEnvironment<Request>, A>, options?: RuntimeRunOptions): Promise<Awaited<A>>;
|
|
90
|
+
private runUnchecked;
|
|
91
|
+
/** Stop new executions and release the Runtime's Layer resources. */
|
|
92
|
+
dispose(options?: RuntimeDisposeOptions): Promise<void>;
|
|
93
|
+
/** @deprecated Scope outcomes are kept for internal compatibility. */
|
|
94
|
+
dispose(outcome: ScopeOutcome): Promise<void>;
|
|
95
|
+
/** Release Runtime-owned resources through JavaScript's async disposal protocol. */
|
|
96
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
97
|
+
private disposeWithOutcome;
|
|
98
|
+
}
|
|
99
|
+
/** Type-level aliases for naming Runtime handles and shutdown options. */
|
|
100
|
+
declare namespace Runtime {
|
|
101
|
+
/** Name a Runtime type from a concrete Layer. */
|
|
102
|
+
type For<L extends LayerInput> = RuntimeFor<L>;
|
|
103
|
+
/** Optional Runtime shutdown configuration. */
|
|
104
|
+
type Options = RuntimeOptions;
|
|
105
|
+
/** Optional signal supplied to one managed Runtime execution. */
|
|
106
|
+
type RunOptions = RuntimeRunOptions;
|
|
107
|
+
/** Cooperative shutdown policy for a managed Runtime. */
|
|
108
|
+
type DisposeOptions = RuntimeDisposeOptions;
|
|
109
|
+
/** Diagnostic reported for aggregated Runtime shutdown cleanup failures. */
|
|
110
|
+
type ShutdownDiagnostic = RuntimeShutdownDiagnostic;
|
|
111
|
+
/** Detached diagnostic snapshot returned by `Runtime.inspect()`. */
|
|
112
|
+
type Inspection = RuntimeInspection;
|
|
113
|
+
/** Detached diagnostic view of one active execution. */
|
|
114
|
+
type ExecutionInspection = RuntimeExecutionInspection;
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region src/runtime/signal.d.ts
|
|
118
|
+
/** Yieldable access to the signal of the current Runtime execution. */
|
|
119
|
+
declare const CurrentAbortSignal: {
|
|
120
|
+
readonly [Symbol.iterator]: () => Generator<never, AbortSignal, unknown>;
|
|
121
|
+
};
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region src/function/pipe.d.ts
|
|
124
|
+
type Unary<A, B> = (value: A) => B;
|
|
125
|
+
declare function pipe<A>(value: A): A;
|
|
126
|
+
declare function pipe<A, B>(value: A, ab: Unary<A, B>): B;
|
|
127
|
+
declare function pipe<A, B, C>(value: A, ab: Unary<A, B>, bc: Unary<B, C>): C;
|
|
128
|
+
declare function pipe<A, B, C, D>(value: A, ab: Unary<A, B>, bc: Unary<B, C>, cd: Unary<C, D>): D;
|
|
129
|
+
declare function pipe<A, B, C, D, E>(value: A, ab: Unary<A, B>, bc: Unary<B, C>, cd: Unary<C, D>, de: Unary<D, E>): E;
|
|
130
|
+
declare function pipe<A, B, C, D, E, F>(value: A, ab: Unary<A, B>, bc: Unary<B, C>, cd: Unary<C, D>, de: Unary<D, E>, ef: Unary<E, F>): F;
|
|
131
|
+
declare function pipe<A, B, C, D, E, F, G>(value: A, ab: Unary<A, B>, bc: Unary<B, C>, cd: Unary<C, D>, de: Unary<D, E>, ef: Unary<E, F>, fg: Unary<F, G>): G;
|
|
132
|
+
declare function pipe<A, B, C, D, E, F, G, H>(value: A, ab: Unary<A, B>, bc: Unary<B, C>, cd: Unary<C, D>, de: Unary<D, E>, ef: Unary<E, F>, fg: Unary<F, G>, gh: Unary<G, H>): H;
|
|
133
|
+
declare function pipe<A, B, C, D, E, F, G, H, I>(value: A, ab: Unary<A, B>, bc: Unary<B, C>, cd: Unary<C, D>, de: Unary<D, E>, ef: Unary<E, F>, fg: Unary<F, G>, gh: Unary<G, H>, hi: Unary<H, I>): I;
|
|
134
|
+
declare function pipe<A, B, C, D, E, F, G, H, I, J>(value: A, ab: Unary<A, B>, bc: Unary<B, C>, cd: Unary<C, D>, de: Unary<D, E>, ef: Unary<E, F>, fg: Unary<F, G>, gh: Unary<G, H>, hi: Unary<H, I>, ij: Unary<I, J>): J;
|
|
135
|
+
declare function pipe<A, B, C, D, E, F, G, H, I, J, K>(value: A, ab: Unary<A, B>, bc: Unary<B, C>, cd: Unary<C, D>, de: Unary<D, E>, ef: Unary<E, F>, fg: Unary<F, G>, gh: Unary<G, H>, hi: Unary<H, I>, ij: Unary<I, J>, jk: Unary<J, K>): K;
|
|
136
|
+
//#endregion
|
|
137
|
+
//#region src/resource/errors.d.ts
|
|
138
|
+
declare const ResourceReleaseFailure_base: import("better-result").TaggedErrorClass<"ResourceReleaseFailure">;
|
|
139
|
+
/** Describes a failure encountered while releasing a Resource. */
|
|
140
|
+
declare class ResourceReleaseFailure extends ResourceReleaseFailure_base<{
|
|
141
|
+
readonly resource: string;
|
|
142
|
+
readonly cause: unknown;
|
|
143
|
+
readonly message: string;
|
|
144
|
+
}> {}
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region src/resource/types.d.ts
|
|
147
|
+
/** A value that may be delivered synchronously or through a thenable. */
|
|
148
|
+
type MaybePromise<T> = T | PromiseLike<T>;
|
|
149
|
+
/** A synchronous or asynchronous better-result Result operation. */
|
|
150
|
+
type AsyncResult<T, E> = MaybePromise<Result<T, E>>;
|
|
151
|
+
/** The allowed return value of a custom Resource release callback. */
|
|
152
|
+
type ReleaseOutcome = void | Result<void, unknown>;
|
|
153
|
+
/** Receives release failures for diagnostics without changing error precedence. */
|
|
154
|
+
type ReleaseFailureObserver = (failure: ResourceReleaseFailure) => MaybePromise<void>;
|
|
155
|
+
/** Options controlling `Resource.acquireUseRelease`. */
|
|
156
|
+
type AcquireUseReleaseOptions<R, A, AcquireError, UseError> = {
|
|
157
|
+
/** Human-readable name included in release failures. */
|
|
158
|
+
readonly name: string;
|
|
159
|
+
/** Acquire the resource. A failure skips use and release. */
|
|
160
|
+
readonly acquire: () => AsyncResult<R, AcquireError>;
|
|
161
|
+
/** Use the acquired resource. Release is attempted afterward. */
|
|
162
|
+
readonly use: (resource: R) => AsyncResult<A, UseError>;
|
|
163
|
+
/** Release the resource, or omit it to use its disposal protocol. */
|
|
164
|
+
readonly release?: (resource: R) => MaybePromise<ReleaseOutcome>;
|
|
165
|
+
/**
|
|
166
|
+
* Observe cleanup failures without changing error precedence. This is most
|
|
167
|
+
* useful when both `use` and `release` can fail.
|
|
168
|
+
*/
|
|
169
|
+
readonly onReleaseFailure?: ReleaseFailureObserver;
|
|
170
|
+
};
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region src/resource/resource.d.ts
|
|
173
|
+
declare const Resource: {
|
|
174
|
+
/** Acquire, use, and release a resource with deterministic error precedence. */
|
|
175
|
+
readonly acquireUseRelease: <R, A, AcquireError, UseError>({ name, acquire, use, release, onReleaseFailure }: AcquireUseReleaseOptions<R, A, AcquireError, UseError>) => Promise<Result<A, AcquireError | UseError | UnhandledException | ResourceReleaseFailure>>;
|
|
176
|
+
};
|
|
177
|
+
//#endregion
|
|
178
|
+
export { ReleaseOutcome as a, CurrentAbortSignal as c, RuntimeFor as d, RuntimeInspection as f, ReleaseFailureObserver as i, Runtime as l, AcquireUseReleaseOptions as n, ResourceReleaseFailure as o, AsyncResult as r, pipe as s, Resource as t, RuntimeExecutionInspection as u };
|
|
179
|
+
//# sourceMappingURL=index-GYJ4qm9K.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-GYJ4qm9K.d.mts","names":[],"sources":["../src/runtime/types.ts","../src/runtime/runtime.ts","../src/runtime/signal.ts","../src/function/pipe.ts","../src/resource/errors.ts","../src/resource/types.ts","../src/resource/resource.ts"],"mappings":";;;;;;;KAMY;WACD;WACA;WACA;;;;;;;;;KAUC;WACD;WACA;WACA;WACA,qBAAqB;WACrB;WACA;;;;;;;;;;;KAYC,WAAW,UAAU,cAAc,QAAQ,MAAM,SAAS;;;KCNjE,sBAAsB,iBAAiB;;;;;;;;;;;;;;;;cA8C/B,QAAQ,iBAAiB;mBACC;UAA9B;;;;;;;;;;;SAYA,KAAK,UAAU,YACpB,OAAO,IAAI,cAAc,IACzB,SAAS,cACT,UAAU,iBACT,QAAQ,QAAQ,oBAAoB;SAEhC,KAAK,UAAU,YACpB,OAAO,IAAI,cAAc,IACzB,UAAU,iBACT,QAAQ,QAAQ,oBAAoB;;;;;;;SAwBhC,IAAI,GAAG,UAAU,YACtB,OAAO,IAAI,cAAc,IACzB,SAAS,cACT,SAAS,kBAAkB,oBAAoB,IAAI,IACnD,UAAU,sBACT,QAAQ,QAAQ;SAEZ,IAAI,GAAG,UAAU,YACtB,OAAO,IAAI,cAAc,IACzB,SAAS,kBAAkB,oBAAoB,IAAI,IACnD,UAAU,sBACT,QAAQ,QAAQ;SAEZ,IAAI,GAAG,UAAU,YACtB,OAAO,IAAI,cAAc,IACzB,SAAS,qBACT,SAAS,kBAAkB,oBAAoB,IAAI,KAClD,QAAQ,QAAQ;;SA2EZ,IAAI,GAAG,UAAU,YACtB,OAAO,IAAI,cAAc,I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AG,IACb,IAAI,MAAM,GAAG,IACb,IAAI,MAAM,GAAG,IACb,IAAI,MAAM,GAAG,IACb,IAAI,MAAM,GAAG,KACZ;;;;;cC3FU,+BAA+B;WACjC;WACA;WACA;;;;;KCCC,aAAa,KAAK,IAAI,YAAY;;KAGlC,YAAY,GAAG,KAAK,aAAa,OAAW,GAAG;;KAG/C,wBAAwB;;KAGxB,0BAA0B,SAAS,2BAA2B;;KAG9D,yBAAyB,GAAG,GAAG,cAAc;;WAE9C;;WAGA,eAAe,YAAY,GAAG;;WAG9B,MAAM,UAAU,MAAM,YAAY,GAAG;;WAGrC,WAAW,UAAU,MAAM,aAAa;;;;;WAMxC,mBAAmB;;;;cCqBjB;;WA3Bc,oBAAA,GAAG,GAAG,cAAc,YAAQ,MAAA,SAAA,KAAA,SAAA,oBAMpD,yBAAyB,GAAG,GAAG,cAAc,cAAY,QAC1D,OAAW,GAAG,eAAe,WAAW,qBAAqB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-heuaRmXR.d.mts","names":[],"sources":["../src/service/types.ts","../src/effect/types.ts","../src/service/service.ts","../src/scope/errors.ts","../src/scope/types.ts","../src/scope/scope.ts","../src/runtime/context.ts","../src/service/runtime.ts","../src/service/errors.ts"],"mappings":";;;cAGqB;;UAGJ,oBAAoB;YACzB,wBAAwB;;;KAIxB,aAAa;;KAGb,gBAAgB,KAAK,oBAAoB,KAAK,UAAU;KAExD,mBAAmB,2BAA2B,iBAAiB;WAChE;WACA,YAAY;;WAGZ,KAAK,YAAY,gBAAgB,gBAAgB,cAAc;;KAGrE,+BAA+B,6BAA6B,gBAAgB;;UAGhE,iBACX,oCACG,iBAAiB,0BAEhB,2BAA2B,WAAW,eAAe,KAAK;;KAGxD,kBAAkB;;KAGlB,aACV,6BACA,iBAAiB,aAAa,uBACnB,gBAAgB,YAAY,eAAe,KAAK;;KAGjD,gBAAgB,UAAU,mBAAmB,aAAa;;KAG1D,aAAa,UAAU,cAAc,SAAS;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;KAIzC,qBAAqB,OAAO,iBAAiB,oBAAwB,QAC/E,QAAQ,WACR,gBAAgB,SAAS,SAAS,WAClC,uBAAuB,SAAS,mBAAmB;;;
|
|
1
|
+
{"version":3,"file":"index-heuaRmXR.d.mts","names":[],"sources":["../src/service/types.ts","../src/effect/types.ts","../src/service/service.ts","../src/scope/errors.ts","../src/scope/types.ts","../src/scope/scope.ts","../src/runtime/context.ts","../src/service/runtime.ts","../src/service/errors.ts"],"mappings":";;;cAGqB;;UAGJ,oBAAoB;YACzB,wBAAwB;;;KAIxB,aAAa;;KAGb,gBAAgB,KAAK,oBAAoB,KAAK,UAAU;KAExD,mBAAmB,2BAA2B,iBAAiB;WAChE;WACA,YAAY;;WAGZ,KAAK,YAAY,gBAAgB,gBAAgB,cAAc;;KAGrE,+BAA+B,6BAA6B,gBAAgB;;UAGhE,iBACX,oCACG,iBAAiB,0BAEhB,2BAA2B,WAAW,eAAe,KAAK;;KAGxD,kBAAkB;;KAGlB,aACV,6BACA,iBAAiB,aAAa,uBACnB,gBAAgB,YAAY,eAAe,KAAK;;KAGjD,gBAAgB,UAAU,mBAAmB,aAAa;;KAG1D,aAAa,UAAU,cAAc,SAAS;;KAG9C,eAAe,UAAU,cAAc,UAAU,aACzD,aAAa,aAAa,IAAI;;KAItB,WAAW,UAAU,aAAa,mBAAmB,UAAU,aACvE,aAAa,KACb,UAAU,kBACR;KAGD,mBAAmB,QACrB,WAAW,IAAI,EAAE,gBAAe,sBAAsB,UAAS,mBAAmB,yBAC7E;;;;;;;KAQI,oBAAoB,UAAU,cAAc,mBAAmB;;;KClEtE,cAAc;;KAGd,eAAe,GAAG,GAAG,UAAU;GACjC,OAAO,aAAa,UAAU,WAAW,KAAK,mBAAmB,IAAI;;KAGnE,cAAc,GAAG,GAAG,UAAU;EACjC,IAAI,GAAG,KAAK,OAAO,MAAM,IAAI,OAAO,GAAG,GAAG;EAC1C,SAAS,IAAI,KAAK,OAAO,MAAM,KAAK,OAAO,GAAG,IAAI;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eAAe,IAAI;EACnD,WAAW;;;;;UCJI;;EAEf,QAAQ,UAAU,iBAAiB,OAAO,IAAI,aAAa,KAAK,YAAY,aAAa;;;cAI9E;;;;;;;;;;;;;SAaJ,IAAI,GACT,UAAU,iBACV,eAAe,GACf,UAAS,wBACR;;SAcI,WAAW;;SAqBL,QAAQ,UAAU,iBAAiB,OAAO,IAAI,QAAQ,aAAa;;;;;cCtErE,yCAAyC;EAAA;;;cASzC,6BAA6B;WACnB,SAAS;EAAT,YAAA,SAAS;;;cAQnB,gCAAgC;WAClC,eAAe;EAEZ,YAAA,eAAe;;;cAWhB,gCAAgC;WAIhC,SAAS;WAHF;EAGP,YAAA,SAAS,iBAClB,yBAAyB,mBACzB;WAgBO,yBAAyB"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { B as ServiceTag, C as EffectError, D as EffectYield, E as EffectSuccess, F as ServiceContract, H as ServiceToken, I as ServiceIdentity, M as AnyService, N as AnyServiceToken, P as ServiceClass, R as ServiceInstance, T as EffectRequirements, U as ServiceTokenOf, _ as ScopeCloseError, a as ServiceResolver, b as Service, c as RuntimeContextStorage, d as CleanupFailureDiagnostic, f as DisposableResource, g as ResourceNotDisposableError, h as ScopeOutcome, i as ServiceRuntimeNotConfiguredError, j as ServiceRequirement, l as CloseableScope, m as ScopeFinalizer, n as ServiceAcquisitionError, o as ServiceRuntime, r as ServiceNotFoundError, s as RuntimeContext, t as CircularDependencyError, u as Scope, v as ScopeClosedError, x as AnyEffect, y as ScopeRuntimeNotConfiguredError, z as ServiceRequirements } from "./index-heuaRmXR.mjs";
|
|
2
|
-
import { _ as
|
|
3
|
-
import {
|
|
2
|
+
import { S as LayerRegistration, _ as LayerRegistrationError, a as RuntimeShutdownDiagnostic, b as LayerBackendDisposeOptions, c as RuntimeExecutionMetadata, d as RuntimeResourceReleaseEvent, f as RuntimeServiceAcquireEvent, g as LayerGeneratorYieldError, h as LayerDisposeError, i as RuntimeRunOptions, l as RuntimeExecutionStartEvent, m as DuplicateServiceError, n as RuntimeDisposeOptions, o as RuntimeExecutionAttributes, p as RuntimeServiceResolveEvent, r as RuntimeOptions, s as RuntimeExecutionEndEvent, t as CleanupFailureObserver, u as RuntimeObserver, v as ServiceTagCollisionError, x as Layer, y as LayerBackend } from "./outcome-CB43bnFW.mjs";
|
|
3
|
+
import { t as MapLayerBackend } from "./index-BMdU_Z72.mjs";
|
|
4
|
+
import { a as ReleaseOutcome, c as CurrentAbortSignal, d as RuntimeFor, f as RuntimeInspection, i as ReleaseFailureObserver, l as Runtime, n as AcquireUseReleaseOptions, o as ResourceReleaseFailure, r as AsyncResult, s as pipe, t as Resource, u as RuntimeExecutionInspection } from "./index-GYJ4qm9K.mjs";
|
|
4
5
|
import { t as RuntimeContextNotConfiguredError } from "./errors-BKcsQ0ip.mjs";
|
|
5
|
-
|
|
6
|
+
import { n as Program, r as ProgramAllOptions, t as Effect } from "./index-CX6iAoCB.mjs";
|
|
7
|
+
export { type AcquireUseReleaseOptions, type AnyEffect, type AnyService, type AnyServiceToken, type AsyncResult, CircularDependencyError, type CleanupFailureDiagnostic, type CleanupFailureObserver, type CloseableScope, CurrentAbortSignal, type DisposableResource, DuplicateServiceError, Effect, type EffectError, type EffectRequirements, type EffectSuccess, type EffectYield, Layer, type LayerBackend, type LayerBackendDisposeOptions, LayerDisposeError, LayerGeneratorYieldError, type LayerRegistration, LayerRegistrationError, MapLayerBackend, Program, type ProgramAllOptions, type ReleaseFailureObserver, type ReleaseOutcome, Resource, ResourceNotDisposableError, ResourceReleaseFailure, Runtime, type RuntimeContext, RuntimeContextNotConfiguredError, type RuntimeContextStorage, type RuntimeDisposeOptions, type RuntimeExecutionAttributes, type RuntimeExecutionEndEvent, type RuntimeExecutionInspection, type RuntimeExecutionMetadata, type RuntimeExecutionStartEvent, type RuntimeFor, type RuntimeInspection, RuntimeObserver, type RuntimeOptions, type RuntimeResourceReleaseEvent, type RuntimeRunOptions, type RuntimeServiceAcquireEvent, type RuntimeServiceResolveEvent, type RuntimeShutdownDiagnostic, Scope, ScopeCloseError, ScopeClosedError, type ScopeFinalizer, type ScopeOutcome, ScopeRuntimeNotConfiguredError, Service, ServiceAcquisitionError, type ServiceClass, type ServiceContract, type ServiceIdentity, type ServiceInstance, ServiceNotFoundError, type ServiceRequirement, type ServiceRequirements, type ServiceResolver, ServiceRuntime, ServiceRuntimeNotConfiguredError, type ServiceTag, ServiceTagCollisionError, type ServiceToken, type ServiceTokenOf, pipe };
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as LayerGeneratorYieldError, c as CircularDependencyError, d as ServiceRuntimeNotConfiguredError, i as LayerDisposeError, l as ServiceAcquisitionError, o as LayerRegistrationError, r as DuplicateServiceError, s as ServiceTagCollisionError, u as ServiceNotFoundError } from "./registration-drnZk0SY.mjs";
|
|
2
2
|
import { h as RuntimeContextNotConfiguredError } from "./context-BUEf1qjL.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { t as
|
|
5
|
-
import { i as
|
|
6
|
-
import { n as
|
|
3
|
+
import { a as ResourceNotDisposableError, c as ScopeRuntimeNotConfiguredError, o as ScopeCloseError, r as disposeResource, s as ScopeClosedError, t as CurrentAbortSignal } from "./signal-D2UTcaaG.mjs";
|
|
4
|
+
import { n as Service, r as ServiceRuntime, t as Layer } from "./layer-D56fRdLt.mjs";
|
|
5
|
+
import { i as Scope } from "./program-metadata-DhQCCirO.mjs";
|
|
6
|
+
import { i as MapLayerBackend, n as RuntimeObserver, t as Runtime } from "./runtime-CBMrX8Wl.mjs";
|
|
7
|
+
import { n as Program, t as Effect } from "./effect-CK4YZaX0.mjs";
|
|
7
8
|
import { Result, TaggedError } from "better-result";
|
|
8
9
|
//#region src/function/pipe.ts
|
|
9
10
|
function pipe(value, ...operations) {
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/function/pipe.ts","../src/resource/errors.ts","../src/resource/internal.ts","../src/resource/resource.ts"],"sourcesContent":["type Unary<A, B> = (value: A) => B\n\n/**\n * Compose a value through a sequence of unary functions.\n *\n * `pipe` is deliberately independent of Effect, Result, Promise, Scope, and\n * Service metadata.\n *\n * @example\n * ```ts\n * const label = pipe(\n * 'alice',\n * (name) => name.trim(),\n * (name) => name.toUpperCase()\n * )\n * ```\n */\ntype PipeRuntimeValue = Parameters<Unary<any, any>>[0]\n\ntype PipeRuntimeOperation = Unary<PipeRuntimeValue, PipeRuntimeValue>\n\nexport function pipe<A>(value: A): A\nexport function pipe<A, B>(value: A, ab: Unary<A, B>): B\nexport function pipe<A, B, C>(value: A, ab: Unary<A, B>, bc: Unary<B, C>): C\nexport function pipe<A, B, C, D>(value: A, ab: Unary<A, B>, bc: Unary<B, C>, cd: Unary<C, D>): D\nexport function pipe<A, B, C, D, E>(\n value: A,\n ab: Unary<A, B>,\n bc: Unary<B, C>,\n cd: Unary<C, D>,\n de: Unary<D, E>\n): E\nexport function pipe<A, B, C, D, E, F>(\n value: A,\n ab: Unary<A, B>,\n bc: Unary<B, C>,\n cd: Unary<C, D>,\n de: Unary<D, E>,\n ef: Unary<E, F>\n): F\nexport function pipe<A, B, C, D, E, F, G>(\n value: A,\n ab: Unary<A, B>,\n bc: Unary<B, C>,\n cd: Unary<C, D>,\n de: Unary<D, E>,\n ef: Unary<E, F>,\n fg: Unary<F, G>\n): G\nexport function pipe<A, B, C, D, E, F, G, H>(\n value: A,\n ab: Unary<A, B>,\n bc: Unary<B, C>,\n cd: Unary<C, D>,\n de: Unary<D, E>,\n ef: Unary<E, F>,\n fg: Unary<F, G>,\n gh: Unary<G, H>\n): H\nexport function pipe<A, B, C, D, E, F, G, H, I>(\n value: A,\n ab: Unary<A, B>,\n bc: Unary<B, C>,\n cd: Unary<C, D>,\n de: Unary<D, E>,\n ef: Unary<E, F>,\n fg: Unary<F, G>,\n gh: Unary<G, H>,\n hi: Unary<H, I>\n): I\nexport function pipe<A, B, C, D, E, F, G, H, I, J>(\n value: A,\n ab: Unary<A, B>,\n bc: Unary<B, C>,\n cd: Unary<C, D>,\n de: Unary<D, E>,\n ef: Unary<E, F>,\n fg: Unary<F, G>,\n gh: Unary<G, H>,\n hi: Unary<H, I>,\n ij: Unary<I, J>\n): J\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K>(\n value: A,\n ab: Unary<A, B>,\n bc: Unary<B, C>,\n cd: Unary<C, D>,\n de: Unary<D, E>,\n ef: Unary<E, F>,\n fg: Unary<F, G>,\n gh: Unary<G, H>,\n hi: Unary<H, I>,\n ij: Unary<I, J>,\n jk: Unary<J, K>\n): K\nexport function pipe(\n value: PipeRuntimeValue,\n ...operations: ReadonlyArray<PipeRuntimeOperation>\n): PipeRuntimeValue {\n return operations.reduce((current, operation) => operation(current), value)\n}\n","import { TaggedError } from 'better-result'\n\n/** Describes a failure encountered while releasing a Resource. */\nexport class ResourceReleaseFailure extends TaggedError('ResourceReleaseFailure')<{\n readonly resource: string\n readonly cause: unknown\n readonly message: string\n}> {}\n","import { Result, type Result as ResultType, type UnhandledException } from 'better-result'\n\nimport { ResourceReleaseFailure } from './errors'\n\nimport { disposeResource } from '../scope/disposable'\n\nexport { disposeResource }\n\nimport type { AsyncResult, MaybePromise, ReleaseFailureObserver, ReleaseOutcome } from './types'\n\nconst toReleaseFailure = (resource: string, cause: unknown): ResourceReleaseFailure =>\n new ResourceReleaseFailure({\n resource,\n cause,\n message: `Failed to release resource: ${resource}`\n })\n\nexport const runResult = async <T, E>(\n operation: () => AsyncResult<T, E>\n): Promise<ResultType<T, E | UnhandledException>> => {\n const execution = await Result.tryPromise(() => Promise.resolve(operation()))\n\n return execution.andThen((result) => result)\n}\n\nconst normalizeReleaseOutcome = (\n name: string,\n outcome: ReleaseOutcome\n): ResultType<void, ResourceReleaseFailure> => {\n if (outcome === undefined) {\n return Result.ok()\n }\n\n return outcome.mapError((cause) => toReleaseFailure(name, cause))\n}\n\nexport const runRelease = async <R>(\n name: string,\n resource: R,\n release: (resource: R) => MaybePromise<ReleaseOutcome>\n): Promise<ResultType<void, ResourceReleaseFailure>> => {\n const execution = await Result.tryPromise({\n try: () => Promise.resolve(release(resource)),\n catch: (cause) => toReleaseFailure(name, cause)\n })\n\n return execution.andThen((outcome) => normalizeReleaseOutcome(name, outcome))\n}\n\nconst notifyReleaseFailure = async (\n observer: ReleaseFailureObserver | undefined,\n\n failure: ResourceReleaseFailure\n): Promise<void> => {\n if (!observer) {\n return\n }\n\n try {\n await observer(failure)\n } catch {\n /*\n * Diagnostics must never replace\n * the actual operation error.\n */\n }\n}\n\nexport const combineUseAndRelease = async <A, E>(\n used: ResultType<A, E>,\n\n released: ResultType<void, ResourceReleaseFailure>,\n\n onReleaseFailure?: ReleaseFailureObserver\n): Promise<ResultType<A, E | ResourceReleaseFailure>> => {\n if (Result.isError(used)) {\n if (Result.isError(released)) {\n await notifyReleaseFailure(onReleaseFailure, released.error)\n }\n\n return Result.err<A, E | ResourceReleaseFailure>(used.error)\n }\n\n if (Result.isError(released)) {\n await notifyReleaseFailure(onReleaseFailure, released.error)\n\n return Result.err<A, E | ResourceReleaseFailure>(released.error)\n }\n\n return Result.ok<A, E | ResourceReleaseFailure>(used.value)\n}\n","import { Result, type Result as ResultType, type UnhandledException } from 'better-result'\n\nimport { Scope } from '../scope'\n\nimport { ResourceReleaseFailure } from './errors'\n\nimport { combineUseAndRelease, disposeResource, runRelease, runResult } from './internal'\n\nimport type { AcquireUseReleaseOptions } from './types'\n\n/**\n * Acquire a resource, use it, and always attempt release afterward.\n *\n * Acquisition, use, and release may be synchronous or asynchronous Result\n * operations. If both use and release fail, the use error remains primary and\n * `onReleaseFailure` receives the cleanup failure as a diagnostic.\n *\n * When `release` is omitted, `Symbol.asyncDispose` is preferred over\n * `Symbol.dispose`.\n *\n * @example\n * ```ts\n * const result = await Resource.acquireUseRelease({\n * name: 'database connection',\n * acquire: () => connect(),\n * use: (connection) => query(connection),\n * release: (connection) => connection.close()\n * })\n * ```\n */\nconst acquireUseRelease = <R, A, AcquireError, UseError>({\n name,\n acquire,\n use,\n release = disposeResource,\n onReleaseFailure\n}: AcquireUseReleaseOptions<R, A, AcquireError, UseError>): Promise<\n ResultType<A, AcquireError | UseError | UnhandledException | ResourceReleaseFailure>\n> =>\n Result.gen(async function* () {\n const resource = yield* Result.await(runResult(acquire))\n\n const scope = Scope.make()\n\n let released: ResultType<void, ResourceReleaseFailure> = Result.ok()\n\n scope.addFinalizer(async () => {\n released = await runRelease(name, resource, release)\n })\n\n const used = await runResult(() => use(resource))\n\n await scope.close()\n\n return await combineUseAndRelease(used, released, onReleaseFailure)\n })\n\nexport const Resource = {\n /** Acquire, use, and release a resource with deterministic error precedence. */\n acquireUseRelease\n} as const\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/function/pipe.ts","../src/resource/errors.ts","../src/resource/internal.ts","../src/resource/resource.ts"],"sourcesContent":["type Unary<A, B> = (value: A) => B\n\n/**\n * Compose a value through a sequence of unary functions.\n *\n * `pipe` is deliberately independent of Effect, Result, Promise, Scope, and\n * Service metadata.\n *\n * @example\n * ```ts\n * const label = pipe(\n * 'alice',\n * (name) => name.trim(),\n * (name) => name.toUpperCase()\n * )\n * ```\n */\ntype PipeRuntimeValue = Parameters<Unary<any, any>>[0]\n\ntype PipeRuntimeOperation = Unary<PipeRuntimeValue, PipeRuntimeValue>\n\nexport function pipe<A>(value: A): A\nexport function pipe<A, B>(value: A, ab: Unary<A, B>): B\nexport function pipe<A, B, C>(value: A, ab: Unary<A, B>, bc: Unary<B, C>): C\nexport function pipe<A, B, C, D>(value: A, ab: Unary<A, B>, bc: Unary<B, C>, cd: Unary<C, D>): D\nexport function pipe<A, B, C, D, E>(\n value: A,\n ab: Unary<A, B>,\n bc: Unary<B, C>,\n cd: Unary<C, D>,\n de: Unary<D, E>\n): E\nexport function pipe<A, B, C, D, E, F>(\n value: A,\n ab: Unary<A, B>,\n bc: Unary<B, C>,\n cd: Unary<C, D>,\n de: Unary<D, E>,\n ef: Unary<E, F>\n): F\nexport function pipe<A, B, C, D, E, F, G>(\n value: A,\n ab: Unary<A, B>,\n bc: Unary<B, C>,\n cd: Unary<C, D>,\n de: Unary<D, E>,\n ef: Unary<E, F>,\n fg: Unary<F, G>\n): G\nexport function pipe<A, B, C, D, E, F, G, H>(\n value: A,\n ab: Unary<A, B>,\n bc: Unary<B, C>,\n cd: Unary<C, D>,\n de: Unary<D, E>,\n ef: Unary<E, F>,\n fg: Unary<F, G>,\n gh: Unary<G, H>\n): H\nexport function pipe<A, B, C, D, E, F, G, H, I>(\n value: A,\n ab: Unary<A, B>,\n bc: Unary<B, C>,\n cd: Unary<C, D>,\n de: Unary<D, E>,\n ef: Unary<E, F>,\n fg: Unary<F, G>,\n gh: Unary<G, H>,\n hi: Unary<H, I>\n): I\nexport function pipe<A, B, C, D, E, F, G, H, I, J>(\n value: A,\n ab: Unary<A, B>,\n bc: Unary<B, C>,\n cd: Unary<C, D>,\n de: Unary<D, E>,\n ef: Unary<E, F>,\n fg: Unary<F, G>,\n gh: Unary<G, H>,\n hi: Unary<H, I>,\n ij: Unary<I, J>\n): J\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K>(\n value: A,\n ab: Unary<A, B>,\n bc: Unary<B, C>,\n cd: Unary<C, D>,\n de: Unary<D, E>,\n ef: Unary<E, F>,\n fg: Unary<F, G>,\n gh: Unary<G, H>,\n hi: Unary<H, I>,\n ij: Unary<I, J>,\n jk: Unary<J, K>\n): K\nexport function pipe(\n value: PipeRuntimeValue,\n ...operations: ReadonlyArray<PipeRuntimeOperation>\n): PipeRuntimeValue {\n return operations.reduce((current, operation) => operation(current), value)\n}\n","import { TaggedError } from 'better-result'\n\n/** Describes a failure encountered while releasing a Resource. */\nexport class ResourceReleaseFailure extends TaggedError('ResourceReleaseFailure')<{\n readonly resource: string\n readonly cause: unknown\n readonly message: string\n}> {}\n","import { Result, type Result as ResultType, type UnhandledException } from 'better-result'\n\nimport { ResourceReleaseFailure } from './errors'\n\nimport { disposeResource } from '../scope/disposable'\n\nexport { disposeResource }\n\nimport type { AsyncResult, MaybePromise, ReleaseFailureObserver, ReleaseOutcome } from './types'\n\nconst toReleaseFailure = (resource: string, cause: unknown): ResourceReleaseFailure =>\n new ResourceReleaseFailure({\n resource,\n cause,\n message: `Failed to release resource: ${resource}`\n })\n\nexport const runResult = async <T, E>(\n operation: () => AsyncResult<T, E>\n): Promise<ResultType<T, E | UnhandledException>> => {\n const execution = await Result.tryPromise(() => Promise.resolve(operation()))\n\n return execution.andThen((result) => result)\n}\n\nconst normalizeReleaseOutcome = (\n name: string,\n outcome: ReleaseOutcome\n): ResultType<void, ResourceReleaseFailure> => {\n if (outcome === undefined) {\n return Result.ok()\n }\n\n return outcome.mapError((cause) => toReleaseFailure(name, cause))\n}\n\nexport const runRelease = async <R>(\n name: string,\n resource: R,\n release: (resource: R) => MaybePromise<ReleaseOutcome>\n): Promise<ResultType<void, ResourceReleaseFailure>> => {\n const execution = await Result.tryPromise({\n try: () => Promise.resolve(release(resource)),\n catch: (cause) => toReleaseFailure(name, cause)\n })\n\n return execution.andThen((outcome) => normalizeReleaseOutcome(name, outcome))\n}\n\nconst notifyReleaseFailure = async (\n observer: ReleaseFailureObserver | undefined,\n\n failure: ResourceReleaseFailure\n): Promise<void> => {\n if (!observer) {\n return\n }\n\n try {\n await observer(failure)\n } catch {\n /*\n * Diagnostics must never replace\n * the actual operation error.\n */\n }\n}\n\nexport const combineUseAndRelease = async <A, E>(\n used: ResultType<A, E>,\n\n released: ResultType<void, ResourceReleaseFailure>,\n\n onReleaseFailure?: ReleaseFailureObserver\n): Promise<ResultType<A, E | ResourceReleaseFailure>> => {\n if (Result.isError(used)) {\n if (Result.isError(released)) {\n await notifyReleaseFailure(onReleaseFailure, released.error)\n }\n\n return Result.err<A, E | ResourceReleaseFailure>(used.error)\n }\n\n if (Result.isError(released)) {\n await notifyReleaseFailure(onReleaseFailure, released.error)\n\n return Result.err<A, E | ResourceReleaseFailure>(released.error)\n }\n\n return Result.ok<A, E | ResourceReleaseFailure>(used.value)\n}\n","import { Result, type Result as ResultType, type UnhandledException } from 'better-result'\n\nimport { Scope } from '../scope'\n\nimport { ResourceReleaseFailure } from './errors'\n\nimport { combineUseAndRelease, disposeResource, runRelease, runResult } from './internal'\n\nimport type { AcquireUseReleaseOptions } from './types'\n\n/**\n * Acquire a resource, use it, and always attempt release afterward.\n *\n * Acquisition, use, and release may be synchronous or asynchronous Result\n * operations. If both use and release fail, the use error remains primary and\n * `onReleaseFailure` receives the cleanup failure as a diagnostic.\n *\n * When `release` is omitted, `Symbol.asyncDispose` is preferred over\n * `Symbol.dispose`.\n *\n * @example\n * ```ts\n * const result = await Resource.acquireUseRelease({\n * name: 'database connection',\n * acquire: () => connect(),\n * use: (connection) => query(connection),\n * release: (connection) => connection.close()\n * })\n * ```\n */\nconst acquireUseRelease = <R, A, AcquireError, UseError>({\n name,\n acquire,\n use,\n release = disposeResource,\n onReleaseFailure\n}: AcquireUseReleaseOptions<R, A, AcquireError, UseError>): Promise<\n ResultType<A, AcquireError | UseError | UnhandledException | ResourceReleaseFailure>\n> =>\n Result.gen(async function* () {\n const resource = yield* Result.await(runResult(acquire))\n\n const scope = Scope.make()\n\n let released: ResultType<void, ResourceReleaseFailure> = Result.ok()\n\n scope.addFinalizer(async () => {\n released = await runRelease(name, resource, release)\n })\n\n const used = await runResult(() => use(resource))\n\n await scope.close()\n\n return await combineUseAndRelease(used, released, onReleaseFailure)\n })\n\nexport const Resource = {\n /** Acquire, use, and release a resource with deterministic error precedence. */\n acquireUseRelease\n} as const\n"],"mappings":";;;;;;;;;AA+FA,SAAgB,KACd,OACA,GAAG,YACe;CAClB,OAAO,WAAW,QAAQ,SAAS,cAAc,UAAU,OAAO,GAAG,KAAK;AAC5E;;;;ACjGA,IAAa,yBAAb,cAA4C,YAAY,wBAAwB,CAAC,CAI9E,CAAC;;;ACGJ,MAAM,oBAAo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AO,CAAC;CAEvD,MAAM,QAAQ,MAAM,KAAK;CAEzB,IAAI,WAAqD,OAAO,GAAG;CAEnE,MAAM,aAAa,YAAY;EAC7B,WAAW,MAAM,WAAW,MAAM,UAAU,OAAO;CACrD,CAAC;CAED,MAAM,OAAO,MAAM,gBAAgB,IAAI,QAAQ,CAAC;CAEhD,MAAM,MAAM,MAAM;CAElB,OAAO,MAAM,qBAAqB,MAAM,UAAU,gBAAgB;AACpE,CAAC;AAEH,MAAa,WAAW;;AAEtB,kBACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { f as captureServiceTag, s as ServiceTagCollisionError } from "./registration-drnZk0SY.mjs";
|
|
2
2
|
//#region src/layer/internal-identity.ts
|
|
3
3
|
const serviceMemberNames = (token) => {
|
|
4
4
|
const names = /* @__PURE__ */ new Set();
|
|
@@ -16,7 +16,7 @@ const serviceMemberNames = (token) => {
|
|
|
16
16
|
* check catches the common incompatible-method collision after erasure.
|
|
17
17
|
*/
|
|
18
18
|
const assertServiceCompatibility = (requested, registered, instance) => {
|
|
19
|
-
if (requested === registered || requested
|
|
19
|
+
if (requested === registered || captureServiceTag(requested) !== captureServiceTag(registered)) return;
|
|
20
20
|
const candidate = Object(instance);
|
|
21
21
|
if (candidate !== instance) throw new ServiceTagCollisionError(registered, requested);
|
|
22
22
|
for (const name of serviceMemberNames(requested)) if (!(name in candidate)) throw new ServiceTagCollisionError(registered, requested);
|
|
@@ -24,4 +24,4 @@ const assertServiceCompatibility = (requested, registered, instance) => {
|
|
|
24
24
|
//#endregion
|
|
25
25
|
export { assertServiceCompatibility as t };
|
|
26
26
|
|
|
27
|
-
//# sourceMappingURL=internal-identity-
|
|
27
|
+
//# sourceMappingURL=internal-identity-CbXoZIfw.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-identity-CbXoZIfw.mjs","names":[],"sources":["../src/layer/internal-identity.ts"],"sourcesContent":["import { captureServiceTag } from '../service/tag'\nimport type { AnyServiceToken } from '../service'\n\nimport { ServiceTagCollisionError } from './errors'\n\nimport type { LayerRegistration } from './types'\n\ntype LayerAcquiredValue = Awaited<ReturnType<LayerRegistration['acquire']>>\n\nconst serviceMemberNames = (token: AnyServiceToken): readonly (string | symbol)[] => {\n const names = new Set<string | symbol>()\n let prototype = token.prototype\n\n while (prototype && prototype !== Object.prototype) {\n for (const name of Object.getOwnPropertyNames(prototype)) {\n if (name !== 'constructor') {\n names.add(name)\n }\n }\n\n for (const symbol of Object.getOwnPropertySymbols(prototype)) {\n names.add(symbol)\n }\n\n prototype = Object.getPrototypeOf(prototype)\n }\n\n return [...names]\n}\n\n/**\n * Check the runtime portion of a same-tag association before returning it.\n * TypeScript remains authoritative for full structural compatibility; this\n * check catches the common incompatible-method collision after erasure.\n */\nexport const assertServiceCompatibility = (\n requested: AnyServiceToken,\n registered: AnyServiceToken,\n instance: LayerAcquiredValue\n): void => {\n if (requested === registered || captureServiceTag(requested) !== captureServiceTag(registered)) {\n return\n }\n\n const candidate = Object(instance)\n\n // SAFETY: Service providers are object instances; Object() lets this runtime boundary reject rogue primitive values without trusting their static type.\n if (candidate !== instance) {\n throw new ServiceTagCollisionError(registered, requested)\n }\n\n for (const name of serviceMemberNames(requested)) {\n if (!(name in candidate)) {\n throw new ServiceTagCollisionError(registered, requested)\n }\n }\n}\n"],"mappings":";;AASA,MAAM,sBAAsB,UAAyD;CACnF,MAAM,wBAAQ,IAAI,IAAqB;CACvC,IAAI,YAAY,MAAM;CAEtB,OAAO,aAAa,cAAc,OAAO,WAAW;EAClD,KAAK,MAAM,QAAQ,OAAO,oBAAoB,SAAS,GACrD,IAAI,SAAS,eACX,MAAM,IAAI,IAAI;EAIlB,KAAK,MAAM,UAAU,OAAO,sBAAsB,SAAS,GACzD,MAAM,IAAI,MAAM;EAGlB,YAAY,OAAO,eAAe,SAAS;CAC7C;CAEA,OAAO,CAAC,GAAG,KAAK;AAClB;;;;;;AAOA,MAAa,8BACX,WACA,YACA,aACS;CACT,IAAI,cAAc,cAAc,kBAAkB,SAAS,MAAM,kBAAkB,UAAU,GAC3F;CAGF,MAAM,YAAY,OAAO,QAAQ;CAGjC,IAAI,cAAc,UAChB,MAAM,IAAI,yBAAyB,YAAY,SAAS;CAG1D,KAAK,MAAM,QAAQ,mBAAmB,SAAS,GAC7C,IAAI,EAAE,QAAQ,YACZ,MAAM,IAAI,yBAAyB,YAAY,SAAS;AAG9D"}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
//#region src/runtime/default.ts
|
|
5
|
-
/** The Node/Bun storage used by the main Runtime entrypoint. */
|
|
6
|
-
const defaultRuntimeContextStorage = nodeRuntimeContextStorage;
|
|
7
|
-
setDefaultRuntimeContextStorage(defaultRuntimeContextStorage);
|
|
8
|
-
//#endregion
|
|
1
|
+
import { a as LayerGeneratorYieldError, d as ServiceRuntimeNotConfiguredError, f as captureServiceTag, m as validateServiceTag, p as registerServiceTag, r as DuplicateServiceError, s as ServiceTagCollisionError, t as captureLayerRegistrationTag } from "./registration-drnZk0SY.mjs";
|
|
2
|
+
import { h as RuntimeContextNotConfiguredError, i as getRuntimeContext, l as makeRuntimeContext, n as currentRuntimeContext, u as runRuntimeContext } from "./context-BUEf1qjL.mjs";
|
|
3
|
+
import { a as ResourceNotDisposableError, i as getDisposeFinalizer, l as defaultRuntimeContextStorage } from "./signal-D2UTcaaG.mjs";
|
|
9
4
|
//#region src/service/runtime.ts
|
|
10
5
|
/** Provides the resolver context used by Service tokens during execution. */
|
|
11
6
|
var ServiceRuntime = class ServiceRuntime {
|
|
@@ -40,6 +35,7 @@ var ServiceRuntime = class ServiceRuntime {
|
|
|
40
35
|
}
|
|
41
36
|
/** Resolve a Service token using the active resolver. */
|
|
42
37
|
static async resolve(token) {
|
|
38
|
+
captureServiceTag(token);
|
|
43
39
|
return await ServiceRuntime.current().resolve(token);
|
|
44
40
|
}
|
|
45
41
|
};
|
|
@@ -69,7 +65,7 @@ var ServiceRuntime = class ServiceRuntime {
|
|
|
69
65
|
*/
|
|
70
66
|
function Service() {
|
|
71
67
|
return function(tag) {
|
|
72
|
-
|
|
68
|
+
validateServiceTag(tag);
|
|
73
69
|
class BaseService {
|
|
74
70
|
/** The stable logical identity used by Layers and resolver backends. */
|
|
75
71
|
static serviceTag = tag;
|
|
@@ -104,57 +100,11 @@ function Service() {
|
|
|
104
100
|
return await ServiceRuntime.resolve(this);
|
|
105
101
|
}
|
|
106
102
|
}
|
|
103
|
+
registerServiceTag(BaseService, tag);
|
|
107
104
|
return BaseService;
|
|
108
105
|
};
|
|
109
106
|
}
|
|
110
107
|
//#endregion
|
|
111
|
-
//#region src/scope/errors.ts
|
|
112
|
-
/** Thrown when Scope context is accessed outside an active Scope execution. */
|
|
113
|
-
var ScopeRuntimeNotConfiguredError = class extends Error {
|
|
114
|
-
constructor() {
|
|
115
|
-
super("No Scope is available in the current execution context");
|
|
116
|
-
this.name = "ScopeRuntimeNotConfiguredError";
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
/** Thrown when a resource or finalizer is added after Scope closure begins. */
|
|
120
|
-
var ScopeClosedError = class extends Error {
|
|
121
|
-
constructor() {
|
|
122
|
-
super("Cannot add resources or finalizers to a closed Scope");
|
|
123
|
-
this.name = "ScopeClosedError";
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
/** Aggregates finalizer failures encountered while closing a Scope. */
|
|
127
|
-
var ScopeCloseError = class extends Error {
|
|
128
|
-
causes;
|
|
129
|
-
constructor(causes) {
|
|
130
|
-
super(`Failed to close Scope (${causes.length} finalizer${causes.length === 1 ? "" : "s"} failed)`);
|
|
131
|
-
this.causes = causes;
|
|
132
|
-
this.name = "ScopeCloseError";
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
/** Thrown when a value has neither Symbol.dispose nor Symbol.asyncDispose. */
|
|
136
|
-
var ResourceNotDisposableError = class extends Error {
|
|
137
|
-
constructor() {
|
|
138
|
-
super("Resource does not implement Symbol.dispose or Symbol.asyncDispose");
|
|
139
|
-
this.name = "ResourceNotDisposableError";
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
//#endregion
|
|
143
|
-
//#region src/scope/disposable.ts
|
|
144
|
-
const SCOPE_SUCCESS = { status: "success" };
|
|
145
|
-
/** Return a Scope finalizer for a value's async or sync disposal protocol. */
|
|
146
|
-
const getDisposeFinalizer = (resource) => {
|
|
147
|
-
const candidate = Object(resource);
|
|
148
|
-
const asyncDispose = candidate[Symbol.asyncDispose];
|
|
149
|
-
if (asyncDispose instanceof Function) return () => asyncDispose.call(resource);
|
|
150
|
-
const dispose = candidate[Symbol.dispose];
|
|
151
|
-
if (dispose instanceof Function) return () => dispose.call(resource);
|
|
152
|
-
};
|
|
153
|
-
/** Dispose a value immediately when it implements a disposal protocol. */
|
|
154
|
-
const disposeResource = (resource) => {
|
|
155
|
-
return getDisposeFinalizer(resource)?.(SCOPE_SUCCESS);
|
|
156
|
-
};
|
|
157
|
-
//#endregion
|
|
158
108
|
//#region src/layer/internal.ts
|
|
159
109
|
const runLayerGenerator = async (service, factory) => {
|
|
160
110
|
const iterator = factory();
|
|
@@ -189,39 +139,49 @@ var Layer = class Layer {
|
|
|
189
139
|
/** The provider registrations retained by this Layer. */
|
|
190
140
|
providers;
|
|
191
141
|
constructor(providers) {
|
|
192
|
-
this.providers = Object.freeze(
|
|
142
|
+
this.providers = Object.freeze(providers.map((provider) => Object.freeze({
|
|
143
|
+
...provider,
|
|
144
|
+
serviceTag: captureLayerRegistrationTag(provider)
|
|
145
|
+
})));
|
|
193
146
|
}
|
|
194
147
|
/** A stable provider-free Layer for composition roots with no Services. */
|
|
195
148
|
static empty = Object.freeze(new Layer([]));
|
|
196
149
|
static make(service, acquire) {
|
|
150
|
+
const serviceTag = captureServiceTag(service);
|
|
197
151
|
const defaultAcquire = () => {
|
|
198
152
|
return new service();
|
|
199
153
|
};
|
|
200
154
|
const normalizedAcquire = normalizeAcquire(acquire ?? defaultAcquire);
|
|
201
155
|
return new Layer([{
|
|
202
156
|
service,
|
|
157
|
+
serviceTag,
|
|
203
158
|
acquire: normalizedAcquire
|
|
204
159
|
}]);
|
|
205
160
|
}
|
|
206
161
|
/** Create a Layer from an already-constructed Service instance. */
|
|
207
162
|
static succeed(service, instance) {
|
|
163
|
+
const serviceTag = captureServiceTag(service);
|
|
208
164
|
const normalizedAcquire = normalizeAcquire(() => instance);
|
|
209
165
|
return new Layer([{
|
|
210
166
|
service,
|
|
167
|
+
serviceTag,
|
|
211
168
|
acquire: normalizedAcquire
|
|
212
169
|
}]);
|
|
213
170
|
}
|
|
214
171
|
/** Alias a source Service under a compatible target contract. */
|
|
215
172
|
static alias(options) {
|
|
216
173
|
const { from, to } = options;
|
|
174
|
+
captureServiceTag(from);
|
|
217
175
|
return Layer.gen(to, async function* () {
|
|
218
176
|
return await ServiceRuntime.resolve(from);
|
|
219
177
|
});
|
|
220
178
|
}
|
|
221
179
|
/** Define a provider with Runtime-root cleanup. */
|
|
222
180
|
static scoped(service, acquire, release) {
|
|
181
|
+
const serviceTag = captureServiceTag(service);
|
|
223
182
|
return new Layer([{
|
|
224
183
|
service,
|
|
184
|
+
serviceTag,
|
|
225
185
|
acquire: normalizeAcquire(acquire),
|
|
226
186
|
release: (instance, outcome) => {
|
|
227
187
|
return release(instance, outcome);
|
|
@@ -239,16 +199,20 @@ var Layer = class Layer {
|
|
|
239
199
|
release: finalizer
|
|
240
200
|
};
|
|
241
201
|
};
|
|
202
|
+
const serviceTag = captureServiceTag(service);
|
|
242
203
|
return new Layer([{
|
|
243
204
|
service,
|
|
205
|
+
serviceTag,
|
|
244
206
|
acquire: async () => (await acquireWithRelease()).instance,
|
|
245
207
|
acquireWithRelease
|
|
246
208
|
}]);
|
|
247
209
|
}
|
|
248
210
|
/** Define a provider whose acquisition can yield contextual Services. */
|
|
249
211
|
static scopedGen(service, factory, release) {
|
|
212
|
+
const serviceTag = captureServiceTag(service);
|
|
250
213
|
return new Layer([{
|
|
251
214
|
service,
|
|
215
|
+
serviceTag,
|
|
252
216
|
acquire: () => runLayerGenerator(service, factory),
|
|
253
217
|
release: (instance, outcome) => {
|
|
254
218
|
return release(instance, outcome);
|
|
@@ -257,8 +221,10 @@ var Layer = class Layer {
|
|
|
257
221
|
}
|
|
258
222
|
/** Define a provider whose acquisition can yield contextual Services. */
|
|
259
223
|
static gen(service, factory) {
|
|
224
|
+
const serviceTag = captureServiceTag(service);
|
|
260
225
|
return new Layer([{
|
|
261
226
|
service,
|
|
227
|
+
serviceTag,
|
|
262
228
|
acquire: () => runLayerGenerator(service, factory)
|
|
263
229
|
}]);
|
|
264
230
|
}
|
|
@@ -267,12 +233,13 @@ var Layer = class Layer {
|
|
|
267
233
|
const providers = /* @__PURE__ */ new Map();
|
|
268
234
|
for (const layer of layers) for (const provider of layer.providers) {
|
|
269
235
|
const service = provider.service;
|
|
270
|
-
const
|
|
236
|
+
const serviceTag = captureLayerRegistrationTag(provider);
|
|
237
|
+
const existing = providers.get(serviceTag);
|
|
271
238
|
if (existing) {
|
|
272
239
|
if (existing.service !== service) throw new ServiceTagCollisionError(existing.service, service);
|
|
273
240
|
throw new DuplicateServiceError(service);
|
|
274
241
|
}
|
|
275
|
-
providers.set(
|
|
242
|
+
providers.set(serviceTag, provider);
|
|
276
243
|
}
|
|
277
244
|
return new Layer([...providers.values()]);
|
|
278
245
|
}
|
|
@@ -282,8 +249,8 @@ var Layer = class Layer {
|
|
|
282
249
|
}
|
|
283
250
|
static override(base, ...overrides) {
|
|
284
251
|
const providers = /* @__PURE__ */ new Map();
|
|
285
|
-
for (const provider of base.providers) providers.set(provider
|
|
286
|
-
for (const layer of overrides) for (const provider of layer.providers) providers.set(provider
|
|
252
|
+
for (const provider of base.providers) providers.set(captureLayerRegistrationTag(provider), provider);
|
|
253
|
+
for (const layer of overrides) for (const provider of layer.providers) providers.set(captureLayerRegistrationTag(provider), provider);
|
|
287
254
|
return new Layer([...providers.values()]);
|
|
288
255
|
}
|
|
289
256
|
};
|
|
@@ -297,54 +264,6 @@ const normalizeAcquire = (acquire) => () => {
|
|
|
297
264
|
return acquire();
|
|
298
265
|
};
|
|
299
266
|
//#endregion
|
|
300
|
-
|
|
301
|
-
const neverAbortedSignal = new AbortController().signal;
|
|
302
|
-
/** Link caller, Runtime and shutdown signals without owning the caller's controller. */
|
|
303
|
-
const linkAbortSignals = (...signals) => {
|
|
304
|
-
const active = signals.filter((signal) => signal !== void 0);
|
|
305
|
-
if (active.length === 0) return {
|
|
306
|
-
signal: neverAbortedSignal,
|
|
307
|
-
dispose: () => {}
|
|
308
|
-
};
|
|
309
|
-
if (active.length === 1) return {
|
|
310
|
-
signal: active[0],
|
|
311
|
-
dispose: () => {}
|
|
312
|
-
};
|
|
313
|
-
const controller = new AbortController();
|
|
314
|
-
const listeners = [];
|
|
315
|
-
let disposed = false;
|
|
316
|
-
const dispose = () => {
|
|
317
|
-
if (disposed) return;
|
|
318
|
-
disposed = true;
|
|
319
|
-
for (const [source, listener] of listeners) source.removeEventListener("abort", listener);
|
|
320
|
-
listeners.length = 0;
|
|
321
|
-
};
|
|
322
|
-
const abortFrom = (source) => {
|
|
323
|
-
if (controller.signal.aborted) return;
|
|
324
|
-
controller.abort(source.reason);
|
|
325
|
-
dispose();
|
|
326
|
-
};
|
|
327
|
-
for (const source of active) {
|
|
328
|
-
if (source.aborted) {
|
|
329
|
-
abortFrom(source);
|
|
330
|
-
break;
|
|
331
|
-
}
|
|
332
|
-
const listener = () => abortFrom(source);
|
|
333
|
-
listeners.push([source, listener]);
|
|
334
|
-
source.addEventListener("abort", listener, { once: true });
|
|
335
|
-
}
|
|
336
|
-
return {
|
|
337
|
-
signal: controller.signal,
|
|
338
|
-
dispose
|
|
339
|
-
};
|
|
340
|
-
};
|
|
341
|
-
/** Return the current cooperative-cancellation signal. */
|
|
342
|
-
const currentAbortSignal = () => currentRuntimeContext().signal ?? neverAbortedSignal;
|
|
343
|
-
/** Yieldable access to the signal of the current Runtime execution. */
|
|
344
|
-
const CurrentAbortSignal = { *[Symbol.iterator]() {
|
|
345
|
-
return currentAbortSignal();
|
|
346
|
-
} };
|
|
347
|
-
//#endregion
|
|
348
|
-
export { getDisposeFinalizer as a, ScopeClosedError as c, ServiceRuntime as d, defaultRuntimeContextStorage as f, disposeResource as i, ScopeRuntimeNotConfiguredError as l, linkAbortSignals as n, ResourceNotDisposableError as o, Layer as r, ScopeCloseError as s, CurrentAbortSignal as t, Service as u };
|
|
267
|
+
export { Service as n, ServiceRuntime as r, Layer as t };
|
|
349
268
|
|
|
350
|
-
//# sourceMappingURL=
|
|
269
|
+
//# sourceMappingURL=layer-D56fRdLt.mjs.map
|