better-effect 0.6.0 → 0.7.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 +47 -15
- package/dist/adapters/iti.d.mts +3 -1
- package/dist/adapters/iti.d.mts.map +1 -1
- package/dist/adapters/iti.mjs +1 -2
- package/dist/adapters/iti.mjs.map +1 -1
- package/dist/context-B4yO5LaH.mjs +80 -0
- package/dist/context-B4yO5LaH.mjs.map +1 -0
- package/dist/errors-BXKc7juX.d.mts +8 -0
- package/dist/errors-BXKc7juX.d.mts.map +1 -0
- package/dist/index-BFgG9zZC.d.mts +374 -0
- package/dist/index-BFgG9zZC.d.mts.map +1 -0
- package/dist/{index-DMfjhNR_.d.mts → index-BddlcJK6.d.mts} +21 -267
- package/dist/index-BddlcJK6.d.mts.map +1 -0
- package/dist/index.d.mts +36 -77
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +163 -47
- package/dist/index.mjs.map +1 -1
- package/dist/internal-identity-Cm4-KIUj.mjs +122 -0
- package/dist/internal-identity-Cm4-KIUj.mjs.map +1 -0
- package/dist/map-layer-backend-BodcEeNA.mjs +52 -0
- package/dist/map-layer-backend-BodcEeNA.mjs.map +1 -0
- package/dist/map-layer-backend-CGibcwkc.d.mts +42 -0
- package/dist/map-layer-backend-CGibcwkc.d.mts.map +1 -0
- package/dist/runtime/explicit.d.mts +18 -0
- package/dist/runtime/explicit.d.mts.map +1 -0
- package/dist/runtime/explicit.mjs +46 -0
- package/dist/runtime/explicit.mjs.map +1 -0
- package/dist/runtime/node.d.mts +13 -0
- package/dist/runtime/node.d.mts.map +1 -0
- package/dist/runtime/node.mjs +21 -0
- package/dist/runtime/node.mjs.map +1 -0
- package/dist/testing.d.mts +2 -22
- package/dist/testing.mjs +2 -58
- package/package.json +3 -1
- package/dist/errors-GR3K_nRu.mjs +0 -74
- package/dist/errors-GR3K_nRu.mjs.map +0 -1
- package/dist/index-DMfjhNR_.d.mts.map +0 -1
- package/dist/internal-identity-C6Awrc33.mjs +0 -27
- package/dist/internal-identity-C6Awrc33.mjs.map +0 -1
- package/dist/testing.d.mts.map +0 -1
- package/dist/testing.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-BFgG9zZC.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,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f,IAAI,GAAG,SAAS,gBAAgB,eAAe,IAAI;EACnD,WAAW;;;;;UCAI;;EAEf,QAAQ,UAAU,iBAAiB,OAAO,IAAI,aAAa,KAAK,YAAY,aAAa;;;cAI9E;;;;;;;;;;;;;SAaJ,IAAI,GACT,UAAU,iBACV,eAAe,GACf,UAAS,wBACR;;SAaI,WAAW;;SAiBL,QAAQ,UAAU,iBAAiB,OAAO,IAAI,QAAQ,aAAa;;;;;cC/DrE,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"}
|
|
@@ -1,249 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/** Internal type-only identity for the branded Service instance. */
|
|
4
|
-
declare const ServiceIdentityTypeId: unique symbol;
|
|
5
|
-
/** A branded Service instance identity carried by the literal Service tag. */
|
|
6
|
-
interface ServiceIdentity<out Tag extends string = string> {
|
|
7
|
-
readonly [ServiceIdentityTypeId]: Tag;
|
|
8
|
-
}
|
|
9
|
-
/** The widened Service instance constraint used by contextual APIs. */
|
|
10
|
-
type AnyService = ServiceIdentity<string>;
|
|
11
|
-
/** Remove the internal Service identity marker from an implementation contract. */
|
|
12
|
-
type ServiceContract<S> = S extends unknown ? Omit<S, typeof ServiceIdentityTypeId> : never;
|
|
13
|
-
type ServiceStatics<out Tag extends string, in out Instance extends AnyService> = {
|
|
14
|
-
readonly name: string;
|
|
15
|
-
readonly serviceTag: Tag;
|
|
16
|
-
/** Type-check a structural implementation and return it unchanged. */
|
|
17
|
-
readonly of: (this: void, implementation: ServiceContract<Instance>) => Instance;
|
|
18
|
-
};
|
|
19
|
-
type AbstractServiceConstructor<out Instance> = abstract new (...args: any[]) => Instance;
|
|
20
|
-
/** A class constructor carrying a Service tag and its instance contract. */
|
|
21
|
-
interface ServiceToken<out Tag extends string = string, in out Instance extends AnyService = any> extends AbstractServiceConstructor<Instance>, ServiceStatics<Tag, Instance> {}
|
|
22
|
-
/** The widened token constraint used by generic Service infrastructure. */
|
|
23
|
-
type AnyServiceToken = ServiceToken<string, any>;
|
|
24
|
-
/** A concrete, constructible Service class accepted by a Layer provider. */
|
|
25
|
-
type ServiceClass<Tag extends string = string, Instance extends AnyService = AnyService> = (new (...args: any[]) => Instance) & ServiceStatics<Tag, Instance>;
|
|
26
|
-
/** Extract the instance type represented by a Service token. */
|
|
27
|
-
type ServiceInstance<T extends AnyServiceToken> = InstanceType<T>;
|
|
28
|
-
/** Extract the literal identity tag represented by a branded Service instance. */
|
|
29
|
-
type ServiceTagOf<S extends AnyService> = S[typeof ServiceIdentityTypeId];
|
|
30
|
-
/** Extract the Service token represented by a branded Service instance. */
|
|
31
|
-
type ServiceTokenOf<S extends AnyService> = S extends AnyService ? ServiceToken<ServiceTagOf<S>, S> : never;
|
|
32
|
-
/** Extract the literal identity tag represented by a Service instance or token. */
|
|
33
|
-
type ServiceTag<T extends AnyService | AnyServiceToken> = T extends AnyService ? ServiceTagOf<T> : T extends AnyServiceToken ? T['serviceTag'] : never;
|
|
34
|
-
type MethodRequirements<T> = { [K in keyof T]: T[K] extends ((...args: any[]) => infer Return) ? EffectRequirements<Return> : never; }[keyof T];
|
|
35
|
-
/**
|
|
36
|
-
* Services required by the Effect-returning methods of a Service class.
|
|
37
|
-
*
|
|
38
|
-
* This type is used automatically by `Layer.make`, `Layer.gen`, and the other
|
|
39
|
-
* provider constructors.
|
|
40
|
-
*/
|
|
41
|
-
type ServiceRequirements<S extends AnyService> = MethodRequirements<S>;
|
|
42
|
-
//#endregion
|
|
43
|
-
//#region src/effect/types.d.ts
|
|
44
|
-
/**
|
|
45
|
-
* Type-only identity for a Service requirement yielded by a generator.
|
|
46
|
-
*
|
|
47
|
-
* The declaration has no runtime value. Service iterators return their
|
|
48
|
-
* resolved instances without yielding a marker at runtime.
|
|
49
|
-
*/
|
|
50
|
-
declare const ServiceRequirementTypeId: unique symbol;
|
|
51
|
-
/** Type-only identity for requirement metadata attached to Effect results. */
|
|
52
|
-
declare const EffectRequirementsTypeId: unique symbol;
|
|
53
|
-
/**
|
|
54
|
-
* Metadata carried by the yield type of a Service token.
|
|
55
|
-
*
|
|
56
|
-
* This interface is intentionally phantom: it is used only while TypeScript
|
|
57
|
-
* infers a generator's yielded values.
|
|
58
|
-
*/
|
|
59
|
-
interface ServiceRequirement<out T> {
|
|
60
|
-
readonly [ServiceRequirementTypeId]: T;
|
|
61
|
-
}
|
|
62
|
-
/** A `better-result` Result with phantom metadata for required Services. */
|
|
63
|
-
type Effect<A, E, R extends AnyService = never> = Result<A, E> & {
|
|
64
|
-
readonly [EffectRequirementsTypeId]?: R;
|
|
65
|
-
};
|
|
66
|
-
/** An Effect with erased success, error, and Service requirements. */
|
|
67
|
-
type AnyEffect = Effect<unknown, unknown, AnyService>;
|
|
68
|
-
/** Values that an Effect generator may yield. */
|
|
69
|
-
type EffectYield = Err<never, unknown> | ServiceRequirement<unknown>;
|
|
70
|
-
/** Extract the error channel from Result values yielded by a generator. */
|
|
71
|
-
type InferYieldError<Y> = Y extends Err<never, infer E> ? E : never;
|
|
72
|
-
/** Extract branded Service instances carried by yielded Service requirements. */
|
|
73
|
-
type InferYieldRequirements<Y> = Y extends ServiceRequirement<infer Requirement> ? Requirement extends AnyService ? Requirement : never : never;
|
|
74
|
-
type InferEffectRequirements<T> = T extends unknown ? typeof EffectRequirementsTypeId extends keyof T ? T extends {
|
|
75
|
-
readonly [EffectRequirementsTypeId]?: infer Requirements extends AnyService;
|
|
76
|
-
} ? Requirements : never : never : never;
|
|
77
|
-
/** Extract phantom Service requirements from an Effect or Promise. */
|
|
78
|
-
type EffectRequirements<T> = InferEffectRequirements<Awaited<T>>;
|
|
79
|
-
/** Extract the success value from an Effect or Promise. */
|
|
80
|
-
type EffectSuccess<T> = Awaited<T> extends Result<infer A, unknown> ? A : never;
|
|
81
|
-
/** Extract the error value from an Effect or Promise. */
|
|
82
|
-
type EffectError<T> = Awaited<T> extends Result<unknown, infer E> ? E : never;
|
|
83
|
-
/** Build the public Effect type produced from a generator. */
|
|
84
|
-
type EffectFromGenerator<Yield, Returned extends Result<any, any>> = Effect<InferOk<Returned>, InferYieldError<Yield> | InferErr<Returned>, InferYieldRequirements<Yield> | EffectRequirements<Returned>>;
|
|
85
|
-
//#endregion
|
|
86
|
-
//#region src/service/service.d.ts
|
|
87
|
-
type ServiceTagLiteral<Tag extends string> = string extends Tag ? never : Tag extends '' ? never : Tag;
|
|
88
|
-
interface ServiceFactory<Self> {
|
|
89
|
-
<const Tag extends string>(tag: ServiceTagLiteral<Tag>): (abstract new () => ServiceIdentity<Tag>) & {
|
|
90
|
-
readonly name: string;
|
|
91
|
-
readonly serviceTag: Tag;
|
|
92
|
-
} & {
|
|
93
|
-
readonly of: Service.FactoryOf<Self, Tag>;
|
|
94
|
-
readonly [Symbol.asyncIterator]: (this: ServiceToken<Tag, Self & ServiceIdentity<Tag>>) => AsyncGenerator<ServiceRequirement<Self>, Self, unknown>;
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Declare a class-backed Service with a stable string-literal identity.
|
|
99
|
-
*
|
|
100
|
-
* The returned class is simultaneously the implementation type, the runtime
|
|
101
|
-
* dependency token, and the value yielded by `yield*` in an Effect generator.
|
|
102
|
-
* The explicit self type preserves exact instance inference, while the second
|
|
103
|
-
* call captures the tag as a literal for Layer composition and diagnostics.
|
|
104
|
-
*
|
|
105
|
-
* @example
|
|
106
|
-
* ```ts
|
|
107
|
-
* class Database extends Service<Database>()('Database') {
|
|
108
|
-
* query(): string {
|
|
109
|
-
* return 'ok'
|
|
110
|
-
* }
|
|
111
|
-
* }
|
|
112
|
-
*
|
|
113
|
-
* const database = yield* Database
|
|
114
|
-
* database.query()
|
|
115
|
-
* ```
|
|
116
|
-
*
|
|
117
|
-
* @typeParam Self The instance type implemented by the declared Service.
|
|
118
|
-
*/
|
|
119
|
-
declare function Service<Self>(): ServiceFactory<Self>;
|
|
120
|
-
/** Type-level aliases for Service tokens and their instance contracts. */
|
|
121
|
-
declare namespace Service {
|
|
122
|
-
/** The widened Service instance constraint. */
|
|
123
|
-
type Any = AnyService;
|
|
124
|
-
/** A class-backed Service token with a stable tag and instance contract. */
|
|
125
|
-
type Token<Tag extends string = string, Instance extends AnyService = any> = ServiceToken<Tag, Instance>;
|
|
126
|
-
/** A constructible Service class with a stable tag and instance contract. */
|
|
127
|
-
type Class<Tag extends string = string, Instance extends AnyService = AnyService> = ServiceClass<Tag, Instance>;
|
|
128
|
-
/** Extract the instance represented by a Service token. */
|
|
129
|
-
type Instance<T extends AnyServiceToken> = ServiceInstance<T>;
|
|
130
|
-
/** Extract the stable tag represented by a Service instance. */
|
|
131
|
-
type Tag<S extends AnyService> = ServiceTag<S>;
|
|
132
|
-
/** A branded Service instance identity with a stable tag. */
|
|
133
|
-
type Identity<Tag extends string = string> = ServiceIdentity<Tag>;
|
|
134
|
-
/** Remove the internal identity marker from a Service implementation contract. */
|
|
135
|
-
type Contract<S extends AnyService> = ServiceContract<S>;
|
|
136
|
-
/** Extract the Service token represented by a branded Service instance. */
|
|
137
|
-
type TokenOf<S extends AnyService> = ServiceTokenOf<S>;
|
|
138
|
-
/** Declaration bridge for the recursive structural `Service.of` signature. */
|
|
139
|
-
type FactoryOf<Self, Tag extends string> = (this: void, implementation: ServiceContract<Self & ServiceIdentity<Tag>>) => Self;
|
|
140
|
-
/** Extract Effect Service requirements from a Service instance. */
|
|
141
|
-
type Requirements<S extends AnyService> = ServiceRequirements<S>;
|
|
142
|
-
}
|
|
143
|
-
//#endregion
|
|
144
|
-
//#region src/service/runtime.d.ts
|
|
145
|
-
/** Resolves class-backed Service tokens for a runtime execution. */
|
|
146
|
-
interface ServiceResolver {
|
|
147
|
-
/** Resolve a token to its corresponding Service instance. */
|
|
148
|
-
resolve<T extends AnyServiceToken>(token: T): InstanceType<T> | PromiseLike<InstanceType<T>>;
|
|
149
|
-
}
|
|
150
|
-
/** Provides the resolver context used by Service tokens during execution. */
|
|
151
|
-
declare class ServiceRuntime {
|
|
152
|
-
/**
|
|
153
|
-
* Run a callback with a resolver available to `yield* Service` expressions.
|
|
154
|
-
*
|
|
155
|
-
* The context is scoped to the callback and is restored afterward.
|
|
156
|
-
*
|
|
157
|
-
* @example
|
|
158
|
-
* ```ts
|
|
159
|
-
* const value = ServiceRuntime.run(resolver, () => {
|
|
160
|
-
* return ServiceRuntime.resolve(Database)
|
|
161
|
-
* })
|
|
162
|
-
* ```
|
|
163
|
-
*/
|
|
164
|
-
static run<A>(resolver: ServiceResolver, program: () => A): A;
|
|
165
|
-
/** Return the resolver active in the current execution context. */
|
|
166
|
-
static current(): ServiceResolver;
|
|
167
|
-
/** Resolve a Service token using the active resolver. */
|
|
168
|
-
static resolve<T extends AnyServiceToken>(token: T): Promise<InstanceType<T>>;
|
|
169
|
-
}
|
|
170
|
-
//#endregion
|
|
171
|
-
//#region src/service/errors.d.ts
|
|
172
|
-
/** Thrown when a Service is accessed without an active runtime resolver. */
|
|
173
|
-
declare class ServiceRuntimeNotConfiguredError extends Error {
|
|
174
|
-
constructor();
|
|
175
|
-
}
|
|
176
|
-
/** Thrown when a runtime has no provider for the requested Service tag. */
|
|
177
|
-
declare class ServiceNotFoundError extends Error {
|
|
178
|
-
readonly service: AnyServiceToken;
|
|
179
|
-
constructor(service: AnyServiceToken);
|
|
180
|
-
}
|
|
181
|
-
//#endregion
|
|
182
|
-
//#region src/scope/errors.d.ts
|
|
183
|
-
/** Thrown when Scope context is accessed outside an active Scope execution. */
|
|
184
|
-
declare class ScopeRuntimeNotConfiguredError extends Error {
|
|
185
|
-
constructor();
|
|
186
|
-
}
|
|
187
|
-
/** Thrown when a resource or finalizer is added after Scope closure begins. */
|
|
188
|
-
declare class ScopeClosedError extends Error {
|
|
189
|
-
constructor();
|
|
190
|
-
}
|
|
191
|
-
/** Aggregates finalizer failures encountered while closing a Scope. */
|
|
192
|
-
declare class ScopeCloseError extends Error {
|
|
193
|
-
readonly causes: readonly unknown[];
|
|
194
|
-
constructor(causes: readonly unknown[]);
|
|
195
|
-
}
|
|
196
|
-
/** Thrown when a value has neither Symbol.dispose nor Symbol.asyncDispose. */
|
|
197
|
-
declare class ResourceNotDisposableError extends Error {
|
|
198
|
-
constructor();
|
|
199
|
-
}
|
|
200
|
-
//#endregion
|
|
201
|
-
//#region src/scope/types.d.ts
|
|
202
|
-
/** A value that may be returned synchronously or asynchronously. */
|
|
203
|
-
type MaybePromise$1<T> = T | PromiseLike<T>;
|
|
204
|
-
/** Final outcome supplied to Scope finalizers and resource releases. */
|
|
205
|
-
type ScopeOutcome = {
|
|
206
|
-
/** Indicates that the owning program completed successfully. */
|
|
207
|
-
readonly status: 'success';
|
|
208
|
-
} | {
|
|
209
|
-
/** Indicates that the owning program failed or was interrupted. */
|
|
210
|
-
readonly status: 'failure';
|
|
211
|
-
/** The original program or execution failure. */
|
|
212
|
-
readonly cause: unknown;
|
|
213
|
-
};
|
|
214
|
-
/** Cleanup callback registered with a Scope. */
|
|
215
|
-
type ScopeFinalizer = (outcome: ScopeOutcome) => MaybePromise$1<void>;
|
|
216
|
-
/** Aggregated cleanup information reported at an execution boundary. */
|
|
217
|
-
type CleanupFailureDiagnostic = {
|
|
218
|
-
/** Outcome used for the Scope close that triggered cleanup. */
|
|
219
|
-
readonly outcome: ScopeOutcome;
|
|
220
|
-
/** Aggregated finalizer failure. */
|
|
221
|
-
readonly error: ScopeCloseError;
|
|
222
|
-
};
|
|
223
|
-
type SyncDisposableResource = {
|
|
224
|
-
[Symbol.dispose]: () => void;
|
|
225
|
-
[Symbol.asyncDispose]?: () => MaybePromise$1<void>;
|
|
226
|
-
};
|
|
227
|
-
type AsyncDisposableResource = {
|
|
228
|
-
[Symbol.dispose]?: () => void;
|
|
229
|
-
[Symbol.asyncDispose]: () => MaybePromise$1<void>;
|
|
230
|
-
};
|
|
231
|
-
/** A value implementing at least one JavaScript disposal protocol. */
|
|
232
|
-
type DisposableResource = SyncDisposableResource | AsyncDisposableResource;
|
|
233
|
-
//#endregion
|
|
1
|
+
import { B as ServiceTagOf, F as ServiceContract, H as ServiceTokenOf, M as AnyService, N as AnyServiceToken, P as ServiceClass, R as ServiceRequirements, T as EffectRequirements, V as ServiceToken, c as RuntimeContextStorage, d as CleanupFailureDiagnostic, h as ScopeOutcome, j as ServiceRequirement, p as MaybePromise } from "./index-BFgG9zZC.mjs";
|
|
2
|
+
import { a as LayerRegistration, i as LayerGeneratorRequirements, n as LayerBackend, o as MaybePromise$1, r as LayerGenerator } from "./map-layer-backend-CGibcwkc.mjs";
|
|
234
3
|
//#region src/internal/variance.d.ts
|
|
235
4
|
/** Type-level marker for a value produced by `A`. */
|
|
236
5
|
type Covariant<A> = () => A;
|
|
237
6
|
/** Type-level marker that both consumes and produces `A`. */
|
|
238
7
|
type Invariant<A> = (value: A) => A;
|
|
239
8
|
//#endregion
|
|
240
|
-
//#region src/utils/types.d.ts
|
|
241
|
-
type MaybePromise<T> = T | PromiseLike<T>;
|
|
242
|
-
//#endregion
|
|
243
9
|
//#region src/internal/missing-dependencies.d.ts
|
|
244
|
-
declare const MissingDependenciesTypeId: unique symbol;
|
|
245
10
|
type MissingDependencies<Missing extends AnyService> = {
|
|
246
|
-
|
|
11
|
+
/** Names the Services that must be supplied before execution. */
|
|
12
|
+
readonly missingServices: Missing;
|
|
247
13
|
};
|
|
248
14
|
//#endregion
|
|
249
15
|
//#region src/layer/metadata.d.ts
|
|
@@ -363,19 +129,6 @@ type CompleteExecutionWithRequirements<Provided extends AnyService, A, Required
|
|
|
363
129
|
/** Keep execution callbacks unchanged when their Effect requirements are met. */
|
|
364
130
|
type CompleteExecution<Provided extends AnyService, A> = CompleteExecutionWithRequirements<Provided, A, EffectRequirements<A>>;
|
|
365
131
|
//#endregion
|
|
366
|
-
//#region src/layer/types.d.ts
|
|
367
|
-
/** Runtime-facing provider registration supplied by a Layer backend. */
|
|
368
|
-
interface LayerRegistration {
|
|
369
|
-
/** The class-backed Service token provided by this registration. */
|
|
370
|
-
readonly service: ServiceClass<any, any>;
|
|
371
|
-
/** Lazily acquire the Service instance; concrete types are erased at this backend boundary. */
|
|
372
|
-
readonly acquire: () => MaybePromise<unknown>;
|
|
373
|
-
}
|
|
374
|
-
/** Generator shape used by `Layer.gen` and `Layer.scopedGen`. */
|
|
375
|
-
type LayerGenerator<S extends ServiceClass<any, any>, Yield extends ServiceRequirement<unknown> = ServiceRequirement<unknown>> = () => AsyncGenerator<Yield, ServiceContract<InstanceType<S>>, unknown>;
|
|
376
|
-
/** Service requirements inferred from a provider's methods and generator. */
|
|
377
|
-
type LayerGeneratorRequirements<S extends ServiceClass<any, any>, Yield extends ServiceRequirement<unknown>> = ServiceRequirements<InstanceType<S>> | InferYieldRequirements<Yield>;
|
|
378
|
-
//#endregion
|
|
379
132
|
//#region src/layer/layer.d.ts
|
|
380
133
|
declare const LayerTypeId: unique symbol;
|
|
381
134
|
interface LayerVariance<in out Provided, out Required> {
|
|
@@ -384,7 +137,7 @@ interface LayerVariance<in out Provided, out Required> {
|
|
|
384
137
|
}
|
|
385
138
|
interface LayerProvider extends LayerRegistration {
|
|
386
139
|
/** Provider storage deliberately erases the concrete instance type. */
|
|
387
|
-
readonly release?: (instance: unknown, outcome: ScopeOutcome) => MaybePromise<void>;
|
|
140
|
+
readonly release?: (instance: unknown, outcome: ScopeOutcome) => MaybePromise$1<void>;
|
|
388
141
|
}
|
|
389
142
|
/** A Service class whose constructor can be called without arguments. */
|
|
390
143
|
type DefaultConstructibleServiceClass<Tag extends string = string, Instance extends AnyService = AnyService> = ServiceClass<Tag, Instance> & (new () => Instance);
|
|
@@ -412,17 +165,19 @@ declare class Layer<in out Provided extends AnyService = AnyService, out Require
|
|
|
412
165
|
private constructor();
|
|
413
166
|
/** Create a Layer that lazily acquires a Service instance. */
|
|
414
167
|
static make<S extends DefaultConstructibleServiceClass<any, any>>(service: S): LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>;
|
|
415
|
-
static make<S extends ServiceClass<any, any>>(service: S, acquire: () => MaybePromise<ServiceContract<InstanceType<S>>>): LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>;
|
|
168
|
+
static make<S extends ServiceClass<any, any>>(service: S, acquire: () => MaybePromise$1<ServiceContract<InstanceType<S>>>): LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>;
|
|
416
169
|
/** Create a Layer from an already-constructed Service instance. */
|
|
417
170
|
static succeed<S extends ServiceClass<any, any>>(service: S, instance: ServiceContract<InstanceType<S>>): LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>;
|
|
418
171
|
/** Define a provider with Runtime-root cleanup. */
|
|
419
|
-
static scoped<S extends ServiceClass<any, any>>(service: S, acquire: () => MaybePromise<ServiceContract<InstanceType<S>>>, release: (instance: InstanceType<S
|
|
172
|
+
static scoped<S extends ServiceClass<any, any>>(service: S, acquire: () => MaybePromise$1<ServiceContract<InstanceType<S>>>, release: (instance: InstanceType<S>, outcome: ScopeOutcome) => MaybePromise$1<void>): LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>;
|
|
420
173
|
/** Define a provider whose acquisition can yield contextual Services. */
|
|
421
|
-
static scopedGen<S extends ServiceClass<any, any>, Yield extends ServiceRequirement<unknown>>(service: S, factory: LayerGenerator<S, Yield>, release: (instance: InstanceType<S>, outcome: ScopeOutcome) => MaybePromise<void>): LayerResult<ProviderEntry<InstanceType<S>, LayerGeneratorRequirements<S, Yield>>>;
|
|
174
|
+
static scopedGen<S extends ServiceClass<any, any>, Yield extends ServiceRequirement<unknown>>(service: S, factory: LayerGenerator<S, Yield>, release: (instance: InstanceType<S>, outcome: ScopeOutcome) => MaybePromise$1<void>): LayerResult<ProviderEntry<InstanceType<S>, LayerGeneratorRequirements<S, Yield>>>;
|
|
422
175
|
/** Define a provider whose acquisition can yield contextual Services. */
|
|
423
176
|
static gen<S extends ServiceClass<any, any>, Yield extends ServiceRequirement<unknown>>(service: S, factory: LayerGenerator<S, Yield>): LayerResult<ProviderEntry<InstanceType<S>, LayerGeneratorRequirements<S, Yield>>>;
|
|
424
177
|
/** Compose Layers without replacing providers. */
|
|
425
178
|
static merge<const Layers extends readonly LayerInput[]>(...layers: Layers & ValidateLayerTuple<Layers>): MergeResult<Layers>;
|
|
179
|
+
/** Mark a Layer composition root as complete without changing its runtime value. */
|
|
180
|
+
static complete<L extends LayerInput>(layer: L & CompleteInput<L>): L;
|
|
426
181
|
/** Replace providers in a base Layer, using tag identity and compatible contracts. */
|
|
427
182
|
static override<Base extends LayerInput, const Overrides extends readonly LayerInput[]>(base: Base & ValidateLayerInput<Base>, ...overrides: Overrides & ValidateOverrides<Base, Overrides>): OverrideLayerResult<Base, Overrides>;
|
|
428
183
|
}
|
|
@@ -434,6 +189,8 @@ declare namespace Layer {
|
|
|
434
189
|
type Provided<L extends LayerInput> = ProvidedEnvironment<L>;
|
|
435
190
|
/** Extract the external Service requirements of a Layer. */
|
|
436
191
|
type Required<L extends LayerInput> = RequiredEnvironment<L>;
|
|
192
|
+
/** Extract the Services still missing from a Layer composition. */
|
|
193
|
+
type Missing<L extends LayerInput> = RequiredEnvironment<L>;
|
|
437
194
|
/** Validate a Layer's requirements and input shape. */
|
|
438
195
|
type Complete<L extends LayerInput> = CompleteInput<L>;
|
|
439
196
|
}
|
|
@@ -480,21 +237,18 @@ type RuntimeShutdownDiagnostic = {
|
|
|
480
237
|
readonly error: LayerDisposeError;
|
|
481
238
|
};
|
|
482
239
|
/** Observer notified about cleanup failures without changing primary results. */
|
|
483
|
-
type CleanupFailureObserver = (diagnostic: CleanupFailureDiagnostic | RuntimeShutdownDiagnostic) => MaybePromise
|
|
240
|
+
type CleanupFailureObserver = (diagnostic: CleanupFailureDiagnostic | RuntimeShutdownDiagnostic) => MaybePromise<void>;
|
|
484
241
|
/** Optional Runtime configuration for cleanup diagnostics. */
|
|
485
242
|
type RuntimeOptions = {
|
|
243
|
+
/** Backend used to register and resolve the Layer. Defaults to MapLayerBackend. */
|
|
244
|
+
readonly backend?: LayerBackend;
|
|
486
245
|
/** Optional observer for best-effort cleanup diagnostics. */
|
|
487
246
|
readonly onCleanupFailure?: CleanupFailureObserver;
|
|
247
|
+
/** Context storage used by Service, Scope and Layer resolution. */
|
|
248
|
+
readonly contextStorage?: RuntimeContextStorage;
|
|
249
|
+
/** Optional signal exposed through the RuntimeContext. */
|
|
250
|
+
readonly signal?: AbortSignal;
|
|
488
251
|
};
|
|
489
252
|
//#endregion
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
interface LayerBackend extends ServiceResolver {
|
|
493
|
-
/** Register one Service provider with the backend. */
|
|
494
|
-
register(registration: LayerRegistration): MaybePromise<void>;
|
|
495
|
-
/** Dispose all backend-owned instances and provider registrations. */
|
|
496
|
-
disposeAll(): MaybePromise<void>;
|
|
497
|
-
}
|
|
498
|
-
//#endregion
|
|
499
|
-
export { AnyEffect as A, ServiceClass as B, ScopeClosedError as C, ServiceResolver as D, ServiceRuntimeNotConfiguredError as E, EffectSuccess as F, ServiceTag as G, ServiceIdentity as H, EffectYield as I, ServiceToken as K, ServiceRequirement as L, EffectError as M, EffectFromGenerator as N, ServiceRuntime as O, EffectRequirements as P, AnyService as R, ScopeCloseError as S, ServiceNotFoundError as T, ServiceInstance as U, ServiceContract as V, ServiceRequirements as W, DisposableResource as _, DuplicateServiceError as a, ScopeOutcome as b, LayerRegistrationError as c, LayerRegistration as d, CompleteExecution as f, CleanupFailureDiagnostic as g, ProvidedEnvironment as h, RuntimeShutdownDiagnostic as i, Effect as j, Service as k, ServiceTagCollisionError as l, LayerInput as m, CleanupFailureObserver as n, LayerDisposeError as o, CompleteInput as p, ServiceTokenOf as q, RuntimeOptions as r, LayerGeneratorYieldError as s, LayerBackend as t, Layer as u, MaybePromise$1 as v, ScopeRuntimeNotConfiguredError as w, ResourceNotDisposableError as x, ScopeFinalizer as y, AnyServiceToken as z };
|
|
500
|
-
//# sourceMappingURL=index-DMfjhNR_.d.mts.map
|
|
253
|
+
export { LayerDisposeError as a, ServiceTagCollisionError as c, CompleteInput as d, LayerInput as f, DuplicateServiceError as i, Layer as l, RuntimeOptions as n, LayerGeneratorYieldError as o, ProvidedEnvironment as p, RuntimeShutdownDiagnostic as r, LayerRegistrationError as s, CleanupFailureObserver as t, CompleteExecution as u };
|
|
254
|
+
//# sourceMappingURL=index-BddlcJK6.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-BddlcJK6.d.mts","names":[],"sources":["../src/internal/variance.ts","../src/internal/missing-dependencies.ts","../src/layer/metadata.ts","../src/layer/inference.ts","../src/layer/layer.ts","../src/layer/errors.ts","../src/runtime/outcome.ts"],"mappings":";;;;KACY,UAAU,WAAW;;KAGrB,UAAU,MAAM,OAAO,MAAM;;;KCF7B,oBAAoB,gBAAgB;;WAErC,iBAAiB;;;;;cCCP;UAEJ,kBACX,iBAAiB,gBACjB,oBAAoB;WAEf,UAAU;WACV,UAAU;;UAGJ,qBACX,iBAAiB,gBACjB,uBAAuB;WAElB,UAAU;WACV,gBAAgB;;UAGV,oBACX,gBAAgB,cAAc,YAAY,yBAC1C,eAAe,iBAAiB,YAAY;YAEtC;aACC,SAAS;aACT,QAAQ;;;;;KCfhB,MAAM,mBAAmB;KACzB,QAAQ,MAAM;KAEd,QAAQ,GAAG,YAAY,KAAK,qBAC5B,oBAAoB;;KAMb,aAAa,kBAAkB;;KAG/B,oBAAoB,UAAU,cACxC,UAAU,YAAY,gBAAgB,aAAa;KAEzC,oBAAoB,UAAU,cACxC,UAAU,YAAY,iBAAiB,YAAY;KAEhD,cAAc,YACjB,MAAM,iCAEF,iBAAiB,4BACA,aAAa;KAK/B,eAAe,aAAa,YAAY,cAAc,eACzD,aAAa,gBACJ,aAAa,WACnB,aAAa,iBAAiB,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
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as ProgramFromGenerator, C as EffectError, D as EffectYield, E as EffectSuccess, F as ServiceContract, H as ServiceTokenOf, I as ServiceIdentity, L as ServiceInstance, M as AnyService, N as AnyServiceToken, P as ServiceClass, R as ServiceRequirements, S as Effect$1, T as EffectRequirements, V as ServiceToken, _ 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, k as Program, l as CloseableScope, m as ScopeFinalizer, n as ServiceAcquisitionError, o as ServiceRuntime, p as MaybePromise$1, r as ServiceNotFoundError, s as RuntimeContext, t as CircularDependencyError, u as Scope, v as ScopeClosedError, w as EffectFromGenerator, x as AnyEffect, y as ScopeRuntimeNotConfiguredError, z as ServiceTag } from "./index-BFgG9zZC.mjs";
|
|
2
|
+
import { a as LayerDisposeError, c as ServiceTagCollisionError, d as CompleteInput, f as LayerInput, i as DuplicateServiceError, l as Layer, n as RuntimeOptions, o as LayerGeneratorYieldError, p as ProvidedEnvironment, r as RuntimeShutdownDiagnostic, s as LayerRegistrationError, t as CleanupFailureObserver, u as CompleteExecution } from "./index-BddlcJK6.mjs";
|
|
3
|
+
import { a as LayerRegistration, n as LayerBackend, t as MapLayerBackend } from "./map-layer-backend-CGibcwkc.mjs";
|
|
4
|
+
import { t as RuntimeContextNotConfiguredError } from "./errors-BXKc7juX.mjs";
|
|
2
5
|
import { Err, Result, UnhandledException } from "better-result";
|
|
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
|
-
*/
|
|
10
|
-
interface Scope {
|
|
11
|
-
/** Register a finalizer that runs when the owning Scope closes. */
|
|
12
|
-
addFinalizer(finalizer: ScopeFinalizer): void;
|
|
13
|
-
/** Acquire a resource and register its outcome-aware release callback. */
|
|
14
|
-
acquire<R>(acquire: () => MaybePromise$1<R>, release: (resource: R, outcome: ScopeOutcome) => MaybePromise$1<void>): Promise<R>;
|
|
15
|
-
/** Register an already-acquired disposable resource. */
|
|
16
|
-
add<R extends DisposableResource>(resource: R): Promise<R>;
|
|
17
|
-
/** Create a child Scope owned by this Scope. */
|
|
18
|
-
fork(): CloseableScope;
|
|
19
|
-
}
|
|
20
|
-
/** A Scope whose owner is responsible for calling `close()`. */
|
|
21
|
-
interface CloseableScope extends Scope {
|
|
22
|
-
/** Close the Scope and run children and finalizers in child-first LIFO order. */
|
|
23
|
-
close(outcome?: ScopeOutcome): Promise<void>;
|
|
24
|
-
}
|
|
25
|
-
declare const Scope: {
|
|
26
|
-
/** Create an owned, initially open Scope. */
|
|
27
|
-
readonly make: () => CloseableScope;
|
|
28
|
-
/** Return the non-owning Scope available in the current execution context. */
|
|
29
|
-
readonly current: () => Scope;
|
|
30
|
-
/** Run a callback with an existing Scope supplied as the current context. */
|
|
31
|
-
readonly provide: <A>(scope: Scope, program: () => A) => A;
|
|
32
|
-
/** Resolve the current Scope through `yield* Scope` inside an Effect. */
|
|
33
|
-
readonly [Symbol.iterator]: () => Generator<never, Scope, unknown>;
|
|
34
|
-
/**
|
|
35
|
-
* Run a program in a newly owned Scope.
|
|
36
|
-
*
|
|
37
|
-
* Scope is independent from `better-result`, so returned values—including
|
|
38
|
-
* `Result.err`—close this Scope with a successful outcome. Result-aware
|
|
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
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
readonly run: <A>(program: (scope: Scope) => A | PromiseLike<A>) => Promise<Awaited<A>>;
|
|
50
|
-
};
|
|
51
|
-
/** Type-level aliases for Scope ownership, outcomes, and cleanup contracts. */
|
|
52
|
-
declare namespace Scope {
|
|
53
|
-
/** A Scope whose owner is responsible for calling `close()`. */
|
|
54
|
-
type Closeable = CloseableScope;
|
|
55
|
-
/** The outcome supplied to Scope finalizers and resource releases. */
|
|
56
|
-
type Outcome = ScopeOutcome;
|
|
57
|
-
/** A cleanup callback registered with a Scope. */
|
|
58
|
-
type Finalizer = ScopeFinalizer;
|
|
59
|
-
/** A value implementing a JavaScript disposal protocol. */
|
|
60
|
-
type Disposable = DisposableResource;
|
|
61
|
-
}
|
|
62
|
-
//#endregion
|
|
63
6
|
//#region src/effect/combinators.d.ts
|
|
64
|
-
type EffectInput<A, E
|
|
65
|
-
type AnyEffectInput = EffectInput<any, any
|
|
66
|
-
type AnyEffectValue =
|
|
67
|
-
type AnyAsyncEffectInput = PromiseLike<
|
|
7
|
+
type EffectInput<A, E> = Result<A, E> | PromiseLike<Result<A, E>>;
|
|
8
|
+
type AnyEffectInput = EffectInput<any, any>;
|
|
9
|
+
type AnyEffectValue = Result<any, any>;
|
|
10
|
+
type AnyAsyncEffectInput = PromiseLike<Result<any, any>>;
|
|
68
11
|
type PreserveAsync<Input, Output> = Input extends PromiseLike<unknown> ? Promise<Output> : Output;
|
|
69
12
|
type MappedResult<Input, B> = Effect$1<B, EffectError<Input>, EffectRequirements<Input>>;
|
|
70
13
|
type ErrorMappedResult<Input, E2> = Effect$1<EffectSuccess<Input>, E2, EffectRequirements<Input>>;
|
|
@@ -72,22 +15,22 @@ type ChainedResult<First, Next> = Effect$1<EffectSuccess<Next>, EffectError<Firs
|
|
|
72
15
|
type ChainedOutput<First, Next> = ChainedResult<First, Next>;
|
|
73
16
|
type AsyncChainedOutput<First, Next> = Promise<ChainedResult<First, Next>>;
|
|
74
17
|
type MapOperation<A, B> = {
|
|
75
|
-
<Input>(effect: Input & EffectInput<A, any
|
|
18
|
+
<Input>(effect: Input & EffectInput<A, any>): PreserveAsync<Input, MappedResult<Input, B>>;
|
|
76
19
|
};
|
|
77
20
|
type MapErrorOperation<E1, E2> = {
|
|
78
|
-
<Input>(effect: Input & EffectInput<any, E1
|
|
21
|
+
<Input>(effect: Input & EffectInput<any, E1>): PreserveAsync<Input, ErrorMappedResult<Input, E2>>;
|
|
79
22
|
};
|
|
80
|
-
type AndThenOperation<
|
|
81
|
-
<Input>(effect: Input &
|
|
23
|
+
type AndThenOperation<Next> = {
|
|
24
|
+
<Input>(effect: Input & AnyEffectValue): ChainedOutput<Input, Next>;
|
|
82
25
|
};
|
|
83
26
|
type AndThenAsyncOperation<A, Next> = {
|
|
84
|
-
<Input>(effect: Input & EffectInput<A, any
|
|
27
|
+
<Input>(effect: Input & EffectInput<A, any>): AsyncChainedOutput<Input, Next>;
|
|
85
28
|
};
|
|
86
29
|
/**
|
|
87
30
|
* Map the successful value of a Result or Effect result.
|
|
88
31
|
*
|
|
89
32
|
* Supports both data-first and data-last forms and preserves asynchronous
|
|
90
|
-
* results and
|
|
33
|
+
* results and declaration-only Service requirements.
|
|
91
34
|
*
|
|
92
35
|
* @example
|
|
93
36
|
* ```ts
|
|
@@ -99,7 +42,7 @@ declare function map<A, B>(fn: (value: A) => B): MapOperation<A, B>;
|
|
|
99
42
|
declare function map<Input, B>(effect: Input & AnyEffectInput, fn: (value: EffectSuccess<Input>) => B): PreserveAsync<Input, MappedResult<Input, B>>;
|
|
100
43
|
/**
|
|
101
44
|
* Map the error value of a Result or Effect result while preserving its
|
|
102
|
-
* successful value, asynchronous shape, and Service requirements.
|
|
45
|
+
* successful value, asynchronous shape, and declaration-only Service requirements.
|
|
103
46
|
*
|
|
104
47
|
* @example
|
|
105
48
|
* ```ts
|
|
@@ -119,7 +62,7 @@ declare function mapError<Input, E2>(effect: Input & AnyEffectInput, fn: (error:
|
|
|
119
62
|
* const user = Effect.andThen(Result.ok('u1'), (id) => repository.find(id))
|
|
120
63
|
* ```
|
|
121
64
|
*/
|
|
122
|
-
declare function andThen<A, Next extends AnyEffectValue>(next: (value: A) => Next): AndThenOperation<
|
|
65
|
+
declare function andThen<A, Next extends AnyEffectValue>(next: (value: A) => Next): AndThenOperation<Next>;
|
|
123
66
|
declare function andThen<Input, Next extends AnyEffectValue>(effect: Input & AnyEffectValue, next: (value: EffectSuccess<Input>) => Next): ChainedOutput<Input, Next>;
|
|
124
67
|
/**
|
|
125
68
|
* Chain an asynchronous Result-producing operation after a successful result.
|
|
@@ -137,14 +80,16 @@ declare function andThenAsync<Input, Next extends AnyAsyncEffectInput>(effect: I
|
|
|
137
80
|
//#endregion
|
|
138
81
|
//#region src/effect/effect.d.ts
|
|
139
82
|
type Effect<A, E, R extends AnyService = never> = Effect$1<A, E, R>;
|
|
83
|
+
type LazyProgram<A, E, R extends AnyService = never> = Program<A, E, R>;
|
|
140
84
|
type AnyResult = Result<any, any>;
|
|
141
85
|
/**
|
|
142
86
|
* Compose `better-result` operations while preserving Service requirements in
|
|
143
|
-
* a
|
|
87
|
+
* a declaration-only type channel.
|
|
144
88
|
*
|
|
145
89
|
* A generator may yield Service tokens and Result operations. It must return a
|
|
146
90
|
* `Result` as its final value; Service yields are resolved by the active
|
|
147
91
|
* Runtime and do not add runtime values to the Result stream.
|
|
92
|
+
* Use `fn` when generator execution should wait for a Runtime boundary.
|
|
148
93
|
*
|
|
149
94
|
* @example
|
|
150
95
|
* ```ts
|
|
@@ -158,6 +103,9 @@ type AnyResult = Result<any, any>;
|
|
|
158
103
|
*/
|
|
159
104
|
declare function gen<Yield extends EffectYield, Returned extends AnyResult>(body: () => Generator<Yield, Returned, unknown>): EffectFromGenerator<Yield, Returned>;
|
|
160
105
|
declare function gen<Yield extends EffectYield, Returned extends AnyResult>(body: () => AsyncGenerator<Yield, Returned, unknown>): Promise<EffectFromGenerator<Yield, Returned>>;
|
|
106
|
+
/** Build a lazy Program without running its generator. */
|
|
107
|
+
declare function fn<Yield extends EffectYield, Returned extends AnyResult>(body: () => Generator<Yield, Returned, unknown>): ProgramFromGenerator<Yield, Returned>;
|
|
108
|
+
declare function fn<Yield extends EffectYield, Returned extends AnyResult>(body: () => AsyncGenerator<Yield, Returned, unknown>): ProgramFromGenerator<Yield, Returned>;
|
|
161
109
|
/**
|
|
162
110
|
* Acquire a resource in the current Scope and register its release callback.
|
|
163
111
|
*
|
|
@@ -196,6 +144,8 @@ declare function add<R extends DisposableResource>(resource: R): AsyncGenerator<
|
|
|
196
144
|
declare const Effect: {
|
|
197
145
|
/** Compose a generator-based Effect program. */
|
|
198
146
|
readonly gen: typeof gen;
|
|
147
|
+
/** Build a lazy Program from a generator. */
|
|
148
|
+
readonly fn: typeof fn;
|
|
199
149
|
/** Acquire and register a resource in the current Scope. */
|
|
200
150
|
readonly acquireRelease: typeof acquireRelease;
|
|
201
151
|
/** Register an already-acquired disposable in the current Scope. */
|
|
@@ -211,6 +161,8 @@ declare const Effect: {
|
|
|
211
161
|
};
|
|
212
162
|
/** Type-level aliases for inspecting Effect result channels and requirements. */
|
|
213
163
|
declare namespace Effect {
|
|
164
|
+
/** A nominal lazy computation that produces an Effect when invoked. */
|
|
165
|
+
type Program<A, E, R extends AnyService = never> = LazyProgram<A, E, R>;
|
|
214
166
|
/** Extract the success channel from an Effect result or Promise. */
|
|
215
167
|
type Success<T> = EffectSuccess<T>;
|
|
216
168
|
/** Extract the error channel from an Effect result or Promise. */
|
|
@@ -297,7 +249,7 @@ type RuntimeFor<L extends LayerInput> = Runtime<Layer.Provided<L>>;
|
|
|
297
249
|
*
|
|
298
250
|
* @example
|
|
299
251
|
* ```ts
|
|
300
|
-
* const runtime = await Runtime.make(AppLive
|
|
252
|
+
* const runtime = await Runtime.make(AppLive)
|
|
301
253
|
* const result = await runtime.run(loadUser('u1'))
|
|
302
254
|
* await runtime.dispose()
|
|
303
255
|
* ```
|
|
@@ -312,12 +264,13 @@ declare class Runtime<Provided extends AnyService = any> {
|
|
|
312
264
|
*
|
|
313
265
|
* @example
|
|
314
266
|
* ```ts
|
|
315
|
-
* const runtime = await Runtime.make(AppLive
|
|
267
|
+
* const runtime = await Runtime.make(AppLive)
|
|
316
268
|
* const result = await runtime.run(program)
|
|
317
269
|
* await runtime.dispose()
|
|
318
270
|
* ```
|
|
319
271
|
*/
|
|
320
272
|
static make<L extends LayerInput>(layer: L & CompleteInput<L>, backend: LayerBackend, options?: RuntimeOptions): Promise<Runtime<ProvidedEnvironment<L>>>;
|
|
273
|
+
static make<L extends LayerInput>(layer: L & CompleteInput<L>, options?: RuntimeOptions): Promise<Runtime<ProvidedEnvironment<L>>>;
|
|
321
274
|
/**
|
|
322
275
|
* Run one program and dispose its Layer resources before resolving.
|
|
323
276
|
*
|
|
@@ -325,11 +278,17 @@ declare class Runtime<Provided extends AnyService = any> {
|
|
|
325
278
|
* Runtime should not outlive the operation.
|
|
326
279
|
*/
|
|
327
280
|
static run<A, L extends LayerInput>(layer: L & CompleteInput<L>, backend: LayerBackend, program: CompleteExecution<ProvidedEnvironment<L>, A>, options?: RuntimeOptions): Promise<Awaited<A>>;
|
|
281
|
+
static run<A, L extends LayerInput>(layer: L & CompleteInput<L>, program: CompleteExecution<ProvidedEnvironment<L>, A>, options?: RuntimeOptions): Promise<Awaited<A>>;
|
|
282
|
+
static run<A, L extends LayerInput>(layer: L & CompleteInput<L>, options: RuntimeOptions, program: CompleteExecution<ProvidedEnvironment<L>, A>): Promise<Awaited<A>>;
|
|
283
|
+
/** Run a callback with a managed Runtime and always dispose it afterward. */
|
|
284
|
+
static use<A, L extends LayerInput>(layer: L & CompleteInput<L>, use: (runtime: Runtime<ProvidedEnvironment<L>>) => A | PromiseLike<A>, options?: RuntimeOptions): Promise<Awaited<A>>;
|
|
328
285
|
/** Run one execution in this Runtime's child Scope. */
|
|
329
286
|
run<A>(program: CompleteExecution<Provided, A>): Promise<Awaited<A>>;
|
|
330
287
|
private runUnchecked;
|
|
331
288
|
/** Stop new executions and release the Runtime's Layer resources. */
|
|
332
289
|
dispose(): Promise<void>;
|
|
290
|
+
/** Release Runtime-owned resources through JavaScript's async disposal protocol. */
|
|
291
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
333
292
|
private disposeWithOutcome;
|
|
334
293
|
}
|
|
335
294
|
/** Type-level aliases for naming Runtime handles and shutdown options. */
|
|
@@ -342,5 +301,5 @@ declare namespace Runtime {
|
|
|
342
301
|
type ShutdownDiagnostic = RuntimeShutdownDiagnostic;
|
|
343
302
|
}
|
|
344
303
|
//#endregion
|
|
345
|
-
export { type AcquireUseReleaseOptions, type AnyEffect, type AnyService, type AnyServiceToken, type AsyncResult, type CleanupFailureDiagnostic, type CleanupFailureObserver, type CloseableScope, type DisposableResource, DuplicateServiceError, Effect, type EffectError, type EffectRequirements, type EffectSuccess, type EffectYield, Layer, type LayerBackend, LayerDisposeError, LayerGeneratorYieldError, type LayerRegistration, LayerRegistrationError, 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 ServiceContract, type ServiceIdentity, type ServiceInstance, ServiceNotFoundError, type ServiceRequirement, type ServiceRequirements, type ServiceResolver, ServiceRuntime, ServiceRuntimeNotConfiguredError, type ServiceTag, ServiceTagCollisionError, type ServiceToken, type ServiceTokenOf, pipe };
|
|
304
|
+
export { type AcquireUseReleaseOptions, type AnyEffect, type AnyService, type AnyServiceToken, type AsyncResult, CircularDependencyError, type CleanupFailureDiagnostic, type CleanupFailureObserver, type CloseableScope, type DisposableResource, DuplicateServiceError, Effect, type EffectError, type EffectRequirements, type EffectSuccess, type EffectYield, Layer, type LayerBackend, LayerDisposeError, LayerGeneratorYieldError, type LayerRegistration, LayerRegistrationError, MapLayerBackend, type Program, type ReleaseFailureObserver, type ReleaseOutcome, Resource, ResourceNotDisposableError, ResourceReleaseFailure, Runtime, type RuntimeContext, RuntimeContextNotConfiguredError, type RuntimeContextStorage, type RuntimeFor, type RuntimeOptions, 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 };
|
|
346
305
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../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/types.ts","../src/runtime/runtime.ts"],"mappings":";;;;;;KAQK,YAAY,GAAG,KAAK,OAAW,GAAG,KAAK,YAAY,OAAW,GAAG;KAEjE,iBAAiB;KACjB,iBAAiB;KACjB,sBAAsB,YAAY;KAIlC,cAAc,OAAO,UAAU,cAAc,uBAAuB,QAAQ,UAAU;KAEtF,aAAa,OAAO,KAAK,SAAO,GAAG,YAAY,QAAQ,mBAAmB;KAE1E,kBAAkB,OAAO,MAAM,SAAO,cAAc,QAAQ,IAAI,mBAAmB;KAEnF,cAAc,OAAO,QAAQ,SAChC,cAAc,OACd,YAAY,SAAS,YAAY,OACjC,mBAAmB,SAAS,mBAAmB;KAG5C,cAAc,OAAO,QAAQ,cAAc,OAAO;KAElD,mBAAmB,OAAO,QAAQ,QAAQ,cAAc,OAAO;KAE/D,aAAa,GAAG;GAClB,OAAO,QAAQ,QAAQ,YAAY,UAAU,cAAc,OAAO,aAAa,OAAO;;KA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