@cadenza.io/service 2.8.0 → 2.10.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _cadenza_io_core from '@cadenza.io/core';
2
- import { Task, ThrottleTagGetter, Schema, GraphContext, AnyObject, InquiryOptions, TaskResult, GraphRoutine, SchemaDefinition, SignalBroker, InquiryBroker, GraphRunner, GraphRegistry, EmitOptions, CadenzaMode, Intent, TaskOptions, TaskFunction, DebounceOptions, DebounceTask, EphemeralTaskOptions, EphemeralTask } from '@cadenza.io/core';
3
- export { AnyObject, DebounceOptions, DebounceTask, EphemeralTask, EphemeralTaskOptions, GraphRoutine, Task, TaskFunction, TaskOptions, ThrottleTagGetter } from '@cadenza.io/core';
2
+ import { Task, ThrottleTagGetter, Schema, GraphContext, AnyObject, InquiryOptions, TaskResult, GraphRoutine, SchemaDefinition, SignalBroker, InquiryBroker, GraphRunner, GraphRegistry, EmitOptions, CadenzaMode, Intent, Actor, TaskOptions, ActorSpec, ActorFactoryOptions, ActorDefinition, TaskFunction, DebounceOptions, DebounceTask, EphemeralTaskOptions, EphemeralTask } from '@cadenza.io/core';
3
+ export { Actor, ActorConsistencyProfileName, ActorDefinition, ActorFactoryOptions, ActorInvocationOptions, ActorKeyDefinition, ActorKind, ActorLoadPolicy, ActorRuntimeReadGuard, ActorSpec, ActorStateDefinition, ActorStateReducer, ActorStateStore, ActorTaskBindingDefinition, ActorTaskBindingOptions, ActorTaskContext, ActorTaskHandler, ActorTaskMode, ActorWriteContract, AnyObject, DebounceOptions, DebounceTask, EphemeralTask, EphemeralTaskOptions, GraphRoutine, IdempotencyPolicy, RetryPolicy, SessionPolicy, Task, TaskFunction, TaskOptions, ThrottleTagGetter } from '@cadenza.io/core';
4
4
 
5
5
  /**
6
6
  * Represents a task that delegates execution of a routine to a remote system or service.
@@ -22223,6 +22223,8 @@ declare class CadenzaService {
22223
22223
  */
22224
22224
  static log(message: string, data?: any, level?: "info" | "warning" | "error" | "critical", subjectServiceName?: string | null, subjectServiceInstanceId?: string | null): void;
22225
22225
  static get(taskName: string): Task | undefined;
22226
+ static getActor<D extends Record<string, any> = AnyObject, R = AnyObject>(actorName: string): Actor<D, R> | undefined;
22227
+ static getAllActors<D extends Record<string, any> = AnyObject, R = AnyObject>(): Actor<D, R>[];
22226
22228
  static getRoutine(routineName: string): GraphRoutine | undefined;
22227
22229
  /**
22228
22230
  * Creates a new DeputyTask instance based on the provided routine name, service name, and options.
@@ -22422,6 +22424,8 @@ declare class CadenzaService {
22422
22424
  * @return {void} - This method does not return a value.
22423
22425
  */
22424
22426
  static createMetaDatabaseService(name: string, schema: DatabaseSchemaDefinition, description?: string, options?: ServerOptions & DatabaseOptions): void;
22427
+ static createActor<D extends Record<string, any> = AnyObject, R = AnyObject>(spec: ActorSpec<D, R>, options?: ActorFactoryOptions): Actor<D, R>;
22428
+ static createActorFromDefinition<D extends Record<string, any> = AnyObject, R = AnyObject>(definition: ActorDefinition<D, R>, options?: ActorFactoryOptions<D, R>): Actor<D, R>;
22425
22429
  /**
22426
22430
  * Creates and registers a new task with the provided name, function, and optional details.
22427
22431
  *
@@ -22784,6 +22788,9 @@ declare class RestController {
22784
22788
  static get instance(): RestController;
22785
22789
  private fetchClientDiagnostics;
22786
22790
  private readonly diagnosticsErrorHistoryLimit;
22791
+ private readonly diagnosticsMaxClientEntries;
22792
+ private readonly destroyedDiagnosticsTtlMs;
22793
+ private pruneFetchClientDiagnostics;
22787
22794
  private resolveTransportDiagnosticsOptions;
22788
22795
  private ensureFetchClientDiagnostics;
22789
22796
  private getErrorMessage;
@@ -22813,41 +22820,68 @@ declare class RestController {
22813
22820
  constructor();
22814
22821
  }
22815
22822
 
22823
+ interface TransportDiagnosticErrorEntry {
22824
+ at: string;
22825
+ message: string;
22826
+ }
22827
+ interface SocketClientDiagnosticsState {
22828
+ fetchId: string;
22829
+ serviceName: string;
22830
+ url: string;
22831
+ socketId: string | null;
22832
+ connected: boolean;
22833
+ handshake: boolean;
22834
+ reconnectAttempts: number;
22835
+ connectErrors: number;
22836
+ reconnectErrors: number;
22837
+ socketErrors: number;
22838
+ pendingDelegations: number;
22839
+ pendingTimers: number;
22840
+ destroyed: boolean;
22841
+ lastHandshakeAt: string | null;
22842
+ lastHandshakeError: string | null;
22843
+ lastDisconnectAt: string | null;
22844
+ lastError: string | null;
22845
+ lastErrorAt: number;
22846
+ errorHistory: TransportDiagnosticErrorEntry[];
22847
+ updatedAt: number;
22848
+ }
22816
22849
  /**
22817
- * The `SocketController` class handles the setup and management of a WebSocket server,
22818
- * ensuring secure connections, message handling, and rate-limiting.
22819
- * This class is designed to function as a singleton, providing a unified interface
22820
- * for WebSocket interactions in the application by standardizing the server setup
22821
- * and integrating task-based processing through the `Cadenza` framework.
22850
+ * Socket transport orchestration in the Cadenza primitive ecosystem.
22851
+ *
22852
+ * - setup is signal-triggered
22853
+ * - state/runtime ownership is actor-backed
22854
+ * - dynamic runtime tasks are still allowed for advanced orchestration (ephemeral resolvers etc.)
22822
22855
  */
22823
22856
  declare class SocketController {
22824
22857
  private static _instance;
22825
22858
  static get instance(): SocketController;
22826
- private socketClientDiagnostics;
22827
22859
  private readonly diagnosticsErrorHistoryLimit;
22828
- private resolveTransportDiagnosticsOptions;
22829
- private ensureSocketClientDiagnostics;
22860
+ private readonly diagnosticsMaxClientEntries;
22861
+ private readonly destroyedDiagnosticsTtlMs;
22862
+ private readonly socketServerDefaultKey;
22863
+ private readonly socketServerInitialSessionState;
22864
+ private readonly socketClientInitialSessionState;
22865
+ private readonly socketServerActor;
22866
+ private readonly socketClientActor;
22867
+ private readonly socketClientDiagnosticsActor;
22868
+ constructor();
22869
+ private registerDiagnosticsTasks;
22870
+ private registerSocketServerTasks;
22871
+ private registerSocketClientTasks;
22872
+ private resolveSocketServerKey;
22873
+ private resolveSocketClientFetchId;
22874
+ private resolveServicePort;
22875
+ private createSocketServerRuntimeHandleFromContext;
22876
+ private destroySocketServerRuntimeHandle;
22877
+ private createSocketClientRuntimeHandle;
22878
+ private destroySocketClientRuntimeHandle;
22879
+ private normalizeCommunicationTypes;
22830
22880
  private getErrorMessage;
22831
- private recordSocketClientError;
22881
+ private pruneDiagnosticsEntries;
22882
+ getSocketClientDiagnosticsEntry(fetchId: string): Promise<SocketClientDiagnosticsState | undefined>;
22883
+ private resolveTransportDiagnosticsOptions;
22832
22884
  private collectSocketTransportDiagnostics;
22833
- /**
22834
- * Constructs the `SocketServer`, setting up a WebSocket server with specific configurations,
22835
- * including connection state recovery, rate limiting, CORS handling, and custom event handling.
22836
- * This class sets up the communication infrastructure for scalable, resilient, and secure WebSocket-based interactions
22837
- * using metadata-driven task execution with `Cadenza`.
22838
- *
22839
- * It provides support for:
22840
- * - Origin-based access control for connections.
22841
- * - Optional payload sanitization.
22842
- * - Configurable rate limiting and behavior on limit breaches (soft/hard disconnects).
22843
- * - Event handlers for connection, handshake, delegation, signaling, status checks, and disconnection.
22844
- *
22845
- * The server can handle both internal and external interactions depending on the provided configurations,
22846
- * and integrates directly with Cadenza's task workflow engine.
22847
- *
22848
- * Initializes the `SocketServer` to be ready for WebSocket communication.
22849
- */
22850
- constructor();
22851
22885
  }
22852
22886
 
22853
22887
  /**
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _cadenza_io_core from '@cadenza.io/core';
2
- import { Task, ThrottleTagGetter, Schema, GraphContext, AnyObject, InquiryOptions, TaskResult, GraphRoutine, SchemaDefinition, SignalBroker, InquiryBroker, GraphRunner, GraphRegistry, EmitOptions, CadenzaMode, Intent, TaskOptions, TaskFunction, DebounceOptions, DebounceTask, EphemeralTaskOptions, EphemeralTask } from '@cadenza.io/core';
3
- export { AnyObject, DebounceOptions, DebounceTask, EphemeralTask, EphemeralTaskOptions, GraphRoutine, Task, TaskFunction, TaskOptions, ThrottleTagGetter } from '@cadenza.io/core';
2
+ import { Task, ThrottleTagGetter, Schema, GraphContext, AnyObject, InquiryOptions, TaskResult, GraphRoutine, SchemaDefinition, SignalBroker, InquiryBroker, GraphRunner, GraphRegistry, EmitOptions, CadenzaMode, Intent, Actor, TaskOptions, ActorSpec, ActorFactoryOptions, ActorDefinition, TaskFunction, DebounceOptions, DebounceTask, EphemeralTaskOptions, EphemeralTask } from '@cadenza.io/core';
3
+ export { Actor, ActorConsistencyProfileName, ActorDefinition, ActorFactoryOptions, ActorInvocationOptions, ActorKeyDefinition, ActorKind, ActorLoadPolicy, ActorRuntimeReadGuard, ActorSpec, ActorStateDefinition, ActorStateReducer, ActorStateStore, ActorTaskBindingDefinition, ActorTaskBindingOptions, ActorTaskContext, ActorTaskHandler, ActorTaskMode, ActorWriteContract, AnyObject, DebounceOptions, DebounceTask, EphemeralTask, EphemeralTaskOptions, GraphRoutine, IdempotencyPolicy, RetryPolicy, SessionPolicy, Task, TaskFunction, TaskOptions, ThrottleTagGetter } from '@cadenza.io/core';
4
4
 
5
5
  /**
6
6
  * Represents a task that delegates execution of a routine to a remote system or service.
@@ -22223,6 +22223,8 @@ declare class CadenzaService {
22223
22223
  */
22224
22224
  static log(message: string, data?: any, level?: "info" | "warning" | "error" | "critical", subjectServiceName?: string | null, subjectServiceInstanceId?: string | null): void;
22225
22225
  static get(taskName: string): Task | undefined;
22226
+ static getActor<D extends Record<string, any> = AnyObject, R = AnyObject>(actorName: string): Actor<D, R> | undefined;
22227
+ static getAllActors<D extends Record<string, any> = AnyObject, R = AnyObject>(): Actor<D, R>[];
22226
22228
  static getRoutine(routineName: string): GraphRoutine | undefined;
22227
22229
  /**
22228
22230
  * Creates a new DeputyTask instance based on the provided routine name, service name, and options.
@@ -22422,6 +22424,8 @@ declare class CadenzaService {
22422
22424
  * @return {void} - This method does not return a value.
22423
22425
  */
22424
22426
  static createMetaDatabaseService(name: string, schema: DatabaseSchemaDefinition, description?: string, options?: ServerOptions & DatabaseOptions): void;
22427
+ static createActor<D extends Record<string, any> = AnyObject, R = AnyObject>(spec: ActorSpec<D, R>, options?: ActorFactoryOptions): Actor<D, R>;
22428
+ static createActorFromDefinition<D extends Record<string, any> = AnyObject, R = AnyObject>(definition: ActorDefinition<D, R>, options?: ActorFactoryOptions<D, R>): Actor<D, R>;
22425
22429
  /**
22426
22430
  * Creates and registers a new task with the provided name, function, and optional details.
22427
22431
  *
@@ -22784,6 +22788,9 @@ declare class RestController {
22784
22788
  static get instance(): RestController;
22785
22789
  private fetchClientDiagnostics;
22786
22790
  private readonly diagnosticsErrorHistoryLimit;
22791
+ private readonly diagnosticsMaxClientEntries;
22792
+ private readonly destroyedDiagnosticsTtlMs;
22793
+ private pruneFetchClientDiagnostics;
22787
22794
  private resolveTransportDiagnosticsOptions;
22788
22795
  private ensureFetchClientDiagnostics;
22789
22796
  private getErrorMessage;
@@ -22813,41 +22820,68 @@ declare class RestController {
22813
22820
  constructor();
22814
22821
  }
22815
22822
 
22823
+ interface TransportDiagnosticErrorEntry {
22824
+ at: string;
22825
+ message: string;
22826
+ }
22827
+ interface SocketClientDiagnosticsState {
22828
+ fetchId: string;
22829
+ serviceName: string;
22830
+ url: string;
22831
+ socketId: string | null;
22832
+ connected: boolean;
22833
+ handshake: boolean;
22834
+ reconnectAttempts: number;
22835
+ connectErrors: number;
22836
+ reconnectErrors: number;
22837
+ socketErrors: number;
22838
+ pendingDelegations: number;
22839
+ pendingTimers: number;
22840
+ destroyed: boolean;
22841
+ lastHandshakeAt: string | null;
22842
+ lastHandshakeError: string | null;
22843
+ lastDisconnectAt: string | null;
22844
+ lastError: string | null;
22845
+ lastErrorAt: number;
22846
+ errorHistory: TransportDiagnosticErrorEntry[];
22847
+ updatedAt: number;
22848
+ }
22816
22849
  /**
22817
- * The `SocketController` class handles the setup and management of a WebSocket server,
22818
- * ensuring secure connections, message handling, and rate-limiting.
22819
- * This class is designed to function as a singleton, providing a unified interface
22820
- * for WebSocket interactions in the application by standardizing the server setup
22821
- * and integrating task-based processing through the `Cadenza` framework.
22850
+ * Socket transport orchestration in the Cadenza primitive ecosystem.
22851
+ *
22852
+ * - setup is signal-triggered
22853
+ * - state/runtime ownership is actor-backed
22854
+ * - dynamic runtime tasks are still allowed for advanced orchestration (ephemeral resolvers etc.)
22822
22855
  */
22823
22856
  declare class SocketController {
22824
22857
  private static _instance;
22825
22858
  static get instance(): SocketController;
22826
- private socketClientDiagnostics;
22827
22859
  private readonly diagnosticsErrorHistoryLimit;
22828
- private resolveTransportDiagnosticsOptions;
22829
- private ensureSocketClientDiagnostics;
22860
+ private readonly diagnosticsMaxClientEntries;
22861
+ private readonly destroyedDiagnosticsTtlMs;
22862
+ private readonly socketServerDefaultKey;
22863
+ private readonly socketServerInitialSessionState;
22864
+ private readonly socketClientInitialSessionState;
22865
+ private readonly socketServerActor;
22866
+ private readonly socketClientActor;
22867
+ private readonly socketClientDiagnosticsActor;
22868
+ constructor();
22869
+ private registerDiagnosticsTasks;
22870
+ private registerSocketServerTasks;
22871
+ private registerSocketClientTasks;
22872
+ private resolveSocketServerKey;
22873
+ private resolveSocketClientFetchId;
22874
+ private resolveServicePort;
22875
+ private createSocketServerRuntimeHandleFromContext;
22876
+ private destroySocketServerRuntimeHandle;
22877
+ private createSocketClientRuntimeHandle;
22878
+ private destroySocketClientRuntimeHandle;
22879
+ private normalizeCommunicationTypes;
22830
22880
  private getErrorMessage;
22831
- private recordSocketClientError;
22881
+ private pruneDiagnosticsEntries;
22882
+ getSocketClientDiagnosticsEntry(fetchId: string): Promise<SocketClientDiagnosticsState | undefined>;
22883
+ private resolveTransportDiagnosticsOptions;
22832
22884
  private collectSocketTransportDiagnostics;
22833
- /**
22834
- * Constructs the `SocketServer`, setting up a WebSocket server with specific configurations,
22835
- * including connection state recovery, rate limiting, CORS handling, and custom event handling.
22836
- * This class sets up the communication infrastructure for scalable, resilient, and secure WebSocket-based interactions
22837
- * using metadata-driven task execution with `Cadenza`.
22838
- *
22839
- * It provides support for:
22840
- * - Origin-based access control for connections.
22841
- * - Optional payload sanitization.
22842
- * - Configurable rate limiting and behavior on limit breaches (soft/hard disconnects).
22843
- * - Event handlers for connection, handshake, delegation, signaling, status checks, and disconnection.
22844
- *
22845
- * The server can handle both internal and external interactions depending on the provided configurations,
22846
- * and integrates directly with Cadenza's task workflow engine.
22847
- *
22848
- * Initializes the `SocketServer` to be ready for WebSocket communication.
22849
- */
22850
- constructor();
22851
22885
  }
22852
22886
 
22853
22887
  /**