@codesoul-co/hypha-core / modules/runtime/event-runtime
- Package index:
@codesoul-co/hypha-core - Source:
packages/core/src/modules/runtime/event-runtime.ts - Exports: 9
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
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
| Symbol | Kind | Signature | Description |
|---|---|---|---|
DurableEventRuntime | class | new DurableEventRuntime(options: DurableEventRuntimeOptions): DurableEventRuntime | Durable Event Runtime class with 9 public constructor or member entries; its exact declarations are listed below. |
eventExportChecksum | function | eventExportChecksum(exported: Omit<EventExportResult, "checksum"> | EventExportResult): string | Event Export Checksum function with 1 public call signature; parameters and return types are listed below. |
DurableEventRuntimeOptions | interface | interface DurableEventRuntimeOptions | Durable Event Runtime Options interface with 2 public fields or methods. |
EventExportResult | interface | interface EventExportResult | Event Export Result interface with 7 public fields or methods. |
EventImportRequest | interface | interface EventImportRequest | Event Import Request interface with 6 public fields or methods. |
EventImportResult | interface | interface EventImportResult extends EventAppendResult | Event Import Result interface with 7 public fields or methods. |
EventReadRequest | interface | interface EventReadRequest | Event Read Request interface with 4 public fields or methods. |
EventRuntime | interface | interface EventRuntime | Event Runtime interface with 8 public fields or methods. |
EventExportRequest | type | type EventExportRequest = EventReadRequest | Public 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.
- Kind: class
- Import:
import { DurableEventRuntime } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/event-runtime
Declaration
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
| Member | Kind | Signature | Description |
|---|---|---|---|
append | method | append(request: EventAppendRequest): Promise<EventAppendResult> | Public method; parameters and return type are shown in the signature. |
constructor | constructor | (options: DurableEventRuntimeOptions): DurableEventRuntime | Creates an instance of this class. |
export | method | export(request: EventExportRequest): Promise<EventExportResult> | Public method; parameters and return type are shown in the signature. |
getStreamHead | method | getStreamHead(scope: EventStreamScope): Promise<EventStreamHead | null> | Public method; parameters and return type are shown in the signature. |
import | method | import(request: EventImportRequest): Promise<EventImportResult> | Public method; parameters and return type are shown in the signature. |
latestSequence | method | latestSequence(scope: EventStreamScope): Promise<number> | Public method; parameters and return type are shown in the signature. |
listStreamHeads | method | listStreamHeads(request?: ListEventStreamHeadsRequest): Promise<ListEventStreamHeadsResult> | Public method; parameters and return type are shown in the signature. |
read | method | read(request: EventReadRequest): Promise<PersistedFrameworkEvent[]> | Public method; parameters and return type are shown in the signature. |
stream | method | stream(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.
- Kind: function
- Import:
import { eventExportChecksum } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/event-runtime
Declaration
export declare function eventExportChecksum(exported: Omit<EventExportResult, 'checksum'> | EventExportResult): string;Call signature
eventExportChecksum(exported: Omit<EventExportResult, "checksum"> | EventExportResult): stringParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
exported | EventExportResult | Omit<EventExportResult, "checksum"> | Yes | Required 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.
- Kind: interface
- Import:
import type { DurableEventRuntimeOptions } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/event-runtime
Declaration
export interface DurableEventRuntimeOptions {
store: DurableEventStore;
now?: () => string;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
now | method | now?(): string | Public method; parameters and return type are shown in the signature. |
store | property | store: DurableEventStore | Public property; its type, readonly modifier and optionality are shown in the signature. |
EventExportResult
Event Export Result interface with 7 public fields or methods.
- Kind: interface
- Import:
import type { EventExportResult } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/event-runtime
Declaration
export interface EventExportResult {
formatVersion: '1.0.0';
scope: EventStreamScope;
head: EventStreamHead | null;
events: PersistedFrameworkEvent[];
eventCount: number;
exportedAt: string;
checksum: string;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
checksum | property | checksum: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
eventCount | property | eventCount: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
events | property | events: PersistedFrameworkEvent<unknown>[] | Public property; its type, readonly modifier and optionality are shown in the signature. |
exportedAt | property | exportedAt: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
formatVersion | property | formatVersion: "1.0.0" | Public property; its type, readonly modifier and optionality are shown in the signature. |
head | property | head: EventStreamHead | Public property; its type, readonly modifier and optionality are shown in the signature. |
scope | property | scope: EventStreamScope | Public property; its type, readonly modifier and optionality are shown in the signature. |
EventImportRequest
Event Import Request interface with 6 public fields or methods.
- Kind: interface
- Import:
import type { EventImportRequest } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/event-runtime
Declaration
export interface EventImportRequest {
scope: EventStreamScope;
exported: EventExportResult;
expectedLastSequence: number;
expectedRunRevision?: number;
fencingToken?: number;
idempotencyKey: string;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
expectedLastSequence | property | expectedLastSequence: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
expectedRunRevision | property | expectedRunRevision?: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
exported | property | exported: EventExportResult | Public property; its type, readonly modifier and optionality are shown in the signature. |
fencingToken | property | fencingToken?: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
idempotencyKey | property | idempotencyKey: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
scope | property | scope: EventStreamScope | Public property; its type, readonly modifier and optionality are shown in the signature. |
EventImportResult
Event Import Result interface with 7 public fields or methods.
- Kind: interface
- Import:
import type { EventImportResult } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/event-runtime
Declaration
export interface EventImportResult extends EventAppendResult {
importedEventCount: number;
sourceChecksum: string;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
events | property | events: PersistedFrameworkEvent<unknown>[] | Public property; its type, readonly modifier and optionality are shown in the signature. |
firstSequence | property | firstSequence: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
importedEventCount | property | importedEventCount: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
lastSequence | property | lastSequence: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
reused | property | reused: boolean | Public property; its type, readonly modifier and optionality are shown in the signature. |
runRevision | property | runRevision: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
sourceChecksum | property | sourceChecksum: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
EventReadRequest
Event Read Request interface with 4 public fields or methods.
- Kind: interface
- Import:
import type { EventReadRequest } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/event-runtime
Declaration
export interface EventReadRequest {
scope: EventStreamScope;
fromSequence?: number;
toSequence?: number;
types?: FrameworkEventType[];
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
fromSequence | property | fromSequence?: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
scope | property | scope: EventStreamScope | Public property; its type, readonly modifier and optionality are shown in the signature. |
toSequence | property | toSequence?: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
types | property | types?: FrameworkEventType[] | Public property; its type, readonly modifier and optionality are shown in the signature. |
EventRuntime
Event Runtime interface with 8 public fields or methods.
- Kind: interface
- Import:
import type { EventRuntime } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/event-runtime
Declaration
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
| Member | Kind | Signature | Description |
|---|---|---|---|
append | method | append(request: EventAppendRequest): Promise<EventAppendResult> | Public method; parameters and return type are shown in the signature. |
export | method | export(request: EventExportRequest): Promise<EventExportResult> | Public method; parameters and return type are shown in the signature. |
getStreamHead | method | getStreamHead(scope: EventStreamScope): Promise<EventStreamHead | null> | Public method; parameters and return type are shown in the signature. |
import | method | import(request: EventImportRequest): Promise<EventImportResult> | Public method; parameters and return type are shown in the signature. |
latestSequence | method | latestSequence(scope: EventStreamScope): Promise<number> | Public method; parameters and return type are shown in the signature. |
listStreamHeads | method | listStreamHeads(request?: ListEventStreamHeadsRequest): Promise<ListEventStreamHeadsResult> | Public method; parameters and return type are shown in the signature. |
read | method | read(request: EventReadRequest): Promise<PersistedFrameworkEvent[]> | Public method; parameters and return type are shown in the signature. |
stream | method | stream(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.
- Kind: type
- Import:
import type { EventExportRequest } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/event-runtime
Declaration
export type EventExportRequest = EventReadRequest;