@aldb2b/common 1.0.145 → 1.0.148

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 (32) hide show
  1. package/build/events/exchanges.d.ts +4 -0
  2. package/build/events/exchanges.js +9 -0
  3. package/build/events/exchanges.js.map +1 -0
  4. package/build/events/subjects.d.ts +17 -3
  5. package/build/events/subjects.js +16 -2
  6. package/build/events/subjects.js.map +1 -1
  7. package/build/index.d.ts +3 -0
  8. package/build/index.js +3 -0
  9. package/build/index.js.map +1 -1
  10. package/build/tsconfig.tsbuildinfo +184 -4
  11. package/build/utils/get-parsed-query.d.ts +1 -0
  12. package/build/utils/get-parsed-query.js +18 -0
  13. package/build/utils/get-parsed-query.js.map +1 -0
  14. package/build/utils/rmq/client/rabbitmq.client.d.ts +29 -0
  15. package/build/utils/rmq/client/rabbitmq.client.js +162 -0
  16. package/build/utils/rmq/client/rabbitmq.client.js.map +1 -0
  17. package/build/utils/rmq/constants.d.ts +9 -0
  18. package/build/utils/rmq/constants.js +13 -0
  19. package/build/utils/rmq/constants.js.map +1 -0
  20. package/build/utils/rmq/ctx-host/rmq.context.d.ts +9 -0
  21. package/build/utils/rmq/ctx-host/rmq.context.js +20 -0
  22. package/build/utils/rmq/ctx-host/rmq.context.js.map +1 -0
  23. package/build/utils/rmq/index.d.ts +4 -0
  24. package/build/utils/rmq/index.js +10 -0
  25. package/build/utils/rmq/index.js.map +1 -0
  26. package/build/utils/rmq/interfaces/rmq-options.interfaces.d.ts +79 -0
  27. package/build/utils/rmq/interfaces/rmq-options.interfaces.js +12 -0
  28. package/build/utils/rmq/interfaces/rmq-options.interfaces.js.map +1 -0
  29. package/build/utils/rmq/server/rabbitmq.server.d.ts +19 -0
  30. package/build/utils/rmq/server/rabbitmq.server.js +114 -0
  31. package/build/utils/rmq/server/rabbitmq.server.js.map +1 -0
  32. package/package.json +1 -1
@@ -0,0 +1,4 @@
1
+ export declare enum Exchanges {
2
+ TOPIC_EXCHANGE = "default_topic_exchange",
3
+ FANOUT_EXCHANGE = "default_fanout_exchange"
4
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Exchanges = void 0;
4
+ var Exchanges;
5
+ (function (Exchanges) {
6
+ Exchanges["TOPIC_EXCHANGE"] = "default_topic_exchange";
7
+ Exchanges["FANOUT_EXCHANGE"] = "default_fanout_exchange";
8
+ })(Exchanges = exports.Exchanges || (exports.Exchanges = {}));
9
+ //# sourceMappingURL=exchanges.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exchanges.js","sourceRoot":"","sources":["../../src/events/exchanges.ts"],"names":[],"mappings":";;;AAAA,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,sDAAyC,CAAA;IACzC,wDAA2C,CAAA;AAC7C,CAAC,EAHW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAGpB"}
@@ -14,8 +14,8 @@ export declare enum Subjects {
14
14
  UpdateUserEventInfo = "user:updateEventInfo",
15
15
  CompanyAccessibility = "companyAccessibility",
16
16
  SendEmails = "sendEmails",
17
- CreateContact = "contact:created",
18
- CreateCompany = "company:created",
17
+ CreateContact = "create:contact",
18
+ CreateCompany = "create:company",
19
19
  CreateCompanySetting = "comapnySetting:created",
20
20
  UpdateCompanySetting = "comapnySetting:updated",
21
21
  ContactsBySearch = "contactsBySearch",
@@ -43,5 +43,19 @@ export declare enum Subjects {
43
43
  ReceivedOrderCRM = "receivedOrder:crm",
44
44
  AddCompanyCRM = "addCompany:crm",
45
45
  AddContactCRM = "addContact:crm",
46
- TableByIdEventTopic = "tableByIdEventTopic"
46
+ TableByIdEventTopic = "tableByIdEventTopic",
47
+ CompanyCreated = "company:created",
48
+ CompanyUpdated = "company:updated",
49
+ ProductCreated = "product:created",
50
+ ProductUpdated = "product:updated",
51
+ ContactCreated = "contact:created",
52
+ ContactUpdated = "contact:updated",
53
+ ServiceCreated = "service:created",
54
+ ServiceUpdated = "service:updated",
55
+ EventCreated = "event:created",
56
+ EventUpdated = "event:updated",
57
+ RFQCreated = "rfq:created",
58
+ RFQUpdated = "rfq:updated",
59
+ QuotationCreated = "quotation:created",
60
+ QuotationUpdated = "quotation:updated"
47
61
  }
@@ -18,8 +18,8 @@ var Subjects;
18
18
  Subjects["UpdateUserEventInfo"] = "user:updateEventInfo";
19
19
  Subjects["CompanyAccessibility"] = "companyAccessibility";
20
20
  Subjects["SendEmails"] = "sendEmails";
21
- Subjects["CreateContact"] = "contact:created";
22
- Subjects["CreateCompany"] = "company:created";
21
+ Subjects["CreateContact"] = "create:contact";
22
+ Subjects["CreateCompany"] = "create:company";
23
23
  Subjects["CreateCompanySetting"] = "comapnySetting:created";
24
24
  Subjects["UpdateCompanySetting"] = "comapnySetting:updated";
25
25
  Subjects["ContactsBySearch"] = "contactsBySearch";
@@ -48,5 +48,19 @@ var Subjects;
48
48
  Subjects["AddCompanyCRM"] = "addCompany:crm";
49
49
  Subjects["AddContactCRM"] = "addContact:crm";
50
50
  Subjects["TableByIdEventTopic"] = "tableByIdEventTopic";
51
+ Subjects["CompanyCreated"] = "company:created";
52
+ Subjects["CompanyUpdated"] = "company:updated";
53
+ Subjects["ProductCreated"] = "product:created";
54
+ Subjects["ProductUpdated"] = "product:updated";
55
+ Subjects["ContactCreated"] = "contact:created";
56
+ Subjects["ContactUpdated"] = "contact:updated";
57
+ Subjects["ServiceCreated"] = "service:created";
58
+ Subjects["ServiceUpdated"] = "service:updated";
59
+ Subjects["EventCreated"] = "event:created";
60
+ Subjects["EventUpdated"] = "event:updated";
61
+ Subjects["RFQCreated"] = "rfq:created";
62
+ Subjects["RFQUpdated"] = "rfq:updated";
63
+ Subjects["QuotationCreated"] = "quotation:created";
64
+ Subjects["QuotationUpdated"] = "quotation:updated";
51
65
  })(Subjects = exports.Subjects || (exports.Subjects = {}));
52
66
  //# sourceMappingURL=subjects.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"subjects.js","sourceRoot":"","sources":["../../src/events/subjects.ts"],"names":[],"mappings":";;;AAAA,IAAY,QA8CX;AA9CD,WAAY,QAAQ;IAClB,yCAA6B,CAAA;IAC7B,mCAAuB,CAAA;IACvB,4CAAgC,CAAA;IAChC,iCAAqB,CAAA;IACrB,uCAA2B,CAAA;IAC3B,+CAAmC,CAAA;IACnC,+CAAmC,CAAA;IACnC,6CAAiC,CAAA;IACjC,4CAAgC,CAAA;IAChC,4CAAgC,CAAA;IAChC,gDAAoC,CAAA;IACpC,4DAAgD,CAAA;IAChD,wDAA4C,CAAA;IAC5C,yDAA6C,CAAA;IAC7C,qCAAyB,CAAA;IACzB,6CAAiC,CAAA;IACjC,6CAAiC,CAAA;IACjC,2DAA+C,CAAA;IAC/C,2DAA+C,CAAA;IAC/C,iDAAqC,CAAA;IACrC,mDAAuC,CAAA;IACvC,mDAAuC,CAAA;IACvC,yCAA6B,CAAA;IAC7B,2DAA+C,CAAA;IAC/C,yCAA6B,CAAA;IAC7B,2CAA+B,CAAA;IAC/B,oDAAwC,CAAA;IACxC,mDAAuC,CAAA;IACvC,mDAAuC,CAAA;IACvC,iEAAqD,CAAA;IACrD,yCAA6B,CAAA;IAC7B,8DAAkD,CAAA;IAClD,iDAAqC,CAAA;IACrC,yCAA6B,CAAA;IAC7B,kDAAsC,CAAA;IACtC,kDAAsC,CAAA;IACtC,0CAA8B,CAAA;IAC9B,0CAA8B,CAAA;IAC9B,sDAA0C,CAAA;IAC1C,0DAA8C,CAAA;IAC9C,8CAAkC,CAAA;IAClC,kDAAsC,CAAA;IACtC,4CAAgC,CAAA;IAChC,4CAAgC,CAAA;IAChC,uDAA2C,CAAA;AAC7C,CAAC,EA9CW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QA8CnB"}
1
+ {"version":3,"file":"subjects.js","sourceRoot":"","sources":["../../src/events/subjects.ts"],"names":[],"mappings":";;;AAAA,IAAY,QA4DX;AA5DD,WAAY,QAAQ;IAClB,yCAA6B,CAAA;IAC7B,mCAAuB,CA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,KAAR,gBAAQ,QA4DnB"}
package/build/index.d.ts CHANGED
@@ -46,6 +46,7 @@ export * from './events/rfq-update-crm.interface';
46
46
  export * from './events/update-meeting-crm.interface';
47
47
  export * from './events/get-table-event-topic.interface';
48
48
  export * from './events/get-meeting-request-by-query.interface';
49
+ export * from './events/exchanges';
49
50
  export * from './validators/conditional-required';
50
51
  export * from './validators/date-validator';
51
52
  export * from './validators/validateNewItem';
@@ -99,3 +100,5 @@ export * from './utils/parse-query';
99
100
  export * from './utils/projection';
100
101
  export * from './utils/timezone';
101
102
  export * from './utils/adjustForTimezone';
103
+ export * from './utils/get-parsed-query';
104
+ export * from './utils/rmq/index';
package/build/index.js CHANGED
@@ -58,6 +58,7 @@ __exportStar(require("./events/rfq-update-crm.interface"), exports);
58
58
  __exportStar(require("./events/update-meeting-crm.interface"), exports);
59
59
  __exportStar(require("./events/get-table-event-topic.interface"), exports);
60
60
  __exportStar(require("./events/get-meeting-request-by-query.interface"), exports);
61
+ __exportStar(require("./events/exchanges"), exports);
61
62
  __exportStar(require("./validators/conditional-required"), exports);
62
63
  __exportStar(require("./validators/date-validator"), exports);
63
64
  __exportStar(require("./validators/validateNewItem"), exports);
@@ -111,4 +112,6 @@ __exportStar(require("./utils/parse-query"), exports);
111
112
  __exportStar(require("./utils/projection"), exports);
112
113
  __exportStar(require("./utils/timezone"), exports);
113
114
  __exportStar(require("./utils/adjustForTimezone"), exports);
115
+ __exportStar(require("./utils/get-parsed-query"), exports);
116
+ __exportStar(require("./utils/rmq/index"), exports);
114
117
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAiC;AACjC,iEAA8C;AAC9C,mEAAgD;AAChD,+DAA4C;AAC5C,oEAAiD;AACjD,qEAAkD;AAClD,oEAAiD;AACjD,sEAAmD;AACnD,6EAA0D;AAC1D,uEAAoD;AACpD,sEAAmD;AACnD,6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AAkD;AAClD,6DAA0C;AAC1C,uDAAoC;AACpC,sDAAmC;AACnC,qDAAkC;AAClC,mDAAgC;AAChC,4DAAyC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAiC;AACjC,iEAA8C;AAC9C,mEAAgD;AAChD,+DAA4C;AAC5C,oEAAiD;AACjD,qEAAkD;AAClD,oEAAiD;AACjD,sEAAmD;AACnD,6EAA0D;AAC1D,uEAAoD;AACpD,sEAAmD;AACnD,6EAA0D;AAC1D,2EAAwD;AACxD,4EAAyD;AACzD,iEAA8C;AAC9C,4EAAyD;AACzD,4EAAyD;AACzD,wEAAqD;AACrD,yEAAsD;AACtD,yEAAsD;AACtD,oEAAiD;AACjD,6EAA0D;AAC1D,2EAAwD;AACxD,8EAA2D;AAC3D,mEAAgD;AAChD,oEAAiD;AACjD,oEAAiD;AACjD,oEAAiD;AACjD,wEAAqD;AACrD,2EAAwD;AACxD,0EAAuD;AACvD,mEAAgD;AAChD,kDAA+B;AAC/B,oEAAiD;AACjD,2EAAwD;AACxD,oEAAiD;AACjD,qEAAkD;AAClD,qEAAkD;AAClD,wEAAqD;AACrD,sEAAmD;AACnD,0EAAuD;AACvD,wEAAqD;AACrD,4EAAyD;AACzD,oEAAiD;AACjD,oEAAiD;AACjD,wEAAqD;AACrD,2EAAwD;AACxD,kFAA+D;AAC/D,qDAAkC;AAElC,oEAAiD;AACjD,8DAA2C;AAC3C,+DAA4C;AAC5C,kEAA+C;AAC/C,wEAAqD;AACrD,kEAA+C;AAC/C,gFAA6D;AAC7D,+DAA4C;AAC5C,yEAAsD;AACtD,mFAAgE;AAChE,iFAA8D;AAC9D,iEAA8C;AAC9C,2EAAwD;AAExD,kEAA+C;AAC/C,sEAAmD;AAEnD,sEAAmD;AACnD,uEAAoD;AAEpD,mDAAgC;AAChC,oDAAiC;AACjC,6DAA0C;AAC1C,oEAAiD;AACjD,yEAAsD;AAEtD,gEAA6C;AAC7C,sEAAmD;AACnD,yDAAsC;AACtC,yDAAsC;AACtC,gEAA6C;AAC7C,yEAAsD;AACtD,2EAAwD;AACxD,4DAAyC;AACzC,0EAAuD;AACvD,0DAAuC;AACvC,gEAA6C;AAC7C,0DAAuC;AACvC,qEAAkD;AAClD,qEAAkD;AAClD,uEAAoD;AACpD,mEAAgD;AAChD,+DAA4C;AAC5C,uEAAoD;AACpD,qEAAkD;AAClD,kEAA+C;AAC/C,oEAAiD;AACjD,iEAA8C;AAE9C,+DAA4C;AAC5C,sEAAmD;AAEnD,qEAAkD;AAClD,6DAA0C;AAC1C,uDAAoC;AACpC,sDAAmC;AACnC,qDAAkC;AAClC,mDAAgC;AAChC,4DAAyC;AACzC,2DAAwC;AACxC,oDAAiC"}
@@ -162,8 +162,8 @@
162
162
  "affectsGlobalScope": false
163
163
  },
164
164
  "../src/events/subjects.ts": {
165
- "version": "92abb38eb961bc1bd6972eac796dd32f32bf04efebe05e0f2ebcb2b436b4a643",
166
- "signature": "d3954b768c9c64c7e589204d2bfb2ed0fb042a5ded200b46161181bba70eb38b",
165
+ "version": "0ba82eb10068552862ca2e6b7b15d210664ee413793150606eb3b5837f226e39",
166
+ "signature": "dc47f82566bf4873ca308a48adfcff4b259e73f699923ff34ee9fbbe28332479",
167
167
  "affectsGlobalScope": false
168
168
  },
169
169
  "../src/events/email-specs.interface.ts": {
@@ -456,6 +456,11 @@
456
456
  "signature": "81ec79934d502db54296825b532dcc0b0e6218857c6b1b60fd286af21da436a8",
457
457
  "affectsGlobalScope": false
458
458
  },
459
+ "../src/events/exchanges.ts": {
460
+ "version": "743fc12eafc6647756cc56bc57c2a5573988c90a42cc197d6031b292491a60c6",
461
+ "signature": "5b1d183287d8fa30787af2d3d69eb1e62cd3325022d10290a3105df283689d25",
462
+ "affectsGlobalScope": false
463
+ },
459
464
  "../node_modules/class-validator/types/validation/ValidationError.d.ts": {
460
465
  "version": "e69d0b59db23f59172cb087ee44a71438f809bd214d4f4105abd6090b341cbdc",
461
466
  "signature": "e69d0b59db23f59172cb087ee44a71438f809bd214d4f4105abd6090b341cbdc",
@@ -6166,9 +6171,74 @@
6166
6171
  "signature": "86fd5e9fe517c2373ee0aece1aae67bd811961244ff42d2ef2d8a81706840f9e",
6167
6172
  "affectsGlobalScope": false
6168
6173
  },
6174
+ "../src/utils/get-parsed-query.ts": {
6175
+ "version": "464d25000000548bd8d7d4be9f7021bfcdd2ceefe043d102bb1ce5d7ded3a8c4",
6176
+ "signature": "5bbe89480f01c11af5cc8a7d5a7b19f5da5252d42f0545bc78b09667bac236c9",
6177
+ "affectsGlobalScope": false
6178
+ },
6179
+ "../node_modules/promise-breaker/index.d.ts": {
6180
+ "version": "9502e5c54e212283b1662c7a72e98d5e206ca983a486e0c87434dedc573546d7",
6181
+ "signature": "9502e5c54e212283b1662c7a72e98d5e206ca983a486e0c87434dedc573546d7",
6182
+ "affectsGlobalScope": false
6183
+ },
6184
+ "../node_modules/amqp-connection-manager/dist/esm/ChannelWrapper.d.ts": {
6185
+ "version": "d6e199b07cfb9d20e81eecec19629bf2f4a68d62f9a06c6903d76974133a8d36",
6186
+ "signature": "d6e199b07cfb9d20e81eecec19629bf2f4a68d62f9a06c6903d76974133a8d36",
6187
+ "affectsGlobalScope": false
6188
+ },
6189
+ "../node_modules/amqp-connection-manager/dist/esm/AmqpConnectionManager.d.ts": {
6190
+ "version": "a0ff1139ce5bf556c107b9d549b142951402d849d9ba2fd1a6bed2a4eb5908ed",
6191
+ "signature": "a0ff1139ce5bf556c107b9d549b142951402d849d9ba2fd1a6bed2a4eb5908ed",
6192
+ "affectsGlobalScope": false
6193
+ },
6194
+ "../node_modules/amqp-connection-manager/dist/esm/index.d.ts": {
6195
+ "version": "dddadc5aa34c610c0d1e7bf6980ff9368a22cc8c54f4f9a2bdbda1777d1d9d11",
6196
+ "signature": "dddadc5aa34c610c0d1e7bf6980ff9368a22cc8c54f4f9a2bdbda1777d1d9d11",
6197
+ "affectsGlobalScope": false
6198
+ },
6199
+ "../src/utils/rmq/interfaces/rmq-options.interfaces.ts": {
6200
+ "version": "25714585f2debc3cc359727b3ef1b535f6b050b4cdb78f524b4c1ef7d508b62b",
6201
+ "signature": "c622a74ac567f8edfd80085420a574990275a5d1038e00ff14d2ea597287cbae",
6202
+ "affectsGlobalScope": false
6203
+ },
6204
+ "../node_modules/@nestjs/common/utils/random-string-generator.util.d.ts": {
6205
+ "version": "e39f001766868e22c7e0d988c4029e1cb1e096e92289366000e39b03b98b684b",
6206
+ "signature": "e39f001766868e22c7e0d988c4029e1cb1e096e92289366000e39b03b98b684b",
6207
+ "affectsGlobalScope": false
6208
+ },
6209
+ "../src/utils/rmq/constants.ts": {
6210
+ "version": "b67638e8479b4ca8e4f7be6af4dc2f2348ef455d2e9079eae4f82694dc06d0b2",
6211
+ "signature": "51e73154dbefc774d71db7864fb8464d0ea41370b5c66fbbd636bb623d890c2b",
6212
+ "affectsGlobalScope": false
6213
+ },
6214
+ "../src/utils/rmq/client/rabbitmq.client.ts": {
6215
+ "version": "5a43b4bc20fca4a96cd97d31abe0abe00ddbcf7d88a5ae2ef1c3f9b98a1e42eb",
6216
+ "signature": "3e52f48f3423f50607de09b5e54749005701f6dc4fb91565109e515e3440d17b",
6217
+ "affectsGlobalScope": false
6218
+ },
6219
+ "../node_modules/@nestjs/common/utils/shared.utils.d.ts": {
6220
+ "version": "84c601d568db7090e26283270f52965d6b49628250c65aa3d81c413b111927d4",
6221
+ "signature": "84c601d568db7090e26283270f52965d6b49628250c65aa3d81c413b111927d4",
6222
+ "affectsGlobalScope": false
6223
+ },
6224
+ "../src/utils/rmq/ctx-host/rmq.context.ts": {
6225
+ "version": "6e3c0dd786025569a339d63cb85085e17130bae7602d6179ef53d9a5e1147b59",
6226
+ "signature": "aacb2a9e7cfcfbc1dfff9858070fa64495cb676c99c171bfab13cacb15ef679e",
6227
+ "affectsGlobalScope": false
6228
+ },
6229
+ "../src/utils/rmq/server/rabbitmq.server.ts": {
6230
+ "version": "9591ac217bea24884b06a07b1eda38aebc38343533af570c26aebe9e7c4b5186",
6231
+ "signature": "f68d078ea010ecb1c154665ac2a6b45db896b304674181d493ded764d19baebd",
6232
+ "affectsGlobalScope": false
6233
+ },
6234
+ "../src/utils/rmq/index.ts": {
6235
+ "version": "e04dc3a3354847bcb07c7b1f1cab75a4bdd80ff220c83c952682efe1d50ffe0b",
6236
+ "signature": "502cfe6675020c575ef067de8cbd3485e8939d6d82e7d557c664eb83e86bdbe6",
6237
+ "affectsGlobalScope": false
6238
+ },
6169
6239
  "../src/index.ts": {
6170
- "version": "d63d3a7cd7d53a13aae34a749ebbc8bfed11eaad303f2e2ebfb798faf89d4135",
6171
- "signature": "443e9c54e0165ef60d4454ac913b9810bba8908e6c8e42e30feca1b432aaec29",
6240
+ "version": "0dd73da44f6c384b1f07c998029b0d2c3e35ca972539e75fdb19fca080f39b9f",
6241
+ "signature": "59c5a44357f02cb1ca74c7249c7fc00f02573432ce77286af70ac4d0f1e7cf95",
6172
6242
  "affectsGlobalScope": false
6173
6243
  },
6174
6244
  "../node_modules/@types/minimatch/index.d.ts": {
@@ -9231,6 +9301,23 @@
9231
9301
  "../node_modules/@types/whatwg-url/index.d.ts": [
9232
9302
  "../node_modules/@types/node/index.d.ts"
9233
9303
  ],
9304
+ "../node_modules/amqp-connection-manager/dist/esm/AmqpConnectionManager.d.ts": [
9305
+ "../node_modules/@types/node/events.d.ts",
9306
+ "../node_modules/@types/node/index.d.ts",
9307
+ "../node_modules/@types/node/net.d.ts",
9308
+ "../node_modules/@types/node/tls.d.ts",
9309
+ "../node_modules/amqp-connection-manager/dist/esm/ChannelWrapper.d.ts"
9310
+ ],
9311
+ "../node_modules/amqp-connection-manager/dist/esm/ChannelWrapper.d.ts": [
9312
+ "../node_modules/@types/node/events.d.ts",
9313
+ "../node_modules/@types/node/index.d.ts",
9314
+ "../node_modules/amqp-connection-manager/dist/esm/AmqpConnectionManager.d.ts",
9315
+ "../node_modules/promise-breaker/index.d.ts"
9316
+ ],
9317
+ "../node_modules/amqp-connection-manager/dist/esm/index.d.ts": [
9318
+ "../node_modules/amqp-connection-manager/dist/esm/AmqpConnectionManager.d.ts",
9319
+ "../node_modules/amqp-connection-manager/dist/esm/ChannelWrapper.d.ts"
9320
+ ],
9234
9321
  "../node_modules/bson/bson.d.ts": [
9235
9322
  "../node_modules/@types/node/buffer.d.ts"
9236
9323
  ],
@@ -11054,6 +11141,7 @@
11054
11141
  "../src/events/data-by-search.interface.ts",
11055
11142
  "../src/events/edit-list-users.interface.ts",
11056
11143
  "../src/events/email-specs.interface.ts",
11144
+ "../src/events/exchanges.ts",
11057
11145
  "../src/events/get-companies.interface.ts",
11058
11146
  "../src/events/get-contacts-by-query.interface.ts",
11059
11147
  "../src/events/get-event.interface.ts",
@@ -11112,8 +11200,10 @@
11112
11200
  "../src/utils/create-default-directories.ts",
11113
11201
  "../src/utils/equal-array-object.ts",
11114
11202
  "../src/utils/equal-object.ts",
11203
+ "../src/utils/get-parsed-query.ts",
11115
11204
  "../src/utils/parse-query.ts",
11116
11205
  "../src/utils/projection.ts",
11206
+ "../src/utils/rmq/index.ts",
11117
11207
  "../src/utils/timezone.ts",
11118
11208
  "../src/validators/conditional-required.ts",
11119
11209
  "../src/validators/date-validator.ts",
@@ -11173,6 +11263,37 @@
11173
11263
  "../src/utils/equal-array-object.ts": [
11174
11264
  "../src/utils/equal-object.ts"
11175
11265
  ],
11266
+ "../src/utils/rmq/client/rabbitmq.client.ts": [
11267
+ "../node_modules/@nestjs/common/index.d.ts",
11268
+ "../node_modules/@nestjs/common/utils/random-string-generator.util.d.ts",
11269
+ "../node_modules/@nestjs/microservices/index.d.ts",
11270
+ "../node_modules/@types/node/events.d.ts",
11271
+ "../node_modules/amqp-connection-manager/dist/esm/index.d.ts",
11272
+ "../node_modules/rxjs/dist/types/index.d.ts",
11273
+ "../node_modules/rxjs/dist/types/operators/index.d.ts",
11274
+ "../src/utils/rmq/constants.ts",
11275
+ "../src/utils/rmq/interfaces/rmq-options.interfaces.ts"
11276
+ ],
11277
+ "../src/utils/rmq/ctx-host/rmq.context.ts": [
11278
+ "../node_modules/@nestjs/microservices/ctx-host/base-rpc.context.d.ts"
11279
+ ],
11280
+ "../src/utils/rmq/index.ts": [
11281
+ "../src/utils/rmq/client/rabbitmq.client.ts",
11282
+ "../src/utils/rmq/interfaces/rmq-options.interfaces.ts",
11283
+ "../src/utils/rmq/server/rabbitmq.server.ts"
11284
+ ],
11285
+ "../src/utils/rmq/interfaces/rmq-options.interfaces.ts": [
11286
+ "../node_modules/@nestjs/microservices/index.d.ts",
11287
+ "../node_modules/amqp-connection-manager/dist/esm/index.d.ts"
11288
+ ],
11289
+ "../src/utils/rmq/server/rabbitmq.server.ts": [
11290
+ "../node_modules/@nestjs/common/utils/shared.utils.d.ts",
11291
+ "../node_modules/@nestjs/microservices/index.d.ts",
11292
+ "../node_modules/amqp-connection-manager/dist/esm/index.d.ts",
11293
+ "../src/utils/rmq/constants.ts",
11294
+ "../src/utils/rmq/ctx-host/rmq.context.ts",
11295
+ "../src/utils/rmq/interfaces/rmq-options.interfaces.ts"
11296
+ ],
11176
11297
  "../src/validators/conditional-required.ts": [
11177
11298
  "../node_modules/class-validator/types/index.d.ts"
11178
11299
  ],
@@ -14201,6 +14322,23 @@
14201
14322
  "../node_modules/@types/whatwg-url/index.d.ts": [
14202
14323
  "../node_modules/@types/node/index.d.ts"
14203
14324
  ],
14325
+ "../node_modules/amqp-connection-manager/dist/esm/AmqpConnectionManager.d.ts": [
14326
+ "../node_modules/@types/node/events.d.ts",
14327
+ "../node_modules/@types/node/index.d.ts",
14328
+ "../node_modules/@types/node/net.d.ts",
14329
+ "../node_modules/@types/node/tls.d.ts",
14330
+ "../node_modules/amqp-connection-manager/dist/esm/ChannelWrapper.d.ts"
14331
+ ],
14332
+ "../node_modules/amqp-connection-manager/dist/esm/ChannelWrapper.d.ts": [
14333
+ "../node_modules/@types/node/events.d.ts",
14334
+ "../node_modules/@types/node/index.d.ts",
14335
+ "../node_modules/amqp-connection-manager/dist/esm/AmqpConnectionManager.d.ts",
14336
+ "../node_modules/promise-breaker/index.d.ts"
14337
+ ],
14338
+ "../node_modules/amqp-connection-manager/dist/esm/index.d.ts": [
14339
+ "../node_modules/amqp-connection-manager/dist/esm/AmqpConnectionManager.d.ts",
14340
+ "../node_modules/amqp-connection-manager/dist/esm/ChannelWrapper.d.ts"
14341
+ ],
14204
14342
  "../node_modules/bson/bson.d.ts": [
14205
14343
  "../node_modules/@types/node/buffer.d.ts"
14206
14344
  ],
@@ -16010,6 +16148,7 @@
16010
16148
  "../src/events/data-by-search.interface.ts",
16011
16149
  "../src/events/edit-list-users.interface.ts",
16012
16150
  "../src/events/email-specs.interface.ts",
16151
+ "../src/events/exchanges.ts",
16013
16152
  "../src/events/get-companies.interface.ts",
16014
16153
  "../src/events/get-contacts-by-query.interface.ts",
16015
16154
  "../src/events/get-event.interface.ts",
@@ -16068,8 +16207,10 @@
16068
16207
  "../src/utils/create-default-directories.ts",
16069
16208
  "../src/utils/equal-array-object.ts",
16070
16209
  "../src/utils/equal-object.ts",
16210
+ "../src/utils/get-parsed-query.ts",
16071
16211
  "../src/utils/parse-query.ts",
16072
16212
  "../src/utils/projection.ts",
16213
+ "../src/utils/rmq/index.ts",
16073
16214
  "../src/utils/timezone.ts",
16074
16215
  "../src/validators/conditional-required.ts",
16075
16216
  "../src/validators/date-validator.ts",
@@ -16114,6 +16255,31 @@
16114
16255
  "../src/types/match.interface.ts": [
16115
16256
  "../src/types/match-group.interface.ts"
16116
16257
  ],
16258
+ "../src/utils/rmq/client/rabbitmq.client.ts": [
16259
+ "../node_modules/@nestjs/common/index.d.ts",
16260
+ "../node_modules/@nestjs/microservices/index.d.ts",
16261
+ "../node_modules/@types/node/events.d.ts",
16262
+ "../node_modules/amqp-connection-manager/dist/esm/index.d.ts",
16263
+ "../node_modules/rxjs/dist/types/index.d.ts",
16264
+ "../src/utils/rmq/interfaces/rmq-options.interfaces.ts"
16265
+ ],
16266
+ "../src/utils/rmq/ctx-host/rmq.context.ts": [
16267
+ "../node_modules/@nestjs/microservices/ctx-host/base-rpc.context.d.ts"
16268
+ ],
16269
+ "../src/utils/rmq/index.ts": [
16270
+ "../src/utils/rmq/client/rabbitmq.client.ts",
16271
+ "../src/utils/rmq/interfaces/rmq-options.interfaces.ts",
16272
+ "../src/utils/rmq/server/rabbitmq.server.ts"
16273
+ ],
16274
+ "../src/utils/rmq/interfaces/rmq-options.interfaces.ts": [
16275
+ "../node_modules/@nestjs/microservices/index.d.ts",
16276
+ "../node_modules/amqp-connection-manager/dist/esm/index.d.ts"
16277
+ ],
16278
+ "../src/utils/rmq/server/rabbitmq.server.ts": [
16279
+ "../node_modules/@nestjs/microservices/index.d.ts",
16280
+ "../node_modules/amqp-connection-manager/dist/esm/index.d.ts",
16281
+ "../src/utils/rmq/interfaces/rmq-options.interfaces.ts"
16282
+ ],
16117
16283
  "../src/validators/conditional-required.ts": [
16118
16284
  "../node_modules/class-validator/types/index.d.ts"
16119
16285
  ],
@@ -16283,6 +16449,8 @@
16283
16449
  "../node_modules/@nestjs/common/utils/forward-ref.util.d.ts",
16284
16450
  "../node_modules/@nestjs/common/utils/http-error-by-code.util.d.ts",
16285
16451
  "../node_modules/@nestjs/common/utils/index.d.ts",
16452
+ "../node_modules/@nestjs/common/utils/random-string-generator.util.d.ts",
16453
+ "../node_modules/@nestjs/common/utils/shared.utils.d.ts",
16286
16454
  "../node_modules/@nestjs/core/adapters/http-adapter.d.ts",
16287
16455
  "../node_modules/@nestjs/core/adapters/index.d.ts",
16288
16456
  "../node_modules/@nestjs/core/application-config.d.ts",
@@ -16891,6 +17059,9 @@
16891
17059
  "../node_modules/@types/serve-static/index.d.ts",
16892
17060
  "../node_modules/@types/webidl-conversions/index.d.ts",
16893
17061
  "../node_modules/@types/whatwg-url/index.d.ts",
17062
+ "../node_modules/amqp-connection-manager/dist/esm/AmqpConnectionManager.d.ts",
17063
+ "../node_modules/amqp-connection-manager/dist/esm/ChannelWrapper.d.ts",
17064
+ "../node_modules/amqp-connection-manager/dist/esm/index.d.ts",
16894
17065
  "../node_modules/axios/index.d.ts",
16895
17066
  "../node_modules/bson/bson.d.ts",
16896
17067
  "../node_modules/buffer/index.d.ts",
@@ -17050,6 +17221,7 @@
17050
17221
  "../node_modules/moment/ts3.1-typings/moment.d.ts",
17051
17222
  "../node_modules/mongodb/mongodb.d.ts",
17052
17223
  "../node_modules/mongoose/index.d.ts",
17224
+ "../node_modules/promise-breaker/index.d.ts",
17053
17225
  "../node_modules/redis/dist/index.d.ts",
17054
17226
  "../node_modules/reflect-metadata/index.d.ts",
17055
17227
  "../node_modules/rxjs/dist/types/index.d.ts",
@@ -17298,6 +17470,7 @@
17298
17470
  "../src/events/data-by-search.interface.ts",
17299
17471
  "../src/events/edit-list-users.interface.ts",
17300
17472
  "../src/events/email-specs.interface.ts",
17473
+ "../src/events/exchanges.ts",
17301
17474
  "../src/events/get-companies.interface.ts",
17302
17475
  "../src/events/get-contacts-by-query.interface.ts",
17303
17476
  "../src/events/get-event.interface.ts",
@@ -17357,8 +17530,15 @@
17357
17530
  "../src/utils/create-default-directories.ts",
17358
17531
  "../src/utils/equal-array-object.ts",
17359
17532
  "../src/utils/equal-object.ts",
17533
+ "../src/utils/get-parsed-query.ts",
17360
17534
  "../src/utils/parse-query.ts",
17361
17535
  "../src/utils/projection.ts",
17536
+ "../src/utils/rmq/client/rabbitmq.client.ts",
17537
+ "../src/utils/rmq/constants.ts",
17538
+ "../src/utils/rmq/ctx-host/rmq.context.ts",
17539
+ "../src/utils/rmq/index.ts",
17540
+ "../src/utils/rmq/interfaces/rmq-options.interfaces.ts",
17541
+ "../src/utils/rmq/server/rabbitmq.server.ts",
17362
17542
  "../src/utils/timezone.ts",
17363
17543
  "../src/validators/conditional-required.ts",
17364
17544
  "../src/validators/date-validator.ts",
@@ -0,0 +1 @@
1
+ export declare function getParsedQuery(filterDto: any): any;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getParsedQuery = void 0;
4
+ function getParsedQuery(filterDto) {
5
+ if (filterDto.query) {
6
+ try {
7
+ return JSON.parse(filterDto.query);
8
+ }
9
+ catch (err) {
10
+ return filterDto.query;
11
+ }
12
+ }
13
+ else {
14
+ return {};
15
+ }
16
+ }
17
+ exports.getParsedQuery = getParsedQuery;
18
+ //# sourceMappingURL=get-parsed-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-parsed-query.js","sourceRoot":"","sources":["../../src/utils/get-parsed-query.ts"],"names":[],"mappings":";;;AAAA,SAAgB,cAAc,CAAC,SAAS;IACtC,IAAI,SAAS,CAAC,KAAK,EAAE;QACnB,IAAI;YACF,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;SACnC;QAAC,OAAO,GAAG,EAAE;YACZ,OAAO,SAAS,CAAC,KAAK,CAAA;SACvB;KACF;SAAM;QACL,OAAO,EAAE,CAAA;KACV;AACH,CAAC;AAVD,wCAUC"}
@@ -0,0 +1,29 @@
1
+ /// <reference types="node" />
2
+ import { ClientProxy, ReadPacket, WritePacket } from '@nestjs/microservices';
3
+ import { AmqpConnectionManager, ChannelWrapper } from 'amqp-connection-manager';
4
+ import { ConfirmChannel } from 'amqplib';
5
+ import { EventEmitter } from 'events';
6
+ import { RMQClientOptions, RMQMessage } from '../interfaces/rmq-options.interfaces';
7
+ import { Observable } from 'rxjs';
8
+ import { Logger } from '@nestjs/common';
9
+ export declare class RabbitMQClient extends ClientProxy {
10
+ private readonly options;
11
+ protected readonly logger: Logger;
12
+ protected client: AmqpConnectionManager;
13
+ protected channel: ChannelWrapper;
14
+ protected responseEmitter: EventEmitter;
15
+ protected connection: Promise<any>;
16
+ protected replyQueue: string;
17
+ constructor(options: RMQClientOptions);
18
+ connect(): Promise<any>;
19
+ createClient(): AmqpConnectionManager;
20
+ handleRMQEvents(): void;
21
+ mergeDisconnectEvent<T = any>(instance: any, source$: Observable<T>): Observable<T>;
22
+ createChannel(): Promise<void>;
23
+ setupChannel(channel: ConfirmChannel, resolve: any): Promise<void>;
24
+ consumeChannel(): void;
25
+ protected publish(message: ReadPacket<string | RMQMessage>, callback: (packet: WritePacket) => any): any;
26
+ handleMessage(packet: unknown, callback: (packet: WritePacket) => any): Promise<void>;
27
+ protected dispatchEvent(packet: ReadPacket<string | RMQMessage>): Promise<any>;
28
+ close(): void;
29
+ }
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RabbitMQClient = void 0;
4
+ const microservices_1 = require("@nestjs/microservices");
5
+ const amqp_connection_manager_1 = require("amqp-connection-manager");
6
+ const events_1 = require("events");
7
+ const rxjs_1 = require("rxjs");
8
+ const operators_1 = require("rxjs/operators");
9
+ const common_1 = require("@nestjs/common");
10
+ const random_string_generator_util_1 = require("@nestjs/common/utils/random-string-generator.util");
11
+ const constants_1 = require("../constants");
12
+ class RabbitMQClient extends microservices_1.ClientProxy {
13
+ constructor(options) {
14
+ super();
15
+ this.options = options;
16
+ this.logger = new common_1.Logger(microservices_1.ClientProxy.name);
17
+ this.initializeSerializer(options);
18
+ this.initializeDeserializer(options);
19
+ }
20
+ connect() {
21
+ if (this.client) {
22
+ return this.connection;
23
+ }
24
+ this.client = this.createClient();
25
+ this.handleRMQEvents();
26
+ const connect$ = this.connect$(this.client);
27
+ this.connection = rxjs_1.lastValueFrom(this.mergeDisconnectEvent(this.client, connect$).pipe(operators_1.switchMap(() => this.createChannel()), operators_1.share()));
28
+ return this.connection;
29
+ }
30
+ createClient() {
31
+ const { urls, socketOptions } = this.options;
32
+ return amqp_connection_manager_1.connect(urls, socketOptions);
33
+ }
34
+ handleRMQEvents() {
35
+ this.client.on(constants_1.CONNECT_FAILED_EVENT, err => {
36
+ this.logger.error(constants_1.CONNECT_FAILED_RMQ_MESSAGE);
37
+ this.logger.error(err);
38
+ });
39
+ this.client.on(constants_1.DISCONNECT_EVENT, err => {
40
+ this.logger.error(constants_1.DISCONNECTED_RMQ_MESSAGE);
41
+ this.logger.error(err);
42
+ this.close();
43
+ });
44
+ this.client.on(constants_1.ERROR_EVENT, err => {
45
+ this.logger.error(constants_1.ERROR_RMQ_MESSAGE);
46
+ this.logger.error(err);
47
+ });
48
+ }
49
+ mergeDisconnectEvent(instance, source$) {
50
+ const close$ = rxjs_1.fromEvent(instance, constants_1.DISCONNECT_EVENT).pipe(operators_1.map((err) => {
51
+ throw err;
52
+ }));
53
+ return rxjs_1.merge(source$, close$).pipe(operators_1.first());
54
+ }
55
+ createChannel() {
56
+ return new Promise(resolve => {
57
+ this.channel = this.client.createChannel({
58
+ json: false,
59
+ setup: (channel) => this.setupChannel(channel, resolve),
60
+ });
61
+ });
62
+ }
63
+ async setupChannel(channel, resolve) {
64
+ const { replyQueue, replyQueueOptions, exchange, exchangeType, exchangeOptions, prefetchCount, isGlobalPrefetchCount, } = this.options;
65
+ await channel.assertExchange(exchange, exchangeType, exchangeOptions);
66
+ const queueOptions = replyQueueOptions !== undefined ? replyQueueOptions : { exclusive: true };
67
+ if (replyQueue !== undefined) {
68
+ this.replyQueue = replyQueue;
69
+ await channel.assertQueue(this.replyQueue, queueOptions);
70
+ }
71
+ else {
72
+ this.replyQueue = (await channel.assertQueue('', queueOptions)).queue;
73
+ }
74
+ await channel.prefetch(prefetchCount, isGlobalPrefetchCount);
75
+ this.responseEmitter = new events_1.EventEmitter();
76
+ this.responseEmitter.setMaxListeners(0);
77
+ this.consumeChannel();
78
+ resolve();
79
+ }
80
+ consumeChannel() {
81
+ const { noAck } = this.options;
82
+ this.channel.addSetup((channel) => {
83
+ channel.consume(this.replyQueue, (message) => {
84
+ this.responseEmitter.emit(message.properties.correlationId, message);
85
+ }, {
86
+ noAck: noAck !== undefined ? noAck : true,
87
+ exclusive: true,
88
+ });
89
+ });
90
+ }
91
+ publish(message, callback) {
92
+ try {
93
+ console.log('PUBLISH-------------------');
94
+ const correlationId = random_string_generator_util_1.randomStringGenerator();
95
+ const listener = ({ content }) => this.handleMessage(JSON.parse(content.toString()), callback);
96
+ const { queue } = this.options;
97
+ let messageOptions;
98
+ if (typeof message.data !== 'string') {
99
+ messageOptions = message.data.options;
100
+ message.data = message.data.content;
101
+ }
102
+ const publishOptions = Object.assign(Object.assign({ replyTo: this.replyQueue }, messageOptions), { correlationId });
103
+ const data = message.pattern.split('/');
104
+ if (data.length === 2) {
105
+ const [destination, pattern] = data;
106
+ console.log('PUBLISHED DESTINATION----------------', destination);
107
+ message.pattern = pattern;
108
+ const serializedPacket = this.serializer.serialize(message);
109
+ this.responseEmitter.on(correlationId, listener);
110
+ this.channel.sendToQueue(destination, Buffer.from(JSON.stringify(serializedPacket)), publishOptions);
111
+ }
112
+ else if (data.length === 1) {
113
+ message.pattern = data[0];
114
+ const serializedPacket = this.serializer.serialize(message);
115
+ this.responseEmitter.on(correlationId, listener);
116
+ console.log('PUBLISHED QUEUE----------------', queue);
117
+ this.channel.sendToQueue(queue, Buffer.from(JSON.stringify(serializedPacket)), publishOptions);
118
+ }
119
+ else {
120
+ throw new Error('Invalid arguments for the message pattern');
121
+ }
122
+ return () => this.responseEmitter.removeListener(correlationId, listener);
123
+ }
124
+ catch (err) {
125
+ callback({ err });
126
+ }
127
+ }
128
+ async handleMessage(packet, callback) {
129
+ const { err, response, isDisposed } = await this.deserializer.deserialize(packet);
130
+ if (isDisposed || err) {
131
+ callback({
132
+ err,
133
+ response,
134
+ isDisposed: true,
135
+ });
136
+ }
137
+ callback({
138
+ err,
139
+ response,
140
+ });
141
+ }
142
+ dispatchEvent(packet) {
143
+ let messageOptions;
144
+ if (typeof packet.data !== 'string') {
145
+ messageOptions = packet.data.options;
146
+ packet.data = packet.data.content;
147
+ }
148
+ const publishOptions = Object.assign({ persistent: true }, messageOptions);
149
+ const serializedPacket = this.serializer.serialize(packet);
150
+ const { exchange } = this.options;
151
+ console.log('INSIDE DISPATCH EVET------------------', exchange, publishOptions);
152
+ return new Promise((resolve, reject) => this.channel.publish(exchange, packet.pattern, Buffer.from(JSON.stringify(serializedPacket)), publishOptions, err => (err ? reject(err) : resolve())));
153
+ }
154
+ close() {
155
+ this.channel && this.channel.close();
156
+ this.client && this.client.close();
157
+ this.channel = null;
158
+ this.client = null;
159
+ }
160
+ }
161
+ exports.RabbitMQClient = RabbitMQClient;
162
+ //# sourceMappingURL=rabbitmq.client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rabbitmq.client.js","sourceRoot":"","sources":["../../../../src/utils/rmq/client/rabbitmq.client.ts"],"names":[],"mappings":";;;AAAA,yDAA4E;AAC5E,qEAIgC;AAEhC,mCAAqC;AAOrC,+BAAkE;AAClE,8CAA6D;AAC7D,2CAAuC;AACvC,oGAAyF;AACzF,4CAOqB;AAErB,MAAa,cAAe,SAAQ,2BAAW;IAQ7C,YAA6B,OAAyB;QACpD,KAAK,EAAE,CAAA;QADoB,YAAO,GAAP,OAAO,CAAkB;QAPnC,WAAM,GAAG,IAAI,eAAM,CAAC,2BAAW,CAAC,IAAI,CAAC,CAAA;QAStD,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAA;QAClC,IAAI,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAA;IACtC,CAAC;IAEM,OAAO;QACZ,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,OAAO,IAAI,CAAC,UAAU,CAAA;SACvB;QACD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,YAAY,EAAE,CAAA;QACjC,IAAI,CAAC,eAAe,EAAE,CAAA;QACtB,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAC3C,IAAI,CAAC,UAAU,GAAG,oBAAa,CAC7B,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,IAAI,CACnD,qBAAS,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,EACrC,iBAAK,EAAE,C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CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CACvC,CACF,CAAA;IACH,CAAC;IAEM,KAAK;QACV,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAA;QACpC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAA;QAClC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;QACnB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;IACpB,CAAC;CACF;AA7ND,wCA6NC"}
@@ -0,0 +1,9 @@
1
+ export declare const NO_MESSAGE_HANDLER = "There is no matching message handler defined in the remote service.";
2
+ export declare const CONNECT_EVENT = "connect";
3
+ export declare const CONNECTED_RMQ_MESSAGE = "Connected to RMQ Server";
4
+ export declare const DISCONNECT_EVENT = "disconnect";
5
+ export declare const DISCONNECTED_RMQ_MESSAGE = "Disconnected from RMQ. Trying to reconnect.";
6
+ export declare const ERROR_EVENT = "error";
7
+ export declare const ERROR_RMQ_MESSAGE = "An error occured";
8
+ export declare const CONNECT_FAILED_EVENT = "connectFailed";
9
+ export declare const CONNECT_FAILED_RMQ_MESSAGE = "The connection to the server failed";
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CONNECT_FAILED_RMQ_MESSAGE = exports.CONNECT_FAILED_EVENT = exports.ERROR_RMQ_MESSAGE = exports.ERROR_EVENT = exports.DISCONNECTED_RMQ_MESSAGE = exports.DISCONNECT_EVENT = exports.CONNECTED_RMQ_MESSAGE = exports.CONNECT_EVENT = exports.NO_MESSAGE_HANDLER = void 0;
4
+ exports.NO_MESSAGE_HANDLER = 'There is no matching message handler defined in the remote service.';
5
+ exports.CONNECT_EVENT = 'connect';
6
+ exports.CONNECTED_RMQ_MESSAGE = 'Connected to RMQ Server';
7
+ exports.DISCONNECT_EVENT = 'disconnect';
8
+ exports.DISCONNECTED_RMQ_MESSAGE = 'Disconnected from RMQ. Trying to reconnect.';
9
+ exports.ERROR_EVENT = 'error';
10
+ exports.ERROR_RMQ_MESSAGE = 'An error occured';
11
+ exports.CONNECT_FAILED_EVENT = 'connectFailed';
12
+ exports.CONNECT_FAILED_RMQ_MESSAGE = 'The connection to the server failed';
13
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/utils/rmq/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,kBAAkB,GAC7B,qEAAqE,CAAA;AAC1D,QAAA,aAAa,GAAG,SAAS,CAAA;AACzB,QAAA,qBAAqB,GAAG,yBAAyB,CAAA;AACjD,QAAA,gBAAgB,GAAG,YAAY,CAAA;AAC/B,QAAA,wBAAwB,GACnC,6CAA6C,CAAA;AAClC,QAAA,WAAW,GAAG,OAAO,CAAA;AACrB,QAAA,iBAAiB,GAAG,kBAAkB,CAAA;AACtC,QAAA,oBAAoB,GAAG,eAAe,CAAA;AACtC,QAAA,0BAA0B,GAAG,qCAAqC,CAAA"}
@@ -0,0 +1,9 @@
1
+ import { BaseRpcContext } from '@nestjs/microservices/ctx-host/base-rpc.context';
2
+ declare type RmqContextArgs = [Record<string, any>, any, string];
3
+ export declare class RmqContext extends BaseRpcContext<RmqContextArgs> {
4
+ constructor(args: RmqContextArgs);
5
+ getMessage(): Record<string, any>;
6
+ getChannelRef(): any;
7
+ getPattern(): string;
8
+ }
9
+ export {};
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RmqContext = void 0;
4
+ const base_rpc_context_1 = require("@nestjs/microservices/ctx-host/base-rpc.context");
5
+ class RmqContext extends base_rpc_context_1.BaseRpcContext {
6
+ constructor(args) {
7
+ super(args);
8
+ }
9
+ getMessage() {
10
+ return this.args[0];
11
+ }
12
+ getChannelRef() {
13
+ return this.args[1];
14
+ }
15
+ getPattern() {
16
+ return this.args[2];
17
+ }
18
+ }
19
+ exports.RmqContext = RmqContext;
20
+ //# sourceMappingURL=rmq.context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rmq.context.js","sourceRoot":"","sources":["../../../../src/utils/rmq/ctx-host/rmq.context.ts"],"names":[],"mappings":";;;AAAA,sFAAgF;AAIhF,MAAa,UAAW,SAAQ,iCAA8B;IAC5D,YAAY,IAAoB;QAC9B,KAAK,CAAC,IAAI,CAAC,CAAA;IACb,CAAC;IAID,UAAU;QACR,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACrB,CAAC;IAKD,aAAa;QACX,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACrB,CAAC;IAKD,UAAU;QACR,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACrB,CAAC;CACF;AAxBD,gCAwBC"}
@@ -0,0 +1,4 @@
1
+ import { RabbitMQClient } from './client/rabbitmq.client';
2
+ import { RabbitMQServer } from './server/rabbitmq.server';
3
+ import { ExchangeOptions, ExchangeType, QueueOptions, RMQOptions } from './interfaces/rmq-options.interfaces';
4
+ export { RabbitMQClient, RabbitMQServer, ExchangeOptions, ExchangeType, QueueOptions, RMQOptions, };
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExchangeType = exports.RabbitMQServer = exports.RabbitMQClient = void 0;
4
+ const rabbitmq_client_1 = require("./client/rabbitmq.client");
5
+ Object.defineProperty(exports, "RabbitMQClient", { enumerable: true, get: function () { return rabbitmq_client_1.RabbitMQClient; } });
6
+ const rabbitmq_server_1 = require("./server/rabbitmq.server");
7
+ Object.defineProperty(exports, "RabbitMQServer", { enumerable: true, get: function () { return rabbitmq_server_1.RabbitMQServer; } });
8
+ const rmq_options_interfaces_1 = require("./interfaces/rmq-options.interfaces");
9
+ Object.defineProperty(exports, "ExchangeType", { enumerable: true, get: function () { return rmq_options_interfaces_1.ExchangeType; } });
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/rmq/index.ts"],"names":[],"mappings":";;;AAAA,8DAAyD;AAUvD,+FAVO,gCAAc,OAUP;AAThB,8DAAyD;AAUvD,+FAVO,gCAAc,OAUP;AAThB,gFAK4C;AAM1C,6FATA,qCAAY,OASA"}
@@ -0,0 +1,79 @@
1
+ import { Serializer, Deserializer } from '@nestjs/microservices';
2
+ import { AmqpConnectionManagerOptions } from 'amqp-connection-manager';
3
+ export interface RMQOptions {
4
+ urls: string[];
5
+ serializer?: Serializer;
6
+ deserializer?: Deserializer;
7
+ prefetchCount?: number;
8
+ isGlobalPrefetchCount?: boolean;
9
+ noAck?: boolean;
10
+ exchange?: string;
11
+ exchangeType?: ExchangeType;
12
+ exchangeOptions?: ExchangeOptions;
13
+ socketOptions?: AmqpConnectionManagerOptions;
14
+ }
15
+ export interface RMQServerOptions extends RMQOptions {
16
+ queue?: string;
17
+ queueOptions?: QueueOptions;
18
+ }
19
+ export interface RMQClientOptions extends RMQOptions {
20
+ queue?: string;
21
+ replyQueue?: string;
22
+ replyQueueOptions?: QueueOptions;
23
+ }
24
+ export interface QueueOptions {
25
+ exclusive?: boolean;
26
+ durable?: boolean;
27
+ autoDelete?: boolean;
28
+ arguments?: any;
29
+ messageTtl?: number;
30
+ expires?: number;
31
+ deadLetterExchange?: string;
32
+ deadLetterRoutingKey?: string;
33
+ maxLength?: number;
34
+ maxPriority?: number;
35
+ }
36
+ export interface MessageOptions {
37
+ expiration?: string | number | undefined;
38
+ userId?: string | undefined;
39
+ CC?: string | string[] | undefined;
40
+ mandatory?: boolean | undefined;
41
+ persistent?: boolean | undefined;
42
+ deliveryMode?: boolean | number | undefined;
43
+ BCC?: string | string[] | undefined;
44
+ contentType?: string | undefined;
45
+ contentEncoding?: string | undefined;
46
+ headers?: any;
47
+ priority?: number | undefined;
48
+ messageId?: string | undefined;
49
+ timestamp?: number | undefined;
50
+ type?: string | undefined;
51
+ appId?: string | undefined;
52
+ timeout?: number;
53
+ }
54
+ export interface PublishOptions extends MessageOptions {
55
+ correlationId?: string | undefined;
56
+ replyTo?: string | undefined;
57
+ }
58
+ export interface RMQMessage {
59
+ options?: MessageOptions;
60
+ content: string;
61
+ }
62
+ export interface RMQServerResponse {
63
+ response: RMQMessage | string;
64
+ isDisposed: boolean;
65
+ }
66
+ export interface ExchangeOptions {
67
+ durable?: boolean;
68
+ internal?: boolean;
69
+ autoDelete?: boolean;
70
+ alternateExchange?: string;
71
+ arguments?: any;
72
+ }
73
+ export declare enum ExchangeType {
74
+ DIRECT = "direct",
75
+ TOPIC = "topic",
76
+ HEADERS = "headers",
77
+ FANOUT = "fanout",
78
+ MATCH = "match"
79
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExchangeType = void 0;
4
+ var ExchangeType;
5
+ (function (ExchangeType) {
6
+ ExchangeType["DIRECT"] = "direct";
7
+ ExchangeType["TOPIC"] = "topic";
8
+ ExchangeType["HEADERS"] = "headers";
9
+ ExchangeType["FANOUT"] = "fanout";
10
+ ExchangeType["MATCH"] = "match";
11
+ })(ExchangeType = exports.ExchangeType || (exports.ExchangeType = {}));
12
+ //# sourceMappingURL=rmq-options.interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rmq-options.interfaces.js","sourceRoot":"","sources":["../../../../src/utils/rmq/interfaces/rmq-options.interfaces.ts"],"names":[],"mappings":";;;AAsHA,IAAY,YAWX;AAXD,WAAY,YAAY;IAEtB,iCAAiB,CAAA;IAEjB,+BAAe,CAAA;IAEf,mCAAmB,CAAA;IAEnB,iCAAiB,CAAA;IAEjB,+BAAe,CAAA;AACjB,CAAC,EAXW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAWvB"}
@@ -0,0 +1,19 @@
1
+ import { Server, CustomTransportStrategy, Transport } from '@nestjs/microservices';
2
+ import { ConfirmChannel, ConsumeMessage } from 'amqplib';
3
+ import { AmqpConnectionManager } from 'amqp-connection-manager';
4
+ import { RMQServerOptions, RMQServerResponse } from '../interfaces/rmq-options.interfaces';
5
+ export declare class RabbitMQServer extends Server implements CustomTransportStrategy {
6
+ private readonly options;
7
+ transportId?: Transport;
8
+ private server;
9
+ private channel;
10
+ constructor(options: RMQServerOptions);
11
+ listen(callback: () => void): Promise<void>;
12
+ createAmqpClient(): AmqpConnectionManager;
13
+ start(callback: any): Promise<void>;
14
+ handleRMQEvents(): void;
15
+ setupChannel(channel: ConfirmChannel, callback: any): Promise<void>;
16
+ handleMessage(message: ConsumeMessage, channel: ConfirmChannel): Promise<any>;
17
+ sendMessage(message: RMQServerResponse, replyTo: any, correlationId: string): void;
18
+ close(): void;
19
+ }
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RabbitMQServer = void 0;
4
+ const microservices_1 = require("@nestjs/microservices");
5
+ const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
6
+ const amqp_connection_manager_1 = require("amqp-connection-manager");
7
+ const constants_1 = require("../constants");
8
+ const rmq_context_1 = require("../ctx-host/rmq.context");
9
+ class RabbitMQServer extends microservices_1.Server {
10
+ constructor(options) {
11
+ super();
12
+ this.options = options;
13
+ this.initializeSerializer(options);
14
+ this.initializeDeserializer(options);
15
+ }
16
+ async listen(callback) {
17
+ this.start(callback);
18
+ }
19
+ createAmqpClient() {
20
+ const { urls, socketOptions } = this.options;
21
+ return amqp_connection_manager_1.connect(urls, socketOptions);
22
+ }
23
+ async start(callback) {
24
+ this.server = this.createAmqpClient();
25
+ this.server.on(constants_1.CONNECT_EVENT, () => {
26
+ if (this.channel) {
27
+ return;
28
+ }
29
+ this.channel = this.server.createChannel({
30
+ json: false,
31
+ setup: (channel) => this.setupChannel(channel, callback),
32
+ });
33
+ });
34
+ this.handleRMQEvents();
35
+ }
36
+ handleRMQEvents() {
37
+ this.server.on(constants_1.CONNECT_FAILED_EVENT, err => {
38
+ this.logger.error(constants_1.CONNECT_FAILED_RMQ_MESSAGE);
39
+ this.logger.error(err);
40
+ });
41
+ this.server.on(constants_1.DISCONNECT_EVENT, err => {
42
+ this.logger.error(constants_1.DISCONNECTED_RMQ_MESSAGE);
43
+ this.logger.error(err);
44
+ this.close();
45
+ });
46
+ this.server.on(constants_1.ERROR_EVENT, err => {
47
+ this.logger.error(constants_1.ERROR_RMQ_MESSAGE);
48
+ this.logger.error(err);
49
+ });
50
+ }
51
+ async setupChannel(channel, callback) {
52
+ const { queue, queueOptions, exchange, exchangeType, exchangeOptions, noAck, prefetchCount, isGlobalPrefetchCount, } = this.options;
53
+ await channel.assertExchange(exchange, exchangeType, exchangeOptions);
54
+ await channel.assertQueue(queue, queueOptions);
55
+ this.messageHandlers.forEach((handler, pattern) => {
56
+ channel.bindQueue(queue, exchange, pattern);
57
+ });
58
+ channel.consume(queue, msg => this.handleMessage(msg, channel), {
59
+ noAck: noAck !== undefined ? noAck : true,
60
+ });
61
+ await channel.prefetch(prefetchCount, isGlobalPrefetchCount);
62
+ callback();
63
+ }
64
+ async handleMessage(message, channel) {
65
+ const rawMessage = JSON.parse(message.content.toString());
66
+ const packet = await this.deserializer.deserialize(rawMessage);
67
+ const pattern = shared_utils_1.isString(packet.pattern)
68
+ ? packet.pattern
69
+ : JSON.stringify(packet.pattern);
70
+ const rmqContext = new rmq_context_1.RmqContext([message, channel, pattern]);
71
+ if (shared_utils_1.isUndefined(message.properties.replyTo)) {
72
+ return this.handleEvent(pattern, packet, rmqContext);
73
+ }
74
+ const handler = this.getHandlerByPattern(pattern);
75
+ if (!handler) {
76
+ const status = 'error';
77
+ const noHandlerPacket = {
78
+ isDisposed: true,
79
+ response: {
80
+ content: JSON.stringify({
81
+ id: message.properties.correlationId,
82
+ err: constants_1.NO_MESSAGE_HANDLER,
83
+ status,
84
+ }),
85
+ },
86
+ };
87
+ return this.sendMessage(noHandlerPacket, message.properties.replyTo, message.properties.correlationId);
88
+ }
89
+ const response$ = this.transformToObservable(await handler(packet.data));
90
+ const publish = (response) => {
91
+ const outgoingResponse = this.serializer.serialize(response);
92
+ this.sendMessage(outgoingResponse, message.properties.replyTo, message.properties.correlationId);
93
+ };
94
+ response$ && this.send(response$, publish);
95
+ }
96
+ sendMessage(message, replyTo, correlationId) {
97
+ let publishOptions = {
98
+ correlationId,
99
+ };
100
+ if (typeof message.response !== 'string') {
101
+ publishOptions = Object.assign(Object.assign({}, message.response.options), publishOptions);
102
+ message.response = message.response.content;
103
+ }
104
+ const outgoingResponse = this.serializer.serialize(message);
105
+ const buffer = Buffer.from(JSON.stringify(outgoingResponse));
106
+ this.channel.sendToQueue(replyTo, buffer, publishOptions);
107
+ }
108
+ close() {
109
+ this.channel && this.channel.close();
110
+ this.server && this.server.close();
111
+ }
112
+ }
113
+ exports.RabbitMQServer = RabbitMQServer;
114
+ //# sourceMappingURL=rabbitmq.server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rabbitmq.server.js","sourceRoot":"","sources":["../../../../src/utils/rmq/server/rabbitmq.server.ts"],"names":[],"mappings":";;;AAAA,yDAK8B;AAC9B,oEAAyE;AAGzE,qEAIgC;AAMhC,4CASqB;AACrB,yDAAoD;AAEpD,MAAa,cAAe,SAAQ,sBAAM;IAKxC,YAA6B,OAAyB;QACpD,KAAK,EAAE,CAAA;QADoB,YAAO,GAAP,OAAO,CAAkB;QAEpD,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAA;QAClC,IAAI,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAA;IACtC,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,QAAoB;QAC/B,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;IACtB,CAAC;IAED,gBAAgB;QACd,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC,OAAO,CAAA;QAC5C,OAAO,iCAAO,CAAC,IAAI,EAAE,aAAa,C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AAC;IAEM,WAAW,CAChB,OAA0B,EAC1B,OAAY,EACZ,aAAqB;QAErB,IAAI,cAAc,GAAmB;YACnC,aAAa;SACd,CAAA;QACD,IAAI,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE;YACxC,cAAc,mCAAQ,OAAO,CAAC,QAAQ,CAAC,OAAO,GAAK,cAAc,CAAE,CAAA;YACnE,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAA;SAC5C;QACD,MAAM,gBAAgB,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAChD,OAAsC,CACvC,CAAA;QACD,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC,CAAA;QAC5D,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,cAAc,CAAC,CAAA;IAC3D,CAAC;IAED,KAAK;QACH,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAA;QACpC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAA;IACpC,CAAC;CACF;AA1ID,wCA0IC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aldb2b/common",
3
- "version": "1.0.145",
3
+ "version": "1.0.148",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",