chore(): tidier types for pending subs, bump axios to latest
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
"node_modules",
|
"node_modules",
|
||||||
"**/node_modules/*",
|
"**/node_modules/*",
|
||||||
"coverage",
|
"coverage",
|
||||||
"doc"
|
"doc",
|
||||||
|
"examples/ignored/*"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
15
package-lock.json
generated
15
package-lock.json
generated
@@ -9,7 +9,7 @@
|
|||||||
"version": "3.10.29",
|
"version": "3.10.29",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.6.6",
|
"axios": "^1.7.9",
|
||||||
"isomorphic-ws": "^4.0.1",
|
"isomorphic-ws": "^4.0.1",
|
||||||
"ws": "^7.4.0"
|
"ws": "^7.4.0"
|
||||||
},
|
},
|
||||||
@@ -2294,9 +2294,10 @@
|
|||||||
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
|
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
|
||||||
},
|
},
|
||||||
"node_modules/axios": {
|
"node_modules/axios": {
|
||||||
"version": "1.7.7",
|
"version": "1.7.9",
|
||||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz",
|
"resolved": "https://registry.npmjs.org/axios/-/axios-1.7.9.tgz",
|
||||||
"integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==",
|
"integrity": "sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==",
|
||||||
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"follow-redirects": "^1.15.6",
|
"follow-redirects": "^1.15.6",
|
||||||
"form-data": "^4.0.0",
|
"form-data": "^4.0.0",
|
||||||
@@ -8784,9 +8785,9 @@
|
|||||||
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
|
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
|
||||||
},
|
},
|
||||||
"axios": {
|
"axios": {
|
||||||
"version": "1.7.7",
|
"version": "1.7.9",
|
||||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz",
|
"resolved": "https://registry.npmjs.org/axios/-/axios-1.7.9.tgz",
|
||||||
"integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==",
|
"integrity": "sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"follow-redirects": "^1.15.6",
|
"follow-redirects": "^1.15.6",
|
||||||
"form-data": "^4.0.0",
|
"form-data": "^4.0.0",
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
"Stefan Aebischer <os@pixtron.ch> (https://pixtron.ch)"
|
"Stefan Aebischer <os@pixtron.ch> (https://pixtron.ch)"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.6.6",
|
"axios": "^1.7.9",
|
||||||
"isomorphic-ws": "^4.0.1",
|
"isomorphic-ws": "^4.0.1",
|
||||||
"ws": "^7.4.0"
|
"ws": "^7.4.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -132,13 +132,14 @@ export abstract class BaseWebsocketClient<
|
|||||||
|
|
||||||
private timeOffsetMs: number = 0;
|
private timeOffsetMs: number = 0;
|
||||||
|
|
||||||
private pendingTopicSubscriptionRequests: {
|
/**
|
||||||
[key in TWSKey]?: {
|
* A nested wsKey->request key store.
|
||||||
[requestKey: string]:
|
* pendingTopicSubscriptionRequests[wsKey][requestKey] = WsKeyPendingTopicSubscriptions<TWSRequestEvent>
|
||||||
| undefined
|
*/
|
||||||
| WsKeyPendingTopicSubscriptions<TWSRequestEvent>;
|
private pendingTopicSubscriptionRequests: Record<
|
||||||
};
|
string,
|
||||||
} = {};
|
Record<string, undefined | WsKeyPendingTopicSubscriptions<TWSRequestEvent>>
|
||||||
|
> = {};
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
options?: WSClientConfigurableOptions,
|
options?: WSClientConfigurableOptions,
|
||||||
@@ -281,9 +282,9 @@ export abstract class BaseWebsocketClient<
|
|||||||
const requestKey = requestData.requestKey;
|
const requestKey = requestData.requestKey;
|
||||||
|
|
||||||
// Should not be possible to see a requestKey collision in the current design, since the req ID increments automatically with every request, so this should never be true, but just in case a future mistake happens...
|
// Should not be possible to see a requestKey collision in the current design, since the req ID increments automatically with every request, so this should never be true, but just in case a future mistake happens...
|
||||||
const existingWsKeyPendingRequests =
|
|
||||||
this.getWsKeyPendingSubscriptionStore(wsKey);
|
const pendingSubReqs = this.getWsKeyPendingSubscriptionStore(wsKey);
|
||||||
if (existingWsKeyPendingRequests[requestKey]) {
|
if (pendingSubReqs[requestKey]) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'Implementation error: attempted to upsert pending topics with duplicate request ID!',
|
'Implementation error: attempted to upsert pending topics with duplicate request ID!',
|
||||||
);
|
);
|
||||||
@@ -294,8 +295,8 @@ export abstract class BaseWebsocketClient<
|
|||||||
resolver: TopicsPendingSubscriptionsResolver<TWSRequestEvent>,
|
resolver: TopicsPendingSubscriptionsResolver<TWSRequestEvent>,
|
||||||
rejector: TopicsPendingSubscriptionsRejector<TWSRequestEvent>,
|
rejector: TopicsPendingSubscriptionsRejector<TWSRequestEvent>,
|
||||||
) => {
|
) => {
|
||||||
const store = this.getWsKeyPendingSubscriptionStore(wsKey);
|
const pendingSubReqs = this.getWsKeyPendingSubscriptionStore(wsKey);
|
||||||
store[requestKey] = {
|
pendingSubReqs[requestKey] = {
|
||||||
requestData: requestData.requestEvent,
|
requestData: requestData.requestEvent,
|
||||||
resolver,
|
resolver,
|
||||||
rejector,
|
rejector,
|
||||||
@@ -305,8 +306,8 @@ export abstract class BaseWebsocketClient<
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected removeTopicPendingSubscription(wsKey: TWSKey, requestKey: string) {
|
protected removeTopicPendingSubscription(wsKey: TWSKey, requestKey: string) {
|
||||||
const store = this.getWsKeyPendingSubscriptionStore(wsKey);
|
const pendingSubReqs = this.getWsKeyPendingSubscriptionStore(wsKey);
|
||||||
delete store[requestKey];
|
delete pendingSubReqs[requestKey];
|
||||||
}
|
}
|
||||||
|
|
||||||
private clearTopicsPendingSubscriptions(
|
private clearTopicsPendingSubscriptions(
|
||||||
@@ -315,9 +316,10 @@ export abstract class BaseWebsocketClient<
|
|||||||
rejectReason: string,
|
rejectReason: string,
|
||||||
) {
|
) {
|
||||||
if (rejectAll) {
|
if (rejectAll) {
|
||||||
const wsKeyPendingRequests = this.getWsKeyPendingSubscriptionStore(wsKey);
|
const pendingSubReqs = this.getWsKeyPendingSubscriptionStore(wsKey);
|
||||||
for (const requestKey in wsKeyPendingRequests) {
|
|
||||||
const request = wsKeyPendingRequests[requestKey];
|
for (const requestKey in pendingSubReqs) {
|
||||||
|
const request = pendingSubReqs[requestKey];
|
||||||
request?.rejector(request.requestData, rejectReason);
|
request?.rejector(request.requestData, rejectReason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user