@auxilium/datalynk-client 0.6.10 → 0.6.13
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/api.d.ts +14 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/auth.d.ts +1 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/index.cjs +175 -153
- package/dist/index.mjs +175 -153
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -5,48 +5,55 @@
|
|
|
5
5
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
6
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
7
|
|
|
8
|
-
var
|
|
9
|
-
var nt = (
|
|
10
|
-
var
|
|
11
|
-
function
|
|
12
|
-
if (
|
|
8
|
+
var rt = Object.defineProperty;
|
|
9
|
+
var nt = (r, t, e) => t in r ? rt(r, t, { enumerable: true, configurable: true, writable: true, value: e }) : r[t] = e;
|
|
10
|
+
var c = (r, t, e) => (nt(r, typeof t != "symbol" ? t + "" : t, e), e);
|
|
11
|
+
function ot(r, t = false) {
|
|
12
|
+
if (r == null)
|
|
13
13
|
throw new Error("Cannot clean a NULL value");
|
|
14
|
-
return Array.isArray(
|
|
15
|
-
(t &&
|
|
16
|
-
}),
|
|
14
|
+
return Array.isArray(r) ? r = r.filter((e) => e != null) : Object.entries(r).forEach(([e, n]) => {
|
|
15
|
+
(t && n === void 0 || !t && n == null) && delete r[e];
|
|
16
|
+
}), r;
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function St(r) {
|
|
19
19
|
const t = new FormData();
|
|
20
|
-
return Object.entries(
|
|
20
|
+
return Object.entries(r).forEach(([e, n]) => t.append(e, n)), t;
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
function T(r) {
|
|
23
|
+
try {
|
|
24
|
+
return JSON.parse(r);
|
|
25
|
+
} catch {
|
|
26
|
+
return r;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
class E extends Promise {
|
|
23
30
|
constructor(e) {
|
|
24
|
-
super((
|
|
25
|
-
(s) =>
|
|
31
|
+
super((n, o) => e(
|
|
32
|
+
(s) => n(s),
|
|
26
33
|
(s) => o(s),
|
|
27
34
|
(s) => this.progress = s
|
|
28
35
|
));
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
c(this, "listeners", []);
|
|
37
|
+
c(this, "_progress", 0);
|
|
31
38
|
}
|
|
32
39
|
get progress() {
|
|
33
40
|
return this._progress;
|
|
34
41
|
}
|
|
35
42
|
set progress(e) {
|
|
36
|
-
e != this._progress && (this._progress = e, this.listeners.forEach((
|
|
43
|
+
e != this._progress && (this._progress = e, this.listeners.forEach((n) => n(e)));
|
|
37
44
|
}
|
|
38
45
|
static from(e) {
|
|
39
|
-
return e instanceof
|
|
46
|
+
return e instanceof E ? e : new E((n, o) => e.then((...s) => n(...s)).catch((...s) => o(...s)));
|
|
40
47
|
}
|
|
41
48
|
from(e) {
|
|
42
|
-
const
|
|
43
|
-
return this.onProgress((o) =>
|
|
49
|
+
const n = E.from(e);
|
|
50
|
+
return this.onProgress((o) => n.progress = o), n;
|
|
44
51
|
}
|
|
45
52
|
onProgress(e) {
|
|
46
53
|
return this.listeners.push(e), this;
|
|
47
54
|
}
|
|
48
|
-
then(e,
|
|
49
|
-
const o = super.then(e,
|
|
55
|
+
then(e, n) {
|
|
56
|
+
const o = super.then(e, n);
|
|
50
57
|
return this.from(o);
|
|
51
58
|
}
|
|
52
59
|
catch(e) {
|
|
@@ -58,51 +65,51 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
58
65
|
}
|
|
59
66
|
class v {
|
|
60
67
|
constructor() {
|
|
61
|
-
|
|
68
|
+
c(this, "listeners", {});
|
|
62
69
|
}
|
|
63
70
|
static emit(t, ...e) {
|
|
64
|
-
(this.listeners["*"] || []).forEach((
|
|
71
|
+
(this.listeners["*"] || []).forEach((n) => n(t, ...e)), (this.listeners[t.toString()] || []).forEach((n) => n(...e));
|
|
65
72
|
}
|
|
66
73
|
static off(t, e) {
|
|
67
|
-
const
|
|
68
|
-
this.listeners[
|
|
74
|
+
const n = t.toString();
|
|
75
|
+
this.listeners[n] = (this.listeners[n] || []).filter((o) => o === e);
|
|
69
76
|
}
|
|
70
77
|
static on(t, e) {
|
|
71
78
|
var o;
|
|
72
|
-
const
|
|
73
|
-
return this.listeners[
|
|
79
|
+
const n = t.toString();
|
|
80
|
+
return this.listeners[n] || (this.listeners[n] = []), (o = this.listeners[n]) == null || o.push(e), () => this.off(t, e);
|
|
74
81
|
}
|
|
75
82
|
static once(t, e) {
|
|
76
|
-
return new Promise((
|
|
83
|
+
return new Promise((n) => {
|
|
77
84
|
const o = this.on(t, (...s) => {
|
|
78
|
-
|
|
85
|
+
n(s.length == 1 ? s[0] : s), e && e(...s), o();
|
|
79
86
|
});
|
|
80
87
|
});
|
|
81
88
|
}
|
|
82
89
|
emit(t, ...e) {
|
|
83
|
-
(this.listeners["*"] || []).forEach((
|
|
90
|
+
(this.listeners["*"] || []).forEach((n) => n(t, ...e)), (this.listeners[t] || []).forEach((n) => n(...e));
|
|
84
91
|
}
|
|
85
92
|
off(t, e) {
|
|
86
|
-
this.listeners[t] = (this.listeners[t] || []).filter((
|
|
93
|
+
this.listeners[t] = (this.listeners[t] || []).filter((n) => n === e);
|
|
87
94
|
}
|
|
88
95
|
on(t, e) {
|
|
89
|
-
var
|
|
90
|
-
return this.listeners[t] || (this.listeners[t] = []), (
|
|
96
|
+
var n;
|
|
97
|
+
return this.listeners[t] || (this.listeners[t] = []), (n = this.listeners[t]) == null || n.push(e), () => this.off(t, e);
|
|
91
98
|
}
|
|
92
99
|
once(t, e) {
|
|
93
|
-
return new Promise((
|
|
100
|
+
return new Promise((n) => {
|
|
94
101
|
const o = this.on(t, (...s) => {
|
|
95
|
-
|
|
102
|
+
n(s.length == 1 ? s[0] : s), e && e(...s), o();
|
|
96
103
|
});
|
|
97
104
|
});
|
|
98
105
|
}
|
|
99
106
|
}
|
|
100
|
-
|
|
107
|
+
c(v, "listeners", {});
|
|
101
108
|
class p extends Error {
|
|
102
|
-
constructor(e,
|
|
109
|
+
constructor(e, n) {
|
|
103
110
|
super(e);
|
|
104
|
-
|
|
105
|
-
|
|
111
|
+
c(this, "_code");
|
|
112
|
+
n != null && (this._code = n);
|
|
106
113
|
}
|
|
107
114
|
get code() {
|
|
108
115
|
return this._code || this.constructor.code;
|
|
@@ -111,11 +118,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
111
118
|
this._code = e;
|
|
112
119
|
}
|
|
113
120
|
static from(e) {
|
|
114
|
-
const
|
|
121
|
+
const n = Number(e.statusCode) ?? Number(e.code), o = new this(e.message || e.toString());
|
|
115
122
|
return Object.assign(o, {
|
|
116
123
|
stack: e.stack,
|
|
117
124
|
...e,
|
|
118
|
-
code:
|
|
125
|
+
code: n ?? void 0
|
|
119
126
|
});
|
|
120
127
|
}
|
|
121
128
|
static instanceof(e) {
|
|
@@ -125,8 +132,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
125
132
|
return this.message || super.toString();
|
|
126
133
|
}
|
|
127
134
|
}
|
|
128
|
-
|
|
129
|
-
class
|
|
135
|
+
c(p, "code", 500);
|
|
136
|
+
class Y extends p {
|
|
130
137
|
constructor(t = "Bad Request") {
|
|
131
138
|
super(t);
|
|
132
139
|
}
|
|
@@ -134,7 +141,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
134
141
|
return t.constructor.code == this.code;
|
|
135
142
|
}
|
|
136
143
|
}
|
|
137
|
-
|
|
144
|
+
c(Y, "code", 400);
|
|
138
145
|
class H extends p {
|
|
139
146
|
constructor(t = "Unauthorized") {
|
|
140
147
|
super(t);
|
|
@@ -143,8 +150,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
143
150
|
return t.constructor.code == this.code;
|
|
144
151
|
}
|
|
145
152
|
}
|
|
146
|
-
|
|
147
|
-
class
|
|
153
|
+
c(H, "code", 401);
|
|
154
|
+
class W extends p {
|
|
148
155
|
constructor(t = "Payment Required") {
|
|
149
156
|
super(t);
|
|
150
157
|
}
|
|
@@ -152,8 +159,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
152
159
|
return t.constructor.code == this.code;
|
|
153
160
|
}
|
|
154
161
|
}
|
|
155
|
-
|
|
156
|
-
class
|
|
162
|
+
c(W, "code", 402);
|
|
163
|
+
class z extends p {
|
|
157
164
|
constructor(t = "Forbidden") {
|
|
158
165
|
super(t);
|
|
159
166
|
}
|
|
@@ -161,8 +168,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
161
168
|
return t.constructor.code == this.code;
|
|
162
169
|
}
|
|
163
170
|
}
|
|
164
|
-
|
|
165
|
-
class
|
|
171
|
+
c(z, "code", 403);
|
|
172
|
+
class K extends p {
|
|
166
173
|
constructor(t = "Not Found") {
|
|
167
174
|
super(t);
|
|
168
175
|
}
|
|
@@ -170,8 +177,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
170
177
|
return t.constructor.code == this.code;
|
|
171
178
|
}
|
|
172
179
|
}
|
|
173
|
-
|
|
174
|
-
class
|
|
180
|
+
c(K, "code", 404);
|
|
181
|
+
class J extends p {
|
|
175
182
|
constructor(t = "Method Not Allowed") {
|
|
176
183
|
super(t);
|
|
177
184
|
}
|
|
@@ -179,8 +186,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
179
186
|
return t.constructor.code == this.code;
|
|
180
187
|
}
|
|
181
188
|
}
|
|
182
|
-
|
|
183
|
-
class
|
|
189
|
+
c(J, "code", 405);
|
|
190
|
+
class Z extends p {
|
|
184
191
|
constructor(t = "Not Acceptable") {
|
|
185
192
|
super(t);
|
|
186
193
|
}
|
|
@@ -188,7 +195,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
188
195
|
return t.constructor.code == this.code;
|
|
189
196
|
}
|
|
190
197
|
}
|
|
191
|
-
|
|
198
|
+
c(Z, "code", 406);
|
|
192
199
|
class V extends p {
|
|
193
200
|
constructor(t = "Internal Server Error") {
|
|
194
201
|
super(t);
|
|
@@ -197,8 +204,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
197
204
|
return t.constructor.code == this.code;
|
|
198
205
|
}
|
|
199
206
|
}
|
|
200
|
-
|
|
201
|
-
class
|
|
207
|
+
c(V, "code", 500);
|
|
208
|
+
class X extends p {
|
|
202
209
|
constructor(t = "Not Implemented") {
|
|
203
210
|
super(t);
|
|
204
211
|
}
|
|
@@ -206,8 +213,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
206
213
|
return t.constructor.code == this.code;
|
|
207
214
|
}
|
|
208
215
|
}
|
|
209
|
-
|
|
210
|
-
class
|
|
216
|
+
c(X, "code", 501);
|
|
217
|
+
class Q extends p {
|
|
211
218
|
constructor(t = "Bad Gateway") {
|
|
212
219
|
super(t);
|
|
213
220
|
}
|
|
@@ -215,8 +222,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
215
222
|
return t.constructor.code == this.code;
|
|
216
223
|
}
|
|
217
224
|
}
|
|
218
|
-
|
|
219
|
-
class
|
|
225
|
+
c(Q, "code", 502);
|
|
226
|
+
class _ extends p {
|
|
220
227
|
constructor(t = "Service Unavailable") {
|
|
221
228
|
super(t);
|
|
222
229
|
}
|
|
@@ -224,8 +231,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
224
231
|
return t.constructor.code == this.code;
|
|
225
232
|
}
|
|
226
233
|
}
|
|
227
|
-
|
|
228
|
-
class
|
|
234
|
+
c(_, "code", 503);
|
|
235
|
+
class tt extends p {
|
|
229
236
|
constructor(t = "Gateway Timeout") {
|
|
230
237
|
super(t);
|
|
231
238
|
}
|
|
@@ -233,44 +240,44 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
233
240
|
return t.constructor.code == this.code;
|
|
234
241
|
}
|
|
235
242
|
}
|
|
236
|
-
|
|
237
|
-
function
|
|
238
|
-
if (
|
|
243
|
+
c(tt, "code", 504);
|
|
244
|
+
function kt(r, t) {
|
|
245
|
+
if (r >= 200 && r < 300)
|
|
239
246
|
return null;
|
|
240
|
-
switch (
|
|
247
|
+
switch (r) {
|
|
241
248
|
case 400:
|
|
242
|
-
return new
|
|
249
|
+
return new Y(t);
|
|
243
250
|
case 401:
|
|
244
251
|
return new H(t);
|
|
245
252
|
case 402:
|
|
246
|
-
return new Y(t);
|
|
247
|
-
case 403:
|
|
248
253
|
return new W(t);
|
|
254
|
+
case 403:
|
|
255
|
+
return new z(t);
|
|
249
256
|
case 404:
|
|
250
|
-
return new
|
|
257
|
+
return new K(t);
|
|
251
258
|
case 405:
|
|
252
|
-
return new
|
|
259
|
+
return new J(t);
|
|
253
260
|
case 406:
|
|
254
|
-
return new
|
|
261
|
+
return new Z(t);
|
|
255
262
|
case 500:
|
|
256
263
|
return new V(t);
|
|
257
264
|
case 501:
|
|
258
|
-
return new Z(t);
|
|
259
|
-
case 502:
|
|
260
265
|
return new X(t);
|
|
261
|
-
case
|
|
266
|
+
case 502:
|
|
262
267
|
return new Q(t);
|
|
263
|
-
case
|
|
268
|
+
case 503:
|
|
264
269
|
return new _(t);
|
|
270
|
+
case 504:
|
|
271
|
+
return new tt(t);
|
|
265
272
|
default:
|
|
266
|
-
return new p(t,
|
|
273
|
+
return new p(t, r);
|
|
267
274
|
}
|
|
268
275
|
}
|
|
269
276
|
const w = class w2 {
|
|
270
277
|
constructor(t = {}) {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
278
|
+
c(this, "interceptors", {});
|
|
279
|
+
c(this, "headers", {});
|
|
280
|
+
c(this, "url");
|
|
274
281
|
this.url = t.url ?? null, this.headers = t.headers || {}, t.interceptors && t.interceptors.forEach((e) => w2.addInterceptor(e));
|
|
275
282
|
}
|
|
276
283
|
static addInterceptor(t) {
|
|
@@ -290,50 +297,56 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
290
297
|
if (!this.url && !t.url)
|
|
291
298
|
throw new Error("URL needs to be set");
|
|
292
299
|
let e = ((o = t.url) != null && o.startsWith("http") ? t.url : (this.url || "") + (t.url || "")).replace(/([^:]\/)\/+/g, "$1");
|
|
293
|
-
if (t.fragment && (e.includes("#") ? e.replace(/#.*(\?|\n)/g, (s,
|
|
294
|
-
const s = Array.isArray(t.query) ? t.query : Object.keys(t.query).map((
|
|
295
|
-
e += (e.includes("?") ? "&" : "?") + s.map((
|
|
300
|
+
if (t.fragment && (e.includes("#") ? e.replace(/#.*(\?|\n)/g, (s, i) => `#${t.fragment}${i}`) : e += "#" + t.fragment), t.query) {
|
|
301
|
+
const s = Array.isArray(t.query) ? t.query : Object.keys(t.query).map((i) => ({ key: i, value: t.query[i] }));
|
|
302
|
+
e += (e.includes("?") ? "&" : "?") + s.map((i) => `${i.key}=${i.value}`).join("&");
|
|
296
303
|
}
|
|
297
|
-
const
|
|
304
|
+
const n = ot({
|
|
298
305
|
"Content-Type": t.body ? t.body instanceof FormData ? "multipart/form-data" : "application/json" : void 0,
|
|
299
306
|
...w2.headers,
|
|
300
307
|
...this.headers,
|
|
301
308
|
...t.headers
|
|
302
309
|
});
|
|
303
|
-
return typeof t.body == "object" && t.body != null &&
|
|
310
|
+
return typeof t.body == "object" && t.body != null && n["Content-Type"] == "application/json" && (t.body = JSON.stringify(t.body)), new E((s, i, y) => {
|
|
304
311
|
fetch(e, {
|
|
305
|
-
headers:
|
|
312
|
+
headers: n,
|
|
306
313
|
method: t.method || (t.body ? "POST" : "GET"),
|
|
307
314
|
body: t.body
|
|
308
315
|
}).then(async (u) => {
|
|
309
|
-
var
|
|
316
|
+
var k, U;
|
|
310
317
|
for (let a of [...Object.values(w2.interceptors), ...Object.values(this.interceptors)])
|
|
311
318
|
await new Promise((O) => a(u, () => O()));
|
|
312
|
-
const R = u.headers.get("Content-Length"),
|
|
313
|
-
let
|
|
314
|
-
const
|
|
319
|
+
const R = u.headers.get("Content-Length"), L = R ? parseInt(R, 10) : 0;
|
|
320
|
+
let M = 0;
|
|
321
|
+
const N = (k = u.body) == null ? void 0 : k.getReader(), et = new ReadableStream({
|
|
315
322
|
start(a) {
|
|
316
323
|
function O() {
|
|
317
|
-
|
|
318
|
-
if (
|
|
324
|
+
N == null || N.read().then((B) => {
|
|
325
|
+
if (B.done)
|
|
319
326
|
return a.close();
|
|
320
|
-
|
|
321
|
-
}).catch((
|
|
327
|
+
M += B.value.byteLength, y(M / L), a.enqueue(B.value), O();
|
|
328
|
+
}).catch((B) => a.error(B));
|
|
322
329
|
}
|
|
323
330
|
O();
|
|
324
331
|
}
|
|
325
332
|
});
|
|
326
|
-
if (u.data = new Response(
|
|
327
|
-
const a = (
|
|
333
|
+
if (u.data = new Response(et), t.decode == null || t.decode) {
|
|
334
|
+
const a = (U = u.headers.get("Content-Type")) == null ? void 0 : U.toLowerCase();
|
|
328
335
|
a != null && a.includes("form") ? u.data = await u.data.formData() : a != null && a.includes("json") ? u.data = await u.data.json() : a != null && a.includes("text") ? u.data = await u.data.text() : a != null && a.includes("application") && (u.data = await u.data.blob());
|
|
329
336
|
}
|
|
330
|
-
u.ok ? s(u) :
|
|
337
|
+
u.ok ? s(u) : i(u);
|
|
331
338
|
});
|
|
332
339
|
});
|
|
333
340
|
}
|
|
334
341
|
};
|
|
335
|
-
|
|
336
|
-
|
|
342
|
+
c(w, "interceptors", {}), c(w, "headers", {});
|
|
343
|
+
function Ut(r) {
|
|
344
|
+
const t = r.split(".")[1].replace(/-/g, "+").replace(/_/g, "/");
|
|
345
|
+
return T(decodeURIComponent(atob(t).split("").map(function(e) {
|
|
346
|
+
return "%" + ("00" + e.charCodeAt(0).toString(16)).slice(-2);
|
|
347
|
+
}).join("")));
|
|
348
|
+
}
|
|
349
|
+
const S = {
|
|
337
350
|
CLEAR: "\x1B[0m",
|
|
338
351
|
BRIGHT: "\x1B[1m",
|
|
339
352
|
DIM: "\x1B[2m",
|
|
@@ -341,7 +354,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
341
354
|
BLINK: "\x1B[5m",
|
|
342
355
|
REVERSE: "\x1B[7m",
|
|
343
356
|
HIDDEN: "\x1B[8m"
|
|
344
|
-
},
|
|
357
|
+
}, C = {
|
|
345
358
|
BLACK: "\x1B[30m",
|
|
346
359
|
RED: "\x1B[31m",
|
|
347
360
|
GREEN: "\x1B[32m",
|
|
@@ -363,11 +376,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
363
376
|
constructor(t) {
|
|
364
377
|
super(), this.namespace = t;
|
|
365
378
|
}
|
|
366
|
-
pad(t, e,
|
|
367
|
-
const s = t.toString(),
|
|
368
|
-
if (
|
|
379
|
+
pad(t, e, n, o = false) {
|
|
380
|
+
const s = t.toString(), i = e - s.length;
|
|
381
|
+
if (i <= 0)
|
|
369
382
|
return s;
|
|
370
|
-
const y = Array(~~(
|
|
383
|
+
const y = Array(~~(i / n.length)).fill(n).join("");
|
|
371
384
|
return o ? s + y : y + s;
|
|
372
385
|
}
|
|
373
386
|
format(...t) {
|
|
@@ -378,40 +391,40 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
378
391
|
if (g2.LOG_LEVEL < 4)
|
|
379
392
|
return;
|
|
380
393
|
const e = this.format(...t);
|
|
381
|
-
g2.emit(4, e), console.debug(
|
|
394
|
+
g2.emit(4, e), console.debug(C.LIGHT_GREY + e + S.CLEAR);
|
|
382
395
|
}
|
|
383
396
|
log(...t) {
|
|
384
397
|
if (g2.LOG_LEVEL < 3)
|
|
385
398
|
return;
|
|
386
399
|
const e = this.format(...t);
|
|
387
|
-
g2.emit(3, e), console.log(
|
|
400
|
+
g2.emit(3, e), console.log(S.CLEAR + e);
|
|
388
401
|
}
|
|
389
402
|
info(...t) {
|
|
390
403
|
if (g2.LOG_LEVEL < 2)
|
|
391
404
|
return;
|
|
392
405
|
const e = this.format(...t);
|
|
393
|
-
g2.emit(2, e), console.info(
|
|
406
|
+
g2.emit(2, e), console.info(C.BLUE + e + S.CLEAR);
|
|
394
407
|
}
|
|
395
408
|
warn(...t) {
|
|
396
409
|
if (g2.LOG_LEVEL < 1)
|
|
397
410
|
return;
|
|
398
411
|
const e = this.format(...t);
|
|
399
|
-
g2.emit(1, e), console.warn(
|
|
412
|
+
g2.emit(1, e), console.warn(C.YELLOW + e + S.CLEAR);
|
|
400
413
|
}
|
|
401
414
|
error(...t) {
|
|
402
415
|
if (g2.LOG_LEVEL < 0)
|
|
403
416
|
return;
|
|
404
417
|
const e = this.format(...t);
|
|
405
|
-
g2.emit(0, e), console.error(
|
|
418
|
+
g2.emit(0, e), console.error(C.RED + e + S.CLEAR);
|
|
406
419
|
}
|
|
407
420
|
};
|
|
408
|
-
|
|
409
|
-
function
|
|
410
|
-
return new Promise((t) => setTimeout(t,
|
|
421
|
+
c(g, "LOG_LEVEL", 4);
|
|
422
|
+
function mt(r) {
|
|
423
|
+
return new Promise((t) => setTimeout(t, r));
|
|
411
424
|
}
|
|
412
|
-
async function
|
|
413
|
-
for (;
|
|
414
|
-
await
|
|
425
|
+
async function _t(r, t = 100) {
|
|
426
|
+
for (; await r(); )
|
|
427
|
+
await mt(t);
|
|
415
428
|
}
|
|
416
429
|
var extendStatics = function(d, b) {
|
|
417
430
|
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
@@ -431,27 +444,27 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
431
444
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
432
445
|
}
|
|
433
446
|
function __values(o) {
|
|
434
|
-
var s = typeof Symbol === "function" && Symbol.iterator,
|
|
435
|
-
if (
|
|
447
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
448
|
+
if (m) return m.call(o);
|
|
436
449
|
if (o && typeof o.length === "number") return {
|
|
437
450
|
next: function() {
|
|
438
|
-
if (o &&
|
|
439
|
-
return { value: o && o[
|
|
451
|
+
if (o && i >= o.length) o = void 0;
|
|
452
|
+
return { value: o && o[i++], done: !o };
|
|
440
453
|
}
|
|
441
454
|
};
|
|
442
455
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
443
456
|
}
|
|
444
457
|
function __read(o, n) {
|
|
445
|
-
var
|
|
446
|
-
if (!
|
|
447
|
-
var
|
|
458
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
459
|
+
if (!m) return o;
|
|
460
|
+
var i = m.call(o), r, ar = [], e;
|
|
448
461
|
try {
|
|
449
|
-
while ((n === void 0 || n-- > 0) && !(r =
|
|
462
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
450
463
|
} catch (error) {
|
|
451
464
|
e = { error };
|
|
452
465
|
} finally {
|
|
453
466
|
try {
|
|
454
|
-
if (r && !r.done && (
|
|
467
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
455
468
|
} finally {
|
|
456
469
|
if (e) throw e.error;
|
|
457
470
|
}
|
|
@@ -459,10 +472,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
459
472
|
return ar;
|
|
460
473
|
}
|
|
461
474
|
function __spreadArray(to, from, pack) {
|
|
462
|
-
if (pack || arguments.length === 2) for (var
|
|
463
|
-
if (ar || !(
|
|
464
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0,
|
|
465
|
-
ar[
|
|
475
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
476
|
+
if (ar || !(i in from)) {
|
|
477
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
478
|
+
ar[i] = from[i];
|
|
466
479
|
}
|
|
467
480
|
}
|
|
468
481
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
@@ -487,8 +500,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
487
500
|
var UnsubscriptionError = createErrorClass(function(_super) {
|
|
488
501
|
return function UnsubscriptionErrorImpl(errors) {
|
|
489
502
|
_super(this);
|
|
490
|
-
this.message = errors ? errors.length + " errors occurred during unsubscription:\n" + errors.map(function(err,
|
|
491
|
-
return
|
|
503
|
+
this.message = errors ? errors.length + " errors occurred during unsubscription:\n" + errors.map(function(err, i) {
|
|
504
|
+
return i + 1 + ") " + err.toString();
|
|
492
505
|
}).join("\n ") : "";
|
|
493
506
|
this.name = "UnsubscriptionError";
|
|
494
507
|
this.errors = errors;
|
|
@@ -1445,6 +1458,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1445
1458
|
set user(user) {
|
|
1446
1459
|
this.user$.next(user);
|
|
1447
1460
|
}
|
|
1461
|
+
get spoke() {
|
|
1462
|
+
var _a;
|
|
1463
|
+
return ((_a = this.api.jwtPayload) == null ? void 0 : _a.realm) || null;
|
|
1464
|
+
}
|
|
1448
1465
|
/**
|
|
1449
1466
|
* Get current user associated with API token
|
|
1450
1467
|
*
|
|
@@ -1536,7 +1553,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1536
1553
|
login(spoke, login, password, twoFactor) {
|
|
1537
1554
|
return fetch(`${this.api.url}login`, {
|
|
1538
1555
|
method: "POST",
|
|
1539
|
-
body:
|
|
1556
|
+
body: St(ot({
|
|
1540
1557
|
realm: spoke.trim(),
|
|
1541
1558
|
login: login.trim(),
|
|
1542
1559
|
password: password.trim(),
|
|
@@ -1545,7 +1562,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1545
1562
|
}))
|
|
1546
1563
|
}).then(async (resp) => {
|
|
1547
1564
|
const data = await resp.json().catch(() => ({}));
|
|
1548
|
-
if (!resp.ok || data["error"]) throw Object.assign(
|
|
1565
|
+
if (!resp.ok || data["error"]) throw Object.assign(kt(resp.status, data.error) || {}, data);
|
|
1549
1566
|
this.api.token = data["token"];
|
|
1550
1567
|
return data;
|
|
1551
1568
|
});
|
|
@@ -1558,7 +1575,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1558
1575
|
loginGuest() {
|
|
1559
1576
|
return fetch(`${this.api.url}guest`).then(async (resp) => {
|
|
1560
1577
|
const data = await resp.json().catch(() => ({}));
|
|
1561
|
-
if (!resp.ok || data["error"]) throw Object.assign(
|
|
1578
|
+
if (!resp.ok || data["error"]) throw Object.assign(kt(resp.status, data.error) || {}, data);
|
|
1562
1579
|
this.api.token = data["token"];
|
|
1563
1580
|
return data;
|
|
1564
1581
|
});
|
|
@@ -1650,11 +1667,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1650
1667
|
data.append("", file, file.name);
|
|
1651
1668
|
return fetch(this.url, {
|
|
1652
1669
|
method: "POST",
|
|
1653
|
-
headers:
|
|
1670
|
+
headers: ot({ "Authorization": this.api.token ? `Bearer ${this.api.token}` : "" }),
|
|
1654
1671
|
body: data
|
|
1655
1672
|
}).then(async (resp) => {
|
|
1656
1673
|
const data2 = await resp.json().catch(() => ({}));
|
|
1657
|
-
if (!resp.ok || data2["error"]) throw Object.assign(
|
|
1674
|
+
if (!resp.ok || data2["error"]) throw Object.assign(kt(resp.status, data2.error) || {}, data2);
|
|
1658
1675
|
return resp;
|
|
1659
1676
|
});
|
|
1660
1677
|
})).then(async (files2) => {
|
|
@@ -1755,22 +1772,22 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1755
1772
|
let meta = obj["meta"];
|
|
1756
1773
|
let col;
|
|
1757
1774
|
let fn = [];
|
|
1758
|
-
for (let
|
|
1759
|
-
col = meta[
|
|
1775
|
+
for (let i in meta) {
|
|
1776
|
+
col = meta[i];
|
|
1760
1777
|
fn.push("this['" + col.name + "'] = ");
|
|
1761
1778
|
if (col.cast == null) {
|
|
1762
|
-
fn.push("a[" +
|
|
1779
|
+
fn.push("a[" + i + "];\n");
|
|
1763
1780
|
} else if (col.cast === "num") {
|
|
1764
|
-
fn.push("a[" +
|
|
1781
|
+
fn.push("a[" + i + "] && parseFloat(a[" + i + "]);\n");
|
|
1765
1782
|
} else {
|
|
1766
1783
|
if (col["native"] === "date") {
|
|
1767
|
-
fn.push("a[" +
|
|
1768
|
-
fn.push("a[" +
|
|
1784
|
+
fn.push("a[" + i + "] && dateParse(a[" + i + "]);\n");
|
|
1785
|
+
fn.push("a[" + i + "] && (this['" + col.name + "'].hint = 'date');\n");
|
|
1769
1786
|
} else if (col["native"] === "time") {
|
|
1770
|
-
fn.push("a[" +
|
|
1771
|
-
fn.push("a[" +
|
|
1787
|
+
fn.push("a[" + i + "] && timeParse(a[" + i + "]);\n");
|
|
1788
|
+
fn.push("a[" + i + "] && (this['" + col.name + "'].hint = 'time');\n");
|
|
1772
1789
|
} else {
|
|
1773
|
-
fn.push("a[" +
|
|
1790
|
+
fn.push("a[" + i + "] && datetimeParse(a[" + i + "]);\n");
|
|
1774
1791
|
}
|
|
1775
1792
|
}
|
|
1776
1793
|
}
|
|
@@ -1798,8 +1815,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1798
1815
|
let ctor = Function("datetimeParse", "dateParse", "timeParse", "a", fn.join(""));
|
|
1799
1816
|
let res = [];
|
|
1800
1817
|
let rows = obj["rows"];
|
|
1801
|
-
for (let
|
|
1802
|
-
res[
|
|
1818
|
+
for (let i in rows) {
|
|
1819
|
+
res[i] = new ctor(dateTimeParse, dateParse, timeParse, rows[i]);
|
|
1803
1820
|
}
|
|
1804
1821
|
res["meta"] = meta;
|
|
1805
1822
|
res["rowConstructor"] = ctor;
|
|
@@ -2049,7 +2066,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2049
2066
|
new Slice(this.slice, this.api).select().exec().rows().then((rows) => this.cache = rows);
|
|
2050
2067
|
if (!this.unsubscribe) this.unsubscribe = this.api.socket.sliceEvents(this.slice, (event) => {
|
|
2051
2068
|
const ids = [...event.data.insert, ...event.data.update];
|
|
2052
|
-
new Slice(this.slice, this.api).select(ids).exec().rows().then((rows) => this.cache = [...this.cache.filter((
|
|
2069
|
+
new Slice(this.slice, this.api).select(ids).exec().rows().then((rows) => this.cache = [...this.cache.filter((c2) => c2.id != null && !ids.includes(c2.id)), ...rows]);
|
|
2053
2070
|
this.cache = this.cache.filter((v2) => v2.id && !event.data.remove.includes(v2.id));
|
|
2054
2071
|
});
|
|
2055
2072
|
return this.cache$;
|
|
@@ -2196,7 +2213,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2196
2213
|
* @return {Unsubscribe} Run returned function to unsubscribe callback
|
|
2197
2214
|
*/
|
|
2198
2215
|
sliceEvents(slice, callback) {
|
|
2199
|
-
|
|
2216
|
+
_t(() => {
|
|
2200
2217
|
var _a;
|
|
2201
2218
|
return ((_a = this.socket) == null ? void 0 : _a.readyState) != 1;
|
|
2202
2219
|
}).then(() => this.send({ onSliceEvents: slice }));
|
|
@@ -2302,19 +2319,24 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2302
2319
|
set token(token) {
|
|
2303
2320
|
this.token$.next(token);
|
|
2304
2321
|
}
|
|
2322
|
+
/** Get session info from JWT payload */
|
|
2323
|
+
get jwtPayload() {
|
|
2324
|
+
if (!this.token) return null;
|
|
2325
|
+
return Ut(this.token);
|
|
2326
|
+
}
|
|
2305
2327
|
_request(req, options = {}) {
|
|
2306
2328
|
return fetch(this.url, {
|
|
2307
2329
|
method: "POST",
|
|
2308
|
-
headers:
|
|
2330
|
+
headers: ot({
|
|
2309
2331
|
Authorization: this.token ? `Bearer ${this.token}` : void 0,
|
|
2310
2332
|
"Content-Type": "application/json"
|
|
2311
2333
|
}),
|
|
2312
2334
|
body: JSON.stringify(Api.translateTokens(req))
|
|
2313
2335
|
}).then(async (resp) => {
|
|
2314
|
-
if (!resp.ok) throw
|
|
2336
|
+
if (!resp.ok) throw kt(resp.status);
|
|
2315
2337
|
let data = await resp.json();
|
|
2316
2338
|
if (!options.raw) data = Api.translateTokens(data);
|
|
2317
|
-
if (data["error"]) throw Object.assign(
|
|
2339
|
+
if (data["error"]) throw Object.assign(kt(resp.status, data["error"]) || {}, data);
|
|
2318
2340
|
return data;
|
|
2319
2341
|
});
|
|
2320
2342
|
}
|
|
@@ -2378,7 +2400,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2378
2400
|
data = originalBundle.map((row) => row.data);
|
|
2379
2401
|
this._request(data, options).then((resp) => {
|
|
2380
2402
|
if (!(resp instanceof Array)) resp = [resp];
|
|
2381
|
-
resp.filter((ignore,
|
|
2403
|
+
resp.filter((ignore, i) => i < originalBundle.length).forEach((row, i) => row.error ? originalBundle[i].rej(row.error) : originalBundle[i].res(row));
|
|
2382
2404
|
}).catch((err) => originalBundle.forEach((req) => req.rej(err)));
|
|
2383
2405
|
}, this.options.bundleTime);
|
|
2384
2406
|
}
|