@spfn/core 0.2.0-beta.2 → 0.2.0-beta.3
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 +91 -6
- package/dist/{boss-D-fGtVgM.d.ts → boss-BO8ty33K.d.ts} +45 -5
- package/dist/job/index.d.ts +34 -3
- package/dist/job/index.js +7 -7
- package/dist/job/index.js.map +1 -1
- package/dist/middleware/index.d.ts +102 -11
- package/dist/middleware/index.js +2 -2
- package/dist/middleware/index.js.map +1 -1
- package/dist/nextjs/index.d.ts +2 -2
- package/dist/nextjs/server.d.ts +2 -2
- package/dist/nextjs/server.js.map +1 -1
- package/dist/route/index.d.ts +62 -12
- package/dist/route/index.js +71 -22
- package/dist/route/index.js.map +1 -1
- package/dist/route/types.d.ts +2 -31
- package/dist/server/index.d.ts +6 -6
- package/dist/server/index.js +6 -6
- package/dist/server/index.js.map +1 -1
- package/dist/{types-DRG2XMTR.d.ts → types-BVxUIkcU.d.ts} +30 -3
- package/package.json +2 -2
|
@@ -4,6 +4,8 @@ import { RouteDef, RouteInput } from '@spfn/core/route';
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Extract structured input from RouteInput
|
|
7
|
+
*
|
|
8
|
+
* Converts TypeBox schemas to their static types for each input field.
|
|
7
9
|
*/
|
|
8
10
|
type StructuredInput<TInput extends RouteInput> = {
|
|
9
11
|
params: TInput['params'] extends TSchema ? Static<TInput['params']> : {};
|
|
@@ -13,11 +15,36 @@ type StructuredInput<TInput extends RouteInput> = {
|
|
|
13
15
|
cookies: TInput['cookies'] extends TSchema ? Static<TInput['cookies']> : {};
|
|
14
16
|
};
|
|
15
17
|
/**
|
|
16
|
-
* Infer route input type
|
|
18
|
+
* Infer route input type from RouteDef
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* // Server route definition
|
|
23
|
+
* const getUser = route.get('/users/:id')
|
|
24
|
+
* .input({ params: Type.Object({ id: Type.String() }) })
|
|
25
|
+
* .handler(...);
|
|
26
|
+
*
|
|
27
|
+
* // Client: extract input type
|
|
28
|
+
* type Input = InferRouteInput<typeof getUser>;
|
|
29
|
+
* // { params: { id: string }, query: {}, body: {}, ... }
|
|
30
|
+
* ```
|
|
17
31
|
*/
|
|
18
32
|
type InferRouteInput<TRoute> = TRoute extends RouteDef<infer TInput, any, any> ? StructuredInput<TInput> : never;
|
|
19
33
|
/**
|
|
20
|
-
* Infer route output type
|
|
34
|
+
* Infer route output type from RouteDef
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* // Server route definition
|
|
39
|
+
* const getUser = route.get('/users/:id')
|
|
40
|
+
* .handler(async (c) => {
|
|
41
|
+
* return { id: '1', name: 'John' };
|
|
42
|
+
* });
|
|
43
|
+
*
|
|
44
|
+
* // Client: extract output type
|
|
45
|
+
* type Output = InferRouteOutput<typeof getUser>;
|
|
46
|
+
* // { id: string, name: string }
|
|
47
|
+
* ```
|
|
21
48
|
*/
|
|
22
49
|
type InferRouteOutput<TRoute> = TRoute extends RouteDef<any, any, infer TResponse> ? TResponse : never;
|
|
23
50
|
/**
|
|
@@ -154,4 +181,4 @@ interface CallOptions {
|
|
|
154
181
|
};
|
|
155
182
|
}
|
|
156
183
|
|
|
157
|
-
export type { ApiConfig as A, CallOptions as C, InferRouteInput as I, RequestInterceptor as R,
|
|
184
|
+
export type { ApiConfig as A, CallOptions as C, InferRouteInput as I, RequestInterceptor as R, StructuredInput as S, ResponseInterceptor as a, InferRouteOutput as b, CookieOptions as c, SetCookie as d };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spfn/core",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.3",
|
|
4
4
|
"description": "SPFN Framework Core - File-based routing, transactions, repository pattern",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -168,7 +168,7 @@
|
|
|
168
168
|
],
|
|
169
169
|
"publishConfig": {
|
|
170
170
|
"access": "public",
|
|
171
|
-
"tag": "
|
|
171
|
+
"tag": "beta"
|
|
172
172
|
},
|
|
173
173
|
"scripts": {
|
|
174
174
|
"build": "pnpm check:circular && tsup",
|