@contello/sdk-client 8.14.0 → 8.15.0-next.1752405584
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/index.d.ts +15 -3
- package/dist/index.js +367 -343
- package/dist/index.umd.cjs +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
function
|
|
1
|
+
function P(e) {
|
|
2
2
|
return e === null ? "null" : Array.isArray(e) ? "array" : typeof e;
|
|
3
3
|
}
|
|
4
|
-
function
|
|
5
|
-
return
|
|
4
|
+
function R(e) {
|
|
5
|
+
return P(e) === "object";
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function be(e) {
|
|
8
8
|
return Array.isArray(e) && // must be at least one error
|
|
9
9
|
e.length > 0 && // error has at least a message
|
|
10
10
|
e.every((t) => "message" in t);
|
|
@@ -12,18 +12,18 @@ function he(e) {
|
|
|
12
12
|
function re(e, t) {
|
|
13
13
|
return e.length < 124 ? e : t;
|
|
14
14
|
}
|
|
15
|
-
const
|
|
16
|
-
var
|
|
15
|
+
const me = "graphql-transport-ws";
|
|
16
|
+
var _ = /* @__PURE__ */ ((e) => (e[e.InternalServerError = 4500] = "InternalServerError", e[e.InternalClientError = 4005] = "InternalClientError", e[e.BadRequest = 4400] = "BadRequest", e[e.BadResponse = 4004] = "BadResponse", e[e.Unauthorized = 4401] = "Unauthorized", e[e.Forbidden = 4403] = "Forbidden", e[e.SubprotocolNotAcceptable = 4406] = "SubprotocolNotAcceptable", e[e.ConnectionInitialisationTimeout = 4408] = "ConnectionInitialisationTimeout", e[e.ConnectionAcknowledgementTimeout = 4504] = "ConnectionAcknowledgementTimeout", e[e.SubscriberAlreadyExists = 4409] = "SubscriberAlreadyExists", e[e.TooManyInitialisationRequests = 4429] = "TooManyInitialisationRequests", e))(_ || {}), O = /* @__PURE__ */ ((e) => (e.ConnectionInit = "connection_init", e.ConnectionAck = "connection_ack", e.Ping = "ping", e.Pong = "pong", e.Subscribe = "subscribe", e.Next = "next", e.Error = "error", e.Complete = "complete", e))(O || {});
|
|
17
17
|
function ue(e) {
|
|
18
|
-
if (!
|
|
18
|
+
if (!R(e))
|
|
19
19
|
throw new Error(
|
|
20
|
-
`Message is expected to be an object, but got ${
|
|
20
|
+
`Message is expected to be an object, but got ${P(e)}`
|
|
21
21
|
);
|
|
22
22
|
if (!e.type)
|
|
23
23
|
throw new Error("Message is missing the 'type' property");
|
|
24
24
|
if (typeof e.type != "string")
|
|
25
25
|
throw new Error(
|
|
26
|
-
`Message is expects the 'type' property to be a string, but got ${
|
|
26
|
+
`Message is expects the 'type' property to be a string, but got ${P(
|
|
27
27
|
e.type
|
|
28
28
|
)}`
|
|
29
29
|
);
|
|
@@ -32,7 +32,7 @@ function ue(e) {
|
|
|
32
32
|
case "connection_ack":
|
|
33
33
|
case "ping":
|
|
34
34
|
case "pong": {
|
|
35
|
-
if (e.payload != null && !
|
|
35
|
+
if (e.payload != null && !R(e.payload))
|
|
36
36
|
throw new Error(
|
|
37
37
|
`"${e.type}" message expects the 'payload' property to be an object or nullish or missing, but got "${e.payload}"`
|
|
38
38
|
);
|
|
@@ -41,7 +41,7 @@ function ue(e) {
|
|
|
41
41
|
case "subscribe": {
|
|
42
42
|
if (typeof e.id != "string")
|
|
43
43
|
throw new Error(
|
|
44
|
-
`"${e.type}" message expects the 'id' property to be a string, but got ${
|
|
44
|
+
`"${e.type}" message expects the 'id' property to be a string, but got ${P(
|
|
45
45
|
e.id
|
|
46
46
|
)}`
|
|
47
47
|
);
|
|
@@ -49,33 +49,33 @@ function ue(e) {
|
|
|
49
49
|
throw new Error(
|
|
50
50
|
`"${e.type}" message requires a non-empty 'id' property`
|
|
51
51
|
);
|
|
52
|
-
if (!
|
|
52
|
+
if (!R(e.payload))
|
|
53
53
|
throw new Error(
|
|
54
|
-
`"${e.type}" message expects the 'payload' property to be an object, but got ${
|
|
54
|
+
`"${e.type}" message expects the 'payload' property to be an object, but got ${P(
|
|
55
55
|
e.payload
|
|
56
56
|
)}`
|
|
57
57
|
);
|
|
58
58
|
if (typeof e.payload.query != "string")
|
|
59
59
|
throw new Error(
|
|
60
|
-
`"${e.type}" message payload expects the 'query' property to be a string, but got ${
|
|
60
|
+
`"${e.type}" message payload expects the 'query' property to be a string, but got ${P(
|
|
61
61
|
e.payload.query
|
|
62
62
|
)}`
|
|
63
63
|
);
|
|
64
|
-
if (e.payload.variables != null && !
|
|
64
|
+
if (e.payload.variables != null && !R(e.payload.variables))
|
|
65
65
|
throw new Error(
|
|
66
|
-
`"${e.type}" message payload expects the 'variables' property to be a an object or nullish or missing, but got ${
|
|
66
|
+
`"${e.type}" message payload expects the 'variables' property to be a an object or nullish or missing, but got ${P(
|
|
67
67
|
e.payload.variables
|
|
68
68
|
)}`
|
|
69
69
|
);
|
|
70
|
-
if (e.payload.operationName != null &&
|
|
70
|
+
if (e.payload.operationName != null && P(e.payload.operationName) !== "string")
|
|
71
71
|
throw new Error(
|
|
72
|
-
`"${e.type}" message payload expects the 'operationName' property to be a string or nullish or missing, but got ${
|
|
72
|
+
`"${e.type}" message payload expects the 'operationName' property to be a string or nullish or missing, but got ${P(
|
|
73
73
|
e.payload.operationName
|
|
74
74
|
)}`
|
|
75
75
|
);
|
|
76
|
-
if (e.payload.extensions != null && !
|
|
76
|
+
if (e.payload.extensions != null && !R(e.payload.extensions))
|
|
77
77
|
throw new Error(
|
|
78
|
-
`"${e.type}" message payload expects the 'extensions' property to be a an object or nullish or missing, but got ${
|
|
78
|
+
`"${e.type}" message payload expects the 'extensions' property to be a an object or nullish or missing, but got ${P(
|
|
79
79
|
e.payload.extensions
|
|
80
80
|
)}`
|
|
81
81
|
);
|
|
@@ -84,7 +84,7 @@ function ue(e) {
|
|
|
84
84
|
case "next": {
|
|
85
85
|
if (typeof e.id != "string")
|
|
86
86
|
throw new Error(
|
|
87
|
-
`"${e.type}" message expects the 'id' property to be a string, but got ${
|
|
87
|
+
`"${e.type}" message expects the 'id' property to be a string, but got ${P(
|
|
88
88
|
e.id
|
|
89
89
|
)}`
|
|
90
90
|
);
|
|
@@ -92,9 +92,9 @@ function ue(e) {
|
|
|
92
92
|
throw new Error(
|
|
93
93
|
`"${e.type}" message requires a non-empty 'id' property`
|
|
94
94
|
);
|
|
95
|
-
if (!
|
|
95
|
+
if (!R(e.payload))
|
|
96
96
|
throw new Error(
|
|
97
|
-
`"${e.type}" message expects the 'payload' property to be an object, but got ${
|
|
97
|
+
`"${e.type}" message expects the 'payload' property to be an object, but got ${P(
|
|
98
98
|
e.payload
|
|
99
99
|
)}`
|
|
100
100
|
);
|
|
@@ -103,7 +103,7 @@ function ue(e) {
|
|
|
103
103
|
case "error": {
|
|
104
104
|
if (typeof e.id != "string")
|
|
105
105
|
throw new Error(
|
|
106
|
-
`"${e.type}" message expects the 'id' property to be a string, but got ${
|
|
106
|
+
`"${e.type}" message expects the 'id' property to be a string, but got ${P(
|
|
107
107
|
e.id
|
|
108
108
|
)}`
|
|
109
109
|
);
|
|
@@ -111,7 +111,7 @@ function ue(e) {
|
|
|
111
111
|
throw new Error(
|
|
112
112
|
`"${e.type}" message requires a non-empty 'id' property`
|
|
113
113
|
);
|
|
114
|
-
if (!
|
|
114
|
+
if (!be(e.payload))
|
|
115
115
|
throw new Error(
|
|
116
116
|
`"${e.type}" message expects the 'payload' property to be an array of GraphQL errors, but got ${JSON.stringify(
|
|
117
117
|
e.payload
|
|
@@ -122,7 +122,7 @@ function ue(e) {
|
|
|
122
122
|
case "complete": {
|
|
123
123
|
if (typeof e.id != "string")
|
|
124
124
|
throw new Error(
|
|
125
|
-
`"${e.type}" message expects the 'id' property to be a string, but got ${
|
|
125
|
+
`"${e.type}" message expects the 'id' property to be a string, but got ${P(
|
|
126
126
|
e.id
|
|
127
127
|
)}`
|
|
128
128
|
);
|
|
@@ -137,38 +137,38 @@ function ue(e) {
|
|
|
137
137
|
}
|
|
138
138
|
return e;
|
|
139
139
|
}
|
|
140
|
-
function
|
|
140
|
+
function ge(e, t) {
|
|
141
141
|
return ue(
|
|
142
142
|
typeof e == "string" ? JSON.parse(e, t) : e
|
|
143
143
|
);
|
|
144
144
|
}
|
|
145
|
-
function
|
|
145
|
+
function F(e, t) {
|
|
146
146
|
return ue(e), JSON.stringify(e, t);
|
|
147
147
|
}
|
|
148
|
-
function
|
|
148
|
+
function we(e) {
|
|
149
149
|
const {
|
|
150
150
|
url: t,
|
|
151
151
|
connectionParams: r,
|
|
152
152
|
lazy: n = !0,
|
|
153
|
-
onNonLazyError:
|
|
153
|
+
onNonLazyError: s = console.error,
|
|
154
154
|
lazyCloseTimeout: i = 0,
|
|
155
155
|
keepAlive: o = 0,
|
|
156
156
|
disablePong: h,
|
|
157
|
-
connectionAckWaitTimeout:
|
|
158
|
-
retryAttempts:
|
|
159
|
-
retryWait:
|
|
160
|
-
const
|
|
157
|
+
connectionAckWaitTimeout: b = 0,
|
|
158
|
+
retryAttempts: A = 5,
|
|
159
|
+
retryWait: w = async function(f) {
|
|
160
|
+
const c = Math.pow(2, f);
|
|
161
161
|
await new Promise(
|
|
162
162
|
(u) => setTimeout(
|
|
163
163
|
u,
|
|
164
|
-
|
|
164
|
+
c * 1e3 + // add random timeout from 300ms to 3s
|
|
165
165
|
Math.floor(Math.random() * 2700 + 300)
|
|
166
166
|
)
|
|
167
167
|
);
|
|
168
168
|
},
|
|
169
|
-
shouldRetry:
|
|
169
|
+
shouldRetry: E = G,
|
|
170
170
|
on: l,
|
|
171
|
-
webSocketImpl:
|
|
171
|
+
webSocketImpl: d,
|
|
172
172
|
/**
|
|
173
173
|
* Generates a v4 UUID to be used as the ID using `Math`
|
|
174
174
|
* as the random number generator. Supply your own generator
|
|
@@ -176,20 +176,20 @@ function ge(e) {
|
|
|
176
176
|
*
|
|
177
177
|
* Reference: https://gist.github.com/jed/982883
|
|
178
178
|
*/
|
|
179
|
-
generateID:
|
|
179
|
+
generateID: v = function() {
|
|
180
180
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (f) => {
|
|
181
|
-
const
|
|
182
|
-
return (f == "x" ?
|
|
181
|
+
const c = Math.random() * 16 | 0;
|
|
182
|
+
return (f == "x" ? c : c & 3 | 8).toString(16);
|
|
183
183
|
});
|
|
184
184
|
},
|
|
185
|
-
jsonMessageReplacer:
|
|
186
|
-
jsonMessageReviver:
|
|
185
|
+
jsonMessageReplacer: m,
|
|
186
|
+
jsonMessageReviver: ye
|
|
187
187
|
} = e;
|
|
188
188
|
let N;
|
|
189
|
-
if (
|
|
190
|
-
if (!xe(
|
|
189
|
+
if (d) {
|
|
190
|
+
if (!xe(d))
|
|
191
191
|
throw new Error("Invalid WebSocket implementation provided");
|
|
192
|
-
N =
|
|
192
|
+
N = d;
|
|
193
193
|
} else typeof WebSocket < "u" ? N = WebSocket : typeof global < "u" ? N = global.WebSocket || // @ts-expect-error: Support more browsers
|
|
194
194
|
global.MozWebSocket : typeof window < "u" && (N = window.WebSocket || // @ts-expect-error: Support more browsers
|
|
195
195
|
window.MozWebSocket);
|
|
@@ -197,17 +197,17 @@ function ge(e) {
|
|
|
197
197
|
throw new Error(
|
|
198
198
|
"WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`"
|
|
199
199
|
);
|
|
200
|
-
const
|
|
200
|
+
const q = N, x = (() => {
|
|
201
201
|
const a = /* @__PURE__ */ (() => {
|
|
202
|
-
const
|
|
202
|
+
const c = {};
|
|
203
203
|
return {
|
|
204
|
-
on(u,
|
|
205
|
-
return
|
|
206
|
-
delete
|
|
204
|
+
on(u, y) {
|
|
205
|
+
return c[u] = y, () => {
|
|
206
|
+
delete c[u];
|
|
207
207
|
};
|
|
208
208
|
},
|
|
209
209
|
emit(u) {
|
|
210
|
-
"id" in u &&
|
|
210
|
+
"id" in u && c[u.id]?.(u);
|
|
211
211
|
}
|
|
212
212
|
};
|
|
213
213
|
})(), f = {
|
|
@@ -222,117 +222,117 @@ function ge(e) {
|
|
|
222
222
|
};
|
|
223
223
|
return {
|
|
224
224
|
onMessage: a.on,
|
|
225
|
-
on(
|
|
226
|
-
const
|
|
227
|
-
return
|
|
228
|
-
|
|
225
|
+
on(c, u) {
|
|
226
|
+
const y = f[c];
|
|
227
|
+
return y.push(u), () => {
|
|
228
|
+
y.splice(y.indexOf(u), 1);
|
|
229
229
|
};
|
|
230
230
|
},
|
|
231
|
-
emit(
|
|
232
|
-
for (const
|
|
233
|
-
|
|
231
|
+
emit(c, ...u) {
|
|
232
|
+
for (const y of [...f[c]])
|
|
233
|
+
y(...u);
|
|
234
234
|
}
|
|
235
235
|
};
|
|
236
236
|
})();
|
|
237
|
-
function
|
|
237
|
+
function H(a) {
|
|
238
238
|
const f = [
|
|
239
239
|
// errors are fatal and more critical than close events, throw them first
|
|
240
|
-
|
|
241
|
-
f.forEach((u) => u()), a(
|
|
240
|
+
x.on("error", (c) => {
|
|
241
|
+
f.forEach((u) => u()), a(c);
|
|
242
242
|
}),
|
|
243
243
|
// closes can be graceful and not fatal, throw them second (if error didnt throw)
|
|
244
|
-
|
|
245
|
-
f.forEach((u) => u()), a(
|
|
244
|
+
x.on("closed", (c) => {
|
|
245
|
+
f.forEach((u) => u()), a(c);
|
|
246
246
|
})
|
|
247
247
|
];
|
|
248
248
|
}
|
|
249
|
-
let
|
|
249
|
+
let $, I = 0, K, W = !1, B = 0, X = !1;
|
|
250
250
|
async function Z() {
|
|
251
251
|
clearTimeout(K);
|
|
252
|
-
const [a, f] = await (
|
|
253
|
-
(
|
|
254
|
-
if (
|
|
255
|
-
if (await
|
|
256
|
-
return
|
|
257
|
-
|
|
252
|
+
const [a, f] = await ($ ?? ($ = new Promise(
|
|
253
|
+
(y, k) => (async () => {
|
|
254
|
+
if (W) {
|
|
255
|
+
if (await w(B), !I)
|
|
256
|
+
return $ = void 0, k({ code: 1e3, reason: "All Subscriptions Gone" });
|
|
257
|
+
B++;
|
|
258
258
|
}
|
|
259
|
-
|
|
260
|
-
const p = new
|
|
259
|
+
x.emit("connecting", W);
|
|
260
|
+
const p = new q(
|
|
261
261
|
typeof t == "function" ? await t() : t,
|
|
262
|
-
|
|
262
|
+
me
|
|
263
263
|
);
|
|
264
|
-
let
|
|
265
|
-
function
|
|
266
|
-
isFinite(o) && o > 0 && (clearTimeout(
|
|
267
|
-
p.readyState ===
|
|
264
|
+
let M, z;
|
|
265
|
+
function U() {
|
|
266
|
+
isFinite(o) && o > 0 && (clearTimeout(z), z = setTimeout(() => {
|
|
267
|
+
p.readyState === q.OPEN && (p.send(F({ type: O.Ping })), x.emit("ping", !1, void 0));
|
|
268
268
|
}, o));
|
|
269
269
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
}), p.onerror = (
|
|
270
|
+
H((S) => {
|
|
271
|
+
$ = void 0, clearTimeout(M), clearTimeout(z), k(S), S instanceof ne && (p.close(4499, "Terminated"), p.onerror = null, p.onclose = null);
|
|
272
|
+
}), p.onerror = (S) => x.emit("error", S), p.onclose = (S) => x.emit("closed", S), p.onopen = async () => {
|
|
273
273
|
try {
|
|
274
|
-
|
|
275
|
-
const
|
|
276
|
-
if (p.readyState !==
|
|
274
|
+
x.emit("opened", p);
|
|
275
|
+
const S = typeof r == "function" ? await r() : r;
|
|
276
|
+
if (p.readyState !== q.OPEN) return;
|
|
277
277
|
p.send(
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
type:
|
|
281
|
-
payload:
|
|
278
|
+
F(
|
|
279
|
+
S ? {
|
|
280
|
+
type: O.ConnectionInit,
|
|
281
|
+
payload: S
|
|
282
282
|
} : {
|
|
283
|
-
type:
|
|
283
|
+
type: O.ConnectionInit
|
|
284
284
|
// payload is completely absent if not provided
|
|
285
285
|
},
|
|
286
|
-
|
|
286
|
+
m
|
|
287
287
|
)
|
|
288
|
-
), isFinite(
|
|
288
|
+
), isFinite(b) && b > 0 && (M = setTimeout(() => {
|
|
289
289
|
p.close(
|
|
290
|
-
|
|
290
|
+
_.ConnectionAcknowledgementTimeout,
|
|
291
291
|
"Connection acknowledgement timeout"
|
|
292
292
|
);
|
|
293
|
-
},
|
|
294
|
-
} catch (
|
|
295
|
-
|
|
296
|
-
|
|
293
|
+
}, b)), U();
|
|
294
|
+
} catch (S) {
|
|
295
|
+
x.emit("error", S), p.close(
|
|
296
|
+
_.InternalClientError,
|
|
297
297
|
re(
|
|
298
|
-
|
|
298
|
+
S instanceof Error ? S.message : String(S),
|
|
299
299
|
"Internal client error"
|
|
300
300
|
)
|
|
301
301
|
);
|
|
302
302
|
}
|
|
303
303
|
};
|
|
304
304
|
let j = !1;
|
|
305
|
-
p.onmessage = ({ data:
|
|
305
|
+
p.onmessage = ({ data: S }) => {
|
|
306
306
|
try {
|
|
307
|
-
const
|
|
308
|
-
if (
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
type:
|
|
313
|
-
payload:
|
|
307
|
+
const g = ge(S, ye);
|
|
308
|
+
if (x.emit("message", g), g.type === "ping" || g.type === "pong") {
|
|
309
|
+
x.emit(g.type, !0, g.payload), g.type === "pong" ? U() : h || (p.send(
|
|
310
|
+
F(
|
|
311
|
+
g.payload ? {
|
|
312
|
+
type: O.Pong,
|
|
313
|
+
payload: g.payload
|
|
314
314
|
} : {
|
|
315
|
-
type:
|
|
315
|
+
type: O.Pong
|
|
316
316
|
// payload is completely absent if not provided
|
|
317
317
|
}
|
|
318
318
|
)
|
|
319
|
-
),
|
|
319
|
+
), x.emit("pong", !1, g.payload));
|
|
320
320
|
return;
|
|
321
321
|
}
|
|
322
322
|
if (j) return;
|
|
323
|
-
if (
|
|
323
|
+
if (g.type !== O.ConnectionAck)
|
|
324
324
|
throw new Error(
|
|
325
|
-
`First message cannot be of type ${
|
|
325
|
+
`First message cannot be of type ${g.type}`
|
|
326
326
|
);
|
|
327
|
-
clearTimeout(
|
|
327
|
+
clearTimeout(M), j = !0, x.emit("connected", p, g.payload, W), W = !1, B = 0, y([
|
|
328
328
|
p,
|
|
329
|
-
new Promise((
|
|
329
|
+
new Promise((Fe, he) => H(he))
|
|
330
330
|
]);
|
|
331
|
-
} catch (
|
|
332
|
-
p.onmessage = null,
|
|
333
|
-
|
|
331
|
+
} catch (g) {
|
|
332
|
+
p.onmessage = null, x.emit("error", g), p.close(
|
|
333
|
+
_.BadResponse,
|
|
334
334
|
re(
|
|
335
|
-
|
|
335
|
+
g instanceof Error ? g.message : String(g),
|
|
336
336
|
"Bad response"
|
|
337
337
|
)
|
|
338
338
|
);
|
|
@@ -340,21 +340,21 @@ function ge(e) {
|
|
|
340
340
|
};
|
|
341
341
|
})()
|
|
342
342
|
)));
|
|
343
|
-
a.readyState ===
|
|
344
|
-
let
|
|
343
|
+
a.readyState === q.CLOSING && await f;
|
|
344
|
+
let c = () => {
|
|
345
345
|
};
|
|
346
|
-
const u = new Promise((
|
|
346
|
+
const u = new Promise((y) => c = y);
|
|
347
347
|
return [
|
|
348
348
|
a,
|
|
349
|
-
|
|
349
|
+
c,
|
|
350
350
|
Promise.race([
|
|
351
351
|
// wait for
|
|
352
352
|
u.then(() => {
|
|
353
|
-
if (
|
|
354
|
-
const
|
|
353
|
+
if (!I) {
|
|
354
|
+
const y = () => a.close(1e3, "Normal Closure");
|
|
355
355
|
isFinite(i) && i > 0 ? K = setTimeout(() => {
|
|
356
|
-
a.readyState ===
|
|
357
|
-
}, i) :
|
|
356
|
+
a.readyState === q.OPEN && y();
|
|
357
|
+
}, i) : y();
|
|
358
358
|
}
|
|
359
359
|
}),
|
|
360
360
|
// or
|
|
@@ -363,29 +363,29 @@ function ge(e) {
|
|
|
363
363
|
];
|
|
364
364
|
}
|
|
365
365
|
function ee(a) {
|
|
366
|
-
if (
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
366
|
+
if (G(a) && (Ee(a.code) || [
|
|
367
|
+
_.InternalServerError,
|
|
368
|
+
_.InternalClientError,
|
|
369
|
+
_.BadRequest,
|
|
370
|
+
_.BadResponse,
|
|
371
|
+
_.Unauthorized,
|
|
372
372
|
// CloseCode.Forbidden, might grant access out after retry
|
|
373
|
-
|
|
373
|
+
_.SubprotocolNotAcceptable,
|
|
374
374
|
// CloseCode.ConnectionInitialisationTimeout, might not time out after retry
|
|
375
375
|
// CloseCode.ConnectionAcknowledgementTimeout, might not time out after retry
|
|
376
|
-
|
|
377
|
-
|
|
376
|
+
_.SubscriberAlreadyExists,
|
|
377
|
+
_.TooManyInitialisationRequests
|
|
378
378
|
// 4499, // Terminated, probably because the socket froze, we want to retry
|
|
379
379
|
].includes(a.code)))
|
|
380
380
|
throw a;
|
|
381
381
|
if (X) return !1;
|
|
382
|
-
if (
|
|
383
|
-
return
|
|
384
|
-
if (!
|
|
385
|
-
return
|
|
382
|
+
if (G(a) && a.code === 1e3)
|
|
383
|
+
return I > 0;
|
|
384
|
+
if (!A || B >= A || !E(a)) throw a;
|
|
385
|
+
return W = !0;
|
|
386
386
|
}
|
|
387
387
|
n || (async () => {
|
|
388
|
-
for (
|
|
388
|
+
for (I++; ; )
|
|
389
389
|
try {
|
|
390
390
|
const [, , a] = await Z();
|
|
391
391
|
await a;
|
|
@@ -393,107 +393,107 @@ function ge(e) {
|
|
|
393
393
|
try {
|
|
394
394
|
if (!ee(a)) return;
|
|
395
395
|
} catch (f) {
|
|
396
|
-
return
|
|
396
|
+
return s?.(f);
|
|
397
397
|
}
|
|
398
398
|
}
|
|
399
399
|
})();
|
|
400
400
|
function te(a, f) {
|
|
401
|
-
const
|
|
402
|
-
let u = !1,
|
|
403
|
-
|
|
401
|
+
const c = v(a);
|
|
402
|
+
let u = !1, y = !1, k = () => {
|
|
403
|
+
I--, u = !0;
|
|
404
404
|
};
|
|
405
405
|
return (async () => {
|
|
406
|
-
for (
|
|
406
|
+
for (I++; ; )
|
|
407
407
|
try {
|
|
408
|
-
const [p,
|
|
409
|
-
if (u) return
|
|
410
|
-
const
|
|
408
|
+
const [p, M, z] = await Z();
|
|
409
|
+
if (u) return M();
|
|
410
|
+
const U = x.onMessage(c, (j) => {
|
|
411
411
|
switch (j.type) {
|
|
412
|
-
case
|
|
412
|
+
case O.Next: {
|
|
413
413
|
f.next(j.payload);
|
|
414
414
|
return;
|
|
415
415
|
}
|
|
416
|
-
case
|
|
417
|
-
|
|
416
|
+
case O.Error: {
|
|
417
|
+
y = !0, u = !0, f.error(j.payload), k();
|
|
418
418
|
return;
|
|
419
419
|
}
|
|
420
|
-
case
|
|
421
|
-
u = !0,
|
|
420
|
+
case O.Complete: {
|
|
421
|
+
u = !0, k();
|
|
422
422
|
return;
|
|
423
423
|
}
|
|
424
424
|
}
|
|
425
425
|
});
|
|
426
426
|
p.send(
|
|
427
|
-
|
|
427
|
+
F(
|
|
428
428
|
{
|
|
429
|
-
id:
|
|
430
|
-
type:
|
|
429
|
+
id: c,
|
|
430
|
+
type: O.Subscribe,
|
|
431
431
|
payload: a
|
|
432
432
|
},
|
|
433
|
-
|
|
433
|
+
m
|
|
434
434
|
)
|
|
435
|
-
),
|
|
436
|
-
!u && p.readyState ===
|
|
437
|
-
|
|
435
|
+
), k = () => {
|
|
436
|
+
!u && p.readyState === q.OPEN && p.send(
|
|
437
|
+
F(
|
|
438
438
|
{
|
|
439
|
-
id:
|
|
440
|
-
type:
|
|
439
|
+
id: c,
|
|
440
|
+
type: O.Complete
|
|
441
441
|
},
|
|
442
|
-
|
|
442
|
+
m
|
|
443
443
|
)
|
|
444
|
-
),
|
|
445
|
-
}, await
|
|
444
|
+
), I--, u = !0, M();
|
|
445
|
+
}, await z.finally(U);
|
|
446
446
|
return;
|
|
447
447
|
} catch (p) {
|
|
448
448
|
if (!ee(p)) return;
|
|
449
449
|
}
|
|
450
450
|
})().then(() => {
|
|
451
|
-
|
|
451
|
+
y || f.complete();
|
|
452
452
|
}).catch((p) => {
|
|
453
453
|
f.error(p);
|
|
454
454
|
}), () => {
|
|
455
|
-
u ||
|
|
455
|
+
u || k();
|
|
456
456
|
};
|
|
457
457
|
}
|
|
458
458
|
return {
|
|
459
|
-
on:
|
|
459
|
+
on: x.on,
|
|
460
460
|
subscribe: te,
|
|
461
461
|
iterate(a) {
|
|
462
|
-
const f = [],
|
|
462
|
+
const f = [], c = {
|
|
463
463
|
done: !1,
|
|
464
464
|
error: null,
|
|
465
465
|
resolve: () => {
|
|
466
466
|
}
|
|
467
467
|
}, u = te(a, {
|
|
468
|
-
next(
|
|
469
|
-
f.push(
|
|
468
|
+
next(k) {
|
|
469
|
+
f.push(k), c.resolve();
|
|
470
470
|
},
|
|
471
|
-
error(
|
|
472
|
-
|
|
471
|
+
error(k) {
|
|
472
|
+
c.done = !0, c.error = k, c.resolve();
|
|
473
473
|
},
|
|
474
474
|
complete() {
|
|
475
|
-
|
|
475
|
+
c.done = !0, c.resolve();
|
|
476
476
|
}
|
|
477
|
-
}),
|
|
477
|
+
}), y = async function* () {
|
|
478
478
|
for (; ; ) {
|
|
479
|
-
for (f.length || await new Promise((p) =>
|
|
479
|
+
for (f.length || await new Promise((p) => c.resolve = p); f.length; )
|
|
480
480
|
yield f.shift();
|
|
481
|
-
if (
|
|
482
|
-
throw
|
|
483
|
-
if (
|
|
481
|
+
if (c.error)
|
|
482
|
+
throw c.error;
|
|
483
|
+
if (c.done)
|
|
484
484
|
return;
|
|
485
485
|
}
|
|
486
486
|
}();
|
|
487
|
-
return
|
|
487
|
+
return y.throw = async (k) => (c.done || (c.done = !0, c.error = k, c.resolve()), { done: !0, value: void 0 }), y.return = async () => (u(), { done: !0, value: void 0 }), y;
|
|
488
488
|
},
|
|
489
489
|
async dispose() {
|
|
490
|
-
if (X = !0,
|
|
491
|
-
const [a] = await
|
|
490
|
+
if (X = !0, $) {
|
|
491
|
+
const [a] = await $;
|
|
492
492
|
a.close(1e3, "Normal Closure");
|
|
493
493
|
}
|
|
494
494
|
},
|
|
495
495
|
terminate() {
|
|
496
|
-
|
|
496
|
+
$ && x.emit("closed", new ne());
|
|
497
497
|
}
|
|
498
498
|
};
|
|
499
499
|
}
|
|
@@ -504,10 +504,10 @@ class ne extends Error {
|
|
|
504
504
|
reason = "Terminated";
|
|
505
505
|
wasClean = !1;
|
|
506
506
|
}
|
|
507
|
-
function
|
|
508
|
-
return
|
|
507
|
+
function G(e) {
|
|
508
|
+
return R(e) && "code" in e && "reason" in e;
|
|
509
509
|
}
|
|
510
|
-
function
|
|
510
|
+
function Ee(e) {
|
|
511
511
|
return [
|
|
512
512
|
1e3,
|
|
513
513
|
// Normal Closure is not an erroneous close code
|
|
@@ -528,39 +528,17 @@ function we(e) {
|
|
|
528
528
|
function xe(e) {
|
|
529
529
|
return typeof e == "function" && "constructor" in e && "CLOSED" in e && "CLOSING" in e && "CONNECTING" in e && "OPEN" in e;
|
|
530
530
|
}
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
this.createClient = t, this.poolSize = r;
|
|
534
|
-
}
|
|
535
|
-
clients = [];
|
|
536
|
-
currentIndex = 0;
|
|
537
|
-
connect() {
|
|
538
|
-
for (let t = 0; t < this.poolSize; t++)
|
|
539
|
-
this.clients.push(this.createClient(`${t + 1}`));
|
|
540
|
-
}
|
|
541
|
-
get() {
|
|
542
|
-
if (this.clients.length === 0)
|
|
543
|
-
throw new Error("Connection pool is empty. Please call connect() first.");
|
|
544
|
-
const t = this.clients[this.currentIndex];
|
|
545
|
-
if (this.currentIndex = (this.currentIndex + 1) % this.poolSize, !t)
|
|
546
|
-
throw new Error("No available WebSocket client");
|
|
547
|
-
return t;
|
|
548
|
-
}
|
|
549
|
-
disconnect() {
|
|
550
|
-
this.clients.forEach((t) => t.dispose()), this.clients = [];
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
var D = function(e, t) {
|
|
554
|
-
return D = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(r, n) {
|
|
531
|
+
var J = function(e, t) {
|
|
532
|
+
return J = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(r, n) {
|
|
555
533
|
r.__proto__ = n;
|
|
556
534
|
} || function(r, n) {
|
|
557
|
-
for (var
|
|
558
|
-
},
|
|
535
|
+
for (var s in n) Object.prototype.hasOwnProperty.call(n, s) && (r[s] = n[s]);
|
|
536
|
+
}, J(e, t);
|
|
559
537
|
};
|
|
560
538
|
function pe(e, t) {
|
|
561
539
|
if (typeof t != "function" && t !== null)
|
|
562
540
|
throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
|
|
563
|
-
|
|
541
|
+
J(e, t);
|
|
564
542
|
function r() {
|
|
565
543
|
this.constructor = e;
|
|
566
544
|
}
|
|
@@ -576,42 +554,42 @@ function oe(e) {
|
|
|
576
554
|
};
|
|
577
555
|
throw new TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
578
556
|
}
|
|
579
|
-
function
|
|
557
|
+
function Q(e, t) {
|
|
580
558
|
var r = typeof Symbol == "function" && e[Symbol.iterator];
|
|
581
559
|
if (!r) return e;
|
|
582
|
-
var n = r.call(e),
|
|
560
|
+
var n = r.call(e), s, i = [], o;
|
|
583
561
|
try {
|
|
584
|
-
for (; (t === void 0 || t-- > 0) && !(
|
|
562
|
+
for (; (t === void 0 || t-- > 0) && !(s = n.next()).done; ) i.push(s.value);
|
|
585
563
|
} catch (h) {
|
|
586
564
|
o = { error: h };
|
|
587
565
|
} finally {
|
|
588
566
|
try {
|
|
589
|
-
|
|
567
|
+
s && !s.done && (r = n.return) && r.call(n);
|
|
590
568
|
} finally {
|
|
591
569
|
if (o) throw o.error;
|
|
592
570
|
}
|
|
593
571
|
}
|
|
594
572
|
return i;
|
|
595
573
|
}
|
|
596
|
-
function
|
|
597
|
-
if (r || arguments.length === 2) for (var n = 0,
|
|
574
|
+
function V(e, t, r) {
|
|
575
|
+
if (r || arguments.length === 2) for (var n = 0, s = t.length, i; n < s; n++)
|
|
598
576
|
(i || !(n in t)) && (i || (i = Array.prototype.slice.call(t, 0, n)), i[n] = t[n]);
|
|
599
577
|
return e.concat(i || Array.prototype.slice.call(t));
|
|
600
578
|
}
|
|
601
|
-
function
|
|
579
|
+
function T(e) {
|
|
602
580
|
return typeof e == "function";
|
|
603
581
|
}
|
|
604
|
-
function
|
|
582
|
+
function le(e) {
|
|
605
583
|
var t = function(n) {
|
|
606
584
|
Error.call(n), n.stack = new Error().stack;
|
|
607
585
|
}, r = e(t);
|
|
608
586
|
return r.prototype = Object.create(Error.prototype), r.prototype.constructor = r, r;
|
|
609
587
|
}
|
|
610
|
-
var
|
|
588
|
+
var D = le(function(e) {
|
|
611
589
|
return function(r) {
|
|
612
590
|
e(this), this.message = r ? r.length + ` errors occurred during unsubscription:
|
|
613
|
-
` + r.map(function(n,
|
|
614
|
-
return
|
|
591
|
+
` + r.map(function(n, s) {
|
|
592
|
+
return s + 1 + ") " + n.toString();
|
|
615
593
|
}).join(`
|
|
616
594
|
`) : "", this.name = "UnsubscriptionError", this.errors = r;
|
|
617
595
|
};
|
|
@@ -622,64 +600,64 @@ function ie(e, t) {
|
|
|
622
600
|
0 <= r && e.splice(r, 1);
|
|
623
601
|
}
|
|
624
602
|
}
|
|
625
|
-
var
|
|
603
|
+
var Y = function() {
|
|
626
604
|
function e(t) {
|
|
627
605
|
this.initialTeardown = t, this.closed = !1, this._parentage = null, this._finalizers = null;
|
|
628
606
|
}
|
|
629
607
|
return e.prototype.unsubscribe = function() {
|
|
630
|
-
var t, r, n,
|
|
608
|
+
var t, r, n, s, i;
|
|
631
609
|
if (!this.closed) {
|
|
632
610
|
this.closed = !0;
|
|
633
611
|
var o = this._parentage;
|
|
634
612
|
if (o)
|
|
635
613
|
if (this._parentage = null, Array.isArray(o))
|
|
636
614
|
try {
|
|
637
|
-
for (var h = oe(o),
|
|
638
|
-
var
|
|
639
|
-
|
|
615
|
+
for (var h = oe(o), b = h.next(); !b.done; b = h.next()) {
|
|
616
|
+
var A = b.value;
|
|
617
|
+
A.remove(this);
|
|
640
618
|
}
|
|
641
|
-
} catch (
|
|
642
|
-
t = { error:
|
|
619
|
+
} catch (m) {
|
|
620
|
+
t = { error: m };
|
|
643
621
|
} finally {
|
|
644
622
|
try {
|
|
645
|
-
|
|
623
|
+
b && !b.done && (r = h.return) && r.call(h);
|
|
646
624
|
} finally {
|
|
647
625
|
if (t) throw t.error;
|
|
648
626
|
}
|
|
649
627
|
}
|
|
650
628
|
else
|
|
651
629
|
o.remove(this);
|
|
652
|
-
var
|
|
653
|
-
if (
|
|
630
|
+
var w = this.initialTeardown;
|
|
631
|
+
if (T(w))
|
|
654
632
|
try {
|
|
655
|
-
|
|
656
|
-
} catch (
|
|
657
|
-
i =
|
|
633
|
+
w();
|
|
634
|
+
} catch (m) {
|
|
635
|
+
i = m instanceof D ? m.errors : [m];
|
|
658
636
|
}
|
|
659
|
-
var
|
|
660
|
-
if (
|
|
637
|
+
var E = this._finalizers;
|
|
638
|
+
if (E) {
|
|
661
639
|
this._finalizers = null;
|
|
662
640
|
try {
|
|
663
|
-
for (var l = oe(
|
|
664
|
-
var
|
|
641
|
+
for (var l = oe(E), d = l.next(); !d.done; d = l.next()) {
|
|
642
|
+
var v = d.value;
|
|
665
643
|
try {
|
|
666
|
-
se(
|
|
667
|
-
} catch (
|
|
668
|
-
i = i ?? [],
|
|
644
|
+
se(v);
|
|
645
|
+
} catch (m) {
|
|
646
|
+
i = i ?? [], m instanceof D ? i = V(V([], Q(i)), Q(m.errors)) : i.push(m);
|
|
669
647
|
}
|
|
670
648
|
}
|
|
671
|
-
} catch (
|
|
672
|
-
n = { error:
|
|
649
|
+
} catch (m) {
|
|
650
|
+
n = { error: m };
|
|
673
651
|
} finally {
|
|
674
652
|
try {
|
|
675
|
-
|
|
653
|
+
d && !d.done && (s = l.return) && s.call(l);
|
|
676
654
|
} finally {
|
|
677
655
|
if (n) throw n.error;
|
|
678
656
|
}
|
|
679
657
|
}
|
|
680
658
|
}
|
|
681
659
|
if (i)
|
|
682
|
-
throw new
|
|
660
|
+
throw new D(i);
|
|
683
661
|
}
|
|
684
662
|
}, e.prototype.add = function(t) {
|
|
685
663
|
var r;
|
|
@@ -711,44 +689,44 @@ var H = function() {
|
|
|
711
689
|
return t.closed = !0, t;
|
|
712
690
|
}(), e;
|
|
713
691
|
}();
|
|
714
|
-
|
|
715
|
-
function
|
|
716
|
-
return e instanceof
|
|
692
|
+
Y.EMPTY;
|
|
693
|
+
function fe(e) {
|
|
694
|
+
return e instanceof Y || e && "closed" in e && T(e.remove) && T(e.add) && T(e.unsubscribe);
|
|
717
695
|
}
|
|
718
696
|
function se(e) {
|
|
719
|
-
|
|
697
|
+
T(e) ? e() : e.unsubscribe();
|
|
720
698
|
}
|
|
721
|
-
var
|
|
699
|
+
var Se = {
|
|
722
700
|
Promise: void 0
|
|
723
|
-
},
|
|
701
|
+
}, ke = {
|
|
724
702
|
setTimeout: function(e, t) {
|
|
725
703
|
for (var r = [], n = 2; n < arguments.length; n++)
|
|
726
704
|
r[n - 2] = arguments[n];
|
|
727
|
-
return setTimeout.apply(void 0,
|
|
705
|
+
return setTimeout.apply(void 0, V([e, t], Q(r)));
|
|
728
706
|
},
|
|
729
707
|
clearTimeout: function(e) {
|
|
730
708
|
return clearTimeout(e);
|
|
731
709
|
},
|
|
732
710
|
delegate: void 0
|
|
733
711
|
};
|
|
734
|
-
function
|
|
735
|
-
|
|
712
|
+
function Pe(e) {
|
|
713
|
+
ke.setTimeout(function() {
|
|
736
714
|
throw e;
|
|
737
715
|
});
|
|
738
716
|
}
|
|
739
717
|
function ce() {
|
|
740
718
|
}
|
|
741
|
-
function
|
|
719
|
+
function ve(e) {
|
|
742
720
|
e();
|
|
743
721
|
}
|
|
744
|
-
var
|
|
722
|
+
var de = function(e) {
|
|
745
723
|
pe(t, e);
|
|
746
724
|
function t(r) {
|
|
747
725
|
var n = e.call(this) || this;
|
|
748
|
-
return n.isStopped = !1, r ? (n.destination = r,
|
|
726
|
+
return n.isStopped = !1, r ? (n.destination = r, fe(r) && r.add(n)) : n.destination = Te, n;
|
|
749
727
|
}
|
|
750
|
-
return t.create = function(r, n,
|
|
751
|
-
return new
|
|
728
|
+
return t.create = function(r, n, s) {
|
|
729
|
+
return new C(r, n, s);
|
|
752
730
|
}, t.prototype.next = function(r) {
|
|
753
731
|
this.isStopped || this._next(r);
|
|
754
732
|
}, t.prototype.error = function(r) {
|
|
@@ -772,7 +750,7 @@ var fe = function(e) {
|
|
|
772
750
|
this.unsubscribe();
|
|
773
751
|
}
|
|
774
752
|
}, t;
|
|
775
|
-
}(
|
|
753
|
+
}(Y), _e = function() {
|
|
776
754
|
function e(t) {
|
|
777
755
|
this.partialObserver = t;
|
|
778
756
|
}
|
|
@@ -782,7 +760,7 @@ var fe = function(e) {
|
|
|
782
760
|
try {
|
|
783
761
|
r.next(t);
|
|
784
762
|
} catch (n) {
|
|
785
|
-
|
|
763
|
+
L(n);
|
|
786
764
|
}
|
|
787
765
|
}, e.prototype.error = function(t) {
|
|
788
766
|
var r = this.partialObserver;
|
|
@@ -790,52 +768,52 @@ var fe = function(e) {
|
|
|
790
768
|
try {
|
|
791
769
|
r.error(t);
|
|
792
770
|
} catch (n) {
|
|
793
|
-
|
|
771
|
+
L(n);
|
|
794
772
|
}
|
|
795
773
|
else
|
|
796
|
-
|
|
774
|
+
L(t);
|
|
797
775
|
}, e.prototype.complete = function() {
|
|
798
776
|
var t = this.partialObserver;
|
|
799
777
|
if (t.complete)
|
|
800
778
|
try {
|
|
801
779
|
t.complete();
|
|
802
780
|
} catch (r) {
|
|
803
|
-
|
|
781
|
+
L(r);
|
|
804
782
|
}
|
|
805
783
|
}, e;
|
|
806
|
-
}(),
|
|
784
|
+
}(), C = function(e) {
|
|
807
785
|
pe(t, e);
|
|
808
|
-
function t(r, n,
|
|
786
|
+
function t(r, n, s) {
|
|
809
787
|
var i = e.call(this) || this, o;
|
|
810
|
-
return
|
|
788
|
+
return T(r) || !r ? o = {
|
|
811
789
|
next: r ?? void 0,
|
|
812
790
|
error: n ?? void 0,
|
|
813
|
-
complete:
|
|
814
|
-
} : o = r, i.destination = new
|
|
791
|
+
complete: s ?? void 0
|
|
792
|
+
} : o = r, i.destination = new _e(o), i;
|
|
815
793
|
}
|
|
816
794
|
return t;
|
|
817
|
-
}(
|
|
818
|
-
function
|
|
819
|
-
|
|
795
|
+
}(de);
|
|
796
|
+
function L(e) {
|
|
797
|
+
Pe(e);
|
|
820
798
|
}
|
|
821
|
-
function
|
|
799
|
+
function Oe(e) {
|
|
822
800
|
throw e;
|
|
823
801
|
}
|
|
824
|
-
var
|
|
802
|
+
var Te = {
|
|
825
803
|
closed: !0,
|
|
826
804
|
next: ce,
|
|
827
|
-
error:
|
|
805
|
+
error: Oe,
|
|
828
806
|
complete: ce
|
|
829
|
-
},
|
|
807
|
+
}, Ae = function() {
|
|
830
808
|
return typeof Symbol == "function" && Symbol.observable || "@@observable";
|
|
831
809
|
}();
|
|
832
|
-
function
|
|
810
|
+
function $e(e) {
|
|
833
811
|
return e;
|
|
834
812
|
}
|
|
835
|
-
function
|
|
836
|
-
return e.length === 0 ?
|
|
837
|
-
return e.reduce(function(n,
|
|
838
|
-
return
|
|
813
|
+
function Ie(e) {
|
|
814
|
+
return e.length === 0 ? $e : e.length === 1 ? e[0] : function(r) {
|
|
815
|
+
return e.reduce(function(n, s) {
|
|
816
|
+
return s(n);
|
|
839
817
|
}, r);
|
|
840
818
|
};
|
|
841
819
|
}
|
|
@@ -847,10 +825,10 @@ var Re = function() {
|
|
|
847
825
|
var r = new e();
|
|
848
826
|
return r.source = this, r.operator = t, r;
|
|
849
827
|
}, e.prototype.subscribe = function(t, r, n) {
|
|
850
|
-
var
|
|
851
|
-
return
|
|
852
|
-
var o =
|
|
853
|
-
i.add(h ? h.call(i,
|
|
828
|
+
var s = this, i = qe(t) ? t : new C(t, r, n);
|
|
829
|
+
return ve(function() {
|
|
830
|
+
var o = s, h = o.operator, b = o.source;
|
|
831
|
+
i.add(h ? h.call(i, b) : b ? s._subscribe(i) : s._trySubscribe(i));
|
|
854
832
|
}), i;
|
|
855
833
|
}, e.prototype._trySubscribe = function(t) {
|
|
856
834
|
try {
|
|
@@ -860,37 +838,37 @@ var Re = function() {
|
|
|
860
838
|
}
|
|
861
839
|
}, e.prototype.forEach = function(t, r) {
|
|
862
840
|
var n = this;
|
|
863
|
-
return r = ae(r), new r(function(
|
|
864
|
-
var o = new
|
|
841
|
+
return r = ae(r), new r(function(s, i) {
|
|
842
|
+
var o = new C({
|
|
865
843
|
next: function(h) {
|
|
866
844
|
try {
|
|
867
845
|
t(h);
|
|
868
|
-
} catch (
|
|
869
|
-
i(
|
|
846
|
+
} catch (b) {
|
|
847
|
+
i(b), o.unsubscribe();
|
|
870
848
|
}
|
|
871
849
|
},
|
|
872
850
|
error: i,
|
|
873
|
-
complete:
|
|
851
|
+
complete: s
|
|
874
852
|
});
|
|
875
853
|
n.subscribe(o);
|
|
876
854
|
});
|
|
877
855
|
}, e.prototype._subscribe = function(t) {
|
|
878
856
|
var r;
|
|
879
857
|
return (r = this.source) === null || r === void 0 ? void 0 : r.subscribe(t);
|
|
880
|
-
}, e.prototype[
|
|
858
|
+
}, e.prototype[Ae] = function() {
|
|
881
859
|
return this;
|
|
882
860
|
}, e.prototype.pipe = function() {
|
|
883
861
|
for (var t = [], r = 0; r < arguments.length; r++)
|
|
884
862
|
t[r] = arguments[r];
|
|
885
|
-
return
|
|
863
|
+
return Ie(t)(this);
|
|
886
864
|
}, e.prototype.toPromise = function(t) {
|
|
887
865
|
var r = this;
|
|
888
|
-
return t = ae(t), new t(function(n,
|
|
866
|
+
return t = ae(t), new t(function(n, s) {
|
|
889
867
|
var i;
|
|
890
868
|
r.subscribe(function(o) {
|
|
891
869
|
return i = o;
|
|
892
870
|
}, function(o) {
|
|
893
|
-
return
|
|
871
|
+
return s(o);
|
|
894
872
|
}, function() {
|
|
895
873
|
return n(i);
|
|
896
874
|
});
|
|
@@ -901,85 +879,131 @@ var Re = function() {
|
|
|
901
879
|
}();
|
|
902
880
|
function ae(e) {
|
|
903
881
|
var t;
|
|
904
|
-
return (t = e ??
|
|
882
|
+
return (t = e ?? Se.Promise) !== null && t !== void 0 ? t : Promise;
|
|
883
|
+
}
|
|
884
|
+
function Ne(e) {
|
|
885
|
+
return e && T(e.next) && T(e.error) && T(e.complete);
|
|
905
886
|
}
|
|
906
887
|
function qe(e) {
|
|
907
|
-
return e &&
|
|
888
|
+
return e && e instanceof de || Ne(e) && fe(e);
|
|
908
889
|
}
|
|
909
|
-
|
|
910
|
-
return
|
|
890
|
+
var Me = le(function(e) {
|
|
891
|
+
return function() {
|
|
892
|
+
e(this), this.name = "EmptyError", this.message = "no elements in sequence";
|
|
893
|
+
};
|
|
894
|
+
});
|
|
895
|
+
function je(e, t) {
|
|
896
|
+
return new Promise(function(r, n) {
|
|
897
|
+
var s = new C({
|
|
898
|
+
next: function(i) {
|
|
899
|
+
r(i), s.unsubscribe();
|
|
900
|
+
},
|
|
901
|
+
error: n,
|
|
902
|
+
complete: function() {
|
|
903
|
+
n(new Me());
|
|
904
|
+
}
|
|
905
|
+
});
|
|
906
|
+
e.subscribe(s);
|
|
907
|
+
});
|
|
911
908
|
}
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
909
|
+
class We {
|
|
910
|
+
constructor(t, r) {
|
|
911
|
+
this.createClient = t, this.poolSize = r;
|
|
912
|
+
}
|
|
913
|
+
clients = [];
|
|
914
|
+
currentIndex = 0;
|
|
915
|
+
connect() {
|
|
916
|
+
for (let t = 0; t < this.poolSize; t++)
|
|
917
|
+
this.clients.push(this.createClient(`${t + 1}`));
|
|
918
|
+
}
|
|
919
|
+
get() {
|
|
920
|
+
if (this.clients.length === 0)
|
|
921
|
+
throw new Error("Connection pool is empty. Please call connect() first.");
|
|
922
|
+
const t = this.clients[this.currentIndex];
|
|
923
|
+
if (this.currentIndex = (this.currentIndex + 1) % this.poolSize, !t)
|
|
924
|
+
throw new Error("No available WebSocket client");
|
|
925
|
+
return t;
|
|
926
|
+
}
|
|
927
|
+
disconnect() {
|
|
928
|
+
this.clients.forEach((t) => t.dispose()), this.clients = [];
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
const ze = (e, t, r) => r((n, s, i) => {
|
|
932
|
+
i && console.warn("options are not supported yet");
|
|
933
|
+
const o = n.loc?.source.body;
|
|
934
|
+
if (!o)
|
|
916
935
|
throw new Error("No query provided");
|
|
917
|
-
if (
|
|
936
|
+
if (s && typeof s != "object")
|
|
918
937
|
throw new Error("Variables must be an object");
|
|
919
|
-
const
|
|
920
|
-
if (!
|
|
938
|
+
const h = n.definitions.find((d) => d.kind === "OperationDefinition");
|
|
939
|
+
if (!h)
|
|
921
940
|
throw new Error("No operation definition found");
|
|
922
|
-
const
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
}
|
|
938
|
-
}
|
|
939
|
-
);
|
|
940
|
-
}) : new Re((P) => y.subscribe({ query: i, variables: n }, P));
|
|
941
|
+
const b = h.operation, A = () => {
|
|
942
|
+
const d = e();
|
|
943
|
+
return new Re((v) => d.subscribe({ query: o, variables: s }, v));
|
|
944
|
+
}, w = {
|
|
945
|
+
kind: b,
|
|
946
|
+
operationName: h.name?.value ?? "",
|
|
947
|
+
query: o,
|
|
948
|
+
variables: s || {}
|
|
949
|
+
}, E = (d, v) => {
|
|
950
|
+
if (v >= d.length)
|
|
951
|
+
return A();
|
|
952
|
+
const m = d[v];
|
|
953
|
+
return m?.onRequest ? m.onRequest(w, () => E(d, v + 1)) : E(d, v + 1);
|
|
954
|
+
}, l = E(t, 0);
|
|
955
|
+
return b !== "subscription" ? je(l) : l;
|
|
941
956
|
});
|
|
942
|
-
class
|
|
957
|
+
class Be {
|
|
943
958
|
_pool;
|
|
944
959
|
_sdk;
|
|
945
960
|
constructor(t, r) {
|
|
946
|
-
const { url: n, project:
|
|
947
|
-
this._pool = new
|
|
948
|
-
(
|
|
949
|
-
const
|
|
950
|
-
return
|
|
951
|
-
url:
|
|
961
|
+
const { url: n, project: s, token: i, client: o, pooling: h } = r, b = `${n}/graphql/projects/${s}`.replace(/^http/i, "ws");
|
|
962
|
+
this._pool = new We(
|
|
963
|
+
(A) => {
|
|
964
|
+
const w = Object.freeze({ connectionId: A, websocketUrl: b });
|
|
965
|
+
return we({
|
|
966
|
+
url: b,
|
|
952
967
|
connectionParams: { authorization: `Bearer ${i}` },
|
|
953
968
|
lazy: !1,
|
|
954
969
|
keepAlive: 3e4,
|
|
955
970
|
retryAttempts: o?.retryAttempts ?? 3,
|
|
956
971
|
shouldRetry: () => !0,
|
|
957
|
-
|
|
972
|
+
jsonMessageReplacer: (E, l) => {
|
|
973
|
+
if (!E) {
|
|
974
|
+
let d = l;
|
|
975
|
+
for (const v of r.middlewares ?? [])
|
|
976
|
+
v.onOutgoingMessage && (d = v.onOutgoingMessage(d));
|
|
977
|
+
return d;
|
|
978
|
+
}
|
|
979
|
+
return l;
|
|
980
|
+
},
|
|
981
|
+
...o?.onError ? { onNonLazyError: (E) => o.onError(w, E) } : {},
|
|
958
982
|
on: {
|
|
959
|
-
...o?.onError ? { error: (
|
|
960
|
-
...o?.onConnected ? { connected: () => o.onConnected(
|
|
961
|
-
...o?.onClosed ? { closed: () => o.onClosed(
|
|
962
|
-
...o?.onConnecting ? { connecting: () => o.onConnecting(
|
|
963
|
-
...o?.onOpened ? { opened: () => o.onOpened(
|
|
964
|
-
...o?.onMessage ? { message: (
|
|
965
|
-
...o?.onPing ? { ping: () => o.onPing(
|
|
966
|
-
...o?.onPong ? { pong: () => o.onPong(
|
|
983
|
+
...o?.onError ? { error: (E) => o.onError(w, E) } : {},
|
|
984
|
+
...o?.onConnected ? { connected: () => o.onConnected(w) } : {},
|
|
985
|
+
...o?.onClosed ? { closed: () => o.onClosed(w) } : {},
|
|
986
|
+
...o?.onConnecting ? { connecting: () => o.onConnecting(w) } : {},
|
|
987
|
+
...o?.onOpened ? { opened: () => o.onOpened(w) } : {},
|
|
988
|
+
...o?.onMessage ? { message: (E) => o.onMessage(w, E) } : {},
|
|
989
|
+
...o?.onPing ? { ping: () => o.onPing(w) } : {},
|
|
990
|
+
...o?.onPong ? { pong: () => o.onPong(w) } : {}
|
|
967
991
|
}
|
|
968
992
|
});
|
|
969
993
|
},
|
|
970
994
|
h?.enabled === !1 ? 1 : h?.size ?? 5
|
|
971
|
-
), this._sdk = { sdk:
|
|
995
|
+
), this._sdk = { sdk: ze(() => this._pool.get(), r.middlewares ?? [], t) };
|
|
972
996
|
}
|
|
973
997
|
get sdk() {
|
|
974
998
|
return this._sdk.sdk;
|
|
975
999
|
}
|
|
976
|
-
connect() {
|
|
1000
|
+
async connect() {
|
|
977
1001
|
this._pool.connect();
|
|
978
1002
|
}
|
|
979
|
-
disconnect() {
|
|
1003
|
+
async disconnect() {
|
|
980
1004
|
this._pool.disconnect();
|
|
981
1005
|
}
|
|
982
1006
|
}
|
|
983
1007
|
export {
|
|
984
|
-
|
|
1008
|
+
Be as ContelloSdkClient
|
|
985
1009
|
};
|