@fraym/streams 0.10.3 → 0.10.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,10 +6,14 @@ const util_1 = require("./util");
6
6
  const publish_1 = require("./publish");
7
7
  const getStream = async (topic, tenantId, stream, perPage, handler, stopLoadingMore, serviceClient) => {
8
8
  let lastEventId = null;
9
+ let possibleSnapshotEventId = null;
9
10
  let events = [];
10
11
  while (true) {
11
12
  if (!lastEventId) {
12
13
  events = await getStreamPage(topic, tenantId, stream, perPage, 0, serviceClient);
14
+ if (events.length > 0) {
15
+ possibleSnapshotEventId = events[0].id;
16
+ }
13
17
  }
14
18
  else {
15
19
  events = await getStreamPageAfterEvent(topic, tenantId, stream, lastEventId, perPage, 0, serviceClient);
@@ -18,6 +22,11 @@ const getStream = async (topic, tenantId, stream, perPage, handler, stopLoadingM
18
22
  for (const eventData of events) {
19
23
  const event = (0, event_1.getSubscriptionEvent)(eventData);
20
24
  if (event) {
25
+ if (lastEventId != null && possibleSnapshotEventId) {
26
+ if (event.id === possibleSnapshotEventId) {
27
+ continue;
28
+ }
29
+ }
21
30
  await handler(event);
22
31
  lastEvent = event;
23
32
  lastEventId = event.id;
@@ -100,7 +109,6 @@ const isStreamEmpty = async (topic, tenantId, stream, serviceClient) => {
100
109
  };
101
110
  exports.isStreamEmpty = isStreamEmpty;
102
111
  const createStreamSnapshot = async (tenantId, topic, stream, lastSnapshottedEventId, snapshotEvent, serviceClient) => {
103
- console.log("creating snapshot", tenantId, topic, stream, lastSnapshottedEventId);
104
112
  return new Promise((resolve, reject) => {
105
113
  serviceClient.createStreamSnapshot({
106
114
  topic,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fraym/streams",
3
- "version": "0.10.3",
3
+ "version": "0.10.5",
4
4
  "license": "MIT",
5
5
  "homepage": "https://github.com/fraym/streams-nodejs",
6
6
  "repository": {