Skip to main content

@actyx/pond

Enumerations

Classes

Interfaces

Type aliases

Actyx

Ƭ Actyx: EventFns & { nodeId: NodeId ; snapshotStore: SnapshotStore ; dispose: () => void ; nodeInfo: (maxAgeMillis: number) => Promise<NodeInfo> ; waitForSync: () => Promise<void> }

Access all sorts of functionality related to the Actyx system!


ActyxEvent

Ƭ ActyxEvent<E>: Object

An event with its metadata.

Type parameters

NameType
Eunknown

Type declaration

NameType
metaMetadata
payloadE

ActyxOpts

Ƭ ActyxOpts: Object

Options used when creating a new Actyx instance.

Type declaration

NameTypeDescription
actyxHost?stringHost of the Actxy service. This defaults to localhost and should stay localhost in almost all cases.
actyxPort?numberAPI port of the Actyx service. Defaults to 4454.
onConnectionEstablished?() => voidHook, when the connection to the store has been established.
onConnectionLost?() => voidHook, when the connection to the store is closed

ActyxTestOpts

Ƭ ActyxTestOpts: Object

Options used when creating a new TEST Actyx instance.

Type declaration

NameTypeDescription
nodeId?NodeIdLocal node id to use
timeInjector?TimeInjectorInstall the given time source for test purposes beta

AddEmission

Ƭ AddEmission<EWrite>: <E>(...args: [Tags<E>, E] | [TaggedTypedEvent<E>]) => void

Type parameters

Name
EWrite

Type declaration

▸ <E>(...args): void

Queue emission of an event whose type is covered by EWrite.

Type parameters
NameType
Eextends EWrite
Parameters
NameType
...args[Tags<E>, E] | [TaggedTypedEvent<E>]
Returns

void


AppId

Ƭ AppId: string

An Actyx app id.


AppManifest

Ƭ AppManifest: Object

Manifest describing an Actyx application. Used for authorizing API access.

Type declaration

NameTypeDescription
appIdstringStructured application id. For testing and development purposes, you can always pass 'com.example.somestring' For production, you will buy a license from Actyx for your specific app id like com.my-company.my-app.
displayNamestringArbitrary string describing the app.
signature?stringManifest signature, if it’s not an example app.
versionstringArbitrary version string

AqlDiagnosticMessage

Ƭ AqlDiagnosticMessage: Object

AQL diagnostic output describing an error that occured during query evaluation.

beta

Type declaration

NameTypeDescription
messagestring-
severitystring-
type"diagnostic"A problem occured

AqlEventMessage

Ƭ AqlEventMessage: Object

AQL message conveying a raw event or a record created by mapping an event via SELECT.

beta

Type declaration

NameTypeDescription
metaMetadataMetadata of the event that yielded this record.
payloadunknownPayload data generated by the AQL query via SELECT statements.
type"event"A simply-mapped event

AqlFutureCompat

Ƭ AqlFutureCompat: Object

Future versions of AQL will know additional response message types.

beta

Type declaration

NameTypeDescription
metaRecord<string, unknown>Consult AQL documentation to find out about future metadata contents.
payloadunknown-
typeExclude<"event" | "offsets" | "diagnostic", string>Consult AQL documentation to find out about future available types.

AqlOffsetsMsg

Ƭ AqlOffsetsMsg: Object

AQL message describing the offsets at the current state of the response stream.

beta

Type declaration

NameType
offsetsOffsetMap
type"offsets"

AqlQuery

Ƭ AqlQuery: string | { order?: EventsSortOrder ; query: string }

An aql query is either a plain string, or an object containing the string and the desired order.

beta


AqlResponse

Ƭ AqlResponse: AqlEventMessage | AqlOffsetsMsg | AqlDiagnosticMessage | AqlFutureCompat

Response message returned by running AQL query.

beta


AutoCappedQuery

Ƭ AutoCappedQuery: Object

Query for a set of events which is automatically capped at the latest available upperBound.

Type declaration

NameTypeDescription
horizon?stringEarliest event ID to consider in the result
lowerBound?OffsetMapStarting point for the query. Everything up-to-and-including lowerBound will be omitted from the result. Defaults to empty map, which means no lower bound at all. Sources not listed in the lowerBound will be delivered in full.
order?EventsSortOrderDesired order of delivery. Defaults to 'Asc'
query?Where<unknown>Statement to select specific events. Defaults to allEvents.

Caching

Ƭ Caching: NoCaching | InProcessCaching

Caching indicator for pond.observeAll().

beta


CancelSubscription

Ƭ CancelSubscription: () => void

Type declaration

▸ (): void

Cancel an ongoing aggregation (the provided callback will stop being called).

Returns

void


Counters

Ƭ Counters: Readonly<CountersMut>

Immutable swarm counters information.


CountersMut

Ƭ CountersMut: Object

Mutable swarm counters information.

Type declaration

NameTypeDescription
bothnumberBoth the pond and the swarm have it
ownnumberThe pond has it, the swarm doesn't
swarmnumberThe swarm has it, the pond does not

EarliestQuery

Ƭ EarliestQuery<E>: Object

Query for observeEarliest.

beta

Type parameters

Name
E

Type declaration

NameTypeDescription
eventOrder?EventOrderThe order to find min/max for. Defaults to Lamport.
lowerBound?OffsetMapStarting point for the query. Everything up-to-and-including lowerBound will be omitted from the result. Defaults to empty map, which means no lower bound at all. Sources not listed in the lowerBound will be delivered in full.
queryWhere<E>Statement to select specific events.

EventChunk

Ƭ EventChunk: Object

A chunk of events, with lower and upper bound. A call to queryKnownRange with the included bounds is guaranteed to return exactly the contained set of events. A call to subscribe with the included lowerBound, however, may find new events from sources not included in the bounds.

Type declaration

NameTypeDescription
eventsActyxEvent[]The event data. Sorting depends on the request which produced this chunk.
lowerBoundOffsetMapThe lower bound of the event chunk, independent of its sorting in memory.
upperBoundOffsetMapThe upper bound of the event chunk, independent of its sorting in memory.

EventKey

Ƭ EventKey: Object

Triple that Actyx events are sorted and identified by.

Type declaration

NameType
lamportLamport
offsetOffset
streamStreamId

EventSubscription

Ƭ EventSubscription: Object

Subscription to a set of events that may still grow.

Type declaration

NameTypeDescription
lowerBound?OffsetMapStarting point for the query. Everything up-to-and-including lowerBound will be omitted from the result. Defaults to empty map, which means no lower bound at all. Sources not listed in the lowerBound will be delivered in full.
query?Where<unknown>Statement to select specific events. Defaults to allEvents.

EventsMsg

Ƭ EventsMsg<E>: Object

Implies consumer should apply the given events to its latest local state.

alpha

Type parameters

Name
E

Type declaration

NameType
caughtUpboolean
eventsActyxEvent<E>[]
typeevents

EventsOrTimetravel

Ƭ EventsOrTimetravel<E>: StateMsg | EventsMsg<E> | TimeTravelMsg<E>

Possible subscribe_monotonic message types.

alpha

Type parameters

Name
E

Fish

Ƭ Fish<S, E>: Object

A Fish<S, E> describes an ongoing aggregration (fold) of events of type E into state of type S. A Fish always sees events in the correct order, even though event delivery on Actyx is only eventually consistent: To this effect, arrival of an hitherto unknown event "from the past" will cause a replay of the aggregation from an earlier state, instead of passing that event to the Fish out of order.

Type parameters

Name
S
E

Type declaration

NameTypeDescription
fishIdFishId-
initialStateS-
isReset?IsReset<E>-
onEventReduce<S, E>Function to create the next state from previous state and next event. It works similar to Array.reduce. Do note however that — while it may modify the passed-in state — this function must be pure: - It should not cause any side-effects (except logging) - It should not reference dynamic outside state like random numbers or the current time. The result must depend purely on the input parameters.
whereWhere<E>Selection of events to aggregate in this Fish. You may specify plain strings inline: where: Tags('my', 'tag', 'selection') (which requires all three tags) Or refer to typed static tags: where: myFirstTag.and(mySecondTag).or(myThirdTag) In both cases you would select events which contain all three given tags.
deserializeState?(jsonState: unknown) => S-

FishErrorContext

Ƭ FishErrorContext: { event: unknown ; metadata: Metadata ; occuredIn: "onEvent" ; state: unknown } | { event: unknown ; metadata: Metadata ; occuredIn: "isReset" } | { jsonState: unknown ; occuredIn: "deserializeState" }

Context for an error thrown by a Fish’s functions.


FishErrorReporter

Ƭ FishErrorReporter: (err: unknown, fishId: FishId, detail: FishErrorContext) => void

Type declaration

▸ (err, fishId, detail): void

Error reporter for when Fish functions throw exceptions.

Parameters
NameType
errunknown
fishIdFishId
detailFishErrorContext
Returns

void


FishId

Ƭ FishId: Object

Unique identifier for a fish.

Type declaration

NameType
entityTypestring
namestring
versionnumber

FishProcessInfo

Ƭ FishProcessInfo: Object

How many Fish are active, and of which entityTypes?

Type declaration

NameType
fishObject
numBeingProcessednumber

FixedStart

Ƭ FixedStart: Object

Sent by the client to indicate it wants event delivery to start from this point. Implies that a state was cached in-process by the client and so it does not want to start from a snapshot known to Actyx.

alpha

Type declaration

NameType
fromOffsetMap
horizon?EventKey
latestEventKeyEventKey

FullWaitForSwarmConfig

Ƭ FullWaitForSwarmConfig: Object

Configure how to wait for swarm.

Type declaration

NameTypeDescription
allowSkipbooleanTrue if we allow the user to skip the splash screen
enabledbooleanSplash screen enabled
minSourcesnumberMinimum number of sources until we consider that we got the swarm state
waitForSwarmMsnumberDelay until we consider that we got the swarm state
waitForSyncMs?numberDelay that we allow to sync with the swarm state (leave undefined to wait indefinitely)

GetNodeConnectivityParams

Ƭ GetNodeConnectivityParams: Object

Parameter object for the Pond.getNodeConnectivity call.

Type declaration

NameType
specialSources?NodeId[]
callback(newState: unknown) => void

HasOffsetAndStream

Ƭ HasOffsetAndStream: Object

Anything with offset on a stream.

Type declaration

NameType
offsetnumber
streamstring

HasTags

Ƭ HasTags: Object

Anything that has tags. @alpha

Type declaration

NameType
tagsstring[]

InProcessCaching

Ƭ InProcessCaching: Object

Indicate in-process (nonpersistent) Caching.

beta

Type declaration

NameType
keystring
type"in-process"

InvalidateAllSnapshots

Ƭ InvalidateAllSnapshots: () => Promise<void>

Type declaration

▸ (): Promise<void>

The signature of the function to invalidate all stored snapshots.

beta

Returns

Promise<void>


InvalidateSnapshots

Ƭ InvalidateSnapshots: (semantics: string, name: string, key: EventKey) => Promise<void>

Type declaration

▸ (semantics, name, key): Promise<void>

The signature of the function to invalidate snapshots for a given fish.

beta

Parameters
NameType
semanticsstring
namestring
keyEventKey
Returns

Promise<void>


IsReset

Ƭ IsReset<E>: (event: E, metadata: Metadata) => boolean

Type parameters

Name
E

Type declaration

▸ (event, metadata): boolean

A function indicating events which completely determine the state. Any event for which isReset returns true will be applied to the initial state, all earlier events discarded.

Parameters
NameType
eventE
metadataMetadata
Returns

boolean


Lamport

Ƭ Lamport: number

Lamport timestamp, cf. https://en.wikipedia.org/wiki/Lamport_timestamp


LatestQuery

Ƭ LatestQuery<E>: EarliestQuery<E>

Query for observeLatest.

beta

Type parameters

Name
E

LocalSnapshot

Ƭ LocalSnapshot<S>: StateWithProvenance<S> & { cycle: number ; eventKey: EventKey ; horizon: EventKey | undefined }

A local snapshot of state.

beta

Type parameters

Name
S

LocalSnapshotFromIndex

Ƭ LocalSnapshotFromIndex: LocalSnapshot<string>

The format of snapshots coming back from the store.

beta


Metadata

Ƭ Metadata: Object

Generic Metadata attached to every event.

Type declaration

NameType
appIdAppId
eventIdstring
isLocalEventboolean
lamportLamport
offsetOffset
streamStreamId
tagsstring[]
timestampMicrosTimestamp
timestampAsDate() => Date

Milliseconds

Ƭ Milliseconds: number

Some number of milliseconds.


MonotonicSubscription

Ƭ MonotonicSubscription<E>: Object

Subscribe to a stream of events that will never go backwards in time, but rather terminate with a timetravel-message.

alpha

Type parameters

Name
E

Type declaration

NameTypeDescription
attemptStartFromFixedStartSending 'attemptStartFrom' means we DONT want a snapshot sent as initial message.
queryWhere<E>Statement to select specific events.
sessionIdstringUser-chosen session id, used to find cached intermediate states aka local snapshots.

NoCaching

Ƭ NoCaching: Object

Indicator for disabled caching of pond.observeAll().

beta

Type declaration

NameType
type"none"

NodeId

Ƭ NodeId: string

An Actyx source id.


NodeInfoEntry

Ƭ NodeInfoEntry: Object

All the info we got for a single node

This might grow in the future to include things like timestamps

Type declaration

NameType
own?number
swarm?number

ObserveAllOpts

Ƭ ObserveAllOpts: Partial<{ caching: Caching ; expireAfterFirst: Milliseconds ; expireAfterSeed: Milliseconds }>

Optional parameters to pond.observeAll

beta


Offset

Ƭ Offset: number

Offset within an Actyx event stream.


OffsetMap

Ƭ OffsetMap: Record<StreamId, Offset>

A offset map stores the high water mark for each source.

The value in the psn map is the highest psn seen for this source. Since sequence numbers start with 0, the default value for sources that are not present is -1


OffsetMapBuilder

Ƭ OffsetMapBuilder: Record<string, Offset>

Relatively pointless attempt to distinguish between mutable and immutable psnmap See https://github.com/Microsoft/TypeScript/issues/13347 for why this does not help much.


OffsetMapCompanion

Ƭ OffsetMapCompanion: Object

OffsetMap companion functions.

Type declaration

NameType
emptyOffsetMap
isEmpty(m: OffsetMap) => boolean
lookup(m: OffsetMap, s: string) => number
lookupOrUndefined(m: OffsetMap, s: string) => undefined | number
update(m: OffsetMapBuilder, ev: HasOffsetAndStream) => OffsetMapBuilder

OffsetsResponse

Ƭ OffsetsResponse: Object

Response to an offsets() call

Type declaration

NameTypeDescription
presentOffsetMapThe current local present, i.e. offsets up to which we can provide events without any gaps.
toReplicateRecord<StreamId, number>For each stream we still need to download events from, the number of pending events.

OnCompleteOrErr

Ƭ OnCompleteOrErr: (err?: unknown) => void

Type declaration

▸ (err?): void

Handler for a streaming operation ending, either normally or with an error. If the err argument is defined, the operation completed due to an error. Otherwise, it completed normally.

Parameters
NameType
err?unknown
Returns

void


PendingCommand

Ƭ PendingCommand: Object

Pending command application.

Type declaration

NameType
subscribe(whenEmitted: () => void) => void
toPromise() => Promise<void>

PendingEmission

Ƭ PendingEmission: Object

Allows you to register actions for when event emission has completed.

Type declaration

NameType
subscribe(whenEmitted: (meta: Metadata[]) => void) => void
toPromise() => Promise<Metadata[]>

Pond

Ƭ Pond: Object

Main interface for interaction with the Actyx event system. New instances are created via Pond.default() or Pond.of(options). Acquire a Pond for testing (which uses a simulated clean Event Store) via Pond.test().

Type declaration

NameType
currentState<S, E>(fish: Fish<S, E>) => Promise<S>
dispose() => void
emit<E>(tags: Tags<E>, event: E) => PendingEmission
events() => Actyx
getPondState(callback: (newState: PondState) => void) => CancelSubscription
info() => PondInfo
keepRunning<S, EWrite>(fish: Fish<S, any>, fn: StateEffect<S, EWrite>, autoCancel?: (state: S) => boolean) => CancelSubscription
nodeInfo(maxAgeMillis: number) => Promise<NodeInfo>
observe<S, E>(fish: Fish<S, E>, callback: (newState: S) => void, stoppedByError?: (err: unknown) => void) => CancelSubscription
observeAll<ESeed, S>(seedEventsSelector: Where<ESeed>, makeFish: (seedEvent: ESeed) => undefined | Fish<S, any>, opts: Partial<{ caching: Caching ; expireAfterFirst: Milliseconds ; expireAfterSeed: Milliseconds }>, callback: (states: S[]) => void) => CancelSubscription
observeOne<ESeed, S>(seedEventSelector: Where<ESeed>, makeFish: (seedEvent: ESeed) => Fish<S, any>, callback: (newState: S) => void, stoppedByError?: (err: unknown) => void) => CancelSubscription
publish(event: TaggedEvent) => Promise<Metadata>(events: TaggedEvent[]) => Promise<Metadata[]>
run<S, EWrite>(fish: Fish<S, any>, fn: StateEffect<S, EWrite>) => PendingCommand
waitForSwarmSync(params: WaitForSwarmSyncParams) => void

PondInfo

Ƭ PondInfo: Object

Information concerning the running Pond.

Type declaration

NameType
nodeIdNodeId

PondOptions

Ƭ PondOptions: Object

Advanced configuration options for the Pond.

Type declaration

NameTypeDescription
fishErrorReporter?FishErrorReporterCallback that is invoked whenever Fish execution encounters an error. If none is supplied, errors will be logged to the console.

PondState

Ƭ PondState: Object

What sort of activity is currently going on in the Pond?

Type declaration

NameType
commandsFishProcessInfo
eventsFromOtherSourcesFishProcessInfo
hydrationFishProcessInfo

Progress

Ƭ Progress: Object

Sync progress in terms of event numbers.

Type declaration

NameType
currentnumber
maxnumber
minnumber

RangeQuery

Ƭ RangeQuery: Object

Query for a fixed set of known events.

Type declaration

NameTypeDescription
horizon?stringEarliest event ID to consider in the result
lowerBound?OffsetMapStarting point (exclusive) for the query. Everything up-to-and-including lowerBound will be omitted from the result. Defaults empty record. Events from sources not included in the lowerBound will be delivered from start, IF they are included in upperBound. Events from sources missing from both lowerBound and upperBound will not be delivered at all.
order?EventsSortOrderDesired order of delivery. Defaults to 'Asc'
query?Where<unknown>Statement to select specific events. Defaults to allEvents.
upperBoundOffsetMapEnding point (inclusive) for the query. Everything covered by upperBound (inclusive) will be part of the result. If a source is not included in upperBound, its events will not be included in the result.

Reduce

Ƭ Reduce<S, E>: (state: S, event: E, metadata: Metadata) => S

Type parameters

Name
S
E

Type declaration

▸ (state, event, metadata): S

Combine the existing ("old") state and next event into a new state. The returned value may be something completely new, or a mutated version of the input state.

Parameters
NameType
stateS
eventE
metadataMetadata
Returns

S


RetrieveSnapshot

Ƭ RetrieveSnapshot: (semantics: string, name: string, version: number) => Promise<LocalSnapshotFromIndex | undefined>

Type declaration

▸ (semantics, name, version): Promise<LocalSnapshotFromIndex | undefined>

The signature of the function to retrieve a snapshot.

beta

Parameters
NameType
semanticsstring
namestring
versionnumber
Returns

Promise<LocalSnapshotFromIndex | undefined>


SerializedStateSnap

Ƭ SerializedStateSnap: LocalSnapshot<string>

A local snapshot where the state has already been serialised.

beta


SplashState

Ƭ SplashState: SplashStateDiscovery | SplashStateSync

Current state of swarm synchronization procedure.


SplashStateDiscovery

Ƭ SplashStateDiscovery: Object

Discovering swarm state.

Type declaration

NameType
currentSwarmSummary
mode"discovery"
skip?() => void

SplashStateSync

Ƭ SplashStateSync: Object

Synchronizing up to the discovered swarm state.

Type declaration

NameType
currentSwarmSummary
mode"sync"
progressSyncProgress
referenceSwarmSummary
skip?() => void

StateEffect

Ƭ StateEffect<S, EWrite>: (state: S, enqueue: AddEmission<EWrite>, pond: Pond) => void | Promise<void>

Type parameters

Name
S
EWrite

Type declaration

▸ (state, enqueue, pond): void | Promise<void>

Enqueue event emissions based on currently known local state.

Parameters
NameType
stateS
enqueueAddEmission<EWrite>
pondPond
Returns

void | Promise<void>


StateMsg

Ƭ StateMsg: Object

Implies consumer should apply the given state.

alpha

Type declaration

NameType
snapshotSerializedStateSnap
typestate

StateWithProvenance

Ƭ StateWithProvenance<S>: Object

A state and its corresponding psn map.

beta

Type parameters

Name
S

Type declaration

NameTypeDescription
offsetsOffsetMapMinimum psn map that allow to reconstruct the state. Only contains sources that contain events matching the filter.
stateS-

StoreSnapshot

Ƭ StoreSnapshot: (semantics: string, name: string, key: EventKey, offsets: OffsetMap, horizon: EventKey | undefined, cycle: number, version: number, tag: string, serializedBlob: string) => Promise<boolean>

Type declaration

▸ (semantics, name, key, offsets, horizon, cycle, version, tag, serializedBlob): Promise<boolean>

The signature of the function to store a snapshot.

beta

Parameters
NameType
semanticsstring
namestring
keyEventKey
offsetsOffsetMap
horizonEventKey | undefined
cyclenumber
versionnumber
tagstring
serializedBlobstring
Returns

Promise<boolean>


StreamId

Ƭ StreamId: string

An Actyx stream id.


SwarmInfo

Ƭ SwarmInfo: Object

All the info we got for our device in relation to the swarm

Type declaration

NameType
nodesimmutable.Map<string, NodeInfoEntry>

SwarmSummary

Ƭ SwarmSummary: Object

Summary of swarm info

Type declaration

NameType
eventsCounters
infoSwarmInfo
sourcesCounters

SyncProgress

Ƭ SyncProgress: Object

Sync progress per source, and overall.

Type declaration

NameType
eventsProgress
sourcesProgress

TaggedEvent

Ƭ TaggedEvent: Object

An event with tags attached.

Type declaration

NameType
eventunknown
tagsstring[]

TestActyx

Ƭ TestActyx: TestEventFns & { nodeId: NodeId ; snapshotStore: SnapshotStore ; dispose: () => void ; waitForSync: () => Promise<void> }

An instance of Actyx that is not talking to any Actyx instance, but mocks all functionality within TypeScript. Very useful for unit-testing.


TestEvent

Ƭ TestEvent: Object

A raw Actyx event to be emitted by the TestEventStore, as if it really arrived from the outside.

Type declaration

NameType
lamportLamport
offsetnumber
payloadunknown
streamstring
tagsstring[]
timestampTimestamp

TestEventFns

Ƭ TestEventFns: EventFns & { directlyPushEvents: (events: TestEvent[]) => void }

EventFns for unit-tests.


TestPond

Ƭ TestPond: Pond & { directlyPushEvents: (events: TestEvent[]) => void }

A Pond with extensions for testing.


TestPondOptions

Ƭ TestPondOptions: PondOptions & { timeInjector?: TimeInjector }

Extended options for TestPond.


TimeInjector

Ƭ TimeInjector: (tags: string[], events: unknown) => Timestamp

Type declaration

▸ (tags, events): Timestamp

Test tool.

beta

Parameters
NameType
tagsstring[]
eventsunknown
Returns

Timestamp


TimeTravelMsg

Ƭ TimeTravelMsg<E>: Object

Implies consumer should re-subscribe starting from trigger or earlier.

alpha

Type parameters

Name
E

Type declaration

NameType
triggerEventKey
typetimetravel

Timestamp

Ƭ Timestamp: number

Timestamp (UNIX epoch), MICROseconds resolution.


WaitForSwarmConfig

Ƭ WaitForSwarmConfig: Partial<FullWaitForSwarmConfig>

Partially configure waiting for the swarm.


WaitForSwarmSyncParams

Ƭ WaitForSwarmSyncParams: WaitForSwarmConfig & { onProgress?: (newState: SplashState) => void ; onSyncComplete: () => void }

Parameter object for the Pond.waitForSwarmSync call.

Variables

Actyx

Actyx: Object

Function for creating Actyx instances.

Type declaration

NameType
of(manifest: AppManifest, opts?: ActyxOpts) => Promise<Actyx>
test(opts?: ActyxTestOpts) => TestActyx

ActyxEvent

ActyxEvent: Object

Things related to ActyxEvent.

Type declaration

NameType
ordOrd<ActyxEvent<unknown>>

AppId

AppId: Object

AppId associated functions.

Type declaration

NameType
of(text: string) => string

Caching

Caching: Object

Caching related functions

beta

Type declaration

NameType
inProcess(key: string) => Caching
isEnabled(c: undefined | Caching) => c is InProcessCaching
noneObject
none.type"none"

EventKey

EventKey: Object

Functions related to EventKey.

Type declaration

NameType
ordOrd<EventKey>
zeroEventKey
format(key: EventKey) => string

Fish

Fish: Object

Fish generic generator methods.

Type declaration

NameType
eventsAscending<E>(where: Where<E>, capacity: number) => Fish<E[], E>
eventsDescending<E>(where: Where<E>, capacity: number) => Fish<E[], E>
latestEvent<E>(where: Where<E>) => Fish<undefined | E, E>

FishId

FishId: Object

FishId associated functions.

Type declaration

NameType
canonical(v: FishId) => string
of(entityType: string, name: string, version: number) => { entityType: string ; name: string ; version: number }

Lamport

Lamport: Object

Type declaration

NameType
zeronumber
of(value: number) => number

Milliseconds

Milliseconds: Object

Helper functions for making sense of and converting Milliseconds.

Type declaration

NameType
zeronumber
fromAny(value: number) => number
fromDate(date: Date) => number
fromMinutes(value: number) => number
fromSeconds(value: number) => number
now(now?: number) => number
of(time: number) => number
toSeconds(value: number) => number
toTimestamp(value: number) => number

NodeId

NodeId: Object

SourceId associated functions.

Type declaration

NameType
of(text: string) => string
random(digits?: number) => string
streamNo(nodeId: string, num: number) => string

Offset

Offset: Object

Functions related to Offsets.

Type declaration

NameTypeDescription
maxnumberA value that is above any valid Offset
minnumberA value that is below any valid Offset
zeronumber-
of(n: number) => number-

OffsetMap

OffsetMap: OffsetMapCompanion

OffsetMap companion functions.


Pond

Pond: Object

Static methods for constructing Pond instances.

Type declaration

NameType
default(manifest: AppManifest) => Promise<Pond>
from(actyx: Actyx, opts: PondOptions) => Pond
of(manifest: AppManifest, connectionOpts: ActyxOpts, opts: PondOptions) => Promise<Pond>
test(opts?: TestPondOptions) => TestPond

PondState

PondState: Object

PondState associated functions.

Type declaration

NameType
isBusy(state: PondState) => boolean
isHydrating(state: PondState) => boolean
isProcessingCommands(state: PondState) => boolean
isProcessingEventsFromOtherSources(state: PondState) => boolean

SnapshotStore

SnapshotStore: Object

Interface to the snapshot store.

beta

Type declaration

NameType
noopSnapshotStore
inMem() => SnapshotStore

StreamId

StreamId: Object

SourceId associated functions.

Type declaration

NameType
of(text: string) => string
random() => string

SwarmSummary

SwarmSummary: Object

SwarmSummary associated functions.

Type declaration

NameType
emptySwarmSummary
fromSwarmInfo(info: SwarmInfo) => SwarmSummary

Timestamp

Timestamp: Object

Helper functions for making sense of and converting Timestamps.

Type declaration

NameType
maxSafenumber
zeronumber
format(timestamp: number) => string
fromDate(date: Date) => number
fromDays(value: number) => number
fromMilliseconds(value: number) => number
fromSeconds(value: number) => number
max(values: number[]) => number
min(...values: number[]) => number
now(now?: number) => number
of(time: number) => number
toDate(value: number) => Date
toMilliseconds(value: number) => number
toSeconds(value: number) => number

WaitForSwarmConfig

WaitForSwarmConfig: Object

WaitForSwarmConfig associated functions.

Type declaration

NameType
defaultsFullWaitForSwarmConfig

allEvents

allEvents: Tags<unknown>

A Where expression that selects all events.

Functions

Tag

Const Tag<E>(rawTagString, extractId?): Tag<E>

Create a new tag from the given string. (Tag factory function. Call WITHOUT new, e.g. const myTag = Tag<MyType>('my-tag'))

Type parameters

NameType
Eunknown

Parameters

NameTypeDescription
rawTagStringstringThe raw tag string
extractId?(e: E) => stringIf supplied, this function will be used to automatically call withId for events this tag is being attached to. The automatism is disabled if there is a manual withId call.

Returns

Tag<E>


Tags

Const Tags<E>(...requiredTags): Tags<E>

Declare a set of tags. This is a generator function to be called WITHOUT new, e.g. const required = Tags('a', 'b', 'c')

Type parameters

NameType
Eunknown

Parameters

NameType
...requiredTagsstring[]

Returns

Tags<E>


isBoolean

Const isBoolean(x): x is boolean

Refinement that checks whether typeof x === 'number'

Parameters

NameType
xany

Returns

x is boolean


isNumber

Const isNumber(x): x is number

Refinement that checks whether typeof x === 'number'

Parameters

NameType
xany

Returns

x is number


isString

Const isString(x): x is string

Refinement that checks whether typeof x === 'string'

Parameters

NameType
xany

Returns

x is string


toEventPredicate

Const toEventPredicate(where): (event: HasTags) => boolean

Turn a Where into a function that can decide whether a locally emitted event matches the clause.

We can ignore the 'local' flag since it will never exclude our local events, and this method is used solely to decide whether locally emitted events are relevant.

TODO: This will be removed once we support other means of 'I got events up to X' feedback

alpha

Parameters

NameType
whereWhere<unknown>

Returns

fn

▸ (event): boolean

Parameters
NameType
eventHasTags
Returns

boolean


unreachable

Const unreachable(x?): never

Assert that from the type information, a piece of code can never be reached. If it’s still reached at runtime, this throws an Error.

Parameters

NameType
x?undefined

Returns

never


unreachableOrElse

unreachableOrElse<T>(_, t): T

Assert that from the type information, a certain statement can never be reached, while installing a default value to return in case the type information was wrong and the statement was in fact reached.

Type parameters

Name
T

Parameters

NameType
_never
tT

Returns

T