@adaas/a-utils 0.1.30 → 0.1.32
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 +11 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +88 -32
- package/dist/index.d.ts +88 -32
- package/dist/index.mjs +11 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/lib/A-Memory/A-Memory.component.ts +1 -1
- package/src/lib/A-Signal/A-Signal.types.ts +12 -3
- package/src/lib/A-Signal/components/A-SignalBus.component.ts +15 -6
- package/src/lib/A-Signal/context/A-SignalConfig.context.ts +7 -5
- package/src/lib/A-Signal/context/A-SignalState.context.ts +17 -19
- package/src/lib/A-Signal/entities/A-Signal.entity.ts +31 -4
- package/src/lib/A-Signal/entities/A-SignalVector.entity.ts +141 -26
- package/tests/A-Signal.test.ts +73 -6
package/dist/index.d.mts
CHANGED
|
@@ -2320,6 +2320,9 @@ declare class A_Memory<_StorageType extends Record<string, any> = Record<string,
|
|
|
2320
2320
|
[A_MemoryFeatures.onExpire](...args: any[]): Promise<void>;
|
|
2321
2321
|
[A_MemoryFeatures.onInit](context: A_MemoryContext<_StorageType>, ...args: any[]): Promise<void>;
|
|
2322
2322
|
[A_MemoryFeatures.onDestroy](context: A_MemoryContext<_StorageType>, ...args: any[]): Promise<void>;
|
|
2323
|
+
/**
|
|
2324
|
+
* Handles the 'get' operation for retrieving a value from memory
|
|
2325
|
+
*/
|
|
2323
2326
|
[A_MemoryFeatures.onGet](operation: A_MemoryOperationContext, context: A_MemoryContext<_StorageType>, ...args: any[]): Promise<void>;
|
|
2324
2327
|
[A_MemoryFeatures.onHas](operation: A_MemoryOperationContext<boolean>, context: A_MemoryContext<_StorageType>, ...args: any[]): Promise<void>;
|
|
2325
2328
|
[A_MemoryFeatures.onSet](operation: A_MemoryOperationContext, context: A_MemoryContext<_StorageType>, scope: A_Scope, ...args: any[]): Promise<void>;
|
|
@@ -2469,9 +2472,9 @@ type A_SignalConfig_Init = {
|
|
|
2469
2472
|
*/
|
|
2470
2473
|
stringStructure?: string;
|
|
2471
2474
|
};
|
|
2472
|
-
type A_SignalVector_Init<
|
|
2473
|
-
structure:
|
|
2474
|
-
values:
|
|
2475
|
+
type A_SignalVector_Init<_TSignals extends Array<A_Signal> = Array<A_Signal>, _TVectorStructure extends Array<A_TYPES__Entity_Constructor<_TSignals[number]>> = Array<A_TYPES__Entity_Constructor<_TSignals[number]>>> = {
|
|
2476
|
+
structure: _TVectorStructure;
|
|
2477
|
+
values: _TSignals;
|
|
2475
2478
|
};
|
|
2476
2479
|
type A_SignalVector_Serialized = A_TYPES__Entity_Serialized & {
|
|
2477
2480
|
structure: string[];
|
|
@@ -2487,6 +2490,12 @@ type A_Signal_Init<T extends Record<string, any> = Record<string, any>> = {
|
|
|
2487
2490
|
*/
|
|
2488
2491
|
data: T;
|
|
2489
2492
|
};
|
|
2493
|
+
type A_Signal_Serialized<T extends Record<string, any> = Record<string, any>> = {
|
|
2494
|
+
/**
|
|
2495
|
+
* The signal data
|
|
2496
|
+
*/
|
|
2497
|
+
data: T;
|
|
2498
|
+
} & A_TYPES__Entity_Serialized;
|
|
2490
2499
|
|
|
2491
2500
|
/**
|
|
2492
2501
|
* A Signal Entity is an individual signal instance that carries data.
|
|
@@ -2501,9 +2510,18 @@ type A_Signal_Init<T extends Record<string, any> = Record<string, any>> = {
|
|
|
2501
2510
|
* Signals are typically used in scenarios where the current state is more important than individual events,
|
|
2502
2511
|
* such as monitoring systems, real-time dashboards, or stateful applications.
|
|
2503
2512
|
*/
|
|
2504
|
-
declare class A_Signal extends A_Entity<A_Signal_Init
|
|
2505
|
-
data:
|
|
2506
|
-
|
|
2513
|
+
declare class A_Signal<_TSignalDataType extends Record<string, any> = Record<string, any>> extends A_Entity<A_Signal_Init<_TSignalDataType>, A_Signal_Serialized<_TSignalDataType>> {
|
|
2514
|
+
data: _TSignalDataType;
|
|
2515
|
+
/**
|
|
2516
|
+
* Allows to define default data for the signal.
|
|
2517
|
+
*
|
|
2518
|
+
* If no data is provided during initialization, the default data will be used.
|
|
2519
|
+
*
|
|
2520
|
+
* @returns
|
|
2521
|
+
*/
|
|
2522
|
+
static default(): Promise<A_Signal | undefined>;
|
|
2523
|
+
fromJSON(serializedEntity: A_Signal_Serialized<_TSignalDataType>): void;
|
|
2524
|
+
fromNew(newEntity: A_Signal_Init<_TSignalDataType>): void;
|
|
2507
2525
|
/**
|
|
2508
2526
|
* Emits this signal within the provided scope.
|
|
2509
2527
|
*
|
|
@@ -2513,6 +2531,7 @@ declare class A_Signal extends A_Entity<A_Signal_Init> {
|
|
|
2513
2531
|
* @param scope
|
|
2514
2532
|
*/
|
|
2515
2533
|
emit(scope: A_Scope): Promise<void>;
|
|
2534
|
+
toJSON(): A_Signal_Serialized<_TSignalDataType>;
|
|
2516
2535
|
}
|
|
2517
2536
|
|
|
2518
2537
|
/**
|
|
@@ -2521,43 +2540,79 @@ declare class A_Signal extends A_Entity<A_Signal_Init> {
|
|
|
2521
2540
|
*
|
|
2522
2541
|
* Signal Vectors are useful in scenarios where multiple related signals need to be handled together,
|
|
2523
2542
|
* as a state of the system or a snapshot of various parameters at a given time.
|
|
2543
|
+
*
|
|
2544
|
+
* @template TSignalsConstructors - Array of signal constructor types (e.g., [typeof MySignal, typeof CustomSignal])
|
|
2545
|
+
* @template TSignals - Array of signal instances derived from constructors
|
|
2524
2546
|
*/
|
|
2525
|
-
declare class A_SignalVector extends A_Entity<A_SignalVector_Init, A_SignalVector_Serialized> {
|
|
2547
|
+
declare class A_SignalVector<TSignals extends Array<A_Signal> = Array<A_Signal>, TSignalsConstructors extends Array<A_TYPES__Entity_Constructor<A_Signal>> = TSignals extends Array<infer U> ? U extends A_Signal ? A_TYPES__Entity_Constructor<U>[] : never : never> extends A_Entity<A_SignalVector_Init<TSignals[number][], TSignalsConstructors>, A_SignalVector_Serialized> {
|
|
2526
2548
|
/**
|
|
2527
2549
|
* The structure of the signal vector, defining the types of signals it contains.
|
|
2528
2550
|
*
|
|
2529
2551
|
* For example:
|
|
2530
2552
|
* [UserSignInSignal, UserStatusSignal, UserActivitySignal]
|
|
2553
|
+
*
|
|
2554
|
+
* [!] if not provided, it will be derived from the signals values.
|
|
2531
2555
|
*/
|
|
2532
|
-
|
|
2556
|
+
protected _structure?: TSignalsConstructors;
|
|
2533
2557
|
/**
|
|
2534
|
-
*
|
|
2535
|
-
*
|
|
2558
|
+
* It's actual vector Values of Signals like :
|
|
2559
|
+
* [UserActionSignal, UserMousePositionSignal, ExternalDependencySignal]
|
|
2560
|
+
*/
|
|
2561
|
+
protected _signals: TSignals[number][];
|
|
2562
|
+
fromNew(newEntity: A_SignalVector_Init<TSignals[number][], TSignalsConstructors>): void;
|
|
2563
|
+
/**
|
|
2564
|
+
* The structure of the signal vector, defining the types of signals it contains.
|
|
2536
2565
|
*
|
|
2537
2566
|
* For example:
|
|
2538
|
-
* [
|
|
2539
|
-
* { userId: '123', timestamp: '2023-10-01T12:00:00Z' }, // UserSignInSignal data
|
|
2540
|
-
* { userId: '123', status: 'online' }, // UserStatusSignal data
|
|
2541
|
-
* { userId: '123', activity: 'browsing' } // UserActivitySignal data
|
|
2542
|
-
* ]
|
|
2567
|
+
* [UserSignInSignal, UserStatusSignal, UserActivitySignal]
|
|
2543
2568
|
*
|
|
2569
|
+
*/
|
|
2570
|
+
get structure(): TSignalsConstructors;
|
|
2571
|
+
get length(): number;
|
|
2572
|
+
/**
|
|
2573
|
+
* Checks if the vector contains a signal of the specified type.
|
|
2544
2574
|
*
|
|
2545
|
-
*
|
|
2575
|
+
* @param signal
|
|
2546
2576
|
*/
|
|
2547
|
-
|
|
2548
|
-
|
|
2577
|
+
has(signal: A_Signal): boolean;
|
|
2578
|
+
has(signalConstructor: A_TYPES__Component_Constructor<A_Signal>): boolean;
|
|
2579
|
+
get(signal: A_Signal): Record<string, any> | undefined;
|
|
2580
|
+
get(signalConstructor: A_TYPES__Component_Constructor<A_Signal>): Record<string, any> | undefined;
|
|
2549
2581
|
/**
|
|
2550
2582
|
* Converts to Array of values of signals in the vector
|
|
2583
|
+
* Maintains the order specified in the structure/generic type
|
|
2551
2584
|
*
|
|
2552
|
-
* @
|
|
2585
|
+
* @param structure - Optional structure to override the default ordering
|
|
2586
|
+
* @returns Array of signal instances in the specified order
|
|
2553
2587
|
*/
|
|
2554
|
-
toVector
|
|
2588
|
+
toVector<T extends Array<A_Signal> = TSignals>(structure?: {
|
|
2589
|
+
[K in keyof T]: T[K] extends A_Signal ? A_TYPES__Entity_Constructor<T[K]> : never;
|
|
2590
|
+
}): Promise<{
|
|
2591
|
+
[K in keyof T]: T[K];
|
|
2592
|
+
}>;
|
|
2555
2593
|
/**
|
|
2556
|
-
* Converts to
|
|
2594
|
+
* Converts to Array of data of signals in the vector
|
|
2595
|
+
* Maintains the order specified in the structure/generic type
|
|
2557
2596
|
*
|
|
2558
|
-
* @
|
|
2597
|
+
* @param structure - Optional structure to override the default ordering
|
|
2598
|
+
* @returns Array of serialized signal data in the specified order
|
|
2559
2599
|
*/
|
|
2560
|
-
|
|
2600
|
+
toDataVector<T extends Array<A_Signal> = TSignals>(structure?: {
|
|
2601
|
+
[K in keyof T]: T[K] extends A_Signal ? A_TYPES__Entity_Constructor<T[K]> : never;
|
|
2602
|
+
}): Promise<{
|
|
2603
|
+
[K in keyof T]: T[K] extends A_Signal<infer D> ? D | undefined : never;
|
|
2604
|
+
}>;
|
|
2605
|
+
/**
|
|
2606
|
+
* Converts to Object with signal constructor names as keys and their corresponding data values
|
|
2607
|
+
* Uses the structure ordering to ensure consistent key ordering
|
|
2608
|
+
*
|
|
2609
|
+
* @returns Object with signal constructor names as keys and signal data as values
|
|
2610
|
+
*/
|
|
2611
|
+
toObject<T extends Array<A_Signal> = TSignals>(structure?: {
|
|
2612
|
+
[K in keyof T]: T[K] extends A_Signal ? A_TYPES__Entity_Constructor<T[K]> : never;
|
|
2613
|
+
}): Promise<{
|
|
2614
|
+
[key: string]: T[number] extends A_Signal<infer D> ? D | undefined : never;
|
|
2615
|
+
}>;
|
|
2561
2616
|
/**
|
|
2562
2617
|
* Serializes the Signal Vector to a JSON-compatible format.
|
|
2563
2618
|
*
|
|
@@ -2593,7 +2648,7 @@ declare class A_SignalState<TSignalData extends Record<string, any> = Record<str
|
|
|
2593
2648
|
* Key: Signal constructor function
|
|
2594
2649
|
* Value: Latest emitted data from that signal type
|
|
2595
2650
|
*/
|
|
2596
|
-
protected _state: Map<A_TYPES__Component_Constructor<A_Signal>,
|
|
2651
|
+
protected _state: Map<A_TYPES__Component_Constructor<A_Signal>, A_Signal>;
|
|
2597
2652
|
/**
|
|
2598
2653
|
* Optional structure defining the ordered list of signal constructors
|
|
2599
2654
|
* Used for vector operations and initialization
|
|
@@ -2618,16 +2673,17 @@ declare class A_SignalState<TSignalData extends Record<string, any> = Record<str
|
|
|
2618
2673
|
* @param signal - The signal constructor to associate the value with
|
|
2619
2674
|
* @param value - The data value emitted by the signal
|
|
2620
2675
|
*/
|
|
2621
|
-
set(signal: A_Signal, value:
|
|
2622
|
-
set(signal:
|
|
2676
|
+
set(signal: A_Signal, value: A_Signal): void;
|
|
2677
|
+
set(signal: A_Signal): void;
|
|
2678
|
+
set(signal: A_TYPES__Component_Constructor<A_Signal>, value: A_Signal): void;
|
|
2623
2679
|
/**
|
|
2624
2680
|
* Retrieves the latest value for a specific signal type
|
|
2625
2681
|
*
|
|
2626
2682
|
* @param signal - The signal constructor to get the value for
|
|
2627
2683
|
* @returns The latest data value or undefined if no value has been set
|
|
2628
2684
|
*/
|
|
2629
|
-
get(signal: A_Signal):
|
|
2630
|
-
get(signal: A_TYPES__Component_Constructor<A_Signal>):
|
|
2685
|
+
get(signal: A_Signal): A_Signal | undefined;
|
|
2686
|
+
get(signal: A_TYPES__Component_Constructor<A_Signal>): A_Signal | undefined;
|
|
2631
2687
|
/**
|
|
2632
2688
|
* Checks if a signal type has been registered in the state
|
|
2633
2689
|
*
|
|
@@ -2663,7 +2719,7 @@ declare class A_SignalState<TSignalData extends Record<string, any> = Record<str
|
|
|
2663
2719
|
* @returns Object mapping signal constructor names to their latest values
|
|
2664
2720
|
* @throws Error if any signal value is undefined
|
|
2665
2721
|
*/
|
|
2666
|
-
toObject(): Record<string,
|
|
2722
|
+
toObject(): Record<string, A_Signal>;
|
|
2667
2723
|
}
|
|
2668
2724
|
|
|
2669
2725
|
/**
|
|
@@ -2720,8 +2776,8 @@ declare class A_SignalBus extends A_Component {
|
|
|
2720
2776
|
* @param state
|
|
2721
2777
|
* @param config
|
|
2722
2778
|
* @returns
|
|
2723
|
-
*/
|
|
2724
|
-
[A_SignalFeatures.Emit](signal: A_Signal, globalConfig?: A_Config<['A_SIGNAL_VECTOR_STRUCTURE']>, logger?: A_Logger, state?: A_SignalState, config?: A_SignalConfig): Promise<void>;
|
|
2779
|
+
*/
|
|
2780
|
+
[A_SignalFeatures.Emit](signal: A_Signal, scope: A_Scope, globalConfig?: A_Config<['A_SIGNAL_VECTOR_STRUCTURE']>, logger?: A_Logger, state?: A_SignalState, config?: A_SignalConfig): Promise<void>;
|
|
2725
2781
|
}
|
|
2726
2782
|
|
|
2727
2783
|
type A_UTILS_TYPES__ScheduleObjectConfig = {
|
|
@@ -2837,4 +2893,4 @@ declare class A_StateMachineError extends A_Error {
|
|
|
2837
2893
|
static readonly TransitionError = "A-StateMachine Transition Error";
|
|
2838
2894
|
}
|
|
2839
2895
|
|
|
2840
|
-
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_CommandEvent, type A_CommandEvents, A_CommandFeatures, A_CommandTransitions, 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_TERMINAL, A_LOGGER_TIME_FORMAT, A_Logger, type A_LoggerColorName, 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_Route, A_Schedule, A_ScheduleObject, A_Service, A_ServiceFeatures, A_Signal, A_SignalBus, A_SignalBusFeatures, A_SignalConfig, type A_SignalConfig_Init, A_SignalFeatures, A_SignalState, A_SignalVector, type A_SignalVector_Init, type A_SignalVector_Serialized, type A_Signal_Init, 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 };
|
|
2896
|
+
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_CommandEvent, type A_CommandEvents, A_CommandFeatures, A_CommandTransitions, 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_TERMINAL, A_LOGGER_TIME_FORMAT, A_Logger, type A_LoggerColorName, 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_Route, A_Schedule, A_ScheduleObject, A_Service, A_ServiceFeatures, A_Signal, A_SignalBus, A_SignalBusFeatures, A_SignalConfig, type A_SignalConfig_Init, A_SignalFeatures, A_SignalState, A_SignalVector, type A_SignalVector_Init, type A_SignalVector_Serialized, type A_Signal_Init, type A_Signal_Serialized, 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
|
@@ -2320,6 +2320,9 @@ declare class A_Memory<_StorageType extends Record<string, any> = Record<string,
|
|
|
2320
2320
|
[A_MemoryFeatures.onExpire](...args: any[]): Promise<void>;
|
|
2321
2321
|
[A_MemoryFeatures.onInit](context: A_MemoryContext<_StorageType>, ...args: any[]): Promise<void>;
|
|
2322
2322
|
[A_MemoryFeatures.onDestroy](context: A_MemoryContext<_StorageType>, ...args: any[]): Promise<void>;
|
|
2323
|
+
/**
|
|
2324
|
+
* Handles the 'get' operation for retrieving a value from memory
|
|
2325
|
+
*/
|
|
2323
2326
|
[A_MemoryFeatures.onGet](operation: A_MemoryOperationContext, context: A_MemoryContext<_StorageType>, ...args: any[]): Promise<void>;
|
|
2324
2327
|
[A_MemoryFeatures.onHas](operation: A_MemoryOperationContext<boolean>, context: A_MemoryContext<_StorageType>, ...args: any[]): Promise<void>;
|
|
2325
2328
|
[A_MemoryFeatures.onSet](operation: A_MemoryOperationContext, context: A_MemoryContext<_StorageType>, scope: A_Scope, ...args: any[]): Promise<void>;
|
|
@@ -2469,9 +2472,9 @@ type A_SignalConfig_Init = {
|
|
|
2469
2472
|
*/
|
|
2470
2473
|
stringStructure?: string;
|
|
2471
2474
|
};
|
|
2472
|
-
type A_SignalVector_Init<
|
|
2473
|
-
structure:
|
|
2474
|
-
values:
|
|
2475
|
+
type A_SignalVector_Init<_TSignals extends Array<A_Signal> = Array<A_Signal>, _TVectorStructure extends Array<A_TYPES__Entity_Constructor<_TSignals[number]>> = Array<A_TYPES__Entity_Constructor<_TSignals[number]>>> = {
|
|
2476
|
+
structure: _TVectorStructure;
|
|
2477
|
+
values: _TSignals;
|
|
2475
2478
|
};
|
|
2476
2479
|
type A_SignalVector_Serialized = A_TYPES__Entity_Serialized & {
|
|
2477
2480
|
structure: string[];
|
|
@@ -2487,6 +2490,12 @@ type A_Signal_Init<T extends Record<string, any> = Record<string, any>> = {
|
|
|
2487
2490
|
*/
|
|
2488
2491
|
data: T;
|
|
2489
2492
|
};
|
|
2493
|
+
type A_Signal_Serialized<T extends Record<string, any> = Record<string, any>> = {
|
|
2494
|
+
/**
|
|
2495
|
+
* The signal data
|
|
2496
|
+
*/
|
|
2497
|
+
data: T;
|
|
2498
|
+
} & A_TYPES__Entity_Serialized;
|
|
2490
2499
|
|
|
2491
2500
|
/**
|
|
2492
2501
|
* A Signal Entity is an individual signal instance that carries data.
|
|
@@ -2501,9 +2510,18 @@ type A_Signal_Init<T extends Record<string, any> = Record<string, any>> = {
|
|
|
2501
2510
|
* Signals are typically used in scenarios where the current state is more important than individual events,
|
|
2502
2511
|
* such as monitoring systems, real-time dashboards, or stateful applications.
|
|
2503
2512
|
*/
|
|
2504
|
-
declare class A_Signal extends A_Entity<A_Signal_Init
|
|
2505
|
-
data:
|
|
2506
|
-
|
|
2513
|
+
declare class A_Signal<_TSignalDataType extends Record<string, any> = Record<string, any>> extends A_Entity<A_Signal_Init<_TSignalDataType>, A_Signal_Serialized<_TSignalDataType>> {
|
|
2514
|
+
data: _TSignalDataType;
|
|
2515
|
+
/**
|
|
2516
|
+
* Allows to define default data for the signal.
|
|
2517
|
+
*
|
|
2518
|
+
* If no data is provided during initialization, the default data will be used.
|
|
2519
|
+
*
|
|
2520
|
+
* @returns
|
|
2521
|
+
*/
|
|
2522
|
+
static default(): Promise<A_Signal | undefined>;
|
|
2523
|
+
fromJSON(serializedEntity: A_Signal_Serialized<_TSignalDataType>): void;
|
|
2524
|
+
fromNew(newEntity: A_Signal_Init<_TSignalDataType>): void;
|
|
2507
2525
|
/**
|
|
2508
2526
|
* Emits this signal within the provided scope.
|
|
2509
2527
|
*
|
|
@@ -2513,6 +2531,7 @@ declare class A_Signal extends A_Entity<A_Signal_Init> {
|
|
|
2513
2531
|
* @param scope
|
|
2514
2532
|
*/
|
|
2515
2533
|
emit(scope: A_Scope): Promise<void>;
|
|
2534
|
+
toJSON(): A_Signal_Serialized<_TSignalDataType>;
|
|
2516
2535
|
}
|
|
2517
2536
|
|
|
2518
2537
|
/**
|
|
@@ -2521,43 +2540,79 @@ declare class A_Signal extends A_Entity<A_Signal_Init> {
|
|
|
2521
2540
|
*
|
|
2522
2541
|
* Signal Vectors are useful in scenarios where multiple related signals need to be handled together,
|
|
2523
2542
|
* as a state of the system or a snapshot of various parameters at a given time.
|
|
2543
|
+
*
|
|
2544
|
+
* @template TSignalsConstructors - Array of signal constructor types (e.g., [typeof MySignal, typeof CustomSignal])
|
|
2545
|
+
* @template TSignals - Array of signal instances derived from constructors
|
|
2524
2546
|
*/
|
|
2525
|
-
declare class A_SignalVector extends A_Entity<A_SignalVector_Init, A_SignalVector_Serialized> {
|
|
2547
|
+
declare class A_SignalVector<TSignals extends Array<A_Signal> = Array<A_Signal>, TSignalsConstructors extends Array<A_TYPES__Entity_Constructor<A_Signal>> = TSignals extends Array<infer U> ? U extends A_Signal ? A_TYPES__Entity_Constructor<U>[] : never : never> extends A_Entity<A_SignalVector_Init<TSignals[number][], TSignalsConstructors>, A_SignalVector_Serialized> {
|
|
2526
2548
|
/**
|
|
2527
2549
|
* The structure of the signal vector, defining the types of signals it contains.
|
|
2528
2550
|
*
|
|
2529
2551
|
* For example:
|
|
2530
2552
|
* [UserSignInSignal, UserStatusSignal, UserActivitySignal]
|
|
2553
|
+
*
|
|
2554
|
+
* [!] if not provided, it will be derived from the signals values.
|
|
2531
2555
|
*/
|
|
2532
|
-
|
|
2556
|
+
protected _structure?: TSignalsConstructors;
|
|
2533
2557
|
/**
|
|
2534
|
-
*
|
|
2535
|
-
*
|
|
2558
|
+
* It's actual vector Values of Signals like :
|
|
2559
|
+
* [UserActionSignal, UserMousePositionSignal, ExternalDependencySignal]
|
|
2560
|
+
*/
|
|
2561
|
+
protected _signals: TSignals[number][];
|
|
2562
|
+
fromNew(newEntity: A_SignalVector_Init<TSignals[number][], TSignalsConstructors>): void;
|
|
2563
|
+
/**
|
|
2564
|
+
* The structure of the signal vector, defining the types of signals it contains.
|
|
2536
2565
|
*
|
|
2537
2566
|
* For example:
|
|
2538
|
-
* [
|
|
2539
|
-
* { userId: '123', timestamp: '2023-10-01T12:00:00Z' }, // UserSignInSignal data
|
|
2540
|
-
* { userId: '123', status: 'online' }, // UserStatusSignal data
|
|
2541
|
-
* { userId: '123', activity: 'browsing' } // UserActivitySignal data
|
|
2542
|
-
* ]
|
|
2567
|
+
* [UserSignInSignal, UserStatusSignal, UserActivitySignal]
|
|
2543
2568
|
*
|
|
2569
|
+
*/
|
|
2570
|
+
get structure(): TSignalsConstructors;
|
|
2571
|
+
get length(): number;
|
|
2572
|
+
/**
|
|
2573
|
+
* Checks if the vector contains a signal of the specified type.
|
|
2544
2574
|
*
|
|
2545
|
-
*
|
|
2575
|
+
* @param signal
|
|
2546
2576
|
*/
|
|
2547
|
-
|
|
2548
|
-
|
|
2577
|
+
has(signal: A_Signal): boolean;
|
|
2578
|
+
has(signalConstructor: A_TYPES__Component_Constructor<A_Signal>): boolean;
|
|
2579
|
+
get(signal: A_Signal): Record<string, any> | undefined;
|
|
2580
|
+
get(signalConstructor: A_TYPES__Component_Constructor<A_Signal>): Record<string, any> | undefined;
|
|
2549
2581
|
/**
|
|
2550
2582
|
* Converts to Array of values of signals in the vector
|
|
2583
|
+
* Maintains the order specified in the structure/generic type
|
|
2551
2584
|
*
|
|
2552
|
-
* @
|
|
2585
|
+
* @param structure - Optional structure to override the default ordering
|
|
2586
|
+
* @returns Array of signal instances in the specified order
|
|
2553
2587
|
*/
|
|
2554
|
-
toVector
|
|
2588
|
+
toVector<T extends Array<A_Signal> = TSignals>(structure?: {
|
|
2589
|
+
[K in keyof T]: T[K] extends A_Signal ? A_TYPES__Entity_Constructor<T[K]> : never;
|
|
2590
|
+
}): Promise<{
|
|
2591
|
+
[K in keyof T]: T[K];
|
|
2592
|
+
}>;
|
|
2555
2593
|
/**
|
|
2556
|
-
* Converts to
|
|
2594
|
+
* Converts to Array of data of signals in the vector
|
|
2595
|
+
* Maintains the order specified in the structure/generic type
|
|
2557
2596
|
*
|
|
2558
|
-
* @
|
|
2597
|
+
* @param structure - Optional structure to override the default ordering
|
|
2598
|
+
* @returns Array of serialized signal data in the specified order
|
|
2559
2599
|
*/
|
|
2560
|
-
|
|
2600
|
+
toDataVector<T extends Array<A_Signal> = TSignals>(structure?: {
|
|
2601
|
+
[K in keyof T]: T[K] extends A_Signal ? A_TYPES__Entity_Constructor<T[K]> : never;
|
|
2602
|
+
}): Promise<{
|
|
2603
|
+
[K in keyof T]: T[K] extends A_Signal<infer D> ? D | undefined : never;
|
|
2604
|
+
}>;
|
|
2605
|
+
/**
|
|
2606
|
+
* Converts to Object with signal constructor names as keys and their corresponding data values
|
|
2607
|
+
* Uses the structure ordering to ensure consistent key ordering
|
|
2608
|
+
*
|
|
2609
|
+
* @returns Object with signal constructor names as keys and signal data as values
|
|
2610
|
+
*/
|
|
2611
|
+
toObject<T extends Array<A_Signal> = TSignals>(structure?: {
|
|
2612
|
+
[K in keyof T]: T[K] extends A_Signal ? A_TYPES__Entity_Constructor<T[K]> : never;
|
|
2613
|
+
}): Promise<{
|
|
2614
|
+
[key: string]: T[number] extends A_Signal<infer D> ? D | undefined : never;
|
|
2615
|
+
}>;
|
|
2561
2616
|
/**
|
|
2562
2617
|
* Serializes the Signal Vector to a JSON-compatible format.
|
|
2563
2618
|
*
|
|
@@ -2593,7 +2648,7 @@ declare class A_SignalState<TSignalData extends Record<string, any> = Record<str
|
|
|
2593
2648
|
* Key: Signal constructor function
|
|
2594
2649
|
* Value: Latest emitted data from that signal type
|
|
2595
2650
|
*/
|
|
2596
|
-
protected _state: Map<A_TYPES__Component_Constructor<A_Signal>,
|
|
2651
|
+
protected _state: Map<A_TYPES__Component_Constructor<A_Signal>, A_Signal>;
|
|
2597
2652
|
/**
|
|
2598
2653
|
* Optional structure defining the ordered list of signal constructors
|
|
2599
2654
|
* Used for vector operations and initialization
|
|
@@ -2618,16 +2673,17 @@ declare class A_SignalState<TSignalData extends Record<string, any> = Record<str
|
|
|
2618
2673
|
* @param signal - The signal constructor to associate the value with
|
|
2619
2674
|
* @param value - The data value emitted by the signal
|
|
2620
2675
|
*/
|
|
2621
|
-
set(signal: A_Signal, value:
|
|
2622
|
-
set(signal:
|
|
2676
|
+
set(signal: A_Signal, value: A_Signal): void;
|
|
2677
|
+
set(signal: A_Signal): void;
|
|
2678
|
+
set(signal: A_TYPES__Component_Constructor<A_Signal>, value: A_Signal): void;
|
|
2623
2679
|
/**
|
|
2624
2680
|
* Retrieves the latest value for a specific signal type
|
|
2625
2681
|
*
|
|
2626
2682
|
* @param signal - The signal constructor to get the value for
|
|
2627
2683
|
* @returns The latest data value or undefined if no value has been set
|
|
2628
2684
|
*/
|
|
2629
|
-
get(signal: A_Signal):
|
|
2630
|
-
get(signal: A_TYPES__Component_Constructor<A_Signal>):
|
|
2685
|
+
get(signal: A_Signal): A_Signal | undefined;
|
|
2686
|
+
get(signal: A_TYPES__Component_Constructor<A_Signal>): A_Signal | undefined;
|
|
2631
2687
|
/**
|
|
2632
2688
|
* Checks if a signal type has been registered in the state
|
|
2633
2689
|
*
|
|
@@ -2663,7 +2719,7 @@ declare class A_SignalState<TSignalData extends Record<string, any> = Record<str
|
|
|
2663
2719
|
* @returns Object mapping signal constructor names to their latest values
|
|
2664
2720
|
* @throws Error if any signal value is undefined
|
|
2665
2721
|
*/
|
|
2666
|
-
toObject(): Record<string,
|
|
2722
|
+
toObject(): Record<string, A_Signal>;
|
|
2667
2723
|
}
|
|
2668
2724
|
|
|
2669
2725
|
/**
|
|
@@ -2720,8 +2776,8 @@ declare class A_SignalBus extends A_Component {
|
|
|
2720
2776
|
* @param state
|
|
2721
2777
|
* @param config
|
|
2722
2778
|
* @returns
|
|
2723
|
-
*/
|
|
2724
|
-
[A_SignalFeatures.Emit](signal: A_Signal, globalConfig?: A_Config<['A_SIGNAL_VECTOR_STRUCTURE']>, logger?: A_Logger, state?: A_SignalState, config?: A_SignalConfig): Promise<void>;
|
|
2779
|
+
*/
|
|
2780
|
+
[A_SignalFeatures.Emit](signal: A_Signal, scope: A_Scope, globalConfig?: A_Config<['A_SIGNAL_VECTOR_STRUCTURE']>, logger?: A_Logger, state?: A_SignalState, config?: A_SignalConfig): Promise<void>;
|
|
2725
2781
|
}
|
|
2726
2782
|
|
|
2727
2783
|
type A_UTILS_TYPES__ScheduleObjectConfig = {
|
|
@@ -2837,4 +2893,4 @@ declare class A_StateMachineError extends A_Error {
|
|
|
2837
2893
|
static readonly TransitionError = "A-StateMachine Transition Error";
|
|
2838
2894
|
}
|
|
2839
2895
|
|
|
2840
|
-
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_CommandEvent, type A_CommandEvents, A_CommandFeatures, A_CommandTransitions, 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_TERMINAL, A_LOGGER_TIME_FORMAT, A_Logger, type A_LoggerColorName, 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_Route, A_Schedule, A_ScheduleObject, A_Service, A_ServiceFeatures, A_Signal, A_SignalBus, A_SignalBusFeatures, A_SignalConfig, type A_SignalConfig_Init, A_SignalFeatures, A_SignalState, A_SignalVector, type A_SignalVector_Init, type A_SignalVector_Serialized, type A_Signal_Init, 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 };
|
|
2896
|
+
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_CommandEvent, type A_CommandEvents, A_CommandFeatures, A_CommandTransitions, 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_TERMINAL, A_LOGGER_TIME_FORMAT, A_Logger, type A_LoggerColorName, 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_Route, A_Schedule, A_ScheduleObject, A_Service, A_ServiceFeatures, A_Signal, A_SignalBus, A_SignalBusFeatures, A_SignalConfig, type A_SignalConfig_Init, A_SignalFeatures, A_SignalState, A_SignalVector, type A_SignalVector_Init, type A_SignalVector_Serialized, type A_Signal_Init, type A_Signal_Serialized, 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 };
|