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