ts-procedures 7.2.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 +139 -53
- package/agent_config/claude-code/skills/ts-procedures/api-reference.md +208 -231
- 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 +36 -48
- package/agent_config/cursor/cursorrules +36 -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 +125 -115
- package/build/index.js +10 -222
- package/build/index.js.map +1 -1
- package/build/index.test.js +30 -822
- 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 +34 -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 +35 -1091
- package/src/index.ts +50 -474
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"on-request-error.test.js","sourceRoot":"","sources":["../../../src/implementations/http/on-request-error.test.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AACnD,OAAO,
|
|
1
|
+
{"version":3,"file":"on-request-error.test.js","sourceRoot":"","sources":["../../../src/implementations/http/on-request-error.test.ts"],"names":[],"mappings":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CAAA;QAC5B,UAAU,CAAC,WAAW,EAAE,CAAA;IAC1B,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -2,10 +2,7 @@
|
|
|
2
2
|
import { describe, expect, test } from 'vitest';
|
|
3
3
|
import { Type } from 'typebox';
|
|
4
4
|
import { Procedures } from '../../index.js';
|
|
5
|
-
import {
|
|
6
|
-
import { HonoRPCAppBuilder } from './hono-rpc/index.js';
|
|
7
|
-
import { ExpressRPCAppBuilder } from './express-rpc/index.js';
|
|
8
|
-
import { HonoStreamAppBuilder } from './hono-stream/index.js';
|
|
5
|
+
import { HonoAppBuilder } from './hono/index.js';
|
|
9
6
|
import { DocRegistry } from './doc-registry.js';
|
|
10
7
|
import { defineErrorTaxonomy } from './error-taxonomy.js';
|
|
11
8
|
class UseCaseError extends Error {
|
|
@@ -24,29 +21,11 @@ const appErrors = defineErrorTaxonomy({
|
|
|
24
21
|
AuthError: { class: AuthError, statusCode: 401 },
|
|
25
22
|
});
|
|
26
23
|
describe('per-route errors declaration', () => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
errors: ['UseCaseError', 'AuthError'],
|
|
33
|
-
schema: {
|
|
34
|
-
input: { pathParams: Type.Object({ id: Type.String() }) },
|
|
35
|
-
returnType: Type.Object({}),
|
|
36
|
-
},
|
|
37
|
-
}, async () => ({}));
|
|
38
|
-
const builder = new HonoAPIAppBuilder().register(API, () => ({}));
|
|
39
|
-
builder.build();
|
|
40
|
-
expect(builder.docs[0].errors).toEqual(['UseCaseError', 'AuthError']);
|
|
41
|
-
});
|
|
42
|
-
test('hono-api route doc omits errors when not declared', () => {
|
|
43
|
-
const API = Procedures();
|
|
44
|
-
API.Create('Health', { path: '/health', method: 'get', schema: { returnType: Type.Object({}) } }, async () => ({}));
|
|
45
|
-
const builder = new HonoAPIAppBuilder().register(API, () => ({}));
|
|
46
|
-
builder.build();
|
|
47
|
-
expect(builder.docs[0].errors).toBeUndefined();
|
|
48
|
-
});
|
|
49
|
-
test('hono-rpc copies config.errors onto the route doc', () => {
|
|
24
|
+
// migrated to schema.req in Phase 3+ (CreateHttp)
|
|
25
|
+
test.todo('hono-api copies config.errors onto the route doc');
|
|
26
|
+
// migrated to schema.req in Phase 3+ (CreateHttp)
|
|
27
|
+
test.todo('hono-api route doc omits errors when not declared');
|
|
28
|
+
test('hono rpc copies config.errors onto the route doc', () => {
|
|
50
29
|
const RPC = Procedures();
|
|
51
30
|
RPC.Create('DoThing', {
|
|
52
31
|
scope: 'things',
|
|
@@ -54,28 +33,16 @@ describe('per-route errors declaration', () => {
|
|
|
54
33
|
errors: ['UseCaseError'],
|
|
55
34
|
schema: { params: Type.Object({}) },
|
|
56
35
|
}, async () => ({}));
|
|
57
|
-
const builder = new
|
|
36
|
+
const builder = new HonoAppBuilder().register(RPC, () => ({}));
|
|
58
37
|
builder.build();
|
|
59
38
|
expect(builder.docs[0].errors).toEqual(['UseCaseError']);
|
|
60
39
|
});
|
|
61
|
-
test('
|
|
62
|
-
const RPC = Procedures();
|
|
63
|
-
RPC.Create('DoThing', {
|
|
64
|
-
scope: 'things',
|
|
65
|
-
version: 1,
|
|
66
|
-
errors: ['AuthError'],
|
|
67
|
-
schema: { params: Type.Object({}) },
|
|
68
|
-
}, async () => ({}));
|
|
69
|
-
const builder = new ExpressRPCAppBuilder().register(RPC, () => ({}));
|
|
70
|
-
builder.build();
|
|
71
|
-
expect(builder.docs[0].errors).toEqual(['AuthError']);
|
|
72
|
-
});
|
|
73
|
-
test('hono-stream copies config.errors onto the route doc', () => {
|
|
40
|
+
test('hono stream copies config.errors onto the route doc', () => {
|
|
74
41
|
const Stream = Procedures();
|
|
75
42
|
Stream.CreateStream('Watch', { scope: 'watch', version: 1, errors: ['AuthError'] }, async function* () {
|
|
76
43
|
yield { ok: true };
|
|
77
44
|
});
|
|
78
|
-
const builder = new
|
|
45
|
+
const builder = new HonoAppBuilder().register(Stream, () => ({}));
|
|
79
46
|
builder.build();
|
|
80
47
|
expect(builder.docs[0].errors).toEqual(['AuthError']);
|
|
81
48
|
});
|
|
@@ -118,22 +85,7 @@ describe('DocRegistry with taxonomy input', () => {
|
|
|
118
85
|
const count = envelope.errors.filter((e) => e.name === 'ProcedureError').length;
|
|
119
86
|
expect(count).toBe(1);
|
|
120
87
|
});
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
API.Create('GetUser', {
|
|
124
|
-
path: '/users/:id',
|
|
125
|
-
method: 'get',
|
|
126
|
-
errors: ['UseCaseError'],
|
|
127
|
-
schema: {
|
|
128
|
-
input: { pathParams: Type.Object({ id: Type.String() }) },
|
|
129
|
-
returnType: Type.Object({}),
|
|
130
|
-
},
|
|
131
|
-
}, async () => ({}));
|
|
132
|
-
const app = new HonoAPIAppBuilder().register(API, () => ({}));
|
|
133
|
-
app.build();
|
|
134
|
-
const envelope = new DocRegistry({ errors: appErrors }).from(app).toJSON();
|
|
135
|
-
const route = envelope.routes.find((r) => r.kind === 'api' && r.name === 'GetUser');
|
|
136
|
-
expect(route?.errors).toEqual(['UseCaseError']);
|
|
137
|
-
});
|
|
88
|
+
// migrated to schema.req in Phase 3+ (CreateHttp)
|
|
89
|
+
test.todo('registered route errors survive DocRegistry composition');
|
|
138
90
|
});
|
|
139
91
|
//# sourceMappingURL=route-errors.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-errors.test.js","sourceRoot":"","sources":["../../../src/implementations/http/route-errors.test.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"route-errors.test.js","sourceRoot":"","sources":["../../../src/implementations/http/route-errors.test.ts"],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AAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC,CAAA;IACtD,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,gEAAgE,EAAE,GAAG,EAAE;QAC1E,MAAM,UAAU,GAAG,mBAAmB,CAAC;YACrC,cAAc,EAAE;gBACd,KAAK,EAAE,KAAK;gBACZ,UAAU,EAAE,GAAG;gBACf,WAAW,EAAE,iBAAiB;aAC/B;SACF,CAAC,CAAA;QACF,MAAM,QAAQ,GAAG,IAAI,WAAW,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAA;QACjE,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,gBAAgB,CAAC,CAAA;QACrE,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAClC,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;QACjD,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,gBAAgB,CAAC,CAAC,MAAM,CAAA;QAC/E,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACvB,CAAC,CAAC,CAAA;IAEF,kDAAkD;IAClD,IAAI,CAAC,IAAI,CAAC,yDAAyD,CAAC,CAAA;AACtE,CAAC,CAAC,CAAA"}
|
|
@@ -54,20 +54,28 @@ export interface APIConfig<TErrorKey extends string = string> {
|
|
|
54
54
|
*/
|
|
55
55
|
errors?: TErrorKey[];
|
|
56
56
|
}
|
|
57
|
-
export interface APIHttpRouteDoc
|
|
57
|
+
export interface APIHttpRouteDoc {
|
|
58
58
|
kind: 'api';
|
|
59
59
|
name: string;
|
|
60
|
+
scope?: string;
|
|
61
|
+
path: string;
|
|
62
|
+
method: HttpMethod;
|
|
60
63
|
/** Full resolved path including pathPrefix */
|
|
61
64
|
fullPath: string;
|
|
65
|
+
successStatus?: number;
|
|
66
|
+
errors?: string[];
|
|
62
67
|
jsonSchema: {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
req?: {
|
|
69
|
+
pathParams?: Record<string, unknown>;
|
|
70
|
+
query?: Record<string, unknown>;
|
|
71
|
+
body?: Record<string, unknown>;
|
|
72
|
+
headers?: Record<string, unknown>;
|
|
73
|
+
};
|
|
74
|
+
res?: {
|
|
75
|
+
body?: Record<string, unknown>;
|
|
76
|
+
headers?: Record<string, unknown>;
|
|
77
|
+
};
|
|
68
78
|
};
|
|
69
|
-
/** Taxonomy keys for errors this route may emit. */
|
|
70
|
-
errors?: string[];
|
|
71
79
|
}
|
|
72
80
|
/**
|
|
73
81
|
* Constrains schema.input channel names to valid HTTP input sources.
|
|
@@ -106,6 +114,29 @@ export interface StreamHttpRouteDoc extends RPCConfig {
|
|
|
106
114
|
/** Taxonomy keys for errors this route may emit (pre-stream only). */
|
|
107
115
|
errors?: string[];
|
|
108
116
|
}
|
|
117
|
+
export interface HttpStreamRouteDoc {
|
|
118
|
+
kind: 'http-stream';
|
|
119
|
+
name: string;
|
|
120
|
+
scope?: string;
|
|
121
|
+
path: string;
|
|
122
|
+
method: HttpMethod;
|
|
123
|
+
fullPath: string;
|
|
124
|
+
streamMode: StreamMode;
|
|
125
|
+
errors?: string[];
|
|
126
|
+
jsonSchema: {
|
|
127
|
+
req?: {
|
|
128
|
+
pathParams?: Record<string, unknown>;
|
|
129
|
+
query?: Record<string, unknown>;
|
|
130
|
+
body?: Record<string, unknown>;
|
|
131
|
+
headers?: Record<string, unknown>;
|
|
132
|
+
};
|
|
133
|
+
res?: {
|
|
134
|
+
headers?: Record<string, unknown>;
|
|
135
|
+
};
|
|
136
|
+
yield?: Record<string, unknown>;
|
|
137
|
+
returnType?: Record<string, unknown>;
|
|
138
|
+
};
|
|
139
|
+
}
|
|
109
140
|
/**
|
|
110
141
|
* Extracts the TContext type from a Procedures factory return type.
|
|
111
142
|
* Uses the first parameter of the handler function to infer the context type.
|
|
@@ -131,14 +162,17 @@ export type ExtractConfig<TFactory> = TFactory extends {
|
|
|
131
162
|
export type ProceduresFactory = {
|
|
132
163
|
getProcedures: () => Array<{
|
|
133
164
|
name: string;
|
|
165
|
+
kind?: import('../types.js').ProcedureKind;
|
|
134
166
|
isStream?: boolean;
|
|
135
167
|
config: any;
|
|
136
168
|
handler: (ctx: any, params?: any) => Promise<any> | AsyncGenerator<any, any, unknown>;
|
|
137
169
|
}>;
|
|
138
170
|
Create: (...args: any[]) => any;
|
|
139
171
|
CreateStream?: (...args: any[]) => any;
|
|
172
|
+
CreateHttp?: (...args: any[]) => any;
|
|
173
|
+
CreateHttpStream?: (...args: any[]) => any;
|
|
140
174
|
};
|
|
141
|
-
export type AnyHttpRouteDoc = RPCHttpRouteDoc | APIHttpRouteDoc | StreamHttpRouteDoc;
|
|
175
|
+
export type AnyHttpRouteDoc = RPCHttpRouteDoc | APIHttpRouteDoc | StreamHttpRouteDoc | HttpStreamRouteDoc;
|
|
142
176
|
export interface DocSource<T = AnyHttpRouteDoc> {
|
|
143
177
|
readonly docs: T[];
|
|
144
178
|
/**
|
package/build/index.d.ts
CHANGED
|
@@ -1,98 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export type TLocalContext = {
|
|
5
|
-
error: (message: string, meta?: object) => ProcedureError;
|
|
6
|
-
signal?: AbortSignal;
|
|
7
|
-
};
|
|
8
|
-
export type TStreamContext = TLocalContext & {
|
|
9
|
-
signal: AbortSignal;
|
|
10
|
-
};
|
|
11
|
-
export type TProcedureRegistration<TContext = unknown, TExtendedConfig = unknown> = {
|
|
12
|
-
name: string;
|
|
13
|
-
isStream?: false;
|
|
14
|
-
config: {
|
|
15
|
-
description?: string;
|
|
16
|
-
schema?: {
|
|
17
|
-
params?: TJSONSchema;
|
|
18
|
-
returnType?: TJSONSchema;
|
|
19
|
-
input?: Record<string, TJSONSchema>;
|
|
20
|
-
};
|
|
21
|
-
validation?: {
|
|
22
|
-
params?: (params: any) => {
|
|
23
|
-
errors?: any[];
|
|
24
|
-
};
|
|
25
|
-
input?: Record<string, (value: any) => {
|
|
26
|
-
errors?: any[];
|
|
27
|
-
}>;
|
|
28
|
-
};
|
|
29
|
-
} & TExtendedConfig;
|
|
30
|
-
handler: (ctx: TContext, params?: any) => Promise<any>;
|
|
31
|
-
};
|
|
32
|
-
export type TStreamProcedureRegistration<TContext = unknown, TExtendedConfig = unknown> = {
|
|
33
|
-
name: string;
|
|
34
|
-
isStream: true;
|
|
35
|
-
config: {
|
|
36
|
-
description?: string;
|
|
37
|
-
schema?: {
|
|
38
|
-
params?: TJSONSchema;
|
|
39
|
-
yieldType?: TJSONSchema;
|
|
40
|
-
returnType?: TJSONSchema;
|
|
41
|
-
input?: Record<string, TJSONSchema>;
|
|
42
|
-
};
|
|
43
|
-
validation?: {
|
|
44
|
-
params?: (params: any) => {
|
|
45
|
-
errors?: any[];
|
|
46
|
-
};
|
|
47
|
-
yield?: (value: any) => {
|
|
48
|
-
errors?: any[];
|
|
49
|
-
};
|
|
50
|
-
input?: Record<string, (value: any) => {
|
|
51
|
-
errors?: any[];
|
|
52
|
-
}>;
|
|
53
|
-
};
|
|
54
|
-
} & TExtendedConfig;
|
|
55
|
-
handler: (ctx: TContext, params?: any) => AsyncGenerator<any, any, unknown>;
|
|
56
|
-
};
|
|
1
|
+
import { Prettify, TJSONSchema } from './schema/types.js';
|
|
2
|
+
export { type TNoContextProvided, type TLocalContext, type TStreamContext, type ProcedureKind, type TProcedureRegistration, type TStreamProcedureRegistration, type THttpProcedureRegistration, type THttpStreamProcedureRegistration, type TBuilderConfig, } from './types.js';
|
|
3
|
+
import { TNoContextProvided, TBuilderConfig, TProcedureRegistration, TStreamProcedureRegistration, THttpProcedureRegistration, THttpStreamProcedureRegistration } from './types.js';
|
|
57
4
|
export declare function Procedures<TContext = TNoContextProvided, TExtendedConfig = unknown>(
|
|
58
5
|
/**
|
|
59
6
|
* Optionally provided builder to register Procedures
|
|
60
7
|
*/
|
|
61
8
|
builder?: {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
validation?: {
|
|
75
|
-
params?: (params: any) => {
|
|
76
|
-
errors?: any[];
|
|
77
|
-
};
|
|
78
|
-
yield?: (value: any) => {
|
|
79
|
-
errors?: any[];
|
|
80
|
-
};
|
|
81
|
-
input?: Record<string, (value: any) => {
|
|
82
|
-
errors?: any[];
|
|
83
|
-
}>;
|
|
84
|
-
};
|
|
85
|
-
} & TExtendedConfig>;
|
|
86
|
-
}>) => void;
|
|
9
|
+
config?: TBuilderConfig;
|
|
10
|
+
/**
|
|
11
|
+
* Called once per registered procedure. Receives the full registration
|
|
12
|
+
* object for any of the four procedure kinds:
|
|
13
|
+
* - `TProcedureRegistration` (Create)
|
|
14
|
+
* - `TStreamProcedureRegistration` (CreateStream)
|
|
15
|
+
* - `THttpProcedureRegistration` (CreateHttp)
|
|
16
|
+
* - `THttpStreamProcedureRegistration` (CreateHttpStream)
|
|
17
|
+
*
|
|
18
|
+
* Use the `kind` discriminant to narrow to the specific shape.
|
|
19
|
+
*/
|
|
20
|
+
onCreate?: (procedure: Prettify<TProcedureRegistration<TContext, TExtendedConfig> | TStreamProcedureRegistration<TContext, TExtendedConfig> | THttpProcedureRegistration<TContext> | THttpStreamProcedureRegistration<TContext>>) => void;
|
|
87
21
|
}): {
|
|
88
22
|
/**
|
|
89
23
|
* Get all registered procedures
|
|
90
24
|
*/
|
|
91
|
-
getProcedures: () => (TProcedureRegistration<TContext, TExtendedConfig> | TStreamProcedureRegistration<TContext, TExtendedConfig>)[];
|
|
25
|
+
getProcedures: () => (TProcedureRegistration<TContext, TExtendedConfig> | TStreamProcedureRegistration<TContext, TExtendedConfig> | THttpProcedureRegistration<TContext> | THttpStreamProcedureRegistration<TContext>)[];
|
|
92
26
|
/**
|
|
93
27
|
* Get a specific procedure by name
|
|
94
28
|
*/
|
|
95
|
-
getProcedure: (name: string) => TProcedureRegistration<TContext, TExtendedConfig> | TStreamProcedureRegistration<TContext, TExtendedConfig> | undefined;
|
|
29
|
+
getProcedure: (name: string) => TProcedureRegistration<TContext, TExtendedConfig> | TStreamProcedureRegistration<TContext, TExtendedConfig> | THttpProcedureRegistration<TContext> | THttpStreamProcedureRegistration<TContext> | undefined;
|
|
96
30
|
/**
|
|
97
31
|
* Remove a procedure by name
|
|
98
32
|
*/
|
|
@@ -101,65 +35,141 @@ builder?: {
|
|
|
101
35
|
* Clear all registered procedures
|
|
102
36
|
*/
|
|
103
37
|
clear: () => void;
|
|
104
|
-
Create: <TName extends string, TParams, TReturnType
|
|
38
|
+
Create: <TName extends string, TParams, TReturnType>(name: TName, config: {
|
|
105
39
|
description?: string;
|
|
106
40
|
schema?: {
|
|
107
|
-
params?: TParams;
|
|
108
|
-
returnType?: TReturnType;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
procedure: (ctx: Prettify<TContext>, params: TInput extends Record<string, unknown> ? Prettify<{ [K in keyof TInput]: TSchemaLib<TInput[K]>; }> : TSchemaLib<TParams>) => Promise<TSchemaLib<TReturnType>>;
|
|
41
|
+
params?: TParams | undefined;
|
|
42
|
+
returnType?: TReturnType | undefined;
|
|
43
|
+
} | undefined;
|
|
44
|
+
} & TExtendedConfig, handler: (ctx: TContext & import("./types.js").TLocalContext extends infer T ? { [Key in keyof T]: T[Key]; } : never, params: import("./schema/types.js").TSchemaLib<TParams>) => Promise<import("./schema/types.js").TSchemaLib<TReturnType>>) => { [K in TName]: (ctx: { [Key in keyof TContext]: TContext[Key]; }, params: import("./schema/types.js").TSchemaLib<TParams>) => Promise<import("./schema/types.js").TSchemaLib<TReturnType>>; } & {
|
|
45
|
+
procedure: (ctx: { [Key in keyof TContext]: TContext[Key]; }, params: import("./schema/types.js").TSchemaLib<TParams>) => Promise<import("./schema/types.js").TSchemaLib<TReturnType>>;
|
|
113
46
|
info: {
|
|
114
47
|
name: TName;
|
|
115
48
|
description?: string;
|
|
116
49
|
schema: {
|
|
117
|
-
params?: TParams;
|
|
118
|
-
returnType?: TReturnType;
|
|
119
|
-
input?: TInput;
|
|
50
|
+
params?: TParams | undefined;
|
|
51
|
+
returnType?: TReturnType | undefined;
|
|
120
52
|
};
|
|
121
53
|
validation?: {
|
|
122
|
-
params?: (params: any) => {
|
|
123
|
-
errors?: any[];
|
|
124
|
-
};
|
|
125
|
-
input?: Record<string, (value: any) => {
|
|
54
|
+
params?: ((params: any) => {
|
|
126
55
|
errors?: any[];
|
|
127
|
-
}
|
|
128
|
-
};
|
|
56
|
+
}) | undefined;
|
|
57
|
+
} | undefined;
|
|
129
58
|
} & TExtendedConfig;
|
|
130
59
|
};
|
|
131
|
-
CreateStream: <TName extends string, TParams, TYieldType, TReturnType = void
|
|
60
|
+
CreateStream: <TName extends string, TParams, TYieldType, TReturnType = void>(name: TName, config: {
|
|
132
61
|
description?: string;
|
|
133
62
|
schema?: {
|
|
134
|
-
params?: TParams;
|
|
135
|
-
yieldType?: TYieldType;
|
|
136
|
-
returnType?: TReturnType;
|
|
137
|
-
|
|
138
|
-
};
|
|
63
|
+
params?: TParams | undefined;
|
|
64
|
+
yieldType?: TYieldType | undefined;
|
|
65
|
+
returnType?: TReturnType | undefined;
|
|
66
|
+
} | undefined;
|
|
139
67
|
validateYields?: boolean;
|
|
140
|
-
} & TExtendedConfig, handler: (ctx:
|
|
141
|
-
|
|
68
|
+
} & TExtendedConfig, handler: (ctx: TContext & import("./types.js").TLocalContext & {
|
|
69
|
+
signal: AbortSignal;
|
|
70
|
+
} extends infer T ? { [Key in keyof T]: T[Key]; } : never, params: import("./schema/types.js").TSchemaLib<TParams>) => AsyncGenerator<import("./schema/types.js").TSchemaLib<TYieldType>, void | import("./schema/types.js").TSchemaLib<TReturnType>, unknown>) => { [K in TName]: (ctx: { [Key in keyof TContext]: TContext[Key]; }, params: import("./schema/types.js").TSchemaLib<TParams>) => AsyncGenerator<import("./schema/types.js").TSchemaLib<TYieldType>, void | import("./schema/types.js").TSchemaLib<TReturnType>, unknown>; } & {
|
|
71
|
+
procedure: (ctx: { [Key in keyof TContext]: TContext[Key]; }, params: import("./schema/types.js").TSchemaLib<TParams>) => AsyncGenerator<import("./schema/types.js").TSchemaLib<TYieldType>, void | import("./schema/types.js").TSchemaLib<TReturnType>, unknown>;
|
|
142
72
|
info: {
|
|
143
73
|
name: TName;
|
|
144
74
|
isStream: true;
|
|
145
75
|
description?: string;
|
|
146
76
|
schema: {
|
|
147
|
-
params?: TParams;
|
|
148
|
-
yieldType?: TYieldType;
|
|
149
|
-
returnType?: TReturnType;
|
|
150
|
-
input?: TInput;
|
|
77
|
+
params?: TParams | undefined;
|
|
78
|
+
yieldType?: TYieldType | undefined;
|
|
79
|
+
returnType?: TReturnType | undefined;
|
|
151
80
|
};
|
|
152
81
|
validation?: {
|
|
153
|
-
params?: (params: any) => {
|
|
82
|
+
params?: ((params: any) => {
|
|
83
|
+
errors?: any[];
|
|
84
|
+
}) | undefined;
|
|
85
|
+
yield?: ((value: any) => {
|
|
154
86
|
errors?: any[];
|
|
87
|
+
}) | undefined;
|
|
88
|
+
} | undefined;
|
|
89
|
+
} & TExtendedConfig;
|
|
90
|
+
};
|
|
91
|
+
CreateHttp: <TName extends string, TReq extends Record<string, unknown> | undefined, TRes extends {
|
|
92
|
+
body?: unknown;
|
|
93
|
+
headers?: unknown;
|
|
94
|
+
} | undefined = undefined, TErrorKey extends string = string>(name: TName, config: import("./types.js").TCreateHttpConfig<TReq, TRes, TErrorKey>, handler: (ctx: TContext & import("./types.js").TLocalContext extends infer T ? { [Key in keyof T]: T[Key]; } : never, req: TReq extends Record<string, unknown> ? { [Key_1 in keyof { [K in keyof TReq]: import("./schema/types.js").TSchemaLib<TReq[K]>; }]: { [K in keyof TReq]: import("./schema/types.js").TSchemaLib<TReq[K]>; }[Key_1]; } : undefined) => Promise<import("./create-http.js").HttpReturn<TRes>>) => { [K in TName]: (ctx: { [Key in keyof TContext]: TContext[Key]; }, req: TReq extends Record<string, unknown> ? { [Key_1 in keyof { [K_2 in keyof TReq]: import("./schema/types.js").TSchemaLib<TReq[K_2]>; }]: { [K_2 in keyof TReq]: import("./schema/types.js").TSchemaLib<TReq[K_2]>; }[Key_1]; } : undefined) => Promise<import("./create-http.js").HttpReturn<TRes>>; } & {
|
|
95
|
+
procedure: (ctx: { [Key in keyof TContext]: TContext[Key]; }, req: TReq extends Record<string, unknown> ? { [Key_1 in keyof { [K_1 in keyof TReq]: import("./schema/types.js").TSchemaLib<TReq[K_1]>; }]: { [K_1 in keyof TReq]: import("./schema/types.js").TSchemaLib<TReq[K_1]>; }[Key_1]; } : undefined) => Promise<import("./create-http.js").HttpReturn<TRes>>;
|
|
96
|
+
info: {
|
|
97
|
+
path: string;
|
|
98
|
+
method: import("./types.js").HttpMethod;
|
|
99
|
+
successStatus?: number;
|
|
100
|
+
scope?: string;
|
|
101
|
+
errors?: string[];
|
|
102
|
+
description?: string;
|
|
103
|
+
schema?: {
|
|
104
|
+
req?: Record<string, TJSONSchema>;
|
|
105
|
+
res?: {
|
|
106
|
+
body?: TJSONSchema;
|
|
107
|
+
headers?: TJSONSchema;
|
|
155
108
|
};
|
|
156
|
-
|
|
109
|
+
};
|
|
110
|
+
validation?: {
|
|
111
|
+
req?: Record<string, (value: any) => {
|
|
157
112
|
errors?: any[];
|
|
113
|
+
}>;
|
|
114
|
+
};
|
|
115
|
+
name: TName;
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
CreateHttpStream: <TName extends string, TReq extends Record<string, unknown> | undefined, TYieldType, TReturnType = void, TResHeaders = undefined, TErrorKey extends string = string>(name: TName, config: {
|
|
119
|
+
path: string;
|
|
120
|
+
method: import("./types.js").HttpMethod;
|
|
121
|
+
scope?: string;
|
|
122
|
+
errors?: TErrorKey[] | undefined;
|
|
123
|
+
description?: string;
|
|
124
|
+
schema: {
|
|
125
|
+
req?: TReq | undefined;
|
|
126
|
+
yield?: TYieldType | undefined;
|
|
127
|
+
returnType?: TReturnType | undefined;
|
|
128
|
+
res?: (TResHeaders extends undefined ? undefined : {
|
|
129
|
+
headers: TResHeaders;
|
|
130
|
+
}) | undefined;
|
|
131
|
+
};
|
|
132
|
+
validateYields?: boolean;
|
|
133
|
+
}, handler: TResHeaders extends undefined ? (ctx: TContext & import("./types.js").TLocalContext & {
|
|
134
|
+
signal: AbortSignal;
|
|
135
|
+
} extends infer T ? { [Key in keyof T]: T[Key]; } : never, req: TReq extends Record<string, unknown> ? { [Key_1 in keyof { [K in keyof TReq]: import("./schema/types.js").TSchemaLib<TReq[K]>; }]: { [K in keyof TReq]: import("./schema/types.js").TSchemaLib<TReq[K]>; }[Key_1]; } : undefined) => AsyncGenerator<import("./schema/types.js").TSchemaLib<TYieldType>, void | import("./schema/types.js").TSchemaLib<TReturnType>, unknown> : (ctx: TContext & import("./types.js").TLocalContext & {
|
|
136
|
+
signal: AbortSignal;
|
|
137
|
+
} extends infer T ? { [Key in keyof T]: T[Key]; } : never, req: TReq extends Record<string, unknown> ? { [Key_1 in keyof { [K in keyof TReq]: import("./schema/types.js").TSchemaLib<TReq[K]>; }]: { [K in keyof TReq]: import("./schema/types.js").TSchemaLib<TReq[K]>; }[Key_1]; } : undefined) => Promise<{
|
|
138
|
+
headers: import("./schema/types.js").TSchemaLib<TResHeaders>;
|
|
139
|
+
stream: AsyncGenerator<import("./schema/types.js").TSchemaLib<TYieldType>, void | import("./schema/types.js").TSchemaLib<TReturnType>, unknown>;
|
|
140
|
+
}>) => { [K in TName]: (ctx: { [Key in keyof TContext]: TContext[Key]; }, req: TReq extends Record<string, unknown> ? { [Key_1 in keyof { [K_2 in keyof TReq]: import("./schema/types.js").TSchemaLib<TReq[K_2]>; }]: { [K_2 in keyof TReq]: import("./schema/types.js").TSchemaLib<TReq[K_2]>; }[Key_1]; } : undefined) => Promise<{
|
|
141
|
+
stream: AsyncGenerator<import("./schema/types.js").TSchemaLib<TYieldType>, void | import("./schema/types.js").TSchemaLib<TReturnType>, unknown>;
|
|
142
|
+
initialHeaders?: Record<string, string>;
|
|
143
|
+
}>; } & {
|
|
144
|
+
procedure: (ctx: { [Key in keyof TContext]: TContext[Key]; }, req: TReq extends Record<string, unknown> ? { [Key_1 in keyof { [K_1 in keyof TReq]: import("./schema/types.js").TSchemaLib<TReq[K_1]>; }]: { [K_1 in keyof TReq]: import("./schema/types.js").TSchemaLib<TReq[K_1]>; }[Key_1]; } : undefined) => Promise<{
|
|
145
|
+
stream: AsyncGenerator<import("./schema/types.js").TSchemaLib<TYieldType>, void | import("./schema/types.js").TSchemaLib<TReturnType>, unknown>;
|
|
146
|
+
initialHeaders?: Record<string, string>;
|
|
147
|
+
}>;
|
|
148
|
+
info: {
|
|
149
|
+
path: string;
|
|
150
|
+
method: import("./types.js").HttpMethod;
|
|
151
|
+
scope?: string;
|
|
152
|
+
errors?: string[];
|
|
153
|
+
description?: string;
|
|
154
|
+
schema?: {
|
|
155
|
+
req?: Record<string, TJSONSchema>;
|
|
156
|
+
res?: {
|
|
157
|
+
headers?: TJSONSchema;
|
|
158
158
|
};
|
|
159
|
-
|
|
159
|
+
yield?: TJSONSchema;
|
|
160
|
+
returnType?: TJSONSchema;
|
|
161
|
+
};
|
|
162
|
+
validation?: {
|
|
163
|
+
req?: Record<string, (value: any) => {
|
|
160
164
|
errors?: any[];
|
|
161
165
|
}>;
|
|
166
|
+
yield?: (value: any) => {
|
|
167
|
+
errors?: any[];
|
|
168
|
+
};
|
|
162
169
|
};
|
|
163
|
-
|
|
170
|
+
validateYields?: boolean;
|
|
171
|
+
name: TName;
|
|
172
|
+
kind: "http-stream";
|
|
173
|
+
};
|
|
164
174
|
};
|
|
165
175
|
};
|