@adaas/a-utils 0.1.40 → 0.2.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.
- package/dist/index.cjs +16 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.mjs +16 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
- package/src/lib/A-Channel/A-Channel.component.ts +6 -0
- package/src/lib/A-Channel/A-ChannelRequest.context.ts +7 -0
- package/src/lib/A-Command/A-Command.entity.ts +7 -1
- package/src/lib/A-Command/A-Command.error.ts +0 -1
- package/src/lib/A-Config/A-Config.container.ts +7 -0
- package/src/lib/A-Config/A-Config.context.ts +7 -0
- package/src/lib/A-Config/components/ConfigReader.component.ts +6 -0
- package/src/lib/A-Config/components/ENVConfigReader.component.ts +7 -0
- package/src/lib/A-Config/components/FileConfigReader.component.ts +8 -0
- package/src/lib/A-Execution/A-Execution.context.ts +7 -0
- package/src/lib/A-Logger/A-Logger.component.ts +30 -24
- package/src/lib/A-Manifest/A-Manifest.context.ts +6 -0
- package/src/lib/A-Memory/A-Memory.component.ts +7 -0
- package/src/lib/A-Memory/A-Memory.context.ts +6 -0
- package/src/lib/A-Operation/A-Operation.context.ts +8 -0
- package/src/lib/A-Polyfill/A-Polyfill.component.ts +9 -0
- package/src/lib/A-Route/A-Route.entity.ts +7 -0
- package/src/lib/A-Schedule/A-Schedule.component.ts +8 -1
- package/src/lib/A-Service/A-Service.container.ts +6 -0
- package/src/lib/A-Signal/components/A-SignalBus.component.ts +6 -0
- package/src/lib/A-Signal/context/A-SignalConfig.context.ts +6 -0
- package/src/lib/A-Signal/context/A-SignalState.context.ts +6 -0
- package/src/lib/A-Signal/entities/A-Signal.entity.ts +6 -0
- package/src/lib/A-Signal/entities/A-SignalVector.entity.ts +6 -0
- package/src/lib/A-StateMachine/A-StateMachine.component.ts +11 -0
- package/src/lib/A-StateMachine/A-StateMachineTransition.context.ts +11 -5
- package/src/lib/A-Command/A-CommandExecution.context.ts +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adaas/a-utils",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "A-Utils is a set of utilities that are used across the ADAAS ecosystem. This package is designed to be a collection of utilities that are used across the ADAAS ecosystem.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -80,7 +80,8 @@
|
|
|
80
80
|
"build": "tsup --config tsup.config.ts"
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
|
-
"@adaas/a-concept": "^0.1.
|
|
83
|
+
"@adaas/a-concept": "^0.1.61",
|
|
84
|
+
"@adaas/a-frame": "^0.0.2"
|
|
84
85
|
},
|
|
85
86
|
"devDependencies": {
|
|
86
87
|
"@types/chai": "^4.3.14",
|
|
@@ -3,6 +3,7 @@ import { A_ChannelError } from "./A-Channel.error";
|
|
|
3
3
|
import { A_ChannelFeatures } from "./A-Channel.constants";
|
|
4
4
|
import { A_OperationContext } from "../A-Operation/A-Operation.context";
|
|
5
5
|
import { A_ChannelRequest } from "./A-ChannelRequest.context";
|
|
6
|
+
import { A_Frame } from "@adaas/a-frame";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* A-Channel - A powerful, extensible communication channel component
|
|
@@ -48,6 +49,11 @@ import { A_ChannelRequest } from "./A-ChannelRequest.context";
|
|
|
48
49
|
*
|
|
49
50
|
* @see {@link ./README.md} For complete documentation and examples
|
|
50
51
|
*/
|
|
52
|
+
@A_Frame.Namespace('A-Utils')
|
|
53
|
+
@A_Frame.Component({
|
|
54
|
+
name: 'A-Channel',
|
|
55
|
+
description: 'Component uses as abstract channel for communication patterns. Can be inherited and extended to implement custom channels.'
|
|
56
|
+
})
|
|
51
57
|
export class A_Channel extends A_Component {
|
|
52
58
|
|
|
53
59
|
/**
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
import { A_Frame } from "@adaas/a-frame";
|
|
1
2
|
import { A_OperationContext } from "../A-Operation/A-Operation.context";
|
|
2
3
|
import { A_ChannelRequestStatuses } from "./A-Channel.constants";
|
|
3
4
|
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@A_Frame.Fragment({
|
|
8
|
+
name: 'A-ChannelRequest',
|
|
9
|
+
description: 'Context for managing channel requests. It encapsulates the request parameters and the result including status and data.'
|
|
10
|
+
})
|
|
4
11
|
export class A_ChannelRequest<
|
|
5
12
|
_ParamsType extends Record<string, any> = Record<string, any>,
|
|
6
13
|
_ResultType extends Record<string, any> = Record<string, any>,
|
|
@@ -10,13 +10,14 @@ import {
|
|
|
10
10
|
A_CommandTransitions,
|
|
11
11
|
A_CommandEvent
|
|
12
12
|
} from "./A-Command.constants";
|
|
13
|
-
import {
|
|
13
|
+
import { A_Context, A_Dependency, A_Entity, A_Error, A_Feature, A_Inject, A_Scope } from "@adaas/a-concept";
|
|
14
14
|
import { A_CommandError } from "./A-Command.error";
|
|
15
15
|
import { A_StateMachine } from "../A-StateMachine/A-StateMachine.component";
|
|
16
16
|
import { A_StateMachineFeatures } from "../A-StateMachine/A-StateMachine.constants";
|
|
17
17
|
import { A_Logger } from "../A-Logger/A-Logger.component";
|
|
18
18
|
import { A_StateMachineTransition } from "../A-StateMachine/A-StateMachineTransition.context";
|
|
19
19
|
import { A_ExecutionContext } from "../A-Execution/A-Execution.context";
|
|
20
|
+
import { A_Frame } from "@adaas/a-frame";
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* A_Command - Advanced Command Pattern Implementation
|
|
@@ -77,6 +78,11 @@ import { A_ExecutionContext } from "../A-Execution/A-Execution.context";
|
|
|
77
78
|
* console.log('Status:', command.status);
|
|
78
79
|
* ```
|
|
79
80
|
*/
|
|
81
|
+
@A_Frame.Entity({
|
|
82
|
+
namespace: 'A-Utils',
|
|
83
|
+
name: 'A-Command',
|
|
84
|
+
description: 'Advanced Command Pattern Implementation with full lifecycle management, event handling, and state persistence. This entity allows to execute commands in distributed environment across multiple services.'
|
|
85
|
+
})
|
|
80
86
|
export class A_Command<
|
|
81
87
|
InvokeType extends A_TYPES__Command_Init = A_TYPES__Command_Init,
|
|
82
88
|
ResultType extends Record<string, any> = Record<string, any>,
|
|
@@ -6,8 +6,15 @@ import { A_ConfigError } from "./A-Config.error";
|
|
|
6
6
|
import { FileConfigReader } from "./components/FileConfigReader.component";
|
|
7
7
|
import { ENVConfigReader } from "./components/ENVConfigReader.component";
|
|
8
8
|
import { A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY } from "./A-Config.constants";
|
|
9
|
+
import { A_Frame } from "@adaas/a-frame";
|
|
9
10
|
|
|
10
11
|
|
|
12
|
+
|
|
13
|
+
@A_Frame.Container({
|
|
14
|
+
namespace: 'A-Utils',
|
|
15
|
+
name: 'A-ConfigLoader',
|
|
16
|
+
description: 'Container responsible for loading and initializing the A_Config component based on the environment and available configuration sources. It can be useful for application that need a separated configuration management and sharable across multiple containers.'
|
|
17
|
+
})
|
|
11
18
|
export class A_ConfigLoader extends A_Container {
|
|
12
19
|
|
|
13
20
|
private reader!: ConfigReader
|
|
@@ -3,8 +3,15 @@ import { A_TYPES__ConfigContainerConstructor } from "./A-Config.types";
|
|
|
3
3
|
import { A_ExecutionContext } from "../A-Execution/A-Execution.context";
|
|
4
4
|
import { A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY } from "./A-Config.constants";
|
|
5
5
|
import { A_ConfigError } from "./A-Config.error";
|
|
6
|
+
import { A_Frame } from "@adaas/a-frame";
|
|
6
7
|
|
|
7
8
|
|
|
9
|
+
|
|
10
|
+
@A_Frame.Fragment({
|
|
11
|
+
namespace: 'A-Utils',
|
|
12
|
+
name: 'A-Config',
|
|
13
|
+
description: 'Configuration management context that provides structured access to application configuration variables, supporting defaults and strict mode for enhanced reliability. Default environment variables are included for comprehensive configuration handling.'
|
|
14
|
+
})
|
|
8
15
|
export class A_Config<
|
|
9
16
|
T extends Array<string | A_TYPES__ConceptENVVariables[number]> = any[]
|
|
10
17
|
> extends A_ExecutionContext<
|
|
@@ -3,10 +3,16 @@ import { A_Config } from "../A-Config.context";
|
|
|
3
3
|
import { A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY } from "../A-Config.constants";
|
|
4
4
|
import { A_Polyfill } from "../../A-Polyfill/A-Polyfill.component";
|
|
5
5
|
import { A_Memory } from "../../A-Memory/A-Memory.component";
|
|
6
|
+
import { A_Frame } from "@adaas/a-frame";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Config Reader
|
|
9
10
|
*/
|
|
11
|
+
@A_Frame.Component({
|
|
12
|
+
namespace: 'A-Utils',
|
|
13
|
+
name: 'ConfigReader',
|
|
14
|
+
description: 'Abstract component for reading configuration data from various sources such as files, environment variables, or remote services. This component can be extended to implement specific configuration reading strategies.'
|
|
15
|
+
})
|
|
10
16
|
export class ConfigReader extends A_Component {
|
|
11
17
|
|
|
12
18
|
protected DEFAULT_ALLOWED_TO_READ_PROPERTIES = [
|
|
@@ -2,8 +2,15 @@ import { A_Concept, A_Feature, A_FormatterHelper, A_Inject, A_TYPES__ConceptENVV
|
|
|
2
2
|
import { ConfigReader } from "./ConfigReader.component";
|
|
3
3
|
import { A_Config } from "../A-Config.context";
|
|
4
4
|
import { A_Polyfill } from "../../A-Polyfill/A-Polyfill.component";
|
|
5
|
+
import { A_Frame } from "@adaas/a-frame";
|
|
5
6
|
|
|
6
7
|
|
|
8
|
+
|
|
9
|
+
@A_Frame.Component({
|
|
10
|
+
namespace: 'A-Utils',
|
|
11
|
+
name: 'ENVConfigReader',
|
|
12
|
+
description: 'Configuration reader that sources configuration data from environment variables. It supports loading variables from a .env file and maps them to the configuration context, making it suitable for applications running in diverse environments such as local development, staging, and production.'
|
|
13
|
+
})
|
|
7
14
|
export class ENVConfigReader extends ConfigReader {
|
|
8
15
|
|
|
9
16
|
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { A_Context, A_FormatterHelper } from "@adaas/a-concept";
|
|
2
2
|
import { ConfigReader } from "./ConfigReader.component";
|
|
3
|
+
import { A_Frame } from "@adaas/a-frame";
|
|
3
4
|
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@A_Frame.Component({
|
|
8
|
+
namespace: 'A-Utils',
|
|
9
|
+
name: 'FileConfigReader',
|
|
10
|
+
description: 'Configuration reader that loads configuration data from a JSON file located in the application root directory. It reads the file named after the current concept with a .conf.json extension and parses its contents into the configuration context.'
|
|
11
|
+
})
|
|
4
12
|
export class FileConfigReader extends ConfigReader {
|
|
5
13
|
|
|
6
14
|
private FileData: Map<string, any> = new Map<string, any>();
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { A_Fragment, A_Meta, A_TYPES__Fragment_Serialized } from "@adaas/a-concept";
|
|
2
|
+
import { A_Frame } from "@adaas/a-frame";
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
|
|
6
|
+
|
|
7
|
+
@A_Frame.Fragment({
|
|
8
|
+
namespace: 'A-Utils',
|
|
9
|
+
name: 'A-ExecutionContext',
|
|
10
|
+
description: 'Execution context fragment that provides a structured way to manage metadata and serialized data for execution environments. It allows storing and retrieving key-value pairs, facilitating context-aware operations within the application. It useful in cases when it\'s necessary to share some runtime data across multiple steps of thee features, or components.'
|
|
11
|
+
})
|
|
5
12
|
export class A_ExecutionContext<
|
|
6
13
|
_MetaType extends Record<string, any> = Record<string, any>,
|
|
7
14
|
_SerializedType extends Record<string, any> = Record<string, any>
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
A_LOGGER_SAFE_RANDOM_COLORS,
|
|
13
13
|
A_LOGGER_TERMINAL
|
|
14
14
|
} from "./A-Logger.constants";
|
|
15
|
+
import { A_Frame } from "@adaas/a-frame";
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* A_Logger - Advanced Logging Component with Scope-based Output Formatting
|
|
@@ -78,6 +79,11 @@ import {
|
|
|
78
79
|
* const logger = new A_Logger(scope, config);
|
|
79
80
|
* ```
|
|
80
81
|
*/
|
|
82
|
+
@A_Frame.Component({
|
|
83
|
+
namespace: 'A-Utils',
|
|
84
|
+
name: 'A_Logger',
|
|
85
|
+
description: 'Advanced Logging Component with Scope-based Output Formatting that provides color-coded console output, multi-type support, and configurable log levels for enhanced debugging and monitoring.'
|
|
86
|
+
})
|
|
81
87
|
export class A_Logger extends A_Component {
|
|
82
88
|
|
|
83
89
|
// =============================================
|
|
@@ -277,10 +283,10 @@ export class A_Logger extends A_Component {
|
|
|
277
283
|
// Continuation lines: terminal_width - scope_padding - pipe_length
|
|
278
284
|
const scopeHeaderLength = this.formattedScope.length + 4 + this.getTime().length + 4; // [scope] |time|
|
|
279
285
|
const continuationIndent = `${scopePadding}${A_LOGGER_FORMAT.PIPE}`;
|
|
280
|
-
|
|
286
|
+
|
|
281
287
|
const firstLineMaxWidth = Math.max(this.TERMINAL_WIDTH - scopeHeaderLength - 1, 20); // -1 for space
|
|
282
288
|
const continuationMaxWidth = Math.max(this.TERMINAL_WIDTH - continuationIndent.length, 20);
|
|
283
|
-
|
|
289
|
+
|
|
284
290
|
// If text fits on first line, return as is
|
|
285
291
|
if (isFirstLine && text.length <= firstLineMaxWidth) {
|
|
286
292
|
return [text];
|
|
@@ -496,14 +502,14 @@ export class A_Logger extends A_Component {
|
|
|
496
502
|
// Apply terminal width wrapping to long JSON string values
|
|
497
503
|
const continuationIndent = `${scopePadding}${A_LOGGER_FORMAT.PIPE}`;
|
|
498
504
|
const maxJsonLineWidth = this.TERMINAL_WIDTH - continuationIndent.length - 4; // -4 for JSON indentation
|
|
499
|
-
|
|
505
|
+
|
|
500
506
|
// Split into lines and wrap long string values
|
|
501
507
|
const lines = jsonString.split('\n').map(line => {
|
|
502
508
|
// Check if this line contains a long string value
|
|
503
509
|
const stringValueMatch = line.match(/^(\s*"[^"]+":\s*")([^"]+)(".*)?$/);
|
|
504
510
|
if (stringValueMatch && stringValueMatch[2].length > maxJsonLineWidth - stringValueMatch[1].length - (stringValueMatch[3] || '').length) {
|
|
505
511
|
const [, prefix, value, suffix = ''] = stringValueMatch;
|
|
506
|
-
|
|
512
|
+
|
|
507
513
|
// Wrap the string value if it's too long
|
|
508
514
|
if (value.length > maxJsonLineWidth - prefix.length - suffix.length) {
|
|
509
515
|
const wrappedValue = this.wrapJsonStringValue(value, maxJsonLineWidth - prefix.length - suffix.length);
|
|
@@ -528,7 +534,7 @@ export class A_Logger extends A_Component {
|
|
|
528
534
|
if (value.length <= maxWidth) {
|
|
529
535
|
return value;
|
|
530
536
|
}
|
|
531
|
-
|
|
537
|
+
|
|
532
538
|
// For JSON string values, truncate with ellipsis to maintain JSON validity
|
|
533
539
|
// This prevents the JSON from becoming unreadable due to excessive wrapping
|
|
534
540
|
// while still showing the most important part of the string
|
|
@@ -558,7 +564,7 @@ export class A_Logger extends A_Component {
|
|
|
558
564
|
// For terminal, apply intelligent text wrapping
|
|
559
565
|
const wrappedLines = this.wrapText(str, scopePadding, !shouldAddNewline);
|
|
560
566
|
const continuationIndent = `${scopePadding}${A_LOGGER_FORMAT.PIPE}`;
|
|
561
|
-
|
|
567
|
+
|
|
562
568
|
// Format the wrapped lines with proper indentation
|
|
563
569
|
const formattedLines = wrappedLines.map((line, index) => {
|
|
564
570
|
if (index === 0 && !shouldAddNewline) {
|
|
@@ -569,7 +575,7 @@ export class A_Logger extends A_Component {
|
|
|
569
575
|
return `${continuationIndent}${line}`;
|
|
570
576
|
}
|
|
571
577
|
});
|
|
572
|
-
|
|
578
|
+
|
|
573
579
|
if (shouldAddNewline) {
|
|
574
580
|
return '\n' + formattedLines.join('\n');
|
|
575
581
|
} else {
|
|
@@ -795,30 +801,30 @@ ${scopePadding}|-------------------------------
|
|
|
795
801
|
lines.push(separator);
|
|
796
802
|
lines.push(`${continuationIndent}A_ERROR: ${error.code}`);
|
|
797
803
|
lines.push(separator);
|
|
798
|
-
|
|
804
|
+
|
|
799
805
|
// Format and wrap error message and description
|
|
800
806
|
const errorMessage = this.wrapText(`Message: ${error.message}`, continuationIndent, false);
|
|
801
807
|
const errorDescription = this.wrapText(`Description: ${error.description}`, continuationIndent, false);
|
|
802
|
-
|
|
808
|
+
|
|
803
809
|
lines.push(...errorMessage.map(line => `${continuationIndent}${line}`));
|
|
804
810
|
lines.push(...errorDescription.map(line => `${continuationIndent}${line}`));
|
|
805
|
-
|
|
811
|
+
|
|
806
812
|
// Show original error FIRST (more important for debugging)
|
|
807
813
|
if (error.originalError) {
|
|
808
814
|
lines.push(separator);
|
|
809
815
|
lines.push(`${continuationIndent}ORIGINAL ERROR:`);
|
|
810
816
|
lines.push(separator);
|
|
811
|
-
|
|
817
|
+
|
|
812
818
|
const originalMessage = this.wrapText(`${error.originalError.name}: ${error.originalError.message}`, continuationIndent, false);
|
|
813
819
|
lines.push(...originalMessage.map(line => `${continuationIndent}${line}`));
|
|
814
|
-
|
|
820
|
+
|
|
815
821
|
if (error.originalError.stack) {
|
|
816
822
|
lines.push(`${continuationIndent}Stack trace:`);
|
|
817
823
|
const stackLines = this.formatStackTrace(error.originalError.stack, continuationIndent);
|
|
818
824
|
lines.push(...stackLines);
|
|
819
825
|
}
|
|
820
826
|
}
|
|
821
|
-
|
|
827
|
+
|
|
822
828
|
// Then show A_Error stack trace
|
|
823
829
|
if (error.stack) {
|
|
824
830
|
lines.push(separator);
|
|
@@ -827,16 +833,16 @@ ${scopePadding}|-------------------------------
|
|
|
827
833
|
const stackLines = this.formatStackTrace(error.stack, continuationIndent);
|
|
828
834
|
lines.push(...stackLines);
|
|
829
835
|
}
|
|
830
|
-
|
|
836
|
+
|
|
831
837
|
// Documentation link at the end
|
|
832
838
|
if (error.link) {
|
|
833
839
|
lines.push(separator);
|
|
834
840
|
const linkText = this.wrapText(`Documentation: ${error.link}`, continuationIndent, false);
|
|
835
841
|
lines.push(...linkText.map(line => `${continuationIndent}${line}`));
|
|
836
842
|
}
|
|
837
|
-
|
|
843
|
+
|
|
838
844
|
lines.push(separator);
|
|
839
|
-
|
|
845
|
+
|
|
840
846
|
return lines.join('\n');
|
|
841
847
|
}
|
|
842
848
|
|
|
@@ -850,20 +856,20 @@ ${scopePadding}|-------------------------------
|
|
|
850
856
|
private formatStackTrace(stack: string, baseIndent: string): string[] {
|
|
851
857
|
const stackLines = stack.split('\n');
|
|
852
858
|
const formatted: string[] = [];
|
|
853
|
-
|
|
859
|
+
|
|
854
860
|
stackLines.forEach((line, index) => {
|
|
855
861
|
if (line.trim()) {
|
|
856
862
|
// Add extra indentation for stack trace lines
|
|
857
863
|
const stackIndent = index === 0 ? baseIndent : `${baseIndent} `;
|
|
858
864
|
const wrappedLines = this.wrapText(line.trim(), stackIndent, false);
|
|
859
|
-
formatted.push(...wrappedLines.map(wrappedLine =>
|
|
860
|
-
index === 0 && wrappedLine === wrappedLines[0]
|
|
865
|
+
formatted.push(...wrappedLines.map(wrappedLine =>
|
|
866
|
+
index === 0 && wrappedLine === wrappedLines[0]
|
|
861
867
|
? `${baseIndent}${wrappedLine}`
|
|
862
868
|
: `${baseIndent} ${wrappedLine}`
|
|
863
869
|
));
|
|
864
870
|
}
|
|
865
871
|
});
|
|
866
|
-
|
|
872
|
+
|
|
867
873
|
return formatted;
|
|
868
874
|
}
|
|
869
875
|
|
|
@@ -888,11 +894,11 @@ ${scopePadding}|-------------------------------
|
|
|
888
894
|
lines.push(separator);
|
|
889
895
|
lines.push(`${continuationIndent}ERROR: ${error.name}`);
|
|
890
896
|
lines.push(separator);
|
|
891
|
-
|
|
897
|
+
|
|
892
898
|
// Format and wrap error message
|
|
893
899
|
const errorMessage = this.wrapText(`Message: ${error.message}`, continuationIndent, false);
|
|
894
900
|
lines.push(...errorMessage.map(line => `${continuationIndent}${line}`));
|
|
895
|
-
|
|
901
|
+
|
|
896
902
|
// Format stack trace if available
|
|
897
903
|
if (error.stack) {
|
|
898
904
|
lines.push(separator);
|
|
@@ -901,9 +907,9 @@ ${scopePadding}|-------------------------------
|
|
|
901
907
|
const stackLines = this.formatStackTrace(error.stack, continuationIndent);
|
|
902
908
|
lines.push(...stackLines);
|
|
903
909
|
}
|
|
904
|
-
|
|
910
|
+
|
|
905
911
|
lines.push(separator);
|
|
906
|
-
|
|
912
|
+
|
|
907
913
|
return lines.join('\n');
|
|
908
914
|
}
|
|
909
915
|
|
|
@@ -2,11 +2,17 @@ import { A_Component, A_Fragment, A_TypeGuards, A_TYPES__Component_Constructor }
|
|
|
2
2
|
import { A_UTILS_TYPES__Manifest_Init, A_UTILS_TYPES__Manifest_ComponentLevelConfig, A_UTILS_TYPES__Manifest_AllowedComponents, A_UTILS_TYPES__ManifestRule, A_UTILS_TYPES__ManifestQuery } from "./A-Manifest.types";
|
|
3
3
|
import { A_ManifestError } from "./A-Manifest.error";
|
|
4
4
|
import { A_ManifestChecker } from "./classes/A-ManifestChecker.class";
|
|
5
|
+
import { A_Frame } from "@adaas/a-frame";
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
|
|
11
|
+
@A_Frame.Fragment({
|
|
12
|
+
namespace: 'A-Utils',
|
|
13
|
+
name: 'A-Manifest',
|
|
14
|
+
description: 'A-Manifest is a configuration fragment that allows to include or exclude component application for particular methods. It provides fine-grained control over which components are applied to which targets and methods within the application, enabling flexible and dynamic behavior based on defined rules.'
|
|
15
|
+
})
|
|
10
16
|
export class A_Manifest extends A_Fragment {
|
|
11
17
|
|
|
12
18
|
private rules: A_UTILS_TYPES__ManifestRule[] = [];
|
|
@@ -4,8 +4,15 @@ import { A_MemoryContext } from "./A-Memory.context";
|
|
|
4
4
|
import { A_MemoryError } from "./A-Memory.error";
|
|
5
5
|
import { A_OperationContext } from "../A-Operation/A-Operation.context";
|
|
6
6
|
import { A_MemoryOperationContext } from "./A-Memory.types";
|
|
7
|
+
import { A_Frame } from "@adaas/a-frame";
|
|
7
8
|
|
|
8
9
|
|
|
10
|
+
|
|
11
|
+
@A_Frame.Component({
|
|
12
|
+
namespace: 'A-Utils',
|
|
13
|
+
name: 'A-Memory',
|
|
14
|
+
description: 'In-memory data storage component that provides a simple key-value store with asynchronous operations. It supports basic memory operations such as get, set, has, drop, and clear, along with lifecycle management and error handling features. This components features can be extended with other components to provide ability store data across multiple storage, or extract data from multiple external sources. Good example is to store some runtime data that needs to be shared across multiple containers or concepts.'
|
|
15
|
+
})
|
|
9
16
|
export class A_Memory<
|
|
10
17
|
_StorageType extends Record<string, any> = Record<string, any>,
|
|
11
18
|
_SerializedType extends Record<string, any> = Record<string, any>
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { A_Error, A_Fragment, A_TYPES__Fragment_Serialized } from "@adaas/a-concept";
|
|
2
|
+
import { A_Frame } from "@adaas/a-frame";
|
|
2
3
|
import { error } from "console";
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
|
|
8
|
+
@A_Frame.Fragment({
|
|
9
|
+
namespace: 'A-Utils',
|
|
10
|
+
name: 'A-MemoryContext',
|
|
11
|
+
description: 'In-memory context fragment that provides a simple key-value store for temporary data storage during application runtime. It allows setting, getting, deleting, and checking the existence of key-value pairs, facilitating quick access to transient data without persistent storage. This context is useful for scenarios where data needs to be shared across different components or operations within the same execution context.'
|
|
12
|
+
})
|
|
7
13
|
export class A_MemoryContext<
|
|
8
14
|
_MemoryType extends Record<string, any> = Record<string, any>,
|
|
9
15
|
_SerializedType extends A_TYPES__Fragment_Serialized = A_TYPES__Fragment_Serialized
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { A_Error, A_Fragment } from "@adaas/a-concept";
|
|
2
2
|
import { A_Operation_Serialized, A_Operation_Storage } from "./A-Operation.types";
|
|
3
3
|
import { A_ExecutionContext } from "../A-Execution/A-Execution.context";
|
|
4
|
+
import { A_Frame } from "@adaas/a-frame";
|
|
4
5
|
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@A_Frame.Fragment({
|
|
9
|
+
namespace: 'A-Utils',
|
|
10
|
+
name: 'A-OperationContext',
|
|
11
|
+
description: 'Operation execution context that encapsulates the metadata and serialized data related to a specific operation. It provides structured access to operation parameters, results, and error handling, facilitating the management of operation lifecycles within the application.'
|
|
12
|
+
})
|
|
5
13
|
export class A_OperationContext<
|
|
6
14
|
_AllowedOperations extends string = string,
|
|
7
15
|
_ParamsType extends Record<string, any> = Record<string, any>,
|
|
@@ -8,7 +8,16 @@ import { A_PathPolyfillClass } from "./classes/A-Path-Polyfill.class";
|
|
|
8
8
|
import { A_UrlPolyfillClass } from "./classes/A-Url-Polyfill.class";
|
|
9
9
|
import { A_BufferPolyfillClass } from "./classes/A-Buffer-Polyfill.class";
|
|
10
10
|
import { A_ProcessPolyfillClass } from "./classes/A-Process-Polyfill.class";
|
|
11
|
+
import { A_Frame } from "@adaas/a-frame";
|
|
11
12
|
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@A_Frame.Component({
|
|
17
|
+
namespace: 'A-Utils',
|
|
18
|
+
name: 'A-Polyfill',
|
|
19
|
+
description: 'Polyfill component that provides cross-environment compatibility for Node.js core modules such as fs, crypto, http, https, path, url, buffer, and process. It dynamically loads appropriate polyfills based on the execution environment (Node.js or browser), enabling seamless usage of these modules in different contexts.'
|
|
20
|
+
})
|
|
12
21
|
export class A_Polyfill extends A_Component {
|
|
13
22
|
|
|
14
23
|
protected _fsPolyfill!: A_FSPolyfillClass;
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { A_Fragment } from '@adaas/a-concept';
|
|
2
|
+
import { A_Frame } from '@adaas/a-frame';
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
|
|
6
|
+
|
|
7
|
+
@A_Frame.Fragment({
|
|
8
|
+
namespace: 'A-Utils',
|
|
9
|
+
name: 'A-Route',
|
|
10
|
+
description: 'Route fragment that defines URL patterns for routing purposes. It supports dynamic parameters and query extraction, allowing for flexible route definitions. This fragment can be used in routing systems to match incoming URLs against defined routes and extract relevant parameters and query strings.'
|
|
11
|
+
})
|
|
5
12
|
export class A_Route<
|
|
6
13
|
_TParams extends Record<string, any> = Record<string, any>,
|
|
7
14
|
_TQuery extends Record<string, any> = Record<string, any>
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import { A_Component, A_TypeGuards } from "@adaas/a-concept";
|
|
1
|
+
import { A_Component, A_Fragment, A_TypeGuards } from "@adaas/a-concept";
|
|
2
2
|
import { A_ScheduleObject } from "./A-ScheduleObject.class";
|
|
3
3
|
import { A_UTILS_TYPES__ScheduleObjectCallback, A_UTILS_TYPES__ScheduleObjectConfig } from "./A-Schedule.types";
|
|
4
|
+
import { A_Frame } from "@adaas/a-frame";
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
|
|
8
|
+
|
|
9
|
+
@A_Frame.Component({
|
|
10
|
+
namespace: 'A-Utils',
|
|
11
|
+
name: 'A-Schedule',
|
|
12
|
+
description: 'Scheduling component that allows scheduling of callbacks to be executed at specific times or after certain delays. It provides methods to schedule callbacks based on Unix timestamps or ISO date strings, as well as a method to execute callbacks after a specified delay in milliseconds. This component is useful for managing timed operations within an application.'
|
|
13
|
+
})
|
|
7
14
|
export class A_Schedule extends A_Component {
|
|
8
15
|
|
|
9
16
|
/**
|
|
@@ -4,6 +4,7 @@ import { A_Polyfill } from "../A-Polyfill/A-Polyfill.component";
|
|
|
4
4
|
import { A_Config } from "../A-Config/A-Config.context";
|
|
5
5
|
import { A_Logger } from "../A-Logger/A-Logger.component";
|
|
6
6
|
import { A_Service_Error } from "./A-Service.error";
|
|
7
|
+
import { A_Frame } from "@adaas/a-frame";
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
|
|
@@ -13,6 +14,11 @@ import { A_Service_Error } from "./A-Service.error";
|
|
|
13
14
|
* Depending on the provided config and configuration, it will load the necessary components and start the service.
|
|
14
15
|
*
|
|
15
16
|
*/
|
|
17
|
+
@A_Frame.Container({
|
|
18
|
+
namespace: 'A-Utils',
|
|
19
|
+
name: 'A-Service',
|
|
20
|
+
description: 'Service container that manages the lifecycle of various types of services, such as HTTP servers and workers or UI loader. It dynamically loads necessary components based on the provided configuration and orchestrates the start and stop processes, ensuring proper error handling and extensibility through feature hooks.'
|
|
21
|
+
})
|
|
16
22
|
export class A_Service extends A_Container {
|
|
17
23
|
|
|
18
24
|
|
|
@@ -5,6 +5,7 @@ import { A_SignalConfig } from "../context/A-SignalConfig.context";
|
|
|
5
5
|
import { A_Config } from "../../A-Config/A-Config.context";
|
|
6
6
|
import { A_Logger } from "../../A-Logger/A-Logger.component";
|
|
7
7
|
import { A_Signal } from "../entities/A-Signal.entity";
|
|
8
|
+
import { A_Frame } from "@adaas/a-frame";
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
|
|
@@ -18,6 +19,11 @@ import { A_Signal } from "../entities/A-Signal.entity";
|
|
|
18
19
|
*
|
|
19
20
|
* The component itself is stateless and all methods uses only parameters (context) is provided with.
|
|
20
21
|
*/
|
|
22
|
+
@A_Frame.Component({
|
|
23
|
+
namespace: 'A-Utils',
|
|
24
|
+
name: 'A-SignalBus',
|
|
25
|
+
description: 'Signal bus component that manages the emission and state of signals within a given scope. It listens for emitted signals, updates their state, and forwards them to registered watchers. The bus ensures a consistent signal vector structure based on the defined configuration, facilitating signal management across multiple components.'
|
|
26
|
+
})
|
|
21
27
|
export class A_SignalBus extends A_Component {
|
|
22
28
|
|
|
23
29
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { A_CommonHelper, A_Context, A_Fragment, A_TYPES__Component_Constructor, A_TYPES__Entity_Constructor } from "@adaas/a-concept";
|
|
2
2
|
import { A_SignalConfig_Init } from "../A-Signal.types";
|
|
3
3
|
import { A_Signal } from "../entities/A-Signal.entity";
|
|
4
|
+
import { A_Frame } from "@adaas/a-frame";
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
|
|
@@ -11,6 +12,11 @@ import { A_Signal } from "../entities/A-Signal.entity";
|
|
|
11
12
|
* e.g. [A_RouterWatcher, A_ScopeWatcher, A_LoggerWatcher]
|
|
12
13
|
* This structure then should be used for any further processing of signals within the scope.
|
|
13
14
|
*/
|
|
15
|
+
@A_Frame.Fragment({
|
|
16
|
+
namespace: 'A-Utils',
|
|
17
|
+
name: 'A-SignalConfig',
|
|
18
|
+
description: 'Signal configuration fragment that defines the structure and types of signals within a given scope. It allows specifying the expected signal constructors and their order, facilitating consistent signal management and processing across components that emit or listen to signals.'
|
|
19
|
+
})
|
|
14
20
|
export class A_SignalConfig extends A_Fragment {
|
|
15
21
|
|
|
16
22
|
protected _structure?: Array<A_TYPES__Entity_Constructor<A_Signal>>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { A_Context, A_Fragment, A_TYPES__Component_Constructor } from "@adaas/a-concept";
|
|
2
2
|
import { A_Signal } from "../entities/A-Signal.entity";
|
|
3
3
|
import { A_SignalVector } from "../entities/A-SignalVector.entity";
|
|
4
|
+
import { A_Frame } from "@adaas/a-frame";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* A_SignalState manages the latest state of all signals within a given scope.
|
|
@@ -15,6 +16,11 @@ import { A_SignalVector } from "../entities/A-SignalVector.entity";
|
|
|
15
16
|
* - Signal instances and their emitted value types
|
|
16
17
|
* - Vector structure and the data it contains
|
|
17
18
|
*/
|
|
19
|
+
@A_Frame.Fragment({
|
|
20
|
+
namespace: 'A-Utils',
|
|
21
|
+
name: 'A-SignalState',
|
|
22
|
+
description: 'Manages the latest state of all signals within a given scope, maintaining a mapping between signal constructors and their most recently emitted values.'
|
|
23
|
+
})
|
|
18
24
|
export class A_SignalState<
|
|
19
25
|
TSignalData extends Record<string, any> = Record<string, any>
|
|
20
26
|
> extends A_Fragment {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { A_Entity, A_Scope } from "@adaas/a-concept";
|
|
2
2
|
import { A_Signal_Init, A_Signal_Serialized } from "../A-Signal.types";
|
|
3
3
|
import { A_SignalFeatures } from "../A-Signal.constants";
|
|
4
|
+
import { A_Frame } from "@adaas/a-frame";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* A Signal Entity is an individual signal instance that carries data.
|
|
@@ -15,6 +16,11 @@ import { A_SignalFeatures } from "../A-Signal.constants";
|
|
|
15
16
|
* Signals are typically used in scenarios where the current state is more important than individual events,
|
|
16
17
|
* such as monitoring systems, real-time dashboards, or stateful applications.
|
|
17
18
|
*/
|
|
19
|
+
@A_Frame.Entity({
|
|
20
|
+
namespace: 'A-Utils',
|
|
21
|
+
name: 'A-Signal',
|
|
22
|
+
description: 'A Signal Entity represents an individual signal instance that carries data, used for managing state within an application context. Signals are designed to reflect the current state rather than individual events, making them suitable for scenarios where state monitoring and real-time updates are essential.'
|
|
23
|
+
})
|
|
18
24
|
export class A_Signal<
|
|
19
25
|
_TSignalDataType extends Record<string, any> = Record<string, any>
|
|
20
26
|
> extends A_Entity<A_Signal_Init<_TSignalDataType>, A_Signal_Serialized<_TSignalDataType>> {
|
|
@@ -2,6 +2,7 @@ import { A_Entity, A_Scope, A_TYPES__Component_Constructor, A_TYPES__Entity_Cons
|
|
|
2
2
|
import { A_SignalVector_Serialized, A_SignalVector_Init } from "../A-Signal.types";
|
|
3
3
|
import { A_Signal } from "./A-Signal.entity";
|
|
4
4
|
import { A_SignalVectorFeatures } from "../A-Signal.constants";
|
|
5
|
+
import { A_Frame } from "@adaas/a-frame";
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -14,6 +15,11 @@ import { A_SignalVectorFeatures } from "../A-Signal.constants";
|
|
|
14
15
|
* @template TSignalsConstructors - Array of signal constructor types (e.g., [typeof MySignal, typeof CustomSignal])
|
|
15
16
|
* @template TSignals - Array of signal instances derived from constructors
|
|
16
17
|
*/
|
|
18
|
+
@A_Frame.Entity({
|
|
19
|
+
namespace: 'A-Utils',
|
|
20
|
+
name: 'A-SignalVector',
|
|
21
|
+
description: 'A Signal Vector Entity represents a collection of signals structured in a specific way, allowing for batch processing and transmission of related signals as a unified state representation.'
|
|
22
|
+
})
|
|
17
23
|
export class A_SignalVector<
|
|
18
24
|
TSignals extends Array<A_Signal> = Array<A_Signal>,
|
|
19
25
|
TSignalsConstructors extends Array<A_TYPES__Entity_Constructor<A_Signal>> = TSignals extends Array<infer U> ? U extends A_Signal ? A_TYPES__Entity_Constructor<U>[] : never : never
|