@hz-9/a5-core 0.2.0-alpha.50 → 0.2.0-alpha.52
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/package.json +1 -1
- package/dist/all.d.ts +0 -871
package/package.json
CHANGED
package/dist/all.d.ts
DELETED
|
@@ -1,871 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
|
|
3
|
-
import { FastifyReply as FastifyReply_2 } from 'fastify';
|
|
4
|
-
import { FastifyRequest as FastifyRequest_2 } from 'fastify';
|
|
5
|
-
import { IncomingHttpHeaders } from 'node:http';
|
|
6
|
-
import { Logger } from '@nestjs/common';
|
|
7
|
-
import { LoggerService } from '@nestjs/common/services/logger.service';
|
|
8
|
-
import { LoggerService as LoggerService_2 } from '@nestjs/common';
|
|
9
|
-
import { LogLevel } from '@nestjs/common/services/logger.service';
|
|
10
|
-
import { NestFactoryStatic } from '@nestjs/core/nest-factory';
|
|
11
|
-
import { NestFastifyApplication } from '@nestjs/platform-fastify';
|
|
12
|
-
import { NestMiddleware } from '@nestjs/common';
|
|
13
|
-
import { V4Options } from 'uuid';
|
|
14
|
-
import { V7Options } from 'uuid';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @public
|
|
18
|
-
*
|
|
19
|
-
* `A5App.prototype.listen` 参数默认值。
|
|
20
|
-
*
|
|
21
|
-
*/
|
|
22
|
-
export declare const A5_APP_LISTEN_OPTIONS_DEFAULT: {
|
|
23
|
-
/**
|
|
24
|
-
* 是否自动退出。
|
|
25
|
-
*/
|
|
26
|
-
readonly AUTO_EXIT: true;
|
|
27
|
-
/**
|
|
28
|
-
* 重试间隔。
|
|
29
|
-
*/
|
|
30
|
-
readonly TRY_INTERVAL: 300;
|
|
31
|
-
/**
|
|
32
|
-
* 最大重试次数。
|
|
33
|
-
*/
|
|
34
|
-
readonly TRY_TIMES: 20;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* @public
|
|
39
|
-
*
|
|
40
|
-
* 默认监听端口。
|
|
41
|
-
*/
|
|
42
|
-
export declare const A5_APP_LISTEN_PORT_DEFAULT: 16100;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* @public
|
|
46
|
-
*
|
|
47
|
-
* A5App Constructor Options
|
|
48
|
-
*
|
|
49
|
-
*/
|
|
50
|
-
export declare interface A5AppConstructorOptions {
|
|
51
|
-
/**
|
|
52
|
-
* Logger 对象。
|
|
53
|
-
*
|
|
54
|
-
* 显性设置 Logger 对象。默认情况下,将会加载 A5LoggerModule 的 Logger 实例。
|
|
55
|
-
*
|
|
56
|
-
* 如果加载失败,将会使用 A5ConsoleLogger 的实例。
|
|
57
|
-
*
|
|
58
|
-
*/
|
|
59
|
-
readonly logger?: LoggerService_2;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* @public
|
|
64
|
-
*
|
|
65
|
-
* `A5` for `NestApplication`。服务应用类。
|
|
66
|
-
*
|
|
67
|
-
*/
|
|
68
|
-
export declare class A5Application {
|
|
69
|
-
protected readonly initTime: Date;
|
|
70
|
-
protected readonly logger: Logger;
|
|
71
|
-
/**
|
|
72
|
-
* setExtraUrl 及 getUrls 函数用于保存数据的数组
|
|
73
|
-
*/
|
|
74
|
-
protected readonly extraUrls: string[];
|
|
75
|
-
/**
|
|
76
|
-
*
|
|
77
|
-
* 由 [nanoid](https://github.com/ai/nanoid) 生成的实例 ID。21 位长的字符串。
|
|
78
|
-
*
|
|
79
|
-
*/
|
|
80
|
-
readonly instanceId: string;
|
|
81
|
-
readonly nestApp: NestFastifyApplication;
|
|
82
|
-
readonly options: A5AppOptions;
|
|
83
|
-
constructor(nestApp: NestFastifyApplication, options?: A5AppConstructorOptions);
|
|
84
|
-
init(): Promise<void>;
|
|
85
|
-
/**
|
|
86
|
-
*
|
|
87
|
-
* @public
|
|
88
|
-
*
|
|
89
|
-
* `A5` 应用,对网络进行监听。
|
|
90
|
-
*
|
|
91
|
-
* `A5` 增加了对端口获取失败的多次尝试。
|
|
92
|
-
*
|
|
93
|
-
* 如果想关闭自动重试,请传入 `listen({ tryTimes: 0 })`
|
|
94
|
-
*
|
|
95
|
-
* TODO 未考虑采用哪种方案,进行多次尝试。
|
|
96
|
-
*
|
|
97
|
-
*/
|
|
98
|
-
listen(options?: A5AppListenOptions): Promise<void>;
|
|
99
|
-
listen(port: number | string, options?: A5AppListenOptions): Promise<void>;
|
|
100
|
-
/**
|
|
101
|
-
*
|
|
102
|
-
* @public
|
|
103
|
-
*
|
|
104
|
-
* 添加额外的 urls, 便于 printAddress 进行输出
|
|
105
|
-
*
|
|
106
|
-
*/
|
|
107
|
-
setExtraUrl(urlOrUrls: string | string[]): Promise<void>;
|
|
108
|
-
/**
|
|
109
|
-
*
|
|
110
|
-
* @public
|
|
111
|
-
*
|
|
112
|
-
* 输出可以访问当前服务的地址。
|
|
113
|
-
*
|
|
114
|
-
* TODO 需要精准判断 IPv4 和 IPv6 等各项情况。
|
|
115
|
-
*
|
|
116
|
-
*/
|
|
117
|
-
getUrls(): Promise<string[]>;
|
|
118
|
-
/**
|
|
119
|
-
*
|
|
120
|
-
* @public
|
|
121
|
-
*
|
|
122
|
-
* 在正常获取 IP 与端口后,可通过此函数输出日志信息。
|
|
123
|
-
*
|
|
124
|
-
*/
|
|
125
|
-
printAddress(): Promise<void>;
|
|
126
|
-
/**
|
|
127
|
-
*
|
|
128
|
-
* @public
|
|
129
|
-
*
|
|
130
|
-
* 关闭应用。
|
|
131
|
-
* 是 `NestApplication.prototype.close()` 的语法糖。
|
|
132
|
-
*
|
|
133
|
-
*/
|
|
134
|
-
close(): Promise<void>;
|
|
135
|
-
/**
|
|
136
|
-
*
|
|
137
|
-
* @public
|
|
138
|
-
*
|
|
139
|
-
* 应用是否处于关闭状态
|
|
140
|
-
*
|
|
141
|
-
*/
|
|
142
|
-
isClose(): boolean;
|
|
143
|
-
/**
|
|
144
|
-
* @internal
|
|
145
|
-
*
|
|
146
|
-
* 将会优先尝试 A5 内部的日志模块。如果没有的话,才会使用 A5ConsoleLogger
|
|
147
|
-
*
|
|
148
|
-
*/
|
|
149
|
-
private _getA5LoggerService;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
*
|
|
154
|
-
* @public
|
|
155
|
-
*
|
|
156
|
-
* `A5App.prototype.listen` 参数
|
|
157
|
-
*
|
|
158
|
-
*/
|
|
159
|
-
export declare interface A5AppListenOptions {
|
|
160
|
-
/**
|
|
161
|
-
*
|
|
162
|
-
* 若多次尝试失败,是否退出 NestApplication。
|
|
163
|
-
*
|
|
164
|
-
* 可选。默认值为 @see A5_APP_LISTEN_OPTIONS_DEFAULT.AUTO_EXIT
|
|
165
|
-
*
|
|
166
|
-
*/
|
|
167
|
-
readonly autoExit?: boolean;
|
|
168
|
-
/**
|
|
169
|
-
*
|
|
170
|
-
* 若端口被占用,则重新获取端口的时间间隔。(单位 ms)
|
|
171
|
-
*
|
|
172
|
-
* 数值是正整数。
|
|
173
|
-
*
|
|
174
|
-
* 可选。默认值为 @see A5_APP_LISTEN_OPTIONS_DEFAULT.TRY_INTERVAL
|
|
175
|
-
*
|
|
176
|
-
* TODO 后续可以添加合适的时间范围。
|
|
177
|
-
*
|
|
178
|
-
*/
|
|
179
|
-
readonly tryInterval?: number;
|
|
180
|
-
/**
|
|
181
|
-
*
|
|
182
|
-
* 若端口被占用,则重新获取端口的最大尝试次数。
|
|
183
|
-
*
|
|
184
|
-
* 数值是正整数。
|
|
185
|
-
*
|
|
186
|
-
* 可选。默认值为 @see A5_APP_LISTEN_OPTIONS_DEFAULT.TRY_TIMES
|
|
187
|
-
*
|
|
188
|
-
*/
|
|
189
|
-
readonly tryTimes?: number;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* @public
|
|
194
|
-
*
|
|
195
|
-
* A5App Options
|
|
196
|
-
*
|
|
197
|
-
*/
|
|
198
|
-
export declare type A5AppOptions = Required<A5AppConstructorOptions>;
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* @public
|
|
202
|
-
*/
|
|
203
|
-
export declare class A5ConsoleLogger implements LoggerService {
|
|
204
|
-
protected static lastTimestampAt?: number;
|
|
205
|
-
protected readonly originalContext: string;
|
|
206
|
-
protected context: string;
|
|
207
|
-
protected options: A5ConsoleLoggerOptions;
|
|
208
|
-
constructor(options?: A5ConsoleLoggerConstructorOptions);
|
|
209
|
-
/**
|
|
210
|
-
* Write a 'log' level log, if the configured level allows for it.
|
|
211
|
-
* Prints to `stdout` with newline.
|
|
212
|
-
*/
|
|
213
|
-
log(message: unknown, context?: string): void;
|
|
214
|
-
log(message: unknown, ...optionalParams: [...unknown[], string | unknown]): void;
|
|
215
|
-
/**
|
|
216
|
-
* Write an 'error' level log, if the configured level allows for it.
|
|
217
|
-
* Prints to `stderr` with newline.
|
|
218
|
-
*/
|
|
219
|
-
error(message: unknown, stackOrContext?: string): void;
|
|
220
|
-
error(message: unknown, stack?: string, context?: string): void;
|
|
221
|
-
error(message: unknown, ...optionalParams: [...unknown[], string | unknown, string | unknown]): void;
|
|
222
|
-
/**
|
|
223
|
-
* Write a 'warn' level log, if the configured level allows for it.
|
|
224
|
-
* Prints to `stdout` with newline.
|
|
225
|
-
*/
|
|
226
|
-
warn(message: unknown, context?: string): void;
|
|
227
|
-
warn(message: unknown, ...optionalParams: [...unknown[], string | unknown]): void;
|
|
228
|
-
/**
|
|
229
|
-
* Write a 'debug' level log, if the configured level allows for it.
|
|
230
|
-
* Prints to `stdout` with newline.
|
|
231
|
-
*/
|
|
232
|
-
debug(message: unknown, context?: string): void;
|
|
233
|
-
debug(message: unknown, ...optionalParams: [...unknown[], string | unknown]): void;
|
|
234
|
-
/**
|
|
235
|
-
* Write a 'verbose' level log, if the configured level allows for it.
|
|
236
|
-
* Prints to `stdout` with newline.
|
|
237
|
-
*/
|
|
238
|
-
verbose(message: unknown, context?: string): void;
|
|
239
|
-
verbose(message: unknown, ...optionalParams: [...unknown[], string | unknown]): void;
|
|
240
|
-
/**
|
|
241
|
-
* TODO 需要思考,是否需要让 fatal 与 error 保持一致!!!
|
|
242
|
-
*/
|
|
243
|
-
/**
|
|
244
|
-
* Write a 'fatal' level log, if the configured level allows for it.
|
|
245
|
-
* Prints to `stdout` with newline.
|
|
246
|
-
*/
|
|
247
|
-
fatal(message: unknown, context?: string): void;
|
|
248
|
-
fatal(message: unknown, ...optionalParams: [...unknown[], string | unknown]): void;
|
|
249
|
-
/**
|
|
250
|
-
* Set log levels
|
|
251
|
-
* @param levels - log levels
|
|
252
|
-
*/
|
|
253
|
-
setLogLevels(levels: LogLevel[]): void;
|
|
254
|
-
/**
|
|
255
|
-
* Set logger context
|
|
256
|
-
* @param context - context
|
|
257
|
-
*/
|
|
258
|
-
setContext(context: string): void;
|
|
259
|
-
/**
|
|
260
|
-
* Get logger context
|
|
261
|
-
* @param context - context
|
|
262
|
-
*/
|
|
263
|
-
getContext(): string;
|
|
264
|
-
/**
|
|
265
|
-
* Resets the logger context to the value that was passed in the constructor.
|
|
266
|
-
*/
|
|
267
|
-
resetContext(): void;
|
|
268
|
-
isLevelEnabled(level: LogLevel): boolean;
|
|
269
|
-
protected printMessages(messages: unknown[], context_: string, logLevel?: LogLevel, writeStreamType?: 'stdout' | 'stderr'): void;
|
|
270
|
-
protected formatMessage(options: A5FormatMessageOptions): string;
|
|
271
|
-
protected formatMessageStructure(options: A5FormatMessageOptions): A5FormatMessageInfo;
|
|
272
|
-
protected formatPrefix(): string;
|
|
273
|
-
protected formatPid(): string;
|
|
274
|
-
protected formatLogLevel(logLevel: LogLevel): string;
|
|
275
|
-
protected formatTimestamp(dateMilliseconds: number): string;
|
|
276
|
-
protected formatContext(context: string): string;
|
|
277
|
-
protected stringifyMessage(message: unknown, logLevel: LogLevel): string;
|
|
278
|
-
protected colorize(message: string, logLevel: LogLevel): string;
|
|
279
|
-
protected printStackTrace(stack: string | undefined): void;
|
|
280
|
-
protected updateAndGetTimestampDiff(): number | null;
|
|
281
|
-
protected formatTimestampDiff(timestampDiff: number | null): string;
|
|
282
|
-
protected getContextAndMessagesToPrint(args: unknown[]): {
|
|
283
|
-
context: string;
|
|
284
|
-
messages: unknown[];
|
|
285
|
-
};
|
|
286
|
-
protected getContextAndStackAndMessagesToPrint(args: unknown[]): {
|
|
287
|
-
messages: unknown[];
|
|
288
|
-
context: string;
|
|
289
|
-
stack?: string;
|
|
290
|
-
};
|
|
291
|
-
protected isStackFormat(stack: unknown): stack is string;
|
|
292
|
-
/**
|
|
293
|
-
* 移除最后 多个 undefined
|
|
294
|
-
*/
|
|
295
|
-
protected removeLastUndefined(args: unknown[]): unknown[];
|
|
296
|
-
protected getColorByLogLevel(level: LogLevel): (text: string) => string;
|
|
297
|
-
/**
|
|
298
|
-
* 保证日志数据的统一格式,对 Nest 默认的日志输出进行格式化。
|
|
299
|
-
*/
|
|
300
|
-
protected _contextNeedApologeticReplace(context: string): context is 'NestFactory' | 'NestApplication';
|
|
301
|
-
/**
|
|
302
|
-
* 保证日志数据的统一格式,对 Nest 默认的日志输出进行格式化。
|
|
303
|
-
*/
|
|
304
|
-
protected _contextApologeticReplace(context: 'NestFactory' | 'NestApplication'): string;
|
|
305
|
-
/**
|
|
306
|
-
* 保证日志数据的统一格式,对 Nest 默认的日志输出进行格式化。
|
|
307
|
-
*/
|
|
308
|
-
protected _messageApologeticReplace(message: unknown): unknown;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
/**
|
|
312
|
-
* @public
|
|
313
|
-
*/
|
|
314
|
-
export declare interface A5ConsoleLoggerConstructorOptions {
|
|
315
|
-
/**
|
|
316
|
-
* Context name for logs
|
|
317
|
-
*
|
|
318
|
-
* Default is ''
|
|
319
|
-
*/
|
|
320
|
-
context?: string;
|
|
321
|
-
/**
|
|
322
|
-
* Enabled log levels.
|
|
323
|
-
*
|
|
324
|
-
* Default is @see DEFAULT_LOG_LEVELS
|
|
325
|
-
*/
|
|
326
|
-
logLevels?: LogLevel[];
|
|
327
|
-
/**
|
|
328
|
-
* If enabled, will print timestamp (time difference) between current and previous log message.
|
|
329
|
-
*
|
|
330
|
-
* Default is `false`
|
|
331
|
-
*/
|
|
332
|
-
timestamp?: boolean;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
/**
|
|
336
|
-
* @public
|
|
337
|
-
*/
|
|
338
|
-
export declare class A5ConsoleLoggerMiddleware implements NestMiddleware {
|
|
339
|
-
protected logger: Logger;
|
|
340
|
-
use(req: FastifyRequestRaw, res: FastifyReplyRaw, next: () => void): void;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* @public
|
|
345
|
-
*/
|
|
346
|
-
export declare type A5ConsoleLoggerOptions = Omit<Required<A5ConsoleLoggerConstructorOptions>, 'context'>;
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* @public
|
|
350
|
-
*/
|
|
351
|
-
export declare const A5Factory: A5FactoryStatic;
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* @public
|
|
355
|
-
*/
|
|
356
|
-
export declare interface A5FactoryCreateOptions {
|
|
357
|
-
/**
|
|
358
|
-
* 是否输出日志信息。可选。默认为 true
|
|
359
|
-
*/
|
|
360
|
-
readonly printLogo?: boolean;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
declare class A5FactoryStatic {
|
|
364
|
-
protected nestFactoryStatic: NestFactoryStatic;
|
|
365
|
-
constructor();
|
|
366
|
-
create(module: unknown, options?: A5FactoryCreateOptions): Promise<A5Application>;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
/**
|
|
370
|
-
* @public
|
|
371
|
-
*/
|
|
372
|
-
export declare interface A5FormatMessageInfo {
|
|
373
|
-
prefix: string;
|
|
374
|
-
pid: string;
|
|
375
|
-
timestamp: number;
|
|
376
|
-
timestampStr: string;
|
|
377
|
-
logLevel: string;
|
|
378
|
-
context: string;
|
|
379
|
-
output: string;
|
|
380
|
-
timestampDiff: number | null;
|
|
381
|
-
timestampDiffStr: string;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
declare interface A5FormatMessageOptions {
|
|
385
|
-
logLevel: LogLevel;
|
|
386
|
-
context: string;
|
|
387
|
-
message: unknown;
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
* @public
|
|
392
|
-
*
|
|
393
|
-
* `A5` 全局提供者 Token。
|
|
394
|
-
*
|
|
395
|
-
*/
|
|
396
|
-
export declare type A5GlobalProvideToken = `Global.A5.${string}`;
|
|
397
|
-
|
|
398
|
-
/**
|
|
399
|
-
* A5 加载包错误
|
|
400
|
-
* 当动态加载可选依赖包失败时抛出此错误
|
|
401
|
-
* @public
|
|
402
|
-
*/
|
|
403
|
-
export declare class A5LoadPackageError extends Error {
|
|
404
|
-
/**
|
|
405
|
-
* 错误名称
|
|
406
|
-
*/
|
|
407
|
-
readonly name: string;
|
|
408
|
-
/**
|
|
409
|
-
* 尝试加载的包名
|
|
410
|
-
*/
|
|
411
|
-
readonly packageName: string;
|
|
412
|
-
/**
|
|
413
|
-
* 原始错误(如果有)
|
|
414
|
-
*/
|
|
415
|
-
readonly cause?: Error;
|
|
416
|
-
constructor(packageName: string, message?: string, cause?: Error);
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
/**
|
|
420
|
-
* @public
|
|
421
|
-
*
|
|
422
|
-
* `A5` 配置项路径。
|
|
423
|
-
*
|
|
424
|
-
*/
|
|
425
|
-
export declare type A5ModuleConfigPath = `A5.${string}`;
|
|
426
|
-
|
|
427
|
-
/**
|
|
428
|
-
* A5 随机工具类
|
|
429
|
-
*
|
|
430
|
-
* 提供生成随机值和 UUID 的静态方法
|
|
431
|
-
*
|
|
432
|
-
* @public
|
|
433
|
-
*/
|
|
434
|
-
export declare class A5RandomUtil {
|
|
435
|
-
static nanoid(size?: number): string;
|
|
436
|
-
static uuidV4(options?: V4Options): string;
|
|
437
|
-
static uuidV7(options?: V7Options): string;
|
|
438
|
-
/**
|
|
439
|
-
* 生成指定位数的随机数字
|
|
440
|
-
*
|
|
441
|
-
* @param digits - 位数,默认 6
|
|
442
|
-
* @returns 随机数字字符串
|
|
443
|
-
*/
|
|
444
|
-
static randomDigits(digits?: number): string;
|
|
445
|
-
/**
|
|
446
|
-
* 生成指定长度的随机字符串(a-zA-Z0-9)
|
|
447
|
-
*
|
|
448
|
-
* @param length - 长度,默认 8
|
|
449
|
-
* @returns 随机字符串
|
|
450
|
-
*/
|
|
451
|
-
static randomString(length?: number, chars?: string): string;
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
/**
|
|
455
|
-
* @public
|
|
456
|
-
*
|
|
457
|
-
* `A5` 作用域提供者 Token。
|
|
458
|
-
*
|
|
459
|
-
*/
|
|
460
|
-
export declare type A5ScopeProvideToken = `Scope.A5.${string}`;
|
|
461
|
-
|
|
462
|
-
/**
|
|
463
|
-
*
|
|
464
|
-
* @public
|
|
465
|
-
*
|
|
466
|
-
* 通用工具类
|
|
467
|
-
*
|
|
468
|
-
*/
|
|
469
|
-
export declare class A5Util {
|
|
470
|
-
/**
|
|
471
|
-
*
|
|
472
|
-
* 睡眠。
|
|
473
|
-
*
|
|
474
|
-
* @param t - 时间。单位:毫秒
|
|
475
|
-
*/
|
|
476
|
-
static sleep(t: number): Promise<void>;
|
|
477
|
-
/**
|
|
478
|
-
* @public
|
|
479
|
-
*
|
|
480
|
-
* 如果不是绝对路径,则进行拼接
|
|
481
|
-
*
|
|
482
|
-
* @param sourcePath - 资源路径
|
|
483
|
-
* @param basePath - 基础路径
|
|
484
|
-
*
|
|
485
|
-
* @returns 资源路径的绝对路径。
|
|
486
|
-
*/
|
|
487
|
-
static tryWithAbsolutePath(sourcePath: string, basePath: string): string;
|
|
488
|
-
static getReqIdFromRequest(req: FastifyRequest): string;
|
|
489
|
-
static getReqHeadersFromRequest(req: FastifyRequest): IncomingHttpHeaders;
|
|
490
|
-
static getReqIdAndHeadersFromRequest(req: FastifyRequest): {
|
|
491
|
-
reqId: string;
|
|
492
|
-
reqHeaders: IncomingHttpHeaders;
|
|
493
|
-
};
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
/**
|
|
497
|
-
* 类型断言工具 - 判断两个类型结构相似
|
|
498
|
-
*
|
|
499
|
-
* @public
|
|
500
|
-
*/
|
|
501
|
-
export declare type Alike<X, Y> = Equal<MergeInsertions<X>, MergeInsertions<Y>>;
|
|
502
|
-
|
|
503
|
-
/**
|
|
504
|
-
* @public
|
|
505
|
-
*/
|
|
506
|
-
export declare class ColorUtil {
|
|
507
|
-
static get isColorAllowed(): boolean;
|
|
508
|
-
static bold(text: string): string;
|
|
509
|
-
static red(text: string): string;
|
|
510
|
-
static green(text: string): string;
|
|
511
|
-
static yellow(text: string): string;
|
|
512
|
-
static blue(text: string): string;
|
|
513
|
-
static magenta(text: string): string;
|
|
514
|
-
static cyan(text: string): string;
|
|
515
|
-
static redBright(text: string): string;
|
|
516
|
-
static greenBright(text: string): string;
|
|
517
|
-
static yellowBright(text: string): string;
|
|
518
|
-
static blueBright(text: string): string;
|
|
519
|
-
static magentaBright(text: string): string;
|
|
520
|
-
static cyanBright(text: string): string;
|
|
521
|
-
/**
|
|
522
|
-
* 移除 ANSI 颜色代码
|
|
523
|
-
*
|
|
524
|
-
* @param text - text to clear
|
|
525
|
-
* @returns cleaned text
|
|
526
|
-
*/
|
|
527
|
-
static clear(text: string): string;
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
/**
|
|
531
|
-
* 类型调试工具 - 展开类型定义
|
|
532
|
-
*
|
|
533
|
-
* @public
|
|
534
|
-
*/
|
|
535
|
-
export declare type Debug<T> = {
|
|
536
|
-
[K in keyof T]: T[K];
|
|
537
|
-
};
|
|
538
|
-
|
|
539
|
-
/**
|
|
540
|
-
* @public
|
|
541
|
-
*/
|
|
542
|
-
export declare const DEFAULT_LOG_LEVELS: LogLevel[];
|
|
543
|
-
|
|
544
|
-
/**
|
|
545
|
-
* 类型断言工具 - 判断两个类型相等
|
|
546
|
-
*
|
|
547
|
-
* @public
|
|
548
|
-
*/
|
|
549
|
-
export declare type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false;
|
|
550
|
-
|
|
551
|
-
/**
|
|
552
|
-
* @public
|
|
553
|
-
*/
|
|
554
|
-
export declare const ERROR_WELCOME_MSG: string;
|
|
555
|
-
|
|
556
|
-
/**
|
|
557
|
-
* 类型断言工具 - 期望类型为 true
|
|
558
|
-
*
|
|
559
|
-
* @public
|
|
560
|
-
*/
|
|
561
|
-
export declare type Expect<T extends true> = T;
|
|
562
|
-
|
|
563
|
-
/**
|
|
564
|
-
* 类型断言工具 - 期望类型扩展自目标类型
|
|
565
|
-
*
|
|
566
|
-
* @public
|
|
567
|
-
*/
|
|
568
|
-
export declare type ExpectExtends<VALUE, EXPECTED> = EXPECTED extends VALUE ? true : false;
|
|
569
|
-
|
|
570
|
-
/**
|
|
571
|
-
* 类型断言工具 - 期望值为 false
|
|
572
|
-
*
|
|
573
|
-
* @public
|
|
574
|
-
*/
|
|
575
|
-
export declare type ExpectFalse<T extends false> = T;
|
|
576
|
-
|
|
577
|
-
/**
|
|
578
|
-
* 类型断言工具 - 期望值为 true
|
|
579
|
-
*
|
|
580
|
-
* @public
|
|
581
|
-
*/
|
|
582
|
-
export declare type ExpectTrue<T extends true> = T;
|
|
583
|
-
|
|
584
|
-
/**
|
|
585
|
-
* 类型断言工具 - 验证函数参数类型
|
|
586
|
-
*
|
|
587
|
-
* @public
|
|
588
|
-
*/
|
|
589
|
-
export declare type ExpectValidArgs<FUNC extends (...args: any[]) => any, ARGS extends any[]> = ARGS extends Parameters<FUNC> ? true : false;
|
|
590
|
-
|
|
591
|
-
/**
|
|
592
|
-
* @public
|
|
593
|
-
*/
|
|
594
|
-
export declare type FastifyReply = FastifyReply_2;
|
|
595
|
-
|
|
596
|
-
/**
|
|
597
|
-
* @public
|
|
598
|
-
*/
|
|
599
|
-
export declare type FastifyReplyRaw = FastifyReply_2['raw'];
|
|
600
|
-
|
|
601
|
-
/**
|
|
602
|
-
* @public
|
|
603
|
-
*/
|
|
604
|
-
export declare type FastifyRequest = FastifyRequest_2;
|
|
605
|
-
|
|
606
|
-
/**
|
|
607
|
-
* @public
|
|
608
|
-
*/
|
|
609
|
-
export declare type FastifyRequestRaw = FastifyRequest_2['raw'];
|
|
610
|
-
|
|
611
|
-
/**
|
|
612
|
-
*
|
|
613
|
-
* @public
|
|
614
|
-
*
|
|
615
|
-
* `A5 Log Module` Global Provide Token
|
|
616
|
-
*
|
|
617
|
-
*/
|
|
618
|
-
export declare const GLOBAL_PROVIDE_TOKEN_A5_CONFIG: A5GlobalProvideToken;
|
|
619
|
-
|
|
620
|
-
/**
|
|
621
|
-
*
|
|
622
|
-
* @public
|
|
623
|
-
*
|
|
624
|
-
* `A5 Log Module` Global Provide Token
|
|
625
|
-
*
|
|
626
|
-
*/
|
|
627
|
-
export declare const GLOBAL_PROVIDE_TOKEN_A5_LOG_LOGGER: A5GlobalProvideToken;
|
|
628
|
-
|
|
629
|
-
/**
|
|
630
|
-
* @public
|
|
631
|
-
*/
|
|
632
|
-
export declare const HOME_STATIC_PATH: string;
|
|
633
|
-
|
|
634
|
-
/**
|
|
635
|
-
*
|
|
636
|
-
* @public
|
|
637
|
-
*
|
|
638
|
-
* `A5 Config Module` 抽象类。
|
|
639
|
-
*
|
|
640
|
-
*/
|
|
641
|
-
export declare abstract class IA5ConfigModule {
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
/**
|
|
645
|
-
*
|
|
646
|
-
* @public
|
|
647
|
-
*
|
|
648
|
-
* `A5 Log Module` 抽象类。
|
|
649
|
-
*
|
|
650
|
-
*/
|
|
651
|
-
export declare abstract class IA5LogModule {
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
/**
|
|
655
|
-
* 类型断言工具 - 判断是否为 any 类型
|
|
656
|
-
*
|
|
657
|
-
* @public
|
|
658
|
-
*/
|
|
659
|
-
export declare type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
660
|
-
|
|
661
|
-
/**
|
|
662
|
-
* 类型断言工具 - 判断是否为 false
|
|
663
|
-
*
|
|
664
|
-
* @public
|
|
665
|
-
*/
|
|
666
|
-
export declare type IsFalse<T extends false> = T;
|
|
667
|
-
|
|
668
|
-
/**
|
|
669
|
-
* 类型断言工具 - 判断是否为 true
|
|
670
|
-
*
|
|
671
|
-
* @public
|
|
672
|
-
*/
|
|
673
|
-
export declare type IsTrue<T extends true> = T;
|
|
674
|
-
|
|
675
|
-
/**
|
|
676
|
-
* JSON 数组类型
|
|
677
|
-
*
|
|
678
|
-
* 表示 JSON 数组结构,元素为任意 JSON 值
|
|
679
|
-
*
|
|
680
|
-
* @public
|
|
681
|
-
*/
|
|
682
|
-
export declare interface JsonArray extends Array<JsonValue> {
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
/**
|
|
686
|
-
* JSON 对象类型
|
|
687
|
-
*
|
|
688
|
-
* 表示 JSON 对象结构,键为字符串,值为任意 JSON 值
|
|
689
|
-
*
|
|
690
|
-
* @public
|
|
691
|
-
*/
|
|
692
|
-
export declare interface JsonObject {
|
|
693
|
-
[key: string]: JsonValue;
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
/**
|
|
697
|
-
* JSON 值类型
|
|
698
|
-
*
|
|
699
|
-
* 表示所有合法的 JSON 值类型,包括基础类型、对象和数组
|
|
700
|
-
*
|
|
701
|
-
* @public
|
|
702
|
-
*/
|
|
703
|
-
export declare type JsonValue = string | number | boolean | null | JsonObject | JsonArray;
|
|
704
|
-
|
|
705
|
-
/**
|
|
706
|
-
* 包加载工具类
|
|
707
|
-
* 用于统一处理可选依赖的动态导入
|
|
708
|
-
* @public
|
|
709
|
-
*/
|
|
710
|
-
export declare class LoadPackageUtil {
|
|
711
|
-
/**
|
|
712
|
-
* 动态加载包
|
|
713
|
-
* @param packageName - 包名
|
|
714
|
-
* @returns 加载的包模块
|
|
715
|
-
* @throws 当包加载失败时抛出错误
|
|
716
|
-
*/
|
|
717
|
-
static loadPackage<T = unknown>(packageName: string): T;
|
|
718
|
-
/**
|
|
719
|
-
* 安全地动态加载包
|
|
720
|
-
* @param packageName - 包名
|
|
721
|
-
* @returns 加载的包模块,如果失败则返回 null
|
|
722
|
-
*/
|
|
723
|
-
static loadPackageSafe<T = unknown>(packageName: string): T | null;
|
|
724
|
-
/**
|
|
725
|
-
* 带重试的动态加载包
|
|
726
|
-
* @param packageName - 包名
|
|
727
|
-
* @param retries - 重试次数,默认为 3
|
|
728
|
-
* @param retryDelay - 重试间隔(毫秒),默认为 100
|
|
729
|
-
* @returns 加载的包模块
|
|
730
|
-
* @throws 当所有重试都失败时抛出错误
|
|
731
|
-
*/
|
|
732
|
-
static loadPackageWithRetry<T = unknown>(packageName: string, retries?: number, retryDelay?: number): Promise<T>;
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
/**
|
|
736
|
-
* 因 `logo` 字符串特殊字符过多,不应直接存放当前文件。
|
|
737
|
-
*
|
|
738
|
-
* 进行 base64 编码并存放。
|
|
739
|
-
*/
|
|
740
|
-
/**
|
|
741
|
-
*
|
|
742
|
-
* @public
|
|
743
|
-
*
|
|
744
|
-
* 打印 Logo。
|
|
745
|
-
*
|
|
746
|
-
* logo 是在 http://patorjk.com/software/taag/#p=display&f=Big&t=a5 进行制作的。
|
|
747
|
-
*
|
|
748
|
-
*/
|
|
749
|
-
export declare class LogoUtil {
|
|
750
|
-
private static _content;
|
|
751
|
-
/**
|
|
752
|
-
* Logo 的文本信息。
|
|
753
|
-
*/
|
|
754
|
-
static get content(): string;
|
|
755
|
-
/**
|
|
756
|
-
*
|
|
757
|
-
* 打印 A5 的 Logo 及版本信息。
|
|
758
|
-
*
|
|
759
|
-
* 使用 `console.log` 输出信息,不会写入到日志文件中。
|
|
760
|
-
*
|
|
761
|
-
* @param onlyLogo - 仅打印 Logo,不包含版本信息。可选。默认为 false
|
|
762
|
-
*
|
|
763
|
-
*/
|
|
764
|
-
static print(onlyLogo?: boolean): void;
|
|
765
|
-
}
|
|
766
|
-
|
|
767
|
-
/**
|
|
768
|
-
* @public
|
|
769
|
-
*/
|
|
770
|
-
export declare const MAIN_STATIC_PATH: string;
|
|
771
|
-
|
|
772
|
-
/**
|
|
773
|
-
* 类型合并工具 - 合并嵌套类型
|
|
774
|
-
*
|
|
775
|
-
* @public
|
|
776
|
-
*/
|
|
777
|
-
export declare type MergeInsertions<T> = T extends object ? {
|
|
778
|
-
[K in keyof T]: MergeInsertions<T[K]>;
|
|
779
|
-
} : T;
|
|
780
|
-
|
|
781
|
-
/**
|
|
782
|
-
*
|
|
783
|
-
* @public
|
|
784
|
-
*
|
|
785
|
-
* `A5 Config Module` Config Path
|
|
786
|
-
*
|
|
787
|
-
*/
|
|
788
|
-
export declare const MODULE_CONFIG_PATH_A5_CONFIG: <T extends string>(str: T) => `A5.config.${T}`;
|
|
789
|
-
|
|
790
|
-
/**
|
|
791
|
-
*
|
|
792
|
-
* @public
|
|
793
|
-
*
|
|
794
|
-
* `A5 Log Module` Config Path
|
|
795
|
-
*
|
|
796
|
-
*/
|
|
797
|
-
export declare const MODULE_CONFIG_PATH_A5_LOG: <T extends string>(str: T) => `A5.log.${T}`;
|
|
798
|
-
|
|
799
|
-
/**
|
|
800
|
-
* 类型断言工具 - 判断不是 any 类型
|
|
801
|
-
*
|
|
802
|
-
* @public
|
|
803
|
-
*/
|
|
804
|
-
export declare type NotAny<T> = true extends IsAny<T> ? false : true;
|
|
805
|
-
|
|
806
|
-
/**
|
|
807
|
-
* 类型断言工具 - 判断两个类型不相等
|
|
808
|
-
*
|
|
809
|
-
* @public
|
|
810
|
-
*/
|
|
811
|
-
export declare type NotEqual<X, Y> = true extends Equal<X, Y> ? false : true;
|
|
812
|
-
|
|
813
|
-
/**
|
|
814
|
-
* @public
|
|
815
|
-
*/
|
|
816
|
-
export declare type RequiredButOmit<T, K extends keyof T> = Required<Pick<T, K>> & Omit<T, K>;
|
|
817
|
-
|
|
818
|
-
/**
|
|
819
|
-
* @public
|
|
820
|
-
*/
|
|
821
|
-
export declare type RequiredButPick<T, K extends keyof T> = Required<Omit<T, K>> & Pick<T, K>;
|
|
822
|
-
|
|
823
|
-
/**
|
|
824
|
-
* @public
|
|
825
|
-
*
|
|
826
|
-
* 当前运行环境。
|
|
827
|
-
*
|
|
828
|
-
*/
|
|
829
|
-
export declare class RunEnvUtil {
|
|
830
|
-
/**
|
|
831
|
-
* 是否处于开发环境.
|
|
832
|
-
*/
|
|
833
|
-
static get isDev(): boolean;
|
|
834
|
-
/**
|
|
835
|
-
* 是否处于生产环境.
|
|
836
|
-
*/
|
|
837
|
-
static get isProd(): boolean;
|
|
838
|
-
/**
|
|
839
|
-
* 是否处于 PKG 打包后的环境。
|
|
840
|
-
*/
|
|
841
|
-
static get inPKG(): boolean;
|
|
842
|
-
/**
|
|
843
|
-
* 是否处于 `VS Code` 的 `Debugger` 模式下。
|
|
844
|
-
*/
|
|
845
|
-
static get inVSCodeDebugger(): boolean;
|
|
846
|
-
/**
|
|
847
|
-
* 是否处于 `Jest` 的单元测试环境下。
|
|
848
|
-
*/
|
|
849
|
-
static get inJest(): boolean;
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
/**
|
|
853
|
-
* 类型转换工具 - 联合类型转交叉类型
|
|
854
|
-
*
|
|
855
|
-
* @public
|
|
856
|
-
*/
|
|
857
|
-
export declare type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
858
|
-
|
|
859
|
-
/**
|
|
860
|
-
* @public
|
|
861
|
-
*/
|
|
862
|
-
export declare type Writable<T> = {
|
|
863
|
-
-readonly [P in keyof T]: T[P];
|
|
864
|
-
};
|
|
865
|
-
|
|
866
|
-
/**
|
|
867
|
-
* @public
|
|
868
|
-
*/
|
|
869
|
-
export declare type WritableRequired<T> = Writable<Required<T>>;
|
|
870
|
-
|
|
871
|
-
export { }
|