better-effect 0.8.0 → 0.9.2
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 -0
- package/dist/adapters/iti.d.mts +3 -3
- package/dist/adapters/iti.mjs +2 -1
- package/dist/adapters/iti.mjs.map +1 -1
- package/dist/{internal-identity-Cm4-KIUj.mjs → errors-Dnjhzbt0.mjs} +2 -25
- package/dist/errors-Dnjhzbt0.mjs.map +1 -0
- package/dist/{index-BFgG9zZC.d.mts → index-1NLNdkJy.d.mts} +2 -2
- package/dist/{index-BFgG9zZC.d.mts.map → index-1NLNdkJy.d.mts.map} +1 -1
- package/dist/index-BJFBEsm5.d.mts +406 -0
- package/dist/index-BJFBEsm5.d.mts.map +1 -0
- package/dist/{index-fUyY0eNJ.d.mts → index-CYAgpM_5.d.mts} +28 -14
- package/dist/index-CYAgpM_5.d.mts.map +1 -0
- package/dist/index.d.mts +5 -320
- package/dist/index.mjs +142 -277
- package/dist/index.mjs.map +1 -1
- package/dist/internal-identity-DmUpBeeL.mjs +27 -0
- package/dist/internal-identity-DmUpBeeL.mjs.map +1 -0
- package/dist/{map-layer-backend-CGibcwkc.d.mts → map-layer-backend-DMJauecV.d.mts} +2 -2
- package/dist/{map-layer-backend-CGibcwkc.d.mts.map → map-layer-backend-DMJauecV.d.mts.map} +1 -1
- package/dist/{map-layer-backend-BodcEeNA.mjs → map-layer-backend-gal-mcRv.mjs} +3 -2
- package/dist/{map-layer-backend-BodcEeNA.mjs.map → map-layer-backend-gal-mcRv.mjs.map} +1 -1
- package/dist/runtime/explicit.d.mts +1 -1
- package/dist/runtime/node.d.mts +1 -1
- package/dist/signal-Cl9tqGyX.mjs +270 -0
- package/dist/signal-Cl9tqGyX.mjs.map +1 -0
- package/dist/standard-services.d.mts +116 -0
- package/dist/standard-services.d.mts.map +1 -0
- package/dist/standard-services.mjs +180 -0
- package/dist/standard-services.mjs.map +1 -0
- package/dist/testing.d.mts +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +6 -2
- package/dist/index-fUyY0eNJ.d.mts.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/internal-identity-Cm4-KIUj.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -113,6 +113,11 @@ await runtime.run(inspectDatabase)
|
|
|
113
113
|
Scope. `Effect.fn` captures the generator as a lazy `Program` for Runtime
|
|
114
114
|
boundaries; the callback form remains supported for compatibility.
|
|
115
115
|
|
|
116
|
+
`Program.all` keeps a collection lazy until the returned Program is run. Pass
|
|
117
|
+
`{ concurrency: n }` for a positive bounded FIFO worker pool; values retain
|
|
118
|
+
input order, and already-started Programs remain owned by the enclosing Runtime
|
|
119
|
+
execution when one returns an error.
|
|
120
|
+
|
|
116
121
|
`Runtime.make(AppLive)` and `Runtime.run(AppLive, program)` use the built-in
|
|
117
122
|
`MapLayerBackend`. Pass `{ backend: new ItiLayerBackend() }` when an external
|
|
118
123
|
container is needed; `MemoryLayerBackend` remains its compatibility alias from
|
|
@@ -146,6 +151,10 @@ already acquired, dispose the backend and reject the Runtime. Optional
|
|
|
146
151
|
observers expose Service resolution/acquisition, execution and Layer release
|
|
147
152
|
events without coupling the core to an observability SDK:
|
|
148
153
|
|
|
154
|
+
Missing, circular, and provider-construction failures use the logical Service
|
|
155
|
+
tags in `ServiceNotFoundError`, `CircularDependencyError`, and
|
|
156
|
+
`ServiceAcquisitionError`; the latter preserves the original provider cause.
|
|
157
|
+
|
|
149
158
|
```ts
|
|
150
159
|
const runtime = await Runtime.make(AppLive, {
|
|
151
160
|
observers: [
|
|
@@ -333,6 +342,25 @@ Dependency resolution stays behind a pluggable backend.
|
|
|
333
342
|
|
|
334
343
|
Your application can keep using ordinary Promises and existing libraries.
|
|
335
344
|
|
|
345
|
+
### Optional standard services
|
|
346
|
+
|
|
347
|
+
Small host-backed services live behind `better-effect/standard-services` so the
|
|
348
|
+
core package stays explicit:
|
|
349
|
+
|
|
350
|
+
```ts
|
|
351
|
+
import { Clock, ClockTest } from 'better-effect/standard-services'
|
|
352
|
+
import { Runtime, ServiceRuntime } from 'better-effect'
|
|
353
|
+
|
|
354
|
+
const ClockTestLive = ClockTest.layer(new Date('2025-01-01T00:00:00.000Z'))
|
|
355
|
+
const runtime = await Runtime.make(ClockTestLive)
|
|
356
|
+
const now = await runtime.run(async () => ServiceRuntime.resolve(Clock))
|
|
357
|
+
await runtime.dispose()
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
The entrypoint also provides `Random`/`RandomSeeded`, `Logger`/`LoggerTest`,
|
|
361
|
+
`CurrentRequest`, and the compatible `CurrentAbortSignal` bridge. None is
|
|
362
|
+
installed implicitly; compose a normal Layer or use the provided test helpers.
|
|
363
|
+
|
|
336
364
|
---
|
|
337
365
|
|
|
338
366
|
## How it compares
|
|
@@ -427,6 +455,25 @@ step after an `Ok`. Use `Effect.andThenAsync` when the next operation returns a
|
|
|
427
455
|
or already an `Err`. The pipeline carries the requirements of every step, so Runtime
|
|
428
456
|
still rejects it when its Layer does not provide every required Service.
|
|
429
457
|
|
|
458
|
+
Observation helpers such as `Effect.tap`, `Effect.tapError`, and `Effect.tapBoth`
|
|
459
|
+
run only the active branch and return the original Result, so logging or metrics
|
|
460
|
+
do not change the pipeline's value or requirement channel.
|
|
461
|
+
|
|
462
|
+
Use `Effect.recover` or `Effect.recoverAsync` for an explicit fallback Result;
|
|
463
|
+
the fallback is evaluated only when the input is an `Err`, and its Service
|
|
464
|
+
requirements are included in the resulting type.
|
|
465
|
+
|
|
466
|
+
`Effect.flatten` removes one nested Result layer. `Effect.as` and `Effect.asVoid`
|
|
467
|
+
replace successful values while leaving the error and requirement channels intact.
|
|
468
|
+
|
|
469
|
+
`Effect.match` supports ordinary branch values as well as branch Effects. Only
|
|
470
|
+
the selected handler runs; Effect-valued handlers contribute both possible
|
|
471
|
+
error and Service requirement channels to the result type.
|
|
472
|
+
|
|
473
|
+
`Effect.all` collects already-created Effects in input order, while `Effect.zip`
|
|
474
|
+
is the two-value form; both union every input's error and Service requirements
|
|
475
|
+
and retain `better-result` short-circuiting.
|
|
476
|
+
|
|
430
477
|
Use `Effect.gen` for larger workflows with several intermediate values, branches or
|
|
431
478
|
procedural logic that already has a resolver. Use `Effect.fn` when the workflow should
|
|
432
479
|
start at a Runtime boundary. Use `pipe` for concise, linear composition; all three
|
package/dist/adapters/iti.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { N as AnyServiceToken } from "../index-
|
|
2
|
-
import "../index-
|
|
3
|
-
import { a as LayerRegistration, n as LayerBackend } from "../map-layer-backend-
|
|
1
|
+
import { N as AnyServiceToken } from "../index-1NLNdkJy.mjs";
|
|
2
|
+
import "../index-CYAgpM_5.mjs";
|
|
3
|
+
import { a as LayerRegistration, n as LayerBackend } from "../map-layer-backend-DMJauecV.mjs";
|
|
4
4
|
//#region src/adapters/iti.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* ITI-backed Layer backend.
|
package/dist/adapters/iti.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as ServiceTagCollisionError, c as ServiceNotFoundError, t as DuplicateServiceError } from "../errors-Dnjhzbt0.mjs";
|
|
2
|
+
import { t as assertServiceCompatibility } from "../internal-identity-DmUpBeeL.mjs";
|
|
2
3
|
import { t as isPromiseLike } from "../runtime-CDcCF5cb.mjs";
|
|
3
4
|
import { createContainer } from "iti";
|
|
4
5
|
//#region src/adapters/iti.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iti.mjs","names":[],"sources":["../../src/adapters/iti.ts"],"sourcesContent":["import { createContainer } from 'iti'\n\nimport {\n DuplicateServiceError,\n ServiceTagCollisionError,\n type LayerBackend,\n type LayerRegistration\n} from '../layer'\n\nimport { ServiceNotFoundError, type AnyServiceToken } from '../service'\n\nimport { assertServiceCompatibility } from '../layer/internal-identity'\nimport { isPromiseLike } from '../utils/runtime'\n\ntype LayerAcquiredValue = Awaited<ReturnType<LayerRegistration['acquire']>>\n\n/**\n * ITI-backed Layer backend.\n *\n * Install `iti` as the optional peer dependency and pass an instance to\n * `Runtime.make` when using ITI's container implementation.\n */\nexport class ItiLayerBackend implements LayerBackend {\n private container: any = createContainer()\n\n private readonly keys = new Map<string, string>()\n\n private readonly registered = new Map<string, AnyServiceToken>()\n\n private keyFor(token: AnyServiceToken): string {\n const tag = token.serviceTag\n const existing = this.keys.get(tag)\n\n if (existing) {\n return existing\n }\n\n const key = `better-effect:${tag}`\n\n this.keys.set(tag, key)\n\n return key\n }\n\n /** Register a Layer provider under its deterministic Service-tag key. */\n register(registration: LayerRegistration): void {\n const token = registration.service\n const tag = token.serviceTag\n const existing = this.registered.get(tag)\n\n if (existing === token) {\n throw new DuplicateServiceError(token)\n }\n\n if (existing) {\n throw new ServiceTagCollisionError(existing, token)\n }\n\n const key = this.keyFor(token)\n\n this.container = this.container.add({\n [key]: registration.acquire\n })\n\n this.registered.set(tag, token)\n }\n\n /** Resolve a registered Service through the ITI container. */\n resolve<T extends AnyServiceToken>(token: T): InstanceType<T> | PromiseLike<InstanceType<T>> {\n const registered = this.registered.get(token.serviceTag)\n\n if (registered === undefined) {\n throw new ServiceNotFoundError(token)\n }\n\n const key = this.keyFor(token)\n const resolved = this.container.get(key)\n\n const validate = (instance: LayerAcquiredValue): InstanceType<T> => {\n assertServiceCompatibility(token, registered, instance)\n\n // SAFETY: The registered tag and compatibility check establish the constructor-to-instance relationship after ITI erases it.\n return instance as InstanceType<T>\n }\n\n if (isPromiseLike(resolved)) {\n return Promise.resolve(resolved).then(validate)\n }\n\n return validate(resolved)\n }\n\n /** Dispose all ITI-managed provider instances. */\n async disposeAll(): Promise<void> {\n await this.container.disposeAll()\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"iti.mjs","names":[],"sources":["../../src/adapters/iti.ts"],"sourcesContent":["import { createContainer } from 'iti'\n\nimport {\n DuplicateServiceError,\n ServiceTagCollisionError,\n type LayerBackend,\n type LayerRegistration\n} from '../layer'\n\nimport { ServiceNotFoundError, type AnyServiceToken } from '../service'\n\nimport { assertServiceCompatibility } from '../layer/internal-identity'\nimport { isPromiseLike } from '../utils/runtime'\n\ntype LayerAcquiredValue = Awaited<ReturnType<LayerRegistration['acquire']>>\n\n/**\n * ITI-backed Layer backend.\n *\n * Install `iti` as the optional peer dependency and pass an instance to\n * `Runtime.make` when using ITI's container implementation.\n */\nexport class ItiLayerBackend implements LayerBackend {\n private container: any = createContainer()\n\n private readonly keys = new Map<string, string>()\n\n private readonly registered = new Map<string, AnyServiceToken>()\n\n private keyFor(token: AnyServiceToken): string {\n const tag = token.serviceTag\n const existing = this.keys.get(tag)\n\n if (existing) {\n return existing\n }\n\n const key = `better-effect:${tag}`\n\n this.keys.set(tag, key)\n\n return key\n }\n\n /** Register a Layer provider under its deterministic Service-tag key. */\n register(registration: LayerRegistration): void {\n const token = registration.service\n const tag = token.serviceTag\n const existing = this.registered.get(tag)\n\n if (existing === token) {\n throw new DuplicateServiceError(token)\n }\n\n if (existing) {\n throw new ServiceTagCollisionError(existing, token)\n }\n\n const key = this.keyFor(token)\n\n this.container = this.container.add({\n [key]: registration.acquire\n })\n\n this.registered.set(tag, token)\n }\n\n /** Resolve a registered Service through the ITI container. */\n resolve<T extends AnyServiceToken>(token: T): InstanceType<T> | PromiseLike<InstanceType<T>> {\n const registered = this.registered.get(token.serviceTag)\n\n if (registered === undefined) {\n throw new ServiceNotFoundError(token)\n }\n\n const key = this.keyFor(token)\n const resolved = this.container.get(key)\n\n const validate = (instance: LayerAcquiredValue): InstanceType<T> => {\n assertServiceCompatibility(token, registered, instance)\n\n // SAFETY: The registered tag and compatibility check establish the constructor-to-instance relationship after ITI erases it.\n return instance as InstanceType<T>\n }\n\n if (isPromiseLike(resolved)) {\n return Promise.resolve(resolved).then(validate)\n }\n\n return validate(resolved)\n }\n\n /** Dispose all ITI-managed provider instances. */\n async disposeAll(): Promise<void> {\n await this.container.disposeAll()\n }\n}\n"],"mappings":";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
//#endregion
|
|
97
|
-
|
|
98
|
-
const serviceMemberNames = (token) => {
|
|
99
|
-
const names = /* @__PURE__ */ new Set();
|
|
100
|
-
let prototype = token.prototype;
|
|
101
|
-
while (prototype && prototype !== Object.prototype) {
|
|
102
|
-
for (const name of Object.getOwnPropertyNames(prototype)) if (name !== "constructor") names.add(name);
|
|
103
|
-
for (const symbol of Object.getOwnPropertySymbols(prototype)) names.add(symbol);
|
|
104
|
-
prototype = Object.getPrototypeOf(prototype);
|
|
105
|
-
}
|
|
106
|
-
return [...names];
|
|
107
|
-
};
|
|
108
|
-
/**
|
|
109
|
-
* Check the runtime portion of a same-tag association before returning it.
|
|
110
|
-
* TypeScript remains authoritative for full structural compatibility; this
|
|
111
|
-
* check catches the common incompatible-method collision after erasure.
|
|
112
|
-
*/
|
|
113
|
-
const assertServiceCompatibility = (requested, registered, instance) => {
|
|
114
|
-
if (requested === registered || requested.serviceTag !== registered.serviceTag) return;
|
|
115
|
-
const candidate = Object(instance);
|
|
116
|
-
if (candidate !== instance) throw new ServiceTagCollisionError(registered, requested);
|
|
117
|
-
for (const name of serviceMemberNames(requested)) if (!(name in candidate)) throw new ServiceTagCollisionError(registered, requested);
|
|
118
|
-
};
|
|
119
|
-
//#endregion
|
|
120
|
-
export { LayerRegistrationError as a, ServiceAcquisitionError as c, LayerGeneratorYieldError as i, ServiceNotFoundError as l, DuplicateServiceError as n, ServiceTagCollisionError as o, LayerDisposeError as r, CircularDependencyError as s, assertServiceCompatibility as t, ServiceRuntimeNotConfiguredError as u };
|
|
97
|
+
export { ServiceTagCollisionError as a, ServiceNotFoundError as c, LayerRegistrationError as i, ServiceRuntimeNotConfiguredError as l, LayerDisposeError as n, CircularDependencyError as o, LayerGeneratorYieldError as r, ServiceAcquisitionError as s, DuplicateServiceError as t };
|
|
121
98
|
|
|
122
|
-
//# sourceMappingURL=
|
|
99
|
+
//# sourceMappingURL=errors-Dnjhzbt0.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-Dnjhzbt0.mjs","names":[],"sources":["../src/service/errors.ts","../src/layer/errors.ts"],"sourcesContent":["import type { AnyServiceToken } from './types'\n\nconst formatResolutionPath = (path: readonly AnyServiceToken[]): string =>\n path.map((service) => service.serviceTag).join(' → ')\n\n/** Thrown when a Service is accessed without an active runtime resolver. */\nexport class ServiceRuntimeNotConfiguredError extends Error {\n constructor() {\n super('No ServiceResolver is available in the current runtime context')\n\n this.name = 'ServiceRuntimeNotConfiguredError'\n }\n}\n\n/** Thrown when a runtime has no provider for the requested Service tag. */\nexport class ServiceNotFoundError extends Error {\n constructor(readonly service: AnyServiceToken) {\n super(`Service \"${service.serviceTag}\" was not provided`)\n\n this.name = 'ServiceNotFoundError'\n }\n}\n\n/** Thrown when resolving a Service re-enters a Service already in its path. */\nexport class CircularDependencyError extends Error {\n readonly path: readonly AnyServiceToken[]\n\n constructor(path: readonly AnyServiceToken[]) {\n const normalizedPath = Object.freeze([...path])\n\n super(`Circular Service dependency detected:\\n${formatResolutionPath(normalizedPath)}`)\n\n this.name = 'CircularDependencyError'\n this.path = normalizedPath\n }\n}\n\n/** Thrown when a registered Service provider fails during lazy acquisition. */\nexport class ServiceAcquisitionError extends Error {\n override readonly cause: unknown\n\n constructor(\n readonly service: AnyServiceToken,\n resolutionPath: readonly AnyServiceToken[],\n cause: unknown\n ) {\n const normalizedPath = Object.freeze([...resolutionPath])\n\n super(\n `Failed to acquire Service \"${service.serviceTag}\"` +\n (normalizedPath.length > 0\n ? ` while resolving: ${formatResolutionPath(normalizedPath)}`\n : '')\n )\n\n this.name = 'ServiceAcquisitionError'\n this.cause = cause\n this.resolutionPath = normalizedPath\n }\n\n readonly resolutionPath: readonly AnyServiceToken[]\n}\n","import type { AnyServiceToken, ServiceClass } from '../service'\nimport type { ScopeOutcome } from '../scope'\n\ntype LayerCause = Extract<ScopeOutcome, { readonly status: 'failure' }>['cause']\n\n/** Thrown when a Layer registers the same Service tag more than once. */\nexport class DuplicateServiceError extends Error {\n constructor(readonly service: ServiceClass<any>) {\n super(`Duplicate service tag \"${service.serviceTag}\"`)\n\n this.name = 'DuplicateServiceError'\n }\n}\n\n/** Thrown when one Service tag is associated with incompatible constructors. */\nexport class ServiceTagCollisionError extends Error {\n constructor(\n readonly existing: AnyServiceToken,\n readonly incoming: AnyServiceToken\n ) {\n super(\n `Service tag \"${incoming.serviceTag}\" is already associated with \"${existing.name}\" ` +\n `and cannot be associated with \"${incoming.name}\"`\n )\n\n this.name = 'ServiceTagCollisionError'\n }\n}\n\n/** Thrown when a backend fails while registering a Layer provider. */\nexport class LayerRegistrationError extends Error {\n constructor(\n readonly service: ServiceClass<any> | undefined,\n readonly registrationCause: LayerCause,\n readonly cleanupCause?: LayerCause\n ) {\n super(\n service ? `Failed to register service \"${service.serviceTag}\"` : 'Failed to build Layer',\n {\n cause: registrationCause\n }\n )\n\n this.name = 'LayerRegistrationError'\n }\n}\n\n/** Thrown when one or more Layer-owned resources fail during disposal. */\nexport class LayerDisposeError extends Error {\n constructor(readonly causes: readonly unknown[]) {\n super(`Failed to dispose Layer (${causes.length} error${causes.length === 1 ? '' : 's'})`)\n\n this.name = 'LayerDisposeError'\n }\n}\n\n/** Thrown when a Layer generator yields a value other than a Service requirement. */\nexport class LayerGeneratorYieldError extends Error {\n constructor(readonly service: ServiceClass<any>) {\n super(`Layer.gen(\"${service.serviceTag}\") yielded an unsupported value`)\n\n this.name = 'LayerGeneratorYieldError'\n }\n}\n"],"mappings":";AAEA,MAAM,wBAAwB,SAC5B,KAAK,KAAK,YAAY,QAAQ,UAAU,CAAC,CAAC,KAAK,KAAK;;AAGtD,IAAa,mCAAb,cAAsD,MAAM;CAC1D,cAAc;EACZ,MAAM,gEAAgE;EAEtE,KAAK,OAAO;CACd;AACF;;AAGA,IAAa,uBAAb,cAA0C,MAAM;CACzB;CAArB,YAAY,SAAmC;EAC7C,MAAM,YAAY,QAAQ,WAAW,mBAAmB;EADrC,KAAA,UAAA;EAGnB,KAAK,OAA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K,IAAI,EAAE;EADtE,KAAA,SAAA;EAGnB,KAAK,OAAO;CACd;AACF;;AAGA,IAAa,2BAAb,cAA8C,MAAM;CAC7B;CAArB,YAAY,SAAqC;EAC/C,MAAM,cAAc,QAAQ,WAAW,gCAAgC;EADpD,KAAA,UAAA;EAGnB,KAAK,OAAO;CACd;AACF"}
|
|
@@ -370,5 +370,5 @@ declare class ServiceAcquisitionError extends Error {
|
|
|
370
370
|
readonly resolutionPath: readonly AnyServiceToken[];
|
|
371
371
|
}
|
|
372
372
|
//#endregion
|
|
373
|
-
export { ProgramFromGenerator as A,
|
|
374
|
-
//# sourceMappingURL=index-
|
|
373
|
+
export { ProgramFromGenerator as A, ServiceTag as B, EffectError as C, EffectYield as D, EffectSuccess as E, ServiceContract as F, ServiceToken as H, ServiceIdentity as I, ServiceIdentityTypeId as L, AnyService as M, AnyServiceToken as N, InferYieldRequirements as O, ServiceClass as P, ServiceInstance as R, Effect as S, EffectRequirements as T, ServiceTokenOf as U, ServiceTagOf as V, ScopeCloseError as _, ServiceResolver as a, Service as b, RuntimeContextStorage as c, CleanupFailureDiagnostic as d, DisposableResource as f, ResourceNotDisposableError as g, ScopeOutcome as h, ServiceRuntimeNotConfiguredError as i, ServiceRequirement as j, Program as k, CloseableScope as l, ScopeFinalizer as m, ServiceAcquisitionError as n, ServiceRuntime as o, MaybePromise as p, ServiceNotFoundError as r, RuntimeContext as s, CircularDependencyError as t, Scope as u, ScopeClosedError as v, EffectFromGenerator as w, AnyEffect as x, ScopeRuntimeNotConfiguredError as y, ServiceRequirements as z };
|
|
374
|
+
//# sourceMappingURL=index-1NLNdkJy.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-1NLNdkJy.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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C,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"}
|
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
import { A as ProgramFromGenerator, C as EffectError, D as EffectYield, E as EffectSuccess, M as AnyService, S as Effect$1, T as EffectRequirements, f as DisposableResource, h as ScopeOutcome, k as Program$1, p as MaybePromise$1, w as EffectFromGenerator, x as AnyEffect } from "./index-1NLNdkJy.mjs";
|
|
2
|
+
import { C as ProvidedEnvironment, _ as Layer, a as RuntimeShutdownDiagnostic, b as CompleteInput, i as RuntimeRunOptions, n as RuntimeDisposeOptions, r as RuntimeOptions, v as CompleteExecution, x as LayerInput, y as CompleteExecutionLayer } from "./index-CYAgpM_5.mjs";
|
|
3
|
+
import { n as LayerBackend } from "./map-layer-backend-DMJauecV.mjs";
|
|
4
|
+
import { Err, Result, UnhandledException } from "better-result";
|
|
5
|
+
//#region src/effect/combinators.d.ts
|
|
6
|
+
type EffectInput<A, E> = Result<A, E> | PromiseLike<Result<A, E>>;
|
|
7
|
+
type AnyEffectInput = EffectInput<any, any>;
|
|
8
|
+
type AnyEffectValue = Result<any, any>;
|
|
9
|
+
type AnyAsyncEffectInput = PromiseLike<Result<any, any>>;
|
|
10
|
+
type PreserveAsync<Input, Output> = Input extends PromiseLike<unknown> ? Promise<Output> : Output;
|
|
11
|
+
type MappedResult<Input, B> = Effect$1<B, EffectError<Input>, EffectRequirements<Input>>;
|
|
12
|
+
type ErrorMappedResult<Input, E2> = Effect$1<EffectSuccess<Input>, E2, EffectRequirements<Input>>;
|
|
13
|
+
type ChainedResult<First, Next> = Effect$1<EffectSuccess<Next>, EffectError<First> | EffectError<Next>, EffectRequirements<First> | EffectRequirements<Next>>;
|
|
14
|
+
type ChainedOutput<First, Next> = ChainedResult<First, Next>;
|
|
15
|
+
type AsyncChainedOutput<First, Next> = Promise<ChainedResult<First, Next>>;
|
|
16
|
+
type MapOperation<A, B> = {
|
|
17
|
+
<Input>(effect: Input & EffectInput<A, any>): PreserveAsync<Input, MappedResult<Input, B>>;
|
|
18
|
+
};
|
|
19
|
+
type MapErrorOperation<E1, E2> = {
|
|
20
|
+
<Input>(effect: Input & EffectInput<any, E1>): PreserveAsync<Input, ErrorMappedResult<Input, E2>>;
|
|
21
|
+
};
|
|
22
|
+
type AndThenOperation<Next> = {
|
|
23
|
+
<Input>(effect: Input & AnyEffectValue): ChainedOutput<Input, Next>;
|
|
24
|
+
};
|
|
25
|
+
type AndThenAsyncOperation<A, Next> = {
|
|
26
|
+
<Input>(effect: Input & EffectInput<A, any>): AsyncChainedOutput<Input, Next>;
|
|
27
|
+
};
|
|
28
|
+
type TappedResult<Input> = Effect$1<EffectSuccess<Input>, EffectError<Input>, EffectRequirements<Input>>;
|
|
29
|
+
type RecoveredResult<Input, Next> = Effect$1<EffectSuccess<Input> | EffectSuccess<Next>, EffectError<Next>, EffectRequirements<Input> | EffectRequirements<Next>>;
|
|
30
|
+
type FlattenedResult<Input> = Effect$1<EffectSuccess<EffectSuccess<Input>>, EffectError<Input> | EffectError<EffectSuccess<Input>>, EffectRequirements<Input> | EffectRequirements<EffectSuccess<Input>>>;
|
|
31
|
+
type AsResult<Input, Value> = Effect$1<Value, EffectError<Input>, EffectRequirements<Input>>;
|
|
32
|
+
type MatchedResult<Input, OkResult, ErrResult> = Effect$1<EffectSuccess<OkResult> | EffectSuccess<ErrResult>, EffectError<OkResult> | EffectError<ErrResult>, EffectRequirements<Input> | EffectRequirements<OkResult> | EffectRequirements<ErrResult>>;
|
|
33
|
+
type AllResult<Results extends readonly AnyEffectValue[]> = Effect$1<{ -readonly [Index in keyof Results]: EffectSuccess<Results[Index]>; }, EffectError<Results[number]>, EffectRequirements<Results[number]>>;
|
|
34
|
+
type ZipResult<Left, Right> = Effect$1<[EffectSuccess<Left>, EffectSuccess<Right>], EffectError<Left> | EffectError<Right>, EffectRequirements<Left> | EffectRequirements<Right>>;
|
|
35
|
+
type TapOperation = {
|
|
36
|
+
<Input>(effect: Input & AnyEffectInput, fn: (value: EffectSuccess<Input>) => void): PreserveAsync<Input, TappedResult<Input>>;
|
|
37
|
+
};
|
|
38
|
+
type TapErrorOperation = {
|
|
39
|
+
<Input>(effect: Input & AnyEffectInput, fn: (error: EffectError<Input>) => void): PreserveAsync<Input, TappedResult<Input>>;
|
|
40
|
+
};
|
|
41
|
+
type TapBothOperation = {
|
|
42
|
+
<Input>(effect: Input & AnyEffectInput, handlers: {
|
|
43
|
+
ok: (value: EffectSuccess<Input>) => void;
|
|
44
|
+
err: (error: EffectError<Input>) => void;
|
|
45
|
+
}): PreserveAsync<Input, TappedResult<Input>>;
|
|
46
|
+
};
|
|
47
|
+
type RecoverOperation<Next> = {
|
|
48
|
+
<Input>(effect: Input & AnyEffectInput, fn: (error: EffectError<Input>) => Next): PreserveAsync<Input, RecoveredResult<Input, Next>>;
|
|
49
|
+
};
|
|
50
|
+
type RecoverAsyncOperation<Next> = {
|
|
51
|
+
<Input>(effect: Input & AnyEffectInput, fn: (error: EffectError<Input>) => Next): Promise<RecoveredResult<Input, Next>>;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Map the successful value of a Result or Effect result.
|
|
55
|
+
*
|
|
56
|
+
* Supports both data-first and data-last forms and preserves asynchronous
|
|
57
|
+
* results and declaration-only Service requirements.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* const doubled = Effect.map(Result.ok(2), (value) => value * 2)
|
|
62
|
+
* const toLabel = Effect.map((value: number) => `#${value}`)
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
declare function map<A, B>(fn: (value: A) => B): MapOperation<A, B>;
|
|
66
|
+
declare function map<Input, B>(effect: Input & AnyEffectInput, fn: (value: EffectSuccess<Input>) => B): PreserveAsync<Input, MappedResult<Input, B>>;
|
|
67
|
+
/**
|
|
68
|
+
* Map the error value of a Result or Effect result while preserving its
|
|
69
|
+
* successful value, asynchronous shape, and declaration-only Service requirements.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* const labelled = Effect.mapError(Result.err('missing'), (error) => ({ error }))
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
declare function mapError<E1, E2>(fn: (error: E1) => E2): MapErrorOperation<E1, E2>;
|
|
77
|
+
declare function mapError<Input, E2>(effect: Input & AnyEffectInput, fn: (error: EffectError<Input>) => E2): PreserveAsync<Input, ErrorMappedResult<Input, E2>>;
|
|
78
|
+
/**
|
|
79
|
+
* Chain a synchronous Result-producing operation after a successful result.
|
|
80
|
+
*
|
|
81
|
+
* The next operation is skipped when the input is an error. Both error types
|
|
82
|
+
* and both sets of Service requirements are preserved in the output.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* const user = Effect.andThen(Result.ok('u1'), (id) => repository.find(id))
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
declare function andThen<A, Next extends AnyEffectValue>(next: (value: A) => Next): AndThenOperation<Next>;
|
|
90
|
+
declare function andThen<Input, Next extends AnyEffectValue>(effect: Input & AnyEffectValue, next: (value: EffectSuccess<Input>) => Next): ChainedOutput<Input, Next>;
|
|
91
|
+
/**
|
|
92
|
+
* Chain an asynchronous Result-producing operation after a successful result.
|
|
93
|
+
*
|
|
94
|
+
* The returned value is always a Promise and retains both operations' error
|
|
95
|
+
* and Service-requirement metadata.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* const user = Effect.andThenAsync(loadUser(), (user) => fetchProfile(user.id))
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
declare function andThenAsync<A, Next extends AnyAsyncEffectInput>(next: (value: A) => Next): AndThenAsyncOperation<A, Next>;
|
|
103
|
+
declare function andThenAsync<Input, Next extends AnyAsyncEffectInput>(effect: Input & AnyEffectInput, next: (value: EffectSuccess<Input>) => Next): AsyncChainedOutput<Input, Next>;
|
|
104
|
+
/** Observe a successful value without changing the Result. */
|
|
105
|
+
declare function tap(fn: (value: any) => void): TapOperation;
|
|
106
|
+
declare function tap<Input>(effect: Input & AnyEffectInput, fn: (value: EffectSuccess<Input>) => void): PreserveAsync<Input, TappedResult<Input>>;
|
|
107
|
+
/** Observe an error value without changing the Result. */
|
|
108
|
+
declare function tapError(fn: (error: any) => void): TapErrorOperation;
|
|
109
|
+
declare function tapError<Input>(effect: Input & AnyEffectInput, fn: (error: EffectError<Input>) => void): PreserveAsync<Input, TappedResult<Input>>;
|
|
110
|
+
/** Observe whichever Result branch is active without changing the Result. */
|
|
111
|
+
declare function tapBoth(handlers: {
|
|
112
|
+
ok: (value: any) => void;
|
|
113
|
+
err: (error: any) => void;
|
|
114
|
+
}): TapBothOperation;
|
|
115
|
+
declare function tapBoth<Input>(effect: Input & AnyEffectInput, handlers: {
|
|
116
|
+
ok: (value: EffectSuccess<Input>) => void;
|
|
117
|
+
err: (error: EffectError<Input>) => void;
|
|
118
|
+
}): PreserveAsync<Input, TappedResult<Input>>;
|
|
119
|
+
/** Recover an Err with a synchronous Result-producing callback. */
|
|
120
|
+
declare function recover<Next extends AnyEffectValue>(fn: (error: any) => Next): RecoverOperation<Next>;
|
|
121
|
+
declare function recover<Input, Next extends AnyEffectValue>(effect: Input & AnyEffectInput, fn: (error: EffectError<Input>) => Next): PreserveAsync<Input, RecoveredResult<Input, Next>>;
|
|
122
|
+
/** Recover an Err with an asynchronous Result-producing callback. */
|
|
123
|
+
declare function recoverAsync<Next extends AnyAsyncEffectInput>(fn: (error: any) => Next): RecoverAsyncOperation<Next>;
|
|
124
|
+
declare function recoverAsync<Input, Next extends AnyAsyncEffectInput>(effect: Input & AnyEffectInput, fn: (error: EffectError<Input>) => Next): Promise<RecoveredResult<Input, Next>>;
|
|
125
|
+
/** Remove one nested Result/Effect layer. */
|
|
126
|
+
declare function flatten<Input>(effect: Input & AnyEffectValue): FlattenedResult<Input>;
|
|
127
|
+
/** Replace a successful value while preserving errors and requirements. */
|
|
128
|
+
declare function as<Value>(value: Value): <Input>(effect: Input & AnyEffectValue) => AsResult<Input, Value>;
|
|
129
|
+
declare function as<Input, Value>(effect: Input & AnyEffectValue, value: Value): AsResult<Input, Value>;
|
|
130
|
+
/** Replace a successful value with void. */
|
|
131
|
+
declare function asVoid<Input>(effect: Input & AnyEffectValue): AsResult<Input, void>;
|
|
132
|
+
/** Match an Effect and return branch Effects with their channels unioned. */
|
|
133
|
+
declare function match<Input, OkResult extends AnyEffectValue, ErrResult extends AnyEffectValue>(effect: Input & AnyEffectValue, handlers: {
|
|
134
|
+
ok: (value: EffectSuccess<Input>) => OkResult;
|
|
135
|
+
err: (error: EffectError<Input>) => ErrResult;
|
|
136
|
+
}): PreserveAsync<Input, MatchedResult<Input, OkResult, ErrResult>>;
|
|
137
|
+
declare function match<Input, OkValue, ErrValue>(effect: Input & AnyEffectValue, handlers: {
|
|
138
|
+
ok: (value: EffectSuccess<Input>) => OkValue;
|
|
139
|
+
err: (error: EffectError<Input>) => ErrValue;
|
|
140
|
+
}): PreserveAsync<Input, OkValue | ErrValue>;
|
|
141
|
+
/** Collect already-created Effects in input order. */
|
|
142
|
+
declare function all<const Results extends readonly AnyEffectValue[]>(results: Results): AllResult<Results>;
|
|
143
|
+
/** Combine two already-created Effects in input order. */
|
|
144
|
+
declare function zip<Left, Right>(left: Left & AnyEffectValue, right: Right & AnyEffectValue): ZipResult<Left, Right>;
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region src/effect/effect.d.ts
|
|
147
|
+
type Effect<A, E, R extends AnyService = never> = Effect$1<A, E, R>;
|
|
148
|
+
type LazyProgram<A, E, R extends AnyService = never> = Program$1<A, E, R>;
|
|
149
|
+
/** A nominal lazy computation that produces an Effect when invoked. */
|
|
150
|
+
type Program<A, E, R extends AnyService = never> = LazyProgram<A, E, R>;
|
|
151
|
+
type AnyResult = Result<any, any>;
|
|
152
|
+
type AnyProgram = Program$1<any, any, AnyService>;
|
|
153
|
+
type ProgramAllSuccess<Programs extends readonly AnyProgram[]> = { -readonly [Index in keyof Programs]: EffectSuccess<Programs[Index]>; };
|
|
154
|
+
type ProgramAllError<Programs extends readonly AnyProgram[]> = EffectError<Programs[number]>;
|
|
155
|
+
type ProgramAllRequirements<Programs extends readonly AnyProgram[]> = EffectRequirements<Programs[number]>;
|
|
156
|
+
type ProgramAllResult<Programs extends readonly AnyProgram[]> = Program$1<ProgramAllSuccess<Programs>, ProgramAllError<Programs>, ProgramAllRequirements<Programs>>;
|
|
157
|
+
type ProgramAllOptions = {
|
|
158
|
+
readonly concurrency?: number;
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* Compose `better-result` operations while preserving Service requirements in
|
|
162
|
+
* a declaration-only type channel.
|
|
163
|
+
*
|
|
164
|
+
* A generator may yield Service tokens and Result operations. It must return a
|
|
165
|
+
* `Result` as its final value; Service yields are resolved by the active
|
|
166
|
+
* Runtime and do not add runtime values to the Result stream.
|
|
167
|
+
* Use `fn` when generator execution should wait for a Runtime boundary.
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```ts
|
|
171
|
+
* const loadUser = Effect.gen(async function* () {
|
|
172
|
+
* const database = yield* Database
|
|
173
|
+
* const user = yield* Result.await(database.findUser('u1'))
|
|
174
|
+
*
|
|
175
|
+
* return Result.ok(user)
|
|
176
|
+
* })
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
declare function gen<Yield extends EffectYield, Returned extends AnyResult>(body: () => Generator<Yield, Returned, unknown>): EffectFromGenerator<Yield, Returned>;
|
|
180
|
+
declare function gen<Yield extends EffectYield, Returned extends AnyResult>(body: () => AsyncGenerator<Yield, Returned, unknown>): Promise<EffectFromGenerator<Yield, Returned>>;
|
|
181
|
+
/** Build a lazy Program without running its generator. */
|
|
182
|
+
declare function fn<Yield extends EffectYield, Returned extends AnyResult>(body: () => Generator<Yield, Returned, unknown>): ProgramFromGenerator<Yield, Returned>;
|
|
183
|
+
declare function fn<Yield extends EffectYield, Returned extends AnyResult>(body: () => AsyncGenerator<Yield, Returned, unknown>): ProgramFromGenerator<Yield, Returned>;
|
|
184
|
+
/** Build a lazy Program collection with optional bounded concurrency. */
|
|
185
|
+
declare function programAll<const Programs extends readonly AnyProgram[]>(programs: Programs, options?: ProgramAllOptions): ProgramAllResult<Programs>;
|
|
186
|
+
/** Value-level namespace for lazy Program combinators. */
|
|
187
|
+
declare const Program: {
|
|
188
|
+
readonly all: typeof programAll;
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* Acquire a resource in the current Scope and register its release callback.
|
|
192
|
+
*
|
|
193
|
+
* Acquisition failures are represented in the Effect Result error channel;
|
|
194
|
+
* release failures remain owned by Scope cleanup. The release callback
|
|
195
|
+
* receives the final outcome chosen by the enclosing execution boundary.
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```ts
|
|
199
|
+
* const connection = yield* Effect.acquireRelease(
|
|
200
|
+
* () => pool.connect(),
|
|
201
|
+
* (connection, outcome) => connection.close(outcome)
|
|
202
|
+
* )
|
|
203
|
+
* ```
|
|
204
|
+
*/
|
|
205
|
+
declare function acquireRelease<R>(acquire: () => MaybePromise$1<R>, release: (resource: R, outcome: ScopeOutcome) => MaybePromise$1<void>): AsyncGenerator<Err<never, UnhandledException>, R, unknown>;
|
|
206
|
+
/**
|
|
207
|
+
* Register an already-acquired disposable resource in the current Scope.
|
|
208
|
+
*
|
|
209
|
+
* The resource is not acquired by this helper. Registration failures are
|
|
210
|
+
* represented in the Effect Result error channel; disposal failures remain
|
|
211
|
+
* owned by Scope cleanup.
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* ```ts
|
|
215
|
+
* const file = yield* Effect.add(await openFile('notes.txt'))
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
declare function add<R extends DisposableResource>(resource: R): AsyncGenerator<Err<never, UnhandledException>, R, unknown>;
|
|
219
|
+
/**
|
|
220
|
+
* Effect namespace containing generator, resource, and Result combinators.
|
|
221
|
+
*
|
|
222
|
+
* Prefer these helpers when a program needs typed Service requirements or
|
|
223
|
+
* Scope-aware acquisition and cleanup.
|
|
224
|
+
*/
|
|
225
|
+
type EffectNamespace = {
|
|
226
|
+
readonly gen: typeof gen;
|
|
227
|
+
readonly fn: typeof fn;
|
|
228
|
+
readonly acquireRelease: typeof acquireRelease;
|
|
229
|
+
readonly add: typeof add;
|
|
230
|
+
readonly map: typeof map;
|
|
231
|
+
readonly mapError: typeof mapError;
|
|
232
|
+
readonly andThen: typeof andThen;
|
|
233
|
+
readonly andThenAsync: typeof andThenAsync;
|
|
234
|
+
readonly tap: typeof tap;
|
|
235
|
+
readonly tapError: typeof tapError;
|
|
236
|
+
readonly tapBoth: typeof tapBoth;
|
|
237
|
+
readonly recover: typeof recover;
|
|
238
|
+
readonly recoverAsync: typeof recoverAsync;
|
|
239
|
+
readonly flatten: typeof flatten;
|
|
240
|
+
readonly as: typeof as;
|
|
241
|
+
readonly asVoid: typeof asVoid;
|
|
242
|
+
readonly match: typeof match;
|
|
243
|
+
readonly all: typeof all;
|
|
244
|
+
readonly zip: typeof zip;
|
|
245
|
+
};
|
|
246
|
+
declare const Effect: EffectNamespace;
|
|
247
|
+
/** Type-level aliases for inspecting Effect result channels and requirements. */
|
|
248
|
+
declare namespace Effect {
|
|
249
|
+
/** A nominal lazy computation that produces an Effect when invoked. */
|
|
250
|
+
type Program<A, E, R extends AnyService = never> = LazyProgram<A, E, R>;
|
|
251
|
+
/** Extract the success channel from an Effect result or Promise. */
|
|
252
|
+
type Success<T> = EffectSuccess<T>;
|
|
253
|
+
/** Extract the error channel from an Effect result or Promise. */
|
|
254
|
+
type Error<T> = EffectError<T>;
|
|
255
|
+
/** Extract the Service requirements from an Effect result or Promise. */
|
|
256
|
+
type Requirements<T> = EffectRequirements<T>;
|
|
257
|
+
/** An Effect with erased success, error, and requirements. */
|
|
258
|
+
type Any = AnyEffect;
|
|
259
|
+
}
|
|
260
|
+
//#endregion
|
|
261
|
+
//#region src/function/pipe.d.ts
|
|
262
|
+
type Unary<A, B> = (value: A) => B;
|
|
263
|
+
declare function pipe<A>(value: A): A;
|
|
264
|
+
declare function pipe<A, B>(value: A, ab: Unary<A, B>): B;
|
|
265
|
+
declare function pipe<A, B, C>(value: A, ab: Unary<A, B>, bc: Unary<B, C>): C;
|
|
266
|
+
declare function pipe<A, B, C, D>(value: A, ab: Unary<A, B>, bc: Unary<B, C>, cd: Unary<C, D>): D;
|
|
267
|
+
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;
|
|
268
|
+
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;
|
|
269
|
+
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;
|
|
270
|
+
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;
|
|
271
|
+
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;
|
|
272
|
+
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;
|
|
273
|
+
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;
|
|
274
|
+
//#endregion
|
|
275
|
+
//#region src/resource/errors.d.ts
|
|
276
|
+
declare const ResourceReleaseFailure_base: import("better-result").TaggedErrorClass<"ResourceReleaseFailure">;
|
|
277
|
+
/** Describes a failure encountered while releasing a Resource. */
|
|
278
|
+
declare class ResourceReleaseFailure extends ResourceReleaseFailure_base<{
|
|
279
|
+
readonly resource: string;
|
|
280
|
+
readonly cause: unknown;
|
|
281
|
+
readonly message: string;
|
|
282
|
+
}> {}
|
|
283
|
+
//#endregion
|
|
284
|
+
//#region src/resource/types.d.ts
|
|
285
|
+
/** A value that may be delivered synchronously or through a thenable. */
|
|
286
|
+
type MaybePromise<T> = T | PromiseLike<T>;
|
|
287
|
+
/** A synchronous or asynchronous better-result Result operation. */
|
|
288
|
+
type AsyncResult<T, E> = MaybePromise<Result<T, E>>;
|
|
289
|
+
/** The allowed return value of a custom Resource release callback. */
|
|
290
|
+
type ReleaseOutcome = void | Result<void, unknown>;
|
|
291
|
+
/** Receives release failures for diagnostics without changing error precedence. */
|
|
292
|
+
type ReleaseFailureObserver = (failure: ResourceReleaseFailure) => MaybePromise<void>;
|
|
293
|
+
/** Options controlling `Resource.acquireUseRelease`. */
|
|
294
|
+
type AcquireUseReleaseOptions<R, A, AcquireError, UseError> = {
|
|
295
|
+
/** Human-readable name included in release failures. */
|
|
296
|
+
readonly name: string;
|
|
297
|
+
/** Acquire the resource. A failure skips use and release. */
|
|
298
|
+
readonly acquire: () => AsyncResult<R, AcquireError>;
|
|
299
|
+
/** Use the acquired resource. Release is attempted afterward. */
|
|
300
|
+
readonly use: (resource: R) => AsyncResult<A, UseError>;
|
|
301
|
+
/** Release the resource, or omit it to use its disposal protocol. */
|
|
302
|
+
readonly release?: (resource: R) => MaybePromise<ReleaseOutcome>;
|
|
303
|
+
/**
|
|
304
|
+
* Observe cleanup failures without changing error precedence. This is most
|
|
305
|
+
* useful when both `use` and `release` can fail.
|
|
306
|
+
*/
|
|
307
|
+
readonly onReleaseFailure?: ReleaseFailureObserver;
|
|
308
|
+
};
|
|
309
|
+
//#endregion
|
|
310
|
+
//#region src/resource/resource.d.ts
|
|
311
|
+
declare const Resource: {
|
|
312
|
+
/** Acquire, use, and release a resource with deterministic error precedence. */
|
|
313
|
+
readonly acquireUseRelease: <R, A, AcquireError, UseError>({ name, acquire, use, release, onReleaseFailure }: AcquireUseReleaseOptions<R, A, AcquireError, UseError>) => Promise<Result<A, AcquireError | UseError | UnhandledException | ResourceReleaseFailure>>;
|
|
314
|
+
};
|
|
315
|
+
//#endregion
|
|
316
|
+
//#region src/runtime/types.d.ts
|
|
317
|
+
/**
|
|
318
|
+
* Name a Runtime type from a concrete Layer without repeating its provided
|
|
319
|
+
* branded Service instance union.
|
|
320
|
+
*
|
|
321
|
+
* @example
|
|
322
|
+
* ```ts
|
|
323
|
+
* type AppRuntime = RuntimeFor<typeof AppLive>
|
|
324
|
+
* ```
|
|
325
|
+
*/
|
|
326
|
+
type RuntimeFor<L extends LayerInput> = Runtime<Layer.Provided<L>>;
|
|
327
|
+
//#endregion
|
|
328
|
+
//#region src/runtime/runtime.d.ts
|
|
329
|
+
/**
|
|
330
|
+
* Long-lived execution environment backed by a complete Layer.
|
|
331
|
+
*
|
|
332
|
+
* A Runtime owns Layer resources until `dispose()` is called. Each `run()` is
|
|
333
|
+
* isolated in a child Scope, while Layer-scoped resources remain shared.
|
|
334
|
+
*
|
|
335
|
+
* @example
|
|
336
|
+
* ```ts
|
|
337
|
+
* const runtime = await Runtime.make(AppLive)
|
|
338
|
+
* const result = await runtime.run(loadUser('u1'))
|
|
339
|
+
* await runtime.dispose()
|
|
340
|
+
* ```
|
|
341
|
+
*
|
|
342
|
+
* @typeParam Provided The branded Service instances supplied by the Layer.
|
|
343
|
+
*/
|
|
344
|
+
declare class Runtime<Provided extends AnyService = any> {
|
|
345
|
+
private readonly handle;
|
|
346
|
+
private constructor();
|
|
347
|
+
/**
|
|
348
|
+
* Create a long-lived Runtime that owns its Layer resources.
|
|
349
|
+
*
|
|
350
|
+
* @example
|
|
351
|
+
* ```ts
|
|
352
|
+
* const runtime = await Runtime.make(AppLive)
|
|
353
|
+
* const result = await runtime.run(program)
|
|
354
|
+
* await runtime.dispose()
|
|
355
|
+
* ```
|
|
356
|
+
*/
|
|
357
|
+
static make<L extends LayerInput>(layer: L & CompleteInput<L>, backend: LayerBackend, options?: RuntimeOptions): Promise<Runtime<ProvidedEnvironment<L>>>;
|
|
358
|
+
static make<L extends LayerInput>(layer: L & CompleteInput<L>, options?: RuntimeOptions): Promise<Runtime<ProvidedEnvironment<L>>>;
|
|
359
|
+
/**
|
|
360
|
+
* Run one program and dispose its Layer resources before resolving.
|
|
361
|
+
*
|
|
362
|
+
* This is convenient for request-style or command-style execution where a
|
|
363
|
+
* Runtime should not outlive the operation.
|
|
364
|
+
*/
|
|
365
|
+
static run<A, L extends LayerInput>(layer: L & CompleteInput<L>, backend: LayerBackend, program: CompleteExecution<ProvidedEnvironment<L>, A>, options?: RuntimeOptions): Promise<Awaited<A>>;
|
|
366
|
+
static run<A, L extends LayerInput>(layer: L & CompleteInput<L>, program: CompleteExecution<ProvidedEnvironment<L>, A>, options?: RuntimeOptions): Promise<Awaited<A>>;
|
|
367
|
+
static run<A, L extends LayerInput>(layer: L & CompleteInput<L>, options: RuntimeOptions, program: CompleteExecution<ProvidedEnvironment<L>, A>): Promise<Awaited<A>>;
|
|
368
|
+
/** Run a callback with a managed Runtime and always dispose it afterward. */
|
|
369
|
+
static use<A, L extends LayerInput>(layer: L & CompleteInput<L>, use: (runtime: Runtime<ProvidedEnvironment<L>>) => A | PromiseLike<A>, options?: RuntimeOptions): Promise<Awaited<A>>;
|
|
370
|
+
/** Resolve every Layer provider and dispose the Runtime if warmup fails. */
|
|
371
|
+
warmup(): Promise<void>;
|
|
372
|
+
/** Run one execution in this Runtime's child Scope. */
|
|
373
|
+
run<A>(program: CompleteExecution<Provided, A>, options?: RuntimeRunOptions): Promise<Awaited<A>>;
|
|
374
|
+
/** Run one execution with a Layer owned by that execution's child Scope. */
|
|
375
|
+
runWith<Request extends LayerInput, A>(layer: Request & CompleteExecutionLayer<Provided, Request>, program: CompleteExecution<Provided | ProvidedEnvironment<Request>, A>, options?: RuntimeRunOptions): Promise<Awaited<A>>;
|
|
376
|
+
private runUnchecked;
|
|
377
|
+
/** Stop new executions and release the Runtime's Layer resources. */
|
|
378
|
+
dispose(options?: RuntimeDisposeOptions): Promise<void>;
|
|
379
|
+
/** @deprecated Scope outcomes are kept for internal compatibility. */
|
|
380
|
+
dispose(outcome: ScopeOutcome): Promise<void>;
|
|
381
|
+
/** Release Runtime-owned resources through JavaScript's async disposal protocol. */
|
|
382
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
383
|
+
private disposeWithOutcome;
|
|
384
|
+
}
|
|
385
|
+
/** Type-level aliases for naming Runtime handles and shutdown options. */
|
|
386
|
+
declare namespace Runtime {
|
|
387
|
+
/** Name a Runtime type from a concrete Layer. */
|
|
388
|
+
type For<L extends LayerInput> = RuntimeFor<L>;
|
|
389
|
+
/** Optional Runtime shutdown configuration. */
|
|
390
|
+
type Options = RuntimeOptions;
|
|
391
|
+
/** Optional signal supplied to one managed Runtime execution. */
|
|
392
|
+
type RunOptions = RuntimeRunOptions;
|
|
393
|
+
/** Cooperative shutdown policy for a managed Runtime. */
|
|
394
|
+
type DisposeOptions = RuntimeDisposeOptions;
|
|
395
|
+
/** Diagnostic reported for aggregated Runtime shutdown cleanup failures. */
|
|
396
|
+
type ShutdownDiagnostic = RuntimeShutdownDiagnostic;
|
|
397
|
+
}
|
|
398
|
+
//#endregion
|
|
399
|
+
//#region src/runtime/signal.d.ts
|
|
400
|
+
/** Yieldable access to the signal of the current Runtime execution. */
|
|
401
|
+
declare const CurrentAbortSignal: {
|
|
402
|
+
readonly [Symbol.iterator]: () => Generator<never, AbortSignal, unknown>;
|
|
403
|
+
};
|
|
404
|
+
//#endregion
|
|
405
|
+
export { AcquireUseReleaseOptions as a, ReleaseOutcome as c, Effect as d, Program as f, Resource as i, ResourceReleaseFailure as l, Runtime as n, AsyncResult as o, ProgramAllOptions as p, RuntimeFor as r, ReleaseFailureObserver as s, CurrentAbortSignal as t, pipe as u };
|
|
406
|
+
//# sourceMappingURL=index-BJFBEsm5.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-BJFBEsm5.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","../src/runtime/signal.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;;KAGpF,kBAAkB,IAAI;GACxB,OAAO,QAAQ,QAAQ,iBAAiB,MAAM,cAAc,OAAO,kBAAkB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