@brokerize/client 1.12.0 → 1.12.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/dist/authorizedApiContext.d.ts +15 -0
- package/dist/authorizedApiContext.js +36 -3
- package/dist/cjs/authorizedApiContext.d.ts +15 -0
- package/dist/cjs/authorizedApiContext.js +36 -3
- package/dist/cjs/websocketClient.d.ts +9 -1
- package/dist/cjs/websocketClient.js +10 -0
- package/dist/client.d.ts +15 -0
- package/dist/websocketClient.d.ts +9 -1
- package/dist/websocketClient.js +10 -0
- package/package.json +1 -1
|
@@ -32,6 +32,21 @@ export declare class AuthorizedApiContext {
|
|
|
32
32
|
private readonly _syncApi;
|
|
33
33
|
private readonly _decoupledOperationsApi;
|
|
34
34
|
constructor(cfg: BrokerizeConfig, auth: Auth, wsClient?: BrokerizeWebSocketClient);
|
|
35
|
+
/**
|
|
36
|
+
* The websocket client keeps one context around to refetch the status of a decoupled operation
|
|
37
|
+
* with after an interrupted connection. That context has to outlive the connection, so it must
|
|
38
|
+
* not simply be whichever one was constructed last: child contexts are commonly created per
|
|
39
|
+
* request and destroyed again, and a destroyed context cannot perform that request.
|
|
40
|
+
*
|
|
41
|
+
* The first context attaches and keeps the client - that is the one that created it, and the
|
|
42
|
+
* children, which are handed the very same client, leave it alone.
|
|
43
|
+
*/
|
|
44
|
+
private _attachToWsClient;
|
|
45
|
+
/**
|
|
46
|
+
* Counterpart of `_attachToWsClient`: leave no destroyed context behind, so that a context
|
|
47
|
+
* created later can take over.
|
|
48
|
+
*/
|
|
49
|
+
private _detachFromWsClient;
|
|
35
50
|
createChildContext(): AuthorizedApiContext;
|
|
36
51
|
private _initRequestInit;
|
|
37
52
|
getBrokers(): Promise<openApiClient.GetBrokersResponse>;
|
|
@@ -53,11 +53,43 @@ export class AuthorizedApiContext {
|
|
|
53
53
|
this._abortController = cfg.createAbortController();
|
|
54
54
|
this._ownsWsClient = !wsClient;
|
|
55
55
|
this._wsClient = wsClient || this._initInternalWebSocketClient();
|
|
56
|
-
|
|
57
|
-
this._wsClient._setAuthorizedApiContext(this);
|
|
58
|
-
}
|
|
56
|
+
this._attachToWsClient();
|
|
59
57
|
this._cache = {};
|
|
60
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* The websocket client keeps one context around to refetch the status of a decoupled operation
|
|
61
|
+
* with after an interrupted connection. That context has to outlive the connection, so it must
|
|
62
|
+
* not simply be whichever one was constructed last: child contexts are commonly created per
|
|
63
|
+
* request and destroyed again, and a destroyed context cannot perform that request.
|
|
64
|
+
*
|
|
65
|
+
* The first context attaches and keeps the client - that is the one that created it, and the
|
|
66
|
+
* children, which are handed the very same client, leave it alone.
|
|
67
|
+
*/
|
|
68
|
+
_attachToWsClient() {
|
|
69
|
+
const wsClient = this._wsClient;
|
|
70
|
+
/* an application may pass in its own implementation of the interface. */
|
|
71
|
+
if (!wsClient._setAuthorizedApiContext ||
|
|
72
|
+
!wsClient._getAuthorizedApiContext) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (!wsClient._getAuthorizedApiContext()) {
|
|
76
|
+
wsClient._setAuthorizedApiContext(this);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Counterpart of `_attachToWsClient`: leave no destroyed context behind, so that a context
|
|
81
|
+
* created later can take over.
|
|
82
|
+
*/
|
|
83
|
+
_detachFromWsClient() {
|
|
84
|
+
const wsClient = this._wsClient;
|
|
85
|
+
if (!wsClient._setAuthorizedApiContext ||
|
|
86
|
+
!wsClient._getAuthorizedApiContext) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (wsClient._getAuthorizedApiContext() === this) {
|
|
90
|
+
wsClient._setAuthorizedApiContext(null);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
61
93
|
createChildContext() {
|
|
62
94
|
const result = new AuthorizedApiContext(this._cfg, this._auth, this._wsClient);
|
|
63
95
|
const childContexts = this._childContexts;
|
|
@@ -444,6 +476,7 @@ export class AuthorizedApiContext {
|
|
|
444
476
|
destroy() {
|
|
445
477
|
this._isDestroyed = true;
|
|
446
478
|
this._abortController.abort();
|
|
479
|
+
this._detachFromWsClient();
|
|
447
480
|
if (this._ownsWsClient) {
|
|
448
481
|
/* otherwise its reconnect timer would keep running and keep reconnecting with the
|
|
449
482
|
tokens of a context that is gone. */
|
|
@@ -32,6 +32,21 @@ export declare class AuthorizedApiContext {
|
|
|
32
32
|
private readonly _syncApi;
|
|
33
33
|
private readonly _decoupledOperationsApi;
|
|
34
34
|
constructor(cfg: BrokerizeConfig, auth: Auth, wsClient?: BrokerizeWebSocketClient);
|
|
35
|
+
/**
|
|
36
|
+
* The websocket client keeps one context around to refetch the status of a decoupled operation
|
|
37
|
+
* with after an interrupted connection. That context has to outlive the connection, so it must
|
|
38
|
+
* not simply be whichever one was constructed last: child contexts are commonly created per
|
|
39
|
+
* request and destroyed again, and a destroyed context cannot perform that request.
|
|
40
|
+
*
|
|
41
|
+
* The first context attaches and keeps the client - that is the one that created it, and the
|
|
42
|
+
* children, which are handed the very same client, leave it alone.
|
|
43
|
+
*/
|
|
44
|
+
private _attachToWsClient;
|
|
45
|
+
/**
|
|
46
|
+
* Counterpart of `_attachToWsClient`: leave no destroyed context behind, so that a context
|
|
47
|
+
* created later can take over.
|
|
48
|
+
*/
|
|
49
|
+
private _detachFromWsClient;
|
|
35
50
|
createChildContext(): AuthorizedApiContext;
|
|
36
51
|
private _initRequestInit;
|
|
37
52
|
getBrokers(): Promise<openApiClient.GetBrokersResponse>;
|
|
@@ -90,11 +90,43 @@ class AuthorizedApiContext {
|
|
|
90
90
|
this._abortController = cfg.createAbortController();
|
|
91
91
|
this._ownsWsClient = !wsClient;
|
|
92
92
|
this._wsClient = wsClient || this._initInternalWebSocketClient();
|
|
93
|
-
|
|
94
|
-
this._wsClient._setAuthorizedApiContext(this);
|
|
95
|
-
}
|
|
93
|
+
this._attachToWsClient();
|
|
96
94
|
this._cache = {};
|
|
97
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* The websocket client keeps one context around to refetch the status of a decoupled operation
|
|
98
|
+
* with after an interrupted connection. That context has to outlive the connection, so it must
|
|
99
|
+
* not simply be whichever one was constructed last: child contexts are commonly created per
|
|
100
|
+
* request and destroyed again, and a destroyed context cannot perform that request.
|
|
101
|
+
*
|
|
102
|
+
* The first context attaches and keeps the client - that is the one that created it, and the
|
|
103
|
+
* children, which are handed the very same client, leave it alone.
|
|
104
|
+
*/
|
|
105
|
+
_attachToWsClient() {
|
|
106
|
+
const wsClient = this._wsClient;
|
|
107
|
+
/* an application may pass in its own implementation of the interface. */
|
|
108
|
+
if (!wsClient._setAuthorizedApiContext ||
|
|
109
|
+
!wsClient._getAuthorizedApiContext) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (!wsClient._getAuthorizedApiContext()) {
|
|
113
|
+
wsClient._setAuthorizedApiContext(this);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Counterpart of `_attachToWsClient`: leave no destroyed context behind, so that a context
|
|
118
|
+
* created later can take over.
|
|
119
|
+
*/
|
|
120
|
+
_detachFromWsClient() {
|
|
121
|
+
const wsClient = this._wsClient;
|
|
122
|
+
if (!wsClient._setAuthorizedApiContext ||
|
|
123
|
+
!wsClient._getAuthorizedApiContext) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (wsClient._getAuthorizedApiContext() === this) {
|
|
127
|
+
wsClient._setAuthorizedApiContext(null);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
98
130
|
createChildContext() {
|
|
99
131
|
const result = new AuthorizedApiContext(this._cfg, this._auth, this._wsClient);
|
|
100
132
|
const childContexts = this._childContexts;
|
|
@@ -481,6 +513,7 @@ class AuthorizedApiContext {
|
|
|
481
513
|
destroy() {
|
|
482
514
|
this._isDestroyed = true;
|
|
483
515
|
this._abortController.abort();
|
|
516
|
+
this._detachFromWsClient();
|
|
484
517
|
if (this._ownsWsClient) {
|
|
485
518
|
/* otherwise its reconnect timer would keep running and keep reconnecting with the
|
|
486
519
|
tokens of a context that is gone. */
|
|
@@ -89,8 +89,16 @@ export declare class BrokerizeWebSocketClientImpl implements BrokerizeWebSocketC
|
|
|
89
89
|
/**
|
|
90
90
|
* Internal method for setting a related AuthorizedApiContext. This is used to retrieve
|
|
91
91
|
* decoupled operation status on interrupted connections.
|
|
92
|
+
*
|
|
93
|
+
* `null` detaches the current one, which a context does when it is destroyed: a destroyed
|
|
94
|
+
* context cannot perform that request, so holding on to it would be worse than holding none.
|
|
95
|
+
*/
|
|
96
|
+
_setAuthorizedApiContext(ctx: AuthorizedApiContext | null): void;
|
|
97
|
+
/**
|
|
98
|
+
* Internal counterpart of `_setAuthorizedApiContext`, so that a context can tell whether the
|
|
99
|
+
* client is already attached to one - and whether that one is itself.
|
|
92
100
|
*/
|
|
93
|
-
|
|
101
|
+
_getAuthorizedApiContext(): AuthorizedApiContext | null;
|
|
94
102
|
_startOrStopDisconnectTimeout(): void;
|
|
95
103
|
private _sendWs;
|
|
96
104
|
/**
|
|
@@ -351,10 +351,20 @@ class BrokerizeWebSocketClientImpl {
|
|
|
351
351
|
/**
|
|
352
352
|
* Internal method for setting a related AuthorizedApiContext. This is used to retrieve
|
|
353
353
|
* decoupled operation status on interrupted connections.
|
|
354
|
+
*
|
|
355
|
+
* `null` detaches the current one, which a context does when it is destroyed: a destroyed
|
|
356
|
+
* context cannot perform that request, so holding on to it would be worse than holding none.
|
|
354
357
|
*/
|
|
355
358
|
_setAuthorizedApiContext(ctx) {
|
|
356
359
|
this._apiCtx = ctx;
|
|
357
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* Internal counterpart of `_setAuthorizedApiContext`, so that a context can tell whether the
|
|
363
|
+
* client is already attached to one - and whether that one is itself.
|
|
364
|
+
*/
|
|
365
|
+
_getAuthorizedApiContext() {
|
|
366
|
+
return this._apiCtx;
|
|
367
|
+
}
|
|
358
368
|
_startOrStopDisconnectTimeout() {
|
|
359
369
|
if (this._shouldConnect()) {
|
|
360
370
|
if (this._disconnectTimeout) {
|
package/dist/client.d.ts
CHANGED
|
@@ -1104,6 +1104,21 @@ export declare class AuthorizedApiContext {
|
|
|
1104
1104
|
private readonly _syncApi;
|
|
1105
1105
|
private readonly _decoupledOperationsApi;
|
|
1106
1106
|
constructor(cfg: BrokerizeConfig, auth: Auth, wsClient?: BrokerizeWebSocketClient);
|
|
1107
|
+
/**
|
|
1108
|
+
* The websocket client keeps one context around to refetch the status of a decoupled operation
|
|
1109
|
+
* with after an interrupted connection. That context has to outlive the connection, so it must
|
|
1110
|
+
* not simply be whichever one was constructed last: child contexts are commonly created per
|
|
1111
|
+
* request and destroyed again, and a destroyed context cannot perform that request.
|
|
1112
|
+
*
|
|
1113
|
+
* The first context attaches and keeps the client - that is the one that created it, and the
|
|
1114
|
+
* children, which are handed the very same client, leave it alone.
|
|
1115
|
+
*/
|
|
1116
|
+
private _attachToWsClient;
|
|
1117
|
+
/**
|
|
1118
|
+
* Counterpart of `_attachToWsClient`: leave no destroyed context behind, so that a context
|
|
1119
|
+
* created later can take over.
|
|
1120
|
+
*/
|
|
1121
|
+
private _detachFromWsClient;
|
|
1107
1122
|
createChildContext(): AuthorizedApiContext;
|
|
1108
1123
|
private _initRequestInit;
|
|
1109
1124
|
getBrokers(): Promise<openApiClient.GetBrokersResponse>;
|
|
@@ -89,8 +89,16 @@ export declare class BrokerizeWebSocketClientImpl implements BrokerizeWebSocketC
|
|
|
89
89
|
/**
|
|
90
90
|
* Internal method for setting a related AuthorizedApiContext. This is used to retrieve
|
|
91
91
|
* decoupled operation status on interrupted connections.
|
|
92
|
+
*
|
|
93
|
+
* `null` detaches the current one, which a context does when it is destroyed: a destroyed
|
|
94
|
+
* context cannot perform that request, so holding on to it would be worse than holding none.
|
|
95
|
+
*/
|
|
96
|
+
_setAuthorizedApiContext(ctx: AuthorizedApiContext | null): void;
|
|
97
|
+
/**
|
|
98
|
+
* Internal counterpart of `_setAuthorizedApiContext`, so that a context can tell whether the
|
|
99
|
+
* client is already attached to one - and whether that one is itself.
|
|
92
100
|
*/
|
|
93
|
-
|
|
101
|
+
_getAuthorizedApiContext(): AuthorizedApiContext | null;
|
|
94
102
|
_startOrStopDisconnectTimeout(): void;
|
|
95
103
|
private _sendWs;
|
|
96
104
|
/**
|
package/dist/websocketClient.js
CHANGED
|
@@ -348,10 +348,20 @@ export class BrokerizeWebSocketClientImpl {
|
|
|
348
348
|
/**
|
|
349
349
|
* Internal method for setting a related AuthorizedApiContext. This is used to retrieve
|
|
350
350
|
* decoupled operation status on interrupted connections.
|
|
351
|
+
*
|
|
352
|
+
* `null` detaches the current one, which a context does when it is destroyed: a destroyed
|
|
353
|
+
* context cannot perform that request, so holding on to it would be worse than holding none.
|
|
351
354
|
*/
|
|
352
355
|
_setAuthorizedApiContext(ctx) {
|
|
353
356
|
this._apiCtx = ctx;
|
|
354
357
|
}
|
|
358
|
+
/**
|
|
359
|
+
* Internal counterpart of `_setAuthorizedApiContext`, so that a context can tell whether the
|
|
360
|
+
* client is already attached to one - and whether that one is itself.
|
|
361
|
+
*/
|
|
362
|
+
_getAuthorizedApiContext() {
|
|
363
|
+
return this._apiCtx;
|
|
364
|
+
}
|
|
355
365
|
_startOrStopDisconnectTimeout() {
|
|
356
366
|
if (this._shouldConnect()) {
|
|
357
367
|
if (this._disconnectTimeout) {
|