@sera4/essentia 3.0.12 → 3.0.13-rc.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 (73) hide show
  1. package/dist/cache/index.d.ts +22 -0
  2. package/dist/cache/index.js +166 -0
  3. package/dist/cache/index.js.map +1 -0
  4. package/dist/constants/index.d.ts +6 -0
  5. package/dist/constants/index.js +9 -0
  6. package/dist/constants/index.js.map +1 -0
  7. package/dist/formatter/index.d.ts +37 -0
  8. package/dist/formatter/index.js +75 -0
  9. package/dist/formatter/index.js.map +1 -0
  10. package/dist/hal/index.d.ts +5 -0
  11. package/dist/hal/index.js +69 -0
  12. package/dist/hal/index.js.map +1 -0
  13. package/dist/health/health-logger.d.ts +9 -0
  14. package/dist/health/health-logger.js +34 -0
  15. package/dist/health/health-logger.js.map +1 -0
  16. package/dist/health/index.d.ts +19 -0
  17. package/dist/health/index.js +175 -0
  18. package/dist/health/index.js.map +1 -0
  19. package/dist/helpers/index.d.ts +1 -0
  20. package/dist/helpers/index.js +2 -0
  21. package/dist/helpers/index.js.map +1 -0
  22. package/dist/helpers/test-server-wrapper.d.ts +120 -0
  23. package/dist/helpers/test-server-wrapper.js +165 -0
  24. package/dist/helpers/test-server-wrapper.js.map +1 -0
  25. package/dist/index.d.ts +1 -0
  26. package/dist/index.js +17 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/last-commit.d.ts +1 -0
  29. package/dist/last-commit.js.map +1 -0
  30. package/dist/last_commit/index.d.ts +7 -0
  31. package/dist/last_commit/index.js +83 -0
  32. package/dist/last_commit/index.js.map +1 -0
  33. package/dist/paginator/s4-pagination.d.ts +9 -0
  34. package/dist/paginator/s4-pagination.js +49 -0
  35. package/dist/paginator/s4-pagination.js.map +1 -0
  36. package/dist/paginator/sql-pagination.d.ts +27 -0
  37. package/dist/paginator/sql-pagination.js +166 -0
  38. package/dist/paginator/sql-pagination.js.map +1 -0
  39. package/dist/paper-trail/helpers.d.ts +11 -0
  40. package/dist/paper-trail/helpers.js +74 -0
  41. package/dist/paper-trail/helpers.js.map +1 -0
  42. package/dist/paper-trail/index.d.ts +13 -0
  43. package/dist/paper-trail/index.js +662 -0
  44. package/dist/paper-trail/index.js.map +1 -0
  45. package/dist/prompts/index.d.ts +14 -0
  46. package/dist/prompts/index.js +63 -0
  47. package/dist/prompts/index.js.map +1 -0
  48. package/dist/queue/index.d.ts +166 -0
  49. package/dist/queue/index.js +371 -0
  50. package/dist/queue/index.js.map +1 -0
  51. package/dist/queue/publisher.d.ts +31 -0
  52. package/dist/queue/publisher.js +84 -0
  53. package/dist/queue/publisher.js.map +1 -0
  54. package/dist/queue/queue-logger.d.ts +9 -0
  55. package/dist/queue/queue-logger.js +35 -0
  56. package/dist/queue/queue-logger.js.map +1 -0
  57. package/dist/queue/subscriber.d.ts +39 -0
  58. package/dist/queue/subscriber.js +97 -0
  59. package/dist/queue/subscriber.js.map +1 -0
  60. package/dist/safe_proxy/index.d.ts +13 -0
  61. package/dist/safe_proxy/index.js +54 -0
  62. package/dist/safe_proxy/index.js.map +1 -0
  63. package/dist/serializer/index.d.ts +5 -0
  64. package/dist/serializer/index.js +83 -0
  65. package/dist/serializer/index.js.map +1 -0
  66. package/dist/ts/queue/index.js +54 -65
  67. package/dist/ts/queue/index.js.map +1 -1
  68. package/dist/ts/task-scheduler/index.d.ts +130 -0
  69. package/dist/ts/task-scheduler/index.js +259 -0
  70. package/dist/ts/task-scheduler/index.js.map +1 -0
  71. package/package.json +9 -3
  72. package/scripts/publish.sh +46 -0
  73. package/package.tar.gz +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../paper-trail/index.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,MAAM,CAAC;AAC/B,OAAO,CAAC,MAAM,QAAQ,CAAC;AACvB,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,SAAS,MAAM,gCAAgC,CAAC;AACvD,OAAO,E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AAK;iBAClB,CAAC,CAAC;gBAEH,cAAc,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;gBAEnC,IAAI,EAAE;oBACL,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC;YAC3C,CAAC;YAED,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAE7B,IAAI,EAAE;gBACL,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC;YAE9B;;;;;;eAMG;YACH,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;gBACvB,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;oBACtD,EAAE,EAAE,SAAS;oBACb,UAAU,EAAE;wBACX,SAAS,EAAE,OAAO,CAAC,kBAAkB;qBACrC;oBACD,QAAQ,EAAE,SAAS;iBACnB,CAAC,CAAC;YACJ,CAAC;YAED,OAAO,QAAQ,CAAC;QACjB,CAAC;KACD,CAAC;AACH,CAAC,CAAC;AAEF;;;GAGG;AACH,UAAU,CAAC,cAAc,GAAG,GAAG,EAAE;IAChC,QAAQ,GAAG,IAAI,CAAC;AACjB,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,14 @@
1
+ export function commonCLIInit(options: any): Promise<void>;
2
+ export const continueCLIPrompt: {
3
+ "Push <enter> to continue": {
4
+ type: string;
5
+ };
6
+ };
7
+ export function promptCLIAsync(options: any): Promise<any>;
8
+ export function setupCLIParser(description: any): any;
9
+ export function cliSleep(ms: any): Promise<any>;
10
+ export const waitCLIPrompt: {
11
+ "Push <enter> when done": {
12
+ type: string;
13
+ };
14
+ };
@@ -0,0 +1,63 @@
1
+ /* Essentia Common Prompt Functions */
2
+ // This file contains common prompt functions that are used in CLI scripts
3
+ // that are run in the each project. These functions are used to
4
+ // prompt the user for input and to wait for the user to press enter
5
+ // before continuing. This is useful for scripts that are run in the
6
+ // command line and need to wait for the user to do something before
7
+ // continuing.
8
+ import { S4Logger } from "../ts/logger/s4-logger.js";
9
+ const logger = new S4Logger();
10
+ import { ArgumentParser } from 'argparse';
11
+ import prompt from "prompt";
12
+ // New common argument parser which makes parsing and setting up commandline options easier
13
+ const setupCLIParser = (description) => {
14
+ logger.info(description);
15
+ return new ArgumentParser({ description });
16
+ };
17
+ // a common init function which waits for the command prompt to be delivered
18
+ // a common use is for the awaiting of the queues to initialize before running
19
+ const commonCLIInit = async (options) => {
20
+ //add in defaults to options if they have not been specified or object is {}
21
+ options = { asyncFcns: [], extraFcns: [], sleepTime: 1000, ...options };
22
+ // Sleep for 1 second to allow the prompt to be displayed
23
+ // at the end of bootstrap logs
24
+ await cliSleep(options.sleepTime);
25
+ options.extraFcns.forEach(fcn => {
26
+ fcn();
27
+ });
28
+ for (const fcn of options.asyncFcns) {
29
+ await fcn();
30
+ }
31
+ };
32
+ const promptCLIAsync = async (options) => {
33
+ return new Promise((resolve, reject) => {
34
+ prompt.start();
35
+ prompt.get(options, (err, res) => {
36
+ if (err) {
37
+ reject(err);
38
+ }
39
+ else {
40
+ resolve(res);
41
+ }
42
+ });
43
+ });
44
+ };
45
+ // A predefined waitPrompt for use at the end of the scripts that use
46
+ // message queues. Message Queues often take a bit to fire
47
+ const waitCLIPrompt = {
48
+ "Push <enter> when done": {
49
+ type: "boolean"
50
+ }
51
+ };
52
+ const continueCLIPrompt = {
53
+ "Push <enter> to continue": {
54
+ type: "boolean"
55
+ }
56
+ };
57
+ const cliSleep = async (ms) => {
58
+ return new Promise((resolve) => {
59
+ setTimeout(resolve, ms);
60
+ });
61
+ };
62
+ export { commonCLIInit, continueCLIPrompt, promptCLIAsync, setupCLIParser, cliSleep, waitCLIPrompt };
63
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../prompts/index.js"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,0EAA0E;AAC1E,kEAAkE;AAClE,qE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M,CAAC,GAAG,CAAC,CAAC;YACd,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,GAAG,CAAC,CAAC;YACf,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAA;AAED,qEAAqE;AACrE,4DAA4D;AAC5D,MAAM,aAAa,GAAG;IACpB,wBAAwB,EAAG;QACzB,IAAI,EAAE,SAAS;KAChB;CACF,CAAC;AAEF,MAAM,iBAAiB,GAAG;IACxB,0BAA0B,EAAG;QAC3B,IAAI,EAAE,SAAS;KAChB;CACF,CAAC;AAEF,MAAM,QAAQ,GAAG,KAAK,EAAC,EAAE,EAAE,EAAE;IAC3B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC,CAAA;AAED,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,QAAQ,EACR,aAAa,EACd,CAAC"}
@@ -0,0 +1,166 @@
1
+ export default queue;
2
+ declare const queue: S4Queue;
3
+ /**
4
+ * An interface to AMQP service
5
+ */
6
+ declare class S4Queue {
7
+ connection: any;
8
+ retry: number;
9
+ pubs: {};
10
+ subs: {};
11
+ /**
12
+ * Tests the connection to the service.
13
+ * Internally, the same connection is used for test
14
+ * and production code, but a separate channel is opened.
15
+ * Once the channel is obtained, there is an assert on the
16
+ * existence of a topic exchange called '--health-check--'.
17
+ * The following must be satisfied for the test to pass
18
+ * 1. must be connected
19
+ * 2. must have a test channel
20
+ * 3. must assert the exchange
21
+ */
22
+ testConnection(): Promise<void>;
23
+ connectionTestChannel: any;
24
+ /**
25
+ * Opens a connection to AMQP server.
26
+ * @param {Object} options Connection parameters. At the very least options.connectionUrl must be present.
27
+ */
28
+ openConnection(options: any): Promise<any>;
29
+ /**
30
+ * Closes the connection to AMQP server
31
+ * and clears the registered publishers
32
+ * and subscribers
33
+ */
34
+ closeConnection(): Promise<any>;
35
+ /**
36
+ * Returns whether we have an active connection
37
+ * or not.
38
+ */
39
+ isConnected(): boolean;
40
+ /**
41
+ * @deprecated Use registerPublisher
42
+ * Registers a new direct publisher on the given exchange.
43
+ * If exchange doesn't exist, one will be created.
44
+ * @param {String} exchange the name of the exchange on AMQP service.
45
+ */
46
+ registerDirectPublisher(exchange: string): Promise<void>;
47
+ /**
48
+ * @deprecated Use registerPublisher
49
+ * Registers a new topic publisher on the given exchange.
50
+ * If exchange doesn't exist, one will be created.
51
+ * @param {String} exchange the name of the exchange on AMQP service.
52
+ */
53
+ registerTopicPublisher(exchange: string): Promise<void>;
54
+ /**
55
+ * @deprecated Use registerPublisher
56
+ * Registers a new fanout publisher on the given exchange.
57
+ * If exchange doesn't exist, one will be created.
58
+ * @param {String} exchange the name of the exchange on AMQP service.
59
+ */
60
+ registerFanoutPublisher(exchange: string): Promise<void>;
61
+ /**
62
+ * Registers a new publisher
63
+ * @param {Object} options connection options.
64
+ */
65
+ registerPublisher(options: any): Promise<void>;
66
+ /**
67
+ * Checks whether or not a publisher with given parameters
68
+ * has been registered already
69
+ * @param {String} exchange the name of the exchange.
70
+ * @returns true if registered already, false otherwise
71
+ */
72
+ hasPublisher(exchange: string): boolean;
73
+ /**
74
+ * Removes a previously registered publisher
75
+ * @param {Object} options
76
+ */
77
+ unregisterPublisher(options: any): Promise<void>;
78
+ /**
79
+ * @deprecated Use registerSubscriber
80
+ * Registers a new direct subscriber on a given exchange and queue.
81
+ * If exchange and queue don't exists, they'll be created
82
+ * and bound through the provided routing key.
83
+ * @param {String} exchange the name of the exchange.
84
+ * @param {String} queue the name of the queue.
85
+ * @param {String} key the name of the routing key.
86
+ */
87
+ registerDirectSubscriber(exchange: string, queue: string, key: string): Promise<void>;
88
+ /**
89
+ * @deprecated Use registerSubscriber
90
+ * Registers a new topic subscriber on a given exchange and queue.
91
+ * If exchange and queue don't exists, they'll be created
92
+ * and bound through the provided routing key.
93
+ * @param {String} exchange the name of the exchange.
94
+ * @param {String} queue the name of the queue.
95
+ * @param {String} key the name of the routing key.
96
+ */
97
+ registerTopicSubscriber(exchange: string, queue: string, key: string): Promise<void>;
98
+ /**
99
+ * An overloaded version of registering a subscriber
100
+ * allowing for more fine tuned parameters
101
+ * @param {Object} options subscribing options
102
+ */
103
+ registerSubscriber(options: any): Promise<void>;
104
+ /**
105
+ * Checks whether or not a subscriber with given parameters
106
+ * has been registered already
107
+ * @param {String} exchange the name of the exchange.
108
+ * @param {String} queue the name of the queue.
109
+ * @param {String} key the name of the routing key.
110
+ * @returns true if registered already, false otherwise
111
+ */
112
+ hasSubscriber(exchange: string, queue: string, key: string): boolean;
113
+ /**
114
+ * Removes a previously registered subscriber
115
+ * @param {OBject} options
116
+ */
117
+ unregisterSubscriber(options: OBject): Promise<void>;
118
+ /**
119
+ * Publishes a message on a given exchange with routing key.
120
+ * @param {String} exchange the name of the exchange.
121
+ * @param {String} key the name of the routing key.
122
+ * @param {Object} msg a JSON object as the message.
123
+ */
124
+ publishDirectMessage(exchange: string, key: string, msg: any): Promise<any>;
125
+ /**
126
+ * Publishes a message on a given exchange with a topic.
127
+ * @param {String} exchange the name of the exchange.
128
+ * @param {String} topic the name of the topic.
129
+ * @param {Object} msg a JSON object as the message.
130
+ */
131
+ publishTopicMessage(exchange: string, topic: string, msg: any): Promise<any>;
132
+ /**
133
+ * Publish a message to the exchange
134
+ * @param {String} exchange name of exchange
135
+ * @param {String} key name of the key or topic
136
+ * @param {Object} msg payload to be published
137
+ */
138
+ publishMessage(exchange: string, key: string, msg: any): Promise<any>;
139
+ /**
140
+ * Binds an exchange to a queue
141
+ * @param {String} exchange the name of the exchange.
142
+ * @param {String} queue the name of the queue.
143
+ * @param {pattern} (optional) pattern for routing key
144
+ */
145
+ bindQueueToExchange(exchange: string, queue: string, pattern: any): Promise<any>;
146
+ /**
147
+ * Adds a listener for a specific key.
148
+ * If a subscriber that was regitered was found
149
+ * with that key, the listener is added, otherwise
150
+ * it's ignored
151
+ * @param {*} key AMQP routing key
152
+ * @param {*} listener callback
153
+ */
154
+ addMessageListener(key: any, listener: any): void;
155
+ /**
156
+ * Updates the connection reference to all the previously
157
+ * registered publishers and subscribers.
158
+ * After we successfully establish a connection and register pubs/subs,
159
+ * it's possible for the connection to break. This object will try
160
+ * to re-establish a new connection every 3 seconds (or whatever configuration is set)
161
+ * and if a new connection is established, we need to pass that connection to
162
+ * all our pubs/subs, otherwise they'll be operating with old/stale references
163
+ * @param {Object} connRef a new connection reference to the AMQP service
164
+ */
165
+ updatePubsAndSubsConnectionRef(connRef: any): void;
166
+ }
@@ -0,0 +1,371 @@
1
+ "use strict";
2
+ import amqp from "amqplib/callback_api.js";
3
+ import logger from "./queue-logger.js";
4
+ import urlParse from "url-parse";
5
+ import { Publisher } from "./publisher.js";
6
+ import { Subscriber } from "./subscriber.js";
7
+ /**
8
+ * An interface to AMQP service
9
+ */
10
+ class S4Queue {
11
+ constructor() {
12
+ this.connection = null;
13
+ this.retry = 10;
14
+ this.pubs = {};
15
+ this.subs = {};
16
+ }
17
+ /**
18
+ * Tests the connection to the service.
19
+ * Internally, the same connection is used for test
20
+ * and production code, but a separate channel is opened.
21
+ * Once the channel is obtained, there is an assert on the
22
+ * existence of a topic exchange called '--health-check--'.
23
+ * The following must be satisfied for the test to pass
24
+ * 1. must be connected
25
+ * 2. must have a test channel
26
+ * 3. must assert the exchange
27
+ */
28
+ async testConnection() {
29
+ if (!this.isConnected()) {
30
+ this.connectionTestChannel = null;
31
+ throw ("queue service not connected");
32
+ }
33
+ this.connectionTestChannel = this.connectionTestChannel || await this.connection.createChannel();
34
+ if (!this.connectionTestChannel) {
35
+ throw ("queue service failed to obtain a channel");
36
+ }
37
+ await this.connectionTestChannel.assertExchange("--health-check--", "topic", { durable: false });
38
+ }
39
+ /**
40
+ * Opens a connection to AMQP server.
41
+ * @param {Object} options Connection parameters. At the very least options.connectionUrl must be present.
42
+ */
43
+ async openConnection(options) {
44
+ logger.setEnabled(options.logEnabled);
45
+ if (this.connection) {
46
+ logger.warn("Already initialized");
47
+ return;
48
+ }
49
+ const retry = parseInt(options.retryInterval);
50
+ this.retry = retry || 10;
51
+ logger.debug("Attempting connection...");
52
+ // The docs say there is amqp.connect returning
53
+ // a promise, but this version doesn't seem to like
54
+ // when a callback isn't provided, therefore run
55
+ // in a new Promise
56
+ return new Promise((resolve, reject) => {
57
+ // We may run into issues with SNI TLS if
58
+ // we host with 3rd parties using our own certs.
59
+ // To avoid any issues, let's parse the url
60
+ // and provide the server name in the socket options
61
+ const urlParts = urlParse(options.connectionUrl);
62
+ const socketOptions = { servername: urlParts.hostname };
63
+ amqp.connect(options.connectionUrl, socketOptions, (err, conn) => {
64
+ if (err) {
65
+ logger.error("Error while connecting", err);
66
+ logger.error("Attempting again in", this.retry, "seconds");
67
+ return setTimeout(() => this.openConnection(options), this.retry * 1000);
68
+ }
69
+ this.connection = conn;
70
+ if (!this.connection) {
71
+ return reject(new Error("Failed to obtain connection"));
72
+ }
73
+ else {
74
+ this.updatePubsAndSubsConnectionRef(conn);
75
+ }
76
+ this.connection.on("error", (err) => {
77
+ logger.error("connection error", err);
78
+ // Do not attempt to reconnect as the
79
+ // 'close' event will also be emitted
80
+ // if this error closes the connection
81
+ });
82
+ this.connection.on("close", (err) => {
83
+ logger.error("connection closed");
84
+ this.connection = null;
85
+ if (err) {
86
+ logger.error("connection closed due to error:", err);
87
+ logger.error("Reconnecting in", this.retry, "seconds");
88
+ setTimeout(() => this.openConnection(options), this.retry * 1000);
89
+ }
90
+ else {
91
+ // If there was no error, it is us who closed
92
+ // this connection, thus a reconnection will not
93
+ // be attempted.
94
+ logger.debug("Will not re-attempt");
95
+ }
96
+ });
97
+ logger.debug("Connected");
98
+ resolve();
99
+ });
100
+ });
101
+ }
102
+ /**
103
+ * Closes the connection to AMQP server
104
+ * and clears the registered publishers
105
+ * and subscribers
106
+ */
107
+ async closeConnection() {
108
+ return new Promise((resolve, reject) => {
109
+ if (!this.connection) {
110
+ return resolve();
111
+ }
112
+ this.connection.close((err) => {
113
+ if (err) {
114
+ reject(err);
115
+ }
116
+ else {
117
+ this.subs = {};
118
+ this.pubs = {};
119
+ this.connection = null;
120
+ resolve();
121
+ }
122
+ });
123
+ });
124
+ }
125
+ /**
126
+ * Returns whether we have an active connection
127
+ * or not.
128
+ */
129
+ isConnected() {
130
+ return this.connection != null && typeof (this.connection) != 'undefined';
131
+ }
132
+ /**
133
+ * @deprecated Use registerPublisher
134
+ * Registers a new direct publisher on the given exchange.
135
+ * If exchange doesn't exist, one will be created.
136
+ * @param {String} exchange the name of the exchange on AMQP service.
137
+ */
138
+ async registerDirectPublisher(exchange) {
139
+ return this.registerPublisher({ exchange: { name: exchange, type: "direct" } });
140
+ }
141
+ /**
142
+ * @deprecated Use registerPublisher
143
+ * Registers a new topic publisher on the given exchange.
144
+ * If exchange doesn't exist, one will be created.
145
+ * @param {String} exchange the name of the exchange on AMQP service.
146
+ */
147
+ async registerTopicPublisher(exchange) {
148
+ return this.registerPublisher({ exchange: { name: exchange, type: "topic" } });
149
+ }
150
+ /**
151
+ * @deprecated Use registerPublisher
152
+ * Registers a new fanout publisher on the given exchange.
153
+ * If exchange doesn't exist, one will be created.
154
+ * @param {String} exchange the name of the exchange on AMQP service.
155
+ */
156
+ async registerFanoutPublisher(exchange) {
157
+ return this.registerPublisher({ exchange: { name: exchange, type: "fanout" } });
158
+ }
159
+ /**
160
+ * Registers a new publisher
161
+ * @param {Object} options connection options.
162
+ */
163
+ async registerPublisher(options) {
164
+ const { exchange } = options;
165
+ const { name } = exchange;
166
+ if (Object.keys(this.pubs).includes(name)) {
167
+ throw new Error(`Publisher ${name} already registered`);
168
+ }
169
+ const p = new Publisher(exchange, name);
170
+ await p.init(this.connection);
171
+ this.pubs[name] = p;
172
+ }
173
+ /**
174
+ * Checks whether or not a publisher with given parameters
175
+ * has been registered already
176
+ * @param {String} exchange the name of the exchange.
177
+ * @returns true if registered already, false otherwise
178
+ */
179
+ hasPublisher(exchange) {
180
+ return Object.keys(this.pubs).includes(exchange);
181
+ }
182
+ /**
183
+ * Removes a previously registered publisher
184
+ * @param {Object} options
185
+ */
186
+ async unregisterPublisher(options) {
187
+ const { exchange } = options;
188
+ const { name } = exchange;
189
+ if (!Object.keys(this.pubs).includes(name)) {
190
+ throw new Error(`Publisher ${name} not registered`);
191
+ }
192
+ const p = this.pubs[name];
193
+ await p.closeChannel();
194
+ delete this.pubs[name];
195
+ logger.debug("Unregistered publisher", name);
196
+ }
197
+ /**
198
+ * @deprecated Use registerSubscriber
199
+ * Registers a new direct subscriber on a given exchange and queue.
200
+ * If exchange and queue don't exists, they'll be created
201
+ * and bound through the provided routing key.
202
+ * @param {String} exchange the name of the exchange.
203
+ * @param {String} queue the name of the queue.
204
+ * @param {String} key the name of the routing key.
205
+ */
206
+ async registerDirectSubscriber(exchange, queue, key) {
207
+ const options = {
208
+ key,
209
+ exchange: { name: exchange, type: "direct" },
210
+ queue: { name: queue }
211
+ };
212
+ return this.registerSubscriber(options);
213
+ }
214
+ /**
215
+ * @deprecated Use registerSubscriber
216
+ * Registers a new topic subscriber on a given exchange and queue.
217
+ * If exchange and queue don't exists, they'll be created
218
+ * and bound through the provided routing key.
219
+ * @param {String} exchange the name of the exchange.
220
+ * @param {String} queue the name of the queue.
221
+ * @param {String} key the name of the routing key.
222
+ */
223
+ async registerTopicSubscriber(exchange, queue, key) {
224
+ const options = {
225
+ key,
226
+ exchange: { name: exchange, type: "topic" },
227
+ queue: { name: queue }
228
+ };
229
+ return this.registerSubscriber(options);
230
+ }
231
+ /**
232
+ * An overloaded version of registering a subscriber
233
+ * allowing for more fine tuned parameters
234
+ * @param {Object} options subscribing options
235
+ */
236
+ async registerSubscriber(options) {
237
+ const { exchange, queue, key } = options;
238
+ const name = `${exchange.name}-${queue.name}-${key}`;
239
+ if (Object.keys(this.subs).includes(name)) {
240
+ throw new Error(`Subscriber ${name} already registered`);
241
+ }
242
+ const s = new Subscriber(exchange, queue, key, name);
243
+ await s.init(this.connection);
244
+ this.subs[name] = s;
245
+ }
246
+ /**
247
+ * Checks whether or not a subscriber with given parameters
248
+ * has been registered already
249
+ * @param {String} exchange the name of the exchange.
250
+ * @param {String} queue the name of the queue.
251
+ * @param {String} key the name of the routing key.
252
+ * @returns true if registered already, false otherwise
253
+ */
254
+ hasSubscriber(exchange, queue, key) {
255
+ const name = `${exchange}-${queue}-${key}`;
256
+ return Object.keys(this.subs).includes(name);
257
+ }
258
+ /**
259
+ * Removes a previously registered subscriber
260
+ * @param {OBject} options
261
+ */
262
+ async unregisterSubscriber(options) {
263
+ const { exchange, queue, key } = options;
264
+ const name = `${exchange.name}-${queue.name}-${key}`;
265
+ if (!Object.keys(this.subs).includes(name)) {
266
+ throw new Error(`Subscriber ${name} not registered`);
267
+ }
268
+ const s = this.subs[name];
269
+ await s.closeChannel();
270
+ delete this.subs[name];
271
+ logger.debug("Unregistered subscriber", name);
272
+ }
273
+ /**
274
+ * Publishes a message on a given exchange with routing key.
275
+ * @param {String} exchange the name of the exchange.
276
+ * @param {String} key the name of the routing key.
277
+ * @param {Object} msg a JSON object as the message.
278
+ */
279
+ async publishDirectMessage(exchange, key, msg) {
280
+ return this.publishMessage(exchange, key, msg);
281
+ }
282
+ /**
283
+ * Publishes a message on a given exchange with a topic.
284
+ * @param {String} exchange the name of the exchange.
285
+ * @param {String} topic the name of the topic.
286
+ * @param {Object} msg a JSON object as the message.
287
+ */
288
+ async publishTopicMessage(exchange, topic, msg) {
289
+ return this.publishMessage(exchange, topic, msg);
290
+ }
291
+ /**
292
+ * Publish a message to the exchange
293
+ * @param {String} exchange name of exchange
294
+ * @param {String} key name of the key or topic
295
+ * @param {Object} msg payload to be published
296
+ */
297
+ async publishMessage(exchange, key, msg) {
298
+ if (!key) {
299
+ throw (new Error(`Key argument not defined`));
300
+ }
301
+ const p = this.pubs[exchange];
302
+ if (!p) {
303
+ throw (new Error(`No PUB for ${exchange} found`));
304
+ }
305
+ let content = msg;
306
+ if (content.constructor !== ({}).constructor) {
307
+ // if not in JSON format, let's make it so
308
+ content = {
309
+ msg: msg
310
+ };
311
+ }
312
+ return await p.publish({ key, content });
313
+ }
314
+ /**
315
+ * Binds an exchange to a queue
316
+ * @param {String} exchange the name of the exchange.
317
+ * @param {String} queue the name of the queue.
318
+ * @param {pattern} (optional) pattern for routing key
319
+ */
320
+ async bindQueueToExchange(exchange, queue, pattern) {
321
+ const p = this.pubs[exchange];
322
+ if (!p) {
323
+ throw (new Error(`No PUB for ${exchange} found`));
324
+ }
325
+ if (!queue) {
326
+ throw (new Error(`Binding a queue requires a queue name`));
327
+ }
328
+ return await p.bindQueue(queue, pattern);
329
+ }
330
+ /**
331
+ * Adds a listener for a specific key.
332
+ * If a subscriber that was regitered was found
333
+ * with that key, the listener is added, otherwise
334
+ * it's ignored
335
+ * @param {*} key AMQP routing key
336
+ * @param {*} listener callback
337
+ */
338
+ addMessageListener(key, listener) {
339
+ Object.keys(this.subs).forEach(k => {
340
+ const s = this.subs[k];
341
+ if (s.key === key) {
342
+ s.registerCallback(listener);
343
+ }
344
+ });
345
+ }
346
+ /**
347
+ * Updates the connection reference to all the previously
348
+ * registered publishers and subscribers.
349
+ * After we successfully establish a connection and register pubs/subs,
350
+ * it's possible for the connection to break. This object will try
351
+ * to re-establish a new connection every 3 seconds (or whatever configuration is set)
352
+ * and if a new connection is established, we need to pass that connection to
353
+ * all our pubs/subs, otherwise they'll be operating with old/stale references
354
+ * @param {Object} connRef a new connection reference to the AMQP service
355
+ */
356
+ updatePubsAndSubsConnectionRef(connRef) {
357
+ Object.keys(this.pubs).forEach(k => {
358
+ logger.debug(`Updating publisher ${k} with a new connection object`);
359
+ const p = this.pubs[k];
360
+ p.init(connRef);
361
+ });
362
+ Object.keys(this.subs).forEach(k => {
363
+ logger.debug(`Updating subscriber ${k} with a new connection object`);
364
+ const s = this.subs[k];
365
+ s.init(connRef);
366
+ });
367
+ }
368
+ }
369
+ const queue = new S4Queue();
370
+ export default queue;
371
+ //# sourceMappingURL=index.js.map