better-effect 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +220 -6
- package/dist/adapters/iti.d.mts +2 -1
- package/dist/adapters/iti.d.mts.map +1 -1
- package/dist/adapters/iti.mjs +11 -10
- package/dist/adapters/iti.mjs.map +1 -1
- package/dist/{effect-2ZcGZI8A.mjs → effect-CK4YZaX0.mjs} +56 -10
- package/dist/effect-CK4YZaX0.mjs.map +1 -0
- package/dist/hono.d.mts +3 -3
- package/dist/hono.mjs +3 -3
- package/dist/{index-DStz0JMN.d.mts → index-B1nH4luq.d.mts} +73 -6
- package/dist/index-B1nH4luq.d.mts.map +1 -0
- package/dist/index-BMdU_Z72.d.mts +18 -0
- package/dist/index-BMdU_Z72.d.mts.map +1 -0
- package/dist/{index-C7Qild0_.d.mts → index-CX6iAoCB.d.mts} +15 -151
- package/dist/index-CX6iAoCB.d.mts.map +1 -0
- package/dist/index-GYJ4qm9K.d.mts +179 -0
- package/dist/index-GYJ4qm9K.d.mts.map +1 -0
- package/dist/index-heuaRmXR.d.mts.map +1 -1
- package/dist/index.d.mts +5 -3
- package/dist/index.mjs +6 -5
- package/dist/index.mjs.map +1 -1
- package/dist/{internal-identity-DmUpBeeL.mjs → internal-identity-CbXoZIfw.mjs} +3 -3
- package/dist/internal-identity-CbXoZIfw.mjs.map +1 -0
- package/dist/{signal-B97cs85Z.mjs → layer-D56fRdLt.mjs} +30 -111
- package/dist/layer-D56fRdLt.mjs.map +1 -0
- package/dist/node-context-DWsCUBRa.d.mts +12 -0
- package/dist/node-context-DWsCUBRa.d.mts.map +1 -0
- package/dist/node-context-lggRF4bR.mjs +25 -0
- package/dist/node-context-lggRF4bR.mjs.map +1 -0
- package/dist/node.d.mts +51 -0
- package/dist/node.d.mts.map +1 -0
- package/dist/node.mjs +233 -0
- package/dist/node.mjs.map +1 -0
- package/dist/{index-rQhZk3Nt.d.mts → outcome-CB43bnFW.d.mts} +29 -19
- package/dist/outcome-CB43bnFW.d.mts.map +1 -0
- package/dist/{scope-GGnmTQck.mjs → program-metadata-DhQCCirO.mjs} +18 -3
- package/dist/program-metadata-DhQCCirO.mjs.map +1 -0
- package/dist/registration-drnZk0SY.mjs +182 -0
- package/dist/registration-drnZk0SY.mjs.map +1 -0
- package/dist/runtime/node.d.mts +2 -11
- package/dist/runtime/node.mjs +2 -24
- package/dist/{runtime-DnMn0X0X.mjs → runtime-CBMrX8Wl.mjs} +210 -47
- package/dist/runtime-CBMrX8Wl.mjs.map +1 -0
- package/dist/signal-D2UTcaaG.mjs +105 -0
- package/dist/signal-D2UTcaaG.mjs.map +1 -0
- package/dist/{standard-services-BFBq-4lo.mjs → standard-services-GBZ32tll.mjs} +200 -16
- package/dist/standard-services-GBZ32tll.mjs.map +1 -0
- package/dist/standard-services.d.mts +3 -3
- package/dist/standard-services.mjs +3 -3
- package/dist/testing.d.mts +65 -6
- package/dist/testing.d.mts.map +1 -1
- package/dist/testing.mjs +191 -8
- package/dist/testing.mjs.map +1 -1
- package/package.json +8 -3
- package/dist/effect-2ZcGZI8A.mjs.map +0 -1
- package/dist/errors-Dnjhzbt0.mjs +0 -99
- package/dist/errors-Dnjhzbt0.mjs.map +0 -1
- package/dist/index-C7Qild0_.d.mts.map +0 -1
- package/dist/index-DStz0JMN.d.mts.map +0 -1
- package/dist/index-rQhZk3Nt.d.mts.map +0 -1
- package/dist/internal-identity-DmUpBeeL.mjs.map +0 -1
- package/dist/runtime/node.d.mts.map +0 -1
- package/dist/runtime/node.mjs.map +0 -1
- package/dist/runtime-DnMn0X0X.mjs.map +0 -1
- package/dist/scope-GGnmTQck.mjs.map +0 -1
- package/dist/signal-B97cs85Z.mjs.map +0 -1
- package/dist/standard-services-BFBq-4lo.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layer-D56fRdLt.mjs","names":["Constructor"],"sources":["../src/service/runtime.ts","../src/service/service.ts","../src/layer/internal.ts","../src/layer/layer.ts"],"sourcesContent":["import { ServiceRuntimeNotConfiguredError } from './errors'\nimport { captureServiceTag } from './tag'\n\nimport { RuntimeContextNotConfiguredError } from '../runtime/errors'\n\nimport {\n currentRuntimeContext,\n getRuntimeContext,\n makeRuntimeContext,\n runRuntimeContext\n} from '../runtime/context'\n\nimport { defaultRuntimeContextStorage } from '../runtime/default'\n\nimport type { AnyServiceToken } from './types'\n\nimport type { RuntimeContextStorage } from '../runtime/context'\n\n/** Resolves class-backed Service tokens for a runtime execution. */\nexport interface ServiceResolver {\n /** Resolve a token to its corresponding Service instance. */\n resolve<T extends AnyServiceToken>(token: T): InstanceType<T> | PromiseLike<InstanceType<T>>\n}\n\n/** Provides the resolver context used by Service tokens during execution. */\nexport class ServiceRuntime {\n /**\n * Run a callback with a resolver available to `yield* Service` expressions.\n *\n * The context is scoped to the callback and is restored afterward.\n *\n * @example\n * ```ts\n * const value = ServiceRuntime.run(resolver, () => {\n * return ServiceRuntime.resolve(Database)\n * })\n * ```\n */\n static run<A>(\n resolver: ServiceResolver,\n program: () => A,\n storage: RuntimeContextStorage = defaultRuntimeContextStorage\n ): A {\n const current = getRuntimeContext(storage)\n const context = makeRuntimeContext(\n resolver,\n current?.scope,\n current?.resolver === resolver ? current.resolutionPath : [],\n current?.signal,\n current?.resolver === resolver ? current : undefined\n )\n\n return runRuntimeContext(storage, context, program)\n }\n\n /** Return the resolver active in the current execution context. */\n static current(): ServiceResolver {\n let context\n\n try {\n context = currentRuntimeContext()\n } catch (cause) {\n if (cause instanceof RuntimeContextNotConfiguredError) {\n throw new ServiceRuntimeNotConfiguredError()\n }\n\n throw cause\n }\n\n if (!context.resolver) {\n throw new ServiceRuntimeNotConfiguredError()\n }\n\n return context.resolver\n }\n\n /** Resolve a Service token using the active resolver. */\n static async resolve<T extends AnyServiceToken>(token: T): Promise<InstanceType<T>> {\n captureServiceTag(token)\n const resolver = ServiceRuntime.current()\n\n return await resolver.resolve(token)\n }\n}\n","import { ServiceRuntime } from './runtime'\nimport { registerServiceTag, validateServiceTag } from './tag'\n\nimport type { ServiceRequirement } from '../effect/types'\n\nimport type {\n AnyService,\n AnyServiceToken,\n ServiceClass,\n ServiceContract,\n ServiceIdentity,\n ServiceIdentityTypeId,\n ServiceInstance,\n ServiceRequirements,\n ServiceTag,\n ServiceToken,\n ServiceTokenOf\n} from './types'\n\ntype ServiceTagLiteral<Tag extends string> = string extends Tag\n ? never\n : Tag extends ''\n ? never\n : Tag\n\ninterface ServiceFactory<Self> {\n <const Tag extends string>(\n tag: ServiceTagLiteral<Tag>\n ): (abstract new () => ServiceIdentity<Tag>) & {\n readonly name: string\n readonly serviceTag: Tag\n } & {\n readonly of: Service.FactoryOf<Self, Tag>\n readonly [Symbol.asyncIterator]: (\n this: ServiceToken<Tag, Self & ServiceIdentity<Tag>>\n ) => AsyncGenerator<ServiceRequirement<Self>, Self, unknown>\n }\n}\n\n/**\n * Declare a class-backed Service with a stable string-literal identity.\n *\n * The returned class is simultaneously the implementation type, the runtime\n * dependency token, and the value yielded by `yield*` in an Effect generator.\n * The explicit self type preserves exact instance inference, while the second\n * call captures the tag as a literal for Layer composition and diagnostics.\n *\n * @example\n * ```ts\n * class Database extends Service<Database>()('Database') {\n * query(): string {\n * return 'ok'\n * }\n * }\n *\n * const database = yield* Database\n * database.query()\n * ```\n *\n * @typeParam Self The instance type implemented by the declared Service.\n */\nexport function Service<Self>(): ServiceFactory<Self> {\n return function <const Tag extends string>(tag: ServiceTagLiteral<Tag>) {\n validateServiceTag(tag)\n\n abstract class BaseService implements ServiceIdentity<Tag> {\n /** The stable logical identity used by Layers and resolver backends. */\n static readonly serviceTag: Tag = tag\n declare readonly [ServiceIdentityTypeId]: Tag\n\n /**\n * Type-check a structural implementation of this Service.\n *\n * This is an identity helper. It returns the supplied value unchanged\n * and does not invoke a constructor or modify its prototype.\n *\n * @example\n * ```ts\n * class Database extends Service<Database>()('Database') {\n * query(sql: string): string {\n * return sql\n * }\n * }\n *\n * const database = Database.of({\n * query: (sql) => `Result: ${sql}`\n * })\n *\n * database.query('SELECT 1')\n * // 'Result: SELECT 1'\n * // database is the original object, not an instance of Database\n * ```\n */\n static of(this: void, implementation: ServiceContract<Self & ServiceIdentity<Tag>>): Self {\n // SAFETY: ServiceContract removes only the phantom marker; this boundary restores Self.\n return implementation as Self\n }\n\n /** Resolve this Service from the resolver active in the current runtime. */\n // oxlint-disable-next-line require-yield\n static async *[Symbol.asyncIterator](\n this: ServiceToken<Tag, Self & ServiceIdentity<Tag>>\n ): AsyncGenerator<ServiceRequirement<Self>, Self, unknown> {\n return await ServiceRuntime.resolve(this)\n }\n }\n\n registerServiceTag(BaseService, tag)\n\n return BaseService\n }\n}\n\n/** Type-level aliases for Service tokens and their instance contracts. */\nexport declare namespace Service {\n /** The widened Service instance constraint. */\n export type Any = AnyService\n\n /** A class-backed Service token with a stable tag and instance contract. */\n export type Token<Tag extends string = string, Instance extends AnyService = any> = ServiceToken<\n Tag,\n Instance\n >\n\n /** A constructible Service class with a stable tag and instance contract. */\n export type Class<\n Tag extends string = string,\n Instance extends AnyService = AnyService\n > = ServiceClass<Tag, Instance>\n\n /** Extract the instance represented by a Service token. */\n export type Instance<T extends AnyServiceToken> = ServiceInstance<T>\n\n /** Extract the stable tag represented by a Service instance. */\n export type Tag<S extends AnyService> = ServiceTag<S>\n\n /** A branded Service instance identity with a stable tag. */\n export type Identity<Tag extends string = string> = ServiceIdentity<Tag>\n\n /** Remove the internal identity marker from a Service implementation contract. */\n export type Contract<S extends AnyService> = ServiceContract<S>\n\n /** Extract the Service token represented by a branded Service instance. */\n export type TokenOf<S extends AnyService> = ServiceTokenOf<S>\n\n /** Declaration bridge for the recursive structural `Service.of` signature. */\n export type FactoryOf<Self, Tag extends string> = (\n this: void,\n implementation: ServiceContract<Self & ServiceIdentity<Tag>>\n ) => Self\n\n /** Extract Effect Service requirements from a Service instance. */\n export type Requirements<S extends AnyService> = ServiceRequirements<S>\n}\n","import { LayerGeneratorYieldError } from './errors'\n\nimport type { ServiceRequirement } from '../effect/types'\nimport type { ServiceClass } from '../service'\n\nimport type { LayerGenerator } from './types'\n\nexport const runLayerGenerator = async <\n S extends ServiceClass<any, any>,\n Yield extends ServiceRequirement<unknown>\n>(\n service: S,\n factory: LayerGenerator<S, Yield>\n): Promise<InstanceType<S>> => {\n const iterator = factory()\n\n const state = await iterator.next()\n\n if (!state.done) {\n try {\n // SAFETY: The iterator is closed only to discard an invalid yield; its return value is ignored.\n await iterator.return(undefined as never)\n } finally {\n // oxlint-disable-next-line no-unsafe-finally\n throw new LayerGeneratorYieldError(service)\n }\n }\n\n // SAFETY: The public generator boundary accepts only the requested Service contract.\n return state.value as InstanceType<S>\n}\n","import type { ServiceRequirement } from '../effect/types'\nimport { ServiceRuntime } from '../service'\nimport { captureServiceTag } from '../service/tag'\nimport type { AnyService, ServiceClass, ServiceContract, ServiceRequirements } from '../service'\nimport { ResourceNotDisposableError } from '../scope'\nimport { getDisposeFinalizer } from '../scope/disposable'\n\nimport type { DisposableResource, ScopeFinalizer, ScopeOutcome } from '../scope'\nimport type { Covariant, Invariant } from '../internal/variance'\nimport type { MaybePromise } from '../utils/types'\n\nimport { DuplicateServiceError, ServiceTagCollisionError } from './errors'\nimport { runLayerGenerator } from './internal'\nimport { captureLayerRegistrationTag } from './registration'\n\nimport type {\n LayerInput,\n CompleteInput,\n LayerResult,\n MergeResult,\n OverrideLayerResult,\n ValidateLayerInput,\n ValidateLayerTuple,\n ValidateOverrides,\n ProvidedEnvironment,\n RequiredEnvironment\n} from './inference'\nimport type { ProviderEntry } from './metadata'\nimport type { LayerGenerator, LayerGeneratorRequirements, LayerRegistration } from './types'\n\ndeclare const LayerTypeId: unique symbol\n\ninterface LayerVariance<in out Provided, out Required> {\n readonly _Provided: Invariant<Provided>\n readonly _Required: Covariant<Required>\n}\n\ntype CapturedLayerAcquisition = {\n readonly instance: unknown\n readonly release: ScopeFinalizer\n}\n\ninterface LayerProvider extends LayerRegistration {\n /** The tag captured before this provider can cross an asynchronous boundary. */\n readonly serviceTag: string\n\n /** Provider storage deliberately erases the concrete instance type. */\n // oxlint-disable-next-line anti-slop/no-unknown-parameters\n readonly release?: (instance: unknown, outcome: ScopeOutcome) => MaybePromise<void>\n\n /** Capture acquisition-local cleanup without retaining the acquired instance. */\n readonly acquireWithRelease?: () => MaybePromise<CapturedLayerAcquisition>\n}\n\n/** A Service class whose constructor can be called without arguments. */\ntype DefaultConstructibleServiceClass<\n Tag extends string = string,\n Instance extends AnyService = AnyService\n> = ServiceClass<Tag, Instance> & (new () => Instance)\n\ntype IsUnion<Type, Candidate = Type> = Type extends unknown\n ? [Candidate] extends [Type]\n ? false\n : true\n : never\n\ntype InvalidUnionAliasToken = {\n readonly __betterEffectUnionLayerAliasToken: unique symbol\n}\n\ntype RejectUnionAliasToken<Token> = IsUnion<Token> extends true ? InvalidUnionAliasToken : unknown\n\ntype LayerAliasOptions<From extends ServiceClass<any, any>, To extends ServiceClass<any, any>> = {\n readonly from: From\n readonly to: To\n} & RejectUnionAliasToken<From> &\n RejectUnionAliasToken<To> &\n ([ServiceContract<InstanceType<From>>] extends [ServiceContract<InstanceType<To>>]\n ? unknown\n : {\n readonly __betterEffectIncompatibleLayerAlias: unique symbol\n })\n\n/**\n * Declarative collection of Service providers.\n *\n * A Layer describes how to acquire implementations; it does not execute\n * providers until a `Runtime` is created. Use `merge` to compose distinct\n * providers and `override` when replacing an existing provider intentionally.\n *\n * @example\n * ```ts\n * const AppLive = Layer.merge(\n * Layer.succeed(Database, database),\n * Layer.make(UserRepository)\n * )\n *\n * const runtime = await Runtime.make(AppLive, backend)\n * ```\n */\nexport class Layer<\n in out Provided extends AnyService = AnyService,\n out Required extends AnyService = AnyService\n> {\n declare readonly [LayerTypeId]: LayerVariance<Provided, Required>\n\n /** The provider registrations retained by this Layer. */\n readonly providers: readonly LayerProvider[]\n\n private constructor(providers: readonly LayerProvider[]) {\n this.providers = Object.freeze(\n providers.map((provider) =>\n Object.freeze({\n ...provider,\n serviceTag: captureLayerRegistrationTag(provider)\n })\n )\n )\n }\n\n /** A stable provider-free Layer for composition roots with no Services. */\n static readonly empty: Layer<never, never> = Object.freeze(new Layer<never, never>([]))\n\n /** Create a Layer that lazily acquires a Service instance. */\n static make<S extends DefaultConstructibleServiceClass<any, any>>(\n service: S\n ): LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>\n\n static make<S extends ServiceClass<any, any>>(\n service: S,\n acquire: () => MaybePromise<ServiceContract<InstanceType<S>>>\n ): LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>\n\n static make<S extends ServiceClass<any, any>>(\n service: S,\n acquire?: () => MaybePromise<ServiceContract<InstanceType<S>>>\n ): LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>> {\n const serviceTag = captureServiceTag(service)\n const defaultAcquire = (): InstanceType<S> => {\n // SAFETY: The no-argument overload constrains `service` to a default constructible class.\n const Constructor = service as new () => InstanceType<S>\n\n return new Constructor()\n }\n\n const normalizedAcquire = normalizeAcquire<S>(acquire ?? defaultAcquire)\n\n // SAFETY: Runtime storage erases only the concrete provider metadata; the public constructor result restores its typed provenance.\n return new Layer([\n {\n service,\n serviceTag,\n acquire: normalizedAcquire\n }\n ]) as LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>\n }\n\n /** Create a Layer from an already-constructed Service instance. */\n static succeed<S extends ServiceClass<any, any>>(\n service: S,\n instance: ServiceContract<InstanceType<S>>\n ): LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>> {\n const serviceTag = captureServiceTag(service)\n const normalizedAcquire = normalizeAcquire<S>(() => instance)\n\n // SAFETY: The structural instance has been checked against the requested Service contract.\n return new Layer([\n {\n service,\n serviceTag,\n acquire: normalizedAcquire\n }\n ]) as LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>\n }\n\n /** Alias a source Service under a compatible target contract. */\n static alias<From extends ServiceClass<any, any>, To extends ServiceClass<any, any>>(\n options: LayerAliasOptions<From, To>\n ): LayerResult<\n ProviderEntry<InstanceType<To>, InstanceType<From> | ServiceRequirements<InstanceType<To>>>\n > {\n const { from, to } = options\n void captureServiceTag(from)\n\n // Keep alias acquisition in the normal Layer generator path so Runtime supplies the active resolver and resolution diagnostics.\n // oxlint-disable-next-line require-yield\n const alias = Layer.gen(to, async function* () {\n const source = await ServiceRuntime.resolve(from)\n\n // SAFETY: LayerAliasOptions checks that the source implementation satisfies the target contract.\n return source as ServiceContract<InstanceType<To>>\n })\n\n // SAFETY: The alias factory resolves the declared source token before returning the target contract.\n return alias as LayerResult<\n ProviderEntry<InstanceType<To>, InstanceType<From> | ServiceRequirements<InstanceType<To>>>\n >\n }\n\n /** Define a provider with Runtime-root cleanup. */\n static scoped<S extends ServiceClass<any, any>>(\n service: S,\n acquire: () => MaybePromise<ServiceContract<InstanceType<S>>>,\n release: (instance: InstanceType<S>, outcome: ScopeOutcome) => MaybePromise<void>\n ): LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>> {\n const serviceTag = captureServiceTag(service)\n\n // SAFETY: The public callbacks constrain acquisition and release to the requested Service.\n return new Layer([\n {\n service,\n serviceTag,\n acquire: normalizeAcquire<S>(acquire),\n release: (instance, outcome) => {\n // SAFETY: The backend invokes release with the instance acquired for this token.\n return release(instance as InstanceType<S>, outcome)\n }\n }\n ]) as LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>\n }\n\n /** Define a provider with Runtime-root cleanup through its disposal protocol. */\n static scopedDisposable<S extends ServiceClass<any, any>>(\n service: S,\n acquire: () => MaybePromise<ServiceContract<InstanceType<S>> & DisposableResource>\n ): LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>> {\n const acquireWithRelease = async (): Promise<CapturedLayerAcquisition> => {\n const instance = await acquire()\n const finalizer = getDisposeFinalizer(instance)\n\n if (!finalizer) {\n throw new ResourceNotDisposableError()\n }\n\n return { instance, release: finalizer }\n }\n\n const serviceTag = captureServiceTag(service)\n\n // SAFETY: The public callback constrains the acquired value and this runtime-only carrier is erased at the Layer boundary.\n return new Layer([\n {\n service,\n serviceTag,\n acquire: async () => (await acquireWithRelease()).instance,\n acquireWithRelease\n }\n ]) as LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>\n }\n\n /** Define a provider whose acquisition can yield contextual Services. */\n static scopedGen<S extends ServiceClass<any, any>, Yield extends ServiceRequirement<unknown>>(\n service: S,\n factory: LayerGenerator<S, Yield>,\n release: (instance: InstanceType<S>, outcome: ScopeOutcome) => MaybePromise<void>\n ): LayerResult<ProviderEntry<InstanceType<S>, LayerGeneratorRequirements<S, Yield>>> {\n const serviceTag = captureServiceTag(service)\n\n // SAFETY: The generator and release callback are checked against the requested Service.\n return new Layer([\n {\n service,\n serviceTag,\n acquire: () => runLayerGenerator(service, factory),\n release: (instance, outcome) => {\n // SAFETY: The backend invokes release with the instance acquired for this token.\n return release(instance as InstanceType<S>, outcome)\n }\n }\n ]) as LayerResult<ProviderEntry<InstanceType<S>, LayerGeneratorRequirements<S, Yield>>>\n }\n\n /** Define a provider whose acquisition can yield contextual Services. */\n static gen<S extends ServiceClass<any, any>, Yield extends ServiceRequirement<unknown>>(\n service: S,\n factory: LayerGenerator<S, Yield>\n ): LayerResult<ProviderEntry<InstanceType<S>, LayerGeneratorRequirements<S, Yield>>> {\n const serviceTag = captureServiceTag(service)\n\n // SAFETY: The generator result is normalized to the requested Service at the runtime boundary.\n return new Layer([\n {\n service,\n serviceTag,\n acquire: () => runLayerGenerator(service, factory)\n }\n ]) as LayerResult<ProviderEntry<InstanceType<S>, LayerGeneratorRequirements<S, Yield>>>\n }\n\n /** Compose Layers without replacing providers. */\n static merge<const Layers extends readonly LayerInput[]>(\n ...layers: Layers & ValidateLayerTuple<Layers>\n ): MergeResult<Layers> {\n const providers = new Map<string, LayerProvider>()\n\n for (const layer of layers) {\n for (const provider of layer.providers) {\n const service = provider.service\n const serviceTag = captureLayerRegistrationTag(provider)\n const existing = providers.get(serviceTag)\n\n if (existing) {\n if (existing.service !== service) {\n throw new ServiceTagCollisionError(existing.service, service)\n }\n\n throw new DuplicateServiceError(service)\n }\n\n providers.set(serviceTag, provider)\n }\n }\n\n // SAFETY: The heterogeneous provider list is erased only at this internal storage boundary.\n return new Layer([...providers.values()]) as MergeResult<Layers>\n }\n\n /** Mark a Layer composition root as complete without changing its runtime value. */\n static complete<L extends LayerInput>(layer: L & CompleteInput<L>): L {\n return layer\n }\n\n /** Replace providers in a base Layer, using tag identity and compatible contracts. */\n static override<Base extends LayerInput>(\n base: Base & ValidateLayerInput<Base>\n ): OverrideLayerResult<Base, readonly []>\n\n static override<\n Base extends LayerInput,\n const Overrides extends readonly [LayerInput, ...LayerInput[]]\n >(\n base: Base & ValidateLayerInput<Base>,\n ...overrides: Overrides & ValidateOverrides<Base, Overrides>\n ): OverrideLayerResult<Base, Overrides>\n\n static override<Base extends LayerInput, const Overrides extends readonly LayerInput[]>(\n base: Base & ValidateLayerInput<Base>,\n ...overrides: Overrides & ValidateOverrides<Base, Overrides>\n ): OverrideLayerResult<Base, Overrides>\n\n static override(base: LayerInput, ...overrides: readonly LayerInput[]): Layer<any, any> {\n const providers = new Map<string, LayerProvider>()\n\n for (const provider of base.providers) {\n providers.set(captureLayerRegistrationTag(provider), provider)\n }\n\n for (const layer of overrides) {\n for (const provider of layer.providers) {\n providers.set(captureLayerRegistrationTag(provider), provider)\n }\n }\n\n // SAFETY: Runtime provider replacement preserves the computed override metadata.\n return new Layer([...providers.values()]) as Layer<any, any>\n }\n}\n\n// TypeScript's `readonly` does not affect the runtime property descriptor. Keep\n// the class field's enumerable behavior while locking the singleton binding.\nObject.defineProperty(Layer, 'empty', {\n value: Layer.empty,\n writable: false,\n enumerable: true,\n configurable: false\n})\n\nconst normalizeAcquire =\n <S extends ServiceClass<any, any>>(\n acquire: () => MaybePromise<ServiceContract<InstanceType<S>>>\n ): (() => MaybePromise<InstanceType<S>>) =>\n () => {\n // SAFETY: ServiceContract removes only the declaration-only identity; runtime values are unchanged.\n return acquire() as MaybePromise<InstanceType<S>>\n }\n\n/** Type-level aliases for inspecting Layer environments and completeness. */\nexport declare namespace Layer {\n /** The widened Layer shape accepted by generic Layer infrastructure. */\n export type Any = LayerInput\n\n /** Extract the branded Service instances provided by a Layer. */\n export type Provided<L extends LayerInput> = ProvidedEnvironment<L>\n\n /** Extract the external Service requirements of a Layer. */\n export type Required<L extends LayerInput> = RequiredEnvironment<L>\n\n /** Extract the Services still missing from a Layer composition. */\n export type Missing<L extends LayerInput> = RequiredEnvironment<L>\n\n /** Validate a Layer's requirements and input shape. */\n export type Complete<L extends LayerInput> = CompleteInput<L>\n}\n"],"mappings":";;;;;AAyBA,IAAa,iBAAb,MAAa,eAAe;;;;;;;;;;;;;CAa1B,OAAO,IACL,UACA,SACA,UAAiC,8BAC9B;EACH,MAAM,UAAU,kBAAkB,OAAO;EACzC,MAAM,UAAU,mBACd,UACA,SAAS,OACT,SAAS,aAAa,WAAW,QAAQ,iBAAiB,CAAC,GAC3D,SAAS,QACT,SAAS,aAAa,WAAW,UAAU,KAAA,CAC7C;EAEA,OAAO,kBAAkB,SAAS,SAAS,OAAO;CACpD;;CAGA,OAAO,UAA2B;EAChC,IAAI;EAEJ,IAAI;GACF,UAAU,sBAAsB;EAClC,SAAS,OAAO;GACd,IAAI,iBAAiB,kCACnB,MAAM,IAAI,iCAAiC;GAG7C,MAAM;EACR;EAEA,IAAI,CAAC,QAAQ,UACX,MAAM,IAAI,iCAAiC;EAG7C,OAAO,QAAQ;CACjB;;CAGA,aAAa,QAAmC,OAAoC;EAClF,kBAAkB,KAAK;EAGvB,OAAO,MAFU,eAAe,QAEZ,CAAC,CAAC,QAAQ,KAAK;CACrC;AACF;;;;;;;;;;;;;;;;;;;;;;;;;ACtBA,SAAgB,UAAsC;CACpD,OAAO,SAAoC,KAA6B;EAC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4BAA4B,QAAQ;GACvD,MAAM,WAAW,UAAU,IAAI,UAAU;GAEzC,IAAI,UAAU;IACZ,IAAI,SAAS,YAAY,SACvB,MAAM,IAAI,yBAAyB,SAAS,SAAS,OAAO;IAG9D,MAAM,IAAI,sBAAsB,OAAO;GACzC;GAEA,UAAU,IAAI,YAAY,QAAQ;EACpC;EAIF,OAAO,IAAI,MAAM,CAAC,GAAG,UAAU,OAAO,CAAC,CAAC;CAC1C;;CAGA,OAAO,SAA+B,OAAgC;EACpE,OAAO;CACT;CAoBA,OAAO,SAAS,MAAkB,GAAG,WAAmD;EACtF,MAAM,4BAAY,IAAI,IAA2B;EAEjD,KAAK,MAAM,YAAY,KAAK,WAC1B,UAAU,IAAI,4BAA4B,QAAQ,GAAG,QAAQ;EAG/D,KAAK,MAAM,SAAS,WAClB,KAAK,MAAM,YAAY,MAAM,WAC3B,UAAU,IAAI,4BAA4B,QAAQ,GAAG,QAAQ;EAKjE,OAAO,IAAI,MAAM,CAAC,GAAG,UAAU,OAAO,CAAC,CAAC;CAC1C;AACF;AAIA,OAAO,eAAe,OAAO,SAAS;CACpC,OAAO,MAAM;CACb,UAAU;CACV,YAAY;CACZ,cAAc;AAChB,CAAC;AAED,MAAM,oBAEF,kBAEI;CAEJ,OAAO,QAAQ;AACjB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { c as RuntimeContextStorage, s as RuntimeContext } from "./index-heuaRmXR.mjs";
|
|
2
|
+
//#region src/runtime/node-context.d.ts
|
|
3
|
+
/** RuntimeContextStorage backed by Node/Bun async context propagation. */
|
|
4
|
+
declare class NodeRuntimeContextStorage implements RuntimeContextStorage {
|
|
5
|
+
run<A>(context: RuntimeContext, program: () => A): A;
|
|
6
|
+
current(): RuntimeContext;
|
|
7
|
+
}
|
|
8
|
+
/** Shared Node/Bun storage used by the compatibility APIs and default Runtime. */
|
|
9
|
+
declare const nodeRuntimeContextStorage: NodeRuntimeContextStorage;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { nodeRuntimeContextStorage as n, NodeRuntimeContextStorage as t };
|
|
12
|
+
//# sourceMappingURL=node-context-DWsCUBRa.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-context-DWsCUBRa.d.mts","names":[],"sources":["../src/runtime/node-context.ts"],"mappings":";;;cA2Ba,qCAAqC;EAChD,IAAI,GAAG,SAAS,gBAAgB,eAAe,IAAI;EAInD,WAAW;;;cAYA,2BAAyB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { f as setRuntimeContextFrameCarrier, h as RuntimeContextNotConfiguredError, m as withActiveRuntimeContextStorage, r as currentRuntimeContextFrame } from "./context-BUEf1qjL.mjs";
|
|
2
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
|
+
//#region src/runtime/node-context.ts
|
|
4
|
+
const asyncLocalStorage = new AsyncLocalStorage();
|
|
5
|
+
setRuntimeContextFrameCarrier({
|
|
6
|
+
run: (frame, program) => asyncLocalStorage.run(frame, program),
|
|
7
|
+
current: () => asyncLocalStorage.getStore()
|
|
8
|
+
});
|
|
9
|
+
/** RuntimeContextStorage backed by Node/Bun async context propagation. */
|
|
10
|
+
var NodeRuntimeContextStorage = class {
|
|
11
|
+
run(context, program) {
|
|
12
|
+
return withActiveRuntimeContextStorage(this, context, program);
|
|
13
|
+
}
|
|
14
|
+
current() {
|
|
15
|
+
const frame = currentRuntimeContextFrame();
|
|
16
|
+
if (!frame || frame.storage !== this) throw new RuntimeContextNotConfiguredError();
|
|
17
|
+
return frame.context;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
/** Shared Node/Bun storage used by the compatibility APIs and default Runtime. */
|
|
21
|
+
const nodeRuntimeContextStorage = new NodeRuntimeContextStorage();
|
|
22
|
+
//#endregion
|
|
23
|
+
export { nodeRuntimeContextStorage as n, NodeRuntimeContextStorage as t };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=node-context-lggRF4bR.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-context-lggRF4bR.mjs","names":[],"sources":["../src/runtime/node-context.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks'\n\nimport { RuntimeContextNotConfiguredError } from './errors'\n\nimport {\n currentRuntimeContextFrame,\n setRuntimeContextFrameCarrier,\n withActiveRuntimeContextStorage\n} from './context'\n\nimport type {\n ActiveRuntimeContextFrame,\n RuntimeContext,\n RuntimeContextFrameCarrier,\n RuntimeContextStorage\n} from './context'\n\nconst asyncLocalStorage = new AsyncLocalStorage<ActiveRuntimeContextFrame>()\n\nconst frameCarrier: RuntimeContextFrameCarrier = {\n run: (frame, program) => asyncLocalStorage.run(frame, program),\n current: () => asyncLocalStorage.getStore()\n}\n\nsetRuntimeContextFrameCarrier(frameCarrier)\n\n/** RuntimeContextStorage backed by Node/Bun async context propagation. */\nexport class NodeRuntimeContextStorage implements RuntimeContextStorage {\n run<A>(context: RuntimeContext, program: () => A): A {\n return withActiveRuntimeContextStorage(this, context, program)\n }\n\n current(): RuntimeContext {\n const frame = currentRuntimeContextFrame()\n\n if (!frame || frame.storage !== this) {\n throw new RuntimeContextNotConfiguredError()\n }\n\n return frame.context\n }\n}\n\n/** Shared Node/Bun storage used by the compatibility APIs and default Runtime. */\nexport const nodeRuntimeContextStorage = new NodeRuntimeContextStorage()\n\nexport { RuntimeContextNotConfiguredError } from './errors'\n\nexport type { RuntimeContext, RuntimeContextStorage } from './context'\n"],"mappings":";;;AAiBA,MAAM,oBAAoB,IAAI,kBAA6C;AAO3E,8BAA8B;CAJ5B,MAAM,OAAO,YAAY,kBAAkB,IAAI,OAAO,OAAO;CAC7D,eAAe,kBAAkB,SAAS;AAGH,CAAC;;AAG1C,IAAa,4BAAb,MAAwE;CACtE,IAAO,SAAyB,SAAqB;EACnD,OAAO,gCAAgC,MAAM,SAAS,OAAO;CAC/D;CAEA,UAA0B;EACxB,MAAM,QAAQ,2BAA2B;EAEzC,IAAI,CAAC,SAAS,MAAM,YAAY,MAC9B,MAAM,IAAI,iCAAiC;EAG7C,OAAO,MAAM;CACf;AACF;;AAGA,MAAa,4BAA4B,IAAI,0BAA0B"}
|
package/dist/node.d.mts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { C as EffectError, E as EffectSuccess, c as RuntimeContextStorage, s as RuntimeContext } from "./index-heuaRmXR.mjs";
|
|
2
|
+
import { C as CompleteExecution, D as LayerInput, M as ProvidedEnvironment, T as CompleteInput, r as RuntimeOptions, y as LayerBackend } from "./outcome-CB43bnFW.mjs";
|
|
3
|
+
import { t as RuntimeContextNotConfiguredError } from "./errors-BKcsQ0ip.mjs";
|
|
4
|
+
import "./index-CX6iAoCB.mjs";
|
|
5
|
+
import { n as nodeRuntimeContextStorage, t as NodeRuntimeContextStorage } from "./node-context-DWsCUBRa.mjs";
|
|
6
|
+
import { Result } from "better-result";
|
|
7
|
+
//#region src/runtime/node-runtime.d.ts
|
|
8
|
+
/** Process signals supported by the Node.js/Bun process boundary. */
|
|
9
|
+
type NodeRuntimeSignal = 'SIGINT' | 'SIGTERM';
|
|
10
|
+
/** Translate a successful main result to a process exit code. */
|
|
11
|
+
type NodeRuntimeSuccessHandler<Success> = (value: Success) => number;
|
|
12
|
+
/** Translate a typed main failure to a process exit code. */
|
|
13
|
+
type NodeRuntimeFailureHandler<Failure> = (error: Failure) => number;
|
|
14
|
+
/** Observe a thrown or rejected main defect while it remains a rejected Promise. */
|
|
15
|
+
type NodeRuntimeDefectHandler = (cause: unknown) => number | void;
|
|
16
|
+
/** Options for the Node.js/Bun process boundary. */
|
|
17
|
+
type NodeRuntimeOptions<Success = unknown, Failure = unknown> = RuntimeOptions & {
|
|
18
|
+
/** Process signals that request cooperative shutdown. Defaults to SIGINT and SIGTERM. */
|
|
19
|
+
readonly signals?: readonly NodeRuntimeSignal[];
|
|
20
|
+
/** Map a nominal Result.ok value, or a plain successful value, to an exit code. */
|
|
21
|
+
readonly onSuccess?: NodeRuntimeSuccessHandler<Success>;
|
|
22
|
+
/** Map a nominal Result.err error to an exit code. */
|
|
23
|
+
readonly onFailure?: NodeRuntimeFailureHandler<Failure>;
|
|
24
|
+
/** Observe a defect. Defects are rethrown after the handler runs. */
|
|
25
|
+
readonly onDefect?: NodeRuntimeDefectHandler;
|
|
26
|
+
};
|
|
27
|
+
type NonResultMainSuccess<Value> = Value extends Result<any, any> ? never : Value;
|
|
28
|
+
type PlainMainSuccess<Value> = NonResultMainSuccess<Awaited<Value>>;
|
|
29
|
+
type MainSuccess<Value> = EffectSuccess<Value> | PlainMainSuccess<Value>;
|
|
30
|
+
type MainFailure<Value> = EffectError<Value>;
|
|
31
|
+
type MainOptions<Value> = NodeRuntimeOptions<MainSuccess<Value>, MainFailure<Value>>;
|
|
32
|
+
/** Node.js/Bun process lifecycle helpers. */
|
|
33
|
+
declare class NodeRuntime {
|
|
34
|
+
/**
|
|
35
|
+
* Run a typed main Program, translate its final result to `process.exitCode`,
|
|
36
|
+
* and dispose the Runtime when the program or a configured process signal settles.
|
|
37
|
+
*/
|
|
38
|
+
static runMain<A, L extends LayerInput>(layer: L & CompleteInput<L>, backend: LayerBackend, program: CompleteExecution<ProvidedEnvironment<L>, A>, options?: MainOptions<A>): Promise<Awaited<A>>;
|
|
39
|
+
static runMain<A, L extends LayerInput>(layer: L & CompleteInput<L>, program: CompleteExecution<ProvidedEnvironment<L>, A>, options?: MainOptions<A>): Promise<Awaited<A>>;
|
|
40
|
+
static runMain<A, L extends LayerInput>(layer: L & CompleteInput<L>, options: MainOptions<A>, program: CompleteExecution<ProvidedEnvironment<L>, A>): Promise<Awaited<A>>;
|
|
41
|
+
}
|
|
42
|
+
/** Type-level aliases for the Node.js/Bun process boundary. */
|
|
43
|
+
declare namespace NodeRuntime {
|
|
44
|
+
/** Options for `NodeRuntime.runMain`. */
|
|
45
|
+
type Options<Success = unknown, Failure = unknown> = NodeRuntimeOptions<Success, Failure>;
|
|
46
|
+
/** A process signal accepted by `NodeRuntime.runMain`. */
|
|
47
|
+
type Signal = NodeRuntimeSignal;
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { NodeRuntime, NodeRuntimeContextStorage, type NodeRuntimeDefectHandler, type NodeRuntimeFailureHandler, type NodeRuntimeOptions, type NodeRuntimeSignal, type NodeRuntimeSuccessHandler, type RuntimeContext, RuntimeContextNotConfiguredError, type RuntimeContextStorage, nodeRuntimeContextStorage };
|
|
51
|
+
//# sourceMappingURL=node.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.mts","names":[],"sources":["../src/runtime/node-runtime.ts"],"mappings":";;;;;;;;KAoBY;;KAGA,0BAA0B,YAAY,OAAO;;KAG7C,0BAA0B,YAAY,OAAO;;KAG7C,4BAA4B;;KAG5B,mBAAmB,mBAAmB,qBAAqB;;WAE5D,mBAAmB;;WAEnB,YAAY,0BAA0B;;WAEtC,YAAY,0BAA0B;;WAEtC,WAAW;;KAGjB,qBAAqB,SAAS,cAAc,2BAA+B;KAE3E,iBAAiB,SAAS,qBAAqB,QAAQ;KAEvD,YAAY,SAAS,cAAc,SAAS,iBAAiB;KAE7D,YAAY,SAAS,YAAY;KAEjC,YAAY,SAAS,mBAAmB,YAAY,QAAQ,YAAY;;cAqMhE;;;;;SAKJ,QAAQ,GAAG,UAAU,YAC1B,OAAO,IAAI,cAAc,IACzB,SAAS,cACT,SAAS,kBAAkB,oBAAoB,IAAI,IACnD,UAAU,YAAY,KACrB,QAAQ,QAAQ;SAEZ,QAAQ,GAAG,UAAU,YAC1B,OAAO,IAAI,cAAc,IACzB,SAAS,kBAAkB,oBAAoB,IAAI,IACnD,UAAU,YAAY,KACrB,QAAQ,QAAQ;SAEZ,QAAQ,GAAG,UAAU,YAC1B,OAAO,IAAI,cAAc,IACzB,SAAS,YAAY,IACrB,SAAS,kBAAkB,oBAAoB,IAAI,KAClD,QAAQ,QAAQ;;;kBA8NI;;OAEX,QAAQ,mBAAmB,qBAAqB,mBAAmB,SAAS;;OAG5E,SAAS"}
|
package/dist/node.mjs
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { h as RuntimeContextNotConfiguredError } from "./context-BUEf1qjL.mjs";
|
|
2
|
+
import { n as nodeRuntimeContextStorage, t as NodeRuntimeContextStorage } from "./node-context-lggRF4bR.mjs";
|
|
3
|
+
import { n as linkAbortSignals } from "./signal-D2UTcaaG.mjs";
|
|
4
|
+
import { t as Runtime } from "./runtime-CBMrX8Wl.mjs";
|
|
5
|
+
import { Err, Ok } from "better-result";
|
|
6
|
+
//#region src/runtime/node-runtime.ts
|
|
7
|
+
const DEFAULT_SIGNALS = ["SIGINT", "SIGTERM"];
|
|
8
|
+
const isLayerBackend = (value) => {
|
|
9
|
+
if (value === null || typeof value !== "object") return false;
|
|
10
|
+
return "register" in value && "resolve" in value && "disposeAll" in value && typeof value.register === "function" && typeof value.resolve === "function" && typeof value.disposeAll === "function";
|
|
11
|
+
};
|
|
12
|
+
const isAbortSignal = (value) => {
|
|
13
|
+
if (value === null || typeof value !== "object") return false;
|
|
14
|
+
return typeof value.aborted === "boolean" && typeof value.addEventListener === "function" && typeof value.removeEventListener === "function";
|
|
15
|
+
};
|
|
16
|
+
const isOptionsObject = (value) => {
|
|
17
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
18
|
+
};
|
|
19
|
+
const validateExitCode = (code) => {
|
|
20
|
+
if (!Number.isSafeInteger(code) || code < 0) throw new RangeError("NodeRuntime exit codes must be non-negative safe integers");
|
|
21
|
+
return code;
|
|
22
|
+
};
|
|
23
|
+
const ensureFailureExitCode = (code) => code === 0 ? 1 : code;
|
|
24
|
+
const validateSignals = (signals) => {
|
|
25
|
+
if (signals !== void 0 && !Array.isArray(signals)) throw new TypeError("NodeRuntime signals must be an array of supported signal names");
|
|
26
|
+
for (const signal of signals ?? DEFAULT_SIGNALS) if (typeof signal !== "string" || signal !== "SIGINT" && signal !== "SIGTERM") throw new RangeError(`NodeRuntime signal "${String(signal)}" is not supported`);
|
|
27
|
+
};
|
|
28
|
+
const validateRuntimeOptions = (options) => {
|
|
29
|
+
if (options.signal !== void 0 && !isAbortSignal(options.signal)) throw new TypeError("NodeRuntime signal must be an AbortSignal");
|
|
30
|
+
};
|
|
31
|
+
const validateCallbacks = (options) => {
|
|
32
|
+
if (options.onSuccess !== void 0 && typeof options.onSuccess !== "function") throw new TypeError("NodeRuntime onSuccess must be a function");
|
|
33
|
+
if (options.onFailure !== void 0 && typeof options.onFailure !== "function") throw new TypeError("NodeRuntime onFailure must be a function");
|
|
34
|
+
if (options.onDefect !== void 0 && typeof options.onDefect !== "function") throw new TypeError("NodeRuntime onDefect must be a function");
|
|
35
|
+
if (options.onCleanupFailure !== void 0 && typeof options.onCleanupFailure !== "function") throw new TypeError("NodeRuntime onCleanupFailure must be a function");
|
|
36
|
+
};
|
|
37
|
+
const validateOptions = (options) => {
|
|
38
|
+
validateSignals(options.signals);
|
|
39
|
+
validateRuntimeOptions(options);
|
|
40
|
+
validateCallbacks(options);
|
|
41
|
+
if (options.observers !== void 0 && !Array.isArray(options.observers)) throw new TypeError("NodeRuntime observers must be an array");
|
|
42
|
+
};
|
|
43
|
+
const normalizeSignals = (signals) => {
|
|
44
|
+
const unique = /* @__PURE__ */ new Set();
|
|
45
|
+
for (const signal of signals ?? DEFAULT_SIGNALS) unique.add(signal);
|
|
46
|
+
return [...unique];
|
|
47
|
+
};
|
|
48
|
+
const removeSignalListeners = (listeners) => {
|
|
49
|
+
const failures = [];
|
|
50
|
+
for (const { signal, listener } of listeners) try {
|
|
51
|
+
process.removeListener(signal, listener);
|
|
52
|
+
} catch (cause) {
|
|
53
|
+
failures.push(cause);
|
|
54
|
+
}
|
|
55
|
+
listeners.length = 0;
|
|
56
|
+
return failures;
|
|
57
|
+
};
|
|
58
|
+
const combineFailures = (failures) => {
|
|
59
|
+
if (failures.length === 0) return [];
|
|
60
|
+
if (failures.length === 1) return [failures[0]];
|
|
61
|
+
return [new AggregateError(failures, "NodeRuntime cleanup failed")];
|
|
62
|
+
};
|
|
63
|
+
const setExitCode = (code) => {
|
|
64
|
+
process.exitCode = validateExitCode(code);
|
|
65
|
+
};
|
|
66
|
+
const reportDefect = (cause, handler) => {
|
|
67
|
+
let exitCode = 1;
|
|
68
|
+
if (handler) try {
|
|
69
|
+
const requestedExitCode = handler(cause);
|
|
70
|
+
if (requestedExitCode !== void 0) exitCode = validateExitCode(requestedExitCode);
|
|
71
|
+
} catch {
|
|
72
|
+
exitCode = 1;
|
|
73
|
+
}
|
|
74
|
+
setExitCode(ensureFailureExitCode(exitCode));
|
|
75
|
+
};
|
|
76
|
+
const installSignalListeners = (signals, listeners, onSignal) => {
|
|
77
|
+
for (const signal of signals) {
|
|
78
|
+
const listener = () => onSignal(signal);
|
|
79
|
+
process.on(signal, listener);
|
|
80
|
+
listeners.push({
|
|
81
|
+
signal,
|
|
82
|
+
listener
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
/** Node.js/Bun process lifecycle helpers. */
|
|
87
|
+
var NodeRuntime = class {
|
|
88
|
+
static async runMain(layer, backendOrProgramOrOptions, programOrOptions, legacyOptions) {
|
|
89
|
+
let backend;
|
|
90
|
+
let program;
|
|
91
|
+
let options;
|
|
92
|
+
if (typeof backendOrProgramOrOptions === "function") {
|
|
93
|
+
program = backendOrProgramOrOptions;
|
|
94
|
+
options = programOrOptions;
|
|
95
|
+
} else if (isLayerBackend(backendOrProgramOrOptions)) {
|
|
96
|
+
backend = backendOrProgramOrOptions;
|
|
97
|
+
program = programOrOptions;
|
|
98
|
+
options = legacyOptions;
|
|
99
|
+
} else {
|
|
100
|
+
options = backendOrProgramOrOptions;
|
|
101
|
+
program = programOrOptions;
|
|
102
|
+
}
|
|
103
|
+
if (options !== void 0 && !isOptionsObject(options)) throw new TypeError("NodeRuntime options must be a non-array object");
|
|
104
|
+
const normalizedOptions = options ?? {};
|
|
105
|
+
validateOptions(normalizedOptions);
|
|
106
|
+
const shutdownController = new AbortController();
|
|
107
|
+
const configuredSignals = normalizeSignals(normalizedOptions.signals);
|
|
108
|
+
const { onSuccess, onFailure, onDefect, signal: callerSignal, ...runtimeOptions } = normalizedOptions;
|
|
109
|
+
const signalLink = linkAbortSignals(callerSignal, shutdownController.signal);
|
|
110
|
+
const listeners = [];
|
|
111
|
+
const cleanupFailures = [];
|
|
112
|
+
let runtime;
|
|
113
|
+
let disposalPromise;
|
|
114
|
+
let disposalObserved = false;
|
|
115
|
+
let firstSignal;
|
|
116
|
+
let setupFailed = false;
|
|
117
|
+
let setupFailure;
|
|
118
|
+
let programFailed = false;
|
|
119
|
+
let programFailure;
|
|
120
|
+
let executionCleanupFailed = false;
|
|
121
|
+
let executionOutcome;
|
|
122
|
+
let programSettled = false;
|
|
123
|
+
let programValue;
|
|
124
|
+
const requestDispose = () => {
|
|
125
|
+
if (disposalPromise) return disposalPromise;
|
|
126
|
+
try {
|
|
127
|
+
disposalPromise = runtime.dispose();
|
|
128
|
+
} catch (cause) {
|
|
129
|
+
disposalPromise = Promise.reject(cause);
|
|
130
|
+
}
|
|
131
|
+
return disposalPromise;
|
|
132
|
+
};
|
|
133
|
+
const observeDisposal = async () => {
|
|
134
|
+
if (!runtime || disposalObserved) return;
|
|
135
|
+
disposalObserved = true;
|
|
136
|
+
try {
|
|
137
|
+
await requestDispose();
|
|
138
|
+
} catch (cause) {
|
|
139
|
+
cleanupFailures.push(cause);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
const onSignal = (signal) => {
|
|
143
|
+
if (firstSignal !== void 0) return;
|
|
144
|
+
firstSignal = signal;
|
|
145
|
+
try {
|
|
146
|
+
shutdownController.abort(signal);
|
|
147
|
+
} finally {
|
|
148
|
+
requestDispose().catch(() => {});
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
try {
|
|
152
|
+
const executionObserver = { onExecutionEnd: ({ outcome }) => {
|
|
153
|
+
executionOutcome = outcome;
|
|
154
|
+
} };
|
|
155
|
+
const runtimeOptionsWithSignal = {
|
|
156
|
+
...runtimeOptions,
|
|
157
|
+
observers: [executionObserver, ...runtimeOptions.observers ?? []],
|
|
158
|
+
signal: signalLink.signal
|
|
159
|
+
};
|
|
160
|
+
runtime = backend ? await Runtime.make(layer, backend, runtimeOptionsWithSignal) : await Runtime.make(layer, runtimeOptionsWithSignal);
|
|
161
|
+
installSignalListeners(configuredSignals, listeners, onSignal);
|
|
162
|
+
try {
|
|
163
|
+
programValue = await runtime.run(program);
|
|
164
|
+
programSettled = true;
|
|
165
|
+
} catch (cause) {
|
|
166
|
+
if (executionOutcome?.status === "success") executionCleanupFailed = true;
|
|
167
|
+
else programFailed = true;
|
|
168
|
+
programFailure = cause;
|
|
169
|
+
}
|
|
170
|
+
await observeDisposal();
|
|
171
|
+
} catch (cause) {
|
|
172
|
+
setupFailed = true;
|
|
173
|
+
setupFailure = cause;
|
|
174
|
+
} finally {
|
|
175
|
+
await observeDisposal();
|
|
176
|
+
cleanupFailures.push(...removeSignalListeners(listeners));
|
|
177
|
+
try {
|
|
178
|
+
signalLink.dispose();
|
|
179
|
+
} catch (cause) {
|
|
180
|
+
cleanupFailures.push(cause);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const cleanupFailureValues = combineFailures(cleanupFailures);
|
|
184
|
+
const hasCleanupFailure = cleanupFailureValues.length > 0;
|
|
185
|
+
const cleanupFailure = cleanupFailureValues[0];
|
|
186
|
+
if (setupFailed) {
|
|
187
|
+
reportDefect(setupFailure, onDefect);
|
|
188
|
+
throw setupFailure;
|
|
189
|
+
}
|
|
190
|
+
if (programFailed) {
|
|
191
|
+
reportDefect(programFailure, onDefect);
|
|
192
|
+
throw programFailure;
|
|
193
|
+
}
|
|
194
|
+
if (executionCleanupFailed) {
|
|
195
|
+
setExitCode(1);
|
|
196
|
+
throw programFailure;
|
|
197
|
+
}
|
|
198
|
+
if (!programSettled) {
|
|
199
|
+
const failure = /* @__PURE__ */ new Error("NodeRuntime main program did not settle");
|
|
200
|
+
reportDefect(failure, onDefect);
|
|
201
|
+
throw failure;
|
|
202
|
+
}
|
|
203
|
+
if (programValue instanceof Err) {
|
|
204
|
+
let exitCode = 1;
|
|
205
|
+
try {
|
|
206
|
+
if (onFailure) exitCode = validateExitCode(onFailure(programValue.error));
|
|
207
|
+
} catch (cause) {
|
|
208
|
+
reportDefect(cause, onDefect);
|
|
209
|
+
throw cause;
|
|
210
|
+
}
|
|
211
|
+
setExitCode(exitCode);
|
|
212
|
+
return programValue;
|
|
213
|
+
}
|
|
214
|
+
let exitCode = 0;
|
|
215
|
+
try {
|
|
216
|
+
if (onSuccess) {
|
|
217
|
+
const successValue = programValue instanceof Ok ? programValue.value : programValue;
|
|
218
|
+
exitCode = validateExitCode(onSuccess(successValue));
|
|
219
|
+
}
|
|
220
|
+
} catch (cause) {
|
|
221
|
+
reportDefect(cause, onDefect);
|
|
222
|
+
throw cause;
|
|
223
|
+
}
|
|
224
|
+
if (hasCleanupFailure) exitCode = ensureFailureExitCode(exitCode);
|
|
225
|
+
setExitCode(exitCode);
|
|
226
|
+
if (hasCleanupFailure) throw cleanupFailure;
|
|
227
|
+
return programValue;
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
//#endregion
|
|
231
|
+
export { NodeRuntime, NodeRuntimeContextStorage, RuntimeContextNotConfiguredError, nodeRuntimeContextStorage };
|
|
232
|
+
|
|
233
|
+
//# sourceMappingURL=node.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.mjs","names":[],"sources":["../src/runtime/node-runtime.ts"],"sourcesContent":["import { Err, Ok } from 'better-result'\n\nimport type { Result as ResultType } from 'better-result'\n\nimport type { EffectError, EffectSuccess } from '../effect'\nimport type { LayerBackend } from '../layer/backend'\nimport type {\n CompleteExecution,\n CompleteInput,\n LayerInput,\n ProvidedEnvironment\n} from '../layer/inference'\nimport { Runtime } from './runtime'\nimport { linkAbortSignals } from './signal'\n\nimport type { RuntimeOptions } from './outcome'\nimport type { RuntimeExecutionEndEvent, RuntimeObserver } from './observer'\nimport type { ScopeOutcome } from '../scope'\n\n/** Process signals supported by the Node.js/Bun process boundary. */\nexport type NodeRuntimeSignal = 'SIGINT' | 'SIGTERM'\n\n/** Translate a successful main result to a process exit code. */\nexport type NodeRuntimeSuccessHandler<Success> = (value: Success) => number\n\n/** Translate a typed main failure to a process exit code. */\nexport type NodeRuntimeFailureHandler<Failure> = (error: Failure) => number\n\n/** Observe a thrown or rejected main defect while it remains a rejected Promise. */\nexport type NodeRuntimeDefectHandler = (cause: unknown) => number | void\n\n/** Options for the Node.js/Bun process boundary. */\nexport type NodeRuntimeOptions<Success = unknown, Failure = unknown> = RuntimeOptions & {\n /** Process signals that request cooperative shutdown. Defaults to SIGINT and SIGTERM. */\n readonly signals?: readonly NodeRuntimeSignal[]\n /** Map a nominal Result.ok value, or a plain successful value, to an exit code. */\n readonly onSuccess?: NodeRuntimeSuccessHandler<Success>\n /** Map a nominal Result.err error to an exit code. */\n readonly onFailure?: NodeRuntimeFailureHandler<Failure>\n /** Observe a defect. Defects are rethrown after the handler runs. */\n readonly onDefect?: NodeRuntimeDefectHandler\n}\n\ntype NonResultMainSuccess<Value> = Value extends ResultType<any, any> ? never : Value\n\ntype PlainMainSuccess<Value> = NonResultMainSuccess<Awaited<Value>>\n\ntype MainSuccess<Value> = EffectSuccess<Value> | PlainMainSuccess<Value>\n\ntype MainFailure<Value> = EffectError<Value>\n\ntype MainOptions<Value> = NodeRuntimeOptions<MainSuccess<Value>, MainFailure<Value>>\n\nconst DEFAULT_SIGNALS = ['SIGINT', 'SIGTERM'] as const satisfies readonly NodeRuntimeSignal[]\n\ntype InstalledSignalListener = {\n readonly signal: NodeRuntimeSignal\n readonly listener: () => void\n}\n\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- backend overload dispatch validates an opaque runtime value.\nconst isLayerBackend = (value: unknown): value is LayerBackend => {\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- runtime overload dispatch must inspect the backend shape.\n if (value === null || typeof value !== 'object') {\n return false\n }\n\n return (\n 'register' in value &&\n 'resolve' in value &&\n 'disposeAll' in value &&\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- the backend contract is validated at this runtime boundary.\n typeof value.register === 'function' &&\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- the backend contract is validated at this runtime boundary.\n typeof value.resolve === 'function' &&\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- the backend contract is validated at this runtime boundary.\n typeof value.disposeAll === 'function'\n )\n}\n\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- AbortSignal validation receives an opaque public option.\nconst isAbortSignal = (value: unknown): value is AbortSignal => {\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- validate the structural host signal contract.\n if (value === null || typeof value !== 'object') {\n return false\n }\n\n return (\n // SAFETY: the preceding guard establishes that the opaque value is an object; these are the required AbortSignal members.\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- validate the structural host signal contract.\n typeof (value as AbortSignal).aborted === 'boolean' &&\n // SAFETY: the preceding guard establishes that the opaque value is an object; these are the required AbortSignal members.\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- validate the structural host signal contract.\n typeof (value as AbortSignal).addEventListener === 'function' &&\n // SAFETY: the preceding guard establishes that the opaque value is an object; these are the required AbortSignal members.\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- validate the structural host signal contract.\n typeof (value as AbortSignal).removeEventListener === 'function'\n )\n}\n\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- options are validated at the public boundary.\nconst isOptionsObject = (value: unknown): value is object => {\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- validate the public options boundary before installing listeners.\n return value !== null && typeof value === 'object' && !Array.isArray(value)\n}\n\nconst validateExitCode = (code: number): number => {\n if (!Number.isSafeInteger(code) || code < 0) {\n throw new RangeError('NodeRuntime exit codes must be non-negative safe integers')\n }\n\n return code\n}\n\nconst ensureFailureExitCode = (code: number): number => (code === 0 ? 1 : code)\n\nconst validateSignals = <Success, Failure>(\n signals: NodeRuntimeOptions<Success, Failure>['signals']\n): void => {\n if (signals !== undefined && !Array.isArray(signals)) {\n throw new TypeError('NodeRuntime signals must be an array of supported signal names')\n }\n\n for (const signal of signals ?? DEFAULT_SIGNALS) {\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- validate untyped options before process.on receives them.\n if (typeof signal !== 'string' || (signal !== 'SIGINT' && signal !== 'SIGTERM')) {\n throw new RangeError(`NodeRuntime signal \"${String(signal)}\" is not supported`)\n }\n }\n}\n\nconst validateRuntimeOptions = <Success, Failure>(\n options: NodeRuntimeOptions<Success, Failure>\n): void => {\n if (options.signal !== undefined && !isAbortSignal(options.signal)) {\n throw new TypeError('NodeRuntime signal must be an AbortSignal')\n }\n}\n\nconst validateCallbacks = <Success, Failure>(\n options: NodeRuntimeOptions<Success, Failure>\n): void => {\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- validate untyped options before invoking the callback.\n if (options.onSuccess !== undefined && typeof options.onSuccess !== 'function') {\n throw new TypeError('NodeRuntime onSuccess must be a function')\n }\n\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- validate untyped options before invoking the callback.\n if (options.onFailure !== undefined && typeof options.onFailure !== 'function') {\n throw new TypeError('NodeRuntime onFailure must be a function')\n }\n\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- validate untyped options before invoking the callback.\n if (options.onDefect !== undefined && typeof options.onDefect !== 'function') {\n throw new TypeError('NodeRuntime onDefect must be a function')\n }\n\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- validate untyped options before Runtime invokes the observer.\n if (options.onCleanupFailure !== undefined && typeof options.onCleanupFailure !== 'function') {\n throw new TypeError('NodeRuntime onCleanupFailure must be a function')\n }\n}\n\nconst validateOptions = <Success, Failure>(options: NodeRuntimeOptions<Success, Failure>): void => {\n validateSignals(options.signals)\n validateRuntimeOptions(options)\n validateCallbacks(options)\n\n if (options.observers !== undefined && !Array.isArray(options.observers)) {\n throw new TypeError('NodeRuntime observers must be an array')\n }\n}\n\nconst normalizeSignals = (\n signals: readonly NodeRuntimeSignal[] | undefined\n): readonly NodeRuntimeSignal[] => {\n const unique = new Set<NodeRuntimeSignal>()\n\n for (const signal of signals ?? DEFAULT_SIGNALS) {\n unique.add(signal)\n }\n\n return [...unique]\n}\n\nconst removeSignalListeners = (listeners: InstalledSignalListener[]): readonly unknown[] => {\n const failures: unknown[] = []\n\n for (const { signal, listener } of listeners) {\n try {\n process.removeListener(signal, listener)\n } catch (cause) {\n failures.push(cause)\n }\n }\n\n listeners.length = 0\n\n return failures\n}\n\nconst combineFailures = (failures: readonly unknown[]): readonly unknown[] => {\n if (failures.length === 0) {\n return []\n }\n\n if (failures.length === 1) {\n return [failures[0]]\n }\n\n return [new AggregateError(failures, 'NodeRuntime cleanup failed')]\n}\n\nconst setExitCode = (code: number): void => {\n process.exitCode = validateExitCode(code)\n}\n\nconst reportDefect = (cause: unknown, handler: NodeRuntimeDefectHandler | undefined): void => {\n let exitCode = 1\n\n if (handler) {\n try {\n const requestedExitCode = handler(cause)\n\n if (requestedExitCode !== undefined) {\n exitCode = validateExitCode(requestedExitCode)\n }\n } catch {\n exitCode = 1\n }\n }\n\n setExitCode(ensureFailureExitCode(exitCode))\n}\n\nconst installSignalListeners = (\n signals: readonly NodeRuntimeSignal[],\n listeners: InstalledSignalListener[],\n onSignal: (signal: NodeRuntimeSignal) => void\n): void => {\n for (const signal of signals) {\n const listener = (): void => onSignal(signal)\n process.on(signal, listener)\n listeners.push({ signal, listener })\n }\n}\n\n/** Node.js/Bun process lifecycle helpers. */\nexport class NodeRuntime {\n /**\n * Run a typed main Program, translate its final result to `process.exitCode`,\n * and dispose the Runtime when the program or a configured process signal settles.\n */\n static runMain<A, L extends LayerInput>(\n layer: L & CompleteInput<L>,\n backend: LayerBackend,\n program: CompleteExecution<ProvidedEnvironment<L>, A>,\n options?: MainOptions<A>\n ): Promise<Awaited<A>>\n\n static runMain<A, L extends LayerInput>(\n layer: L & CompleteInput<L>,\n program: CompleteExecution<ProvidedEnvironment<L>, A>,\n options?: MainOptions<A>\n ): Promise<Awaited<A>>\n\n static runMain<A, L extends LayerInput>(\n layer: L & CompleteInput<L>,\n options: MainOptions<A>,\n program: CompleteExecution<ProvidedEnvironment<L>, A>\n ): Promise<Awaited<A>>\n\n static async runMain<A, L extends LayerInput>(\n layer: L & CompleteInput<L>,\n backendOrProgramOrOptions:\n | LayerBackend\n | MainOptions<A>\n | CompleteExecution<ProvidedEnvironment<L>, A>,\n programOrOptions?: CompleteExecution<ProvidedEnvironment<L>, A> | MainOptions<A>,\n legacyOptions?: MainOptions<A>\n ): Promise<Awaited<A>> {\n let backend: LayerBackend | undefined\n let program!: CompleteExecution<ProvidedEnvironment<L>, A>\n let options: MainOptions<A> | undefined\n\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- overload dispatch distinguishes the Program callback from configuration.\n if (typeof backendOrProgramOrOptions === 'function') {\n program = backendOrProgramOrOptions\n // SAFETY: this branch is selected by the Program overload, so the optional value is its options object.\n options = programOrOptions as MainOptions<A> | undefined\n } else if (isLayerBackend(backendOrProgramOrOptions)) {\n backend = backendOrProgramOrOptions\n // SAFETY: the backend overload requires a Program in the third argument.\n program = programOrOptions as CompleteExecution<ProvidedEnvironment<L>, A>\n options = legacyOptions\n } else {\n options = backendOrProgramOrOptions\n // SAFETY: the options overload requires a Program in the third argument.\n program = programOrOptions as CompleteExecution<ProvidedEnvironment<L>, A>\n }\n\n if (options !== undefined && !isOptionsObject(options)) {\n throw new TypeError('NodeRuntime options must be a non-array object')\n }\n\n // SAFETY: validation above establishes an object; the empty object is the omitted-options case.\n const normalizedOptions = (options ?? {}) as MainOptions<A>\n validateOptions(normalizedOptions)\n\n const shutdownController = new AbortController()\n const configuredSignals = normalizeSignals(normalizedOptions.signals)\n const {\n onSuccess,\n onFailure,\n onDefect,\n signal: callerSignal,\n ...runtimeOptions\n } = normalizedOptions\n const signalLink = linkAbortSignals(callerSignal, shutdownController.signal)\n const listeners: InstalledSignalListener[] = []\n const cleanupFailures: unknown[] = []\n\n let runtime: Runtime<ProvidedEnvironment<L>> | undefined\n let disposalPromise: Promise<void> | undefined\n let disposalObserved = false\n let firstSignal: NodeRuntimeSignal | undefined\n let setupFailed = false\n let setupFailure: unknown\n let programFailed = false\n let programFailure: unknown\n let executionCleanupFailed = false\n let executionOutcome: ScopeOutcome | undefined\n let programSettled = false\n let programValue!: Awaited<A>\n\n const requestDispose = (): Promise<void> => {\n if (disposalPromise) {\n return disposalPromise\n }\n\n try {\n disposalPromise = runtime!.dispose()\n } catch (cause) {\n disposalPromise = Promise.reject(cause)\n }\n\n return disposalPromise\n }\n\n const observeDisposal = async (): Promise<void> => {\n if (!runtime || disposalObserved) {\n return\n }\n\n disposalObserved = true\n\n try {\n await requestDispose()\n } catch (cause) {\n cleanupFailures.push(cause)\n }\n }\n\n const onSignal = (signal: NodeRuntimeSignal): void => {\n if (firstSignal !== undefined) {\n return\n }\n\n firstSignal = signal\n\n try {\n shutdownController.abort(signal)\n } finally {\n void requestDispose().catch(() => {})\n }\n }\n\n try {\n const executionObserver: RuntimeObserver = {\n onExecutionEnd: ({ outcome }: RuntimeExecutionEndEvent): void => {\n executionOutcome = outcome\n }\n }\n const runtimeOptionsWithSignal: RuntimeOptions = {\n ...runtimeOptions,\n observers: [executionObserver, ...(runtimeOptions.observers ?? [])],\n signal: signalLink.signal\n }\n\n runtime = backend\n ? await Runtime.make(layer, backend, runtimeOptionsWithSignal)\n : await Runtime.make(layer, runtimeOptionsWithSignal)\n\n installSignalListeners(configuredSignals, listeners, onSignal)\n\n try {\n programValue = await runtime.run(program)\n programSettled = true\n } catch (cause) {\n if (executionOutcome?.status === 'success') {\n executionCleanupFailed = true\n } else {\n programFailed = true\n }\n programFailure = cause\n }\n\n await observeDisposal()\n } catch (cause) {\n setupFailed = true\n setupFailure = cause\n } finally {\n await observeDisposal()\n cleanupFailures.push(...removeSignalListeners(listeners))\n\n try {\n signalLink.dispose()\n } catch (cause) {\n cleanupFailures.push(cause)\n }\n }\n\n const cleanupFailureValues = combineFailures(cleanupFailures)\n const hasCleanupFailure = cleanupFailureValues.length > 0\n const cleanupFailure = cleanupFailureValues[0]\n\n if (setupFailed) {\n reportDefect(setupFailure, onDefect)\n throw setupFailure\n }\n\n if (programFailed) {\n reportDefect(programFailure, onDefect)\n throw programFailure\n }\n\n if (executionCleanupFailed) {\n setExitCode(1)\n throw programFailure\n }\n\n if (!programSettled) {\n const failure = new Error('NodeRuntime main program did not settle')\n reportDefect(failure, onDefect)\n throw failure\n }\n\n if (programValue instanceof Err) {\n let exitCode = 1\n\n try {\n if (onFailure) {\n // SAFETY: Err carries the failure channel represented by MainFailure<A>.\n exitCode = validateExitCode(onFailure(programValue.error as MainFailure<A>))\n }\n } catch (cause) {\n reportDefect(cause, onDefect)\n throw cause\n }\n\n setExitCode(exitCode)\n return programValue\n }\n\n let exitCode = 0\n\n try {\n if (onSuccess) {\n const successValue = programValue instanceof Ok ? programValue.value : programValue\n // SAFETY: Ok is unwrapped above; plain successful values retain the MainSuccess<A> channel.\n exitCode = validateExitCode(onSuccess(successValue as MainSuccess<A>))\n }\n } catch (cause) {\n reportDefect(cause, onDefect)\n throw cause\n }\n\n if (hasCleanupFailure) {\n exitCode = ensureFailureExitCode(exitCode)\n }\n\n setExitCode(exitCode)\n\n if (hasCleanupFailure) {\n throw cleanupFailure\n }\n\n return programValue\n }\n}\n\n/** Type-level aliases for the Node.js/Bun process boundary. */\nexport declare namespace NodeRuntime {\n /** Options for `NodeRuntime.runMain`. */\n export type Options<Success = unknown, Failure = unknown> = NodeRuntimeOptions<Success, Failure>\n\n /** A process signal accepted by `NodeRuntime.runMain`. */\n export type Signal = NodeRuntimeSignal\n}\n"],"mappings":";;;;;;AAqDA,MAAM,kBAAkB,CAAC,UAAU,SAAS;AAQ5C,MAAM,kBAAkB,UAA0C;CAEhE,IAAI,UAAU,QAAQ,OAAO,UAAU,UACrC,OAAO;CAGT,OACE,cAAc,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IAAI,CAAC,gBAAgB;GACnB,MAAM,0BAAU,IAAI,MAAM,yCAAyC;GACnE,aAAa,SAAS,QAAQ;GAC9B,MAAM;EACR;EAEA,IAAI,wBAAwB,KAAK;GAC/B,IAAI,WAAW;GAEf,IAAI;IACF,IAAI,WAEF,WAAW,iBAAiB,UAAU,aAAa,KAAuB,CAAC;GAE/E,SAAS,OAAO;IACd,aAAa,OAAO,QAAQ;IAC5B,MAAM;GACR;GAEA,YAAY,QAAQ;GACpB,OAAO;EACT;EAEA,IAAI,WAAW;EAEf,IAAI;GACF,IAAI,WAAW;IACb,MAAM,eAAe,wBAAwB,KAAK,aAAa,QAAQ;IAEvE,WAAW,iBAAiB,UAAU,YAA8B,CAAC;GACvE;EACF,SAAS,OAAO;GACd,aAAa,OAAO,QAAQ;GAC5B,MAAM;EACR;EAEA,IAAI,mBACF,WAAW,sBAAsB,QAAQ;EAG3C,YAAY,QAAQ;EAEpB,IAAI,mBACF,MAAM;EAGR,OAAO;CACT;AACF"}
|
|
@@ -187,6 +187,14 @@ type CompleteExecution<Provided extends AnyService, A> = CompleteExecutionWithRe
|
|
|
187
187
|
interface LayerRegistration {
|
|
188
188
|
/** The class-backed Service token provided by this registration. */
|
|
189
189
|
readonly service: ServiceClass<any, any>;
|
|
190
|
+
/**
|
|
191
|
+
* The canonical tag captured when the provider was created.
|
|
192
|
+
*
|
|
193
|
+
* This remains optional for direct backend registrations created against the
|
|
194
|
+
* pre-inspection API; backends capture the token tag synchronously when it is
|
|
195
|
+
* omitted.
|
|
196
|
+
*/
|
|
197
|
+
readonly serviceTag?: string;
|
|
190
198
|
/** Lazily acquire the Service instance; concrete types are erased at this backend boundary. */
|
|
191
199
|
readonly acquire: () => MaybePromise<unknown>;
|
|
192
200
|
}
|
|
@@ -206,6 +214,8 @@ type CapturedLayerAcquisition = {
|
|
|
206
214
|
readonly release: ScopeFinalizer;
|
|
207
215
|
};
|
|
208
216
|
interface LayerProvider extends LayerRegistration {
|
|
217
|
+
/** The tag captured before this provider can cross an asynchronous boundary. */
|
|
218
|
+
readonly serviceTag: string;
|
|
209
219
|
/** Provider storage deliberately erases the concrete instance type. */
|
|
210
220
|
readonly release?: (instance: unknown, outcome: ScopeOutcome) => MaybePromise<void>;
|
|
211
221
|
/** Capture acquisition-local cleanup without retaining the acquired instance. */
|
|
@@ -303,20 +313,6 @@ interface LayerBackend extends ServiceResolver {
|
|
|
303
313
|
disposeAll(options?: LayerBackendDisposeOptions): MaybePromise<void>;
|
|
304
314
|
}
|
|
305
315
|
//#endregion
|
|
306
|
-
//#region src/layer/map-layer-backend.d.ts
|
|
307
|
-
/** Native map-backed Layer backend used by Runtime when no adapter is supplied. */
|
|
308
|
-
declare class MapLayerBackend implements LayerBackend {
|
|
309
|
-
private readonly providers;
|
|
310
|
-
private readonly instances;
|
|
311
|
-
private readonly pending;
|
|
312
|
-
/** Register a provider, rejecting duplicate or colliding Service tags. */
|
|
313
|
-
register(registration: LayerRegistration): void;
|
|
314
|
-
/** Resolve and cache a provider instance by Service tag. */
|
|
315
|
-
resolve<T extends AnyServiceToken>(token: T): Promise<InstanceType<T>>;
|
|
316
|
-
/** Clear pending acquisitions, cached instances, and provider registrations. */
|
|
317
|
-
disposeAll(options?: LayerBackendDisposeOptions): Promise<void>;
|
|
318
|
-
}
|
|
319
|
-
//#endregion
|
|
320
316
|
//#region src/layer/errors.d.ts
|
|
321
317
|
type LayerCause = Extract<ScopeOutcome, {
|
|
322
318
|
readonly status: 'failure';
|
|
@@ -363,14 +359,26 @@ type RuntimeServiceAcquireEvent = {
|
|
|
363
359
|
readonly resolutionPath: readonly AnyServiceToken[];
|
|
364
360
|
readonly outcome: ScopeOutcome;
|
|
365
361
|
};
|
|
362
|
+
/** Values supplied to one Runtime execution for diagnostic correlation. */
|
|
363
|
+
type RuntimeExecutionAttributes = Readonly<Record<string, unknown>>;
|
|
364
|
+
/** Metadata shared by the start and end events for one execution. */
|
|
365
|
+
type RuntimeExecutionMetadata = {
|
|
366
|
+
readonly executionId: string;
|
|
367
|
+
readonly name?: string;
|
|
368
|
+
readonly attributes?: RuntimeExecutionAttributes;
|
|
369
|
+
/** Monotonic host timestamp captured immediately before the Program starts. */
|
|
370
|
+
readonly startedAt: number;
|
|
371
|
+
};
|
|
366
372
|
/** Event emitted immediately before a program starts in an execution Scope. */
|
|
367
|
-
type RuntimeExecutionStartEvent = {
|
|
373
|
+
type RuntimeExecutionStartEvent = RuntimeExecutionMetadata & {
|
|
368
374
|
readonly scope: Scope;
|
|
369
375
|
};
|
|
370
376
|
/** Event emitted after a program and its execution Scope settle. */
|
|
371
|
-
type RuntimeExecutionEndEvent = {
|
|
377
|
+
type RuntimeExecutionEndEvent = RuntimeExecutionMetadata & {
|
|
372
378
|
readonly scope: Scope;
|
|
373
379
|
readonly outcome: ScopeOutcome;
|
|
380
|
+
/** Monotonic elapsed time for the Program and its execution cleanup. */
|
|
381
|
+
readonly durationMs: number;
|
|
374
382
|
};
|
|
375
383
|
/** Event emitted after a Layer provider release callback settles. */
|
|
376
384
|
type RuntimeResourceReleaseEvent = {
|
|
@@ -416,9 +424,11 @@ type RuntimeOptions = {
|
|
|
416
424
|
/** Optional signal exposed through the RuntimeContext. */
|
|
417
425
|
readonly signal?: AbortSignal;
|
|
418
426
|
};
|
|
419
|
-
/** Optional signal supplied to one
|
|
427
|
+
/** Optional signal and diagnostic attributes supplied to one Runtime execution. */
|
|
420
428
|
type RuntimeRunOptions = {
|
|
421
429
|
readonly signal?: AbortSignal;
|
|
430
|
+
/** Copied once and exposed as a readonly event view. */
|
|
431
|
+
readonly attributes?: RuntimeExecutionAttributes;
|
|
422
432
|
};
|
|
423
433
|
/** Cooperative shutdown policy for a managed Runtime. */
|
|
424
434
|
type RuntimeDisposeOptions = {
|
|
@@ -428,5 +438,5 @@ type RuntimeDisposeOptions = {
|
|
|
428
438
|
readonly abortAfterGracePeriod?: boolean;
|
|
429
439
|
};
|
|
430
440
|
//#endregion
|
|
431
|
-
export {
|
|
432
|
-
//# sourceMappingURL=
|
|
441
|
+
export { MissingServices as A, CompleteExecution as C, LayerInput as D, ExecutionMissing as E, ValidateOneOverride as F, ValidateOverrides as I, ValidateOverridesWitness as L, ProvidedEnvironment as M, RequiredEnvironment as N, LayerInputState as O, ValidateLayerInput as P, ProviderEntry as R, LayerRegistration as S, CompleteInput as T, LayerRegistrationError as _, RuntimeShutdownDiagnostic as a, LayerBackendDisposeOptions as b, RuntimeExecutionMetadata as c, RuntimeResourceReleaseEvent as d, RuntimeServiceAcquireEvent as f, LayerGeneratorYieldError as g, LayerDisposeError as h, RuntimeRunOptions as i, OverrideLayerResult as j, LayerResult as k, RuntimeExecutionStartEvent as l, DuplicateServiceError as m, RuntimeDisposeOptions as n, RuntimeExecutionAttributes as o, RuntimeServiceResolveEvent as p, RuntimeOptions as r, RuntimeExecutionEndEvent as s, CleanupFailureObserver as t, RuntimeObserver as u, ServiceTagCollisionError as v, CompleteExecutionLayer as w, Layer as x, LayerBackend as y, MissingDependencies as z };
|
|
442
|
+
//# sourceMappingURL=outcome-CB43bnFW.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outcome-CB43bnFW.d.mts","names":[],"sources":["../src/internal/variance.ts","../src/utils/types.ts","../src/internal/missing-dependencies.ts","../src/layer/metadata.ts","../src/layer/inference.ts","../src/layer/types.ts","../src/layer/layer.ts","../src/layer/backend.ts","../src/layer/errors.ts","../src/runtime/observer.ts","../src/runtime/outcome.ts"],"mappings":";;;KACY,UAAU,WAAW;;KAGrB,UAAU,MAAM,OAAO,MAAM;;;KCJ7B,aAAa,KAAK,IAAI,YAAY;;;KCElC,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,Y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ext, l as makeRuntimeContext, n as currentRuntimeContext, t as activeRuntimeContextStorage, u as runRuntimeContext } from "./context-BUEf1qjL.mjs";
|
|
2
|
-
import { a as
|
|
2
|
+
import { a as ResourceNotDisposableError, c as ScopeRuntimeNotConfiguredError, i as getDisposeFinalizer, o as ScopeCloseError, s as ScopeClosedError } from "./signal-D2UTcaaG.mjs";
|
|
3
3
|
//#region src/scope/runtime.ts
|
|
4
4
|
const scopeStorages = /* @__PURE__ */ new WeakMap();
|
|
5
5
|
/** Bridges the current Scope through async execution context. */
|
|
@@ -240,6 +240,21 @@ const Scope = {
|
|
|
240
240
|
}
|
|
241
241
|
};
|
|
242
242
|
//#endregion
|
|
243
|
-
|
|
243
|
+
//#region src/effect/program-metadata.ts
|
|
244
|
+
const programNames = /* @__PURE__ */ new WeakMap();
|
|
245
|
+
/** Return the private diagnostic name attached to a callable Program. */
|
|
246
|
+
const getProgramName = (program) => programNames.get(program);
|
|
247
|
+
/** Attach a name without changing the callable Program facade. */
|
|
248
|
+
const setProgramName = (program, name) => {
|
|
249
|
+
programNames.set(program, name);
|
|
250
|
+
return program;
|
|
251
|
+
};
|
|
252
|
+
/** Copy a source Program's name to a lazily-created derived Program. */
|
|
253
|
+
const inheritProgramName = (source, derived) => {
|
|
254
|
+
const name = getProgramName(source);
|
|
255
|
+
return name === void 0 ? derived : setProgramName(derived, name);
|
|
256
|
+
};
|
|
257
|
+
//#endregion
|
|
258
|
+
export { runScoped as a, Scope as i, inheritProgramName as n, ScopeRuntime as o, setProgramName as r, getProgramName as t };
|
|
244
259
|
|
|
245
|
-
//# sourceMappingURL=
|
|
260
|
+
//# sourceMappingURL=program-metadata-DhQCCirO.mjs.map
|