gemcap-be-common 1.4.248 → 1.4.250

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.
@@ -1,6 +1,7 @@
1
1
  export declare const MESSAGE_CHANNELS: {
2
2
  readonly AI: "ai.exchange";
3
3
  readonly COMPLIANCE: "compliance.exchange";
4
+ readonly CRM: "crm.exchange";
4
5
  readonly FINANCE: "finance.exchange";
5
6
  readonly PORTFOLIO: "portfolio.exchange";
6
7
  readonly NOTIFICATIONS: "notifications.exchange";
@@ -4,6 +4,7 @@ exports.MESSAGE_CHANNELS = void 0;
4
4
  exports.MESSAGE_CHANNELS = {
5
5
  AI: 'ai.exchange',
6
6
  COMPLIANCE: 'compliance.exchange',
7
+ CRM: 'crm.exchange',
7
8
  FINANCE: 'finance.exchange',
8
9
  PORTFOLIO: 'portfolio.exchange',
9
10
  NOTIFICATIONS: 'notifications.exchange',
@@ -1,6 +1,7 @@
1
1
  export const MESSAGE_CHANNELS = {
2
2
  AI: 'ai.exchange',
3
3
  COMPLIANCE: 'compliance.exchange',
4
+ CRM: 'crm.exchange',
4
5
  FINANCE: 'finance.exchange',
5
6
  PORTFOLIO: 'portfolio.exchange',
6
7
  NOTIFICATIONS: 'notifications.exchange',
@@ -15,6 +15,12 @@ export declare const EVENT_KEYS: {
15
15
  readonly SUMMARY_GENERATED: "compliance.summary.generated";
16
16
  readonly FIND_MATCH_COMPLETED: "compliance.find-match.completed";
17
17
  };
18
+ /**
19
+ * ========= CRM DOMAIN EVENTS =========
20
+ */
21
+ readonly crm: {
22
+ readonly PROSPECT_EMAILS_SEND_REQUESTED: "crm.prospect.emails.requested";
23
+ };
18
24
  /**
19
25
  * ========= FINANCE DOMAIN EVENTS =========
20
26
  */
@@ -18,6 +18,12 @@ exports.EVENT_KEYS = {
18
18
  SUMMARY_GENERATED: 'compliance.summary.generated',
19
19
  FIND_MATCH_COMPLETED: 'compliance.find-match.completed',
20
20
  },
21
+ /**
22
+ * ========= CRM DOMAIN EVENTS =========
23
+ */
24
+ crm: {
25
+ PROSPECT_EMAILS_SEND_REQUESTED: 'crm.prospect.emails.requested',
26
+ },
21
27
  /**
22
28
  * ========= FINANCE DOMAIN EVENTS =========
23
29
  */
@@ -17,6 +17,13 @@ export const EVENT_KEYS = {
17
17
  FIND_MATCH_COMPLETED: 'compliance.find-match.completed',
18
18
  },
19
19
 
20
+ /**
21
+ * ========= CRM DOMAIN EVENTS =========
22
+ */
23
+ crm: {
24
+ PROSPECT_EMAILS_SEND_REQUESTED: 'crm.prospect.emails.requested',
25
+ },
26
+
20
27
  /**
21
28
  * ========= FINANCE DOMAIN EVENTS =========
22
29
  */
@@ -17,6 +17,9 @@ export declare const QUEUES: {
17
17
  readonly summaryReady: "compliance.summary.ready";
18
18
  readonly findMatchReady: "compliance.find-match.ready";
19
19
  };
20
+ readonly crm: {
21
+ readonly prospectEmailsSend: "crm.prospect.emails.send";
22
+ };
20
23
  readonly finance: {
21
24
  readonly reports: {
22
25
  readonly perAccount: "finance.report.per-account";
@@ -20,6 +20,9 @@ exports.QUEUES = {
20
20
  summaryReady: 'compliance.summary.ready',
21
21
  findMatchReady: 'compliance.find-match.ready',
22
22
  },
23
+ crm: {
24
+ prospectEmailsSend: 'crm.prospect.emails.send',
25
+ },
23
26
  finance: {
24
27
  reports: {
25
28
  perAccount: 'finance.report.per-account',
@@ -17,6 +17,9 @@ export const QUEUES = {
17
17
  summaryReady: 'compliance.summary.ready',
18
18
  findMatchReady: 'compliance.find-match.ready',
19
19
  },
20
+ crm: {
21
+ prospectEmailsSend: 'crm.prospect.emails.send',
22
+ },
20
23
  finance: {
21
24
  reports: {
22
25
  perAccount: 'finance.report.per-account',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemcap-be-common",
3
- "version": "1.4.248",
3
+ "version": "1.4.250",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -0,0 +1,6 @@
1
+ export declare class RabbitService {
2
+ private connection;
3
+ private channel;
4
+ init(): Promise<void>;
5
+ publish(exchange: string, routingKey: string, payload: unknown): Promise<void>;
6
+ }
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.RabbitService = void 0;
27
+ const amqp = __importStar(require("amqplib"));
28
+ const { NODE_ENV } = process.env;
29
+ class RabbitService {
30
+ connection = null;
31
+ channel = null;
32
+ async init() {
33
+ const rabbitMQApi = NODE_ENV === 'development' ? 'localhost' : 'rabbitmq';
34
+ this.connection = await amqp.connect(`amqp://${rabbitMQApi}`, { heartbeat: 10 });
35
+ this.connection.on('error', (err) => {
36
+ console.error('RabbitMQ connection error', err);
37
+ });
38
+ this.connection.on('close', () => {
39
+ console.warn('RabbitMQ connection closed. Reconnecting...');
40
+ setTimeout(() => this.init(), 5000);
41
+ });
42
+ this.channel = await this.connection.createChannel();
43
+ console.log('RabbitMQ connected');
44
+ }
45
+ async publish(exchange, routingKey, payload) {
46
+ if (!this.channel) {
47
+ throw new Error('RabbitMQ channel is not initialized');
48
+ }
49
+ this.channel.publish(exchange, routingKey, Buffer.from(JSON.stringify(payload)), { persistent: true });
50
+ }
51
+ }
52
+ exports.RabbitService = RabbitService;
@@ -0,0 +1,40 @@
1
+ import * as amqp from 'amqplib';
2
+
3
+ const { NODE_ENV } = process.env;
4
+
5
+ export class RabbitService {
6
+ private connection: amqp.ChannelModel | null = null;
7
+ private channel: amqp.Channel | null = null;
8
+
9
+ async init() {
10
+ const rabbitMQApi = NODE_ENV === 'development' ? 'localhost' : 'rabbitmq';
11
+
12
+ this.connection = await amqp.connect(`amqp://${rabbitMQApi}`, { heartbeat: 10 });
13
+
14
+ this.connection.on('error', (err) => {
15
+ console.error('RabbitMQ connection error', err);
16
+ });
17
+
18
+ this.connection.on('close', () => {
19
+ console.warn('RabbitMQ connection closed. Reconnecting...');
20
+ setTimeout(() => this.init(), 5000);
21
+ });
22
+
23
+ this.channel = await this.connection.createChannel();
24
+
25
+ console.log('RabbitMQ connected');
26
+ }
27
+
28
+ async publish(exchange: string, routingKey: string, payload: unknown) {
29
+ if (!this.channel) {
30
+ throw new Error('RabbitMQ channel is not initialized');
31
+ }
32
+
33
+ this.channel.publish(
34
+ exchange,
35
+ routingKey,
36
+ Buffer.from(JSON.stringify(payload)),
37
+ { persistent: true },
38
+ );
39
+ }
40
+ }