ts-procedures 5.16.0 → 6.0.1
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 +2 -0
- package/agent_config/claude-code/agents/ts-procedures-architect.md +13 -6
- package/agent_config/claude-code/skills/ts-procedures/SKILL.md +26 -4
- package/agent_config/claude-code/skills/ts-procedures/anti-patterns.md +87 -19
- package/agent_config/claude-code/skills/ts-procedures/api-reference.md +162 -16
- package/agent_config/claude-code/skills/ts-procedures/patterns.md +179 -16
- package/agent_config/claude-code/skills/ts-procedures-review/SKILL.md +1 -1
- package/agent_config/claude-code/skills/ts-procedures-review/checklist.md +20 -12
- package/agent_config/claude-code/skills/ts-procedures-scaffold/SKILL.md +2 -1
- package/agent_config/claude-code/skills/ts-procedures-scaffold/templates/client.md +22 -15
- package/agent_config/claude-code/skills/ts-procedures-scaffold/templates/express-rpc.md +20 -17
- package/agent_config/claude-code/skills/ts-procedures-scaffold/templates/hono-api.md +20 -16
- package/agent_config/claude-code/skills/ts-procedures-scaffold/templates/hono-rpc.md +20 -17
- package/agent_config/claude-code/skills/ts-procedures-scaffold/templates/hono-stream.md +16 -3
- package/agent_config/copilot/copilot-instructions.md +78 -12
- package/agent_config/cursor/cursorrules +78 -12
- package/build/client/call.d.ts +2 -1
- package/build/client/call.js +9 -1
- package/build/client/call.js.map +1 -1
- package/build/client/error-dispatch.d.ts +13 -0
- package/build/client/error-dispatch.js +26 -0
- package/build/client/error-dispatch.js.map +1 -0
- package/build/client/error-dispatch.test.d.ts +1 -0
- package/build/client/error-dispatch.test.js +56 -0
- package/build/client/error-dispatch.test.js.map +1 -0
- package/build/client/fetch-adapter.js +10 -4
- package/build/client/fetch-adapter.js.map +1 -1
- package/build/client/index.d.ts +2 -1
- package/build/client/index.js +5 -1
- package/build/client/index.js.map +1 -1
- package/build/client/stream.d.ts +2 -1
- package/build/client/stream.js +13 -3
- package/build/client/stream.js.map +1 -1
- package/build/client/typed-error-dispatch.test.d.ts +1 -0
- package/build/client/typed-error-dispatch.test.js +168 -0
- package/build/client/typed-error-dispatch.test.js.map +1 -0
- package/build/client/types.d.ts +37 -0
- package/build/codegen/e2e.test.js +9 -4
- package/build/codegen/e2e.test.js.map +1 -1
- package/build/codegen/emit-client-runtime.js +4 -0
- package/build/codegen/emit-client-runtime.js.map +1 -1
- package/build/codegen/emit-errors.d.ts +17 -6
- package/build/codegen/emit-errors.integration.test.d.ts +1 -0
- package/build/codegen/emit-errors.integration.test.js +162 -0
- package/build/codegen/emit-errors.integration.test.js.map +1 -0
- package/build/codegen/emit-errors.js +50 -39
- package/build/codegen/emit-errors.js.map +1 -1
- package/build/codegen/emit-errors.test.js +75 -78
- package/build/codegen/emit-errors.test.js.map +1 -1
- package/build/codegen/emit-index.d.ts +7 -0
- package/build/codegen/emit-index.js +26 -4
- package/build/codegen/emit-index.js.map +1 -1
- package/build/codegen/emit-index.test.js +55 -23
- package/build/codegen/emit-index.test.js.map +1 -1
- package/build/codegen/emit-scope.d.ts +8 -0
- package/build/codegen/emit-scope.js +82 -7
- package/build/codegen/emit-scope.js.map +1 -1
- package/build/codegen/pipeline.js +22 -2
- package/build/codegen/pipeline.js.map +1 -1
- package/build/implementations/http/doc-registry.d.ts +17 -1
- package/build/implementations/http/doc-registry.js +47 -79
- package/build/implementations/http/doc-registry.js.map +1 -1
- package/build/implementations/http/doc-registry.test.js +149 -16
- package/build/implementations/http/doc-registry.test.js.map +1 -1
- package/build/implementations/http/error-taxonomy.d.ts +249 -0
- package/build/implementations/http/error-taxonomy.js +252 -0
- package/build/implementations/http/error-taxonomy.js.map +1 -0
- package/build/implementations/http/error-taxonomy.test.d.ts +1 -0
- package/build/implementations/http/error-taxonomy.test.js +399 -0
- package/build/implementations/http/error-taxonomy.test.js.map +1 -0
- package/build/implementations/http/express-rpc/error-taxonomy.test.d.ts +1 -0
- package/build/implementations/http/express-rpc/error-taxonomy.test.js +83 -0
- package/build/implementations/http/express-rpc/error-taxonomy.test.js.map +1 -0
- package/build/implementations/http/express-rpc/index.d.ts +39 -8
- package/build/implementations/http/express-rpc/index.js +39 -8
- package/build/implementations/http/express-rpc/index.js.map +1 -1
- package/build/implementations/http/hono-api/error-taxonomy.test.d.ts +1 -0
- package/build/implementations/http/hono-api/error-taxonomy.test.js +137 -0
- package/build/implementations/http/hono-api/error-taxonomy.test.js.map +1 -0
- package/build/implementations/http/hono-api/index.d.ts +38 -1
- package/build/implementations/http/hono-api/index.js +32 -0
- package/build/implementations/http/hono-api/index.js.map +1 -1
- package/build/implementations/http/hono-rpc/error-taxonomy.test.d.ts +1 -0
- package/build/implementations/http/hono-rpc/error-taxonomy.test.js +64 -0
- package/build/implementations/http/hono-rpc/error-taxonomy.test.js.map +1 -0
- package/build/implementations/http/hono-rpc/index.d.ts +34 -7
- package/build/implementations/http/hono-rpc/index.js +31 -4
- package/build/implementations/http/hono-rpc/index.js.map +1 -1
- package/build/implementations/http/hono-stream/error-taxonomy.test.d.ts +1 -0
- package/build/implementations/http/hono-stream/error-taxonomy.test.js +87 -0
- package/build/implementations/http/hono-stream/error-taxonomy.test.js.map +1 -0
- package/build/implementations/http/hono-stream/index.d.ts +40 -3
- package/build/implementations/http/hono-stream/index.js +37 -10
- package/build/implementations/http/hono-stream/index.js.map +1 -1
- package/build/implementations/http/hono-stream/index.test.js +45 -18
- package/build/implementations/http/hono-stream/index.test.js.map +1 -1
- package/build/implementations/http/on-request-error.test.d.ts +1 -0
- package/build/implementations/http/on-request-error.test.js +173 -0
- package/build/implementations/http/on-request-error.test.js.map +1 -0
- package/build/implementations/http/route-errors.test.d.ts +1 -0
- package/build/implementations/http/route-errors.test.js +139 -0
- package/build/implementations/http/route-errors.test.js.map +1 -0
- package/build/implementations/types.d.ts +43 -3
- package/docs/client-and-codegen.md +105 -12
- package/docs/core.md +14 -5
- package/docs/http-integrations.md +138 -5
- package/docs/streaming.md +3 -1
- package/docs/superpowers/plans/2026-04-24-doc-registry-simplification.md +886 -0
- package/package.json +7 -2
- package/src/client/call.ts +10 -1
- package/src/client/error-dispatch.test.ts +72 -0
- package/src/client/error-dispatch.ts +27 -0
- package/src/client/fetch-adapter.ts +11 -5
- package/src/client/index.ts +9 -0
- package/src/client/stream.ts +14 -3
- package/src/client/typed-error-dispatch.test.ts +211 -0
- package/src/client/types.ts +42 -0
- package/src/codegen/e2e.test.ts +9 -4
- package/src/codegen/emit-client-runtime.ts +4 -0
- package/src/codegen/emit-errors.integration.test.ts +183 -0
- package/src/codegen/emit-errors.test.ts +91 -87
- package/src/codegen/emit-errors.ts +123 -41
- package/src/codegen/emit-index.test.ts +68 -24
- package/src/codegen/emit-index.ts +66 -4
- package/src/codegen/emit-scope.ts +124 -7
- package/src/codegen/pipeline.ts +25 -2
- package/src/implementations/http/README.md +21 -7
- package/src/implementations/http/doc-registry.test.ts +164 -16
- package/src/implementations/http/doc-registry.ts +58 -82
- package/src/implementations/http/error-taxonomy.test.ts +438 -0
- package/src/implementations/http/error-taxonomy.ts +361 -0
- package/src/implementations/http/express-rpc/README.md +23 -24
- package/src/implementations/http/express-rpc/error-taxonomy.test.ts +103 -0
- package/src/implementations/http/express-rpc/index.ts +75 -14
- package/src/implementations/http/hono-api/README.md +284 -0
- package/src/implementations/http/hono-api/error-taxonomy.test.ts +179 -0
- package/src/implementations/http/hono-api/index.ts +76 -1
- package/src/implementations/http/hono-rpc/README.md +20 -21
- package/src/implementations/http/hono-rpc/error-taxonomy.test.ts +82 -0
- package/src/implementations/http/hono-rpc/index.ts +65 -9
- package/src/implementations/http/hono-stream/README.md +44 -25
- package/src/implementations/http/hono-stream/error-taxonomy.test.ts +98 -0
- package/src/implementations/http/hono-stream/index.test.ts +54 -18
- package/src/implementations/http/hono-stream/index.ts +83 -13
- package/src/implementations/http/on-request-error.test.ts +201 -0
- package/src/implementations/http/route-errors.test.ts +176 -0
- package/src/implementations/types.ts +43 -3
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import { Procedures } from '../index.js'
|
|
2
|
+
import type { ErrorTaxonomy } from './http/error-taxonomy.js'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
/**
|
|
5
|
+
* @typeParam TErrorKey - Union of valid taxonomy keys. Defaults to `string`
|
|
6
|
+
* (unconstrained). Narrow it by passing `keyof typeof yourTaxonomy & string`
|
|
7
|
+
* to get compile-time typo protection on `errors`.
|
|
8
|
+
*/
|
|
9
|
+
export interface RPCConfig<TErrorKey extends string = string> {
|
|
4
10
|
// Scope or scopes (scope segments) required to access the RPC
|
|
5
11
|
scope: string | string[]
|
|
6
12
|
version: number
|
|
13
|
+
/**
|
|
14
|
+
* Taxonomy keys for errors this procedure may emit. Purely informational at
|
|
15
|
+
* runtime (nothing is rejected), but populates the DocEnvelope per-route
|
|
16
|
+
* error list so generated clients can narrow their catch types.
|
|
17
|
+
*/
|
|
18
|
+
errors?: TErrorKey[]
|
|
7
19
|
}
|
|
8
20
|
|
|
9
21
|
export type FactoryItem<C> = {
|
|
@@ -20,6 +32,8 @@ export interface RPCHttpRouteDoc extends RPCConfig {
|
|
|
20
32
|
body?: Record<string, unknown>
|
|
21
33
|
response?: Record<string, unknown>
|
|
22
34
|
}
|
|
35
|
+
/** Taxonomy keys for errors this route may emit. */
|
|
36
|
+
errors?: string[]
|
|
23
37
|
}
|
|
24
38
|
|
|
25
39
|
export type StreamMode = 'sse' | 'text'
|
|
@@ -30,7 +44,12 @@ export type StreamMode = 'sse' | 'text'
|
|
|
30
44
|
|
|
31
45
|
export type HttpMethod = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'head'
|
|
32
46
|
|
|
33
|
-
|
|
47
|
+
/**
|
|
48
|
+
* @typeParam TErrorKey - Union of valid taxonomy keys. Defaults to `string`.
|
|
49
|
+
* Narrow it by passing `keyof typeof yourTaxonomy & string` for compile-time
|
|
50
|
+
* typo protection on `errors`.
|
|
51
|
+
*/
|
|
52
|
+
export interface APIConfig<TErrorKey extends string = string> {
|
|
34
53
|
/** HTTP route path (supports Hono path params, e.g., '/users/:id') */
|
|
35
54
|
path: string
|
|
36
55
|
/** HTTP method for this endpoint */
|
|
@@ -39,6 +58,12 @@ export interface APIConfig {
|
|
|
39
58
|
successStatus?: number
|
|
40
59
|
/** Optional scope for grouping API routes in generated client files */
|
|
41
60
|
scope?: string
|
|
61
|
+
/**
|
|
62
|
+
* Taxonomy keys for errors this procedure may emit. Purely informational at
|
|
63
|
+
* runtime (nothing is rejected), but populates the DocEnvelope per-route
|
|
64
|
+
* error list so generated clients can narrow their catch types.
|
|
65
|
+
*/
|
|
66
|
+
errors?: TErrorKey[]
|
|
42
67
|
}
|
|
43
68
|
|
|
44
69
|
export interface APIHttpRouteDoc extends APIConfig {
|
|
@@ -53,6 +78,8 @@ export interface APIHttpRouteDoc extends APIConfig {
|
|
|
53
78
|
headers?: Record<string, unknown>
|
|
54
79
|
response?: Record<string, unknown>
|
|
55
80
|
}
|
|
81
|
+
/** Taxonomy keys for errors this route may emit. */
|
|
82
|
+
errors?: string[]
|
|
56
83
|
}
|
|
57
84
|
|
|
58
85
|
/**
|
|
@@ -90,6 +117,8 @@ export interface StreamHttpRouteDoc extends RPCConfig {
|
|
|
90
117
|
yieldType?: Record<string, unknown> // Schema for each streamed value
|
|
91
118
|
returnType?: Record<string, unknown> // Final return (optional)
|
|
92
119
|
}
|
|
120
|
+
/** Taxonomy keys for errors this route may emit (pre-stream only). */
|
|
121
|
+
errors?: string[]
|
|
93
122
|
}
|
|
94
123
|
|
|
95
124
|
// ================
|
|
@@ -158,7 +187,18 @@ export interface ErrorDoc {
|
|
|
158
187
|
export interface DocRegistryConfig {
|
|
159
188
|
basePath?: string
|
|
160
189
|
headers?: HeaderDoc[]
|
|
161
|
-
|
|
190
|
+
/**
|
|
191
|
+
* Errors to document in the envelope. Accepts either your runtime
|
|
192
|
+
* {@link ErrorTaxonomy} (from `defineErrorTaxonomy`) — the common case — or
|
|
193
|
+
* a raw `ErrorDoc[]` for consumers who aren't using a taxonomy.
|
|
194
|
+
*
|
|
195
|
+
* Framework defaults (`ProcedureError`, `ProcedureValidationError`,
|
|
196
|
+
* `ProcedureYieldValidationError`, `ProcedureRegistrationError`) are merged
|
|
197
|
+
* in automatically and deduped. Opt out via `includeDefaults: false`.
|
|
198
|
+
*/
|
|
199
|
+
errors?: ErrorTaxonomy | ErrorDoc[]
|
|
200
|
+
/** Whether to auto-merge framework error defaults. Defaults to `true`. */
|
|
201
|
+
includeDefaults?: boolean
|
|
162
202
|
}
|
|
163
203
|
|
|
164
204
|
export interface DocRegistryOutputOptions<TEnvelope = DocEnvelope> {
|