@sprucelabs/mercury-client 46.0.1 → 46.1.0
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.
- package/build/clients/MercuryClientFactory.js +2 -1
- package/build/clients/MercurySocketIoClient.d.ts +2 -2
- package/build/clients/MercurySocketIoClient.js +2 -2
- package/build/esm/clients/MercuryClientFactory.js +2 -1
- package/build/esm/clients/MercurySocketIoClient.d.ts +2 -2
- package/build/esm/clients/MercurySocketIoClient.js +2 -2
- package/build/esm/types/client.types.d.ts +2 -0
- package/build/types/client.types.d.ts +2 -0
- package/package.json +3 -3
|
@@ -10,7 +10,7 @@ const SpruceError_1 = __importDefault(require("../errors/SpruceError"));
|
|
|
10
10
|
const MutableContractClient_1 = __importDefault(require("./MutableContractClient"));
|
|
11
11
|
class MercuryClientFactory {
|
|
12
12
|
static async Client(connectionOptions) {
|
|
13
|
-
const { host: hostOption, contracts, reconnectDelayMs, allowSelfSignedCrt, emitTimeoutMs = this.timeoutMs, shouldReconnect, maxEmitRetries, connectionRetries, } = connectionOptions || {};
|
|
13
|
+
const { host: hostOption, contracts, reconnectDelayMs, allowSelfSignedCrt, emitTimeoutMs = this.timeoutMs, shouldReconnect, maxEmitRetries, connectionRetries, log, } = connectionOptions || {};
|
|
14
14
|
const host = hostOption ?? constants_1.DEFAULT_HOST;
|
|
15
15
|
if (host.substr(0, 4) !== 'http') {
|
|
16
16
|
throw new SpruceError_1.default({ code: 'INVALID_PROTOCOL', uri: host });
|
|
@@ -41,6 +41,7 @@ class MercuryClientFactory {
|
|
|
41
41
|
shouldReconnect,
|
|
42
42
|
maxEmitRetries,
|
|
43
43
|
connectionRetries,
|
|
44
|
+
log,
|
|
44
45
|
});
|
|
45
46
|
await client.connect();
|
|
46
47
|
this.totalClients++;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EmitCallback, EventContract, EventName, EventSignature, MercuryAggregateResponse, SpruceSchemas } from '@sprucelabs/mercury-types';
|
|
2
2
|
import { Schema, SchemaValues } from '@sprucelabs/schema';
|
|
3
|
-
import { io, SocketOptions, ManagerOptions } from 'socket.io-client';
|
|
3
|
+
import { io, Socket, SocketOptions, ManagerOptions } from 'socket.io-client';
|
|
4
4
|
import { ConnectionOptions, MercuryClient } from '../types/client.types';
|
|
5
5
|
export default class MercurySocketIoClient<Contract extends EventContract> implements MercuryClient<Contract> {
|
|
6
6
|
protected _eventContract?: Contract;
|
|
@@ -10,7 +10,7 @@ export default class MercurySocketIoClient<Contract extends EventContract> imple
|
|
|
10
10
|
private log;
|
|
11
11
|
private host;
|
|
12
12
|
private ioOptions;
|
|
13
|
-
|
|
13
|
+
protected socket?: Socket;
|
|
14
14
|
private proxyToken;
|
|
15
15
|
private emitTimeoutMs;
|
|
16
16
|
private reconnectDelayMs;
|
|
@@ -19,7 +19,6 @@ class MercurySocketIoClient {
|
|
|
19
19
|
this._eventContract = contract;
|
|
20
20
|
}
|
|
21
21
|
constructor(options) {
|
|
22
|
-
this.log = (0, spruce_skill_utils_1.buildLog)('MercurySocketIoClient');
|
|
23
22
|
this.proxyToken = null;
|
|
24
23
|
this.listenerMap = new WeakMap();
|
|
25
24
|
this.isReAuthing = false;
|
|
@@ -32,8 +31,9 @@ class MercurySocketIoClient {
|
|
|
32
31
|
this.isReconnecting = false;
|
|
33
32
|
this.skipWaitIfReconnecting = false;
|
|
34
33
|
this.shouldRegisterProxyOnReconnect = false;
|
|
35
|
-
const { host, eventContract, emitTimeoutMs, reconnectDelayMs, shouldReconnect, maxEmitRetries = 5, connectionRetries, ...ioOptions } = options;
|
|
34
|
+
const { host, eventContract, emitTimeoutMs, reconnectDelayMs, shouldReconnect, maxEmitRetries = 5, connectionRetries, log, ...ioOptions } = options;
|
|
36
35
|
this.host = host;
|
|
36
|
+
this.log = log ?? (0, spruce_skill_utils_1.buildLog)('MercurySocketIoClient');
|
|
37
37
|
this.ioOptions = { ...ioOptions, withCredentials: false };
|
|
38
38
|
this.eventContract = eventContract;
|
|
39
39
|
this.emitTimeoutMs = emitTimeoutMs ?? 30000;
|
|
@@ -16,7 +16,7 @@ class MercuryClientFactory {
|
|
|
16
16
|
static Client(connectionOptions) {
|
|
17
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
18
|
var _a;
|
|
19
|
-
const { host: hostOption, contracts, reconnectDelayMs, allowSelfSignedCrt, emitTimeoutMs = this.timeoutMs, shouldReconnect, maxEmitRetries, connectionRetries, } = connectionOptions || {};
|
|
19
|
+
const { host: hostOption, contracts, reconnectDelayMs, allowSelfSignedCrt, emitTimeoutMs = this.timeoutMs, shouldReconnect, maxEmitRetries, connectionRetries, log, } = connectionOptions || {};
|
|
20
20
|
const host = hostOption !== null && hostOption !== void 0 ? hostOption : DEFAULT_HOST;
|
|
21
21
|
if (host.substr(0, 4) !== 'http') {
|
|
22
22
|
throw new SpruceError({ code: 'INVALID_PROTOCOL', uri: host });
|
|
@@ -46,6 +46,7 @@ class MercuryClientFactory {
|
|
|
46
46
|
shouldReconnect,
|
|
47
47
|
maxEmitRetries,
|
|
48
48
|
connectionRetries,
|
|
49
|
+
log,
|
|
49
50
|
});
|
|
50
51
|
yield client.connect();
|
|
51
52
|
this.totalClients++;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EmitCallback, EventContract, EventName, EventSignature, MercuryAggregateResponse, SpruceSchemas } from '@sprucelabs/mercury-types';
|
|
2
2
|
import { Schema, SchemaValues } from '@sprucelabs/schema';
|
|
3
|
-
import { io, SocketOptions, ManagerOptions } from 'socket.io-client';
|
|
3
|
+
import { io, Socket, SocketOptions, ManagerOptions } from 'socket.io-client';
|
|
4
4
|
import { ConnectionOptions, MercuryClient } from '../types/client.types';
|
|
5
5
|
export default class MercurySocketIoClient<Contract extends EventContract> implements MercuryClient<Contract> {
|
|
6
6
|
protected _eventContract?: Contract;
|
|
@@ -10,7 +10,7 @@ export default class MercurySocketIoClient<Contract extends EventContract> imple
|
|
|
10
10
|
private log;
|
|
11
11
|
private host;
|
|
12
12
|
private ioOptions;
|
|
13
|
-
|
|
13
|
+
protected socket?: Socket;
|
|
14
14
|
private proxyToken;
|
|
15
15
|
private emitTimeoutMs;
|
|
16
16
|
private reconnectDelayMs;
|
|
@@ -33,7 +33,6 @@ class MercurySocketIoClient {
|
|
|
33
33
|
this._eventContract = contract;
|
|
34
34
|
}
|
|
35
35
|
constructor(options) {
|
|
36
|
-
this.log = buildLog('MercurySocketIoClient');
|
|
37
36
|
this.proxyToken = null;
|
|
38
37
|
this.listenerMap = new WeakMap();
|
|
39
38
|
this.isReAuthing = false;
|
|
@@ -46,8 +45,9 @@ class MercurySocketIoClient {
|
|
|
46
45
|
this.isReconnecting = false;
|
|
47
46
|
this.skipWaitIfReconnecting = false;
|
|
48
47
|
this.shouldRegisterProxyOnReconnect = false;
|
|
49
|
-
const { host, eventContract, emitTimeoutMs, reconnectDelayMs, shouldReconnect, maxEmitRetries = 5, connectionRetries } = options, ioOptions = __rest(options, ["host", "eventContract", "emitTimeoutMs", "reconnectDelayMs", "shouldReconnect", "maxEmitRetries", "connectionRetries"]);
|
|
48
|
+
const { host, eventContract, emitTimeoutMs, reconnectDelayMs, shouldReconnect, maxEmitRetries = 5, connectionRetries, log } = options, ioOptions = __rest(options, ["host", "eventContract", "emitTimeoutMs", "reconnectDelayMs", "shouldReconnect", "maxEmitRetries", "connectionRetries", "log"]);
|
|
50
49
|
this.host = host;
|
|
50
|
+
this.log = log !== null && log !== void 0 ? log : buildLog('MercurySocketIoClient');
|
|
51
51
|
this.ioOptions = Object.assign(Object.assign({}, ioOptions), { withCredentials: false });
|
|
52
52
|
this.eventContract = eventContract;
|
|
53
53
|
this.emitTimeoutMs = emitTimeoutMs !== null && emitTimeoutMs !== void 0 ? emitTimeoutMs : 30000;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EventContract, MercuryEventEmitter, SkillEventContract, SpruceSchemas } from '@sprucelabs/mercury-types';
|
|
2
|
+
import { Log } from '@sprucelabs/spruce-skill-utils';
|
|
2
3
|
export interface ConnectionOptions {
|
|
3
4
|
host?: string;
|
|
4
5
|
allowSelfSignedCrt?: boolean;
|
|
@@ -8,6 +9,7 @@ export interface ConnectionOptions {
|
|
|
8
9
|
shouldReconnect?: boolean;
|
|
9
10
|
maxEmitRetries?: number;
|
|
10
11
|
connectionRetries?: number;
|
|
12
|
+
log?: Log;
|
|
11
13
|
}
|
|
12
14
|
export type MercuryConnectFactory = (options?: ConnectionOptions) => Promise<MercuryClient>;
|
|
13
15
|
export type MercuryClient<Contract extends EventContract = SkillEventContract> = MercuryEventEmitter<Contract> & {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EventContract, MercuryEventEmitter, SkillEventContract, SpruceSchemas } from '@sprucelabs/mercury-types';
|
|
2
|
+
import { Log } from '@sprucelabs/spruce-skill-utils';
|
|
2
3
|
export interface ConnectionOptions {
|
|
3
4
|
host?: string;
|
|
4
5
|
allowSelfSignedCrt?: boolean;
|
|
@@ -8,6 +9,7 @@ export interface ConnectionOptions {
|
|
|
8
9
|
shouldReconnect?: boolean;
|
|
9
10
|
maxEmitRetries?: number;
|
|
10
11
|
connectionRetries?: number;
|
|
12
|
+
log?: Log;
|
|
11
13
|
}
|
|
12
14
|
export type MercuryConnectFactory = (options?: ConnectionOptions) => Promise<MercuryClient>;
|
|
13
15
|
export type MercuryClient<Contract extends EventContract = SkillEventContract> = MercuryEventEmitter<Contract> & {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "46.0
|
|
6
|
+
"version": "46.1.0",
|
|
7
7
|
"files": [
|
|
8
8
|
"build"
|
|
9
9
|
],
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"@sprucelabs/esm-postbuild": "^9.0.13",
|
|
85
85
|
"@sprucelabs/jest-json-reporter": "^10.0.19",
|
|
86
86
|
"@sprucelabs/mercury-core-events": "^29.0.1",
|
|
87
|
-
"@sprucelabs/mercury-event-emitter": "^46.0
|
|
87
|
+
"@sprucelabs/mercury-event-emitter": "^46.1.0",
|
|
88
88
|
"@sprucelabs/mercury-types": "^49.1.3",
|
|
89
89
|
"@sprucelabs/resolve-path-aliases": "^4.0.13",
|
|
90
90
|
"@sprucelabs/semantic-release": "^6.0.0",
|
|
@@ -120,5 +120,5 @@
|
|
|
120
120
|
"^#spruce/(.*)$": "<rootDir>/build/.spruce/$1"
|
|
121
121
|
}
|
|
122
122
|
},
|
|
123
|
-
"gitHead": "
|
|
123
|
+
"gitHead": "ac1ff0eeb859a4bb985ec0fd1d3b3461d73e6633"
|
|
124
124
|
}
|