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,27 +1,24 @@
|
|
|
1
1
|
# ts-procedures API Reference
|
|
2
2
|
|
|
3
|
-
## Procedures\<TContext, TExtendedConfig\>(
|
|
3
|
+
## Procedures\<TContext, TExtendedConfig\>(options?)
|
|
4
4
|
|
|
5
5
|
Factory function that creates a scoped procedure registration system.
|
|
6
6
|
|
|
7
7
|
```typescript
|
|
8
8
|
function Procedures<TContext = unknown, TExtendedConfig = unknown>(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
onCreate?: (procedure:
|
|
14
|
-
name: string
|
|
15
|
-
isStream?: boolean
|
|
16
|
-
handler: Function
|
|
17
|
-
config: { description?: string; schema?: object } & TExtendedConfig
|
|
18
|
-
}) => void
|
|
9
|
+
options?: {
|
|
10
|
+
validation?: false | { ajv?: Ajv | AjvOptions }
|
|
11
|
+
schema?: { adapters?: SchemaAdapter[] }
|
|
12
|
+
http?: { pathPrefix?: string; scope?: string }
|
|
13
|
+
onCreate?: (procedure: AnyProcedureRegistration<TContext, TExtendedConfig>) => void
|
|
19
14
|
}
|
|
20
15
|
): {
|
|
21
16
|
Create: CreateFunction
|
|
22
17
|
CreateStream: CreateStreamFunction
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
CreateHttp: CreateHttpFunction
|
|
19
|
+
CreateHttpStream: CreateHttpStreamFunction
|
|
20
|
+
getProcedures(): AnyProcedureRegistration[]
|
|
21
|
+
getProcedure(name: string): AnyProcedureRegistration | undefined
|
|
25
22
|
removeProcedure(name: string): boolean
|
|
26
23
|
clear(): void
|
|
27
24
|
}
|
|
@@ -29,8 +26,10 @@ function Procedures<TContext = unknown, TExtendedConfig = unknown>(
|
|
|
29
26
|
|
|
30
27
|
### Parameters
|
|
31
28
|
|
|
32
|
-
- `
|
|
33
|
-
- `
|
|
29
|
+
- `options.validation` — Runtime validation behavior. Omitted: validate every call with the default AJV configuration (`allErrors`, `coerceTypes`, `removeAdditional`). `false`: every procedure registered through this factory skips AJV validation at call time (replaces v8's `config.noRuntimeValidation`). Applies to all four creators: `Create` and `CreateStream` skip `schema.params` validation; `CreateHttp` and `CreateHttpStream` skip per-channel `schema.req.{pathParams,query,body,headers}` validation. JSON Schema and validators are still computed at registration time, so bad schemas still fail fast and `info.schema` / codegen are unaffected. Use only for trusted internal factories whose callers are already type-checked at build time; do **not** enable for procedures that accept input from public clients or untyped JSON bodies. `{ ajv }`: AJV options merged over the defaults, or a configured `Ajv` instance used as-is — AJV is per-factory, not a module-level singleton.
|
|
30
|
+
- `options.schema.adapters` — Plug in other schema libraries via the `SchemaAdapter` interface (`{ name, detect, toJsonSchema }`). TypeBox is built in and always last in the chain. Custom adapters get runtime validation + docs; compile-time inference (`Infer<T>`) is built in only for TypeBox.
|
|
31
|
+
- `options.http` — Factory-level defaults for `CreateHttp` / `CreateHttpStream`: `pathPrefix` is prepended to every route's `path` at registration time (part of the route's identity — it shows up in `config.path` and route docs, unlike a server adapter's mount prefix); `scope` is the default codegen scope for routes that don't set one. Per-route values win.
|
|
32
|
+
- `options.onCreate` — Called each time a procedure is registered with the full registration object (narrow on the `kind` discriminant: `'rpc' | 'rpc-stream' | 'http' | 'http-stream'`). Use for framework integration, route registration, or logging.
|
|
34
33
|
|
|
35
34
|
### Return Value
|
|
36
35
|
|
|
@@ -68,13 +67,14 @@ function Create<TName extends string, TParams, TReturnType>(
|
|
|
68
67
|
} & TExtendedConfig,
|
|
69
68
|
handler: (
|
|
70
69
|
ctx: TContext & TLocalContext,
|
|
71
|
-
params:
|
|
72
|
-
) => Promise<
|
|
70
|
+
params: Infer<TParams>
|
|
71
|
+
) => Promise<Infer<TReturnType>>
|
|
73
72
|
): {
|
|
74
|
-
[K in TName]: (ctx: TContext, params:
|
|
75
|
-
procedure: (ctx: TContext, params:
|
|
73
|
+
[K in TName]: (ctx: TContext, params: Infer<TParams>) => Promise<Infer<TReturnType>>
|
|
74
|
+
procedure: (ctx: TContext, params: Infer<TParams>) => Promise<Infer<TReturnType>>
|
|
76
75
|
info: {
|
|
77
76
|
name: TName
|
|
77
|
+
kind: 'rpc'
|
|
78
78
|
description?: string
|
|
79
79
|
schema: { params?: TJSONSchema; returnType?: TJSONSchema }
|
|
80
80
|
validation?: { params?: (params: any) => { errors?: TSchemaValidationError[] } }
|
|
@@ -131,14 +131,14 @@ function CreateStream<TName extends string, TParams, TYieldType, TReturnType = v
|
|
|
131
131
|
} & TExtendedConfig,
|
|
132
132
|
handler: (
|
|
133
133
|
ctx: TContext & TStreamContext,
|
|
134
|
-
params:
|
|
135
|
-
) => AsyncGenerator<
|
|
134
|
+
params: Infer<TParams>
|
|
135
|
+
) => AsyncGenerator<Infer<TYieldType>, Infer<TReturnType> | void, unknown>
|
|
136
136
|
): {
|
|
137
|
-
[K in TName]: (ctx: TContext, params:
|
|
138
|
-
procedure: (ctx: TContext, params:
|
|
137
|
+
[K in TName]: (ctx: TContext, params: Infer<TParams>) => AsyncGenerator<...>
|
|
138
|
+
procedure: (ctx: TContext, params: Infer<TParams>) => AsyncGenerator<...>
|
|
139
139
|
info: {
|
|
140
140
|
name: TName
|
|
141
|
-
|
|
141
|
+
kind: 'rpc-stream'
|
|
142
142
|
description?: string
|
|
143
143
|
schema: { params?: TJSONSchema; yieldType?: TJSONSchema; returnType?: TJSONSchema }
|
|
144
144
|
validation?: {
|
|
@@ -202,7 +202,7 @@ function CreateHttp<
|
|
|
202
202
|
},
|
|
203
203
|
handler: (
|
|
204
204
|
ctx: TContext & TLocalContext,
|
|
205
|
-
req: { [K in keyof TReq]:
|
|
205
|
+
req: { [K in keyof TReq]: Infer<TReq[K]> }
|
|
206
206
|
) => Promise<HttpReturn<TRes>>
|
|
207
207
|
): {
|
|
208
208
|
[K in TName]: typeof handler
|
|
@@ -265,6 +265,7 @@ Base error class for all procedure errors.
|
|
|
265
265
|
|
|
266
266
|
```typescript
|
|
267
267
|
class ProcedureError extends Error {
|
|
268
|
+
readonly kind: ProcedureErrorKind // 'procedure' | 'validation' | 'yield-validation' | 'registration'
|
|
268
269
|
readonly procedureName: string
|
|
269
270
|
readonly message: string
|
|
270
271
|
readonly meta?: object
|
|
@@ -280,6 +281,7 @@ class ProcedureError extends Error {
|
|
|
280
281
|
- Created via `ctx.error(message, meta?)` in handlers
|
|
281
282
|
- Unhandled handler exceptions are wrapped: original error in `cause`
|
|
282
283
|
- Stack trace enhanced with procedure definition location
|
|
284
|
+
- Every framework error carries a `kind` discriminant (`'procedure' | 'validation' | 'yield-validation' | 'registration'`) as an alternative to `instanceof`; each subclass overrides it
|
|
283
285
|
|
|
284
286
|
### ProcedureValidationError extends ProcedureError
|
|
285
287
|
|
|
@@ -308,7 +310,7 @@ class ProcedureYieldValidationError extends ProcedureError {
|
|
|
308
310
|
|
|
309
311
|
### ProcedureRegistrationError extends ProcedureError
|
|
310
312
|
|
|
311
|
-
Thrown at registration time. Common
|
|
313
|
+
Thrown at registration time. Common sources: schema extraction/compilation failure, duplicate procedure name (message: `Procedure with name <name> is already registered` — v8 threw a bare `Error` here), using the removed v7 `schema.input` field (rejected with a migration message pointing to `CreateHttp` / `CreateHttpStream`), declaring both `schema.params` and `schema.req` on the same procedure (mutually exclusive — RPC vs HTTP), passing `schema.params` to `CreateHttp` / `CreateHttpStream` (use `schema.req.body` or `schema.req.query` instead), and path/schema mismatches on HTTP procedures (path declares params not in `schema.req.pathParams`, or vice versa).
|
|
312
314
|
|
|
313
315
|
```typescript
|
|
314
316
|
class ProcedureRegistrationError extends ProcedureError {
|
|
@@ -654,26 +656,56 @@ interface ClassifiedError {
|
|
|
654
656
|
|
|
655
657
|
## Schema Utilities
|
|
656
658
|
|
|
657
|
-
|
|
659
|
+
Most users never call these directly — the factory does. They matter when building custom tooling.
|
|
660
|
+
|
|
661
|
+
### SchemaAdapter
|
|
662
|
+
|
|
663
|
+
Bridges a schema library to the framework. The framework only ever needs one thing from a schema object: its JSON Schema.
|
|
664
|
+
|
|
665
|
+
```typescript
|
|
666
|
+
interface SchemaAdapter {
|
|
667
|
+
name: string // short identifier used in registration error messages
|
|
668
|
+
detect(schema: unknown): boolean // does this adapter recognize the schema object?
|
|
669
|
+
toJsonSchema(schema: unknown): TJSONSchema // convert a recognized schema to JSON Schema
|
|
670
|
+
}
|
|
671
|
+
```
|
|
672
|
+
|
|
673
|
+
TypeBox is built in (`typeboxAdapter`); pass custom adapters via `Procedures({ schema: { adapters: [...] } })`. Compile-time inference (`Infer<T>`) works only for TypeBox — custom adapters get runtime validation + docs.
|
|
674
|
+
|
|
675
|
+
### extractJsonSchema(schema, adapters)
|
|
658
676
|
|
|
659
|
-
|
|
677
|
+
Runs the adapter chain against a schema value.
|
|
660
678
|
|
|
661
679
|
```typescript
|
|
662
|
-
function extractJsonSchema(
|
|
680
|
+
function extractJsonSchema(schema: unknown, adapters: readonly SchemaAdapter[]): TJSONSchema | undefined
|
|
663
681
|
```
|
|
664
682
|
|
|
665
|
-
-
|
|
666
|
-
-
|
|
683
|
+
- Returns the JSON Schema from the first adapter whose `detect` matches
|
|
684
|
+
- TypeBox schemas are valid JSON Schema — returned as-is by `typeboxAdapter`
|
|
685
|
+
- Returns `undefined` if no adapter recognizes the value
|
|
667
686
|
|
|
668
|
-
###
|
|
687
|
+
### computeSchema(name, schema, options)
|
|
669
688
|
|
|
670
|
-
|
|
689
|
+
Computes JSON Schemas and compiled AJV validators for a procedure's schema config (replaces v8's `schemaParser`). Throws `ProcedureRegistrationError` on extraction/compilation failure instead of taking an error callback.
|
|
671
690
|
|
|
672
691
|
```typescript
|
|
673
|
-
function
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
692
|
+
function computeSchema(
|
|
693
|
+
name: string,
|
|
694
|
+
schema: { params?: unknown; returnType?: unknown; yieldType?: unknown; req?: object; res?: object } | undefined,
|
|
695
|
+
options: {
|
|
696
|
+
adapters: readonly SchemaAdapter[]
|
|
697
|
+
compile: ValidatorCompiler
|
|
698
|
+
definitionInfo?: DefinitionInfo
|
|
699
|
+
}
|
|
700
|
+
): ComputedSchema // { jsonSchema, validations }
|
|
701
|
+
```
|
|
702
|
+
|
|
703
|
+
### createValidatorCompiler(options?)
|
|
704
|
+
|
|
705
|
+
Builds a per-factory AJV-backed `ValidatorCompiler` (AJV is no longer a module-level singleton). Defaults (`allErrors`, `coerceTypes`, `removeAdditional`, ajv-formats) live in `DEFAULT_AJV_OPTIONS`.
|
|
706
|
+
|
|
707
|
+
```typescript
|
|
708
|
+
function createValidatorCompiler(options?: { ajv?: Ajv | AjvOptions }): ValidatorCompiler
|
|
677
709
|
```
|
|
678
710
|
|
|
679
711
|
### isTypeboxSchema(schema)
|
|
@@ -684,17 +716,19 @@ Type guard for TypeBox schema detection.
|
|
|
684
716
|
function isTypeboxSchema(schema: any): schema is TSchema
|
|
685
717
|
```
|
|
686
718
|
|
|
687
|
-
###
|
|
719
|
+
### Infer\<SchemaType\>
|
|
688
720
|
|
|
689
|
-
Maps schema type to inferred TypeScript type:
|
|
721
|
+
Maps schema type to inferred TypeScript type — the primary inference type in v9:
|
|
690
722
|
- TypeBox `TSchema` → `Static<T>`
|
|
691
723
|
- Otherwise → `unknown`
|
|
692
724
|
|
|
725
|
+
`TSchemaLib<T>` remains exported as a v8-compatible alias.
|
|
726
|
+
|
|
693
727
|
---
|
|
694
728
|
|
|
695
729
|
## HonoAppBuilder\<TStreamErrorData\>
|
|
696
730
|
|
|
697
|
-
Unified Hono HTTP implementation
|
|
731
|
+
Unified Hono HTTP implementation (public surface unchanged from v8). A single builder dispatches all four procedure kinds (`Create` → RPC, `CreateStream` → streaming RPC, `CreateHttp` → REST-style, `CreateHttpStream` → streaming REST) from one `register()` call. Replaces v7's separate `HonoRPCAppBuilder` / `HonoStreamAppBuilder` / `HonoAPIAppBuilder` classes. The machinery behind it lives in the transport-agnostic `ts-procedures/server` subpath (see below).
|
|
698
732
|
|
|
699
733
|
Config is **stratified**: cross-cutting fields live at the top level, kind-specific fields live in `rpc:` / `api:` / `stream:` blocks.
|
|
700
734
|
|
|
@@ -799,6 +833,8 @@ function sse<T extends object>(data: T, options?: {
|
|
|
799
833
|
}): T
|
|
800
834
|
```
|
|
801
835
|
|
|
836
|
+
SSE wire behavior is identical for `rpc-stream` and `http-stream` routes (one shared `SseEventSequencer`): `sse()` metadata is honored on both (v8 silently ignored it on `http-stream`), and a `null` yield serializes as empty SSE data on both (v8's `http-stream` wrote the string `null`).
|
|
837
|
+
|
|
802
838
|
### HTTP Methods (RPC streams)
|
|
803
839
|
|
|
804
840
|
For `CreateStream` procedures (RPC-style streams), both GET and POST are registered:
|
|
@@ -812,7 +848,7 @@ For `CreateHttpStream`, the method comes from `config.method` (no auto-pairing).
|
|
|
812
848
|
```typescript
|
|
813
849
|
type MidStreamErrorResult<TErrorData = unknown> = {
|
|
814
850
|
data: TErrorData // Data to yield as final event
|
|
815
|
-
closeStream?: boolean //
|
|
851
|
+
closeStream?: boolean // Reserved — the stream currently always closes after dispatch
|
|
816
852
|
}
|
|
817
853
|
```
|
|
818
854
|
|
|
@@ -884,6 +920,48 @@ Uses `c.req.raw.signal` — native Request signal from Hono context.
|
|
|
884
920
|
|
|
885
921
|
For apps that build all routes through one `HonoAppBuilder`, `builder.toDocEnvelope()` returns the full `DocEnvelope` directly — no `DocRegistry` wiring needed. `DocRegistry` is still preferred for multi-app aggregation.
|
|
886
922
|
|
|
923
|
+
Note (v9 fix): `http-stream` route docs now include the `yield` and `res.headers` schemas — in v8, live envelopes silently dropped them, so generated clients lost those types unless the envelope was hand-authored.
|
|
924
|
+
|
|
925
|
+
---
|
|
926
|
+
|
|
927
|
+
## Server Toolkit — `ts-procedures/server` (v9)
|
|
928
|
+
|
|
929
|
+
Transport-agnostic adapter toolkit: everything a server adapter (Hono, Fastify, Express, ...) needs to serve the four procedure kinds without re-implementing the framework. `src/adapters/hono/` is the reference implementation — a custom adapter is ~4 thin handlers translating between the framework's request/response/streaming primitives and these helpers.
|
|
930
|
+
|
|
931
|
+
```typescript
|
|
932
|
+
import {
|
|
933
|
+
// Error dispatch — data-in/data-out (no framework Response objects)
|
|
934
|
+
dispatchPreStreamError, // → { type: 'body', statusCode, body } | { type: 'response', response }
|
|
935
|
+
dispatchMidStreamError, // → { data, sseEvent?, sseId?, sseRetry?, runOnCatch? }
|
|
936
|
+
// Request channel extraction (schema.req → pathParams/query/body/headers)
|
|
937
|
+
extractReqChannels, // (source: RequestSource, method, reqSchema, parser) → declared schema.req channels
|
|
938
|
+
parseQueryNative,
|
|
939
|
+
// Context resolution
|
|
940
|
+
resolveFactoryContext,
|
|
941
|
+
// Route-doc builders (one per procedure kind)
|
|
942
|
+
buildRpcRouteDoc,
|
|
943
|
+
buildStreamRouteDoc,
|
|
944
|
+
buildHttpRouteDoc,
|
|
945
|
+
buildHttpStreamRouteDoc,
|
|
946
|
+
// SSE
|
|
947
|
+
SseEventSequencer,
|
|
948
|
+
sse,
|
|
949
|
+
// Docs
|
|
950
|
+
DocRegistry,
|
|
951
|
+
writeDocEnvelope,
|
|
952
|
+
} from 'ts-procedures/server'
|
|
953
|
+
```
|
|
954
|
+
|
|
955
|
+
Key behaviors:
|
|
956
|
+
|
|
957
|
+
- `dispatchPreStreamError({ err, procedure, raw, cfg })` runs the full pre-stream dispatch order — `onRequestError` observer (awaited, throws swallowed) → taxonomy resolver → imperative `onError` → hard default (`{ error: message }`, 500) — and returns plain data. `{ type: 'body', statusCode, body }` means serialize `body` as JSON with `statusCode`; `{ type: 'response', response }` means the imperative `onError` produced a framework response — send it as-is. (In v8 this helper produced Hono `Response` objects directly.)
|
|
958
|
+
- `RequestSource` is the adapter-neutral request view `extractReqChannels` reads channels from; adapters construct it from their framework's request.
|
|
959
|
+
- `SseEventSequencer` is the single SSE writer shared by `rpc-stream` and `http-stream` routes — event names, id sequencing, `sse()` metadata, and the `event: 'return'` envelope are uniform across both kinds.
|
|
960
|
+
- Taxonomy callbacks' `raw` parameter is typed `unknown` at this layer (it is your framework's request context; cast in your adapter).
|
|
961
|
+
- No framework imports are allowed in this subtree (enforced by test).
|
|
962
|
+
|
|
963
|
+
The `ts-procedures/http`, `ts-procedures/http-docs`, and `ts-procedures/http-errors` subpaths re-export the same names as v8.
|
|
964
|
+
|
|
887
965
|
---
|
|
888
966
|
|
|
889
967
|
## HTTP Types
|
|
@@ -1422,10 +1500,15 @@ Constraints:
|
|
|
1422
1500
|
// Core
|
|
1423
1501
|
import { Procedures } from 'ts-procedures'
|
|
1424
1502
|
import type {
|
|
1503
|
+
ProceduresOptions,
|
|
1504
|
+
ProcedureKind,
|
|
1425
1505
|
TLocalContext,
|
|
1426
1506
|
TStreamContext,
|
|
1427
1507
|
TProcedureRegistration,
|
|
1428
1508
|
TStreamProcedureRegistration,
|
|
1509
|
+
THttpProcedureRegistration,
|
|
1510
|
+
THttpStreamProcedureRegistration,
|
|
1511
|
+
AnyProcedureRegistration,
|
|
1429
1512
|
} from 'ts-procedures'
|
|
1430
1513
|
|
|
1431
1514
|
// Errors
|
|
@@ -1435,12 +1518,11 @@ import {
|
|
|
1435
1518
|
ProcedureYieldValidationError,
|
|
1436
1519
|
ProcedureRegistrationError,
|
|
1437
1520
|
} from 'ts-procedures'
|
|
1521
|
+
import type { ProcedureErrorKind } from 'ts-procedures'
|
|
1438
1522
|
|
|
1439
1523
|
// Schema utilities
|
|
1440
|
-
import { extractJsonSchema } from 'ts-procedures'
|
|
1441
|
-
import {
|
|
1442
|
-
import { isTypeboxSchema } from 'ts-procedures'
|
|
1443
|
-
import type { TSchemaLib, TSchemaLibGenerator, TJSONSchema, TSchemaParsed, TSchemaValidationError } from 'ts-procedures'
|
|
1524
|
+
import { extractJsonSchema, computeSchema, createValidatorCompiler, typeboxAdapter, isTypeboxSchema } from 'ts-procedures'
|
|
1525
|
+
import type { SchemaAdapter, Infer, TSchemaLib, TJSONSchema, ComputedSchema, TSchemaValidationError } from 'ts-procedures'
|
|
1444
1526
|
|
|
1445
1527
|
// Stack utilities
|
|
1446
1528
|
import { captureDefinitionInfo, formatDefinitionInfo } from 'ts-procedures'
|
|
@@ -1453,6 +1535,20 @@ import type { RPCConfig, RPCHttpRouteDoc, StreamHttpRouteDoc, StreamMode, HttpMe
|
|
|
1453
1535
|
// Hono — single unified builder dispatches RPC, HTTP, and streaming kinds
|
|
1454
1536
|
import { HonoAppBuilder, sse } from 'ts-procedures/hono'
|
|
1455
1537
|
|
|
1538
|
+
// Server toolkit — transport-agnostic adapter machinery (build your own adapter)
|
|
1539
|
+
import {
|
|
1540
|
+
dispatchPreStreamError,
|
|
1541
|
+
dispatchMidStreamError,
|
|
1542
|
+
extractReqChannels,
|
|
1543
|
+
resolveFactoryContext,
|
|
1544
|
+
buildRpcRouteDoc,
|
|
1545
|
+
buildStreamRouteDoc,
|
|
1546
|
+
buildHttpRouteDoc,
|
|
1547
|
+
buildHttpStreamRouteDoc,
|
|
1548
|
+
SseEventSequencer,
|
|
1549
|
+
} from 'ts-procedures/server'
|
|
1550
|
+
import type { RequestSource } from 'ts-procedures/server'
|
|
1551
|
+
|
|
1456
1552
|
// Client
|
|
1457
1553
|
import {
|
|
1458
1554
|
createClient,
|
|
@@ -28,12 +28,14 @@
|
|
|
28
28
|
### CRITICAL
|
|
29
29
|
- [ ] Uses TypeBox (`Type.Object(...)`, `Type.String()`, etc.) — not plain objects
|
|
30
30
|
- [ ] Required fields use `Type.String()` directly; optional fields wrapped with `Type.Optional(...)`
|
|
31
|
-
- [ ] Does not define both `schema.params` and `schema.
|
|
31
|
+
- [ ] Does not define both `schema.params` and `schema.req` on the same procedure (mutually exclusive — RPC vs HTTP)
|
|
32
32
|
|
|
33
33
|
### WARNING
|
|
34
34
|
- [ ] Understands AJV `coerceTypes: true` — no manual type parsing for query string values
|
|
35
35
|
- [ ] Understands AJV `removeAdditional: true` — extra fields in params are silently stripped
|
|
36
36
|
- [ ] Does not rely on params fields not in the schema (they get removed)
|
|
37
|
+
- [ ] Factory-level `validation: false` is used only on trusted internal factories — never on factories whose procedures receive caller-supplied JSON (anti-pattern #22)
|
|
38
|
+
- [ ] Non-TypeBox schema libraries go through a registered `SchemaAdapter` (`Procedures({ schema: { adapters } })`), with the caveat that `Infer<T>` only works for TypeBox
|
|
37
39
|
|
|
38
40
|
### SUGGESTION
|
|
39
41
|
- [ ] `returnType` schema provided for documentation generation
|
|
@@ -101,16 +103,15 @@
|
|
|
101
103
|
|
|
102
104
|
### CRITICAL
|
|
103
105
|
- [ ] `build()` is called synchronously — it returns `Hono`, NOT `Promise<Hono>`. Do not `await` it.
|
|
104
|
-
- [ ] Path param names in route template match `schema.
|
|
105
|
-
- [ ] Does not define both `schema.params` and `schema.
|
|
106
|
+
- [ ] Path param names in route template match `schema.req.pathParams` property names exactly
|
|
107
|
+
- [ ] Does not define both `schema.params` and `schema.req` on the same procedure
|
|
106
108
|
- [ ] Custom error classes registered via `defineErrorTaxonomy` + builder `errors` config — not hand-written `onError` ladders
|
|
107
109
|
|
|
108
110
|
### WARNING
|
|
109
|
-
- [ ] Uses `schema.
|
|
111
|
+
- [ ] Uses `schema.req` channels appropriate for the HTTP method (no `body` on GET/HEAD)
|
|
110
112
|
- [ ] `pathPrefix` set consistently
|
|
111
113
|
- [ ] `successStatus` overridden only when default (POST→201, DELETE→204) is wrong
|
|
112
|
-
- [ ]
|
|
113
|
-
- [ ] `APIConfig<keyof typeof appErrors & string>` used when the app wants compile-time typo protection on per-route `errors: [...]`
|
|
114
|
+
- [ ] `CreateHttp` routes do NOT pass an explicit generic for error-key typo protection (that binds `TName` and breaks `schema.req`/`schema.res` inference) — attach `satisfies (keyof typeof appErrors & string)[]` to the `errors` array instead
|
|
114
115
|
|
|
115
116
|
### SUGGESTION
|
|
116
117
|
- [ ] Route documentation accessed via `builder.docs` for OpenAPI generation
|
|
@@ -33,6 +33,40 @@ const result = await GetUser({ userId: 'u1', requestId: 'r1' }, {})
|
|
|
33
33
|
|
|
34
34
|
---
|
|
35
35
|
|
|
36
|
+
## Factory Options
|
|
37
|
+
|
|
38
|
+
All options are optional. `validation: false` replaces v8's `config: { noRuntimeValidation: true }`.
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
import { Procedures } from 'ts-procedures'
|
|
42
|
+
import type { SchemaAdapter } from 'ts-procedures'
|
|
43
|
+
|
|
44
|
+
const { Create, CreateHttp } = Procedures<AppContext>({
|
|
45
|
+
// Skip per-call AJV validation for the whole factory (trusted internal callers only).
|
|
46
|
+
// Schemas/validators are still computed at registration — bad schemas still fail fast.
|
|
47
|
+
validation: false,
|
|
48
|
+
|
|
49
|
+
// OR customize AJV per factory (options merged over the defaults, or pass an Ajv instance)
|
|
50
|
+
// validation: { ajv: { coerceTypes: false } },
|
|
51
|
+
|
|
52
|
+
// Plug in another schema library (TypeBox is built in).
|
|
53
|
+
// Runtime validation + docs only — Infer<T> works only for TypeBox.
|
|
54
|
+
schema: {
|
|
55
|
+
adapters: [{
|
|
56
|
+
name: 'zod',
|
|
57
|
+
detect: (s) => s instanceof z.ZodType,
|
|
58
|
+
toJsonSchema: (s) => z.toJSONSchema(s as z.ZodType),
|
|
59
|
+
} satisfies SchemaAdapter],
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
// Factory-level defaults for CreateHttp / CreateHttpStream (per-route values win).
|
|
63
|
+
// pathPrefix is part of the route's identity — it shows up in config.path and route docs.
|
|
64
|
+
http: { pathPrefix: '/v1', scope: 'billing' },
|
|
65
|
+
})
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
36
70
|
## Schema Validation with TypeBox
|
|
37
71
|
|
|
38
72
|
```typescript
|
|
@@ -585,9 +619,9 @@ const app = new HonoAppBuilder({
|
|
|
585
619
|
|
|
586
620
|
---
|
|
587
621
|
|
|
588
|
-
## Hono API Integration (REST-style) —
|
|
622
|
+
## Hono API Integration (REST-style) — `CreateHttp`
|
|
589
623
|
|
|
590
|
-
|
|
624
|
+
HTTP routes use `CreateHttp` (and `CreateHttpStream` for streaming; both v8+). The factory does not need an `APIConfig` type parameter; HTTP fields (`path`, `method`, `scope`, `errors`) live on the `CreateHttp` config directly.
|
|
591
625
|
|
|
592
626
|
```typescript
|
|
593
627
|
import { Procedures } from 'ts-procedures'
|
|
@@ -656,7 +690,7 @@ const app = new HonoAppBuilder({
|
|
|
656
690
|
|
|
657
691
|
---
|
|
658
692
|
|
|
659
|
-
## schema.req — Multi-Channel Structured Input
|
|
693
|
+
## schema.req — Multi-Channel Structured Input
|
|
660
694
|
|
|
661
695
|
Use `schema.req` for structured per-channel validation. Channels: `pathParams`, `query`, `body`, `headers`.
|
|
662
696
|
|
|
@@ -689,7 +723,7 @@ API.CreateHttp('UpdateUserField', {
|
|
|
689
723
|
|
|
690
724
|
---
|
|
691
725
|
|
|
692
|
-
## Response Headers (
|
|
726
|
+
## Response Headers (`CreateHttp`)
|
|
693
727
|
|
|
694
728
|
The `{ body, headers }` envelope is strictly **opt-in**. By default the handler's return value is serialized verbatim as the response body — the framework does **not** duck-type the result looking for a `body` key. The envelope is only expected when `schema.res.headers` is declared; in that case (and only then) the handler must return `{ body, headers }` instead of the body bare. The client surfaces initial response headers on `TypedStream.headers` for streaming routes.
|
|
695
729
|
|
|
@@ -720,12 +754,15 @@ API.CreateHttp('DownloadReport', {
|
|
|
720
754
|
## onCreate Callback for Framework Integration
|
|
721
755
|
|
|
722
756
|
```typescript
|
|
723
|
-
|
|
757
|
+
import type { AnyProcedureRegistration } from 'ts-procedures'
|
|
758
|
+
|
|
759
|
+
const registeredProcedures: AnyProcedureRegistration[] = []
|
|
724
760
|
|
|
725
761
|
const { Create } = Procedures<AppContext>({
|
|
726
762
|
onCreate: (procedure) => {
|
|
727
763
|
registeredProcedures.push(procedure)
|
|
728
|
-
|
|
764
|
+
// Narrow on the kind discriminant: 'rpc' | 'rpc-stream' | 'http' | 'http-stream'
|
|
765
|
+
console.log(`Registered: ${procedure.kind} ${procedure.name}`)
|
|
729
766
|
},
|
|
730
767
|
})
|
|
731
768
|
|
|
@@ -736,6 +773,8 @@ const { Create } = Procedures<AppContext>({
|
|
|
736
773
|
// - Permission registration
|
|
737
774
|
```
|
|
738
775
|
|
|
776
|
+
For a full custom server adapter (Fastify, Express, raw http, ...), pair `onCreate`/`getProcedures()` with the transport-agnostic `ts-procedures/server` toolkit — route-doc builders, data-in/data-out error dispatch (`dispatchPreStreamError` / `dispatchMidStreamError`), `RequestSource` channel extraction, and `SseEventSequencer` — so the adapter is thin glue instead of a framework re-implementation. See `api-reference.md § Server Toolkit`.
|
|
777
|
+
|
|
739
778
|
---
|
|
740
779
|
|
|
741
780
|
## getProcedures() for Introspection
|
|
@@ -56,7 +56,7 @@ export const {{name}}Client = createApiClient({
|
|
|
56
56
|
// --- RPC call example ---
|
|
57
57
|
// const user = await {{name}}Client.users.GetUser({ userId: '123' })
|
|
58
58
|
|
|
59
|
-
// --- API call example (with schema.
|
|
59
|
+
// --- API call example (with schema.req channels) ---
|
|
60
60
|
// const user = await {{name}}Client.users.GetUser({ pathParams: { id: '123' } })
|
|
61
61
|
|
|
62
62
|
// --- Streaming call example ---
|
|
@@ -139,7 +139,7 @@ const {{name}}Errors = defineErrorTaxonomy({
|
|
|
139
139
|
// One builder, one register() call, all four kinds. Config is stratified by
|
|
140
140
|
// kind: rpc.{onSuccess}, api.{queryParser, onSuccess}, stream.{...}. Cross-cutting
|
|
141
141
|
// concerns (errors, unknownError, onError, onRequestError, onRequestStart/End,
|
|
142
|
-
// pathPrefix) live at the top level. See src/
|
|
142
|
+
// pathPrefix) live at the top level. See src/adapters/hono/types.ts.
|
|
143
143
|
|
|
144
144
|
// Optional observers (uncomment as needed):
|
|
145
145
|
// onRequestStart: (c) => {...} // every inbound request (all kinds)
|