@adaas/a-utils 0.1.21 → 0.1.22
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 +5 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +66 -21
- package/dist/index.d.ts +66 -21
- package/dist/index.mjs +5 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +6 -0
- package/src/lib/A-Command/A-Command.entity.ts +21 -4
- package/src/lib/A-Command/A-Command.types.ts +19 -11
- package/src/lib/A-Config/A-Config.context.ts +38 -59
- package/src/lib/A-Config/components/ConfigReader.component.ts +17 -15
- package/src/lib/A-Execution/A-Execution.context.ts +67 -0
- package/src/lib/A-Execution/A-Execution.types.ts +0 -0
- package/src/lib/A-Memory/A-Memory.component.ts +1 -1
- package/src/lib/A-Memory/A-Memory.context.ts +18 -9
- package/src/lib/A-Memory/A-Memory.types.ts +12 -1
- package/src/lib/A-Operation/A-Operation.context.ts +3 -2
- package/tests/A-Config.test.ts +5 -11
- package/tests/A-Manifest.test.ts +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A_Error, A_TYPES__Error_Serialized, A_Fragment, A_Component, A_TYPES__Entity_Serialized, A_TYPES__ConceptENVVariables, A_TYPES__Fragment_Constructor, A_Scope, A_Entity, A_Container, A_Feature, A_TYPES__Component_Constructor, A_TYPES__Entity_Constructor, A_TYPES__Container_Constructor
|
|
1
|
+
import { A_Error, A_TYPES__Error_Serialized, A_Fragment, A_Meta, A_TYPES__Fragment_Serialized, A_Component, A_TYPES__Entity_Serialized, A_TYPES__ConceptENVVariables, A_TYPES__Fragment_Constructor, A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY, A_Scope, A_Entity, A_Container, A_Feature, A_TYPES__Component_Constructor, A_TYPES__Entity_Constructor, A_TYPES__Container_Constructor } from '@adaas/a-concept';
|
|
2
2
|
|
|
3
3
|
type A_Operation_Storage<_Result_type extends any = any, _ParamsType extends Record<string, any> = Record<string, any>> = {
|
|
4
4
|
/**
|
|
@@ -37,7 +37,21 @@ type A_Operation_Serialized<_Result_type extends any = any, _ParamsType extends
|
|
|
37
37
|
error?: A_TYPES__Error_Serialized;
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
declare class
|
|
40
|
+
declare class A_ExecutionContext<_MetaType extends Record<string, any> = Record<string, any>, _SerializedType extends Record<string, any> = Record<string, any>> extends A_Fragment {
|
|
41
|
+
protected _meta: A_Meta<_MetaType, _SerializedType>;
|
|
42
|
+
constructor(name: string, defaults?: Partial<_MetaType>);
|
|
43
|
+
[Symbol.iterator](): Iterator<[keyof _MetaType, _MetaType[keyof _MetaType]]>;
|
|
44
|
+
get meta(): A_Meta<_MetaType>;
|
|
45
|
+
get(key: keyof _MetaType): _MetaType[keyof _MetaType] | undefined;
|
|
46
|
+
set(key: keyof _MetaType, value: _MetaType[keyof _MetaType]): void;
|
|
47
|
+
has(key: keyof _MetaType): boolean;
|
|
48
|
+
drop(key: keyof _MetaType): void;
|
|
49
|
+
clear(): void;
|
|
50
|
+
toRaw(): _SerializedType;
|
|
51
|
+
toJSON(): A_TYPES__Fragment_Serialized;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
declare class A_OperationContext<_AllowedOperations extends string = string, _ParamsType extends Record<string, any> = Record<string, any>, _ResultType = any, _StorageType extends A_Operation_Storage<_ResultType, _ParamsType> = A_Operation_Storage<_ResultType, _ParamsType>> extends A_ExecutionContext<_StorageType, A_Operation_Serialized<_ResultType, _ParamsType>> {
|
|
41
55
|
constructor(operation: _AllowedOperations, params?: _ParamsType);
|
|
42
56
|
get name(): _AllowedOperations;
|
|
43
57
|
get result(): _ResultType | undefined;
|
|
@@ -706,6 +720,10 @@ type A_TYPES__Command_Serialized<ParamsType extends Record<string, any> = Record
|
|
|
706
720
|
* ```
|
|
707
721
|
*/
|
|
708
722
|
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_Command_Event> = (command?: A_Command<InvokeType, ResultType, LifecycleEvents>) => void;
|
|
723
|
+
type A_Command_ExecutionContext<InvokeType extends A_TYPES__Command_Init = A_TYPES__Command_Init, ResultType extends Record<string, any> = Record<string, any>> = {
|
|
724
|
+
result: ResultType;
|
|
725
|
+
params: InvokeType;
|
|
726
|
+
};
|
|
709
727
|
|
|
710
728
|
declare enum A_StateMachineFeatures {
|
|
711
729
|
/**
|
|
@@ -921,20 +939,28 @@ type A_TYPES__ConfigContainerConstructor<T extends Array<string | A_TYPES__Conce
|
|
|
921
939
|
};
|
|
922
940
|
} & A_TYPES__Fragment_Constructor;
|
|
923
941
|
|
|
924
|
-
declare
|
|
942
|
+
declare const A_CONSTANTS__CONFIG_ENV_VARIABLES: {};
|
|
943
|
+
type A_TYPES__ConfigENVVariables = (typeof A_CONSTANTS__CONFIG_ENV_VARIABLES)[keyof typeof A_CONSTANTS__CONFIG_ENV_VARIABLES][];
|
|
944
|
+
declare const A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY: readonly [];
|
|
945
|
+
|
|
946
|
+
declare class A_Config<T extends Array<string | A_TYPES__ConceptENVVariables[number]> = any[]> extends A_ExecutionContext<{
|
|
925
947
|
[key in T[number]]: any;
|
|
948
|
+
} & {
|
|
949
|
+
[key in typeof A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY[number]]: any;
|
|
950
|
+
} & {
|
|
951
|
+
[key in typeof A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY[number]]: any;
|
|
926
952
|
}> {
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
CONFIG_PROPERTIES: T;
|
|
953
|
+
protected _strict: boolean;
|
|
954
|
+
protected _configProperties: T;
|
|
930
955
|
protected DEFAULT_ALLOWED_TO_READ_PROPERTIES: ("A_CONCEPT_NAME" | "A_CONCEPT_ROOT_SCOPE" | "A_CONCEPT_ENVIRONMENT" | "A_CONCEPT_ROOT_FOLDER" | "A_ERROR_DEFAULT_DESCRIPTION")[];
|
|
931
956
|
constructor(config: Partial<A_TYPES__ConfigContainerConstructor<T>>);
|
|
957
|
+
get strict(): boolean;
|
|
932
958
|
/**
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
959
|
+
* This method is used to get the configuration property by name
|
|
960
|
+
*
|
|
961
|
+
* @param property
|
|
962
|
+
* @returns
|
|
963
|
+
*/
|
|
938
964
|
get<K extends T[number]>(property: K | typeof this.DEFAULT_ALLOWED_TO_READ_PROPERTIES[number]): {
|
|
939
965
|
[key in T[number]]: any;
|
|
940
966
|
}[K] | undefined;
|
|
@@ -1402,6 +1428,10 @@ declare class A_Command<InvokeType extends A_TYPES__Command_Init = A_TYPES__Comm
|
|
|
1402
1428
|
* command was registered.
|
|
1403
1429
|
*/
|
|
1404
1430
|
get scope(): A_Scope;
|
|
1431
|
+
/**
|
|
1432
|
+
* Execution context associated with the command
|
|
1433
|
+
*/
|
|
1434
|
+
get context(): A_ExecutionContext<A_Command_ExecutionContext<InvokeType, ResultType>>;
|
|
1405
1435
|
/**
|
|
1406
1436
|
* Unique command type identifier
|
|
1407
1437
|
*
|
|
@@ -1504,7 +1534,7 @@ declare class A_Command<InvokeType extends A_TYPES__Command_Init = A_TYPES__Comm
|
|
|
1504
1534
|
protected [A_CommandFeatures.onExecute](...args: any[]): Promise<void>;
|
|
1505
1535
|
protected [A_CommandFeatures.onAfterExecute](...args: any[]): Promise<void>;
|
|
1506
1536
|
protected [A_CommandFeatures.onComplete](stateMachine: A_StateMachine, ...args: any[]): Promise<void>;
|
|
1507
|
-
protected [A_CommandFeatures.onFail](stateMachine: A_StateMachine, operation:
|
|
1537
|
+
protected [A_CommandFeatures.onFail](stateMachine: A_StateMachine, operation: A_ExecutionContext<A_Command_ExecutionContext<InvokeType, ResultType>>, ...args: any[]): Promise<void>;
|
|
1508
1538
|
/**
|
|
1509
1539
|
* Initializes the command before execution.
|
|
1510
1540
|
*/
|
|
@@ -1515,6 +1545,16 @@ declare class A_Command<InvokeType extends A_TYPES__Command_Init = A_TYPES__Comm
|
|
|
1515
1545
|
execute(): Promise<any>;
|
|
1516
1546
|
/**
|
|
1517
1547
|
* Marks the command as completed
|
|
1548
|
+
*
|
|
1549
|
+
*
|
|
1550
|
+
* Calling This method will set the command status to COMPLETED, record the end time,
|
|
1551
|
+
* store the result, emit the onComplete event, and destroy the execution scope.
|
|
1552
|
+
*
|
|
1553
|
+
* [!] After Calling this method, the command is considered fully processed And further processing will be INTERRUPTED.
|
|
1554
|
+
* [!] If the command is already processed (COMPLETED or FAILED), this method does nothing.
|
|
1555
|
+
* [!] This method can be called with optional result data to store with the command.
|
|
1556
|
+
*
|
|
1557
|
+
* @param result - Optional result data to store with the command
|
|
1518
1558
|
*/
|
|
1519
1559
|
complete(result?: ResultType): Promise<void>;
|
|
1520
1560
|
/**
|
|
@@ -1831,8 +1871,9 @@ declare class A_ConfigError extends A_Error {
|
|
|
1831
1871
|
*/
|
|
1832
1872
|
declare class ConfigReader extends A_Component {
|
|
1833
1873
|
protected polyfill: A_Polyfill;
|
|
1874
|
+
protected DEFAULT_ALLOWED_TO_READ_PROPERTIES: ("A_CONCEPT_NAME" | "A_CONCEPT_ROOT_SCOPE" | "A_CONCEPT_ENVIRONMENT" | "A_CONCEPT_ROOT_FOLDER" | "A_ERROR_DEFAULT_DESCRIPTION")[];
|
|
1834
1875
|
constructor(polyfill: A_Polyfill);
|
|
1835
|
-
attachContext(container: A_Container,
|
|
1876
|
+
attachContext(container: A_Container, context: A_Scope, config?: A_Config<any>): Promise<void>;
|
|
1836
1877
|
initialize(config: A_Config): Promise<void>;
|
|
1837
1878
|
/**
|
|
1838
1879
|
* Get the configuration property by Name
|
|
@@ -1876,10 +1917,6 @@ declare class FileConfigReader extends ConfigReader {
|
|
|
1876
1917
|
read<T extends string>(variables?: Array<T>): Promise<Record<T, any>>;
|
|
1877
1918
|
}
|
|
1878
1919
|
|
|
1879
|
-
declare const A_CONSTANTS__CONFIG_ENV_VARIABLES: {};
|
|
1880
|
-
type A_TYPES__ConfigENVVariables = (typeof A_CONSTANTS__CONFIG_ENV_VARIABLES)[keyof typeof A_CONSTANTS__CONFIG_ENV_VARIABLES][];
|
|
1881
|
-
declare const A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY: readonly [];
|
|
1882
|
-
|
|
1883
1920
|
type A_LoggerLevel = 'debug' | 'info' | 'warn' | 'error' | 'all';
|
|
1884
1921
|
|
|
1885
1922
|
/**
|
|
@@ -2123,11 +2160,13 @@ declare enum A_MemoryFeatures {
|
|
|
2123
2160
|
onHas = "onHas"
|
|
2124
2161
|
}
|
|
2125
2162
|
|
|
2126
|
-
declare class A_MemoryContext<_MemoryType extends Record<string, any> = Record<string, any>, _SerializedType extends A_TYPES__Fragment_Serialized = A_TYPES__Fragment_Serialized> extends A_Fragment
|
|
2127
|
-
|
|
2163
|
+
declare class A_MemoryContext<_MemoryType extends Record<string, any> = Record<string, any>, _SerializedType extends A_TYPES__Fragment_Serialized = A_TYPES__Fragment_Serialized> extends A_Fragment {
|
|
2164
|
+
protected _storage: Map<keyof _MemoryType, _MemoryType[keyof _MemoryType]>;
|
|
2128
2165
|
set<K extends keyof _MemoryType>(param: K, value: _MemoryType[K]): void;
|
|
2129
|
-
get<K extends keyof A_Error>(param: 'error'): A_Error | undefined;
|
|
2130
2166
|
get<K extends keyof _MemoryType>(param: K): _MemoryType[K] | undefined;
|
|
2167
|
+
delete<K extends keyof _MemoryType>(param: K): void;
|
|
2168
|
+
has<K extends keyof _MemoryType>(param: K): boolean;
|
|
2169
|
+
clear(): void;
|
|
2131
2170
|
}
|
|
2132
2171
|
|
|
2133
2172
|
type A_MemoryContextMeta<T extends Record<string, any> = Record<string, any>> = Omit<T, 'error'> & {
|
|
@@ -2141,6 +2180,12 @@ type A_MemoryOperationContext<T extends any = any> = A_OperationContext<A_Memory
|
|
|
2141
2180
|
key: string;
|
|
2142
2181
|
value?: any;
|
|
2143
2182
|
}, T>;
|
|
2183
|
+
type A_MemoryOperationContextMeta<T extends any = any, I extends any = any> = {
|
|
2184
|
+
result: T;
|
|
2185
|
+
operation: A_MemoryOperations;
|
|
2186
|
+
key: string;
|
|
2187
|
+
value?: I;
|
|
2188
|
+
};
|
|
2144
2189
|
|
|
2145
2190
|
declare class A_Memory<_StorageType extends Record<string, any> = Record<string, any>, _SerializedType extends Record<string, any> = Record<string, any>> extends A_Component {
|
|
2146
2191
|
protected _ready?: Promise<void>;
|
|
@@ -2340,4 +2385,4 @@ declare class A_StateMachineError extends A_Error {
|
|
|
2340
2385
|
static readonly TransitionError = "A-StateMachine Transition Error";
|
|
2341
2386
|
}
|
|
2342
2387
|
|
|
2343
|
-
export { A_CONSTANTS__CONFIG_ENV_VARIABLES, A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY, A_Channel, A_ChannelError, A_ChannelFeatures, A_ChannelRequest, A_ChannelRequestStatuses, A_Command, A_CommandError, A_CommandFeatures, A_CommandTransitions, type A_Command_Event, A_Command_Status, A_Config, A_ConfigError, A_ConfigLoader, A_Deferred, A_LOGGER_ANSI, A_LOGGER_COLORS, A_LOGGER_DEFAULT_LEVEL, A_LOGGER_DEFAULT_SCOPE_LENGTH, A_LOGGER_ENV_KEYS, A_LOGGER_FORMAT, A_LOGGER_SAFE_RANDOM_COLORS, A_LOGGER_TIME_FORMAT, A_Logger, A_LoggerEnvVariables, A_LoggerEnvVariablesArray, type A_LoggerEnvVariablesType, type A_LoggerLevel, A_Manifest, A_ManifestChecker, A_ManifestError, A_Memory, A_MemoryContext, type A_MemoryContextMeta, A_MemoryError, A_MemoryFeatures, type A_MemoryOperationContext, type A_MemoryOperations, type A_Memory_Storage, A_OperationContext, type A_Operation_Serialized, type A_Operation_Storage, A_Polyfill, A_Schedule, A_ScheduleObject, A_StateMachine, A_StateMachineError, A_StateMachineFeatures, A_StateMachineTransition, type A_StateMachineTransitionParams, type A_StateMachineTransitionStorage, 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 };
|
|
2388
|
+
export { A_CONSTANTS__CONFIG_ENV_VARIABLES, A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY, A_Channel, A_ChannelError, A_ChannelFeatures, A_ChannelRequest, A_ChannelRequestStatuses, A_Command, A_CommandError, A_CommandFeatures, A_CommandTransitions, type A_Command_Event, type A_Command_ExecutionContext, A_Command_Status, A_Config, A_ConfigError, A_ConfigLoader, A_Deferred, A_ExecutionContext, A_LOGGER_ANSI, A_LOGGER_COLORS, A_LOGGER_DEFAULT_LEVEL, A_LOGGER_DEFAULT_SCOPE_LENGTH, A_LOGGER_ENV_KEYS, A_LOGGER_FORMAT, A_LOGGER_SAFE_RANDOM_COLORS, A_LOGGER_TIME_FORMAT, A_Logger, A_LoggerEnvVariables, A_LoggerEnvVariablesArray, type A_LoggerEnvVariablesType, type A_LoggerLevel, A_Manifest, A_ManifestChecker, A_ManifestError, A_Memory, A_MemoryContext, type A_MemoryContextMeta, A_MemoryError, A_MemoryFeatures, type A_MemoryOperationContext, type A_MemoryOperationContextMeta, type A_MemoryOperations, type A_Memory_Storage, A_OperationContext, type A_Operation_Serialized, type A_Operation_Storage, A_Polyfill, A_Schedule, A_ScheduleObject, A_StateMachine, A_StateMachineError, A_StateMachineFeatures, A_StateMachineTransition, type A_StateMachineTransitionParams, type A_StateMachineTransitionStorage, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A_Error, A_TYPES__Error_Serialized, A_Fragment, A_Component, A_TYPES__Entity_Serialized, A_TYPES__ConceptENVVariables, A_TYPES__Fragment_Constructor, A_Scope, A_Entity, A_Container, A_Feature, A_TYPES__Component_Constructor, A_TYPES__Entity_Constructor, A_TYPES__Container_Constructor
|
|
1
|
+
import { A_Error, A_TYPES__Error_Serialized, A_Fragment, A_Meta, A_TYPES__Fragment_Serialized, A_Component, A_TYPES__Entity_Serialized, A_TYPES__ConceptENVVariables, A_TYPES__Fragment_Constructor, A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY, A_Scope, A_Entity, A_Container, A_Feature, A_TYPES__Component_Constructor, A_TYPES__Entity_Constructor, A_TYPES__Container_Constructor } from '@adaas/a-concept';
|
|
2
2
|
|
|
3
3
|
type A_Operation_Storage<_Result_type extends any = any, _ParamsType extends Record<string, any> = Record<string, any>> = {
|
|
4
4
|
/**
|
|
@@ -37,7 +37,21 @@ type A_Operation_Serialized<_Result_type extends any = any, _ParamsType extends
|
|
|
37
37
|
error?: A_TYPES__Error_Serialized;
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
declare class
|
|
40
|
+
declare class A_ExecutionContext<_MetaType extends Record<string, any> = Record<string, any>, _SerializedType extends Record<string, any> = Record<string, any>> extends A_Fragment {
|
|
41
|
+
protected _meta: A_Meta<_MetaType, _SerializedType>;
|
|
42
|
+
constructor(name: string, defaults?: Partial<_MetaType>);
|
|
43
|
+
[Symbol.iterator](): Iterator<[keyof _MetaType, _MetaType[keyof _MetaType]]>;
|
|
44
|
+
get meta(): A_Meta<_MetaType>;
|
|
45
|
+
get(key: keyof _MetaType): _MetaType[keyof _MetaType] | undefined;
|
|
46
|
+
set(key: keyof _MetaType, value: _MetaType[keyof _MetaType]): void;
|
|
47
|
+
has(key: keyof _MetaType): boolean;
|
|
48
|
+
drop(key: keyof _MetaType): void;
|
|
49
|
+
clear(): void;
|
|
50
|
+
toRaw(): _SerializedType;
|
|
51
|
+
toJSON(): A_TYPES__Fragment_Serialized;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
declare class A_OperationContext<_AllowedOperations extends string = string, _ParamsType extends Record<string, any> = Record<string, any>, _ResultType = any, _StorageType extends A_Operation_Storage<_ResultType, _ParamsType> = A_Operation_Storage<_ResultType, _ParamsType>> extends A_ExecutionContext<_StorageType, A_Operation_Serialized<_ResultType, _ParamsType>> {
|
|
41
55
|
constructor(operation: _AllowedOperations, params?: _ParamsType);
|
|
42
56
|
get name(): _AllowedOperations;
|
|
43
57
|
get result(): _ResultType | undefined;
|
|
@@ -706,6 +720,10 @@ type A_TYPES__Command_Serialized<ParamsType extends Record<string, any> = Record
|
|
|
706
720
|
* ```
|
|
707
721
|
*/
|
|
708
722
|
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_Command_Event> = (command?: A_Command<InvokeType, ResultType, LifecycleEvents>) => void;
|
|
723
|
+
type A_Command_ExecutionContext<InvokeType extends A_TYPES__Command_Init = A_TYPES__Command_Init, ResultType extends Record<string, any> = Record<string, any>> = {
|
|
724
|
+
result: ResultType;
|
|
725
|
+
params: InvokeType;
|
|
726
|
+
};
|
|
709
727
|
|
|
710
728
|
declare enum A_StateMachineFeatures {
|
|
711
729
|
/**
|
|
@@ -921,20 +939,28 @@ type A_TYPES__ConfigContainerConstructor<T extends Array<string | A_TYPES__Conce
|
|
|
921
939
|
};
|
|
922
940
|
} & A_TYPES__Fragment_Constructor;
|
|
923
941
|
|
|
924
|
-
declare
|
|
942
|
+
declare const A_CONSTANTS__CONFIG_ENV_VARIABLES: {};
|
|
943
|
+
type A_TYPES__ConfigENVVariables = (typeof A_CONSTANTS__CONFIG_ENV_VARIABLES)[keyof typeof A_CONSTANTS__CONFIG_ENV_VARIABLES][];
|
|
944
|
+
declare const A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY: readonly [];
|
|
945
|
+
|
|
946
|
+
declare class A_Config<T extends Array<string | A_TYPES__ConceptENVVariables[number]> = any[]> extends A_ExecutionContext<{
|
|
925
947
|
[key in T[number]]: any;
|
|
948
|
+
} & {
|
|
949
|
+
[key in typeof A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY[number]]: any;
|
|
950
|
+
} & {
|
|
951
|
+
[key in typeof A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY[number]]: any;
|
|
926
952
|
}> {
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
CONFIG_PROPERTIES: T;
|
|
953
|
+
protected _strict: boolean;
|
|
954
|
+
protected _configProperties: T;
|
|
930
955
|
protected DEFAULT_ALLOWED_TO_READ_PROPERTIES: ("A_CONCEPT_NAME" | "A_CONCEPT_ROOT_SCOPE" | "A_CONCEPT_ENVIRONMENT" | "A_CONCEPT_ROOT_FOLDER" | "A_ERROR_DEFAULT_DESCRIPTION")[];
|
|
931
956
|
constructor(config: Partial<A_TYPES__ConfigContainerConstructor<T>>);
|
|
957
|
+
get strict(): boolean;
|
|
932
958
|
/**
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
959
|
+
* This method is used to get the configuration property by name
|
|
960
|
+
*
|
|
961
|
+
* @param property
|
|
962
|
+
* @returns
|
|
963
|
+
*/
|
|
938
964
|
get<K extends T[number]>(property: K | typeof this.DEFAULT_ALLOWED_TO_READ_PROPERTIES[number]): {
|
|
939
965
|
[key in T[number]]: any;
|
|
940
966
|
}[K] | undefined;
|
|
@@ -1402,6 +1428,10 @@ declare class A_Command<InvokeType extends A_TYPES__Command_Init = A_TYPES__Comm
|
|
|
1402
1428
|
* command was registered.
|
|
1403
1429
|
*/
|
|
1404
1430
|
get scope(): A_Scope;
|
|
1431
|
+
/**
|
|
1432
|
+
* Execution context associated with the command
|
|
1433
|
+
*/
|
|
1434
|
+
get context(): A_ExecutionContext<A_Command_ExecutionContext<InvokeType, ResultType>>;
|
|
1405
1435
|
/**
|
|
1406
1436
|
* Unique command type identifier
|
|
1407
1437
|
*
|
|
@@ -1504,7 +1534,7 @@ declare class A_Command<InvokeType extends A_TYPES__Command_Init = A_TYPES__Comm
|
|
|
1504
1534
|
protected [A_CommandFeatures.onExecute](...args: any[]): Promise<void>;
|
|
1505
1535
|
protected [A_CommandFeatures.onAfterExecute](...args: any[]): Promise<void>;
|
|
1506
1536
|
protected [A_CommandFeatures.onComplete](stateMachine: A_StateMachine, ...args: any[]): Promise<void>;
|
|
1507
|
-
protected [A_CommandFeatures.onFail](stateMachine: A_StateMachine, operation:
|
|
1537
|
+
protected [A_CommandFeatures.onFail](stateMachine: A_StateMachine, operation: A_ExecutionContext<A_Command_ExecutionContext<InvokeType, ResultType>>, ...args: any[]): Promise<void>;
|
|
1508
1538
|
/**
|
|
1509
1539
|
* Initializes the command before execution.
|
|
1510
1540
|
*/
|
|
@@ -1515,6 +1545,16 @@ declare class A_Command<InvokeType extends A_TYPES__Command_Init = A_TYPES__Comm
|
|
|
1515
1545
|
execute(): Promise<any>;
|
|
1516
1546
|
/**
|
|
1517
1547
|
* Marks the command as completed
|
|
1548
|
+
*
|
|
1549
|
+
*
|
|
1550
|
+
* Calling This method will set the command status to COMPLETED, record the end time,
|
|
1551
|
+
* store the result, emit the onComplete event, and destroy the execution scope.
|
|
1552
|
+
*
|
|
1553
|
+
* [!] After Calling this method, the command is considered fully processed And further processing will be INTERRUPTED.
|
|
1554
|
+
* [!] If the command is already processed (COMPLETED or FAILED), this method does nothing.
|
|
1555
|
+
* [!] This method can be called with optional result data to store with the command.
|
|
1556
|
+
*
|
|
1557
|
+
* @param result - Optional result data to store with the command
|
|
1518
1558
|
*/
|
|
1519
1559
|
complete(result?: ResultType): Promise<void>;
|
|
1520
1560
|
/**
|
|
@@ -1831,8 +1871,9 @@ declare class A_ConfigError extends A_Error {
|
|
|
1831
1871
|
*/
|
|
1832
1872
|
declare class ConfigReader extends A_Component {
|
|
1833
1873
|
protected polyfill: A_Polyfill;
|
|
1874
|
+
protected DEFAULT_ALLOWED_TO_READ_PROPERTIES: ("A_CONCEPT_NAME" | "A_CONCEPT_ROOT_SCOPE" | "A_CONCEPT_ENVIRONMENT" | "A_CONCEPT_ROOT_FOLDER" | "A_ERROR_DEFAULT_DESCRIPTION")[];
|
|
1834
1875
|
constructor(polyfill: A_Polyfill);
|
|
1835
|
-
attachContext(container: A_Container,
|
|
1876
|
+
attachContext(container: A_Container, context: A_Scope, config?: A_Config<any>): Promise<void>;
|
|
1836
1877
|
initialize(config: A_Config): Promise<void>;
|
|
1837
1878
|
/**
|
|
1838
1879
|
* Get the configuration property by Name
|
|
@@ -1876,10 +1917,6 @@ declare class FileConfigReader extends ConfigReader {
|
|
|
1876
1917
|
read<T extends string>(variables?: Array<T>): Promise<Record<T, any>>;
|
|
1877
1918
|
}
|
|
1878
1919
|
|
|
1879
|
-
declare const A_CONSTANTS__CONFIG_ENV_VARIABLES: {};
|
|
1880
|
-
type A_TYPES__ConfigENVVariables = (typeof A_CONSTANTS__CONFIG_ENV_VARIABLES)[keyof typeof A_CONSTANTS__CONFIG_ENV_VARIABLES][];
|
|
1881
|
-
declare const A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY: readonly [];
|
|
1882
|
-
|
|
1883
1920
|
type A_LoggerLevel = 'debug' | 'info' | 'warn' | 'error' | 'all';
|
|
1884
1921
|
|
|
1885
1922
|
/**
|
|
@@ -2123,11 +2160,13 @@ declare enum A_MemoryFeatures {
|
|
|
2123
2160
|
onHas = "onHas"
|
|
2124
2161
|
}
|
|
2125
2162
|
|
|
2126
|
-
declare class A_MemoryContext<_MemoryType extends Record<string, any> = Record<string, any>, _SerializedType extends A_TYPES__Fragment_Serialized = A_TYPES__Fragment_Serialized> extends A_Fragment
|
|
2127
|
-
|
|
2163
|
+
declare class A_MemoryContext<_MemoryType extends Record<string, any> = Record<string, any>, _SerializedType extends A_TYPES__Fragment_Serialized = A_TYPES__Fragment_Serialized> extends A_Fragment {
|
|
2164
|
+
protected _storage: Map<keyof _MemoryType, _MemoryType[keyof _MemoryType]>;
|
|
2128
2165
|
set<K extends keyof _MemoryType>(param: K, value: _MemoryType[K]): void;
|
|
2129
|
-
get<K extends keyof A_Error>(param: 'error'): A_Error | undefined;
|
|
2130
2166
|
get<K extends keyof _MemoryType>(param: K): _MemoryType[K] | undefined;
|
|
2167
|
+
delete<K extends keyof _MemoryType>(param: K): void;
|
|
2168
|
+
has<K extends keyof _MemoryType>(param: K): boolean;
|
|
2169
|
+
clear(): void;
|
|
2131
2170
|
}
|
|
2132
2171
|
|
|
2133
2172
|
type A_MemoryContextMeta<T extends Record<string, any> = Record<string, any>> = Omit<T, 'error'> & {
|
|
@@ -2141,6 +2180,12 @@ type A_MemoryOperationContext<T extends any = any> = A_OperationContext<A_Memory
|
|
|
2141
2180
|
key: string;
|
|
2142
2181
|
value?: any;
|
|
2143
2182
|
}, T>;
|
|
2183
|
+
type A_MemoryOperationContextMeta<T extends any = any, I extends any = any> = {
|
|
2184
|
+
result: T;
|
|
2185
|
+
operation: A_MemoryOperations;
|
|
2186
|
+
key: string;
|
|
2187
|
+
value?: I;
|
|
2188
|
+
};
|
|
2144
2189
|
|
|
2145
2190
|
declare class A_Memory<_StorageType extends Record<string, any> = Record<string, any>, _SerializedType extends Record<string, any> = Record<string, any>> extends A_Component {
|
|
2146
2191
|
protected _ready?: Promise<void>;
|
|
@@ -2340,4 +2385,4 @@ declare class A_StateMachineError extends A_Error {
|
|
|
2340
2385
|
static readonly TransitionError = "A-StateMachine Transition Error";
|
|
2341
2386
|
}
|
|
2342
2387
|
|
|
2343
|
-
export { A_CONSTANTS__CONFIG_ENV_VARIABLES, A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY, A_Channel, A_ChannelError, A_ChannelFeatures, A_ChannelRequest, A_ChannelRequestStatuses, A_Command, A_CommandError, A_CommandFeatures, A_CommandTransitions, type A_Command_Event, A_Command_Status, A_Config, A_ConfigError, A_ConfigLoader, A_Deferred, A_LOGGER_ANSI, A_LOGGER_COLORS, A_LOGGER_DEFAULT_LEVEL, A_LOGGER_DEFAULT_SCOPE_LENGTH, A_LOGGER_ENV_KEYS, A_LOGGER_FORMAT, A_LOGGER_SAFE_RANDOM_COLORS, A_LOGGER_TIME_FORMAT, A_Logger, A_LoggerEnvVariables, A_LoggerEnvVariablesArray, type A_LoggerEnvVariablesType, type A_LoggerLevel, A_Manifest, A_ManifestChecker, A_ManifestError, A_Memory, A_MemoryContext, type A_MemoryContextMeta, A_MemoryError, A_MemoryFeatures, type A_MemoryOperationContext, type A_MemoryOperations, type A_Memory_Storage, A_OperationContext, type A_Operation_Serialized, type A_Operation_Storage, A_Polyfill, A_Schedule, A_ScheduleObject, A_StateMachine, A_StateMachineError, A_StateMachineFeatures, A_StateMachineTransition, type A_StateMachineTransitionParams, type A_StateMachineTransitionStorage, 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 };
|
|
2388
|
+
export { A_CONSTANTS__CONFIG_ENV_VARIABLES, A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY, A_Channel, A_ChannelError, A_ChannelFeatures, A_ChannelRequest, A_ChannelRequestStatuses, A_Command, A_CommandError, A_CommandFeatures, A_CommandTransitions, type A_Command_Event, type A_Command_ExecutionContext, A_Command_Status, A_Config, A_ConfigError, A_ConfigLoader, A_Deferred, A_ExecutionContext, A_LOGGER_ANSI, A_LOGGER_COLORS, A_LOGGER_DEFAULT_LEVEL, A_LOGGER_DEFAULT_SCOPE_LENGTH, A_LOGGER_ENV_KEYS, A_LOGGER_FORMAT, A_LOGGER_SAFE_RANDOM_COLORS, A_LOGGER_TIME_FORMAT, A_Logger, A_LoggerEnvVariables, A_LoggerEnvVariablesArray, type A_LoggerEnvVariablesType, type A_LoggerLevel, A_Manifest, A_ManifestChecker, A_ManifestError, A_Memory, A_MemoryContext, type A_MemoryContextMeta, A_MemoryError, A_MemoryFeatures, type A_MemoryOperationContext, type A_MemoryOperationContextMeta, type A_MemoryOperations, type A_Memory_Storage, A_OperationContext, type A_Operation_Serialized, type A_Operation_Storage, A_Polyfill, A_Schedule, A_ScheduleObject, A_StateMachine, A_StateMachineError, A_StateMachineFeatures, A_StateMachineTransition, type A_StateMachineTransitionParams, type A_StateMachineTransitionStorage, 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 };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {A_Feature,A_Inject,A_Scope,A_Error,A_Dependency,A_Concept,A_Container,A_TypeGuards,A_Component,A_IdentityHelper,A_Context,A_FormatterHelper,A_Fragment,A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,A_CommonHelper,A_Entity,A_ScopeError}from'@adaas/a-concept';var Ke=Object.defineProperty;var pt=Object.getOwnPropertyDescriptor;var i=(k,t)=>Ke(k,"name",{value:t,configurable:true});var p=(k,t,e,r)=>{for(var o=r>1?void 0:r?pt(t,e):t,n=k.length-1,s;n>=0;n--)(s=k[n])&&(o=(r?s(t,e,o):s(o))||o);return r&&o&&Ke(t,e,o),o},c=(k,t)=>(e,r)=>t(e,r,k);var ue=class ue extends A_Fragment{constructor(t,e){super(),this.meta.set("name",t),this.meta.set("params",e||{});}get name(){return this._meta.get("name")||this._name}get result(){return this._meta.get("result")}get error(){return this._meta.get("error")}get params(){return this._meta.get("params")||{}}fail(t){this._meta.set("error",t);}succeed(t){this._meta.set("result",t);}toJSON(){return {name:this.name,params:this.params,result:this.result||{},error:this.error?.toJSON()}}};i(ue,"A_OperationContext");var l=ue;var re=class re extends A_Error{constructor(t,e){A_TypeGuards.isString(e)?super(t,e):super(t),e instanceof l&&(this._context=e);}get context(){return this._context}};i(re,"A_ChannelError"),re.MethodNotImplemented="A-Channel Method Not Implemented";var M=re;var dt=(E=>(E.onTimeout="onTimeout",E.onRetry="onRetry",E.onCircuitBreakerOpen="onCircuitBreakerOpen",E.onCache="onCache",E.onConnect="onConnect",E.onDisconnect="onDisconnect",E.onBeforeRequest="onBeforeRequest",E.onRequest="onRequest",E.onAfterRequest="onAfterRequest",E.onError="onError",E.onSend="onSend",E.onConsume="onConsume",E))(dt||{}),ht=(r=>(r.PENDING="PENDING",r.SUCCESS="SUCCESS",r.FAILED="FAILED",r))(ht||{});var ye=class ye extends l{constructor(t){super("request",t);}get status(){return this.result?.status}get data(){return this.result?.data}succeed(t){let e=this.result;super.succeed({...e,data:t,status:"SUCCESS"});}};i(ye,"A_ChannelRequest");var X=ye;var P=class P extends A_Component{constructor(){super();this._processing=false;this._cache=new Map;}get processing(){return this._processing}get initialize(){return this._initialized||(this._initialized=this.connect()),this._initialized}async onConnect(...e){}async onDisconnect(...e){}async onBeforeRequest(...e){}async onRequest(...e){}async onAfterRequest(...e){}async onError(...e){}async onSend(...e){}async connect(){await this.call("onConnect");}async disconnect(){await this.call("onDisconnect");}async request(e){await this.initialize,this._processing=true;let r=new A_Scope({name:`a-channel@scope:request:${A_IdentityHelper.generateTimeId()}`}),o=new X(e);try{return r.register(o),await this.call("onBeforeRequest",r),await this.call("onRequest",r),await this.call("onAfterRequest",r),this._processing=!1,o}catch(n){this._processing=false;let s=new M(n);throw o.fail(s),r.register(s),await this.call("onError",r),r.destroy(),s}}async send(e){await this.initialize,this._processing=true;let r=new A_Scope({name:`a-channel@scope:send:${A_IdentityHelper.generateTimeId()}`}),o=new l("send",e);try{r.inherit(A_Context.scope(this)),r.register(o),await this.call("onSend",r),this._processing=!1;}catch(n){this._processing=false;let s=new M(n);r.register(s),o.fail(s),await this.call("onError",r),r.destroy();}}async consume(){await this.initialize,this._processing=true;let e=new A_Scope({name:`a-channel@scope:consume:${A_IdentityHelper.generateTimeId()}`}),r=new l("consume",{});try{return e.inherit(A_Context.scope(this)),e.register(r),await this.call("onConsume",e),this._processing=!1,r}catch(o){this._processing=false;let n=new M(o);return r.fail(n),await this.call("onError",e),r}}};i(P,"A_Channel"),p([A_Feature.Extend({name:"onConnect"})],P.prototype,"onConnect",1),p([A_Feature.Extend({name:"onDisconnect"})],P.prototype,"onDisconnect",1),p([A_Feature.Extend({name:"onBeforeRequest"})],P.prototype,"onBeforeRequest",1),p([A_Feature.Extend({name:"onRequest"})],P.prototype,"onRequest",1),p([A_Feature.Extend({name:"onAfterRequest"})],P.prototype,"onAfterRequest",1),p([A_Feature.Extend({name:"onError"})],P.prototype,"onError",1),p([A_Feature.Extend({name:"onSend"})],P.prototype,"onSend",1);var Ae=P;var gt=(s=>(s.CREATED="CREATED",s.INITIALIZED="INITIALIZED",s.COMPILED="COMPILED",s.EXECUTING="EXECUTING",s.COMPLETED="COMPLETED",s.FAILED="FAILED",s))(gt||{}),ut=(o=>(o.CREATED_TO_INITIALIZED="created_initialized",o.INITIALIZED_TO_EXECUTING="initialized_executing",o.EXECUTING_TO_COMPLETED="executing_completed",o.EXECUTING_TO_FAILED="executing_failed",o))(ut||{}),yt=(a=>(a.onInit="onInit",a.onBeforeExecute="onBeforeExecute",a.onExecute="onExecute",a.onAfterExecute="onAfterExecute",a.onComplete="onComplete",a.onFail="onFail",a.onError="onError",a))(yt||{});var U=class U extends A_Error{};i(U,"A_CommandError"),U.CommandScopeBindingError="A-Command Scope Binding Error",U.ExecutionError="A-Command Execution Error",U.ResultProcessingError="A-Command Result Processing Error",U.CommandInterruptedError="A-Command Interrupted Error";var L=U;var J=class J extends A_Error{};i(J,"A_StateMachineError"),J.InitializationError="A-StateMachine Initialization Error",J.TransitionError="A-StateMachine Transition Error";var V=J;var At=(o=>(o.onError="onError",o.onInitialize="onInitialize",o.onBeforeTransition="onBeforeTransition",o.onAfterTransition="onAfterTransition",o))(At||{});var Se=class Se extends l{constructor(t){super("a-state-machine-transition",t),this._meta.set("from",t.from),this._meta.set("to",t.to);}get from(){return this._meta.get("from")}get to(){return this._meta.get("to")}};i(Se,"A_StateMachineTransition");var R=Se;var xt,Rt,vt,wt,z=class z extends A_Component{get ready(){return this._initialized||(this._initialized=this.call("onInitialize")),this._initialized}async[wt="onInitialize"](...t){}async[vt="onBeforeTransition"](...t){}async[Rt="onAfterTransition"](...t){}async[xt="onError"](...t){}async transition(t,e,r){await this.ready;let o=`${A_FormatterHelper.toCamelCase(String(t))}_${A_FormatterHelper.toCamelCase(String(e))}`,n=new R({from:String(t),to:String(e),props:r}),s=new A_Scope({name:`A-StateMachine-Transition-Scope-${o}`,fragments:[n]});try{return await this.call("onBeforeTransition",s),await this.call(o,s),await this.call("onAfterTransition",s),s.destroy(),n.result}catch(a){let d=new V({title:V.TransitionError,description:`An error occurred while transitioning to "${o}"`,originalError:a});throw s.register(d),await this.call("onError",s),s.destroy(),d}}};i(z,"A_StateMachine"),p([A_Feature.Extend()],z.prototype,wt,1),p([A_Feature.Extend()],z.prototype,vt,1),p([A_Feature.Extend()],z.prototype,Rt,1),p([A_Feature.Extend()],z.prototype,xt,1);var O=z;var So={},B=[];var xe=class xe extends A_Fragment{constructor(e){super({name:"A_Config"});this.VARIABLES=new Map;this.DEFAULT_ALLOWED_TO_READ_PROPERTIES=[...A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,...B];this.config=A_CommonHelper.deepCloneAndMerge(e,{strict:false,defaults:{},variables:A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY}),this.CONFIG_PROPERTIES=this.config.variables?this.config.variables:[],this.config.variables.forEach(r=>{this.VARIABLES.set(A_FormatterHelper.toUpperSnakeCase(r),this.config.defaults[r]);});}get(e){if(this.CONFIG_PROPERTIES.includes(e)||this.DEFAULT_ALLOWED_TO_READ_PROPERTIES.includes(e)||!this.config.strict)return this.VARIABLES.get(A_FormatterHelper.toUpperSnakeCase(e));throw new Error("Property not exists or not allowed to read")}set(e,r){let o=Array.isArray(e)?e:typeof e=="string"?[{property:e,value:r}]:Object.keys(e).map(n=>({property:n,value:e[n]}));for(let{property:n,value:s}of o){let a=s||(this.config?.defaults?this.config.defaults[n]:void 0);this.VARIABLES.set(A_FormatterHelper.toUpperSnakeCase(n),a);}}};i(xe,"A_Config");var f=xe;var We=20,Oo="all",Qe={red:"31",yellow:"33",green:"32",blue:"34",cyan:"36",magenta:"35",gray:"90",brightBlue:"94",brightCyan:"96",brightMagenta:"95",darkGray:"30",lightGray:"37",indigo:"38;5;54",violet:"38;5;93",purple:"38;5;129",lavender:"38;5;183",skyBlue:"38;5;117",steelBlue:"38;5;67",slateBlue:"38;5;62",deepBlue:"38;5;18",lightBlue:"38;5;153",periwinkle:"38;5;111",cornflower:"38;5;69",powder:"38;5;152",charcoal:"38;5;236",silver:"38;5;250",smoke:"38;5;244",slate:"38;5;240"},et=["blue","cyan","magenta","gray","brightBlue","brightCyan","brightMagenta","darkGray","lightGray","indigo","violet","purple","lavender","skyBlue","steelBlue","slateBlue","deepBlue","lightBlue","periwinkle","cornflower","powder","charcoal","silver","smoke","slate"],N={RESET:"\x1B[0m",PREFIX:"\x1B[",SUFFIX:"m"},j={MINUTES_PAD:2,SECONDS_PAD:2,MILLISECONDS_PAD:3,SEPARATOR:":"},T={SCOPE_OPEN:"[",SCOPE_CLOSE:"]",TIME_OPEN:"|",TIME_CLOSE:"|",SEPARATOR:"-------------------------------",INDENT_BASE:3,PIPE:"| "},Z={LOG_LEVEL:"A_LOGGER_LEVEL",DEFAULT_SCOPE_LENGTH:"A_LOGGER_DEFAULT_SCOPE_LENGTH",DEFAULT_SCOPE_COLOR:"A_LOGGER_DEFAULT_SCOPE_COLOR",DEFAULT_LOG_COLOR:"A_LOGGER_DEFAULT_LOG_COLOR"};var v=class extends A_Component{constructor(e,r){super();this.scope=e;this.config=r;this.COLORS=Qe,this.STANDARD_SCOPE_LENGTH=r?.get(Z.DEFAULT_SCOPE_LENGTH)||20;let o=r?.get(Z.DEFAULT_SCOPE_COLOR),n=r?.get(Z.DEFAULT_LOG_COLOR);if(o||n)this.DEFAULT_SCOPE_COLOR=o||this.generateColorFromScopeName(this.scope.name),this.DEFAULT_LOG_COLOR=n||this.generateColorFromScopeName(this.scope.name);else {let s=this.generateComplementaryColorsFromScope(this.scope.name);this.DEFAULT_SCOPE_COLOR=s.scopeColor,this.DEFAULT_LOG_COLOR=s.logColor;}}simpleHash(e){let r=0;for(let o=0;o<e.length;o++){let n=e.charCodeAt(o);r=(r<<5)-r+n,r=r&r;}return Math.abs(r)}generateColorFromScopeName(e){let r=et,n=this.simpleHash(e)%r.length;return r[n]}generateComplementaryColorsFromScope(e){let r=[{scopeColor:"indigo",logColor:"lightBlue"},{scopeColor:"deepBlue",logColor:"cyan"},{scopeColor:"purple",logColor:"lavender"},{scopeColor:"steelBlue",logColor:"skyBlue"},{scopeColor:"slateBlue",logColor:"periwinkle"},{scopeColor:"charcoal",logColor:"silver"},{scopeColor:"violet",logColor:"brightMagenta"},{scopeColor:"darkGray",logColor:"lightGray"},{scopeColor:"cornflower",logColor:"powder"},{scopeColor:"slate",logColor:"smoke"}],n=this.simpleHash(e)%r.length;return r[n]}get scopeLength(){return Math.max(this.scope.name.length,this.STANDARD_SCOPE_LENGTH)}get formattedScope(){let e=this.scope.name,r=this.STANDARD_SCOPE_LENGTH;if(e.length>=r)return e.substring(0,r);let o=r-e.length,n=Math.floor(o/2),s=o-n;return " ".repeat(n)+e+" ".repeat(s)}compile(e,...r){let o=this.getTime(),n=" ".repeat(this.scopeLength+3),s=r.length>1;return [`${N.PREFIX}${this.COLORS[this.DEFAULT_SCOPE_COLOR]}${N.SUFFIX}${T.SCOPE_OPEN}${this.formattedScope}${T.SCOPE_CLOSE}${N.RESET} ${N.PREFIX}${this.COLORS[e]}${N.SUFFIX}${T.TIME_OPEN}${o}${T.TIME_CLOSE}`,s?`
|
|
2
|
-
${n}${T.TIME_OPEN}${T.SEPARATOR}`:"",...r.map((
|
|
3
|
-
${n}${T.TIME_OPEN}${T.SEPARATOR}${
|
|
1
|
+
import {A_Feature,A_Inject,A_Scope,A_Error,A_Dependency,A_Concept,A_Container,A_TypeGuards,A_Component,A_IdentityHelper,A_Context,A_FormatterHelper,A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,A_Entity,A_Fragment,A_Meta,A_ScopeError}from'@adaas/a-concept';var Je=Object.defineProperty;var lt=Object.getOwnPropertyDescriptor;var i=($,t)=>Je($,"name",{value:t,configurable:true});var p=($,t,e,r)=>{for(var o=r>1?void 0:r?lt(t,e):t,n=$.length-1,s;n>=0;n--)(s=$[n])&&(o=(r?s(t,e,o):s(o))||o);return r&&o&&Je(t,e,o),o},a=($,t)=>(e,r)=>t(e,r,$);var ue=class ue extends A_Fragment{constructor(t,e){super({name:t}),this._meta=new A_Meta;for(let r in e)this._meta.set(r,e[r]);}[Symbol.iterator](){return this._meta[Symbol.iterator]()}get meta(){return this._meta}get(t){return this._meta.get(t)}set(t,e){this._meta.set(t,e);}has(t){return this._meta.has(t)}drop(t){this._meta.delete(t);}clear(){this._meta.clear();}toRaw(){return this._meta.toJSON()}toJSON(){return {name:this.name,...this.meta.toJSON()}}};i(ue,"A_ExecutionContext");var R=ue;var Ee=class Ee extends R{constructor(t,e){super("operation-context"),this.meta.set("name",t),this.meta.set("params",e||{});}get name(){return this._meta.get("name")||this._name}get result(){return this._meta.get("result")}get error(){return this._meta.get("error")}get params(){return this._meta.get("params")||{}}fail(t){this._meta.set("error",t);}succeed(t){this._meta.set("result",t);}toJSON(){return {name:this.name,params:this.params,result:this.result||{},error:this.error?.toJSON()}}};i(Ee,"A_OperationContext");var l=Ee;var oe=class oe extends A_Error{constructor(t,e){A_TypeGuards.isString(e)?super(t,e):super(t),e instanceof l&&(this._context=e);}get context(){return this._context}};i(oe,"A_ChannelError"),oe.MethodNotImplemented="A-Channel Method Not Implemented";var F=oe;var ft=(E=>(E.onTimeout="onTimeout",E.onRetry="onRetry",E.onCircuitBreakerOpen="onCircuitBreakerOpen",E.onCache="onCache",E.onConnect="onConnect",E.onDisconnect="onDisconnect",E.onBeforeRequest="onBeforeRequest",E.onRequest="onRequest",E.onAfterRequest="onAfterRequest",E.onError="onError",E.onSend="onSend",E.onConsume="onConsume",E))(ft||{}),yt=(r=>(r.PENDING="PENDING",r.SUCCESS="SUCCESS",r.FAILED="FAILED",r))(yt||{});var Te=class Te extends l{constructor(t){super("request",t);}get status(){return this.result?.status}get data(){return this.result?.data}succeed(t){let e=this.result;super.succeed({...e,data:t,status:"SUCCESS"});}};i(Te,"A_ChannelRequest");var J=Te;var O=class O extends A_Component{constructor(){super();this._processing=false;this._cache=new Map;}get processing(){return this._processing}get initialize(){return this._initialized||(this._initialized=this.connect()),this._initialized}async onConnect(...e){}async onDisconnect(...e){}async onBeforeRequest(...e){}async onRequest(...e){}async onAfterRequest(...e){}async onError(...e){}async onSend(...e){}async connect(){await this.call("onConnect");}async disconnect(){await this.call("onDisconnect");}async request(e){await this.initialize,this._processing=true;let r=new A_Scope({name:`a-channel@scope:request:${A_IdentityHelper.generateTimeId()}`}),o=new J(e);try{return r.register(o),await this.call("onBeforeRequest",r),await this.call("onRequest",r),await this.call("onAfterRequest",r),this._processing=!1,o}catch(n){this._processing=false;let s=new F(n);throw o.fail(s),r.register(s),await this.call("onError",r),r.destroy(),s}}async send(e){await this.initialize,this._processing=true;let r=new A_Scope({name:`a-channel@scope:send:${A_IdentityHelper.generateTimeId()}`}),o=new l("send",e);try{r.inherit(A_Context.scope(this)),r.register(o),await this.call("onSend",r),this._processing=!1;}catch(n){this._processing=false;let s=new F(n);r.register(s),o.fail(s),await this.call("onError",r),r.destroy();}}async consume(){await this.initialize,this._processing=true;let e=new A_Scope({name:`a-channel@scope:consume:${A_IdentityHelper.generateTimeId()}`}),r=new l("consume",{});try{return e.inherit(A_Context.scope(this)),e.register(r),await this.call("onConsume",e),this._processing=!1,r}catch(o){this._processing=false;let n=new F(o);return r.fail(n),await this.call("onError",e),r}}};i(O,"A_Channel"),p([A_Feature.Extend({name:"onConnect"})],O.prototype,"onConnect",1),p([A_Feature.Extend({name:"onDisconnect"})],O.prototype,"onDisconnect",1),p([A_Feature.Extend({name:"onBeforeRequest"})],O.prototype,"onBeforeRequest",1),p([A_Feature.Extend({name:"onRequest"})],O.prototype,"onRequest",1),p([A_Feature.Extend({name:"onAfterRequest"})],O.prototype,"onAfterRequest",1),p([A_Feature.Extend({name:"onError"})],O.prototype,"onError",1),p([A_Feature.Extend({name:"onSend"})],O.prototype,"onSend",1);var xe=O;var ut=(s=>(s.CREATED="CREATED",s.INITIALIZED="INITIALIZED",s.COMPILED="COMPILED",s.EXECUTING="EXECUTING",s.COMPLETED="COMPLETED",s.FAILED="FAILED",s))(ut||{}),Et=(o=>(o.CREATED_TO_INITIALIZED="created_initialized",o.INITIALIZED_TO_EXECUTING="initialized_executing",o.EXECUTING_TO_COMPLETED="executing_completed",o.EXECUTING_TO_FAILED="executing_failed",o))(Et||{}),Tt=(c=>(c.onInit="onInit",c.onBeforeExecute="onBeforeExecute",c.onExecute="onExecute",c.onAfterExecute="onAfterExecute",c.onComplete="onComplete",c.onFail="onFail",c.onError="onError",c))(Tt||{});var z=class z extends A_Error{};i(z,"A_CommandError"),z.CommandScopeBindingError="A-Command Scope Binding Error",z.ExecutionError="A-Command Execution Error",z.ResultProcessingError="A-Command Result Processing Error",z.CommandInterruptedError="A-Command Interrupted Error";var b=z;var W=class W extends A_Error{};i(W,"A_StateMachineError"),W.InitializationError="A-StateMachine Initialization Error",W.TransitionError="A-StateMachine Transition Error";var V=W;var xt=(o=>(o.onError="onError",o.onInitialize="onInitialize",o.onBeforeTransition="onBeforeTransition",o.onAfterTransition="onAfterTransition",o))(xt||{});var Ce=class Ce extends l{constructor(t){super("a-state-machine-transition",t),this._meta.set("from",t.from),this._meta.set("to",t.to);}get from(){return this._meta.get("from")}get to(){return this._meta.get("to")}};i(Ce,"A_StateMachineTransition");var v=Ce;var vt,wt,Pt,Ot,Y=class Y extends A_Component{get ready(){return this._initialized||(this._initialized=this.call("onInitialize")),this._initialized}async[Ot="onInitialize"](...t){}async[Pt="onBeforeTransition"](...t){}async[wt="onAfterTransition"](...t){}async[vt="onError"](...t){}async transition(t,e,r){await this.ready;let o=`${A_FormatterHelper.toCamelCase(String(t))}_${A_FormatterHelper.toCamelCase(String(e))}`,n=new v({from:String(t),to:String(e),props:r}),s=new A_Scope({name:`A-StateMachine-Transition-Scope-${o}`,fragments:[n]});try{return await this.call("onBeforeTransition",s),await this.call(o,s),await this.call("onAfterTransition",s),s.destroy(),n.result}catch(c){let d=new V({title:V.TransitionError,description:`An error occurred while transitioning to "${o}"`,originalError:c});throw s.register(d),await this.call("onError",s),s.destroy(),d}}};i(Y,"A_StateMachine"),p([A_Feature.Extend()],Y.prototype,Ot,1),p([A_Feature.Extend()],Y.prototype,Pt,1),p([A_Feature.Extend()],Y.prototype,wt,1),p([A_Feature.Extend()],Y.prototype,vt,1);var L=Y;var wo={},j=[];var ne=class ne extends A_Error{};i(ne,"A_ConfigError"),ne.InitializationError="A-Config Initialization Error";var I=ne;var ve=class ve extends R{constructor(e){super("a-config");this.DEFAULT_ALLOWED_TO_READ_PROPERTIES=[...A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,...j];this._strict=e.strict??false,this._configProperties=e.variables??[];for(let r in e.defaults)this.set(A_FormatterHelper.toUpperSnakeCase(r),e.defaults[r]);}get strict(){return this._strict}get(e){if(this._configProperties.includes(e)||this.DEFAULT_ALLOWED_TO_READ_PROPERTIES.includes(e)||!this._strict)return super.get(A_FormatterHelper.toUpperSnakeCase(e));throw new I("Property not exists or not allowed to read")}set(e,r){let o=Array.isArray(e)?e:typeof e=="string"?[{property:e,value:r}]:Object.keys(e).map(n=>({property:n,value:e[n]}));for(let{property:n,value:s}of o)super.set(A_FormatterHelper.toUpperSnakeCase(n),s);}};i(ve,"A_Config");var f=ve;var Qe=20,Fo="all",et={red:"31",yellow:"33",green:"32",blue:"34",cyan:"36",magenta:"35",gray:"90",brightBlue:"94",brightCyan:"96",brightMagenta:"95",darkGray:"30",lightGray:"37",indigo:"38;5;54",violet:"38;5;93",purple:"38;5;129",lavender:"38;5;183",skyBlue:"38;5;117",steelBlue:"38;5;67",slateBlue:"38;5;62",deepBlue:"38;5;18",lightBlue:"38;5;153",periwinkle:"38;5;111",cornflower:"38;5;69",powder:"38;5;152",charcoal:"38;5;236",silver:"38;5;250",smoke:"38;5;244",slate:"38;5;240"},tt=["blue","cyan","magenta","gray","brightBlue","brightCyan","brightMagenta","darkGray","lightGray","indigo","violet","purple","lavender","skyBlue","steelBlue","slateBlue","deepBlue","lightBlue","periwinkle","cornflower","powder","charcoal","silver","smoke","slate"],k={RESET:"\x1B[0m",PREFIX:"\x1B[",SUFFIX:"m"},q={MINUTES_PAD:2,SECONDS_PAD:2,MILLISECONDS_PAD:3,SEPARATOR:":"},T={SCOPE_OPEN:"[",SCOPE_CLOSE:"]",TIME_OPEN:"|",TIME_CLOSE:"|",SEPARATOR:"-------------------------------",INDENT_BASE:3,PIPE:"| "},Z={LOG_LEVEL:"A_LOGGER_LEVEL",DEFAULT_SCOPE_LENGTH:"A_LOGGER_DEFAULT_SCOPE_LENGTH",DEFAULT_SCOPE_COLOR:"A_LOGGER_DEFAULT_SCOPE_COLOR",DEFAULT_LOG_COLOR:"A_LOGGER_DEFAULT_LOG_COLOR"};var w=class extends A_Component{constructor(e,r){super();this.scope=e;this.config=r;this.COLORS=et,this.STANDARD_SCOPE_LENGTH=r?.get(Z.DEFAULT_SCOPE_LENGTH)||20;let o=r?.get(Z.DEFAULT_SCOPE_COLOR),n=r?.get(Z.DEFAULT_LOG_COLOR);if(o||n)this.DEFAULT_SCOPE_COLOR=o||this.generateColorFromScopeName(this.scope.name),this.DEFAULT_LOG_COLOR=n||this.generateColorFromScopeName(this.scope.name);else {let s=this.generateComplementaryColorsFromScope(this.scope.name);this.DEFAULT_SCOPE_COLOR=s.scopeColor,this.DEFAULT_LOG_COLOR=s.logColor;}}simpleHash(e){let r=0;for(let o=0;o<e.length;o++){let n=e.charCodeAt(o);r=(r<<5)-r+n,r=r&r;}return Math.abs(r)}generateColorFromScopeName(e){let r=tt,n=this.simpleHash(e)%r.length;return r[n]}generateComplementaryColorsFromScope(e){let r=[{scopeColor:"indigo",logColor:"lightBlue"},{scopeColor:"deepBlue",logColor:"cyan"},{scopeColor:"purple",logColor:"lavender"},{scopeColor:"steelBlue",logColor:"skyBlue"},{scopeColor:"slateBlue",logColor:"periwinkle"},{scopeColor:"charcoal",logColor:"silver"},{scopeColor:"violet",logColor:"brightMagenta"},{scopeColor:"darkGray",logColor:"lightGray"},{scopeColor:"cornflower",logColor:"powder"},{scopeColor:"slate",logColor:"smoke"}],n=this.simpleHash(e)%r.length;return r[n]}get scopeLength(){return Math.max(this.scope.name.length,this.STANDARD_SCOPE_LENGTH)}get formattedScope(){let e=this.scope.name,r=this.STANDARD_SCOPE_LENGTH;if(e.length>=r)return e.substring(0,r);let o=r-e.length,n=Math.floor(o/2),s=o-n;return " ".repeat(n)+e+" ".repeat(s)}compile(e,...r){let o=this.getTime(),n=" ".repeat(this.scopeLength+3),s=r.length>1;return [`${k.PREFIX}${this.COLORS[this.DEFAULT_SCOPE_COLOR]}${k.SUFFIX}${T.SCOPE_OPEN}${this.formattedScope}${T.SCOPE_CLOSE}${k.RESET} ${k.PREFIX}${this.COLORS[e]}${k.SUFFIX}${T.TIME_OPEN}${o}${T.TIME_CLOSE}`,s?`
|
|
2
|
+
${n}${T.TIME_OPEN}${T.SEPARATOR}`:"",...r.map((c,d)=>{let D=d>0||s;switch(true){case c instanceof A_Error:return this.compile_A_Error(c);case c instanceof Error:return this.compile_Error(c);case(typeof c=="object"&&c!==null):return this.formatObject(c,D,n);default:return this.formatString(String(c),D,n)}}),s?`
|
|
3
|
+
${n}${T.TIME_OPEN}${T.SEPARATOR}${k.RESET}`:k.RESET]}formatObject(e,r,o){let n;try{n=JSON.stringify(e,null,2);}catch{let d=new WeakSet;n=JSON.stringify(e,(D,m)=>{if(typeof m=="object"&&m!==null){if(d.has(m))return "[Circular Reference]";d.add(m);}return m},2);}let s=n.replace(/\n/g,`
|
|
4
4
|
${o}${T.PIPE}`);return r?`
|
|
5
5
|
${o}${T.PIPE}`+s:s}formatString(e,r,o){return ((r?`
|
|
6
6
|
`:"")+e).replace(/\n/g,`
|
|
@@ -40,6 +40,6 @@ ${r}|-------------------------------`:"")}compile_Error(e){let r=" ".repeat(this
|
|
|
40
40
|
`).map((o,n)=>n===0?o:`${r}| ${o}`).join(`
|
|
41
41
|
`)},null,2).replace(/\n/g,`
|
|
42
42
|
${r}| `).replace(/\\n/g,`
|
|
43
|
-
`)}getTime(){let e=new Date,r=String(e.getMinutes()).padStart(j.MINUTES_PAD,"0"),o=String(e.getSeconds()).padStart(j.SECONDS_PAD,"0"),n=String(e.getMilliseconds()).padStart(j.MILLISECONDS_PAD,"0");return `${r}${j.SEPARATOR}${o}${j.SEPARATOR}${n}`}};i(v,"A_Logger"),v=p([c(0,A_Inject(A_Scope)),c(1,A_Inject(f))],v);var Dt,Gt,$t,kt,Mt,Ft,Ut,zt,Bt,Yt,Vt,u=class u extends A_Entity{constructor(e){super(e);this._listeners=new Map;}static get code(){return super.entity}get duration(){return this._endTime&&this._startTime?this._endTime.getTime()-this._startTime.getTime():this._startTime?new Date().getTime()-this._startTime.getTime():void 0}get idleTime(){return this._startTime&&this._createdAt?this._startTime.getTime()-this._createdAt.getTime():void 0}get scope(){return this._executionScope}get code(){return this.constructor.code}get status(){return this._status}get createdAt(){return this._createdAt}get startedAt(){return this._startTime}get endedAt(){return this._endTime}get result(){return this._result}get error(){return this._error}get params(){return this._params}get isProcessed(){return this._status==="COMPLETED"||this._status==="FAILED"}async[Vt="onBeforeTransition"](e,r,...o){this.checkScopeInheritance(),r?.debug("yellow",`Command ${this.aseid.toString()} transitioning from ${e.from} to ${e.to}`);}async[Yt="created_initialized"](e,...r){this._status==="CREATED"&&(this._createdAt=new Date,this._status="INITIALIZED",this.emit("onInit"));}async[Bt="initialized_executing"](e,...r){this._status!=="INITIALIZED"&&this._status!=="CREATED"||(this._startTime=new Date,this._status="EXECUTING",this.emit("onExecute"));}async[zt="executing_completed"](e,...r){this._endTime=new Date,this._status="COMPLETED",this.emit("onComplete");}async[Ut="executing_failed"](e,r,...o){this._endTime=new Date,this._status="FAILED",this.emit("onFail");}async[Ft="onInit"](e,...r){await e.transition("CREATED","INITIALIZED");}async[Mt="onBeforeExecute"](e,...r){await e.transition("INITIALIZED","EXECUTING");}async[kt="onExecute"](...e){}async[$t="onAfterExecute"](...e){}async[Gt="onComplete"](e,...r){await e.transition("EXECUTING","COMPLETED");}async[Dt="onFail"](e,r,...o){await e.transition("EXECUTING","FAILED");}async init(){await this.call("onInit",this.scope);}async execute(){if(!this.isProcessed)try{this.checkScopeInheritance();let e=new l("execute-command");this.scope.register(e),await new Promise(async(r,o)=>{try{let n=new A_Feature({name:"onBeforeExecute",component:this,scope:this.scope}),s=new A_Feature({name:"onExecute",component:this,scope:this.scope}),a=new A_Feature({name:"onAfterExecute",component:this,scope:this.scope});this.on("onComplete",()=>{n.interrupt(),s.interrupt(),a.interrupt(),r();}),await n.process(this.scope),await s.process(this.scope),await a.process(this.scope),this._origin==="invoked"&&await this.complete(),r();}catch(n){o(n);}});}catch(e){let r=e instanceof A_Error?e:new L({title:L.ExecutionError,description:`An error occurred while executing command "${this.aseid.toString()}".`,originalError:e});await this.fail(r);}}async complete(e){this.isProcessed||(this._status="COMPLETED",this._result=e,await this.call("onComplete",this.scope),this.scope.destroy());}async fail(e){this.isProcessed||(this._status="FAILED",e&&(this._error=e,this.scope.register(e)),await this.call("onFail",this.scope),this.scope.destroy());}on(e,r){this._listeners.has(e)||this._listeners.set(e,new Set),this._listeners.get(e).add(r);}off(e,r){this._listeners.get(e)?.delete(r);}emit(e){this._listeners.get(e)?.forEach(async r=>{r(this);});}fromNew(e){super.fromNew(e),this._origin="invoked",this._executionScope=new A_Scope({name:`A-Command-Execution-Scope-${this.aseid.toString()}`,components:[O]}),this._createdAt=new Date,this._params=e,this._status="CREATED";}fromJSON(e){super.fromJSON(e),this._origin="serialized",this._executionScope=new A_Scope({name:`A-Command-Execution-Scope-${this.aseid.toString()}`,components:[O]}),e.createdAt&&(this._createdAt=new Date(e.createdAt)),e.startedAt&&(this._startTime=new Date(e.startedAt)),e.endedAt&&(this._endTime=new Date(e.endedAt)),this._params=e.params,this._status=e.status,e.error&&(this._error=new L(e.error)),e.result&&(this._result=e.result);}toJSON(){return {...super.toJSON(),code:this.code,status:this._status,params:this._params,createdAt:this._createdAt.toISOString(),startedAt:this._startTime?this._startTime.toISOString():void 0,endedAt:this._endTime?this._endTime.toISOString():void 0,duration:this.duration,idleTime:this.idleTime,result:this.result,error:this.error?this.error.toJSON():void 0}}checkScopeInheritance(){let e;try{e=A_Context.scope(this);}catch(r){throw new L({title:L.CommandScopeBindingError,description:`Command ${this.aseid.toString()} is not bound to any context scope. Ensure the command is properly registered within a context before execution.`,originalError:r})}this.scope.isInheritedFrom(A_Context.scope(this))||this.scope.inherit(A_Context.scope(this));}};i(u,"A_Command"),p([A_Feature.Extend(),c(0,A_Inject(R)),c(1,A_Inject(v))],u.prototype,Vt,1),p([A_Feature.Extend(),c(0,A_Inject(R))],u.prototype,Yt,1),p([A_Feature.Extend(),c(0,A_Inject(R))],u.prototype,Bt,1),p([A_Feature.Extend(),c(0,A_Inject(R))],u.prototype,zt,1),p([A_Feature.Extend(),c(0,A_Inject(R)),c(1,A_Inject(A_Error))],u.prototype,Ut,1),p([A_Feature.Extend(),c(0,A_Inject(O))],u.prototype,Ft,1),p([A_Feature.Extend({after:/.*/}),c(0,A_Dependency.Required()),c(0,A_Inject(O))],u.prototype,Mt,1),p([A_Feature.Extend()],u.prototype,kt,1),p([A_Feature.Extend()],u.prototype,$t,1),p([A_Feature.Extend({after:/.*/}),c(0,A_Inject(O))],u.prototype,Gt,1),p([A_Feature.Extend({after:/.*/}),c(0,A_Dependency.Required()),c(0,A_Inject(O)),c(1,A_Inject(l))],u.prototype,Dt,1);var ve=u;var we=class we{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._fs}async init(){try{A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){this._fs=await import('fs');}initBrowser(){this._fs={readFileSync:i((t,e)=>(this.logger.warning("fs.readFileSync not available in browser environment"),""),"readFileSync"),existsSync:i(t=>(this.logger.warning("fs.existsSync not available in browser environment"),false),"existsSync"),createReadStream:i(t=>(this.logger.warning("fs.createReadStream not available in browser environment"),null),"createReadStream")};}};i(we,"A_FSPolyfillClass");var ie=we;var Pe=class Pe{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(t){return this._initialized||(this._fsPolyfill=t,await this.init()),this._crypto}async init(){try{A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('crypto');this._crypto={createTextHash:i((e,r="sha384")=>Promise.resolve(`${r}-${t.createHash(r).update(e).digest("base64")}`),"createTextHash"),createFileHash:i((e,r="sha384")=>new Promise(async(o,n)=>{try{if(!this._fsPolyfill)throw new Error("FS polyfill is required for file hashing");let s=t.createHash(r),a=this._fsPolyfill.createReadStream(e);a.on("data",d=>s.update(d)),a.on("end",()=>o(`${r}-${s.digest("base64")}`)),a.on("error",d=>n(d));}catch(s){n(s);}}),"createFileHash")};}initBrowser(){this._crypto={createFileHash:i(()=>(this.logger.warning("File hash not available in browser environment"),Promise.resolve("")),"createFileHash"),createTextHash:i((t,e="SHA-384")=>new Promise(async(r,o)=>{try{if(!crypto.subtle)throw new Error("SubtleCrypto not available");let s=new TextEncoder().encode(t),a=await crypto.subtle.digest(e,s),d=Array.from(new Uint8Array(a)),b=btoa(String.fromCharCode(...d));r(`${e}-${b}`);}catch(n){o(n);}}),"createTextHash")};}};i(Pe,"A_CryptoPolyfillClass");var ne=Pe;var Oe=class Oe{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._http}async init(){try{A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('http');this._http={request:t.request,get:t.get,createServer:t.createServer};}initBrowser(){this._http={request:i((t,e)=>(this.logger.warning("http.request not available in browser/test environment, use fetch instead"),this.createMockRequest(t,e,false)),"request"),get:i((t,e)=>(this.logger.warning("http.get not available in browser/test environment, use fetch instead"),this.createMockRequest(typeof t=="string"?{hostname:t}:t,e,false)),"get"),createServer:i(()=>(this.logger.error("http.createServer not available in browser/test environment"),null),"createServer")};}createMockRequest(t,e,r=false){return {end:i(()=>{if(e){let n={statusCode:200,headers:{},on:i((s,a)=>{s==="data"?setTimeout(()=>a("mock data"),0):s==="end"&&setTimeout(()=>a(),0);},"on"),pipe:i(s=>{s.write&&s.write("mock data"),s.end&&s.end();},"pipe")};setTimeout(()=>e(n),0);}},"end"),write:i(n=>{},"write"),on:i((n,s)=>{},"on")}}};i(Oe,"A_HttpPolyfillClass");var se=Oe;var Le=class Le{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._https}async init(){try{A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('https');this._https={request:t.request,get:t.get,createServer:t.createServer};}initBrowser(){this._https={request:i((t,e)=>(this.logger.warning("https.request not available in browser/test environment, use fetch instead"),this.createMockRequest(t,e,true)),"request"),get:i((t,e)=>(this.logger.warning("https.get not available in browser/test environment, use fetch instead"),this.createMockRequest(typeof t=="string"?{hostname:t}:t,e,true)),"get"),createServer:i(()=>(this.logger.error("https.createServer not available in browser/test environment"),null),"createServer")};}createMockRequest(t,e,r=true){return {end:i(()=>{if(e){let n={statusCode:200,headers:{},on:i((s,a)=>{s==="data"?setTimeout(()=>a("mock data"),0):s==="end"&&setTimeout(()=>a(),0);},"on"),pipe:i(s=>{s.write&&s.write("mock data"),s.end&&s.end();},"pipe")};setTimeout(()=>e(n),0);}},"end"),write:i(n=>{},"write"),on:i((n,s)=>{},"on")}}};i(Le,"A_HttpsPolyfillClass");var ae=Le;var Ie=class Ie{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._path}async init(){try{A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){this._path=await import('path');}initBrowser(){this._path={join:i((...t)=>t.join("/").replace(/\/+/g,"/"),"join"),resolve:i((...t)=>{let e="";for(let r of t)r.startsWith("/")?e=r:e=this._path.join(e,r);return e||"/"},"resolve"),dirname:i(t=>t.split("/").slice(0,-1).join("/")||"/","dirname"),basename:i((t,e)=>{let r=t.split("/").pop()||"";return e&&r.endsWith(e)?r.slice(0,-e.length):r},"basename"),extname:i(t=>{let e=t.split(".");return e.length>1?"."+e.pop():""},"extname"),relative:i((t,e)=>e.replace(t,"").replace(/^\//,""),"relative"),normalize:i(t=>t.replace(/\/+/g,"/").replace(/\/$/,"")||"/","normalize"),isAbsolute:i(t=>t.startsWith("/")||/^[a-zA-Z]:/.test(t),"isAbsolute"),parse:i(t=>{let e=this._path.extname(t),r=this._path.basename(t),o=this._path.basename(t,e);return {root:"/",dir:this._path.dirname(t),base:r,ext:e,name:o}},"parse"),format:i(t=>this._path.join(t.dir||"",t.base||""),"format"),sep:"/",delimiter:":"};}};i(Ie,"A_PathPolyfillClass");var ce=Ie;var be=class be{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._url}async init(){try{A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('url');this._url={parse:t.parse,format:t.format,resolve:t.resolve,URL:t.URL||globalThis.URL,URLSearchParams:t.URLSearchParams||globalThis.URLSearchParams};}initBrowser(){this._url={parse:i(t=>{try{let e=new URL(t);return {protocol:e.protocol,hostname:e.hostname,port:e.port,pathname:e.pathname,search:e.search,hash:e.hash,host:e.host,href:e.href}}catch{return {}}},"parse"),format:i(t=>{try{return new URL("",t.href||`${t.protocol}//${t.host}${t.pathname}${t.search}${t.hash}`).href}catch{return ""}},"format"),resolve:i((t,e)=>{try{return new URL(e,t).href}catch{return e}},"resolve"),URL:globalThis.URL,URLSearchParams:globalThis.URLSearchParams};}};i(be,"A_UrlPolyfillClass");var pe=be;var Ne=class Ne{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._buffer}async init(){try{A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('buffer');this._buffer={from:t.Buffer.from,alloc:t.Buffer.alloc,allocUnsafe:t.Buffer.allocUnsafe,isBuffer:t.Buffer.isBuffer,concat:t.Buffer.concat};}initBrowser(){this._buffer={from:i((t,e)=>typeof t=="string"?new TextEncoder().encode(t):new Uint8Array(t),"from"),alloc:i((t,e)=>{let r=new Uint8Array(t);return e!==void 0&&r.fill(e),r},"alloc"),allocUnsafe:i(t=>new Uint8Array(t),"allocUnsafe"),isBuffer:i(t=>t instanceof Uint8Array||t instanceof ArrayBuffer,"isBuffer"),concat:i((t,e)=>{let r=e||t.reduce((s,a)=>s+a.length,0),o=new Uint8Array(r),n=0;for(let s of t)o.set(s,n),n+=s.length;return o},"concat")};}};i(Ne,"A_BufferPolyfillClass");var le=Ne;var De=class De{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._process}async init(){try{A_Context.environment==="server"?this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}initServer(){this._process={env:process.env,argv:process.argv,platform:process.platform,version:process.version,versions:process.versions,cwd:process.cwd,exit:process.exit,nextTick:process.nextTick};}initBrowser(){this._process={env:{NODE_ENV:"browser",...globalThis.process?.env||{}},argv:["browser"],platform:"browser",version:"browser",versions:{node:"browser"},cwd:i(()=>"/","cwd"),exit:i(t=>{throw this.logger.warning("process.exit not available in browser"),new Error(`Process exit with code ${t}`)},"exit"),nextTick:i((t,...e)=>{setTimeout(()=>t(...e),0);},"nextTick")};}};i(De,"A_ProcessPolyfillClass");var _e=De;var h=class extends A_Component{constructor(e){super();this.logger=e;this._initializing=null;}get ready(){return this._initialized||(this._initialized=this._loadInternal()),this._initialized}async load(){await this.ready;}async attachToWindow(){A_Context.environment==="browser"&&(globalThis.A_Polyfill=this,globalThis.process={env:{NODE_ENV:"production"},cwd:i(()=>"/","cwd")},globalThis.__dirname="/");}async _loadInternal(){this._fsPolyfill=new ie(this.logger),this._cryptoPolyfill=new ne(this.logger),this._httpPolyfill=new se(this.logger),this._httpsPolyfill=new ae(this.logger),this._pathPolyfill=new ce(this.logger),this._urlPolyfill=new pe(this.logger),this._bufferPolyfill=new le(this.logger),this._processPolyfill=new _e(this.logger),await this._fsPolyfill.get(),await this._cryptoPolyfill.get(await this._fsPolyfill.get()),await this._httpPolyfill.get(),await this._httpsPolyfill.get(),await this._pathPolyfill.get(),await this._urlPolyfill.get(),await this._bufferPolyfill.get(),await this._processPolyfill.get();}async fs(){return await this.ready,await this._fsPolyfill.get()}async crypto(){return await this.ready,await this._cryptoPolyfill.get()}async http(){return await this.ready,await this._httpPolyfill.get()}async https(){return await this.ready,await this._httpsPolyfill.get()}async path(){return await this.ready,await this._pathPolyfill.get()}async url(){return await this.ready,await this._urlPolyfill.get()}async buffer(){return await this.ready,await this._bufferPolyfill.get()}async process(){return await this.ready,await this._processPolyfill.get()}};i(h,"A_Polyfill"),p([A_Concept.Load()],h.prototype,"load",1),p([A_Concept.Load()],h.prototype,"attachToWindow",1),h=p([c(0,A_Inject(v))],h);var me=class me extends A_Error{};i(me,"A_ConfigError"),me.InitializationError="A-Config Initialization Error";var D=me;var y=class extends A_Component{constructor(e){super();this.polyfill=e;}async attachContext(e,r,o){o||(o=new f({variables:[...A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,...B],defaults:{}}),e.scope.register(o));let n=await this.getProjectRoot();o.set("A_CONCEPT_ROOT_FOLDER",n);}async initialize(e){let r=await this.read([...e.CONFIG_PROPERTIES,...A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,...B]);e.set(r);}resolve(e){return e}async read(e=[]){return {}}async getProjectRoot(e=__dirname){return process.cwd()}};i(y,"ConfigReader"),p([A_Concept.Load(),c(0,A_Inject(A_Container)),c(1,A_Inject(A_Feature)),c(2,A_Inject(f))],y.prototype,"attachContext",1),p([A_Concept.Load(),c(0,A_Inject(f))],y.prototype,"initialize",1),y=p([c(0,A_Inject(h))],y);var Ge=class Ge extends y{constructor(){super(...arguments);this.FileData=new Map;}getConfigurationProperty_File_Alias(e){return A_FormatterHelper.toCamelCase(e)}resolve(e){return this.FileData.get(this.getConfigurationProperty_File_Alias(e))}async read(e){let r=await this.polyfill.fs();try{let o=r.readFileSync(`${A_Context.concept}.conf.json`,"utf8"),n=JSON.parse(o);return this.FileData=new Map(Object.entries(n)),n}catch{return {}}}};i(Ge,"FileConfigReader");var Q=Ge;var de=class de extends y{async readEnvFile(t,e,r){let o=await e.fs();o.existsSync(".env")&&o.readFileSync(`${t.get("A_CONCEPT_ROOT_FOLDER")}/.env`,"utf-8").split(`
|
|
44
|
-
`).forEach(n=>{let[s,a]=n.split("=");s&&a&&(process.env[s.trim()]=a.trim());});}getConfigurationProperty_ENV_Alias(t){return A_FormatterHelper.toUpperSnakeCase(t)}resolve(t){return process.env[this.getConfigurationProperty_ENV_Alias(t)]}async read(t=[]){let e=[...t,...Object.keys(process.env)],r={};return e.forEach(o=>{r[o]=this.resolve(o);}),r}};i(de,"ENVConfigReader"),p([A_Concept.Load({before:["ENVConfigReader.initialize"]}),c(0,A_Inject(f)),c(1,A_Inject(h)),c(2,A_Inject(A_Feature))],de.prototype,"readEnvFile",1);var q=de;var he=class he extends A_Container{async prepare(t){if(!this.scope.has(f)){let r=new f({variables:[...A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,...B],defaults:{}});this.scope.register(r);}let e=await t.fs();try{switch(!0){case(A_Context.environment==="server"&&!!e.existsSync(`${A_Context.concept}.conf.json`)):this.reader=this.scope.resolve(Q);break;case(A_Context.environment==="server"&&!e.existsSync(`${A_Context.concept}.conf.json`)):this.reader=this.scope.resolve(q);break;case A_Context.environment==="browser":this.reader=this.scope.resolve(q);break;default:throw new D(D.InitializationError,`Environment ${A_Context.environment} is not supported`)}}catch(r){if(r instanceof A_ScopeError)throw new D({title:D.InitializationError,description:`Failed to initialize A_ConfigLoader. Reader not found for environment ${A_Context.environment}`,originalError:r})}}};i(he,"A_ConfigLoader"),p([A_Concept.Load({before:/.*/}),c(0,A_Inject(h))],he.prototype,"prepare",1);var ke=he;var gr=(k=>k)(gr||{});var fe={A_LOGGER_LEVEL:"A_LOGGER_LEVEL",A_LOGGER_DEFAULT_SCOPE_LENGTH:"A_LOGGER_DEFAULT_SCOPE_LENGTH",A_LOGGER_DEFAULT_SCOPE_COLOR:"A_LOGGER_DEFAULT_SCOPE_COLOR",A_LOGGER_DEFAULT_LOG_COLOR:"A_LOGGER_DEFAULT_LOG_COLOR"},an=[fe.A_LOGGER_LEVEL,fe.A_LOGGER_DEFAULT_SCOPE_LENGTH,fe.A_LOGGER_DEFAULT_SCOPE_COLOR,fe.A_LOGGER_DEFAULT_LOG_COLOR];var ge=class ge extends A_Error{};i(ge,"A_ManifestError"),ge.ManifestInitializationError="A-Manifest Initialization Error";var G=ge;var Me=class Me{constructor(t,e,r,o=false){this.manifest=t;this.component=e;this.method=r;this.checkExclusion=o;}for(t){let e=this.manifest.internal_checkAccess({component:this.component,method:this.method,target:t});return this.checkExclusion?!e:e}};i(Me,"A_ManifestChecker");var H=Me;var Ue=class Ue extends A_Fragment{constructor(e=[]){super({name:"A-Manifest"});this.rules=[];this.prepare(e);}prepare(e){if(!A_TypeGuards.isArray(e))throw new G(G.ManifestInitializationError,"A-Manifest configuration should be an array of configurations");for(let r of e)this.processConfigItem(r);}processConfigItem(e){if(!A_TypeGuards.isComponentConstructor(e.component))throw new G(G.ManifestInitializationError,"A-Manifest configuration item should be a A-Component constructor");let r=this.constructorToRegex(e.component);if(e.apply||e.exclude){let o=/.*/;this.rules.push({componentRegex:r,methodRegex:o,applyRegex:e.apply?this.allowedComponentsToRegex(e.apply):void 0,excludeRegex:e.exclude?this.allowedComponentsToRegex(e.exclude):void 0});}if(e.methods&&e.methods.length>0)for(let o of e.methods){let n=this.methodToRegex(o.method);this.rules.push({componentRegex:r,methodRegex:n,applyRegex:o.apply?this.allowedComponentsToRegex(o.apply):void 0,excludeRegex:o.exclude?this.allowedComponentsToRegex(o.exclude):void 0});}}constructorToRegex(e){return new RegExp(`^${this.escapeRegex(e.name)}$`)}methodToRegex(e){return e instanceof RegExp?e:new RegExp(`^${this.escapeRegex(e)}$`)}allowedComponentsToRegex(e){if(e instanceof RegExp)return e;let r=e.map(o=>this.escapeRegex(o.name));return new RegExp(`^(${r.join("|")})$`)}escapeRegex(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}configItemToRegexp(e){return this.constructorToRegex(e)}ID(e,r){return `${e.name}.${r}`}isAllowed(e,r){let o=typeof e=="function"?e:e.constructor;return new H(this,o,r)}internal_checkAccess(e){let r=e.component.name,o=e.method,n=e.target.name,s=this.rules.filter(a=>a.componentRegex.test(r)&&a.methodRegex.test(o)).sort((a,d)=>{let b=a.methodRegex.source===".*",m=d.methodRegex.source===".*";return b&&!m?1:!b&&m?-1:0});if(s.length===0)return true;for(let a of s){if(a.excludeRegex&&a.excludeRegex.test(n))return false;if(a.applyRegex)return a.applyRegex.test(n)}return true}isExcluded(e,r){let o=typeof e=="function"?e:e.constructor;return new H(this,o,r,true)}};i(Ue,"A_Manifest");var Fe=Ue;var Er=(m=>(m.onInit="onInit",m.onDestroy="onDestroy",m.onExpire="onExpire",m.onError="onError",m.onSerialize="onSerialize",m.onSet="onSet",m.onGet="onGet",m.onDrop="onDrop",m.onClear="onClear",m.onHas="onHas",m))(Er||{});var ze=class ze extends A_Fragment{set(t,e){super.set(t,e);}get(t){return super.get(t)}};i(ze,"A_MemoryContext");var S=ze;var w=class w extends A_Error{};i(w,"A_MemoryError"),w.MemoryInitializationError="Memory initialization error",w.MemoryDestructionError="Memory destruction error",w.MemoryGetError="Memory GET operation failed",w.MemorySetError="Memory SET operation failed",w.MemoryDropError="Memory DROP operation failed",w.MemoryClearError="Memory CLEAR operation failed",w.MemoryHasError="Memory HAS operation failed",w.MemorySerializeError="Memory toJSON operation failed";var _=w;var Cr,xr,Rr,vr,wr,Pr,Or,Lr,Ir,x=class x extends A_Component{get ready(){return this._ready||(this._ready=this.init()),this._ready}async[Ir="onError"](...t){}async[Lr="onExpire"](...t){}async[Or="onInit"](t,...e){t||(t=new S,A_Context.scope(this).register(t));}async[Pr="onDestroy"](t,...e){t.clear();}async[wr="onGet"](t,e,...r){t.succeed(e.get(t.params.key));}async[vr="onHas"](t,e,...r){t.succeed(e.has(t.params.key));}async[Rr="onSet"](t,e,...r){e.set(t.params.key,t.params.value);}async[xr="onDrop"](t,e,...r){e.drop(t.params.key);}async[Cr="onClear"](t,e,...r){e.clear();}async init(){if(this._ready)return this._ready;let t=new A_Scope({name:"A-Memory-Init-Scope"}).inherit(A_Context.scope(this));try{await this.call("onInit",t);}catch(e){let r=new _({title:_.MemoryInitializationError,description:"An error occurred during memory initialization",originalError:e});throw t.register(r),await this.call("onError",t),t.destroy(),r}}async destroy(){let t=new A_Scope({name:"A-Memory-Destroy-Scope"}).inherit(A_Context.scope(this));try{this._ready=void 0,await this.call("onDestroy",t);}catch(e){let r=new _({title:_.MemoryDestructionError,description:"An error occurred during memory destruction",originalError:e});throw t.register(r),await this.call("onError",t),t.destroy(),r}}async get(t){let e=new l("get",{key:t}),r=new A_Scope({name:"A-Memory-Get-Operation-Scope",fragments:[e]});try{return await this.call("onGet",r),r.destroy(),e.result}catch(o){let n=new _({title:_.MemoryGetError,description:`An error occurred while getting the value for key "${String(t)}"`,originalError:o});throw r.register(n),await this.call("onError",r),r.destroy(),n}}async has(t){let e=new l("has",{key:t}),r=new A_Scope({name:"A-Memory-Has-Operation-Scope",fragments:[e]});try{return await this.call("onHas",r),r.destroy(),e.result}catch(o){let n=new _({title:_.MemoryHasError,description:`An error occurred while checking existence for key "${String(t)}"`,originalError:o});throw r.register(n),await this.call("onError",r),r.destroy(),n}}async set(t,e){let r=new l("set",{key:t,value:e}),o=new A_Scope({name:"A-Memory-Set-Operation-Scope",fragments:[r]});try{await this.call("onSet",o);}catch(n){let s=new _({title:_.MemorySetError,description:`An error occurred while setting the value for key "${String(t)}"`,originalError:n});throw o.register(s),await this.call("onError",o),o.destroy(),s}}async drop(t){let e=new l("drop",{key:t}),r=new A_Scope({name:"A-Memory-Drop-Operation-Scope",fragments:[e]});try{await this.call("onDrop",r);}catch(o){let n=new _({title:_.MemoryDropError,description:`An error occurred while dropping the value for key "${String(t)}"`,originalError:o});throw r.register(n),await this.call("onError",r),r.destroy(),n}}async clear(){let t=new l("clear"),e=new A_Scope({name:"A-Memory-Clear-Operation-Scope",fragments:[t]});try{await this.call("onClear",e);}catch(r){let o=new _({title:_.MemoryClearError,description:"An error occurred while clearing the memory",originalError:r});throw e.register(o),await this.call("onError",e),e.destroy(),o}}async toJSON(){let t=new l("serialize"),e=new A_Scope({name:"A-Memory-Serialize-Operation-Scope",fragments:[t]});try{return await this.call("onSerialize",e),t.result}catch(r){let o=new _({title:_.MemorySerializeError,description:"An error occurred while serializing the memory",originalError:r});throw e.register(o),await this.call("onError",e),e.destroy(),o}}};i(x,"A_Memory"),p([A_Feature.Extend()],x.prototype,Ir,1),p([A_Feature.Extend()],x.prototype,Lr,1),p([A_Feature.Extend(),c(0,A_Inject(S))],x.prototype,Or,1),p([A_Feature.Extend(),c(0,A_Inject(S))],x.prototype,Pr,1),p([A_Feature.Extend(),c(0,A_Dependency.Required()),c(0,A_Inject(l)),c(1,A_Inject(S))],x.prototype,wr,1),p([A_Feature.Extend(),c(0,A_Dependency.Required()),c(0,A_Inject(l)),c(1,A_Inject(S))],x.prototype,vr,1),p([A_Feature.Extend(),c(0,A_Dependency.Required()),c(0,A_Inject(l)),c(1,A_Inject(S))],x.prototype,Rr,1),p([A_Feature.Extend(),c(0,A_Dependency.Required()),c(0,A_Inject(l)),c(1,A_Inject(S))],x.prototype,xr,1),p([A_Feature.Extend(),c(0,A_Dependency.Required()),c(0,A_Inject(l)),c(1,A_Inject(S))],x.prototype,Cr,1);var Ye=x;var Ve=class Ve{constructor(){this.promise=new Promise((t,e)=>{this.resolveFn=t,this.rejectFn=e;});}resolve(t){this.resolveFn(t);}reject(t){this.rejectFn(t);}};i(Ve,"A_Deferred");var te=Ve;var je=class je{constructor(t,e,r){this.config={resolveOnClear:false};r&&(this.config={...this.config,...r}),this.deferred=new te,this.timeout=setTimeout(()=>e().then((...o)=>this.deferred.resolve(...o)).catch((...o)=>this.deferred.reject(...o)),t);}get promise(){return this.deferred.promise}clear(){this.timeout&&(clearTimeout(this.timeout),this.config.resolveOnClear?this.deferred.resolve(void 0):this.deferred.reject(new A_Error("Timeout Cleared")));}};i(je,"A_ScheduleObject");var K=je;var He=class He extends A_Component{async schedule(t,e,r){let o=A_TypeGuards.isString(t)?new Date(t).getTime():t;return new K(o-Date.now(),e,r)}async delay(t,e,r){return new K(t,e,r)}};i(He,"A_Schedule");var qe=He;export{So as A_CONSTANTS__CONFIG_ENV_VARIABLES,B as A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY,Ae as A_Channel,M as A_ChannelError,dt as A_ChannelFeatures,X as A_ChannelRequest,ht as A_ChannelRequestStatuses,ve as A_Command,L as A_CommandError,yt as A_CommandFeatures,ut as A_CommandTransitions,gt as A_Command_Status,f as A_Config,D as A_ConfigError,ke as A_ConfigLoader,te as A_Deferred,N as A_LOGGER_ANSI,Qe as A_LOGGER_COLORS,Oo as A_LOGGER_DEFAULT_LEVEL,We as A_LOGGER_DEFAULT_SCOPE_LENGTH,Z as A_LOGGER_ENV_KEYS,T as A_LOGGER_FORMAT,et as A_LOGGER_SAFE_RANDOM_COLORS,j as A_LOGGER_TIME_FORMAT,v as A_Logger,fe as A_LoggerEnvVariables,an as A_LoggerEnvVariablesArray,Fe as A_Manifest,H as A_ManifestChecker,G as A_ManifestError,Ye as A_Memory,S as A_MemoryContext,_ as A_MemoryError,Er as A_MemoryFeatures,l as A_OperationContext,h as A_Polyfill,qe as A_Schedule,K as A_ScheduleObject,O as A_StateMachine,V as A_StateMachineError,At as A_StateMachineFeatures,R as A_StateMachineTransition,gr as A_TYPES__ConfigFeature,y as ConfigReader,q as ENVConfigReader,Q as FileConfigReader};//# sourceMappingURL=index.mjs.map
|
|
43
|
+
`)}getTime(){let e=new Date,r=String(e.getMinutes()).padStart(q.MINUTES_PAD,"0"),o=String(e.getSeconds()).padStart(q.SECONDS_PAD,"0"),n=String(e.getMilliseconds()).padStart(q.MILLISECONDS_PAD,"0");return `${r}${q.SEPARATOR}${o}${q.SEPARATOR}${n}`}};i(w,"A_Logger"),w=p([a(0,A_Inject(A_Scope)),a(1,A_Inject(f))],w);var Gt,Mt,$t,Ft,Ut,zt,Yt,Bt,Vt,jt,qt,g=class g extends A_Entity{constructor(e){super(e);this._listeners=new Map;}static get code(){return super.entity}get duration(){return this._endTime&&this._startTime?this._endTime.getTime()-this._startTime.getTime():this._startTime?new Date().getTime()-this._startTime.getTime():void 0}get idleTime(){return this._startTime&&this._createdAt?this._startTime.getTime()-this._createdAt.getTime():void 0}get scope(){return this._executionScope}get context(){return this.scope.resolve(R)}get code(){return this.constructor.code}get status(){return this._status}get createdAt(){return this._createdAt}get startedAt(){return this._startTime}get endedAt(){return this._endTime}get result(){return this._result}get error(){return this._error}get params(){return this._params}get isProcessed(){return this._status==="COMPLETED"||this._status==="FAILED"}async[qt="onBeforeTransition"](e,r,...o){this.checkScopeInheritance(),r?.debug("yellow",`Command ${this.aseid.toString()} transitioning from ${e.from} to ${e.to}`);}async[jt="created_initialized"](e,...r){this._status==="CREATED"&&(this._createdAt=new Date,this._status="INITIALIZED",this.emit("onInit"));}async[Vt="initialized_executing"](e,...r){this._status!=="INITIALIZED"&&this._status!=="CREATED"||(this._startTime=new Date,this._status="EXECUTING",this.emit("onExecute"));}async[Bt="executing_completed"](e,...r){this._endTime=new Date,this._status="COMPLETED",this.emit("onComplete");}async[Yt="executing_failed"](e,r,...o){this._endTime=new Date,this._status="FAILED",this.emit("onFail");}async[zt="onInit"](e,...r){await e.transition("CREATED","INITIALIZED");}async[Ut="onBeforeExecute"](e,...r){await e.transition("INITIALIZED","EXECUTING");}async[Ft="onExecute"](...e){}async[$t="onAfterExecute"](...e){}async[Mt="onComplete"](e,...r){await e.transition("EXECUTING","COMPLETED");}async[Gt="onFail"](e,r,...o){await e.transition("EXECUTING","FAILED");}async init(){await this.call("onInit",this.scope);}async execute(){if(!this.isProcessed)try{this.checkScopeInheritance();let e=new R("execute-command");this.scope.register(e),await new Promise(async(r,o)=>{try{let n=new A_Feature({name:"onBeforeExecute",component:this,scope:this.scope}),s=new A_Feature({name:"onExecute",component:this,scope:this.scope}),c=new A_Feature({name:"onAfterExecute",component:this,scope:this.scope});this.on("onComplete",()=>{n.interrupt(),s.interrupt(),c.interrupt(),r();}),await n.process(this.scope),await s.process(this.scope),await c.process(this.scope),this._origin==="invoked"&&await this.complete(),r();}catch(n){o(n);}});}catch(e){let r=e instanceof A_Error?e:new b({title:b.ExecutionError,description:`An error occurred while executing command "${this.aseid.toString()}".`,originalError:e});await this.fail(r);}}async complete(e){this.isProcessed||(this._status="COMPLETED",this._result=e,await this.call("onComplete",this.scope),this.scope.destroy());}async fail(e){this.isProcessed||(this._status="FAILED",e&&(this._error=e,this.scope.register(e)),await this.call("onFail",this.scope),this.scope.destroy());}on(e,r){this._listeners.has(e)||this._listeners.set(e,new Set),this._listeners.get(e).add(r);}off(e,r){this._listeners.get(e)?.delete(r);}emit(e){this._listeners.get(e)?.forEach(async r=>{r(this);});}fromNew(e){super.fromNew(e),this._origin="invoked",this._executionScope=new A_Scope({name:`A-Command-Execution-Scope-${this.aseid.toString()}`,components:[L]}),this._createdAt=new Date,this._params=e,this._status="CREATED";}fromJSON(e){super.fromJSON(e),this._origin="serialized",this._executionScope=new A_Scope({name:`A-Command-Execution-Scope-${this.aseid.toString()}`,components:[L]}),e.createdAt&&(this._createdAt=new Date(e.createdAt)),e.startedAt&&(this._startTime=new Date(e.startedAt)),e.endedAt&&(this._endTime=new Date(e.endedAt)),this._params=e.params,this._status=e.status,e.error&&(this._error=new b(e.error)),e.result&&(this._result=e.result);}toJSON(){return {...super.toJSON(),code:this.code,status:this._status,params:this._params,createdAt:this._createdAt.toISOString(),startedAt:this._startTime?this._startTime.toISOString():void 0,endedAt:this._endTime?this._endTime.toISOString():void 0,duration:this.duration,idleTime:this.idleTime,result:this.result,error:this.error?this.error.toJSON():void 0}}checkScopeInheritance(){let e;try{e=A_Context.scope(this);}catch(r){throw new b({title:b.CommandScopeBindingError,description:`Command ${this.aseid.toString()} is not bound to any context scope. Ensure the command is properly registered within a context before execution.`,originalError:r})}this.scope.isInheritedFrom(A_Context.scope(this))||this.scope.inherit(A_Context.scope(this));}};i(g,"A_Command"),p([A_Feature.Extend(),a(0,A_Inject(v)),a(1,A_Inject(w))],g.prototype,qt,1),p([A_Feature.Extend(),a(0,A_Inject(v))],g.prototype,jt,1),p([A_Feature.Extend(),a(0,A_Inject(v))],g.prototype,Vt,1),p([A_Feature.Extend(),a(0,A_Inject(v))],g.prototype,Bt,1),p([A_Feature.Extend(),a(0,A_Inject(v)),a(1,A_Inject(A_Error))],g.prototype,Yt,1),p([A_Feature.Extend(),a(0,A_Inject(L))],g.prototype,zt,1),p([A_Feature.Extend({after:/.*/}),a(0,A_Dependency.Required()),a(0,A_Inject(L))],g.prototype,Ut,1),p([A_Feature.Extend()],g.prototype,Ft,1),p([A_Feature.Extend()],g.prototype,$t,1),p([A_Feature.Extend({after:/.*/}),a(0,A_Inject(L))],g.prototype,Mt,1),p([A_Feature.Extend({after:/.*/}),a(0,A_Dependency.Required()),a(0,A_Inject(L)),a(1,A_Inject(R))],g.prototype,Gt,1);var Pe=g;var Oe=class Oe{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._fs}async init(){try{A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){this._fs=await import('fs');}initBrowser(){this._fs={readFileSync:i((t,e)=>(this.logger.warning("fs.readFileSync not available in browser environment"),""),"readFileSync"),existsSync:i(t=>(this.logger.warning("fs.existsSync not available in browser environment"),false),"existsSync"),createReadStream:i(t=>(this.logger.warning("fs.createReadStream not available in browser environment"),null),"createReadStream")};}};i(Oe,"A_FSPolyfillClass");var se=Oe;var Le=class Le{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(t){return this._initialized||(this._fsPolyfill=t,await this.init()),this._crypto}async init(){try{A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('crypto');this._crypto={createTextHash:i((e,r="sha384")=>Promise.resolve(`${r}-${t.createHash(r).update(e).digest("base64")}`),"createTextHash"),createFileHash:i((e,r="sha384")=>new Promise(async(o,n)=>{try{if(!this._fsPolyfill)throw new Error("FS polyfill is required for file hashing");let s=t.createHash(r),c=this._fsPolyfill.createReadStream(e);c.on("data",d=>s.update(d)),c.on("end",()=>o(`${r}-${s.digest("base64")}`)),c.on("error",d=>n(d));}catch(s){n(s);}}),"createFileHash")};}initBrowser(){this._crypto={createFileHash:i(()=>(this.logger.warning("File hash not available in browser environment"),Promise.resolve("")),"createFileHash"),createTextHash:i((t,e="SHA-384")=>new Promise(async(r,o)=>{try{if(!crypto.subtle)throw new Error("SubtleCrypto not available");let s=new TextEncoder().encode(t),c=await crypto.subtle.digest(e,s),d=Array.from(new Uint8Array(c)),D=btoa(String.fromCharCode(...d));r(`${e}-${D}`);}catch(n){o(n);}}),"createTextHash")};}};i(Le,"A_CryptoPolyfillClass");var ae=Le;var Ie=class Ie{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._http}async init(){try{A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('http');this._http={request:t.request,get:t.get,createServer:t.createServer};}initBrowser(){this._http={request:i((t,e)=>(this.logger.warning("http.request not available in browser/test environment, use fetch instead"),this.createMockRequest(t,e,false)),"request"),get:i((t,e)=>(this.logger.warning("http.get not available in browser/test environment, use fetch instead"),this.createMockRequest(typeof t=="string"?{hostname:t}:t,e,false)),"get"),createServer:i(()=>(this.logger.error("http.createServer not available in browser/test environment"),null),"createServer")};}createMockRequest(t,e,r=false){return {end:i(()=>{if(e){let n={statusCode:200,headers:{},on:i((s,c)=>{s==="data"?setTimeout(()=>c("mock data"),0):s==="end"&&setTimeout(()=>c(),0);},"on"),pipe:i(s=>{s.write&&s.write("mock data"),s.end&&s.end();},"pipe")};setTimeout(()=>e(n),0);}},"end"),write:i(n=>{},"write"),on:i((n,s)=>{},"on")}}};i(Ie,"A_HttpPolyfillClass");var ce=Ie;var be=class be{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._https}async init(){try{A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('https');this._https={request:t.request,get:t.get,createServer:t.createServer};}initBrowser(){this._https={request:i((t,e)=>(this.logger.warning("https.request not available in browser/test environment, use fetch instead"),this.createMockRequest(t,e,true)),"request"),get:i((t,e)=>(this.logger.warning("https.get not available in browser/test environment, use fetch instead"),this.createMockRequest(typeof t=="string"?{hostname:t}:t,e,true)),"get"),createServer:i(()=>(this.logger.error("https.createServer not available in browser/test environment"),null),"createServer")};}createMockRequest(t,e,r=true){return {end:i(()=>{if(e){let n={statusCode:200,headers:{},on:i((s,c)=>{s==="data"?setTimeout(()=>c("mock data"),0):s==="end"&&setTimeout(()=>c(),0);},"on"),pipe:i(s=>{s.write&&s.write("mock data"),s.end&&s.end();},"pipe")};setTimeout(()=>e(n),0);}},"end"),write:i(n=>{},"write"),on:i((n,s)=>{},"on")}}};i(be,"A_HttpsPolyfillClass");var pe=be;var Ne=class Ne{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._path}async init(){try{A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){this._path=await import('path');}initBrowser(){this._path={join:i((...t)=>t.join("/").replace(/\/+/g,"/"),"join"),resolve:i((...t)=>{let e="";for(let r of t)r.startsWith("/")?e=r:e=this._path.join(e,r);return e||"/"},"resolve"),dirname:i(t=>t.split("/").slice(0,-1).join("/")||"/","dirname"),basename:i((t,e)=>{let r=t.split("/").pop()||"";return e&&r.endsWith(e)?r.slice(0,-e.length):r},"basename"),extname:i(t=>{let e=t.split(".");return e.length>1?"."+e.pop():""},"extname"),relative:i((t,e)=>e.replace(t,"").replace(/^\//,""),"relative"),normalize:i(t=>t.replace(/\/+/g,"/").replace(/\/$/,"")||"/","normalize"),isAbsolute:i(t=>t.startsWith("/")||/^[a-zA-Z]:/.test(t),"isAbsolute"),parse:i(t=>{let e=this._path.extname(t),r=this._path.basename(t),o=this._path.basename(t,e);return {root:"/",dir:this._path.dirname(t),base:r,ext:e,name:o}},"parse"),format:i(t=>this._path.join(t.dir||"",t.base||""),"format"),sep:"/",delimiter:":"};}};i(Ne,"A_PathPolyfillClass");var le=Ne;var De=class De{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._url}async init(){try{A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('url');this._url={parse:t.parse,format:t.format,resolve:t.resolve,URL:t.URL||globalThis.URL,URLSearchParams:t.URLSearchParams||globalThis.URLSearchParams};}initBrowser(){this._url={parse:i(t=>{try{let e=new URL(t);return {protocol:e.protocol,hostname:e.hostname,port:e.port,pathname:e.pathname,search:e.search,hash:e.hash,host:e.host,href:e.href}}catch{return {}}},"parse"),format:i(t=>{try{return new URL("",t.href||`${t.protocol}//${t.host}${t.pathname}${t.search}${t.hash}`).href}catch{return ""}},"format"),resolve:i((t,e)=>{try{return new URL(e,t).href}catch{return e}},"resolve"),URL:globalThis.URL,URLSearchParams:globalThis.URLSearchParams};}};i(De,"A_UrlPolyfillClass");var _e=De;var ke=class ke{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._buffer}async init(){try{A_Context.environment==="server"?await this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}async initServer(){let t=await import('buffer');this._buffer={from:t.Buffer.from,alloc:t.Buffer.alloc,allocUnsafe:t.Buffer.allocUnsafe,isBuffer:t.Buffer.isBuffer,concat:t.Buffer.concat};}initBrowser(){this._buffer={from:i((t,e)=>typeof t=="string"?new TextEncoder().encode(t):new Uint8Array(t),"from"),alloc:i((t,e)=>{let r=new Uint8Array(t);return e!==void 0&&r.fill(e),r},"alloc"),allocUnsafe:i(t=>new Uint8Array(t),"allocUnsafe"),isBuffer:i(t=>t instanceof Uint8Array||t instanceof ArrayBuffer,"isBuffer"),concat:i((t,e)=>{let r=e||t.reduce((s,c)=>s+c.length,0),o=new Uint8Array(r),n=0;for(let s of t)o.set(s,n),n+=s.length;return o},"concat")};}};i(ke,"A_BufferPolyfillClass");var me=ke;var Ge=class Ge{constructor(t){this.logger=t;this._initialized=false;}get isInitialized(){return this._initialized}async get(){return this._initialized||await this.init(),this._process}async init(){try{A_Context.environment==="server"?this.initServer():this.initBrowser(),this._initialized=!0;}catch{this.initBrowser(),this._initialized=true;}}initServer(){this._process={env:process.env,argv:process.argv,platform:process.platform,version:process.version,versions:process.versions,cwd:process.cwd,exit:process.exit,nextTick:process.nextTick};}initBrowser(){this._process={env:{NODE_ENV:"browser",...globalThis.process?.env||{}},argv:["browser"],platform:"browser",version:"browser",versions:{node:"browser"},cwd:i(()=>"/","cwd"),exit:i(t=>{throw this.logger.warning("process.exit not available in browser"),new Error(`Process exit with code ${t}`)},"exit"),nextTick:i((t,...e)=>{setTimeout(()=>t(...e),0);},"nextTick")};}};i(Ge,"A_ProcessPolyfillClass");var de=Ge;var h=class extends A_Component{constructor(e){super();this.logger=e;this._initializing=null;}get ready(){return this._initialized||(this._initialized=this._loadInternal()),this._initialized}async load(){await this.ready;}async attachToWindow(){A_Context.environment==="browser"&&(globalThis.A_Polyfill=this,globalThis.process={env:{NODE_ENV:"production"},cwd:i(()=>"/","cwd")},globalThis.__dirname="/");}async _loadInternal(){this._fsPolyfill=new se(this.logger),this._cryptoPolyfill=new ae(this.logger),this._httpPolyfill=new ce(this.logger),this._httpsPolyfill=new pe(this.logger),this._pathPolyfill=new le(this.logger),this._urlPolyfill=new _e(this.logger),this._bufferPolyfill=new me(this.logger),this._processPolyfill=new de(this.logger),await this._fsPolyfill.get(),await this._cryptoPolyfill.get(await this._fsPolyfill.get()),await this._httpPolyfill.get(),await this._httpsPolyfill.get(),await this._pathPolyfill.get(),await this._urlPolyfill.get(),await this._bufferPolyfill.get(),await this._processPolyfill.get();}async fs(){return await this.ready,await this._fsPolyfill.get()}async crypto(){return await this.ready,await this._cryptoPolyfill.get()}async http(){return await this.ready,await this._httpPolyfill.get()}async https(){return await this.ready,await this._httpsPolyfill.get()}async path(){return await this.ready,await this._pathPolyfill.get()}async url(){return await this.ready,await this._urlPolyfill.get()}async buffer(){return await this.ready,await this._bufferPolyfill.get()}async process(){return await this.ready,await this._processPolyfill.get()}};i(h,"A_Polyfill"),p([A_Concept.Load()],h.prototype,"load",1),p([A_Concept.Load()],h.prototype,"attachToWindow",1),h=p([a(0,A_Inject(w))],h);var u=class extends A_Component{constructor(e){super();this.polyfill=e;this.DEFAULT_ALLOWED_TO_READ_PROPERTIES=[...A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,...j];}async attachContext(e,r,o){o||(o=new f({defaults:{}}),e.scope.register(o));let n=await this.getProjectRoot();o.set("A_CONCEPT_ROOT_FOLDER",n);}async initialize(e){let r=await this.read();for(let o in r)e.set(o,r[o]);}resolve(e){return e}async read(e=[]){return {}}async getProjectRoot(e=__dirname){return (await this.polyfill.process()).cwd()}};i(u,"ConfigReader"),p([A_Concept.Load(),a(0,A_Inject(A_Container)),a(1,A_Inject(A_Scope)),a(2,A_Inject(f))],u.prototype,"attachContext",1),p([A_Concept.Load(),a(0,A_Dependency.Required()),a(0,A_Inject(f))],u.prototype,"initialize",1),u=p([a(0,A_Dependency.Required()),a(0,A_Inject(h))],u);var Me=class Me extends u{constructor(){super(...arguments);this.FileData=new Map;}getConfigurationProperty_File_Alias(e){return A_FormatterHelper.toCamelCase(e)}resolve(e){return this.FileData.get(this.getConfigurationProperty_File_Alias(e))}async read(e){let r=await this.polyfill.fs();try{let o=r.readFileSync(`${A_Context.concept}.conf.json`,"utf8"),n=JSON.parse(o);return this.FileData=new Map(Object.entries(n)),n}catch{return {}}}};i(Me,"FileConfigReader");var ee=Me;var he=class he extends u{async readEnvFile(t,e,r){let o=await e.fs();o.existsSync(".env")&&o.readFileSync(`${t.get("A_CONCEPT_ROOT_FOLDER")}/.env`,"utf-8").split(`
|
|
44
|
+
`).forEach(n=>{let[s,c]=n.split("=");s&&c&&(process.env[s.trim()]=c.trim());});}getConfigurationProperty_ENV_Alias(t){return A_FormatterHelper.toUpperSnakeCase(t)}resolve(t){return process.env[this.getConfigurationProperty_ENV_Alias(t)]}async read(t=[]){let e=[...t,...Object.keys(process.env)],r={};return e.forEach(o=>{r[o]=this.resolve(o);}),r}};i(he,"ENVConfigReader"),p([A_Concept.Load({before:["ENVConfigReader.initialize"]}),a(0,A_Inject(f)),a(1,A_Inject(h)),a(2,A_Inject(A_Feature))],he.prototype,"readEnvFile",1);var H=he;var fe=class fe extends A_Container{async prepare(t){if(!this.scope.has(f)){let r=new f({variables:[...A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,...j],defaults:{}});this.scope.register(r);}let e=await t.fs();try{switch(!0){case(A_Context.environment==="server"&&!!e.existsSync(`${A_Context.concept}.conf.json`)):this.reader=this.scope.resolve(ee);break;case(A_Context.environment==="server"&&!e.existsSync(`${A_Context.concept}.conf.json`)):this.reader=this.scope.resolve(H);break;case A_Context.environment==="browser":this.reader=this.scope.resolve(H);break;default:throw new I(I.InitializationError,`Environment ${A_Context.environment} is not supported`)}}catch(r){if(r instanceof A_ScopeError)throw new I({title:I.InitializationError,description:`Failed to initialize A_ConfigLoader. Reader not found for environment ${A_Context.environment}`,originalError:r})}}};i(fe,"A_ConfigLoader"),p([A_Concept.Load({before:/.*/}),a(0,A_Inject(h))],fe.prototype,"prepare",1);var Fe=fe;var ur=($=>$)(ur||{});var ye={A_LOGGER_LEVEL:"A_LOGGER_LEVEL",A_LOGGER_DEFAULT_SCOPE_LENGTH:"A_LOGGER_DEFAULT_SCOPE_LENGTH",A_LOGGER_DEFAULT_SCOPE_COLOR:"A_LOGGER_DEFAULT_SCOPE_COLOR",A_LOGGER_DEFAULT_LOG_COLOR:"A_LOGGER_DEFAULT_LOG_COLOR"},fn=[ye.A_LOGGER_LEVEL,ye.A_LOGGER_DEFAULT_SCOPE_LENGTH,ye.A_LOGGER_DEFAULT_SCOPE_COLOR,ye.A_LOGGER_DEFAULT_LOG_COLOR];var ge=class ge extends A_Error{};i(ge,"A_ManifestError"),ge.ManifestInitializationError="A-Manifest Initialization Error";var G=ge;var Ue=class Ue{constructor(t,e,r,o=false){this.manifest=t;this.component=e;this.method=r;this.checkExclusion=o;}for(t){let e=this.manifest.internal_checkAccess({component:this.component,method:this.method,target:t});return this.checkExclusion?!e:e}};i(Ue,"A_ManifestChecker");var K=Ue;var Ye=class Ye extends A_Fragment{constructor(e=[]){super({name:"A-Manifest"});this.rules=[];this.prepare(e);}prepare(e){if(!A_TypeGuards.isArray(e))throw new G(G.ManifestInitializationError,"A-Manifest configuration should be an array of configurations");for(let r of e)this.processConfigItem(r);}processConfigItem(e){if(!A_TypeGuards.isComponentConstructor(e.component))throw new G(G.ManifestInitializationError,"A-Manifest configuration item should be a A-Component constructor");let r=this.constructorToRegex(e.component);if(e.apply||e.exclude){let o=/.*/;this.rules.push({componentRegex:r,methodRegex:o,applyRegex:e.apply?this.allowedComponentsToRegex(e.apply):void 0,excludeRegex:e.exclude?this.allowedComponentsToRegex(e.exclude):void 0});}if(e.methods&&e.methods.length>0)for(let o of e.methods){let n=this.methodToRegex(o.method);this.rules.push({componentRegex:r,methodRegex:n,applyRegex:o.apply?this.allowedComponentsToRegex(o.apply):void 0,excludeRegex:o.exclude?this.allowedComponentsToRegex(o.exclude):void 0});}}constructorToRegex(e){return new RegExp(`^${this.escapeRegex(e.name)}$`)}methodToRegex(e){return e instanceof RegExp?e:new RegExp(`^${this.escapeRegex(e)}$`)}allowedComponentsToRegex(e){if(e instanceof RegExp)return e;let r=e.map(o=>this.escapeRegex(o.name));return new RegExp(`^(${r.join("|")})$`)}escapeRegex(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}configItemToRegexp(e){return this.constructorToRegex(e)}ID(e,r){return `${e.name}.${r}`}isAllowed(e,r){let o=typeof e=="function"?e:e.constructor;return new K(this,o,r)}internal_checkAccess(e){let r=e.component.name,o=e.method,n=e.target.name,s=this.rules.filter(c=>c.componentRegex.test(r)&&c.methodRegex.test(o)).sort((c,d)=>{let D=c.methodRegex.source===".*",m=d.methodRegex.source===".*";return D&&!m?1:!D&&m?-1:0});if(s.length===0)return true;for(let c of s){if(c.excludeRegex&&c.excludeRegex.test(n))return false;if(c.applyRegex)return c.applyRegex.test(n)}return true}isExcluded(e,r){let o=typeof e=="function"?e:e.constructor;return new K(this,o,r,true)}};i(Ye,"A_Manifest");var ze=Ye;var Ar=(m=>(m.onInit="onInit",m.onDestroy="onDestroy",m.onExpire="onExpire",m.onError="onError",m.onSerialize="onSerialize",m.onSet="onSet",m.onGet="onGet",m.onDrop="onDrop",m.onClear="onClear",m.onHas="onHas",m))(Ar||{});var Be=class Be extends A_Fragment{constructor(){super(...arguments);this._storage=new Map;}set(e,r){this._storage.set(e,r);}get(e){return this._storage.get(e)}delete(e){this._storage.delete(e);}has(e){return this._storage.has(e)}clear(){this._storage.clear();}};i(Be,"A_MemoryContext");var S=Be;var P=class P extends A_Error{};i(P,"A_MemoryError"),P.MemoryInitializationError="Memory initialization error",P.MemoryDestructionError="Memory destruction error",P.MemoryGetError="Memory GET operation failed",P.MemorySetError="Memory SET operation failed",P.MemoryDropError="Memory DROP operation failed",P.MemoryClearError="Memory CLEAR operation failed",P.MemoryHasError="Memory HAS operation failed",P.MemorySerializeError="Memory toJSON operation failed";var _=P;var Rr,vr,wr,Pr,Or,Lr,Ir,br,Nr,C=class C extends A_Component{get ready(){return this._ready||(this._ready=this.init()),this._ready}async[Nr="onError"](...t){}async[br="onExpire"](...t){}async[Ir="onInit"](t,...e){t||(t=new S,A_Context.scope(this).register(t));}async[Lr="onDestroy"](t,...e){t.clear();}async[Or="onGet"](t,e,...r){t.succeed(e.get(t.params.key));}async[Pr="onHas"](t,e,...r){t.succeed(e.has(t.params.key));}async[wr="onSet"](t,e,...r){e.set(t.params.key,t.params.value);}async[vr="onDrop"](t,e,...r){e.delete(t.params.key);}async[Rr="onClear"](t,e,...r){e.clear();}async init(){if(this._ready)return this._ready;let t=new A_Scope({name:"A-Memory-Init-Scope"}).inherit(A_Context.scope(this));try{await this.call("onInit",t);}catch(e){let r=new _({title:_.MemoryInitializationError,description:"An error occurred during memory initialization",originalError:e});throw t.register(r),await this.call("onError",t),t.destroy(),r}}async destroy(){let t=new A_Scope({name:"A-Memory-Destroy-Scope"}).inherit(A_Context.scope(this));try{this._ready=void 0,await this.call("onDestroy",t);}catch(e){let r=new _({title:_.MemoryDestructionError,description:"An error occurred during memory destruction",originalError:e});throw t.register(r),await this.call("onError",t),t.destroy(),r}}async get(t){let e=new l("get",{key:t}),r=new A_Scope({name:"A-Memory-Get-Operation-Scope",fragments:[e]});try{return await this.call("onGet",r),r.destroy(),e.result}catch(o){let n=new _({title:_.MemoryGetError,description:`An error occurred while getting the value for key "${String(t)}"`,originalError:o});throw r.register(n),await this.call("onError",r),r.destroy(),n}}async has(t){let e=new l("has",{key:t}),r=new A_Scope({name:"A-Memory-Has-Operation-Scope",fragments:[e]});try{return await this.call("onHas",r),r.destroy(),e.result}catch(o){let n=new _({title:_.MemoryHasError,description:`An error occurred while checking existence for key "${String(t)}"`,originalError:o});throw r.register(n),await this.call("onError",r),r.destroy(),n}}async set(t,e){let r=new l("set",{key:t,value:e}),o=new A_Scope({name:"A-Memory-Set-Operation-Scope",fragments:[r]});try{await this.call("onSet",o);}catch(n){let s=new _({title:_.MemorySetError,description:`An error occurred while setting the value for key "${String(t)}"`,originalError:n});throw o.register(s),await this.call("onError",o),o.destroy(),s}}async drop(t){let e=new l("drop",{key:t}),r=new A_Scope({name:"A-Memory-Drop-Operation-Scope",fragments:[e]});try{await this.call("onDrop",r);}catch(o){let n=new _({title:_.MemoryDropError,description:`An error occurred while dropping the value for key "${String(t)}"`,originalError:o});throw r.register(n),await this.call("onError",r),r.destroy(),n}}async clear(){let t=new l("clear"),e=new A_Scope({name:"A-Memory-Clear-Operation-Scope",fragments:[t]});try{await this.call("onClear",e);}catch(r){let o=new _({title:_.MemoryClearError,description:"An error occurred while clearing the memory",originalError:r});throw e.register(o),await this.call("onError",e),e.destroy(),o}}async toJSON(){let t=new l("serialize"),e=new A_Scope({name:"A-Memory-Serialize-Operation-Scope",fragments:[t]});try{return await this.call("onSerialize",e),t.result}catch(r){let o=new _({title:_.MemorySerializeError,description:"An error occurred while serializing the memory",originalError:r});throw e.register(o),await this.call("onError",e),e.destroy(),o}}};i(C,"A_Memory"),p([A_Feature.Extend()],C.prototype,Nr,1),p([A_Feature.Extend()],C.prototype,br,1),p([A_Feature.Extend(),a(0,A_Inject(S))],C.prototype,Ir,1),p([A_Feature.Extend(),a(0,A_Inject(S))],C.prototype,Lr,1),p([A_Feature.Extend(),a(0,A_Dependency.Required()),a(0,A_Inject(l)),a(1,A_Inject(S))],C.prototype,Or,1),p([A_Feature.Extend(),a(0,A_Dependency.Required()),a(0,A_Inject(l)),a(1,A_Inject(S))],C.prototype,Pr,1),p([A_Feature.Extend(),a(0,A_Dependency.Required()),a(0,A_Inject(l)),a(1,A_Inject(S))],C.prototype,wr,1),p([A_Feature.Extend(),a(0,A_Dependency.Required()),a(0,A_Inject(l)),a(1,A_Inject(S))],C.prototype,vr,1),p([A_Feature.Extend(),a(0,A_Dependency.Required()),a(0,A_Inject(l)),a(1,A_Inject(S))],C.prototype,Rr,1);var je=C;var qe=class qe{constructor(){this.promise=new Promise((t,e)=>{this.resolveFn=t,this.rejectFn=e;});}resolve(t){this.resolveFn(t);}reject(t){this.rejectFn(t);}};i(qe,"A_Deferred");var re=qe;var He=class He{constructor(t,e,r){this.config={resolveOnClear:false};r&&(this.config={...this.config,...r}),this.deferred=new re,this.timeout=setTimeout(()=>e().then((...o)=>this.deferred.resolve(...o)).catch((...o)=>this.deferred.reject(...o)),t);}get promise(){return this.deferred.promise}clear(){this.timeout&&(clearTimeout(this.timeout),this.config.resolveOnClear?this.deferred.resolve(void 0):this.deferred.reject(new A_Error("Timeout Cleared")));}};i(He,"A_ScheduleObject");var X=He;var Xe=class Xe extends A_Component{async schedule(t,e,r){let o=A_TypeGuards.isString(t)?new Date(t).getTime():t;return new X(o-Date.now(),e,r)}async delay(t,e,r){return new X(t,e,r)}};i(Xe,"A_Schedule");var Ke=Xe;export{wo as A_CONSTANTS__CONFIG_ENV_VARIABLES,j as A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY,xe as A_Channel,F as A_ChannelError,ft as A_ChannelFeatures,J as A_ChannelRequest,yt as A_ChannelRequestStatuses,Pe as A_Command,b as A_CommandError,Tt as A_CommandFeatures,Et as A_CommandTransitions,ut as A_Command_Status,f as A_Config,I as A_ConfigError,Fe as A_ConfigLoader,re as A_Deferred,R as A_ExecutionContext,k as A_LOGGER_ANSI,et as A_LOGGER_COLORS,Fo as A_LOGGER_DEFAULT_LEVEL,Qe as A_LOGGER_DEFAULT_SCOPE_LENGTH,Z as A_LOGGER_ENV_KEYS,T as A_LOGGER_FORMAT,tt as A_LOGGER_SAFE_RANDOM_COLORS,q as A_LOGGER_TIME_FORMAT,w as A_Logger,ye as A_LoggerEnvVariables,fn as A_LoggerEnvVariablesArray,ze as A_Manifest,K as A_ManifestChecker,G as A_ManifestError,je as A_Memory,S as A_MemoryContext,_ as A_MemoryError,Ar as A_MemoryFeatures,l as A_OperationContext,h as A_Polyfill,Ke as A_Schedule,X as A_ScheduleObject,L as A_StateMachine,V as A_StateMachineError,xt as A_StateMachineFeatures,v as A_StateMachineTransition,ur as A_TYPES__ConfigFeature,u as ConfigReader,H as ENVConfigReader,ee as FileConfigReader};//# sourceMappingURL=index.mjs.map
|
|
45
45
|
//# sourceMappingURL=index.mjs.map
|