better-effect 0.9.3 → 0.9.31
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 +19 -5
- package/dist/hono.d.mts +25 -4
- package/dist/hono.d.mts.map +1 -1
- package/dist/hono.mjs +19 -25
- package/dist/hono.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -216,9 +216,9 @@ app.get(
|
|
|
216
216
|
)
|
|
217
217
|
```
|
|
218
218
|
|
|
219
|
-
Hono validators can
|
|
220
|
-
|
|
221
|
-
|
|
219
|
+
Hono validators can precede the generator or handler callback. Their validated
|
|
220
|
+
`c.req.valid(...)` inputs are combined and inferred without a manual `Input`
|
|
221
|
+
helper:
|
|
222
222
|
|
|
223
223
|
```ts
|
|
224
224
|
import { sValidator } from '@hono/standard-validator'
|
|
@@ -239,9 +239,23 @@ app.post(
|
|
|
239
239
|
)
|
|
240
240
|
```
|
|
241
241
|
|
|
242
|
+
For multiple validators, pass them in order before the callback:
|
|
243
|
+
|
|
244
|
+
```ts
|
|
245
|
+
app.post(
|
|
246
|
+
'/work-orders/:id',
|
|
247
|
+
http.gen(validateParam, validateHeader, validateCreateWorkOrder, async function* (c) {
|
|
248
|
+
const id = c.req.valid('param').id
|
|
249
|
+
const key = c.req.valid('header')['X-Idempotency-Key']
|
|
250
|
+
const input = c.req.valid('json')
|
|
251
|
+
return Result.ok({ id, key, input })
|
|
252
|
+
})
|
|
253
|
+
)
|
|
254
|
+
```
|
|
255
|
+
|
|
242
256
|
The validator middleware runs before the Program and short-circuits with its
|
|
243
|
-
own `Response` when validation fails. `http.handler` accepts the same
|
|
244
|
-
|
|
257
|
+
own `Response` when validation fails. `http.handler` accepts the same ordered
|
|
258
|
+
validator arguments followed by the program factory and options.
|
|
245
259
|
|
|
246
260
|
Install `hono` only when this subpath is used. The main entrypoint does not
|
|
247
261
|
load the framework.
|
package/dist/hono.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ import { E as MissingDependencies, S as LayerInput, w as ProvidedEnvironment, x
|
|
|
3
3
|
import { f as Runtime } from "./index-BsPr7qHf.mjs";
|
|
4
4
|
import { a as CurrentRequest } from "./index-CITM15SE.mjs";
|
|
5
5
|
import { Result } from "better-result";
|
|
6
|
-
import { Context, Env, Handler, Input, MiddlewareHandler } from "hono";
|
|
6
|
+
import { Context, Env, Handler, HonoRequest, Input, MiddlewareHandler } from "hono";
|
|
7
7
|
//#region src/hono/types.d.ts
|
|
8
8
|
type AnyResult = Result<any, any>;
|
|
9
9
|
type AnyProgram = Program<any, any, AnyService>;
|
|
@@ -11,6 +11,23 @@ type HonoContext = Context<any, any, any>;
|
|
|
11
11
|
type ResponseLike = Response | Promise<Response>;
|
|
12
12
|
type AnyHonoMiddleware = MiddlewareHandler<any, any, any, any>;
|
|
13
13
|
type MiddlewareInput<Middleware extends AnyHonoMiddleware> = Middleware extends MiddlewareHandler<any, any, infer InputType, any> ? InputType : Input;
|
|
14
|
+
type MiddlewareInputs<Middlewares extends readonly AnyHonoMiddleware[]> = Middlewares extends readonly [infer Head extends AnyHonoMiddleware, ...infer Tail extends AnyHonoMiddleware[]] ? MiddlewareInput<Head> & MiddlewareInputs<Tail> : Input;
|
|
15
|
+
type ValidatedTarget<InputType extends Input, Target extends 'param' | 'header'> = NonNullable<InputType['out']> extends Record<Target, infer Value> ? Value extends object ? Value : never : never;
|
|
16
|
+
type ValidatedRequest<P extends string, InputType extends Input> = Omit<HonoRequest<P, NonNullable<InputType['out']>>, 'param' | 'header'> & {
|
|
17
|
+
param: [ValidatedTarget<InputType, 'param'>] extends [never] ? HonoRequest<P, NonNullable<InputType['out']>>['param'] : {
|
|
18
|
+
<Key extends keyof ValidatedTarget<InputType, 'param'> & string>(key: Key): ValidatedTarget<InputType, 'param'>[Key];
|
|
19
|
+
(key: string): string | undefined;
|
|
20
|
+
(): ValidatedTarget<InputType, 'param'>;
|
|
21
|
+
};
|
|
22
|
+
header: [ValidatedTarget<InputType, 'header'>] extends [never] ? HonoRequest<P, NonNullable<InputType['out']>>['header'] : {
|
|
23
|
+
<Key extends keyof ValidatedTarget<InputType, 'header'> & string>(name: Key): ValidatedTarget<InputType, 'header'>[Key];
|
|
24
|
+
(name: string): string | undefined;
|
|
25
|
+
(): ValidatedTarget<InputType, 'header'>;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
type HonoEffectContext<E extends Env, P extends string, InputType extends Input> = Omit<Context<E, P, InputType>, 'req'> & {
|
|
29
|
+
readonly req: ValidatedRequest<P, InputType>;
|
|
30
|
+
};
|
|
14
31
|
type MiddlewareEnvironment<Middleware extends AnyHonoMiddleware> = Middleware extends MiddlewareHandler<infer Environment, any, any, any> ? Environment : Env;
|
|
15
32
|
type MiddlewarePath<Middleware extends AnyHonoMiddleware> = Middleware extends MiddlewareHandler<any, infer Path, any, any> ? Path : string;
|
|
16
33
|
type HonoJsonValue = null | boolean | number | string | readonly HonoJsonValue[] | {
|
|
@@ -21,7 +38,7 @@ type RequestProvided<RequestLayer extends LayerInput> = ProvidedEnvironment<Requ
|
|
|
21
38
|
type AvailableServices<Provided extends AnyService, RequestLayer extends LayerInput> = Provided | InstanceType<typeof CurrentRequest> | RequestProvided<RequestLayer>;
|
|
22
39
|
type ProgramMissing<Provided extends AnyService, Program extends AnyProgram> = ExecutionMissing<Provided, Program>;
|
|
23
40
|
type CompleteProgram<Provided extends AnyService, Program extends AnyProgram> = [ProgramMissing<Provided, Program>] extends [never] ? Program : Program & MissingDependencies<ProgramMissing<Provided, Program>>;
|
|
24
|
-
type GeneratorBody<ContextType extends
|
|
41
|
+
type GeneratorBody<ContextType extends object, Yield extends EffectYield, Returned extends AnyResult> = (context: ContextType) => Generator<Yield, Returned, unknown> | AsyncGenerator<Yield, Returned, unknown>;
|
|
25
42
|
type GeneratorChecks<Provided extends AnyService, Yield extends EffectYield, Returned extends AnyResult> = [ProgramMissing<Provided, ProgramFromGenerator<Yield, Returned>>] extends [never] ? unknown : MissingDependencies<ProgramMissing<Provided, ProgramFromGenerator<Yield, Returned>>>;
|
|
26
43
|
type HonoEffectSuccess<A = unknown> = {
|
|
27
44
|
readonly value: A;
|
|
@@ -51,9 +68,13 @@ declare class HonoEffect<Provided extends AnyService = any, Failure = unknown, R
|
|
|
51
68
|
static make<Provided extends AnyService, Failure = unknown, RequestLayer extends LayerInput = DefaultRequestLayer>(runtime: Runtime<Provided>, options?: HonoEffectOptions<Failure, RequestLayer>): HonoEffect<Provided, Failure, RequestLayer>;
|
|
52
69
|
middleware<E extends Env = Env, Path extends string = string>(): MiddlewareHandler<E, Path>;
|
|
53
70
|
handler<E extends Env = Env, Path extends string = string, InputType extends Input = Input, Program extends AnyProgram = AnyProgram>(makeProgram: (context: Context<E, Path, InputType>) => CompleteProgram<AvailableServices<Provided, RequestLayer>, Program>, options?: HonoEffectRouteOptions<EffectSuccess<Program>, Context<E, Path, InputType>>): Handler<E, Path, InputType, Promise<Response>>;
|
|
54
|
-
handler<const
|
|
71
|
+
handler<const FirstMiddleware extends AnyHonoMiddleware, const SecondMiddleware extends AnyHonoMiddleware, E extends Env = MiddlewareEnvironment<FirstMiddleware>, Path extends string = MiddlewarePath<FirstMiddleware>, Program extends AnyProgram = AnyProgram>(firstMiddleware: FirstMiddleware, secondMiddleware: SecondMiddleware, makeProgram: (context: HonoEffectContext<E, Path, MiddlewareInputs<[FirstMiddleware, SecondMiddleware]>>) => CompleteProgram<AvailableServices<Provided, RequestLayer>, Program>, options?: HonoEffectRouteOptions<EffectSuccess<Program>, Context<E, Path, MiddlewareInputs<[FirstMiddleware, SecondMiddleware]>>>): Handler<E, Path, MiddlewareInputs<[FirstMiddleware, SecondMiddleware]>, Promise<Response>>;
|
|
72
|
+
handler<const FirstMiddleware extends AnyHonoMiddleware, const SecondMiddleware extends AnyHonoMiddleware, const ThirdMiddleware extends AnyHonoMiddleware, E extends Env = MiddlewareEnvironment<FirstMiddleware>, Path extends string = MiddlewarePath<FirstMiddleware>, Program extends AnyProgram = AnyProgram>(firstMiddleware: FirstMiddleware, secondMiddleware: SecondMiddleware, thirdMiddleware: ThirdMiddleware, makeProgram: (context: HonoEffectContext<E, Path, MiddlewareInputs<[FirstMiddleware, SecondMiddleware, ThirdMiddleware]>>) => CompleteProgram<AvailableServices<Provided, RequestLayer>, Program>, options?: HonoEffectRouteOptions<EffectSuccess<Program>, Context<E, Path, MiddlewareInputs<[FirstMiddleware, SecondMiddleware, ThirdMiddleware]>>>): Handler<E, Path, MiddlewareInputs<[FirstMiddleware, SecondMiddleware, ThirdMiddleware]>, Promise<Response>>;
|
|
73
|
+
handler<const InputMiddleware extends AnyHonoMiddleware, E extends Env = MiddlewareEnvironment<InputMiddleware>, Path extends string = MiddlewarePath<InputMiddleware>, Program extends AnyProgram = AnyProgram>(inputMiddleware: InputMiddleware, makeProgram: (context: HonoEffectContext<E, Path, MiddlewareInput<InputMiddleware>>) => CompleteProgram<AvailableServices<Provided, RequestLayer>, Program>, options?: HonoEffectRouteOptions<EffectSuccess<Program>, Context<E, Path, MiddlewareInput<InputMiddleware>>>): Handler<E, Path, MiddlewareInput<InputMiddleware>, Promise<Response>>;
|
|
55
74
|
gen<E extends Env = Env, Path extends string = string, InputType extends Input = Input, const Yield extends EffectYield = EffectYield, const Returned extends AnyResult = AnyResult>(body: GeneratorBody<Context<E, Path, InputType>, Yield, Returned> & GeneratorChecks<AvailableServices<Provided, RequestLayer>, Yield, Returned>, options?: HonoEffectRouteOptions<EffectSuccess<ProgramFromGenerator<Yield, Returned>>, Context<E, Path, InputType>>): Handler<E, Path, InputType, Promise<Response>>;
|
|
56
|
-
gen<const
|
|
75
|
+
gen<const FirstMiddleware extends AnyHonoMiddleware, const SecondMiddleware extends AnyHonoMiddleware, E extends Env = MiddlewareEnvironment<FirstMiddleware>, Path extends string = MiddlewarePath<FirstMiddleware>, const Yield extends EffectYield = EffectYield, const Returned extends AnyResult = AnyResult>(firstMiddleware: FirstMiddleware, secondMiddleware: SecondMiddleware, body: GeneratorBody<HonoEffectContext<E, Path, MiddlewareInputs<[FirstMiddleware, SecondMiddleware]>>, Yield, Returned> & GeneratorChecks<AvailableServices<Provided, RequestLayer>, Yield, Returned>, options?: HonoEffectRouteOptions<EffectSuccess<ProgramFromGenerator<Yield, Returned>>, Context<E, Path, MiddlewareInputs<[FirstMiddleware, SecondMiddleware]>>>): Handler<E, Path, MiddlewareInputs<[FirstMiddleware, SecondMiddleware]>, Promise<Response>>;
|
|
76
|
+
gen<const FirstMiddleware extends AnyHonoMiddleware, const SecondMiddleware extends AnyHonoMiddleware, const ThirdMiddleware extends AnyHonoMiddleware, E extends Env = MiddlewareEnvironment<FirstMiddleware>, Path extends string = MiddlewarePath<FirstMiddleware>, const Yield extends EffectYield = EffectYield, const Returned extends AnyResult = AnyResult>(firstMiddleware: FirstMiddleware, secondMiddleware: SecondMiddleware, thirdMiddleware: ThirdMiddleware, body: GeneratorBody<HonoEffectContext<E, Path, MiddlewareInputs<[FirstMiddleware, SecondMiddleware, ThirdMiddleware]>>, Yield, Returned> & GeneratorChecks<AvailableServices<Provided, RequestLayer>, Yield, Returned>, options?: HonoEffectRouteOptions<EffectSuccess<ProgramFromGenerator<Yield, Returned>>, Context<E, Path, MiddlewareInputs<[FirstMiddleware, SecondMiddleware, ThirdMiddleware]>>>): Handler<E, Path, MiddlewareInputs<[FirstMiddleware, SecondMiddleware, ThirdMiddleware]>, Promise<Response>>;
|
|
77
|
+
gen<const InputMiddleware extends AnyHonoMiddleware, E extends Env = MiddlewareEnvironment<InputMiddleware>, Path extends string = MiddlewarePath<InputMiddleware>, const Yield extends EffectYield = EffectYield, const Returned extends AnyResult = AnyResult>(inputMiddleware: InputMiddleware, body: GeneratorBody<HonoEffectContext<E, Path, MiddlewareInput<InputMiddleware>>, Yield, Returned> & GeneratorChecks<AvailableServices<Provided, RequestLayer>, Yield, Returned>, options?: HonoEffectRouteOptions<EffectSuccess<ProgramFromGenerator<Yield, Returned>>, Context<E, Path, MiddlewareInput<InputMiddleware>>>): Handler<E, Path, MiddlewareInput<InputMiddleware>, Promise<Response>>;
|
|
57
78
|
guard<E extends Env = Env, Path extends string = string, InputType extends Input = Input, const Yield extends EffectYield = EffectYield, const Returned extends AnyResult = AnyResult>(body: GeneratorBody<Context<E, Path, InputType>, Yield, Returned> & GeneratorChecks<AvailableServices<Provided, RequestLayer>, Yield, Returned>): MiddlewareHandler<E, Path>;
|
|
58
79
|
private makeHandler;
|
|
59
80
|
private composeInputMiddleware;
|
package/dist/hono.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hono.d.mts","names":[],"sources":["../src/hono/types.ts","../src/hono/hono-effect.ts"],"mappings":";;;;;;;KASY,YAAY;KACZ,aAAa,kBAAsB;KACnC,cAAc;KACd,eAAe,WAAW,QAAQ;KAClC,oBAAoB;KAIpB,gBAAgB,mBAAmB,qBAC7C,mBAAmB,kCAAkC,kBAAkB,YAAY;KAEzE,sBAAsB,mBAAmB,qBACnD,mBAAmB,wBAAwB,8BAA8B,cAAc;KAE7E,eAAe,mBAAmB,qBAC5C,mBAAmB,6BAA6B,kBAAkB;KAExD,4DAKC;YACG,cAAc;;KAElB,sBAAsB,kBAAkB,eAAe;KACvD,gBAAgB,qBAAqB,cAAc,oBAAoB;KACvE,kBAAkB,iBAAiB,YAAY,qBAAqB,cAC5E,WACA,oBAAoB,kBACpB,gBAAgB;KAER,eACV,iBAAiB,YACjB,gBAAgB,cACd,iBAAiB,UAAU;KAEnB,gBAAgB,iBAAiB,YAAY,gBAAgB,eACvE,eAAe,UAAU,4BAEvB,UACA,UAAU,oBAAoB,eAAe,UAAU;KAE/C,cACV,
|
|
1
|
+
{"version":3,"file":"hono.d.mts","names":[],"sources":["../src/hono/types.ts","../src/hono/hono-effect.ts"],"mappings":";;;;;;;KASY,YAAY;KACZ,aAAa,kBAAsB;KACnC,cAAc;KACd,eAAe,WAAW,QAAQ;KAClC,oBAAoB;KAIpB,gBAAgB,mBAAmB,qBAC7C,mBAAmB,kCAAkC,kBAAk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27 @@ var HonoEffect = class HonoEffect {
|
|
|
71
71
|
requestLayer: this.requestLayer
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
|
-
handler(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return
|
|
74
|
+
handler(...args) {
|
|
75
|
+
const last = args.at(-1);
|
|
76
|
+
const hasOptions = args.length > 1 && (last === void 0 || typeof last !== "function");
|
|
77
|
+
const options = hasOptions ? last : {};
|
|
78
|
+
const bodyIndex = hasOptions ? args.length - 2 : args.length - 1;
|
|
79
|
+
const makeProgram = args[bodyIndex];
|
|
80
|
+
let handler = this.makeHandler(makeProgram, options);
|
|
81
|
+
for (let index = bodyIndex - 1; index >= 0; index -= 1) handler = this.composeInputMiddleware(args[index], handler);
|
|
82
|
+
return handler;
|
|
83
83
|
}
|
|
84
|
-
gen(
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
body = second;
|
|
92
|
-
options = third;
|
|
93
|
-
} else {
|
|
94
|
-
body = first;
|
|
95
|
-
options = second;
|
|
96
|
-
}
|
|
97
|
-
const handler = this.makeHandler((context) => {
|
|
84
|
+
gen(...args) {
|
|
85
|
+
const last = args.at(-1);
|
|
86
|
+
const hasOptions = args.length > 1 && (last === void 0 || typeof last !== "function");
|
|
87
|
+
const options = hasOptions ? last : {};
|
|
88
|
+
const bodyIndex = hasOptions ? args.length - 2 : args.length - 1;
|
|
89
|
+
const body = args[bodyIndex];
|
|
90
|
+
let handler = this.makeHandler((context) => {
|
|
98
91
|
return Effect.fn(() => body(context));
|
|
99
|
-
}, options
|
|
100
|
-
|
|
92
|
+
}, options);
|
|
93
|
+
for (let index = bodyIndex - 1; index >= 0; index -= 1) handler = this.composeInputMiddleware(args[index], handler);
|
|
94
|
+
return handler;
|
|
101
95
|
}
|
|
102
96
|
guard(body) {
|
|
103
97
|
return async (context, next) => {
|
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\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 // SAFETY: a custom request Layer extends or intentionally overrides the built-in CurrentRequest provider.\n const layer =\n customLayer === undefined\n ? requestLayer\n : Layer.override(requestLayer, customLayer as never)\n\n // SAFETY: request Layers are supplied by this adapter and execute inside the Runtime's typed boundary.\n await options.runtime.runWith(\n layer as never,\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\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 const message = error instanceof Error ? error.message : String(error)\n\n return context.json({ error: 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 HonoEffectOptions,\n HonoEffectRouteOptions,\n HonoEffectSuccess,\n MiddlewareEnvironment,\n MiddlewareInput,\n MiddlewarePath\n} from './types'\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 ): 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>,\n options?: HonoEffectRouteOptions<EffectSuccess<Program>, Context<E, Path, InputType>>\n ): Handler<E, Path, InputType, Promise<Response>>\n handler<\n const InputMiddleware extends AnyHonoMiddleware,\n E extends Env = MiddlewareEnvironment<InputMiddleware>,\n Path extends string = MiddlewarePath<InputMiddleware>,\n Program extends AnyProgram = AnyProgram\n >(\n inputMiddleware: InputMiddleware,\n makeProgram: (\n context: Context<E, Path, MiddlewareInput<InputMiddleware>>\n ) => CompleteProgram<AvailableServices<Provided, RequestLayer>, Program>,\n options?: HonoEffectRouteOptions<\n EffectSuccess<Program>,\n Context<E, Path, MiddlewareInput<InputMiddleware>>\n >\n ): Handler<E, Path, MiddlewareInput<InputMiddleware>, Promise<Response>>\n handler(\n first: AnyHonoMiddleware | AnyProgramFactory,\n second?: AnyProgramFactory | AnyRouteOptions,\n third?: AnyRouteOptions\n ): Handler<any, any, any, Promise<Response>> {\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- overload dispatch distinguishes middleware from the program factory.\n if (typeof second === 'function') {\n // SAFETY: the function-valued second argument identifies the first argument as the input middleware overload.\n const inputMiddleware = first as AnyHonoMiddleware\n // SAFETY: the function-valued second argument is the program factory overload.\n const makeProgram = second as AnyProgramFactory\n\n return this.composeInputMiddleware(\n inputMiddleware,\n this.makeHandler(makeProgram, third ?? {})\n )\n }\n\n // SAFETY: without a function-valued second argument, the first argument is the program factory overload.\n const makeProgram = first as AnyProgramFactory\n // SAFETY: without a function-valued second argument, the second argument is route options.\n const options = second as AnyRouteOptions | undefined\n\n return this.makeHandler(makeProgram, options ?? {})\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>,\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 InputMiddleware extends AnyHonoMiddleware,\n E extends Env = MiddlewareEnvironment<InputMiddleware>,\n Path extends string = MiddlewarePath<InputMiddleware>,\n const Yield extends EffectYield = EffectYield,\n const Returned extends AnyResult = AnyResult\n >(\n inputMiddleware: InputMiddleware,\n body: GeneratorBody<Context<E, Path, MiddlewareInput<InputMiddleware>>, Yield, Returned> &\n GeneratorChecks<AvailableServices<Provided, RequestLayer>, Yield, Returned>,\n options?: HonoEffectRouteOptions<\n EffectSuccess<ProgramFromGenerator<Yield, Returned>>,\n Context<E, Path, MiddlewareInput<InputMiddleware>>\n >\n ): Handler<E, Path, MiddlewareInput<InputMiddleware>, Promise<Response>>\n gen(\n first: AnyHonoMiddleware | AnyGeneratorBody,\n second?: AnyGeneratorBody | AnyRouteOptions,\n third?: AnyRouteOptions\n ): 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 hasInputMiddleware = typeof second === 'function'\n let inputMiddleware: AnyHonoMiddleware | undefined\n let body: AnyGeneratorBody\n let options: AnyRouteOptions | undefined\n\n if (hasInputMiddleware) {\n // SAFETY: a function-valued second argument identifies the first argument as input middleware.\n inputMiddleware = first as AnyHonoMiddleware\n // SAFETY: a function-valued second argument is the generator body overload.\n body = second as AnyGeneratorBody\n options = third\n } else {\n // SAFETY: without a function-valued second argument, the first argument is the generator body overload.\n body = first as AnyGeneratorBody\n // SAFETY: without a function-valued second argument, the second argument is route options.\n options = second as AnyRouteOptions | undefined\n }\n\n const 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 return inputMiddleware === undefined\n ? handler\n : this.composeInputMiddleware(inputMiddleware, 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>\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 state.failure ??= { cause: result.error }\n // SAFETY: the configured failure policy is the boundary for this guard's Result error channel.\n return await this.onFailure(result.error as Failure, context)\n }\n\n await next()\n }\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 state.failure ??= { cause: result.error }\n // SAFETY: the configured failure policy is the boundary for this Program's Result error channel.\n return await this.onFailure(result.error as Failure, 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\n const middlewareResponse = await inputMiddleware(context, async () => {\n downstreamResponse = await handler(context, next)\n })\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,MAAa,uBAMX,YAC+B;CAE/B,OAAO,iBAAiB,OAAO,SAAS,SAAS;EAC/C,MAAM,MAAM;EAGZ,IAFiB,QAAQ,OAAO,IAAI,GAEzB,MAAM,KAA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c;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 { 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\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 // SAFETY: a custom request Layer extends or intentionally overrides the built-in CurrentRequest provider.\n const layer =\n customLayer === undefined\n ? requestLayer\n : Layer.override(requestLayer, customLayer as never)\n\n // SAFETY: request Layers are supplied by this adapter and execute inside the Runtime's typed boundary.\n await options.runtime.runWith(\n layer as never,\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\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 const message = error instanceof Error ? error.message : String(error)\n\n return context.json({ error: 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 HonoEffectSuccess,\n MiddlewareEnvironment,\n MiddlewareInput,\n MiddlewareInputs,\n MiddlewarePath\n} from './types'\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 ): 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>,\n options?: HonoEffectRouteOptions<EffectSuccess<Program>, Context<E, Path, InputType>>\n ): Handler<E, Path, InputType, Promise<Response>>\n handler<\n const FirstMiddleware extends AnyHonoMiddleware,\n const SecondMiddleware extends AnyHonoMiddleware,\n E extends Env = MiddlewareEnvironment<FirstMiddleware>,\n Path extends string = MiddlewarePath<FirstMiddleware>,\n Program extends AnyProgram = AnyProgram\n >(\n firstMiddleware: FirstMiddleware,\n secondMiddleware: SecondMiddleware,\n makeProgram: (\n context: HonoEffectContext<E, Path, MiddlewareInputs<[FirstMiddleware, SecondMiddleware]>>\n ) => CompleteProgram<AvailableServices<Provided, RequestLayer>, Program>,\n options?: HonoEffectRouteOptions<\n EffectSuccess<Program>,\n Context<E, Path, MiddlewareInputs<[FirstMiddleware, SecondMiddleware]>>\n >\n ): Handler<E, Path, MiddlewareInputs<[FirstMiddleware, SecondMiddleware]>, Promise<Response>>\n handler<\n const FirstMiddleware extends AnyHonoMiddleware,\n const SecondMiddleware extends AnyHonoMiddleware,\n const ThirdMiddleware extends AnyHonoMiddleware,\n E extends Env = MiddlewareEnvironment<FirstMiddleware>,\n Path extends string = MiddlewarePath<FirstMiddleware>,\n Program extends AnyProgram = AnyProgram\n >(\n firstMiddleware: FirstMiddleware,\n secondMiddleware: SecondMiddleware,\n thirdMiddleware: ThirdMiddleware,\n makeProgram: (\n context: HonoEffectContext<\n E,\n Path,\n MiddlewareInputs<[FirstMiddleware, SecondMiddleware, ThirdMiddleware]>\n >\n ) => CompleteProgram<AvailableServices<Provided, RequestLayer>, Program>,\n options?: HonoEffectRouteOptions<\n EffectSuccess<Program>,\n Context<E, Path, MiddlewareInputs<[FirstMiddleware, SecondMiddleware, ThirdMiddleware]>>\n >\n ): Handler<\n E,\n Path,\n MiddlewareInputs<[FirstMiddleware, SecondMiddleware, ThirdMiddleware]>,\n Promise<Response>\n >\n handler<\n const InputMiddleware extends AnyHonoMiddleware,\n E extends Env = MiddlewareEnvironment<InputMiddleware>,\n Path extends string = MiddlewarePath<InputMiddleware>,\n Program extends AnyProgram = AnyProgram\n >(\n inputMiddleware: InputMiddleware,\n makeProgram: (\n context: HonoEffectContext<E, Path, MiddlewareInput<InputMiddleware>>\n ) => CompleteProgram<AvailableServices<Provided, RequestLayer>, Program>,\n options?: HonoEffectRouteOptions<\n EffectSuccess<Program>,\n Context<E, Path, MiddlewareInput<InputMiddleware>>\n >\n ): Handler<E, Path, MiddlewareInput<InputMiddleware>, 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>,\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 FirstMiddleware extends AnyHonoMiddleware,\n const SecondMiddleware extends AnyHonoMiddleware,\n E extends Env = MiddlewareEnvironment<FirstMiddleware>,\n Path extends string = MiddlewarePath<FirstMiddleware>,\n const Yield extends EffectYield = EffectYield,\n const Returned extends AnyResult = AnyResult\n >(\n firstMiddleware: FirstMiddleware,\n secondMiddleware: SecondMiddleware,\n body: GeneratorBody<\n HonoEffectContext<E, Path, MiddlewareInputs<[FirstMiddleware, SecondMiddleware]>>,\n Yield,\n Returned\n > &\n GeneratorChecks<AvailableServices<Provided, RequestLayer>, Yield, Returned>,\n options?: HonoEffectRouteOptions<\n EffectSuccess<ProgramFromGenerator<Yield, Returned>>,\n Context<E, Path, MiddlewareInputs<[FirstMiddleware, SecondMiddleware]>>\n >\n ): Handler<E, Path, MiddlewareInputs<[FirstMiddleware, SecondMiddleware]>, Promise<Response>>\n gen<\n const FirstMiddleware extends AnyHonoMiddleware,\n const SecondMiddleware extends AnyHonoMiddleware,\n const ThirdMiddleware extends AnyHonoMiddleware,\n E extends Env = MiddlewareEnvironment<FirstMiddleware>,\n Path extends string = MiddlewarePath<FirstMiddleware>,\n const Yield extends EffectYield = EffectYield,\n const Returned extends AnyResult = AnyResult\n >(\n firstMiddleware: FirstMiddleware,\n secondMiddleware: SecondMiddleware,\n thirdMiddleware: ThirdMiddleware,\n body: GeneratorBody<\n HonoEffectContext<\n E,\n Path,\n MiddlewareInputs<[FirstMiddleware, SecondMiddleware, ThirdMiddleware]>\n >,\n Yield,\n Returned\n > &\n GeneratorChecks<AvailableServices<Provided, RequestLayer>, Yield, Returned>,\n options?: HonoEffectRouteOptions<\n EffectSuccess<ProgramFromGenerator<Yield, Returned>>,\n Context<E, Path, MiddlewareInputs<[FirstMiddleware, SecondMiddleware, ThirdMiddleware]>>\n >\n ): Handler<\n E,\n Path,\n MiddlewareInputs<[FirstMiddleware, SecondMiddleware, ThirdMiddleware]>,\n Promise<Response>\n >\n gen<\n const InputMiddleware extends AnyHonoMiddleware,\n E extends Env = MiddlewareEnvironment<InputMiddleware>,\n Path extends string = MiddlewarePath<InputMiddleware>,\n const Yield extends EffectYield = EffectYield,\n const Returned extends AnyResult = AnyResult\n >(\n inputMiddleware: InputMiddleware,\n body: GeneratorBody<\n HonoEffectContext<E, Path, MiddlewareInput<InputMiddleware>>,\n Yield,\n Returned\n > &\n GeneratorChecks<AvailableServices<Provided, RequestLayer>, Yield, Returned>,\n options?: HonoEffectRouteOptions<\n EffectSuccess<ProgramFromGenerator<Yield, Returned>>,\n Context<E, Path, MiddlewareInput<InputMiddleware>>\n >\n ): Handler<E, Path, MiddlewareInput<InputMiddleware>, 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>\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 state.failure ??= { cause: result.error }\n // SAFETY: the configured failure policy is the boundary for this guard's Result error channel.\n return await this.onFailure(result.error as Failure, context)\n }\n\n await next()\n }\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 state.failure ??= { cause: result.error }\n // SAFETY: the configured failure policy is the boundary for this Program's Result error channel.\n return await this.onFailure(result.error as Failure, 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\n const middlewareResponse = await inputMiddleware(context, async () => {\n downstreamResponse = await handler(context, next)\n })\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,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,eAAe,OAAO;GAElD,MAAM,QACJ,gBAAgB,KAAA,IACZ,eACA,MAAM,SAAS,cAAc,WAAoB;GAGvD,MAAM,QAAQ,QAA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@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "better-effect",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.31",
|
|
4
4
|
"description": "Effect-inspired application architecture for better-result with typechecked Services and environments, scoped resource lifetimes, and pluggable DI backends.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"better-result",
|