ts-procedures 3.0.1 → 3.1.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/build/implementations/http/express-rpc/index.d.ts +14 -4
- package/build/implementations/http/express-rpc/index.js +20 -8
- package/build/implementations/http/express-rpc/index.js.map +1 -1
- package/build/implementations/http/express-rpc/index.test.js +162 -3
- package/build/implementations/http/express-rpc/index.test.js.map +1 -1
- package/build/implementations/http/express-rpc/types.d.ts +6 -23
- package/build/implementations/http/hono-rpc/index.d.ts +13 -4
- package/build/implementations/http/hono-rpc/index.js +20 -8
- package/build/implementations/http/hono-rpc/index.js.map +1 -1
- package/build/implementations/http/hono-rpc/index.test.js +158 -2
- package/build/implementations/http/hono-rpc/index.test.js.map +1 -1
- package/build/implementations/http/hono-rpc/types.d.ts +6 -23
- package/build/implementations/types.d.ts +32 -1
- package/package.json +1 -1
- package/src/implementations/http/express-rpc/README.md +2 -2
- package/src/implementations/http/express-rpc/index.test.ts +234 -3
- package/src/implementations/http/express-rpc/index.ts +49 -13
- package/src/implementations/http/express-rpc/types.ts +8 -25
- package/src/implementations/http/hono-rpc/README.md +84 -44
- package/src/implementations/http/hono-rpc/index.test.ts +230 -2
- package/src/implementations/http/hono-rpc/index.ts +49 -14
- package/src/implementations/http/hono-rpc/types.ts +8 -25
- package/src/implementations/types.ts +39 -1
|
@@ -11,7 +11,8 @@ export type FactoryItem<C> = {
|
|
|
11
11
|
factoryContext: (req: Request) => C
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export interface RPCHttpRouteDoc {
|
|
14
|
+
export interface RPCHttpRouteDoc extends RPCConfig {
|
|
15
|
+
name: string // procedure name
|
|
15
16
|
path: string
|
|
16
17
|
method: 'post'
|
|
17
18
|
jsonSchema: {
|
|
@@ -19,3 +20,40 @@ export interface RPCHttpRouteDoc {
|
|
|
19
20
|
response?: object
|
|
20
21
|
}
|
|
21
22
|
}
|
|
23
|
+
|
|
24
|
+
// ================
|
|
25
|
+
// Utility types
|
|
26
|
+
// ================
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Extracts the TContext type from a Procedures factory return type.
|
|
30
|
+
* Uses the first parameter of the handler function to infer the context type.
|
|
31
|
+
*/
|
|
32
|
+
export type ExtractContext<TFactory> = TFactory extends {
|
|
33
|
+
getProcedures: () => Array<{ handler: (ctx: infer TContext, ...args: any[]) => any }>
|
|
34
|
+
}
|
|
35
|
+
? TContext
|
|
36
|
+
: never
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Extracts the TConfig type from a Procedures factory return type.
|
|
40
|
+
* Uses the config property of the procedure registration to infer the config type.
|
|
41
|
+
*/
|
|
42
|
+
export type ExtractConfig<TFactory> = TFactory extends {
|
|
43
|
+
getProcedures: () => Array<{ config: infer TConfig }>
|
|
44
|
+
}
|
|
45
|
+
? TConfig
|
|
46
|
+
: never
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Minimal structural type for a Procedures factory.
|
|
50
|
+
* Uses explicit `any` types to avoid variance issues with generic constraints.
|
|
51
|
+
*/
|
|
52
|
+
export type ProceduresFactory = {
|
|
53
|
+
getProcedures: () => Array<{
|
|
54
|
+
name: string
|
|
55
|
+
config: any
|
|
56
|
+
handler: (ctx: any, params?: any) => Promise<any>
|
|
57
|
+
}>
|
|
58
|
+
Create: (...args: any[]) => any
|
|
59
|
+
}
|