@milaboratories/pl-client 2.17.7 → 2.17.9
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/_virtual/_rolldown/runtime.cjs +43 -0
- package/dist/_virtual/_rolldown/runtime.js +18 -0
- package/dist/core/PromiseTracker.cjs +33 -33
- package/dist/core/PromiseTracker.cjs.map +1 -1
- package/dist/core/PromiseTracker.d.ts +10 -7
- package/dist/core/PromiseTracker.js +33 -31
- package/dist/core/PromiseTracker.js.map +1 -1
- package/dist/core/StatefulPromise.cjs +60 -61
- package/dist/core/StatefulPromise.cjs.map +1 -1
- package/dist/core/StatefulPromise.js +60 -60
- package/dist/core/StatefulPromise.js.map +1 -1
- package/dist/core/abstract_stream.d.ts +18 -15
- package/dist/core/advisory_locks.cjs +42 -49
- package/dist/core/advisory_locks.cjs.map +1 -1
- package/dist/core/advisory_locks.js +42 -48
- package/dist/core/advisory_locks.js.map +1 -1
- package/dist/core/auth.cjs +10 -15
- package/dist/core/auth.cjs.map +1 -1
- package/dist/core/auth.d.ts +7 -3
- package/dist/core/auth.js +10 -13
- package/dist/core/auth.js.map +1 -1
- package/dist/core/cache.d.ts +11 -7
- package/dist/core/client.cjs +255 -306
- package/dist/core/client.cjs.map +1 -1
- package/dist/core/client.d.ts +72 -68
- package/dist/core/client.js +253 -285
- package/dist/core/client.js.map +1 -1
- package/dist/core/config.cjs +81 -99
- package/dist/core/config.cjs.map +1 -1
- package/dist/core/config.d.ts +93 -90
- package/dist/core/config.js +81 -98
- package/dist/core/config.js.map +1 -1
- package/dist/core/default_client.cjs +84 -125
- package/dist/core/default_client.cjs.map +1 -1
- package/dist/core/default_client.d.ts +9 -6
- package/dist/core/default_client.js +78 -103
- package/dist/core/default_client.js.map +1 -1
- package/dist/core/driver.cjs +12 -16
- package/dist/core/driver.cjs.map +1 -1
- package/dist/core/driver.d.ts +18 -14
- package/dist/core/driver.js +12 -15
- package/dist/core/driver.js.map +1 -1
- package/dist/core/error_resource.cjs +5 -4
- package/dist/core/error_resource.cjs.map +1 -1
- package/dist/core/error_resource.js +5 -3
- package/dist/core/error_resource.js.map +1 -1
- package/dist/core/errors.cjs +104 -140
- package/dist/core/errors.cjs.map +1 -1
- package/dist/core/errors.d.ts +34 -30
- package/dist/core/errors.js +102 -137
- package/dist/core/errors.js.map +1 -1
- package/dist/core/final.cjs +63 -89
- package/dist/core/final.cjs.map +1 -1
- package/dist/core/final.d.ts +8 -4
- package/dist/core/final.js +63 -87
- package/dist/core/final.js.map +1 -1
- package/dist/core/ll_client.cjs +416 -521
- package/dist/core/ll_client.cjs.map +1 -1
- package/dist/core/ll_client.d.ts +100 -97
- package/dist/core/ll_client.js +415 -519
- package/dist/core/ll_client.js.map +1 -1
- package/dist/core/ll_transaction.cjs +206 -240
- package/dist/core/ll_transaction.cjs.map +1 -1
- package/dist/core/ll_transaction.d.ts +50 -52
- package/dist/core/ll_transaction.js +205 -238
- package/dist/core/ll_transaction.js.map +1 -1
- package/dist/core/stat.cjs +64 -63
- package/dist/core/stat.cjs.map +1 -1
- package/dist/core/stat.d.ts +35 -36
- package/dist/core/stat.js +64 -62
- package/dist/core/stat.js.map +1 -1
- package/dist/core/transaction.cjs +613 -650
- package/dist/core/transaction.cjs.map +1 -1
- package/dist/core/transaction.d.ts +165 -162
- package/dist/core/transaction.js +612 -648
- package/dist/core/transaction.js.map +1 -1
- package/dist/core/type_conversion.cjs +62 -83
- package/dist/core/type_conversion.cjs.map +1 -1
- package/dist/core/type_conversion.js +61 -81
- package/dist/core/type_conversion.js.map +1 -1
- package/dist/core/types.cjs +56 -86
- package/dist/core/types.cjs.map +1 -1
- package/dist/core/types.d.ts +63 -62
- package/dist/core/types.js +54 -83
- package/dist/core/types.js.map +1 -1
- package/dist/core/unauth_client.cjs +35 -41
- package/dist/core/unauth_client.cjs.map +1 -1
- package/dist/core/unauth_client.d.ts +18 -14
- package/dist/core/unauth_client.js +34 -39
- package/dist/core/unauth_client.js.map +1 -1
- package/dist/core/websocket_stream.cjs +280 -349
- package/dist/core/websocket_stream.cjs.map +1 -1
- package/dist/core/websocket_stream.js +278 -347
- package/dist/core/websocket_stream.js.map +1 -1
- package/dist/core/wire.d.ts +21 -17
- package/dist/helpers/pl.cjs +71 -73
- package/dist/helpers/pl.cjs.map +1 -1
- package/dist/helpers/pl.d.ts +40 -41
- package/dist/helpers/pl.js +66 -46
- package/dist/helpers/pl.js.map +1 -1
- package/dist/helpers/poll.cjs +99 -134
- package/dist/helpers/poll.cjs.map +1 -1
- package/dist/helpers/poll.d.ts +37 -34
- package/dist/helpers/poll.js +97 -113
- package/dist/helpers/poll.js.map +1 -1
- package/dist/helpers/retry_strategy.cjs +82 -87
- package/dist/helpers/retry_strategy.cjs.map +1 -1
- package/dist/helpers/retry_strategy.js +83 -86
- package/dist/helpers/retry_strategy.js.map +1 -1
- package/dist/helpers/tx_helpers.cjs +21 -20
- package/dist/helpers/tx_helpers.cjs.map +1 -1
- package/dist/helpers/tx_helpers.d.ts +11 -7
- package/dist/helpers/tx_helpers.js +20 -18
- package/dist/helpers/tx_helpers.js.map +1 -1
- package/dist/index.cjs +117 -106
- package/dist/index.d.ts +17 -17
- package/dist/index.js +17 -19
- package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.cjs +72 -66
- package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.cjs.map +1 -1
- package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.d.ts +35 -37
- package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.js +71 -64
- package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.js.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.cjs +12611 -12866
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.cjs.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.cjs +226 -226
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.cjs.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.d.ts +281 -330
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.js +225 -224
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.js.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts +2640 -4294
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.js +12608 -12706
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.js.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.cjs +1230 -1089
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.cjs.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.d.ts +393 -420
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.js +1228 -1083
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.js.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.cjs +142 -143
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.cjs.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.d.ts +62 -64
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.js +140 -141
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.js.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.cjs +572 -487
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.cjs.map +1 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.d.ts +125 -228
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.js +572 -485
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.js.map +1 -1
- package/dist/proto-grpc/google/protobuf/any.cjs +131 -146
- package/dist/proto-grpc/google/protobuf/any.cjs.map +1 -1
- package/dist/proto-grpc/google/protobuf/any.d.ts +78 -84
- package/dist/proto-grpc/google/protobuf/any.js +130 -144
- package/dist/proto-grpc/google/protobuf/any.js.map +1 -1
- package/dist/proto-grpc/google/protobuf/duration.cjs +92 -100
- package/dist/proto-grpc/google/protobuf/duration.cjs.map +1 -1
- package/dist/proto-grpc/google/protobuf/duration.d.ts +38 -43
- package/dist/proto-grpc/google/protobuf/duration.js +91 -98
- package/dist/proto-grpc/google/protobuf/duration.js.map +1 -1
- package/dist/proto-grpc/google/protobuf/timestamp.cjs +117 -128
- package/dist/proto-grpc/google/protobuf/timestamp.cjs.map +1 -1
- package/dist/proto-grpc/google/protobuf/timestamp.d.ts +50 -55
- package/dist/proto-grpc/google/protobuf/timestamp.js +116 -126
- package/dist/proto-grpc/google/protobuf/timestamp.js.map +1 -1
- package/dist/proto-grpc/google/rpc/code.cjs +223 -238
- package/dist/proto-grpc/google/rpc/code.cjs.map +1 -1
- package/dist/proto-grpc/google/rpc/code.d.ts +209 -206
- package/dist/proto-grpc/google/rpc/code.js +221 -237
- package/dist/proto-grpc/google/rpc/code.js.map +1 -1
- package/dist/proto-rest/index.cjs +67 -66
- package/dist/proto-rest/index.cjs.map +1 -1
- package/dist/proto-rest/index.d.ts +24 -18
- package/dist/proto-rest/index.js +61 -65
- package/dist/proto-rest/index.js.map +1 -1
- package/dist/proto-rest/plapi.d.ts +1400 -1477
- package/dist/test/tcp-proxy.cjs +100 -126
- package/dist/test/tcp-proxy.cjs.map +1 -1
- package/dist/test/tcp-proxy.d.ts +17 -13
- package/dist/test/tcp-proxy.js +97 -104
- package/dist/test/tcp-proxy.js.map +1 -1
- package/dist/test/test_config.cjs +145 -194
- package/dist/test/test_config.cjs.map +1 -1
- package/dist/test/test_config.d.ts +34 -30
- package/dist/test/test_config.js +138 -166
- package/dist/test/test_config.js.map +1 -1
- package/dist/util/pl.cjs +4 -3
- package/dist/util/pl.cjs.map +1 -1
- package/dist/util/pl.js +4 -2
- package/dist/util/pl.js.map +1 -1
- package/dist/util/util.cjs +7 -10
- package/dist/util/util.cjs.map +1 -1
- package/dist/util/util.js +7 -9
- package/dist/util/util.js.map +1 -1
- package/package.json +8 -8
- package/src/core/errors.ts +1 -1
- package/src/core/transaction.ts +123 -133
- package/src/core/websocket_stream.ts +10 -1
- package/dist/__external/.pnpm/@rollup_plugin-typescript@12.3.0_rollup@4.52.4_tslib@2.8.1_typescript@5.6.3/__external/tslib/tslib.es6.cjs +0 -61
- package/dist/__external/.pnpm/@rollup_plugin-typescript@12.3.0_rollup@4.52.4_tslib@2.8.1_typescript@5.6.3/__external/tslib/tslib.es6.cjs.map +0 -1
- package/dist/__external/.pnpm/@rollup_plugin-typescript@12.3.0_rollup@4.52.4_tslib@2.8.1_typescript@5.6.3/__external/tslib/tslib.es6.js +0 -58
- package/dist/__external/.pnpm/@rollup_plugin-typescript@12.3.0_rollup@4.52.4_tslib@2.8.1_typescript@5.6.3/__external/tslib/tslib.es6.js.map +0 -1
- package/dist/core/PromiseTracker.d.ts.map +0 -1
- package/dist/core/StatefulPromise.d.ts +0 -39
- package/dist/core/StatefulPromise.d.ts.map +0 -1
- package/dist/core/abstract_stream.d.ts.map +0 -1
- package/dist/core/advisory_locks.d.ts +0 -10
- package/dist/core/advisory_locks.d.ts.map +0 -1
- package/dist/core/auth.d.ts.map +0 -1
- package/dist/core/cache.d.ts.map +0 -1
- package/dist/core/client.d.ts.map +0 -1
- package/dist/core/config.d.ts.map +0 -1
- package/dist/core/default_client.d.ts.map +0 -1
- package/dist/core/driver.d.ts.map +0 -1
- package/dist/core/error_resource.d.ts +0 -6
- package/dist/core/error_resource.d.ts.map +0 -1
- package/dist/core/errors.d.ts.map +0 -1
- package/dist/core/final.d.ts.map +0 -1
- package/dist/core/ll_client.d.ts.map +0 -1
- package/dist/core/ll_transaction.d.ts.map +0 -1
- package/dist/core/stat.d.ts.map +0 -1
- package/dist/core/transaction.d.ts.map +0 -1
- package/dist/core/type_conversion.d.ts +0 -8
- package/dist/core/type_conversion.d.ts.map +0 -1
- package/dist/core/types.d.ts.map +0 -1
- package/dist/core/unauth_client.d.ts.map +0 -1
- package/dist/core/websocket_stream.d.ts +0 -67
- package/dist/core/websocket_stream.d.ts.map +0 -1
- package/dist/core/wire.d.ts.map +0 -1
- package/dist/helpers/pl.d.ts.map +0 -1
- package/dist/helpers/poll.d.ts.map +0 -1
- package/dist/helpers/retry_strategy.d.ts +0 -24
- package/dist/helpers/retry_strategy.d.ts.map +0 -1
- package/dist/helpers/state_helpers.d.ts +0 -3
- package/dist/helpers/state_helpers.d.ts.map +0 -1
- package/dist/helpers/tx_helpers.d.ts.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/proto-grpc/github.com/googleapis/googleapis/google/rpc/status.d.ts.map +0 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.client.d.ts.map +0 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api.d.ts.map +0 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/api_types.d.ts.map +0 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/base_types.d.ts.map +0 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/import.d.ts +0 -106
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/import.d.ts.map +0 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/resource_types.d.ts.map +0 -1
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/ws-test.d.ts +0 -73
- package/dist/proto-grpc/github.com/milaboratory/pl/plapi/plapiproto/ws-test.d.ts.map +0 -1
- package/dist/proto-grpc/google/api/http.d.ts +0 -456
- package/dist/proto-grpc/google/api/http.d.ts.map +0 -1
- package/dist/proto-grpc/google/protobuf/any.d.ts.map +0 -1
- package/dist/proto-grpc/google/protobuf/descriptor.d.ts +0 -2340
- package/dist/proto-grpc/google/protobuf/descriptor.d.ts.map +0 -1
- package/dist/proto-grpc/google/protobuf/duration.d.ts.map +0 -1
- package/dist/proto-grpc/google/protobuf/empty.d.ts +0 -32
- package/dist/proto-grpc/google/protobuf/empty.d.ts.map +0 -1
- package/dist/proto-grpc/google/protobuf/struct.d.ts +0 -187
- package/dist/proto-grpc/google/protobuf/struct.d.ts.map +0 -1
- package/dist/proto-grpc/google/protobuf/timestamp.d.ts.map +0 -1
- package/dist/proto-grpc/google/protobuf/wrappers.d.ts +0 -308
- package/dist/proto-grpc/google/protobuf/wrappers.d.ts.map +0 -1
- package/dist/proto-grpc/google/rpc/code.d.ts.map +0 -1
- package/dist/proto-grpc/google/rpc/error_details.d.ts +0 -654
- package/dist/proto-grpc/google/rpc/error_details.d.ts.map +0 -1
- package/dist/proto-grpc/google/rpc/http.d.ts +0 -121
- package/dist/proto-grpc/google/rpc/http.d.ts.map +0 -1
- package/dist/proto-grpc/google/rpc/status.d.ts +0 -55
- package/dist/proto-grpc/google/rpc/status.d.ts.map +0 -1
- package/dist/proto-rest/index.d.ts.map +0 -1
- package/dist/proto-rest/plapi.d.ts.map +0 -1
- package/dist/test/tcp-proxy.d.ts.map +0 -1
- package/dist/test/test_config.d.ts.map +0 -1
- package/dist/util/branding.d.ts +0 -7
- package/dist/util/branding.d.ts.map +0 -1
- package/dist/util/pl.d.ts +0 -9
- package/dist/util/pl.d.ts.map +0 -1
- package/dist/util/util.d.ts +0 -2
- package/dist/util/util.d.ts.map +0 -1
|
@@ -1,353 +1,284 @@
|
|
|
1
|
-
|
|
1
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
const require_errors = require('./errors.cjs');
|
|
3
|
+
const require_retry_strategy = require('../helpers/retry_strategy.cjs');
|
|
4
|
+
let denque = require("denque");
|
|
5
|
+
denque = require_runtime.__toESM(denque);
|
|
6
|
+
let undici = require("undici");
|
|
2
7
|
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
ConnectionState[ConnectionState["CONNECTED"] = 2] = "CONNECTED";
|
|
13
|
-
ConnectionState[ConnectionState["CLOSING"] = 3] = "CLOSING";
|
|
14
|
-
ConnectionState[ConnectionState["CLOSED"] = 4] = "CLOSED";
|
|
15
|
-
})(ConnectionState || (ConnectionState = {}));
|
|
8
|
+
//#region src/core/websocket_stream.ts
|
|
9
|
+
var ConnectionState = /* @__PURE__ */ function(ConnectionState) {
|
|
10
|
+
ConnectionState[ConnectionState["NEW"] = 0] = "NEW";
|
|
11
|
+
ConnectionState[ConnectionState["CONNECTING"] = 1] = "CONNECTING";
|
|
12
|
+
ConnectionState[ConnectionState["CONNECTED"] = 2] = "CONNECTED";
|
|
13
|
+
ConnectionState[ConnectionState["CLOSING"] = 3] = "CLOSING";
|
|
14
|
+
ConnectionState[ConnectionState["CLOSED"] = 4] = "CLOSED";
|
|
15
|
+
return ConnectionState;
|
|
16
|
+
}(ConnectionState || {});
|
|
16
17
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
resolveAllPendingResponses() {
|
|
283
|
-
while (this.responseResolvers.length > 0) {
|
|
284
|
-
const resolver = this.responseResolvers.shift();
|
|
285
|
-
resolver.resolve({ value: undefined, done: true });
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
// === Error Handling ===
|
|
289
|
-
handleError(error) {
|
|
290
|
-
this.lastError = error;
|
|
291
|
-
this.close();
|
|
292
|
-
}
|
|
293
|
-
rejectAllPendingOperations(error) {
|
|
294
|
-
this.rejectAllSendOperations(error);
|
|
295
|
-
this.rejectAllResponseResolvers(error);
|
|
296
|
-
}
|
|
297
|
-
rejectAllSendOperations(error) {
|
|
298
|
-
while (this.sendQueue.length > 0) {
|
|
299
|
-
const queued = this.sendQueue.shift();
|
|
300
|
-
queued.reject(error);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
rejectAllResponseResolvers(error) {
|
|
304
|
-
while (this.responseResolvers.length > 0) {
|
|
305
|
-
const resolver = this.responseResolvers.shift();
|
|
306
|
-
resolver.reject(error);
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
createStreamClosedError() {
|
|
310
|
-
if (this.options.abortSignal?.aborted) {
|
|
311
|
-
const reason = this.options.abortSignal.reason;
|
|
312
|
-
if (reason instanceof Error) {
|
|
313
|
-
return reason;
|
|
314
|
-
}
|
|
315
|
-
return new Error("Stream aborted", { cause: reason });
|
|
316
|
-
}
|
|
317
|
-
return new Error("Stream closed");
|
|
318
|
-
}
|
|
319
|
-
// === Helpers ===
|
|
320
|
-
isStreamEnded() {
|
|
321
|
-
return (this.connectionState === ConnectionState.CLOSED || this.options.abortSignal?.aborted || false);
|
|
322
|
-
}
|
|
323
|
-
toError(error) {
|
|
324
|
-
if (error instanceof Error)
|
|
325
|
-
return error;
|
|
326
|
-
if (error instanceof undici.ErrorEvent) {
|
|
327
|
-
const err = error.error;
|
|
328
|
-
// undici WebSocket throws TypeError with empty message on socket close
|
|
329
|
-
// (e.g., when connection is lost or server disconnects)
|
|
330
|
-
if (err instanceof TypeError && !err.message) {
|
|
331
|
-
return new errors.DisconnectedError("WebSocket connection closed unexpectedly");
|
|
332
|
-
}
|
|
333
|
-
return err instanceof Error ? err : new Error("WebSocket error", { cause: error });
|
|
334
|
-
}
|
|
335
|
-
return new Error(String(error));
|
|
336
|
-
}
|
|
337
|
-
/**
|
|
338
|
-
* Connection state progresses linearly from NEW to CLOSED and never goes back.
|
|
339
|
-
* This internal contract dramatically simplifies the internal stream state management.
|
|
340
|
-
*
|
|
341
|
-
* If you ever feel the need to make this contract less strict, think twice.
|
|
342
|
-
*/
|
|
343
|
-
progressConnectionState(newState) {
|
|
344
|
-
if (newState < this.connectionState) {
|
|
345
|
-
return false;
|
|
346
|
-
}
|
|
347
|
-
this.connectionState = newState;
|
|
348
|
-
return true;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
18
|
+
* WebSocket-based bidirectional stream implementation for LLTransaction.
|
|
19
|
+
* Implements BiDiStream interface which is compatible with DuplexStreamingCall.
|
|
20
|
+
*/
|
|
21
|
+
var WebSocketBiDiStream = class {
|
|
22
|
+
ws = null;
|
|
23
|
+
connectionState = ConnectionState.NEW;
|
|
24
|
+
reconnection;
|
|
25
|
+
sendQueue = new denque.default();
|
|
26
|
+
sendCompleted = false;
|
|
27
|
+
onComplete;
|
|
28
|
+
responseQueue = new denque.default();
|
|
29
|
+
responseResolvers = [];
|
|
30
|
+
lastError;
|
|
31
|
+
abortHandler;
|
|
32
|
+
requests = {
|
|
33
|
+
send: async (message) => {
|
|
34
|
+
return await this.enqueueSend(message);
|
|
35
|
+
},
|
|
36
|
+
complete: async () => {
|
|
37
|
+
if (this.sendCompleted) return;
|
|
38
|
+
await this.drainSendQueue();
|
|
39
|
+
try {
|
|
40
|
+
await this.onComplete(this);
|
|
41
|
+
} catch {}
|
|
42
|
+
this.sendCompleted = true;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
responses = { [Symbol.asyncIterator]: () => this.createResponseIterator() };
|
|
46
|
+
close() {
|
|
47
|
+
this.reconnection.cancel();
|
|
48
|
+
if (this.connectionState < ConnectionState.CONNECTED) {
|
|
49
|
+
this.ws?.close();
|
|
50
|
+
this.onClose();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (!this.progressConnectionState(ConnectionState.CLOSING)) return;
|
|
54
|
+
this.ws.close();
|
|
55
|
+
}
|
|
56
|
+
constructor(url, serializeClientMessage, parseServerMessage, options = {}) {
|
|
57
|
+
this.url = url;
|
|
58
|
+
this.serializeClientMessage = serializeClientMessage;
|
|
59
|
+
this.parseServerMessage = parseServerMessage;
|
|
60
|
+
this.options = options;
|
|
61
|
+
this.onComplete = this.options.onComplete ?? ((stream) => stream.close());
|
|
62
|
+
this.reconnection = new require_retry_strategy.RetryStrategy(this.options.retryConfig ?? {}, {
|
|
63
|
+
onRetry: () => {
|
|
64
|
+
this.connect();
|
|
65
|
+
},
|
|
66
|
+
onMaxAttemptsReached: (error) => this.handleError(error)
|
|
67
|
+
});
|
|
68
|
+
if (this.options.abortSignal?.aborted) {
|
|
69
|
+
this.progressConnectionState(ConnectionState.CLOSED);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
this.abortHandler = () => this.close();
|
|
73
|
+
this.options.abortSignal?.addEventListener("abort", this.abortHandler, { once: true });
|
|
74
|
+
this.connect();
|
|
75
|
+
}
|
|
76
|
+
connect() {
|
|
77
|
+
if (this.options.abortSignal?.aborted) return;
|
|
78
|
+
if (!this.progressConnectionState(ConnectionState.CONNECTING)) return;
|
|
79
|
+
try {
|
|
80
|
+
this.ws = this.createWebSocket();
|
|
81
|
+
this.ws.addEventListener("open", () => this.onOpen());
|
|
82
|
+
this.ws.addEventListener("message", (event) => this.onMessage(event.data));
|
|
83
|
+
this.ws.addEventListener("error", (error) => this.onError(error));
|
|
84
|
+
this.ws.addEventListener("close", () => this.onClose());
|
|
85
|
+
} catch (error) {
|
|
86
|
+
this.lastError = this.toError(error);
|
|
87
|
+
this.reconnection.schedule();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
createWebSocket() {
|
|
91
|
+
const options = {};
|
|
92
|
+
if (this.options.jwtToken) options.headers = { authorization: `Bearer ${this.options.jwtToken}` };
|
|
93
|
+
if (this.options.dispatcher) options.dispatcher = this.options.dispatcher;
|
|
94
|
+
const ws = new undici.WebSocket(this.url, options);
|
|
95
|
+
ws.binaryType = "arraybuffer";
|
|
96
|
+
return ws;
|
|
97
|
+
}
|
|
98
|
+
onOpen() {
|
|
99
|
+
this.progressConnectionState(ConnectionState.CONNECTED);
|
|
100
|
+
this.processSendQueue();
|
|
101
|
+
}
|
|
102
|
+
onMessage(data) {
|
|
103
|
+
if (!(data instanceof ArrayBuffer)) {
|
|
104
|
+
this.handleError(/* @__PURE__ */ new Error(`Unexpected WS message format: ${typeof data}`));
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
108
|
+
const message = this.parseServerMessage(new Uint8Array(data));
|
|
109
|
+
this.deliverResponse(message);
|
|
110
|
+
} catch (error) {
|
|
111
|
+
this.handleError(this.toError(error));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
onError(error) {
|
|
115
|
+
if (this.connectionState < ConnectionState.CONNECTED) {
|
|
116
|
+
this.lastError = this.toError(error);
|
|
117
|
+
this.reconnection.schedule();
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
this.handleError(this.toError(error));
|
|
121
|
+
}
|
|
122
|
+
onClose() {
|
|
123
|
+
this.progressConnectionState(ConnectionState.CLOSED);
|
|
124
|
+
if (this.abortHandler) this.options.abortSignal?.removeEventListener("abort", this.abortHandler);
|
|
125
|
+
if (this.options.abortSignal?.aborted && !this.lastError) {
|
|
126
|
+
const reason = this.options.abortSignal.reason;
|
|
127
|
+
if (reason instanceof Error) this.lastError = reason;
|
|
128
|
+
else if (reason !== void 0) this.lastError = new Error(String(reason), { cause: reason });
|
|
129
|
+
else this.lastError = this.createStreamClosedError();
|
|
130
|
+
}
|
|
131
|
+
if (!this.lastError) {
|
|
132
|
+
this.rejectAllSendOperations(this.createStreamClosedError());
|
|
133
|
+
this.resolveAllPendingResponses();
|
|
134
|
+
} else this.rejectAllPendingOperations(this.lastError);
|
|
135
|
+
}
|
|
136
|
+
enqueueSend(message) {
|
|
137
|
+
if (this.sendCompleted) throw new Error("Cannot send: stream already completed");
|
|
138
|
+
if (this.options.abortSignal?.aborted) throw new Error("Cannot send: stream aborted");
|
|
139
|
+
return new Promise((resolve, reject) => {
|
|
140
|
+
this.sendQueue.push({
|
|
141
|
+
message,
|
|
142
|
+
resolve,
|
|
143
|
+
reject
|
|
144
|
+
});
|
|
145
|
+
this.processSendQueue();
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
processSendQueue() {
|
|
149
|
+
if (!this.canSendMessages()) return;
|
|
150
|
+
while (this.sendQueue.length > 0) {
|
|
151
|
+
const queued = this.sendQueue.shift();
|
|
152
|
+
this.sendQueuedMessage(queued);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
canSendMessages() {
|
|
156
|
+
return this.connectionState === ConnectionState.CONNECTED;
|
|
157
|
+
}
|
|
158
|
+
sendQueuedMessage(queued) {
|
|
159
|
+
try {
|
|
160
|
+
const ws = this.ws;
|
|
161
|
+
if (!ws) throw new Error("WebSocket is not connected");
|
|
162
|
+
if (ws.readyState !== undici.WebSocket.OPEN) throw new Error(`WebSocket is not open (readyState: ${ws.readyState})`);
|
|
163
|
+
const binary = this.serializeClientMessage(queued.message);
|
|
164
|
+
ws.send(binary);
|
|
165
|
+
queued.resolve();
|
|
166
|
+
} catch (error) {
|
|
167
|
+
queued.reject(this.toError(error));
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
async drainSendQueue() {
|
|
171
|
+
const POLL_INTERVAL_MS = 5;
|
|
172
|
+
while (this.sendQueue.length > 0) await this.waitForCondition(() => this.sendQueue.length === 0, POLL_INTERVAL_MS);
|
|
173
|
+
}
|
|
174
|
+
waitForCondition(condition, intervalMs) {
|
|
175
|
+
return new Promise((resolve, reject) => {
|
|
176
|
+
if (this.options.abortSignal?.aborted) return reject(this.toError(this.options.abortSignal.reason) ?? /* @__PURE__ */ new Error("Stream aborted"));
|
|
177
|
+
let timeoutId;
|
|
178
|
+
const onAbort = () => {
|
|
179
|
+
clearTimeout(timeoutId);
|
|
180
|
+
reject(this.toError(this.options.abortSignal?.reason) ?? /* @__PURE__ */ new Error("Stream aborted"));
|
|
181
|
+
};
|
|
182
|
+
this.options.abortSignal?.addEventListener("abort", onAbort, { once: true });
|
|
183
|
+
const check = () => {
|
|
184
|
+
if (condition() || this.isStreamEnded()) {
|
|
185
|
+
this.options.abortSignal?.removeEventListener("abort", onAbort);
|
|
186
|
+
resolve();
|
|
187
|
+
} else timeoutId = setTimeout(check, intervalMs);
|
|
188
|
+
};
|
|
189
|
+
check();
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
deliverResponse(message) {
|
|
193
|
+
if (this.responseResolvers.length > 0) this.responseResolvers.shift().resolve({
|
|
194
|
+
value: message,
|
|
195
|
+
done: false
|
|
196
|
+
});
|
|
197
|
+
else this.responseQueue.push(message);
|
|
198
|
+
}
|
|
199
|
+
async *createResponseIterator() {
|
|
200
|
+
while (true) {
|
|
201
|
+
const result = await this.nextResponse();
|
|
202
|
+
if (result.done) break;
|
|
203
|
+
yield result.value;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
nextResponse() {
|
|
207
|
+
return new Promise((resolve, reject) => {
|
|
208
|
+
if (this.responseQueue.length > 0) {
|
|
209
|
+
resolve({
|
|
210
|
+
value: this.responseQueue.shift(),
|
|
211
|
+
done: false
|
|
212
|
+
});
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
if (this.isStreamEnded()) {
|
|
216
|
+
if (this.lastError) reject(this.lastError);
|
|
217
|
+
else resolve({
|
|
218
|
+
value: void 0,
|
|
219
|
+
done: true
|
|
220
|
+
});
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
this.responseResolvers.push({
|
|
224
|
+
resolve,
|
|
225
|
+
reject
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
resolveAllPendingResponses() {
|
|
230
|
+
while (this.responseResolvers.length > 0) this.responseResolvers.shift().resolve({
|
|
231
|
+
value: void 0,
|
|
232
|
+
done: true
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
handleError(error) {
|
|
236
|
+
this.lastError = error;
|
|
237
|
+
this.close();
|
|
238
|
+
}
|
|
239
|
+
rejectAllPendingOperations(error) {
|
|
240
|
+
this.rejectAllSendOperations(error);
|
|
241
|
+
this.rejectAllResponseResolvers(error);
|
|
242
|
+
}
|
|
243
|
+
rejectAllSendOperations(error) {
|
|
244
|
+
while (this.sendQueue.length > 0) this.sendQueue.shift().reject(error);
|
|
245
|
+
}
|
|
246
|
+
rejectAllResponseResolvers(error) {
|
|
247
|
+
while (this.responseResolvers.length > 0) this.responseResolvers.shift().reject(error);
|
|
248
|
+
}
|
|
249
|
+
createStreamClosedError() {
|
|
250
|
+
if (this.options.abortSignal?.aborted) {
|
|
251
|
+
const reason = this.options.abortSignal.reason;
|
|
252
|
+
if (reason instanceof Error) return reason;
|
|
253
|
+
return new Error("Stream aborted", { cause: reason });
|
|
254
|
+
}
|
|
255
|
+
return /* @__PURE__ */ new Error("Stream closed");
|
|
256
|
+
}
|
|
257
|
+
isStreamEnded() {
|
|
258
|
+
return this.connectionState === ConnectionState.CLOSED || this.options.abortSignal?.aborted || false;
|
|
259
|
+
}
|
|
260
|
+
toError(error) {
|
|
261
|
+
if (error instanceof Error) return error;
|
|
262
|
+
if (error instanceof undici.ErrorEvent) {
|
|
263
|
+
const err = error.error;
|
|
264
|
+
if (err instanceof TypeError && !err.message) return new require_errors.DisconnectedError("WebSocket connection closed unexpectedly");
|
|
265
|
+
return err instanceof Error ? err : new Error("WebSocket error", { cause: error });
|
|
266
|
+
}
|
|
267
|
+
return new Error(String(error));
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Connection state progresses linearly from NEW to CLOSED and never goes back.
|
|
271
|
+
* This internal contract dramatically simplifies the internal stream state management.
|
|
272
|
+
*
|
|
273
|
+
* If you ever feel the need to make this contract less strict, think twice.
|
|
274
|
+
*/
|
|
275
|
+
progressConnectionState(newState) {
|
|
276
|
+
if (newState < this.connectionState) return false;
|
|
277
|
+
this.connectionState = newState;
|
|
278
|
+
return true;
|
|
279
|
+
}
|
|
280
|
+
};
|
|
351
281
|
|
|
282
|
+
//#endregion
|
|
352
283
|
exports.WebSocketBiDiStream = WebSocketBiDiStream;
|
|
353
|
-
//# sourceMappingURL=websocket_stream.cjs.map
|
|
284
|
+
//# sourceMappingURL=websocket_stream.cjs.map
|