@hz-9/a5-core 0.2.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 (75) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +15 -0
  3. package/dist/all.d.ts +676 -0
  4. package/dist/const/index.d.ts +38 -0
  5. package/dist/const/index.js +46 -0
  6. package/dist/core/__import-reflect-metadata.d.ts +1 -0
  7. package/dist/core/__import-reflect-metadata.js +4 -0
  8. package/dist/core/a5-application.d.ts +154 -0
  9. package/dist/core/a5-application.js +315 -0
  10. package/dist/core/a5-console-logger.d.ts +163 -0
  11. package/dist/core/a5-console-logger.js +354 -0
  12. package/dist/core/a5-factory.d.ts +21 -0
  13. package/dist/core/a5-factory.js +49 -0
  14. package/dist/core/index.d.ts +3 -0
  15. package/dist/core/index.js +20 -0
  16. package/dist/index.d.ts +7 -0
  17. package/dist/index.js +24 -0
  18. package/dist/interface/base.d.ts +18 -0
  19. package/dist/interface/base.js +3 -0
  20. package/dist/interface/http.d.ts +16 -0
  21. package/dist/interface/http.js +3 -0
  22. package/dist/interface/index.d.ts +3 -0
  23. package/dist/interface/index.js +20 -0
  24. package/dist/interface/provide-token.d.ts +21 -0
  25. package/dist/interface/provide-token.js +3 -0
  26. package/dist/middleware/a5-console-logger.middleware.d.ts +9 -0
  27. package/dist/middleware/a5-console-logger.middleware.js +58 -0
  28. package/dist/middleware/index.d.ts +1 -0
  29. package/dist/middleware/index.js +18 -0
  30. package/dist/module/config/index.d.ts +18 -0
  31. package/dist/module/config/index.js +36 -0
  32. package/dist/module/config/interface.d.ts +9 -0
  33. package/dist/module/config/interface.js +15 -0
  34. package/dist/module/index.d.ts +2 -0
  35. package/dist/module/index.js +19 -0
  36. package/dist/module/log/index.d.ts +18 -0
  37. package/dist/module/log/index.js +44 -0
  38. package/dist/module/log/interface.d.ts +9 -0
  39. package/dist/module/log/interface.js +15 -0
  40. package/dist/plugins/index.d.ts +1 -0
  41. package/dist/plugins/index.js +18 -0
  42. package/dist/plugins/nanoid.d.ts +1 -0
  43. package/dist/plugins/nanoid.js +6 -0
  44. package/dist/test/integration/core/a5-factory.integration.spec.d.ts +1 -0
  45. package/dist/test/integration/core/a5-factory.integration.spec.js +99 -0
  46. package/dist/test/integration/core/with-logger-module.integration.spec.d.ts +1 -0
  47. package/dist/test/integration/core/with-logger-module.integration.spec.js +401 -0
  48. package/dist/test/unit/core/a5-application.unit.spec.d.ts +1 -0
  49. package/dist/test/unit/core/a5-application.unit.spec.js +450 -0
  50. package/dist/test/unit/core/a5-console-logger.unit.spec.d.ts +1 -0
  51. package/dist/test/unit/core/a5-console-logger.unit.spec.js +998 -0
  52. package/dist/test/unit/middleware/a5-console-logger.middleware.unit.spec.d.ts +1 -0
  53. package/dist/test/unit/middleware/a5-console-logger.middleware.unit.spec.js +379 -0
  54. package/dist/test/unit/util/a5.util.unit.spec.d.ts +1 -0
  55. package/dist/test/unit/util/a5.util.unit.spec.js +109 -0
  56. package/dist/test/unit/util/color.util.unit.spec.d.ts +1 -0
  57. package/dist/test/unit/util/color.util.unit.spec.js +277 -0
  58. package/dist/test/unit/util/logo.util.unit.spec.d.ts +1 -0
  59. package/dist/test/unit/util/logo.util.unit.spec.js +202 -0
  60. package/dist/test/unit/util/run-env.util.unit.spec.d.ts +1 -0
  61. package/dist/test/unit/util/run-env.util.unit.spec.js +183 -0
  62. package/dist/util/a5.util.d.ts +27 -0
  63. package/dist/util/a5.util.js +41 -0
  64. package/dist/util/color.util.d.ts +26 -0
  65. package/dist/util/color.util.js +62 -0
  66. package/dist/util/index.d.ts +5 -0
  67. package/dist/util/index.js +22 -0
  68. package/dist/util/load-package.util.d.ts +29 -0
  69. package/dist/util/load-package.util.js +71 -0
  70. package/dist/util/logo.util.d.ts +31 -0
  71. package/dist/util/logo.util.js +59 -0
  72. package/dist/util/run-env.util.d.ts +28 -0
  73. package/dist/util/run-env.util.js +48 -0
  74. package/logo +7 -0
  75. package/package.json +96 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Chen Zhen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # @hz-9/a5-core
2
+
3
+ The core library for the `@hz-9/a5-*` series of repositories. It is used to bootstrap application services, encapsulate `NestApplication` and `NestFactory`, and create common classes for `@hz-9/a5-*`.
4
+
5
+ ![NPM Version][npm-version-url] ![NPM License][npm-license-url] ![NPM Downloads][npm-downloads-url] ![Types][types-url]
6
+ <br /> ![Node Version][node-version-url] ![Last Commit][last-commit-url]
7
+
8
+ [npm-version-url]: https://badgen.net/npm/v/@hz-9/a5-core
9
+ [npm-license-url]: https://badgen.net/npm/license/@hz-9/a5-core
10
+ [npm-downloads-url]: https://badgen.net/npm/dt/@hz-9/a5-core
11
+ [types-url]: https://badgen.net/npm/types/@hz-9/a5-core
12
+ [node-version-url]: https://badgen.net/npm/node/@hz-9/a5-core
13
+ [last-commit-url]: https://badgen.net/github/last-commit/hz-9/a5
14
+
15
+ [Document](https://hz-9.github.io/a5/guide/a5-core/) | [文档](https://hz-9.github.io/a5/zh-CN/guide/a5-core/)
package/dist/all.d.ts ADDED
@@ -0,0 +1,676 @@
1
+ import { FastifyReply as FastifyReply_2 } from 'fastify';
2
+ import { FastifyRequest as FastifyRequest_2 } from 'fastify';
3
+ import { Logger } from '@nestjs/common';
4
+ import { LoggerService } from '@nestjs/common/services/logger.service';
5
+ import { LoggerService as LoggerService_2 } from '@nestjs/common';
6
+ import { LogLevel } from '@nestjs/common/services/logger.service';
7
+ import { nanoid } from 'nanoid';
8
+ import { NestFactoryStatic } from '@nestjs/core/nest-factory';
9
+ import { NestFastifyApplication } from '@nestjs/platform-fastify';
10
+ import { NestMiddleware } from '@nestjs/common';
11
+
12
+ /**
13
+ * @public
14
+ *
15
+ * `A5App.prototype.listen` 参数默认值。
16
+ *
17
+ */
18
+ export declare const A5_APP_LISTEN_OPTIONS_DEFAULT: {
19
+ /**
20
+ * 是否自动退出。
21
+ */
22
+ readonly AUTO_EXIT: true;
23
+ /**
24
+ * 重试间隔。
25
+ */
26
+ readonly TRY_INTERVAL: 300;
27
+ /**
28
+ * 最大重试次数。
29
+ */
30
+ readonly TRY_TIMES: 20;
31
+ };
32
+
33
+ /**
34
+ * @public
35
+ *
36
+ * 默认监听端口。
37
+ */
38
+ export declare const A5_APP_LISTEN_PORT_DEFAULT: 16100;
39
+
40
+ /**
41
+ * @public
42
+ *
43
+ * A5App Constructor Options
44
+ *
45
+ */
46
+ export declare interface A5AppConstructorOptions {
47
+ /**
48
+ * Logger 对象。
49
+ *
50
+ * 显性设置 Logger 对象。默认情况下,将会加载 A5LoggerModule 的 Logger 实例。
51
+ *
52
+ * 如果加载失败,将会使用 A5ConsoleLogger 的实例。
53
+ *
54
+ */
55
+ readonly logger?: LoggerService_2;
56
+ }
57
+
58
+ /**
59
+ * @public
60
+ *
61
+ * `A5` for `NestApplication`。服务应用类。
62
+ *
63
+ */
64
+ export declare class A5Application {
65
+ protected readonly initTime: Date;
66
+ protected readonly logger: Logger;
67
+ /**
68
+ * setExtraUrl 及 getUrls 函数用于保存数据的数组
69
+ */
70
+ protected readonly extraUrls: string[];
71
+ /**
72
+ *
73
+ * 由 [nanoid](https://github.com/ai/nanoid) 生成的实例 ID。21 位长的字符串。
74
+ *
75
+ */
76
+ readonly instanceId: string;
77
+ readonly nestApp: NestFastifyApplication;
78
+ readonly options: A5AppOptions;
79
+ constructor(nestApp: NestFastifyApplication, options?: A5AppConstructorOptions);
80
+ init(): Promise<void>;
81
+ /**
82
+ *
83
+ * @public
84
+ *
85
+ * `A5` 应用,对网络进行监听。
86
+ *
87
+ * `A5` 增加了对端口获取失败的多次尝试。
88
+ *
89
+ * 如果想关闭自动重试,请传入 `listen({ tryTimes: 0 })`
90
+ *
91
+ * TODO 未考虑采用哪种方案,进行多次尝试。
92
+ *
93
+ */
94
+ listen(options?: A5AppListenOptions): Promise<void>;
95
+ listen(port: number | string, options?: A5AppListenOptions): Promise<void>;
96
+ /**
97
+ *
98
+ * @public
99
+ *
100
+ * 添加额外的 urls, 便于 printAddress 进行输出
101
+ *
102
+ */
103
+ setExtraUrl(urlOrUrls: string | string[]): Promise<void>;
104
+ /**
105
+ *
106
+ * @public
107
+ *
108
+ * 输出可以访问当前服务的地址。
109
+ *
110
+ * TODO 需要精准判断 IPv4 和 IPv6 等各项情况。
111
+ *
112
+ */
113
+ getUrls(): Promise<string[]>;
114
+ /**
115
+ *
116
+ * @public
117
+ *
118
+ * 在正常获取 IP 与端口后,可通过此函数输出日志信息。
119
+ *
120
+ */
121
+ printAddress(): Promise<void>;
122
+ /**
123
+ *
124
+ * @public
125
+ *
126
+ * 关闭应用。
127
+ * 是 `NestApplication.prototype.close()` 的语法糖。
128
+ *
129
+ */
130
+ close(): Promise<void>;
131
+ /**
132
+ *
133
+ * @public
134
+ *
135
+ * 应用是否处于关闭状态
136
+ *
137
+ */
138
+ isClose(): boolean;
139
+ /**
140
+ * @internal
141
+ *
142
+ * 将会优先尝试 A5 内部的日志模块。如果没有的话,才会使用 A5ConsoleLogger
143
+ *
144
+ */
145
+ private _getA5LoggerService;
146
+ }
147
+
148
+ /**
149
+ *
150
+ * @public
151
+ *
152
+ * `A5App.prototype.listen` 参数
153
+ *
154
+ */
155
+ export declare interface A5AppListenOptions {
156
+ /**
157
+ *
158
+ * 若多次尝试失败,是否退出 NestApplication。
159
+ *
160
+ * 可选。默认值为 @see A5_APP_LISTEN_OPTIONS_DEFAULT.AUTO_EXIT
161
+ *
162
+ */
163
+ readonly autoExit?: boolean;
164
+ /**
165
+ *
166
+ * 若端口被占用,则重新获取端口的时间间隔。(单位 ms)
167
+ *
168
+ * 数值是正整数。
169
+ *
170
+ * 可选。默认值为 @see A5_APP_LISTEN_OPTIONS_DEFAULT.TRY_INTERVAL
171
+ *
172
+ * TODO 后续可以添加合适的时间范围。
173
+ *
174
+ */
175
+ readonly tryInterval?: number;
176
+ /**
177
+ *
178
+ * 若端口被占用,则重新获取端口的最大尝试次数。
179
+ *
180
+ * 数值是正整数。
181
+ *
182
+ * 可选。默认值为 @see A5_APP_LISTEN_OPTIONS_DEFAULT.TRY_TIMES
183
+ *
184
+ */
185
+ readonly tryTimes?: number;
186
+ }
187
+
188
+ /**
189
+ * @public
190
+ *
191
+ * A5App Options
192
+ *
193
+ */
194
+ export declare type A5AppOptions = Required<A5AppConstructorOptions>;
195
+
196
+ /**
197
+ * @public
198
+ */
199
+ export declare class A5ConsoleLogger implements LoggerService {
200
+ protected static lastTimestampAt?: number;
201
+ protected readonly originalContext: string;
202
+ protected context: string;
203
+ protected options: A5ConsoleLoggerOptions;
204
+ constructor(options?: A5ConsoleLoggerConstructorOptions);
205
+ /**
206
+ * Write a 'log' level log, if the configured level allows for it.
207
+ * Prints to `stdout` with newline.
208
+ */
209
+ log(message: unknown, context?: string): void;
210
+ log(message: unknown, ...optionalParams: [...unknown[], string | unknown]): void;
211
+ /**
212
+ * Write an 'error' level log, if the configured level allows for it.
213
+ * Prints to `stderr` with newline.
214
+ */
215
+ error(message: unknown, stackOrContext?: string): void;
216
+ error(message: unknown, stack?: string, context?: string): void;
217
+ error(message: unknown, ...optionalParams: [...unknown[], string | unknown, string | unknown]): void;
218
+ /**
219
+ * Write a 'warn' level log, if the configured level allows for it.
220
+ * Prints to `stdout` with newline.
221
+ */
222
+ warn(message: unknown, context?: string): void;
223
+ warn(message: unknown, ...optionalParams: [...unknown[], string | unknown]): void;
224
+ /**
225
+ * Write a 'debug' level log, if the configured level allows for it.
226
+ * Prints to `stdout` with newline.
227
+ */
228
+ debug(message: unknown, context?: string): void;
229
+ debug(message: unknown, ...optionalParams: [...unknown[], string | unknown]): void;
230
+ /**
231
+ * Write a 'verbose' level log, if the configured level allows for it.
232
+ * Prints to `stdout` with newline.
233
+ */
234
+ verbose(message: unknown, context?: string): void;
235
+ verbose(message: unknown, ...optionalParams: [...unknown[], string | unknown]): void;
236
+ /**
237
+ * TODO 需要思考,是否需要让 fatal 与 error 保持一致!!!
238
+ */
239
+ /**
240
+ * Write a 'fatal' level log, if the configured level allows for it.
241
+ * Prints to `stdout` with newline.
242
+ */
243
+ fatal(message: unknown, context?: string): void;
244
+ fatal(message: unknown, ...optionalParams: [...unknown[], string | unknown]): void;
245
+ /**
246
+ * Set log levels
247
+ * @param levels - log levels
248
+ */
249
+ setLogLevels(levels: LogLevel[]): void;
250
+ /**
251
+ * Set logger context
252
+ * @param context - context
253
+ */
254
+ setContext(context: string): void;
255
+ /**
256
+ * Get logger context
257
+ * @param context - context
258
+ */
259
+ getContext(): string;
260
+ /**
261
+ * Resets the logger context to the value that was passed in the constructor.
262
+ */
263
+ resetContext(): void;
264
+ isLevelEnabled(level: LogLevel): boolean;
265
+ protected printMessages(messages: unknown[], context_: string, logLevel?: LogLevel, writeStreamType?: 'stdout' | 'stderr'): void;
266
+ protected formatMessage(options: A5FormatMessageOptions): string;
267
+ protected formatMessageStructure(options: A5FormatMessageOptions): A5FormatMessageInfo;
268
+ protected formatPrefix(): string;
269
+ protected formatPid(): string;
270
+ protected formatLogLevel(logLevel: LogLevel): string;
271
+ protected formatTimestamp(dateMilliseconds: number): string;
272
+ protected formatContext(context: string): string;
273
+ protected stringifyMessage(message: unknown, logLevel: LogLevel): string;
274
+ protected colorize(message: string, logLevel: LogLevel): string;
275
+ protected printStackTrace(stack: string | undefined): void;
276
+ protected updateAndGetTimestampDiff(): number | null;
277
+ protected formatTimestampDiff(timestampDiff: number | null): string;
278
+ protected getContextAndMessagesToPrint(args: unknown[]): {
279
+ context: string;
280
+ messages: unknown[];
281
+ };
282
+ protected getContextAndStackAndMessagesToPrint(args: unknown[]): {
283
+ messages: unknown[];
284
+ context: string;
285
+ stack?: string;
286
+ };
287
+ protected isStackFormat(stack: unknown): stack is string;
288
+ /**
289
+ * 移除最后 多个 undefined
290
+ */
291
+ protected removeLastUndefined(args: unknown[]): unknown[];
292
+ protected getColorByLogLevel(level: LogLevel): (text: string) => string;
293
+ /**
294
+ * 保证日志数据的统一格式,对 Nest 默认的日志输出进行格式化。
295
+ */
296
+ protected _contextNeedApologeticReplace(context: string): context is 'NestFactory' | 'NestApplication';
297
+ /**
298
+ * 保证日志数据的统一格式,对 Nest 默认的日志输出进行格式化。
299
+ */
300
+ protected _contextApologeticReplace(context: 'NestFactory' | 'NestApplication'): string;
301
+ /**
302
+ * 保证日志数据的统一格式,对 Nest 默认的日志输出进行格式化。
303
+ */
304
+ protected _messageApologeticReplace(message: unknown): unknown;
305
+ }
306
+
307
+ /**
308
+ * @public
309
+ */
310
+ export declare interface A5ConsoleLoggerConstructorOptions {
311
+ /**
312
+ * Context name for logs
313
+ *
314
+ * Default is ''
315
+ */
316
+ context?: string;
317
+ /**
318
+ * Enabled log levels.
319
+ *
320
+ * Default is @see DEFAULT_LOG_LEVELS
321
+ */
322
+ logLevels?: LogLevel[];
323
+ /**
324
+ * If enabled, will print timestamp (time difference) between current and previous log message.
325
+ *
326
+ * Default is `false`
327
+ */
328
+ timestamp?: boolean;
329
+ }
330
+
331
+ /**
332
+ * @public
333
+ */
334
+ export declare class A5ConsoleLoggerMiddleware implements NestMiddleware {
335
+ protected logger: Logger;
336
+ use(req: FastifyRequestRaw, res: FastifyReplyRaw, next: () => void): void;
337
+ }
338
+
339
+ /**
340
+ * @public
341
+ */
342
+ export declare type A5ConsoleLoggerOptions = Omit<Required<A5ConsoleLoggerConstructorOptions>, 'context'>;
343
+
344
+ /**
345
+ * @public
346
+ */
347
+ export declare const A5Factory: A5FactoryStatic;
348
+
349
+ /**
350
+ * @public
351
+ */
352
+ export declare interface A5FactoryCreateOptions {
353
+ /**
354
+ * 是否输出日志信息。可选。默认为 true
355
+ */
356
+ readonly printLogo?: boolean;
357
+ }
358
+
359
+ declare class A5FactoryStatic {
360
+ protected nestFactoryStatic: NestFactoryStatic;
361
+ constructor();
362
+ create(module: unknown, options?: A5FactoryCreateOptions): Promise<A5Application>;
363
+ }
364
+
365
+ /**
366
+ * @public
367
+ */
368
+ export declare interface A5FormatMessageInfo {
369
+ prefix: string;
370
+ pid: string;
371
+ timestamp: number;
372
+ timestampStr: string;
373
+ logLevel: string;
374
+ context: string;
375
+ output: string;
376
+ timestampDiff: number | null;
377
+ timestampDiffStr: string;
378
+ }
379
+
380
+ declare interface A5FormatMessageOptions {
381
+ logLevel: LogLevel;
382
+ context: string;
383
+ message: unknown;
384
+ }
385
+
386
+ /**
387
+ * @public
388
+ *
389
+ * `A5` 全局提供者 Token。
390
+ *
391
+ */
392
+ export declare type A5GlobalProvideToken = `Global.A5.${string}`;
393
+
394
+ /**
395
+ * @public
396
+ *
397
+ * `A5` 配置项路径。
398
+ *
399
+ */
400
+ export declare type A5ModuleConfigPath = `A5.${string}`;
401
+
402
+ /**
403
+ * @public
404
+ *
405
+ * `A5` 作用域提供者 Token。
406
+ *
407
+ */
408
+ export declare type A5ScopeProvideToken = `Scope.A5.${string}`;
409
+
410
+ /**
411
+ *
412
+ * @public
413
+ *
414
+ * 通用工具类
415
+ *
416
+ */
417
+ export declare class A5Util {
418
+ /**
419
+ *
420
+ * 睡眠。
421
+ *
422
+ * @param t - 时间。单位:毫秒
423
+ */
424
+ static sleep(t: number): Promise<void>;
425
+ /**
426
+ * @public
427
+ *
428
+ * 如果不是绝对路径,则进行拼接
429
+ *
430
+ * @param sourcePath - 资源路径
431
+ * @param basePath - 基础路径
432
+ *
433
+ * @returns 资源路径的绝对路径。
434
+ */
435
+ static tryWithAbsolutePath(sourcePath: string, basePath: string): string;
436
+ }
437
+
438
+ /**
439
+ * @public
440
+ */
441
+ export declare class ColorUtil {
442
+ static get isColorAllowed(): boolean;
443
+ static bold(text: string): string;
444
+ static red(text: string): string;
445
+ static green(text: string): string;
446
+ static yellow(text: string): string;
447
+ static blue(text: string): string;
448
+ static magenta(text: string): string;
449
+ static cyan(text: string): string;
450
+ static redBright(text: string): string;
451
+ static greenBright(text: string): string;
452
+ static yellowBright(text: string): string;
453
+ static blueBright(text: string): string;
454
+ static magentaBright(text: string): string;
455
+ static cyanBright(text: string): string;
456
+ /**
457
+ * 移除 ANSI 颜色代码
458
+ *
459
+ * @param text - text to clear
460
+ * @returns cleaned text
461
+ */
462
+ static clear(text: string): string;
463
+ }
464
+
465
+ /**
466
+ * @public
467
+ */
468
+ export declare const DEFAULT_LOG_LEVELS: LogLevel[];
469
+
470
+ /**
471
+ * @public
472
+ */
473
+ export declare const ERROR_WELCOME_MSG: string;
474
+
475
+ /**
476
+ * @public
477
+ */
478
+ export declare type FastifyReply = FastifyReply_2;
479
+
480
+ /**
481
+ * @public
482
+ */
483
+ export declare type FastifyReplyRaw = FastifyReply_2['raw'];
484
+
485
+ /**
486
+ * @public
487
+ */
488
+ export declare type FastifyRequest = FastifyRequest_2;
489
+
490
+ /**
491
+ * @public
492
+ */
493
+ export declare type FastifyRequestRaw = FastifyRequest_2['raw'];
494
+
495
+ /**
496
+ *
497
+ * @public
498
+ *
499
+ * `A5 Log Module` Global Provide Token
500
+ *
501
+ */
502
+ export declare const GLOBAL_PROVIDE_TOKEN_A5_CONFIG: A5GlobalProvideToken;
503
+
504
+ /**
505
+ *
506
+ * @public
507
+ *
508
+ * `A5 Log Module` Global Provide Token
509
+ *
510
+ */
511
+ export declare const GLOBAL_PROVIDE_TOKEN_A5_LOG_LOGGER: A5GlobalProvideToken;
512
+
513
+ /**
514
+ * @public
515
+ */
516
+ export declare const HOME_STATIC_PATH: string;
517
+
518
+ /**
519
+ *
520
+ * @public
521
+ *
522
+ * `A5 Config Module` 抽象类。
523
+ *
524
+ */
525
+ export declare abstract class IA5ConfigModule {
526
+ }
527
+
528
+ /**
529
+ *
530
+ * @public
531
+ *
532
+ * `A5 Log Module` 抽象类。
533
+ *
534
+ */
535
+ export declare abstract class IA5LogModule {
536
+ }
537
+
538
+ /**
539
+ * 包加载工具类
540
+ * 用于统一处理可选依赖的动态导入
541
+ * @public
542
+ */
543
+ export declare class LoadPackageUtil {
544
+ /**
545
+ * 动态加载包
546
+ * @param packageName - 包名
547
+ * @returns 加载的包模块
548
+ * @throws 当包加载失败时抛出错误
549
+ */
550
+ static loadPackage<T = unknown>(packageName: string): Promise<T>;
551
+ /**
552
+ * 安全地动态加载包
553
+ * @param packageName - 包名
554
+ * @returns 加载的包模块,如果失败则返回 null
555
+ */
556
+ static loadPackageSafe<T = unknown>(packageName: string): Promise<T | null>;
557
+ /**
558
+ * 带重试的动态加载包
559
+ * @param packageName - 包名
560
+ * @param retries - 重试次数,默认为 3
561
+ * @param retryDelay - 重试间隔(毫秒),默认为 100
562
+ * @returns 加载的包模块
563
+ * @throws 当所有重试都失败时抛出错误
564
+ */
565
+ static loadPackageWithRetry<T = unknown>(packageName: string, retries?: number, retryDelay?: number): Promise<T>;
566
+ }
567
+
568
+ /**
569
+ * 因 `logo` 字符串特殊字符过多,不应直接存放当前文件。
570
+ *
571
+ * 进行 base64 编码并存放。
572
+ */
573
+ /**
574
+ *
575
+ * @public
576
+ *
577
+ * 打印 Logo。
578
+ *
579
+ * logo 是在 http://patorjk.com/software/taag/#p=display&f=Big&t=a5 进行制作的。
580
+ *
581
+ */
582
+ export declare class LogoUtil {
583
+ private static _content;
584
+ /**
585
+ * Logo 的文本信息。
586
+ */
587
+ static get content(): string;
588
+ /**
589
+ *
590
+ * 打印 A5 的 Logo 及版本信息。
591
+ *
592
+ * 使用 `console.log` 输出信息,不会写入到日志文件中。
593
+ *
594
+ * @param onlyLogo - 仅打印 Logo,不包含版本信息。可选。默认为 false
595
+ *
596
+ */
597
+ static print(onlyLogo?: boolean): void;
598
+ }
599
+
600
+ /**
601
+ * @public
602
+ */
603
+ export declare const MAIN_STATIC_PATH: string;
604
+
605
+ /**
606
+ *
607
+ * @public
608
+ *
609
+ * `A5 Config Module` Config Path
610
+ *
611
+ */
612
+ export declare const MODULE_CONFIG_PATH_A5_CONFIG: <T extends string>(str: T) => `A5.config.${T}`;
613
+
614
+ /**
615
+ *
616
+ * @public
617
+ *
618
+ * `A5 Log Module` Config Path
619
+ *
620
+ */
621
+ export declare const MODULE_CONFIG_PATH_A5_LOG: <T extends string>(str: T) => `A5.log.${T}`;
622
+
623
+ export { nanoid }
624
+
625
+ /**
626
+ * @public
627
+ */
628
+ export declare type RequiredButOmit<T, K extends keyof T> = Required<Pick<T, K>> & Omit<T, K>;
629
+
630
+ /**
631
+ * @public
632
+ */
633
+ export declare type RequiredButPick<T, K extends keyof T> = Required<Omit<T, K>> & Pick<T, K>;
634
+
635
+ /**
636
+ * @public
637
+ *
638
+ * 当前运行环境。
639
+ *
640
+ */
641
+ export declare class RunEnvUtil {
642
+ /**
643
+ * 是否处于开发环境.
644
+ */
645
+ static get isDev(): boolean;
646
+ /**
647
+ * 是否处于生产环境.
648
+ */
649
+ static get isProd(): boolean;
650
+ /**
651
+ * 是否处于 PKG 打包后的环境。
652
+ */
653
+ static get inPKG(): boolean;
654
+ /**
655
+ * 是否处于 `VS Code` 的 `Debugger` 模式下。
656
+ */
657
+ static get inVSCodeDebugger(): boolean;
658
+ /**
659
+ * 是否处于 `Jest` 的单元测试环境下。
660
+ */
661
+ static get inJest(): boolean;
662
+ }
663
+
664
+ /**
665
+ * @public
666
+ */
667
+ export declare type Writable<T> = {
668
+ -readonly [P in keyof T]: T[P];
669
+ };
670
+
671
+ /**
672
+ * @public
673
+ */
674
+ export declare type WritableRequired<T> = Writable<Required<T>>;
675
+
676
+ export { }