@fraym/streams 0.3.0 → 0.4.0
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/allEvents.d.ts +1 -1
- package/dist/client/allEventsFiltered.d.ts +3 -0
- package/dist/client/allEventsFiltered.js +25 -0
- package/dist/client/client.d.ts +2 -1
- package/dist/client/client.js +6 -2
- package/dist/client/event.d.ts +1 -1
- package/dist/client/event.js +1 -1
- package/dist/client/getEvent.d.ts +1 -1
- package/dist/client/init.d.ts +1 -1
- package/dist/client/introduceGdpr.d.ts +1 -1
- package/dist/client/invalidateGdpr.d.ts +1 -1
- package/dist/client/publish.d.ts +1 -1
- package/dist/client/publish.js +1 -1
- package/dist/client/snapshot.d.ts +1 -1
- package/dist/client/stream.d.ts +1 -1
- package/package.json +6 -4
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ServiceClient } from "@fraym/streams
|
|
1
|
+
import { ServiceClient } from "@fraym/proto/freym/streams/clientchannel";
|
|
2
2
|
import { HandlerFunc } from "./event";
|
|
3
3
|
export declare const getAllEvents: (includedTopics: string[], excludedTopics: string[], handler: HandlerFunc, serviceClient: ServiceClient) => Promise<void>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ServiceClient } from "@fraym/proto/freym/streams/clientchannel";
|
|
2
|
+
import { HandlerFunc } from "./event";
|
|
3
|
+
export declare const getAllEventsFiltered: (includedTopics: string[], includedEventTypes: string[], handler: HandlerFunc, serviceClient: ServiceClient) => Promise<void>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAllEventsFiltered = void 0;
|
|
4
|
+
const event_1 = require("./event");
|
|
5
|
+
const getAllEventsFiltered = async (includedTopics, includedEventTypes, handler, serviceClient) => {
|
|
6
|
+
const stream = serviceClient.getFilteredEventsFromStart({
|
|
7
|
+
includedTopics,
|
|
8
|
+
includedEventTypes,
|
|
9
|
+
});
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
stream.on("data", (data) => {
|
|
12
|
+
const event = (0, event_1.getSubscriptionEvent)(data);
|
|
13
|
+
if (event) {
|
|
14
|
+
handler(event);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
stream.on("end", () => {
|
|
18
|
+
resolve();
|
|
19
|
+
});
|
|
20
|
+
stream.on("error", e => {
|
|
21
|
+
reject(e);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
exports.getAllEventsFiltered = getAllEventsFiltered;
|
package/dist/client/client.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { ServiceClient } from "@fraym/streams
|
|
1
|
+
import { ServiceClient } from "@fraym/proto/freym/streams/clientchannel";
|
|
2
2
|
import { ClientConfig } from "./config";
|
|
3
3
|
import { HandlerFunc, PublishEvent, SubscriptionEvent } from "./event";
|
|
4
4
|
export interface Client {
|
|
5
5
|
getAllEvents: (handler: HandlerFunc, includedTopics?: string[], excludedTopics?: string[]) => Promise<void>;
|
|
6
|
+
getAllEventsFiltered: (handler: HandlerFunc, includedTopics: string[], includedEventTypes: string[]) => Promise<void>;
|
|
6
7
|
getEvent: (tenantId: string, topic: string, eventId: string) => Promise<SubscriptionEvent>;
|
|
7
8
|
getStream: (tenantId: string, stream: string) => Promise<SubscriptionEvent[]>;
|
|
8
9
|
useEventHandler: (type: string, handler: HandlerFunc) => void;
|
package/dist/client/client.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.newClient = void 0;
|
|
4
|
-
const
|
|
4
|
+
const clientchannel_1 = require("@fraym/proto/freym/streams/clientchannel");
|
|
5
5
|
const grpc_js_1 = require("@grpc/grpc-js");
|
|
6
6
|
const allEvents_1 = require("./allEvents");
|
|
7
7
|
const config_1 = require("./config");
|
|
@@ -15,9 +15,10 @@ const stream_1 = require("./stream");
|
|
|
15
15
|
const subscribe_1 = require("./subscribe");
|
|
16
16
|
const getEvent_1 = require("./getEvent");
|
|
17
17
|
const introduceGdpr_1 = require("./introduceGdpr");
|
|
18
|
+
const allEventsFiltered_1 = require("./allEventsFiltered");
|
|
18
19
|
const newClient = async (config) => {
|
|
19
20
|
config = (0, config_1.useConfigDefaults)(config);
|
|
20
|
-
const serviceClient = new
|
|
21
|
+
const serviceClient = new clientchannel_1.ServiceClient(config.serverAddress, grpc_js_1.credentials.createInsecure(), {
|
|
21
22
|
"grpc.keepalive_time_ms": config.keepaliveInterval,
|
|
22
23
|
"grpc.keepalive_timeout_ms": config.keepaliveTimeout,
|
|
23
24
|
"grpc.keepalive_permit_without_calls": 1,
|
|
@@ -29,6 +30,9 @@ const newClient = async (config) => {
|
|
|
29
30
|
getAllEvents: async (handler, includedTopics = [], excludedTopics = []) => {
|
|
30
31
|
await (0, allEvents_1.getAllEvents)(includedTopics, excludedTopics, handler, serviceClient);
|
|
31
32
|
},
|
|
33
|
+
getAllEventsFiltered: async (handler, includedTopics, includedEventTypes) => {
|
|
34
|
+
await (0, allEventsFiltered_1.getAllEventsFiltered)(includedTopics, includedEventTypes, handler, serviceClient);
|
|
35
|
+
},
|
|
32
36
|
getEvent: async (tenantId, topic, eventId) => {
|
|
33
37
|
return await (0, getEvent_1.getEvent)(tenantId, topic, eventId, serviceClient);
|
|
34
38
|
},
|
package/dist/client/event.d.ts
CHANGED
package/dist/client/event.js
CHANGED
|
@@ -37,7 +37,7 @@ const getSubscriptionEvent = (eventEnvelope) => {
|
|
|
37
37
|
topic: eventEnvelope.topic,
|
|
38
38
|
tenantId: eventEnvelope.tenantId,
|
|
39
39
|
payload,
|
|
40
|
-
raisedAt: new Date(parseInt(event.raisedAt.slice(0, -6))),
|
|
40
|
+
raisedAt: new Date(parseInt(event.raisedAt.toString().slice(0, -6))),
|
|
41
41
|
stream: event.stream || undefined,
|
|
42
42
|
type: event.type || undefined,
|
|
43
43
|
causationId: event.causationId || undefined,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ServiceClient } from "@fraym/streams
|
|
1
|
+
import { ServiceClient } from "@fraym/proto/freym/streams/clientchannel";
|
|
2
2
|
import { SubscriptionEvent } from "./event";
|
|
3
3
|
export declare const getEvent: (tenantId: string, topic: string, eventId: string, serviceClient: ServiceClient) => Promise<SubscriptionEvent>;
|
package/dist/client/init.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ClientConfig } from "./config";
|
|
2
2
|
import { ClientDuplexStream } from "@grpc/grpc-js";
|
|
3
|
-
import { SubscribeRequest, ServiceClient, SubscribeResponse } from "@fraym/streams
|
|
3
|
+
import { SubscribeRequest, ServiceClient, SubscribeResponse } from "@fraym/proto/freym/streams/clientchannel";
|
|
4
4
|
export type Stream = ClientDuplexStream<SubscribeRequest, SubscribeResponse>;
|
|
5
5
|
export declare const initStream: (config: ClientConfig, serviceClient: ServiceClient) => Promise<Stream>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ServiceClient } from "@fraym/streams
|
|
1
|
+
import { ServiceClient } from "@fraym/proto/freym/streams/clientchannel";
|
|
2
2
|
export declare const introduceGdprOnField: (defaultValue: string, topic: string, eventType: string, fieldName: string, serviceClient: ServiceClient) => Promise<void>;
|
|
3
3
|
export declare const introduceGdprOnEventField: (tenantId: string, defaultValue: string, topic: string, eventId: string, fieldName: string, serviceClient: ServiceClient) => Promise<void>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ServiceClient } from "@fraym/streams
|
|
1
|
+
import { ServiceClient } from "@fraym/proto/freym/streams/clientchannel";
|
|
2
2
|
export declare const sendInvalidateGdpr: (tenantId: string, topic: string, gdprId: string, serviceClient: ServiceClient) => Promise<void>;
|
package/dist/client/publish.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { PublishEvent } from "./event";
|
|
2
|
-
import { ServiceClient } from "@fraym/streams
|
|
2
|
+
import { ServiceClient } from "@fraym/proto/freym/streams/clientchannel";
|
|
3
3
|
export declare const sendPublish: (topic: string, events: PublishEvent[], serviceClient: ServiceClient) => Promise<void>;
|
package/dist/client/publish.js
CHANGED
|
@@ -49,7 +49,7 @@ const getEventEnvelopeFromPublishedEvent = (event) => {
|
|
|
49
49
|
correlationId: (_f = event.correlationId) !== null && _f !== void 0 ? _f : "",
|
|
50
50
|
causationId: (_g = event.causationId) !== null && _g !== void 0 ? _g : "",
|
|
51
51
|
payload,
|
|
52
|
-
raisedAt:
|
|
52
|
+
raisedAt: 0,
|
|
53
53
|
},
|
|
54
54
|
};
|
|
55
55
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ServiceClient } from "@fraym/streams
|
|
1
|
+
import { ServiceClient } from "@fraym/proto/freym/streams/clientchannel";
|
|
2
2
|
export declare const sendSnapshot: (topic: string, toTime: Date, serviceClient: ServiceClient) => Promise<void>;
|
package/dist/client/stream.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { SubscriptionEvent } from "./event";
|
|
2
|
-
import { ServiceClient } from "@fraym/streams
|
|
2
|
+
import { ServiceClient } from "@fraym/proto/freym/streams/clientchannel";
|
|
3
3
|
export declare const getStream: (tenantId: string, stream: string, serviceClient: ServiceClient) => Promise<SubscriptionEvent[]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fraym/streams",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"homepage": "https://github.com/fraym/streams-nodejs",
|
|
6
6
|
"repository": {
|
|
@@ -15,16 +15,18 @@
|
|
|
15
15
|
"build": "npm run clean && tsc",
|
|
16
16
|
"clean": "rm -rf dist",
|
|
17
17
|
"prepublishOnly": "npm test && npm run lint && npm run build",
|
|
18
|
-
"preversion": "npm run lint"
|
|
19
|
-
"protobuf": "./protobuf.sh"
|
|
18
|
+
"preversion": "npm run lint"
|
|
20
19
|
},
|
|
21
20
|
"files": [
|
|
22
21
|
"dist/**/*"
|
|
23
22
|
],
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=16"
|
|
25
|
+
},
|
|
24
26
|
"main": "dist/index.js",
|
|
25
27
|
"types": "dist/index.d.ts",
|
|
26
28
|
"dependencies": {
|
|
27
|
-
"@fraym/
|
|
29
|
+
"@fraym/proto": "^0.3.0",
|
|
28
30
|
"@grpc/grpc-js": "^1.8.17",
|
|
29
31
|
"ts-node": "^10.9.1",
|
|
30
32
|
"uuid": "^9.0.0"
|