UNPKG

arvo-core

Version:

The core Arvo package which provides application tier core primitives and contract system for building production-grade event-driven application. Provides ArvoEvent (CloudEvents-compliant), ArvoContract for type-safe service interfaces, event factories, O

49 lines (48 loc) 2.67 kB
import type { z } from 'zod'; import ArvoEventFactory from '.'; import type { VersionedArvoContract } from '../ArvoContract/VersionedArvoContract'; import type { CreateArvoEvent } from '../ArvoEvent/types'; /** * Factory class for creating and validating orchestrator-specific events with managed subject hierarchies. * Extends ArvoEventFactory with parent-child subject relationship handling and orchestration flows. * * @example * ```typescript * const contract = createArvoOrchestratorContract({ ... }); * * const factory = createArvoOrchestratorEventFactory(contract.version('1.0.0')); * ``` */ export declare class ArvoOrchestratorEventFactory<TContract extends VersionedArvoContract<any, any>> extends ArvoEventFactory<TContract> { protected readonly _name: string; constructor(contract: TContract); /** * Initializes a new orchestration event, handling parent-child subject relationships. * - If parentSubject$$ is provided, creates a child subject * - If no parent, creates a new root orchestration subject * * @param event - Event configuration without type/schema/subject * @param [extensions] - Optional additional properties * @returns Validated orchestration event with proper subject hierarchy * * @throws Error if event validation fails */ init<TExtension extends Record<string, any>>(event: Omit<CreateArvoEvent<z.input<TContract['accepts']['schema']>, TContract['accepts']['type']>, 'type' | 'datacontenttype' | 'dataschema' | 'subject' | 'domain'> & { subject?: string; domain?: string | null; }, extensions?: TExtension): import("..").ArvoEvent<z.TypeOf<TContract["accepts"]["schema"]>, TExtension, TContract["accepts"]["type"]>; /** * Creates a completion event for the orchestration flow. * Uses the contract's configured complete event type from metadata. * * @param event - Completion event configuration * @param [extensions] - Optional additional properties * @returns Validated completion event * * @throws Error if event validation fails or complete event type not configured */ complete<TExtension extends Record<string, any>>(event: Omit<CreateArvoEvent<z.input<TContract['emits'][TContract['metadata']['completeEventType']]>, TContract['metadata']['completeEventType']>, 'datacontenttype' | 'dataschema' | 'type' | 'subject' | 'domain'> & { subject?: string; domain?: string | null; }, extensions?: TExtension): import("..").ArvoEvent<z.TypeOf<TContract["emits"][TContract["metadata"]["completeEventType"]]>, TExtension, TContract["metadata"]["completeEventType"]>; }