@bolt.tech/kafka-utils 1.0.13 → 2.0.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/build/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { notificationType } from './store/types/notification.type';
|
|
2
2
|
import { IUser, IMessage, ISmsObj, IOneSignalPayload, IAttachment } from './store/interfaces/notification.interface';
|
|
3
|
+
import { IWhatsappPayload } from './store/interfaces/whatsappPayload.interface';
|
|
3
4
|
export declare function initialiseNotification(paramStorePath: string, nodeEnvLocal: string, serviceName: string, notificationType: notificationType): Promise<void>;
|
|
4
5
|
export declare function sendEmailNotifications(user: IUser, message: IMessage, attachment?: IAttachment): Promise<void>;
|
|
5
6
|
export declare function sendSmsNotifications(user: IUser, message: IMessage, smsObj: ISmsObj): Promise<void>;
|
|
6
7
|
export declare function sendPushNotification(user: IUser, message: IMessage, appId: string, oneSignalPayload: IOneSignalPayload): Promise<void>;
|
|
7
8
|
export declare function sendInAppNotification(user: IUser, message: IMessage, appId: string): Promise<void>;
|
|
9
|
+
export declare function sendWhatsappNotification(whatsappPayload: IWhatsappPayload): Promise<void>;
|
package/build/index.js
CHANGED
|
@@ -14,6 +14,7 @@ exports.sendEmailNotifications = sendEmailNotifications;
|
|
|
14
14
|
exports.sendSmsNotifications = sendSmsNotifications;
|
|
15
15
|
exports.sendPushNotification = sendPushNotification;
|
|
16
16
|
exports.sendInAppNotification = sendInAppNotification;
|
|
17
|
+
exports.sendWhatsappNotification = sendWhatsappNotification;
|
|
17
18
|
const notificationSchema_registry_1 = require("./utils/schemaRegistry/notificationSchema.registry");
|
|
18
19
|
const getTopic = require('./utils/kafka/topicMap.kafka');
|
|
19
20
|
const publishToKafka = require('./utils/kafka/publisher.kafka');
|
|
@@ -126,3 +127,18 @@ function sendInAppNotification(user, message, appId) {
|
|
|
126
127
|
yield sendNotificationToKafka(user.inAppNotificationUserId, payload);
|
|
127
128
|
});
|
|
128
129
|
}
|
|
130
|
+
/* send whatsapp notifications to users */
|
|
131
|
+
function sendWhatsappNotification(whatsappPayload) {
|
|
132
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
133
|
+
var _a;
|
|
134
|
+
if (!((_a = whatsappPayload === null || whatsappPayload === void 0 ? void 0 : whatsappPayload.phone) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
135
|
+
console.log("No phone number provided");
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const payload = {
|
|
139
|
+
user: { phoneNumbers: [whatsappPayload.phone] },
|
|
140
|
+
whatsappPayload,
|
|
141
|
+
};
|
|
142
|
+
yield sendNotificationToKafka(whatsappPayload.phone, payload);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
@@ -6,6 +6,7 @@ message AssetsTriggerNotification {
|
|
|
6
6
|
optional string appId = 3;
|
|
7
7
|
optional SmsObj smsObj = 4;
|
|
8
8
|
optional OneSignalPayload oneSignalPayload = 6;
|
|
9
|
+
optional WhatsappPayload whatsappPayload = 7;
|
|
9
10
|
|
|
10
11
|
message User {
|
|
11
12
|
optional string inAppNotificationUserId = 1;
|
|
@@ -27,4 +28,20 @@ message AssetsTriggerNotification {
|
|
|
27
28
|
optional bool sos = 2;
|
|
28
29
|
optional string vin = 3;
|
|
29
30
|
}
|
|
31
|
+
message WhatsappPayload {
|
|
32
|
+
optional string name = 1;
|
|
33
|
+
optional string phone = 2;
|
|
34
|
+
optional string template_name = 3;
|
|
35
|
+
optional TemplateParams template_params = 4;
|
|
36
|
+
message TemplateParams {
|
|
37
|
+
optional string agent_name = 1;
|
|
38
|
+
optional string agent_phone = 2;
|
|
39
|
+
optional string time = 3;
|
|
40
|
+
optional string order_id = 4;
|
|
41
|
+
optional string tracking_id = 5;
|
|
42
|
+
optional string tracking_link = 6;
|
|
43
|
+
optional string branch_name = 7;
|
|
44
|
+
optional string feedback_link = 8;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
30
47
|
}
|