Class ArvoEvent<TData, TExtension, TType>

Represents an ArvoEvent, which extends the CloudEvent specification with Arvo-specific extensions for event routing, access control, execution metrics, and OpenTelemetry distributed tracing support.

Type Parameters

Constructors

  • Creates an instance of ArvoEvent with CloudEvent context, data, and optional extensions.

    Type Parameters

    • TData extends Record<string, any> = Record<string, any>
    • TExtension extends Record<string,
          | null
          | string
          | number
          | boolean> = Record<string,
          | null
          | string
          | number
          | boolean>
    • TType extends string = string

    Parameters

    • context: {
          datacontenttype: string;
          dataschema: null | string;
          id: string;
          source: string;
          specversion: "1.0";
          subject: string;
          time: string;
          type: string;
      } & {
          accesscontrol: null | string;
          domain: null | string;
          executionunits: null | number;
          parentid: null | string;
          redirectto: null | string;
          to: null | string;
      } & {
          traceparent: null | string;
          tracestate: null | string;
      }

      The CloudEvent context combined with required Arvo and OpenTelemetry extensions

    • data: TData

      The event data payload (must be JSON serializable)

    • Optionalextensions: TExtension

      Optional additional custom extensions with lowercase alphanumeric keys

    Returns ArvoEvent<TData, TExtension, TType>

    If datacontenttype is "application/cloudevents+json;charset=UTF-8;profile=arvo" but the 'to' field is not defined

    If any validation fails according to the respective schemas

    const event = new ArvoEvent(
    {
    id: 'event-123',
    source: 'https://example.com/service',
    type: 'com.example.user.created',
    subject: 'https://example.com/users/123',
    time: new Date().toISOString(),
    specversion: '1.0',
    datacontenttype: 'application/cloudevents+json;charset=UTF-8;profile=arvo',
    dataschema: null,
    to: 'com.example.user.processor',
    accesscontrol: 'role:admin;department:hr',
    redirectto: null,
    executionunits: 10,
    parentid: 'parent-event-456',
    domain: 'analytics',
    traceparent: '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01',
    tracestate: 'vendor=trace-data'
    },
    { userId: '123', name: 'John Doe' }
    );

Properties

data: TData

The event data payload as a JSON serializable object

datacontenttype: string

Content type of the data value following RFC 2046 format. Must contain 'application/cloudevents+json' or 'application/json'. Defaults to 'application/cloudevents+json;charset=UTF-8;profile=arvo'.

dataschema: null | string

URI identifying the schema that the data adheres to. Must be a properly encoded URI if present, null otherwise.

id: string

Unique identifier of the event

source: string

URI reference identifying the context in which the event happened. Must be a properly encoded URI representing the event producer.

specversion: string

The version of the CloudEvents specification which the event uses. Must be '1.0' for this version of the specification.

subject: string

Identifies the subject of the event in the context of the event producer. In Arvo, this must be the Process ID and must be a properly encoded URI.

time: string

Timestamp of when the occurrence happened in RFC 3339 format. If the actual occurrence time cannot be determined, this may be set to another time (such as current time) by the producer.

type: TType

Describes the type of event related to the originating occurrence. Must follow reverse-DNS naming convention (e.g., 'com.example.service.eventtype').

Accessors

  • get accesscontrol(): null | string
  • Gets the access control information for the event. Can contain:

    • A UserID (valid UUID)
    • An encrypted base64 string with access control data
    • Key-value pairs (semicolon-separated, colon-delimited) Example: "role:admin;department:finance;clearance:top-secret"

    Returns null | string

  • get cloudevent(): {
        default: {
            data: TData;
            datacontenttype: string;
            dataschema: null | string;
            id: string;
            source: string;
            specversion: string;
            subject: string;
            time: string;
            type: TType;
        };
        extensions: TExtension & {
            accesscontrol: null | string;
            domain: null | string;
            executionunits: null | number;
            parentid: null | string;
            redirectto: null | string;
            to: null | string;
        } & {
            traceparent: null | string;
            tracestate: null | string;
        };
    }
  • Gets the CloudEvent-specified fields separated into default attributes and extensions.

    Returns {
        default: {
            data: TData;
            datacontenttype: string;
            dataschema: null | string;
            id: string;
            source: string;
            specversion: string;
            subject: string;
            time: string;
            type: TType;
        };
        extensions: TExtension & {
            accesscontrol: null | string;
            domain: null | string;
            executionunits: null | number;
            parentid: null | string;
            redirectto: null | string;
            to: null | string;
        } & {
            traceparent: null | string;
            tracestate: null | string;
        };
    }

    An object containing:

    • default: Standard CloudEvent attributes (id, source, specversion, type, subject, datacontenttype, dataschema, data, time)
    • extensions: All extension attributes including:
      • Arvo extensions
      • OpenTelemetry extensions
      • Custom extensions
    • default: {
          data: TData;
          datacontenttype: string;
          dataschema: null | string;
          id: string;
          source: string;
          specversion: string;
          subject: string;
          time: string;
          type: TType;
      }
      • data: TData
      • datacontenttype: string
      • dataschema: null | string
      • id: string
      • source: string
      • specversion: string
      • subject: string
      • time: string
      • type: TType
    • extensions: TExtension & {
          accesscontrol: null | string;
          domain: null | string;
          executionunits: null | number;
          parentid: null | string;
          redirectto: null | string;
          to: null | string;
      } & {
          traceparent: null | string;
          tracestate: null | string;
      }
    const { default: defaults, extensions } = event.cloudevent;
    console.log(defaults.id); // Event ID
    console.log(extensions.to); // Arvo 'to' field
  • get domain(): null | string
  • Gets the processing domain for event routing and workflow orchestration.

    Returns null | string

  • get executionunits(): null | number
  • Gets the execution units representing the cost associated with generating this event. Used for tracking financial impact and resource utilization in cloud-based systems.

    Returns null | number

  • get extensions(): TExtension
  • Gets only the custom extensions (TExtension) added to the ArvoEvent, excluding the standard Arvo and OpenTelemetry extensions.

    Returns TExtension

    The custom extensions object with Arvo and OpenTelemetry fields removed

    For accessing all extensions including Arvo and OpenTelemetry, use cloudevent.extensions. For accessing basic CloudEvent fields, use cloudevent.default. Custom extension keys must follow lowercase alphanumeric naming (a-z, 0-9 only).

  • get otelAttributes(): {
        cloudevents.arvo.event_domain: string;
        cloudevents.arvo.event_executionunits: string | number;
        cloudevents.arvo.event_parentid: string;
        cloudevents.arvo.event_redirectto: string;
        cloudevents.arvo.event_to: string;
        cloudevents.event_datacontenttype: string;
        cloudevents.event_dataschema: string;
        cloudevents.event_id: string;
        cloudevents.event_source: string;
        cloudevents.event_spec_version: string;
        cloudevents.event_subject: string;
        cloudevents.event_time: string;
        cloudevents.event_type: string | TType;
    }
  • Gets OpenTelemetry attributes derived from the ArvoEvent for distributed tracing.

    Returns {
        cloudevents.arvo.event_domain: string;
        cloudevents.arvo.event_executionunits: string | number;
        cloudevents.arvo.event_parentid: string;
        cloudevents.arvo.event_redirectto: string;
        cloudevents.arvo.event_to: string;
        cloudevents.event_datacontenttype: string;
        cloudevents.event_dataschema: string;
        cloudevents.event_id: string;
        cloudevents.event_source: string;
        cloudevents.event_spec_version: string;
        cloudevents.event_subject: string;
        cloudevents.event_time: string;
        cloudevents.event_type: string | TType;
    }

    An object containing OpenTelemetry semantic convention attributes:

    • Standard CloudEvent attributes prefixed with 'cloudevents.event_*'
    • Arvo-specific attributes prefixed with 'cloudevents.arvo.*'
    • Uses 'N/A' for undefined/null values to maintain telemetry consistency
    • cloudevents.arvo.event_domain: string
    • cloudevents.arvo.event_executionunits: string | number
    • cloudevents.arvo.event_parentid: string
    • cloudevents.arvo.event_redirectto: string
    • cloudevents.arvo.event_to: string
    • cloudevents.event_datacontenttype: string
    • cloudevents.event_dataschema: string
    • cloudevents.event_id: string
    • cloudevents.event_source: string
    • cloudevents.event_spec_version: string
    • cloudevents.event_subject: string
    • cloudevents.event_time: string
    • cloudevents.event_type: string | TType

    The attributes follow the OpenTelemetry semantic conventions for CloudEvents as specified in the official documentation: https://opentelemetry.io/docs/specs/semconv/attributes-registry/cloudevents/

  • get parentid(): null | string
  • Gets the unique identifier of the event that directly triggered the creation of this event within the Arvo ecosystem. Establishes direct causal relationships for event lineage tracking. Null indicates an initiating event or generation outside direct causation.

    Returns null | string

  • get redirectto(): null | string
  • Gets the alternative recipient or destination for dynamic routing. Enables complex workflows and conditional event routing.

    Returns null | string

  • get to(): null | string
  • Gets the target consumer machine for event routing.

    Returns null | string

  • get traceparent(): null | string
  • Gets the OpenTelemetry traceparent header containing trace context information including trace ID, parent span ID, and trace flags for distributed tracing across services.

    Returns null | string

  • get tracestate(): null | string
  • Gets the OpenTelemetry tracestate header containing vendor-specific trace information as key-value pairs propagated alongside traceparent in distributed tracing scenarios.

    Returns null | string

Methods

  • Converts the ArvoEvent to a JSON-serializable object by combining all CloudEvent default fields with all extensions into a single flat object.

    Returns InferArvoEvent<ArvoEvent<TData, TExtension, TType>>

    A flat object containing all CloudEvent fields and extensions, suitable for JSON serialization and network transmission

    This method creates a flattened representation where both standard CloudEvent fields and all extensions (Arvo, OpenTelemetry, and custom) are at the same level. For separated access to defaults and extensions, use the cloudevent getter instead.

    const jsonObj = event.toJSON();
    // Contains: id, source, type, subject, data, time, to, traceparent, etc.
  • Converts the ArvoEvent to a JSON string representation.

    Parameters

    • spacing: number = 0

      The number of spaces to use for indentation (default: 0 for compact output)

    Returns string

    A JSON string representation of the complete ArvoEvent

    const compactJson = event.toString(); // Compact JSON
    const prettyJson = event.toString(2); // Pretty-printed with 2-space indentation