better-effect 0.12.0 → 0.13.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 +327 -7
- package/dist/adapters/iti.d.mts +3 -3
- package/dist/bun.d.mts +43 -0
- package/dist/bun.d.mts.map +1 -0
- package/dist/bun.mjs +40 -0
- package/dist/bun.mjs.map +1 -0
- package/dist/{context-BUEf1qjL.mjs → context-BphfFUMO.mjs} +4 -2
- package/dist/context-BphfFUMO.mjs.map +1 -0
- package/dist/current-request-CIU7AHhF.d.mts +22 -0
- package/dist/current-request-CIU7AHhF.d.mts.map +1 -0
- package/dist/current-request-DDKNyymv.mjs +20 -0
- package/dist/current-request-DDKNyymv.mjs.map +1 -0
- package/dist/{signal-D2UTcaaG.mjs → disposable-CP-Q2H3l.mjs} +4 -52
- package/dist/disposable-CP-Q2H3l.mjs.map +1 -0
- package/dist/{effect-CK4YZaX0.mjs → effect-CPdV7Yv8.mjs} +2 -2
- package/dist/{effect-CK4YZaX0.mjs.map → effect-CPdV7Yv8.mjs.map} +1 -1
- package/dist/hono.d.mts +7 -5
- package/dist/hono.d.mts.map +1 -1
- package/dist/hono.mjs +88 -30
- package/dist/hono.mjs.map +1 -1
- package/dist/{index-heuaRmXR.d.mts → index-AiKM71-u.d.mts} +3 -1
- package/dist/{index-heuaRmXR.d.mts.map → index-AiKM71-u.d.mts.map} +1 -1
- package/dist/{index-GYJ4qm9K.d.mts → index-BodMy6rO.d.mts} +6 -5
- package/dist/index-BodMy6rO.d.mts.map +1 -0
- package/dist/{index-CX6iAoCB.d.mts → index-CCi07kUw.d.mts} +2 -2
- package/dist/{index-CX6iAoCB.d.mts.map → index-CCi07kUw.d.mts.map} +1 -1
- package/dist/{index-BMdU_Z72.d.mts → index-DAKn0qHk.d.mts} +4 -3
- package/dist/index-DAKn0qHk.d.mts.map +1 -0
- package/dist/{index-B1nH4luq.d.mts → index-cXgyMa0v.d.mts} +6 -20
- package/dist/index-cXgyMa0v.d.mts.map +1 -0
- package/dist/index.d.mts +6 -5
- package/dist/index.mjs +7 -6
- package/dist/index.mjs.map +1 -1
- package/dist/{layer-D56fRdLt.mjs → layer-D16GKxuX.mjs} +4 -4
- package/dist/layer-D16GKxuX.mjs.map +1 -0
- package/dist/next.d.mts +116 -0
- package/dist/next.d.mts.map +1 -0
- package/dist/next.mjs +68 -0
- package/dist/next.mjs.map +1 -0
- package/dist/{node-context-lggRF4bR.mjs → node-context-Ca18oNSg.mjs} +2 -2
- package/dist/{node-context-lggRF4bR.mjs.map → node-context-Ca18oNSg.mjs.map} +1 -1
- package/dist/{node-context-DWsCUBRa.d.mts → node-context-DczjAcrX.d.mts} +2 -2
- package/dist/{node-context-DWsCUBRa.d.mts.map → node-context-DczjAcrX.d.mts.map} +1 -1
- package/dist/node.d.mts +4 -4
- package/dist/node.mjs +4 -4
- package/dist/observer-9nhbL7Pr.d.mts +68 -0
- package/dist/observer-9nhbL7Pr.d.mts.map +1 -0
- package/dist/opentelemetry.d.mts +94 -0
- package/dist/opentelemetry.d.mts.map +1 -0
- package/dist/opentelemetry.mjs +453 -0
- package/dist/opentelemetry.mjs.map +1 -0
- package/dist/{outcome-CB43bnFW.d.mts → outcome-DI8LPIQ4.d.mts} +14 -69
- package/dist/outcome-DI8LPIQ4.d.mts.map +1 -0
- package/dist/{program-metadata-DhQCCirO.mjs → program-metadata-BxjGkT17.mjs} +3 -3
- package/dist/{program-metadata-DhQCCirO.mjs.map → program-metadata-BxjGkT17.mjs.map} +1 -1
- package/dist/runtime/explicit.d.mts +1 -1
- package/dist/runtime/explicit.mjs +1 -1
- package/dist/runtime/node.d.mts +2 -2
- package/dist/runtime/node.mjs +2 -2
- package/dist/{runtime-CBMrX8Wl.mjs → runtime-C_55ofnL.mjs} +42 -27
- package/dist/runtime-C_55ofnL.mjs.map +1 -0
- package/dist/signal-nfgFyNCk.mjs +52 -0
- package/dist/signal-nfgFyNCk.mjs.map +1 -0
- package/dist/{standard-services-GBZ32tll.mjs → standard-services-vnGIafkS.mjs} +3 -17
- package/dist/standard-services-vnGIafkS.mjs.map +1 -0
- package/dist/standard-services.d.mts +3 -2
- package/dist/standard-services.mjs +3 -2
- package/dist/testing.d.mts +6 -5
- package/dist/testing.d.mts.map +1 -1
- package/dist/testing.mjs +6 -6
- package/dist/types-oihI-ESv.d.mts +54 -0
- package/dist/types-oihI-ESv.d.mts.map +1 -0
- package/dist/web-Bq3MfMrj.mjs +147 -0
- package/dist/web-Bq3MfMrj.mjs.map +1 -0
- package/dist/web.d.mts +47 -0
- package/dist/web.d.mts.map +1 -0
- package/dist/web.mjs +2 -0
- package/package.json +33 -2
- package/dist/context-BUEf1qjL.mjs.map +0 -1
- package/dist/index-B1nH4luq.d.mts.map +0 -1
- package/dist/index-BMdU_Z72.d.mts.map +0 -1
- package/dist/index-GYJ4qm9K.d.mts.map +0 -1
- package/dist/layer-D56fRdLt.mjs.map +0 -1
- package/dist/outcome-CB43bnFW.d.mts.map +0 -1
- package/dist/runtime-CBMrX8Wl.mjs.map +0 -1
- package/dist/signal-D2UTcaaG.mjs.map +0 -1
- package/dist/standard-services-GBZ32tll.mjs.map +0 -1
package/dist/hono.mjs
CHANGED
|
@@ -1,11 +1,54 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import { t as
|
|
3
|
-
import { a as CurrentRequest } from "./standard-services-GBZ32tll.mjs";
|
|
1
|
+
import { t as Effect } from "./effect-CPdV7Yv8.mjs";
|
|
2
|
+
import { r as assertResponse, t as WebEffect } from "./web-Bq3MfMrj.mjs";
|
|
4
3
|
import { Result } from "better-result";
|
|
5
4
|
import { createMiddleware } from "hono/factory";
|
|
6
5
|
//#region src/hono/request-boundary.ts
|
|
7
|
-
const
|
|
8
|
-
|
|
6
|
+
const recordRequestFailure = (state, cause) => {
|
|
7
|
+
state.outcome ??= {
|
|
8
|
+
kind: "failure",
|
|
9
|
+
cause
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
const recordRequestSuccess = (state, value, options) => {
|
|
13
|
+
state.outcome ??= {
|
|
14
|
+
kind: "success",
|
|
15
|
+
value,
|
|
16
|
+
options
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
const makeBoundaryOptions = (options, state, context) => {
|
|
20
|
+
const boundaryOptions = {
|
|
21
|
+
onSuccess: ({ value }) => {
|
|
22
|
+
if (context.finalized) return context.res;
|
|
23
|
+
const outcome = state.outcome;
|
|
24
|
+
if (outcome?.kind !== "success") return value;
|
|
25
|
+
if (outcome.options.respond !== void 0) return outcome.options.respond(value, context);
|
|
26
|
+
const success = { value };
|
|
27
|
+
if (outcome.options.status !== void 0) Object.assign(success, { status: outcome.options.status });
|
|
28
|
+
if (outcome.options.serialize !== void 0) Object.assign(success, { serialize: outcome.options.serialize });
|
|
29
|
+
return options.onSuccess(success, context);
|
|
30
|
+
},
|
|
31
|
+
onFailure: (error) => {
|
|
32
|
+
if (context.error !== void 0 || context.finalized) return context.res;
|
|
33
|
+
if (state.outcome?.kind === "defect") return context.res;
|
|
34
|
+
return options.onFailure(error, context);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
if (options.requestLayer !== void 0) Object.assign(boundaryOptions, { requestLayer: (_request) => options.requestLayer(context) });
|
|
38
|
+
return boundaryOptions;
|
|
39
|
+
};
|
|
40
|
+
const selectBoundaryResult = (state, context) => {
|
|
41
|
+
const outcome = state.outcome;
|
|
42
|
+
if (outcome?.kind === "failure") return Result.err(outcome.cause);
|
|
43
|
+
if (context.error !== void 0) {
|
|
44
|
+
state.outcome = {
|
|
45
|
+
kind: "defect",
|
|
46
|
+
cause: context.error
|
|
47
|
+
};
|
|
48
|
+
return Result.err(context.error);
|
|
49
|
+
}
|
|
50
|
+
if (outcome?.kind === "success") return Result.ok(outcome.value);
|
|
51
|
+
return Result.ok(context.res);
|
|
9
52
|
};
|
|
10
53
|
const makeRequestBoundary = (options) => {
|
|
11
54
|
return createMiddleware(async (context, next) => {
|
|
@@ -17,19 +60,25 @@ const makeRequestBoundary = (options) => {
|
|
|
17
60
|
const state = {};
|
|
18
61
|
options.states.set(key, state);
|
|
19
62
|
try {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
63
|
+
const program = Effect.fn(async function* () {
|
|
64
|
+
await next();
|
|
65
|
+
return selectBoundaryResult(state, context);
|
|
66
|
+
});
|
|
67
|
+
const boundaryOptions = makeBoundaryOptions(options, state, context);
|
|
68
|
+
let response;
|
|
69
|
+
if (options.requestLayer === void 0) response = await WebEffect.handle(options.runtime, context.req.raw, program, {
|
|
70
|
+
onSuccess: boundaryOptions.onSuccess,
|
|
71
|
+
onFailure: boundaryOptions.onFailure
|
|
72
|
+
});
|
|
73
|
+
else {
|
|
74
|
+
const requestBoundaryOptions = {
|
|
75
|
+
onSuccess: boundaryOptions.onSuccess,
|
|
76
|
+
onFailure: boundaryOptions.onFailure,
|
|
77
|
+
requestLayer: (_request) => options.requestLayer(context)
|
|
78
|
+
};
|
|
79
|
+
response = await WebEffect.handle(options.runtime, context.req.raw, program, requestBoundaryOptions);
|
|
80
|
+
}
|
|
81
|
+
if (!context.finalized || context.res !== response) context.res = response;
|
|
33
82
|
} finally {
|
|
34
83
|
options.states.delete(key);
|
|
35
84
|
}
|
|
@@ -71,7 +120,9 @@ var HonoEffect = class HonoEffect {
|
|
|
71
120
|
return makeRequestBoundary({
|
|
72
121
|
runtime: this.runtime,
|
|
73
122
|
states: this.states,
|
|
74
|
-
requestLayer: this.requestLayer
|
|
123
|
+
requestLayer: this.requestLayer,
|
|
124
|
+
onSuccess: this.onSuccess,
|
|
125
|
+
onFailure: this.onFailure
|
|
75
126
|
});
|
|
76
127
|
}
|
|
77
128
|
handler(...args) {
|
|
@@ -104,23 +155,29 @@ var HonoEffect = class HonoEffect {
|
|
|
104
155
|
await next();
|
|
105
156
|
};
|
|
106
157
|
}
|
|
107
|
-
|
|
108
|
-
state
|
|
109
|
-
return this.onFailure(error, context);
|
|
158
|
+
recordFailure(state, error) {
|
|
159
|
+
recordRequestFailure(state, error);
|
|
110
160
|
}
|
|
111
161
|
makeHandler(makeProgram, options) {
|
|
112
162
|
return async (context) => {
|
|
113
163
|
const state = this.getState(context);
|
|
114
164
|
const result = await makeProgram(context)();
|
|
115
165
|
if (Result.isError(result)) return await this.handleFailure(state, result.error, context);
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
const success = { value };
|
|
119
|
-
if (options.status !== void 0) Object.assign(success, { status: options.status });
|
|
120
|
-
if (options.serialize !== void 0) Object.assign(success, { serialize: options.serialize });
|
|
121
|
-
return await this.onSuccess(success, context);
|
|
166
|
+
recordRequestSuccess(state, result.value, options);
|
|
167
|
+
return await this.handleSuccess(result.value, options, context);
|
|
122
168
|
};
|
|
123
169
|
}
|
|
170
|
+
async handleSuccess(value, options, context) {
|
|
171
|
+
if (options.respond !== void 0) return assertResponse(await options.respond(value, context));
|
|
172
|
+
const success = { value };
|
|
173
|
+
if (options.status !== void 0) Object.assign(success, { status: options.status });
|
|
174
|
+
if (options.serialize !== void 0) Object.assign(success, { serialize: options.serialize });
|
|
175
|
+
return assertResponse(await this.onSuccess(success, context));
|
|
176
|
+
}
|
|
177
|
+
async handleFailure(state, error, context) {
|
|
178
|
+
this.recordFailure(state, error);
|
|
179
|
+
return assertResponse(await this.onFailure(error, context));
|
|
180
|
+
}
|
|
124
181
|
composeInputMiddleware(inputMiddleware, handler) {
|
|
125
182
|
return async (context, next) => {
|
|
126
183
|
let downstreamResponse;
|
|
@@ -128,12 +185,13 @@ var HonoEffect = class HonoEffect {
|
|
|
128
185
|
const nextOnce = async () => {
|
|
129
186
|
if (nextCalled) throw new Error("next() called multiple times");
|
|
130
187
|
nextCalled = true;
|
|
131
|
-
|
|
188
|
+
const response = await handler(context, next);
|
|
189
|
+
if (response !== void 0) downstreamResponse = response;
|
|
132
190
|
};
|
|
133
191
|
const middlewareResponse = await inputMiddleware(context, nextOnce);
|
|
134
192
|
if (middlewareResponse instanceof Response) return middlewareResponse;
|
|
135
193
|
if (downstreamResponse !== void 0) return downstreamResponse;
|
|
136
|
-
return context.res;
|
|
194
|
+
if (context.finalized) return context.res;
|
|
137
195
|
};
|
|
138
196
|
}
|
|
139
197
|
getState(context) {
|
package/dist/hono.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hono.mjs","names":[],"sources":["../src/hono/request-boundary.ts","../src/hono/responses.ts","../src/hono/hono-effect.ts"],"sourcesContent":["import { Result } from 'better-result'\nimport { createMiddleware } from 'hono/factory'\nimport type { Env, MiddlewareHandler } from 'hono'\n\nimport { CurrentRequest } from '../standard-services'\nimport { Layer } from '../layer'\nimport type { LayerInput } from '../layer/inference'\nimport { Runtime } from '../runtime'\nimport type { AnyService } from '../service'\nimport type { HonoContext } from './types'\n\nexport type RequestState = {\n failure?: {\n readonly cause: unknown\n }\n}\n\nexport type RequestBoundaryOptions<Provided extends AnyService, RequestLayer extends LayerInput> = {\n readonly runtime: Runtime<Provided>\n readonly states: WeakMap<object, RequestState>\n readonly requestLayer?: ((context: HonoContext) => RequestLayer) | undefined\n}\n\nconst overrideRequestLayer = (base: LayerInput, replacement: LayerInput): Layer<any, any> => {\n // SAFETY: HonoEffect.make validates the concrete replacement before this erased dispatch boundary.\n return Layer.override(base, replacement as never)\n}\n\nexport const makeRequestBoundary = <\n Provided extends AnyService,\n RequestLayer extends LayerInput,\n E extends Env = Env,\n Path extends string = string\n>(\n options: RequestBoundaryOptions<Provided, RequestLayer>\n): MiddlewareHandler<E, Path> => {\n // SAFETY: createMiddleware preserves the Hono handler contract; only the generic Context is restored here.\n return createMiddleware(async (context, next) => {\n const key = context\n const existing = options.states.get(key)\n\n if (existing !== undefined) {\n await next()\n return\n }\n\n const state: RequestState = {}\n options.states.set(key, state)\n\n try {\n const requestLayer = CurrentRequest.layer(context.req.raw)\n const customLayer = options.requestLayer?.(context)\n const layer: Layer<any, any> =\n customLayer === undefined ? requestLayer : overrideRequestLayer(requestLayer, customLayer)\n\n await options.runtime.runWith(\n layer,\n async () => {\n try {\n await next()\n } catch (cause) {\n state.failure ??= { cause }\n }\n\n if (state.failure !== undefined) {\n return Result.err(state.failure.cause)\n }\n\n if (context.error !== undefined) {\n return Result.err(context.error)\n }\n\n return Result.ok(context.res)\n },\n { signal: context.req.raw.signal }\n )\n } finally {\n options.states.delete(key)\n }\n }) as MiddlewareHandler<E, Path>\n}\n","import type { HonoContext, HonoEffectSuccess } from './types'\n\nconst DEFAULT_FAILURE_MESSAGE = 'Internal Server Error'\n\nexport const defaultSuccess = (\n { value, status, serialize }: HonoEffectSuccess,\n context: HonoContext\n): Response => {\n if (value instanceof Response) {\n return value\n }\n\n const body = serialize === undefined ? value : serialize(value)\n\n if (body === undefined) {\n // SAFETY: route status is intentionally configurable and Hono validates it at response construction.\n return context.body(null, (status ?? 204) as never)\n }\n\n if (status === undefined) {\n return context.json({ data: body })\n }\n\n // SAFETY: route status is intentionally configurable and Hono validates it at response construction.\n return context.json({ data: body }, status as never)\n}\n\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- Result errors are intentionally opaque at this HTTP boundary.\nexport const defaultFailure = (error: unknown, context: HonoContext): Response => {\n if (error instanceof Response) {\n return error\n }\n\n return context.json({ error: DEFAULT_FAILURE_MESSAGE }, 500)\n}\n","import { Result } from 'better-result'\nimport type { Context, Env, Handler, Input, MiddlewareHandler } from 'hono'\n\nimport { Effect } from '../effect'\nimport type { EffectSuccess, EffectYield, ProgramFromGenerator } from '../effect/types'\nimport { Runtime } from '../runtime'\nimport type { LayerInput } from '../layer/inference'\nimport type { AnyService } from '../service'\nimport { makeRequestBoundary, type RequestState } from './request-boundary'\nimport { defaultFailure, defaultSuccess } from './responses'\nimport type {\n AnyGeneratorBody,\n AnyHonoMiddleware,\n AnyProgram,\n AnyProgramFactory,\n AnyResult,\n AnyRouteOptions,\n AvailableServices,\n CompleteProgram,\n DefaultRequestLayer,\n GeneratorBody,\n GeneratorChecks,\n HonoContext,\n HonoEffectContext,\n HonoEffectOptions,\n HonoEffectRouteOptions,\n HonoRequestLayerChecks,\n HonoEffectSuccess,\n MiddlewareEnvironment,\n ResponseLike,\n MiddlewareInputs,\n MiddlewarePath\n} from './types'\n\ntype HonoRouteArguments<Middlewares extends readonly AnyHonoMiddleware[], Body, Options> =\n | [...middlewares: Middlewares, body: Body]\n | [...middlewares: Middlewares, body: Body, options: Options | undefined]\n\ntype HonoHandlerFactory<\n ContextType extends object,\n Provided extends AnyService,\n Failure,\n ProgramFactory extends (context: ContextType) => AnyProgram\n> = ProgramFactory &\n ([ReturnType<ProgramFactory>] extends [\n CompleteProgram<Provided, ReturnType<ProgramFactory>, Failure>\n ]\n ? unknown\n : (context: ContextType) => CompleteProgram<Provided, ReturnType<ProgramFactory>, Failure>)\n\n/** Run Effect Programs inside one Runtime execution per Hono request. */\nexport class HonoEffect<\n Provided extends AnyService = any,\n Failure = unknown,\n RequestLayer extends LayerInput = DefaultRequestLayer\n> {\n readonly runtime: Runtime<Provided>\n\n private readonly states = new WeakMap<object, RequestState>()\n\n private readonly onSuccess: NonNullable<HonoEffectOptions<Failure, RequestLayer>['onSuccess']>\n\n private readonly onFailure: NonNullable<HonoEffectOptions<Failure, RequestLayer>['onFailure']>\n\n private readonly requestLayer: HonoEffectOptions<Failure, RequestLayer>['requestLayer']\n\n private constructor(\n runtime: Runtime<Provided>,\n options: HonoEffectOptions<Failure, RequestLayer>\n ) {\n this.runtime = runtime\n this.onSuccess = options.onSuccess ?? defaultSuccess\n this.onFailure = options.onFailure ?? defaultFailure\n this.requestLayer = options.requestLayer\n }\n\n static make<\n Provided extends AnyService,\n Failure = unknown,\n RequestLayer extends LayerInput = DefaultRequestLayer\n >(\n runtime: Runtime<Provided>,\n options?: HonoEffectOptions<Failure, RequestLayer> &\n HonoRequestLayerChecks<Provided, RequestLayer>\n ): HonoEffect<Provided, Failure, RequestLayer> {\n return new HonoEffect(runtime, options ?? {})\n }\n\n middleware<E extends Env = Env, Path extends string = string>(): MiddlewareHandler<E, Path> {\n return makeRequestBoundary<Provided, RequestLayer, E, Path>({\n runtime: this.runtime,\n states: this.states,\n requestLayer: this.requestLayer\n })\n }\n\n handler<\n E extends Env = Env,\n Path extends string = string,\n InputType extends Input = Input,\n Program extends AnyProgram = AnyProgram\n >(\n makeProgram: (\n context: Context<E, Path, InputType>\n ) => CompleteProgram<AvailableServices<Provided, RequestLayer>, Program, Failure>,\n options?: HonoEffectRouteOptions<EffectSuccess<Program>, Context<E, Path, InputType>>\n ): Handler<E, Path, InputType, Promise<Response>>\n handler<\n const Middlewares extends readonly AnyHonoMiddleware[],\n E extends Env = MiddlewareEnvironment<Middlewares>,\n Path extends string = MiddlewarePath<Middlewares>,\n const ProgramFactory extends (\n context: HonoEffectContext<E, Path, MiddlewareInputs<Middlewares>>\n ) => AnyProgram = (\n context: HonoEffectContext<E, Path, MiddlewareInputs<Middlewares>>\n ) => AnyProgram\n >(\n ...args: HonoRouteArguments<\n Middlewares,\n HonoHandlerFactory<\n HonoEffectContext<E, Path, MiddlewareInputs<Middlewares>>,\n AvailableServices<Provided, RequestLayer>,\n Failure,\n ProgramFactory\n >,\n HonoEffectRouteOptions<\n EffectSuccess<ReturnType<ProgramFactory>>,\n Context<E, Path, MiddlewareInputs<Middlewares>>\n >\n >\n ): Handler<E, Path, MiddlewareInputs<Middlewares>, Promise<Response>>\n handler(...args: unknown[]): Handler<any, any, any, Promise<Response>> {\n const last = args.at(-1)\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- overload dispatch separates route options from function callbacks.\n const hasOptions = args.length > 1 && (last === undefined || typeof last !== 'function')\n // SAFETY: the overloads restrict the optional trailing argument to route options.\n const options = ((hasOptions ? last : {}) ?? {}) as AnyRouteOptions\n const bodyIndex = hasOptions ? args.length - 2 : args.length - 1\n // SAFETY: the overloads place the program factory immediately before route options.\n const makeProgram = args[bodyIndex] as AnyProgramFactory\n let handler = this.makeHandler(makeProgram, options)\n\n for (let index = bodyIndex - 1; index >= 0; index -= 1) {\n // SAFETY: every argument before the program factory is an input middleware by the overloads.\n handler = this.composeInputMiddleware(args[index] as AnyHonoMiddleware, handler)\n }\n\n return handler\n }\n\n gen<\n E extends Env = Env,\n Path extends string = string,\n InputType extends Input = Input,\n const Yield extends EffectYield = EffectYield,\n const Returned extends AnyResult = AnyResult\n >(\n body: GeneratorBody<Context<E, Path, InputType>, Yield, Returned> &\n GeneratorChecks<AvailableServices<Provided, RequestLayer>, Yield, Returned, Failure>,\n options?: HonoEffectRouteOptions<\n EffectSuccess<ProgramFromGenerator<Yield, Returned>>,\n Context<E, Path, InputType>\n >\n ): Handler<E, Path, InputType, Promise<Response>>\n gen<\n const Middlewares extends readonly AnyHonoMiddleware[],\n E extends Env = MiddlewareEnvironment<Middlewares>,\n Path extends string = MiddlewarePath<Middlewares>,\n const Yield extends EffectYield = EffectYield,\n const Returned extends AnyResult = AnyResult\n >(\n ...args: HonoRouteArguments<\n Middlewares,\n GeneratorBody<HonoEffectContext<E, Path, MiddlewareInputs<Middlewares>>, Yield, Returned> &\n GeneratorChecks<AvailableServices<Provided, RequestLayer>, Yield, Returned, Failure>,\n HonoEffectRouteOptions<\n EffectSuccess<ProgramFromGenerator<Yield, Returned>>,\n Context<E, Path, MiddlewareInputs<Middlewares>>\n >\n >\n ): Handler<E, Path, MiddlewareInputs<Middlewares>, Promise<Response>>\n gen(...args: unknown[]): Handler<any, any, any, Promise<Response>> {\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- overload dispatch distinguishes middleware from the generator body.\n const last = args.at(-1)\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- overload dispatch separates route options from function callbacks.\n const hasOptions = args.length > 1 && (last === undefined || typeof last !== 'function')\n // SAFETY: the overloads restrict the optional trailing argument to route options.\n const options = ((hasOptions ? last : {}) ?? {}) as AnyRouteOptions\n const bodyIndex = hasOptions ? args.length - 2 : args.length - 1\n // SAFETY: the overloads place the generator body immediately before route options.\n const body = args[bodyIndex] as AnyGeneratorBody\n\n let handler = this.makeHandler((context) => {\n // SAFETY: Effect.fn's runtime generator accepts both sync and async generators; the cast only joins its overloads.\n const program = Effect.fn(\n () => body(context) as AsyncGenerator<EffectYield, AnyResult, unknown>\n )\n\n // SAFETY: the public GeneratorChecks overload validates requirements before this erased boundary.\n return program as AnyProgram\n }, options)\n\n for (let index = bodyIndex - 1; index >= 0; index -= 1) {\n // SAFETY: every argument before the generator body is an input middleware by the overloads.\n handler = this.composeInputMiddleware(args[index] as AnyHonoMiddleware, handler)\n }\n\n return handler\n }\n\n guard<\n E extends Env = Env,\n Path extends string = string,\n InputType extends Input = Input,\n const Yield extends EffectYield = EffectYield,\n const Returned extends AnyResult = AnyResult\n >(\n body: GeneratorBody<Context<E, Path, InputType>, Yield, Returned> &\n GeneratorChecks<AvailableServices<Provided, RequestLayer>, Yield, Returned, Failure>\n ): MiddlewareHandler<E, Path> {\n return async (context, next) => {\n const state = this.getState(context)\n // SAFETY: Effect.fn accepts the sync or async generator supplied by the caller; this joins its overloads.\n const program = Effect.fn(() => body(context) as AsyncGenerator<Yield, Returned, unknown>)\n const result = await program()\n\n if (Result.isError(result)) {\n return await this.handleFailure(state, result.error, context)\n }\n\n await next()\n }\n }\n\n private handleFailure(\n state: RequestState,\n // oxlint-disable-next-line anti-slop/no-unknown-parameters -- Result errors are intentionally opaque at this HTTP boundary.\n error: unknown,\n context: HonoContext\n ): ResponseLike {\n state.failure ??= { cause: error }\n // SAFETY: the public handler, gen, and guard constraints validate this error against Failure.\n return this.onFailure(error as Failure, context)\n }\n\n private makeHandler(\n makeProgram: (context: HonoContext) => AnyProgram,\n options: HonoEffectRouteOptions<any, any>\n ): Handler<any, any, any, Promise<Response>> {\n return async (context) => {\n const state = this.getState(context)\n const program = makeProgram(context)\n const result = await program()\n\n if (Result.isError(result)) {\n return await this.handleFailure(state, result.error, context)\n }\n\n const value = result.value\n\n if (options.respond !== undefined) {\n return await options.respond(value, context)\n }\n\n const success: HonoEffectSuccess<any> = { value }\n\n if (options.status !== undefined) {\n Object.assign(success, { status: options.status })\n }\n\n if (options.serialize !== undefined) {\n Object.assign(success, { serialize: options.serialize })\n }\n\n return await this.onSuccess(success, context)\n }\n }\n\n private composeInputMiddleware(\n inputMiddleware: AnyHonoMiddleware,\n handler: Handler<any, any, any, Promise<Response>>\n ): Handler<any, any, any, Promise<Response>> {\n return async (context, next) => {\n let downstreamResponse: Response | undefined\n let nextCalled = false\n\n // Match Hono's compose guard: a middleware may advance the chain only once.\n const nextOnce = async (): Promise<void> => {\n if (nextCalled) {\n throw new Error('next() called multiple times')\n }\n\n nextCalled = true\n downstreamResponse = await handler(context, next)\n }\n const middlewareResponse = await inputMiddleware(context, nextOnce)\n\n if (middlewareResponse instanceof Response) {\n return middlewareResponse\n }\n\n if (downstreamResponse !== undefined) {\n return downstreamResponse\n }\n\n return context.res\n }\n }\n\n private getState(context: HonoContext): RequestState {\n const state = this.states.get(context)\n\n if (state === undefined) {\n throw new HonoEffectBoundaryMissingError()\n }\n\n return state\n }\n}\n\nexport class HonoEffectBoundaryMissingError extends Error {\n constructor() {\n super('Register HonoEffect.middleware() before better-effect handlers')\n this.name = 'HonoEffectBoundaryMissingError'\n }\n}\n"],"mappings":";;;;;;AAuBA,MAAM,wBAAwB,MAAkB,gBAA6C;CAE3F,OAAO,MAAM,SAAS,MAAM,WAAoB;AAClD;AAEA,MAAa,uBAMX,YAC+B;CAE/B,OAAO,iBAAiB,OAAO,SAAS,SAAS;EAC/C,MAAM,MAAM;EAGZ,IAFiB,QAAQ,OAAO,IAAI,GAEzB,MAAM,KAAA,GAAW;GAC1B,MAAM,KAAK;GACX;EACF;EAEA,MAAM,QAAsB,CAAC;EAC7B,QAAQ,OAAO,IAAI,KAAK,KAAK;EAE7B,IAAI;GACF,MAAM,eAAe,eAAe,MAAM,QAAQ,IAAI,GAAG;GACzD,MAAM,cAAc,QAAQ,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,OAAO;EAErC,IAAI,UAAU,KAAA,GACZ,MAAM,IAAI,+BAA+B;EAG3C,OAAO;CACT;AACF;AAEA,IAAa,iCAAb,cAAoD,MAAM;CACxD,cAAc;EACZ,MAAM,gEAAgE;EACtE,KAAK,OAAO;CACd;AACF"}
|
|
1
|
+
{"version":3,"file":"hono.mjs","names":[],"sources":["../src/hono/request-boundary.ts","../src/hono/responses.ts","../src/hono/hono-effect.ts"],"sourcesContent":["import { Result } from 'better-result'\nimport { createMiddleware } from 'hono/factory'\nimport type { Env, MiddlewareHandler } from 'hono'\n\nimport { Effect } from '../effect'\nimport type { LayerInput } from '../layer/inference'\nimport { Runtime } from '../runtime'\nimport type { AnyService } from '../service'\nimport { WebEffect } from '../web'\nimport type { AnyRouteOptions, HonoContext, HonoEffectSuccess, ResponseLike } from './types'\n\n/* oxlint-disable anti-slop/no-unknown-parameters -- Hono handlers carry opaque Result values until the typed adapter callbacks consume them. */\n\ntype RequestOutcome =\n | {\n readonly kind: 'success'\n readonly value: unknown\n readonly options: AnyRouteOptions\n }\n | {\n readonly kind: 'failure'\n readonly cause: unknown\n }\n | {\n readonly kind: 'defect'\n readonly cause: unknown\n }\n\nexport type RequestState = {\n outcome?: RequestOutcome\n}\n\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- Result failures are intentionally opaque until the Hono policy narrows them.\nexport const recordRequestFailure = (state: RequestState, cause: unknown): void => {\n state.outcome ??= { kind: 'failure', cause }\n}\n\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- Route success values retain their public generic type only at the Hono handler boundary.\nexport const recordRequestSuccess = (\n state: RequestState,\n value: unknown,\n options: AnyRouteOptions\n): void => {\n state.outcome ??= { kind: 'success', value, options }\n}\n\nexport type RequestBoundaryOptions<\n Provided extends AnyService,\n RequestLayer extends LayerInput,\n Failure\n> = {\n readonly runtime: Runtime<Provided>\n readonly states: WeakMap<object, RequestState>\n readonly requestLayer?: ((context: HonoContext) => RequestLayer) | undefined\n readonly onSuccess: (result: HonoEffectSuccess<any>, context: HonoContext) => ResponseLike\n readonly onFailure: (error: Failure, context: HonoContext) => ResponseLike\n}\n\ntype BoundaryOptions<RequestLayer extends LayerInput> = {\n readonly requestLayer?: (request: Request) => RequestLayer\n readonly onSuccess: (result: { readonly value: unknown }) => ResponseLike\n readonly onFailure: (error: unknown) => ResponseLike\n}\n\nconst makeBoundaryOptions = <Provided extends AnyService, RequestLayer extends LayerInput, Failure>(\n options: RequestBoundaryOptions<Provided, RequestLayer, Failure>,\n state: RequestState,\n context: HonoContext\n): BoundaryOptions<RequestLayer> => {\n const boundaryOptions: BoundaryOptions<RequestLayer> = {\n onSuccess: ({ value }) => {\n if (context.finalized) {\n return context.res\n }\n\n const outcome = state.outcome\n\n if (outcome?.kind !== 'success') {\n // SAFETY: Values without a Hono route outcome are existing Web Responses; WebEffect validates them.\n return value as Response\n }\n\n if (outcome.options.respond !== undefined) {\n return outcome.options.respond(value, context)\n }\n\n const success: HonoEffectSuccess = { value }\n\n if (outcome.options.status !== undefined) {\n Object.assign(success, { status: outcome.options.status })\n }\n\n if (outcome.options.serialize !== undefined) {\n Object.assign(success, { serialize: outcome.options.serialize })\n }\n\n return options.onSuccess(success, context)\n },\n onFailure: (error) => {\n if (context.error !== undefined || context.finalized) {\n return context.res\n }\n\n if (state.outcome?.kind === 'defect') {\n // SAFETY: Hono has already converted its Error into context.res through app.onError; WebEffect validates it.\n return context.res\n }\n\n // SAFETY: HonoEffect validates the Program failure channel against Failure before this erased Web boundary.\n return options.onFailure(error as Failure, context)\n }\n }\n\n if (options.requestLayer !== undefined) {\n Object.assign(boundaryOptions, {\n requestLayer: (_request: Request) => options.requestLayer!(context)\n })\n }\n\n return boundaryOptions\n}\n\nconst selectBoundaryResult = (state: RequestState, context: HonoContext) => {\n const outcome = state.outcome\n\n if (outcome?.kind === 'failure') {\n return Result.err(outcome.cause)\n }\n\n if (context.error !== undefined) {\n state.outcome = { kind: 'defect', cause: context.error }\n return Result.err(context.error)\n }\n\n if (outcome?.kind === 'success') {\n return Result.ok(outcome.value)\n }\n\n return Result.ok(context.res)\n}\n\nexport const makeRequestBoundary = <\n Provided extends AnyService,\n RequestLayer extends LayerInput,\n Failure,\n E extends Env = Env,\n Path extends string = string\n>(\n options: RequestBoundaryOptions<Provided, RequestLayer, Failure>\n): MiddlewareHandler<E, Path> => {\n // SAFETY: createMiddleware preserves the Hono handler contract; only the generic Context is restored here.\n return createMiddleware(async (context, next) => {\n const key = context\n const existing = options.states.get(key)\n\n if (existing !== undefined) {\n await next()\n return\n }\n\n const state: RequestState = {}\n options.states.set(key, state)\n\n try {\n // oxlint-disable-next-line require-yield -- The bridge turns the complete Hono chain into one lazy WebEffect Program.\n const program = Effect.fn(async function* () {\n await next()\n return selectBoundaryResult(state, context)\n })\n const boundaryOptions = makeBoundaryOptions(options, state, context)\n let response: Response\n\n if (options.requestLayer === undefined) {\n response = await WebEffect.handle(options.runtime, context.req.raw, program, {\n onSuccess: boundaryOptions.onSuccess,\n onFailure: boundaryOptions.onFailure\n })\n } else {\n const requestBoundaryOptions = {\n onSuccess: boundaryOptions.onSuccess,\n onFailure: boundaryOptions.onFailure,\n requestLayer: (_request: Request) => options.requestLayer!(context)\n }\n // SAFETY: HonoEffect.make validates the concrete request Layer before this erased WebEffect dispatch.\n response = await WebEffect.handle(\n options.runtime,\n context.req.raw,\n program,\n requestBoundaryOptions as never\n )\n }\n\n if (!context.finalized || context.res !== response) {\n context.res = response\n }\n } finally {\n options.states.delete(key)\n }\n }) as MiddlewareHandler<E, Path>\n}\n","import type { HonoContext, HonoEffectSuccess } from './types'\n\nconst DEFAULT_FAILURE_MESSAGE = 'Internal Server Error'\n\nexport const defaultSuccess = (\n { value, status, serialize }: HonoEffectSuccess,\n context: HonoContext\n): Response => {\n if (value instanceof Response) {\n return value\n }\n\n const body = serialize === undefined ? value : serialize(value)\n\n if (body === undefined) {\n // SAFETY: route status is intentionally configurable and Hono validates it at response construction.\n return context.body(null, (status ?? 204) as never)\n }\n\n if (status === undefined) {\n return context.json({ data: body })\n }\n\n // SAFETY: route status is intentionally configurable and Hono validates it at response construction.\n return context.json({ data: body }, status as never)\n}\n\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- Result errors are intentionally opaque at this HTTP boundary.\nexport const defaultFailure = (error: unknown, context: HonoContext): Response => {\n if (error instanceof Response) {\n return error\n }\n\n return context.json({ error: DEFAULT_FAILURE_MESSAGE }, 500)\n}\n","import { Result } from 'better-result'\nimport type { Context, Env, Handler, Input, MiddlewareHandler } from 'hono'\n\nimport { Effect } from '../effect'\nimport type { EffectSuccess, EffectYield, ProgramFromGenerator } from '../effect/types'\nimport { Runtime } from '../runtime'\nimport type { LayerInput } from '../layer/inference'\nimport type { AnyService } from '../service'\nimport {\n makeRequestBoundary,\n recordRequestFailure,\n recordRequestSuccess,\n type RequestState\n} from './request-boundary'\nimport { assertResponse } from '../web/responses'\nimport { defaultFailure, defaultSuccess } from './responses'\nimport type {\n AnyGeneratorBody,\n AnyHonoMiddleware,\n AnyProgram,\n AnyProgramFactory,\n AnyResult,\n AnyRouteOptions,\n AvailableServices,\n CompleteProgram,\n DefaultRequestLayer,\n GeneratorBody,\n GeneratorChecks,\n HonoContext,\n HonoEffectContext,\n HonoEffectOptions,\n HonoEffectRouteOptions,\n HonoEffectSuccess,\n HonoRequestLayerChecks,\n MiddlewareEnvironment,\n MiddlewareInputs,\n MiddlewarePath\n} from './types'\n\ntype HonoRouteArguments<Middlewares extends readonly AnyHonoMiddleware[], Body, Options> =\n | [...middlewares: Middlewares, body: Body]\n | [...middlewares: Middlewares, body: Body, options: Options | undefined]\n\ntype HonoInternalHandler = (\n context: HonoContext,\n next: () => Promise<void>\n) => Promise<Response | void>\n\ntype HonoHandlerFactory<\n ContextType extends object,\n Provided extends AnyService,\n Failure,\n ProgramFactory extends (context: ContextType) => AnyProgram\n> = ProgramFactory &\n ([ReturnType<ProgramFactory>] extends [\n CompleteProgram<Provided, ReturnType<ProgramFactory>, Failure>\n ]\n ? unknown\n : (context: ContextType) => CompleteProgram<Provided, ReturnType<ProgramFactory>, Failure>)\n\n/** Run Effect Programs inside one Runtime execution per Hono request. */\nexport class HonoEffect<\n Provided extends AnyService = any,\n Failure = unknown,\n RequestLayer extends LayerInput = DefaultRequestLayer\n> {\n readonly runtime: Runtime<Provided>\n\n private readonly states = new WeakMap<object, RequestState>()\n\n private readonly onSuccess: NonNullable<HonoEffectOptions<Failure, RequestLayer>['onSuccess']>\n\n private readonly onFailure: NonNullable<HonoEffectOptions<Failure, RequestLayer>['onFailure']>\n\n private readonly requestLayer: HonoEffectOptions<Failure, RequestLayer>['requestLayer']\n\n private constructor(\n runtime: Runtime<Provided>,\n options: HonoEffectOptions<Failure, RequestLayer>\n ) {\n this.runtime = runtime\n this.onSuccess = options.onSuccess ?? defaultSuccess\n this.onFailure = options.onFailure ?? defaultFailure\n this.requestLayer = options.requestLayer\n }\n\n static make<\n Provided extends AnyService,\n Failure = unknown,\n RequestLayer extends LayerInput = DefaultRequestLayer\n >(\n runtime: Runtime<Provided>,\n options?: HonoEffectOptions<Failure, RequestLayer> &\n HonoRequestLayerChecks<Provided, RequestLayer>\n ): HonoEffect<Provided, Failure, RequestLayer> {\n return new HonoEffect(runtime, options ?? {})\n }\n\n middleware<E extends Env = Env, Path extends string = string>(): MiddlewareHandler<E, Path> {\n return makeRequestBoundary<Provided, RequestLayer, Failure, E, Path>({\n runtime: this.runtime,\n states: this.states,\n requestLayer: this.requestLayer,\n onSuccess: this.onSuccess,\n onFailure: this.onFailure\n })\n }\n\n handler<\n E extends Env = Env,\n Path extends string = string,\n InputType extends Input = Input,\n Program extends AnyProgram = AnyProgram\n >(\n makeProgram: (\n context: Context<E, Path, InputType>\n ) => CompleteProgram<AvailableServices<Provided, RequestLayer>, Program, Failure>,\n options?: HonoEffectRouteOptions<EffectSuccess<Program>, Context<E, Path, InputType>>\n ): Handler<E, Path, InputType, Promise<Response>>\n handler<\n const Middlewares extends readonly AnyHonoMiddleware[],\n E extends Env = MiddlewareEnvironment<Middlewares>,\n Path extends string = MiddlewarePath<Middlewares>,\n const ProgramFactory extends (\n context: HonoEffectContext<E, Path, MiddlewareInputs<Middlewares>>\n ) => AnyProgram = (\n context: HonoEffectContext<E, Path, MiddlewareInputs<Middlewares>>\n ) => AnyProgram\n >(\n ...args: HonoRouteArguments<\n Middlewares,\n HonoHandlerFactory<\n HonoEffectContext<E, Path, MiddlewareInputs<Middlewares>>,\n AvailableServices<Provided, RequestLayer>,\n Failure,\n ProgramFactory\n >,\n HonoEffectRouteOptions<\n EffectSuccess<ReturnType<ProgramFactory>>,\n Context<E, Path, MiddlewareInputs<Middlewares>>\n >\n >\n ): Handler<E, Path, MiddlewareInputs<Middlewares>, Promise<Response>>\n handler(...args: unknown[]): Handler<any, any, any, Promise<Response>> {\n const last = args.at(-1)\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- overload dispatch separates route options from function callbacks.\n const hasOptions = args.length > 1 && (last === undefined || typeof last !== 'function')\n // SAFETY: the overloads restrict the optional trailing argument to route options.\n const options = ((hasOptions ? last : {}) ?? {}) as AnyRouteOptions\n const bodyIndex = hasOptions ? args.length - 2 : args.length - 1\n // SAFETY: the overloads place the program factory immediately before route options.\n const makeProgram = args[bodyIndex] as AnyProgramFactory\n let handler = this.makeHandler(makeProgram, options)\n\n for (let index = bodyIndex - 1; index >= 0; index -= 1) {\n // SAFETY: every argument before the program factory is an input middleware by the overloads.\n handler = this.composeInputMiddleware(args[index] as AnyHonoMiddleware, handler)\n }\n\n // SAFETY: The public overload retains HonoEffect's Promise<Response> source contract; Hono also accepts the internal Promise<void> completion.\n return handler as Handler<any, any, any, Promise<Response>>\n }\n\n gen<\n E extends Env = Env,\n Path extends string = string,\n InputType extends Input = Input,\n const Yield extends EffectYield = EffectYield,\n const Returned extends AnyResult = AnyResult\n >(\n body: GeneratorBody<Context<E, Path, InputType>, Yield, Returned> &\n GeneratorChecks<AvailableServices<Provided, RequestLayer>, Yield, Returned, Failure>,\n options?: HonoEffectRouteOptions<\n EffectSuccess<ProgramFromGenerator<Yield, Returned>>,\n Context<E, Path, InputType>\n >\n ): Handler<E, Path, InputType, Promise<Response>>\n gen<\n const Middlewares extends readonly AnyHonoMiddleware[],\n E extends Env = MiddlewareEnvironment<Middlewares>,\n Path extends string = MiddlewarePath<Middlewares>,\n const Yield extends EffectYield = EffectYield,\n const Returned extends AnyResult = AnyResult\n >(\n ...args: HonoRouteArguments<\n Middlewares,\n GeneratorBody<HonoEffectContext<E, Path, MiddlewareInputs<Middlewares>>, Yield, Returned> &\n GeneratorChecks<AvailableServices<Provided, RequestLayer>, Yield, Returned, Failure>,\n HonoEffectRouteOptions<\n EffectSuccess<ProgramFromGenerator<Yield, Returned>>,\n Context<E, Path, MiddlewareInputs<Middlewares>>\n >\n >\n ): Handler<E, Path, MiddlewareInputs<Middlewares>, Promise<Response>>\n gen(...args: unknown[]): Handler<any, any, any, Promise<Response>> {\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- overload dispatch distinguishes middleware from the generator body.\n const last = args.at(-1)\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- overload dispatch separates route options from function callbacks.\n const hasOptions = args.length > 1 && (last === undefined || typeof last !== 'function')\n // SAFETY: the overloads restrict the optional trailing argument to route options.\n const options = ((hasOptions ? last : {}) ?? {}) as AnyRouteOptions\n const bodyIndex = hasOptions ? args.length - 2 : args.length - 1\n // SAFETY: the overloads place the generator body immediately before route options.\n const body = args[bodyIndex] as AnyGeneratorBody\n\n let handler = this.makeHandler((context) => {\n // SAFETY: Effect.fn's runtime generator accepts both sync and async generators; the cast only joins its overloads.\n const program = Effect.fn(\n () => body(context) as AsyncGenerator<EffectYield, AnyResult, unknown>\n )\n\n // SAFETY: the public GeneratorChecks overload validates requirements before this erased boundary.\n return program as AnyProgram\n }, options)\n\n for (let index = bodyIndex - 1; index >= 0; index -= 1) {\n // SAFETY: every argument before the generator body is an input middleware by the overloads.\n handler = this.composeInputMiddleware(args[index] as AnyHonoMiddleware, handler)\n }\n\n // SAFETY: The public overload retains HonoEffect's Promise<Response> source contract; Hono also accepts the internal Promise<void> completion.\n return handler as Handler<any, any, any, Promise<Response>>\n }\n\n guard<\n E extends Env = Env,\n Path extends string = string,\n InputType extends Input = Input,\n const Yield extends EffectYield = EffectYield,\n const Returned extends AnyResult = AnyResult\n >(\n body: GeneratorBody<Context<E, Path, InputType>, Yield, Returned> &\n GeneratorChecks<AvailableServices<Provided, RequestLayer>, Yield, Returned, Failure>\n ): MiddlewareHandler<E, Path> {\n return async (context, next) => {\n const state = this.getState(context)\n // SAFETY: Effect.fn accepts the sync or async generator supplied by the caller; this joins its overloads.\n const program = Effect.fn(() => body(context) as AsyncGenerator<Yield, Returned, unknown>)\n const result = await program()\n\n if (Result.isError(result)) {\n return await this.handleFailure(state, result.error, context)\n }\n\n await next()\n }\n }\n\n private recordFailure(\n state: RequestState,\n // oxlint-disable-next-line anti-slop/no-unknown-parameters -- Result errors are intentionally opaque until the WebEffect policy narrows them.\n error: unknown\n ): void {\n recordRequestFailure(state, error)\n }\n\n private makeHandler(\n makeProgram: (context: HonoContext) => AnyProgram,\n options: HonoEffectRouteOptions<any, any>\n ): HonoInternalHandler {\n return async (context) => {\n const state = this.getState(context)\n const result = await makeProgram(context)()\n\n if (Result.isError(result)) {\n return await this.handleFailure(state, result.error, context)\n }\n\n recordRequestSuccess(state, result.value, options)\n return await this.handleSuccess(result.value, options, context)\n }\n }\n\n private async handleSuccess(\n // oxlint-disable-next-line anti-slop/no-unknown-parameters -- Route values are intentionally opaque until the Hono success policy consumes them.\n value: unknown,\n options: AnyRouteOptions,\n context: HonoContext\n ): Promise<Response> {\n if (options.respond !== undefined) {\n return assertResponse(await options.respond(value, context))\n }\n\n const success: HonoEffectSuccess = { value }\n\n if (options.status !== undefined) {\n Object.assign(success, { status: options.status })\n }\n\n if (options.serialize !== undefined) {\n Object.assign(success, { serialize: options.serialize })\n }\n\n return assertResponse(await this.onSuccess(success, context))\n }\n\n private async handleFailure(\n state: RequestState,\n // oxlint-disable-next-line anti-slop/no-unknown-parameters -- Result errors are intentionally opaque until the Hono failure policy consumes them.\n error: unknown,\n context: HonoContext\n ): Promise<Response> {\n this.recordFailure(state, error)\n // SAFETY: The public handler, generator, and guard constraints validate this error against Failure.\n return assertResponse(await this.onFailure(error as Failure, context))\n }\n\n private composeInputMiddleware(\n inputMiddleware: AnyHonoMiddleware,\n handler: HonoInternalHandler\n ): HonoInternalHandler {\n return async (context, next) => {\n let downstreamResponse: Response | undefined\n let nextCalled = false\n\n // Match Hono's compose guard: a middleware may advance the chain only once.\n const nextOnce = async (): Promise<void> => {\n if (nextCalled) {\n throw new Error('next() called multiple times')\n }\n\n nextCalled = true\n const response = await handler(context, next)\n\n if (response !== undefined) {\n downstreamResponse = response\n }\n }\n const middlewareResponse = await inputMiddleware(context, nextOnce)\n\n if (middlewareResponse instanceof Response) {\n return middlewareResponse\n }\n\n if (downstreamResponse !== undefined) {\n return downstreamResponse\n }\n\n if (context.finalized) {\n return context.res\n }\n }\n }\n\n private getState(context: HonoContext): RequestState {\n const state = this.states.get(context)\n\n if (state === undefined) {\n throw new HonoEffectBoundaryMissingError()\n }\n\n return state\n }\n}\n\nexport class HonoEffectBoundaryMissingError extends Error {\n constructor() {\n super('Register HonoEffect.middleware() before better-effect handlers')\n this.name = 'HonoEffectBoundaryMissingError'\n }\n}\n"],"mappings":";;;;;AAiCA,MAAa,wBAAwB,OAAqB,UAAyB;CACjF,MAAM,YAAY;EAAE,MAAM;EAAW;CAAM;AAC7C;AAGA,MAAa,wBACX,OACA,OACA,YACS;CACT,MAAM,YAAY;EAAE,MAAM;EAAW;EAAO;CAAQ;AACtD;AAoBA,MAAM,uBACJ,SACA,OACA,YACkC;CAClC,MAAM,kBAAiD;EACrD,YAAY,EAAE,YAAY;GACxB,IAAI,QAAQ,WACV,OAAO,QAAQ;GAGjB,MAAM,UAAU,MAAM;GAEtB,IAAI,SAAS,SAAS,WAEpB,OAAO;GAGT,IAAI,QAAQ,QAAQ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E;CAEA,uBACE,iBACA,SACqB;EACrB,OAAO,OAAO,SAAS,SAAS;GAC9B,IAAI;GACJ,IAAI,aAAa;GAGjB,MAAM,WAAW,YAA2B;IAC1C,IAAI,YACF,MAAM,IAAI,MAAM,8BAA8B;IAGhD,aAAa;IACb,MAAM,WAAW,MAAM,QAAQ,SAAS,IAAI;IAE5C,IAAI,aAAa,KAAA,GACf,qBAAqB;GAEzB;GACA,MAAM,qBAAqB,MAAM,gBAAgB,SAAS,QAAQ;GAElE,IAAI,8BAA8B,UAChC,OAAO;GAGT,IAAI,uBAAuB,KAAA,GACzB,OAAO;GAGT,IAAI,QAAQ,WACV,OAAO,QAAQ;EAEnB;CACF;CAEA,SAAiB,SAAoC;EACnD,MAAM,QAAQ,KAAK,OAAO,IAAI,OAAO;EAErC,IAAI,UAAU,KAAA,GACZ,MAAM,IAAI,+BAA+B;EAG3C,OAAO;CACT;AACF;AAEA,IAAa,iCAAb,cAAoD,MAAM;CACxD,cAAc;EACZ,MAAM,gEAAgE;EACtE,KAAK,OAAO;CACd;AACF"}
|
|
@@ -313,6 +313,8 @@ interface RuntimeContext {
|
|
|
313
313
|
readonly scope?: Scope;
|
|
314
314
|
readonly signal?: AbortSignal;
|
|
315
315
|
readonly resolutionPath: readonly AnyServiceToken[];
|
|
316
|
+
/** Runtime execution owner, omitted for warmup and Runtime-root activity. */
|
|
317
|
+
readonly executionId?: string;
|
|
316
318
|
}
|
|
317
319
|
/** Host-specific storage for the current RuntimeContext. */
|
|
318
320
|
interface RuntimeContextStorage {
|
|
@@ -371,4 +373,4 @@ declare class ServiceAcquisitionError extends Error {
|
|
|
371
373
|
}
|
|
372
374
|
//#endregion
|
|
373
375
|
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-
|
|
376
|
+
//# sourceMappingURL=index-AiKM71-u.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-AiKM71-u.d.mts","names":[],"sources":["../src/service/types.ts","../src/effect/types.ts","../src/service/service.ts","../src/scope/errors.ts","../src/scope/types.ts","../src/scope/scope.ts","../src/runtime/context.ts","../src/service/runtime.ts","../src/service/errors.ts"],"mappings":";;;cAGqB;;UAGJ,oBAAoB;YACzB,wBAAwB;;;KAIxB,aAAa;;KAGb,gBAAgB,KAAK,oBAAoB,KAAK,UAAU;KAExD,mBAAmB,2BAA2B,iBAAiB;WAChE;WACA,YAAY;;WAGZ,KAAK,YAAY,gBAAgB,gBAAgB,cAAc;;KAGrE,+BAA+B,6BAA6B,gBAAgB;;UAGhE,iBACX,oCACG,iBAAiB,0BAEhB,2BAA2B,WAAW,eAAe,KAAK;;KAGxD,kBAAkB;;KAGlB,aACV,6BACA,iBAAiB,aAAa,uBACnB,gBAAgB,YAAY,eAAe,KAAK;;KAGjD,gBAAgB,UAAU,mBAAmB,aAAa;;KAG1D,aAAa,UAAU,cAAc,SAAS;;KAG9C,eAAe,UAAU,cAAc,UAAU,aACzD,aAAa,aAAa,IAAI;;KAItB,WAAW,UAAU,aAAa,mBAAmB,UAAU,aACvE,aAAa,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EtC,MAAM,UAAU,eAAe;;cA2LpB;;WAEH,YAAA;;WAKG,eAAA;;WAKH,UAAA,GAAC,OAAS,OAAK,eAAiB,MAAI;;YAMtB,OAAA,iBAAA,iBAAiB;;;;;;;;;;;;;;;;WAmBnC,MAAA,GAAC,UAAY,OAAO,UAAU,IAAI,YAAY,OAAK,QAAQ,QAAQ;;;kBAUhD;;OAEX,YAAY;;OAGZ,UAAU;;OAGV,YAAY;;OAGZ,aAAa;;;;;UClRV;WACN,WAAW;WACX,QAAQ;WACR,SAAS;WACT,yBAAyB;;WAEzB;;;UAUM;EACf,IAAI,GAAG,SAAS,gBAAgB,eAAe,IAAI;EACnD,WAAW;;;;;UCNI;;EAEf,QAAQ,UAAU,iBAAiB,OAAO,IAAI,aAAa,KAAK,YAAY,aAAa;;;cAI9E;;;;;;;;;;;;;SAaJ,IAAI,GACT,UAAU,iBACV,eAAe,GACf,UAAS,wBACR;;SAeI,WAAW;;SAqBL,QAAQ,UAAU,iBAAiB,OAAO,IAAI,QAAQ,aAAa;;;;;cCvErE,yCAAyC;EAAA;;;cASzC,6BAA6B;WACnB,SAAS;EAAT,YAAA,SAAS;;;cAQnB,gCAAgC;WAClC,eAAe;EAEZ,YAAA,eAAe;;;cAWhB,gCAAgC;WAIhC,SAAS;WAHF;EAGP,YAAA,SAAS,iBAClB,yBAAyB,mBACzB;WAgBO,yBAAyB"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { M as AnyService, h as ScopeOutcome } from "./index-
|
|
2
|
-
import {
|
|
3
|
-
import "./
|
|
4
|
-
import "./index-
|
|
1
|
+
import { M as AnyService, h as ScopeOutcome } from "./index-AiKM71-u.mjs";
|
|
2
|
+
import { _ as CompleteInput, a as RuntimeShutdownDiagnostic, d as LayerBackend, g as CompleteExecutionLayer, h as CompleteExecution, i as RuntimeRunOptions, n as RuntimeDisposeOptions, p as Layer, r as RuntimeOptions, w as ProvidedEnvironment, y as LayerInput } from "./outcome-DI8LPIQ4.mjs";
|
|
3
|
+
import "./observer-9nhbL7Pr.mjs";
|
|
4
|
+
import "./index-DAKn0qHk.mjs";
|
|
5
|
+
import "./index-CCi07kUw.mjs";
|
|
5
6
|
import { Result, UnhandledException } from "better-result";
|
|
6
7
|
//#region src/runtime/types.d.ts
|
|
7
8
|
/** A detached diagnostic view of one active Runtime execution. */
|
|
@@ -176,4 +177,4 @@ declare const Resource: {
|
|
|
176
177
|
};
|
|
177
178
|
//#endregion
|
|
178
179
|
export { ReleaseOutcome as a, CurrentAbortSignal as c, RuntimeFor as d, RuntimeInspection as f, ReleaseFailureObserver as i, Runtime as l, AcquireUseReleaseOptions as n, ResourceReleaseFailure as o, AsyncResult as r, pipe as s, Resource as t, RuntimeExecutionInspection as u };
|
|
179
|
-
//# sourceMappingURL=index-
|
|
180
|
+
//# sourceMappingURL=index-BodMy6rO.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-BodMy6rO.d.mts","names":[],"sources":["../src/runtime/types.ts","../src/runtime/runtime.ts","../src/runtime/signal.ts","../src/function/pipe.ts","../src/resource/errors.ts","../src/resource/types.ts","../src/resource/resource.ts"],"mappings":";;;;;;;;KAMY;WACD;WACA;WACA;;;;;;;;;KAUC;WACD;WACA;WACA;WACA,qBAAqB;WACrB;WACA;;;;;;;;;;;KAYC,WAAW,UAAU,cAAc,QAAQ,MAAM,SAAS;;;KCNjE,sBAAsB,iBAAiB;;;;;;;;;;;;;;;;cA8C/B,QAAQ,iBAAiB;mBACC;UAA9B;;;;;;;;;;;SAYA,KAAK,UAAU,YACpB,OAAO,IAAI,cAAc,IACzB,SAAS,cACT,UAAU,iBACT,QAAQ,QAAQ,oBAAoB;SAEhC,KAAK,UAAU,YACpB,OAAO,IAAI,cAAc,IACzB,UAAU,iBACT,QAAQ,QAAQ,oBAAoB;;;;;;;SAwBhC,IAAI,GAAG,UAAU,YACtB,OAAO,IAAI,cAAc,IACzB,SAAS,cACT,SAAS,kBAAkB,oBAAoB,IA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,GAAG,IACb,IAAI,MAAM,GAAG,IACb,IAAI,MAAM,GAAG,IACb,IAAI,MAAM,GAAG,IACb,IAAI,MAAM,GAAG,KACZ;iBACa,KAAK,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GACjD,OAAO,GACP,IAAI,MAAM,GAAG,IACb,IAAI,MAAM,GAAG,IACb,IAAI,MAAM,GAAG,IACb,IAAI,MAAM,GAAG,IACb,IAAI,MAAM,GAAG,IACb,IAAI,MAAM,GAAG,IACb,IAAI,MAAM,GAAG,IACb,IAAI,MAAM,GAAG,IACb,IAAI,MAAM,GAAG,IACb,IAAI,MAAM,GAAG,KACZ;;;;;cC3FU,+BAA+B;WACjC;WACA;WACA;;;;;KCCC,aAAa,KAAK,IAAI,YAAY;;KAGlC,YAAY,GAAG,KAAK,aAAa,OAAW,GAAG;;KAG/C,wBAAwB;;KAGxB,0BAA0B,SAAS,2BAA2B;;KAG9D,yBAAyB,GAAG,GAAG,cAAc;;WAE9C;;WAGA,eAAe,YAAY,GAAG;;WAG9B,MAAM,UAAU,MAAM,YAAY,GAAG;;WAGrC,WAAW,UAAU,MAAM,aAAa;;;;;WAMxC,mBAAmB;;;;cCqBjB;;WA3Bc,oBAAA,GAAG,GAAG,cAAc,YAAQ,MAAA,SAAA,KAAA,SAAA,oBAMpD,yBAAyB,GAAG,GAAG,cAAc,cAAY,QAC1D,OAAW,GAAG,eAAe,WAAW,qBAAqB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
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, w as EffectFromGenerator, x as AnyEffect } from "./index-
|
|
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, w as EffectFromGenerator, x as AnyEffect } from "./index-AiKM71-u.mjs";
|
|
2
2
|
import { Err, Result, UnhandledException } from "better-result";
|
|
3
3
|
//#region src/effect/combinators.d.ts
|
|
4
4
|
type EffectInput<A, E> = Result<A, E> | PromiseLike<Result<A, E>>;
|
|
@@ -397,4 +397,4 @@ declare namespace Effect {
|
|
|
397
397
|
}
|
|
398
398
|
//#endregion
|
|
399
399
|
export { Program as n, ProgramAllOptions as r, Effect as t };
|
|
400
|
-
//# sourceMappingURL=index-
|
|
400
|
+
//# sourceMappingURL=index-CCi07kUw.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-CCi07kUw.d.mts","names":[],"sources":["../src/effect/combinators.ts","../src/effect/program-combinators.ts","../src/effect/effect.ts"],"mappings":";;;KAYK,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,eAAa,GAAG;GAClB,OAAO,QAAQ,QAAQ,YAAY,UAAU,cAAc,OAAO,aAAa,OAAO;;KAGpF,oBAAkB,IAAI;GACxB,OAAO,QAAQ,QAAQ,iBAAiB,MAAM,cAAc,OAAO,kBAAkB,OAAO;;KAG1F,mBAAiB;GACnB,OAAO,QAAQ,QAAQ,iBAAiB,cAAc,OAAO;;KAG3D,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iBAiCtC,kBAAkB,UAAU,oBAC1C,eAAe,aAAa,KAC3B,eAAe,WAAW,qBAAqB;;;;;;;;;;;;;iBAkBlC,IAAI,UAAU,oBAC5B,UAAU,IACT,eAAe,WAAW,qBAAqB;;;;;;;KAY7C;WACM,YAAY;WACZ,WAAW;WACX,uBAAuB;WACvB,6BAA6B;WAC7B,0BAA0B;WAC1B,YAAY;WACZ,YAAY;WACZ,iBAAiB;WACjB,gBAAgB;WAChB,qBAAqB;WACrB,YAAY;WACZ,iBAAiB;WACjB,iBAAiB;WACjB,sBAAsB;WACtB,gBAAgB;WAChB,qBAAqB;WACrB,mBAAmB;WACnB,0BAA0B;WAC1B,gBAAgB;WAChB,qBAAqB;WACrB,gBAAgB;WAChB,WAAW;WACX,eAAe;WACf,cAAc;WACd,YAAY;WACZ,YAAY;;cAGV,QAAQ;;kBAwDI;;OAEX,QAAQ,GAAG,GAAG,UAAU,sBAAsB,YAAY,GAAG,GAAG;;OAGhE,QAAQ,KAAK,cAAc;;OAG3B,MAAM,KAAK,YAAY;;OAGvB,aAAa,KAAK,mBAAmB;;OAGrC,MAAM"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { N as AnyServiceToken } from "./index-
|
|
2
|
-
import {
|
|
1
|
+
import { N as AnyServiceToken } from "./index-AiKM71-u.mjs";
|
|
2
|
+
import { d as LayerBackend, f as LayerBackendDisposeOptions, m as LayerRegistration } from "./outcome-DI8LPIQ4.mjs";
|
|
3
|
+
import "./observer-9nhbL7Pr.mjs";
|
|
3
4
|
//#region src/layer/map-layer-backend.d.ts
|
|
4
5
|
/** Native map-backed Layer backend used by Runtime when no adapter is supplied. */
|
|
5
6
|
declare class MapLayerBackend implements LayerBackend {
|
|
@@ -15,4 +16,4 @@ declare class MapLayerBackend implements LayerBackend {
|
|
|
15
16
|
}
|
|
16
17
|
//#endregion
|
|
17
18
|
export { MapLayerBackend as t };
|
|
18
|
-
//# sourceMappingURL=index-
|
|
19
|
+
//# sourceMappingURL=index-DAKn0qHk.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-DAKn0qHk.d.mts","names":[],"sources":["../src/layer/map-layer-backend.ts"],"mappings":";;;;;cAca,2BAA2B;mBACrB;mBAEA;mBAEA;;EAGjB,SAAS,cAAc;;EAiBjB,QAAQ,UAAU,iBAAiB,OAAO,IAAI,QAAQ,aAAa;;EA6CnE,WAAW,UAAU,6BAA6B"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { H as ServiceToken, I as ServiceIdentity, b as Service, j as ServiceRequirement } from "./index-
|
|
2
|
-
import {
|
|
3
|
-
import "./index-
|
|
1
|
+
import { H as ServiceToken, I as ServiceIdentity, b as Service, j as ServiceRequirement } from "./index-AiKM71-u.mjs";
|
|
2
|
+
import { A as ProviderEntry, x as LayerResult } from "./outcome-DI8LPIQ4.mjs";
|
|
3
|
+
import "./index-BodMy6rO.mjs";
|
|
4
|
+
import "./current-request-CIU7AHhF.mjs";
|
|
4
5
|
import { Err, StandardSchemaV1, UnhandledException } from "better-result";
|
|
5
6
|
//#region src/standard-services/config.d.ts
|
|
6
7
|
/** Raw string values supplied to a configuration schema. */
|
|
@@ -229,21 +230,6 @@ declare class LoggerTest implements Service.Contract<Logger> {
|
|
|
229
230
|
static layer(logger?: LoggerTest): LayerResult<ProviderEntry<Logger, never>>;
|
|
230
231
|
}
|
|
231
232
|
declare const LoggerTestLayer: () => LayerResult<ProviderEntry<Logger, never>>;
|
|
232
|
-
declare const CurrentRequest_base: (abstract new () => ServiceIdentity<"CurrentRequest">) & {
|
|
233
|
-
readonly name: string;
|
|
234
|
-
readonly serviceTag: "CurrentRequest";
|
|
235
|
-
} & {
|
|
236
|
-
readonly of: Service.FactoryOf<CurrentRequest, "CurrentRequest">;
|
|
237
|
-
readonly [Symbol.asyncIterator]: (this: ServiceToken<"CurrentRequest", CurrentRequest & ServiceIdentity<"CurrentRequest">>) => AsyncGenerator<ServiceRequirement<CurrentRequest>, CurrentRequest, unknown>;
|
|
238
|
-
};
|
|
239
|
-
/** Execution-local request value carried by a normal Service provider. */
|
|
240
|
-
declare class CurrentRequest extends CurrentRequest_base {
|
|
241
|
-
readonly value: unknown;
|
|
242
|
-
readonly request: unknown;
|
|
243
|
-
constructor(value: unknown);
|
|
244
|
-
static layer(value: unknown): LayerResult<ProviderEntry<CurrentRequest, never>>;
|
|
245
|
-
}
|
|
246
|
-
declare const CurrentRequestLayer: (value: unknown) => LayerResult<ProviderEntry<CurrentRequest, never>>;
|
|
247
233
|
//#endregion
|
|
248
|
-
export {
|
|
249
|
-
//# sourceMappingURL=index-
|
|
234
|
+
export { ConfigOutput as A, IdGeneratorUnavailableError as C, ConfigInput as D, ConfigFromEnvOptions as E, ConfigValue as F, StandardSchemaV1 as I, ConfigSourceError as M, ConfigSourceOptions as N, ConfigIssue as O, ConfigValidationError as P, IdGeneratorTestLayer as S, ConfigError as T, RandomSeededLayer as _, ClockTestLayer as a, IdGeneratorLive as b, LoggerData as c, LoggerLive as d, LoggerTest as f, RandomSeeded as g, RandomLive as h, ClockTest as i, ConfigSource as j, ConfigLive as k, LoggerEvent as l, Random as m, ClockLive as n, ClockTestRunAllOptions as o, LoggerTestLayer as p, ClockSleepOptions as r, Logger as s, Clock as t, LoggerLevel as u, IdGenerator as v, Config as w, IdGeneratorTest as x, IdGeneratorExhaustedError as y };
|
|
235
|
+
//# sourceMappingURL=index-cXgyMa0v.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-cXgyMa0v.d.mts","names":[],"sources":["../src/standard-services/config.ts","../src/standard-services/id-generator.ts","../src/standard-services/index.ts"],"mappings":";;;;;;;KAcY,eAAe,SAAS;;KAGxB;WACD;WACA,YAAY;;;KAIX,qBAAqB,eAAe,oBAAoB;WACzD,QAAQ;;;KAIP,aAAa,eAAe,oBAAoB,iBAAiB,YAAY;;KAG7E,YAAY,eAAe,oBAAoB,iBAAiB,WAAW;;KAG3E,cAAc,iBA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EAIJ,OAAO;;EAKP,QAAQ,OAAO;EAWf,QAAQ;EAMR,MAAM,sBAAsB,UAAU,oBAAoB;;EA2C1D;;EAaM,OAAO,UAAU,yBAAyB;SAiBzC,MAAM,UAAS,gBAAiB,YAAA,cAAA;UAI/B;UAUA;UAUA;UAaA;;cAqBG,iBAAkB,UAAS,kBAAiB,YAAA,cAAA;;;;;;;;;cAG5C,eAAe;EAC1B;EAIA,QAAQ;;;cAUG,YAAU,YAAA,cAAA;;cAGV,wBAAwB,QAAQ,SAAS;UAC5C;EAEI,YAAA;EAQZ;EAKA,QAAQ;SAQD,MAAM,eAAY,YAAA,cAAA;;cAKd,oBAAqB,iBAAY,YAAA,cAAA;KAElC;KAEA;EACV,OAAO;EACP;EACA,OAAO;;KAGG,kEAMC;YACG,cAAc;;;;;;;;;;cAqBjB,eAAe;EAC1B,IAAI,OAAO;EACX,IAAI,OAAO,aAAa,iBAAiB,OAAO;EAahD,MAAM,iBAAiB,OAAO;EAI9B,KAAK,iBAAiB,OAAO;EAI7B,KAAK,iBAAiB,OAAO;EAI7B,MAAM,iBAAiB,OAAO;;;cAMnB,YAAU,YAAA,cAAA;;cAGV,sBAAsB,QAAQ,SAAS;WACzC,QAAQ;EAEjB,IAAI,OAAO;EACX,IAAI,OAAO,aAAa,iBAAiB,OAAO;EAOhD,MAAM,iBAAiB,OAAO;EAI9B,KAAK,iBAAiB,OAAO;EAI7B,KAAK,iBAAiB,OAAO;EAI7B,MAAM,iBAAiB,OAAO;EAI9B;SAIO;;;;SAKA,MAAM,SAAQ,aAA6B,YAAA,cAAA;;cAKvC,uBAAe,YAAA,cAAA"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { B as ServiceTag, C as EffectError, D as EffectYield, E as EffectSuccess, F as ServiceContract, H as ServiceToken, I as ServiceIdentity, M as AnyService, N as AnyServiceToken, P as ServiceClass, R as ServiceInstance, T as EffectRequirements, U as ServiceTokenOf, _ as ScopeCloseError, a as ServiceResolver, b as Service, c as RuntimeContextStorage, d as CleanupFailureDiagnostic, f as DisposableResource, g as ResourceNotDisposableError, h as ScopeOutcome, i as ServiceRuntimeNotConfiguredError, j as ServiceRequirement, l as CloseableScope, m as ScopeFinalizer, n as ServiceAcquisitionError, o as ServiceRuntime, r as ServiceNotFoundError, s as RuntimeContext, t as CircularDependencyError, u as Scope, v as ScopeClosedError, x as AnyEffect, y as ScopeRuntimeNotConfiguredError, z as ServiceRequirements } from "./index-
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
4
|
-
import {
|
|
1
|
+
import { B as ServiceTag, C as EffectError, D as EffectYield, E as EffectSuccess, F as ServiceContract, H as ServiceToken, I as ServiceIdentity, M as AnyService, N as AnyServiceToken, P as ServiceClass, R as ServiceInstance, T as EffectRequirements, U as ServiceTokenOf, _ as ScopeCloseError, a as ServiceResolver, b as Service, c as RuntimeContextStorage, d as CleanupFailureDiagnostic, f as DisposableResource, g as ResourceNotDisposableError, h as ScopeOutcome, i as ServiceRuntimeNotConfiguredError, j as ServiceRequirement, l as CloseableScope, m as ScopeFinalizer, n as ServiceAcquisitionError, o as ServiceRuntime, r as ServiceNotFoundError, s as RuntimeContext, t as CircularDependencyError, u as Scope, v as ScopeClosedError, x as AnyEffect, y as ScopeRuntimeNotConfiguredError, z as ServiceRequirements } from "./index-AiKM71-u.mjs";
|
|
2
|
+
import { a as RuntimeShutdownDiagnostic, c as LayerGeneratorYieldError, d as LayerBackend, f as LayerBackendDisposeOptions, i as RuntimeRunOptions, l as LayerRegistrationError, m as LayerRegistration, n as RuntimeDisposeOptions, o as DuplicateServiceError, p as Layer, r as RuntimeOptions, s as LayerDisposeError, t as CleanupFailureObserver, u as ServiceTagCollisionError } from "./outcome-DI8LPIQ4.mjs";
|
|
3
|
+
import { a as RuntimeObserver, c as RuntimeServiceResolveEvent, i as RuntimeExecutionStartEvent, n as RuntimeExecutionEndEvent, o as RuntimeResourceReleaseEvent, r as RuntimeExecutionMetadata, s as RuntimeServiceAcquireEvent, t as RuntimeExecutionAttributes } from "./observer-9nhbL7Pr.mjs";
|
|
4
|
+
import { t as MapLayerBackend } from "./index-DAKn0qHk.mjs";
|
|
5
|
+
import { a as ReleaseOutcome, c as CurrentAbortSignal, d as RuntimeFor, f as RuntimeInspection, i as ReleaseFailureObserver, l as Runtime, n as AcquireUseReleaseOptions, o as ResourceReleaseFailure, r as AsyncResult, s as pipe, t as Resource, u as RuntimeExecutionInspection } from "./index-BodMy6rO.mjs";
|
|
5
6
|
import { t as RuntimeContextNotConfiguredError } from "./errors-BKcsQ0ip.mjs";
|
|
6
|
-
import { n as Program, r as ProgramAllOptions, t as Effect } from "./index-
|
|
7
|
+
import { n as Program, r as ProgramAllOptions, t as Effect } from "./index-CCi07kUw.mjs";
|
|
7
8
|
export { type AcquireUseReleaseOptions, type AnyEffect, type AnyService, type AnyServiceToken, type AsyncResult, CircularDependencyError, type CleanupFailureDiagnostic, type CleanupFailureObserver, type CloseableScope, CurrentAbortSignal, type DisposableResource, DuplicateServiceError, Effect, type EffectError, type EffectRequirements, type EffectSuccess, type EffectYield, Layer, type LayerBackend, type LayerBackendDisposeOptions, LayerDisposeError, LayerGeneratorYieldError, type LayerRegistration, LayerRegistrationError, MapLayerBackend, Program, type ProgramAllOptions, type ReleaseFailureObserver, type ReleaseOutcome, Resource, ResourceNotDisposableError, ResourceReleaseFailure, Runtime, type RuntimeContext, RuntimeContextNotConfiguredError, type RuntimeContextStorage, type RuntimeDisposeOptions, type RuntimeExecutionAttributes, type RuntimeExecutionEndEvent, type RuntimeExecutionInspection, type RuntimeExecutionMetadata, type RuntimeExecutionStartEvent, type RuntimeFor, type RuntimeInspection, RuntimeObserver, type RuntimeOptions, type RuntimeResourceReleaseEvent, type RuntimeRunOptions, type RuntimeServiceAcquireEvent, type RuntimeServiceResolveEvent, type RuntimeShutdownDiagnostic, Scope, ScopeCloseError, ScopeClosedError, type ScopeFinalizer, type ScopeOutcome, ScopeRuntimeNotConfiguredError, Service, ServiceAcquisitionError, type ServiceClass, type ServiceContract, type ServiceIdentity, type ServiceInstance, ServiceNotFoundError, type ServiceRequirement, type ServiceRequirements, type ServiceResolver, ServiceRuntime, ServiceRuntimeNotConfiguredError, type ServiceTag, ServiceTagCollisionError, type ServiceToken, type ServiceTokenOf, pipe };
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { a as LayerGeneratorYieldError, c as CircularDependencyError, d as ServiceRuntimeNotConfiguredError, i as LayerDisposeError, l as ServiceAcquisitionError, o as LayerRegistrationError, r as DuplicateServiceError, s as ServiceTagCollisionError, u as ServiceNotFoundError } from "./registration-drnZk0SY.mjs";
|
|
2
|
-
import { h as RuntimeContextNotConfiguredError } from "./context-
|
|
3
|
-
import { a as
|
|
4
|
-
import { n as Service, r as ServiceRuntime, t as Layer } from "./layer-
|
|
5
|
-
import { i as Scope } from "./program-metadata-
|
|
6
|
-
import { i as MapLayerBackend, n as RuntimeObserver, t as Runtime } from "./runtime-
|
|
7
|
-
import { n as Program, t as Effect } from "./effect-
|
|
2
|
+
import { h as RuntimeContextNotConfiguredError } from "./context-BphfFUMO.mjs";
|
|
3
|
+
import { a as ScopeClosedError, i as ScopeCloseError, o as ScopeRuntimeNotConfiguredError, r as ResourceNotDisposableError, t as disposeResource } from "./disposable-CP-Q2H3l.mjs";
|
|
4
|
+
import { n as Service, r as ServiceRuntime, t as Layer } from "./layer-D16GKxuX.mjs";
|
|
5
|
+
import { i as Scope } from "./program-metadata-BxjGkT17.mjs";
|
|
6
|
+
import { i as MapLayerBackend, n as RuntimeObserver, t as Runtime } from "./runtime-C_55ofnL.mjs";
|
|
7
|
+
import { n as Program, t as Effect } from "./effect-CPdV7Yv8.mjs";
|
|
8
|
+
import { t as CurrentAbortSignal } from "./signal-nfgFyNCk.mjs";
|
|
8
9
|
import { Result, TaggedError } from "better-result";
|
|
9
10
|
//#region src/function/pipe.ts
|
|
10
11
|
function pipe(value, ...operations) {
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/function/pipe.ts","../src/resource/errors.ts","../src/resource/internal.ts","../src/resource/resource.ts"],"sourcesContent":["type Unary<A, B> = (value: A) => B\n\n/**\n * Compose a value through a sequence of unary functions.\n *\n * `pipe` is deliberately independent of Effect, Result, Promise, Scope, and\n * Service metadata.\n *\n * @example\n * ```ts\n * const label = pipe(\n * 'alice',\n * (name) => name.trim(),\n * (name) => name.toUpperCase()\n * )\n * ```\n */\ntype PipeRuntimeValue = Parameters<Unary<any, any>>[0]\n\ntype PipeRuntimeOperation = Unary<PipeRuntimeValue, PipeRuntimeValue>\n\nexport function pipe<A>(value: A): A\nexport function pipe<A, B>(value: A, ab: Unary<A, B>): B\nexport function pipe<A, B, C>(value: A, ab: Unary<A, B>, bc: Unary<B, C>): C\nexport function pipe<A, B, C, D>(value: A, ab: Unary<A, B>, bc: Unary<B, C>, cd: Unary<C, D>): D\nexport function pipe<A, B, C, D, E>(\n value: A,\n ab: Unary<A, B>,\n bc: Unary<B, C>,\n cd: Unary<C, D>,\n de: Unary<D, E>\n): E\nexport function pipe<A, B, C, D, E, F>(\n value: A,\n ab: Unary<A, B>,\n bc: Unary<B, C>,\n cd: Unary<C, D>,\n de: Unary<D, E>,\n ef: Unary<E, F>\n): F\nexport function pipe<A, B, C, D, E, F, G>(\n value: A,\n ab: Unary<A, B>,\n bc: Unary<B, C>,\n cd: Unary<C, D>,\n de: Unary<D, E>,\n ef: Unary<E, F>,\n fg: Unary<F, G>\n): G\nexport function pipe<A, B, C, D, E, F, G, H>(\n value: A,\n ab: Unary<A, B>,\n bc: Unary<B, C>,\n cd: Unary<C, D>,\n de: Unary<D, E>,\n ef: Unary<E, F>,\n fg: Unary<F, G>,\n gh: Unary<G, H>\n): H\nexport function pipe<A, B, C, D, E, F, G, H, I>(\n value: A,\n ab: Unary<A, B>,\n bc: Unary<B, C>,\n cd: Unary<C, D>,\n de: Unary<D, E>,\n ef: Unary<E, F>,\n fg: Unary<F, G>,\n gh: Unary<G, H>,\n hi: Unary<H, I>\n): I\nexport function pipe<A, B, C, D, E, F, G, H, I, J>(\n value: A,\n ab: Unary<A, B>,\n bc: Unary<B, C>,\n cd: Unary<C, D>,\n de: Unary<D, E>,\n ef: Unary<E, F>,\n fg: Unary<F, G>,\n gh: Unary<G, H>,\n hi: Unary<H, I>,\n ij: Unary<I, J>\n): J\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K>(\n value: A,\n ab: Unary<A, B>,\n bc: Unary<B, C>,\n cd: Unary<C, D>,\n de: Unary<D, E>,\n ef: Unary<E, F>,\n fg: Unary<F, G>,\n gh: Unary<G, H>,\n hi: Unary<H, I>,\n ij: Unary<I, J>,\n jk: Unary<J, K>\n): K\nexport function pipe(\n value: PipeRuntimeValue,\n ...operations: ReadonlyArray<PipeRuntimeOperation>\n): PipeRuntimeValue {\n return operations.reduce((current, operation) => operation(current), value)\n}\n","import { TaggedError } from 'better-result'\n\n/** Describes a failure encountered while releasing a Resource. */\nexport class ResourceReleaseFailure extends TaggedError('ResourceReleaseFailure')<{\n readonly resource: string\n readonly cause: unknown\n readonly message: string\n}> {}\n","import { Result, type Result as ResultType, type UnhandledException } from 'better-result'\n\nimport { ResourceReleaseFailure } from './errors'\n\nimport { disposeResource } from '../scope/disposable'\n\nexport { disposeResource }\n\nimport type { AsyncResult, MaybePromise, ReleaseFailureObserver, ReleaseOutcome } from './types'\n\nconst toReleaseFailure = (resource: string, cause: unknown): ResourceReleaseFailure =>\n new ResourceReleaseFailure({\n resource,\n cause,\n message: `Failed to release resource: ${resource}`\n })\n\nexport const runResult = async <T, E>(\n operation: () => AsyncResult<T, E>\n): Promise<ResultType<T, E | UnhandledException>> => {\n const execution = await Result.tryPromise(() => Promise.resolve(operation()))\n\n return execution.andThen((result) => result)\n}\n\nconst normalizeReleaseOutcome = (\n name: string,\n outcome: ReleaseOutcome\n): ResultType<void, ResourceReleaseFailure> => {\n if (outcome === undefined) {\n return Result.ok()\n }\n\n return outcome.mapError((cause) => toReleaseFailure(name, cause))\n}\n\nexport const runRelease = async <R>(\n name: string,\n resource: R,\n release: (resource: R) => MaybePromise<ReleaseOutcome>\n): Promise<ResultType<void, ResourceReleaseFailure>> => {\n const execution = await Result.tryPromise({\n try: () => Promise.resolve(release(resource)),\n catch: (cause) => toReleaseFailure(name, cause)\n })\n\n return execution.andThen((outcome) => normalizeReleaseOutcome(name, outcome))\n}\n\nconst notifyReleaseFailure = async (\n observer: ReleaseFailureObserver | undefined,\n\n failure: ResourceReleaseFailure\n): Promise<void> => {\n if (!observer) {\n return\n }\n\n try {\n await observer(failure)\n } catch {\n /*\n * Diagnostics must never replace\n * the actual operation error.\n */\n }\n}\n\nexport const combineUseAndRelease = async <A, E>(\n used: ResultType<A, E>,\n\n released: ResultType<void, ResourceReleaseFailure>,\n\n onReleaseFailure?: ReleaseFailureObserver\n): Promise<ResultType<A, E | ResourceReleaseFailure>> => {\n if (Result.isError(used)) {\n if (Result.isError(released)) {\n await notifyReleaseFailure(onReleaseFailure, released.error)\n }\n\n return Result.err<A, E | ResourceReleaseFailure>(used.error)\n }\n\n if (Result.isError(released)) {\n await notifyReleaseFailure(onReleaseFailure, released.error)\n\n return Result.err<A, E | ResourceReleaseFailure>(released.error)\n }\n\n return Result.ok<A, E | ResourceReleaseFailure>(used.value)\n}\n","import { Result, type Result as ResultType, type UnhandledException } from 'better-result'\n\nimport { Scope } from '../scope'\n\nimport { ResourceReleaseFailure } from './errors'\n\nimport { combineUseAndRelease, disposeResource, runRelease, runResult } from './internal'\n\nimport type { AcquireUseReleaseOptions } from './types'\n\n/**\n * Acquire a resource, use it, and always attempt release afterward.\n *\n * Acquisition, use, and release may be synchronous or asynchronous Result\n * operations. If both use and release fail, the use error remains primary and\n * `onReleaseFailure` receives the cleanup failure as a diagnostic.\n *\n * When `release` is omitted, `Symbol.asyncDispose` is preferred over\n * `Symbol.dispose`.\n *\n * @example\n * ```ts\n * const result = await Resource.acquireUseRelease({\n * name: 'database connection',\n * acquire: () => connect(),\n * use: (connection) => query(connection),\n * release: (connection) => connection.close()\n * })\n * ```\n */\nconst acquireUseRelease = <R, A, AcquireError, UseError>({\n name,\n acquire,\n use,\n release = disposeResource,\n onReleaseFailure\n}: AcquireUseReleaseOptions<R, A, AcquireError, UseError>): Promise<\n ResultType<A, AcquireError | UseError | UnhandledException | ResourceReleaseFailure>\n> =>\n Result.gen(async function* () {\n const resource = yield* Result.await(runResult(acquire))\n\n const scope = Scope.make()\n\n let released: ResultType<void, ResourceReleaseFailure> = Result.ok()\n\n scope.addFinalizer(async () => {\n released = await runRelease(name, resource, release)\n })\n\n const used = await runResult(() => use(resource))\n\n await scope.close()\n\n return await combineUseAndRelease(used, released, onReleaseFailure)\n })\n\nexport const Resource = {\n /** Acquire, use, and release a resource with deterministic error precedence. */\n acquireUseRelease\n} as const\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/function/pipe.ts","../src/resource/errors.ts","../src/resource/internal.ts","../src/resource/resource.ts"],"sourcesContent":["type Unary<A, B> = (value: A) => B\n\n/**\n * Compose a value through a sequence of unary functions.\n *\n * `pipe` is deliberately independent of Effect, Result, Promise, Scope, and\n * Service metadata.\n *\n * @example\n * ```ts\n * const label = pipe(\n * 'alice',\n * (name) => name.trim(),\n * (name) => name.toUpperCase()\n * )\n * ```\n */\ntype PipeRuntimeValue = Parameters<Unary<any, any>>[0]\n\ntype PipeRuntimeOperation = Unary<PipeRuntimeValue, PipeRuntimeValue>\n\nexport function pipe<A>(value: A): A\nexport function pipe<A, B>(value: A, ab: Unary<A, B>): B\nexport function pipe<A, B, C>(value: A, ab: Unary<A, B>, bc: Unary<B, C>): C\nexport function pipe<A, B, C, D>(value: A, ab: Unary<A, B>, bc: Unary<B, C>, cd: Unary<C, D>): D\nexport function pipe<A, B, C, D, E>(\n value: A,\n ab: Unary<A, B>,\n bc: Unary<B, C>,\n cd: Unary<C, D>,\n de: Unary<D, E>\n): E\nexport function pipe<A, B, C, D, E, F>(\n value: A,\n ab: Unary<A, B>,\n bc: Unary<B, C>,\n cd: Unary<C, D>,\n de: Unary<D, E>,\n ef: Unary<E, F>\n): F\nexport function pipe<A, B, C, D, E, F, G>(\n value: A,\n ab: Unary<A, B>,\n bc: Unary<B, C>,\n cd: Unary<C, D>,\n de: Unary<D, E>,\n ef: Unary<E, F>,\n fg: Unary<F, G>\n): G\nexport function pipe<A, B, C, D, E, F, G, H>(\n value: A,\n ab: Unary<A, B>,\n bc: Unary<B, C>,\n cd: Unary<C, D>,\n de: Unary<D, E>,\n ef: Unary<E, F>,\n fg: Unary<F, G>,\n gh: Unary<G, H>\n): H\nexport function pipe<A, B, C, D, E, F, G, H, I>(\n value: A,\n ab: Unary<A, B>,\n bc: Unary<B, C>,\n cd: Unary<C, D>,\n de: Unary<D, E>,\n ef: Unary<E, F>,\n fg: Unary<F, G>,\n gh: Unary<G, H>,\n hi: Unary<H, I>\n): I\nexport function pipe<A, B, C, D, E, F, G, H, I, J>(\n value: A,\n ab: Unary<A, B>,\n bc: Unary<B, C>,\n cd: Unary<C, D>,\n de: Unary<D, E>,\n ef: Unary<E, F>,\n fg: Unary<F, G>,\n gh: Unary<G, H>,\n hi: Unary<H, I>,\n ij: Unary<I, J>\n): J\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K>(\n value: A,\n ab: Unary<A, B>,\n bc: Unary<B, C>,\n cd: Unary<C, D>,\n de: Unary<D, E>,\n ef: Unary<E, F>,\n fg: Unary<F, G>,\n gh: Unary<G, H>,\n hi: Unary<H, I>,\n ij: Unary<I, J>,\n jk: Unary<J, K>\n): K\nexport function pipe(\n value: PipeRuntimeValue,\n ...operations: ReadonlyArray<PipeRuntimeOperation>\n): PipeRuntimeValue {\n return operations.reduce((current, operation) => operation(current), value)\n}\n","import { TaggedError } from 'better-result'\n\n/** Describes a failure encountered while releasing a Resource. */\nexport class ResourceReleaseFailure extends TaggedError('ResourceReleaseFailure')<{\n readonly resource: string\n readonly cause: unknown\n readonly message: string\n}> {}\n","import { Result, type Result as ResultType, type UnhandledException } from 'better-result'\n\nimport { ResourceReleaseFailure } from './errors'\n\nimport { disposeResource } from '../scope/disposable'\n\nexport { disposeResource }\n\nimport type { AsyncResult, MaybePromise, ReleaseFailureObserver, ReleaseOutcome } from './types'\n\nconst toReleaseFailure = (resource: string, cause: unknown): ResourceReleaseFailure =>\n new ResourceReleaseFailure({\n resource,\n cause,\n message: `Failed to release resource: ${resource}`\n })\n\nexport const runResult = async <T, E>(\n operation: () => AsyncResult<T, E>\n): Promise<ResultType<T, E | UnhandledException>> => {\n const execution = await Result.tryPromise(() => Promise.resolve(operation()))\n\n return execution.andThen((result) => result)\n}\n\nconst normalizeReleaseOutcome = (\n name: string,\n outcome: ReleaseOutcome\n): ResultType<void, ResourceReleaseFailure> => {\n if (outcome === undefined) {\n return Result.ok()\n }\n\n return outcome.mapError((cause) => toReleaseFailure(name, cause))\n}\n\nexport const runRelease = async <R>(\n name: string,\n resource: R,\n release: (resource: R) => MaybePromise<ReleaseOutcome>\n): Promise<ResultType<void, ResourceReleaseFailure>> => {\n const execution = await Result.tryPromise({\n try: () => Promise.resolve(release(resource)),\n catch: (cause) => toReleaseFailure(name, cause)\n })\n\n return execution.andThen((outcome) => normalizeReleaseOutcome(name, outcome))\n}\n\nconst notifyReleaseFailure = async (\n observer: ReleaseFailureObserver | undefined,\n\n failure: ResourceReleaseFailure\n): Promise<void> => {\n if (!observer) {\n return\n }\n\n try {\n await observer(failure)\n } catch {\n /*\n * Diagnostics must never replace\n * the actual operation error.\n */\n }\n}\n\nexport const combineUseAndRelease = async <A, E>(\n used: ResultType<A, E>,\n\n released: ResultType<void, ResourceReleaseFailure>,\n\n onReleaseFailure?: ReleaseFailureObserver\n): Promise<ResultType<A, E | ResourceReleaseFailure>> => {\n if (Result.isError(used)) {\n if (Result.isError(released)) {\n await notifyReleaseFailure(onReleaseFailure, released.error)\n }\n\n return Result.err<A, E | ResourceReleaseFailure>(used.error)\n }\n\n if (Result.isError(released)) {\n await notifyReleaseFailure(onReleaseFailure, released.error)\n\n return Result.err<A, E | ResourceReleaseFailure>(released.error)\n }\n\n return Result.ok<A, E | ResourceReleaseFailure>(used.value)\n}\n","import { Result, type Result as ResultType, type UnhandledException } from 'better-result'\n\nimport { Scope } from '../scope'\n\nimport { ResourceReleaseFailure } from './errors'\n\nimport { combineUseAndRelease, disposeResource, runRelease, runResult } from './internal'\n\nimport type { AcquireUseReleaseOptions } from './types'\n\n/**\n * Acquire a resource, use it, and always attempt release afterward.\n *\n * Acquisition, use, and release may be synchronous or asynchronous Result\n * operations. If both use and release fail, the use error remains primary and\n * `onReleaseFailure` receives the cleanup failure as a diagnostic.\n *\n * When `release` is omitted, `Symbol.asyncDispose` is preferred over\n * `Symbol.dispose`.\n *\n * @example\n * ```ts\n * const result = await Resource.acquireUseRelease({\n * name: 'database connection',\n * acquire: () => connect(),\n * use: (connection) => query(connection),\n * release: (connection) => connection.close()\n * })\n * ```\n */\nconst acquireUseRelease = <R, A, AcquireError, UseError>({\n name,\n acquire,\n use,\n release = disposeResource,\n onReleaseFailure\n}: AcquireUseReleaseOptions<R, A, AcquireError, UseError>): Promise<\n ResultType<A, AcquireError | UseError | UnhandledException | ResourceReleaseFailure>\n> =>\n Result.gen(async function* () {\n const resource = yield* Result.await(runResult(acquire))\n\n const scope = Scope.make()\n\n let released: ResultType<void, ResourceReleaseFailure> = Result.ok()\n\n scope.addFinalizer(async () => {\n released = await runRelease(name, resource, release)\n })\n\n const used = await runResult(() => use(resource))\n\n await scope.close()\n\n return await combineUseAndRelease(used, released, onReleaseFailure)\n })\n\nexport const Resource = {\n /** Acquire, use, and release a resource with deterministic error precedence. */\n acquireUseRelease\n} as const\n"],"mappings":";;;;;;;;;;AA+FA,SAAgB,KACd,OACA,GAAG,YACe;CAClB,OAAO,WAAW,QAAQ,SAAS,cAAc,UAAU,OAAO,GAAG,KAAK;AAC5E;;;;ACjGA,IAA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BAIA,OAAO,IAAI,mBAAmB;CAC5B,MAAM,WAAW,OAAO,OAAO,MAAM,UAAU,OAAO,CAAC;CAEvD,MAAM,QAAQ,MAAM,KAAK;CAEzB,IAAI,WAAqD,OAAO,GAAG;CAEnE,MAAM,aAAa,YAAY;EAC7B,WAAW,MAAM,WAAW,MAAM,UAAU,OAAO;CACrD,CAAC;CAED,MAAM,OAAO,MAAM,gBAAgB,IAAI,QAAQ,CAAC;CAEhD,MAAM,MAAM,MAAM;CAElB,OAAO,MAAM,qBAAqB,MAAM,UAAU,gBAAgB;AACpE,CAAC;AAEH,MAAa,WAAW;;AAEtB,kBACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as LayerGeneratorYieldError, d as ServiceRuntimeNotConfiguredError, f as captureServiceTag, m as validateServiceTag, p as registerServiceTag, r as DuplicateServiceError, s as ServiceTagCollisionError, t as captureLayerRegistrationTag } from "./registration-drnZk0SY.mjs";
|
|
2
|
-
import { h as RuntimeContextNotConfiguredError, i as getRuntimeContext, l as makeRuntimeContext, n as currentRuntimeContext, u as runRuntimeContext } from "./context-
|
|
3
|
-
import {
|
|
2
|
+
import { h as RuntimeContextNotConfiguredError, i as getRuntimeContext, l as makeRuntimeContext, n as currentRuntimeContext, u as runRuntimeContext } from "./context-BphfFUMO.mjs";
|
|
3
|
+
import { n as getDisposeFinalizer, r as ResourceNotDisposableError, s as defaultRuntimeContextStorage } from "./disposable-CP-Q2H3l.mjs";
|
|
4
4
|
//#region src/service/runtime.ts
|
|
5
5
|
/** Provides the resolver context used by Service tokens during execution. */
|
|
6
6
|
var ServiceRuntime = class ServiceRuntime {
|
|
@@ -18,7 +18,7 @@ var ServiceRuntime = class ServiceRuntime {
|
|
|
18
18
|
*/
|
|
19
19
|
static run(resolver, program, storage = defaultRuntimeContextStorage) {
|
|
20
20
|
const current = getRuntimeContext(storage);
|
|
21
|
-
const context = makeRuntimeContext(resolver, current?.scope, current?.resolver === resolver ? current.resolutionPath : [], current?.signal, current?.resolver === resolver ? current : void 0);
|
|
21
|
+
const context = makeRuntimeContext(resolver, current?.scope, current?.resolver === resolver ? current.resolutionPath : [], current?.signal, current?.resolver === resolver ? current : void 0, current?.executionId);
|
|
22
22
|
return runRuntimeContext(storage, context, program);
|
|
23
23
|
}
|
|
24
24
|
/** Return the resolver active in the current execution context. */
|
|
@@ -266,4 +266,4 @@ const normalizeAcquire = (acquire) => () => {
|
|
|
266
266
|
//#endregion
|
|
267
267
|
export { Service as n, ServiceRuntime as r, Layer as t };
|
|
268
268
|
|
|
269
|
-
//# sourceMappingURL=layer-
|
|
269
|
+
//# sourceMappingURL=layer-D16GKxuX.mjs.map
|