Releases: EventStore/EventStore-Client-NodeJS
v3.3.1
v3.3.0
v3.2.0
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
- Methods:
v3.1.0
Features
getProjectionStatistics
has been renamed togetProjectionStatus
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
.
- Will be removed in
v3.0.0
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 tosubscribeToPersistentSubscription
ViewpersistentSubscriptionSettings
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 toUNBOUNDED
. View
Projections
The projections api has been completely overhauled, removing one time and transient projections. View
createProjection
:createContinuousProjection
has been renamed tocreateProjection
.createOneTimeProjection
has been removed.createTransientProjection
has been removed.
listProjections
:listContinuousProjections
has been renamed tolistProjections
.listOneTimeProjections
has been removed.listTransientProjections
has been removed.mode
has been removed fromProjectionDetails
, onlyCONTINUOUS
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. UseabortProjection
if wishing to set this tofalse
.
abortProjection
:abortProjection
method has been added.
deleteProjection
:deleteEmittedStreams
option now defaults tofalse
.deleteStateStream
option now defaults tofalse
.deleteCheckpointStream
option now defaults tofalse
.
getProjectionState
&getProjectionResult
:fromPartition
option has been renamed topartition
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 togetProjectionState
View- Improved
tlsVerifyCert
not supported message View
Bug Fixes
- Fixed incorrect log message where http was logged as https and vice versa. View
updateProjection
optiontrackEmittedStreams
name has been corrected asemitEnabled
. 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
Breaking changes
Projections
fromPartition
option has been renamed topartition
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
v3.0.0-alpha.1
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 tosubscribeToPersistentSubscription
ViewpersistentSubscriptionSettings
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 toUNBOUNDED
. View
Projections
The projections api has been completely overhauled, removing one time and transient projections. View
createProjection
:createContinuousProjection
has been renamed tocreateProjection
.createOneTimeProjection
has been removed.createTransientProjection
has been removed.
listProjections
:listContinuousProjections
has been renamed tolistProjections
.listOneTimeProjections
has been removed.listTransientProjections
has been removed.mode
has been removed fromProjectionDetails
, onlyCONTINUOUS
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. UseabortProjection
if wishing to set this tofalse
.
abortProjection
:abortProjection
method has been added.
deleteProjection
:deleteEmittedStreams
option now defaults tofalse
.deleteStateStream
option now defaults tofalse
.deleteCheckpointStream
option now defaults tofalse
.
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
v2.1.1
v2.1.0
v2.0.0
Breaking changes
readStream
andreadAll
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
Bug Fixes
- Ensure member is in a connectable state during discovery View
Removal of Deprecated Apis
ConnectionTypeOptions
View