@adaas/a-utils 0.1.14 → 0.1.16
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/README.md +92 -18
- package/dist/index.d.mts +335 -71
- package/dist/index.d.ts +335 -71
- package/dist/index.js +491 -210
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +489 -210
- package/dist/index.mjs.map +1 -1
- package/examples/{channel-examples.ts → A-Channel-examples.ts} +15 -15
- package/examples/{command-examples.ts → A-Command-examples.ts} +47 -45
- package/examples/A-Logger-examples.ts +308 -0
- package/examples/config.ts +1 -1
- package/package.json +26 -7
- package/src/index.ts +3 -1
- package/src/lib/A-Channel/A-Channel.component.ts +84 -17
- package/src/lib/A-Channel/A-Channel.error.ts +5 -5
- package/src/lib/A-Channel/A-ChannelRequest.context.ts +1 -1
- package/src/lib/A-Channel/README.md +24 -24
- package/src/lib/A-Command/A-Command.constants.ts +49 -13
- package/src/lib/A-Command/A-Command.entity.ts +21 -15
- package/src/lib/A-Command/A-Command.types.ts +2 -35
- package/src/lib/A-Config/A-Config.container.ts +3 -3
- package/src/lib/A-Config/components/ConfigReader.component.ts +4 -6
- package/src/lib/A-Logger/A-Logger.component.ts +369 -130
- package/src/lib/A-Logger/A-Logger.constants.ts +69 -0
- package/src/lib/A-Logger/A-Logger.env.ts +27 -0
- package/src/lib/A-Logger/A-Logger.types.ts +3 -0
- package/src/lib/A-Logger/README.md +383 -0
- package/src/lib/A-Manifest/A-Manifest.types.ts +1 -2
- package/src/lib/A-Memory/A-Memory.context.ts +1 -1
- package/tests/A-Channel.test.ts +14 -14
- package/tests/A-Command.test.ts +26 -26
- package/tests/A-Logger.test.ts +520 -0
- package/tests/A-Memory.test.ts +5 -5
- package/tests/A-Polyfill.test.ts +3 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,57 @@
|
|
|
1
|
-
import { A_Fragment, A_Error, A_Component, A_TYPES__Error_Serialized, A_TYPES__Entity_Serialized,
|
|
2
|
-
import { A_TYPES__Container_Constructor } from '@adaas/a-concept/dist/src/global/A-Container/A-Container.types';
|
|
1
|
+
import { A_Fragment, A_Error, A_Component, A_TYPES__Error_Serialized, A_TYPES__Entity_Serialized, A_Entity, A_Scope, A_TYPES__ConceptENVVariables, A_TYPES__Fragment_Constructor, A_Container, A_Feature, A_TYPES__Component_Constructor, A_TYPES__Entity_Constructor, A_TYPES__Container_Constructor } from '@adaas/a-concept';
|
|
3
2
|
|
|
3
|
+
declare enum A_ChannelFeatures {
|
|
4
|
+
/**
|
|
5
|
+
* Allows to extend timeout logic and behavior
|
|
6
|
+
*/
|
|
7
|
+
onTimeout = "onTimeout",
|
|
8
|
+
/**
|
|
9
|
+
* Allows to extend retry logic and behavior
|
|
10
|
+
*/
|
|
11
|
+
onRetry = "onRetry",
|
|
12
|
+
/**
|
|
13
|
+
* Allows to extend circuit breaker logic and behavior
|
|
14
|
+
*/
|
|
15
|
+
onCircuitBreakerOpen = "onCircuitBreakerOpen",
|
|
16
|
+
/**
|
|
17
|
+
* Allows to extend cache logic and behavior
|
|
18
|
+
*/
|
|
19
|
+
onCache = "onCache",
|
|
20
|
+
/**
|
|
21
|
+
* Allows to extend connection logic and behavior
|
|
22
|
+
*/
|
|
23
|
+
onConnect = "onConnect",
|
|
24
|
+
/**
|
|
25
|
+
* Allows to extend disconnection logic and behavior
|
|
26
|
+
*/
|
|
27
|
+
onDisconnect = "onDisconnect",
|
|
28
|
+
/**
|
|
29
|
+
* Allows to extend request preparation logic and behavior
|
|
30
|
+
*/
|
|
31
|
+
onBeforeRequest = "onBeforeRequest",
|
|
32
|
+
/**
|
|
33
|
+
* Allows to extend request sending logic and behavior
|
|
34
|
+
*/
|
|
35
|
+
onRequest = "onRequest",
|
|
36
|
+
/**
|
|
37
|
+
* Allows to extend request post-processing logic and behavior
|
|
38
|
+
*/
|
|
39
|
+
onAfterRequest = "onAfterRequest",
|
|
40
|
+
/**
|
|
41
|
+
* Allows to extend error handling logic and behavior
|
|
42
|
+
*
|
|
43
|
+
* [!] The same approach uses for ALL errors within the channel
|
|
44
|
+
*/
|
|
45
|
+
onError = "onError",
|
|
46
|
+
/**
|
|
47
|
+
* Allows to extend send logic and behavior
|
|
48
|
+
*/
|
|
49
|
+
onSend = "onSend",
|
|
50
|
+
/**
|
|
51
|
+
* Allows to extend consume logic and behavior
|
|
52
|
+
*/
|
|
53
|
+
onConsume = "onConsume"
|
|
54
|
+
}
|
|
4
55
|
declare enum A_ChannelRequestStatuses {
|
|
5
56
|
/**
|
|
6
57
|
* Request is pending
|
|
@@ -23,7 +74,7 @@ type A_ChannelRequestContext_Serialized<_ParamsType extends Record<string, any>
|
|
|
23
74
|
errors?: string[];
|
|
24
75
|
};
|
|
25
76
|
|
|
26
|
-
declare class
|
|
77
|
+
declare class A_ChannelRequest<_ParamsType extends Record<string, any> = Record<string, any>, _ResultType extends Record<string, any> = Record<string, any>> extends A_Fragment {
|
|
27
78
|
protected _params: _ParamsType;
|
|
28
79
|
protected _result?: _ResultType;
|
|
29
80
|
protected _errors: Set<Error>;
|
|
@@ -100,7 +151,7 @@ declare class A_ChannelRequestContext<_ParamsType extends Record<string, any> =
|
|
|
100
151
|
* class HttpProcessor extends A_Component {
|
|
101
152
|
* @A_Feature.Extend({ scope: [HttpChannel] })
|
|
102
153
|
* async [A_ChannelFeatures.onRequest](
|
|
103
|
-
* @A_Inject(
|
|
154
|
+
* @A_Inject(A_ChannelRequest) context: A_ChannelRequest
|
|
104
155
|
* ) {
|
|
105
156
|
* const response = await fetch(context.params.url);
|
|
106
157
|
* (context as any)._result = await response.json();
|
|
@@ -215,7 +266,7 @@ declare class A_Channel extends A_Component {
|
|
|
215
266
|
* ```typescript
|
|
216
267
|
* @A_Feature.Extend({ scope: [HttpChannel] })
|
|
217
268
|
* async [A_ChannelFeatures.onBeforeRequest](
|
|
218
|
-
* @A_Inject(
|
|
269
|
+
* @A_Inject(A_ChannelRequest) context: A_ChannelRequest
|
|
219
270
|
* ) {
|
|
220
271
|
* // Validate required parameters
|
|
221
272
|
* if (!context.params.url) {
|
|
@@ -240,7 +291,7 @@ declare class A_Channel extends A_Component {
|
|
|
240
291
|
* ```typescript
|
|
241
292
|
* @A_Feature.Extend({ scope: [HttpChannel] })
|
|
242
293
|
* async [A_ChannelFeatures.onRequest](
|
|
243
|
-
* @A_Inject(
|
|
294
|
+
* @A_Inject(A_ChannelRequest) context: A_ChannelRequest
|
|
244
295
|
* ) {
|
|
245
296
|
* const response = await fetch(context.params.url);
|
|
246
297
|
* (context as any)._result = await response.json();
|
|
@@ -262,7 +313,7 @@ declare class A_Channel extends A_Component {
|
|
|
262
313
|
* ```typescript
|
|
263
314
|
* @A_Feature.Extend({ scope: [HttpChannel] })
|
|
264
315
|
* async [A_ChannelFeatures.onAfterRequest](
|
|
265
|
-
* @A_Inject(
|
|
316
|
+
* @A_Inject(A_ChannelRequest) context: A_ChannelRequest
|
|
266
317
|
* ) {
|
|
267
318
|
* console.log(`Request completed in ${Date.now() - context.startTime}ms`);
|
|
268
319
|
* await this.cacheResponse(context.params, context.data);
|
|
@@ -284,7 +335,7 @@ declare class A_Channel extends A_Component {
|
|
|
284
335
|
* ```typescript
|
|
285
336
|
* @A_Feature.Extend({ scope: [HttpChannel] })
|
|
286
337
|
* async [A_ChannelFeatures.onError](
|
|
287
|
-
* @A_Inject(
|
|
338
|
+
* @A_Inject(A_ChannelRequest) context: A_ChannelRequest
|
|
288
339
|
* ) {
|
|
289
340
|
* console.error('Request failed:', context.params, context.failed);
|
|
290
341
|
* await this.logError(context);
|
|
@@ -306,7 +357,7 @@ declare class A_Channel extends A_Component {
|
|
|
306
357
|
* ```typescript
|
|
307
358
|
* @A_Feature.Extend({ scope: [EventChannel] })
|
|
308
359
|
* async [A_ChannelFeatures.onSend](
|
|
309
|
-
* @A_Inject(
|
|
360
|
+
* @A_Inject(A_ChannelRequest) context: A_ChannelRequest
|
|
310
361
|
* ) {
|
|
311
362
|
* const { eventType, payload } = context.params;
|
|
312
363
|
* await this.publishEvent(eventType, payload);
|
|
@@ -348,7 +399,7 @@ declare class A_Channel extends A_Component {
|
|
|
348
399
|
* @template _ParamsType The type of request parameters
|
|
349
400
|
* @template _ResultType The type of response data
|
|
350
401
|
* @param params The request parameters
|
|
351
|
-
* @returns {Promise<
|
|
402
|
+
* @returns {Promise<A_ChannelRequest<_ParamsType, _ResultType>>} Request context with response
|
|
352
403
|
*
|
|
353
404
|
* @example
|
|
354
405
|
* ```typescript
|
|
@@ -368,7 +419,7 @@ declare class A_Channel extends A_Component {
|
|
|
368
419
|
* }
|
|
369
420
|
* ```
|
|
370
421
|
*/
|
|
371
|
-
request<_ParamsType extends Record<string, any> = Record<string, any>, _ResultType extends Record<string, any> = Record<string, any>>(params: _ParamsType): Promise<
|
|
422
|
+
request<_ParamsType extends Record<string, any> = Record<string, any>, _ResultType extends Record<string, any> = Record<string, any>>(params: _ParamsType): Promise<A_ChannelRequest<_ParamsType, _ResultType>>;
|
|
372
423
|
/**
|
|
373
424
|
* Sends a fire-and-forget message (Send pattern).
|
|
374
425
|
*
|
|
@@ -420,12 +471,12 @@ declare class A_Channel extends A_Component {
|
|
|
420
471
|
* For fire-and-forget pattern: Use send()
|
|
421
472
|
* For consumer patterns: Implement custom consumer logic using request() in a loop
|
|
422
473
|
*/
|
|
423
|
-
consume<T extends Record<string, any> = Record<string, any>>(): Promise<
|
|
474
|
+
consume<T extends Record<string, any> = Record<string, any>>(): Promise<A_ChannelRequest<any, T>>;
|
|
424
475
|
}
|
|
425
476
|
|
|
426
477
|
declare class A_ChannelError extends A_Error {
|
|
427
478
|
static readonly MethodNotImplemented = "A-Channel Method Not Implemented";
|
|
428
|
-
protected _context?:
|
|
479
|
+
protected _context?: A_ChannelRequest;
|
|
429
480
|
/**
|
|
430
481
|
* Channel Error allows to keep track of errors within a channel if something goes wrong
|
|
431
482
|
*
|
|
@@ -433,39 +484,76 @@ declare class A_ChannelError extends A_Error {
|
|
|
433
484
|
* @param originalError
|
|
434
485
|
* @param context
|
|
435
486
|
*/
|
|
436
|
-
constructor(originalError: string | A_Error | Error | any, context?:
|
|
487
|
+
constructor(originalError: string | A_Error | Error | any, context?: A_ChannelRequest | string);
|
|
437
488
|
/***
|
|
438
489
|
* Returns Context of the error
|
|
439
490
|
*/
|
|
440
|
-
get context():
|
|
491
|
+
get context(): A_ChannelRequest | undefined;
|
|
441
492
|
}
|
|
442
493
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
ABSTRACTIONS = "a-command-abstractions"
|
|
447
|
-
}
|
|
494
|
+
/**
|
|
495
|
+
* A-Command Statuses
|
|
496
|
+
*/
|
|
448
497
|
declare enum A_CONSTANTS__A_Command_Status {
|
|
498
|
+
/**
|
|
499
|
+
* Command has been created but not yet initialized
|
|
500
|
+
*/
|
|
449
501
|
CREATED = "CREATED",
|
|
502
|
+
/**
|
|
503
|
+
* Command is initializing
|
|
504
|
+
*/
|
|
450
505
|
INITIALIZATION = "INITIALIZATION",
|
|
506
|
+
/**
|
|
507
|
+
* Command has been initialized
|
|
508
|
+
*/
|
|
451
509
|
INITIALIZED = "INITIALIZED",
|
|
510
|
+
/**
|
|
511
|
+
* Command is compiling
|
|
512
|
+
*/
|
|
452
513
|
COMPILATION = "COMPILATION",
|
|
514
|
+
/**
|
|
515
|
+
* Command is compiled
|
|
516
|
+
*/
|
|
453
517
|
COMPILED = "COMPILED",
|
|
518
|
+
/**
|
|
519
|
+
* Command is executing
|
|
520
|
+
*/
|
|
454
521
|
IN_PROGRESS = "IN_PROGRESS",
|
|
522
|
+
/**
|
|
523
|
+
* Command has completed successfully
|
|
524
|
+
*/
|
|
455
525
|
COMPLETED = "COMPLETED",
|
|
526
|
+
/**
|
|
527
|
+
* Command has failed
|
|
528
|
+
*/
|
|
456
529
|
FAILED = "FAILED"
|
|
457
530
|
}
|
|
458
531
|
/**
|
|
459
532
|
* A-Command Lifecycle Features
|
|
460
533
|
*/
|
|
461
|
-
declare enum
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
534
|
+
declare enum A_CommandFeatures {
|
|
535
|
+
/**
|
|
536
|
+
* Allows to extend initialization logic and behavior
|
|
537
|
+
*/
|
|
538
|
+
onInit = "onInit",
|
|
539
|
+
/**
|
|
540
|
+
* Allows to extend compilation logic and behavior
|
|
541
|
+
*/
|
|
542
|
+
onCompile = "onCompile",
|
|
543
|
+
/**
|
|
544
|
+
* Allows to extend execution logic and behavior
|
|
545
|
+
*/
|
|
546
|
+
onExecute = "onExecute",
|
|
547
|
+
/**
|
|
548
|
+
* Allows to extend completion logic and behavior
|
|
549
|
+
*/
|
|
550
|
+
onComplete = "onComplete",
|
|
551
|
+
/**
|
|
552
|
+
*
|
|
553
|
+
*/
|
|
554
|
+
onFail = "onFail"
|
|
467
555
|
}
|
|
468
|
-
type A_CONSTANTS__A_Command_Event =
|
|
556
|
+
type A_CONSTANTS__A_Command_Event = keyof typeof A_CommandFeatures;
|
|
469
557
|
|
|
470
558
|
/**
|
|
471
559
|
* Command constructor type
|
|
@@ -517,30 +605,6 @@ type A_TYPES__Command_Serialized<ParamsType extends Record<string, any> = Record
|
|
|
517
605
|
* Command listener type
|
|
518
606
|
*/
|
|
519
607
|
type A_TYPES__Command_Listener<InvokeType extends A_TYPES__Command_Init = A_TYPES__Command_Init, ResultType extends Record<string, any> = Record<string, any>, LifecycleEvents extends string = A_CONSTANTS__A_Command_Event> = (command?: A_Command<InvokeType, ResultType, LifecycleEvents>) => void;
|
|
520
|
-
/**
|
|
521
|
-
* Command meta type
|
|
522
|
-
*/
|
|
523
|
-
type A_TYPES__CommandMeta = {
|
|
524
|
-
[A_TYPES__CommandMetaKey.EXTENSIONS]: A_Meta<{
|
|
525
|
-
/**
|
|
526
|
-
* Where Key the regexp for what to apply the extension
|
|
527
|
-
* A set of container names or a wildcard, or a regexp
|
|
528
|
-
*
|
|
529
|
-
*
|
|
530
|
-
* Where value is the extension instructions
|
|
531
|
-
*/
|
|
532
|
-
[Key: string]: A_TYPES__FeatureExtendDecoratorMeta[];
|
|
533
|
-
}>;
|
|
534
|
-
case: any;
|
|
535
|
-
[A_TYPES__CommandMetaKey.FEATURES]: A_Meta<{
|
|
536
|
-
/**
|
|
537
|
-
* Where Key is the name of the feature
|
|
538
|
-
*
|
|
539
|
-
* Where value is the list of features
|
|
540
|
-
*/
|
|
541
|
-
[Key: string]: A_TYPES__FeatureDefineDecoratorMeta;
|
|
542
|
-
}>;
|
|
543
|
-
};
|
|
544
608
|
|
|
545
609
|
declare class A_Command<InvokeType extends A_TYPES__Command_Init = A_TYPES__Command_Init, ResultType extends Record<string, any> = Record<string, any>, LifecycleEvents extends string | A_CONSTANTS__A_Command_Event = A_CONSTANTS__A_Command_Event> extends A_Entity<InvokeType, A_TYPES__Command_Serialized<InvokeType, ResultType>> {
|
|
546
610
|
/**
|
|
@@ -789,31 +853,231 @@ declare class A_Config<T extends Array<string | A_TYPES__ConceptENVVariables[num
|
|
|
789
853
|
set(property: T[number] | A_TYPES__ConceptENVVariables[number], value: any): any;
|
|
790
854
|
}
|
|
791
855
|
|
|
856
|
+
declare const A_LoggerEnvVariables: {
|
|
857
|
+
/**
|
|
858
|
+
* Sets the log level for the logger
|
|
859
|
+
*
|
|
860
|
+
* @example 'debug', 'info', 'warn', 'error'
|
|
861
|
+
*/
|
|
862
|
+
readonly A_LOGGER_LEVEL: "A_LOGGER_LEVEL";
|
|
863
|
+
/**
|
|
864
|
+
* Sets the default scope length for log messages
|
|
865
|
+
*
|
|
866
|
+
* @example 'A_LOGGER_DEFAULT_SCOPE_LENGTH'
|
|
867
|
+
*/
|
|
868
|
+
readonly A_LOGGER_DEFAULT_SCOPE_LENGTH: "A_LOGGER_DEFAULT_SCOPE_LENGTH";
|
|
869
|
+
};
|
|
870
|
+
type A_LoggerEnvVariablesType = (typeof A_LoggerEnvVariables)[keyof typeof A_LoggerEnvVariables][];
|
|
871
|
+
|
|
872
|
+
/**
|
|
873
|
+
* A_Logger - Advanced Logging Component with Scope-based Output Formatting
|
|
874
|
+
*
|
|
875
|
+
* This component provides comprehensive logging capabilities with:
|
|
876
|
+
* - Color-coded console output for different log levels
|
|
877
|
+
* - Scope-based message formatting with consistent alignment
|
|
878
|
+
* - Support for multiple data types (objects, errors, strings)
|
|
879
|
+
* - Configurable log levels for filtering output
|
|
880
|
+
* - Special handling for A_Error and native Error objects
|
|
881
|
+
* - Timestamp inclusion for better debugging
|
|
882
|
+
*
|
|
883
|
+
* Key Features:
|
|
884
|
+
* - **Scope Integration**: Uses A_Scope for consistent message prefixing
|
|
885
|
+
* - **Color Support**: Terminal color codes for visual distinction
|
|
886
|
+
* - **Object Formatting**: Pretty-prints JSON objects with proper indentation
|
|
887
|
+
* - **Error Handling**: Special formatting for A_Error and Error objects
|
|
888
|
+
* - **Log Level Filtering**: Configurable filtering based on severity
|
|
889
|
+
* - **Multi-line Support**: Proper alignment for multi-line messages
|
|
890
|
+
*
|
|
891
|
+
* @example
|
|
892
|
+
* ```typescript
|
|
893
|
+
* // Basic usage with dependency injection
|
|
894
|
+
* class MyService {
|
|
895
|
+
* constructor(@A_Inject(A_Logger) private logger: A_Logger) {}
|
|
896
|
+
*
|
|
897
|
+
* doSomething() {
|
|
898
|
+
* this.logger.log('Processing started');
|
|
899
|
+
* this.logger.log('blue', 'Custom color message');
|
|
900
|
+
* this.logger.warning('Something might be wrong');
|
|
901
|
+
* this.logger.error(new Error('Something failed'));
|
|
902
|
+
* }
|
|
903
|
+
* }
|
|
904
|
+
*
|
|
905
|
+
* // Advanced usage with objects
|
|
906
|
+
* logger.log('green', 'User data:', { id: 1, name: 'John' });
|
|
907
|
+
* logger.error(new A_Error('VALIDATION_FAILED', 'Invalid input data'));
|
|
908
|
+
* ```
|
|
909
|
+
*/
|
|
792
910
|
declare class A_Logger extends A_Component {
|
|
793
911
|
protected scope: A_Scope;
|
|
794
|
-
protected config?: A_Config<
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
912
|
+
protected config?: A_Config<A_LoggerEnvVariablesType> | undefined;
|
|
913
|
+
/**
|
|
914
|
+
* Terminal color codes for different log levels and custom styling
|
|
915
|
+
* These codes work with ANSI escape sequences for colored terminal output
|
|
916
|
+
*/
|
|
917
|
+
readonly COLORS: any;
|
|
918
|
+
/**
|
|
919
|
+
* Standard scope length for consistent formatting
|
|
920
|
+
* This ensures all log messages align properly regardless of scope name length
|
|
921
|
+
*/
|
|
922
|
+
private readonly STANDARD_SCOPE_LENGTH;
|
|
923
|
+
/**
|
|
924
|
+
* Initialize A_Logger with dependency injection
|
|
925
|
+
*
|
|
926
|
+
* @param scope - The current scope context for message prefixing
|
|
927
|
+
* @param config - Optional configuration for log level filtering
|
|
928
|
+
*/
|
|
929
|
+
constructor(scope: A_Scope, config?: A_Config<A_LoggerEnvVariablesType> | undefined);
|
|
930
|
+
/**
|
|
931
|
+
* Get the formatted scope length for consistent message alignment
|
|
932
|
+
* Uses a standard length to ensure all messages align properly regardless of scope name
|
|
933
|
+
*
|
|
934
|
+
* @returns The scope length to use for padding calculations
|
|
935
|
+
*/
|
|
807
936
|
get scopeLength(): number;
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
937
|
+
/**
|
|
938
|
+
* Get the formatted scope name with proper padding
|
|
939
|
+
* Ensures consistent width for all scope names in log output
|
|
940
|
+
*
|
|
941
|
+
* @returns Padded scope name for consistent formatting
|
|
942
|
+
*/
|
|
943
|
+
get formattedScope(): string;
|
|
944
|
+
/**
|
|
945
|
+
* Compile log arguments into formatted console output with colors and proper alignment
|
|
946
|
+
*
|
|
947
|
+
* This method handles the core formatting logic for all log messages:
|
|
948
|
+
* - Applies terminal color codes for visual distinction
|
|
949
|
+
* - Formats scope names with consistent padding
|
|
950
|
+
* - Handles different data types appropriately
|
|
951
|
+
* - Maintains proper indentation for multi-line content
|
|
952
|
+
*
|
|
953
|
+
* @param color - The color key to apply to the message
|
|
954
|
+
* @param args - Variable arguments to format and display
|
|
955
|
+
* @returns Array of formatted strings ready for console output
|
|
956
|
+
*/
|
|
957
|
+
compile(color: keyof typeof this.COLORS, ...args: any[]): Array<string>;
|
|
958
|
+
/**
|
|
959
|
+
* Format an object for display with proper JSON indentation
|
|
960
|
+
*
|
|
961
|
+
* @param obj - The object to format
|
|
962
|
+
* @param shouldAddNewline - Whether to add a newline prefix
|
|
963
|
+
* @param scopePadding - The padding string for consistent alignment
|
|
964
|
+
* @returns Formatted object string
|
|
965
|
+
*/
|
|
966
|
+
private formatObject;
|
|
967
|
+
/**
|
|
968
|
+
* Format a string for display with proper indentation
|
|
969
|
+
*
|
|
970
|
+
* @param str - The string to format
|
|
971
|
+
* @param shouldAddNewline - Whether to add a newline prefix
|
|
972
|
+
* @param scopePadding - The padding string for consistent alignment
|
|
973
|
+
* @returns Formatted string
|
|
974
|
+
*/
|
|
975
|
+
private formatString;
|
|
976
|
+
/**
|
|
977
|
+
* Determine if a log message should be output based on configured log level
|
|
978
|
+
*
|
|
979
|
+
* Log level hierarchy:
|
|
980
|
+
* - debug: Shows all messages
|
|
981
|
+
* - info: Shows info, warning, and error messages
|
|
982
|
+
* - warn: Shows warning and error messages only
|
|
983
|
+
* - error: Shows error messages only
|
|
984
|
+
* - all: Shows all messages (alias for debug)
|
|
985
|
+
*
|
|
986
|
+
* @param logMethod - The type of log method being called
|
|
987
|
+
* @returns True if the message should be logged, false otherwise
|
|
988
|
+
*/
|
|
989
|
+
protected shouldLog(logMethod: 'log' | 'warning' | 'error'): boolean;
|
|
990
|
+
/**
|
|
991
|
+
* General purpose logging method with optional color specification
|
|
992
|
+
*
|
|
993
|
+
* Supports two usage patterns:
|
|
994
|
+
* 1. log(message, ...args) - Uses default blue color
|
|
995
|
+
* 2. log(color, message, ...args) - Uses specified color
|
|
996
|
+
*
|
|
997
|
+
* @param color - Optional color key or the first message argument
|
|
998
|
+
* @param args - Additional arguments to log
|
|
999
|
+
*
|
|
1000
|
+
* @example
|
|
1001
|
+
* ```typescript
|
|
1002
|
+
* logger.log('Hello World');
|
|
1003
|
+
* logger.log('green', 'Success message');
|
|
1004
|
+
* logger.log('Processing user:', { id: 1, name: 'John' });
|
|
1005
|
+
* ```
|
|
1006
|
+
*/
|
|
1007
|
+
log(color: keyof typeof this.COLORS, ...args: any[]): void;
|
|
1008
|
+
log(...args: any[]): void;
|
|
1009
|
+
/**
|
|
1010
|
+
* Log warning messages with yellow color coding
|
|
1011
|
+
*
|
|
1012
|
+
* Use for non-critical issues that should be brought to attention
|
|
1013
|
+
* but don't prevent normal operation
|
|
1014
|
+
*
|
|
1015
|
+
* @param args - Arguments to log as warnings
|
|
1016
|
+
*
|
|
1017
|
+
* @example
|
|
1018
|
+
* ```typescript
|
|
1019
|
+
* logger.warning('Deprecated method used');
|
|
1020
|
+
* logger.warning('Rate limit approaching:', { current: 95, limit: 100 });
|
|
1021
|
+
* ```
|
|
1022
|
+
*/
|
|
812
1023
|
warning(...args: any[]): void;
|
|
1024
|
+
/**
|
|
1025
|
+
* Log error messages with red color coding
|
|
1026
|
+
*
|
|
1027
|
+
* Use for critical issues, exceptions, and failures that need immediate attention
|
|
1028
|
+
*
|
|
1029
|
+
* @param args - Arguments to log as errors
|
|
1030
|
+
* @returns void (for compatibility with console.log)
|
|
1031
|
+
*
|
|
1032
|
+
* @example
|
|
1033
|
+
* ```typescript
|
|
1034
|
+
* logger.error('Database connection failed');
|
|
1035
|
+
* logger.error(new Error('Validation failed'));
|
|
1036
|
+
* logger.error('Critical error:', error, { context: 'user-registration' });
|
|
1037
|
+
* ```
|
|
1038
|
+
*/
|
|
813
1039
|
error(...args: any[]): void;
|
|
1040
|
+
/**
|
|
1041
|
+
* Legacy method for A_Error logging (kept for backward compatibility)
|
|
1042
|
+
*
|
|
1043
|
+
* @deprecated Use error() method instead which handles A_Error automatically
|
|
1044
|
+
* @param error - The A_Error instance to log
|
|
1045
|
+
*/
|
|
814
1046
|
protected log_A_Error(error: A_Error): void;
|
|
1047
|
+
/**
|
|
1048
|
+
* Format A_Error instances for inline display within compiled messages
|
|
1049
|
+
*
|
|
1050
|
+
* Provides detailed formatting for A_Error objects including:
|
|
1051
|
+
* - Error code and message
|
|
1052
|
+
* - Description and stack trace
|
|
1053
|
+
* - Original error information (if wrapped)
|
|
1054
|
+
* - Documentation links (if available)
|
|
1055
|
+
*
|
|
1056
|
+
* @param error - The A_Error instance to format
|
|
1057
|
+
* @returns Formatted string ready for display
|
|
1058
|
+
*/
|
|
815
1059
|
protected compile_A_Error(error: A_Error): string;
|
|
1060
|
+
/**
|
|
1061
|
+
* Format standard Error instances for inline display within compiled messages
|
|
1062
|
+
*
|
|
1063
|
+
* Converts standard JavaScript Error objects into a readable JSON format
|
|
1064
|
+
* with proper indentation and stack trace formatting
|
|
1065
|
+
*
|
|
1066
|
+
* @param error - The Error instance to format
|
|
1067
|
+
* @returns Formatted string ready for display
|
|
1068
|
+
*/
|
|
816
1069
|
protected compile_Error(error: Error): string;
|
|
1070
|
+
/**
|
|
1071
|
+
* Generate timestamp string for log messages
|
|
1072
|
+
*
|
|
1073
|
+
* Format: MM:SS:mmm (minutes:seconds:milliseconds)
|
|
1074
|
+
* This provides sufficient precision for debugging while remaining readable
|
|
1075
|
+
*
|
|
1076
|
+
* @returns Formatted timestamp string
|
|
1077
|
+
*
|
|
1078
|
+
* @example
|
|
1079
|
+
* Returns: "15:42:137" for 3:42:15 PM and 137 milliseconds
|
|
1080
|
+
*/
|
|
817
1081
|
protected getTime(): string;
|
|
818
1082
|
}
|
|
819
1083
|
|
|
@@ -1012,7 +1276,7 @@ declare class A_ConfigError extends A_Error {
|
|
|
1012
1276
|
declare class ConfigReader extends A_Component {
|
|
1013
1277
|
protected polyfill: A_Polyfill;
|
|
1014
1278
|
constructor(polyfill: A_Polyfill);
|
|
1015
|
-
attachContext(container: A_Container, feature: A_Feature): Promise<void>;
|
|
1279
|
+
attachContext(container: A_Container, feature: A_Feature, config?: A_Config): Promise<void>;
|
|
1016
1280
|
initialize(config: A_Config): Promise<void>;
|
|
1017
1281
|
/**
|
|
1018
1282
|
* Get the configuration property by Name
|
|
@@ -1190,7 +1454,7 @@ declare class A_Memory<_MemoryType extends Record<string, any> = Record<string,
|
|
|
1190
1454
|
* @param requiredKeys
|
|
1191
1455
|
* @returns
|
|
1192
1456
|
*/
|
|
1193
|
-
|
|
1457
|
+
prerequisites(requiredKeys: Array<keyof _MemoryType>): Promise<boolean>;
|
|
1194
1458
|
/**
|
|
1195
1459
|
* Adds an error to the context
|
|
1196
1460
|
*
|
|
@@ -1351,4 +1615,4 @@ declare class A_Deferred<T> {
|
|
|
1351
1615
|
reject(reason?: any): void;
|
|
1352
1616
|
}
|
|
1353
1617
|
|
|
1354
|
-
export {
|
|
1618
|
+
export { type A_CONSTANTS__A_Command_Event, A_CONSTANTS__A_Command_Status, A_CONSTANTS__CONFIG_ENV_VARIABLES, A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY, A_Channel, A_ChannelError, A_ChannelFeatures, A_ChannelRequest, type A_ChannelRequestContext_Serialized, A_ChannelRequestStatuses, A_Command, A_CommandError, A_CommandFeatures, A_Config, A_ConfigError, A_ConfigLoader, A_Deferred, A_Logger, A_Manifest, A_ManifestChecker, A_ManifestError, A_Memory, A_Polyfill, A_Schedule, A_ScheduleObject, type A_TYPES__Command_Constructor, type A_TYPES__Command_Init, type A_TYPES__Command_Listener, type A_TYPES__Command_Serialized, type A_TYPES__ConfigContainerConstructor, type A_TYPES__ConfigENVVariables, A_TYPES__ConfigFeature, type A_UTILS_TYPES__ManifestQuery, type A_UTILS_TYPES__ManifestRule, type A_UTILS_TYPES__Manifest_AllowedComponents, type A_UTILS_TYPES__Manifest_ComponentLevelConfig, type A_UTILS_TYPES__Manifest_Init, type A_UTILS_TYPES__Manifest_MethodLevelConfig, type A_UTILS_TYPES__Manifest_Rules, type A_UTILS_TYPES__ScheduleObjectCallback, type A_UTILS_TYPES__ScheduleObjectConfig, ConfigReader, ENVConfigReader, FileConfigReader, type IbufferInterface, type IcryptoInterface, type Ifspolyfill, type IhttpInterface, type IhttpsInterface, type IpathInterface, type IprocessInterface, type IurlInterface };
|