arvo-core
    Preparing search index...

    Class ArvoOrchestratorEventFactory<TContract>

    Factory class for creating and validating orchestrator-specific events with managed subject hierarchies. Extends ArvoEventFactory with parent-child subject relationship handling and orchestration flows.

    const contract = createArvoOrchestratorContract({ ... });

    const factory = createArvoOrchestratorEventFactory(contract.version('1.0.0'));

    Type Parameters

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _name: string = 'OrchestratorEventFactory'
    contract: TContract

    Methods

    • Creates and validates an event matching the contract's accept specification.

      Type Parameters

      • TExtension extends Record<string, any>

      Parameters

      • event: Omit<
            CreateArvoEvent<
                input<TContract["accepts"]["schema"]>,
                TContract["accepts"]["type"],
            >,
            "type" | "subject" | "datacontenttype" | "dataschema" | "domain",
        > & { domain?: string | null; subject?: string }

        The event configuration object

      • Optionalextensions: TExtension

        Optional additional properties for the event

      Returns ArvoEvent<
          TypeOf<TContract["accepts"]["schema"]>,
          TExtension,
          TContract["accepts"]["type"],
      >

      A validated ArvoEvent matching the contract's accept specification

      If validation fails or OpenTelemetry operations fail

      const event = factory.accepts({
      source: 'api/users',
      data: { name: 'John', email: 'john@example.com' }
      });
    • Creates a completion event for the orchestration flow. Uses the contract's configured complete event type from metadata.

      Type Parameters

      • TExtension extends Record<string, any>

      Parameters

      • event: Omit<
            CreateArvoEvent<
                input<TContract["emits"][TContract["metadata"]["completeEventType"]]>,
                TContract["metadata"]["completeEventType"],
            >,
            "type" | "subject" | "datacontenttype" | "dataschema" | "domain",
        > & { domain?: string | null; subject?: string }

        Completion event configuration

      • Optionalextensions: TExtension

        Optional additional properties

      Returns ArvoEvent<
          TypeOf<TContract["emits"][TContract["metadata"]["completeEventType"]]>,
          TExtension,
          TContract["metadata"]["completeEventType"],
      >

      Validated completion event

      Error if event validation fails or complete event type not configured

    • Creates and validates an event matching one of the contract's emit specifications.

      Type Parameters

      • U extends string
      • TExtension extends Record<string, any>

      Parameters

      • event: Omit<
            CreateArvoEvent<input<TContract["emits"][U]>, U>,
            "subject" | "datacontenttype" | "dataschema" | "domain",
        > & { domain?: string | null; subject?: string }

        The event configuration object

      • Optionalextensions: TExtension

        Optional additional properties for the event

      Returns ArvoEvent<TypeOf<TContract["emits"][U]>, TExtension, U>

      A validated ArvoEvent matching the specified emit type

      If validation fails, emit type doesn't exist, or OpenTelemetry operations fail

      const event = factory.emits({
      type: 'user.created',
      source: 'api/users',
      data: { id: '123', timestamp: new Date() }
      });
    • 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

      Type Parameters

      • TExtension extends Record<string, any>

      Parameters

      • event: Omit<
            CreateArvoEvent<
                input<TContract["accepts"]["schema"]>,
                TContract["accepts"]["type"],
            >,
            "type" | "subject" | "datacontenttype" | "dataschema" | "domain",
        > & { domain?: string | null; subject?: string }

        Event configuration without type/schema/subject

      • Optionalextensions: TExtension

        Optional additional properties

      Returns ArvoEvent<
          TypeOf<TContract["accepts"]["schema"]>,
          TExtension,
          TContract["accepts"]["type"],
      >

      Validated orchestration event with proper subject hierarchy

      Error if event validation fails

    • Creates a system error event for error reporting and handling.

      Type Parameters

      • TExtension extends Record<string, any>

      Parameters

      • event: Omit<
            CreateArvoEvent<any, any>,
            "type" | "subject" | "datacontenttype" | "dataschema" | "domain" | "data",
        > & { domain?: string | null; error: Error; subject?: string }

        The error event configuration

        • error

          The Error instance to convert to an event

        • Optionaldomain?: string | null
        • error: Error

          The Error instance to convert to an event

        • Optionalsubject?: string
      • Optionalextensions: TExtension

        Optional additional properties for the event

      Returns ArvoEvent<
          { errorMessage: string; errorName: string; errorStack: string
          | null },
          TExtension,
          TContract["systemError"]["type"],
      >

      A system error ArvoEvent

      If event creation or OpenTelemetry operations fail

      const errorEvent = factory.systemError({
      error: new Error('Validation failed'),
      source: 'api/validation'
      });