@cadenza.io/core 3.15.13 → 3.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +42 -12
- package/dist/index.d.ts +42 -12
- package/dist/index.js +1185 -106
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1185 -106
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -145,14 +145,16 @@ declare abstract class SignalEmitter {
|
|
|
145
145
|
* Emits a signal via the broker.
|
|
146
146
|
* @param signal The signal name.
|
|
147
147
|
* @param data Optional payload (defaults to empty object).
|
|
148
|
+
* @param options
|
|
148
149
|
*/
|
|
149
|
-
emit(signal: string, data?: AnyObject): void;
|
|
150
|
+
emit(signal: string, data?: AnyObject, options?: EmitOptions): void;
|
|
150
151
|
/**
|
|
151
152
|
* Emits a signal via the broker if not silent.
|
|
152
153
|
* @param signal The signal name.
|
|
153
154
|
* @param data Optional payload (defaults to empty object).
|
|
155
|
+
* @param options
|
|
154
156
|
*/
|
|
155
|
-
emitMetrics(signal: string, data?: AnyObject): void;
|
|
157
|
+
emitMetrics(signal: string, data?: AnyObject, options?: EmitOptions): void;
|
|
156
158
|
}
|
|
157
159
|
|
|
158
160
|
/**
|
|
@@ -482,17 +484,19 @@ declare class GraphNode extends SignalEmitter implements Graph {
|
|
|
482
484
|
* @param {string} signal - The name of the signal to be emitted.
|
|
483
485
|
* @param {AnyObject} data - The data object to be sent along with the signal. Metadata
|
|
484
486
|
* will be injected into this object before being emitted.
|
|
487
|
+
* @param options
|
|
485
488
|
* @return {void} No return value.
|
|
486
489
|
*/
|
|
487
|
-
emitWithMetadata(signal: string, data: AnyObject): void;
|
|
490
|
+
emitWithMetadata(signal: string, data: AnyObject, options?: EmitOptions): void;
|
|
488
491
|
/**
|
|
489
492
|
* Emits metrics with additional metadata describing the task execution and context.
|
|
490
493
|
*
|
|
491
494
|
* @param {string} signal - The signal name being emitted.
|
|
492
495
|
* @param {AnyObject} data - The data associated with the signal emission, enriched with metadata.
|
|
496
|
+
* @param options
|
|
493
497
|
* @return {void} Emits the signal with enriched data and does not return a value.
|
|
494
498
|
*/
|
|
495
|
-
emitMetricsWithMetadata(signal: string, data: AnyObject): void;
|
|
499
|
+
emitMetricsWithMetadata(signal: string, data: AnyObject, options?: EmitOptions): void;
|
|
496
500
|
/**
|
|
497
501
|
* Updates the progress of a task and emits metrics with associated metadata.
|
|
498
502
|
*
|
|
@@ -1394,6 +1398,15 @@ declare class GraphRunner extends SignalEmitter {
|
|
|
1394
1398
|
setStrategy(strategy: GraphRunStrategy): void;
|
|
1395
1399
|
}
|
|
1396
1400
|
|
|
1401
|
+
interface EmitOptions {
|
|
1402
|
+
squash?: boolean;
|
|
1403
|
+
squashId?: string | null;
|
|
1404
|
+
mergeFunction?: ((oldContext: AnyObject, newContext: AnyObject) => AnyObject) | null;
|
|
1405
|
+
debounce?: boolean;
|
|
1406
|
+
delayMs?: number;
|
|
1407
|
+
schedule?: boolean;
|
|
1408
|
+
exactDateTime?: Date | null;
|
|
1409
|
+
}
|
|
1397
1410
|
/**
|
|
1398
1411
|
* This class manages signals and observers, enabling communication across different parts of an application.
|
|
1399
1412
|
* It follows a singleton design pattern, allowing for centralized signal management.
|
|
@@ -1418,6 +1431,8 @@ declare class SignalBroker {
|
|
|
1418
1431
|
runner: GraphRunner | undefined;
|
|
1419
1432
|
metaRunner: GraphRunner | undefined;
|
|
1420
1433
|
debouncedEmitters: Map<string, any>;
|
|
1434
|
+
squashedEmitters: Map<string, any>;
|
|
1435
|
+
squashedContexts: Map<string, any>;
|
|
1421
1436
|
getSignalsTask: Task | undefined;
|
|
1422
1437
|
registerSignalTask: Task | undefined;
|
|
1423
1438
|
signalObservers: Map<string, {
|
|
@@ -1459,11 +1474,10 @@ declare class SignalBroker {
|
|
|
1459
1474
|
*
|
|
1460
1475
|
* @param {string} signal - The name of the signal to be emitted.
|
|
1461
1476
|
* @param {AnyObject} context - The context to be passed along with the signal.
|
|
1462
|
-
* @param
|
|
1463
|
-
* @param {Date} [exactDateTime] - An exact date and time at which to emit the signal. If provided, this overrides the `timeoutMs`.
|
|
1477
|
+
* @param options
|
|
1464
1478
|
* @return {AbortController} An AbortController instance that can be used to cancel the scheduled signal emission.
|
|
1465
1479
|
*/
|
|
1466
|
-
schedule(signal: string, context: AnyObject,
|
|
1480
|
+
schedule(signal: string, context: AnyObject, options?: EmitOptions): AbortController;
|
|
1467
1481
|
/**
|
|
1468
1482
|
* Emits `signal` repeatedly with a fixed interval.
|
|
1469
1483
|
*
|
|
@@ -1475,16 +1489,31 @@ declare class SignalBroker {
|
|
|
1475
1489
|
* @returns a handle with `clear()` to stop the loop.
|
|
1476
1490
|
*/
|
|
1477
1491
|
interval(signal: string, context: AnyObject, intervalMs?: number, leading?: boolean, startDateTime?: Date): ThrottleHandle;
|
|
1478
|
-
debounce(signal: string, context: any,
|
|
1492
|
+
debounce(signal: string, context: any, options?: {
|
|
1493
|
+
delayMs: number;
|
|
1494
|
+
}): void;
|
|
1495
|
+
/**
|
|
1496
|
+
* Aggregates and debounces multiple events with the same identifier to minimize redundant operations.
|
|
1497
|
+
*
|
|
1498
|
+
* @param {string} signal - The identifier for the event being emitted.
|
|
1499
|
+
* @param {AnyObject} context - The context data associated with the event.
|
|
1500
|
+
* @param {Object} [options] - Configuration options for handling the squashed event.
|
|
1501
|
+
* @param {boolean} [options.squash=true] - Whether the event should be squashed.
|
|
1502
|
+
* @param {string|null} [options.squashId=null] - A unique identifier for the squashed group of events. Defaults to the signal if null.
|
|
1503
|
+
* @param {function|null} [options.mergeFunction=null] - A custom merge function that combines old and new contexts. If null, a default merge is used.
|
|
1504
|
+
* @return {void} Does not return a value.
|
|
1505
|
+
*/
|
|
1506
|
+
squash(signal: string, context: AnyObject, options?: EmitOptions): void;
|
|
1479
1507
|
/**
|
|
1480
1508
|
* Emits a signal with the specified context, triggering any associated handlers for that signal.
|
|
1481
1509
|
*
|
|
1482
1510
|
* @param {string} signal - The name of the signal to emit.
|
|
1483
1511
|
* @param {AnyObject} [context={}] - An optional context object containing additional information or metadata
|
|
1484
1512
|
* associated with the signal. If the context includes a `__routineExecId`, it will be handled accordingly.
|
|
1513
|
+
* @param options
|
|
1485
1514
|
* @return {void} This method does not return a value.
|
|
1486
1515
|
*/
|
|
1487
|
-
emit(signal: string, context?: AnyObject): void;
|
|
1516
|
+
emit(signal: string, context?: AnyObject, options?: EmitOptions): void;
|
|
1488
1517
|
/**
|
|
1489
1518
|
* Executes a signal by emitting events, updating context, and invoking listeners.
|
|
1490
1519
|
* Creates a new execution trace if necessary and updates the context with relevant metadata.
|
|
@@ -1781,6 +1810,7 @@ declare class Cadenza {
|
|
|
1781
1810
|
*
|
|
1782
1811
|
* @param {string} event - The name of the event to emit.
|
|
1783
1812
|
* @param {AnyObject} [data={}] - The data payload associated with the event.
|
|
1813
|
+
* @param options
|
|
1784
1814
|
* @return {void} - No return value.
|
|
1785
1815
|
*
|
|
1786
1816
|
* @example
|
|
@@ -1790,8 +1820,8 @@ declare class Cadenza {
|
|
|
1790
1820
|
* Cadenza.emit('main.my_event', { foo: 'bar' });
|
|
1791
1821
|
* ```
|
|
1792
1822
|
*/
|
|
1793
|
-
static emit(event: string, data?: AnyObject): void;
|
|
1794
|
-
static schedule(taskName: string, context: AnyObject,
|
|
1823
|
+
static emit(event: string, data?: AnyObject, options?: EmitOptions): void;
|
|
1824
|
+
static schedule(taskName: string, context: AnyObject, delayMs: number, exactDateTime?: Date): void;
|
|
1795
1825
|
static interval(taskName: string, context: AnyObject, intervalMs: number, leading?: boolean, startDateTime?: Date): void;
|
|
1796
1826
|
static debounce(signalName: string, context: any, delayMs: number): void;
|
|
1797
1827
|
static get(taskName: string): Task | undefined;
|
|
@@ -2151,4 +2181,4 @@ declare class SignalTask extends Task {
|
|
|
2151
2181
|
constructor(signal: string, description?: string);
|
|
2152
2182
|
}
|
|
2153
2183
|
|
|
2154
|
-
export { type AnyObject, type CadenzaMode, type DebounceOptions, DebounceTask, EphemeralTask, type EphemeralTaskOptions, GraphContext, GraphRegistry, GraphRoutine, GraphRun, GraphRunner, type SchemaConstraints, type SchemaDefinition, type SchemaType, SignalBroker, SignalEmitter, SignalTask, Task, type TaskFunction, type TaskOptions, type TaskResult, type ThrottleTagGetter, Cadenza as default };
|
|
2184
|
+
export { type AnyObject, type CadenzaMode, type DebounceOptions, DebounceTask, type EmitOptions, EphemeralTask, type EphemeralTaskOptions, GraphContext, GraphRegistry, GraphRoutine, GraphRun, GraphRunner, type SchemaConstraints, type SchemaDefinition, type SchemaType, SignalBroker, SignalEmitter, SignalTask, Task, type TaskFunction, type TaskOptions, type TaskResult, type ThrottleTagGetter, Cadenza as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -145,14 +145,16 @@ declare abstract class SignalEmitter {
|
|
|
145
145
|
* Emits a signal via the broker.
|
|
146
146
|
* @param signal The signal name.
|
|
147
147
|
* @param data Optional payload (defaults to empty object).
|
|
148
|
+
* @param options
|
|
148
149
|
*/
|
|
149
|
-
emit(signal: string, data?: AnyObject): void;
|
|
150
|
+
emit(signal: string, data?: AnyObject, options?: EmitOptions): void;
|
|
150
151
|
/**
|
|
151
152
|
* Emits a signal via the broker if not silent.
|
|
152
153
|
* @param signal The signal name.
|
|
153
154
|
* @param data Optional payload (defaults to empty object).
|
|
155
|
+
* @param options
|
|
154
156
|
*/
|
|
155
|
-
emitMetrics(signal: string, data?: AnyObject): void;
|
|
157
|
+
emitMetrics(signal: string, data?: AnyObject, options?: EmitOptions): void;
|
|
156
158
|
}
|
|
157
159
|
|
|
158
160
|
/**
|
|
@@ -482,17 +484,19 @@ declare class GraphNode extends SignalEmitter implements Graph {
|
|
|
482
484
|
* @param {string} signal - The name of the signal to be emitted.
|
|
483
485
|
* @param {AnyObject} data - The data object to be sent along with the signal. Metadata
|
|
484
486
|
* will be injected into this object before being emitted.
|
|
487
|
+
* @param options
|
|
485
488
|
* @return {void} No return value.
|
|
486
489
|
*/
|
|
487
|
-
emitWithMetadata(signal: string, data: AnyObject): void;
|
|
490
|
+
emitWithMetadata(signal: string, data: AnyObject, options?: EmitOptions): void;
|
|
488
491
|
/**
|
|
489
492
|
* Emits metrics with additional metadata describing the task execution and context.
|
|
490
493
|
*
|
|
491
494
|
* @param {string} signal - The signal name being emitted.
|
|
492
495
|
* @param {AnyObject} data - The data associated with the signal emission, enriched with metadata.
|
|
496
|
+
* @param options
|
|
493
497
|
* @return {void} Emits the signal with enriched data and does not return a value.
|
|
494
498
|
*/
|
|
495
|
-
emitMetricsWithMetadata(signal: string, data: AnyObject): void;
|
|
499
|
+
emitMetricsWithMetadata(signal: string, data: AnyObject, options?: EmitOptions): void;
|
|
496
500
|
/**
|
|
497
501
|
* Updates the progress of a task and emits metrics with associated metadata.
|
|
498
502
|
*
|
|
@@ -1394,6 +1398,15 @@ declare class GraphRunner extends SignalEmitter {
|
|
|
1394
1398
|
setStrategy(strategy: GraphRunStrategy): void;
|
|
1395
1399
|
}
|
|
1396
1400
|
|
|
1401
|
+
interface EmitOptions {
|
|
1402
|
+
squash?: boolean;
|
|
1403
|
+
squashId?: string | null;
|
|
1404
|
+
mergeFunction?: ((oldContext: AnyObject, newContext: AnyObject) => AnyObject) | null;
|
|
1405
|
+
debounce?: boolean;
|
|
1406
|
+
delayMs?: number;
|
|
1407
|
+
schedule?: boolean;
|
|
1408
|
+
exactDateTime?: Date | null;
|
|
1409
|
+
}
|
|
1397
1410
|
/**
|
|
1398
1411
|
* This class manages signals and observers, enabling communication across different parts of an application.
|
|
1399
1412
|
* It follows a singleton design pattern, allowing for centralized signal management.
|
|
@@ -1418,6 +1431,8 @@ declare class SignalBroker {
|
|
|
1418
1431
|
runner: GraphRunner | undefined;
|
|
1419
1432
|
metaRunner: GraphRunner | undefined;
|
|
1420
1433
|
debouncedEmitters: Map<string, any>;
|
|
1434
|
+
squashedEmitters: Map<string, any>;
|
|
1435
|
+
squashedContexts: Map<string, any>;
|
|
1421
1436
|
getSignalsTask: Task | undefined;
|
|
1422
1437
|
registerSignalTask: Task | undefined;
|
|
1423
1438
|
signalObservers: Map<string, {
|
|
@@ -1459,11 +1474,10 @@ declare class SignalBroker {
|
|
|
1459
1474
|
*
|
|
1460
1475
|
* @param {string} signal - The name of the signal to be emitted.
|
|
1461
1476
|
* @param {AnyObject} context - The context to be passed along with the signal.
|
|
1462
|
-
* @param
|
|
1463
|
-
* @param {Date} [exactDateTime] - An exact date and time at which to emit the signal. If provided, this overrides the `timeoutMs`.
|
|
1477
|
+
* @param options
|
|
1464
1478
|
* @return {AbortController} An AbortController instance that can be used to cancel the scheduled signal emission.
|
|
1465
1479
|
*/
|
|
1466
|
-
schedule(signal: string, context: AnyObject,
|
|
1480
|
+
schedule(signal: string, context: AnyObject, options?: EmitOptions): AbortController;
|
|
1467
1481
|
/**
|
|
1468
1482
|
* Emits `signal` repeatedly with a fixed interval.
|
|
1469
1483
|
*
|
|
@@ -1475,16 +1489,31 @@ declare class SignalBroker {
|
|
|
1475
1489
|
* @returns a handle with `clear()` to stop the loop.
|
|
1476
1490
|
*/
|
|
1477
1491
|
interval(signal: string, context: AnyObject, intervalMs?: number, leading?: boolean, startDateTime?: Date): ThrottleHandle;
|
|
1478
|
-
debounce(signal: string, context: any,
|
|
1492
|
+
debounce(signal: string, context: any, options?: {
|
|
1493
|
+
delayMs: number;
|
|
1494
|
+
}): void;
|
|
1495
|
+
/**
|
|
1496
|
+
* Aggregates and debounces multiple events with the same identifier to minimize redundant operations.
|
|
1497
|
+
*
|
|
1498
|
+
* @param {string} signal - The identifier for the event being emitted.
|
|
1499
|
+
* @param {AnyObject} context - The context data associated with the event.
|
|
1500
|
+
* @param {Object} [options] - Configuration options for handling the squashed event.
|
|
1501
|
+
* @param {boolean} [options.squash=true] - Whether the event should be squashed.
|
|
1502
|
+
* @param {string|null} [options.squashId=null] - A unique identifier for the squashed group of events. Defaults to the signal if null.
|
|
1503
|
+
* @param {function|null} [options.mergeFunction=null] - A custom merge function that combines old and new contexts. If null, a default merge is used.
|
|
1504
|
+
* @return {void} Does not return a value.
|
|
1505
|
+
*/
|
|
1506
|
+
squash(signal: string, context: AnyObject, options?: EmitOptions): void;
|
|
1479
1507
|
/**
|
|
1480
1508
|
* Emits a signal with the specified context, triggering any associated handlers for that signal.
|
|
1481
1509
|
*
|
|
1482
1510
|
* @param {string} signal - The name of the signal to emit.
|
|
1483
1511
|
* @param {AnyObject} [context={}] - An optional context object containing additional information or metadata
|
|
1484
1512
|
* associated with the signal. If the context includes a `__routineExecId`, it will be handled accordingly.
|
|
1513
|
+
* @param options
|
|
1485
1514
|
* @return {void} This method does not return a value.
|
|
1486
1515
|
*/
|
|
1487
|
-
emit(signal: string, context?: AnyObject): void;
|
|
1516
|
+
emit(signal: string, context?: AnyObject, options?: EmitOptions): void;
|
|
1488
1517
|
/**
|
|
1489
1518
|
* Executes a signal by emitting events, updating context, and invoking listeners.
|
|
1490
1519
|
* Creates a new execution trace if necessary and updates the context with relevant metadata.
|
|
@@ -1781,6 +1810,7 @@ declare class Cadenza {
|
|
|
1781
1810
|
*
|
|
1782
1811
|
* @param {string} event - The name of the event to emit.
|
|
1783
1812
|
* @param {AnyObject} [data={}] - The data payload associated with the event.
|
|
1813
|
+
* @param options
|
|
1784
1814
|
* @return {void} - No return value.
|
|
1785
1815
|
*
|
|
1786
1816
|
* @example
|
|
@@ -1790,8 +1820,8 @@ declare class Cadenza {
|
|
|
1790
1820
|
* Cadenza.emit('main.my_event', { foo: 'bar' });
|
|
1791
1821
|
* ```
|
|
1792
1822
|
*/
|
|
1793
|
-
static emit(event: string, data?: AnyObject): void;
|
|
1794
|
-
static schedule(taskName: string, context: AnyObject,
|
|
1823
|
+
static emit(event: string, data?: AnyObject, options?: EmitOptions): void;
|
|
1824
|
+
static schedule(taskName: string, context: AnyObject, delayMs: number, exactDateTime?: Date): void;
|
|
1795
1825
|
static interval(taskName: string, context: AnyObject, intervalMs: number, leading?: boolean, startDateTime?: Date): void;
|
|
1796
1826
|
static debounce(signalName: string, context: any, delayMs: number): void;
|
|
1797
1827
|
static get(taskName: string): Task | undefined;
|
|
@@ -2151,4 +2181,4 @@ declare class SignalTask extends Task {
|
|
|
2151
2181
|
constructor(signal: string, description?: string);
|
|
2152
2182
|
}
|
|
2153
2183
|
|
|
2154
|
-
export { type AnyObject, type CadenzaMode, type DebounceOptions, DebounceTask, EphemeralTask, type EphemeralTaskOptions, GraphContext, GraphRegistry, GraphRoutine, GraphRun, GraphRunner, type SchemaConstraints, type SchemaDefinition, type SchemaType, SignalBroker, SignalEmitter, SignalTask, Task, type TaskFunction, type TaskOptions, type TaskResult, type ThrottleTagGetter, Cadenza as default };
|
|
2184
|
+
export { type AnyObject, type CadenzaMode, type DebounceOptions, DebounceTask, type EmitOptions, EphemeralTask, type EphemeralTaskOptions, GraphContext, GraphRegistry, GraphRoutine, GraphRun, GraphRunner, type SchemaConstraints, type SchemaDefinition, type SchemaType, SignalBroker, SignalEmitter, SignalTask, Task, type TaskFunction, type TaskOptions, type TaskResult, type ThrottleTagGetter, Cadenza as default };
|