@contello/sdk-client 8.20.0 → 8.20.1-next.1763378120
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.js +85 -85
- package/dist/index.umd.cjs +2 -2
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
function
|
|
1
|
+
function k(e) {
|
|
2
2
|
return e === null ? "null" : Array.isArray(e) ? "array" : typeof e;
|
|
3
3
|
}
|
|
4
4
|
function R(e) {
|
|
5
|
-
return
|
|
5
|
+
return k(e) === "object";
|
|
6
6
|
}
|
|
7
7
|
function be(e) {
|
|
8
8
|
return Array.isArray(e) && // must be at least one error
|
|
@@ -17,13 +17,13 @@ var _ = /* @__PURE__ */ ((e) => (e[e.InternalServerError = 4500] = "InternalServ
|
|
|
17
17
|
function ue(e) {
|
|
18
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 ${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
|
);
|
|
@@ -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
|
);
|
|
@@ -51,31 +51,31 @@ function ue(e) {
|
|
|
51
51
|
);
|
|
52
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 ${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
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 ${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
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 ${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
|
);
|
|
@@ -94,7 +94,7 @@ function ue(e) {
|
|
|
94
94
|
);
|
|
95
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 ${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
|
);
|
|
@@ -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
|
);
|
|
@@ -168,7 +168,7 @@ function we(e) {
|
|
|
168
168
|
},
|
|
169
169
|
shouldRetry: E = G,
|
|
170
170
|
on: l,
|
|
171
|
-
webSocketImpl:
|
|
171
|
+
webSocketImpl: y,
|
|
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: P = function() {
|
|
180
180
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (f) => {
|
|
181
181
|
const c = Math.random() * 16 | 0;
|
|
182
182
|
return (f == "x" ? c : c & 3 | 8).toString(16);
|
|
183
183
|
});
|
|
184
184
|
},
|
|
185
185
|
jsonMessageReplacer: m,
|
|
186
|
-
jsonMessageReviver:
|
|
186
|
+
jsonMessageReviver: de
|
|
187
187
|
} = e;
|
|
188
188
|
let N;
|
|
189
|
-
if (
|
|
190
|
-
if (!xe(
|
|
189
|
+
if (y) {
|
|
190
|
+
if (!xe(y))
|
|
191
191
|
throw new Error("Invalid WebSocket implementation provided");
|
|
192
|
-
N =
|
|
192
|
+
N = y;
|
|
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);
|
|
@@ -201,8 +201,8 @@ function we(e) {
|
|
|
201
201
|
const a = /* @__PURE__ */ (() => {
|
|
202
202
|
const c = {};
|
|
203
203
|
return {
|
|
204
|
-
on(u,
|
|
205
|
-
return c[u] =
|
|
204
|
+
on(u, d) {
|
|
205
|
+
return c[u] = d, () => {
|
|
206
206
|
delete c[u];
|
|
207
207
|
};
|
|
208
208
|
},
|
|
@@ -223,14 +223,14 @@ function we(e) {
|
|
|
223
223
|
return {
|
|
224
224
|
onMessage: a.on,
|
|
225
225
|
on(c, u) {
|
|
226
|
-
const
|
|
227
|
-
return
|
|
228
|
-
|
|
226
|
+
const d = f[c];
|
|
227
|
+
return d.push(u), () => {
|
|
228
|
+
d.splice(d.indexOf(u), 1);
|
|
229
229
|
};
|
|
230
230
|
},
|
|
231
231
|
emit(c, ...u) {
|
|
232
|
-
for (const
|
|
233
|
-
|
|
232
|
+
for (const d of [...f[c]])
|
|
233
|
+
d(...u);
|
|
234
234
|
}
|
|
235
235
|
};
|
|
236
236
|
})();
|
|
@@ -250,10 +250,10 @@ function we(e) {
|
|
|
250
250
|
async function Z() {
|
|
251
251
|
clearTimeout(K);
|
|
252
252
|
const [a, f] = await ($ ?? ($ = new Promise(
|
|
253
|
-
(
|
|
253
|
+
(d, v) => (async () => {
|
|
254
254
|
if (W) {
|
|
255
255
|
if (await w(B), !I)
|
|
256
|
-
return $ = void 0,
|
|
256
|
+
return $ = void 0, v({ code: 1e3, reason: "All Subscriptions Gone" });
|
|
257
257
|
B++;
|
|
258
258
|
}
|
|
259
259
|
x.emit("connecting", W);
|
|
@@ -268,7 +268,7 @@ function we(e) {
|
|
|
268
268
|
}, o));
|
|
269
269
|
}
|
|
270
270
|
H((S) => {
|
|
271
|
-
$ = void 0, clearTimeout(M), clearTimeout(z),
|
|
271
|
+
$ = void 0, clearTimeout(M), clearTimeout(z), v(S), S instanceof ne && (p.close(4499, "Terminated"), p.onerror = null, p.onclose = null);
|
|
272
272
|
}), p.onerror = (S) => x.emit("error", S), p.onclose = (S) => x.emit("closed", S), p.onopen = async () => {
|
|
273
273
|
try {
|
|
274
274
|
x.emit("opened", p);
|
|
@@ -304,7 +304,7 @@ function we(e) {
|
|
|
304
304
|
let j = !1;
|
|
305
305
|
p.onmessage = ({ data: S }) => {
|
|
306
306
|
try {
|
|
307
|
-
const g = ge(S,
|
|
307
|
+
const g = ge(S, de);
|
|
308
308
|
if (x.emit("message", g), g.type === "ping" || g.type === "pong") {
|
|
309
309
|
x.emit(g.type, !0, g.payload), g.type === "pong" ? U() : h || (p.send(
|
|
310
310
|
F(
|
|
@@ -324,7 +324,7 @@ function we(e) {
|
|
|
324
324
|
throw new Error(
|
|
325
325
|
`First message cannot be of type ${g.type}`
|
|
326
326
|
);
|
|
327
|
-
clearTimeout(M), j = !0, x.emit("connected", p, g.payload, W), W = !1, B = 0,
|
|
327
|
+
clearTimeout(M), j = !0, x.emit("connected", p, g.payload, W), W = !1, B = 0, d([
|
|
328
328
|
p,
|
|
329
329
|
new Promise((Fe, he) => H(he))
|
|
330
330
|
]);
|
|
@@ -343,7 +343,7 @@ function we(e) {
|
|
|
343
343
|
a.readyState === q.CLOSING && await f;
|
|
344
344
|
let c = () => {
|
|
345
345
|
};
|
|
346
|
-
const u = new Promise((
|
|
346
|
+
const u = new Promise((d) => c = d);
|
|
347
347
|
return [
|
|
348
348
|
a,
|
|
349
349
|
c,
|
|
@@ -351,10 +351,10 @@ function we(e) {
|
|
|
351
351
|
// wait for
|
|
352
352
|
u.then(() => {
|
|
353
353
|
if (!I) {
|
|
354
|
-
const
|
|
354
|
+
const d = () => a.close(1e3, "Normal Closure");
|
|
355
355
|
isFinite(i) && i > 0 ? K = setTimeout(() => {
|
|
356
|
-
a.readyState === q.OPEN &&
|
|
357
|
-
}, i) :
|
|
356
|
+
a.readyState === q.OPEN && d();
|
|
357
|
+
}, i) : d();
|
|
358
358
|
}
|
|
359
359
|
}),
|
|
360
360
|
// or
|
|
@@ -398,8 +398,8 @@ function we(e) {
|
|
|
398
398
|
}
|
|
399
399
|
})();
|
|
400
400
|
function te(a, f) {
|
|
401
|
-
const c =
|
|
402
|
-
let u = !1,
|
|
401
|
+
const c = P(a);
|
|
402
|
+
let u = !1, d = !1, v = () => {
|
|
403
403
|
I--, u = !0;
|
|
404
404
|
};
|
|
405
405
|
return (async () => {
|
|
@@ -414,11 +414,11 @@ function we(e) {
|
|
|
414
414
|
return;
|
|
415
415
|
}
|
|
416
416
|
case O.Error: {
|
|
417
|
-
|
|
417
|
+
d = !0, u = !0, f.error(j.payload), v();
|
|
418
418
|
return;
|
|
419
419
|
}
|
|
420
420
|
case O.Complete: {
|
|
421
|
-
u = !0,
|
|
421
|
+
u = !0, v();
|
|
422
422
|
return;
|
|
423
423
|
}
|
|
424
424
|
}
|
|
@@ -432,7 +432,7 @@ function we(e) {
|
|
|
432
432
|
},
|
|
433
433
|
m
|
|
434
434
|
)
|
|
435
|
-
),
|
|
435
|
+
), v = () => {
|
|
436
436
|
!u && p.readyState === q.OPEN && p.send(
|
|
437
437
|
F(
|
|
438
438
|
{
|
|
@@ -448,11 +448,11 @@ function we(e) {
|
|
|
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 || v();
|
|
456
456
|
};
|
|
457
457
|
}
|
|
458
458
|
return {
|
|
@@ -465,16 +465,16 @@ function we(e) {
|
|
|
465
465
|
resolve: () => {
|
|
466
466
|
}
|
|
467
467
|
}, u = te(a, {
|
|
468
|
-
next(
|
|
469
|
-
f.push(
|
|
468
|
+
next(v) {
|
|
469
|
+
f.push(v), c.resolve();
|
|
470
470
|
},
|
|
471
|
-
error(
|
|
472
|
-
c.done = !0, c.error =
|
|
471
|
+
error(v) {
|
|
472
|
+
c.done = !0, c.error = v, c.resolve();
|
|
473
473
|
},
|
|
474
474
|
complete() {
|
|
475
475
|
c.done = !0, c.resolve();
|
|
476
476
|
}
|
|
477
|
-
}),
|
|
477
|
+
}), d = (async function* () {
|
|
478
478
|
for (; ; ) {
|
|
479
479
|
for (f.length || await new Promise((p) => c.resolve = p); f.length; )
|
|
480
480
|
yield f.shift();
|
|
@@ -483,8 +483,8 @@ function we(e) {
|
|
|
483
483
|
if (c.done)
|
|
484
484
|
return;
|
|
485
485
|
}
|
|
486
|
-
}();
|
|
487
|
-
return
|
|
486
|
+
})();
|
|
487
|
+
return d.throw = async (v) => (c.done || (c.done = !0, c.error = v, c.resolve()), { done: !0, value: void 0 }), d.return = async () => (u(), { done: !0, value: void 0 }), d;
|
|
488
488
|
},
|
|
489
489
|
async dispose() {
|
|
490
490
|
if (X = !0, $) {
|
|
@@ -600,7 +600,7 @@ function ie(e, t) {
|
|
|
600
600
|
0 <= r && e.splice(r, 1);
|
|
601
601
|
}
|
|
602
602
|
}
|
|
603
|
-
var Y = function() {
|
|
603
|
+
var Y = (function() {
|
|
604
604
|
function e(t) {
|
|
605
605
|
this.initialTeardown = t, this.closed = !1, this._parentage = null, this._finalizers = null;
|
|
606
606
|
}
|
|
@@ -638,10 +638,10 @@ var Y = function() {
|
|
|
638
638
|
if (E) {
|
|
639
639
|
this._finalizers = null;
|
|
640
640
|
try {
|
|
641
|
-
for (var l = oe(E),
|
|
642
|
-
var
|
|
641
|
+
for (var l = oe(E), y = l.next(); !y.done; y = l.next()) {
|
|
642
|
+
var P = y.value;
|
|
643
643
|
try {
|
|
644
|
-
se(
|
|
644
|
+
se(P);
|
|
645
645
|
} catch (m) {
|
|
646
646
|
i = i ?? [], m instanceof D ? i = V(V([], Q(i)), Q(m.errors)) : i.push(m);
|
|
647
647
|
}
|
|
@@ -650,7 +650,7 @@ var Y = function() {
|
|
|
650
650
|
n = { error: m };
|
|
651
651
|
} finally {
|
|
652
652
|
try {
|
|
653
|
-
|
|
653
|
+
y && !y.done && (s = l.return) && s.call(l);
|
|
654
654
|
} finally {
|
|
655
655
|
if (n) throw n.error;
|
|
656
656
|
}
|
|
@@ -684,11 +684,11 @@ var Y = function() {
|
|
|
684
684
|
}, e.prototype.remove = function(t) {
|
|
685
685
|
var r = this._finalizers;
|
|
686
686
|
r && ie(r, t), t instanceof e && t._removeParent(this);
|
|
687
|
-
}, e.EMPTY = function() {
|
|
687
|
+
}, e.EMPTY = (function() {
|
|
688
688
|
var t = new e();
|
|
689
689
|
return t.closed = !0, t;
|
|
690
|
-
}(), e;
|
|
691
|
-
}();
|
|
690
|
+
})(), e;
|
|
691
|
+
})();
|
|
692
692
|
Y.EMPTY;
|
|
693
693
|
function fe(e) {
|
|
694
694
|
return e instanceof Y || e && "closed" in e && T(e.remove) && T(e.add) && T(e.unsubscribe);
|
|
@@ -698,7 +698,7 @@ function se(e) {
|
|
|
698
698
|
}
|
|
699
699
|
var Se = {
|
|
700
700
|
Promise: void 0
|
|
701
|
-
},
|
|
701
|
+
}, ve = {
|
|
702
702
|
setTimeout: function(e, t) {
|
|
703
703
|
for (var r = [], n = 2; n < arguments.length; n++)
|
|
704
704
|
r[n - 2] = arguments[n];
|
|
@@ -709,17 +709,17 @@ var Se = {
|
|
|
709
709
|
},
|
|
710
710
|
delegate: void 0
|
|
711
711
|
};
|
|
712
|
-
function
|
|
713
|
-
|
|
712
|
+
function ke(e) {
|
|
713
|
+
ve.setTimeout(function() {
|
|
714
714
|
throw e;
|
|
715
715
|
});
|
|
716
716
|
}
|
|
717
717
|
function ce() {
|
|
718
718
|
}
|
|
719
|
-
function
|
|
719
|
+
function Pe(e) {
|
|
720
720
|
e();
|
|
721
721
|
}
|
|
722
|
-
var
|
|
722
|
+
var ye = (function(e) {
|
|
723
723
|
pe(t, e);
|
|
724
724
|
function t(r) {
|
|
725
725
|
var n = e.call(this) || this;
|
|
@@ -750,7 +750,7 @@ var de = function(e) {
|
|
|
750
750
|
this.unsubscribe();
|
|
751
751
|
}
|
|
752
752
|
}, t;
|
|
753
|
-
}(Y), _e = function() {
|
|
753
|
+
})(Y), _e = (function() {
|
|
754
754
|
function e(t) {
|
|
755
755
|
this.partialObserver = t;
|
|
756
756
|
}
|
|
@@ -781,7 +781,7 @@ var de = function(e) {
|
|
|
781
781
|
L(r);
|
|
782
782
|
}
|
|
783
783
|
}, e;
|
|
784
|
-
}(), C = function(e) {
|
|
784
|
+
})(), C = (function(e) {
|
|
785
785
|
pe(t, e);
|
|
786
786
|
function t(r, n, s) {
|
|
787
787
|
var i = e.call(this) || this, o;
|
|
@@ -792,9 +792,9 @@ var de = function(e) {
|
|
|
792
792
|
} : o = r, i.destination = new _e(o), i;
|
|
793
793
|
}
|
|
794
794
|
return t;
|
|
795
|
-
}(
|
|
795
|
+
})(ye);
|
|
796
796
|
function L(e) {
|
|
797
|
-
|
|
797
|
+
ke(e);
|
|
798
798
|
}
|
|
799
799
|
function Oe(e) {
|
|
800
800
|
throw e;
|
|
@@ -804,9 +804,9 @@ var Te = {
|
|
|
804
804
|
next: ce,
|
|
805
805
|
error: Oe,
|
|
806
806
|
complete: ce
|
|
807
|
-
}, Ae = function() {
|
|
807
|
+
}, Ae = (function() {
|
|
808
808
|
return typeof Symbol == "function" && Symbol.observable || "@@observable";
|
|
809
|
-
}();
|
|
809
|
+
})();
|
|
810
810
|
function $e(e) {
|
|
811
811
|
return e;
|
|
812
812
|
}
|
|
@@ -817,7 +817,7 @@ function Ie(e) {
|
|
|
817
817
|
}, r);
|
|
818
818
|
};
|
|
819
819
|
}
|
|
820
|
-
var Re = function() {
|
|
820
|
+
var Re = (function() {
|
|
821
821
|
function e(t) {
|
|
822
822
|
t && (this._subscribe = t);
|
|
823
823
|
}
|
|
@@ -826,7 +826,7 @@ var Re = function() {
|
|
|
826
826
|
return r.source = this, r.operator = t, r;
|
|
827
827
|
}, e.prototype.subscribe = function(t, r, n) {
|
|
828
828
|
var s = this, i = qe(t) ? t : new C(t, r, n);
|
|
829
|
-
return
|
|
829
|
+
return Pe(function() {
|
|
830
830
|
var o = s, h = o.operator, b = o.source;
|
|
831
831
|
i.add(h ? h.call(i, b) : b ? s._subscribe(i) : s._trySubscribe(i));
|
|
832
832
|
}), i;
|
|
@@ -876,7 +876,7 @@ var Re = function() {
|
|
|
876
876
|
}, e.create = function(t) {
|
|
877
877
|
return new e(t);
|
|
878
878
|
}, e;
|
|
879
|
-
}();
|
|
879
|
+
})();
|
|
880
880
|
function ae(e) {
|
|
881
881
|
var t;
|
|
882
882
|
return (t = e ?? Se.Promise) !== null && t !== void 0 ? t : Promise;
|
|
@@ -885,7 +885,7 @@ function Ne(e) {
|
|
|
885
885
|
return e && T(e.next) && T(e.error) && T(e.complete);
|
|
886
886
|
}
|
|
887
887
|
function qe(e) {
|
|
888
|
-
return e && e instanceof
|
|
888
|
+
return e && e instanceof ye || Ne(e) && fe(e);
|
|
889
889
|
}
|
|
890
890
|
var Me = le(function(e) {
|
|
891
891
|
return function() {
|
|
@@ -935,22 +935,22 @@ const ze = (e, t, r) => r((n, s, i) => {
|
|
|
935
935
|
throw new Error("No query provided");
|
|
936
936
|
if (s && typeof s != "object")
|
|
937
937
|
throw new Error("Variables must be an object");
|
|
938
|
-
const h = n.definitions.find((
|
|
938
|
+
const h = n.definitions.find((y) => y.kind === "OperationDefinition");
|
|
939
939
|
if (!h)
|
|
940
940
|
throw new Error("No operation definition found");
|
|
941
941
|
const b = h.operation, A = () => {
|
|
942
|
-
const
|
|
943
|
-
return new Re((
|
|
942
|
+
const y = e();
|
|
943
|
+
return new Re((P) => y.subscribe({ query: o, variables: s }, P));
|
|
944
944
|
}, w = {
|
|
945
945
|
kind: b,
|
|
946
946
|
operationName: h.name?.value ?? "",
|
|
947
947
|
query: o,
|
|
948
948
|
variables: s || {}
|
|
949
|
-
}, E = (
|
|
950
|
-
if (
|
|
949
|
+
}, E = (y, P) => {
|
|
950
|
+
if (P >= y.length)
|
|
951
951
|
return A();
|
|
952
|
-
const m =
|
|
953
|
-
return m?.onRequest ? m.onRequest(w, () => E(
|
|
952
|
+
const m = y[P];
|
|
953
|
+
return m?.onRequest ? m.onRequest(w, () => E(y, P + 1)) : E(y, P + 1);
|
|
954
954
|
}, l = E(t, 0);
|
|
955
955
|
return b !== "subscription" ? je(l) : l;
|
|
956
956
|
});
|
|
@@ -971,10 +971,10 @@ class Be {
|
|
|
971
971
|
shouldRetry: () => !0,
|
|
972
972
|
jsonMessageReplacer: (E, l) => {
|
|
973
973
|
if (!E) {
|
|
974
|
-
let
|
|
975
|
-
for (const
|
|
976
|
-
|
|
977
|
-
return
|
|
974
|
+
let y = l;
|
|
975
|
+
for (const P of r.middlewares ?? [])
|
|
976
|
+
P.onOutgoingMessage && (y = P.onOutgoingMessage(y));
|
|
977
|
+
return y;
|
|
978
978
|
}
|
|
979
979
|
return l;
|
|
980
980
|
},
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(N,m){typeof exports=="object"&&typeof module<"u"?m(exports):typeof define=="function"&&define.amd?define(["exports"],m):(N=typeof globalThis<"u"?globalThis:N||self,m(N.ContelloSdkClient={}))})(this,function(N){"use strict";function m(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function $(e){return m(e)==="object"}function he(e){return Array.isArray(e)&&e.length>0&&e.every(t=>"message"in t)}function K(e,t){return e.length<124?e:t}const be="graphql-transport-ws";var T=(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))(T||{}),O=(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||{});function X(e){if(!$(e))throw new Error(`Message is expected to be an object, but got ${m(e)}`);if(!e.type)throw new Error("Message is missing the 'type' property");if(typeof e.type!="string")throw new Error(`Message is expects the 'type' property to be a string, but got ${m(e.type)}`);switch(e.type){case"connection_init":case"connection_ack":case"ping":case"pong":{if(e.payload!=null&&!$(e.payload))throw new Error(`"${e.type}" message expects the 'payload' property to be an object or nullish or missing, but got "${e.payload}"`);break}case"subscribe":{if(typeof e.id!="string")throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${m(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);if(!$(e.payload))throw new Error(`"${e.type}" message expects the 'payload' property to be an object, but got ${m(e.payload)}`);if(typeof e.payload.query!="string")throw new Error(`"${e.type}" message payload expects the 'query' property to be a string, but got ${m(e.payload.query)}`);if(e.payload.variables!=null&&!$(e.payload.variables))throw new Error(`"${e.type}" message payload expects the 'variables' property to be a an object or nullish or missing, but got ${m(e.payload.variables)}`);if(e.payload.operationName!=null&&m(e.payload.operationName)!=="string")throw new Error(`"${e.type}" message payload expects the 'operationName' property to be a string or nullish or missing, but got ${m(e.payload.operationName)}`);if(e.payload.extensions!=null&&!$(e.payload.extensions))throw new Error(`"${e.type}" message payload expects the 'extensions' property to be a an object or nullish or missing, but got ${m(e.payload.extensions)}`);break}case"next":{if(typeof e.id!="string")throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${m(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);if(!$(e.payload))throw new Error(`"${e.type}" message expects the 'payload' property to be an object, but got ${m(e.payload)}`);break}case"error":{if(typeof e.id!="string")throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${m(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);if(!he(e.payload))throw new Error(`"${e.type}" message expects the 'payload' property to be an array of GraphQL errors, but got ${JSON.stringify(e.payload)}`);break}case"complete":{if(typeof e.id!="string")throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${m(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);break}default:throw new Error(`Invalid message 'type' property "${e.type}"`)}return e}function me(e,t){return X(typeof e=="string"?JSON.parse(e,t):e)}function z(e,t){return X(e),JSON.stringify(e,t)}function ge(e){const{url:t,connectionParams:r,lazy:n=!0,onNonLazyError:s=console.error,lazyCloseTimeout:i=0,keepAlive:o=0,disablePong:h,connectionAckWaitTimeout:b=0,retryAttempts:A=5,retryWait:E=async function(f){const c=Math.pow(2,f);await new Promise(u=>setTimeout(u,c*1e3+Math.floor(Math.random()*2700+300)))},shouldRetry:S=D,on:l,webSocketImpl:d,generateID:v=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,f=>{const c=Math.random()*16|0;return(f=="x"?c:c&3|8).toString(16)})},jsonMessageReplacer:g,jsonMessageReviver:Ce}=e;let q;if(d){if(!Ee(d))throw new Error("Invalid WebSocket implementation provided");q=d}else typeof WebSocket<"u"?q=WebSocket:typeof global<"u"?q=global.WebSocket||global.MozWebSocket:typeof window<"u"&&(q=window.WebSocket||window.MozWebSocket);if(!q)throw new Error("WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`");const M=q,x=(()=>{const a=(()=>{const c={};return{on(u,y){return c[u]=y,()=>{delete c[u]}},emit(u){"id"in u&&c[u.id]?.(u)}}})(),f={connecting:l?.connecting?[l.connecting]:[],opened:l?.opened?[l.opened]:[],connected:l?.connected?[l.connected]:[],ping:l?.ping?[l.ping]:[],pong:l?.pong?[l.pong]:[],message:l?.message?[a.emit,l.message]:[a.emit],closed:l?.closed?[l.closed]:[],error:l?.error?[l.error]:[]};return{onMessage:a.on,on(c,u){const y=f[c];return y.push(u),()=>{y.splice(y.indexOf(u),1)}},emit(c,...u){for(const y of[...f[c]])y(...u)}}})();function ue(a){const f=[x.on("error",c=>{f.forEach(u=>u()),a(c)}),x.on("closed",c=>{f.forEach(u=>u()),a(c)})]}let I,R=0,pe,C=!1,L=0,le=!1;async function fe(){clearTimeout(pe);const[a,f]=await(I??(I=new Promise((y,P)=>(async()=>{if(C){if(await E(L),!R)return I=void 0,P({code:1e3,reason:"All Subscriptions Gone"});L++}x.emit("connecting",C);const p=new M(typeof t=="function"?await t():t,be);let j,F;function G(){isFinite(o)&&o>0&&(clearTimeout(F),F=setTimeout(()=>{p.readyState===M.OPEN&&(p.send(z({type:O.Ping})),x.emit("ping",!1,void 0))},o))}ue(k=>{I=void 0,clearTimeout(j),clearTimeout(F),P(k),k instanceof Z&&(p.close(4499,"Terminated"),p.onerror=null,p.onclose=null)}),p.onerror=k=>x.emit("error",k),p.onclose=k=>x.emit("closed",k),p.onopen=async()=>{try{x.emit("opened",p);const k=typeof r=="function"?await r():r;if(p.readyState!==M.OPEN)return;p.send(z(k?{type:O.ConnectionInit,payload:k}:{type:O.ConnectionInit},g)),isFinite(b)&&b>0&&(j=setTimeout(()=>{p.close(T.ConnectionAcknowledgementTimeout,"Connection acknowledgement timeout")},b)),G()}catch(k){x.emit("error",k),p.close(T.InternalClientError,K(k instanceof Error?k.message:String(k),"Internal client error"))}};let W=!1;p.onmessage=({data:k})=>{try{const w=me(k,Ce);if(x.emit("message",w),w.type==="ping"||w.type==="pong"){x.emit(w.type,!0,w.payload),w.type==="pong"?G():h||(p.send(z(w.payload?{type:O.Pong,payload:w.payload}:{type:O.Pong})),x.emit("pong",!1,w.payload));return}if(W)return;if(w.type!==O.ConnectionAck)throw new Error(`First message cannot be of type ${w.type}`);clearTimeout(j),W=!0,x.emit("connected",p,w.payload,C),C=!1,L=0,y([p,new Promise((Be,Fe)=>ue(Fe))])}catch(w){p.onmessage=null,x.emit("error",w),p.close(T.BadResponse,K(w instanceof Error?w.message:String(w),"Bad response"))}}})())));a.readyState===M.CLOSING&&await f;let c=()=>{};const u=new Promise(y=>c=y);return[a,c,Promise.race([u.then(()=>{if(!R){const y=()=>a.close(1e3,"Normal Closure");isFinite(i)&&i>0?pe=setTimeout(()=>{a.readyState===M.OPEN&&y()},i):y()}}),f])]}function de(a){if(D(a)&&(we(a.code)||[T.InternalServerError,T.InternalClientError,T.BadRequest,T.BadResponse,T.Unauthorized,T.SubprotocolNotAcceptable,T.SubscriberAlreadyExists,T.TooManyInitialisationRequests].includes(a.code)))throw a;if(le)return!1;if(D(a)&&a.code===1e3)return R>0;if(!A||L>=A||!S(a))throw a;return C=!0}n||(async()=>{for(R++;;)try{const[,,a]=await fe();await a}catch(a){try{if(!de(a))return}catch(f){return s?.(f)}}})();function ye(a,f){const c=v(a);let u=!1,y=!1,P=()=>{R--,u=!0};return(async()=>{for(R++;;)try{const[p,j,F]=await fe();if(u)return j();const G=x.onMessage(c,W=>{switch(W.type){case O.Next:{f.next(W.payload);return}case O.Error:{y=!0,u=!0,f.error(W.payload),P();return}case O.Complete:{u=!0,P();return}}});p.send(z({id:c,type:O.Subscribe,payload:a},g)),P=()=>{!u&&p.readyState===M.OPEN&&p.send(z({id:c,type:O.Complete},g)),R--,u=!0,j()},await F.finally(G);return}catch(p){if(!de(p))return}})().then(()=>{y||f.complete()}).catch(p=>{f.error(p)}),()=>{u||P()}}return{on:x.on,subscribe:ye,iterate(a){const f=[],c={done:!1,error:null,resolve:()=>{}},u=ye(a,{next(P){f.push(P),c.resolve()},error(P){c.done=!0,c.error=P,c.resolve()},complete(){c.done=!0,c.resolve()}}),y=async function*(){for(;;){for(f.length||await new Promise(p=>c.resolve=p);f.length;)yield f.shift();if(c.error)throw c.error;if(c.done)return}}();return y.throw=async P=>(c.done||(c.done=!0,c.error=P,c.resolve()),{done:!0,value:void 0}),y.return=async()=>(u(),{done:!0,value:void 0}),y},async dispose(){if(le=!0,I){const[a]=await I;a.close(1e3,"Normal Closure")}},terminate(){I&&x.emit("closed",new Z)}}}class Z extends Error{name="TerminatedCloseEvent";message="4499: Terminated";code=4499;reason="Terminated";wasClean=!1}function D(e){return $(e)&&"code"in e&&"reason"in e}function we(e){return[1e3,1001,1006,1005,1012,1013,1014].includes(e)?!1:e>=1e3&&e<=1999}function Ee(e){return typeof e=="function"&&"constructor"in e&&"CLOSED"in e&&"CLOSING"in e&&"CONNECTING"in e&&"OPEN"in e}var J=function(e,t){return J=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(r[s]=n[s])},J(e,t)};function ee(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");J(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function te(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Q(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),s,i=[],o;try{for(;(t===void 0||t-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(h){o={error:h}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i}function V(e,t,r){if(r||arguments.length===2)for(var n=0,s=t.length,i;n<s;n++)(i||!(n in t))&&(i||(i=Array.prototype.slice.call(t,0,n)),i[n]=t[n]);return e.concat(i||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;function _(e){return typeof e=="function"}function re(e){var t=function(n){Error.call(n),n.stack=new Error().stack},r=e(t);return r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r}var Y=re(function(e){return function(r){e(this),this.message=r?r.length+` errors occurred during unsubscription:
|
|
1
|
+
(function(N,m){typeof exports=="object"&&typeof module<"u"?m(exports):typeof define=="function"&&define.amd?define(["exports"],m):(N=typeof globalThis<"u"?globalThis:N||self,m(N.ContelloSdkClient={}))})(this,(function(N){"use strict";function m(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function $(e){return m(e)==="object"}function he(e){return Array.isArray(e)&&e.length>0&&e.every(t=>"message"in t)}function K(e,t){return e.length<124?e:t}const be="graphql-transport-ws";var T=(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))(T||{}),O=(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||{});function X(e){if(!$(e))throw new Error(`Message is expected to be an object, but got ${m(e)}`);if(!e.type)throw new Error("Message is missing the 'type' property");if(typeof e.type!="string")throw new Error(`Message is expects the 'type' property to be a string, but got ${m(e.type)}`);switch(e.type){case"connection_init":case"connection_ack":case"ping":case"pong":{if(e.payload!=null&&!$(e.payload))throw new Error(`"${e.type}" message expects the 'payload' property to be an object or nullish or missing, but got "${e.payload}"`);break}case"subscribe":{if(typeof e.id!="string")throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${m(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);if(!$(e.payload))throw new Error(`"${e.type}" message expects the 'payload' property to be an object, but got ${m(e.payload)}`);if(typeof e.payload.query!="string")throw new Error(`"${e.type}" message payload expects the 'query' property to be a string, but got ${m(e.payload.query)}`);if(e.payload.variables!=null&&!$(e.payload.variables))throw new Error(`"${e.type}" message payload expects the 'variables' property to be a an object or nullish or missing, but got ${m(e.payload.variables)}`);if(e.payload.operationName!=null&&m(e.payload.operationName)!=="string")throw new Error(`"${e.type}" message payload expects the 'operationName' property to be a string or nullish or missing, but got ${m(e.payload.operationName)}`);if(e.payload.extensions!=null&&!$(e.payload.extensions))throw new Error(`"${e.type}" message payload expects the 'extensions' property to be a an object or nullish or missing, but got ${m(e.payload.extensions)}`);break}case"next":{if(typeof e.id!="string")throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${m(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);if(!$(e.payload))throw new Error(`"${e.type}" message expects the 'payload' property to be an object, but got ${m(e.payload)}`);break}case"error":{if(typeof e.id!="string")throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${m(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);if(!he(e.payload))throw new Error(`"${e.type}" message expects the 'payload' property to be an array of GraphQL errors, but got ${JSON.stringify(e.payload)}`);break}case"complete":{if(typeof e.id!="string")throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${m(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);break}default:throw new Error(`Invalid message 'type' property "${e.type}"`)}return e}function me(e,t){return X(typeof e=="string"?JSON.parse(e,t):e)}function z(e,t){return X(e),JSON.stringify(e,t)}function ge(e){const{url:t,connectionParams:r,lazy:n=!0,onNonLazyError:s=console.error,lazyCloseTimeout:i=0,keepAlive:o=0,disablePong:h,connectionAckWaitTimeout:b=0,retryAttempts:A=5,retryWait:E=async function(f){const c=Math.pow(2,f);await new Promise(u=>setTimeout(u,c*1e3+Math.floor(Math.random()*2700+300)))},shouldRetry:S=D,on:l,webSocketImpl:d,generateID:P=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,f=>{const c=Math.random()*16|0;return(f=="x"?c:c&3|8).toString(16)})},jsonMessageReplacer:g,jsonMessageReviver:Ce}=e;let q;if(d){if(!Ee(d))throw new Error("Invalid WebSocket implementation provided");q=d}else typeof WebSocket<"u"?q=WebSocket:typeof global<"u"?q=global.WebSocket||global.MozWebSocket:typeof window<"u"&&(q=window.WebSocket||window.MozWebSocket);if(!q)throw new Error("WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`");const M=q,x=(()=>{const a=(()=>{const c={};return{on(u,y){return c[u]=y,()=>{delete c[u]}},emit(u){"id"in u&&c[u.id]?.(u)}}})(),f={connecting:l?.connecting?[l.connecting]:[],opened:l?.opened?[l.opened]:[],connected:l?.connected?[l.connected]:[],ping:l?.ping?[l.ping]:[],pong:l?.pong?[l.pong]:[],message:l?.message?[a.emit,l.message]:[a.emit],closed:l?.closed?[l.closed]:[],error:l?.error?[l.error]:[]};return{onMessage:a.on,on(c,u){const y=f[c];return y.push(u),()=>{y.splice(y.indexOf(u),1)}},emit(c,...u){for(const y of[...f[c]])y(...u)}}})();function ue(a){const f=[x.on("error",c=>{f.forEach(u=>u()),a(c)}),x.on("closed",c=>{f.forEach(u=>u()),a(c)})]}let I,R=0,pe,C=!1,L=0,le=!1;async function fe(){clearTimeout(pe);const[a,f]=await(I??(I=new Promise((y,k)=>(async()=>{if(C){if(await E(L),!R)return I=void 0,k({code:1e3,reason:"All Subscriptions Gone"});L++}x.emit("connecting",C);const p=new M(typeof t=="function"?await t():t,be);let j,F;function G(){isFinite(o)&&o>0&&(clearTimeout(F),F=setTimeout(()=>{p.readyState===M.OPEN&&(p.send(z({type:O.Ping})),x.emit("ping",!1,void 0))},o))}ue(v=>{I=void 0,clearTimeout(j),clearTimeout(F),k(v),v instanceof Z&&(p.close(4499,"Terminated"),p.onerror=null,p.onclose=null)}),p.onerror=v=>x.emit("error",v),p.onclose=v=>x.emit("closed",v),p.onopen=async()=>{try{x.emit("opened",p);const v=typeof r=="function"?await r():r;if(p.readyState!==M.OPEN)return;p.send(z(v?{type:O.ConnectionInit,payload:v}:{type:O.ConnectionInit},g)),isFinite(b)&&b>0&&(j=setTimeout(()=>{p.close(T.ConnectionAcknowledgementTimeout,"Connection acknowledgement timeout")},b)),G()}catch(v){x.emit("error",v),p.close(T.InternalClientError,K(v instanceof Error?v.message:String(v),"Internal client error"))}};let W=!1;p.onmessage=({data:v})=>{try{const w=me(v,Ce);if(x.emit("message",w),w.type==="ping"||w.type==="pong"){x.emit(w.type,!0,w.payload),w.type==="pong"?G():h||(p.send(z(w.payload?{type:O.Pong,payload:w.payload}:{type:O.Pong})),x.emit("pong",!1,w.payload));return}if(W)return;if(w.type!==O.ConnectionAck)throw new Error(`First message cannot be of type ${w.type}`);clearTimeout(j),W=!0,x.emit("connected",p,w.payload,C),C=!1,L=0,y([p,new Promise((Be,Fe)=>ue(Fe))])}catch(w){p.onmessage=null,x.emit("error",w),p.close(T.BadResponse,K(w instanceof Error?w.message:String(w),"Bad response"))}}})())));a.readyState===M.CLOSING&&await f;let c=()=>{};const u=new Promise(y=>c=y);return[a,c,Promise.race([u.then(()=>{if(!R){const y=()=>a.close(1e3,"Normal Closure");isFinite(i)&&i>0?pe=setTimeout(()=>{a.readyState===M.OPEN&&y()},i):y()}}),f])]}function de(a){if(D(a)&&(we(a.code)||[T.InternalServerError,T.InternalClientError,T.BadRequest,T.BadResponse,T.Unauthorized,T.SubprotocolNotAcceptable,T.SubscriberAlreadyExists,T.TooManyInitialisationRequests].includes(a.code)))throw a;if(le)return!1;if(D(a)&&a.code===1e3)return R>0;if(!A||L>=A||!S(a))throw a;return C=!0}n||(async()=>{for(R++;;)try{const[,,a]=await fe();await a}catch(a){try{if(!de(a))return}catch(f){return s?.(f)}}})();function ye(a,f){const c=P(a);let u=!1,y=!1,k=()=>{R--,u=!0};return(async()=>{for(R++;;)try{const[p,j,F]=await fe();if(u)return j();const G=x.onMessage(c,W=>{switch(W.type){case O.Next:{f.next(W.payload);return}case O.Error:{y=!0,u=!0,f.error(W.payload),k();return}case O.Complete:{u=!0,k();return}}});p.send(z({id:c,type:O.Subscribe,payload:a},g)),k=()=>{!u&&p.readyState===M.OPEN&&p.send(z({id:c,type:O.Complete},g)),R--,u=!0,j()},await F.finally(G);return}catch(p){if(!de(p))return}})().then(()=>{y||f.complete()}).catch(p=>{f.error(p)}),()=>{u||k()}}return{on:x.on,subscribe:ye,iterate(a){const f=[],c={done:!1,error:null,resolve:()=>{}},u=ye(a,{next(k){f.push(k),c.resolve()},error(k){c.done=!0,c.error=k,c.resolve()},complete(){c.done=!0,c.resolve()}}),y=(async function*(){for(;;){for(f.length||await new Promise(p=>c.resolve=p);f.length;)yield f.shift();if(c.error)throw c.error;if(c.done)return}})();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},async dispose(){if(le=!0,I){const[a]=await I;a.close(1e3,"Normal Closure")}},terminate(){I&&x.emit("closed",new Z)}}}class Z extends Error{name="TerminatedCloseEvent";message="4499: Terminated";code=4499;reason="Terminated";wasClean=!1}function D(e){return $(e)&&"code"in e&&"reason"in e}function we(e){return[1e3,1001,1006,1005,1012,1013,1014].includes(e)?!1:e>=1e3&&e<=1999}function Ee(e){return typeof e=="function"&&"constructor"in e&&"CLOSED"in e&&"CLOSING"in e&&"CONNECTING"in e&&"OPEN"in e}var J=function(e,t){return J=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(r[s]=n[s])},J(e,t)};function ee(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");J(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function te(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Q(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),s,i=[],o;try{for(;(t===void 0||t-- >0)&&!(s=n.next()).done;)i.push(s.value)}catch(h){o={error:h}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return i}function V(e,t,r){if(r||arguments.length===2)for(var n=0,s=t.length,i;n<s;n++)(i||!(n in t))&&(i||(i=Array.prototype.slice.call(t,0,n)),i[n]=t[n]);return e.concat(i||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;function _(e){return typeof e=="function"}function re(e){var t=function(n){Error.call(n),n.stack=new Error().stack},r=e(t);return r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r}var Y=re(function(e){return function(r){e(this),this.message=r?r.length+` errors occurred during unsubscription:
|
|
2
2
|
`+r.map(function(n,s){return s+1+") "+n.toString()}).join(`
|
|
3
|
-
`):"",this.name="UnsubscriptionError",this.errors=r}});function ne(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var H=function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,r,n,s,i;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var h=te(o),b=h.next();!b.done;b=h.next()){var A=b.value;A.remove(this)}}catch(g){t={error:g}}finally{try{b&&!b.done&&(r=h.return)&&r.call(h)}finally{if(t)throw t.error}}else o.remove(this);var E=this.initialTeardown;if(_(E))try{E()}catch(g){i=g instanceof Y?g.errors:[g]}var S=this._finalizers;if(S){this._finalizers=null;try{for(var l=te(S),d=l.next();!d.done;d=l.next()){var
|
|
3
|
+
`):"",this.name="UnsubscriptionError",this.errors=r}});function ne(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var H=(function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,r,n,s,i;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var h=te(o),b=h.next();!b.done;b=h.next()){var A=b.value;A.remove(this)}}catch(g){t={error:g}}finally{try{b&&!b.done&&(r=h.return)&&r.call(h)}finally{if(t)throw t.error}}else o.remove(this);var E=this.initialTeardown;if(_(E))try{E()}catch(g){i=g instanceof Y?g.errors:[g]}var S=this._finalizers;if(S){this._finalizers=null;try{for(var l=te(S),d=l.next();!d.done;d=l.next()){var P=d.value;try{ie(P)}catch(g){i=i??[],g instanceof Y?i=V(V([],Q(i)),Q(g.errors)):i.push(g)}}}catch(g){n={error:g}}finally{try{d&&!d.done&&(s=l.return)&&s.call(l)}finally{if(n)throw n.error}}}if(i)throw new Y(i)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)ie(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(r=this._finalizers)!==null&&r!==void 0?r:[]).push(t)}},e.prototype._hasParent=function(t){var r=this._parentage;return r===t||Array.isArray(r)&&r.includes(t)},e.prototype._addParent=function(t){var r=this._parentage;this._parentage=Array.isArray(r)?(r.push(t),r):r?[r,t]:t},e.prototype._removeParent=function(t){var r=this._parentage;r===t?this._parentage=null:Array.isArray(r)&&ne(r,t)},e.prototype.remove=function(t){var r=this._finalizers;r&&ne(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=(function(){var t=new e;return t.closed=!0,t})(),e})();H.EMPTY;function oe(e){return e instanceof H||e&&"closed"in e&&_(e.remove)&&_(e.add)&&_(e.unsubscribe)}function ie(e){_(e)?e():e.unsubscribe()}var Se={Promise:void 0},xe={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,V([e,t],Q(r)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function ve(e){xe.setTimeout(function(){throw e})}function se(){}function ke(e){e()}var ce=(function(e){ee(t,e);function t(r){var n=e.call(this)||this;return n.isStopped=!1,r?(n.destination=r,oe(r)&&r.add(n)):n.destination=Oe,n}return t.create=function(r,n,s){return new B(r,n,s)},t.prototype.next=function(r){this.isStopped||this._next(r)},t.prototype.error=function(r){this.isStopped||(this.isStopped=!0,this._error(r))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(r){this.destination.next(r)},t.prototype._error=function(r){try{this.destination.error(r)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t})(H),Pe=(function(){function e(t){this.partialObserver=t}return e.prototype.next=function(t){var r=this.partialObserver;if(r.next)try{r.next(t)}catch(n){U(n)}},e.prototype.error=function(t){var r=this.partialObserver;if(r.error)try{r.error(t)}catch(n){U(n)}else U(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(r){U(r)}},e})(),B=(function(e){ee(t,e);function t(r,n,s){var i=e.call(this)||this,o;return _(r)||!r?o={next:r??void 0,error:n??void 0,complete:s??void 0}:o=r,i.destination=new Pe(o),i}return t})(ce);function U(e){ve(e)}function Te(e){throw e}var Oe={closed:!0,next:se,error:Te,complete:se},_e=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function Ae(e){return e}function $e(e){return e.length===0?Ae:e.length===1?e[0]:function(r){return e.reduce(function(n,s){return s(n)},r)}}var Ie=(function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(t,r,n){var s=this,i=Ne(t)?t:new B(t,r,n);return ke(function(){var o=s,h=o.operator,b=o.source;i.add(h?h.call(i,b):b?s._subscribe(i):s._trySubscribe(i))}),i},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(r){t.error(r)}},e.prototype.forEach=function(t,r){var n=this;return r=ae(r),new r(function(s,i){var o=new B({next:function(h){try{t(h)}catch(b){i(b),o.unsubscribe()}},error:i,complete:s});n.subscribe(o)})},e.prototype._subscribe=function(t){var r;return(r=this.source)===null||r===void 0?void 0:r.subscribe(t)},e.prototype[_e]=function(){return this},e.prototype.pipe=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return $e(t)(this)},e.prototype.toPromise=function(t){var r=this;return t=ae(t),new t(function(n,s){var i;r.subscribe(function(o){return i=o},function(o){return s(o)},function(){return n(i)})})},e.create=function(t){return new e(t)},e})();function ae(e){var t;return(t=e??Se.Promise)!==null&&t!==void 0?t:Promise}function Re(e){return e&&_(e.next)&&_(e.error)&&_(e.complete)}function Ne(e){return e&&e instanceof ce||Re(e)&&oe(e)}var qe=re(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function Me(e,t){return new Promise(function(r,n){var s=new B({next:function(i){r(i),s.unsubscribe()},error:n,complete:function(){n(new qe)}});e.subscribe(s)})}class je{constructor(t,r){this.createClient=t,this.poolSize=r}clients=[];currentIndex=0;connect(){for(let t=0;t<this.poolSize;t++)this.clients.push(this.createClient(`${t+1}`))}get(){if(this.clients.length===0)throw new Error("Connection pool is empty. Please call connect() first.");const t=this.clients[this.currentIndex];if(this.currentIndex=(this.currentIndex+1)%this.poolSize,!t)throw new Error("No available WebSocket client");return t}disconnect(){this.clients.forEach(t=>t.dispose()),this.clients=[]}}const We=(e,t,r)=>r((n,s,i)=>{i&&console.warn("options are not supported yet");const o=n.loc?.source.body;if(!o)throw new Error("No query provided");if(s&&typeof s!="object")throw new Error("Variables must be an object");const h=n.definitions.find(d=>d.kind==="OperationDefinition");if(!h)throw new Error("No operation definition found");const b=h.operation,A=()=>{const d=e();return new Ie(P=>d.subscribe({query:o,variables:s},P))},E={kind:b,operationName:h.name?.value??"",query:o,variables:s||{}},S=(d,P)=>{if(P>=d.length)return A();const g=d[P];return g?.onRequest?g.onRequest(E,()=>S(d,P+1)):S(d,P+1)},l=S(t,0);return b!=="subscription"?Me(l):l});class ze{_pool;_sdk;constructor(t,r){const{url:n,project:s,token:i,client:o,pooling:h}=r,b=`${n}/graphql/projects/${s}`.replace(/^http/i,"ws");this._pool=new je(A=>{const E=Object.freeze({connectionId:A,websocketUrl:b});return ge({url:b,connectionParams:{authorization:`Bearer ${i}`},lazy:!1,keepAlive:3e4,retryAttempts:o?.retryAttempts??3,shouldRetry:()=>!0,jsonMessageReplacer:(S,l)=>{if(!S){let d=l;for(const P of r.middlewares??[])P.onOutgoingMessage&&(d=P.onOutgoingMessage(d));return d}return l},...o?.onError?{onNonLazyError:S=>o.onError(E,S)}:{},on:{...o?.onError?{error:S=>o.onError(E,S)}:{},...o?.onConnected?{connected:()=>o.onConnected(E)}:{},...o?.onClosed?{closed:()=>o.onClosed(E)}:{},...o?.onConnecting?{connecting:()=>o.onConnecting(E)}:{},...o?.onOpened?{opened:()=>o.onOpened(E)}:{},...o?.onMessage?{message:S=>o.onMessage(E,S)}:{},...o?.onPing?{ping:()=>o.onPing(E)}:{},...o?.onPong?{pong:()=>o.onPong(E)}:{}}})},h?.enabled===!1?1:h?.size??5),this._sdk={sdk:We(()=>this._pool.get(),r.middlewares??[],t)}}get sdk(){return this._sdk.sdk}async connect(){this._pool.connect()}async disconnect(){this._pool.disconnect()}}N.ContelloSdkClient=ze,Object.defineProperty(N,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -13,18 +13,18 @@
|
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"rxjs": "^7.8.2",
|
|
16
|
-
"@types/node": "^24.
|
|
17
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
18
|
-
"eslint": "^9.
|
|
19
|
-
"eslint-config-prettier": "^10.1.
|
|
16
|
+
"@types/node": "^24.7.1",
|
|
17
|
+
"@typescript-eslint/eslint-plugin": "^8.46.0",
|
|
18
|
+
"eslint": "^9.37.0",
|
|
19
|
+
"eslint-config-prettier": "^10.1.8",
|
|
20
20
|
"eslint-plugin-import": "^2.32.0",
|
|
21
|
-
"eslint-plugin-prettier": "^5.5.
|
|
21
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
22
22
|
"npm-run-all": "^4.1.5",
|
|
23
|
-
"typescript": "^5.
|
|
24
|
-
"typescript-eslint": "^8.
|
|
23
|
+
"typescript": "^5.9.3",
|
|
24
|
+
"typescript-eslint": "^8.46.0",
|
|
25
25
|
"graphql": "^16.11.0",
|
|
26
|
-
"graphql-ws": "^6.0.
|
|
27
|
-
"vite": "^7.
|
|
26
|
+
"graphql-ws": "^6.0.6",
|
|
27
|
+
"vite": "^7.1.9",
|
|
28
28
|
"vite-plugin-dts": "^4.5.4"
|
|
29
29
|
},
|
|
30
30
|
"author": "admin@entwico.com",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"access": "public",
|
|
45
45
|
"registry": "https://registry.npmjs.org"
|
|
46
46
|
},
|
|
47
|
-
"version": "8.20.
|
|
47
|
+
"version": "8.20.1-next.1763378120"
|
|
48
48
|
}
|