ts-procedures 5.3.0 → 5.4.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.
Files changed (38) hide show
  1. package/README.md +90 -0
  2. package/agent_config/claude-code/agents/ts-procedures-architect.md +15 -0
  3. package/agent_config/claude-code/skills/guide/anti-patterns.md +106 -0
  4. package/agent_config/claude-code/skills/guide/api-reference.md +150 -4
  5. package/agent_config/claude-code/skills/guide/patterns.md +155 -0
  6. package/agent_config/claude-code/skills/review/checklist.md +22 -0
  7. package/agent_config/claude-code/skills/scaffold/SKILL.md +3 -1
  8. package/agent_config/claude-code/skills/scaffold/templates/hono-api.md +169 -0
  9. package/agent_config/copilot/copilot-instructions.md +35 -0
  10. package/agent_config/cursor/cursorrules +35 -0
  11. package/build/implementations/http/hono-api/index.d.ts +102 -0
  12. package/build/implementations/http/hono-api/index.js +339 -0
  13. package/build/implementations/http/hono-api/index.js.map +1 -0
  14. package/build/implementations/http/hono-api/index.test.d.ts +1 -0
  15. package/build/implementations/http/hono-api/index.test.js +983 -0
  16. package/build/implementations/http/hono-api/index.test.js.map +1 -0
  17. package/build/implementations/http/hono-api/types.d.ts +13 -0
  18. package/build/implementations/http/hono-api/types.js +2 -0
  19. package/build/implementations/http/hono-api/types.js.map +1 -0
  20. package/build/implementations/types.d.ts +44 -0
  21. package/build/index.d.ts +28 -6
  22. package/build/index.js +28 -0
  23. package/build/index.js.map +1 -1
  24. package/build/schema/compute-schema.d.ts +5 -0
  25. package/build/schema/compute-schema.js +8 -1
  26. package/build/schema/compute-schema.js.map +1 -1
  27. package/build/schema/parser.d.ts +6 -5
  28. package/build/schema/parser.js +54 -0
  29. package/build/schema/parser.js.map +1 -1
  30. package/package.json +8 -3
  31. package/src/implementations/http/README.md +45 -2
  32. package/src/implementations/http/hono-api/index.test.ts +1328 -0
  33. package/src/implementations/http/hono-api/index.ts +461 -0
  34. package/src/implementations/http/hono-api/types.ts +16 -0
  35. package/src/implementations/types.ts +52 -0
  36. package/src/index.ts +87 -10
  37. package/src/schema/compute-schema.ts +23 -2
  38. package/src/schema/parser.ts +70 -3
@@ -21,12 +21,21 @@ For procedures created with `CreateStream()` - server-sent events and streaming
21
21
  |-----------|---------|-------------|
22
22
  | [Hono Stream](./hono-stream/README.md) | `hono-stream` | SSE and text streaming for async generators |
23
23
 
24
+ ### API (REST-style)
25
+
26
+ For procedures using `schema.input` — per-channel input validation with standard HTTP methods.
27
+
28
+ | Framework | Package | Description |
29
+ |-----------|---------|-------------|
30
+ | [Hono API](./hono-api/) | `hono-api` | REST-style routing by HTTP method (GET, POST, PUT, DELETE, PATCH, HEAD) |
31
+
24
32
  ## Procedure Types
25
33
 
26
34
  | Type | Created With | Handler Return | HTTP Methods | Use Case |
27
35
  |------|--------------|----------------|--------------|----------|
28
36
  | RPC | `Create()` | `Promise<T>` | POST | Standard request/response |
29
37
  | Stream | `CreateStream()` | `AsyncGenerator<T>` | GET, POST | Real-time updates, SSE |
38
+ | API | `Create()` | `Promise<T>` | GET, POST, PUT, DELETE, PATCH, HEAD | REST-style endpoints with per-channel input |
30
39
 
31
40
  ## Core Concepts
32
41
 
@@ -41,6 +50,18 @@ interface RPCConfig {
41
50
  }
42
51
  ```
43
52
 
53
+ #### APIConfig (REST-style)
54
+
55
+ ```typescript
56
+ interface APIConfig {
57
+ path: string // Route path with Hono params (e.g., '/users/:id')
58
+ method: HttpMethod // 'get' | 'post' | 'put' | 'delete' | 'patch' | 'head'
59
+ successStatus?: number // Default: POST→201, DELETE→204, others→200
60
+ }
61
+ ```
62
+
63
+ API routes use developer-defined paths — no auto-generation from scope/version.
64
+
44
65
  ### Path Generation
45
66
 
46
67
  Routes are generated using kebab-case conversion:
@@ -127,8 +148,8 @@ onRequestStart → onStreamStart → [yields...] → onStreamEnd → onRequestEn
127
148
  |------|--------------|---------|
128
149
  | `onRequestStart` | Both | Before route handler |
129
150
  | `onRequestEnd` | Both | After response sent |
130
- | `onSuccess` | RPC | After successful handler |
131
- | `onError` | RPC | On handler error |
151
+ | `onSuccess` | RPC, API | After successful handler |
152
+ | `onError` | RPC, API | On handler error |
132
153
  | `onStreamStart` | Stream | Before first yield |
133
154
  | `onStreamEnd` | Stream | After stream completes |
134
155
  | `onPreStreamError` | Stream | On pre-stream error (validation, auth) |
@@ -172,6 +193,25 @@ interface StreamHttpRouteDoc {
172
193
  }
173
194
  ```
174
195
 
196
+ **API Documentation (`APIHttpRouteDoc`):**
197
+
198
+ ```typescript
199
+ interface APIHttpRouteDoc {
200
+ name: string
201
+ path: string
202
+ method: HttpMethod
203
+ fullPath: string
204
+ successStatus?: number
205
+ jsonSchema: {
206
+ pathParams?: object // From schema.input.pathParams
207
+ query?: object // From schema.input.query
208
+ body?: object // From schema.input.body
209
+ headers?: object // From schema.input.headers
210
+ response?: object // From schema.returnType
211
+ }
212
+ }
213
+ ```
214
+
175
215
  ### Builder Pattern
176
216
 
177
217
  All implementations follow the same builder pattern:
@@ -185,6 +225,8 @@ const app = builder.build()
185
225
  const docs = builder.docs
186
226
  ```
187
227
 
228
+ **Note:** `HonoAPIAppBuilder.build()` is async (resolves query parser on first call).
229
+
188
230
  **Key methods:**
189
231
 
190
232
  | Method | Returns | Description |
@@ -214,4 +256,5 @@ const docs = builder.docs
214
256
 
215
257
  ```typescript
216
258
  import { RPCConfig, RPCHttpRouteDoc, StreamHttpRouteDoc, StreamMode } from 'ts-procedures/implementations/types'
259
+ import type { APIConfig, APIHttpRouteDoc, APIInput, HttpMethod } from 'ts-procedures/http'
217
260
  ```