@sprucelabs/mercury-client 42.0.557 → 42.0.558
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/esm/.spruce/errors/errors.types.d.ts +324 -0
- package/build/esm/.spruce/errors/errors.types.js +1 -0
- package/build/esm/.spruce/errors/mercuryClient/connectionFailed.schema.d.ts +3 -0
- package/build/esm/.spruce/errors/mercuryClient/connectionFailed.schema.js +25 -0
- package/build/esm/.spruce/errors/mercuryClient/invalidEventSignature.schema.d.ts +3 -0
- package/build/esm/.spruce/errors/mercuryClient/invalidEventSignature.schema.js +25 -0
- package/build/esm/.spruce/errors/mercuryClient/invalidPayload.schema.d.ts +3 -0
- package/build/esm/.spruce/errors/mercuryClient/invalidPayload.schema.js +19 -0
- package/build/esm/.spruce/errors/mercuryClient/invalidProtocol.schema.d.ts +3 -0
- package/build/esm/.spruce/errors/mercuryClient/invalidProtocol.schema.js +19 -0
- package/build/esm/.spruce/errors/mercuryClient/missingTestCacheDir.schema.d.ts +3 -0
- package/build/esm/.spruce/errors/mercuryClient/missingTestCacheDir.schema.js +12 -0
- package/build/esm/.spruce/errors/mercuryClient/mustCreateEvent.schema.d.ts +3 -0
- package/build/esm/.spruce/errors/mercuryClient/mustCreateEvent.schema.js +19 -0
- package/build/esm/.spruce/errors/mercuryClient/mustHandleLocally.schema.d.ts +3 -0
- package/build/esm/.spruce/errors/mercuryClient/mustHandleLocally.schema.js +19 -0
- package/build/esm/.spruce/errors/mercuryClient/notConnected.schema.d.ts +3 -0
- package/build/esm/.spruce/errors/mercuryClient/notConnected.schema.js +25 -0
- package/build/esm/.spruce/errors/mercuryClient/timeout.schema.d.ts +3 -0
- package/build/esm/.spruce/errors/mercuryClient/timeout.schema.js +35 -0
- package/build/esm/.spruce/errors/mercuryClient/unauthorizedAccess.schema.d.ts +3 -0
- package/build/esm/.spruce/errors/mercuryClient/unauthorizedAccess.schema.js +41 -0
- package/build/esm/.spruce/errors/mercuryClient/unauthorizedTarget.schema.d.ts +3 -0
- package/build/esm/.spruce/errors/mercuryClient/unauthorizedTarget.schema.js +38 -0
- package/build/esm/.spruce/errors/mercuryClient/unexpectedPayload.schema.d.ts +3 -0
- package/build/esm/.spruce/errors/mercuryClient/unexpectedPayload.schema.js +19 -0
- package/build/esm/.spruce/errors/mercuryClient/unknownError.schema.d.ts +3 -0
- package/build/esm/.spruce/errors/mercuryClient/unknownError.schema.js +12 -0
- package/build/esm/.spruce/errors/options.types.d.ts +40 -0
- package/build/esm/.spruce/errors/options.types.js +1 -0
- package/build/esm/.spruce/event-cache.json +1 -0
- package/build/esm/.spruce/schemas/fields/fieldClassMap.d.ts +2 -0
- package/build/esm/.spruce/schemas/fields/fieldClassMap.js +5 -0
- package/build/esm/.spruce/schemas/fields/fields.types.d.ts +1 -0
- package/build/esm/.spruce/schemas/fields/fields.types.js +3 -0
- package/build/esm/.spruce/schemas/schemas.types.d.ts +1 -0
- package/build/esm/.spruce/schemas/schemas.types.js +3 -0
- package/build/esm/.spruce/settings.json +26 -0
- package/build/esm/clients/MercuryClientFactory.d.ts +26 -0
- package/build/esm/clients/MercuryClientFactory.js +96 -0
- package/build/esm/clients/MercurySocketIoClient.d.ts +89 -0
- package/build/esm/clients/MercurySocketIoClient.js +605 -0
- package/build/esm/clients/MercuryTestClient.d.ts +57 -0
- package/build/esm/clients/MercuryTestClient.js +389 -0
- package/build/esm/clients/MutableContractClient.d.ts +10 -0
- package/build/esm/clients/MutableContractClient.js +43 -0
- package/build/esm/clients/statusChangePayloadSchema.d.ts +103 -0
- package/build/esm/clients/statusChangePayloadSchema.js +45 -0
- package/build/esm/constants.d.ts +1 -0
- package/build/esm/constants.js +1 -0
- package/build/esm/errors/SpruceError.d.ts +5 -0
- package/build/esm/errors/SpruceError.js +66 -0
- package/build/esm/errors/connectionFailed.builder.d.ts +16 -0
- package/build/esm/errors/connectionFailed.builder.js +16 -0
- package/build/esm/errors/invalidEventSignature.builder.d.ts +15 -0
- package/build/esm/errors/invalidEventSignature.builder.js +15 -0
- package/build/esm/errors/invalidPayload.builder.d.ts +12 -0
- package/build/esm/errors/invalidPayload.builder.js +12 -0
- package/build/esm/errors/invalidProtocol.builder.d.ts +12 -0
- package/build/esm/errors/invalidProtocol.builder.js +12 -0
- package/build/esm/errors/missingTestCacheDir.builder.d.ts +7 -0
- package/build/esm/errors/missingTestCacheDir.builder.js +7 -0
- package/build/esm/errors/mustCreateEvent.builder.d.ts +11 -0
- package/build/esm/errors/mustCreateEvent.builder.js +11 -0
- package/build/esm/errors/mustHandleLocally.builder.d.ts +11 -0
- package/build/esm/errors/mustHandleLocally.builder.js +11 -0
- package/build/esm/errors/notConnected.builder.d.ts +16 -0
- package/build/esm/errors/notConnected.builder.js +16 -0
- package/build/esm/errors/timeout.builder.d.ts +22 -0
- package/build/esm/errors/timeout.builder.js +22 -0
- package/build/esm/errors/unauthorizedAccess.builder.d.ts +57 -0
- package/build/esm/errors/unauthorizedAccess.builder.js +39 -0
- package/build/esm/errors/unexpectedPayload.builder.d.ts +12 -0
- package/build/esm/errors/unexpectedPayload.builder.js +12 -0
- package/build/esm/errors/unknownError.builder.d.ts +6 -0
- package/build/esm/errors/unknownError.builder.js +6 -0
- package/build/esm/index.d.ts +6 -0
- package/build/esm/index.js +6 -0
- package/build/esm/tests/AbstractClientTest.d.ts +31 -0
- package/build/esm/tests/AbstractClientTest.js +212 -0
- package/build/esm/tests/constants.d.ts +9 -0
- package/build/esm/tests/constants.js +11 -0
- package/build/esm/types/client.types.d.ts +30 -0
- package/build/esm/types/client.types.js +1 -0
- package/build/esm/utilities/socketIoEventUtil.utility.d.ts +5 -0
- package/build/esm/utilities/socketIoEventUtil.utility.js +9 -0
- package/package.json +12 -12
- package/build/__tests__/behavioral/AuthenticatingAndReauthenticating.test.d.ts +0 -21
- package/build/__tests__/behavioral/AuthenticatingAndReauthenticating.test.js +0 -287
- package/build/__tests__/behavioral/AuthenticatingAndReauthenticating.test.js.map +0 -1
- package/build/__tests__/behavioral/DisablingPermissionChecksWhenEmittingLocally.test.d.ts +0 -7
- package/build/__tests__/behavioral/DisablingPermissionChecksWhenEmittingLocally.test.js +0 -49
- package/build/__tests__/behavioral/DisablingPermissionChecksWhenEmittingLocally.test.js.map +0 -1
- package/build/__tests__/behavioral/EmittingAndFlatteningResponses.test.d.ts +0 -52
- package/build/__tests__/behavioral/EmittingAndFlatteningResponses.test.js +0 -123
- package/build/__tests__/behavioral/EmittingAndFlatteningResponses.test.js.map +0 -1
- package/build/__tests__/behavioral/EmittingConnectionChangeInTests.test.d.ts +0 -9
- package/build/__tests__/behavioral/EmittingConnectionChangeInTests.test.js +0 -103
- package/build/__tests__/behavioral/EmittingConnectionChangeInTests.test.js.map +0 -1
- package/build/__tests__/behavioral/LocallyHandlingAuthenticateDelaysConnect.test.d.ts +0 -7
- package/build/__tests__/behavioral/LocallyHandlingAuthenticateDelaysConnect.test.js +0 -91
- package/build/__tests__/behavioral/LocallyHandlingAuthenticateDelaysConnect.test.js.map +0 -1
- package/build/__tests__/behavioral/MercuryClientFactory.test.d.ts +0 -7
- package/build/__tests__/behavioral/MercuryClientFactory.test.js +0 -85
- package/build/__tests__/behavioral/MercuryClientFactory.test.js.map +0 -1
- package/build/__tests__/behavioral/ProxyingEvents.test.d.ts +0 -11
- package/build/__tests__/behavioral/ProxyingEvents.test.js +0 -99
- package/build/__tests__/behavioral/ProxyingEvents.test.js.map +0 -1
- package/build/__tests__/behavioral/ReconnectingAutomatically.test.d.ts +0 -33
- package/build/__tests__/behavioral/ReconnectingAutomatically.test.js +0 -390
- package/build/__tests__/behavioral/ReconnectingAutomatically.test.js.map +0 -1
- package/build/__tests__/behavioral/RequiringLocalListeners.test.d.ts +0 -7
- package/build/__tests__/behavioral/RequiringLocalListeners.test.js +0 -65
- package/build/__tests__/behavioral/RequiringLocalListeners.test.js.map +0 -1
- package/build/__tests__/behavioral/SettingNamespacesThatMustBeHandledLocally.test.d.ts +0 -9
- package/build/__tests__/behavioral/SettingNamespacesThatMustBeHandledLocally.test.js +0 -66
- package/build/__tests__/behavioral/SettingNamespacesThatMustBeHandledLocally.test.js.map +0 -1
- package/build/__tests__/behavioral/SimulatingEventsForTesting.test.d.ts +0 -51
- package/build/__tests__/behavioral/SimulatingEventsForTesting.test.js +0 -821
- package/build/__tests__/behavioral/SimulatingEventsForTesting.test.js.map +0 -1
- package/build/__tests__/behavioral/TestClientSpeedTests.test.d.ts +0 -7
- package/build/__tests__/behavioral/TestClientSpeedTests.test.js +0 -44
- package/build/__tests__/behavioral/TestClientSpeedTests.test.js.map +0 -1
- package/build/__tests__/behavioral/TestingWithDefaultContracts.test.d.ts +0 -7
- package/build/__tests__/behavioral/TestingWithDefaultContracts.test.js +0 -56
- package/build/__tests__/behavioral/TestingWithDefaultContracts.test.js.map +0 -1
- package/build/__tests__/behavioral/TurningOffAListener.test.d.ts +0 -16
- package/build/__tests__/behavioral/TurningOffAListener.test.js +0 -126
- package/build/__tests__/behavioral/TurningOffAListener.test.js.map +0 -1
- package/build/__tests__/behavioral/UsingMercuryClient.test.d.ts +0 -45
- package/build/__tests__/behavioral/UsingMercuryClient.test.js +0 -662
- package/build/__tests__/behavioral/UsingMercuryClient.test.js.map +0 -1
- /package/build/{.spruce → esm/.spruce}/errors/errors.types.js.map +0 -0
- /package/build/{.spruce → esm/.spruce}/errors/mercuryClient/connectionFailed.schema.js.map +0 -0
- /package/build/{.spruce → esm/.spruce}/errors/mercuryClient/invalidEventSignature.schema.js.map +0 -0
- /package/build/{.spruce → esm/.spruce}/errors/mercuryClient/invalidPayload.schema.js.map +0 -0
- /package/build/{.spruce → esm/.spruce}/errors/mercuryClient/invalidProtocol.schema.js.map +0 -0
- /package/build/{.spruce → esm/.spruce}/errors/mercuryClient/missingTestCacheDir.schema.js.map +0 -0
- /package/build/{.spruce → esm/.spruce}/errors/mercuryClient/mustCreateEvent.schema.js.map +0 -0
- /package/build/{.spruce → esm/.spruce}/errors/mercuryClient/mustHandleLocally.schema.js.map +0 -0
- /package/build/{.spruce → esm/.spruce}/errors/mercuryClient/notConnected.schema.js.map +0 -0
- /package/build/{.spruce → esm/.spruce}/errors/mercuryClient/timeout.schema.js.map +0 -0
- /package/build/{.spruce → esm/.spruce}/errors/mercuryClient/unauthorizedAccess.schema.js.map +0 -0
- /package/build/{.spruce → esm/.spruce}/errors/mercuryClient/unauthorizedTarget.schema.js.map +0 -0
- /package/build/{.spruce → esm/.spruce}/errors/mercuryClient/unexpectedPayload.schema.js.map +0 -0
- /package/build/{.spruce → esm/.spruce}/errors/mercuryClient/unknownError.schema.js.map +0 -0
- /package/build/{.spruce → esm/.spruce}/errors/options.types.js.map +0 -0
- /package/build/{.spruce → esm/.spruce}/schemas/fields/fieldClassMap.js.map +0 -0
- /package/build/{.spruce → esm/.spruce}/schemas/fields/fields.types.js.map +0 -0
- /package/build/{.spruce → esm/.spruce}/schemas/schemas.types.js.map +0 -0
- /package/build/{clients → esm/clients}/MercuryClientFactory.js.map +0 -0
- /package/build/{clients → esm/clients}/MercurySocketIoClient.js.map +0 -0
- /package/build/{clients → esm/clients}/MercuryTestClient.js.map +0 -0
- /package/build/{clients → esm/clients}/MutableContractClient.js.map +0 -0
- /package/build/{clients → esm/clients}/statusChangePayloadSchema.js.map +0 -0
- /package/build/{constants.js.map → esm/constants.js.map} +0 -0
- /package/build/{errors → esm/errors}/SpruceError.js.map +0 -0
- /package/build/{errors → esm/errors}/connectionFailed.builder.js.map +0 -0
- /package/build/{errors → esm/errors}/invalidEventSignature.builder.js.map +0 -0
- /package/build/{errors → esm/errors}/invalidPayload.builder.js.map +0 -0
- /package/build/{errors → esm/errors}/invalidProtocol.builder.js.map +0 -0
- /package/build/{errors → esm/errors}/missingTestCacheDir.builder.js.map +0 -0
- /package/build/{errors → esm/errors}/mustCreateEvent.builder.js.map +0 -0
- /package/build/{errors → esm/errors}/mustHandleLocally.builder.js.map +0 -0
- /package/build/{errors → esm/errors}/notConnected.builder.js.map +0 -0
- /package/build/{errors → esm/errors}/timeout.builder.js.map +0 -0
- /package/build/{errors → esm/errors}/unauthorizedAccess.builder.js.map +0 -0
- /package/build/{errors → esm/errors}/unexpectedPayload.builder.js.map +0 -0
- /package/build/{errors → esm/errors}/unknownError.builder.js.map +0 -0
- /package/build/{index.js.map → esm/index.js.map} +0 -0
- /package/build/{tests → esm/tests}/AbstractClientTest.js.map +0 -0
- /package/build/{tests → esm/tests}/constants.js.map +0 -0
- /package/build/{types → esm/types}/client.types.js.map +0 -0
- /package/build/{utilities → esm/utilities}/socketIoEventUtil.utility.js.map +0 -0
|
@@ -1,662 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const error_1 = __importDefault(require("@sprucelabs/error"));
|
|
13
|
-
const spruce_event_utils_1 = require("@sprucelabs/spruce-event-utils");
|
|
14
|
-
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
15
|
-
const MercuryClientFactory_1 = __importDefault(require("../../clients/MercuryClientFactory"));
|
|
16
|
-
const MercurySocketIoClient_1 = __importDefault(require("../../clients/MercurySocketIoClient"));
|
|
17
|
-
const SpruceError_1 = __importDefault(require("../../errors/SpruceError"));
|
|
18
|
-
const AbstractClientTest_1 = __importDefault(require("../../tests/AbstractClientTest"));
|
|
19
|
-
const constants_1 = require("../../tests/constants");
|
|
20
|
-
require('dotenv').config();
|
|
21
|
-
class UsingMercuryClient extends AbstractClientTest_1.default {
|
|
22
|
-
static async afterEach() {
|
|
23
|
-
if (this.timeoutClient) {
|
|
24
|
-
this.timeoutClient.socket = null;
|
|
25
|
-
}
|
|
26
|
-
await super.afterEach();
|
|
27
|
-
}
|
|
28
|
-
static async factoryCanCreateClient() {
|
|
29
|
-
test_utils_1.assert.isTruthy(MercuryClientFactory_1.default.Client);
|
|
30
|
-
}
|
|
31
|
-
static async allowsEmptyContracts() {
|
|
32
|
-
const client = await MercuryClientFactory_1.default.Client({
|
|
33
|
-
host: constants_1.TEST_HOST,
|
|
34
|
-
allowSelfSignedCrt: true,
|
|
35
|
-
});
|
|
36
|
-
this.clients.push(client);
|
|
37
|
-
}
|
|
38
|
-
static async factoryClientCountStartsAtZero() {
|
|
39
|
-
test_utils_1.assert.isFunction(MercuryClientFactory_1.default.getTotalClients);
|
|
40
|
-
test_utils_1.assert.isEqual(MercuryClientFactory_1.default.getTotalClients(), 0);
|
|
41
|
-
test_utils_1.assert.isLength(MercuryClientFactory_1.default.getClients(), 0);
|
|
42
|
-
const client = await this.connectToApi();
|
|
43
|
-
test_utils_1.assert.isEqual(MercuryClientFactory_1.default.getTotalClients(), 1);
|
|
44
|
-
test_utils_1.assert.isEqual(MercuryClientFactory_1.default.getClients()[0], client);
|
|
45
|
-
const client2 = await this.connectToApi();
|
|
46
|
-
test_utils_1.assert.isEqual(MercuryClientFactory_1.default.getTotalClients(), 2);
|
|
47
|
-
test_utils_1.assert.isEqual(MercuryClientFactory_1.default.getClients()[1], client2);
|
|
48
|
-
}
|
|
49
|
-
static async connectingToBadProtocolThrows() {
|
|
50
|
-
const err = await test_utils_1.assert.doesThrowAsync(() => MercuryClientFactory_1.default.Client({
|
|
51
|
-
host: 'aoeu://tasty.org',
|
|
52
|
-
contracts: [],
|
|
53
|
-
}));
|
|
54
|
-
test_utils_1.errorAssert.assertError(err, 'INVALID_PROTOCOL');
|
|
55
|
-
}
|
|
56
|
-
static async factoryReturnsSocketIoClient() {
|
|
57
|
-
const client = await this.connectToApi();
|
|
58
|
-
test_utils_1.assert.isTruthy(client instanceof MercurySocketIoClient_1.default);
|
|
59
|
-
test_utils_1.assert.isTrue(client.isConnected());
|
|
60
|
-
await client.disconnect();
|
|
61
|
-
test_utils_1.assert.isFalse(client.isConnected());
|
|
62
|
-
}
|
|
63
|
-
static async throwsWithBadEventName() {
|
|
64
|
-
const client = await this.connectToApi();
|
|
65
|
-
//@ts-ignore
|
|
66
|
-
const err = await test_utils_1.assert.doesThrowAsync(() => client.emit('health2'));
|
|
67
|
-
test_utils_1.errorAssert.assertError(err, 'INVALID_EVENT_NAME');
|
|
68
|
-
}
|
|
69
|
-
static async throwsWithHelpfulErrorWithInvalidPayload() {
|
|
70
|
-
const client = await this.connectToApi();
|
|
71
|
-
const err = await test_utils_1.assert.doesThrowAsync(() =>
|
|
72
|
-
//@ts-ignore
|
|
73
|
-
client.emit('get-skill::v2020_12_25', { taco: 'true' }));
|
|
74
|
-
test_utils_1.assert.doesInclude(err.message, 'taco');
|
|
75
|
-
}
|
|
76
|
-
static async throwsHelpfulErrorWhenCantReachHost() {
|
|
77
|
-
const host = 'https://wontfindthisanywhere.com';
|
|
78
|
-
const err = await test_utils_1.assert.doesThrowAsync(() => this.connectToApi({
|
|
79
|
-
host,
|
|
80
|
-
reconnectDelayMs: 10,
|
|
81
|
-
connectionRetries: 0,
|
|
82
|
-
}));
|
|
83
|
-
test_utils_1.errorAssert.assertError(err, 'CONNECTION_FAILED', {
|
|
84
|
-
host,
|
|
85
|
-
statusCode: 503,
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
static async triesToReconnect5TimesMax() {
|
|
89
|
-
const client = await this.connectToApi({ reconnectDelayMs: 100 });
|
|
90
|
-
let count = 0;
|
|
91
|
-
//@ts-ignore
|
|
92
|
-
client.connect = () => {
|
|
93
|
-
count++;
|
|
94
|
-
throw new SpruceError_1.default({
|
|
95
|
-
code: 'CONNECTION_FAILED',
|
|
96
|
-
host: 'no-found',
|
|
97
|
-
statusCode: 305,
|
|
98
|
-
});
|
|
99
|
-
};
|
|
100
|
-
//@ts-ignore
|
|
101
|
-
await test_utils_1.assert.doesThrowAsync(() => client.attemptReconnectAfterDelay());
|
|
102
|
-
test_utils_1.assert.isEqual(count, 5);
|
|
103
|
-
}
|
|
104
|
-
static async getsAccessDeniedWhenTryingToListenToUnknownEventAnonymously() {
|
|
105
|
-
const client = await this.connectToApi();
|
|
106
|
-
const err = await test_utils_1.assert.doesThrowAsync(() =>
|
|
107
|
-
//@ts-ignore
|
|
108
|
-
client.on('waka-waka', () => { }));
|
|
109
|
-
test_utils_1.errorAssert.assertError(err, 'UNAUTHORIZED_ACCESS');
|
|
110
|
-
}
|
|
111
|
-
static async cantEmitEventWithWithInvalidPayload() {
|
|
112
|
-
const client = await this.connectToApi();
|
|
113
|
-
const err = await test_utils_1.assert.doesThrowAsync(() =>
|
|
114
|
-
//@ts-ignore
|
|
115
|
-
client.emit('request-pin::v2020_12_25', {}));
|
|
116
|
-
test_utils_1.errorAssert.assertError(err, 'INVALID_PAYLOAD', {
|
|
117
|
-
eventName: 'request-pin',
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
static async canRunHealthCheck() {
|
|
121
|
-
const client = await this.connectToApi();
|
|
122
|
-
const results = await client.emit('health::v2020_12_25');
|
|
123
|
-
test_utils_1.assert.isEqualDeep(results.responses[0].payload, {
|
|
124
|
-
skill: { status: 'passed' },
|
|
125
|
-
mercury: { status: 'passed' },
|
|
126
|
-
});
|
|
127
|
-
await client.disconnect();
|
|
128
|
-
}
|
|
129
|
-
static async skillsCanListenToEachOther() {
|
|
130
|
-
const { org, skill1, skill1Client, skill2Client } = await this.setup2SkillsAndOneEvent();
|
|
131
|
-
let newEventTriggered = false;
|
|
132
|
-
//@ts-ignore
|
|
133
|
-
await skill2Client.on(`${skill1.slug}.will-send-vip::v1`, () => {
|
|
134
|
-
newEventTriggered = true;
|
|
135
|
-
return {
|
|
136
|
-
messages: ['hello world'],
|
|
137
|
-
};
|
|
138
|
-
});
|
|
139
|
-
const results = await skill1Client.emit(
|
|
140
|
-
//@ts-ignore
|
|
141
|
-
`${skill1.slug}.will-send-vip::v1`, {
|
|
142
|
-
target: {
|
|
143
|
-
organizationId: org.id,
|
|
144
|
-
},
|
|
145
|
-
});
|
|
146
|
-
test_utils_1.assert.isEqual(results.totalErrors, 0);
|
|
147
|
-
test_utils_1.assert.isTrue(newEventTriggered);
|
|
148
|
-
}
|
|
149
|
-
static async errorsInListenersRetainOptions() {
|
|
150
|
-
const error = new SpruceError_1.default({
|
|
151
|
-
code: 'UNKNOWN_ERROR',
|
|
152
|
-
//@ts-ignore
|
|
153
|
-
param: 1,
|
|
154
|
-
test: 1,
|
|
155
|
-
});
|
|
156
|
-
const results = await this.setup2Skills1EventAddThrowingListenerAndEmit(
|
|
157
|
-
//@ts-ignore
|
|
158
|
-
error);
|
|
159
|
-
test_utils_1.assert.isEqual(results.totalErrors, 1);
|
|
160
|
-
spruce_event_utils_1.eventAssertUtil.assertErrorFromResponse(results, 'UNKNOWN_ERROR', {
|
|
161
|
-
param: 1,
|
|
162
|
-
test: 1,
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
static async retainsGeneratedFriendlyMessage() {
|
|
166
|
-
class TestError extends error_1.default {
|
|
167
|
-
friendlyMessage() {
|
|
168
|
-
return 'test this dude!';
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
const results = await this.setup2Skills1EventAddThrowingListenerAndEmit(
|
|
172
|
-
//@ts-ignore
|
|
173
|
-
new TestError({ code: 'INVALID_PARAMETERS' }));
|
|
174
|
-
test_utils_1.assert.isEqual(
|
|
175
|
-
//@ts-ignore
|
|
176
|
-
results.responses[0].errors[0].message, 'test this dude!');
|
|
177
|
-
}
|
|
178
|
-
static async nonSpruceErrorsArePassedBackAsListenerErrors() {
|
|
179
|
-
const { org, skill1, skill1Client, skill2Client } = await this.setup2SkillsAndOneEvent();
|
|
180
|
-
const fqen = `${skill1.slug}.will-send-vip::v1`;
|
|
181
|
-
//@ts-ignore
|
|
182
|
-
await skill2Client.on(fqen, () => {
|
|
183
|
-
throw new Error('oh shoot');
|
|
184
|
-
});
|
|
185
|
-
//@ts-ignore
|
|
186
|
-
const results = await skill1Client.emit(fqen, {
|
|
187
|
-
target: {
|
|
188
|
-
organizationId: org.id,
|
|
189
|
-
},
|
|
190
|
-
});
|
|
191
|
-
test_utils_1.assert.isEqual(results.totalErrors, 1);
|
|
192
|
-
const err = spruce_event_utils_1.eventAssertUtil.assertErrorFromResponse(results, 'LISTENER_ERROR');
|
|
193
|
-
//@ts-ignore
|
|
194
|
-
test_utils_1.assert.isEqual(err.options.fqen, fqen);
|
|
195
|
-
test_utils_1.assert.doesInclude(results.responses[0].errors?.[0].message, 'oh shoot');
|
|
196
|
-
}
|
|
197
|
-
static async emitterGetsCalledBackForEachListener(shouldDisconnect = false) {
|
|
198
|
-
const { org, client, skill1, skill1Client, skill2Client } = await this.setup2SkillsAndOneEvent(constants_1.DEMO_PHONE_RECONNECT);
|
|
199
|
-
const { client: skill3Client } = await this.seedInstallAndLoginAsSkill(client, org.id);
|
|
200
|
-
const { client: skill4Client } = await this.seedInstallAndLoginAsSkill(client, org.id);
|
|
201
|
-
let listenTriggerCount = 0;
|
|
202
|
-
//@ts-ignore
|
|
203
|
-
await skill2Client.on(`${skill1.slug}.will-send-vip::v1`, () => {
|
|
204
|
-
listenTriggerCount++;
|
|
205
|
-
return {
|
|
206
|
-
messages: ['hello from skill 2'],
|
|
207
|
-
};
|
|
208
|
-
});
|
|
209
|
-
//@ts-ignore
|
|
210
|
-
await skill3Client.on(`${skill1.slug}.will-send-vip::v1`, () => {
|
|
211
|
-
listenTriggerCount++;
|
|
212
|
-
return {
|
|
213
|
-
messages: ['hello from skill 3'],
|
|
214
|
-
};
|
|
215
|
-
});
|
|
216
|
-
//@ts-ignore
|
|
217
|
-
await skill4Client.on(`${skill1.slug}.will-send-vip::v1`, () => {
|
|
218
|
-
listenTriggerCount++;
|
|
219
|
-
return {
|
|
220
|
-
messages: ['hello from skill 4'],
|
|
221
|
-
};
|
|
222
|
-
});
|
|
223
|
-
if (shouldDisconnect) {
|
|
224
|
-
//@ts-ignore
|
|
225
|
-
client.socket.disconnect();
|
|
226
|
-
//@ts-ignore
|
|
227
|
-
skill1Client.socket.disconnect();
|
|
228
|
-
//@ts-ignore
|
|
229
|
-
skill2Client.socket.disconnect();
|
|
230
|
-
do {
|
|
231
|
-
await this.wait(1000);
|
|
232
|
-
} while (!skill1Client.isConnected() ||
|
|
233
|
-
!skill2Client.isConnected() ||
|
|
234
|
-
!client.isConnected());
|
|
235
|
-
}
|
|
236
|
-
let responseTriggerCount = 0;
|
|
237
|
-
await skill1Client.emit(
|
|
238
|
-
//@ts-ignore
|
|
239
|
-
`${skill1.slug}.will-send-vip::v1`, {
|
|
240
|
-
//@ts-ignore
|
|
241
|
-
target: {
|
|
242
|
-
organizationId: org.id,
|
|
243
|
-
},
|
|
244
|
-
}, () => {
|
|
245
|
-
responseTriggerCount++;
|
|
246
|
-
});
|
|
247
|
-
test_utils_1.assert.isEqual(listenTriggerCount, 3);
|
|
248
|
-
test_utils_1.assert.isEqual(responseTriggerCount, 3);
|
|
249
|
-
}
|
|
250
|
-
static async eachResponseMustFinishBeforeEmitReturns() {
|
|
251
|
-
const { org, client, skill1, skill1Client, skill2Client } = await this.setup2SkillsAndOneEvent(constants_1.DEMO_PHONE_RECONNECT);
|
|
252
|
-
const { client: skill3Client } = await this.seedInstallAndLoginAsSkill(client, org.id);
|
|
253
|
-
//@ts-ignore
|
|
254
|
-
await skill2Client.on(`${skill1.slug}.will-send-vip::v1`, async () => {
|
|
255
|
-
return {
|
|
256
|
-
messages: ['hello from skill 2'],
|
|
257
|
-
};
|
|
258
|
-
});
|
|
259
|
-
//@ts-ignore
|
|
260
|
-
await skill3Client.on(`${skill1.slug}.will-send-vip::v1`, async () => {
|
|
261
|
-
return {
|
|
262
|
-
messages: ['hello from skill 2'],
|
|
263
|
-
};
|
|
264
|
-
});
|
|
265
|
-
let ttl = 1000;
|
|
266
|
-
let hitCount = 0;
|
|
267
|
-
let wasHit = false;
|
|
268
|
-
await skill1Client.emit(
|
|
269
|
-
//@ts-ignore
|
|
270
|
-
`${skill1.slug}.will-send-vip::v1`, {
|
|
271
|
-
//@ts-ignore
|
|
272
|
-
target: {
|
|
273
|
-
organizationId: org.id,
|
|
274
|
-
},
|
|
275
|
-
}, async () => {
|
|
276
|
-
if (!wasHit) {
|
|
277
|
-
wasHit = true;
|
|
278
|
-
await new Promise((r) => setTimeout(r, ttl));
|
|
279
|
-
}
|
|
280
|
-
hitCount++;
|
|
281
|
-
});
|
|
282
|
-
test_utils_1.assert.isEqual(hitCount, 2);
|
|
283
|
-
}
|
|
284
|
-
static async offRemovesListener() {
|
|
285
|
-
const { org, skill1, skill1Client, skill2Client } = await this.setup2SkillsAndOneEvent();
|
|
286
|
-
let listenerTriggerCount = 0;
|
|
287
|
-
const eventName = `${skill1.slug}.will-send-vip::v1`;
|
|
288
|
-
//@ts-ignore
|
|
289
|
-
await skill2Client.on(eventName, () => {
|
|
290
|
-
listenerTriggerCount++;
|
|
291
|
-
return {
|
|
292
|
-
messages: ['hello world'],
|
|
293
|
-
};
|
|
294
|
-
});
|
|
295
|
-
//@ts-ignore
|
|
296
|
-
await skill1Client.emit(eventName, {
|
|
297
|
-
target: {
|
|
298
|
-
organizationId: org.id,
|
|
299
|
-
},
|
|
300
|
-
});
|
|
301
|
-
//@ts-ignore
|
|
302
|
-
const offCount = await skill2Client.off(eventName);
|
|
303
|
-
test_utils_1.assert.isEqual(offCount, 1);
|
|
304
|
-
//@ts-ignore
|
|
305
|
-
await skill1Client.emit(eventName, {
|
|
306
|
-
target: {
|
|
307
|
-
organizationId: org.id,
|
|
308
|
-
},
|
|
309
|
-
});
|
|
310
|
-
test_utils_1.assert.isEqual(listenerTriggerCount, 1);
|
|
311
|
-
}
|
|
312
|
-
static async throwsWhenEmittingWhenNotConnected() {
|
|
313
|
-
const client = await this.connectToApi();
|
|
314
|
-
await client.disconnect();
|
|
315
|
-
const err = await test_utils_1.assert.doesThrowAsync(() => client.emit('health::v2020_12_25'));
|
|
316
|
-
test_utils_1.errorAssert.assertError(err, 'NOT_CONNECTED');
|
|
317
|
-
}
|
|
318
|
-
static async serverSideErrorsMappedToSpruceErrors() {
|
|
319
|
-
const client = await this.connectToApi();
|
|
320
|
-
const response = await client.emit('register-skill::v2020_12_25', {
|
|
321
|
-
payload: { name: 'test' },
|
|
322
|
-
});
|
|
323
|
-
const errors = response.responses[0].errors;
|
|
324
|
-
test_utils_1.assert.isTruthy(errors);
|
|
325
|
-
test_utils_1.errorAssert.assertError(errors[0], 'UNAUTHORIZED_ACCESS');
|
|
326
|
-
}
|
|
327
|
-
static async timesOutWhenEmittingEventThatIsNeverHandled(maxEmitRetries) {
|
|
328
|
-
const client = await this.TimeoutClient(undefined, maxEmitRetries);
|
|
329
|
-
const err = await test_utils_1.assert.doesThrowAsync(() => client.emit('register-skill::v2020_12_25', {
|
|
330
|
-
payload: { name: 'test' },
|
|
331
|
-
}));
|
|
332
|
-
test_utils_1.errorAssert.assertError(err, 'TIMEOUT', {
|
|
333
|
-
eventName: 'register-skill::v2020_12_25',
|
|
334
|
-
});
|
|
335
|
-
test_utils_1.assert.isEqual(client.socket.invocationCounts.off, maxEmitRetries + 1);
|
|
336
|
-
}
|
|
337
|
-
static async timeoutMakesEventualResponseNotCount() {
|
|
338
|
-
const client = await this.TimeoutClient(12000);
|
|
339
|
-
const err = await test_utils_1.assert.doesThrowAsync(() => client.emit('register-skill::v2020_12_25', {
|
|
340
|
-
payload: { name: 'test' },
|
|
341
|
-
}));
|
|
342
|
-
test_utils_1.errorAssert.assertError(err, 'TIMEOUT', {
|
|
343
|
-
eventName: 'register-skill::v2020_12_25',
|
|
344
|
-
});
|
|
345
|
-
await this.wait(4000);
|
|
346
|
-
test_utils_1.assert.isEqual(client.socket.invocationCounts.off, 6);
|
|
347
|
-
}
|
|
348
|
-
static async emitTimeoutsAreResetAfterEmit(maxEmitRetries) {
|
|
349
|
-
const client = await this.TimeoutClient(undefined, maxEmitRetries);
|
|
350
|
-
await test_utils_1.assert.doesThrowAsync(() => client.emit('register-skill::v2020_12_25', {
|
|
351
|
-
payload: { name: 'test' },
|
|
352
|
-
}));
|
|
353
|
-
test_utils_1.assert.isEqual(client.socket.invocationCounts.off, maxEmitRetries + 1);
|
|
354
|
-
client.socket.invocationCounts.off = 0;
|
|
355
|
-
await test_utils_1.assert.doesThrowAsync(() => client.emit('register-skill::v2020_12_25', {
|
|
356
|
-
payload: { name: 'test' },
|
|
357
|
-
}));
|
|
358
|
-
test_utils_1.assert.isEqual(client.socket.invocationCounts.off, maxEmitRetries + 1);
|
|
359
|
-
}
|
|
360
|
-
static async emitTimeoutsAreScopedPerEmit() {
|
|
361
|
-
const client = await this.TimeoutClient();
|
|
362
|
-
const promise1 = client.emit('register-skill::v2020_12_25', {
|
|
363
|
-
payload: { name: 'test' },
|
|
364
|
-
});
|
|
365
|
-
const promise2 = client.emit('register-skill::v2020_12_25', {
|
|
366
|
-
payload: { name: 'test' },
|
|
367
|
-
});
|
|
368
|
-
await test_utils_1.assert.doesThrowAsync(() => promise1);
|
|
369
|
-
await test_utils_1.assert.doesThrowAsync(() => promise2);
|
|
370
|
-
test_utils_1.assert.isEqual(client.socket.invocationCounts.off, 12);
|
|
371
|
-
}
|
|
372
|
-
static async canRegisterEventsSimultaneously() {
|
|
373
|
-
const { client } = await this.loginAsDemoPerson();
|
|
374
|
-
const org = await this.seedDummyOrg(client);
|
|
375
|
-
const { client: originalSkillClient } = await this.seedInstallAndLoginAsSkill(client, org.id);
|
|
376
|
-
const eventsToCheck = [];
|
|
377
|
-
await Promise.all(new Array(20).fill(0).map(async (_, idx) => {
|
|
378
|
-
this.skillName = `Simultanious skill ${idx}`;
|
|
379
|
-
const { skill, client: skillClient } = await this.seedInstallAndLoginAsSkill(client, org.id);
|
|
380
|
-
await skillClient.emitAndFlattenResponses('register-events::v2020_12_25', {
|
|
381
|
-
payload: {
|
|
382
|
-
contract: this.generateWillSendVipEventSignature(),
|
|
383
|
-
},
|
|
384
|
-
});
|
|
385
|
-
const [{ contracts }] = await originalSkillClient.emitAndFlattenResponses('get-event-contracts::v2020_12_25');
|
|
386
|
-
let found = false;
|
|
387
|
-
for (const contract of contracts) {
|
|
388
|
-
if (contract.eventSignatures?.[`${skill.slug}.will-send-vip::v1`]) {
|
|
389
|
-
found = true;
|
|
390
|
-
break;
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
test_utils_1.assert.isTrue(found);
|
|
394
|
-
}));
|
|
395
|
-
const results = await originalSkillClient.emit('get-event-contracts::v2020_12_25');
|
|
396
|
-
const { contracts } = spruce_event_utils_1.eventResponseUtil.getFirstResponseOrThrow(results);
|
|
397
|
-
do {
|
|
398
|
-
const checking = eventsToCheck[eventsToCheck.length - 1];
|
|
399
|
-
for (const contract of contracts) {
|
|
400
|
-
if (contract.eventSignatures[checking]) {
|
|
401
|
-
eventsToCheck.pop();
|
|
402
|
-
break;
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
} while (eventsToCheck.length > 0);
|
|
406
|
-
}
|
|
407
|
-
static async handlesCantEmitElegantly() {
|
|
408
|
-
const client = await this.connectToApi();
|
|
409
|
-
const results = await client.emit('did-message::v2020_12_25', {
|
|
410
|
-
target: {},
|
|
411
|
-
payload: {
|
|
412
|
-
message: {
|
|
413
|
-
id: '13234',
|
|
414
|
-
target: {},
|
|
415
|
-
source: {},
|
|
416
|
-
classification: 'incoming',
|
|
417
|
-
body: 'go team!',
|
|
418
|
-
dateCreated: new Date().getTime(),
|
|
419
|
-
},
|
|
420
|
-
},
|
|
421
|
-
});
|
|
422
|
-
spruce_event_utils_1.eventAssertUtil.assertErrorFromResponse(results, 'UNAUTHORIZED_ACCESS');
|
|
423
|
-
}
|
|
424
|
-
static async canDisableAutoRegisterListener() {
|
|
425
|
-
const { org, skill1, skill1Client, skill2Client } = await this.setup2SkillsAndOneEvent();
|
|
426
|
-
let listenerTriggerCount = 0;
|
|
427
|
-
const eventName = `${skill1.slug}.will-send-vip::v1`;
|
|
428
|
-
skill2Client.setShouldAutoRegisterListeners(false);
|
|
429
|
-
//@ts-ignore
|
|
430
|
-
await skill2Client.on(eventName, () => {
|
|
431
|
-
listenerTriggerCount++;
|
|
432
|
-
return {
|
|
433
|
-
messages: ['hello world'],
|
|
434
|
-
};
|
|
435
|
-
});
|
|
436
|
-
//@ts-ignore
|
|
437
|
-
await skill1Client.emit(eventName, {
|
|
438
|
-
target: {
|
|
439
|
-
organizationId: org.id,
|
|
440
|
-
},
|
|
441
|
-
});
|
|
442
|
-
test_utils_1.assert.isEqual(listenerTriggerCount, 0);
|
|
443
|
-
}
|
|
444
|
-
static async notAuthenticatedToStart() {
|
|
445
|
-
const client = await this.connectToApi();
|
|
446
|
-
test_utils_1.assert.isFalse(client.isAuthenticated());
|
|
447
|
-
}
|
|
448
|
-
static async knowsWhenAuthenticated() {
|
|
449
|
-
const { client } = await this.loginAsDemoPerson();
|
|
450
|
-
test_utils_1.assert.isTrue(client.isAuthenticated());
|
|
451
|
-
}
|
|
452
|
-
static async noProxyTokenToStart() {
|
|
453
|
-
const client = await this.connectToApi();
|
|
454
|
-
test_utils_1.assert.isFalsy(client.getProxyToken());
|
|
455
|
-
}
|
|
456
|
-
static async canSetProxyToken() {
|
|
457
|
-
const client = await this.connectToApi();
|
|
458
|
-
test_utils_1.assert.isFalsy(client.getProxyToken());
|
|
459
|
-
client.setProxyToken('yummy');
|
|
460
|
-
test_utils_1.assert.isEqual(client.getProxyToken(), 'yummy');
|
|
461
|
-
}
|
|
462
|
-
static async requestsAreMadeWithProxyGoingForward() {
|
|
463
|
-
const { client2, token, person1 } = await this.loginAndRegisterToken();
|
|
464
|
-
client2.setProxyToken(token);
|
|
465
|
-
const results = await client2.emit('whoami::v2020_12_25');
|
|
466
|
-
this.assertPerson1ComesBack(results, person1);
|
|
467
|
-
}
|
|
468
|
-
static async prefersProxyPassedInSource() {
|
|
469
|
-
const { client2, token, person1 } = await this.loginAndRegisterToken();
|
|
470
|
-
client2.setProxyToken('aoeuaoeuaoeu');
|
|
471
|
-
const results = await client2.emit('whoami::v2020_12_25', {
|
|
472
|
-
source: {
|
|
473
|
-
proxyToken: token,
|
|
474
|
-
},
|
|
475
|
-
});
|
|
476
|
-
this.assertPerson1ComesBack(results, person1);
|
|
477
|
-
}
|
|
478
|
-
static assertPerson1ComesBack(results, person1) {
|
|
479
|
-
const { auth } = spruce_event_utils_1.eventResponseUtil.getFirstResponseOrThrow(results);
|
|
480
|
-
test_utils_1.assert.isTruthy(auth.person);
|
|
481
|
-
test_utils_1.assert.isEqual(auth.person.id, person1.id);
|
|
482
|
-
}
|
|
483
|
-
static async loginAndRegisterToken() {
|
|
484
|
-
const { client: client1, person: person1 } = await this.loginAsDemoPerson(constants_1.DEMO_PHONE);
|
|
485
|
-
const { client: client2 } = await this.loginAsDemoPerson(constants_1.DEMO_PHONE_PROXY);
|
|
486
|
-
const results = await client1.emit('register-proxy-token::v2020_12_25');
|
|
487
|
-
const { token } = spruce_event_utils_1.eventResponseUtil.getFirstResponseOrThrow(results);
|
|
488
|
-
return { client2, token, person1 };
|
|
489
|
-
}
|
|
490
|
-
static async TimeoutClient(emitDelay, maxEmitRetries) {
|
|
491
|
-
const client = await this.connectToApi({
|
|
492
|
-
emitTimeoutMs: 100,
|
|
493
|
-
shouldReconnect: false,
|
|
494
|
-
maxEmitRetries,
|
|
495
|
-
});
|
|
496
|
-
//@ts-ignore
|
|
497
|
-
const socket = client.socket;
|
|
498
|
-
await new Promise((resolve) => {
|
|
499
|
-
socket?.once('disconnect', () => {
|
|
500
|
-
socket?.removeAllListeners();
|
|
501
|
-
resolve(undefined);
|
|
502
|
-
});
|
|
503
|
-
socket?.disconnect();
|
|
504
|
-
});
|
|
505
|
-
//@ts-ignore
|
|
506
|
-
client.socket = {
|
|
507
|
-
connected: true,
|
|
508
|
-
invocationCounts: {
|
|
509
|
-
off: 0,
|
|
510
|
-
},
|
|
511
|
-
emit: (_, __, cb) => {
|
|
512
|
-
if (emitDelay && emitDelay > 0) {
|
|
513
|
-
setTimeout(cb, emitDelay);
|
|
514
|
-
}
|
|
515
|
-
},
|
|
516
|
-
on: () => { },
|
|
517
|
-
off() {
|
|
518
|
-
this.invocationCounts.off++;
|
|
519
|
-
},
|
|
520
|
-
once: () => { },
|
|
521
|
-
disconnect: () => { },
|
|
522
|
-
};
|
|
523
|
-
this.timeoutClient = client;
|
|
524
|
-
return client;
|
|
525
|
-
}
|
|
526
|
-
static async setup2Skills1EventAddThrowingListenerAndEmit(error) {
|
|
527
|
-
const { org, skill1, skill1Client, skill2Client } = await this.setup2SkillsAndOneEvent();
|
|
528
|
-
//@ts-ignore
|
|
529
|
-
await this.throwOnWillSendVip(skill2Client, skill1.slug, error);
|
|
530
|
-
const results = await skill1Client.emit(
|
|
531
|
-
//@ts-ignore
|
|
532
|
-
`${skill1.slug}.will-send-vip::v1`, {
|
|
533
|
-
target: {
|
|
534
|
-
organizationId: org.id,
|
|
535
|
-
},
|
|
536
|
-
});
|
|
537
|
-
return results;
|
|
538
|
-
}
|
|
539
|
-
static async throwOnWillSendVip(client, namespace, error) {
|
|
540
|
-
//@ts-ignore
|
|
541
|
-
await client.on(`${namespace}.will-send-vip::v1`, () => {
|
|
542
|
-
//@ts-ignore
|
|
543
|
-
throw error;
|
|
544
|
-
});
|
|
545
|
-
}
|
|
546
|
-
static async setup2SkillsAndOneEvent(phone) {
|
|
547
|
-
const { client } = await this.loginAsDemoPerson(phone);
|
|
548
|
-
const org = await this.seedDummyOrg(client);
|
|
549
|
-
const createLogin = this.seedInstallAndLoginAsSkill(client, org.id);
|
|
550
|
-
const createLogin2 = this.seedInstallAndLoginAsSkill(client, org.id);
|
|
551
|
-
const { skill: skill1, client: skill1Client } = await createLogin;
|
|
552
|
-
const { client: skill2Client } = await createLogin2;
|
|
553
|
-
await this.registerEvent(skill1.slug, skill1Client);
|
|
554
|
-
return { client, org, skill1, skill1Client, skill2Client };
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
exports.default = UsingMercuryClient;
|
|
558
|
-
__decorate([
|
|
559
|
-
(0, test_utils_1.test)()
|
|
560
|
-
], UsingMercuryClient, "factoryCanCreateClient", null);
|
|
561
|
-
__decorate([
|
|
562
|
-
(0, test_utils_1.test)()
|
|
563
|
-
], UsingMercuryClient, "allowsEmptyContracts", null);
|
|
564
|
-
__decorate([
|
|
565
|
-
(0, test_utils_1.test)()
|
|
566
|
-
], UsingMercuryClient, "factoryClientCountStartsAtZero", null);
|
|
567
|
-
__decorate([
|
|
568
|
-
(0, test_utils_1.test)()
|
|
569
|
-
], UsingMercuryClient, "connectingToBadProtocolThrows", null);
|
|
570
|
-
__decorate([
|
|
571
|
-
(0, test_utils_1.test)()
|
|
572
|
-
], UsingMercuryClient, "factoryReturnsSocketIoClient", null);
|
|
573
|
-
__decorate([
|
|
574
|
-
(0, test_utils_1.test)()
|
|
575
|
-
], UsingMercuryClient, "throwsWithBadEventName", null);
|
|
576
|
-
__decorate([
|
|
577
|
-
(0, test_utils_1.test)()
|
|
578
|
-
], UsingMercuryClient, "throwsWithHelpfulErrorWithInvalidPayload", null);
|
|
579
|
-
__decorate([
|
|
580
|
-
(0, test_utils_1.test)()
|
|
581
|
-
], UsingMercuryClient, "throwsHelpfulErrorWhenCantReachHost", null);
|
|
582
|
-
__decorate([
|
|
583
|
-
(0, test_utils_1.test)()
|
|
584
|
-
], UsingMercuryClient, "triesToReconnect5TimesMax", null);
|
|
585
|
-
__decorate([
|
|
586
|
-
(0, test_utils_1.test)()
|
|
587
|
-
], UsingMercuryClient, "getsAccessDeniedWhenTryingToListenToUnknownEventAnonymously", null);
|
|
588
|
-
__decorate([
|
|
589
|
-
(0, test_utils_1.test)()
|
|
590
|
-
], UsingMercuryClient, "cantEmitEventWithWithInvalidPayload", null);
|
|
591
|
-
__decorate([
|
|
592
|
-
(0, test_utils_1.test)()
|
|
593
|
-
], UsingMercuryClient, "canRunHealthCheck", null);
|
|
594
|
-
__decorate([
|
|
595
|
-
(0, test_utils_1.test)()
|
|
596
|
-
], UsingMercuryClient, "skillsCanListenToEachOther", null);
|
|
597
|
-
__decorate([
|
|
598
|
-
(0, test_utils_1.test)()
|
|
599
|
-
], UsingMercuryClient, "errorsInListenersRetainOptions", null);
|
|
600
|
-
__decorate([
|
|
601
|
-
(0, test_utils_1.test)()
|
|
602
|
-
], UsingMercuryClient, "retainsGeneratedFriendlyMessage", null);
|
|
603
|
-
__decorate([
|
|
604
|
-
(0, test_utils_1.test)()
|
|
605
|
-
], UsingMercuryClient, "nonSpruceErrorsArePassedBackAsListenerErrors", null);
|
|
606
|
-
__decorate([
|
|
607
|
-
(0, test_utils_1.test)('each listener gets fired'),
|
|
608
|
-
(0, test_utils_1.test)('each listener gets fired after lost connection', true)
|
|
609
|
-
], UsingMercuryClient, "emitterGetsCalledBackForEachListener", null);
|
|
610
|
-
__decorate([
|
|
611
|
-
(0, test_utils_1.test)()
|
|
612
|
-
], UsingMercuryClient, "eachResponseMustFinishBeforeEmitReturns", null);
|
|
613
|
-
__decorate([
|
|
614
|
-
(0, test_utils_1.test)()
|
|
615
|
-
], UsingMercuryClient, "offRemovesListener", null);
|
|
616
|
-
__decorate([
|
|
617
|
-
(0, test_utils_1.test)()
|
|
618
|
-
], UsingMercuryClient, "throwsWhenEmittingWhenNotConnected", null);
|
|
619
|
-
__decorate([
|
|
620
|
-
(0, test_utils_1.test)()
|
|
621
|
-
], UsingMercuryClient, "serverSideErrorsMappedToSpruceErrors", null);
|
|
622
|
-
__decorate([
|
|
623
|
-
(0, test_utils_1.test)('times out when giving up on 1 retry on emit', 1),
|
|
624
|
-
(0, test_utils_1.test)('times out when giving up on 5 retries on emit', 5)
|
|
625
|
-
], UsingMercuryClient, "timesOutWhenEmittingEventThatIsNeverHandled", null);
|
|
626
|
-
__decorate([
|
|
627
|
-
(0, test_utils_1.test)()
|
|
628
|
-
], UsingMercuryClient, "timeoutMakesEventualResponseNotCount", null);
|
|
629
|
-
__decorate([
|
|
630
|
-
(0, test_utils_1.test)('emit timeouts are reset after each emit with 5 retries', 5),
|
|
631
|
-
(0, test_utils_1.test)('emit timeouts are reset after each emit with 3 retries', 3)
|
|
632
|
-
], UsingMercuryClient, "emitTimeoutsAreResetAfterEmit", null);
|
|
633
|
-
__decorate([
|
|
634
|
-
(0, test_utils_1.test)()
|
|
635
|
-
], UsingMercuryClient, "emitTimeoutsAreScopedPerEmit", null);
|
|
636
|
-
__decorate([
|
|
637
|
-
(0, test_utils_1.test)()
|
|
638
|
-
], UsingMercuryClient, "canRegisterEventsSimultaneously", null);
|
|
639
|
-
__decorate([
|
|
640
|
-
(0, test_utils_1.test)()
|
|
641
|
-
], UsingMercuryClient, "handlesCantEmitElegantly", null);
|
|
642
|
-
__decorate([
|
|
643
|
-
(0, test_utils_1.test)()
|
|
644
|
-
], UsingMercuryClient, "canDisableAutoRegisterListener", null);
|
|
645
|
-
__decorate([
|
|
646
|
-
(0, test_utils_1.test)()
|
|
647
|
-
], UsingMercuryClient, "notAuthenticatedToStart", null);
|
|
648
|
-
__decorate([
|
|
649
|
-
(0, test_utils_1.test)()
|
|
650
|
-
], UsingMercuryClient, "knowsWhenAuthenticated", null);
|
|
651
|
-
__decorate([
|
|
652
|
-
(0, test_utils_1.test)()
|
|
653
|
-
], UsingMercuryClient, "noProxyTokenToStart", null);
|
|
654
|
-
__decorate([
|
|
655
|
-
(0, test_utils_1.test)()
|
|
656
|
-
], UsingMercuryClient, "canSetProxyToken", null);
|
|
657
|
-
__decorate([
|
|
658
|
-
(0, test_utils_1.test)()
|
|
659
|
-
], UsingMercuryClient, "requestsAreMadeWithProxyGoingForward", null);
|
|
660
|
-
__decorate([
|
|
661
|
-
(0, test_utils_1.test)()
|
|
662
|
-
], UsingMercuryClient, "prefersProxyPassedInSource", null);
|