xpe 0.0.0-alpha.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.
Files changed (150) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +71 -0
  3. package/framework/es/core/Application.d.ts +126 -0
  4. package/framework/es/core/Command/Command.d.ts +7 -0
  5. package/framework/es/core/Container/Container.d.ts +80 -0
  6. package/framework/es/core/Contracts/AxiosAdapter.d.ts +12 -0
  7. package/framework/es/core/Helper/Helper.d.ts +43 -0
  8. package/framework/es/core/Helper/Storage/WebStorage.d.ts +71 -0
  9. package/framework/es/core/Libs/Exception.d.ts +24 -0
  10. package/framework/es/core/Libs/Lib.d.ts +72 -0
  11. package/framework/es/core/Provider/CommandProvider.d.ts +4 -0
  12. package/framework/es/core/Provider/HelperProvider.d.ts +4 -0
  13. package/framework/es/core/Provider/HttpProvider.d.ts +13 -0
  14. package/framework/es/core/Provider/ServiceProvider.d.ts +15 -0
  15. package/framework/es/core/Service/HttpService.d.ts +133 -0
  16. package/framework/es/core/Service/Service.d.ts +6 -0
  17. package/framework/es/core/Spanner/RESTful.d.ts +30 -0
  18. package/framework/es/core/Transformer/Transformer.d.ts +46 -0
  19. package/framework/es/core/Type/adapters.d.ts +25 -0
  20. package/framework/es/core/Type/types.d.ts +161 -0
  21. package/framework/es/core/TypeFunc/index.d.ts +6 -0
  22. package/framework/es/core/Wrenches/EventBus.d.ts +56 -0
  23. package/framework/es/core/Wrenches/is.d.ts +19 -0
  24. package/framework/es/ege.js +4 -0
  25. package/framework/es/ege.js.map +1 -0
  26. package/framework/es/index.d.ts +13 -0
  27. package/framework/es/pdd.js +4 -0
  28. package/framework/es/pdd.js.map +1 -0
  29. package/framework/es/src/core/Application.d.ts +127 -0
  30. package/framework/es/src/core/Application.d.ts.map +1 -0
  31. package/framework/es/src/core/Command/Command.d.ts +8 -0
  32. package/framework/es/src/core/Command/Command.d.ts.map +1 -0
  33. package/framework/es/src/core/Container/Container.d.ts +81 -0
  34. package/framework/es/src/core/Container/Container.d.ts.map +1 -0
  35. package/framework/es/src/core/Contracts/AxiosAdapter.d.ts +13 -0
  36. package/framework/es/src/core/Contracts/AxiosAdapter.d.ts.map +1 -0
  37. package/framework/es/src/core/Helper/Helper.d.ts +45 -0
  38. package/framework/es/src/core/Helper/Helper.d.ts.map +1 -0
  39. package/framework/es/src/core/Helper/Storage/WebStorage.d.ts +72 -0
  40. package/framework/es/src/core/Helper/Storage/WebStorage.d.ts.map +1 -0
  41. package/framework/es/src/core/Libs/Exception.d.ts +25 -0
  42. package/framework/es/src/core/Libs/Exception.d.ts.map +1 -0
  43. package/framework/es/src/core/Libs/Lib.d.ts +73 -0
  44. package/framework/es/src/core/Libs/Lib.d.ts.map +1 -0
  45. package/framework/es/src/core/Provider/CommandProvider.d.ts +5 -0
  46. package/framework/es/src/core/Provider/CommandProvider.d.ts.map +1 -0
  47. package/framework/es/src/core/Provider/HelperProvider.d.ts +5 -0
  48. package/framework/es/src/core/Provider/HelperProvider.d.ts.map +1 -0
  49. package/framework/es/src/core/Provider/HttpProvider.d.ts +14 -0
  50. package/framework/es/src/core/Provider/HttpProvider.d.ts.map +1 -0
  51. package/framework/es/src/core/Provider/ServiceProvider.d.ts +16 -0
  52. package/framework/es/src/core/Provider/ServiceProvider.d.ts.map +1 -0
  53. package/framework/es/src/core/Service/HttpService.d.ts +128 -0
  54. package/framework/es/src/core/Service/HttpService.d.ts.map +1 -0
  55. package/framework/es/src/core/Service/Service.d.ts +7 -0
  56. package/framework/es/src/core/Service/Service.d.ts.map +1 -0
  57. package/framework/es/src/core/Spanner/RESTful.d.ts +32 -0
  58. package/framework/es/src/core/Spanner/RESTful.d.ts.map +1 -0
  59. package/framework/es/src/core/Transformer/Transformer.d.ts +47 -0
  60. package/framework/es/src/core/Transformer/Transformer.d.ts.map +1 -0
  61. package/framework/es/src/core/Type/adapters.d.ts +26 -0
  62. package/framework/es/src/core/Type/adapters.d.ts.map +1 -0
  63. package/framework/es/src/core/Type/types.d.ts +186 -0
  64. package/framework/es/src/core/Type/types.d.ts.map +1 -0
  65. package/framework/es/src/core/TypeFunc/index.d.ts +8 -0
  66. package/framework/es/src/core/TypeFunc/index.d.ts.map +1 -0
  67. package/framework/es/src/core/Wrenches/EventBus.d.ts +57 -0
  68. package/framework/es/src/core/Wrenches/EventBus.d.ts.map +1 -0
  69. package/framework/es/src/core/Wrenches/is.d.ts +20 -0
  70. package/framework/es/src/core/Wrenches/is.d.ts.map +1 -0
  71. package/framework/es/src/index.d.ts +14 -0
  72. package/framework/es/src/index.d.ts.map +1 -0
  73. package/framework/es/src/utils.d.ts +17 -0
  74. package/framework/es/src/utils.d.ts.map +1 -0
  75. package/framework/es/utils.d.ts +16 -0
  76. package/framework/umd/core/Application.d.ts +126 -0
  77. package/framework/umd/core/Command/Command.d.ts +7 -0
  78. package/framework/umd/core/Container/Container.d.ts +80 -0
  79. package/framework/umd/core/Contracts/AxiosAdapter.d.ts +12 -0
  80. package/framework/umd/core/Helper/Helper.d.ts +43 -0
  81. package/framework/umd/core/Helper/Storage/WebStorage.d.ts +71 -0
  82. package/framework/umd/core/Libs/Exception.d.ts +24 -0
  83. package/framework/umd/core/Libs/Lib.d.ts +72 -0
  84. package/framework/umd/core/Provider/CommandProvider.d.ts +4 -0
  85. package/framework/umd/core/Provider/HelperProvider.d.ts +4 -0
  86. package/framework/umd/core/Provider/HttpProvider.d.ts +13 -0
  87. package/framework/umd/core/Provider/ServiceProvider.d.ts +15 -0
  88. package/framework/umd/core/Service/HttpService.d.ts +133 -0
  89. package/framework/umd/core/Service/Service.d.ts +6 -0
  90. package/framework/umd/core/Spanner/RESTful.d.ts +30 -0
  91. package/framework/umd/core/Transformer/Transformer.d.ts +46 -0
  92. package/framework/umd/core/Type/adapters.d.ts +25 -0
  93. package/framework/umd/core/Type/types.d.ts +161 -0
  94. package/framework/umd/core/TypeFunc/index.d.ts +6 -0
  95. package/framework/umd/core/Wrenches/EventBus.d.ts +56 -0
  96. package/framework/umd/core/Wrenches/is.d.ts +19 -0
  97. package/framework/umd/ege.js +4 -0
  98. package/framework/umd/ege.js.map +1 -0
  99. package/framework/umd/index.d.ts +13 -0
  100. package/framework/umd/pdd.js +4 -0
  101. package/framework/umd/pdd.js.map +1 -0
  102. package/framework/umd/src/core/Application.d.ts +127 -0
  103. package/framework/umd/src/core/Application.d.ts.map +1 -0
  104. package/framework/umd/src/core/Command/Command.d.ts +8 -0
  105. package/framework/umd/src/core/Command/Command.d.ts.map +1 -0
  106. package/framework/umd/src/core/Container/Container.d.ts +81 -0
  107. package/framework/umd/src/core/Container/Container.d.ts.map +1 -0
  108. package/framework/umd/src/core/Contracts/AxiosAdapter.d.ts +13 -0
  109. package/framework/umd/src/core/Contracts/AxiosAdapter.d.ts.map +1 -0
  110. package/framework/umd/src/core/Helper/Helper.d.ts +45 -0
  111. package/framework/umd/src/core/Helper/Helper.d.ts.map +1 -0
  112. package/framework/umd/src/core/Helper/Storage/WebStorage.d.ts +72 -0
  113. package/framework/umd/src/core/Helper/Storage/WebStorage.d.ts.map +1 -0
  114. package/framework/umd/src/core/Libs/Exception.d.ts +25 -0
  115. package/framework/umd/src/core/Libs/Exception.d.ts.map +1 -0
  116. package/framework/umd/src/core/Libs/Lib.d.ts +73 -0
  117. package/framework/umd/src/core/Libs/Lib.d.ts.map +1 -0
  118. package/framework/umd/src/core/Provider/CommandProvider.d.ts +5 -0
  119. package/framework/umd/src/core/Provider/CommandProvider.d.ts.map +1 -0
  120. package/framework/umd/src/core/Provider/HelperProvider.d.ts +5 -0
  121. package/framework/umd/src/core/Provider/HelperProvider.d.ts.map +1 -0
  122. package/framework/umd/src/core/Provider/HttpProvider.d.ts +14 -0
  123. package/framework/umd/src/core/Provider/HttpProvider.d.ts.map +1 -0
  124. package/framework/umd/src/core/Provider/ServiceProvider.d.ts +16 -0
  125. package/framework/umd/src/core/Provider/ServiceProvider.d.ts.map +1 -0
  126. package/framework/umd/src/core/Service/HttpService.d.ts +128 -0
  127. package/framework/umd/src/core/Service/HttpService.d.ts.map +1 -0
  128. package/framework/umd/src/core/Service/Service.d.ts +7 -0
  129. package/framework/umd/src/core/Service/Service.d.ts.map +1 -0
  130. package/framework/umd/src/core/Spanner/RESTful.d.ts +32 -0
  131. package/framework/umd/src/core/Spanner/RESTful.d.ts.map +1 -0
  132. package/framework/umd/src/core/Transformer/Transformer.d.ts +47 -0
  133. package/framework/umd/src/core/Transformer/Transformer.d.ts.map +1 -0
  134. package/framework/umd/src/core/Type/adapters.d.ts +26 -0
  135. package/framework/umd/src/core/Type/adapters.d.ts.map +1 -0
  136. package/framework/umd/src/core/Type/types.d.ts +186 -0
  137. package/framework/umd/src/core/Type/types.d.ts.map +1 -0
  138. package/framework/umd/src/core/TypeFunc/index.d.ts +8 -0
  139. package/framework/umd/src/core/TypeFunc/index.d.ts.map +1 -0
  140. package/framework/umd/src/core/Wrenches/EventBus.d.ts +57 -0
  141. package/framework/umd/src/core/Wrenches/EventBus.d.ts.map +1 -0
  142. package/framework/umd/src/core/Wrenches/is.d.ts +20 -0
  143. package/framework/umd/src/core/Wrenches/is.d.ts.map +1 -0
  144. package/framework/umd/src/index.d.ts +14 -0
  145. package/framework/umd/src/index.d.ts.map +1 -0
  146. package/framework/umd/src/utils.d.ts +17 -0
  147. package/framework/umd/src/utils.d.ts.map +1 -0
  148. package/framework/umd/utils.d.ts +16 -0
  149. package/index.d.ts +724 -0
  150. package/package.json +57 -0
package/index.d.ts ADDED
@@ -0,0 +1,724 @@
1
+ declare type UtilityFunction<T = any, K = any> = (...args: T[]) => K | typeof Function;
2
+ declare type UtilityObject = Record<any, any>;
3
+ interface UtilityClass {
4
+ new <T>(...items: T[]): T[];
5
+ }
6
+ interface ClassConstructor {
7
+ new <T>(...items: T[]): T[];
8
+ }
9
+
10
+ declare abstract class ServiceProvider {
11
+ protected app: IApplication;
12
+ /**
13
+ * constructor
14
+ * @param app Application instance
15
+ *
16
+ */
17
+ constructor(app: IApplicationInstance);
18
+ /**
19
+ * register
20
+ * 注册 provider
21
+ */
22
+ register(): void;
23
+ }
24
+
25
+ /**
26
+ * Interface Container
27
+ * @description 容器接口
28
+ */
29
+ interface IContainer {
30
+ /**
31
+ * bind 绑定实体
32
+ * @param {String|Array} abstract
33
+ * @param {*} concrete
34
+ */
35
+ bind(abstract: string | string[], concrete: any): void;
36
+ /**
37
+ * make 创建类的实例/获取对象 create instance/object
38
+ * @param abstract
39
+ * @param params
40
+ * @param shared
41
+ */
42
+ make(abstract: string, params?: object | [], shared?: boolean): any;
43
+ /**
44
+ * has as existence
45
+ * 是否存在标识 existence 的别名
46
+ * @param {String} name
47
+ */
48
+ has(name: string): boolean;
49
+ /**
50
+ * existence 存在标识
51
+ * @param {String} name
52
+ */
53
+ existence(name: string): boolean;
54
+ /**
55
+ * getAlias 获取别名
56
+ * @param abstract
57
+ */
58
+ getAlias(abstract: string): string;
59
+ /**
60
+ * get 获取实例
61
+ * @param abstract
62
+ */
63
+ get(abstract: string): any;
64
+ /**
65
+ * singleton 单例
66
+ * @param abstract
67
+ * @param concrete
68
+ */
69
+ singleton(abstract: string, concrete: any): void;
70
+ }
71
+ /**
72
+ * Interface Application
73
+ * @description 应用接口
74
+ */
75
+ interface IApplication extends IContainer {
76
+ /**
77
+ * getterProviders Providers 获取器
78
+ */
79
+ getterProviders(): any[];
80
+ /**
81
+ * setterProviders Providers
82
+ * 设置器
83
+ * @param providers
84
+ */
85
+ setterProviders<T>(providers: T[]): void;
86
+ /**
87
+ * static getAdapter
88
+ * 适配器 获取器
89
+ * @param adapter
90
+ */
91
+ getterAdapter(adapter: UtilityClass): any;
92
+ /**
93
+ * setAdapter
94
+ * 新增
95
+ * @param adapter
96
+ * @param instance
97
+ * @protected
98
+ */
99
+ setterAdapter(adapter: UtilityClass, instance: UtilityObject): void;
100
+ }
101
+ declare type IApplicationInstance = IApplication;
102
+ declare type RequestMethod = 'post' | 'get' | 'put' | 'delete' | 'POST' | 'GET' | 'PUT' | 'DELETE';
103
+ declare type TContentType = 'REQUEST_PAYLOAD' | 'FORM_DATA';
104
+ declare type TCarryData = 'REQUEST_HEADERS' | 'REQUEST_DATA';
105
+ declare type TApiRoute = [
106
+ string,
107
+ (RequestMethod | [RequestMethod, TContentType])?,
108
+ (true | false)?,
109
+ (true | false | undefined)?
110
+ ];
111
+ interface HttpApis {
112
+ [api: string]: TApiRoute;
113
+ }
114
+ declare type IHttpSendConfig = {
115
+ host?: string;
116
+ headers?: Record<string, any>;
117
+ mode?: TContentType;
118
+ responseData?: boolean;
119
+ };
120
+ declare type TResponseDataReturn = {
121
+ statusCode: number;
122
+ msg: string;
123
+ data: any;
124
+ timestamp: number;
125
+ };
126
+ interface IResponseReturn extends Response {
127
+ data: TResponseDataReturn;
128
+ }
129
+ declare type TApiRoute1 = {
130
+ bb: boolean;
131
+ cc: number;
132
+ };
133
+ interface IHelper {
134
+ env(): Record<any, any>;
135
+ storage(name: string): Record<any, any>;
136
+ storage(name: string, payload?: any): void;
137
+ cookies(name: string): Record<any, any>;
138
+ cookies(name: string, payload?: any): void;
139
+ session(name: string): Record<any, any>;
140
+ session(name: string, payload?: any): void;
141
+ /**
142
+ * 发送一个http请求
143
+ * @param api 接口key
144
+ * @param data 请求数据
145
+ * @param headers 自定义头
146
+ */
147
+ http(api: string | TApiRoute, data?: UtilityObject, headers?: Record<string, string | number>): Promise<TResponseDataReturn>;
148
+ fetch(api: string | TApiRoute, data?: UtilityObject, headers?: Record<string, string | number>): Promise<IResponseReturn>;
149
+ send(api: string | TApiRoute, data?: UtilityObject, handle?: (response: IResponseReturn) => void, config?: IHttpSendConfig, returnResponse?: boolean): Promise<IResponseReturn>;
150
+ }
151
+ /**
152
+ * Adapter Interface
153
+ */
154
+ declare type RequestConfig = {
155
+ method?: RequestMethod;
156
+ url?: string;
157
+ data?: Record<string, any>;
158
+ headers?: HeadersInit | Record<string, string | number>;
159
+ };
160
+ declare type IHttpAdapter<T> = (config: RequestConfig) => Promise<T>;
161
+ declare type IAxiosAdapterHttp<T> = (config: RequestConfig) => Promise<T>;
162
+ /**
163
+ * Service Interface
164
+ */
165
+ interface IHttpService {
166
+ send(apiRoute: string, data: Record<string, any>, config?: IHttpSendConfig, returnResponse?: boolean): Promise<any>;
167
+ http(api: string | TApiRoute, data?: UtilityObject, headers?: Record<string, string | number>): Promise<IResponseReturn>;
168
+ }
169
+ declare type IServiceProvider = typeof ServiceProvider;
170
+ declare type APP_CONFIG = {
171
+ PROVIDERS?: IServiceProvider[];
172
+ APP_TYPE: 'VUE' | 'REACT' | 'UNI_APP' | 'MP_VUE' | 'WX_APP';
173
+ HTTP_CONFIG: HTTP_CONFIG;
174
+ };
175
+ declare type HTTP_CONFIG = {
176
+ HTTP_ADAPTER: any;
177
+ HTTP_LIB: UtilityFunction | UtilityClass;
178
+ HTTP_API: any;
179
+ HTTP_HOST: string;
180
+ IS_RESTFUL: boolean;
181
+ CONTENT_TYPE: TContentType;
182
+ DATA_CARRYING: DATA_CARRYING;
183
+ REQUEST_MIDDLEWARE?: HttpMiddleware<any>;
184
+ RESPONSE_MIDDLEWARE?: HttpMiddleware<any>;
185
+ };
186
+ declare type DATA_CARRYING = {
187
+ REQUEST_DATA?: Record<any, any>;
188
+ REQUEST_HEADERS?: Record<any, any>;
189
+ };
190
+ declare type HttpMiddleware<T> = (context?: any) => void;
191
+ declare type HTTP_SERVICE_CONFIG = Pick<HTTP_CONFIG, 'HTTP_ADAPTER' | 'HTTP_API' | 'HTTP_HOST' | 'IS_RESTFUL' | 'CONTENT_TYPE' | 'DATA_CARRYING' | 'REQUEST_MIDDLEWARE' | 'RESPONSE_MIDDLEWARE'>;
192
+ interface IMiddleware<TContext> {
193
+ handle(context: TContext, next: UtilityFunction): void;
194
+ }
195
+ declare type HttpContext<T> = {
196
+ request: {
197
+ hairstyle: TApiRoute;
198
+ body: Record<string, any>;
199
+ data: Record<string, any>;
200
+ auth: boolean;
201
+ headers: Record<string, string | number>;
202
+ method: RequestMethod;
203
+ api: string;
204
+ url: string;
205
+ };
206
+ response: T;
207
+ };
208
+
209
+ /**
210
+ * Class Container
211
+ * 容器类
212
+ * @author SunnyXu <xy@ztes.com>
213
+ */
214
+ declare class Container implements IContainer {
215
+ protected static instance: unknown;
216
+ protected instances: Map<any, any>;
217
+ protected bindings: Record<string, any>;
218
+ protected aliases: Record<string, any>;
219
+ /**
220
+ * bind 绑定实体
221
+ * @param {String|Array} abstract
222
+ * @param {*} concrete
223
+ */
224
+ bind(abstract: string | string[], concrete: any): void;
225
+ /**
226
+ * make 创建类的实例/获取对象 create instance/object
227
+ * @param abstract
228
+ * @param params
229
+ * @param shared
230
+ */
231
+ make(abstract: string, params?: object | [], shared?: boolean): any;
232
+ /**
233
+ * makeClass 创建类
234
+ * @param name
235
+ * @param executor
236
+ * @param params
237
+ * @param shared
238
+ */
239
+ protected makeClass(name: string, executor: ClassConstructor, params: unknown, shared?: boolean): any;
240
+ /**
241
+ * makeFunc 创建函数
242
+ * @param name
243
+ * @param executor
244
+ * @param params
245
+ * @param shared
246
+ * @protected
247
+ */
248
+ protected makeFunc(name: string, executor: CallableFunction, params: unknown, shared?: boolean): any;
249
+ /**
250
+ * has as existence
251
+ * 是否存在标识 existence 的别名
252
+ * @param {String} name
253
+ */
254
+ has(name: string): boolean;
255
+ /**
256
+ * existence 存在标识
257
+ * @param {String} name
258
+ */
259
+ existence(name: string): boolean;
260
+ /**
261
+ * getAlias 获取别名
262
+ * @param abstract
263
+ */
264
+ getAlias(abstract: string): any;
265
+ /**
266
+ * get 获取实例
267
+ * @param abstract
268
+ */
269
+ get(abstract: string): any;
270
+ /**
271
+ * singleton 单例
272
+ * @param abstract
273
+ * @param concrete
274
+ */
275
+ singleton(abstract: string, concrete: any): void;
276
+ /**
277
+ * getInstance 获取实例
278
+ *
279
+ */
280
+ static getInstance<Instance>(): Container | Instance;
281
+ /**
282
+ * proxyInstance 代理实例
283
+ *
284
+ */
285
+ protected proxyInstance(): this;
286
+ }
287
+
288
+ /**
289
+ * Application 核心应用
290
+ * @extends Container
291
+ * @author SunnyXu <xy@ztes.com>
292
+ */
293
+ declare class Application extends Container {
294
+ private static VERSION;
295
+ private adapters;
296
+ private providers;
297
+ /**
298
+ * lifecycle
299
+ * 生命周期
300
+ * @private
301
+ */
302
+ private static lifecycle;
303
+ /**
304
+ * getterProviders Providers 获取器
305
+ */
306
+ getterProviders(): IServiceProvider[];
307
+ /**
308
+ * getProviders
309
+ * 获取
310
+ * @protected
311
+ */
312
+ private static getProviders;
313
+ /**
314
+ * setterProviders Providers
315
+ * 设置器
316
+ * @param providers
317
+ */
318
+ setterProviders(providers: IServiceProvider[]): void;
319
+ /**
320
+ * setProviders
321
+ * 设置
322
+ * @param providers
323
+ */
324
+ static setProviders(providers: IServiceProvider[]): void;
325
+ /**
326
+ * registerProvider
327
+ * @description 注册服务提供者
328
+ * @param provider
329
+ */
330
+ static registerProvider(provider: any): void;
331
+ /**
332
+ * registerProviders
333
+ * 批量注册
334
+ * @param providers
335
+ */
336
+ static registerProviders(providers: IServiceProvider[]): void;
337
+ /**
338
+ * config
339
+ * 配置
340
+ * @param {Object} config
341
+ * @param {String} name
342
+ */
343
+ static setConfig(name: string, config: UtilityObject): void;
344
+ /**
345
+ * getConfig
346
+ * 获取
347
+ * @param name
348
+ * @param {Object} def 默认值
349
+ */
350
+ static getConfig(name: string, def?: any): UtilityObject;
351
+ /**
352
+ * setAppConfig
353
+ * 设置App配置
354
+ * @param config
355
+ */
356
+ static setAppConfig(config: APP_CONFIG): void;
357
+ /**
358
+ * getAppConfig
359
+ * 获取App配置
360
+ * @param name
361
+ * @description 遵守getAppConfig中参数值和返回值的约定
362
+ */
363
+ static getAppConfig<T extends keyof APP_CONFIG>(name: T): APP_CONFIG[T];
364
+ /**
365
+ * bindAdapter
366
+ * 绑定
367
+ * @param adapter
368
+ * @param payload
369
+ */
370
+ static bindAdapter(adapter: UtilityClass, payload?: UtilityObject): void;
371
+ /**
372
+ * setAdapter
373
+ * 新增
374
+ * @param adapter
375
+ * @param instance
376
+ * @protected
377
+ */
378
+ setterAdapter(adapter: UtilityClass, instance: UtilityObject): void;
379
+ /**
380
+ * static getAdapter
381
+ * 获取适配器
382
+ * @param adapter 必须是个类
383
+ * @return instance
384
+ */
385
+ static getAdapter(adapter: UtilityClass): any;
386
+ /**
387
+ * static getAdapter
388
+ * 适配器 获取器
389
+ * @param adapter
390
+ */
391
+ getterAdapter(adapter: UtilityClass): any;
392
+ /**
393
+ * getService
394
+ * 获取服务实例
395
+ * @param serviceName
396
+ */
397
+ static getService<T>(serviceName: string): T;
398
+ /**
399
+ * Application instance
400
+ * 获取应用实例
401
+ * @description 应该使用Proxy进行拦截,目前先放行
402
+ */
403
+ static getInstance(): InstanceType<typeof Application>;
404
+ /**
405
+ * App run
406
+ * 框架应用运行
407
+ * @param {CallableFunction} callback
408
+ */
409
+ static run(callback?: CallableFunction): void;
410
+ }
411
+
412
+ /**
413
+ * Exception Class
414
+ * 目前原生的错误类型
415
+ * Error [一般错误类型]
416
+ * SyntaxError [语法错误]
417
+ * ReferenceError [不存在的变量]
418
+ * RangeError [超出有效范围]
419
+ * TypeError [非预期类型]
420
+ * URIError [URI参数错误]
421
+ * EvalError [eval函数没有正确执行]
422
+ * Example: throw new Exception() catch(error) error.name,error.message,error.code,error.stack
423
+ */
424
+ declare class Exception extends Error {
425
+ name: string;
426
+ message: string;
427
+ code: number;
428
+ /**
429
+ *
430
+ * @param {String} name 错误名称
431
+ * @param {String} message 错误提示
432
+ * @param {Number} code 错误码
433
+ */
434
+ constructor(name: string, message: string, code?: number);
435
+ }
436
+
437
+ declare abstract class Command {
438
+ protected payload: any[];
439
+ protected $helper: IHelper;
440
+ protected constructor(...payload: any[]);
441
+ abstract handle(...args: any[]): any | Promise<any> | void;
442
+ }
443
+
444
+ declare type Callback = (item: Record<any, any>, index?: number) => Record<any, any>;
445
+ /**
446
+ * Class Transformer 转换器
447
+ * NewTransformer extends Transformer -> constructor(){super(data,payload)}
448
+ */
449
+ declare class Transformer {
450
+ private readonly data;
451
+ private payload;
452
+ /**
453
+ * Method constructor
454
+ * @param {*} data 需处理的数据
455
+ * @param {*} payload 携带的载荷
456
+ * @returns
457
+ */
458
+ constructor(data: any, payload?: unknown);
459
+ /**
460
+ * Method transform
461
+ * 转换方法
462
+ * @param {Object|String|Number} data
463
+ * @param tData
464
+ * @returns
465
+ */
466
+ transform(data: any, tData?: any): any;
467
+ /**
468
+ * Method create
469
+ * 创建新数据
470
+ * @return {Array/Object|String|Number|*}
471
+ */
472
+ create(callback?: Callback): any;
473
+ /**
474
+ * 格式化数字
475
+ * @param {String|Number} number 待处理数字
476
+ * @param {Number} places 小数点位数 -1为原样保留
477
+ * @param {String} thousand 千位字符串 默认为空
478
+ * @param {String} decimal 小数点替换字符 默认为.
479
+ * @return {String|Number}
480
+ */
481
+ formatNumber(number: string | number, places?: number | string, thousand?: string, decimal?: string): string;
482
+ /**
483
+ * formatDate 日期格式化
484
+ * @param {string|number} timestamp
485
+ * @returns
486
+ */
487
+ formatDate(timestamp?: number | string | unknown): Record<string, number | string>;
488
+ }
489
+
490
+ declare type variableType = "string" | "number" | "object" | "undefined" | "function" | "boolean" | "bigInt" | "symbol";
491
+ declare type TrimType = "R" | "L" | "";
492
+ /**
493
+ * Class Lib
494
+ * 基础函数库,Lodash、Underscore... So big
495
+ */
496
+ declare class Lib {
497
+ /**
498
+ * typeOf 判断变量类型
499
+ * @param value
500
+ * @param type
501
+ */
502
+ static typeOf<T>(value: unknown, type: variableType): value is T;
503
+ /**
504
+ * getTag 判断变量类型
505
+ * @param value
506
+ */
507
+ static getTag(value: unknown): string;
508
+ /**
509
+ * isFunction 是否函数
510
+ * @param {Function} value
511
+ * @return {Boolean}
512
+ */
513
+ static isFunction(value: unknown): value is typeof Function;
514
+ /**
515
+ * isString 是否字符串
516
+ * @param {String} value
517
+ * @return {Boolean}
518
+ */
519
+ static isString(value: unknown): value is string;
520
+ /**
521
+ * isNumber 是否数字
522
+ * @param value
523
+ * @return {Boolean}
524
+ */
525
+ static isNumber(value: unknown): value is number;
526
+ /**
527
+ * isObject 是否对象
528
+ * @param {Object} value
529
+ */
530
+ static isObject(value: unknown): value is Record<any, any>;
531
+ /**
532
+ * isObject 是否Undefined
533
+ * @param {*} value
534
+ * @return boolean
535
+ */
536
+ static isUndefined(value: unknown): boolean;
537
+ /**
538
+ * isNull 是否Null
539
+ * @param value
540
+ */
541
+ static isNull(value: unknown): boolean;
542
+ /**
543
+ * isEmpty 是否空
544
+ * 目前只对 null undefined '' {} [] 做处理
545
+ * @param value
546
+ */
547
+ static isEmpty(value: unknown): boolean;
548
+ /**
549
+ * isClass 是否类
550
+ * @param value
551
+ */
552
+ static isClass(value: unknown): boolean;
553
+ /**
554
+ * 字符串去除首尾字符
555
+ * @param str 字符串
556
+ * @param char 字符
557
+ * @param type 类型
558
+ */
559
+ static strTrim(str: string, char: string, type?: TrimType): string;
560
+ }
561
+
562
+ declare abstract class HttpAdapterInterface<T> {
563
+ protected http: IHttpAdapter<T>;
564
+ protected method: RequestMethod;
565
+ protected url: string;
566
+ protected data: {};
567
+ protected headers: {};
568
+ /**
569
+ * Method constructor 注入Axios
570
+ * @param {*} $function
571
+ * @returns
572
+ */
573
+ protected constructor($function: IHttpAdapter<T>);
574
+ /**
575
+ * Method setConfig
576
+ * 设置配置信息
577
+ * @param {method,url,data,headers} param
578
+ */
579
+ setConfig({ method, url, data, headers }: RequestConfig): void;
580
+ /**
581
+ * Method request
582
+ * @returns Promise
583
+ */
584
+ request(): Promise<unknown>;
585
+ }
586
+
587
+ /**
588
+ * Class AxiosAdapter
589
+ * @description axios适配器,适配器主要完成
590
+ */
591
+ declare class AxiosAdapter extends HttpAdapterInterface<{}> {
592
+ /**
593
+ * Method request
594
+ * @returns Promise
595
+ */
596
+ request(): Promise<unknown>;
597
+ }
598
+
599
+ declare class EventBus {
600
+ _events: Map<any, any>;
601
+ static _instance: InstanceType<typeof EventBus>;
602
+ /**
603
+ * 获取EventBus实例
604
+ * @return {EventBus}
605
+ */
606
+ static getInstance(): EventBus;
607
+ /**
608
+ * EventBus.getEvents
609
+ * @return {Map<any, any>}
610
+ */
611
+ static getEvents(): Map<any, any>;
612
+ static getEventsSize(): number;
613
+ static getEvent(name: string): any;
614
+ static hasEvent(name: string): boolean;
615
+ static deleteEvent(name: string): boolean;
616
+ /**
617
+ * Method EventBus.setEvent
618
+ * @param name
619
+ * @param callback
620
+ * @return {Map<any, any>}
621
+ */
622
+ static setEvent(name: string, callback: CallableFunction): Map<any, any>;
623
+ /**
624
+ * Method EventBus.on as EventBus.setEvent
625
+ * 绑定事件
626
+ * @param name
627
+ * @param callback
628
+ * @return {Map<*, *>}
629
+ */
630
+ static on(name: string, callback: CallableFunction): Map<any, any>;
631
+ /**
632
+ * Method EventBus.emit
633
+ * 执行事件
634
+ * @param name
635
+ * @param payload
636
+ * @return {*}
637
+ */
638
+ static emit(name: string, ...payload: any[]): any;
639
+ /**
640
+ * Method EventBus.once
641
+ * 执行事件并关闭事件
642
+ * @param name
643
+ * @param payload
644
+ */
645
+ static once(name: string, ...payload: any[]): void;
646
+ /**
647
+ * EventBus.off
648
+ * 关闭事件
649
+ * @param name
650
+ * @return {boolean}
651
+ */
652
+ static off(name: string): boolean;
653
+ }
654
+
655
+ declare function isArray(obj: any): obj is any[];
656
+ declare function isNull(obj: any): obj is null;
657
+ declare function isBoolean(obj: unknown): obj is boolean;
658
+ declare function isObject(obj: any): obj is Record<string, unknown>;
659
+ declare const isPromise: <T>(obj: unknown) => obj is Promise<T>;
660
+ declare function isString(obj: any): obj is string;
661
+ declare function isNumber(obj: any): obj is number;
662
+ declare function isRegExp(obj: any): boolean;
663
+ declare function isDate(obj: any): boolean;
664
+ declare function isColor(color: any): boolean;
665
+ declare function isUndefined(obj: any): obj is undefined;
666
+ declare function isFunction(obj: any): obj is (...args: any[]) => any;
667
+ declare function isClass(value: unknown): boolean;
668
+ declare function isEmptyObject(obj: any): boolean;
669
+ declare function isEmpty(obj: any): boolean;
670
+ declare function isExist(obj: any): boolean;
671
+ declare function isWindow(el: any): el is Window;
672
+ declare function isPhone(obj: any): boolean;
673
+ declare function isEmail(obj: any): boolean;
674
+
675
+ declare const is_isArray: typeof isArray;
676
+ declare const is_isNull: typeof isNull;
677
+ declare const is_isBoolean: typeof isBoolean;
678
+ declare const is_isObject: typeof isObject;
679
+ declare const is_isPromise: typeof isPromise;
680
+ declare const is_isString: typeof isString;
681
+ declare const is_isNumber: typeof isNumber;
682
+ declare const is_isRegExp: typeof isRegExp;
683
+ declare const is_isDate: typeof isDate;
684
+ declare const is_isColor: typeof isColor;
685
+ declare const is_isUndefined: typeof isUndefined;
686
+ declare const is_isFunction: typeof isFunction;
687
+ declare const is_isClass: typeof isClass;
688
+ declare const is_isEmptyObject: typeof isEmptyObject;
689
+ declare const is_isEmpty: typeof isEmpty;
690
+ declare const is_isExist: typeof isExist;
691
+ declare const is_isWindow: typeof isWindow;
692
+ declare const is_isPhone: typeof isPhone;
693
+ declare const is_isEmail: typeof isEmail;
694
+ declare namespace is {
695
+ export {
696
+ is_isArray as isArray,
697
+ is_isNull as isNull,
698
+ is_isBoolean as isBoolean,
699
+ is_isObject as isObject,
700
+ is_isPromise as isPromise,
701
+ is_isString as isString,
702
+ is_isNumber as isNumber,
703
+ is_isRegExp as isRegExp,
704
+ is_isDate as isDate,
705
+ is_isColor as isColor,
706
+ is_isUndefined as isUndefined,
707
+ is_isFunction as isFunction,
708
+ is_isClass as isClass,
709
+ is_isEmptyObject as isEmptyObject,
710
+ is_isEmpty as isEmpty,
711
+ is_isExist as isExist,
712
+ is_isWindow as isWindow,
713
+ is_isPhone as isPhone,
714
+ is_isEmail as isEmail,
715
+ };
716
+ }
717
+
718
+ declare function defineAppConfig(config: APP_CONFIG): APP_CONFIG;
719
+ declare function defineAppHttpConfig<T>(config: HTTP_CONFIG | T): HTTP_CONFIG | T;
720
+ declare function defineHttpConfig<T>(config: HTTP_CONFIG | T): HTTP_CONFIG | T;
721
+ declare function defineHttpApis(apis: HttpApis): HttpApis;
722
+ declare function defineHttpRequestConfig(apis: HttpApis): HttpApis;
723
+
724
+ export { APP_CONFIG, AxiosAdapter, Command, Container, DATA_CARRYING, EventBus, Exception, HTTP_CONFIG, HTTP_SERVICE_CONFIG, HttpApis, HttpContext, HttpMiddleware, IApplication, IApplicationInstance, IAxiosAdapterHttp, IContainer, IHelper, IHttpAdapter, IHttpSendConfig, IHttpService, IMiddleware, IResponseReturn, IServiceProvider, is as Is, Lib, RequestConfig, RequestMethod, ServiceProvider, TApiRoute, TApiRoute1, TCarryData, TContentType, TResponseDataReturn, Transformer, Application as default, defineAppConfig, defineAppHttpConfig, defineHttpApis, defineHttpConfig, defineHttpRequestConfig };