ts-procedures 7.3.0 → 8.0.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 +65 -3
- package/agent_config/claude-code/agents/ts-procedures-architect.md +6 -8
- package/agent_config/claude-code/skills/ts-procedures/SKILL.md +30 -33
- package/agent_config/claude-code/skills/ts-procedures/anti-patterns.md +104 -53
- package/agent_config/claude-code/skills/ts-procedures/api-reference.md +205 -232
- package/agent_config/claude-code/skills/ts-procedures/patterns.md +80 -153
- package/agent_config/claude-code/skills/ts-procedures-review/SKILL.md +1 -1
- package/agent_config/claude-code/skills/ts-procedures-review/checklist.md +4 -5
- package/agent_config/claude-code/skills/ts-procedures-scaffold/SKILL.md +4 -7
- package/agent_config/claude-code/skills/ts-procedures-scaffold/templates/hono.md +223 -0
- package/agent_config/copilot/copilot-instructions.md +34 -48
- package/agent_config/cursor/cursorrules +34 -48
- package/build/client/call.js +4 -1
- package/build/client/call.js.map +1 -1
- package/build/client/call.test.js +23 -0
- package/build/client/call.test.js.map +1 -1
- package/build/client/fetch-adapter.js +3 -1
- package/build/client/fetch-adapter.js.map +1 -1
- package/build/client/fetch-adapter.test.js +11 -1
- package/build/client/fetch-adapter.test.js.map +1 -1
- package/build/client/index.test.js +7 -7
- package/build/client/index.test.js.map +1 -1
- package/build/client/request-builder.d.ts +1 -1
- package/build/client/request-builder.js +2 -2
- package/build/client/request-builder.js.map +1 -1
- package/build/client/stream.js +13 -2
- package/build/client/stream.js.map +1 -1
- package/build/client/stream.test.js +32 -7
- package/build/client/stream.test.js.map +1 -1
- package/build/client/typed-error-dispatch.test.js +8 -92
- package/build/client/typed-error-dispatch.test.js.map +1 -1
- package/build/client/types.d.ts +21 -3
- package/build/codegen/bin/cli.js +0 -0
- package/build/codegen/e2e.test.js +87 -23
- package/build/codegen/e2e.test.js.map +1 -1
- package/build/codegen/emit-errors.integration.test.js +1 -1
- package/build/codegen/emit-errors.integration.test.js.map +1 -1
- package/build/codegen/emit-scope.js +308 -47
- package/build/codegen/emit-scope.js.map +1 -1
- package/build/codegen/emit-scope.test.js +363 -110
- package/build/codegen/emit-scope.test.js.map +1 -1
- package/build/codegen/pipeline.test.js +7 -7
- package/build/codegen/pipeline.test.js.map +1 -1
- package/build/codegen/resolve-envelope.js +1 -1
- package/build/codegen/resolve-envelope.js.map +1 -1
- package/build/codegen/resolve-envelope.test.js +5 -5
- package/build/codegen/resolve-envelope.test.js.map +1 -1
- package/build/codegen/targets/_shared/route-slots.d.ts +8 -3
- package/build/codegen/targets/_shared/route-slots.js +49 -8
- package/build/codegen/targets/_shared/route-slots.js.map +1 -1
- package/build/codegen/targets/_shared/route-slots.test.js +99 -26
- package/build/codegen/targets/_shared/route-slots.test.js.map +1 -1
- package/build/codegen/targets/kotlin/emit-route-kotlin.test.js +88 -17
- package/build/codegen/targets/kotlin/emit-route-kotlin.test.js.map +1 -1
- package/build/codegen/targets/kotlin/emit-scope-kotlin.test.js +9 -6
- package/build/codegen/targets/kotlin/emit-scope-kotlin.test.js.map +1 -1
- package/build/codegen/targets/kotlin/integration.test.js +6 -0
- package/build/codegen/targets/kotlin/integration.test.js.map +1 -1
- package/build/codegen/targets/swift/access-level.test.js +8 -11
- package/build/codegen/targets/swift/access-level.test.js.map +1 -1
- package/build/codegen/targets/swift/emit-route-swift.test.js +91 -20
- package/build/codegen/targets/swift/emit-route-swift.test.js.map +1 -1
- package/build/codegen/targets/swift/emit-scope-swift.test.js +12 -9
- package/build/codegen/targets/swift/emit-scope-swift.test.js.map +1 -1
- package/build/codegen/targets/swift/integration.test.js +6 -0
- package/build/codegen/targets/swift/integration.test.js.map +1 -1
- package/build/create-http-stream.d.ts +58 -0
- package/build/create-http-stream.js +122 -0
- package/build/create-http-stream.js.map +1 -0
- package/build/create-http-stream.test.js +88 -0
- package/build/create-http-stream.test.js.map +1 -0
- package/build/create-http.d.ts +49 -0
- package/build/create-http.js +108 -0
- package/build/create-http.js.map +1 -0
- package/build/create-http.test.js +137 -0
- package/build/create-http.test.js.map +1 -0
- package/build/create-stream.d.ts +35 -0
- package/build/create-stream.js +123 -0
- package/build/create-stream.js.map +1 -0
- package/build/create-stream.test.js +428 -0
- package/build/create-stream.test.js.map +1 -0
- package/build/create.d.ts +28 -0
- package/build/create.js +82 -0
- package/build/create.js.map +1 -0
- package/build/create.test.js +483 -0
- package/build/create.test.js.map +1 -0
- package/build/exports.d.ts +2 -0
- package/build/implementations/http/astro/index.test.js +20 -12
- package/build/implementations/http/astro/index.test.js.map +1 -1
- package/build/implementations/http/doc-registry.js +1 -1
- package/build/implementations/http/doc-registry.js.map +1 -1
- package/build/implementations/http/doc-registry.test.js +36 -5
- package/build/implementations/http/doc-registry.test.js.map +1 -1
- package/build/implementations/http/error-dispatch.d.ts +76 -0
- package/build/implementations/http/error-dispatch.js +77 -0
- package/build/implementations/http/error-dispatch.js.map +1 -0
- package/build/implementations/http/error-dispatch.test.js +254 -0
- package/build/implementations/http/error-dispatch.test.js.map +1 -0
- package/build/implementations/http/error-taxonomy.d.ts +5 -5
- package/build/implementations/http/hono/docs/http-doc.d.ts +6 -0
- package/build/implementations/http/hono/docs/http-doc.js +42 -0
- package/build/implementations/http/hono/docs/http-doc.js.map +1 -0
- package/build/implementations/http/hono/docs/http-stream-doc.d.ts +6 -0
- package/build/implementations/http/hono/docs/http-stream-doc.js +40 -0
- package/build/implementations/http/hono/docs/http-stream-doc.js.map +1 -0
- package/build/implementations/http/hono/docs/rpc-doc.d.ts +6 -0
- package/build/implementations/http/hono/docs/rpc-doc.js +24 -0
- package/build/implementations/http/hono/docs/rpc-doc.js.map +1 -0
- package/build/implementations/http/hono/docs/stream-doc.d.ts +6 -0
- package/build/implementations/http/hono/docs/stream-doc.js +42 -0
- package/build/implementations/http/hono/docs/stream-doc.js.map +1 -0
- package/build/implementations/http/hono/handlers/http-stream.d.ts +10 -0
- package/build/implementations/http/hono/handlers/http-stream.js +123 -0
- package/build/implementations/http/hono/handlers/http-stream.js.map +1 -0
- package/build/implementations/http/hono/handlers/http-stream.test.js +128 -0
- package/build/implementations/http/hono/handlers/http-stream.test.js.map +1 -0
- package/build/implementations/http/hono/handlers/http.d.ts +10 -0
- package/build/implementations/http/hono/handlers/http.js +115 -0
- package/build/implementations/http/hono/handlers/http.js.map +1 -0
- package/build/implementations/http/hono/handlers/http.test.js +118 -0
- package/build/implementations/http/hono/handlers/http.test.js.map +1 -0
- package/build/implementations/http/hono/handlers/rpc.d.ts +11 -0
- package/build/implementations/http/hono/handlers/rpc.js +32 -0
- package/build/implementations/http/hono/handlers/rpc.js.map +1 -0
- package/build/implementations/http/hono/handlers/rpc.test.js +73 -0
- package/build/implementations/http/hono/handlers/rpc.test.js.map +1 -0
- package/build/implementations/http/hono/handlers/stream.d.ts +23 -0
- package/build/implementations/http/hono/handlers/stream.js +147 -0
- package/build/implementations/http/hono/handlers/stream.js.map +1 -0
- package/build/implementations/http/hono/handlers/stream.test.d.ts +1 -0
- package/build/implementations/http/hono/handlers/stream.test.js +177 -0
- package/build/implementations/http/hono/handlers/stream.test.js.map +1 -0
- package/build/implementations/http/hono/index.d.ts +57 -0
- package/build/implementations/http/hono/index.js +149 -0
- package/build/implementations/http/hono/index.js.map +1 -0
- package/build/implementations/http/hono/index.test.d.ts +1 -0
- package/build/implementations/http/hono/index.test.js +274 -0
- package/build/implementations/http/hono/index.test.js.map +1 -0
- package/build/implementations/http/hono/path.d.ts +17 -0
- package/build/implementations/http/hono/path.js +39 -0
- package/build/implementations/http/hono/path.js.map +1 -0
- package/build/implementations/http/hono/path.test.d.ts +1 -0
- package/build/implementations/http/hono/path.test.js +83 -0
- package/build/implementations/http/hono/path.test.js.map +1 -0
- package/build/implementations/http/hono/types.d.ts +51 -0
- package/build/implementations/http/hono/types.js.map +1 -0
- package/build/implementations/http/on-request-error.test.js +6 -96
- package/build/implementations/http/on-request-error.test.js.map +1 -1
- package/build/implementations/http/route-errors.test.js +11 -59
- package/build/implementations/http/route-errors.test.js.map +1 -1
- package/build/implementations/types.d.ts +43 -9
- package/build/index.d.ts +124 -124
- package/build/index.js +10 -221
- package/build/index.js.map +1 -1
- package/build/index.test.js +20 -919
- package/build/index.test.js.map +1 -1
- package/build/migration.test.d.ts +1 -0
- package/build/migration.test.js +34 -0
- package/build/migration.test.js.map +1 -0
- package/build/schema/compute-schema.d.ts +11 -3
- package/build/schema/compute-schema.js +13 -7
- package/build/schema/compute-schema.js.map +1 -1
- package/build/schema/parser.d.ts +11 -3
- package/build/schema/parser.js +49 -9
- package/build/schema/parser.js.map +1 -1
- package/build/stack-utils.js +8 -0
- package/build/stack-utils.js.map +1 -1
- package/build/types.d.ts +142 -0
- package/build/types.js.map +1 -0
- package/docs/astro-adapter.md +5 -5
- package/docs/core.md +15 -17
- package/docs/http-integrations.md +83 -170
- package/docs/streaming.md +3 -60
- package/docs/superpowers/plans/2026-05-07-astro-adapter.md +2 -7
- package/docs/superpowers/plans/2026-05-08-create-http.md +3355 -0
- package/docs/superpowers/plans/2026-05-08-hono-app-builder-convergence.md +3365 -0
- package/docs/superpowers/specs/2026-05-07-astro-adapter-design.md +1 -3
- package/docs/superpowers/specs/2026-05-08-create-http-design.md +409 -0
- package/docs/superpowers/specs/2026-05-08-hono-app-builder-convergence-design.md +411 -0
- package/package.json +4 -22
- package/src/client/call.test.ts +26 -0
- package/src/client/call.ts +4 -1
- package/src/client/fetch-adapter.test.ts +14 -1
- package/src/client/fetch-adapter.ts +3 -1
- package/src/client/index.test.ts +7 -7
- package/src/client/request-builder.ts +2 -2
- package/src/client/stream.test.ts +39 -7
- package/src/client/stream.ts +16 -2
- package/src/client/typed-error-dispatch.test.ts +7 -97
- package/src/client/types.ts +21 -3
- package/src/codegen/__fixtures__/users-envelope.json +119 -38
- package/src/codegen/e2e.test.ts +98 -24
- package/src/codegen/emit-errors.integration.test.ts +1 -1
- package/src/codegen/emit-scope.test.ts +395 -110
- package/src/codegen/emit-scope.ts +350 -55
- package/src/codegen/pipeline.test.ts +7 -7
- package/src/codegen/resolve-envelope.test.ts +5 -5
- package/src/codegen/resolve-envelope.ts +1 -1
- package/src/codegen/targets/_shared/route-slots.test.ts +109 -26
- package/src/codegen/targets/_shared/route-slots.ts +48 -11
- package/src/codegen/targets/kotlin/__fixtures__/users-golden.kt +73 -0
- package/src/codegen/targets/kotlin/emit-route-kotlin.test.ts +100 -17
- package/src/codegen/targets/kotlin/emit-scope-kotlin.test.ts +9 -6
- package/src/codegen/targets/kotlin/integration.test.ts +19 -0
- package/src/codegen/targets/swift/__fixtures__/users-golden.swift +79 -0
- package/src/codegen/targets/swift/access-level.test.ts +8 -11
- package/src/codegen/targets/swift/emit-route-swift.test.ts +103 -20
- package/src/codegen/targets/swift/emit-scope-swift.test.ts +12 -9
- package/src/codegen/targets/swift/integration.test.ts +17 -0
- package/src/create-http-stream.test.ts +97 -0
- package/src/create-http-stream.ts +191 -0
- package/src/create-http.test.ts +163 -0
- package/src/create-http.ts +211 -0
- package/src/create-stream.test.ts +565 -0
- package/src/create-stream.ts +228 -0
- package/src/create.test.ts +658 -0
- package/src/create.ts +172 -0
- package/src/exports.ts +2 -0
- package/src/implementations/http/README.md +135 -95
- package/src/implementations/http/astro/README.md +4 -5
- package/src/implementations/http/astro/index.test.ts +25 -18
- package/src/implementations/http/doc-registry.test.ts +42 -5
- package/src/implementations/http/doc-registry.ts +1 -1
- package/src/implementations/http/error-dispatch.test.ts +283 -0
- package/src/implementations/http/error-dispatch.ts +176 -0
- package/src/implementations/http/error-taxonomy.ts +5 -5
- package/src/implementations/http/hono/docs/http-doc.ts +43 -0
- package/src/implementations/http/hono/docs/http-stream-doc.ts +44 -0
- package/src/implementations/http/hono/docs/rpc-doc.ts +34 -0
- package/src/implementations/http/hono/docs/stream-doc.ts +53 -0
- package/src/implementations/http/hono/handlers/http-stream.test.ts +150 -0
- package/src/implementations/http/hono/handlers/http-stream.ts +152 -0
- package/src/implementations/http/hono/handlers/http.test.ts +130 -0
- package/src/implementations/http/hono/handlers/http.ts +147 -0
- package/src/implementations/http/hono/handlers/rpc.test.ts +81 -0
- package/src/implementations/http/hono/handlers/rpc.ts +54 -0
- package/src/implementations/http/hono/handlers/stream.test.ts +198 -0
- package/src/implementations/http/hono/handlers/stream.ts +208 -0
- package/src/implementations/http/hono/index.test.ts +329 -0
- package/src/implementations/http/hono/index.ts +204 -0
- package/src/implementations/http/hono/path.test.ts +96 -0
- package/src/implementations/http/hono/path.ts +59 -0
- package/src/implementations/http/hono/types.ts +93 -0
- package/src/implementations/http/on-request-error.test.ts +10 -116
- package/src/implementations/http/route-errors.test.ts +11 -77
- package/src/implementations/types.ts +44 -9
- package/src/index.test.ts +22 -1249
- package/src/index.ts +49 -485
- package/src/migration.test.ts +48 -0
- package/src/schema/compute-schema.ts +26 -12
- package/src/schema/parser.ts +62 -12
- package/src/stack-utils.ts +8 -0
- package/src/types.ts +133 -0
- package/agent_config/claude-code/skills/ts-procedures-scaffold/templates/express-rpc.md +0 -137
- package/agent_config/claude-code/skills/ts-procedures-scaffold/templates/hono-api.md +0 -173
- package/agent_config/claude-code/skills/ts-procedures-scaffold/templates/hono-rpc.md +0 -142
- package/agent_config/claude-code/skills/ts-procedures-scaffold/templates/hono-stream.md +0 -147
- package/build/implementations/http/express-rpc/error-taxonomy.test.js +0 -83
- package/build/implementations/http/express-rpc/error-taxonomy.test.js.map +0 -1
- package/build/implementations/http/express-rpc/index.d.ts +0 -125
- package/build/implementations/http/express-rpc/index.js +0 -216
- package/build/implementations/http/express-rpc/index.js.map +0 -1
- package/build/implementations/http/express-rpc/index.test.js +0 -684
- package/build/implementations/http/express-rpc/index.test.js.map +0 -1
- package/build/implementations/http/express-rpc/types.d.ts +0 -11
- package/build/implementations/http/express-rpc/types.js.map +0 -1
- package/build/implementations/http/hono-api/error-taxonomy.test.js +0 -137
- package/build/implementations/http/hono-api/error-taxonomy.test.js.map +0 -1
- package/build/implementations/http/hono-api/index.d.ts +0 -151
- package/build/implementations/http/hono-api/index.js +0 -344
- package/build/implementations/http/hono-api/index.js.map +0 -1
- package/build/implementations/http/hono-api/index.test.js +0 -992
- package/build/implementations/http/hono-api/index.test.js.map +0 -1
- package/build/implementations/http/hono-api/types.d.ts +0 -13
- package/build/implementations/http/hono-api/types.js.map +0 -1
- package/build/implementations/http/hono-rpc/error-taxonomy.test.js +0 -64
- package/build/implementations/http/hono-rpc/error-taxonomy.test.js.map +0 -1
- package/build/implementations/http/hono-rpc/index.d.ts +0 -130
- package/build/implementations/http/hono-rpc/index.js +0 -209
- package/build/implementations/http/hono-rpc/index.js.map +0 -1
- package/build/implementations/http/hono-rpc/index.test.js +0 -828
- package/build/implementations/http/hono-rpc/index.test.js.map +0 -1
- package/build/implementations/http/hono-rpc/types.d.ts +0 -11
- package/build/implementations/http/hono-rpc/types.js +0 -2
- package/build/implementations/http/hono-rpc/types.js.map +0 -1
- package/build/implementations/http/hono-stream/error-taxonomy.test.js +0 -159
- package/build/implementations/http/hono-stream/error-taxonomy.test.js.map +0 -1
- package/build/implementations/http/hono-stream/index.d.ts +0 -171
- package/build/implementations/http/hono-stream/index.js +0 -415
- package/build/implementations/http/hono-stream/index.js.map +0 -1
- package/build/implementations/http/hono-stream/index.test.js +0 -1383
- package/build/implementations/http/hono-stream/index.test.js.map +0 -1
- package/build/implementations/http/hono-stream/types.d.ts +0 -15
- package/build/implementations/http/hono-stream/types.js +0 -2
- package/build/implementations/http/hono-stream/types.js.map +0 -1
- package/src/implementations/http/express-rpc/README.md +0 -280
- package/src/implementations/http/express-rpc/error-taxonomy.test.ts +0 -103
- package/src/implementations/http/express-rpc/index.test.ts +0 -957
- package/src/implementations/http/express-rpc/index.ts +0 -327
- package/src/implementations/http/express-rpc/types.ts +0 -16
- package/src/implementations/http/hono-api/README.md +0 -284
- package/src/implementations/http/hono-api/error-taxonomy.test.ts +0 -179
- package/src/implementations/http/hono-api/index.test.ts +0 -1341
- package/src/implementations/http/hono-api/index.ts +0 -519
- package/src/implementations/http/hono-api/types.ts +0 -16
- package/src/implementations/http/hono-rpc/README.md +0 -357
- package/src/implementations/http/hono-rpc/error-taxonomy.test.ts +0 -82
- package/src/implementations/http/hono-rpc/index.test.ts +0 -1107
- package/src/implementations/http/hono-rpc/index.ts +0 -320
- package/src/implementations/http/hono-rpc/types.ts +0 -16
- package/src/implementations/http/hono-stream/README.md +0 -559
- package/src/implementations/http/hono-stream/error-taxonomy.test.ts +0 -178
- package/src/implementations/http/hono-stream/index.test.ts +0 -1804
- package/src/implementations/http/hono-stream/index.ts +0 -622
- package/src/implementations/http/hono-stream/types.ts +0 -20
- /package/build/{implementations/http/express-rpc/error-taxonomy.test.d.ts → create-http-stream.test.d.ts} +0 -0
- /package/build/{implementations/http/express-rpc/index.test.d.ts → create-http.test.d.ts} +0 -0
- /package/build/{implementations/http/hono-api/error-taxonomy.test.d.ts → create-stream.test.d.ts} +0 -0
- /package/build/{implementations/http/hono-api/index.test.d.ts → create.test.d.ts} +0 -0
- /package/build/implementations/http/{hono-rpc/error-taxonomy.test.d.ts → error-dispatch.test.d.ts} +0 -0
- /package/build/implementations/http/{hono-rpc/index.test.d.ts → hono/handlers/http-stream.test.d.ts} +0 -0
- /package/build/implementations/http/{hono-stream/error-taxonomy.test.d.ts → hono/handlers/http.test.d.ts} +0 -0
- /package/build/implementations/http/{hono-stream/index.test.d.ts → hono/handlers/rpc.test.d.ts} +0 -0
- /package/build/implementations/http/{express-rpc → hono}/types.js +0 -0
- /package/build/{implementations/http/hono-api/types.js → types.js} +0 -0
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { describe, expect, test, vi } from 'vitest';
|
|
2
|
+
import { Hono } from 'hono';
|
|
3
|
+
import { Type } from 'typebox';
|
|
4
|
+
import { Procedures } from '../../../index.js';
|
|
5
|
+
import { HonoAppBuilder } from './index.js';
|
|
6
|
+
import { defineErrorTaxonomy } from '../error-taxonomy.js';
|
|
7
|
+
import { DocRegistry } from '../doc-registry.js';
|
|
8
|
+
describe('HonoAppBuilder — public surface', () => {
|
|
9
|
+
test('constructor with no args', () => {
|
|
10
|
+
const b = new HonoAppBuilder();
|
|
11
|
+
expect(b.app).toBeInstanceOf(Hono);
|
|
12
|
+
expect(b.docs).toEqual([]);
|
|
13
|
+
expect(b.skippedProcedures).toEqual([]);
|
|
14
|
+
});
|
|
15
|
+
test('constructor accepts existing Hono app', () => {
|
|
16
|
+
const custom = new Hono();
|
|
17
|
+
const b = new HonoAppBuilder({ app: custom });
|
|
18
|
+
expect(b.app).toBe(custom);
|
|
19
|
+
});
|
|
20
|
+
test('register is chainable', () => {
|
|
21
|
+
const b = new HonoAppBuilder();
|
|
22
|
+
const P = Procedures();
|
|
23
|
+
const result = b.register(P, () => ({}));
|
|
24
|
+
expect(result).toBe(b);
|
|
25
|
+
});
|
|
26
|
+
test('docs is lazily computed before build()', () => {
|
|
27
|
+
const b = new HonoAppBuilder();
|
|
28
|
+
const P = Procedures();
|
|
29
|
+
P.Create('A', { scope: 's', version: 1 }, async () => ({}));
|
|
30
|
+
b.register(P, () => ({}));
|
|
31
|
+
const docs1 = b.docs;
|
|
32
|
+
expect(docs1).toHaveLength(1);
|
|
33
|
+
expect(docs1[0].kind).toBe('rpc');
|
|
34
|
+
// Calling docs again returns the same cached array reference
|
|
35
|
+
expect(b.docs).toBe(docs1);
|
|
36
|
+
});
|
|
37
|
+
test('docs reads after build() return the same content', () => {
|
|
38
|
+
const b = new HonoAppBuilder();
|
|
39
|
+
const P = Procedures();
|
|
40
|
+
P.Create('A', { scope: 's', version: 1 }, async () => ({}));
|
|
41
|
+
b.register(P, () => ({}));
|
|
42
|
+
b.build();
|
|
43
|
+
expect(b.docs).toHaveLength(1);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
describe('HonoAppBuilder — mixed-kind dispatch', () => {
|
|
47
|
+
test('one factory with all four kinds mounts each at the correct path', async () => {
|
|
48
|
+
const P = Procedures();
|
|
49
|
+
P.Create('Echo', { scope: 'rpc', version: 1 }, async (_ctx, p) => p);
|
|
50
|
+
P.CreateStream('Tail', { scope: 'rpc', version: 1 }, async function* () { yield 1; });
|
|
51
|
+
P.CreateHttp('GetUser', {
|
|
52
|
+
path: '/users/:id',
|
|
53
|
+
method: 'get',
|
|
54
|
+
schema: {
|
|
55
|
+
req: { pathParams: Type.Object({ id: Type.String() }) },
|
|
56
|
+
res: { body: Type.Object({ id: Type.String() }) },
|
|
57
|
+
},
|
|
58
|
+
}, async () => ({ id: '1' }));
|
|
59
|
+
P.CreateHttpStream('Watch', {
|
|
60
|
+
path: '/watch', method: 'get',
|
|
61
|
+
schema: { yield: Type.String() },
|
|
62
|
+
}, (async function* () { yield 'tick'; }));
|
|
63
|
+
const app = new HonoAppBuilder()
|
|
64
|
+
.register(P, () => ({ uid: 'u1' }))
|
|
65
|
+
.build();
|
|
66
|
+
const rpc = await app.request('/rpc/echo/1', { method: 'POST', body: '{}', headers: { 'Content-Type': 'application/json' } });
|
|
67
|
+
expect(rpc.status).toBe(200);
|
|
68
|
+
const stream = await app.request('/rpc/tail/1', { method: 'POST', body: '{}', headers: { 'Content-Type': 'application/json' } });
|
|
69
|
+
expect(stream.status).toBe(200);
|
|
70
|
+
await stream.text();
|
|
71
|
+
const http = await app.request('/users/1');
|
|
72
|
+
expect(http.status).toBe(200);
|
|
73
|
+
const httpStream = await app.request('/watch');
|
|
74
|
+
expect(httpStream.status).toBe(200);
|
|
75
|
+
await httpStream.text();
|
|
76
|
+
});
|
|
77
|
+
test('toDocEnvelope produces same shape as DocRegistry.toJSON', () => {
|
|
78
|
+
const P = Procedures();
|
|
79
|
+
P.Create('Echo', { scope: 'e', version: 1 }, async () => ({}));
|
|
80
|
+
const errors = defineErrorTaxonomy({});
|
|
81
|
+
const builder = new HonoAppBuilder({ pathPrefix: '/api', errors });
|
|
82
|
+
builder.register(P, () => ({}));
|
|
83
|
+
builder.build();
|
|
84
|
+
const builderEnvelope = builder.toDocEnvelope({ basePath: '/api', errors });
|
|
85
|
+
const registryEnvelope = new DocRegistry({ basePath: '/api', errors }).from(builder).toJSON();
|
|
86
|
+
expect(builderEnvelope.basePath).toBe(registryEnvelope.basePath);
|
|
87
|
+
expect(builderEnvelope.routes).toEqual(registryEnvelope.routes);
|
|
88
|
+
expect(builderEnvelope.errors.map(e => e.name).sort()).toEqual(registryEnvelope.errors.map(e => e.name).sort());
|
|
89
|
+
});
|
|
90
|
+
test('toDocEnvelope filter and transform options work', () => {
|
|
91
|
+
const P = Procedures();
|
|
92
|
+
P.Create('A', { scope: 's', version: 1 }, async () => ({}));
|
|
93
|
+
P.Create('B', { scope: 's', version: 1 }, async () => ({}));
|
|
94
|
+
const builder = new HonoAppBuilder().register(P, () => ({}));
|
|
95
|
+
const onlyA = builder.toDocEnvelope({ filter: r => r.name === 'A' });
|
|
96
|
+
expect(onlyA.routes).toHaveLength(1);
|
|
97
|
+
expect(onlyA.routes[0].name).toBe('A');
|
|
98
|
+
const tagged = builder.toDocEnvelope({
|
|
99
|
+
transform: env => ({ ...env, tagged: true }),
|
|
100
|
+
});
|
|
101
|
+
expect(tagged.tagged).toBe(true);
|
|
102
|
+
});
|
|
103
|
+
test('makeRoutePath static is exposed', () => {
|
|
104
|
+
const P = Procedures();
|
|
105
|
+
P.Create('GetUser', { scope: 'users', version: 1 }, async () => ({}));
|
|
106
|
+
const proc = P.getProcedure('GetUser');
|
|
107
|
+
expect(HonoAppBuilder.makeRoutePath({ procedure: proc })).toBe('/users/get-user/1');
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
describe('HonoAppBuilder — factoryContext variants', () => {
|
|
111
|
+
test('factoryContext as a static object is forwarded into ctx', async () => {
|
|
112
|
+
const P = Procedures();
|
|
113
|
+
P.Create('GetRequestId', { scope: 'get-request-id', version: 1 }, async (ctx) => ({
|
|
114
|
+
id: ctx.requestId,
|
|
115
|
+
}));
|
|
116
|
+
const app = new HonoAppBuilder()
|
|
117
|
+
.register(P, { requestId: 'req-123' })
|
|
118
|
+
.build();
|
|
119
|
+
const res = await app.request('/get-request-id/get-request-id/1', {
|
|
120
|
+
method: 'POST',
|
|
121
|
+
headers: { 'Content-Type': 'application/json' },
|
|
122
|
+
body: JSON.stringify({}),
|
|
123
|
+
});
|
|
124
|
+
expect(await res.json()).toEqual({ id: 'req-123' });
|
|
125
|
+
});
|
|
126
|
+
test('factoryContext as an async function is awaited and result reaches handler', async () => {
|
|
127
|
+
const factoryContext = vi.fn(async () => ({ requestId: 'req-456' }));
|
|
128
|
+
const P = Procedures();
|
|
129
|
+
P.Create('GetRequestId', { scope: 'get-request-id', version: 1 }, async (ctx) => ({
|
|
130
|
+
id: ctx.requestId,
|
|
131
|
+
}));
|
|
132
|
+
const app = new HonoAppBuilder().register(P, factoryContext).build();
|
|
133
|
+
const res = await app.request('/get-request-id/get-request-id/1', {
|
|
134
|
+
method: 'POST',
|
|
135
|
+
headers: { 'Content-Type': 'application/json' },
|
|
136
|
+
body: JSON.stringify({}),
|
|
137
|
+
});
|
|
138
|
+
expect(factoryContext).toHaveBeenCalledTimes(1);
|
|
139
|
+
expect(await res.json()).toEqual({ id: 'req-456' });
|
|
140
|
+
});
|
|
141
|
+
test('factoryContext rejection flows through dispatchPreStreamError → 500', async () => {
|
|
142
|
+
const P = Procedures();
|
|
143
|
+
P.Create('GetRequestId', { scope: 'get-request-id', version: 1 }, async (ctx) => ({
|
|
144
|
+
id: ctx.requestId,
|
|
145
|
+
}));
|
|
146
|
+
const app = new HonoAppBuilder()
|
|
147
|
+
.register(P, async () => {
|
|
148
|
+
throw new Error('context-load-failed');
|
|
149
|
+
})
|
|
150
|
+
.build();
|
|
151
|
+
const res = await app.request('/get-request-id/get-request-id/1', {
|
|
152
|
+
method: 'POST',
|
|
153
|
+
headers: { 'Content-Type': 'application/json' },
|
|
154
|
+
body: JSON.stringify({}),
|
|
155
|
+
});
|
|
156
|
+
expect(res.status).toBe(500);
|
|
157
|
+
const body = await res.json();
|
|
158
|
+
expect(body.error).toContain('context-load-failed');
|
|
159
|
+
});
|
|
160
|
+
test('factoryContext function receives Hono Context with req.header access', async () => {
|
|
161
|
+
const factoryContext = vi.fn((c) => ({
|
|
162
|
+
authHeader: c.req.header('authorization'),
|
|
163
|
+
}));
|
|
164
|
+
const P = Procedures();
|
|
165
|
+
P.Create('GetAuth', { scope: 'get-auth', version: 1 }, async (ctx) => ({
|
|
166
|
+
auth: ctx.authHeader,
|
|
167
|
+
}));
|
|
168
|
+
const app = new HonoAppBuilder().register(P, factoryContext).build();
|
|
169
|
+
const res = await app.request('/get-auth/get-auth/1', {
|
|
170
|
+
method: 'POST',
|
|
171
|
+
headers: {
|
|
172
|
+
'Content-Type': 'application/json',
|
|
173
|
+
Authorization: 'Bearer token123',
|
|
174
|
+
},
|
|
175
|
+
body: JSON.stringify({}),
|
|
176
|
+
});
|
|
177
|
+
expect(factoryContext).toHaveBeenCalledTimes(1);
|
|
178
|
+
expect(factoryContext.mock.calls[0][0]).toHaveProperty('req');
|
|
179
|
+
expect(await res.json()).toEqual({ auth: 'Bearer token123' });
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
describe('HonoAppBuilder — extendProcedureDoc discriminated union per kind', () => {
|
|
183
|
+
test('rpc: base.kind === "rpc" and returned object is merged into doc', () => {
|
|
184
|
+
const extend = vi.fn(({ base }) => ({
|
|
185
|
+
summary: `RPC: ${base.kind}`,
|
|
186
|
+
tags: ['rpc'],
|
|
187
|
+
}));
|
|
188
|
+
const P = Procedures();
|
|
189
|
+
P.Create('GetUser', { scope: 'users', version: 1 }, async () => ({}));
|
|
190
|
+
const builder = new HonoAppBuilder().register(P, () => ({}), { extendProcedureDoc: extend });
|
|
191
|
+
builder.build();
|
|
192
|
+
expect(extend).toHaveBeenCalledTimes(1);
|
|
193
|
+
expect(extend.mock.calls[0][0].base.kind).toBe('rpc');
|
|
194
|
+
const doc = builder.docs[0];
|
|
195
|
+
expect(doc.summary).toBe('RPC: rpc');
|
|
196
|
+
expect(doc.tags).toEqual(['rpc']);
|
|
197
|
+
});
|
|
198
|
+
test('api (http): base.kind === "api" and returned object is merged into doc', () => {
|
|
199
|
+
const extend = vi.fn(({ base }) => ({
|
|
200
|
+
summary: `API: ${base.kind}`,
|
|
201
|
+
tags: ['api'],
|
|
202
|
+
}));
|
|
203
|
+
const P = Procedures();
|
|
204
|
+
P.CreateHttp('GetUser', {
|
|
205
|
+
path: '/users/:id',
|
|
206
|
+
method: 'get',
|
|
207
|
+
schema: {
|
|
208
|
+
req: { pathParams: Type.Object({ id: Type.String() }) },
|
|
209
|
+
res: { body: Type.Object({ id: Type.String() }) },
|
|
210
|
+
},
|
|
211
|
+
}, async () => ({ id: '1' }));
|
|
212
|
+
const builder = new HonoAppBuilder().register(P, () => ({}), { extendProcedureDoc: extend });
|
|
213
|
+
builder.build();
|
|
214
|
+
expect(extend).toHaveBeenCalledTimes(1);
|
|
215
|
+
expect(extend.mock.calls[0][0].base.kind).toBe('api');
|
|
216
|
+
const doc = builder.docs[0];
|
|
217
|
+
expect(doc.summary).toBe('API: api');
|
|
218
|
+
expect(doc.tags).toEqual(['api']);
|
|
219
|
+
});
|
|
220
|
+
test('rpc-stream: base.kind === "stream" and returned object is merged into doc', () => {
|
|
221
|
+
const extend = vi.fn(({ base }) => ({
|
|
222
|
+
summary: `Stream: ${base.kind}`,
|
|
223
|
+
tags: ['stream'],
|
|
224
|
+
}));
|
|
225
|
+
const P = Procedures();
|
|
226
|
+
P.CreateStream('Tail', { scope: 'rpc', version: 1 }, async function* () {
|
|
227
|
+
yield 1;
|
|
228
|
+
});
|
|
229
|
+
const builder = new HonoAppBuilder().register(P, () => ({}), { extendProcedureDoc: extend });
|
|
230
|
+
builder.build();
|
|
231
|
+
expect(extend).toHaveBeenCalledTimes(1);
|
|
232
|
+
expect(extend.mock.calls[0][0].base.kind).toBe('stream');
|
|
233
|
+
const doc = builder.docs[0];
|
|
234
|
+
expect(doc.summary).toBe('Stream: stream');
|
|
235
|
+
expect(doc.tags).toEqual(['stream']);
|
|
236
|
+
});
|
|
237
|
+
test('http-stream: base.kind === "http-stream" and returned object is merged into doc', () => {
|
|
238
|
+
const extend = vi.fn(({ base }) => ({
|
|
239
|
+
summary: `HTTP-Stream: ${base.kind}`,
|
|
240
|
+
tags: ['http-stream'],
|
|
241
|
+
}));
|
|
242
|
+
const P = Procedures();
|
|
243
|
+
P.CreateHttpStream('Watch', { path: '/watch', method: 'get', schema: { yield: Type.String() } }, (async function* () {
|
|
244
|
+
yield 'tick';
|
|
245
|
+
}));
|
|
246
|
+
const builder = new HonoAppBuilder().register(P, () => ({}), { extendProcedureDoc: extend });
|
|
247
|
+
builder.build();
|
|
248
|
+
expect(extend).toHaveBeenCalledTimes(1);
|
|
249
|
+
expect(extend.mock.calls[0][0].base.kind).toBe('http-stream');
|
|
250
|
+
const doc = builder.docs[0];
|
|
251
|
+
expect(doc.summary).toBe('HTTP-Stream: http-stream');
|
|
252
|
+
expect(doc.tags).toEqual(['http-stream']);
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
describe('HonoAppBuilder — per-factory streamMode override', () => {
|
|
256
|
+
test('register options.streamMode overrides stream.defaultStreamMode', async () => {
|
|
257
|
+
const P = Procedures();
|
|
258
|
+
P.CreateStream('Test', { scope: 'test', version: 1 }, async function* () {
|
|
259
|
+
yield { ok: true };
|
|
260
|
+
});
|
|
261
|
+
const app = new HonoAppBuilder({ stream: { defaultStreamMode: 'sse' } })
|
|
262
|
+
.register(P, () => ({}), { streamMode: 'text' })
|
|
263
|
+
.build();
|
|
264
|
+
const res = await app.request('/test/test/1', {
|
|
265
|
+
method: 'POST',
|
|
266
|
+
headers: { 'Content-Type': 'application/json' },
|
|
267
|
+
body: '{}',
|
|
268
|
+
});
|
|
269
|
+
expect(res.headers.get('content-type')).toContain('text/plain');
|
|
270
|
+
// Drain the response so the stream lifecycle completes cleanly.
|
|
271
|
+
await res.text();
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
//# sourceMappingURL=index.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../../../src/implementations/http/hono/index.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E,CAAC,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;aAC/C,KAAK,EAAE,CAAA;QAEV,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,cAAc,EAAE;YAC5C,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;YAC/C,IAAI,EAAE,IAAI;SACX,CAAC,CAAA;QACF,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,YAAY,CAAC,CAAA;QAC/D,gEAAgE;QAChE,MAAM,GAAG,CAAC,IAAI,EAAE,CAAA;IAClB,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { TProcedureRegistration, TStreamProcedureRegistration, THttpProcedureRegistration, THttpStreamProcedureRegistration } from '../../../types.js';
|
|
2
|
+
export type AnyProcedureRegistration = TProcedureRegistration | TStreamProcedureRegistration | THttpProcedureRegistration<any> | THttpStreamProcedureRegistration<any>;
|
|
3
|
+
/**
|
|
4
|
+
* Resolves the full route path for any procedure kind.
|
|
5
|
+
*
|
|
6
|
+
* - `rpc` / `rpc-stream`: `{prefix}/{kebab(scope)}/{kebab(name)}/{version}`
|
|
7
|
+
* - `http` / `http-stream`: `{prefix}{config.path}` (path-as-given, prefix normalized)
|
|
8
|
+
*/
|
|
9
|
+
export declare function makeRoutePath({ procedure, prefix, }: {
|
|
10
|
+
procedure: AnyProcedureRegistration;
|
|
11
|
+
prefix?: string;
|
|
12
|
+
}): string;
|
|
13
|
+
/**
|
|
14
|
+
* Combines a developer-supplied path with an optional prefix. Both are
|
|
15
|
+
* normalized to begin with a single `/`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function resolveFullPath(procedurePath: string, prefix?: string): string;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { kebabCase } from 'es-toolkit/string';
|
|
2
|
+
import { castArray } from 'es-toolkit/compat';
|
|
3
|
+
function normalizePrefix(prefix) {
|
|
4
|
+
if (!prefix)
|
|
5
|
+
return '';
|
|
6
|
+
return prefix.startsWith('/') ? prefix : `/${prefix}`;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Resolves the full route path for any procedure kind.
|
|
10
|
+
*
|
|
11
|
+
* - `rpc` / `rpc-stream`: `{prefix}/{kebab(scope)}/{kebab(name)}/{version}`
|
|
12
|
+
* - `http` / `http-stream`: `{prefix}{config.path}` (path-as-given, prefix normalized)
|
|
13
|
+
*/
|
|
14
|
+
export function makeRoutePath({ procedure, prefix, }) {
|
|
15
|
+
const normalizedPrefix = normalizePrefix(prefix);
|
|
16
|
+
switch (procedure.kind) {
|
|
17
|
+
case 'rpc':
|
|
18
|
+
case 'rpc-stream': {
|
|
19
|
+
const cfg = procedure.config;
|
|
20
|
+
const scopeSegments = castArray(cfg.scope).map(kebabCase).join('/');
|
|
21
|
+
return `${normalizedPrefix}/${scopeSegments}/${kebabCase(procedure.name)}/${String(cfg.version).trim()}`;
|
|
22
|
+
}
|
|
23
|
+
case 'http':
|
|
24
|
+
case 'http-stream': {
|
|
25
|
+
const cfg = procedure.config;
|
|
26
|
+
return resolveFullPath(cfg.path, prefix);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Combines a developer-supplied path with an optional prefix. Both are
|
|
32
|
+
* normalized to begin with a single `/`.
|
|
33
|
+
*/
|
|
34
|
+
export function resolveFullPath(procedurePath, prefix) {
|
|
35
|
+
const normalizedPrefix = normalizePrefix(prefix);
|
|
36
|
+
const normalizedPath = procedurePath.startsWith('/') ? procedurePath : `/${procedurePath}`;
|
|
37
|
+
return `${normalizedPrefix}${normalizedPath}`;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.js","sourceRoot":"","sources":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,MAAM,CAAC,CAAA;IAChD,MAAM,cAAc,GAAG,aAAa,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,aAAa,EAAE,CAAA;IAC1F,OAAO,GAAG,gBAAgB,GAAG,cAAc,EAAE,CAAA;AAC/C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest';
|
|
2
|
+
import { makeRoutePath, resolveFullPath } from './path.js';
|
|
3
|
+
describe('makeRoutePath', () => {
|
|
4
|
+
test('rpc: scope/name/version with kebab-case', () => {
|
|
5
|
+
const proc = {
|
|
6
|
+
name: 'GetUser',
|
|
7
|
+
kind: 'rpc',
|
|
8
|
+
config: { scope: 'users', version: 1 },
|
|
9
|
+
handler: async () => undefined,
|
|
10
|
+
};
|
|
11
|
+
expect(makeRoutePath({ procedure: proc })).toBe('/users/get-user/1');
|
|
12
|
+
});
|
|
13
|
+
test('rpc: array scope joined with /', () => {
|
|
14
|
+
const proc = {
|
|
15
|
+
name: 'List',
|
|
16
|
+
kind: 'rpc',
|
|
17
|
+
config: { scope: ['UserModule', 'admin'], version: 2 },
|
|
18
|
+
handler: async () => undefined,
|
|
19
|
+
};
|
|
20
|
+
expect(makeRoutePath({ procedure: proc })).toBe('/user-module/admin/list/2');
|
|
21
|
+
});
|
|
22
|
+
test('rpc: pathPrefix is normalized (leading slash inserted)', () => {
|
|
23
|
+
const proc = {
|
|
24
|
+
name: 'Echo',
|
|
25
|
+
kind: 'rpc',
|
|
26
|
+
config: { scope: 'echo', version: 1 },
|
|
27
|
+
handler: async () => undefined,
|
|
28
|
+
};
|
|
29
|
+
expect(makeRoutePath({ procedure: proc, prefix: 'api/v1' })).toBe('/api/v1/echo/echo/1');
|
|
30
|
+
});
|
|
31
|
+
test('rpc-stream: same shape as rpc', () => {
|
|
32
|
+
const proc = {
|
|
33
|
+
name: 'Tail',
|
|
34
|
+
kind: 'rpc-stream',
|
|
35
|
+
isStream: true,
|
|
36
|
+
config: { scope: 'logs', version: 1 },
|
|
37
|
+
handler: async function* () { },
|
|
38
|
+
};
|
|
39
|
+
expect(makeRoutePath({ procedure: proc, prefix: '/api' })).toBe('/api/logs/tail/1');
|
|
40
|
+
});
|
|
41
|
+
test('http: prepends prefix to config.path', () => {
|
|
42
|
+
const proc = {
|
|
43
|
+
name: 'GetUser',
|
|
44
|
+
kind: 'http',
|
|
45
|
+
config: { path: '/users/:id', method: 'get' },
|
|
46
|
+
handler: async () => undefined,
|
|
47
|
+
};
|
|
48
|
+
expect(makeRoutePath({ procedure: proc, prefix: '/api/v1' })).toBe('/api/v1/users/:id');
|
|
49
|
+
});
|
|
50
|
+
test('http: leading slash on path is preserved (not duplicated)', () => {
|
|
51
|
+
const proc = {
|
|
52
|
+
name: 'Get',
|
|
53
|
+
kind: 'http',
|
|
54
|
+
config: { path: 'users', method: 'get' },
|
|
55
|
+
handler: async () => undefined,
|
|
56
|
+
};
|
|
57
|
+
expect(makeRoutePath({ procedure: proc, prefix: '/api' })).toBe('/api/users');
|
|
58
|
+
});
|
|
59
|
+
test('http-stream: same shape as http', () => {
|
|
60
|
+
const proc = {
|
|
61
|
+
name: 'TailLogs',
|
|
62
|
+
kind: 'http-stream',
|
|
63
|
+
config: { path: '/logs/tail', method: 'get' },
|
|
64
|
+
handler: async () => ({ stream: (async function* () { })(), initialHeaders: undefined }),
|
|
65
|
+
};
|
|
66
|
+
expect(makeRoutePath({ procedure: proc })).toBe('/logs/tail');
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
describe('resolveFullPath', () => {
|
|
70
|
+
test('combines prefix and path', () => {
|
|
71
|
+
expect(resolveFullPath('/users', '/api/v1')).toBe('/api/v1/users');
|
|
72
|
+
});
|
|
73
|
+
test('normalizes prefix without leading slash', () => {
|
|
74
|
+
expect(resolveFullPath('/users', 'api')).toBe('/api/users');
|
|
75
|
+
});
|
|
76
|
+
test('normalizes path without leading slash', () => {
|
|
77
|
+
expect(resolveFullPath('users', '/api')).toBe('/api/users');
|
|
78
|
+
});
|
|
79
|
+
test('no prefix', () => {
|
|
80
|
+
expect(resolveFullPath('/users')).toBe('/users');
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
//# sourceMappingURL=path.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.test.js","sourceRoot":"","sources":["../../../../src/implementations/http/hono/path.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAQ1D,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,IAAI,CAAC,yCAAyC,EAAE,GAAG,EAAE;QACnD,MAAM,IAAI,GAAG;YACX,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,KAAK;YACX,MAAM,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE;YACtC,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,SAAS;SACM,CAAA;QACtC,MAAM,CAAC,aAAa,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAA;IACtE,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,gCAAgC,EAAE,GAAG,EAAE;QAC1C,MAAM,IAAI,GAAG;YACX,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,KAAK;YACX,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,YAAY,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE;YACtD,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,SAAS;SACM,CAAA;QACtC,MAAM,CAAC,aAAa,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CA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EAAE,GAAG,EAAE;QACnD,MAAM,CAAC,eAAe,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;IAC7D,CAAC,CAAC,CAAA;IACF,IAAI,CAAC,uCAAuC,EAAE,GAAG,EAAE;QACjD,MAAM,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;IAC7D,CAAC,CAAC,CAAA;IACF,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE;QACrB,MAAM,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAClD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Context, Hono } from 'hono';
|
|
2
|
+
import type { ErrorTaxonomy, UnknownErrorConfig } from '../error-taxonomy.js';
|
|
3
|
+
import type { AnyProcedureRegistration, OnRequestErrorObserver, OnMidStreamError, PreStreamOnError } from '../error-dispatch.js';
|
|
4
|
+
import type { ProceduresFactory, ExtractContext, StreamMode, AnyHttpRouteDoc, RPCHttpRouteDoc, APIHttpRouteDoc, StreamHttpRouteDoc, HttpStreamRouteDoc } from '../../types.js';
|
|
5
|
+
import type { TProcedureRegistration, TStreamProcedureRegistration, THttpProcedureRegistration, THttpStreamProcedureRegistration } from '../../../types.js';
|
|
6
|
+
export type { AnyProcedureRegistration } from '../error-dispatch.js';
|
|
7
|
+
/** Default query parser using URLSearchParams. */
|
|
8
|
+
export type QueryParser = (queryString: string) => Record<string, unknown>;
|
|
9
|
+
export type OnRequestErrorContext = {
|
|
10
|
+
err: unknown;
|
|
11
|
+
procedure: AnyProcedureRegistration;
|
|
12
|
+
raw: Context;
|
|
13
|
+
};
|
|
14
|
+
export type ExtendProcedureDoc = (params: {
|
|
15
|
+
base: RPCHttpRouteDoc | APIHttpRouteDoc | StreamHttpRouteDoc | HttpStreamRouteDoc;
|
|
16
|
+
procedure: AnyProcedureRegistration;
|
|
17
|
+
}) => Record<string, unknown>;
|
|
18
|
+
export type HonoFactoryItem<TFactory extends ProceduresFactory = ProceduresFactory> = {
|
|
19
|
+
factory: TFactory;
|
|
20
|
+
factoryContext: ExtractContext<TFactory> | ((c: Context) => ExtractContext<TFactory> | Promise<ExtractContext<TFactory>>);
|
|
21
|
+
streamMode?: StreamMode;
|
|
22
|
+
extendProcedureDoc?: ExtendProcedureDoc;
|
|
23
|
+
};
|
|
24
|
+
export type HonoAppBuilderConfig<TStreamErrorData = unknown> = {
|
|
25
|
+
/** Existing Hono app. If omitted, a new instance is created. */
|
|
26
|
+
app?: Hono;
|
|
27
|
+
/** Path prefix applied to every route across all kinds. */
|
|
28
|
+
pathPrefix?: string;
|
|
29
|
+
errors?: ErrorTaxonomy;
|
|
30
|
+
unknownError?: UnknownErrorConfig;
|
|
31
|
+
onError?: PreStreamOnError;
|
|
32
|
+
/** Cross-cutting observer — fires for every caught error before dispatch. */
|
|
33
|
+
onRequestError?: OnRequestErrorObserver;
|
|
34
|
+
onRequestStart?: (c: Context) => void;
|
|
35
|
+
onRequestEnd?: (c: Context) => void;
|
|
36
|
+
rpc?: {
|
|
37
|
+
onSuccess?: (procedure: TProcedureRegistration, c: Context) => void;
|
|
38
|
+
};
|
|
39
|
+
api?: {
|
|
40
|
+
queryParser?: QueryParser;
|
|
41
|
+
onSuccess?: (procedure: THttpProcedureRegistration<any>, c: Context) => void;
|
|
42
|
+
};
|
|
43
|
+
stream?: {
|
|
44
|
+
/** Default for both rpc-stream and http-stream. */
|
|
45
|
+
defaultStreamMode?: StreamMode;
|
|
46
|
+
onStreamStart?: (procedure: TStreamProcedureRegistration | THttpStreamProcedureRegistration<any>, c: Context, streamMode: StreamMode) => void;
|
|
47
|
+
onStreamEnd?: (procedure: TStreamProcedureRegistration | THttpStreamProcedureRegistration<any>, c: Context, streamMode: StreamMode) => void;
|
|
48
|
+
onMidStreamError?: OnMidStreamError<TStreamErrorData>;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export type DocAccumulator = AnyHttpRouteDoc[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/implementations/http/hono/types.ts"],"names":[],"mappings":""}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Cross-builder tests for the `onRequestError` observer hook.
|
|
4
4
|
*
|
|
5
|
-
* Invariants verified
|
|
5
|
+
* Invariants verified per builder:
|
|
6
6
|
* 1. Fires exactly once for every caught error.
|
|
7
7
|
* 2. Runs BEFORE dispatch (taxonomy / onError / hard default).
|
|
8
8
|
* 3. Is awaited — async observer work completes before the response is sent.
|
|
@@ -12,75 +12,16 @@
|
|
|
12
12
|
* path still produces a response.
|
|
13
13
|
*/
|
|
14
14
|
import { describe, expect, test, vi } from 'vitest';
|
|
15
|
-
import request from 'supertest';
|
|
16
15
|
import { Type } from 'typebox';
|
|
17
16
|
import { Procedures } from '../../index.js';
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
import { ExpressRPCAppBuilder } from './express-rpc/index.js';
|
|
21
|
-
import { HonoStreamAppBuilder } from './hono-stream/index.js';
|
|
22
|
-
describe('onRequestError — HonoAPIAppBuilder', () => {
|
|
23
|
-
function boomApp(config) {
|
|
24
|
-
const API = Procedures();
|
|
25
|
-
API.Create('Boom', { path: '/boom', method: 'get', schema: { returnType: Type.Object({}) } }, async () => {
|
|
26
|
-
throw new TypeError('boom');
|
|
27
|
-
});
|
|
28
|
-
return new HonoAPIAppBuilder(config).register(API, () => ({})).build();
|
|
29
|
-
}
|
|
30
|
-
test('fires exactly once and before dispatch', async () => {
|
|
31
|
-
const order = [];
|
|
32
|
-
const onRequestError = vi.fn(() => {
|
|
33
|
-
order.push('observer');
|
|
34
|
-
});
|
|
35
|
-
const onError = vi.fn((_p, c) => {
|
|
36
|
-
order.push('onError');
|
|
37
|
-
return c.json({ handled: true }, 418);
|
|
38
|
-
});
|
|
39
|
-
const app = boomApp({ onRequestError, onError });
|
|
40
|
-
await app.request('/boom');
|
|
41
|
-
expect(onRequestError).toHaveBeenCalledTimes(1);
|
|
42
|
-
expect(order).toEqual(['observer', 'onError']);
|
|
43
|
-
});
|
|
44
|
-
test('is awaited — async work completes before response is sent', async () => {
|
|
45
|
-
const log = [];
|
|
46
|
-
const onRequestError = async () => {
|
|
47
|
-
await new Promise((r) => setTimeout(r, 5));
|
|
48
|
-
log.push('observer-done');
|
|
49
|
-
};
|
|
50
|
-
const app = boomApp({
|
|
51
|
-
onRequestError,
|
|
52
|
-
onError: (_p, c) => {
|
|
53
|
-
log.push('onError-called');
|
|
54
|
-
return c.json({ ok: true }, 500);
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
await app.request('/boom');
|
|
58
|
-
expect(log).toEqual(['observer-done', 'onError-called']);
|
|
59
|
-
});
|
|
60
|
-
test('observer-thrown errors are swallowed — dispatch still produces a response', async () => {
|
|
61
|
-
const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => { });
|
|
62
|
-
const app = boomApp({
|
|
63
|
-
onRequestError: () => {
|
|
64
|
-
throw new Error('observer exploded');
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
|
-
const res = await app.request('/boom');
|
|
68
|
-
expect(res.status).toBe(500);
|
|
69
|
-
consoleSpy.mockRestore();
|
|
70
|
-
});
|
|
71
|
-
test('omitting observer preserves existing behavior', async () => {
|
|
72
|
-
const app = boomApp({ onError: (_p, c) => c.json({ ok: true }, 418) });
|
|
73
|
-
const res = await app.request('/boom');
|
|
74
|
-
expect(res.status).toBe(418);
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
describe('onRequestError — HonoRPCAppBuilder', () => {
|
|
17
|
+
import { HonoAppBuilder } from './hono/index.js';
|
|
18
|
+
describe('onRequestError — HonoAppBuilder (rpc kind)', () => {
|
|
78
19
|
function boomApp(config) {
|
|
79
20
|
const RPC = Procedures();
|
|
80
21
|
RPC.Create('Boom', { scope: 'test', version: 1, schema: { params: Type.Object({}) } }, async () => {
|
|
81
22
|
throw new TypeError('boom');
|
|
82
23
|
});
|
|
83
|
-
return new
|
|
24
|
+
return new HonoAppBuilder(config).register(RPC, () => ({})).build();
|
|
84
25
|
}
|
|
85
26
|
test('fires once; runs before onError', async () => {
|
|
86
27
|
const order = [];
|
|
@@ -108,44 +49,13 @@ describe('onRequestError — HonoRPCAppBuilder', () => {
|
|
|
108
49
|
consoleSpy.mockRestore();
|
|
109
50
|
});
|
|
110
51
|
});
|
|
111
|
-
describe('onRequestError —
|
|
112
|
-
function boomApp(config) {
|
|
113
|
-
const RPC = Procedures();
|
|
114
|
-
RPC.Create('Boom', { scope: 'test', version: 1, schema: { params: Type.Object({}) } }, async () => {
|
|
115
|
-
throw new TypeError('boom');
|
|
116
|
-
});
|
|
117
|
-
return new ExpressRPCAppBuilder(config).register(RPC, () => ({})).build();
|
|
118
|
-
}
|
|
119
|
-
test('fires once; raw is { req, res }', async () => {
|
|
120
|
-
let rawSeen;
|
|
121
|
-
const app = boomApp({
|
|
122
|
-
onRequestError: (ctx) => {
|
|
123
|
-
rawSeen = ctx.raw;
|
|
124
|
-
},
|
|
125
|
-
});
|
|
126
|
-
await request(app).post('/test/boom/1').send({});
|
|
127
|
-
expect(rawSeen.req).toBeDefined();
|
|
128
|
-
expect(rawSeen.res).toBeDefined();
|
|
129
|
-
});
|
|
130
|
-
test('observer throws are swallowed', async () => {
|
|
131
|
-
const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => { });
|
|
132
|
-
const app = boomApp({
|
|
133
|
-
onRequestError: () => {
|
|
134
|
-
throw new Error('observer bug');
|
|
135
|
-
},
|
|
136
|
-
});
|
|
137
|
-
const res = await request(app).post('/test/boom/1').send({});
|
|
138
|
-
expect(res.status).toBe(500);
|
|
139
|
-
consoleSpy.mockRestore();
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
describe('onRequestError — HonoStreamAppBuilder (pre-stream)', () => {
|
|
52
|
+
describe('onRequestError — HonoAppBuilder (rpc-stream pre-stream)', () => {
|
|
143
53
|
function boomApp(config) {
|
|
144
54
|
const RPC = Procedures();
|
|
145
55
|
RPC.CreateStream('Stream', { scope: 'test', version: 1 }, async function* () {
|
|
146
56
|
yield { ok: true };
|
|
147
57
|
});
|
|
148
|
-
return new
|
|
58
|
+
return new HonoAppBuilder(config)
|
|
149
59
|
.register(RPC, () => {
|
|
150
60
|
throw new TypeError('context failed');
|
|
151
61
|
})
|