Skip to content

Releases: EventStore/EventStore-Client-NodeJS

v3.3.1

06 Apr 08:39
Compare
Choose a tag to compare

Bug Fixes

  • Close channels when they fail to prevent memory leak. View

v3.3.0

30 Mar 10:12
Compare
Choose a tag to compare

Features

  • Added dispose method to dispose all currently running streaming calls. View

v3.2.0

23 Feb 15:48
Compare
Choose a tag to compare

Features

Persistent Subscription Control

New methods for persistent subscription control have been added.

Method Name Description
getPersistendSubscriptionToAllInfo Gets information and statistics on the specified persistent subscription to $all and its connections. View
getPersistentSubscriptionToStreamInfo Gets information and statistics on the specified persistent subscription and its connections. View
listAllPersistentSubscriptions Lists all persistent subscriptions. View
listPersistentSubscriptionsToAll Lists persistent subscriptions to the $all stream. View
listPersistentSubscriptionsToStream Lists persistent subscriptions to a specified stream. View
replayParkedMessagesToAll Replays the parked messages of a persistent subscription to $all. View
replayParkedMessagesToStream Replays the parked messages of a persistent subscription. View
restartPersistentSubscriptionSubsystem Restarts the persistent subscription subsystem. View

Connection Name

The connectionName option has been added allowing you to name the connection in logs and persistent subscription info. View

  • Defaults to a UUID.
  • Adds connectionName option to constructor.
  • Adds connectionName=<name> param to connection string
  • Adds connectionName getter to client for reading the name of the client.

Allow skipping metadata key in EventType

Previously, to use JSONEventType or BinaryEventType you would have to provide a metadata key, even if you typed it as unknown or never. View

Before:

type MyEvent = JSONEventType<"my-event", { some: string }>;

// Property 'metadata' is missing in type '{ type: "my-event"; data: { some: string; }; }' but required in type 'JSONEventType<"my-event", { some: string; }, unknown>'.ts(2741)
const myEventData: MyEvent = {
    type: "my-event",
    { some: "data" }
}

After:

type MyEvent = JSONEventType<"my-event", { some: string }>;

const myEventData: MyEvent = {
    type: "my-event",
    { some: "data" }
}

Retain ability to descriminate event type unions after converting types

Previously, if you had a union of event types, you would lose the ability it descriminate them after converting them to EventData or a RecordedEvent due to typescript combining them into an intersection of the types. View

Before:

type MyFirstEvent = JSONEventType<
  "my-first-type",
  { some: string; other: string }
>;
type MySecondEvent = JSONEventType<
  "my-second-event",
  { other: string; another: boolean }
>;

type MyEvents = MyFirstEvent | MySecondEvent;

We can descriminate based on the type key.

const descriminateType = (eventData: MyEvents) => {
  if (eventData.type === "my-first-type") {
    // { some: string; other: string; }
    eventData.data;
  } else {
    //  { other: string; another: boolean }
    eventData.data;
  }
};

However, this breaks down when MyEvents is passed directly to JSONEventData or a JSONRecordedEvent.

const descriminateType = (eventData: JSONRecordedEvent<MyEvents>) => {
  if (eventData.type === "my-first-type") {
    // { some: string; other: string; } | { other: string; another: boolean }
    eventData.data;
  } else {
    // { some: string; other: string; } | { other: string; another: boolean }
    eventData.data;
  }
};

You would have to use the helper type EventTypeToRecordedEvent to retain correct descrimination.

const descriminateType = (eventData: EventTypeToRecordedEvent<MyEvents>) => {
  if (eventData.type === "my-first-type") {
    // { some: string; other: string; }
    eventData.data;
  } else {
    // { other: string; another: boolean }
    eventData.data;
  }
};

After:

You can now pass your union directly to JSONRecordedEvent, BinaryRecordedEvent or the now generic RecordedEvent without losing the ability to descriminate the union:

const descriminateType = (eventData: RecordedEvent<MyEvents>) => {
  if (eventData.type === "my-first-type") {
    // { some: string; other: string; }
    eventData.data;
  } else {
    // { other: string; another: boolean }
    eventData.data;
  }
};

All converter types (EventTypeToRecordedEvent, RecordedEventToEventType, EventTypeToEventData, EventDataToEventType, RecordedEventToEventData, EventDataToRecordedEvent) are still available.

Allow enforcing types on appendToStream

You can now enforce the types you append to a stream. View

await client.appendToStream<MyEvents>(`my_stream`, jsonEvents);

Export Options types

All method option types are now exported. View

Bug Fixes

  • Fix doc comment for persistent subscription startFrom View
  • Ensure rediscovery is not run when the server returns a timeout View

Deprecations

  • Consumer strategy names have been matched with server counterparts. View
    • DISPATCH_TO_SINGLE: dispatch_to_single -> DispatchToSingle;
    • ROUND_ROBIN: round_robin -> RoundRobin;
    • PINNED: pinned -> Pinned;
    • Only affects users who pass the strings directly. Constants have changed to match.
    • Previous strings will log a warning.
    • Will be removed in v4.0.0
  • Persistent subscription methods, helpers and types relating to streams have been renamed to align with other method names. View
    • Methods:
      • createPersistentSubscription -> createPersistentSubscriptionToStream
      • deletePersistentSubscription -> deletePersistentSubscriptionToStream
      • subscribeToPersistentSubscription -> subscribeToPersistentSubscriptionToStream
      • updatePersistentSubscription -> updatePersistentSubscriptionToStream
    • Helper Functions:
      • persistentSubscriptionSettingsFromDefaults -> persistentSubscriptionToStreamSettingsFromDefaults
    • Types:
      • PersistentSubscriptionSettings -> PersistentSubscriptionToStreamSettings
      • PersistentSubscription -> PersistentSubscriptionToStream
    • Will be removed in v4.0.0

v3.1.0

04 Feb 14:08
Compare
Choose a tag to compare

Features

  • getProjectionStatistics has been renamed to getProjectionStatus to align with other clients. View

Bug Fixes

  • Increase maximum readable event size to match maximum event size that can be written internally. View

Deprecations

  • getProjectionStatistics is now deprecated. View
    • Will be removed in v4.0.0.
    • Use getProjectionStatus.

v3.0.0

27 Jan 14:25
Compare
Choose a tag to compare

Breaking changes

EventStoreDBClient

  • The default node preference is now LEADER. This applies when connecting with a connection string, and via the client constructor. View

Persistent Subscriptions

The persistent subscriptions api has been updated to align with other eventstore clients, and the new persistent subscriptions to all api.

  • connectToPersistentSubscription has been renamed to subscribeToPersistentSubscription View
  • persistentSubscriptionSettings keys and default values have been changed. View
Key Default Description
- fromRevision
+ startFrom
- START
+ END
The exclusive position in the stream or transaction file the subscription should start from.
- extraStats
+ extraStatistics
false Enables if depth latency statistics should be tracked on subscription.
- checkpointAfter
+ checkPointAfter
2_000 The amount of time to try checkpoint after in milliseconds.
- minCheckpointCount
+ checkPointLowerBound
10 The minimum number of messages to process before a checkpoint may be written.
- maxCheckpointCount
+ checkPointUpperBound
1_000 The maximum number of messages to process before a checkpoint may be written.
maxSubscriberCount
- UNLIMITED
+ UNBOUNDED
The maximum number of subscribers allowed..
- strategy
+ consumerStrategyName
ROUND_ROBIN The strategy to use for distributing events to client consumers.
-- The following options remain unchanged. --
resolveLinkTos false Also return events targeted by the links.
messageTimeout 30_000 The amount of time in milliseconds after which a message should be considered to be timeout and retried.
maxRetryCount 10 The maximum number of retries (due to timeout) before a message is considered to be parked.
liveBufferSize 500 The size of the buffer listening to live messages as they happen.
readBatchSize 20 The number of events read at a time when paging in history.
historyBufferSize 500 The number of events to cache when paging through history.
  • Constant UNLIMITED has been renamed to UNBOUNDED. View

Projections

The projections api has been completely overhauled, removing one time and transient projections. View

  • createProjection:
    • createContinuousProjection has been renamed to createProjection.
    • createOneTimeProjection has been removed.
    • createTransientProjection has been removed.
  • listProjections:
    • listContinuousProjections has been renamed to listProjections.
    • listOneTimeProjections has been removed.
    • listTransientProjections has been removed.
    • mode has been removed from ProjectionDetails, only CONTINUOUS projections are returned.
    • CONTINUOUS ONE_TIME & TRANSIENT constants have been removed.
  • resetProjection:
    • writeCheckpoint option has been removed. (It previously had no effect ).
  • disableProjection:
    • writeCheckpoint option has been removed. Use abortProjection if wishing to set this to false.
  • abortProjection:
    • abortProjection method has been added.
  • deleteProjection:
    • deleteEmittedStreams option now defaults to false.
    • deleteStateStream option now defaults to false.
    • deleteCheckpointStream option now defaults to false.
  • getProjectionState & getProjectionResult:
    • fromPartition option has been renamed to partition View

Client Deadlines

The client now supports setting deadlines for non-streaming gRPC requests, with a default deadline of 10 seconds (formerly Infinity). View

  • defaultDeadline global setting has been added to the constructor options and connection string.
  • deadline option has been added to all methods, to allow setting the deadline per request.
  • DeadlineExceeded error will now be thrown if a deadline has been exceeded.

Features

Persistent Subscriptions to all

The client now supports persistent subscriptions to the all stream, for server version 21.10 and greater.

  • Added createPersistentSubscriptionToAll method. View
const groupName = "my_persistent_subscription";
const settings = persistentSubscriptionToAllSettingsFromDefaults({
  // start from the beginning of the all stream
  startFrom: START,
});
// Filter only events with type matching regex
const filter = eventTypeFilter({
  regex: "^[0-9]*_regex_filter_eventType_[A-z]*$",
});

// Create a persistent subscrition to the all stream
await client.createPersistentSubscriptionToAll(groupName, settings, { filter });
  • Added subscribeToPersistentSubscriptionToAll method. View
// Connect to the created persistent subscription to all stream
const psToAll = client.subscribeToPersistentSubscriptionToAll(groupName);

for await (const event of psToAll) {
  doSomethingWithEvent(event);
  // Acknowledge that the event has been handled
  await psToAll.ack(event);
}
  • Added updatePersistentSubscriptionToAll method. View
const updatedSettings =  persistentSubscriptionToAllSettingsFromDefaults({
  // Ensure that our previous settings are persisted
  ...settings,
  // Enable extra statistics
  extraStatistics: true,
});

// Update the persistent subscription to use new settings.
await client.updatePersistentSubscriptionToAll(groupName, updatedSettings);
  • Added deletePersistentSubscriptionToAll method. View
// delete the unwanted persistent subscription to all
await client.deletePersistentSubscriptionToAll(groupName);

Other features

  • When connected to server version 21.10 and greater, the client will now send appended events over a single duplex stream, resulting in much faster append times. View
  • Client now internally checks if the server supports an api before sending a request. View
  • fromPartition option added to getProjectionState View
  • Improved tlsVerifyCert not supported message View

Bug Fixes

  • Fixed incorrect log message where http was logged as https and vice versa. View
  • updateProjection option trackEmittedStreams name has been corrected as emitEnabled. View
  • Prevent WRITE_AFTER_END from still being uncaught in rare cases. View

Removal of Deprecated Apis

  • Remove ack and nack via event id View

v3.0.0-alpha.2

26 Jan 15:02
Compare
Choose a tag to compare
v3.0.0-alpha.2 Pre-release
Pre-release

Breaking changes

Projections

  • fromPartition option has been renamed to partition View

Client Deadlines

The client now supports setting deadlines for non-streaming gRPC requests, with a default deadline of 10 seconds (formerly Infinity). View

  • defaultDeadline global setting has been added to the constructor options and connection string.
  • deadline option has been added to all methods, to allow setting the deadline per request.
  • DeadlineExceeded error will now be thrown if a deadline has been exceeded.

Features

  • fromPartition option added to getProjectionState View
  • Improved tlsVerifyCert not supported message View

v3.0.0-alpha.1

18 Nov 13:03
Compare
Choose a tag to compare
v3.0.0-alpha.1 Pre-release
Pre-release

Breaking changes

EventStoreDBClient

  • The default node preference is now LEADER. This applies when connecting with a connection string, and via the client constructor. View

Persistent Subscriptions

The persistent subscriptions api has been updated to align with other eventstore clients, and the new persistent subscriptions to all api.

  • connectToPersistentSubscription has been renamed to subscribeToPersistentSubscription View
  • persistentSubscriptionSettings keys and default values have been changed. View
Key Default Description
- fromRevision
+ startFrom
- START
+ END
The exclusive position in the stream or transaction file the subscription should start from.
- extraStats
+ extraStatistics
false Enables if depth latency statistics should be tracked on subscription.
- checkpointAfter
+ checkPointAfter
2_000 The amount of time to try checkpoint after in milliseconds.
- minCheckpointCount
+ checkPointLowerBound
10 The minimum number of messages to process before a checkpoint may be written.
- maxCheckpointCount
+ checkPointUpperBound
1_000 The maximum number of messages to process before a checkpoint may be written.
maxSubscriberCount
- UNLIMITED
+ UNBOUNDED
The maximum number of subscribers allowed..
- strategy
+ consumerStrategyName
ROUND_ROBIN The strategy to use for distributing events to client consumers.
-- The following options remain unchanged. --
resolveLinkTos false Also return events targeted by the links.
messageTimeout 30_000 The amount of time in milliseconds after which a message should be considered to be timeout and retried.
maxRetryCount 10 The maximum number of retries (due to timeout) before a message is considered to be parked.
liveBufferSize 500 The size of the buffer listening to live messages as they happen.
readBatchSize 20 The number of events read at a time when paging in history.
historyBufferSize 500 The number of events to cache when paging through history.
  • Constant UNLIMITED has been renamed to UNBOUNDED. View

Projections

The projections api has been completely overhauled, removing one time and transient projections. View

  • createProjection:
    • createContinuousProjection has been renamed to createProjection.
    • createOneTimeProjection has been removed.
    • createTransientProjection has been removed.
  • listProjections:
    • listContinuousProjections has been renamed to listProjections.
    • listOneTimeProjections has been removed.
    • listTransientProjections has been removed.
    • mode has been removed from ProjectionDetails, only CONTINUOUS projections are returned.
    • CONTINUOUS ONE_TIME & TRANSIENT constants have been removed.
  • resetProjection:
    • writeCheckpoint option has been removed. (It previously had no effect ).
  • disableProjection:
    • writeCheckpoint option has been removed. Use abortProjection if wishing to set this to false.
  • abortProjection:
    • abortProjection method has been added.
  • deleteProjection:
    • deleteEmittedStreams option now defaults to false.
    • deleteStateStream option now defaults to false.
    • deleteCheckpointStream option now defaults to false.

Features

Persistent Subscriptions to all

The client now supports persistent subscriptions to the all stream, for server version 21.10 and greater.

  • Added createPersistentSubscriptionToAll method. View
const groupName = "my_persistent_subscription";
const settings = persistentSubscriptionToAllSettingsFromDefaults({
  // start from the beginning of the all stream
  startFrom: START,
});
// Filter only events with type matching regex
const filter = eventTypeFilter({
  regex: "^[0-9]*_regex_filter_eventType_[A-z]*$",
});
// Create a persistent subscrition to the all stream
await client.createPersistentSubscriptionToAll(groupName, settings, { filter });
  • Added subscribeToPersistentSubscriptionToAll method. View
// Connect to the created persistent subscription to all stream
const psToAll = client.subscribeToPersistentSubscriptionToAll(groupName);
for await (const event of psToAll) {
  doSomethingWithEvent(event);
  // Acknowledge that the event has been handled
  await psToAll.ack(event);
}
  • Added updatePersistentSubscriptionToAll method. View
const updatedSettings =  persistentSubscriptionToAllSettingsFromDefaults({
  // Ensure that our previous settings are persisted
  ...settings,
  // Enable extra statistics
  extraStatistics: true,
});
// Update the persistent subscription to use new settings.
await client.updatePersistentSubscriptionToAll(groupName, updatedSettings)l
  • Added deletePersistentSubscriptionToAll method. View
// delete the unwanted persistent subscription to all
await client.deletePersistentSubscriptionToAll(groupName);

Other features

  • When connected to server version 21.10 and greater, the client will now send appended events over a single duplex stream, resulting in much faster append times. View
  • Client now internally checks if the server supports an api before sending a request. View

Bug Fixes

  • Fixed incorrect log message where http was logged as https and vice versa. View

  • updateProjection option trackEmittedStreams name has been corrected as emitEnabled. View

  • Prevent WRITE_AFTER_END from still being uncaught in rare cases. View

v2.1.1

29 Sep 12:04
Compare
Choose a tag to compare

Bug Fixes

  • Ack and nack take a resolved event, rather than an event id View
  • Prevent appendToStream from writing after the stream has closed View

Deprecations

  • Ack and nack via event id View
    • Will be removed in v3.0.0.
    • Pass entire resolved event

v2.1.0

05 Aug 09:55
Compare
Choose a tag to compare

Features

  • checkpointReached callback added to filter to allow checkpointing filtered reads to all View
  • LinkEvent type added to event types View
  • resolveLinkTos option added to readAll View

Bug Fixes

  • parseConnectionString allows different casings of nodePreference View

v2.0.0

28 Jul 10:58
Compare
Choose a tag to compare

Breaking changes

  • readStream and readAll return a stream of events View

To allow for reading large numbers of events without running out of memory, readSteam and readAll now return a readable stream rather than a promise of an array.

Before v1.x:

const events = await client.readStream<MyEventTypes>(streamName);

for (const event of events) {
  doSomething(event);
}

After v2.x:

const eventStream = client.readStream<MyEventTypes>(streamName);

for await (const event of eventStream) {
  doSomething(event);
}

Features

  • Reconnect on node loss View
  • readonlyreplica node preference View
  • Faster data encoding View

Bug Fixes

  • Ensure member is in a connectable state during discovery View

Removal of Deprecated Apis

  • ConnectionTypeOptions View