import { HotMesh } from '../hotmesh'; import { ClientConfig, ClientWorkflow, Connection, WorkflowOptions } from '../../types/durable'; import { EscalationClientService } from '../escalations/client'; import { EventsConfig } from '../../types/system_events'; /** * Workflow client. Starts workflows, sends signals, and reads results. * * Pass `config.events` to receive system-event notifications from all * escalation operations performed through this client. Events fire * post-commit, from this process only — no fanout to other containers. * See `EventsConfig` and `SystemEvent` in `types/system_events` for the full ontology. * * @example * ```typescript * import { Durable } from '@hotmeshio/hotmesh'; * import { Client as Postgres } from 'pg'; * * const client = new Durable.Client({ * connection: { * class: Postgres, * options: { connectionString: 'postgresql://usr:pwd@localhost:5432/db' }, * }, * // optional — wire lifecycle events * events: { * publish: (event) => { * // event.type follows system.escalation.{id}.{verb} * myEventBus.emit(event.type, event.data); * }, * }, * }); * * // Start a workflow and await its result * const handle = await client.workflow.start({ * args: ['order-123'], * taskQueue: 'orders', * workflowName: 'orderWorkflow', * workflowId: Durable.guid(), * }); * const result = await handle.result(); * * // Send a signal to a running workflow * await handle.signal('approval', { approved: true }); * * // Cancel a running workflow * await handle.cancel(); * ``` */ export declare class ClientService { /** * @private */ connection: Connection; /** * @private */ options: WorkflowOptions; /** * @private */ events?: EventsConfig; /** * @private */ static topics: string[]; /** * @private */ static instances: Map>; /** * Escalation queue operations — a thin proxy to `Escalations.Client` that * reuses this Durable.Client's engine pool. Calling * `client.escalations.list(...)` is identical to creating a separate * `new Escalations.Client({ connection })` — just more convenient. */ escalations: EscalationClientService; /** * @private */ constructor(config: ClientConfig); /** * @private */ getHotMeshClient: (taskQueue: string | null, namespace?: string) => Promise; /** * Creates a stream where messages can be published to ensure there is a * channel in place when the message arrives (a race condition for those * platforms without implicit topic setup). * @private */ static createStream: (hotMeshClient: HotMesh, workflowTopic: string, namespace?: string) => Promise; hashOptions(): string; /** * It is possible for a client to invoke a workflow without first * creating the stream. This method will verify that the stream * exists and if not, create it. * @private */ verifyStream: (hotMeshClient: HotMesh, workflowTopic: string, namespace?: string) => Promise; /** * @private */ search: (hotMeshClient: HotMesh, index: string, query: string[]) => Promise; /** * The Durable `Client` service provides methods for * starting, signaling, and querying workflows. * Starting a workflow is the primary use case and * is accessed by calling workflow.start(). */ workflow: ClientWorkflow; /** * Any router can be used to deploy and activate the HotMesh * distributed executable to the active quorum EXCEPT for * those routers in `readonly` mode. */ deployAndActivate(namespace?: string, version?: string): Promise; /** * @private */ verifyWorkflowActive(hotMesh: HotMesh, appId?: string, count?: number): Promise; /** * @private */ activateWorkflow(hotMesh: HotMesh, appId?: string, version?: string): Promise; /** * @private */ static shutdown(): Promise; }