@codesoul-co/hypha-core / modules/runtime/event-store
- Package index:
@codesoul-co/hypha-core - Source:
packages/core/src/modules/runtime/event-store.ts - Exports: 17
Using this module
Use the Event store module for creating, recording, or reading Event contracts. It exports 1 class, 8 functions, 8 interfaces.
Import from the package entrypoint
import {
InMemoryDurableEventStore,
createPersistedEventBatch,
decodeEventStreamHeadCursor,
encodeEventStreamHeadCursor,
eventStreamKey,
hashEventAppendRequest,
streamHeadListLimit,
validateEventAppendRequest,
} from '@codesoul-co/hypha-core';
import type {
DurableEventStore,
EventAppendRequest,
EventAppendResult,
EventStreamHead,
EventStreamScope,
InMemoryDurableEventStoreOptions,
ListEventStreamHeadsRequest,
ListEventStreamHeadsResult,
} from '@codesoul-co/hypha-core';
// The complete export list is documented below.Usage patterns
- Use the 8 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 8 functions as direct operation entrypoints. Every overload, required/optional parameter, and return type is documented below.
Public exports
| Symbol | Kind | Signature | Description |
|---|---|---|---|
InMemoryDurableEventStore | class | new InMemoryDurableEventStore(options: InMemoryDurableEventStoreOptions): InMemoryDurableEventStore | In Memory Durable Event Store class with 7 public constructor or member entries; its exact declarations are listed below. |
createPersistedEventBatch | function | createPersistedEventBatch(request: EventAppendRequest, firstSequence: number, firstGlobalSequence: number, recordedAt: string): PersistedFrameworkEvent[] | Create Persisted Event Batch function with 1 public call signature; parameters and return types are listed below. |
decodeEventStreamHeadCursor | function | decodeEventStreamHeadCursor(cursor: string): string | Decode Event Stream Head Cursor function with 1 public call signature; parameters and return types are listed below. |
encodeEventStreamHeadCursor | function | encodeEventStreamHeadCursor(streamKey: string): string | Encode Event Stream Head Cursor function with 1 public call signature; parameters and return types are listed below. |
eventStreamKey | function | eventStreamKey(scope: EventStreamScope): string | Event Stream Key function with 1 public call signature; parameters and return types are listed below. |
hashEventAppendRequest | function | hashEventAppendRequest(request: EventAppendRequest): string | Hash Event Append Request function with 1 public call signature; parameters and return types are listed below. |
streamHeadListLimit | function | streamHeadListLimit(limit?: number): number | Stream Head List Limit function with 1 public call signature; parameters and return types are listed below. |
validateEventAppendRequest | function | validateEventAppendRequest(request: EventAppendRequest): void | Validate Event Append Request function with 1 public call signature; parameters and return types are listed below. |
validateEventAppendSchemas | function | validateEventAppendSchemas(registry: EventSchemaRegistry, request: EventAppendRequest): Promise<void> | Validate Event Append Schemas function with 1 public call signature; parameters and return types are listed below. |
DurableEventStore | interface | interface DurableEventStore | Durable Event Store interface with 6 public fields or methods. |
EventAppendRequest | interface | interface EventAppendRequest | Event Append Request interface with 7 public fields or methods. |
EventAppendResult | interface | interface EventAppendResult | Event Append Result interface with 5 public fields or methods. |
EventStreamHead | interface | interface EventStreamHead | Event Stream Head interface with 5 public fields or methods. |
EventStreamScope | interface | interface EventStreamScope | Event Stream Scope interface with 3 public fields or methods. |
InMemoryDurableEventStoreOptions | interface | interface InMemoryDurableEventStoreOptions | In Memory Durable Event Store Options interface with 2 public fields or methods. |
ListEventStreamHeadsRequest | interface | interface ListEventStreamHeadsRequest | List Event Stream Heads Request interface with 2 public fields or methods. |
ListEventStreamHeadsResult | interface | interface ListEventStreamHeadsResult | List Event Stream Heads Result interface with 2 public fields or methods. |
InMemoryDurableEventStore
In Memory Durable Event Store class with 7 public constructor or member entries; its exact declarations are listed below.
- Kind: class
- Import:
import { InMemoryDurableEventStore } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/event-store
Declaration
export declare class InMemoryDurableEventStore implements DurableEventStore {
constructor(options: InMemoryDurableEventStoreOptions);
append(request: EventAppendRequest): Promise<EventAppendResult>;
readStream(scope: EventStreamScope, fromSequence?: number): Promise<PersistedFrameworkEvent[]>;
readById(scope: EventStreamScope, eventId: string): Promise<PersistedFrameworkEvent | null>;
getStreamHead(scope: EventStreamScope): Promise<EventStreamHead | null>;
listStreamHeads(request?: ListEventStreamHeadsRequest): Promise<ListEventStreamHeadsResult>;
health(): Promise<ProviderHealth>;
}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: InMemoryDurableEventStoreOptions): InMemoryDurableEventStore | Creates an instance of this class. |
getStreamHead | method | getStreamHead(scope: EventStreamScope): Promise<EventStreamHead | null> | Public method; parameters and return type are shown in the signature. |
health | method | health(): Promise<ProviderHealth> | 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. |
readById | method | readById(scope: EventStreamScope, eventId: string): Promise<PersistedFrameworkEvent | null> | Public method; parameters and return type are shown in the signature. |
readStream | method | readStream(scope: EventStreamScope, fromSequence?: number): Promise<PersistedFrameworkEvent[]> | Public method; parameters and return type are shown in the signature. |
createPersistedEventBatch
Create Persisted Event Batch function with 1 public call signature; parameters and return types are listed below.
- Kind: function
- Import:
import { createPersistedEventBatch } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/event-store
Declaration
export declare function createPersistedEventBatch(request: EventAppendRequest, firstSequence: number, firstGlobalSequence: number, recordedAt: string): PersistedFrameworkEvent[];Call signature
createPersistedEventBatch(request: EventAppendRequest, firstSequence: number, firstGlobalSequence: number, recordedAt: string): PersistedFrameworkEvent[]Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | EventAppendRequest | Yes | Required parameter; accepted values are defined by the type column. |
firstSequence | number | Yes | Required parameter; accepted values are defined by the type column. |
firstGlobalSequence | number | Yes | Required parameter; accepted values are defined by the type column. |
recordedAt | string | Yes | Required parameter; accepted values are defined by the type column. |
Returns
- Type:
PersistedFrameworkEvent<unknown>[] - Description: The return contract is defined by the type shown above.
decodeEventStreamHeadCursor
Decode Event Stream Head Cursor function with 1 public call signature; parameters and return types are listed below.
- Kind: function
- Import:
import { decodeEventStreamHeadCursor } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/event-store
Declaration
export declare function decodeEventStreamHeadCursor(cursor: string): string;Call signature
decodeEventStreamHeadCursor(cursor: string): stringParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
cursor | string | 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.
encodeEventStreamHeadCursor
Encode Event Stream Head Cursor function with 1 public call signature; parameters and return types are listed below.
- Kind: function
- Import:
import { encodeEventStreamHeadCursor } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/event-store
Declaration
export declare function encodeEventStreamHeadCursor(streamKey: string): string;Call signature
encodeEventStreamHeadCursor(streamKey: string): stringParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
streamKey | string | 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.
eventStreamKey
Event Stream Key function with 1 public call signature; parameters and return types are listed below.
- Kind: function
- Import:
import { eventStreamKey } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/event-store
Declaration
export declare function eventStreamKey(scope: EventStreamScope): string;Call signature
eventStreamKey(scope: EventStreamScope): stringParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
scope | EventStreamScope | 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.
hashEventAppendRequest
Hash Event Append Request function with 1 public call signature; parameters and return types are listed below.
- Kind: function
- Import:
import { hashEventAppendRequest } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/event-store
Declaration
export declare function hashEventAppendRequest(request: EventAppendRequest): string;Call signature
hashEventAppendRequest(request: EventAppendRequest): stringParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | EventAppendRequest | 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.
streamHeadListLimit
Stream Head List Limit function with 1 public call signature; parameters and return types are listed below.
- Kind: function
- Import:
import { streamHeadListLimit } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/event-store
Declaration
export declare function streamHeadListLimit(limit?: number): number;Call signature
streamHeadListLimit(limit?: number): numberParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
limit | number | No | Optional parameter; accepted values are defined by the type column. |
Returns
- Type:
number - Description: The return contract is defined by the type shown above.
validateEventAppendRequest
Validate Event Append Request function with 1 public call signature; parameters and return types are listed below.
- Kind: function
- Import:
import { validateEventAppendRequest } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/event-store
Declaration
export declare function validateEventAppendRequest(request: EventAppendRequest): void;Call signature
validateEventAppendRequest(request: EventAppendRequest): voidParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | EventAppendRequest | Yes | Required parameter; accepted values are defined by the type column. |
Returns
- Type:
void - Description: Returns no value.
validateEventAppendSchemas
Validate Event Append Schemas function with 1 public call signature; parameters and return types are listed below.
- Kind: function
- Import:
import { validateEventAppendSchemas } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/event-store
Declaration
export declare function validateEventAppendSchemas(registry: EventSchemaRegistry, request: EventAppendRequest): Promise<void>;Call signature
validateEventAppendSchemas(registry: EventSchemaRegistry, request: EventAppendRequest): Promise<void>Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
registry | EventSchemaRegistry | Yes | Required parameter; accepted values are defined by the type column. |
request | EventAppendRequest | Yes | Required parameter; accepted values are defined by the type column. |
Returns
- Type:
Promise<void> - Description: The return contract is defined by the type shown above.
DurableEventStore
Durable Event Store interface with 6 public fields or methods.
- Kind: interface
- Import:
import type { DurableEventStore } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/event-store
Declaration
export interface DurableEventStore {
append(request: EventAppendRequest): Promise<EventAppendResult>;
readStream(scope: EventStreamScope, fromSequence?: number): Promise<PersistedFrameworkEvent[]>;
readById(scope: EventStreamScope, eventId: string): Promise<PersistedFrameworkEvent | null>;
getStreamHead(scope: EventStreamScope): Promise<EventStreamHead | null>;
listStreamHeads(request?: ListEventStreamHeadsRequest): Promise<ListEventStreamHeadsResult>;
health(): Promise<ProviderHealth>;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
append | method | append(request: EventAppendRequest): Promise<EventAppendResult> | 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. |
health | method | health(): Promise<ProviderHealth> | 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. |
readById | method | readById(scope: EventStreamScope, eventId: string): Promise<PersistedFrameworkEvent | null> | Public method; parameters and return type are shown in the signature. |
readStream | method | readStream(scope: EventStreamScope, fromSequence?: number): Promise<PersistedFrameworkEvent[]> | Public method; parameters and return type are shown in the signature. |
EventAppendRequest
Event Append Request interface with 7 public fields or methods.
- Kind: interface
- Import:
import type { EventAppendRequest } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/event-store
Declaration
export interface EventAppendRequest {
scope: EventStreamScope;
events: EventCreateInput[];
expectedLastSequence: number;
expectedRunRevision?: number;
fencingToken?: number;
idempotencyKey: string;
transactionGroupId?: string;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
events | property | events: EventCreateInput<unknown>[] | Public property; its type, readonly modifier and optionality are shown in the signature. |
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. |
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. |
transactionGroupId | property | transactionGroupId?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
EventAppendResult
Event Append Result interface with 5 public fields or methods.
- Kind: interface
- Import:
import type { EventAppendResult } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/event-store
Declaration
export interface EventAppendResult {
events: PersistedFrameworkEvent[];
firstSequence: number;
lastSequence: number;
runRevision: number;
reused: boolean;
}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. |
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. |
EventStreamHead
Event Stream Head interface with 5 public fields or methods.
- Kind: interface
- Import:
import type { EventStreamHead } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/event-store
Declaration
export interface EventStreamHead {
scope: EventStreamScope;
lastSequence: number;
runRevision: number;
fencingToken?: number;
updatedAt: string;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
fencingToken | property | fencingToken?: 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. |
runRevision | property | runRevision: 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. |
updatedAt | property | updatedAt: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
EventStreamScope
Event Stream Scope interface with 3 public fields or methods.
- Kind: interface
- Import:
import type { EventStreamScope } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/event-store
Declaration
export interface EventStreamScope {
tenantId?: string;
userId: string;
runId: string;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
runId | property | runId: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
tenantId | property | tenantId?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
userId | property | userId: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
InMemoryDurableEventStoreOptions
In Memory Durable Event Store Options interface with 2 public fields or methods.
- Kind: interface
- Import:
import type { InMemoryDurableEventStoreOptions } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/event-store
Declaration
export interface InMemoryDurableEventStoreOptions {
schemaRegistry: EventSchemaRegistry;
now?: () => string;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
now | method | now?(): string | Public method; parameters and return type are shown in the signature. |
schemaRegistry | property | schemaRegistry: EventSchemaRegistry | Public property; its type, readonly modifier and optionality are shown in the signature. |
ListEventStreamHeadsRequest
List Event Stream Heads Request interface with 2 public fields or methods.
- Kind: interface
- Import:
import type { ListEventStreamHeadsRequest } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/event-store
Declaration
export interface ListEventStreamHeadsRequest {
cursor?: string;
limit?: number;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
cursor | property | cursor?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
limit | property | limit?: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
ListEventStreamHeadsResult
List Event Stream Heads Result interface with 2 public fields or methods.
- Kind: interface
- Import:
import type { ListEventStreamHeadsResult } from '@codesoul-co/hypha-core'; - Source module:
modules/runtime/event-store
Declaration
export interface ListEventStreamHeadsResult {
heads: EventStreamHead[];
nextCursor?: string;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
heads | property | heads: EventStreamHead[] | Public property; its type, readonly modifier and optionality are shown in the signature. |
nextCursor | property | nextCursor?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
