ts-procedures 5.7.0 → 5.7.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 +185 -0
- package/agent_config/claude-code/skills/guide/api-reference.md +200 -0
- package/agent_config/claude-code/skills/guide/patterns.md +108 -0
- package/agent_config/copilot/copilot-instructions.md +87 -0
- package/agent_config/cursor/cursorrules +87 -0
- package/build/implementations/http/doc-registry.test.js +27 -1
- package/build/implementations/http/doc-registry.test.js.map +1 -1
- package/build/implementations/http/express-rpc/index.js +1 -0
- package/build/implementations/http/express-rpc/index.js.map +1 -1
- package/build/implementations/http/express-rpc/index.test.js +1 -1
- package/build/implementations/http/express-rpc/index.test.js.map +1 -1
- package/build/implementations/http/hono-api/index.js +2 -0
- package/build/implementations/http/hono-api/index.js.map +1 -1
- package/build/implementations/http/hono-api/index.test.js +9 -0
- package/build/implementations/http/hono-api/index.test.js.map +1 -1
- package/build/implementations/http/hono-rpc/index.js +1 -0
- package/build/implementations/http/hono-rpc/index.js.map +1 -1
- package/build/implementations/http/hono-rpc/index.test.js +1 -1
- package/build/implementations/http/hono-rpc/index.test.js.map +1 -1
- package/build/implementations/http/hono-stream/index.js +17 -1
- package/build/implementations/http/hono-stream/index.js.map +1 -1
- package/build/implementations/http/hono-stream/index.test.js +61 -0
- package/build/implementations/http/hono-stream/index.test.js.map +1 -1
- package/build/implementations/http/hono-stream/types.d.ts +4 -13
- package/build/implementations/types.d.ts +5 -0
- package/build/index.js +8 -1
- package/build/index.js.map +1 -1
- package/package.json +21 -3
- package/src/client/call.ts +74 -0
- package/src/client/errors.ts +43 -0
- package/src/client/fetch-adapter.ts +191 -0
- package/src/client/hooks.ts +65 -0
- package/src/client/index.ts +121 -0
- package/src/client/request-builder.ts +73 -0
- package/src/client/stream.ts +164 -0
- package/src/client/types.ts +103 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// ── Adapter ──────────────────────────────────────────────
|
|
2
|
+
|
|
3
|
+
export interface ClientAdapter {
|
|
4
|
+
request(config: AdapterRequest): Promise<AdapterResponse>
|
|
5
|
+
stream(config: AdapterRequest): Promise<AdapterStreamResponse>
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface AdapterRequest {
|
|
9
|
+
url: string
|
|
10
|
+
method: string
|
|
11
|
+
headers?: Record<string, string>
|
|
12
|
+
body?: unknown
|
|
13
|
+
signal?: AbortSignal
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface AdapterResponse {
|
|
17
|
+
status: number
|
|
18
|
+
headers: Record<string, string>
|
|
19
|
+
body: unknown
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface AdapterStreamResponse {
|
|
23
|
+
status: number
|
|
24
|
+
headers: Record<string, string>
|
|
25
|
+
body: AsyncIterable<unknown>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// ── Hooks ────────────────────────────────────────────────
|
|
29
|
+
|
|
30
|
+
export interface ClientHooks {
|
|
31
|
+
onBeforeRequest?(context: BeforeRequestContext): BeforeRequestContext | Promise<BeforeRequestContext>
|
|
32
|
+
onAfterResponse?(context: AfterResponseContext): void | Promise<void>
|
|
33
|
+
onError?(context: ErrorContext): void | Promise<void>
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface BeforeRequestContext {
|
|
37
|
+
procedureName: string
|
|
38
|
+
scope: string
|
|
39
|
+
request: AdapterRequest
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface AfterResponseContext {
|
|
43
|
+
procedureName: string
|
|
44
|
+
scope: string
|
|
45
|
+
request: AdapterRequest
|
|
46
|
+
response: AdapterResponse
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface ErrorContext {
|
|
50
|
+
procedureName: string
|
|
51
|
+
scope: string
|
|
52
|
+
request: AdapterRequest
|
|
53
|
+
error: unknown
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// ── Descriptors ──────────────────────────────────────────
|
|
57
|
+
|
|
58
|
+
export interface CallDescriptor {
|
|
59
|
+
name: string
|
|
60
|
+
scope: string
|
|
61
|
+
path: string
|
|
62
|
+
method: string
|
|
63
|
+
kind: 'rpc' | 'api' | 'stream'
|
|
64
|
+
params: unknown
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface StreamDescriptor extends CallDescriptor {
|
|
68
|
+
kind: 'stream'
|
|
69
|
+
streamMode: 'sse' | 'text'
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// ── TypedStream ──────────────────────────────────────────
|
|
73
|
+
|
|
74
|
+
export interface TypedStream<TYield, TReturn = void> extends AsyncIterable<TYield> {
|
|
75
|
+
/**
|
|
76
|
+
* Resolves when the stream completes with the final return value.
|
|
77
|
+
* Rejects if the stream errors before completing.
|
|
78
|
+
* Note: iteration must begin (via for-await) for this promise to settle,
|
|
79
|
+
* since resolution depends on the async generator running to completion.
|
|
80
|
+
*/
|
|
81
|
+
result: Promise<TReturn>
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// ── Client Instance ──────────────────────────────────────
|
|
85
|
+
|
|
86
|
+
export type ProcedureCallOptions = ClientHooks
|
|
87
|
+
|
|
88
|
+
export interface ClientInstance {
|
|
89
|
+
basePath: string
|
|
90
|
+
adapter: ClientAdapter
|
|
91
|
+
hooks: ClientHooks
|
|
92
|
+
call<TResponse>(descriptor: CallDescriptor, options?: ProcedureCallOptions): Promise<TResponse>
|
|
93
|
+
stream<TYield, TReturn>(descriptor: StreamDescriptor, options?: ProcedureCallOptions): TypedStream<TYield, TReturn>
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// ── createClient Config ──────────────────────────────────
|
|
97
|
+
|
|
98
|
+
export interface CreateClientConfig<TScopes> {
|
|
99
|
+
adapter: ClientAdapter
|
|
100
|
+
basePath: string
|
|
101
|
+
scopes: (client: ClientInstance) => TScopes
|
|
102
|
+
hooks?: ClientHooks
|
|
103
|
+
}
|