@sprucelabs/mercury-client 42.0.129 → 42.0.131

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.
@@ -7,6 +7,7 @@ export default class MercurySocketIoClient<Contract extends EventContract> imple
7
7
  protected get eventContract(): Contract;
8
8
  protected set eventContract(contract: Contract);
9
9
  static io: typeof io;
10
+ private log;
10
11
  private host;
11
12
  private ioOptions;
12
13
  private socket?;
@@ -49,7 +50,6 @@ export default class MercurySocketIoClient<Contract extends EventContract> imple
49
50
  private attachConnectError;
50
51
  private attemptReconnectAfterDelay;
51
52
  protected reconnect(resolve: any, reject: any, retriesLeft: number): Promise<void>;
52
- private log;
53
53
  protected waitIfReconnecting(): Promise<void>;
54
54
  private reRegisterAllListeners;
55
55
  private mapSocketErrorToSpruceError;
@@ -7,6 +7,7 @@ exports.authenticateFqen = void 0;
7
7
  const error_1 = __importDefault(require("@sprucelabs/error"));
8
8
  const schema_1 = require("@sprucelabs/schema");
9
9
  const spruce_event_utils_1 = require("@sprucelabs/spruce-event-utils");
10
+ const spruce_skill_utils_1 = require("@sprucelabs/spruce-skill-utils");
10
11
  const socket_io_client_1 = require("socket.io-client");
11
12
  const SpruceError_1 = __importDefault(require("../errors/SpruceError"));
12
13
  const socketIoEventUtil_utility_1 = __importDefault(require("../utilities/socketIoEventUtil.utility"));
@@ -18,6 +19,7 @@ class MercurySocketIoClient {
18
19
  this._eventContract = contract;
19
20
  }
20
21
  constructor(options) {
22
+ this.log = (0, spruce_skill_utils_1.buildLog)('MercurySocketIoClient');
21
23
  this.proxyToken = null;
22
24
  this.listenerMap = new WeakMap();
23
25
  this.isReAuthing = false;
@@ -50,15 +52,13 @@ class MercurySocketIoClient {
50
52
  (_a = this.socket) === null || _a === void 0 ? void 0 : _a.on('connect', () => {
51
53
  var _a, _b;
52
54
  this.connectionRetriesRemaining = this.connectionRetries;
53
- //@ts-ignore
54
55
  (_a = this.socket) === null || _a === void 0 ? void 0 : _a.removeAllListeners();
55
- this.log(`Connection established!`);
56
56
  if (!this.isReconnecting) {
57
57
  this.emitStatusChange('connected');
58
58
  }
59
59
  if (this.shouldReconnect) {
60
60
  (_b = this.socket) === null || _b === void 0 ? void 0 : _b.once('disconnect', async (opts) => {
61
- this.log('Mercury disconnected, reason:', opts);
61
+ this.log.error('Mercury disconnected, reason:', opts);
62
62
  await this.attemptReconnectAfterDelay();
63
63
  });
64
64
  }
@@ -91,8 +91,8 @@ class MercurySocketIoClient {
91
91
  const error = this.mapSocketErrorToSpruceError(err);
92
92
  //@ts-ignore
93
93
  (_a = this.socket) === null || _a === void 0 ? void 0 : _a.removeAllListeners();
94
- this.log('Failed to connect to Mercury', error.message);
95
- this.log('Connection retries left', `${this.connectionRetriesRemaining}`);
94
+ this.log.error('Failed to connect to Mercury', error.message);
95
+ this.log.error('Connection retries left', `${this.connectionRetriesRemaining}`);
96
96
  if (this.connectionRetriesRemaining === 0) {
97
97
  reject === null || reject === void 0 ? void 0 : reject(error);
98
98
  return;
@@ -117,7 +117,6 @@ class MercurySocketIoClient {
117
117
  return;
118
118
  }
119
119
  this.emitStatusChange('disconnected');
120
- this.log('Attempting to reconnect...');
121
120
  delete this.authPromise;
122
121
  this.isReconnecting = true;
123
122
  this.proxyToken = null;
@@ -166,7 +165,6 @@ class MercurySocketIoClient {
166
165
  this.isReconnecting = false;
167
166
  this.skipWaitIfReconnecting = false;
168
167
  resolve();
169
- this.log(`Connection re-established with Mercury!`);
170
168
  }
171
169
  catch (err) {
172
170
  ;
@@ -187,9 +185,6 @@ class MercurySocketIoClient {
187
185
  }
188
186
  }
189
187
  }
190
- log(..._args) {
191
- // return console.log(...args)
192
- }
193
188
  async waitIfReconnecting() {
194
189
  await this.reconnectPromise;
195
190
  }
@@ -7,6 +7,7 @@ export default class MercurySocketIoClient<Contract extends EventContract> imple
7
7
  protected get eventContract(): Contract;
8
8
  protected set eventContract(contract: Contract);
9
9
  static io: typeof io;
10
+ private log;
10
11
  private host;
11
12
  private ioOptions;
12
13
  private socket?;
@@ -49,7 +50,6 @@ export default class MercurySocketIoClient<Contract extends EventContract> imple
49
50
  private attachConnectError;
50
51
  private attemptReconnectAfterDelay;
51
52
  protected reconnect(resolve: any, reject: any, retriesLeft: number): Promise<void>;
52
- private log;
53
53
  protected waitIfReconnecting(): Promise<void>;
54
54
  private reRegisterAllListeners;
55
55
  private mapSocketErrorToSpruceError;
@@ -21,6 +21,7 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  import AbstractSpruceError from '@sprucelabs/error';
22
22
  import { SchemaError, validateSchemaValues, } from '@sprucelabs/schema';
23
23
  import { eventContractUtil, eventResponseUtil, eventNameUtil, } from '@sprucelabs/spruce-event-utils';
24
+ import { buildLog } from '@sprucelabs/spruce-skill-utils';
24
25
  import { io } from 'socket.io-client';
25
26
  import SpruceError from '../errors/SpruceError.js';
26
27
  import socketIoEventUtil from '../utilities/socketIoEventUtil.utility.js';
@@ -32,6 +33,7 @@ class MercurySocketIoClient {
32
33
  this._eventContract = contract;
33
34
  }
34
35
  constructor(options) {
36
+ this.log = buildLog('MercurySocketIoClient');
35
37
  this.proxyToken = null;
36
38
  this.listenerMap = new WeakMap();
37
39
  this.isReAuthing = false;
@@ -65,15 +67,13 @@ class MercurySocketIoClient {
65
67
  (_a = this.socket) === null || _a === void 0 ? void 0 : _a.on('connect', () => {
66
68
  var _a, _b;
67
69
  this.connectionRetriesRemaining = this.connectionRetries;
68
- //@ts-ignore
69
70
  (_a = this.socket) === null || _a === void 0 ? void 0 : _a.removeAllListeners();
70
- this.log(`Connection established!`);
71
71
  if (!this.isReconnecting) {
72
72
  this.emitStatusChange('connected');
73
73
  }
74
74
  if (this.shouldReconnect) {
75
75
  (_b = this.socket) === null || _b === void 0 ? void 0 : _b.once('disconnect', (opts) => __awaiter(this, void 0, void 0, function* () {
76
- this.log('Mercury disconnected, reason:', opts);
76
+ this.log.error('Mercury disconnected, reason:', opts);
77
77
  yield this.attemptReconnectAfterDelay();
78
78
  }));
79
79
  }
@@ -107,8 +107,8 @@ class MercurySocketIoClient {
107
107
  const error = this.mapSocketErrorToSpruceError(err);
108
108
  //@ts-ignore
109
109
  (_b = this.socket) === null || _b === void 0 ? void 0 : _b.removeAllListeners();
110
- this.log('Failed to connect to Mercury', error.message);
111
- this.log('Connection retries left', `${this.connectionRetriesRemaining}`);
110
+ this.log.error('Failed to connect to Mercury', error.message);
111
+ this.log.error('Connection retries left', `${this.connectionRetriesRemaining}`);
112
112
  if (this.connectionRetriesRemaining === 0) {
113
113
  reject === null || reject === void 0 ? void 0 : reject(error);
114
114
  return;
@@ -134,7 +134,6 @@ class MercurySocketIoClient {
134
134
  return;
135
135
  }
136
136
  this.emitStatusChange('disconnected');
137
- this.log('Attempting to reconnect...');
138
137
  delete this.authPromise;
139
138
  this.isReconnecting = true;
140
139
  this.proxyToken = null;
@@ -185,7 +184,6 @@ class MercurySocketIoClient {
185
184
  this.isReconnecting = false;
186
185
  this.skipWaitIfReconnecting = false;
187
186
  resolve();
188
- this.log(`Connection re-established with Mercury!`);
189
187
  }
190
188
  catch (err) {
191
189
  ;
@@ -207,9 +205,6 @@ class MercurySocketIoClient {
207
205
  }
208
206
  });
209
207
  }
210
- log(..._args) {
211
- // return console.log(...args)
212
- }
213
208
  waitIfReconnecting() {
214
209
  return __awaiter(this, void 0, void 0, function* () {
215
210
  yield this.reconnectPromise;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "42.0.129",
6
+ "version": "42.0.131",
7
7
  "files": [
8
8
  "build"
9
9
  ],
@@ -63,28 +63,29 @@
63
63
  "watch.tsc": "tsc -w"
64
64
  },
65
65
  "dependencies": {
66
- "@sprucelabs/error": "^6.0.55",
67
- "@sprucelabs/schema": "^30.0.98",
68
- "@sprucelabs/spruce-core-schemas": "^40.1.38",
69
- "@sprucelabs/spruce-event-utils": "^40.0.107",
66
+ "@sprucelabs/error": "^6.0.56",
67
+ "@sprucelabs/schema": "^30.0.99",
68
+ "@sprucelabs/spruce-core-schemas": "^40.1.39",
69
+ "@sprucelabs/spruce-event-utils": "^40.0.108",
70
+ "@sprucelabs/spruce-skill-utils": "^31.0.109",
70
71
  "dotenv": "^16.4.5",
71
72
  "just-clone": "^6.2.0",
72
73
  "socket.io-client": "^4.7.5"
73
74
  },
74
75
  "devDependencies": {
75
- "@sprucelabs/esm-postbuild": "^6.0.42",
76
- "@sprucelabs/jest-json-reporter": "^8.0.61",
77
- "@sprucelabs/mercury-core-events": "^24.0.122",
78
- "@sprucelabs/mercury-event-emitter": "^42.0.129",
79
- "@sprucelabs/mercury-types": "^47.0.97",
80
- "@sprucelabs/resolve-path-aliases": "^2.0.40",
76
+ "@sprucelabs/esm-postbuild": "^6.0.43",
77
+ "@sprucelabs/jest-json-reporter": "^8.0.62",
78
+ "@sprucelabs/mercury-core-events": "^24.0.123",
79
+ "@sprucelabs/mercury-event-emitter": "^42.0.131",
80
+ "@sprucelabs/mercury-types": "^47.0.98",
81
+ "@sprucelabs/resolve-path-aliases": "^2.0.41",
81
82
  "@sprucelabs/semantic-release": "^5.0.1",
82
- "@sprucelabs/test": "^9.0.28",
83
- "@sprucelabs/test-utils": "^5.0.85",
84
- "@types/node": "^20.14.2",
83
+ "@sprucelabs/test": "^9.0.29",
84
+ "@sprucelabs/test-utils": "^5.0.86",
85
+ "@types/node": "^20.14.3",
85
86
  "chokidar-cli": "^3.0.0",
86
87
  "eslint": "^9.5.0",
87
- "eslint-config-spruce": "^11.2.23",
88
+ "eslint-config-spruce": "^11.2.24",
88
89
  "jest": "^29.7.0",
89
90
  "jest-circus": "^29.7.0",
90
91
  "prettier": "^3.3.2",
@@ -111,5 +112,5 @@
111
112
  "^#spruce/(.*)$": "<rootDir>/build/.spruce/$1"
112
113
  }
113
114
  },
114
- "gitHead": "c7fbbc7c9a60b98f2f278a2f54d8ac271fc47bf9"
115
+ "gitHead": "284c58ef553477d4a902cc44bfa2ce52c7f597a8"
115
116
  }