UNPKG

arvo-event-handler

Version:

A complete set of orthogonal event handler and orchestration primitives for Arvo based applications, featuring declarative state machines (XState), imperative resumables for agentic workflows, contract-based routing, OpenTelemetry observability, and in-me

83 lines (82 loc) 3.39 kB
import { type ArvoEvent, type VersionedArvoContract } from 'arvo-core'; /** * Symbolic constants for domain resolution in Arvo event emission. * * These can be passed into the `domain` array of an emitted ArvoEvent to indicate * that the final domain should be dynamically resolved from a specific context. */ export declare const ArvoDomain: { /** * Resolve domain from the handler's contract. * * Uses `handlerSelfContract.domain` for all emitted events. */ readonly FROM_SELF_CONTRACT: "domain.contract.self.inherit"; /** * Resolve domain from the event's contract. * * For orchestrators, uses the service contract's domain. * For handlers, behaves the same as FROM_SELF_CONTRACT. */ readonly FROM_EVENT_CONTRACT: "domain.contract.inherit"; /** * Resolve domain from the triggering event's domain field. * * Preserves the domain context of the incoming event. */ readonly FROM_TRIGGERING_EVENT: "domain.event.inherit"; /** * Extract domain from the current event's subject. * * Parses the subject to retrieve `execution.domain`. * Falls back to LOCAL if subject is not a valid ArvoOrchestrationSubject. */ readonly FROM_CURRENT_SUBJECT: "domain.event.current.subject"; /** * Extract domain from the parent orchestration subject. * * Parses the parent subject to retrieve `execution.domain`. * Falls back to LOCAL if subject is not a valid ArvoOrchestrationSubject. */ readonly FROM_PARENT_SUBJECT: "domain.parent.subject"; /** * Resolve domain based on orchestration context. * * Routes responses and completions back through the orchestration chain: * - For handlers: routes back to the orchestration's domain * - For child orchestrations: routes to parent's domain if different, LOCAL if same * - For root orchestrations: routes to own domain if cross-domain call, LOCAL otherwise * * This is the recommended default for maintaining domain coherence in orchestration workflows. */ readonly ORCHESTRATION_CONTEXT: "domain.orchestration.context"; /** * Stay in the current execution context (null domain). * * Event remains local without crossing domain boundaries. */ readonly LOCAL: null; }; /** * Resolves symbolic domain constants to concrete domain values. * * Interprets domain resolution symbols and returns the appropriate domain string or null. * Static domain strings pass through unchanged. * * @param param.domainToResolve - Domain string or symbolic constant to resolve * @param param.parentSubject - Parent orchestration subject (null for root orchestrations or handlers) * @param param.currentSubject - Current event subject * @param param.handlerSelfContract - Contract of the handler emitting the event * @param param.eventContract - Contract of the event being emitted (optional) * @param param.triggeringEvent - Event that triggered this emission * * @returns Resolved domain string or null */ export declare const resolveEventDomain: (param: { domainToResolve: string | null; parentSubject: string | null; currentSubject: string; handlerSelfContract: VersionedArvoContract<any, any>; eventContract: VersionedArvoContract<any, any> | null; triggeringEvent: ArvoEvent; }) => string | null;