import { StringAnyType } from './common'; /** * Emits pub/sub events to the event bus, allowing workflows to broadcast * messages to external subscribers. Each entry in the `events` map is * published as a separate message on the corresponding topic. * * By default (`config.once = true`), events are emitted exactly once per * workflow execution — the `isSideEffectAllowed` guard prevents re-emission * on replay. Set `config.once = false` to emit on every re-execution * (rarely needed). * * ## Examples * * ```typescript * import { Durable } from '@hotmeshio/hotmesh'; * * // Emit a domain event when an order is processed * export async function orderWorkflow(orderId: string): Promise { * const { processOrder } = Durable.workflow.proxyActivities(); * const result = await processOrder(orderId); * * await Durable.workflow.emit({ * 'order.completed': { orderId, total: result.total }, * 'analytics.event': { type: 'order', orderId }, * }); * } * ``` * * ```typescript * // Emit progress events during a long-running workflow * export async function batchWorkflow(items: string[]): Promise { * const { processItem } = Durable.workflow.proxyActivities(); * * for (let i = 0; i < items.length; i++) { * await processItem(items[i]); * await Durable.workflow.emit( * { 'batch.progress': { completed: i + 1, total: items.length } }, * { once: false }, // emit on every execution (progress updates) * ); * } * } * ``` * * @param {StringAnyType} events - A mapping of `topic` to message payload. * @param {{ once: boolean }} [config={ once: true }] - If `true`, events emit only once (idempotent). * @returns {Promise} `true` after emission completes. */ export declare function emit(events: StringAnyType, config?: { once: boolean; }): Promise;