@bolt.tech/kafka-utils 1.0.0 → 1.0.2

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,5 +1,3 @@
1
1
  import { notificationType } from './store/types/notification.type';
2
- declare let notificationType: notificationType;
3
2
  export declare function initialiseNotification(paramStorePath: "dev" | "prod", nodeEnvLocal: "TRUE" | "FALSE", serviceName: string, notificationType: notificationType): Promise<void>;
4
3
  export declare function sendNotification(userId: string, message: any): Promise<void>;
5
- export {};
package/build/index.js CHANGED
@@ -11,16 +11,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.initialiseNotification = initialiseNotification;
13
13
  exports.sendNotification = sendNotification;
14
- const getTopic = require('./kafka/topicMap.kafka');
15
- let notificationType;
14
+ const getTopic = require('./utils/kafka/topicMap.kafka');
15
+ let currentNotificationType;
16
16
  function initialiseNotification(paramStorePath, nodeEnvLocal, serviceName, notificationType) {
17
17
  return __awaiter(this, void 0, void 0, function* () {
18
18
  try {
19
- notificationType = notificationType;
19
+ currentNotificationType = notificationType;
20
20
  const KafkaServer = require('./kafkaServer');
21
21
  const kafkaInstance = new KafkaServer();
22
22
  yield kafkaInstance.setupKafka(paramStorePath, nodeEnvLocal, serviceName, notificationType);
23
- this.setupShutdownHandlers();
23
+ yield kafkaInstance.setupShutdownHandlers();
24
24
  console.log("---------------------------------------------");
25
25
  console.log("Notification utility is ready.");
26
26
  console.log("---------------------------------------------");
@@ -30,17 +30,17 @@ function initialiseNotification(paramStorePath, nodeEnvLocal, serviceName, notif
30
30
  }
31
31
  });
32
32
  }
33
- const NotificationSchema = require('./schemaRegistry/notificationSchema.registry');
34
- const publishToKafka = require('./kafka/publisher.kafka');
33
+ const notificationSchema_registry_1 = require("./utils/schemaRegistry/notificationSchema.registry");
34
+ const publishToKafka = require('./utils/kafka/publisher.kafka');
35
35
  function sendNotification(userId, message) {
36
36
  return __awaiter(this, void 0, void 0, function* () {
37
37
  try {
38
- if (!this.notificationSchema) {
38
+ if (!notificationSchema_registry_1.NotificationSchema) {
39
39
  throw new Error("Notification schema is not initialised");
40
40
  }
41
- const topic = getTopic(notificationType);
41
+ const topic = getTopic(currentNotificationType);
42
42
  let key = userId;
43
- const instance = NotificationSchema.getInstance();
43
+ const instance = notificationSchema_registry_1.NotificationSchema.getInstance();
44
44
  const schemaId = yield instance.getSchemaId();
45
45
  yield publishToKafka(topic, schemaId, { key, value: message });
46
46
  }
@@ -47,7 +47,9 @@ class KafkaServer {
47
47
  this.notificationSchema = null;
48
48
  this.handleShutdown = () => __awaiter(this, void 0, void 0, function* () {
49
49
  console.log('Shutting down Kafka Server...');
50
- yield producer_kafka_1.KafkaProducer.shutdown();
50
+ if (producer_kafka_1.KafkaProducer) {
51
+ yield producer_kafka_1.KafkaProducer.shutdown();
52
+ }
51
53
  process.exit(0);
52
54
  });
53
55
  dotenv.config();
@@ -21,4 +21,4 @@ function getKafkaBrokers() {
21
21
  return config;
22
22
  });
23
23
  }
24
- module.exports = { getKafkaBroker: getKafkaBrokers };
24
+ module.exports = getKafkaBrokers;
@@ -18,7 +18,7 @@ const schemaMap = {
18
18
  function pickSchema(notificationType) {
19
19
  let schemaPath;
20
20
  switch (notificationType) {
21
- case 'bolt':
21
+ case 'common':
22
22
  schemaPath = schemaMap["common"];
23
23
  break;
24
24
  case 'asset-triggers':
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bolt.tech/kafka-utils",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",