@bolt.tech/kafka-utils 1.0.11 → 1.0.13
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/build/index.d.ts +2 -2
- package/build/index.js +3 -3
- package/build/kafkaServer.d.ts +11 -1
- package/build/kafkaServer.js +0 -2
- package/build/store/schemas/proto/assetTriggersNotification.proto +33 -27
- package/build/store/schemas/proto/boltNotification.proto +1 -1
- package/build/store/schemas/proto/commonNotification.proto +28 -34
- package/build/utils/kafka/brokers.kafka.d.ts +3 -1
- package/build/utils/kafka/brokers.kafka.js +0 -1
- package/build/utils/kafka/config.kafka.js +4 -2
- package/build/utils/kafka/publisher.kafka.d.ts +6 -1
- package/build/utils/kafka/publisher.kafka.js +0 -1
- package/build/utils/kafka/topicMap.kafka.d.ts +3 -1
- package/build/utils/kafka/topicMap.kafka.js +0 -1
- package/build/utils/schemaRegistry/notificationSchema.registry.d.ts +1 -1
- package/build/utils/schemaRegistry/pickSchema.d.ts +7 -1
- package/build/utils/schemaRegistry/pickSchema.js +0 -1
- package/build/utils/schemaRegistry/registry.util.d.ts +2 -2
- package/package.json +1 -1
package/build/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IAttachment, IMessage, IOneSignalPayload, ISmsObj, IUser } from './store/interfaces/notification.interface';
|
|
2
1
|
import { notificationType } from './store/types/notification.type';
|
|
3
|
-
|
|
2
|
+
import { IUser, IMessage, ISmsObj, IOneSignalPayload, IAttachment } from './store/interfaces/notification.interface';
|
|
3
|
+
export declare function initialiseNotification(paramStorePath: string, nodeEnvLocal: string, serviceName: string, notificationType: notificationType): Promise<void>;
|
|
4
4
|
export declare function sendEmailNotifications(user: IUser, message: IMessage, attachment?: IAttachment): Promise<void>;
|
|
5
5
|
export declare function sendSmsNotifications(user: IUser, message: IMessage, smsObj: ISmsObj): Promise<void>;
|
|
6
6
|
export declare function sendPushNotification(user: IUser, message: IMessage, appId: string, oneSignalPayload: IOneSignalPayload): Promise<void>;
|
package/build/index.js
CHANGED
|
@@ -14,7 +14,9 @@ exports.sendEmailNotifications = sendEmailNotifications;
|
|
|
14
14
|
exports.sendSmsNotifications = sendSmsNotifications;
|
|
15
15
|
exports.sendPushNotification = sendPushNotification;
|
|
16
16
|
exports.sendInAppNotification = sendInAppNotification;
|
|
17
|
+
const notificationSchema_registry_1 = require("./utils/schemaRegistry/notificationSchema.registry");
|
|
17
18
|
const getTopic = require('./utils/kafka/topicMap.kafka');
|
|
19
|
+
const publishToKafka = require('./utils/kafka/publisher.kafka');
|
|
18
20
|
let currentNotificationType;
|
|
19
21
|
function initialiseNotification(paramStorePath, nodeEnvLocal, serviceName, notificationType) {
|
|
20
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -33,8 +35,6 @@ function initialiseNotification(paramStorePath, nodeEnvLocal, serviceName, notif
|
|
|
33
35
|
}
|
|
34
36
|
});
|
|
35
37
|
}
|
|
36
|
-
const notificationSchema_registry_1 = require("./utils/schemaRegistry/notificationSchema.registry");
|
|
37
|
-
const publishToKafka = require('./utils/kafka/publisher.kafka');
|
|
38
38
|
/* publish notifications to kafka */
|
|
39
39
|
function sendNotificationToKafka(userId, payload) {
|
|
40
40
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -56,7 +56,7 @@ function sendNotificationToKafka(userId, payload) {
|
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
|
-
/* send
|
|
59
|
+
/* send email notifications to users */
|
|
60
60
|
function sendEmailNotifications(user, message, attachment) {
|
|
61
61
|
return __awaiter(this, void 0, void 0, function* () {
|
|
62
62
|
if (user.emailIds.length === 0) {
|
package/build/kafkaServer.d.ts
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { notificationType } from './store/types/notification.type';
|
|
2
|
+
declare class KafkaServer {
|
|
3
|
+
private paramStore;
|
|
4
|
+
private schemaRegistry;
|
|
5
|
+
private notificationSchema;
|
|
6
|
+
constructor();
|
|
7
|
+
setupKafka(paramStorePath: string, nodeEnvLocal: string, serviceName: string, notificationType: notificationType): Promise<void>;
|
|
8
|
+
setupShutdownHandlers(): void;
|
|
9
|
+
private handleShutdown;
|
|
10
|
+
}
|
|
11
|
+
export = KafkaServer;
|
package/build/kafkaServer.js
CHANGED
|
@@ -31,7 +31,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
31
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
34
|
const producer_kafka_1 = require("./utils/kafka/producer.kafka");
|
|
36
35
|
const config_kafka_1 = require("./utils/kafka/config.kafka");
|
|
37
36
|
const dotenv = __importStar(require("dotenv"));
|
|
@@ -41,7 +40,6 @@ const registry_util_1 = require("./utils/schemaRegistry/registry.util");
|
|
|
41
40
|
const getKafkaBrokers = require('./utils/kafka/brokers.kafka');
|
|
42
41
|
class KafkaServer {
|
|
43
42
|
constructor() {
|
|
44
|
-
// public express: express.Application;
|
|
45
43
|
this.paramStore = null;
|
|
46
44
|
this.schemaRegistry = null;
|
|
47
45
|
this.notificationSchema = null;
|
|
@@ -1,30 +1,36 @@
|
|
|
1
1
|
syntax = "proto3";
|
|
2
2
|
|
|
3
|
-
message
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
3
|
+
message Notification {
|
|
4
|
+
message User {
|
|
5
|
+
string inAppNotificationUserId = 1;
|
|
6
|
+
string pushNotificationUserId = 2;
|
|
7
|
+
repeated string emailIds = 3;
|
|
8
|
+
repeated string phoneNumbers = 4;
|
|
9
|
+
}
|
|
10
|
+
message Message {
|
|
11
|
+
string body = 1;
|
|
12
|
+
string subject = 2;
|
|
13
|
+
int32 priority = 3;
|
|
14
|
+
repeated bytes attachments = 4;
|
|
15
|
+
string html = 5;
|
|
16
|
+
}
|
|
17
|
+
message SmsObj {
|
|
18
|
+
string smsType = 1;
|
|
19
|
+
string templateId = 2;
|
|
20
|
+
}
|
|
21
|
+
message OneSignalPayload {
|
|
22
|
+
string alert = 1;
|
|
23
|
+
bool sos = 2;
|
|
24
|
+
string vin = 3;
|
|
25
|
+
}
|
|
26
|
+
message Attachment {
|
|
27
|
+
string filename = 1;
|
|
28
|
+
string filetype = 2;
|
|
29
|
+
bytes content = 3;
|
|
30
|
+
}
|
|
31
|
+
User user = 1;
|
|
32
|
+
Message message = 2;
|
|
33
|
+
string appId = 3;
|
|
34
|
+
SmsObj smsObj = 4;
|
|
35
|
+
OneSignalPayload oneSignalPayload = 6;
|
|
30
36
|
}
|
|
@@ -1,36 +1,30 @@
|
|
|
1
1
|
syntax = "proto3";
|
|
2
2
|
|
|
3
|
-
message
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
User user = 1;
|
|
32
|
-
Message message = 2;
|
|
33
|
-
string appId = 3;
|
|
34
|
-
SmsObj smsObj = 4;
|
|
35
|
-
OneSignalPayload oneSignalPayload = 6;
|
|
36
|
-
}
|
|
3
|
+
message AssetsTriggerNotification {
|
|
4
|
+
optional User user = 1;
|
|
5
|
+
optional Message message = 2;
|
|
6
|
+
optional string appId = 3;
|
|
7
|
+
optional SmsObj smsObj = 4;
|
|
8
|
+
optional OneSignalPayload oneSignalPayload = 6;
|
|
9
|
+
|
|
10
|
+
message User {
|
|
11
|
+
optional string inAppNotificationUserId = 1;
|
|
12
|
+
optional string pushNotificationUserId = 2;
|
|
13
|
+
repeated string emailIds = 3;
|
|
14
|
+
repeated string phoneNumbers = 4;
|
|
15
|
+
}
|
|
16
|
+
message Message {
|
|
17
|
+
optional string body = 1;
|
|
18
|
+
optional string subject = 2;
|
|
19
|
+
optional int32 priority = 3;
|
|
20
|
+
}
|
|
21
|
+
message SmsObj {
|
|
22
|
+
optional string smsType = 1;
|
|
23
|
+
optional string templateId = 2;
|
|
24
|
+
}
|
|
25
|
+
message OneSignalPayload {
|
|
26
|
+
optional string alert = 1;
|
|
27
|
+
optional bool sos = 2;
|
|
28
|
+
optional string vin = 3;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -8,7 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
11
|
const bolt_paramstore_1 = require("bolt-paramstore");
|
|
13
12
|
function getKafkaBrokers() {
|
|
14
13
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -11,14 +11,16 @@ class KafkaConfig {
|
|
|
11
11
|
constructor() { }
|
|
12
12
|
static getConfig(config, clientId) {
|
|
13
13
|
if (!this.config) {
|
|
14
|
+
const isExternal = process.env.NODE_ENV_LOCAL === "TRUE"; // ← Add this line
|
|
14
15
|
this.config = new kafkajs_1.Kafka({
|
|
15
16
|
clientId: clientId,
|
|
16
17
|
brokers: config.brokers,
|
|
17
18
|
sasl: {
|
|
18
|
-
mechanism: "
|
|
19
|
+
mechanism: "scram-sha-512",
|
|
19
20
|
username: config.username,
|
|
20
21
|
password: config.password
|
|
21
|
-
}
|
|
22
|
+
},
|
|
23
|
+
ssl: isExternal ? { rejectUnauthorized: false } : false
|
|
22
24
|
});
|
|
23
25
|
}
|
|
24
26
|
return this.config;
|
|
@@ -8,7 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
11
|
const registry_util_1 = require("./../schemaRegistry/registry.util");
|
|
13
12
|
const producer_kafka_1 = require("./producer.kafka");
|
|
14
13
|
function publishToKafka(topic, schemaId, message) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { SchemaRegistry } from
|
|
1
|
+
import { SchemaRegistry } from '@kafkajs/confluent-schema-registry';
|
|
2
2
|
export declare class SchemaRegistryS extends SchemaRegistry {
|
|
3
3
|
private static instance;
|
|
4
|
-
|
|
4
|
+
constructor(url: string);
|
|
5
5
|
static connect(url: string): void;
|
|
6
6
|
static getInstance(): SchemaRegistryS;
|
|
7
7
|
getRegistry(url: string): SchemaRegistryS;
|