@fraym/streams 0.9.0 → 0.10.1
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.
package/dist/client/client.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export interface StreamIterator {
|
|
|
9
9
|
export interface Client {
|
|
10
10
|
getEvent: (tenantId: string, topic: string, eventId: string) => Promise<SubscriptionEvent>;
|
|
11
11
|
getLastEvent: (tenantId: string, topic: string) => Promise<SubscriptionEvent | null>;
|
|
12
|
+
getLastEventByTypes: (tenantId: string, topic: string, types: string[]) => Promise<SubscriptionEvent | null>;
|
|
12
13
|
iterateAllEvents: (tenantId: string, topic: string, includedEventTypes: string[], perPage: number, handler: HandlerFunc) => Promise<void>;
|
|
13
14
|
iterateAllEventsAfterEvent: (tenantId: string, topic: string, includedEventTypes: string[], eventId: string, perPage: number, handler: HandlerFunc) => Promise<void>;
|
|
14
15
|
publish: (topic: string, events: PublishEvent[]) => Promise<void>;
|
package/dist/client/client.js
CHANGED
|
@@ -12,6 +12,7 @@ const invalidateGdpr_1 = require("./invalidateGdpr");
|
|
|
12
12
|
const stream_1 = require("./stream");
|
|
13
13
|
const subscribe_1 = require("./subscribe");
|
|
14
14
|
const getLastEvent_1 = require("./getLastEvent");
|
|
15
|
+
const getLastEventByTypes_1 = require("./getLastEventByTypes");
|
|
15
16
|
const newClient = async (config) => {
|
|
16
17
|
config = (0, config_1.useConfigDefaults)(config);
|
|
17
18
|
const serviceClient = new management_1.ServiceClient(config.serverAddress, grpc_js_1.credentials.createInsecure(), {
|
|
@@ -70,6 +71,9 @@ const newClient = async (config) => {
|
|
|
70
71
|
getLastEvent: async (tenantId, topic) => {
|
|
71
72
|
return await (0, getLastEvent_1.getLastEvent)(tenantId, topic, serviceClient);
|
|
72
73
|
},
|
|
74
|
+
getLastEventByTypes: async (tenantId, topic, types) => {
|
|
75
|
+
return await (0, getLastEventByTypes_1.getLastEventByTypes)(tenantId, topic, types, serviceClient);
|
|
76
|
+
},
|
|
73
77
|
iterateAllEvents: async (tenantId, topic, includedEventTypes, perPage, handler) => {
|
|
74
78
|
const lastEventCheck = await getLastEventCheck(tenantId, topic);
|
|
75
79
|
if (!lastEventCheck) {
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ServiceClient } from "@fraym/proto/freym/streams/management";
|
|
2
|
+
import { SubscriptionEvent } from "./event";
|
|
3
|
+
export declare const getLastEventByTypes: (tenantId: string, topic: string, types: string[], serviceClient: ServiceClient) => Promise<SubscriptionEvent | null>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getLastEventByTypes = void 0;
|
|
4
|
+
const event_1 = require("./event");
|
|
5
|
+
const util_1 = require("./util");
|
|
6
|
+
const getLastEventByTypes = async (tenantId, topic, types, serviceClient) => {
|
|
7
|
+
return (0, util_1.retry)(() => new Promise((resolve, reject) => {
|
|
8
|
+
serviceClient.getLastEventByTypes({
|
|
9
|
+
tenantId,
|
|
10
|
+
topic,
|
|
11
|
+
types,
|
|
12
|
+
}, (error, response) => {
|
|
13
|
+
if (error === null || error === void 0 ? void 0 : error.details.includes("unable to find last event by types")) {
|
|
14
|
+
resolve(null);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (error) {
|
|
18
|
+
reject(error);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const event = (0, event_1.getSubscriptionEvent)(response);
|
|
22
|
+
if (event) {
|
|
23
|
+
resolve(event);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
reject("unable to resolve last event by types from event data");
|
|
27
|
+
});
|
|
28
|
+
}));
|
|
29
|
+
};
|
|
30
|
+
exports.getLastEventByTypes = getLastEventByTypes;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fraym/streams",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"homepage": "https://github.com/fraym/streams-nodejs",
|
|
6
6
|
"repository": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"main": "dist/index.js",
|
|
27
27
|
"types": "dist/index.d.ts",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@fraym/proto": "^0.
|
|
29
|
+
"@fraym/proto": "^0.20.0",
|
|
30
30
|
"@grpc/grpc-js": "^1.11.1",
|
|
31
31
|
"uuid": "^9.0.1"
|
|
32
32
|
},
|