@kosdev-code/kos-ui-sdk 0.1.0-next.808 → 0.1.0-next.810
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/core/core/transport/webSocketTransport.d.ts +30 -2
- package/core/core/transport/webSocketTransport.d.ts.map +1 -1
- package/core/types/utils/kos-fetch.d.ts +17 -0
- package/core/types/utils/kos-fetch.d.ts.map +1 -1
- package/core/util/abortable-when.d.ts +21 -0
- package/core/util/abortable-when.d.ts.map +1 -0
- package/core/util/index.d.ts +1 -0
- package/core/util/index.d.ts.map +1 -1
- package/core/util/kos-fetch.d.ts.map +1 -1
- package/core/util/kos-service-request.d.ts +10 -0
- package/core/util/kos-service-request.d.ts.map +1 -1
- package/core/util/transport-not-ready-error.d.ts +67 -0
- package/core/util/transport-not-ready-error.d.ts.map +1 -0
- package/index.cjs +113 -9
- package/index.cjs.map +1 -1
- package/index.js +113 -9
- package/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -13,6 +13,23 @@ export interface IKosConnectionStatus {
|
|
|
13
13
|
status: string;
|
|
14
14
|
message?: string;
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Options for {@link IKosServiceTransport.whenReady}.
|
|
18
|
+
*
|
|
19
|
+
* @kosService core.transport
|
|
20
|
+
* @kosApiLevel 23
|
|
21
|
+
*/
|
|
22
|
+
export interface KosTransportReadyOptions {
|
|
23
|
+
/**
|
|
24
|
+
* Cancels the readiness wait when it aborts. Without one the wait is
|
|
25
|
+
* indefinite, which is correct for startup/lifecycle code but not for a
|
|
26
|
+
* request working against a deadline.
|
|
27
|
+
*
|
|
28
|
+
* When the signal aborts, `whenReady` rejects with the signal's reason and
|
|
29
|
+
* disposes the underlying reactive waiter.
|
|
30
|
+
*/
|
|
31
|
+
signal?: AbortSignal;
|
|
32
|
+
}
|
|
16
33
|
export interface KosSubscriptionParams {
|
|
17
34
|
topic: string;
|
|
18
35
|
callback: EventCallback;
|
|
@@ -32,7 +49,7 @@ export interface IKosServiceTransport {
|
|
|
32
49
|
socket?: MessageTransport;
|
|
33
50
|
init(): IKosServiceTransport;
|
|
34
51
|
subscribeTopic(params: KosSubscriptionParams): VoidFunction;
|
|
35
|
-
whenReady(): Promise<IKosConnectionStatus>;
|
|
52
|
+
whenReady(options?: KosTransportReadyOptions): Promise<IKosConnectionStatus>;
|
|
36
53
|
fosSocket?: MessageTransport;
|
|
37
54
|
}
|
|
38
55
|
export type KosCallback = (msg: IKosMessage) => void;
|
|
@@ -78,7 +95,18 @@ export declare class WebSocketTransport implements IKosServiceTransport {
|
|
|
78
95
|
private calculateBackoffDelay;
|
|
79
96
|
private _sendSubscriptionMessage;
|
|
80
97
|
subscribeTopic({ topic, callback, fos, bridge, destinationAddress, explicitDestination, }: KosSubscriptionParams): () => void;
|
|
81
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Resolves once the transport can carry requests: the socket (and the FOS
|
|
100
|
+
* socket, when used) is connected and the connection is authorized.
|
|
101
|
+
*
|
|
102
|
+
* Pass `options.signal` to bound the wait. `connectionEstablished` flips back
|
|
103
|
+
* to `false` on socket close, so an unbounded wait parks indefinitely while
|
|
104
|
+
* the transport is down — callers with a deadline must supply a signal.
|
|
105
|
+
*
|
|
106
|
+
* @param options - See {@link KosTransportReadyOptions}.
|
|
107
|
+
* @throws The signal's abort reason if it aborts before the transport is ready.
|
|
108
|
+
*/
|
|
109
|
+
whenReady(options?: KosTransportReadyOptions): Promise<{
|
|
82
110
|
status: string;
|
|
83
111
|
}>;
|
|
84
112
|
get token(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webSocketTransport.d.ts","sourceRoot":"","sources":["../../../../../../packages/kos-ui-sdk/src/core/core/transport/webSocketTransport.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webSocketTransport.d.ts","sourceRoot":"","sources":["../../../../../../packages/kos-ui-sdk/src/core/core/transport/webSocketTransport.ts"],"names":[],"mappings":"AAEA,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AAwB;IA+C3B,IAAI,qBAAqB,YAsBxB;IAED,IAAI;IA+BJ;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;IAwBzB,OAAO,CAAC,qBAAqB;IAU7B,OAAO,CAAC,wBAAwB;IAyChC,cAAc,CAAC,EACb,KAAK,EACL,QAAQ,EACR,GAAG,EACH,MAAM,EACN,kBAAkB,EAClB,mBAAmB,GACpB,EAAE,qBAAqB;IA4BxB;;;;;;;;;;OAUG;IACG,SAAS,CAAC,OAAO,CAAC,EAAE,wBAAwB;;;IAkBlD,IAAI,KAAK,IAGQ,MAAM,CADtB;IACD,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,EAGtB;WACa,IAAI,CAAC,IAAI,SAAc;WAKvB,IAAI,CAAC,IAAI,SAAO;WAKhB,KAAK,CAAC,KAAK,EAAE,MAAM;WAInB,WAAW,CAAC,IAAI,SAAO,EAAE,KAAK,CAAC,EAAE,MAAM;CAStD"}
|
|
@@ -141,6 +141,23 @@ export interface KosFetchOptions {
|
|
|
141
141
|
* @internal
|
|
142
142
|
*/
|
|
143
143
|
bridge?: boolean;
|
|
144
|
+
/**
|
|
145
|
+
* Timeout budget for the **entire call**, in milliseconds: waiting for the
|
|
146
|
+
* transport to become ready plus the request itself.
|
|
147
|
+
*
|
|
148
|
+
* A request issued while the socket is down or reconnecting settles within
|
|
149
|
+
* this budget — it rejects with a `TransportNotReadyError` if the transport
|
|
150
|
+
* never becomes ready — rather than queuing indefinitely. If the transport
|
|
151
|
+
* becomes ready with budget remaining, the remainder applies to the request,
|
|
152
|
+
* which then rejects with a `TimeoutError` `DOMException`. The two errors are
|
|
153
|
+
* distinct so callers can tell "service is slow" from "transport is down".
|
|
154
|
+
*
|
|
155
|
+
* Defaults to the `KOS_WS_TIMEOUT` environment value, or 30000.
|
|
156
|
+
*
|
|
157
|
+
* Pass `0` or `Infinity` to opt out of the budget entirely and queue until
|
|
158
|
+
* the transport recovers — a request that does this can never settle while
|
|
159
|
+
* the socket is down.
|
|
160
|
+
*/
|
|
144
161
|
timeout?: number;
|
|
145
162
|
/**
|
|
146
163
|
* @kosApiLevel 5
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kos-fetch.d.ts","sourceRoot":"","sources":["../../../../../../packages/kos-ui-sdk/src/core/types/utils/kos-fetch.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,oBAAY,eAAe;IACzB,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,MAAM,WAAW;CAClB;AAED,KAAK,kBAAkB,GAAG,MAAM,OAAO,eAAe,CAAC;AAEvD;;;GAGG;AACH,MAAM,WAAW,OAAO;IACtB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACjC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3B,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,OAAO,CACL,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,EACjE,OAAO,CAAC,EAAE,GAAG,GACZ,IAAI,CAAC;CACT;AAED,UAAU,IAAI;IACZ,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;IACjD,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC;IACpC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC9B,IAAI,CAAC,CAAC,GAAG,GAAG,K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AAO,CAAC,CAAC;CACrD;AAED;;;GAGG;AACH,MAAM,WAAW,iBACf,SAAQ,IAAI,CAAC,eAAe,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;IAC9D,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AACD;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAkB,SAAQ,mBAAmB;IAC5D,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;CACnC;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAoB,SAAQ,eAAe;IAC1D,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
|
|
1
|
+
{"version":3,"file":"kos-fetch.d.ts","sourceRoot":"","sources":["../../../../../../packages/kos-ui-sdk/src/core/types/utils/kos-fetch.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,oBAAY,eAAe;IACzB,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,IAAI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AClC;AACD;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAkB,SAAQ,mBAAmB;IAC5D,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;CACnC;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAoB,SAAQ,eAAe;IAC1D,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Waits for a MobX predicate to become `true`, but gives up as soon as the
|
|
3
|
+
* supplied signal aborts.
|
|
4
|
+
*
|
|
5
|
+
* MobX's `when()` waits forever by design. That is the right default for
|
|
6
|
+
* lifecycle code, but a caller working against a deadline needs the wait to be
|
|
7
|
+
* cancellable — and, more importantly, needs the underlying reaction disposed
|
|
8
|
+
* when it gives up. Without disposal, every abandoned waiter leaves a live
|
|
9
|
+
* reaction observing the predicate for the lifetime of the process.
|
|
10
|
+
*
|
|
11
|
+
* @param predicate - The reactive condition to wait for.
|
|
12
|
+
* @param signal - Optional signal that cancels the wait. When omitted the wait
|
|
13
|
+
* is indefinite, matching plain `when()`.
|
|
14
|
+
* @returns A promise that resolves once the predicate holds.
|
|
15
|
+
* @throws The signal's abort reason (a `TimeoutError` or `AbortError`
|
|
16
|
+
* `DOMException` for signals created by the SDK) if it aborts first.
|
|
17
|
+
*
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export declare const abortableWhen: (predicate: () => boolean, signal?: AbortSignal) => Promise<void>;
|
|
21
|
+
//# sourceMappingURL=abortable-when.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abortable-when.d.ts","sourceRoot":"","sources":["../../../../../packages/kos-ui-sdk/src/core/util/abortable-when.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,aAAa,GACxB,WAAW,MAAM,OAAO,EACxB,SAAS,WAAW,KACnB,OAAO,CAAC,IAAI,CAqCd,CAAC"}
|
package/core/util/index.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export * from './service-factory';
|
|
|
30
30
|
export * from './service-request-error';
|
|
31
31
|
export * from './service-response';
|
|
32
32
|
export * from './session-utils';
|
|
33
|
+
export * from './transport-not-ready-error';
|
|
33
34
|
export * from './wait-for-request';
|
|
34
35
|
export * from './when-ready';
|
|
35
36
|
//# sourceMappingURL=index.d.ts.map
|
package/core/util/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/kos-ui-sdk/src/core/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,OAAO,KAAK,WAAW,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,cAAc,iBAAiB,CA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ClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,eAAe,CAAC;AAC9B,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,QAAQ,CAAC;AACvB,cAAc,kCAAkC,CAAC;AACjD,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kos-fetch.d.ts","sourceRoot":"","sources":["../../../../../packages/kos-ui-sdk/src/core/util/kos-fetch.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"kos-fetch.d.ts","sourceRoot":"","sources":["../../../../../packages/kos-ui-sdk/src/core/util/kos-fetch.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAoBrE;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC,IAAI,EAAE,CAAC,CAAC;IACR,MAAM,EAAE,MAAM,CAAC;CAChB;AA4XD;;;;;GAKG;AACH,QAAA,IAAI,QAAQ,QAAS,CAAC;AACtB;;;;;GAKG;AACH,QAAA,IAAI,QAAQ,QA9OL,MAAM,YACD,eAAe,KACxB,OAAO,CAAC,QAAQ,CA4OM,CAAC;AAS1B,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -13,6 +13,16 @@ export declare const resolveBaseUrl: () => {
|
|
|
13
13
|
isMock: boolean;
|
|
14
14
|
URL: string;
|
|
15
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* Error string returned when the transport never became ready inside the
|
|
18
|
+
* request's timeout budget, so the request was never sent. Distinct from
|
|
19
|
+
* `"Request timed out"`, which means the request was sent and the service was
|
|
20
|
+
* slow.
|
|
21
|
+
*
|
|
22
|
+
* @kosService core.service-request
|
|
23
|
+
* @kosApiLevel 23
|
|
24
|
+
*/
|
|
25
|
+
export declare const ERROR_TRANSPORT_NOT_READY = "Transport not ready";
|
|
16
26
|
type NonNeverKeys<T> = {
|
|
17
27
|
[K in keyof T]-?: T[K] extends never | undefined ? never : K;
|
|
18
28
|
}[keyof T];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kos-service-request.d.ts","sourceRoot":"","sources":["../../../../../packages/kos-ui-sdk/src/core/util/kos-service-request.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,UAAU,CAAC;AAG7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"kos-service-request.d.ts","sourceRoot":"","sources":["../../../../../packages/kos-ui-sdk/src/core/util/kos-service-request.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,UAAU,CAAC;AAG7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAGpE,YAAY,EAAE,oBAAoB,EAAE,CAAC;AAErC;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc;;;CAI1B,CAAC;AAKF;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB,wBAAwB,CAAC;AAC/D,KAAK,YAAY,CAAC,CAAC,IAAI;KACpB,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG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AAC,CAAC,CAAC;CACT,CAAC;AACF;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC;AA4O/D,KAAK,cAAc,GAAG,IAAI,CAAC,eAAe,EAAE,QAAQ,GAAG,MAAM,CAAC,CAAC;AAC/D;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;UAKpD,CAAC,8MACK,CAAC,WACF,eAAe,CAAC,KAAK,EAAE,CAAC,CAAC,YACxB,cAAc;WAGnB,CAAC,gNACI,CAAC,WACF,gBAAgB,CAAC,KAAK,EAAE,CAAC,CAAC,yDAEzB,cAAc;UAIpB,CAAC,8MACK,CAAC,WACF,eAAe,CAAC,KAAK,EAAE,CAAC,CAAC,wDAExB,cAAc;aAGjB,CAAC,oNACE,CAAC,WACF,kBAAkB,CAAC,KAAK,EAAE,CAAC,CAAC,wDAE3B,cAAc;EAU7B"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discriminator carried by every {@link TransportNotReadyError}.
|
|
3
|
+
*
|
|
4
|
+
* Prefer checking `error.code === TRANSPORT_NOT_READY` over `instanceof` when
|
|
5
|
+
* the error may have crossed a bundle boundary (an app and the SDK can end up
|
|
6
|
+
* with separate copies of the class).
|
|
7
|
+
*
|
|
8
|
+
* @category Service Request
|
|
9
|
+
* @kosService core.fetch
|
|
10
|
+
* @kosApiLevel 23
|
|
11
|
+
*/
|
|
12
|
+
export declare const TRANSPORT_NOT_READY = "TRANSPORT_NOT_READY";
|
|
13
|
+
/**
|
|
14
|
+
* Raised when a request's timeout budget expires while waiting for the KOS
|
|
15
|
+
* transport to become ready — the socket is closed, reconnecting, or not yet
|
|
16
|
+
* authorized — so the request was never sent.
|
|
17
|
+
*
|
|
18
|
+
* This is deliberately distinct from the `TimeoutError` `DOMException` raised
|
|
19
|
+
* when the request itself times out. The two call for different reactions:
|
|
20
|
+
*
|
|
21
|
+
* - `TimeoutError` — the request reached the service and the service was slow.
|
|
22
|
+
* Retrying later is usually reasonable.
|
|
23
|
+
* - `TransportNotReadyError` — connectivity is down. Retrying the same request
|
|
24
|
+
* will fail the same way until the socket comes back; surface a connectivity
|
|
25
|
+
* state to the user or trigger a reconnect/reload instead.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* try {
|
|
30
|
+
* await api.get("/api/device/status", { timeout: 3000 });
|
|
31
|
+
* } catch (error) {
|
|
32
|
+
* if (isTransportNotReadyError(error)) {
|
|
33
|
+
* // websocket is down — show the offline UI
|
|
34
|
+
* }
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @category Service Request
|
|
39
|
+
* @kosService core.fetch
|
|
40
|
+
* @kosApiLevel 23
|
|
41
|
+
*/
|
|
42
|
+
export declare class TransportNotReadyError extends Error {
|
|
43
|
+
/** Stable discriminator; see {@link TRANSPORT_NOT_READY}. */
|
|
44
|
+
readonly code = "TRANSPORT_NOT_READY";
|
|
45
|
+
/**
|
|
46
|
+
* The budget, in milliseconds, that expired while waiting. `undefined` when
|
|
47
|
+
* the wait was cut short by a caller-supplied timeout signal rather than by
|
|
48
|
+
* the request's own budget.
|
|
49
|
+
*/
|
|
50
|
+
readonly timeout?: number;
|
|
51
|
+
/** The URL of the request that was never sent. */
|
|
52
|
+
readonly url?: string;
|
|
53
|
+
constructor(details?: {
|
|
54
|
+
timeout?: number;
|
|
55
|
+
url?: string;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Type guard for {@link TransportNotReadyError} that works across bundle
|
|
60
|
+
* boundaries by checking the `code` discriminator rather than the prototype.
|
|
61
|
+
*
|
|
62
|
+
* @category Service Request
|
|
63
|
+
* @kosService core.fetch
|
|
64
|
+
* @kosApiLevel 23
|
|
65
|
+
*/
|
|
66
|
+
export declare const isTransportNotReadyError: (error: unknown) => error is TransportNotReadyError;
|
|
67
|
+
//# sourceMappingURL=transport-not-ready-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport-not-ready-error.d.ts","sourceRoot":"","sources":["../../../../../packages/kos-ui-sdk/src/core/util/transport-not-ready-error.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,6DAA6D;IAC7D,QAAQ,CAAC,IAAI,yBAAuB;IAEpC;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAE1B,kDAAkD;IAClD,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;gBAEV,OAAO,GAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAO;CAU7D;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,GACnC,OAAO,OAAO,KACb,KAAK,IAAI,sBAC+D,CAAC"}
|
package/index.cjs
CHANGED
|
@@ -6362,8 +6362,38 @@ const getMessageBody = (payload, skipParse) => {
|
|
|
6362
6362
|
return payload.body || payload;
|
|
6363
6363
|
}
|
|
6364
6364
|
};
|
|
6365
|
+
const TRANSPORT_NOT_READY = "TRANSPORT_NOT_READY";
|
|
6366
|
+
class TransportNotReadyError extends Error {
|
|
6367
|
+
/** Stable discriminator; see {@link TRANSPORT_NOT_READY}. */
|
|
6368
|
+
code = TRANSPORT_NOT_READY;
|
|
6369
|
+
/**
|
|
6370
|
+
* The budget, in milliseconds, that expired while waiting. `undefined` when
|
|
6371
|
+
* the wait was cut short by a caller-supplied timeout signal rather than by
|
|
6372
|
+
* the request's own budget.
|
|
6373
|
+
*/
|
|
6374
|
+
timeout;
|
|
6375
|
+
/** The URL of the request that was never sent. */
|
|
6376
|
+
url;
|
|
6377
|
+
constructor(details = {}) {
|
|
6378
|
+
super(
|
|
6379
|
+
`Transport not ready${details.timeout === void 0 ? "" : ` after ${details.timeout}ms`}${details.url ? ` - url: ${details.url}` : ""}`
|
|
6380
|
+
);
|
|
6381
|
+
this.name = "TransportNotReadyError";
|
|
6382
|
+
this.timeout = details.timeout;
|
|
6383
|
+
this.url = details.url;
|
|
6384
|
+
}
|
|
6385
|
+
}
|
|
6386
|
+
const isTransportNotReadyError = (error) => !!error && error.code === TRANSPORT_NOT_READY;
|
|
6365
6387
|
const log$D = KosLog.createLogger({ name: "kos-fetch" });
|
|
6366
|
-
const
|
|
6388
|
+
const DEFAULT_WS_TIMEOUT = 3e4;
|
|
6389
|
+
const WS_TIMEOUT = (() => {
|
|
6390
|
+
const configured = process.env.KOS_WS_TIMEOUT ? parseInt(process.env.KOS_WS_TIMEOUT) : DEFAULT_WS_TIMEOUT;
|
|
6391
|
+
return Number.isNaN(configured) ? DEFAULT_WS_TIMEOUT : configured;
|
|
6392
|
+
})();
|
|
6393
|
+
const resolveTimeoutBudget = (timeout) => {
|
|
6394
|
+
const budget = timeout ?? WS_TIMEOUT;
|
|
6395
|
+
return Number.isFinite(budget) && budget > 0 ? budget : void 0;
|
|
6396
|
+
};
|
|
6367
6397
|
const delay = () => new Promise((resolve) => {
|
|
6368
6398
|
setTimeout(() => {
|
|
6369
6399
|
resolve(true);
|
|
@@ -6397,6 +6427,14 @@ const combineSignals = (signals) => {
|
|
|
6397
6427
|
}
|
|
6398
6428
|
return controller.signal;
|
|
6399
6429
|
};
|
|
6430
|
+
const createRequestSignal = (budget, callerSignal) => {
|
|
6431
|
+
const timeoutSignal = budget ? createTimeoutSignal(budget) : void 0;
|
|
6432
|
+
if (timeoutSignal && callerSignal) {
|
|
6433
|
+
return combineSignals([callerSignal, timeoutSignal]);
|
|
6434
|
+
}
|
|
6435
|
+
return timeoutSignal ?? callerSignal ?? new AbortController().signal;
|
|
6436
|
+
};
|
|
6437
|
+
const isTimeoutReason = (reason) => reason?.name === "TimeoutError";
|
|
6400
6438
|
const fetchMessageFactory = (options) => {
|
|
6401
6439
|
if (options?.studio) {
|
|
6402
6440
|
return createStudioMessage;
|
|
@@ -6408,15 +6446,25 @@ const fetchMessageFactory = (options) => {
|
|
|
6408
6446
|
};
|
|
6409
6447
|
const kosFetchWs = async (url, options) => {
|
|
6410
6448
|
const transport = KosCore.getInstance().transport;
|
|
6411
|
-
await transport.whenReady();
|
|
6412
6449
|
const requestId = uuid();
|
|
6413
6450
|
const urlObj = new URL(url);
|
|
6414
6451
|
const path = `${urlObj.pathname}${urlObj.search}`;
|
|
6415
6452
|
log$D.debug(`path: ${path}`);
|
|
6416
|
-
const
|
|
6453
|
+
const budget = resolveTimeoutBudget(options?.timeout);
|
|
6417
6454
|
const messageFactory = fetchMessageFactory(options);
|
|
6418
|
-
const
|
|
6419
|
-
|
|
6455
|
+
const signal = createRequestSignal(budget, options?.signal);
|
|
6456
|
+
try {
|
|
6457
|
+
await transport.whenReady({ signal });
|
|
6458
|
+
} catch (error) {
|
|
6459
|
+
if (isTimeoutReason(error)) {
|
|
6460
|
+
log$D.error(
|
|
6461
|
+
`Transport not ready${budget === void 0 ? "" : ` after ${budget}ms`} - request not sent - url: ${url}`
|
|
6462
|
+
);
|
|
6463
|
+
throw new TransportNotReadyError({ timeout: budget, url });
|
|
6464
|
+
}
|
|
6465
|
+
log$D.debug(`Request aborted while waiting for transport - url: ${url}`);
|
|
6466
|
+
throw error;
|
|
6467
|
+
}
|
|
6420
6468
|
const processedBody = await processRequestBody(options?.body);
|
|
6421
6469
|
const additionalHeaders = {};
|
|
6422
6470
|
if (processedBody.contentType) {
|
|
@@ -6579,6 +6627,7 @@ const resolveBaseUrl = () => {
|
|
|
6579
6627
|
};
|
|
6580
6628
|
const log$C = KosLog.createLogger({ name: "kos-service-request" });
|
|
6581
6629
|
const ERROR_UNKNOWN = "errUnknown";
|
|
6630
|
+
const ERROR_TRANSPORT_NOT_READY = "Transport not ready";
|
|
6582
6631
|
const MUTATING_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "DELETE", "PATCH"]);
|
|
6583
6632
|
const RETRY_DEFAULTS = {
|
|
6584
6633
|
maxAttempts: 3,
|
|
@@ -6628,6 +6677,10 @@ async function executeFetch(fullUrl, fetchOptions) {
|
|
|
6628
6677
|
const payload = await response.json();
|
|
6629
6678
|
return [null, payload.data ?? payload];
|
|
6630
6679
|
} catch (error) {
|
|
6680
|
+
if (isTransportNotReadyError(error)) {
|
|
6681
|
+
log$C.error(`Transport not ready, request not sent: ${fullUrl}`);
|
|
6682
|
+
return [ERROR_TRANSPORT_NOT_READY, null];
|
|
6683
|
+
}
|
|
6631
6684
|
if (error instanceof DOMException) {
|
|
6632
6685
|
if (error.name === "TimeoutError") {
|
|
6633
6686
|
log$C.error(`Request timed out: ${fullUrl}`);
|
|
@@ -6671,6 +6724,10 @@ async function executeFetchWithRetry(fullUrl, fetchOptions, config2) {
|
|
|
6671
6724
|
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
6672
6725
|
}
|
|
6673
6726
|
} catch (error) {
|
|
6727
|
+
if (isTransportNotReadyError(error)) {
|
|
6728
|
+
log$C.error(`Transport not ready, request not sent: ${fullUrl}`);
|
|
6729
|
+
return [ERROR_TRANSPORT_NOT_READY, null];
|
|
6730
|
+
}
|
|
6674
6731
|
if (error instanceof DOMException) {
|
|
6675
6732
|
if (error.name === "TimeoutError") {
|
|
6676
6733
|
log$C.error(`Request timed out: ${fullUrl}`);
|
|
@@ -7482,6 +7539,38 @@ class FlowControlManager {
|
|
|
7482
7539
|
return { ...this.stats };
|
|
7483
7540
|
}
|
|
7484
7541
|
}
|
|
7542
|
+
const abortReason = (signal) => signal.reason ?? new DOMException("Aborted", "AbortError");
|
|
7543
|
+
const abortableWhen = async (predicate, signal) => {
|
|
7544
|
+
if (predicate()) {
|
|
7545
|
+
return;
|
|
7546
|
+
}
|
|
7547
|
+
if (!signal) {
|
|
7548
|
+
await mobx.when(predicate);
|
|
7549
|
+
return;
|
|
7550
|
+
}
|
|
7551
|
+
if (signal.aborted) {
|
|
7552
|
+
throw abortReason(signal);
|
|
7553
|
+
}
|
|
7554
|
+
const pending = mobx.when(predicate);
|
|
7555
|
+
let onAbort;
|
|
7556
|
+
try {
|
|
7557
|
+
await Promise.race([
|
|
7558
|
+
// `cancel()` below rejects this promise with MobX's WHEN_CANCELLED
|
|
7559
|
+
// sentinel. That rejection *is* the cancellation, never a real failure,
|
|
7560
|
+
// so it is swallowed here; the abort branch supplies the thrown reason.
|
|
7561
|
+
pending.catch(() => void 0),
|
|
7562
|
+
new Promise((_, reject) => {
|
|
7563
|
+
onAbort = () => reject(abortReason(signal));
|
|
7564
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
7565
|
+
})
|
|
7566
|
+
]);
|
|
7567
|
+
} finally {
|
|
7568
|
+
if (onAbort) {
|
|
7569
|
+
signal.removeEventListener("abort", onAbort);
|
|
7570
|
+
}
|
|
7571
|
+
pending.cancel();
|
|
7572
|
+
}
|
|
7573
|
+
};
|
|
7485
7574
|
class WebSocketBridgeTransport extends WebSocket {
|
|
7486
7575
|
constructor(address) {
|
|
7487
7576
|
super(address);
|
|
@@ -8114,15 +8203,26 @@ ${dstAddr}topics:${topic}
|
|
|
8114
8203
|
}
|
|
8115
8204
|
};
|
|
8116
8205
|
}
|
|
8117
|
-
|
|
8118
|
-
|
|
8206
|
+
/**
|
|
8207
|
+
* Resolves once the transport can carry requests: the socket (and the FOS
|
|
8208
|
+
* socket, when used) is connected and the connection is authorized.
|
|
8209
|
+
*
|
|
8210
|
+
* Pass `options.signal` to bound the wait. `connectionEstablished` flips back
|
|
8211
|
+
* to `false` on socket close, so an unbounded wait parks indefinitely while
|
|
8212
|
+
* the transport is down — callers with a deadline must supply a signal.
|
|
8213
|
+
*
|
|
8214
|
+
* @param options - See {@link KosTransportReadyOptions}.
|
|
8215
|
+
* @throws The signal's abort reason if it aborts before the transport is ready.
|
|
8216
|
+
*/
|
|
8217
|
+
async whenReady(options) {
|
|
8119
8218
|
if (!this.webSocketSupported) {
|
|
8120
8219
|
return {
|
|
8121
8220
|
status: `not supported`
|
|
8122
8221
|
};
|
|
8123
8222
|
}
|
|
8124
|
-
await
|
|
8125
|
-
() => !!
|
|
8223
|
+
await abortableWhen(
|
|
8224
|
+
() => !!this.socket?.connectionEstablished && (!this.useFosTransport || !!this.fosSocket?.connectionEstablished) && this.authorized,
|
|
8225
|
+
options?.signal
|
|
8126
8226
|
);
|
|
8127
8227
|
return {
|
|
8128
8228
|
status: `success`
|
|
@@ -26955,6 +27055,7 @@ exports.DependencyResolutionPolicy = DependencyResolutionPolicy;
|
|
|
26955
27055
|
exports.Device = Device;
|
|
26956
27056
|
exports.DeviceServices = index$6;
|
|
26957
27057
|
exports.DomIntersectionStrategy = DomIntersectionStrategy;
|
|
27058
|
+
exports.ERROR_TRANSPORT_NOT_READY = ERROR_TRANSPORT_NOT_READY;
|
|
26958
27059
|
exports.EVENT_KOS_MODEL_READY = EVENT_KOS_MODEL_READY;
|
|
26959
27060
|
exports.EVENT_TROUBLE_ADDED = EVENT_TROUBLE_ADDED;
|
|
26960
27061
|
exports.EVENT_TROUBLE_REMOVED = EVENT_TROUBLE_REMOVED;
|
|
@@ -27137,6 +27238,7 @@ exports.SubscriptionHandlers = SubscriptionHandlers;
|
|
|
27137
27238
|
exports.TIMER_END = TIMER_END;
|
|
27138
27239
|
exports.TIMER_EVENT = TIMER_EVENT;
|
|
27139
27240
|
exports.TOPIC_TIMER_TICK_EVENT = TOPIC_TIMER_TICK_EVENT;
|
|
27241
|
+
exports.TRANSPORT_NOT_READY = TRANSPORT_NOT_READY;
|
|
27140
27242
|
exports.TimerManager = TimerManager;
|
|
27141
27243
|
exports.TokenContext = TokenContext;
|
|
27142
27244
|
exports.TokenProvider = TokenProvider;
|
|
@@ -27149,6 +27251,7 @@ exports.TranslationContainer = TranslationContainer;
|
|
|
27149
27251
|
exports.TranslationContainerContext = TranslationContainerContext;
|
|
27150
27252
|
exports.TranslationContext = TranslationContext;
|
|
27151
27253
|
exports.TransportFactory = TransportFactory;
|
|
27254
|
+
exports.TransportNotReadyError = TransportNotReadyError;
|
|
27152
27255
|
exports.Trouble = Trouble;
|
|
27153
27256
|
exports.TroubleAwareSetup = TroubleAwareSetup;
|
|
27154
27257
|
exports.TroubleContainer = TroubleContainer;
|
|
@@ -27286,6 +27389,7 @@ exports.isLeapYear = isLeapYear;
|
|
|
27286
27389
|
exports.isLocalRefId = isLocalRefId;
|
|
27287
27390
|
exports.isNumber = isNumber;
|
|
27288
27391
|
exports.isPrintable = isPrintable;
|
|
27392
|
+
exports.isTransportNotReadyError = isTransportNotReadyError;
|
|
27289
27393
|
exports.isTroubleAware = isTroubleAware;
|
|
27290
27394
|
exports.isValidDate = isValidDate;
|
|
27291
27395
|
exports.kosAction = kosAction;
|