soonjs 0.0.5 → 0.0.8
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/dist/index.d.ts +17 -15
- package/dist/index.js +36210 -3632
- package/dist/one.d.ts +4 -1
- package/dist/{pazu-id.d.ts → soon-id.d.ts} +1 -1
- package/dist/types.d.ts +8 -6
- package/dist/vite-plugin-soon-client.d.ts +7 -0
- package/dist/{vite-plugin-pazu-server.d.ts → vite-plugin-soon-server.d.ts} +1 -1
- package/package.json +1 -2
- package/dist/vite-plugin-pazu-client.d.ts +0 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { PassThrough } from 'stream';
|
|
2
2
|
import { z, ZodType } from 'zod';
|
|
3
3
|
import { default as Observable } from 'zen-observable';
|
|
4
|
-
import { APIOptionsBase, Context, Middleware,
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { APIOptionsBase, Context, Middleware, SoonAppOptions, SoonFetchOptions, Response, APIOptions } from './types';
|
|
5
|
+
import { vitePluginSoonServer } from './vite-plugin-soon-server';
|
|
6
|
+
import { vitePluginSoonClient } from './vite-plugin-soon-client';
|
|
7
7
|
|
|
8
8
|
export interface Meta {
|
|
9
9
|
}
|
|
@@ -13,10 +13,12 @@ export interface Platform {
|
|
|
13
13
|
}
|
|
14
14
|
export interface Config {
|
|
15
15
|
}
|
|
16
|
-
export
|
|
16
|
+
export interface ServiceContext {
|
|
17
|
+
}
|
|
18
|
+
export { Context, SoonFetchOptions };
|
|
17
19
|
export type ReturnRealType<T extends (...args: any) => any | Promise<(...args: any) => any>, R = ReturnType<T>> = R extends Promise<infer U> ? U : R;
|
|
18
20
|
export type ReturnConfig<ConfigDefine extends () => any, T = ReturnType<ConfigDefine>> = T extends Promise<infer U> ? U : T;
|
|
19
|
-
export declare class
|
|
21
|
+
export declare class SoonApp {
|
|
20
22
|
private options;
|
|
21
23
|
private apis;
|
|
22
24
|
private middlewares;
|
|
@@ -26,15 +28,15 @@ export declare class PazuApp {
|
|
|
26
28
|
private getId;
|
|
27
29
|
config: Config;
|
|
28
30
|
apiList: APIOptions[];
|
|
29
|
-
constructor(options?:
|
|
31
|
+
constructor(options?: SoonAppOptions, callback?: (error: any, app: SoonApp) => void);
|
|
30
32
|
private init;
|
|
31
33
|
/**
|
|
32
34
|
* 调用 API
|
|
33
35
|
*/
|
|
34
|
-
fetchRaw(url: string, body?: any,
|
|
35
|
-
fetch(url: string, body?: any,
|
|
36
|
+
fetchRaw(url: string, body?: any, soonFetchOptions?: SoonFetchOptions): Promise<Response<any>>;
|
|
37
|
+
fetch(url: string, body?: any, soonFetchOptions?: SoonFetchOptions): Promise<any>;
|
|
36
38
|
}
|
|
37
|
-
export declare const
|
|
39
|
+
export declare const soonApiSymbol: unique symbol;
|
|
38
40
|
/**
|
|
39
41
|
* 定义 API
|
|
40
42
|
*/
|
|
@@ -51,7 +53,7 @@ export declare function defineApi<BodySchema extends ZodType<any, any, any>, Cus
|
|
|
51
53
|
}>) => Promise<Data> | Data;
|
|
52
54
|
}): {
|
|
53
55
|
path?: string;
|
|
54
|
-
method?: "get" | "head" | "post" | "put" | "delete" | "
|
|
56
|
+
method?: "get" | "head" | "post" | "put" | "delete" | "options" | "patch" | "all";
|
|
55
57
|
disabled?: boolean;
|
|
56
58
|
name?: string;
|
|
57
59
|
desc?: string;
|
|
@@ -68,7 +70,7 @@ export declare function defineApi<BodySchema extends ZodType<any, any, any>, Cus
|
|
|
68
70
|
bodySchema?: BodySchema;
|
|
69
71
|
}>) => Promise<Data> | Data;
|
|
70
72
|
};
|
|
71
|
-
export declare const
|
|
73
|
+
export declare const soonServiceSymbol: unique symbol;
|
|
72
74
|
/**
|
|
73
75
|
* 定义服务,使用时会以单例形式被调用
|
|
74
76
|
*/
|
|
@@ -80,7 +82,7 @@ export declare function defineService<T>(args: {
|
|
|
80
82
|
/** 是否在 client 中启用,默认为 false */
|
|
81
83
|
enableClient?: boolean;
|
|
82
84
|
/** 服务函数 */
|
|
83
|
-
service: (app:
|
|
85
|
+
service: (app: SoonApp) => T | Promise<T>;
|
|
84
86
|
}): () => Promise<T>;
|
|
85
87
|
/**
|
|
86
88
|
* 定义中间件
|
|
@@ -91,9 +93,9 @@ export declare function defineMiddleware<T extends Middleware>(middlewareFn: T):
|
|
|
91
93
|
*/
|
|
92
94
|
export declare function defineConfig<T>(configFn: () => T | Promise<T>): () => T | Promise<T>;
|
|
93
95
|
/**
|
|
94
|
-
* 创建
|
|
96
|
+
* 创建 SoonApp 实例,只允许存在一个
|
|
95
97
|
*/
|
|
96
|
-
export declare function
|
|
98
|
+
export declare function createSoonApp(options?: SoonAppOptions): Promise<SoonApp>;
|
|
97
99
|
/**
|
|
98
100
|
* 错误
|
|
99
101
|
*/
|
|
@@ -132,4 +134,4 @@ export { Observable };
|
|
|
132
134
|
/**
|
|
133
135
|
* Vite Plugin
|
|
134
136
|
*/
|
|
135
|
-
export {
|
|
137
|
+
export { vitePluginSoonServer, vitePluginSoonClient };
|