@btffamily/chekaam 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 (52) 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 +54 -0
  10. package/build/brokers/rabbitMQ/exchanges.js +61 -0
  11. package/build/brokers/rabbitMQ/producer.d.ts +17 -0
  12. package/build/brokers/rabbitMQ/producer.js +40 -0
  13. package/build/dtos/auth.dto.d.ts +5 -0
  14. package/build/dtos/auth.dto.js +2 -0
  15. package/build/dtos/word.dto.d.ts +11 -0
  16. package/build/dtos/word.dto.js +2 -0
  17. package/build/index.d.ts +15 -0
  18. package/build/index.js +110 -0
  19. package/build/middleware/async.mw.d.ts +3 -0
  20. package/build/middleware/async.mw.js +4 -0
  21. package/build/middleware/auth.mw.d.ts +4 -0
  22. package/build/middleware/auth.mw.js +91 -0
  23. package/build/middleware/db.mw.d.ts +6 -0
  24. package/build/middleware/db.mw.js +43 -0
  25. package/build/middleware/redis.mw.d.ts +19 -0
  26. package/build/middleware/redis.mw.js +28 -0
  27. package/build/middleware/role.mw.d.ts +4 -0
  28. package/build/middleware/role.mw.js +19 -0
  29. package/build/services/auth.service.d.ts +13 -0
  30. package/build/services/auth.service.js +37 -0
  31. package/build/services/mongo.service.d.ts +7 -0
  32. package/build/services/mongo.service.js +14 -0
  33. package/build/services/random.service.d.ts +8 -0
  34. package/build/services/random.service.js +30 -0
  35. package/build/services/word.service.d.ts +8 -0
  36. package/build/services/word.service.js +73 -0
  37. package/build/src/ca-certificate.crt +32 -0
  38. package/build/src/index.ts +196 -0
  39. package/build/utils/cache.util.d.ts +3 -0
  40. package/build/utils/cache.util.js +7 -0
  41. package/build/utils/encryption.util.d.ts +66 -0
  42. package/build/utils/encryption.util.js +208 -0
  43. package/build/utils/functions.util.d.ts +134 -0
  44. package/build/utils/functions.util.js +1039 -0
  45. package/build/utils/interfaces.util.d.ts +25 -0
  46. package/build/utils/interfaces.util.js +2 -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
  52. package/readme.md +0 -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 = "vacebook.prod.user.created",
3
+ UserUpdated = "vacebook.prod.user.updated",
4
+ UserDeleted = "vacebook.prod.user.deleted",
5
+ CountryFound = "vacebook.prod.country.found",
6
+ LocationSaved = "vacebook.prod.location.saved",
7
+ NotificationCreated = "vacebook.prod.notification.created",
8
+ NotificationUpdated = "vacebook.prod.notification.updated",
9
+ NotificationDeleted = "vacebook.prod.notification.deleted",
10
+ AuditCreated = "vacebook.prod.audit.created",
11
+ AuditUpdated = "vacebook.prod.audit.updated",
12
+ AuditDeleted = "vacebook.prod.audit.deleted",
13
+ KYCCreated = "vacebook.prod.kyc.created",
14
+ KYCUpdated = "vacebook.prod.kyc.updated",
15
+ AssetCreated = "vacebook.prod.asset.created",
16
+ AssetUpdated = "vacebook.prod.asset.updated",
17
+ AssetDeleted = "vacebook.prod.asset.deleted",
18
+ BankCreated = "vacebook.prod.bank.created",
19
+ BankUpdated = "vacebook.prod.bank.updated",
20
+ BankDeleted = "vacebook.prod.bank.deleted",
21
+ CoinCreated = "vacebook.prod.coin.created",
22
+ CoinUpdated = "vacebook.prod.coin.updated",
23
+ CoinDeleted = "vacebook.prod.coin.deleted",
24
+ LanguageCreated = "vacebook.prod.lang.created",
25
+ LanguageUpdated = "vacebook.prod.lang.updated",
26
+ LanguageDeleted = "vacebook.prod.lang.deleted",
27
+ ComplianceUpdated = "vacebook.prod.compliance.updated"
28
+ }
29
+ export declare enum STGSubjects {
30
+ UserCreated = "vacebook.staging.user.created",
31
+ UserUpdated = "vacebook.staging.user.updated",
32
+ UserDeleted = "vacebook.staging.user.deleted",
33
+ CountryFound = "vacebook.staging.country.found",
34
+ LocationSaved = "vacebook.staging.location.saved",
35
+ NotificationCreated = "vacebook.staging.notification.created",
36
+ NotificationUpdated = "vacebook.staging.notification.updated",
37
+ NotificationDeleted = "vacebook.staging.notification.deleted",
38
+ AuditCreated = "vacebook.staging.audit.created",
39
+ AuditUpdated = "vacebook.staging.audit.updated",
40
+ AuditDeleted = "vacebook.staging.audit.deleted",
41
+ KYCCreated = "vacebook.staging.kyc.created",
42
+ KYCUpdated = "vacebook.staging.kyc.updated",
43
+ AssetCreated = "vacebook.staging.asset.created",
44
+ AssetUpdated = "vacebook.staging.asset.updated",
45
+ AssetDeleted = "vacebook.staging.asset.deleted",
46
+ BankCreated = "vacebook.staging.bank.created",
47
+ BankUpdated = "vacebook.staging.bank.updated",
48
+ BankDeleted = "vacebook.staging.bank.deleted",
49
+ CoinCreated = "vacebook.staging.coin.created",
50
+ CoinUpdated = "vacebook.staging.coin.updated",
51
+ CoinDeleted = "vacebook.staging.coin.deleted",
52
+ LanguageCreated = "vacebook.staging.lang.created",
53
+ LanguageUpdated = "vacebook.staging.lang.updated",
54
+ LanguageDeleted = "vacebook.staging.lang.deleted",
55
+ ComplianceUpdated = "vacebook.staging.compliance.updated"
56
+ }
57
+ export declare enum DEVSubjects {
58
+ UserCreated = "vacebook.development.user.created",
59
+ UserUpdated = "vacebook.development.user.updated",
60
+ UserDeleted = "vacebook.development.user.deleted",
61
+ CountryFound = "vacebook.development.country.found",
62
+ LocationSaved = "vacebook.development.location.saved",
63
+ NotificationCreated = "vacebook.development.notification.created",
64
+ NotificationUpdated = "vacebook.development.notification.updated",
65
+ NotificationDeleted = "vacebook.development.notification.deleted",
66
+ AuditCreated = "vacebook.development.audit.created",
67
+ AuditUpdated = "vacebook.development.audit.updated",
68
+ AuditDeleted = "vacebook.development.audit.deleted",
69
+ KYCCreated = "vacebook.development.kyc.created",
70
+ KYCUpdated = "vacebook.development.kyc.updated",
71
+ AssetCreated = "vacebook.development.asset.created",
72
+ AssetUpdated = "vacebook.development.asset.updated",
73
+ AssetDeleted = "vacebook.development.asset.deleted",
74
+ BankCreated = "vacebook.development.bank.created",
75
+ BankUpdated = "vacebook.development.bank.updated",
76
+ BankDeleted = "vacebook.development.bank.deleted",
77
+ CoinCreated = "vacebook.development.coin.created",
78
+ CoinUpdated = "vacebook.development.coin.updated",
79
+ CoinDeleted = "vacebook.development.coin.deleted",
80
+ LanguageCreated = "vacebook.development.lang.created",
81
+ LanguageUpdated = "vacebook.development.lang.updated",
82
+ LanguageDeleted = "vacebook.development.lang.deleted",
83
+ ComplianceUpdated = "vacebook.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"] = "vacebook.prod.user.created";
8
+ Subjects["UserUpdated"] = "vacebook.prod.user.updated";
9
+ Subjects["UserDeleted"] = "vacebook.prod.user.deleted";
10
+ Subjects["CountryFound"] = "vacebook.prod.country.found";
11
+ Subjects["LocationSaved"] = "vacebook.prod.location.saved";
12
+ Subjects["NotificationCreated"] = "vacebook.prod.notification.created";
13
+ Subjects["NotificationUpdated"] = "vacebook.prod.notification.updated";
14
+ Subjects["NotificationDeleted"] = "vacebook.prod.notification.deleted";
15
+ Subjects["AuditCreated"] = "vacebook.prod.audit.created";
16
+ Subjects["AuditUpdated"] = "vacebook.prod.audit.updated";
17
+ Subjects["AuditDeleted"] = "vacebook.prod.audit.deleted";
18
+ Subjects["KYCCreated"] = "vacebook.prod.kyc.created";
19
+ Subjects["KYCUpdated"] = "vacebook.prod.kyc.updated";
20
+ Subjects["AssetCreated"] = "vacebook.prod.asset.created";
21
+ Subjects["AssetUpdated"] = "vacebook.prod.asset.updated";
22
+ Subjects["AssetDeleted"] = "vacebook.prod.asset.deleted";
23
+ Subjects["BankCreated"] = "vacebook.prod.bank.created";
24
+ Subjects["BankUpdated"] = "vacebook.prod.bank.updated";
25
+ Subjects["BankDeleted"] = "vacebook.prod.bank.deleted";
26
+ Subjects["CoinCreated"] = "vacebook.prod.coin.created";
27
+ Subjects["CoinUpdated"] = "vacebook.prod.coin.updated";
28
+ Subjects["CoinDeleted"] = "vacebook.prod.coin.deleted";
29
+ Subjects["LanguageCreated"] = "vacebook.prod.lang.created";
30
+ Subjects["LanguageUpdated"] = "vacebook.prod.lang.updated";
31
+ Subjects["LanguageDeleted"] = "vacebook.prod.lang.deleted";
32
+ Subjects["ComplianceUpdated"] = "vacebook.prod.compliance.updated";
33
+ })(Subjects = exports.Subjects || (exports.Subjects = {}));
34
+ var STGSubjects;
35
+ (function (STGSubjects) {
36
+ STGSubjects["UserCreated"] = "vacebook.staging.user.created";
37
+ STGSubjects["UserUpdated"] = "vacebook.staging.user.updated";
38
+ STGSubjects["UserDeleted"] = "vacebook.staging.user.deleted";
39
+ STGSubjects["CountryFound"] = "vacebook.staging.country.found";
40
+ STGSubjects["LocationSaved"] = "vacebook.staging.location.saved";
41
+ STGSubjects["NotificationCreated"] = "vacebook.staging.notification.created";
42
+ STGSubjects["NotificationUpdated"] = "vacebook.staging.notification.updated";
43
+ STGSubjects["NotificationDeleted"] = "vacebook.staging.notification.deleted";
44
+ STGSubjects["AuditCreated"] = "vacebook.staging.audit.created";
45
+ STGSubjects["AuditUpdated"] = "vacebook.staging.audit.updated";
46
+ STGSubjects["AuditDeleted"] = "vacebook.staging.audit.deleted";
47
+ STGSubjects["KYCCreated"] = "vacebook.staging.kyc.created";
48
+ STGSubjects["KYCUpdated"] = "vacebook.staging.kyc.updated";
49
+ STGSubjects["AssetCreated"] = "vacebook.staging.asset.created";
50
+ STGSubjects["AssetUpdated"] = "vacebook.staging.asset.updated";
51
+ STGSubjects["AssetDeleted"] = "vacebook.staging.asset.deleted";
52
+ STGSubjects["BankCreated"] = "vacebook.staging.bank.created";
53
+ STGSubjects["BankUpdated"] = "vacebook.staging.bank.updated";
54
+ STGSubjects["BankDeleted"] = "vacebook.staging.bank.deleted";
55
+ STGSubjects["CoinCreated"] = "vacebook.staging.coin.created";
56
+ STGSubjects["CoinUpdated"] = "vacebook.staging.coin.updated";
57
+ STGSubjects["CoinDeleted"] = "vacebook.staging.coin.deleted";
58
+ STGSubjects["LanguageCreated"] = "vacebook.staging.lang.created";
59
+ STGSubjects["LanguageUpdated"] = "vacebook.staging.lang.updated";
60
+ STGSubjects["LanguageDeleted"] = "vacebook.staging.lang.deleted";
61
+ STGSubjects["ComplianceUpdated"] = "vacebook.staging.compliance.updated";
62
+ })(STGSubjects = exports.STGSubjects || (exports.STGSubjects = {}));
63
+ var DEVSubjects;
64
+ (function (DEVSubjects) {
65
+ DEVSubjects["UserCreated"] = "vacebook.development.user.created";
66
+ DEVSubjects["UserUpdated"] = "vacebook.development.user.updated";
67
+ DEVSubjects["UserDeleted"] = "vacebook.development.user.deleted";
68
+ DEVSubjects["CountryFound"] = "vacebook.development.country.found";
69
+ DEVSubjects["LocationSaved"] = "vacebook.development.location.saved";
70
+ DEVSubjects["NotificationCreated"] = "vacebook.development.notification.created";
71
+ DEVSubjects["NotificationUpdated"] = "vacebook.development.notification.updated";
72
+ DEVSubjects["NotificationDeleted"] = "vacebook.development.notification.deleted";
73
+ DEVSubjects["AuditCreated"] = "vacebook.development.audit.created";
74
+ DEVSubjects["AuditUpdated"] = "vacebook.development.audit.updated";
75
+ DEVSubjects["AuditDeleted"] = "vacebook.development.audit.deleted";
76
+ DEVSubjects["KYCCreated"] = "vacebook.development.kyc.created";
77
+ DEVSubjects["KYCUpdated"] = "vacebook.development.kyc.updated";
78
+ DEVSubjects["AssetCreated"] = "vacebook.development.asset.created";
79
+ DEVSubjects["AssetUpdated"] = "vacebook.development.asset.updated";
80
+ DEVSubjects["AssetDeleted"] = "vacebook.development.asset.deleted";
81
+ DEVSubjects["BankCreated"] = "vacebook.development.bank.created";
82
+ DEVSubjects["BankUpdated"] = "vacebook.development.bank.updated";
83
+ DEVSubjects["BankDeleted"] = "vacebook.development.bank.deleted";
84
+ DEVSubjects["CoinCreated"] = "vacebook.development.coin.created";
85
+ DEVSubjects["CoinUpdated"] = "vacebook.development.coin.updated";
86
+ DEVSubjects["CoinDeleted"] = "vacebook.development.coin.deleted";
87
+ DEVSubjects["LanguageCreated"] = "vacebook.development.lang.created";
88
+ DEVSubjects["LanguageUpdated"] = "vacebook.development.lang.updated";
89
+ DEVSubjects["LanguageDeleted"] = "vacebook.development.lang.deleted";
90
+ DEVSubjects["ComplianceUpdated"] = "vacebook.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,54 @@
1
+ export declare enum Exchanges {
2
+ NotifyEmail = "fieldos.prod.notify.email",
3
+ NotifySMS = "fieldos.prod.notify.sms",
4
+ WelcomeEmail = "fieldos.prod.welcome.email",
5
+ SendOTPEmail = "fieldos.prod.send.otp.email",
6
+ SendOTPSMS = "fieldos.prod.send.otp.sms",
7
+ ComplianceUpdated = "fieldos.prod.compliance.updated.email",
8
+ EmailSent = "fieldos.prod.email.sent",
9
+ SMSSent = "fieldos.prod.sms.sent",
10
+ NotifyCreate = "fieldos.prod.notify.create",
11
+ NotifyRead = "fieldos.prod.notify.read",
12
+ SaleCreated = "fieldos.prod.sale.created",
13
+ SaleUpdated = "fieldos.prod.sale.updated",
14
+ SalePaymentRecorded = "fieldos.prod.sale.payment.recorded",
15
+ ExpenseCreated = "fieldos.prod.expense.created",
16
+ ExpenseUpdated = "fieldos.prod.expense.updated",
17
+ ExpenseLinked = "fieldos.prod.expense.linked"
18
+ }
19
+ export declare enum STGSExchanges {
20
+ NotifyEmail = "fieldos.staging.notify.email",
21
+ NotifySMS = "fieldos.staging.notify.sms",
22
+ WelcomeEmail = "fieldos.staging.welcome.email",
23
+ SendOTPEmail = "fieldos.staging.send.otp.email",
24
+ SendOTPSMS = "fieldos.staging.send.otp.sms",
25
+ ComplianceUpdated = "fieldos.staging.compliance.updated.email",
26
+ EmailSent = "fieldos.staging.email.sent",
27
+ SMSSent = "fieldos.staging.sms.sent",
28
+ NotifyCreate = "fieldos.staging.notify.create",
29
+ NotifyRead = "fieldos.staging.notify.read",
30
+ SaleCreated = "fieldos.staging.sale.created",
31
+ SaleUpdated = "fieldos.staging.sale.updated",
32
+ SalePaymentRecorded = "fieldos.staging.sale.payment.recorded",
33
+ ExpenseCreated = "fieldos.staging.expense.created",
34
+ ExpenseUpdated = "fieldos.staging.expense.updated",
35
+ ExpenseLinked = "fieldos.staging.expense.linked"
36
+ }
37
+ export declare enum DEVExchanges {
38
+ NotifyEmail = "fieldos.dev.notify.email",
39
+ NotifySMS = "fieldos.dev.notify.sms",
40
+ WelcomeEmail = "fieldos.dev.welcome.email",
41
+ SendOTPEmail = "fieldos.dev.send.otp.email",
42
+ SendOTPSMS = "fieldos.dev.send.otp.sms",
43
+ ComplianceUpdated = "fieldos.dev.compliance.updated.email",
44
+ EmailSent = "fieldos.dev.email.sent",
45
+ SMSSent = "fieldos.dev.sms.sent",
46
+ NotifyCreate = "fieldos.dev.notify.create",
47
+ NotifyRead = "fieldos.dev.notify.read",
48
+ SaleCreated = "fieldos.dev.sale.created",
49
+ SaleUpdated = "fieldos.dev.sale.updated",
50
+ SalePaymentRecorded = "fieldos.dev.sale.payment.recorded",
51
+ ExpenseCreated = "fieldos.dev.expense.created",
52
+ ExpenseUpdated = "fieldos.dev.expense.updated",
53
+ ExpenseLinked = "fieldos.dev.expense.linked"
54
+ }
@@ -0,0 +1,61 @@
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"] = "fieldos.prod.notify.email";
8
+ Exchanges["NotifySMS"] = "fieldos.prod.notify.sms";
9
+ Exchanges["WelcomeEmail"] = "fieldos.prod.welcome.email";
10
+ Exchanges["SendOTPEmail"] = "fieldos.prod.send.otp.email";
11
+ Exchanges["SendOTPSMS"] = "fieldos.prod.send.otp.sms";
12
+ Exchanges["ComplianceUpdated"] = "fieldos.prod.compliance.updated.email";
13
+ Exchanges["EmailSent"] = "fieldos.prod.email.sent";
14
+ Exchanges["SMSSent"] = "fieldos.prod.sms.sent";
15
+ Exchanges["NotifyCreate"] = "fieldos.prod.notify.create";
16
+ Exchanges["NotifyRead"] = "fieldos.prod.notify.read";
17
+ Exchanges["SaleCreated"] = "fieldos.prod.sale.created";
18
+ Exchanges["SaleUpdated"] = "fieldos.prod.sale.updated";
19
+ Exchanges["SalePaymentRecorded"] = "fieldos.prod.sale.payment.recorded";
20
+ Exchanges["ExpenseCreated"] = "fieldos.prod.expense.created";
21
+ Exchanges["ExpenseUpdated"] = "fieldos.prod.expense.updated";
22
+ Exchanges["ExpenseLinked"] = "fieldos.prod.expense.linked";
23
+ })(Exchanges = exports.Exchanges || (exports.Exchanges = {}));
24
+ var STGSExchanges;
25
+ (function (STGSExchanges) {
26
+ STGSExchanges["NotifyEmail"] = "fieldos.staging.notify.email";
27
+ STGSExchanges["NotifySMS"] = "fieldos.staging.notify.sms";
28
+ STGSExchanges["WelcomeEmail"] = "fieldos.staging.welcome.email";
29
+ STGSExchanges["SendOTPEmail"] = "fieldos.staging.send.otp.email";
30
+ STGSExchanges["SendOTPSMS"] = "fieldos.staging.send.otp.sms";
31
+ STGSExchanges["ComplianceUpdated"] = "fieldos.staging.compliance.updated.email";
32
+ STGSExchanges["EmailSent"] = "fieldos.staging.email.sent";
33
+ STGSExchanges["SMSSent"] = "fieldos.staging.sms.sent";
34
+ STGSExchanges["NotifyCreate"] = "fieldos.staging.notify.create";
35
+ STGSExchanges["NotifyRead"] = "fieldos.staging.notify.read";
36
+ STGSExchanges["SaleCreated"] = "fieldos.staging.sale.created";
37
+ STGSExchanges["SaleUpdated"] = "fieldos.staging.sale.updated";
38
+ STGSExchanges["SalePaymentRecorded"] = "fieldos.staging.sale.payment.recorded";
39
+ STGSExchanges["ExpenseCreated"] = "fieldos.staging.expense.created";
40
+ STGSExchanges["ExpenseUpdated"] = "fieldos.staging.expense.updated";
41
+ STGSExchanges["ExpenseLinked"] = "fieldos.staging.expense.linked";
42
+ })(STGSExchanges = exports.STGSExchanges || (exports.STGSExchanges = {}));
43
+ var DEVExchanges;
44
+ (function (DEVExchanges) {
45
+ DEVExchanges["NotifyEmail"] = "fieldos.dev.notify.email";
46
+ DEVExchanges["NotifySMS"] = "fieldos.dev.notify.sms";
47
+ DEVExchanges["WelcomeEmail"] = "fieldos.dev.welcome.email";
48
+ DEVExchanges["SendOTPEmail"] = "fieldos.dev.send.otp.email";
49
+ DEVExchanges["SendOTPSMS"] = "fieldos.dev.send.otp.sms";
50
+ DEVExchanges["ComplianceUpdated"] = "fieldos.dev.compliance.updated.email";
51
+ DEVExchanges["EmailSent"] = "fieldos.dev.email.sent";
52
+ DEVExchanges["SMSSent"] = "fieldos.dev.sms.sent";
53
+ DEVExchanges["NotifyCreate"] = "fieldos.dev.notify.create";
54
+ DEVExchanges["NotifyRead"] = "fieldos.dev.notify.read";
55
+ DEVExchanges["SaleCreated"] = "fieldos.dev.sale.created";
56
+ DEVExchanges["SaleUpdated"] = "fieldos.dev.sale.updated";
57
+ DEVExchanges["SalePaymentRecorded"] = "fieldos.dev.sale.payment.recorded";
58
+ DEVExchanges["ExpenseCreated"] = "fieldos.dev.expense.created";
59
+ DEVExchanges["ExpenseUpdated"] = "fieldos.dev.expense.updated";
60
+ DEVExchanges["ExpenseLinked"] = "fieldos.dev.expense.linked";
61
+ })(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,5 @@
1
+ export interface VerifyJWTDTO {
2
+ token: string;
3
+ secret: string;
4
+ isApiKey: boolean;
5
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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,15 @@
1
+ import asyncHandler from './middleware/async.mw';
2
+ import { protect, authorize, permit } from './middleware/auth.mw';
3
+ import { Subjects, STGSubjects, DEVSubjects } from './brokers/nats/subjects.ev';
4
+ import { Exchanges, STGSExchanges, DEVExchanges } from './brokers/rabbitMQ/exchanges';
5
+ import Publisher from './brokers/nats/publisher.ev';
6
+ import Listener from './brokers/nats/publisher.ev';
7
+ import Consumer from './brokers/rabbitMQ/consumer';
8
+ import Producer from './brokers/rabbitMQ/producer';
9
+ import Random from './services/random.service';
10
+ import Mongo from './services/mongo.service';
11
+ import Encryption from './utils/encryption.util';
12
+ import { SyncAction, SyncType, SyncNotify, IDateToday, IDatesSplit, IMonthsSplit, DateCompare } from './utils/types.util';
13
+ import { IPermitOptions, IRedisConnOptions, IRedisData, IVerifyJWT } from './utils/interfaces.util';
14
+ import { isObject, isString, isArray, strToArray, strToArrayEs6, strIncludes, strIncludesEs6, arrayIncludes, arrayIncludesEs6, listIncludes, timeToMinutes, rangeFromMinutes, dateToWord, dateToWordRaw, leadingNum, dateToday, isEmptyObject, convertUrlToBase64, urlToBase64, sortData, rearrangeArray, isObjectId, isPos, isNeg, isNumber, isZero, checkDateFormat, checkTimeFormat, dateIsToday, dateIsYesterday, dateIsEqual, generate, notDefined, UIID, compareISODate, getWeeksDates, getDatesInRange, getWeeksInMonth, validateBase64, getCodeFromName, getDaysFromDates, lastDayOfMonth, firstDayOfMonth, isBase64, getBase64Mime, daysOfWeek, monthsOfYear, capitalize, isPrecise, hasDecimal, formatISO, hasSAC, toDecimal, charLen, wordLen, slugit, isDefined, objectToArray, isJson, arrayToObject, formatDate, arrayToSingleObject, dateIsPast, dateIsFuture, yesterdayFromDate, daysFromDates, enumToArray, stringToBase64, base64ToString, dateFromWeekNumber, weekStartDate, weekEndDate, toMongoId, pickFrom } from './utils/functions.util';
15
+ export { Subjects, Publisher, Listener, STGSubjects, DEVSubjects, Consumer, Producer, Exchanges, STGSExchanges, DEVExchanges, SyncAction, SyncType, SyncNotify, Random, Mongo, asyncHandler, protect, authorize, permit, IPermitOptions, IRedisConnOptions, IRedisData, IVerifyJWT, IDateToday, IDatesSplit, IMonthsSplit, DateCompare, Encryption, isObject, isObjectId, isPos, isNeg, isNumber, isString, isArray, isBase64, getBase64Mime, strToArray, strToArrayEs6, strIncludes, strIncludesEs6, arrayIncludes, arrayIncludesEs6, listIncludes, timeToMinutes, rangeFromMinutes, dateToWord, dateToWordRaw, leadingNum, formatDate, dateToday, isEmptyObject, convertUrlToBase64, urlToBase64, sortData, rearrangeArray, isZero, checkDateFormat, checkTimeFormat, dateIsToday, dateIsYesterday, dateIsEqual, dateIsPast, dateIsFuture, yesterdayFromDate, generate, notDefined, isDefined, UIID, compareISODate, getWeeksDates, getDatesInRange, getWeeksInMonth, validateBase64, getCodeFromName, getDaysFromDates, lastDayOfMonth, firstDayOfMonth, daysOfWeek, monthsOfYear, capitalize, isPrecise, hasDecimal, toDecimal, formatISO, hasSAC, charLen, wordLen, slugit, objectToArray, isJson, arrayToObject, arrayToSingleObject, enumToArray, stringToBase64, base64ToString, dateFromWeekNumber, daysFromDates, weekStartDate, weekEndDate, toMongoId, pickFrom };