soonjs 0.0.5 → 0.0.7

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 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, PazuAppOptions, PazuFetchOptions, Response, APIOptions } from './types';
5
- import { vitePluginPazuServer } from './vite-plugin-pazu-server';
6
- import { vitePluginPazuClient } from './vite-plugin-pazu-client';
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 { Context, PazuFetchOptions };
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 PazuApp {
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?: PazuAppOptions, callback?: (error: any, app: PazuApp) => void);
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, pazuFetchOptions?: PazuFetchOptions): Promise<Response<any>>;
35
- fetch(url: string, body?: any, pazuFetchOptions?: PazuFetchOptions): Promise<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 pazuApiSymbol: unique symbol;
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" | "connect" | "options" | "trace" | "patch" | "all";
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 pazuServiceSymbol: unique symbol;
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: PazuApp) => T | Promise<T>;
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
- * 创建 PazuApp 实例,只允许存在一个
96
+ * 创建 SoonApp 实例,只允许存在一个
95
97
  */
96
- export declare function createPazuApp(options?: PazuAppOptions): Promise<PazuApp>;
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 { vitePluginPazuServer, vitePluginPazuClient };
137
+ export { vitePluginSoonServer, vitePluginSoonClient };