@factset/frontgate-js-sdk 6.11.1 → 7.0.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.
- package/CHANGELOG.md +97 -40
- package/dist/lib/esnext/FrontgateClient.js +0 -3
- package/dist/lib/esnext/authentication/index.js +3 -4
- package/dist/lib/esnext/common/errors.js +0 -35
- package/dist/lib/esnext/common/functions.js +0 -84
- package/dist/lib/esnext/common/interfaces/index.js +0 -1
- package/dist/lib/esnext/compat/index.js +0 -3
- package/dist/lib/esnext/connection/index.js +19 -6
- package/dist/lib/esnext/connection/util/functions.js +0 -56
- package/dist/lib/esnext/index.js +0 -1
- package/dist/lib/esnext/message/index.js +1 -1
- package/dist/lib/esnext/message/interfaces/index.js +0 -1
- package/dist/lib/esnext/message/request/TransportLayerClientRequestHeader.js +1 -1
- package/dist/lib/esnext/message/request/raw/example/CreateNotationSearchRequest.js +1 -1
- package/dist/lib/esnext/message/request/raw/index.js +0 -1
- package/dist/lib/esnext/message/response/index.js +0 -5
- package/dist/lib/esnext/message/update/index.js +0 -1
- package/dist/lib/esnext/mixins/EndpointRequestMixin.js +1 -1
- package/dist/lib/esnext/mixins/RemoteLoggerMixin.js +29 -0
- package/dist/lib/esnext/mixins/auth/AppAuthMixin.js +79 -11
- package/dist/lib/esnext/mixins/auth/SessionAuthMixin.js +76 -36
- package/dist/lib/esnext/mixins/auth/UserCredentialAuthMixin.js +82 -12
- package/dist/lib/esnext/mixins/auth/UserPasswordAuthMixin.js +80 -13
- package/dist/lib/esnext/mixins/auth/index.js +0 -31
- package/dist/lib/esnext/mixins/index.js +1 -0
- package/dist/lib/esnext/mixins/subscription/EndpointSubscriptionMixin.js +149 -122
- package/dist/lib/esnext/version.js +1 -1
- package/dist/lib/node/FrontgateClient.js +0 -3
- package/dist/lib/node/authentication/index.js +4 -4
- package/dist/lib/node/common/errors.js +1 -41
- package/dist/lib/node/common/functions.js +0 -92
- package/dist/lib/node/common/interfaces/index.js +0 -1
- package/dist/lib/node/compat/index.js +0 -3
- package/dist/lib/node/connection/index.js +20 -6
- package/dist/lib/node/connection/util/functions.js +0 -63
- package/dist/lib/node/index.js +1 -3
- package/dist/lib/node/message/index.js +2 -1
- package/dist/lib/node/message/interfaces/index.js +0 -1
- package/dist/lib/node/message/request/TransportLayerClientRequestHeader.js +3 -3
- package/dist/lib/node/message/request/raw/example/CreateNotationSearchRequest.js +3 -3
- package/dist/lib/node/message/request/raw/index.js +0 -1
- package/dist/lib/node/message/response/index.js +0 -5
- package/dist/lib/node/message/update/index.js +0 -1
- package/dist/lib/node/mixins/EndpointRequestMixin.js +2 -2
- package/dist/lib/node/mixins/RemoteLoggerMixin.js +33 -0
- package/dist/lib/node/mixins/auth/AppAuthMixin.js +78 -10
- package/dist/lib/node/mixins/auth/SessionAuthMixin.js +75 -35
- package/dist/lib/node/mixins/auth/UserCredentialAuthMixin.js +80 -10
- package/dist/lib/node/mixins/auth/UserPasswordAuthMixin.js +78 -11
- package/dist/lib/node/mixins/auth/index.js +0 -33
- package/dist/lib/node/mixins/index.js +1 -0
- package/dist/lib/node/mixins/subscription/EndpointSubscriptionMixin.js +149 -122
- package/dist/lib/node/version.js +1 -1
- package/dist/lib/types/FrontgateClient.d.ts +0 -1
- package/dist/lib/types/authentication/index.d.ts +3 -4
- package/dist/lib/types/authentication/util/ChallengeResolver.d.ts +2 -1
- package/dist/lib/types/common/errors.d.ts +0 -21
- package/dist/lib/types/common/functions.d.ts +0 -8
- package/dist/lib/types/common/interfaces/index.d.ts +0 -1
- package/dist/lib/types/compat/index.d.ts +0 -3
- package/dist/lib/types/connection/index.d.ts +16 -6
- package/dist/lib/types/connection/util/functions.d.ts +0 -18
- package/dist/lib/types/index.d.ts +0 -1
- package/dist/lib/types/message/index.d.ts +1 -1
- package/dist/lib/types/message/interfaces/index.d.ts +0 -1
- package/dist/lib/types/message/request/TransportLayerClientRequestHeader.d.ts +1 -0
- package/dist/lib/types/message/request/raw/index.d.ts +0 -1
- package/dist/lib/types/message/response/index.d.ts +0 -5
- package/dist/lib/types/message/update/index.d.ts +0 -1
- package/dist/lib/types/mixins/AuthTokenRequestMixin.d.ts +1 -2
- package/dist/lib/types/mixins/EndpointRequestMixin.d.ts +1 -2
- package/dist/lib/types/mixins/HTTPProxyRequestMixin.d.ts +1 -4
- package/dist/lib/types/mixins/LoggerMixin.d.ts +1 -2
- package/dist/lib/types/mixins/MessageCompressorMixin.d.ts +1 -2
- package/dist/lib/types/mixins/OpenTelemetryMixin.d.ts +1 -2
- package/dist/lib/types/mixins/PingMixin.d.ts +1 -2
- package/dist/lib/types/mixins/ReconnectMixin.d.ts +1 -2
- package/dist/lib/types/mixins/RemoteLoggerMixin.d.ts +16 -0
- package/dist/lib/types/mixins/RequestMixin.d.ts +1 -2
- package/dist/lib/types/mixins/auth/AppAuthMixin.d.ts +15 -8
- package/dist/lib/types/mixins/auth/CookieTokenAuthMixin.d.ts +1 -2
- package/dist/lib/types/mixins/auth/FetchAuthenticationMixin.d.ts +1 -2
- package/dist/lib/types/mixins/auth/SessionAuthMixin.d.ts +10 -5
- package/dist/lib/types/mixins/auth/TokenAuthMixin.d.ts +1 -2
- package/dist/lib/types/mixins/auth/UserCredentialAuthMixin.d.ts +15 -8
- package/dist/lib/types/mixins/auth/UserPasswordAuthMixin.d.ts +15 -8
- package/dist/lib/types/mixins/auth/index.d.ts +0 -8
- package/dist/lib/types/mixins/connection/FrontgateWSMixin.d.ts +1 -2
- package/dist/lib/types/mixins/index.d.ts +2 -1
- package/dist/lib/types/mixins/subscription/EndpointSubscriptionMixin.d.ts +4 -6
- package/dist/lib/types/mixins/subscription/RawSubscriptionMixin.d.ts +1 -2
- package/dist/lib/umd/mdg2.client.min.umd.js +1 -12
- package/dist/lib/umd/mdg2.client.umd.js +4061 -8138
- package/package.json +25 -28
- package/dist/lib/esnext/Mdg2Client.js +0 -185
- package/dist/lib/esnext/authentication/AbstractAuthentication.js +0 -49
- package/dist/lib/esnext/authentication/AppAuthentication.js +0 -70
- package/dist/lib/esnext/authentication/AuthenticationInterface.js +0 -1
- package/dist/lib/esnext/authentication/CookieTokenAuthentication.js +0 -18
- package/dist/lib/esnext/authentication/TokenAuthentication.js +0 -42
- package/dist/lib/esnext/authentication/UserCredentialAuthentication.js +0 -73
- package/dist/lib/esnext/authentication/UserPasswordAuthentication.js +0 -71
- package/dist/lib/esnext/common/Mdg2ClientOptions.js +0 -1
- package/dist/lib/esnext/common/constants.js +0 -10
- package/dist/lib/esnext/common/interfaces/observe/ObserveOptions.js +0 -1
- package/dist/lib/esnext/connection/AbstractFrontgateConnection.js +0 -324
- package/dist/lib/esnext/connection/ConnectionInterface.js +0 -1
- package/dist/lib/esnext/connection/FrontgateWSConnection.js +0 -281
- package/dist/lib/esnext/connection/JobPromise.js +0 -2
- package/dist/lib/esnext/connection/LatencyHandler.js +0 -1
- package/dist/lib/esnext/connection/LatencyTracker.js +0 -47
- package/dist/lib/esnext/connection/MessageProcessor.js +0 -1
- package/dist/lib/esnext/connection/util/Encoding.js +0 -14
- package/dist/lib/esnext/core/RequestModule.js +0 -349
- package/dist/lib/esnext/core/SubscriptionModule.js +0 -104
- package/dist/lib/esnext/core/subscription/EndpointHandler.js +0 -121
- package/dist/lib/esnext/core/subscription/SubjectManager.js +0 -39
- package/dist/lib/esnext/message/MessageFactory.js +0 -36
- package/dist/lib/esnext/message/guards.js +0 -21
- package/dist/lib/esnext/message/interfaces/JobObservable.js +0 -1
- package/dist/lib/esnext/message/request/raw/RawRequestFactory.js +0 -18
- package/dist/lib/esnext/message/response/AuthenticationByTokenResponse.js +0 -1
- package/dist/lib/esnext/message/response/CancelSubscriptionResponse.js +0 -3
- package/dist/lib/esnext/message/response/LoadNotificationMessage.js +0 -1
- package/dist/lib/esnext/message/response/PermissionDeniedResponse.js +0 -6
- package/dist/lib/esnext/message/response/RejectResponse.js +0 -9
- package/dist/lib/esnext/message/update/SubscriptionLossMessage.js +0 -10
- package/dist/lib/esnext/util/TimeOutWrapper.js +0 -51
- package/dist/lib/node/Mdg2Client.js +0 -189
- package/dist/lib/node/authentication/AbstractAuthentication.js +0 -53
- package/dist/lib/node/authentication/AppAuthentication.js +0 -74
- package/dist/lib/node/authentication/AuthenticationInterface.js +0 -2
- package/dist/lib/node/authentication/CookieTokenAuthentication.js +0 -22
- package/dist/lib/node/authentication/TokenAuthentication.js +0 -46
- package/dist/lib/node/authentication/UserCredentialAuthentication.js +0 -77
- package/dist/lib/node/authentication/UserPasswordAuthentication.js +0 -75
- package/dist/lib/node/common/Mdg2ClientOptions.js +0 -2
- package/dist/lib/node/common/constants.js +0 -13
- package/dist/lib/node/common/interfaces/observe/ObserveOptions.js +0 -2
- package/dist/lib/node/connection/AbstractFrontgateConnection.js +0 -328
- package/dist/lib/node/connection/ConnectionInterface.js +0 -2
- package/dist/lib/node/connection/FrontgateWSConnection.js +0 -288
- package/dist/lib/node/connection/JobPromise.js +0 -6
- package/dist/lib/node/connection/LatencyHandler.js +0 -2
- package/dist/lib/node/connection/LatencyTracker.js +0 -51
- package/dist/lib/node/connection/MessageProcessor.js +0 -2
- package/dist/lib/node/connection/util/Encoding.js +0 -18
- package/dist/lib/node/core/RequestModule.js +0 -353
- package/dist/lib/node/core/SubscriptionModule.js +0 -108
- package/dist/lib/node/core/subscription/EndpointHandler.js +0 -125
- package/dist/lib/node/core/subscription/SubjectManager.js +0 -43
- package/dist/lib/node/message/MessageFactory.js +0 -73
- package/dist/lib/node/message/guards.js +0 -30
- package/dist/lib/node/message/interfaces/JobObservable.js +0 -2
- package/dist/lib/node/message/request/raw/RawRequestFactory.js +0 -22
- package/dist/lib/node/message/response/AuthenticationByTokenResponse.js +0 -2
- package/dist/lib/node/message/response/CancelSubscriptionResponse.js +0 -7
- package/dist/lib/node/message/response/LoadNotificationMessage.js +0 -2
- package/dist/lib/node/message/response/PermissionDeniedResponse.js +0 -10
- package/dist/lib/node/message/response/RejectResponse.js +0 -13
- package/dist/lib/node/message/update/SubscriptionLossMessage.js +0 -14
- package/dist/lib/node/util/TimeOutWrapper.js +0 -55
- package/dist/lib/types/Mdg2Client.d.ts +0 -52
- package/dist/lib/types/authentication/AbstractAuthentication.d.ts +0 -17
- package/dist/lib/types/authentication/AppAuthentication.d.ts +0 -12
- package/dist/lib/types/authentication/AuthenticationInterface.d.ts +0 -9
- package/dist/lib/types/authentication/CookieTokenAuthentication.d.ts +0 -6
- package/dist/lib/types/authentication/TokenAuthentication.d.ts +0 -14
- package/dist/lib/types/authentication/UserCredentialAuthentication.d.ts +0 -13
- package/dist/lib/types/authentication/UserPasswordAuthentication.d.ts +0 -14
- package/dist/lib/types/common/Mdg2ClientOptions.d.ts +0 -12
- package/dist/lib/types/common/constants.d.ts +0 -11
- package/dist/lib/types/common/interfaces/observe/ObserveOptions.d.ts +0 -5
- package/dist/lib/types/connection/AbstractFrontgateConnection.d.ts +0 -116
- package/dist/lib/types/connection/ConnectionInterface.d.ts +0 -53
- package/dist/lib/types/connection/FrontgateWSConnection.d.ts +0 -23
- package/dist/lib/types/connection/JobPromise.d.ts +0 -3
- package/dist/lib/types/connection/LatencyHandler.d.ts +0 -1
- package/dist/lib/types/connection/LatencyTracker.d.ts +0 -13
- package/dist/lib/types/connection/MessageProcessor.d.ts +0 -2
- package/dist/lib/types/connection/util/Encoding.d.ts +0 -9
- package/dist/lib/types/core/RequestModule.d.ts +0 -78
- package/dist/lib/types/core/SubscriptionModule.d.ts +0 -24
- package/dist/lib/types/core/subscription/EndpointHandler.d.ts +0 -37
- package/dist/lib/types/core/subscription/SubjectManager.d.ts +0 -21
- package/dist/lib/types/message/MessageFactory.d.ts +0 -29
- package/dist/lib/types/message/guards.d.ts +0 -11
- package/dist/lib/types/message/interfaces/JobObservable.d.ts +0 -4
- package/dist/lib/types/message/request/raw/RawRequestFactory.d.ts +0 -4
- package/dist/lib/types/message/response/AuthenticationByTokenResponse.d.ts +0 -20
- package/dist/lib/types/message/response/CancelSubscriptionResponse.d.ts +0 -3
- package/dist/lib/types/message/response/LoadNotificationMessage.d.ts +0 -8
- package/dist/lib/types/message/response/PermissionDeniedResponse.d.ts +0 -4
- package/dist/lib/types/message/response/RejectResponse.d.ts +0 -5
- package/dist/lib/types/message/update/SubscriptionLossMessage.d.ts +0 -17
- package/dist/lib/types/util/TimeOutWrapper.d.ts +0 -12
|
@@ -9,23 +9,33 @@ import { HighLevelRequest, ErrorResponse, HighLevelUpdate, CancelSubscriptionReq
|
|
|
9
9
|
import { useTimeout, addRandomnessToTime } from '../../util/functions';
|
|
10
10
|
export const endpointSubscriptions = (originalConfig) => {
|
|
11
11
|
const mixinEndpointSubscribable = (Base) => {
|
|
12
|
-
var _subscriptions, _a;
|
|
12
|
+
var _subscriptions, _subscriptionCounts, _inFlights, _a;
|
|
13
13
|
const config = { ...originalConfig };
|
|
14
14
|
return _a = class extends Base {
|
|
15
15
|
constructor() {
|
|
16
16
|
super(...arguments);
|
|
17
17
|
_subscriptions.set(this, new Map());
|
|
18
|
+
_subscriptionCounts.set(this, new Map());
|
|
19
|
+
_inFlights.set(this, new Map());
|
|
18
20
|
}
|
|
19
21
|
async observeEndpoint(method, path, data, requestOptions) {
|
|
20
22
|
const key = `${method}:${path}:${JSON.stringify(data)}:${JSON.stringify(requestOptions ?? {})}`;
|
|
23
|
+
if (__classPrivateFieldGet(this, _inFlights, "f").has(key)) {
|
|
24
|
+
const inFlightPromise = __classPrivateFieldGet(this, _inFlights, "f").get(key);
|
|
25
|
+
this.log(LogLevel.INFO, `Catching inflight subscription for ${key}`);
|
|
26
|
+
const subscriptionCount = __classPrivateFieldGet(this, _subscriptionCounts, "f").get(key) ?? 0;
|
|
27
|
+
__classPrivateFieldGet(this, _subscriptionCounts, "f").set(key, subscriptionCount + 1);
|
|
28
|
+
return inFlightPromise;
|
|
29
|
+
}
|
|
21
30
|
const timeOutInMs = config.timeout ?? this.defaultTimeoutInMs;
|
|
22
31
|
const resubscribeTimeout = config.subscriptionResubscribeTimeout ?? 1000;
|
|
23
32
|
if (__classPrivateFieldGet(this, _subscriptions, "f").has(key)) {
|
|
24
33
|
const subscription = __classPrivateFieldGet(this, _subscriptions, "f").get(key);
|
|
34
|
+
const subscriptionCount = __classPrivateFieldGet(this, _subscriptionCounts, "f").get(key) ?? 0;
|
|
25
35
|
if (subscription) {
|
|
26
|
-
|
|
36
|
+
__classPrivateFieldGet(this, _subscriptionCounts, "f").set(key, subscriptionCount + 1);
|
|
27
37
|
this.log(LogLevel.INFO, `Reusing existing subscription for ${key}`);
|
|
28
|
-
return subscription
|
|
38
|
+
return subscription;
|
|
29
39
|
}
|
|
30
40
|
}
|
|
31
41
|
this.log(LogLevel.INFO, `Creating new subscription for ${key}`);
|
|
@@ -36,153 +46,170 @@ export const endpointSubscriptions = (originalConfig) => {
|
|
|
36
46
|
callbackType: 'job',
|
|
37
47
|
callbackId: '',
|
|
38
48
|
};
|
|
39
|
-
await this.hooks.callHook('frontgateConnection:sendMessage', subscriptionMsg);
|
|
40
49
|
const promise = new Promise((resolve, reject) => {
|
|
41
|
-
this.hooks
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
let hlResponseData;
|
|
48
|
-
try {
|
|
49
|
-
hlResponseData = JSON.parse(response.body.value);
|
|
50
|
-
}
|
|
51
|
-
catch (e) {
|
|
52
|
-
this.log(LogLevel.ERROR, `Failed to parse response: ${response.body.value}`);
|
|
53
|
-
this.log(LogLevel.ERROR, e);
|
|
54
|
-
reject(e);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const observer = new FrontgateClientEndpointDataObserver(response.header.id_job, hlResponseData);
|
|
58
|
-
let removeMessageUpdateHook = this.hooks.hook(`frontgateConnection:response:${subscriptionMsg.callbackId}`, (update) => {
|
|
59
|
-
if (!update.Message.includes('HighLevelUpdate')) {
|
|
60
|
-
if (update.Message.includes('SubscriptionLoss')) {
|
|
61
|
-
this.log(LogLevel.DEBUG, `Received: ${update.Message}`);
|
|
62
|
-
setTimeout(() => {
|
|
63
|
-
void resubscribe();
|
|
64
|
-
}, addRandomnessToTime(resubscribeTimeout));
|
|
65
|
-
removeMessageUpdateHook();
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
50
|
+
this.hooks
|
|
51
|
+
.callHook('frontgateConnection:sendMessage', subscriptionMsg)
|
|
52
|
+
.then(() => {
|
|
53
|
+
this.hooks.hookOnce(`frontgateConnection:response:${subscriptionMsg.callbackId}`, (response) => {
|
|
54
|
+
if (!response.Message.includes('HighLevelResponse')) {
|
|
68
55
|
this.log(LogLevel.ERROR, `Unexpected response: ${response.Message}`);
|
|
69
|
-
|
|
70
|
-
removeMessageUpdateHook();
|
|
56
|
+
reject(new ErrorResponse(JSON.stringify(response)));
|
|
71
57
|
return;
|
|
72
58
|
}
|
|
73
|
-
let
|
|
59
|
+
let hlResponseData;
|
|
74
60
|
try {
|
|
75
|
-
|
|
61
|
+
hlResponseData = JSON.parse(response.body.value);
|
|
76
62
|
}
|
|
77
63
|
catch (e) {
|
|
78
|
-
this.log(LogLevel.ERROR, `Failed to parse response: ${
|
|
79
|
-
|
|
64
|
+
this.log(LogLevel.ERROR, `Failed to parse response: ${response.body.value}`);
|
|
65
|
+
this.log(LogLevel.ERROR, e);
|
|
66
|
+
reject(e);
|
|
80
67
|
return;
|
|
81
68
|
}
|
|
82
|
-
observer
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if (!response.Message.includes('HighLevelResponse')) {
|
|
91
|
-
const err = new ErrorResponse(resp);
|
|
92
|
-
this.log(LogLevel.ERROR, `Unexpected response: ${resp.Message}`);
|
|
69
|
+
const observer = new FrontgateClientEndpointDataObserver(response.header.id_job, hlResponseData);
|
|
70
|
+
let removeMessageUpdateHook = this.hooks.hook(`frontgateConnection:response:${subscriptionMsg.callbackId}`, (update) => {
|
|
71
|
+
if (!update.Message.includes('HighLevelUpdate')) {
|
|
72
|
+
if (update.Message.includes('SubscriptionLoss')) {
|
|
73
|
+
this.log(LogLevel.DEBUG, `Received: ${update.Message}`);
|
|
74
|
+
setTimeout(() => {
|
|
75
|
+
void resubscribe();
|
|
76
|
+
}, addRandomnessToTime(resubscribeTimeout));
|
|
93
77
|
removeMessageUpdateHook();
|
|
94
|
-
rej(err);
|
|
95
78
|
return;
|
|
96
79
|
}
|
|
97
|
-
this.log(LogLevel.
|
|
98
|
-
observer.
|
|
99
|
-
removeMessageUpdateHook
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
80
|
+
this.log(LogLevel.ERROR, `Unexpected response: ${response.Message}`);
|
|
81
|
+
observer.pushError(new ErrorResponse(JSON.stringify(update)));
|
|
82
|
+
removeMessageUpdateHook();
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
let hlUpdate;
|
|
86
|
+
try {
|
|
87
|
+
hlUpdate = new HighLevelUpdate(update);
|
|
88
|
+
}
|
|
89
|
+
catch (e) {
|
|
90
|
+
this.log(LogLevel.ERROR, `Failed to parse response: ${update.body.value}`);
|
|
91
|
+
observer.pushError(e);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
observer.pushPatchData(hlUpdate.data);
|
|
95
|
+
});
|
|
96
|
+
const resubscribe = async () => {
|
|
97
|
+
removeMessageUpdateHook();
|
|
98
|
+
this.log(LogLevel.INFO, `Resubscribing to ${key} due to reconnect`);
|
|
99
|
+
await this.hooks.callHook('frontgateConnection:sendMessage', subscriptionMsg);
|
|
100
|
+
const resubscribePromise = new Promise((res, rej) => {
|
|
101
|
+
this.hooks.hookOnce(`frontgateConnection:response:${subscriptionMsg.callbackId}`, (resp) => {
|
|
102
|
+
if (!response.Message.includes('HighLevelResponse')) {
|
|
103
|
+
const err = new ErrorResponse(resp);
|
|
104
|
+
this.log(LogLevel.ERROR, `Unexpected response: ${resp.Message}`);
|
|
105
|
+
removeMessageUpdateHook();
|
|
106
|
+
rej(err);
|
|
120
107
|
return;
|
|
121
108
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
if (
|
|
127
|
-
this.log(LogLevel.
|
|
109
|
+
this.log(LogLevel.INFO, `Resubscribed to ${key} with ${resp.header.id_job}`);
|
|
110
|
+
observer.idJob = resp.header.id_job;
|
|
111
|
+
removeMessageUpdateHook = this.hooks.hook(`frontgateConnection:response:${resp.header.id_job}`, (update) => {
|
|
112
|
+
if (!update.Message.includes('HighLevelUpdate')) {
|
|
113
|
+
if (update.Message.includes('SubscriptionLoss')) {
|
|
114
|
+
this.log(LogLevel.DEBUG, `Received: ${update.Message}`);
|
|
115
|
+
setTimeout(() => {
|
|
116
|
+
void resubscribe();
|
|
117
|
+
}, addRandomnessToTime(resubscribeTimeout));
|
|
128
118
|
return;
|
|
129
119
|
}
|
|
130
|
-
|
|
120
|
+
this.log(LogLevel.ERROR, `Unexpected response: ${update.Message}`);
|
|
121
|
+
const err = new ErrorResponse(update);
|
|
122
|
+
observer.pushError(err);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
let hlUpdate;
|
|
126
|
+
try {
|
|
127
|
+
hlUpdate = new HighLevelUpdate(update);
|
|
131
128
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
129
|
+
catch (e) {
|
|
130
|
+
this.log(LogLevel.ERROR, `Failed to parse response: ${update.body.value}`);
|
|
131
|
+
observer.pushError(e);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
observer.unsubscribe = () => {
|
|
135
|
+
const subscription = __classPrivateFieldGet(this, _subscriptions, "f").get(key);
|
|
136
|
+
if (subscription) {
|
|
137
|
+
const subcounts = __classPrivateFieldGet(this, _subscriptionCounts, "f").get(key) ?? 0;
|
|
138
|
+
__classPrivateFieldGet(this, _subscriptionCounts, "f").set(key, subcounts - 1);
|
|
139
|
+
if (subcounts - 1 > 0) {
|
|
140
|
+
this.log(LogLevel.INFO, `Not unsubscribing from ${key} as there are still ${subcounts} subscribers`);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
__classPrivateFieldGet(this, _subscriptions, "f").delete(key);
|
|
144
|
+
__classPrivateFieldGet(this, _subscriptionCounts, "f").delete(key);
|
|
145
|
+
}
|
|
146
|
+
this.log(LogLevel.INFO, `Unsubscribing from ${key}`);
|
|
147
|
+
const cancelationRequest = new CancelSubscriptionRequest(observer.idJob);
|
|
148
|
+
const unsubscribeMsg = {
|
|
149
|
+
message: cancelationRequest.getPtlMessage(),
|
|
150
|
+
callbackType: 'job',
|
|
151
|
+
callbackId: '',
|
|
152
|
+
};
|
|
153
|
+
void this.hooks.callHook('frontgateConnection:sendMessage', unsubscribeMsg);
|
|
154
|
+
removeMessageUpdateHook();
|
|
155
|
+
removeReconnectHook();
|
|
138
156
|
};
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
};
|
|
143
|
-
observer.pushPatchData(hlUpdate.data);
|
|
157
|
+
observer.pushPatchData(hlUpdate.data);
|
|
158
|
+
});
|
|
159
|
+
res();
|
|
144
160
|
});
|
|
145
|
-
res();
|
|
146
161
|
});
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
await useTimeout(timeOutInMs, 'Request timeout reached', resubscribePromise);
|
|
150
|
-
}
|
|
151
|
-
catch (e) {
|
|
152
|
-
observer.pushError(new ErrorResponse({ Message: 'Reconnect failed', Error: e }));
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
const removeReconnectHook = this.hooks.hook('reconnect:success', resubscribe);
|
|
156
|
-
observer.unsubscribe = () => {
|
|
157
|
-
const subscription = __classPrivateFieldGet(this, _subscriptions, "f").get(key);
|
|
158
|
-
if (subscription) {
|
|
159
|
-
subscription.count--;
|
|
160
|
-
if (subscription.count > 0) {
|
|
161
|
-
this.log(LogLevel.INFO, `Not unsubscribing from ${key} as there are still ${subscription.count} subscribers`);
|
|
162
|
-
return;
|
|
162
|
+
try {
|
|
163
|
+
await useTimeout(timeOutInMs, 'Request timeout reached', resubscribePromise);
|
|
163
164
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
165
|
+
catch (e) {
|
|
166
|
+
observer.pushError(new ErrorResponse({ Message: 'Reconnect failed', Error: e }));
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
const removeReconnectHook = this.hooks.hook('reconnect:success', resubscribe);
|
|
170
|
+
observer.unsubscribe = () => {
|
|
171
|
+
const subscription = __classPrivateFieldGet(this, _subscriptions, "f").get(key);
|
|
172
|
+
if (subscription) {
|
|
173
|
+
const subcounts = __classPrivateFieldGet(this, _subscriptionCounts, "f").get(key) ?? 0;
|
|
174
|
+
__classPrivateFieldGet(this, _subscriptionCounts, "f").set(key, subcounts - 1);
|
|
175
|
+
if (subcounts - 1 > 0) {
|
|
176
|
+
this.log(LogLevel.INFO, `Not unsubscribing from ${key} as there are still ${subcounts} subscribers`);
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
__classPrivateFieldGet(this, _subscriptions, "f").delete(key);
|
|
180
|
+
__classPrivateFieldGet(this, _subscriptionCounts, "f").delete(key);
|
|
181
|
+
}
|
|
182
|
+
this.log(LogLevel.INFO, `Unsubscribing from ${key}`);
|
|
183
|
+
const cancelationRequest = new CancelSubscriptionRequest(observer.idJob);
|
|
184
|
+
const unsubscribeMsg = {
|
|
185
|
+
message: cancelationRequest.getPtlMessage(),
|
|
186
|
+
callbackType: 'job',
|
|
187
|
+
callbackId: '',
|
|
188
|
+
};
|
|
189
|
+
void this.hooks.callHook('frontgateConnection:sendMessage', unsubscribeMsg);
|
|
190
|
+
removeMessageUpdateHook();
|
|
191
|
+
removeReconnectHook();
|
|
172
192
|
};
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
193
|
+
__classPrivateFieldGet(this, _subscriptions, "f").set(key, observer);
|
|
194
|
+
const currentSubscounts = __classPrivateFieldGet(this, _subscriptionCounts, "f").get(key) ?? 0;
|
|
195
|
+
__classPrivateFieldGet(this, _subscriptionCounts, "f").set(key, currentSubscounts + 1);
|
|
196
|
+
__classPrivateFieldGet(this, _inFlights, "f").delete(key);
|
|
197
|
+
resolve(observer);
|
|
198
|
+
});
|
|
199
|
+
})
|
|
200
|
+
.catch((e) => {
|
|
201
|
+
reject(e);
|
|
179
202
|
});
|
|
180
203
|
});
|
|
181
204
|
const rejectReason = `Request timeout reached (${timeOutInMs} ms) for ${subscriptionMsg.message.Message}`;
|
|
182
|
-
|
|
205
|
+
const wrappedTimeoutPromise = useTimeout(timeOutInMs, rejectReason, promise);
|
|
206
|
+
__classPrivateFieldGet(this, _inFlights, "f").set(key, wrappedTimeoutPromise);
|
|
207
|
+
return wrappedTimeoutPromise;
|
|
183
208
|
}
|
|
184
209
|
},
|
|
185
210
|
_subscriptions = new WeakMap(),
|
|
211
|
+
_subscriptionCounts = new WeakMap(),
|
|
212
|
+
_inFlights = new WeakMap(),
|
|
186
213
|
_a;
|
|
187
214
|
};
|
|
188
215
|
return createExtendedMixinFactory(mixinEndpointSubscribable, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const PACKAGE_JSON = { version: '
|
|
1
|
+
export const PACKAGE_JSON = { version: '7.0.1', package: '@factset/frontgate-js-sdk' };
|
|
@@ -19,9 +19,6 @@ class FrontgateClient {
|
|
|
19
19
|
get defaultTimeoutInMs() {
|
|
20
20
|
return __classPrivateFieldGet(this, _FrontgateClient_defaultTimeoutInMs, "f");
|
|
21
21
|
}
|
|
22
|
-
set defaultTimeoutInMs(value) {
|
|
23
|
-
__classPrivateFieldSet(this, _FrontgateClient_defaultTimeoutInMs, value, "f");
|
|
24
|
-
}
|
|
25
22
|
constructor(conf) {
|
|
26
23
|
this.hooks = (0, hookable_1.createHooks)();
|
|
27
24
|
_FrontgateClient_defaultTimeoutInMs.set(this, 10000);
|
|
@@ -14,8 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
18
|
-
__exportStar(require("./AuthenticationInterface"), exports);
|
|
19
|
-
__exportStar(require("./CookieTokenAuthentication"), exports);
|
|
17
|
+
exports.ID_USER_NONE = exports.ID_USER_AUTHENTICATED = exports.ID_APP_AUTHENTICATED = void 0;
|
|
20
18
|
__exportStar(require("./CookieTokenAuthenticationFactors"), exports);
|
|
21
|
-
|
|
19
|
+
exports.ID_APP_AUTHENTICATED = -2;
|
|
20
|
+
exports.ID_USER_AUTHENTICATED = -2;
|
|
21
|
+
exports.ID_USER_NONE = -1;
|
|
@@ -1,22 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
class ServiceUnavailableError extends Error {
|
|
5
|
-
constructor(message = 'Service Unavailable', error) {
|
|
6
|
-
super(message, { cause: error });
|
|
7
|
-
this.name = 'ServiceUnavailableError';
|
|
8
|
-
this.code = 503;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.ServiceUnavailableError = ServiceUnavailableError;
|
|
12
|
-
class InternalServerError extends Error {
|
|
13
|
-
constructor(message = 'Internal Server Error', error) {
|
|
14
|
-
super(message, { cause: error });
|
|
15
|
-
this.name = 'InternalServerError';
|
|
16
|
-
this.code = 500;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.InternalServerError = InternalServerError;
|
|
3
|
+
exports.TimeoutError = void 0;
|
|
20
4
|
class TimeoutError extends Error {
|
|
21
5
|
constructor(message = 'Timeout', error) {
|
|
22
6
|
super(message, { cause: error });
|
|
@@ -25,27 +9,3 @@ class TimeoutError extends Error {
|
|
|
25
9
|
}
|
|
26
10
|
}
|
|
27
11
|
exports.TimeoutError = TimeoutError;
|
|
28
|
-
class UnauthorizedError extends Error {
|
|
29
|
-
constructor(message = 'Unauthorized', error) {
|
|
30
|
-
super(message, { cause: error });
|
|
31
|
-
this.name = 'UnauthorizedError';
|
|
32
|
-
this.code = 401;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.UnauthorizedError = UnauthorizedError;
|
|
36
|
-
class BadRequestError extends Error {
|
|
37
|
-
constructor(message = 'Bad Request', error) {
|
|
38
|
-
super(message, { cause: error });
|
|
39
|
-
this.name = 'BadRequestError';
|
|
40
|
-
this.code = 400;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.BadRequestError = BadRequestError;
|
|
44
|
-
class ResponseError extends Error {
|
|
45
|
-
constructor(message, response) {
|
|
46
|
-
super(message, { cause: response });
|
|
47
|
-
this.name = 'ResponseError';
|
|
48
|
-
this.response = response;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
exports.ResponseError = ResponseError;
|
|
@@ -3,16 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isNodeEnvironment = exports.delay = exports.errorHandler = void 0;
|
|
7
6
|
exports.isObject = isObject;
|
|
8
7
|
exports.deepmerge = deepmerge;
|
|
9
|
-
exports.provideAsArray = provideAsArray;
|
|
10
|
-
exports.unsignedArrayToBase64 = unsignedArrayToBase64;
|
|
11
8
|
exports.toUrlBase64 = toUrlBase64;
|
|
12
|
-
exports.isBase64Url = isBase64Url;
|
|
13
|
-
exports.base64UrlToBase64 = base64UrlToBase64;
|
|
14
9
|
const deepmerge_1 = __importDefault(require("deepmerge"));
|
|
15
|
-
const errors_1 = require("./errors");
|
|
16
10
|
function isObject(obj) {
|
|
17
11
|
return !!obj && typeof obj === 'object';
|
|
18
12
|
}
|
|
@@ -22,92 +16,6 @@ function deepmerge(...args) {
|
|
|
22
16
|
arrayMerge: (destinationArray, sourceArray) => sourceArray,
|
|
23
17
|
});
|
|
24
18
|
}
|
|
25
|
-
function provideAsArray(subject) {
|
|
26
|
-
return subject instanceof Array ? subject : [subject];
|
|
27
|
-
}
|
|
28
|
-
function unsignedArrayToBase64(data) {
|
|
29
|
-
const b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
30
|
-
const res = [];
|
|
31
|
-
let o1;
|
|
32
|
-
let o2;
|
|
33
|
-
let o3;
|
|
34
|
-
let h1;
|
|
35
|
-
let h2;
|
|
36
|
-
let h3;
|
|
37
|
-
let h4;
|
|
38
|
-
let bits;
|
|
39
|
-
let i = 0;
|
|
40
|
-
do {
|
|
41
|
-
o1 = data[i];
|
|
42
|
-
i++;
|
|
43
|
-
o2 = data[i];
|
|
44
|
-
i++;
|
|
45
|
-
o3 = data[i];
|
|
46
|
-
i++;
|
|
47
|
-
bits = (o1 << 16) | (o2 << 8) | o3;
|
|
48
|
-
h1 = (bits >> 18) & 0x3f;
|
|
49
|
-
h2 = (bits >> 12) & 0x3f;
|
|
50
|
-
h3 = (bits >> 6) & 0x3f;
|
|
51
|
-
h4 = bits & 0x3f;
|
|
52
|
-
res.push(b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4));
|
|
53
|
-
} while (i < data.length);
|
|
54
|
-
const enc = res.join('');
|
|
55
|
-
const r = data.length % 3;
|
|
56
|
-
return (r ? enc.slice(0, r - 3) : enc) + '==='.slice(r || 3);
|
|
57
|
-
}
|
|
58
19
|
function toUrlBase64(strInBase64) {
|
|
59
20
|
return strInBase64.replace(/[=]/g, '').replace(/\//g, '_').replace(/\+/g, '-');
|
|
60
21
|
}
|
|
61
|
-
function isBase64Url(tokenStr) {
|
|
62
|
-
const base64UrlRegex = /^[A-Za-z0-9_-]*$/;
|
|
63
|
-
return base64UrlRegex.test(tokenStr);
|
|
64
|
-
}
|
|
65
|
-
function base64UrlToBase64(base64Url) {
|
|
66
|
-
let base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
|
|
67
|
-
while (base64.length % 4 !== 0) {
|
|
68
|
-
base64 += '=';
|
|
69
|
-
}
|
|
70
|
-
switch (base64.length % 4) {
|
|
71
|
-
case 0:
|
|
72
|
-
break;
|
|
73
|
-
case 1:
|
|
74
|
-
base64 += '===';
|
|
75
|
-
break;
|
|
76
|
-
case 2:
|
|
77
|
-
base64 += '==';
|
|
78
|
-
break;
|
|
79
|
-
case 3:
|
|
80
|
-
base64 += '=';
|
|
81
|
-
break;
|
|
82
|
-
default:
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
return base64;
|
|
86
|
-
}
|
|
87
|
-
const errorHandler = (response) => {
|
|
88
|
-
let message = 'Unknown';
|
|
89
|
-
let code = 500;
|
|
90
|
-
if (response.name === 'Foundation::PermissionDeniedResponse') {
|
|
91
|
-
code = 403;
|
|
92
|
-
message = `Permission Denied. Job ID: ${response.jobId} failed with status code ${code} `;
|
|
93
|
-
}
|
|
94
|
-
else if (response.name === 'Foundation::ErrorResponse' && response.reason) {
|
|
95
|
-
const isJson = response.reason.startsWith('{');
|
|
96
|
-
const reason = isJson ? JSON.parse(response.reason) || {} : response.reason;
|
|
97
|
-
if (isJson && reason.errors?.[0].details) {
|
|
98
|
-
message = reason.errors[0].details;
|
|
99
|
-
}
|
|
100
|
-
else if (typeof reason === 'string') {
|
|
101
|
-
message = reason;
|
|
102
|
-
}
|
|
103
|
-
code = parseInt(reason?.meta?.status?.code ?? response.msg.reason?.value ?? 500, 10);
|
|
104
|
-
}
|
|
105
|
-
return new errors_1.ResponseError(`${message} (${code})`, response);
|
|
106
|
-
};
|
|
107
|
-
exports.errorHandler = errorHandler;
|
|
108
|
-
const delay = async (delayInMs) => new Promise((resolve) => {
|
|
109
|
-
setTimeout(resolve, delayInMs);
|
|
110
|
-
});
|
|
111
|
-
exports.delay = delay;
|
|
112
|
-
const isNodeEnvironment = () => typeof window === 'undefined';
|
|
113
|
-
exports.isNodeEnvironment = isNodeEnvironment;
|
|
@@ -14,7 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./observe/ObserveOptions"), exports);
|
|
18
17
|
__exportStar(require("./result/RequestResult"), exports);
|
|
19
18
|
__exportStar(require("./result/HighLevelRequestResult"), exports);
|
|
20
19
|
__exportStar(require("./result/HTTPProxyRequestResult"), exports);
|
|
@@ -15,9 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("../authentication/util"), exports);
|
|
18
|
-
__exportStar(require("../authentication/AppAuthentication"), exports);
|
|
19
|
-
__exportStar(require("../authentication/UserCredentialAuthentication"), exports);
|
|
20
|
-
__exportStar(require("../authentication/UserPasswordAuthentication"), exports);
|
|
21
18
|
__exportStar(require("../message/request/AuthenticationRequest"), exports);
|
|
22
19
|
__exportStar(require("../message/request/ConfigurationRequest"), exports);
|
|
23
20
|
__exportStar(require("../mixins/auth/AppAuthMixin"), exports);
|
|
@@ -14,10 +14,24 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
18
|
-
__exportStar(require("./AbstractFrontgateConnection"), exports);
|
|
19
|
-
__exportStar(require("./FrontgateWSConnection"), exports);
|
|
20
|
-
__exportStar(require("./util/Encoding"), exports);
|
|
17
|
+
exports.DefaultHosts = exports.DeploymentStage = exports.ConnectionState = void 0;
|
|
21
18
|
__exportStar(require("./util/functions"), exports);
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
var ConnectionState;
|
|
20
|
+
(function (ConnectionState) {
|
|
21
|
+
ConnectionState[ConnectionState["DISCONNECTED"] = 0] = "DISCONNECTED";
|
|
22
|
+
ConnectionState[ConnectionState["CONNECTING"] = 1] = "CONNECTING";
|
|
23
|
+
ConnectionState[ConnectionState["AUTHENTICATED"] = 2] = "AUTHENTICATED";
|
|
24
|
+
ConnectionState[ConnectionState["RECONNECTING"] = 3] = "RECONNECTING";
|
|
25
|
+
})(ConnectionState || (exports.ConnectionState = ConnectionState = {}));
|
|
26
|
+
var DeploymentStage;
|
|
27
|
+
(function (DeploymentStage) {
|
|
28
|
+
DeploymentStage[DeploymentStage["production"] = 40] = "production";
|
|
29
|
+
DeploymentStage[DeploymentStage["preproduction"] = 35] = "preproduction";
|
|
30
|
+
DeploymentStage[DeploymentStage["show"] = 30] = "show";
|
|
31
|
+
DeploymentStage[DeploymentStage["testing"] = 20] = "testing";
|
|
32
|
+
})(DeploymentStage || (exports.DeploymentStage = DeploymentStage = {}));
|
|
33
|
+
var DefaultHosts;
|
|
34
|
+
(function (DefaultHosts) {
|
|
35
|
+
DefaultHosts["production"] = "frontgate-eu.factsetdigitalsolutions.com";
|
|
36
|
+
DefaultHosts["show"] = "frontgate-eu.show.factsetdigitalsolutions.com";
|
|
37
|
+
})(DefaultHosts || (exports.DefaultHosts = DefaultHosts = {}));
|