@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 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
- export declare function initialiseNotification(paramStorePath: "dev" | "prod", nodeEnvLocal: "TRUE" | "FALSE", serviceName: string, notificationType: notificationType): Promise<void>;
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 emaail notifications to users */
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) {
@@ -1 +1,11 @@
1
- export {};
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;
@@ -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 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
- }
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
  }
@@ -20,4 +20,4 @@ message BoltNotification {
20
20
  optional string smsType = 1;
21
21
  optional string templateId = 2;
22
22
  }
23
- }
23
+ }
@@ -1,36 +1,30 @@
1
1
  syntax = "proto3";
2
2
 
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;
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
+ }
@@ -1 +1,3 @@
1
- export {};
1
+ import { IKafkaSecret } from '../../store/interfaces/kafkaSecret.interface';
2
+ declare function getKafkaBrokers(): Promise<IKafkaSecret>;
3
+ export = getKafkaBrokers;
@@ -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: "plain",
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;
@@ -1 +1,6 @@
1
- export {};
1
+ interface KafkaMessage {
2
+ key: string;
3
+ value: any;
4
+ }
5
+ declare function publishToKafka(topic: string, schemaId: number, message: KafkaMessage): Promise<void>;
6
+ export = publishToKafka;
@@ -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 +1,3 @@
1
- export {};
1
+ import { notificationType } from '../../store/types/notification.type';
2
+ declare function getTopic(type: notificationType): string;
3
+ export = getTopic;
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
2
  const typeTopicMap = {
4
3
  "common": "COMMON_NOTIFICATIONS",
5
4
  "asset-triggers": "ASSET_TRIGGER_NOTIFICATIONS",
@@ -1,4 +1,4 @@
1
- import { notificationType } from './../../store/types/notification.type';
1
+ import { notificationType } from '../../store/types/notification.type';
2
2
  export declare class NotificationSchema {
3
3
  private static instance;
4
4
  private registry;
@@ -1 +1,7 @@
1
- export {};
1
+ import { notificationType } from '../../store/types/notification.type';
2
+ interface SchemaInfo {
3
+ path: string;
4
+ subject: string;
5
+ }
6
+ declare function pickSchema(notificationType: notificationType): SchemaInfo;
7
+ export = pickSchema;
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
2
  const path = require('path');
4
3
  const schemaMap = {
5
4
  'common': {
@@ -1,7 +1,7 @@
1
- import { SchemaRegistry } from "@kafkajs/confluent-schema-registry";
1
+ import { SchemaRegistry } from '@kafkajs/confluent-schema-registry';
2
2
  export declare class SchemaRegistryS extends SchemaRegistry {
3
3
  private static instance;
4
- private constructor();
4
+ constructor(url: string);
5
5
  static connect(url: string): void;
6
6
  static getInstance(): SchemaRegistryS;
7
7
  getRegistry(url: string): SchemaRegistryS;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bolt.tech/kafka-utils",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",