@btffamily/vacepey 1.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.
Files changed (51) hide show
  1. package/build/brokers/nats/listener.ev.d.ts +29 -0
  2. package/build/brokers/nats/listener.ev.js +44 -0
  3. package/build/brokers/nats/publisher.ev.d.ts +19 -0
  4. package/build/brokers/nats/publisher.ev.js +28 -0
  5. package/build/brokers/nats/subjects.ev.d.ts +84 -0
  6. package/build/brokers/nats/subjects.ev.js +91 -0
  7. package/build/brokers/rabbitMQ/consumer.d.ts +35 -0
  8. package/build/brokers/rabbitMQ/consumer.js +74 -0
  9. package/build/brokers/rabbitMQ/exchanges.d.ts +36 -0
  10. package/build/brokers/rabbitMQ/exchanges.js +43 -0
  11. package/build/brokers/rabbitMQ/producer.d.ts +17 -0
  12. package/build/brokers/rabbitMQ/producer.js +40 -0
  13. package/build/dtos/word.dto.d.ts +11 -0
  14. package/build/dtos/word.dto.js +2 -0
  15. package/build/events/listener.ev.d.ts +29 -0
  16. package/build/events/listener.ev.js +44 -0
  17. package/build/events/publisher.ev.d.ts +19 -0
  18. package/build/events/publisher.ev.js +28 -0
  19. package/build/events/subjects.ev.d.ts +84 -0
  20. package/build/events/subjects.ev.js +91 -0
  21. package/build/index.d.ts +14 -0
  22. package/build/index.js +109 -0
  23. package/build/middleware/async.mw.d.ts +3 -0
  24. package/build/middleware/async.mw.js +4 -0
  25. package/build/middleware/auth.mw.d.ts +24 -0
  26. package/build/middleware/auth.mw.js +98 -0
  27. package/build/middleware/db.mw.d.ts +6 -0
  28. package/build/middleware/db.mw.js +43 -0
  29. package/build/middleware/redis.mw.d.ts +19 -0
  30. package/build/middleware/redis.mw.js +28 -0
  31. package/build/middleware/role.mw.d.ts +4 -0
  32. package/build/middleware/role.mw.js +19 -0
  33. package/build/services/mongo.service.d.ts +7 -0
  34. package/build/services/mongo.service.js +14 -0
  35. package/build/services/random.service.d.ts +8 -0
  36. package/build/services/random.service.js +30 -0
  37. package/build/services/word.service.d.ts +8 -0
  38. package/build/services/word.service.js +73 -0
  39. package/build/src/ca-certificate.crt +32 -0
  40. package/build/src/index.ts +192 -0
  41. package/build/utils/cache.util.d.ts +3 -0
  42. package/build/utils/cache.util.js +7 -0
  43. package/build/utils/encryption.util.d.ts +66 -0
  44. package/build/utils/encryption.util.js +208 -0
  45. package/build/utils/functions.util.d.ts +133 -0
  46. package/build/utils/functions.util.js +1032 -0
  47. package/build/utils/snippets/decryption.snippet.d.ts +0 -0
  48. package/build/utils/snippets/decryption.snippet.js +255 -0
  49. package/build/utils/types.util.d.ts +58 -0
  50. package/build/utils/types.util.js +2 -0
  51. package/package.json +49 -0
@@ -0,0 +1,29 @@
1
+ /** Abstract Class Listener
2
+ *
3
+ * @class Listener
4
+ *
5
+ */
6
+ import nats, { Stan } from 'node-nats-streaming';
7
+ import { Subjects, STGSubjects } from './subjects.ev';
8
+ interface IListener {
9
+ subject: Subjects | STGSubjects;
10
+ client: Stan;
11
+ _ackwait: number;
12
+ queueGroupName: any;
13
+ subscriptionOptions(): any;
14
+ onMessage(data: object, message: any): void;
15
+ parseMessage(message: any): object;
16
+ listen(): void;
17
+ }
18
+ declare class Listener implements IListener {
19
+ subject: any;
20
+ queueGroupName: any;
21
+ client: Stan;
22
+ _ackwait: number;
23
+ constructor(client: Stan);
24
+ subscriptionOptions(): nats.SubscriptionOptions;
25
+ listen(log?: boolean): void;
26
+ parseMessage(message: any): object;
27
+ onMessage(data: object, message: any): void;
28
+ }
29
+ export default Listener;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ /** Abstract Class Listener
3
+ *
4
+ * @class Listener
5
+ *
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ class Listener {
9
+ subject;
10
+ queueGroupName;
11
+ client;
12
+ _ackwait = 1 * 1000;
13
+ constructor(client) {
14
+ this.client = client;
15
+ }
16
+ subscriptionOptions() {
17
+ return this.client
18
+ .subscriptionOptions()
19
+ .setDeliverAllAvailable()
20
+ .setManualAckMode(true)
21
+ .setAckWait(this._ackwait)
22
+ .setStartAtTimeDelta(1 * 1000) // starting at a specific amount of time in the past
23
+ .setDurableName(this.queueGroupName);
24
+ }
25
+ listen(log = true) {
26
+ // create the subscription
27
+ const subscription = this.client.subscribe(this.subject, this.queueGroupName, this.subscriptionOptions());
28
+ subscription.on('message', (msg) => {
29
+ if (log === true) {
30
+ console.log(`Message recieved from ${this.subject}/${this.queueGroupName}`);
31
+ }
32
+ const parsedData = this.parseMessage(msg);
33
+ this.onMessage(parsedData, msg);
34
+ });
35
+ }
36
+ parseMessage(message) {
37
+ const data = message.getData();
38
+ return typeof (data) === 'string'
39
+ ? JSON.parse(data)
40
+ : JSON.parse(data.toString('utf8'));
41
+ }
42
+ onMessage(data, message) { }
43
+ }
44
+ exports.default = Listener;
@@ -0,0 +1,19 @@
1
+ /** Abstract Class Publisher
2
+ *
3
+ * @class Publisher
4
+ *
5
+ */
6
+ import { Stan } from 'node-nats-streaming';
7
+ import { Subjects, STGSubjects } from './subjects.ev';
8
+ interface IPublisher {
9
+ subject: Subjects | STGSubjects;
10
+ client: Stan;
11
+ publish(data: object): Promise<any>;
12
+ }
13
+ declare class Publisher implements IPublisher {
14
+ subject: any;
15
+ client: Stan;
16
+ constructor(client: Stan);
17
+ publish(data: object | any, log?: boolean): Promise<any>;
18
+ }
19
+ export default Publisher;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ /** Abstract Class Publisher
3
+ *
4
+ * @class Publisher
5
+ *
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ class Publisher {
9
+ subject;
10
+ client;
11
+ constructor(client) {
12
+ this.client = client;
13
+ }
14
+ publish(data, log = true) {
15
+ return new Promise((resolve, reject) => {
16
+ this.client.publish(this.subject, JSON.stringify(data), (err) => {
17
+ if (err) {
18
+ reject(err);
19
+ }
20
+ if (log === true) {
21
+ console.log(`Event published to channel ${this.subject}`);
22
+ }
23
+ resolve();
24
+ });
25
+ });
26
+ }
27
+ }
28
+ exports.default = Publisher;
@@ -0,0 +1,84 @@
1
+ export declare enum Subjects {
2
+ UserCreated = "pacitude.prod.user.created",
3
+ UserUpdated = "pacitude.prod.user.updated",
4
+ UserDeleted = "pacitude.prod.user.deleted",
5
+ CountryFound = "pacitude.prod.country.found",
6
+ LocationSaved = "pacitude.prod.location.saved",
7
+ NotificationCreated = "pacitude.prod.notification.created",
8
+ NotificationUpdated = "pacitude.prod.notification.updated",
9
+ NotificationDeleted = "pacitude.prod.notification.deleted",
10
+ AuditCreated = "pacitude.prod.audit.created",
11
+ AuditUpdated = "pacitude.prod.audit.updated",
12
+ AuditDeleted = "pacitude.prod.audit.deleted",
13
+ KYCCreated = "pacitude.prod.kyc.created",
14
+ KYCUpdated = "pacitude.prod.kyc.updated",
15
+ AssetCreated = "pacitude.prod.asset.created",
16
+ AssetUpdated = "pacitude.prod.asset.updated",
17
+ AssetDeleted = "pacitude.prod.asset.deleted",
18
+ BankCreated = "pacitude.prod.bank.created",
19
+ BankUpdated = "pacitude.prod.bank.updated",
20
+ BankDeleted = "pacitude.prod.bank.deleted",
21
+ CoinCreated = "pacitude.prod.coin.created",
22
+ CoinUpdated = "pacitude.prod.coin.updated",
23
+ CoinDeleted = "pacitude.prod.coin.deleted",
24
+ LanguageCreated = "pacitude.prod.lang.created",
25
+ LanguageUpdated = "pacitude.prod.lang.updated",
26
+ LanguageDeleted = "pacitude.prod.lang.deleted",
27
+ ComplianceUpdated = "pacitude.prod.compliance.updated"
28
+ }
29
+ export declare enum STGSubjects {
30
+ UserCreated = "pacitude.staging.user.created",
31
+ UserUpdated = "pacitude.staging.user.updated",
32
+ UserDeleted = "pacitude.staging.user.deleted",
33
+ CountryFound = "pacitude.staging.country.found",
34
+ LocationSaved = "pacitude.staging.location.saved",
35
+ NotificationCreated = "pacitude.staging.notification.created",
36
+ NotificationUpdated = "pacitude.staging.notification.updated",
37
+ NotificationDeleted = "pacitude.staging.notification.deleted",
38
+ AuditCreated = "pacitude.staging.audit.created",
39
+ AuditUpdated = "pacitude.staging.audit.updated",
40
+ AuditDeleted = "pacitude.staging.audit.deleted",
41
+ KYCCreated = "pacitude.staging.kyc.created",
42
+ KYCUpdated = "pacitude.staging.kyc.updated",
43
+ AssetCreated = "pacitude.staging.asset.created",
44
+ AssetUpdated = "pacitude.staging.asset.updated",
45
+ AssetDeleted = "pacitude.staging.asset.deleted",
46
+ BankCreated = "pacitude.staging.bank.created",
47
+ BankUpdated = "pacitude.staging.bank.updated",
48
+ BankDeleted = "pacitude.staging.bank.deleted",
49
+ CoinCreated = "pacitude.staging.coin.created",
50
+ CoinUpdated = "pacitude.staging.coin.updated",
51
+ CoinDeleted = "pacitude.staging.coin.deleted",
52
+ LanguageCreated = "pacitude.staging.lang.created",
53
+ LanguageUpdated = "pacitude.staging.lang.updated",
54
+ LanguageDeleted = "pacitude.staging.lang.deleted",
55
+ ComplianceUpdated = "pacitude.staging.compliance.updated"
56
+ }
57
+ export declare enum DEVSubjects {
58
+ UserCreated = "pacitude.development.user.created",
59
+ UserUpdated = "pacitude.development.user.updated",
60
+ UserDeleted = "pacitude.development.user.deleted",
61
+ CountryFound = "pacitude.development.country.found",
62
+ LocationSaved = "pacitude.development.location.saved",
63
+ NotificationCreated = "pacitude.development.notification.created",
64
+ NotificationUpdated = "pacitude.development.notification.updated",
65
+ NotificationDeleted = "pacitude.development.notification.deleted",
66
+ AuditCreated = "pacitude.development.audit.created",
67
+ AuditUpdated = "pacitude.development.audit.updated",
68
+ AuditDeleted = "pacitude.development.audit.deleted",
69
+ KYCCreated = "pacitude.development.kyc.created",
70
+ KYCUpdated = "pacitude.development.kyc.updated",
71
+ AssetCreated = "pacitude.development.asset.created",
72
+ AssetUpdated = "pacitude.development.asset.updated",
73
+ AssetDeleted = "pacitude.development.asset.deleted",
74
+ BankCreated = "pacitude.development.bank.created",
75
+ BankUpdated = "pacitude.development.bank.updated",
76
+ BankDeleted = "pacitude.development.bank.deleted",
77
+ CoinCreated = "pacitude.development.coin.created",
78
+ CoinUpdated = "pacitude.development.coin.updated",
79
+ CoinDeleted = "pacitude.development.coin.deleted",
80
+ LanguageCreated = "pacitude.development.lang.created",
81
+ LanguageUpdated = "pacitude.development.lang.updated",
82
+ LanguageDeleted = "pacitude.development.lang.deleted",
83
+ ComplianceUpdated = "pacitude.development.compliance.updated"
84
+ }
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEVSubjects = exports.STGSubjects = exports.Subjects = void 0;
4
+ // subject enums
5
+ var Subjects;
6
+ (function (Subjects) {
7
+ Subjects["UserCreated"] = "pacitude.prod.user.created";
8
+ Subjects["UserUpdated"] = "pacitude.prod.user.updated";
9
+ Subjects["UserDeleted"] = "pacitude.prod.user.deleted";
10
+ Subjects["CountryFound"] = "pacitude.prod.country.found";
11
+ Subjects["LocationSaved"] = "pacitude.prod.location.saved";
12
+ Subjects["NotificationCreated"] = "pacitude.prod.notification.created";
13
+ Subjects["NotificationUpdated"] = "pacitude.prod.notification.updated";
14
+ Subjects["NotificationDeleted"] = "pacitude.prod.notification.deleted";
15
+ Subjects["AuditCreated"] = "pacitude.prod.audit.created";
16
+ Subjects["AuditUpdated"] = "pacitude.prod.audit.updated";
17
+ Subjects["AuditDeleted"] = "pacitude.prod.audit.deleted";
18
+ Subjects["KYCCreated"] = "pacitude.prod.kyc.created";
19
+ Subjects["KYCUpdated"] = "pacitude.prod.kyc.updated";
20
+ Subjects["AssetCreated"] = "pacitude.prod.asset.created";
21
+ Subjects["AssetUpdated"] = "pacitude.prod.asset.updated";
22
+ Subjects["AssetDeleted"] = "pacitude.prod.asset.deleted";
23
+ Subjects["BankCreated"] = "pacitude.prod.bank.created";
24
+ Subjects["BankUpdated"] = "pacitude.prod.bank.updated";
25
+ Subjects["BankDeleted"] = "pacitude.prod.bank.deleted";
26
+ Subjects["CoinCreated"] = "pacitude.prod.coin.created";
27
+ Subjects["CoinUpdated"] = "pacitude.prod.coin.updated";
28
+ Subjects["CoinDeleted"] = "pacitude.prod.coin.deleted";
29
+ Subjects["LanguageCreated"] = "pacitude.prod.lang.created";
30
+ Subjects["LanguageUpdated"] = "pacitude.prod.lang.updated";
31
+ Subjects["LanguageDeleted"] = "pacitude.prod.lang.deleted";
32
+ Subjects["ComplianceUpdated"] = "pacitude.prod.compliance.updated";
33
+ })(Subjects = exports.Subjects || (exports.Subjects = {}));
34
+ var STGSubjects;
35
+ (function (STGSubjects) {
36
+ STGSubjects["UserCreated"] = "pacitude.staging.user.created";
37
+ STGSubjects["UserUpdated"] = "pacitude.staging.user.updated";
38
+ STGSubjects["UserDeleted"] = "pacitude.staging.user.deleted";
39
+ STGSubjects["CountryFound"] = "pacitude.staging.country.found";
40
+ STGSubjects["LocationSaved"] = "pacitude.staging.location.saved";
41
+ STGSubjects["NotificationCreated"] = "pacitude.staging.notification.created";
42
+ STGSubjects["NotificationUpdated"] = "pacitude.staging.notification.updated";
43
+ STGSubjects["NotificationDeleted"] = "pacitude.staging.notification.deleted";
44
+ STGSubjects["AuditCreated"] = "pacitude.staging.audit.created";
45
+ STGSubjects["AuditUpdated"] = "pacitude.staging.audit.updated";
46
+ STGSubjects["AuditDeleted"] = "pacitude.staging.audit.deleted";
47
+ STGSubjects["KYCCreated"] = "pacitude.staging.kyc.created";
48
+ STGSubjects["KYCUpdated"] = "pacitude.staging.kyc.updated";
49
+ STGSubjects["AssetCreated"] = "pacitude.staging.asset.created";
50
+ STGSubjects["AssetUpdated"] = "pacitude.staging.asset.updated";
51
+ STGSubjects["AssetDeleted"] = "pacitude.staging.asset.deleted";
52
+ STGSubjects["BankCreated"] = "pacitude.staging.bank.created";
53
+ STGSubjects["BankUpdated"] = "pacitude.staging.bank.updated";
54
+ STGSubjects["BankDeleted"] = "pacitude.staging.bank.deleted";
55
+ STGSubjects["CoinCreated"] = "pacitude.staging.coin.created";
56
+ STGSubjects["CoinUpdated"] = "pacitude.staging.coin.updated";
57
+ STGSubjects["CoinDeleted"] = "pacitude.staging.coin.deleted";
58
+ STGSubjects["LanguageCreated"] = "pacitude.staging.lang.created";
59
+ STGSubjects["LanguageUpdated"] = "pacitude.staging.lang.updated";
60
+ STGSubjects["LanguageDeleted"] = "pacitude.staging.lang.deleted";
61
+ STGSubjects["ComplianceUpdated"] = "pacitude.staging.compliance.updated";
62
+ })(STGSubjects = exports.STGSubjects || (exports.STGSubjects = {}));
63
+ var DEVSubjects;
64
+ (function (DEVSubjects) {
65
+ DEVSubjects["UserCreated"] = "pacitude.development.user.created";
66
+ DEVSubjects["UserUpdated"] = "pacitude.development.user.updated";
67
+ DEVSubjects["UserDeleted"] = "pacitude.development.user.deleted";
68
+ DEVSubjects["CountryFound"] = "pacitude.development.country.found";
69
+ DEVSubjects["LocationSaved"] = "pacitude.development.location.saved";
70
+ DEVSubjects["NotificationCreated"] = "pacitude.development.notification.created";
71
+ DEVSubjects["NotificationUpdated"] = "pacitude.development.notification.updated";
72
+ DEVSubjects["NotificationDeleted"] = "pacitude.development.notification.deleted";
73
+ DEVSubjects["AuditCreated"] = "pacitude.development.audit.created";
74
+ DEVSubjects["AuditUpdated"] = "pacitude.development.audit.updated";
75
+ DEVSubjects["AuditDeleted"] = "pacitude.development.audit.deleted";
76
+ DEVSubjects["KYCCreated"] = "pacitude.development.kyc.created";
77
+ DEVSubjects["KYCUpdated"] = "pacitude.development.kyc.updated";
78
+ DEVSubjects["AssetCreated"] = "pacitude.development.asset.created";
79
+ DEVSubjects["AssetUpdated"] = "pacitude.development.asset.updated";
80
+ DEVSubjects["AssetDeleted"] = "pacitude.development.asset.deleted";
81
+ DEVSubjects["BankCreated"] = "pacitude.development.bank.created";
82
+ DEVSubjects["BankUpdated"] = "pacitude.development.bank.updated";
83
+ DEVSubjects["BankDeleted"] = "pacitude.development.bank.deleted";
84
+ DEVSubjects["CoinCreated"] = "pacitude.development.coin.created";
85
+ DEVSubjects["CoinUpdated"] = "pacitude.development.coin.updated";
86
+ DEVSubjects["CoinDeleted"] = "pacitude.development.coin.deleted";
87
+ DEVSubjects["LanguageCreated"] = "pacitude.development.lang.created";
88
+ DEVSubjects["LanguageUpdated"] = "pacitude.development.lang.updated";
89
+ DEVSubjects["LanguageDeleted"] = "pacitude.development.lang.deleted";
90
+ DEVSubjects["ComplianceUpdated"] = "pacitude.development.compliance.updated";
91
+ })(DEVSubjects = exports.DEVSubjects || (exports.DEVSubjects = {}));
@@ -0,0 +1,35 @@
1
+ import { Channel, ConsumeMessage } from 'amqplib';
2
+ interface IConsumer {
3
+ channel: Channel | null;
4
+ exchange: string;
5
+ queueName: string;
6
+ router: string;
7
+ listen(): Promise<any>;
8
+ }
9
+ declare class Consumer implements IConsumer {
10
+ channel: Channel | null;
11
+ exchange: any;
12
+ queueName: any;
13
+ router: any;
14
+ constructor(channel: Channel | null);
15
+ /**
16
+ * @name listen
17
+ * @param data
18
+ * @param log
19
+ * @returns
20
+ */
21
+ listen(log?: boolean): Promise<any>;
22
+ /**
23
+ * @name parseMessage
24
+ * @param message
25
+ * @returns
26
+ */
27
+ private parseMessage;
28
+ /**
29
+ * @name onMessage
30
+ * @param data
31
+ * @param message
32
+ */
33
+ onMessage(data: object, message: ConsumeMessage): void;
34
+ }
35
+ export default Consumer;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // rabbitMQ consumer class
4
+ class Consumer {
5
+ channel = null;
6
+ exchange;
7
+ queueName;
8
+ router;
9
+ constructor(channel) {
10
+ this.channel = channel;
11
+ }
12
+ /**
13
+ * @name listen
14
+ * @param data
15
+ * @param log
16
+ * @returns
17
+ */
18
+ listen(log = true) {
19
+ return new Promise(async (resolve, reject) => {
20
+ if (this.channel) {
21
+ try {
22
+ // Assert a queue to ensure it exists.
23
+ await this.channel.assertExchange(this.exchange, 'direct', {
24
+ durable: true, // The queue will survive a broker restart,
25
+ });
26
+ // Assert a queue to ensure it exists.
27
+ const conQueue = await this.channel.assertQueue(this.queueName, {
28
+ durable: true,
29
+ autoDelete: false
30
+ });
31
+ // bind the queue to the exchange
32
+ await this.channel.bindQueue(conQueue.queue, this.exchange, this.router);
33
+ // consume message
34
+ // noAck means you want to acknowledge manually
35
+ this.channel.consume(conQueue.queue, (message) => {
36
+ if (message) {
37
+ if (log === true) {
38
+ console.log(`Message recieved from ${this.exchange}/${this.queueName}`);
39
+ }
40
+ const parsed = this.parseMessage(message);
41
+ this.onMessage(parsed, message);
42
+ // ack() the message manually in the sub-class
43
+ }
44
+ }, { noAck: false });
45
+ resolve();
46
+ }
47
+ catch (error) {
48
+ reject(`Error consuming message:, ${error}`);
49
+ }
50
+ }
51
+ else {
52
+ reject('channel does not exist');
53
+ }
54
+ });
55
+ }
56
+ /**
57
+ * @name parseMessage
58
+ * @param message
59
+ * @returns
60
+ */
61
+ parseMessage(message) {
62
+ const data = message.content.toString('utf8');
63
+ return JSON.parse(data);
64
+ }
65
+ /**
66
+ * @name onMessage
67
+ * @param data
68
+ * @param message
69
+ */
70
+ onMessage(data, message) {
71
+ // this menthod is intended to be implemented by a sub-class
72
+ }
73
+ }
74
+ exports.default = Consumer;
@@ -0,0 +1,36 @@
1
+ export declare enum Exchanges {
2
+ NotifyEmail = "pacitude.prod.notify.email",
3
+ NotifySMS = "pacitude.prod.notify.sms",
4
+ WelcomeEmail = "pacitude.prod.welcome.email",
5
+ SendOTPEmail = "pacitude.prod.send.otp.email",
6
+ SendOTPSMS = "pacitude.prod.send.otp.sms",
7
+ ComplianceUpdated = "pacitude.prod.compliance.updated.email",
8
+ EmailSent = "pacitude.prod.email.sent",
9
+ SMSSent = "pacitude.prod.sms.sent",
10
+ NotifyCreate = "pacitude.prod.notify.create",
11
+ NotifyRead = "pacitude.prod.notify.read"
12
+ }
13
+ export declare enum STGSExchanges {
14
+ NotifyEmail = "pacitude.staging.notify.email",
15
+ NotifySMS = "pacitude.staging.notify.sms",
16
+ WelcomeEmail = "pacitude.staging.welcome.email",
17
+ SendOTPEmail = "pacitude.staging.send.otp.email",
18
+ SendOTPSMS = "pacitude.staging.send.otp.sms",
19
+ ComplianceUpdated = "pacitude.staging.compliance.updated.email",
20
+ EmailSent = "pacitude.staging.email.sent",
21
+ SMSSent = "pacitude.staging.sms.sent",
22
+ NotifyCreate = "pacitude.staging.notify.create",
23
+ NotifyRead = "pacitude.staging.notify.read"
24
+ }
25
+ export declare enum DEVExchanges {
26
+ NotifyEmail = "pacitude.dev.notify.email",
27
+ NotifySMS = "pacitude.dev.notify.sms",
28
+ WelcomeEmail = "pacitude.dev.welcome.email",
29
+ SendOTPEmail = "pacitude.dev.send.otp.email",
30
+ SendOTPSMS = "pacitude.dev.send.otp.sms",
31
+ ComplianceUpdated = "pacitude.dev.compliance.updated.email",
32
+ EmailSent = "pacitude.dev.email.sent",
33
+ SMSSent = "pacitude.dev.sms.sent",
34
+ NotifyCreate = "pacitude.dev.notify.create",
35
+ NotifyRead = "pacitude.dev.notify.read"
36
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEVExchanges = exports.STGSExchanges = exports.Exchanges = void 0;
4
+ // exchange enums
5
+ var Exchanges;
6
+ (function (Exchanges) {
7
+ Exchanges["NotifyEmail"] = "pacitude.prod.notify.email";
8
+ Exchanges["NotifySMS"] = "pacitude.prod.notify.sms";
9
+ Exchanges["WelcomeEmail"] = "pacitude.prod.welcome.email";
10
+ Exchanges["SendOTPEmail"] = "pacitude.prod.send.otp.email";
11
+ Exchanges["SendOTPSMS"] = "pacitude.prod.send.otp.sms";
12
+ Exchanges["ComplianceUpdated"] = "pacitude.prod.compliance.updated.email";
13
+ Exchanges["EmailSent"] = "pacitude.prod.email.sent";
14
+ Exchanges["SMSSent"] = "pacitude.prod.sms.sent";
15
+ Exchanges["NotifyCreate"] = "pacitude.prod.notify.create";
16
+ Exchanges["NotifyRead"] = "pacitude.prod.notify.read";
17
+ })(Exchanges = exports.Exchanges || (exports.Exchanges = {}));
18
+ var STGSExchanges;
19
+ (function (STGSExchanges) {
20
+ STGSExchanges["NotifyEmail"] = "pacitude.staging.notify.email";
21
+ STGSExchanges["NotifySMS"] = "pacitude.staging.notify.sms";
22
+ STGSExchanges["WelcomeEmail"] = "pacitude.staging.welcome.email";
23
+ STGSExchanges["SendOTPEmail"] = "pacitude.staging.send.otp.email";
24
+ STGSExchanges["SendOTPSMS"] = "pacitude.staging.send.otp.sms";
25
+ STGSExchanges["ComplianceUpdated"] = "pacitude.staging.compliance.updated.email";
26
+ STGSExchanges["EmailSent"] = "pacitude.staging.email.sent";
27
+ STGSExchanges["SMSSent"] = "pacitude.staging.sms.sent";
28
+ STGSExchanges["NotifyCreate"] = "pacitude.staging.notify.create";
29
+ STGSExchanges["NotifyRead"] = "pacitude.staging.notify.read";
30
+ })(STGSExchanges = exports.STGSExchanges || (exports.STGSExchanges = {}));
31
+ var DEVExchanges;
32
+ (function (DEVExchanges) {
33
+ DEVExchanges["NotifyEmail"] = "pacitude.dev.notify.email";
34
+ DEVExchanges["NotifySMS"] = "pacitude.dev.notify.sms";
35
+ DEVExchanges["WelcomeEmail"] = "pacitude.dev.welcome.email";
36
+ DEVExchanges["SendOTPEmail"] = "pacitude.dev.send.otp.email";
37
+ DEVExchanges["SendOTPSMS"] = "pacitude.dev.send.otp.sms";
38
+ DEVExchanges["ComplianceUpdated"] = "pacitude.dev.compliance.updated.email";
39
+ DEVExchanges["EmailSent"] = "pacitude.dev.email.sent";
40
+ DEVExchanges["SMSSent"] = "pacitude.dev.sms.sent";
41
+ DEVExchanges["NotifyCreate"] = "pacitude.dev.notify.create";
42
+ DEVExchanges["NotifyRead"] = "pacitude.dev.notify.read";
43
+ })(DEVExchanges = exports.DEVExchanges || (exports.DEVExchanges = {}));
@@ -0,0 +1,17 @@
1
+ import { Channel } from 'amqplib';
2
+ interface IProducer {
3
+ channel: Channel | null;
4
+ exchange: string;
5
+ queueName: string;
6
+ router: string;
7
+ publish(data: object): Promise<any>;
8
+ }
9
+ declare class Producer implements IProducer {
10
+ channel: Channel | null;
11
+ exchange: any;
12
+ queueName: any;
13
+ router: any;
14
+ constructor(channel: Channel | null);
15
+ publish(data: object, log?: boolean): Promise<any>;
16
+ }
17
+ export default Producer;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // rabbitMQ producer class
4
+ class Producer {
5
+ channel = null;
6
+ exchange;
7
+ queueName;
8
+ router;
9
+ constructor(channel) {
10
+ this.channel = channel;
11
+ }
12
+ publish(data, log = true) {
13
+ return new Promise(async (resolve, reject) => {
14
+ if (this.channel) {
15
+ try {
16
+ // Assert a queue to ensure it exists.
17
+ await this.channel.assertExchange(this.exchange, 'direct', { durable: true });
18
+ // Publish the message to the queue
19
+ const sent = this.channel.publish(this.exchange, this.router, Buffer.from(JSON.stringify(data)), { persistent: true });
20
+ if (sent) {
21
+ if (log) {
22
+ console.log(`Message sent to ${this.exchange}`);
23
+ }
24
+ }
25
+ else {
26
+ reject('Failed to send message. Queue is full or connection is down.');
27
+ }
28
+ resolve();
29
+ }
30
+ catch (error) {
31
+ reject(`Error sending message:, ${error}`);
32
+ }
33
+ }
34
+ else {
35
+ reject('channel does not exist');
36
+ }
37
+ });
38
+ }
39
+ }
40
+ exports.default = Producer;
@@ -0,0 +1,11 @@
1
+ import { SentcompLikely, SentcompPattern } from "../utils/types.util";
2
+ export interface ISentCompDTO {
3
+ text1: string;
4
+ text2: string;
5
+ pattern: SentcompPattern;
6
+ }
7
+ export interface ISentCompResultDTO {
8
+ score: number;
9
+ likely: SentcompLikely;
10
+ message: string;
11
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,29 @@
1
+ /** Abstract Class Listener
2
+ *
3
+ * @class Listener
4
+ *
5
+ */
6
+ import nats, { Stan } from 'node-nats-streaming';
7
+ import { Subjects, STGSubjects } from './subjects.ev';
8
+ interface IListener {
9
+ subject: Subjects | STGSubjects;
10
+ client: Stan;
11
+ _ackwait: number;
12
+ queueGroupName: any;
13
+ subscriptionOptions(): any;
14
+ onMessage(data: object, message: any): void;
15
+ parseMessage(message: any): object;
16
+ listen(): void;
17
+ }
18
+ declare class Listener implements IListener {
19
+ subject: any;
20
+ queueGroupName: any;
21
+ client: Stan;
22
+ _ackwait: number;
23
+ constructor(client: Stan);
24
+ subscriptionOptions(): nats.SubscriptionOptions;
25
+ listen(log?: boolean): void;
26
+ parseMessage(message: any): object;
27
+ onMessage(data: object, message: any): void;
28
+ }
29
+ export default Listener;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ /** Abstract Class Listener
3
+ *
4
+ * @class Listener
5
+ *
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ class Listener {
9
+ subject;
10
+ queueGroupName;
11
+ client;
12
+ _ackwait = 1 * 1000;
13
+ constructor(client) {
14
+ this.client = client;
15
+ }
16
+ subscriptionOptions() {
17
+ return this.client
18
+ .subscriptionOptions()
19
+ .setDeliverAllAvailable()
20
+ .setManualAckMode(true)
21
+ .setAckWait(this._ackwait)
22
+ .setStartAtTimeDelta(1 * 1000) // starting at a specific amount of time in the past
23
+ .setDurableName(this.queueGroupName);
24
+ }
25
+ listen(log = true) {
26
+ // create the subscription
27
+ const subscription = this.client.subscribe(this.subject, this.queueGroupName, this.subscriptionOptions());
28
+ subscription.on('message', (msg) => {
29
+ if (log === true) {
30
+ console.log(`Message recieved from ${this.subject}/${this.queueGroupName}`);
31
+ }
32
+ const parsedData = this.parseMessage(msg);
33
+ this.onMessage(parsedData, msg);
34
+ });
35
+ }
36
+ parseMessage(message) {
37
+ const data = message.getData();
38
+ return typeof (data) === 'string'
39
+ ? JSON.parse(data)
40
+ : JSON.parse(data.toString('utf8'));
41
+ }
42
+ onMessage(data, message) { }
43
+ }
44
+ exports.default = Listener;
@@ -0,0 +1,19 @@
1
+ /** Abstract Class Publisher
2
+ *
3
+ * @class Publisher
4
+ *
5
+ */
6
+ import { Stan } from 'node-nats-streaming';
7
+ import { Subjects, STGSubjects } from './subjects.ev';
8
+ interface IPublisher {
9
+ subject: Subjects | STGSubjects;
10
+ client: Stan;
11
+ publish(data: object): Promise<any>;
12
+ }
13
+ declare class Publisher implements IPublisher {
14
+ subject: any;
15
+ client: Stan;
16
+ constructor(client: Stan);
17
+ publish(data: object | any, log?: boolean): Promise<any>;
18
+ }
19
+ export default Publisher;