Skip to content

@codesoul-co/hypha-core / modules/runtime/event-runtime

Using this module

Use the Event runtime module for creating, recording, or reading Event contracts. It exports 1 class, 1 function, 6 interfaces, 1 type.

Import from the package entrypoint

ts
import {
  DurableEventRuntime,
  eventExportChecksum,
} from '@codesoul-co/hypha-core';

import type {
  DurableEventRuntimeOptions,
  EventExportResult,
  EventImportRequest,
  EventImportResult,
  EventReadRequest,
  EventRuntime,
  EventExportRequest,
} from '@codesoul-co/hypha-core';

Usage patterns

  • Use the 7 type/interface exports as static contracts in application code, adapters, or tests. Import them with import type; they do not exist at runtime.
  • The module exposes 1 class as constructable runtime implementations. Each symbol entry lists its constructor and public methods.
  • The module exposes 1 function as direct operation entrypoints. Every overload, required/optional parameter, and return type is documented below.

Public exports

SymbolKindSignatureDescription
DurableEventRuntimeclassnew DurableEventRuntime(options: DurableEventRuntimeOptions): DurableEventRuntimeDurable Event Runtime class with 9 public constructor or member entries; its exact declarations are listed below.
eventExportChecksumfunctioneventExportChecksum(exported: Omit<EventExportResult, "checksum"> | EventExportResult): stringEvent Export Checksum function with 1 public call signature; parameters and return types are listed below.
DurableEventRuntimeOptionsinterfaceinterface DurableEventRuntimeOptionsDurable Event Runtime Options interface with 2 public fields or methods.
EventExportResultinterfaceinterface EventExportResultEvent Export Result interface with 7 public fields or methods.
EventImportRequestinterfaceinterface EventImportRequestEvent Import Request interface with 6 public fields or methods.
EventImportResultinterfaceinterface EventImportResult extends EventAppendResultEvent Import Result interface with 7 public fields or methods.
EventReadRequestinterfaceinterface EventReadRequestEvent Read Request interface with 4 public fields or methods.
EventRuntimeinterfaceinterface EventRuntimeEvent Runtime interface with 8 public fields or methods.
EventExportRequesttypetype EventExportRequest = EventReadRequestPublic type alias for Event Export Request; the declaration contains its complete type expression.

DurableEventRuntime

Durable Event Runtime class with 9 public constructor or member entries; its exact declarations are listed below.

Declaration

text
export declare class DurableEventRuntime implements EventRuntime {
    constructor(options: DurableEventRuntimeOptions);
    append(request: EventAppendRequest): Promise<EventAppendResult>;
    read(request: EventReadRequest): Promise<PersistedFrameworkEvent[]>;
    stream(request: EventReadRequest): AsyncIterable<PersistedFrameworkEvent>;
    latestSequence(scope: EventStreamScope): Promise<number>;
    getStreamHead(scope: EventStreamScope): Promise<EventStreamHead | null>;
    listStreamHeads(request?: ListEventStreamHeadsRequest): Promise<ListEventStreamHeadsResult>;
    export(request: EventExportRequest): Promise<EventExportResult>;
    import(request: EventImportRequest): Promise<EventImportResult>;
}

Public members

MemberKindSignatureDescription
appendmethodappend(request: EventAppendRequest): Promise<EventAppendResult>Public method; parameters and return type are shown in the signature.
constructorconstructor(options: DurableEventRuntimeOptions): DurableEventRuntimeCreates an instance of this class.
exportmethodexport(request: EventExportRequest): Promise<EventExportResult>Public method; parameters and return type are shown in the signature.
getStreamHeadmethodgetStreamHead(scope: EventStreamScope): Promise<EventStreamHead | null>Public method; parameters and return type are shown in the signature.
importmethodimport(request: EventImportRequest): Promise<EventImportResult>Public method; parameters and return type are shown in the signature.
latestSequencemethodlatestSequence(scope: EventStreamScope): Promise<number>Public method; parameters and return type are shown in the signature.
listStreamHeadsmethodlistStreamHeads(request?: ListEventStreamHeadsRequest): Promise<ListEventStreamHeadsResult>Public method; parameters and return type are shown in the signature.
readmethodread(request: EventReadRequest): Promise<PersistedFrameworkEvent[]>Public method; parameters and return type are shown in the signature.
streammethodstream(request: EventReadRequest): AsyncIterable<PersistedFrameworkEvent>Public method; parameters and return type are shown in the signature.

eventExportChecksum

Event Export Checksum function with 1 public call signature; parameters and return types are listed below.

Declaration

text
export declare function eventExportChecksum(exported: Omit<EventExportResult, 'checksum'> | EventExportResult): string;

Call signature

text
eventExportChecksum(exported: Omit<EventExportResult, "checksum"> | EventExportResult): string

Parameters

ParameterTypeRequiredDescription
exportedEventExportResult | Omit<EventExportResult, "checksum">YesRequired parameter; accepted values are defined by the type column.

Returns

  • Type: string
  • Description: The return contract is defined by the type shown above.

DurableEventRuntimeOptions

Durable Event Runtime Options interface with 2 public fields or methods.

Declaration

text
export interface DurableEventRuntimeOptions {
    store: DurableEventStore;
    now?: () => string;
}

Contract members

MemberKindSignatureDescription
nowmethodnow?(): stringPublic method; parameters and return type are shown in the signature.
storepropertystore: DurableEventStorePublic property; its type, readonly modifier and optionality are shown in the signature.

EventExportResult

Event Export Result interface with 7 public fields or methods.

Declaration

text
export interface EventExportResult {
    formatVersion: '1.0.0';
    scope: EventStreamScope;
    head: EventStreamHead | null;
    events: PersistedFrameworkEvent[];
    eventCount: number;
    exportedAt: string;
    checksum: string;
}

Contract members

MemberKindSignatureDescription
checksumpropertychecksum: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
eventCountpropertyeventCount: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
eventspropertyevents: PersistedFrameworkEvent<unknown>[]Public property; its type, readonly modifier and optionality are shown in the signature.
exportedAtpropertyexportedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
formatVersionpropertyformatVersion: "1.0.0"Public property; its type, readonly modifier and optionality are shown in the signature.
headpropertyhead: EventStreamHeadPublic property; its type, readonly modifier and optionality are shown in the signature.
scopepropertyscope: EventStreamScopePublic property; its type, readonly modifier and optionality are shown in the signature.

EventImportRequest

Event Import Request interface with 6 public fields or methods.

Declaration

text
export interface EventImportRequest {
    scope: EventStreamScope;
    exported: EventExportResult;
    expectedLastSequence: number;
    expectedRunRevision?: number;
    fencingToken?: number;
    idempotencyKey: string;
}

Contract members

MemberKindSignatureDescription
expectedLastSequencepropertyexpectedLastSequence: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
expectedRunRevisionpropertyexpectedRunRevision?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
exportedpropertyexported: EventExportResultPublic property; its type, readonly modifier and optionality are shown in the signature.
fencingTokenpropertyfencingToken?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
idempotencyKeypropertyidempotencyKey: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
scopepropertyscope: EventStreamScopePublic property; its type, readonly modifier and optionality are shown in the signature.

EventImportResult

Event Import Result interface with 7 public fields or methods.

Declaration

text
export interface EventImportResult extends EventAppendResult {
    importedEventCount: number;
    sourceChecksum: string;
}

Contract members

MemberKindSignatureDescription
eventspropertyevents: PersistedFrameworkEvent<unknown>[]Public property; its type, readonly modifier and optionality are shown in the signature.
firstSequencepropertyfirstSequence: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
importedEventCountpropertyimportedEventCount: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
lastSequencepropertylastSequence: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
reusedpropertyreused: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
runRevisionpropertyrunRevision: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
sourceChecksumpropertysourceChecksum: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

EventReadRequest

Event Read Request interface with 4 public fields or methods.

Declaration

text
export interface EventReadRequest {
    scope: EventStreamScope;
    fromSequence?: number;
    toSequence?: number;
    types?: FrameworkEventType[];
}

Contract members

MemberKindSignatureDescription
fromSequencepropertyfromSequence?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
scopepropertyscope: EventStreamScopePublic property; its type, readonly modifier and optionality are shown in the signature.
toSequencepropertytoSequence?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
typespropertytypes?: FrameworkEventType[]Public property; its type, readonly modifier and optionality are shown in the signature.

EventRuntime

Event Runtime interface with 8 public fields or methods.

Declaration

text
export interface EventRuntime {
    append(request: EventAppendRequest): Promise<EventAppendResult>;
    read(request: EventReadRequest): Promise<PersistedFrameworkEvent[]>;
    stream(request: EventReadRequest): AsyncIterable<PersistedFrameworkEvent>;
    latestSequence(scope: EventStreamScope): Promise<number>;
    getStreamHead(scope: EventStreamScope): Promise<EventStreamHead | null>;
    listStreamHeads(request?: ListEventStreamHeadsRequest): Promise<ListEventStreamHeadsResult>;
    export(request: EventExportRequest): Promise<EventExportResult>;
    import(request: EventImportRequest): Promise<EventImportResult>;
}

Contract members

MemberKindSignatureDescription
appendmethodappend(request: EventAppendRequest): Promise<EventAppendResult>Public method; parameters and return type are shown in the signature.
exportmethodexport(request: EventExportRequest): Promise<EventExportResult>Public method; parameters and return type are shown in the signature.
getStreamHeadmethodgetStreamHead(scope: EventStreamScope): Promise<EventStreamHead | null>Public method; parameters and return type are shown in the signature.
importmethodimport(request: EventImportRequest): Promise<EventImportResult>Public method; parameters and return type are shown in the signature.
latestSequencemethodlatestSequence(scope: EventStreamScope): Promise<number>Public method; parameters and return type are shown in the signature.
listStreamHeadsmethodlistStreamHeads(request?: ListEventStreamHeadsRequest): Promise<ListEventStreamHeadsResult>Public method; parameters and return type are shown in the signature.
readmethodread(request: EventReadRequest): Promise<PersistedFrameworkEvent[]>Public method; parameters and return type are shown in the signature.
streammethodstream(request: EventReadRequest): AsyncIterable<PersistedFrameworkEvent>Public method; parameters and return type are shown in the signature.

EventExportRequest

Public type alias for Event Export Request; the declaration contains its complete type expression.

Declaration

text
export type EventExportRequest = EventReadRequest;