ts-procedures 8.5.0 → 9.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 +166 -101
- package/agent_config/claude-code/.claude-plugin/plugin.json +1 -1
- package/agent_config/claude-code/agents/ts-procedures-architect.md +11 -10
- package/agent_config/claude-code/skills/ts-procedures/SKILL.md +25 -12
- package/agent_config/claude-code/skills/ts-procedures/anti-patterns.md +10 -12
- package/agent_config/claude-code/skills/ts-procedures/api-reference.md +141 -45
- package/agent_config/claude-code/skills/ts-procedures/checklist.md +7 -6
- package/agent_config/claude-code/skills/ts-procedures/patterns.md +45 -6
- package/agent_config/claude-code/skills/ts-procedures/templates/client.md +1 -1
- package/agent_config/claude-code/skills/ts-procedures/templates/hono.md +1 -1
- package/agent_config/copilot/copilot-instructions.md +50 -33
- package/agent_config/cursor/cursorrules +50 -33
- package/build/adapters/astro/astro-context.js.map +1 -0
- package/build/adapters/astro/create-handler.js.map +1 -0
- package/build/adapters/astro/index.js.map +1 -0
- package/build/{implementations/http → adapters}/astro/index.test.js +1 -1
- package/build/adapters/astro/index.test.js.map +1 -0
- package/build/adapters/astro/rewrite-request.js.map +1 -0
- package/build/adapters/hono/envelope-parity.test.js +98 -0
- package/build/adapters/hono/envelope-parity.test.js.map +1 -0
- package/build/{implementations/http → adapters}/hono/handlers/http-stream.d.ts +1 -1
- package/build/adapters/hono/handlers/http-stream.js +55 -0
- package/build/adapters/hono/handlers/http-stream.js.map +1 -0
- package/build/{implementations/http → adapters}/hono/handlers/http-stream.test.js +1 -1
- package/build/adapters/hono/handlers/http-stream.test.js.map +1 -0
- package/build/{implementations/http → adapters}/hono/handlers/http.d.ts +1 -1
- package/build/adapters/hono/handlers/http.js +50 -0
- package/build/adapters/hono/handlers/http.js.map +1 -0
- package/build/{implementations/http → adapters}/hono/handlers/http.test.js +1 -1
- package/build/adapters/hono/handlers/http.test.js.map +1 -0
- package/build/{implementations/http → adapters}/hono/handlers/rpc.d.ts +2 -2
- package/build/adapters/hono/handlers/rpc.js +23 -0
- package/build/adapters/hono/handlers/rpc.js.map +1 -0
- package/build/{implementations/http → adapters}/hono/handlers/rpc.test.js +1 -1
- package/build/adapters/hono/handlers/rpc.test.js.map +1 -0
- package/build/adapters/hono/handlers/stream.d.ts +12 -0
- package/build/adapters/hono/handlers/stream.js +89 -0
- package/build/adapters/hono/handlers/stream.js.map +1 -0
- package/build/{implementations/http → adapters}/hono/handlers/stream.test.js +3 -2
- package/build/adapters/hono/handlers/stream.test.js.map +1 -0
- package/build/{implementations/http → adapters}/hono/index.d.ts +24 -12
- package/build/{implementations/http → adapters}/hono/index.js +19 -8
- package/build/adapters/hono/index.js.map +1 -0
- package/build/{implementations/http → adapters}/hono/index.test.js +2 -4
- package/build/adapters/hono/index.test.js.map +1 -0
- package/build/{implementations/http → adapters/hono}/on-request-error.test.js +2 -2
- package/build/adapters/hono/on-request-error.test.js.map +1 -0
- package/build/adapters/hono/request.d.ts +7 -0
- package/build/adapters/hono/request.js +22 -0
- package/build/adapters/hono/request.js.map +1 -0
- package/build/{implementations/http → adapters/hono}/route-errors.test.js +4 -4
- package/build/adapters/hono/route-errors.test.js.map +1 -0
- package/build/adapters/hono/types.d.ts +55 -0
- package/build/adapters/hono/types.js +19 -0
- package/build/adapters/hono/types.js.map +1 -0
- package/build/client/freeze.test.js +39 -0
- package/build/client/freeze.test.js.map +1 -0
- package/build/client/typed-error-dispatch.test.js +2 -2
- package/build/client/typed-error-dispatch.test.js.map +1 -1
- package/build/codegen/__fixtures__/make-envelope.d.ts +1 -1
- package/build/codegen/bin/cli.d.ts +5 -0
- package/build/codegen/bin/cli.js +139 -182
- package/build/codegen/bin/cli.js.map +1 -1
- package/build/codegen/bin/cli.test.js +12 -2
- package/build/codegen/bin/cli.test.js.map +1 -1
- package/build/codegen/bin/flag-specs.d.ts +9 -0
- package/build/codegen/bin/flag-specs.js +33 -31
- package/build/codegen/bin/flag-specs.js.map +1 -1
- package/build/codegen/bin/flag-specs.test.js +14 -1
- package/build/codegen/bin/flag-specs.test.js.map +1 -1
- package/build/codegen/collect-models.d.ts +1 -1
- package/build/codegen/emit/api-route.d.ts +8 -0
- package/build/codegen/emit/api-route.js +156 -0
- package/build/codegen/emit/api-route.js.map +1 -0
- package/build/codegen/emit/context.d.ts +30 -0
- package/build/codegen/emit/context.js +2 -0
- package/build/codegen/emit/context.js.map +1 -0
- package/build/codegen/emit/declarations.d.ts +24 -0
- package/build/codegen/emit/declarations.js +48 -0
- package/build/codegen/emit/declarations.js.map +1 -0
- package/build/codegen/emit/format-types.d.ts +61 -0
- package/build/codegen/emit/format-types.js +188 -0
- package/build/codegen/emit/format-types.js.map +1 -0
- package/build/codegen/emit/http-stream-route.d.ts +7 -0
- package/build/codegen/emit/http-stream-route.js +138 -0
- package/build/codegen/emit/http-stream-route.js.map +1 -0
- package/build/codegen/emit/route-shared.d.ts +35 -0
- package/build/codegen/emit/route-shared.js +88 -0
- package/build/codegen/emit/route-shared.js.map +1 -0
- package/build/codegen/emit/rpc-route.d.ts +7 -0
- package/build/codegen/emit/rpc-route.js +37 -0
- package/build/codegen/emit/rpc-route.js.map +1 -0
- package/build/codegen/emit/scope-file.d.ts +39 -0
- package/build/codegen/emit/scope-file.js +166 -0
- package/build/codegen/emit/scope-file.js.map +1 -0
- package/build/codegen/emit/stream-route.d.ts +7 -0
- package/build/codegen/emit/stream-route.js +62 -0
- package/build/codegen/emit/stream-route.js.map +1 -0
- package/build/codegen/emit-errors.d.ts +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-index.js +13 -0
- package/build/codegen/emit-index.js.map +1 -1
- package/build/codegen/emit-index.test.js +25 -0
- package/build/codegen/emit-index.test.js.map +1 -1
- package/build/codegen/emit-scope.d.ts +13 -30
- package/build/codegen/emit-scope.js +15 -807
- package/build/codegen/emit-scope.js.map +1 -1
- package/build/codegen/emit-scope.test.js +86 -4
- package/build/codegen/emit-scope.test.js.map +1 -1
- package/build/codegen/goldens.test.js +69 -0
- package/build/codegen/goldens.test.js.map +1 -0
- package/build/codegen/group-routes.d.ts +1 -1
- package/build/codegen/pipeline.d.ts +1 -1
- package/build/codegen/resolve-envelope.d.ts +1 -1
- package/build/codegen/targets/_shared/error-schemas.d.ts +1 -1
- package/build/codegen/targets/_shared/route-slots.d.ts +1 -1
- package/build/codegen/targets/_shared/target-run.d.ts +1 -1
- package/build/codegen/targets/kotlin/emit-route-kotlin.d.ts +1 -1
- package/build/codegen/targets/swift/emit-route-swift.d.ts +1 -1
- package/build/core/create-http-stream.d.ts +50 -0
- package/build/core/create-http-stream.js +108 -0
- package/build/core/create-http-stream.js.map +1 -0
- package/build/{create-http-stream.test.js → core/create-http-stream.test.js} +1 -1
- package/build/core/create-http-stream.test.js.map +1 -0
- package/build/core/create-http.d.ts +51 -0
- package/build/core/create-http.js +65 -0
- package/build/core/create-http.js.map +1 -0
- package/build/{create-http.test.js → core/create-http.test.js} +13 -4
- package/build/core/create-http.test.js.map +1 -0
- package/build/core/create-stream.d.ts +26 -0
- package/build/core/create-stream.js +80 -0
- package/build/core/create-stream.js.map +1 -0
- package/build/{create-stream.test.js → core/create-stream.test.js} +23 -28
- package/build/core/create-stream.test.js.map +1 -0
- package/build/core/create.d.ts +22 -0
- package/build/core/create.js +71 -0
- package/build/core/create.js.map +1 -0
- package/build/{create.test.js → core/create.test.js} +25 -46
- package/build/core/create.test.js.map +1 -0
- package/build/core/definition-site.d.ts +24 -0
- package/build/{stack-utils.js → core/definition-site.js} +20 -20
- package/build/core/definition-site.js.map +1 -0
- package/build/{stack-utils.test.js → core/definition-site.test.js} +12 -3
- package/build/core/definition-site.test.js.map +1 -0
- package/build/{errors.d.ts → core/errors.d.ts} +19 -8
- package/build/{errors.js → core/errors.js} +21 -26
- package/build/core/errors.js.map +1 -0
- package/build/core/errors.test.js.map +1 -0
- package/build/core/factory-options.test.js +82 -0
- package/build/core/factory-options.test.js.map +1 -0
- package/build/core/http-route.d.ts +13 -0
- package/build/core/http-route.js +54 -0
- package/build/core/http-route.js.map +1 -0
- package/build/core/internal.d.ts +72 -0
- package/build/core/internal.js +128 -0
- package/build/core/internal.js.map +1 -0
- package/build/{migration.test.js → core/migration.test.js} +17 -1
- package/build/core/migration.test.js.map +1 -0
- package/build/core/procedures.d.ts +143 -0
- package/build/core/procedures.js +64 -0
- package/build/core/procedures.js.map +1 -0
- package/build/{index.test.js → core/procedures.test.js} +14 -11
- package/build/core/procedures.test.js.map +1 -0
- package/build/core/types.d.ts +182 -0
- package/build/{schema → core}/types.js.map +1 -1
- package/build/exports.d.ts +31 -11
- package/build/exports.js +23 -8
- package/build/exports.js.map +1 -1
- package/build/schema/adapter.d.ts +35 -0
- package/build/schema/adapter.js +13 -0
- package/build/schema/adapter.js.map +1 -0
- package/build/schema/adapter.test.js +53 -0
- package/build/schema/adapter.test.js.map +1 -0
- package/build/schema/compile.d.ts +37 -0
- package/build/schema/compile.js +38 -0
- package/build/schema/compile.js.map +1 -0
- package/build/schema/compile.test.js +78 -0
- package/build/schema/compile.test.js.map +1 -0
- package/build/schema/compute-schema.d.ts +47 -37
- package/build/schema/compute-schema.js +86 -29
- package/build/schema/compute-schema.js.map +1 -1
- package/build/schema/compute-schema.test.js +158 -40
- package/build/schema/compute-schema.test.js.map +1 -1
- package/build/schema/json-schema.d.ts +17 -0
- package/build/schema/json-schema.js +2 -0
- package/build/schema/json-schema.js.map +1 -0
- package/build/schema/typebox.d.ts +11 -0
- package/build/schema/typebox.js +24 -0
- package/build/schema/typebox.js.map +1 -0
- package/build/schema/typebox.test.js +34 -0
- package/build/schema/typebox.test.js.map +1 -0
- package/build/server/context.d.ts +8 -0
- package/build/server/context.js +7 -0
- package/build/server/context.js.map +1 -0
- package/build/server/context.test.js +16 -0
- package/build/server/context.test.js.map +1 -0
- package/build/{doc-envelope.d.ts → server/doc-envelope.d.ts} +1 -1
- package/build/server/doc-envelope.js.map +1 -0
- package/build/server/doc-envelope.test.d.ts +1 -0
- package/build/server/doc-envelope.test.js.map +1 -0
- package/build/{implementations/http → server}/doc-registry.d.ts +7 -2
- package/build/{implementations/http → server}/doc-registry.js +9 -5
- package/build/server/doc-registry.js.map +1 -0
- package/build/server/doc-registry.test.d.ts +1 -0
- package/build/{implementations/http → server}/doc-registry.test.js +27 -24
- package/build/server/doc-registry.test.js.map +1 -0
- package/build/server/docs/docs.test.d.ts +1 -0
- package/build/server/docs/docs.test.js +237 -0
- package/build/server/docs/docs.test.js.map +1 -0
- package/build/{implementations/http/hono → server}/docs/http-doc.d.ts +2 -2
- package/build/{implementations/http/hono → server}/docs/http-doc.js +1 -1
- package/build/server/docs/http-doc.js.map +1 -0
- package/build/{implementations/http/hono → server}/docs/http-stream-doc.d.ts +2 -2
- package/build/{implementations/http/hono → server}/docs/http-stream-doc.js +1 -1
- package/build/server/docs/http-stream-doc.js.map +1 -0
- package/build/{implementations/http/hono → server}/docs/rpc-doc.d.ts +2 -2
- package/build/{implementations/http/hono → server}/docs/rpc-doc.js +1 -1
- package/build/server/docs/rpc-doc.js.map +1 -0
- package/build/{implementations/http/hono → server}/docs/stream-doc.d.ts +2 -2
- package/build/{implementations/http/hono → server}/docs/stream-doc.js +1 -1
- package/build/server/docs/stream-doc.js.map +1 -0
- package/build/server/errors/dispatch.d.ts +96 -0
- package/build/{implementations/http/error-dispatch.js → server/errors/dispatch.js} +20 -10
- package/build/server/errors/dispatch.js.map +1 -0
- package/build/server/errors/dispatch.test.d.ts +1 -0
- package/build/server/errors/dispatch.test.js +418 -0
- package/build/server/errors/dispatch.test.js.map +1 -0
- package/build/{implementations/http/error-taxonomy.d.ts → server/errors/taxonomy.d.ts} +8 -17
- package/build/{implementations/http/error-taxonomy.js → server/errors/taxonomy.js} +6 -15
- package/build/server/errors/taxonomy.js.map +1 -0
- package/build/server/errors/taxonomy.test.d.ts +1 -0
- package/build/{implementations/http/error-taxonomy.test.js → server/errors/taxonomy.test.js} +45 -39
- package/build/server/errors/taxonomy.test.js.map +1 -0
- package/build/server/index.d.ts +29 -0
- package/build/server/index.js +27 -0
- package/build/server/index.js.map +1 -0
- package/build/server/no-framework-imports.test.d.ts +1 -0
- package/build/server/no-framework-imports.test.js +40 -0
- package/build/server/no-framework-imports.test.js.map +1 -0
- package/build/{implementations/http/hono/path.d.ts → server/paths.d.ts} +2 -3
- package/build/{implementations/http/hono/path.js → server/paths.js} +1 -1
- package/build/server/paths.js.map +1 -0
- package/build/server/paths.test.d.ts +1 -0
- package/build/server/paths.test.js +111 -0
- package/build/server/paths.test.js.map +1 -0
- package/build/server/request/params.d.ts +29 -0
- package/build/server/request/params.js +43 -0
- package/build/server/request/params.js.map +1 -0
- package/build/server/request/params.test.d.ts +1 -0
- package/build/server/request/params.test.js +91 -0
- package/build/server/request/params.test.js.map +1 -0
- package/build/server/request/query.d.ts +9 -0
- package/build/server/request/query.js +22 -0
- package/build/server/request/query.js.map +1 -0
- package/build/server/request/query.test.d.ts +1 -0
- package/build/server/request/query.test.js +60 -0
- package/build/server/request/query.test.js.map +1 -0
- package/build/server/sse.d.ts +70 -0
- package/build/server/sse.js +94 -0
- package/build/server/sse.js.map +1 -0
- package/build/server/sse.test.d.ts +1 -0
- package/build/server/sse.test.js +98 -0
- package/build/server/sse.test.js.map +1 -0
- package/build/{implementations → server}/types.d.ts +17 -15
- package/build/{implementations → server}/types.js.map +1 -1
- package/docs/astro-adapter.md +8 -9
- package/docs/client-and-codegen.md +4 -4
- package/docs/client-error-handling.md +92 -5
- package/docs/codegen-kotlin.md +2 -3
- package/docs/codegen-swift.md +1 -2
- package/docs/core.md +135 -54
- package/docs/http-integrations.md +83 -6
- package/docs/migration-v8-to-v9.md +192 -0
- package/docs/plans/2026-06-09-v9-rewrite.md +130 -0
- package/docs/specs/2026-06-09-v9-rewrite-design.md +221 -0
- package/docs/streaming.md +12 -0
- package/package.json +23 -47
- package/src/{implementations/http → adapters}/astro/index.test.ts +2 -2
- package/src/adapters/hono/__fixtures__/parity-envelope.json +389 -0
- package/src/adapters/hono/envelope-parity.test.ts +126 -0
- package/src/{implementations/http → adapters}/hono/handlers/http-stream.test.ts +1 -1
- package/src/adapters/hono/handlers/http-stream.ts +73 -0
- package/src/{implementations/http → adapters}/hono/handlers/http.test.ts +1 -1
- package/src/adapters/hono/handlers/http.ts +70 -0
- package/src/{implementations/http → adapters}/hono/handlers/rpc.test.ts +2 -2
- package/src/adapters/hono/handlers/rpc.ts +39 -0
- package/src/{implementations/http → adapters}/hono/handlers/stream.test.ts +4 -3
- package/src/{implementations/http → adapters}/hono/handlers/stream.ts +19 -92
- package/src/{implementations/http → adapters}/hono/index.test.ts +14 -16
- package/src/{implementations/http → adapters}/hono/index.ts +35 -30
- package/src/{implementations/http → adapters/hono}/on-request-error.test.ts +3 -3
- package/src/adapters/hono/request.ts +28 -0
- package/src/{implementations/http → adapters/hono}/route-errors.test.ts +5 -5
- package/src/{implementations/http → adapters}/hono/types.ts +43 -20
- package/src/client/freeze.test.ts +41 -0
- package/src/client/typed-error-dispatch.test.ts +3 -3
- package/src/codegen/__fixtures__/make-envelope.ts +1 -1
- package/src/codegen/__fixtures__/models-envelope.json +310 -0
- package/src/codegen/__fixtures__/users-envelope.json +9 -0
- package/src/codegen/__goldens__/MANIFEST.json +85 -0
- package/src/codegen/__goldens__/kotlin-default--models/Billing.kt +112 -0
- package/src/codegen/__goldens__/kotlin-default--models/BillingReports.kt +26 -0
- package/src/codegen/__goldens__/kotlin-default--models/Orders.kt +88 -0
- package/src/codegen/__goldens__/kotlin-default--users/Users.kt +189 -0
- package/src/codegen/__goldens__/swift-default--models/Billing.swift +97 -0
- package/src/codegen/__goldens__/swift-default--models/BillingReports.swift +20 -0
- package/src/codegen/__goldens__/swift-default--models/Orders.swift +81 -0
- package/src/codegen/__goldens__/swift-default--users/Users.swift +204 -0
- package/src/codegen/__goldens__/ts-default--models/_client.ts +1319 -0
- package/src/codegen/__goldens__/ts-default--models/_errors.ts +90 -0
- package/src/codegen/__goldens__/ts-default--models/_models.ts +10 -0
- package/src/codegen/__goldens__/ts-default--models/_types.ts +502 -0
- package/src/codegen/__goldens__/ts-default--models/billing-reports.ts +29 -0
- package/src/codegen/__goldens__/ts-default--models/billing.ts +67 -0
- package/src/codegen/__goldens__/ts-default--models/index.ts +48 -0
- package/src/codegen/__goldens__/ts-default--models/orders.ts +80 -0
- package/src/codegen/__goldens__/ts-default--users/_client.ts +1319 -0
- package/src/codegen/__goldens__/ts-default--users/_errors.ts +90 -0
- package/src/codegen/__goldens__/ts-default--users/_types.ts +502 -0
- package/src/codegen/__goldens__/ts-default--users/index.ts +38 -0
- package/src/codegen/__goldens__/ts-default--users/users.ts +169 -0
- package/src/codegen/__goldens__/ts-external-runtime--models/_errors.ts +90 -0
- package/src/codegen/__goldens__/ts-external-runtime--models/_models.ts +10 -0
- package/src/codegen/__goldens__/ts-external-runtime--models/billing-reports.ts +29 -0
- package/src/codegen/__goldens__/ts-external-runtime--models/billing.ts +67 -0
- package/src/codegen/__goldens__/ts-external-runtime--models/index.ts +48 -0
- package/src/codegen/__goldens__/ts-external-runtime--models/orders.ts +80 -0
- package/src/codegen/__goldens__/ts-external-runtime--users/_errors.ts +90 -0
- package/src/codegen/__goldens__/ts-external-runtime--users/index.ts +38 -0
- package/src/codegen/__goldens__/ts-external-runtime--users/users.ts +169 -0
- package/src/codegen/__goldens__/ts-flat--models/_client.ts +1319 -0
- package/src/codegen/__goldens__/ts-flat--models/_errors.ts +87 -0
- package/src/codegen/__goldens__/ts-flat--models/_models.ts +10 -0
- package/src/codegen/__goldens__/ts-flat--models/_types.ts +502 -0
- package/src/codegen/__goldens__/ts-flat--models/billing-reports.ts +28 -0
- package/src/codegen/__goldens__/ts-flat--models/billing.ts +51 -0
- package/src/codegen/__goldens__/ts-flat--models/index.ts +42 -0
- package/src/codegen/__goldens__/ts-flat--models/orders.ts +73 -0
- package/src/codegen/__goldens__/ts-flat--users/_client.ts +1319 -0
- package/src/codegen/__goldens__/ts-flat--users/_errors.ts +87 -0
- package/src/codegen/__goldens__/ts-flat--users/_types.ts +502 -0
- package/src/codegen/__goldens__/ts-flat--users/index.ts +34 -0
- package/src/codegen/__goldens__/ts-flat--users/users.ts +126 -0
- package/src/codegen/__goldens__/ts-no-share-models--models/_client.ts +1319 -0
- package/src/codegen/__goldens__/ts-no-share-models--models/_errors.ts +90 -0
- package/src/codegen/__goldens__/ts-no-share-models--models/_types.ts +502 -0
- package/src/codegen/__goldens__/ts-no-share-models--models/billing-reports.ts +29 -0
- package/src/codegen/__goldens__/ts-no-share-models--models/billing.ts +111 -0
- package/src/codegen/__goldens__/ts-no-share-models--models/index.ts +48 -0
- package/src/codegen/__goldens__/ts-no-share-models--models/orders.ts +112 -0
- package/src/codegen/__goldens__/ts-no-share-models--users/_client.ts +1319 -0
- package/src/codegen/__goldens__/ts-no-share-models--users/_errors.ts +90 -0
- package/src/codegen/__goldens__/ts-no-share-models--users/_types.ts +502 -0
- package/src/codegen/__goldens__/ts-no-share-models--users/index.ts +38 -0
- package/src/codegen/__goldens__/ts-no-share-models--users/users.ts +169 -0
- package/src/codegen/__goldens__/ts-shared-models-module--models/_client.ts +1319 -0
- package/src/codegen/__goldens__/ts-shared-models-module--models/_errors.ts +90 -0
- package/src/codegen/__goldens__/ts-shared-models-module--models/_models.ts +7 -0
- package/src/codegen/__goldens__/ts-shared-models-module--models/_types.ts +502 -0
- package/src/codegen/__goldens__/ts-shared-models-module--models/billing-reports.ts +29 -0
- package/src/codegen/__goldens__/ts-shared-models-module--models/billing.ts +67 -0
- package/src/codegen/__goldens__/ts-shared-models-module--models/index.ts +48 -0
- package/src/codegen/__goldens__/ts-shared-models-module--models/orders.ts +80 -0
- package/src/codegen/bin/cli.test.ts +13 -2
- package/src/codegen/bin/cli.ts +181 -144
- package/src/codegen/bin/flag-specs.test.ts +16 -1
- package/src/codegen/bin/flag-specs.ts +43 -31
- package/src/codegen/bundle-size.test.ts +1 -1
- package/src/codegen/collect-models.ts +1 -1
- package/src/codegen/e2e.test.ts +1 -1
- package/src/codegen/emit/api-route.ts +184 -0
- package/src/codegen/emit/context.ts +32 -0
- package/src/codegen/emit/declarations.ts +49 -0
- package/src/codegen/emit/format-types.ts +232 -0
- package/src/codegen/emit/http-stream-route.ts +162 -0
- package/src/codegen/emit/route-shared.ts +102 -0
- package/src/codegen/emit/rpc-route.ts +49 -0
- package/src/codegen/emit/scope-file.ts +226 -0
- package/src/codegen/emit/stream-route.ts +81 -0
- package/src/codegen/emit-errors.integration.test.ts +2 -2
- package/src/codegen/emit-errors.test.ts +1 -1
- package/src/codegen/emit-errors.ts +1 -1
- package/src/codegen/emit-index.test.ts +34 -0
- package/src/codegen/emit-index.ts +19 -0
- package/src/codegen/emit-scope.test.ts +96 -6
- package/src/codegen/emit-scope.ts +15 -1003
- package/src/codegen/goldens.test.ts +89 -0
- package/src/codegen/group-routes.test.ts +1 -1
- package/src/codegen/group-routes.ts +1 -1
- package/src/codegen/pipeline.test.ts +1 -1
- package/src/codegen/pipeline.ts +1 -1
- package/src/codegen/resolve-envelope.test.ts +1 -1
- package/src/codegen/resolve-envelope.ts +1 -1
- package/src/codegen/targets/_shared/error-schemas.test.ts +1 -1
- package/src/codegen/targets/_shared/error-schemas.ts +1 -1
- package/src/codegen/targets/_shared/route-slots.test.ts +1 -1
- package/src/codegen/targets/_shared/route-slots.ts +1 -1
- package/src/codegen/targets/_shared/target-run.ts +1 -1
- package/src/codegen/targets/kotlin/__fixtures__/users-golden.kt +6 -0
- package/src/codegen/targets/kotlin/emit-route-kotlin.test.ts +1 -1
- package/src/codegen/targets/kotlin/emit-route-kotlin.ts +1 -1
- package/src/codegen/targets/kotlin/emit-scope-kotlin.test.ts +1 -1
- package/src/codegen/targets/swift/__fixtures__/users-golden.swift +6 -0
- package/src/codegen/targets/swift/access-level.test.ts +1 -1
- package/src/codegen/targets/swift/emit-route-swift.test.ts +1 -1
- package/src/codegen/targets/swift/emit-route-swift.ts +1 -1
- package/src/codegen/targets/swift/emit-scope-swift.test.ts +1 -1
- package/src/codegen/targets/ts/shared-models.test.ts +1 -1
- package/src/{create-http-stream.test.ts → core/create-http-stream.test.ts} +1 -1
- package/src/core/create-http-stream.ts +207 -0
- package/src/{create-http.test.ts → core/create-http.test.ts} +15 -4
- package/src/core/create-http.ts +126 -0
- package/src/{create-stream.test.ts → core/create-stream.test.ts} +28 -31
- package/src/core/create-stream.ts +142 -0
- package/src/{create.test.ts → core/create.test.ts} +25 -57
- package/src/core/create.ts +121 -0
- package/src/{stack-utils.test.ts → core/definition-site.test.ts} +14 -3
- package/src/{stack-utils.ts → core/definition-site.ts} +20 -23
- package/src/{errors.test.ts → core/errors.test.ts} +1 -1
- package/src/{errors.ts → core/errors.ts} +30 -28
- package/src/core/factory-options.test.ts +112 -0
- package/src/core/http-route.ts +73 -0
- package/src/core/internal.ts +203 -0
- package/src/{migration.test.ts → core/migration.test.ts} +23 -1
- package/src/{index.test.ts → core/procedures.test.ts} +13 -11
- package/src/core/procedures.ts +75 -0
- package/src/core/types.ts +195 -0
- package/src/exports.ts +60 -11
- package/src/schema/adapter.test.ts +58 -0
- package/src/schema/adapter.ts +45 -0
- package/src/schema/compile.test.ts +95 -0
- package/src/schema/compile.ts +64 -0
- package/src/schema/compute-schema.test.ts +222 -41
- package/src/schema/compute-schema.ts +145 -71
- package/src/schema/json-schema.ts +21 -0
- package/src/schema/typebox.test.ts +40 -0
- package/src/schema/typebox.ts +27 -0
- package/src/server/context.test.ts +22 -0
- package/src/server/context.ts +18 -0
- package/src/{doc-envelope.test.ts → server/doc-envelope.test.ts} +2 -2
- package/src/{doc-envelope.ts → server/doc-envelope.ts} +1 -1
- package/src/{implementations/http → server}/doc-registry.test.ts +32 -26
- package/src/{implementations/http → server}/doc-registry.ts +11 -7
- package/src/server/docs/docs.test.ts +287 -0
- package/src/{implementations/http/hono → server}/docs/http-doc.ts +3 -3
- package/src/{implementations/http/hono → server}/docs/http-stream-doc.ts +3 -3
- package/src/{implementations/http/hono → server}/docs/rpc-doc.ts +3 -3
- package/src/{implementations/http/hono → server}/docs/stream-doc.ts +3 -3
- package/src/server/errors/dispatch.test.ts +450 -0
- package/src/server/errors/dispatch.ts +189 -0
- package/src/{implementations/http/error-taxonomy.test.ts → server/errors/taxonomy.test.ts} +45 -39
- package/src/{implementations/http/error-taxonomy.ts → server/errors/taxonomy.ts} +8 -17
- package/src/server/index.ts +29 -0
- package/src/server/no-framework-imports.test.ts +43 -0
- package/src/server/paths.test.ts +141 -0
- package/src/{implementations/http/hono/path.ts → server/paths.ts} +2 -13
- package/src/server/request/params.test.ts +143 -0
- package/src/server/request/params.ts +68 -0
- package/src/server/request/query.test.ts +70 -0
- package/src/server/request/query.ts +24 -0
- package/src/server/sse.test.ts +113 -0
- package/src/server/sse.ts +117 -0
- package/src/{implementations → server}/types.ts +17 -16
- package/build/create-http-stream.d.ts +0 -58
- package/build/create-http-stream.js +0 -122
- package/build/create-http-stream.js.map +0 -1
- package/build/create-http-stream.test.js.map +0 -1
- package/build/create-http.d.ts +0 -49
- package/build/create-http.js +0 -108
- package/build/create-http.js.map +0 -1
- package/build/create-http.test.js.map +0 -1
- package/build/create-stream.d.ts +0 -35
- package/build/create-stream.js +0 -123
- package/build/create-stream.js.map +0 -1
- package/build/create-stream.test.js.map +0 -1
- package/build/create.d.ts +0 -28
- package/build/create.js +0 -82
- package/build/create.js.map +0 -1
- package/build/create.test.js.map +0 -1
- package/build/doc-envelope.js.map +0 -1
- package/build/doc-envelope.test.js.map +0 -1
- package/build/errors.js.map +0 -1
- package/build/errors.test.js.map +0 -1
- package/build/implementations/http/astro/astro-context.js.map +0 -1
- package/build/implementations/http/astro/create-handler.js.map +0 -1
- package/build/implementations/http/astro/index.js.map +0 -1
- package/build/implementations/http/astro/index.test.js.map +0 -1
- package/build/implementations/http/astro/rewrite-request.js.map +0 -1
- package/build/implementations/http/doc-registry.js.map +0 -1
- package/build/implementations/http/doc-registry.test.js.map +0 -1
- package/build/implementations/http/error-dispatch.d.ts +0 -76
- package/build/implementations/http/error-dispatch.js.map +0 -1
- package/build/implementations/http/error-dispatch.test.js +0 -254
- package/build/implementations/http/error-dispatch.test.js.map +0 -1
- package/build/implementations/http/error-taxonomy.js.map +0 -1
- package/build/implementations/http/error-taxonomy.test.js.map +0 -1
- package/build/implementations/http/hono/docs/http-doc.js.map +0 -1
- package/build/implementations/http/hono/docs/http-stream-doc.js.map +0 -1
- package/build/implementations/http/hono/docs/rpc-doc.js.map +0 -1
- package/build/implementations/http/hono/docs/stream-doc.js.map +0 -1
- package/build/implementations/http/hono/handlers/http-stream.js +0 -123
- package/build/implementations/http/hono/handlers/http-stream.js.map +0 -1
- package/build/implementations/http/hono/handlers/http-stream.test.js.map +0 -1
- package/build/implementations/http/hono/handlers/http.js +0 -110
- package/build/implementations/http/hono/handlers/http.js.map +0 -1
- package/build/implementations/http/hono/handlers/http.test.js.map +0 -1
- package/build/implementations/http/hono/handlers/rpc.js +0 -32
- package/build/implementations/http/hono/handlers/rpc.js.map +0 -1
- package/build/implementations/http/hono/handlers/rpc.test.js.map +0 -1
- package/build/implementations/http/hono/handlers/stream.d.ts +0 -23
- package/build/implementations/http/hono/handlers/stream.js +0 -147
- package/build/implementations/http/hono/handlers/stream.js.map +0 -1
- package/build/implementations/http/hono/handlers/stream.test.js.map +0 -1
- package/build/implementations/http/hono/index.js.map +0 -1
- package/build/implementations/http/hono/index.test.js.map +0 -1
- package/build/implementations/http/hono/path.js.map +0 -1
- package/build/implementations/http/hono/path.test.js +0 -83
- package/build/implementations/http/hono/path.test.js.map +0 -1
- package/build/implementations/http/hono/types.d.ts +0 -51
- package/build/implementations/http/hono/types.js.map +0 -1
- package/build/implementations/http/on-request-error.test.js.map +0 -1
- package/build/implementations/http/route-errors.test.js.map +0 -1
- package/build/index.d.ts +0 -175
- package/build/index.js +0 -47
- package/build/index.js.map +0 -1
- package/build/index.test.js.map +0 -1
- package/build/migration.test.js.map +0 -1
- package/build/schema/extract-json-schema.d.ts +0 -2
- package/build/schema/extract-json-schema.js +0 -12
- package/build/schema/extract-json-schema.js.map +0 -1
- package/build/schema/extract-json-schema.test.js +0 -23
- package/build/schema/extract-json-schema.test.js.map +0 -1
- package/build/schema/parser.d.ts +0 -36
- package/build/schema/parser.js +0 -210
- package/build/schema/parser.js.map +0 -1
- package/build/schema/parser.test.js +0 -120
- package/build/schema/parser.test.js.map +0 -1
- package/build/schema/resolve-schema-lib.d.ts +0 -12
- package/build/schema/resolve-schema-lib.js +0 -11
- package/build/schema/resolve-schema-lib.js.map +0 -1
- package/build/schema/resolve-schema-lib.test.js +0 -17
- package/build/schema/resolve-schema-lib.test.js.map +0 -1
- package/build/schema/types.d.ts +0 -8
- package/build/schema/types.js +0 -2
- package/build/stack-utils.d.ts +0 -25
- package/build/stack-utils.js.map +0 -1
- package/build/stack-utils.test.js.map +0 -1
- package/build/types.d.ts +0 -142
- package/build/types.js +0 -2
- package/build/types.js.map +0 -1
- package/docs/decisions/2026-06-02-monorepo-split-evaluation.md +0 -80
- package/docs/handoffs/ajsc-named-type-collision.md +0 -134
- package/docs/handoffs/ajsc-named-type-support.md +0 -181
- package/docs/handoffs/shared-models-auto-resolve-response.md +0 -181
- package/docs/npm-workspaces-migration-plan.md +0 -611
- package/docs/superpowers/plans/2026-04-24-doc-registry-simplification.md +0 -886
- package/docs/superpowers/plans/2026-04-24-kotlin-codegen-target.md +0 -1265
- package/docs/superpowers/plans/2026-04-25-ajsc-v7-kotlin-polish.md +0 -1993
- package/docs/superpowers/plans/2026-04-29-safe-result-api.md +0 -2293
- package/docs/superpowers/plans/2026-05-07-astro-adapter.md +0 -1391
- package/docs/superpowers/plans/2026-05-08-create-http.md +0 -3355
- package/docs/superpowers/plans/2026-05-08-hono-app-builder-convergence.md +0 -3365
- package/docs/superpowers/plans/2026-06-05-dx-feedback-round.md +0 -1292
- package/docs/superpowers/plans/2026-06-06-shared-models-convention-and-diagnostics.md +0 -659
- package/docs/superpowers/specs/2026-04-24-kotlin-swift-codegen-design.md +0 -401
- package/docs/superpowers/specs/2026-04-25-ajsc-v7-kotlin-polish-design.md +0 -314
- package/docs/superpowers/specs/2026-04-25-swift-codegen-design.md +0 -264
- package/docs/superpowers/specs/2026-04-29-safe-result-api-design.md +0 -324
- package/docs/superpowers/specs/2026-05-07-astro-adapter-design.md +0 -252
- package/docs/superpowers/specs/2026-05-08-create-http-design.md +0 -409
- package/docs/superpowers/specs/2026-05-08-hono-app-builder-convergence-design.md +0 -411
- package/docs/superpowers/specs/2026-06-05-dx-feedback-round-design.md +0 -285
- package/src/create-http-stream.ts +0 -191
- package/src/create-http.ts +0 -210
- package/src/create-stream.ts +0 -228
- package/src/create.ts +0 -172
- package/src/implementations/http/README.md +0 -390
- package/src/implementations/http/error-dispatch.test.ts +0 -283
- package/src/implementations/http/error-dispatch.ts +0 -176
- package/src/implementations/http/hono/handlers/http-stream.ts +0 -152
- package/src/implementations/http/hono/handlers/http.ts +0 -145
- package/src/implementations/http/hono/handlers/rpc.ts +0 -54
- package/src/implementations/http/hono/path.test.ts +0 -96
- package/src/index.ts +0 -101
- package/src/schema/extract-json-schema.test.ts +0 -25
- package/src/schema/extract-json-schema.ts +0 -15
- package/src/schema/parser.test.ts +0 -182
- package/src/schema/parser.ts +0 -265
- package/src/schema/resolve-schema-lib.test.ts +0 -19
- package/src/schema/resolve-schema-lib.ts +0 -29
- package/src/schema/types.ts +0 -20
- package/src/types.ts +0 -133
- /package/build/{implementations/http → adapters}/astro/astro-context.d.ts +0 -0
- /package/build/{implementations/http → adapters}/astro/astro-context.js +0 -0
- /package/build/{implementations/http → adapters}/astro/create-handler.d.ts +0 -0
- /package/build/{implementations/http → adapters}/astro/create-handler.js +0 -0
- /package/build/{implementations/http → adapters}/astro/index.d.ts +0 -0
- /package/build/{implementations/http → adapters}/astro/index.js +0 -0
- /package/build/{implementations/http → adapters}/astro/index.test.d.ts +0 -0
- /package/build/{implementations/http → adapters}/astro/rewrite-request.d.ts +0 -0
- /package/build/{implementations/http → adapters}/astro/rewrite-request.js +0 -0
- /package/build/{create-http-stream.test.d.ts → adapters/hono/envelope-parity.test.d.ts} +0 -0
- /package/build/{implementations/http → adapters}/hono/handlers/http-stream.test.d.ts +0 -0
- /package/build/{implementations/http → adapters}/hono/handlers/http.test.d.ts +0 -0
- /package/build/{implementations/http → adapters}/hono/handlers/rpc.test.d.ts +0 -0
- /package/build/{implementations/http → adapters}/hono/handlers/stream.test.d.ts +0 -0
- /package/build/{implementations/http → adapters}/hono/index.test.d.ts +0 -0
- /package/build/{implementations/http → adapters/hono}/on-request-error.test.d.ts +0 -0
- /package/build/{implementations/http → adapters/hono}/route-errors.test.d.ts +0 -0
- /package/build/{create-http.test.d.ts → client/freeze.test.d.ts} +0 -0
- /package/build/{create-stream.test.d.ts → codegen/goldens.test.d.ts} +0 -0
- /package/build/{create.test.d.ts → core/create-http-stream.test.d.ts} +0 -0
- /package/build/{doc-envelope.test.d.ts → core/create-http.test.d.ts} +0 -0
- /package/build/{errors.test.d.ts → core/create-stream.test.d.ts} +0 -0
- /package/build/{implementations/http/doc-registry.test.d.ts → core/create.test.d.ts} +0 -0
- /package/build/{implementations/http/error-dispatch.test.d.ts → core/definition-site.test.d.ts} +0 -0
- /package/build/{implementations/http/error-taxonomy.test.d.ts → core/errors.test.d.ts} +0 -0
- /package/build/{errors.test.js → core/errors.test.js} +0 -0
- /package/build/{implementations/http/hono/path.test.d.ts → core/factory-options.test.d.ts} +0 -0
- /package/build/{migration.test.d.ts → core/migration.test.d.ts} +0 -0
- /package/build/{index.test.d.ts → core/procedures.test.d.ts} +0 -0
- /package/build/{implementations/http/hono → core}/types.js +0 -0
- /package/build/schema/{extract-json-schema.test.d.ts → adapter.test.d.ts} +0 -0
- /package/build/schema/{parser.test.d.ts → compile.test.d.ts} +0 -0
- /package/build/schema/{resolve-schema-lib.test.d.ts → typebox.test.d.ts} +0 -0
- /package/build/{stack-utils.test.d.ts → server/context.test.d.ts} +0 -0
- /package/build/{doc-envelope.js → server/doc-envelope.js} +0 -0
- /package/build/{doc-envelope.test.js → server/doc-envelope.test.js} +0 -0
- /package/build/{implementations → server}/types.js +0 -0
- /package/src/{implementations/http → adapters}/astro/README.md +0 -0
- /package/src/{implementations/http → adapters}/astro/astro-context.ts +0 -0
- /package/src/{implementations/http → adapters}/astro/create-handler.ts +0 -0
- /package/src/{implementations/http → adapters}/astro/index.ts +0 -0
- /package/src/{implementations/http → adapters}/astro/rewrite-request.ts +0 -0
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import type { Context } from 'hono'
|
|
2
|
-
import {
|
|
3
|
-
resolveErrorResponse,
|
|
4
|
-
type ErrorTaxonomy,
|
|
5
|
-
type TAnyProcedureRegistration,
|
|
6
|
-
type UnknownErrorConfig,
|
|
7
|
-
} from './error-taxonomy.js'
|
|
8
|
-
import type { TStreamProcedureRegistration, THttpStreamProcedureRegistration } from '../../types.js'
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Public alias of {@link TAnyProcedureRegistration} — re-exported here so the
|
|
12
|
-
* hono/ module can import it from one place without taking a direct dependency
|
|
13
|
-
* on error-taxonomy internals. Single source of truth lives in
|
|
14
|
-
* error-taxonomy.ts.
|
|
15
|
-
*/
|
|
16
|
-
export type AnyProcedureRegistration = TAnyProcedureRegistration
|
|
17
|
-
|
|
18
|
-
export type OnRequestErrorContext = {
|
|
19
|
-
err: unknown
|
|
20
|
-
procedure: AnyProcedureRegistration
|
|
21
|
-
raw: Context
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export type OnRequestErrorObserver = (
|
|
25
|
-
ctx: OnRequestErrorContext,
|
|
26
|
-
) => void | Promise<void>
|
|
27
|
-
|
|
28
|
-
export type PreStreamOnError = (
|
|
29
|
-
procedure: AnyProcedureRegistration,
|
|
30
|
-
raw: Context,
|
|
31
|
-
err: Error,
|
|
32
|
-
) => Response | Promise<Response>
|
|
33
|
-
|
|
34
|
-
export type PreStreamErrorConfig = {
|
|
35
|
-
errors?: ErrorTaxonomy
|
|
36
|
-
unknownError?: UnknownErrorConfig
|
|
37
|
-
onError?: PreStreamOnError
|
|
38
|
-
onRequestError?: OnRequestErrorObserver
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Used by rpc, http, and the pre-stream guard in stream / http-stream
|
|
43
|
-
* handlers. Order: onRequestError observer (awaited, throws swallowed) →
|
|
44
|
-
* taxonomy resolver → imperative onError → hard default 500.
|
|
45
|
-
*/
|
|
46
|
-
export async function dispatchPreStreamError(params: {
|
|
47
|
-
err: unknown
|
|
48
|
-
procedure: AnyProcedureRegistration
|
|
49
|
-
raw: Context
|
|
50
|
-
cfg: PreStreamErrorConfig
|
|
51
|
-
}): Promise<Response> {
|
|
52
|
-
const { err, procedure, raw, cfg } = params
|
|
53
|
-
|
|
54
|
-
if (cfg.onRequestError) {
|
|
55
|
-
try {
|
|
56
|
-
await cfg.onRequestError({ err, procedure, raw })
|
|
57
|
-
} catch (observerErr) {
|
|
58
|
-
console.error(
|
|
59
|
-
'[ts-procedures hono] onRequestError threw — swallowed:',
|
|
60
|
-
observerErr,
|
|
61
|
-
)
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const resolved = resolveErrorResponse({
|
|
66
|
-
err,
|
|
67
|
-
userTaxonomy: cfg.errors,
|
|
68
|
-
unknownError: cfg.unknownError,
|
|
69
|
-
procedure,
|
|
70
|
-
raw,
|
|
71
|
-
})
|
|
72
|
-
if (resolved) {
|
|
73
|
-
await resolved.runOnCatch()
|
|
74
|
-
return raw.json(resolved.body, resolved.statusCode as never)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (cfg.onError) {
|
|
78
|
-
return cfg.onError(procedure, raw, err as Error)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return raw.json({ error: (err as Error).message }, 500)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Return shape of an `onMidStreamError` callback.
|
|
86
|
-
*
|
|
87
|
-
* - `data`: the value to write to the open stream as the error payload.
|
|
88
|
-
* Decorate with the `sse(data, { event, id, retry })` helper from
|
|
89
|
-
* `hono/handlers/stream` to attach SSE metadata; the stream handler
|
|
90
|
-
* reads that metadata via `getSSEMeta` after dispatch.
|
|
91
|
-
* - `closeStream`: reserved for future use. The stream currently always
|
|
92
|
-
* closes naturally after the catch block returns; this flag is kept on
|
|
93
|
-
* the public type for forward compatibility but the dispatcher does not
|
|
94
|
-
* read it.
|
|
95
|
-
*/
|
|
96
|
-
export type MidStreamErrorResult<TErrorData = unknown> = {
|
|
97
|
-
data: TErrorData
|
|
98
|
-
closeStream?: boolean
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export type OnMidStreamError<TErrorData = unknown> = (
|
|
102
|
-
procedure: TStreamProcedureRegistration | THttpStreamProcedureRegistration<any>,
|
|
103
|
-
raw: Context,
|
|
104
|
-
err: Error,
|
|
105
|
-
) => MidStreamErrorResult<TErrorData> | undefined
|
|
106
|
-
|
|
107
|
-
export type MidStreamErrorConfig<TErrorData = unknown> = {
|
|
108
|
-
errors?: ErrorTaxonomy
|
|
109
|
-
unknownError?: UnknownErrorConfig
|
|
110
|
-
onMidStreamError?: OnMidStreamError<TErrorData>
|
|
111
|
-
onRequestError?: OnRequestErrorObserver
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export type DispatchedMidStreamError = {
|
|
115
|
-
data: unknown
|
|
116
|
-
sseEvent?: string
|
|
117
|
-
sseId?: string
|
|
118
|
-
sseRetry?: number
|
|
119
|
-
runOnCatch?: () => Promise<void>
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Used inside SSE / text-stream generator catch blocks. Returns the bytes
|
|
124
|
-
* to write to the open stream — the HTTP status is already committed, so we
|
|
125
|
-
* can't return a Response. Order matches dispatchPreStreamError: observer
|
|
126
|
-
* (awaited, throws swallowed) → taxonomy → onMidStreamError → hard default.
|
|
127
|
-
*/
|
|
128
|
-
export async function dispatchMidStreamError<TErrorData = unknown>(params: {
|
|
129
|
-
err: unknown
|
|
130
|
-
procedure: TStreamProcedureRegistration | THttpStreamProcedureRegistration<any>
|
|
131
|
-
raw: Context
|
|
132
|
-
cfg: MidStreamErrorConfig<TErrorData>
|
|
133
|
-
}): Promise<DispatchedMidStreamError> {
|
|
134
|
-
const { err, procedure, raw, cfg } = params
|
|
135
|
-
|
|
136
|
-
if (cfg.onRequestError) {
|
|
137
|
-
try {
|
|
138
|
-
await cfg.onRequestError({ err, procedure, raw })
|
|
139
|
-
} catch (observerErr) {
|
|
140
|
-
console.error(
|
|
141
|
-
'[ts-procedures hono] onRequestError (mid-stream) threw — swallowed:',
|
|
142
|
-
observerErr,
|
|
143
|
-
)
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
const resolved = resolveErrorResponse({
|
|
148
|
-
err,
|
|
149
|
-
userTaxonomy: cfg.errors,
|
|
150
|
-
unknownError: cfg.unknownError,
|
|
151
|
-
procedure,
|
|
152
|
-
raw,
|
|
153
|
-
})
|
|
154
|
-
if (resolved) {
|
|
155
|
-
return {
|
|
156
|
-
data: resolved.body,
|
|
157
|
-
sseEvent: 'error',
|
|
158
|
-
runOnCatch: resolved.runOnCatch,
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
if (cfg.onMidStreamError) {
|
|
163
|
-
const result = cfg.onMidStreamError(procedure, raw, err as Error)
|
|
164
|
-
if (result?.data !== undefined) {
|
|
165
|
-
return {
|
|
166
|
-
data: result.data,
|
|
167
|
-
sseEvent: procedure.name,
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
return {
|
|
173
|
-
data: { error: (err as Error).message },
|
|
174
|
-
sseEvent: 'error',
|
|
175
|
-
}
|
|
176
|
-
}
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import type { Context, Hono } from 'hono'
|
|
2
|
-
import { streamSSE } from 'hono/streaming'
|
|
3
|
-
import type { THttpStreamProcedureRegistration } from '../../../../types.js'
|
|
4
|
-
import type { HttpMethod } from '../../../types.js'
|
|
5
|
-
import { dispatchMidStreamError, dispatchPreStreamError } from '../../error-dispatch.js'
|
|
6
|
-
import { buildHttpStreamRouteDoc } from '../docs/http-stream-doc.js'
|
|
7
|
-
import type { DocAccumulator, HonoAppBuilderConfig, HonoFactoryItem, QueryParser } from '../types.js'
|
|
8
|
-
|
|
9
|
-
const BODY_METHODS: HttpMethod[] = ['post', 'put', 'patch']
|
|
10
|
-
|
|
11
|
-
function parseQueryNative(queryString: string): Record<string, unknown> {
|
|
12
|
-
const sp = new URLSearchParams(queryString)
|
|
13
|
-
const result: Record<string, unknown> = {}
|
|
14
|
-
for (const key of new Set(sp.keys())) {
|
|
15
|
-
const values = sp.getAll(key)
|
|
16
|
-
result[key] = values.length > 1 ? values : values[0]
|
|
17
|
-
}
|
|
18
|
-
return result
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function extractQuery(url: string, parser: QueryParser): Record<string, unknown> {
|
|
22
|
-
const q = url.indexOf('?')
|
|
23
|
-
if (q === -1) return {}
|
|
24
|
-
const raw = url.slice(q + 1)
|
|
25
|
-
return raw ? parser(raw) : {}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async function extractParams(
|
|
29
|
-
c: Context,
|
|
30
|
-
method: HttpMethod,
|
|
31
|
-
reqSchema: Record<string, unknown>,
|
|
32
|
-
parser: QueryParser,
|
|
33
|
-
): Promise<Record<string, unknown>> {
|
|
34
|
-
const params: Record<string, unknown> = {}
|
|
35
|
-
for (const channel of Object.keys(reqSchema)) {
|
|
36
|
-
switch (channel) {
|
|
37
|
-
case 'pathParams':
|
|
38
|
-
params.pathParams = c.req.param()
|
|
39
|
-
break
|
|
40
|
-
case 'query':
|
|
41
|
-
params.query = extractQuery(c.req.url, parser)
|
|
42
|
-
break
|
|
43
|
-
case 'body':
|
|
44
|
-
if (BODY_METHODS.includes(method)) {
|
|
45
|
-
params.body = await c.req.json().catch(() => ({}))
|
|
46
|
-
}
|
|
47
|
-
break
|
|
48
|
-
case 'headers': {
|
|
49
|
-
const obj: Record<string, string> = {}
|
|
50
|
-
c.req.raw.headers.forEach((v, k) => { obj[k] = v })
|
|
51
|
-
params.headers = obj
|
|
52
|
-
break
|
|
53
|
-
}
|
|
54
|
-
default:
|
|
55
|
-
params[channel] = undefined
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return params
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function installHttpStreamRoute(params: {
|
|
62
|
-
app: Hono
|
|
63
|
-
procedure: THttpStreamProcedureRegistration<any>
|
|
64
|
-
factoryItem: HonoFactoryItem
|
|
65
|
-
cfg: HonoAppBuilderConfig
|
|
66
|
-
docs: DocAccumulator
|
|
67
|
-
}): void {
|
|
68
|
-
const { app, procedure, factoryItem, cfg, docs } = params
|
|
69
|
-
const queryParser = cfg.api?.queryParser ?? parseQueryNative
|
|
70
|
-
|
|
71
|
-
const route = buildHttpStreamRouteDoc(
|
|
72
|
-
procedure,
|
|
73
|
-
cfg.pathPrefix,
|
|
74
|
-
factoryItem.extendProcedureDoc as any,
|
|
75
|
-
)
|
|
76
|
-
docs.push(route)
|
|
77
|
-
|
|
78
|
-
const reqSchema = procedure.config.schema?.req
|
|
79
|
-
|
|
80
|
-
app.on(procedure.config.method.toUpperCase(), route.fullPath, async (c: Context) => {
|
|
81
|
-
try {
|
|
82
|
-
const context =
|
|
83
|
-
typeof factoryItem.factoryContext === 'function'
|
|
84
|
-
? await (factoryItem.factoryContext as (c: Context) => any)(c)
|
|
85
|
-
: factoryItem.factoryContext
|
|
86
|
-
|
|
87
|
-
const reqParams = reqSchema
|
|
88
|
-
? await extractParams(c, procedure.config.method, reqSchema as Record<string, unknown>, queryParser)
|
|
89
|
-
: undefined
|
|
90
|
-
|
|
91
|
-
const { stream: gen, initialHeaders } = await procedure.handler(
|
|
92
|
-
{ ...context, signal: c.req.raw.signal },
|
|
93
|
-
reqParams,
|
|
94
|
-
)
|
|
95
|
-
|
|
96
|
-
if (initialHeaders) {
|
|
97
|
-
for (const [k, v] of Object.entries(initialHeaders)) c.header(k, v)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
cfg.stream?.onStreamStart?.(procedure, c, 'sse')
|
|
101
|
-
|
|
102
|
-
return streamSSE(c, async (stream) => {
|
|
103
|
-
let eventId = 0
|
|
104
|
-
try {
|
|
105
|
-
let it = await gen.next()
|
|
106
|
-
while (!it.done) {
|
|
107
|
-
const data = typeof it.value === 'string' ? it.value : JSON.stringify(it.value)
|
|
108
|
-
await stream.writeSSE({ data, event: procedure.name, id: String(eventId++) })
|
|
109
|
-
it = await gen.next()
|
|
110
|
-
}
|
|
111
|
-
if (it.value !== undefined) {
|
|
112
|
-
const data = typeof it.value === 'string' ? it.value : JSON.stringify(it.value)
|
|
113
|
-
await stream.writeSSE({ data, event: 'return', id: String(eventId++) })
|
|
114
|
-
}
|
|
115
|
-
} catch (error) {
|
|
116
|
-
const dispatched = await dispatchMidStreamError({
|
|
117
|
-
err: error,
|
|
118
|
-
procedure,
|
|
119
|
-
raw: c,
|
|
120
|
-
cfg: {
|
|
121
|
-
errors: cfg.errors,
|
|
122
|
-
unknownError: cfg.unknownError,
|
|
123
|
-
onMidStreamError: cfg.stream?.onMidStreamError,
|
|
124
|
-
onRequestError: cfg.onRequestError,
|
|
125
|
-
},
|
|
126
|
-
})
|
|
127
|
-
await stream.writeSSE({
|
|
128
|
-
data: typeof dispatched.data === 'string' ? dispatched.data : JSON.stringify(dispatched.data),
|
|
129
|
-
event: dispatched.sseEvent ?? 'error',
|
|
130
|
-
id: String(eventId++),
|
|
131
|
-
})
|
|
132
|
-
if (dispatched.runOnCatch) await dispatched.runOnCatch()
|
|
133
|
-
} finally {
|
|
134
|
-
cfg.stream?.onStreamEnd?.(procedure, c, 'sse')
|
|
135
|
-
cfg.onRequestEnd?.(c)
|
|
136
|
-
}
|
|
137
|
-
})
|
|
138
|
-
} catch (error) {
|
|
139
|
-
return dispatchPreStreamError({
|
|
140
|
-
err: error,
|
|
141
|
-
procedure,
|
|
142
|
-
raw: c,
|
|
143
|
-
cfg: {
|
|
144
|
-
errors: cfg.errors,
|
|
145
|
-
unknownError: cfg.unknownError,
|
|
146
|
-
onError: cfg.onError,
|
|
147
|
-
onRequestError: cfg.onRequestError,
|
|
148
|
-
},
|
|
149
|
-
})
|
|
150
|
-
}
|
|
151
|
-
})
|
|
152
|
-
}
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import type { Context, Hono } from 'hono'
|
|
2
|
-
import type { THttpProcedureRegistration } from '../../../../types.js'
|
|
3
|
-
import type { HttpMethod } from '../../../types.js'
|
|
4
|
-
import { dispatchPreStreamError } from '../../error-dispatch.js'
|
|
5
|
-
import { buildHttpRouteDoc } from '../docs/http-doc.js'
|
|
6
|
-
import type { DocAccumulator, HonoAppBuilderConfig, HonoFactoryItem, QueryParser } from '../types.js'
|
|
7
|
-
|
|
8
|
-
const BODY_METHODS: HttpMethod[] = ['post', 'put', 'patch']
|
|
9
|
-
|
|
10
|
-
function defaultSuccessStatus(method: HttpMethod): number {
|
|
11
|
-
switch (method) {
|
|
12
|
-
case 'post': return 201
|
|
13
|
-
case 'delete': return 204
|
|
14
|
-
default: return 200
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function parseQueryNative(queryString: string): Record<string, unknown> {
|
|
19
|
-
const sp = new URLSearchParams(queryString)
|
|
20
|
-
const result: Record<string, unknown> = {}
|
|
21
|
-
for (const key of new Set(sp.keys())) {
|
|
22
|
-
const values = sp.getAll(key)
|
|
23
|
-
result[key] = values.length > 1 ? values : values[0]
|
|
24
|
-
}
|
|
25
|
-
return result
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function extractQuery(url: string, parser: QueryParser): Record<string, unknown> {
|
|
29
|
-
const q = url.indexOf('?')
|
|
30
|
-
if (q === -1) return {}
|
|
31
|
-
const raw = url.slice(q + 1)
|
|
32
|
-
return raw ? parser(raw) : {}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async function extractParams(
|
|
36
|
-
c: Context,
|
|
37
|
-
method: HttpMethod,
|
|
38
|
-
reqSchema: Record<string, unknown>,
|
|
39
|
-
parser: QueryParser,
|
|
40
|
-
): Promise<Record<string, unknown>> {
|
|
41
|
-
const params: Record<string, unknown> = {}
|
|
42
|
-
for (const channel of Object.keys(reqSchema)) {
|
|
43
|
-
switch (channel) {
|
|
44
|
-
case 'pathParams':
|
|
45
|
-
params.pathParams = c.req.param()
|
|
46
|
-
break
|
|
47
|
-
case 'query':
|
|
48
|
-
params.query = extractQuery(c.req.url, parser)
|
|
49
|
-
break
|
|
50
|
-
case 'body':
|
|
51
|
-
if (BODY_METHODS.includes(method)) {
|
|
52
|
-
params.body = await c.req.json().catch(() => ({}))
|
|
53
|
-
}
|
|
54
|
-
break
|
|
55
|
-
case 'headers': {
|
|
56
|
-
const obj: Record<string, string> = {}
|
|
57
|
-
c.req.raw.headers.forEach((v, k) => { obj[k] = v })
|
|
58
|
-
params.headers = obj
|
|
59
|
-
break
|
|
60
|
-
}
|
|
61
|
-
default:
|
|
62
|
-
params[channel] = undefined
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return params
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export function installHttpRoute(params: {
|
|
69
|
-
app: Hono
|
|
70
|
-
procedure: THttpProcedureRegistration<any>
|
|
71
|
-
factoryItem: HonoFactoryItem
|
|
72
|
-
cfg: HonoAppBuilderConfig
|
|
73
|
-
docs: DocAccumulator
|
|
74
|
-
}): void {
|
|
75
|
-
const { app, procedure, factoryItem, cfg, docs } = params
|
|
76
|
-
const queryParser = cfg.api?.queryParser ?? parseQueryNative
|
|
77
|
-
|
|
78
|
-
const route = buildHttpRouteDoc(
|
|
79
|
-
procedure,
|
|
80
|
-
cfg.pathPrefix,
|
|
81
|
-
factoryItem.extendProcedureDoc as any,
|
|
82
|
-
)
|
|
83
|
-
docs.push(route)
|
|
84
|
-
|
|
85
|
-
const successStatus = procedure.config.successStatus ?? defaultSuccessStatus(procedure.config.method)
|
|
86
|
-
const reqSchema = procedure.config.schema?.req
|
|
87
|
-
|
|
88
|
-
app.on(procedure.config.method.toUpperCase(), route.fullPath, async (c: Context) => {
|
|
89
|
-
try {
|
|
90
|
-
const context =
|
|
91
|
-
typeof factoryItem.factoryContext === 'function'
|
|
92
|
-
? await (factoryItem.factoryContext as (c: Context) => any)(c)
|
|
93
|
-
: factoryItem.factoryContext
|
|
94
|
-
|
|
95
|
-
const reqParams = reqSchema
|
|
96
|
-
? await extractParams(c, procedure.config.method, reqSchema, queryParser)
|
|
97
|
-
: undefined
|
|
98
|
-
|
|
99
|
-
const result = await procedure.handler(
|
|
100
|
-
{ ...context, signal: c.req.raw.signal },
|
|
101
|
-
reqParams,
|
|
102
|
-
)
|
|
103
|
-
|
|
104
|
-
cfg.api?.onSuccess?.(procedure, c)
|
|
105
|
-
|
|
106
|
-
// The `{ body, headers }` envelope is OPT-IN via `schema.res.headers`: when
|
|
107
|
-
// the route declares response headers, the handler returns `{ body, headers }`;
|
|
108
|
-
// otherwise its return value IS the body. Gating on the schema (rather than
|
|
109
|
-
// duck-typing the result for a `body`/`headers` key) lets a domain object
|
|
110
|
-
// safely carry its own `body`/`headers` field without being unwrapped.
|
|
111
|
-
// Normalize both shapes to a single `{ body, headers }` so the response
|
|
112
|
-
// decision below is uniform for every legal return shape.
|
|
113
|
-
const hasResHeaders = procedure.config.schema?.res?.headers != null
|
|
114
|
-
const { body, headers } = hasResHeaders
|
|
115
|
-
? ((result ?? {}) as { body?: unknown; headers?: unknown })
|
|
116
|
-
: { body: result, headers: undefined }
|
|
117
|
-
|
|
118
|
-
if (headers && typeof headers === 'object') {
|
|
119
|
-
for (const [k, v] of Object.entries(headers as Record<string, string>)) c.header(k, v)
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// No body to send — a 204 status, or an `undefined` return (a `void`
|
|
123
|
-
// handler, or a headers-only `res: { headers }` envelope). Emit a clean
|
|
124
|
-
// bodyless response instead of `c.json(undefined)`, which would send an
|
|
125
|
-
// empty, unparseable body under an `application/json` content-type.
|
|
126
|
-
if (successStatus === 204 || body === undefined) {
|
|
127
|
-
return c.body(null, successStatus as any)
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return c.json(body, successStatus as any)
|
|
131
|
-
} catch (error) {
|
|
132
|
-
return dispatchPreStreamError({
|
|
133
|
-
err: error,
|
|
134
|
-
procedure,
|
|
135
|
-
raw: c,
|
|
136
|
-
cfg: {
|
|
137
|
-
errors: cfg.errors,
|
|
138
|
-
unknownError: cfg.unknownError,
|
|
139
|
-
onError: cfg.onError,
|
|
140
|
-
onRequestError: cfg.onRequestError,
|
|
141
|
-
},
|
|
142
|
-
})
|
|
143
|
-
}
|
|
144
|
-
})
|
|
145
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import type { Context, Hono } from 'hono'
|
|
2
|
-
import type { TProcedureRegistration } from '../../../../types.js'
|
|
3
|
-
import type { RPCConfig } from '../../../types.js'
|
|
4
|
-
import { dispatchPreStreamError } from '../../error-dispatch.js'
|
|
5
|
-
import { buildRpcRouteDoc } from '../docs/rpc-doc.js'
|
|
6
|
-
import type { DocAccumulator, HonoAppBuilderConfig, HonoFactoryItem } from '../types.js'
|
|
7
|
-
|
|
8
|
-
export function installRpcRoute(params: {
|
|
9
|
-
app: Hono
|
|
10
|
-
procedure: TProcedureRegistration<any, RPCConfig>
|
|
11
|
-
factoryItem: HonoFactoryItem
|
|
12
|
-
cfg: HonoAppBuilderConfig
|
|
13
|
-
docs: DocAccumulator
|
|
14
|
-
}): void {
|
|
15
|
-
const { app, procedure, factoryItem, cfg, docs } = params
|
|
16
|
-
|
|
17
|
-
const route = buildRpcRouteDoc(
|
|
18
|
-
procedure,
|
|
19
|
-
cfg.pathPrefix,
|
|
20
|
-
factoryItem.extendProcedureDoc as any,
|
|
21
|
-
)
|
|
22
|
-
docs.push(route)
|
|
23
|
-
|
|
24
|
-
app.post(route.path, async (c: Context) => {
|
|
25
|
-
try {
|
|
26
|
-
const context =
|
|
27
|
-
typeof factoryItem.factoryContext === 'function'
|
|
28
|
-
? await (factoryItem.factoryContext as (c: Context) => any)(c)
|
|
29
|
-
: factoryItem.factoryContext
|
|
30
|
-
|
|
31
|
-
const body = await c.req.json().catch(() => ({}))
|
|
32
|
-
const result = await procedure.handler(
|
|
33
|
-
{ ...context, signal: c.req.raw.signal },
|
|
34
|
-
body,
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
cfg.rpc?.onSuccess?.(procedure, c)
|
|
38
|
-
|
|
39
|
-
return c.json(result)
|
|
40
|
-
} catch (error) {
|
|
41
|
-
return dispatchPreStreamError({
|
|
42
|
-
err: error,
|
|
43
|
-
procedure,
|
|
44
|
-
raw: c,
|
|
45
|
-
cfg: {
|
|
46
|
-
errors: cfg.errors,
|
|
47
|
-
unknownError: cfg.unknownError,
|
|
48
|
-
onError: cfg.onError,
|
|
49
|
-
onRequestError: cfg.onRequestError,
|
|
50
|
-
},
|
|
51
|
-
})
|
|
52
|
-
}
|
|
53
|
-
})
|
|
54
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from 'vitest'
|
|
2
|
-
import { makeRoutePath, resolveFullPath } from './path.js'
|
|
3
|
-
import type {
|
|
4
|
-
TProcedureRegistration,
|
|
5
|
-
TStreamProcedureRegistration,
|
|
6
|
-
THttpProcedureRegistration,
|
|
7
|
-
THttpStreamProcedureRegistration,
|
|
8
|
-
} from '../../../types.js'
|
|
9
|
-
|
|
10
|
-
describe('makeRoutePath', () => {
|
|
11
|
-
test('rpc: scope/name/version with kebab-case', () => {
|
|
12
|
-
const proc = {
|
|
13
|
-
name: 'GetUser',
|
|
14
|
-
kind: 'rpc',
|
|
15
|
-
config: { scope: 'users', version: 1 },
|
|
16
|
-
handler: async () => undefined,
|
|
17
|
-
} as unknown as TProcedureRegistration
|
|
18
|
-
expect(makeRoutePath({ procedure: proc })).toBe('/users/get-user/1')
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
test('rpc: array scope joined with /', () => {
|
|
22
|
-
const proc = {
|
|
23
|
-
name: 'List',
|
|
24
|
-
kind: 'rpc',
|
|
25
|
-
config: { scope: ['UserModule', 'admin'], version: 2 },
|
|
26
|
-
handler: async () => undefined,
|
|
27
|
-
} as unknown as TProcedureRegistration
|
|
28
|
-
expect(makeRoutePath({ procedure: proc })).toBe('/user-module/admin/list/2')
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
test('rpc: pathPrefix is normalized (leading slash inserted)', () => {
|
|
32
|
-
const proc = {
|
|
33
|
-
name: 'Echo',
|
|
34
|
-
kind: 'rpc',
|
|
35
|
-
config: { scope: 'echo', version: 1 },
|
|
36
|
-
handler: async () => undefined,
|
|
37
|
-
} as unknown as TProcedureRegistration
|
|
38
|
-
expect(makeRoutePath({ procedure: proc, prefix: 'api/v1' })).toBe('/api/v1/echo/echo/1')
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
test('rpc-stream: same shape as rpc', () => {
|
|
42
|
-
const proc = {
|
|
43
|
-
name: 'Tail',
|
|
44
|
-
kind: 'rpc-stream',
|
|
45
|
-
isStream: true,
|
|
46
|
-
config: { scope: 'logs', version: 1 },
|
|
47
|
-
handler: async function* () {},
|
|
48
|
-
} as unknown as TStreamProcedureRegistration
|
|
49
|
-
expect(makeRoutePath({ procedure: proc, prefix: '/api' })).toBe('/api/logs/tail/1')
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
test('http: prepends prefix to config.path', () => {
|
|
53
|
-
const proc = {
|
|
54
|
-
name: 'GetUser',
|
|
55
|
-
kind: 'http',
|
|
56
|
-
config: { path: '/users/:id', method: 'get' },
|
|
57
|
-
handler: async () => undefined,
|
|
58
|
-
} as unknown as THttpProcedureRegistration
|
|
59
|
-
expect(makeRoutePath({ procedure: proc, prefix: '/api/v1' })).toBe('/api/v1/users/:id')
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
test('http: leading slash on path is preserved (not duplicated)', () => {
|
|
63
|
-
const proc = {
|
|
64
|
-
name: 'Get',
|
|
65
|
-
kind: 'http',
|
|
66
|
-
config: { path: 'users', method: 'get' },
|
|
67
|
-
handler: async () => undefined,
|
|
68
|
-
} as unknown as THttpProcedureRegistration
|
|
69
|
-
expect(makeRoutePath({ procedure: proc, prefix: '/api' })).toBe('/api/users')
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
test('http-stream: same shape as http', () => {
|
|
73
|
-
const proc = {
|
|
74
|
-
name: 'TailLogs',
|
|
75
|
-
kind: 'http-stream',
|
|
76
|
-
config: { path: '/logs/tail', method: 'get' },
|
|
77
|
-
handler: async () => ({ stream: (async function* () {})(), initialHeaders: undefined }),
|
|
78
|
-
} as unknown as THttpStreamProcedureRegistration
|
|
79
|
-
expect(makeRoutePath({ procedure: proc })).toBe('/logs/tail')
|
|
80
|
-
})
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
describe('resolveFullPath', () => {
|
|
84
|
-
test('combines prefix and path', () => {
|
|
85
|
-
expect(resolveFullPath('/users', '/api/v1')).toBe('/api/v1/users')
|
|
86
|
-
})
|
|
87
|
-
test('normalizes prefix without leading slash', () => {
|
|
88
|
-
expect(resolveFullPath('/users', 'api')).toBe('/api/users')
|
|
89
|
-
})
|
|
90
|
-
test('normalizes path without leading slash', () => {
|
|
91
|
-
expect(resolveFullPath('users', '/api')).toBe('/api/users')
|
|
92
|
-
})
|
|
93
|
-
test('no prefix', () => {
|
|
94
|
-
expect(resolveFullPath('/users')).toBe('/users')
|
|
95
|
-
})
|
|
96
|
-
})
|