@auxilium/datalynk-client 0.8.0 → 0.8.1
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.map +1 -1
- package/dist/index.cjs +349 -425
- package/dist/index.mjs +347 -423
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,348 +1,404 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (
|
|
1
|
+
(function(global, factory) {
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.utils = {}));
|
|
3
3
|
})(this, function(exports2) {
|
|
4
4
|
"use strict";var __defProp = Object.defineProperty;
|
|
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
|
|
10
|
-
var
|
|
11
|
-
function
|
|
12
|
-
if (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
8
|
+
var __defProp2 = Object.defineProperty;
|
|
9
|
+
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
11
|
+
function clean(obj, undefinedOnly = false) {
|
|
12
|
+
if (obj == null) throw new Error("Cannot clean a NULL value");
|
|
13
|
+
if (Array.isArray(obj)) {
|
|
14
|
+
obj = obj.filter((o) => o != null);
|
|
15
|
+
} else {
|
|
16
|
+
Object.entries(obj).forEach(([key, value]) => {
|
|
17
|
+
if (undefinedOnly && value === void 0 || !undefinedOnly && value == null) delete obj[key];
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return obj;
|
|
16
21
|
}
|
|
17
|
-
function
|
|
18
|
-
const
|
|
19
|
-
|
|
22
|
+
function formData(target) {
|
|
23
|
+
const data = new FormData();
|
|
24
|
+
Object.entries(target).forEach(([key, value]) => data.append(key, value));
|
|
25
|
+
return data;
|
|
20
26
|
}
|
|
21
|
-
function
|
|
27
|
+
function JSONAttemptParse(json) {
|
|
22
28
|
try {
|
|
23
|
-
return JSON.parse(
|
|
29
|
+
return JSON.parse(json);
|
|
24
30
|
} catch {
|
|
25
|
-
return
|
|
31
|
+
return json;
|
|
26
32
|
}
|
|
27
33
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
(
|
|
33
|
-
(
|
|
34
|
+
function JSONSanitize(obj, space) {
|
|
35
|
+
let cache = [];
|
|
36
|
+
return JSON.stringify(obj, (key, value) => {
|
|
37
|
+
if (typeof value === "object" && value !== null) {
|
|
38
|
+
if (cache.includes(value)) return;
|
|
39
|
+
cache.push(value);
|
|
40
|
+
}
|
|
41
|
+
return value;
|
|
42
|
+
}, space);
|
|
43
|
+
}
|
|
44
|
+
class PromiseProgress extends Promise {
|
|
45
|
+
constructor(executor) {
|
|
46
|
+
super((resolve, reject) => executor(
|
|
47
|
+
(value) => resolve(value),
|
|
48
|
+
(reason) => reject(reason),
|
|
49
|
+
(progress) => this.progress = progress
|
|
34
50
|
));
|
|
35
|
-
|
|
36
|
-
|
|
51
|
+
__publicField2(this, "listeners", []);
|
|
52
|
+
__publicField2(this, "_progress", 0);
|
|
37
53
|
}
|
|
38
54
|
get progress() {
|
|
39
55
|
return this._progress;
|
|
40
56
|
}
|
|
41
|
-
set progress(
|
|
42
|
-
|
|
57
|
+
set progress(p) {
|
|
58
|
+
if (p == this._progress) return;
|
|
59
|
+
this._progress = p;
|
|
60
|
+
this.listeners.forEach((l) => l(p));
|
|
43
61
|
}
|
|
44
|
-
static from(
|
|
45
|
-
|
|
62
|
+
static from(promise) {
|
|
63
|
+
if (promise instanceof PromiseProgress) return promise;
|
|
64
|
+
return new PromiseProgress((res, rej) => promise.then((...args) => res(...args)).catch((...args) => rej(...args)));
|
|
46
65
|
}
|
|
47
|
-
from(
|
|
48
|
-
const
|
|
49
|
-
|
|
66
|
+
from(promise) {
|
|
67
|
+
const newPromise = PromiseProgress.from(promise);
|
|
68
|
+
this.onProgress((p) => newPromise.progress = p);
|
|
69
|
+
return newPromise;
|
|
50
70
|
}
|
|
51
|
-
onProgress(
|
|
52
|
-
|
|
71
|
+
onProgress(callback) {
|
|
72
|
+
this.listeners.push(callback);
|
|
73
|
+
return this;
|
|
53
74
|
}
|
|
54
|
-
then(
|
|
55
|
-
const
|
|
56
|
-
return this.from(
|
|
75
|
+
then(res, rej) {
|
|
76
|
+
const resp = super.then(res, rej);
|
|
77
|
+
return this.from(resp);
|
|
57
78
|
}
|
|
58
|
-
catch(
|
|
59
|
-
return this.from(super.catch(
|
|
79
|
+
catch(rej) {
|
|
80
|
+
return this.from(super.catch(rej));
|
|
60
81
|
}
|
|
61
|
-
finally(
|
|
62
|
-
return this.from(super.finally(
|
|
82
|
+
finally(res) {
|
|
83
|
+
return this.from(super.finally(res));
|
|
63
84
|
}
|
|
64
85
|
}
|
|
65
|
-
class
|
|
86
|
+
class TypedEmitter {
|
|
66
87
|
constructor() {
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
static emit(t, ...e) {
|
|
70
|
-
(this.listeners["*"] || []).forEach((n) => n(t, ...e)), (this.listeners[t.toString()] || []).forEach((n) => n(...e));
|
|
88
|
+
__publicField2(this, "listeners", {});
|
|
71
89
|
}
|
|
72
|
-
static
|
|
73
|
-
|
|
74
|
-
this.listeners[
|
|
90
|
+
static emit(event, ...args) {
|
|
91
|
+
(this.listeners["*"] || []).forEach((l) => l(event, ...args));
|
|
92
|
+
(this.listeners[event.toString()] || []).forEach((l) => l(...args));
|
|
75
93
|
}
|
|
76
|
-
static
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return this.listeners[n] || (this.listeners[n] = []), (s = this.listeners[n]) == null || s.push(e), () => this.off(t, e);
|
|
94
|
+
static off(event, listener) {
|
|
95
|
+
const e = event.toString();
|
|
96
|
+
this.listeners[e] = (this.listeners[e] || []).filter((l) => l === listener);
|
|
80
97
|
}
|
|
81
|
-
static
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
98
|
+
static on(event, listener) {
|
|
99
|
+
var _a;
|
|
100
|
+
const e = event.toString();
|
|
101
|
+
if (!this.listeners[e]) this.listeners[e] = [];
|
|
102
|
+
(_a = this.listeners[e]) == null ? void 0 : _a.push(listener);
|
|
103
|
+
return () => this.off(event, listener);
|
|
104
|
+
}
|
|
105
|
+
static once(event, listener) {
|
|
106
|
+
return new Promise((res) => {
|
|
107
|
+
const unsubscribe = this.on(event, (...args) => {
|
|
108
|
+
res(args.length == 1 ? args[0] : args);
|
|
109
|
+
if (listener) listener(...args);
|
|
110
|
+
unsubscribe();
|
|
85
111
|
});
|
|
86
112
|
});
|
|
87
113
|
}
|
|
88
|
-
emit(
|
|
89
|
-
(this.listeners["*"] || []).forEach((
|
|
90
|
-
|
|
91
|
-
off(t, e) {
|
|
92
|
-
this.listeners[t] = (this.listeners[t] || []).filter((n) => n === e);
|
|
114
|
+
emit(event, ...args) {
|
|
115
|
+
(this.listeners["*"] || []).forEach((l) => l(event, ...args));
|
|
116
|
+
(this.listeners[event] || []).forEach((l) => l(...args));
|
|
93
117
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return this.listeners[t] || (this.listeners[t] = []), (n = this.listeners[t]) == null || n.push(e), () => this.off(t, e);
|
|
118
|
+
off(event, listener) {
|
|
119
|
+
this.listeners[event] = (this.listeners[event] || []).filter((l) => l === listener);
|
|
97
120
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
121
|
+
on(event, listener) {
|
|
122
|
+
var _a;
|
|
123
|
+
if (!this.listeners[event]) this.listeners[event] = [];
|
|
124
|
+
(_a = this.listeners[event]) == null ? void 0 : _a.push(listener);
|
|
125
|
+
return () => this.off(event, listener);
|
|
126
|
+
}
|
|
127
|
+
once(event, listener) {
|
|
128
|
+
return new Promise((res) => {
|
|
129
|
+
const unsubscribe = this.on(event, (...args) => {
|
|
130
|
+
res(args.length == 1 ? args[0] : args);
|
|
131
|
+
if (listener) listener(...args);
|
|
132
|
+
unsubscribe();
|
|
102
133
|
});
|
|
103
134
|
});
|
|
104
135
|
}
|
|
105
136
|
}
|
|
106
|
-
|
|
107
|
-
class
|
|
108
|
-
constructor(
|
|
109
|
-
super(
|
|
110
|
-
|
|
111
|
-
|
|
137
|
+
__publicField2(TypedEmitter, "listeners", {});
|
|
138
|
+
class CustomError extends Error {
|
|
139
|
+
constructor(message, code) {
|
|
140
|
+
super(message);
|
|
141
|
+
__publicField2(this, "_code");
|
|
142
|
+
if (code != null) this._code = code;
|
|
112
143
|
}
|
|
113
144
|
get code() {
|
|
114
145
|
return this._code || this.constructor.code;
|
|
115
146
|
}
|
|
116
|
-
set code(
|
|
117
|
-
this._code =
|
|
147
|
+
set code(c) {
|
|
148
|
+
this._code = c;
|
|
118
149
|
}
|
|
119
|
-
static from(
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
150
|
+
static from(err) {
|
|
151
|
+
const code = Number(err.statusCode) ?? Number(err.code);
|
|
152
|
+
const newErr = new this(err.message || err.toString());
|
|
153
|
+
return Object.assign(newErr, {
|
|
154
|
+
stack: err.stack,
|
|
155
|
+
...err,
|
|
156
|
+
code: code ?? void 0
|
|
125
157
|
});
|
|
126
158
|
}
|
|
127
|
-
static instanceof(
|
|
128
|
-
return
|
|
159
|
+
static instanceof(err) {
|
|
160
|
+
return err.constructor.code != void 0;
|
|
129
161
|
}
|
|
130
162
|
toString() {
|
|
131
163
|
return this.message || super.toString();
|
|
132
164
|
}
|
|
133
165
|
}
|
|
134
|
-
|
|
135
|
-
class
|
|
136
|
-
constructor(
|
|
137
|
-
super(
|
|
166
|
+
__publicField2(CustomError, "code", 500);
|
|
167
|
+
class BadRequestError extends CustomError {
|
|
168
|
+
constructor(message = "Bad Request") {
|
|
169
|
+
super(message);
|
|
138
170
|
}
|
|
139
|
-
static instanceof(
|
|
140
|
-
return
|
|
171
|
+
static instanceof(err) {
|
|
172
|
+
return err.constructor.code == this.code;
|
|
141
173
|
}
|
|
142
174
|
}
|
|
143
|
-
|
|
144
|
-
class
|
|
145
|
-
constructor(
|
|
146
|
-
super(
|
|
175
|
+
__publicField2(BadRequestError, "code", 400);
|
|
176
|
+
class UnauthorizedError extends CustomError {
|
|
177
|
+
constructor(message = "Unauthorized") {
|
|
178
|
+
super(message);
|
|
147
179
|
}
|
|
148
|
-
static instanceof(
|
|
149
|
-
return
|
|
180
|
+
static instanceof(err) {
|
|
181
|
+
return err.constructor.code == this.code;
|
|
150
182
|
}
|
|
151
183
|
}
|
|
152
|
-
|
|
153
|
-
class
|
|
154
|
-
constructor(
|
|
155
|
-
super(
|
|
184
|
+
__publicField2(UnauthorizedError, "code", 401);
|
|
185
|
+
class PaymentRequiredError extends CustomError {
|
|
186
|
+
constructor(message = "Payment Required") {
|
|
187
|
+
super(message);
|
|
156
188
|
}
|
|
157
|
-
static instanceof(
|
|
158
|
-
return
|
|
189
|
+
static instanceof(err) {
|
|
190
|
+
return err.constructor.code == this.code;
|
|
159
191
|
}
|
|
160
192
|
}
|
|
161
|
-
|
|
162
|
-
class
|
|
163
|
-
constructor(
|
|
164
|
-
super(
|
|
193
|
+
__publicField2(PaymentRequiredError, "code", 402);
|
|
194
|
+
class ForbiddenError extends CustomError {
|
|
195
|
+
constructor(message = "Forbidden") {
|
|
196
|
+
super(message);
|
|
165
197
|
}
|
|
166
|
-
static instanceof(
|
|
167
|
-
return
|
|
198
|
+
static instanceof(err) {
|
|
199
|
+
return err.constructor.code == this.code;
|
|
168
200
|
}
|
|
169
201
|
}
|
|
170
|
-
|
|
171
|
-
class
|
|
172
|
-
constructor(
|
|
173
|
-
super(
|
|
202
|
+
__publicField2(ForbiddenError, "code", 403);
|
|
203
|
+
class NotFoundError extends CustomError {
|
|
204
|
+
constructor(message = "Not Found") {
|
|
205
|
+
super(message);
|
|
174
206
|
}
|
|
175
|
-
static instanceof(
|
|
176
|
-
return
|
|
207
|
+
static instanceof(err) {
|
|
208
|
+
return err.constructor.code == this.code;
|
|
177
209
|
}
|
|
178
210
|
}
|
|
179
|
-
|
|
180
|
-
class
|
|
181
|
-
constructor(
|
|
182
|
-
super(
|
|
211
|
+
__publicField2(NotFoundError, "code", 404);
|
|
212
|
+
class MethodNotAllowedError extends CustomError {
|
|
213
|
+
constructor(message = "Method Not Allowed") {
|
|
214
|
+
super(message);
|
|
183
215
|
}
|
|
184
|
-
static instanceof(
|
|
185
|
-
return
|
|
216
|
+
static instanceof(err) {
|
|
217
|
+
return err.constructor.code == this.code;
|
|
186
218
|
}
|
|
187
219
|
}
|
|
188
|
-
|
|
189
|
-
class
|
|
190
|
-
constructor(
|
|
191
|
-
super(
|
|
220
|
+
__publicField2(MethodNotAllowedError, "code", 405);
|
|
221
|
+
class NotAcceptableError extends CustomError {
|
|
222
|
+
constructor(message = "Not Acceptable") {
|
|
223
|
+
super(message);
|
|
192
224
|
}
|
|
193
|
-
static instanceof(
|
|
194
|
-
return
|
|
225
|
+
static instanceof(err) {
|
|
226
|
+
return err.constructor.code == this.code;
|
|
195
227
|
}
|
|
196
228
|
}
|
|
197
|
-
|
|
198
|
-
class
|
|
199
|
-
constructor(
|
|
200
|
-
super(
|
|
229
|
+
__publicField2(NotAcceptableError, "code", 406);
|
|
230
|
+
class InternalServerError extends CustomError {
|
|
231
|
+
constructor(message = "Internal Server Error") {
|
|
232
|
+
super(message);
|
|
201
233
|
}
|
|
202
|
-
static instanceof(
|
|
203
|
-
return
|
|
234
|
+
static instanceof(err) {
|
|
235
|
+
return err.constructor.code == this.code;
|
|
204
236
|
}
|
|
205
237
|
}
|
|
206
|
-
|
|
207
|
-
class
|
|
208
|
-
constructor(
|
|
209
|
-
super(
|
|
238
|
+
__publicField2(InternalServerError, "code", 500);
|
|
239
|
+
class NotImplementedError extends CustomError {
|
|
240
|
+
constructor(message = "Not Implemented") {
|
|
241
|
+
super(message);
|
|
210
242
|
}
|
|
211
|
-
static instanceof(
|
|
212
|
-
return
|
|
243
|
+
static instanceof(err) {
|
|
244
|
+
return err.constructor.code == this.code;
|
|
213
245
|
}
|
|
214
246
|
}
|
|
215
|
-
|
|
216
|
-
class
|
|
217
|
-
constructor(
|
|
218
|
-
super(
|
|
247
|
+
__publicField2(NotImplementedError, "code", 501);
|
|
248
|
+
class BadGatewayError extends CustomError {
|
|
249
|
+
constructor(message = "Bad Gateway") {
|
|
250
|
+
super(message);
|
|
219
251
|
}
|
|
220
|
-
static instanceof(
|
|
221
|
-
return
|
|
252
|
+
static instanceof(err) {
|
|
253
|
+
return err.constructor.code == this.code;
|
|
222
254
|
}
|
|
223
255
|
}
|
|
224
|
-
|
|
225
|
-
class
|
|
226
|
-
constructor(
|
|
227
|
-
super(
|
|
256
|
+
__publicField2(BadGatewayError, "code", 502);
|
|
257
|
+
class ServiceUnavailableError extends CustomError {
|
|
258
|
+
constructor(message = "Service Unavailable") {
|
|
259
|
+
super(message);
|
|
228
260
|
}
|
|
229
|
-
static instanceof(
|
|
230
|
-
return
|
|
261
|
+
static instanceof(err) {
|
|
262
|
+
return err.constructor.code == this.code;
|
|
231
263
|
}
|
|
232
264
|
}
|
|
233
|
-
|
|
234
|
-
class
|
|
235
|
-
constructor(
|
|
236
|
-
super(
|
|
265
|
+
__publicField2(ServiceUnavailableError, "code", 503);
|
|
266
|
+
class GatewayTimeoutError extends CustomError {
|
|
267
|
+
constructor(message = "Gateway Timeout") {
|
|
268
|
+
super(message);
|
|
237
269
|
}
|
|
238
|
-
static instanceof(
|
|
239
|
-
return
|
|
270
|
+
static instanceof(err) {
|
|
271
|
+
return err.constructor.code == this.code;
|
|
240
272
|
}
|
|
241
273
|
}
|
|
242
|
-
|
|
243
|
-
function
|
|
244
|
-
|
|
245
|
-
switch (r) {
|
|
274
|
+
__publicField2(GatewayTimeoutError, "code", 504);
|
|
275
|
+
function errorFromCode(code, message) {
|
|
276
|
+
switch (code) {
|
|
246
277
|
case 400:
|
|
247
|
-
return new
|
|
278
|
+
return new BadRequestError(message);
|
|
248
279
|
case 401:
|
|
249
|
-
return new
|
|
280
|
+
return new UnauthorizedError(message);
|
|
250
281
|
case 402:
|
|
251
|
-
return new
|
|
282
|
+
return new PaymentRequiredError(message);
|
|
252
283
|
case 403:
|
|
253
|
-
return new
|
|
284
|
+
return new ForbiddenError(message);
|
|
254
285
|
case 404:
|
|
255
|
-
return new
|
|
286
|
+
return new NotFoundError(message);
|
|
256
287
|
case 405:
|
|
257
|
-
return new
|
|
288
|
+
return new MethodNotAllowedError(message);
|
|
258
289
|
case 406:
|
|
259
|
-
return new
|
|
290
|
+
return new NotAcceptableError(message);
|
|
260
291
|
case 500:
|
|
261
|
-
return new
|
|
292
|
+
return new InternalServerError(message);
|
|
262
293
|
case 501:
|
|
263
|
-
return new
|
|
294
|
+
return new NotImplementedError(message);
|
|
264
295
|
case 502:
|
|
265
|
-
return new
|
|
296
|
+
return new BadGatewayError(message);
|
|
266
297
|
case 503:
|
|
267
|
-
return new
|
|
298
|
+
return new ServiceUnavailableError(message);
|
|
268
299
|
case 504:
|
|
269
|
-
return new
|
|
300
|
+
return new GatewayTimeoutError(message);
|
|
270
301
|
default:
|
|
271
|
-
return new
|
|
302
|
+
return new CustomError(message, code);
|
|
272
303
|
}
|
|
273
304
|
}
|
|
274
|
-
const
|
|
275
|
-
constructor(
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
this.url =
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
305
|
+
const _Http = class _Http2 {
|
|
306
|
+
constructor(defaults = {}) {
|
|
307
|
+
__publicField2(this, "interceptors", {});
|
|
308
|
+
__publicField2(this, "headers", {});
|
|
309
|
+
__publicField2(this, "url");
|
|
310
|
+
this.url = defaults.url ?? null;
|
|
311
|
+
this.headers = defaults.headers || {};
|
|
312
|
+
if (defaults.interceptors) {
|
|
313
|
+
defaults.interceptors.forEach((i) => _Http2.addInterceptor(i));
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
static addInterceptor(fn) {
|
|
317
|
+
const key = Object.keys(_Http2.interceptors).length.toString();
|
|
318
|
+
_Http2.interceptors[key] = fn;
|
|
319
|
+
return () => {
|
|
320
|
+
_Http2.interceptors[key] = null;
|
|
285
321
|
};
|
|
286
322
|
}
|
|
287
|
-
addInterceptor(
|
|
288
|
-
const
|
|
289
|
-
|
|
290
|
-
|
|
323
|
+
addInterceptor(fn) {
|
|
324
|
+
const key = Object.keys(this.interceptors).length.toString();
|
|
325
|
+
this.interceptors[key] = fn;
|
|
326
|
+
return () => {
|
|
327
|
+
this.interceptors[key] = null;
|
|
291
328
|
};
|
|
292
329
|
}
|
|
293
|
-
request(
|
|
294
|
-
var
|
|
295
|
-
if (!this.url && !
|
|
296
|
-
let
|
|
297
|
-
if (
|
|
298
|
-
|
|
299
|
-
|
|
330
|
+
request(opts = {}) {
|
|
331
|
+
var _a;
|
|
332
|
+
if (!this.url && !opts.url) throw new Error("URL needs to be set");
|
|
333
|
+
let url = (((_a = opts.url) == null ? void 0 : _a.startsWith("http")) ? opts.url : (this.url || "") + (opts.url || "")).replace(/([^:]\/)\/+/g, "$1");
|
|
334
|
+
if (opts.fragment) url.includes("#") ? url.replace(/#.*(\?|\n)/g, (match, arg1) => `#${opts.fragment}${arg1}`) : url += "#" + opts.fragment;
|
|
335
|
+
if (opts.query) {
|
|
336
|
+
const q = Array.isArray(opts.query) ? opts.query : Object.keys(opts.query).map((k) => ({ key: k, value: opts.query[k] }));
|
|
337
|
+
url += (url.includes("?") ? "&" : "?") + q.map((q2) => `${q2.key}=${q2.value}`).join("&");
|
|
300
338
|
}
|
|
301
|
-
const
|
|
302
|
-
"Content-Type":
|
|
303
|
-
...
|
|
339
|
+
const headers = clean({
|
|
340
|
+
"Content-Type": !opts.body ? void 0 : opts.body instanceof FormData ? "multipart/form-data" : "application/json",
|
|
341
|
+
..._Http2.headers,
|
|
304
342
|
...this.headers,
|
|
305
|
-
...
|
|
343
|
+
...opts.headers
|
|
306
344
|
});
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
345
|
+
if (typeof opts.body == "object" && opts.body != null && headers["Content-Type"] == "application/json")
|
|
346
|
+
opts.body = JSON.stringify(opts.body);
|
|
347
|
+
return new PromiseProgress((res, rej, prog) => {
|
|
348
|
+
try {
|
|
349
|
+
fetch(url, {
|
|
350
|
+
headers,
|
|
351
|
+
method: opts.method || (opts.body ? "POST" : "GET"),
|
|
352
|
+
body: opts.body
|
|
353
|
+
}).then(async (resp) => {
|
|
354
|
+
var _a2, _b;
|
|
355
|
+
for (let fn of [...Object.values(_Http2.interceptors), ...Object.values(this.interceptors)]) {
|
|
356
|
+
await new Promise((res2) => fn(resp, () => res2()));
|
|
357
|
+
}
|
|
358
|
+
const contentLength = resp.headers.get("Content-Length");
|
|
359
|
+
const total = contentLength ? parseInt(contentLength, 10) : 0;
|
|
360
|
+
let loaded = 0;
|
|
361
|
+
const reader = (_a2 = resp.body) == null ? void 0 : _a2.getReader();
|
|
362
|
+
const stream = new ReadableStream({
|
|
363
|
+
start(controller) {
|
|
364
|
+
function push() {
|
|
365
|
+
reader == null ? void 0 : reader.read().then((event) => {
|
|
366
|
+
if (event.done) return controller.close();
|
|
367
|
+
loaded += event.value.byteLength;
|
|
368
|
+
prog(loaded / total);
|
|
369
|
+
controller.enqueue(event.value);
|
|
370
|
+
push();
|
|
371
|
+
}).catch((error) => controller.error(error));
|
|
372
|
+
}
|
|
373
|
+
push();
|
|
325
374
|
}
|
|
326
|
-
|
|
375
|
+
});
|
|
376
|
+
resp.data = new Response(stream);
|
|
377
|
+
if (opts.decode == null || opts.decode) {
|
|
378
|
+
const content = (_b = resp.headers.get("Content-Type")) == null ? void 0 : _b.toLowerCase();
|
|
379
|
+
if (content == null ? void 0 : content.includes("form")) resp.data = await resp.data.formData();
|
|
380
|
+
else if (content == null ? void 0 : content.includes("json")) resp.data = await resp.data.json();
|
|
381
|
+
else if (content == null ? void 0 : content.includes("text")) resp.data = await resp.data.text();
|
|
382
|
+
else if (content == null ? void 0 : content.includes("application")) resp.data = await resp.data.blob();
|
|
327
383
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
});
|
|
384
|
+
if (resp.ok) res(resp);
|
|
385
|
+
else rej(resp);
|
|
386
|
+
}).catch((err) => rej(err));
|
|
387
|
+
} catch (err) {
|
|
388
|
+
rej(err);
|
|
389
|
+
}
|
|
335
390
|
});
|
|
336
391
|
}
|
|
337
392
|
};
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
393
|
+
__publicField2(_Http, "interceptors", {});
|
|
394
|
+
__publicField2(_Http, "headers", {});
|
|
395
|
+
function jwtDecode(token) {
|
|
396
|
+
const base64 = token.split(".")[1].replace(/-/g, "+").replace(/_/g, "/");
|
|
397
|
+
return JSONAttemptParse(decodeURIComponent(atob(base64).split("").map(function(c) {
|
|
398
|
+
return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
|
|
343
399
|
}).join("")));
|
|
344
400
|
}
|
|
345
|
-
const
|
|
401
|
+
const CliEffects = {
|
|
346
402
|
CLEAR: "\x1B[0m",
|
|
347
403
|
BRIGHT: "\x1B[1m",
|
|
348
404
|
DIM: "\x1B[2m",
|
|
@@ -350,7 +406,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
350
406
|
BLINK: "\x1B[5m",
|
|
351
407
|
REVERSE: "\x1B[7m",
|
|
352
408
|
HIDDEN: "\x1B[8m"
|
|
353
|
-
}
|
|
409
|
+
};
|
|
410
|
+
const CliForeground = {
|
|
354
411
|
BLACK: "\x1B[30m",
|
|
355
412
|
RED: "\x1B[31m",
|
|
356
413
|
GREEN: "\x1B[32m",
|
|
@@ -368,191 +425,59 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
368
425
|
LIGHT_CYAN: "\x1B[96m",
|
|
369
426
|
WHITE: "\x1B[97m"
|
|
370
427
|
};
|
|
371
|
-
const
|
|
372
|
-
constructor(
|
|
373
|
-
super()
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
const
|
|
379
|
-
return
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
}
|
|
405
|
-
error(...
|
|
406
|
-
if (
|
|
407
|
-
const
|
|
408
|
-
|
|
428
|
+
const _Logger = class _Logger2 extends TypedEmitter {
|
|
429
|
+
constructor(namespace) {
|
|
430
|
+
super();
|
|
431
|
+
this.namespace = namespace;
|
|
432
|
+
}
|
|
433
|
+
format(...text) {
|
|
434
|
+
const now = /* @__PURE__ */ new Date();
|
|
435
|
+
const timestamp = `${now.getFullYear()}-${now.getMonth() + 1}-${now.getDate()} ${now.getHours().toString().padStart(2, "0")}:${now.getMinutes().toString().padStart(2, "0")}:${now.getSeconds().toString().padStart(2, "0")}.${now.getMilliseconds().toString().padEnd(3, "0")}`;
|
|
436
|
+
return `${timestamp}${this.namespace ? ` [${this.namespace}]` : ""} ${text.map((t) => typeof t == "string" ? t : JSONSanitize(t, 2)).join(" ")}`;
|
|
437
|
+
}
|
|
438
|
+
debug(...args) {
|
|
439
|
+
if (_Logger2.LOG_LEVEL < 4) return;
|
|
440
|
+
const str = this.format(...args);
|
|
441
|
+
_Logger2.emit(4, str);
|
|
442
|
+
console.debug(CliForeground.LIGHT_GREY + str + CliEffects.CLEAR);
|
|
443
|
+
}
|
|
444
|
+
log(...args) {
|
|
445
|
+
if (_Logger2.LOG_LEVEL < 3) return;
|
|
446
|
+
const str = this.format(...args);
|
|
447
|
+
_Logger2.emit(3, str);
|
|
448
|
+
console.log(CliEffects.CLEAR + str);
|
|
449
|
+
}
|
|
450
|
+
info(...args) {
|
|
451
|
+
if (_Logger2.LOG_LEVEL < 2) return;
|
|
452
|
+
const str = this.format(...args);
|
|
453
|
+
_Logger2.emit(2, str);
|
|
454
|
+
console.info(CliForeground.BLUE + str + CliEffects.CLEAR);
|
|
455
|
+
}
|
|
456
|
+
warn(...args) {
|
|
457
|
+
if (_Logger2.LOG_LEVEL < 1) return;
|
|
458
|
+
const str = this.format(...args);
|
|
459
|
+
_Logger2.emit(1, str);
|
|
460
|
+
console.warn(CliForeground.YELLOW + str + CliEffects.CLEAR);
|
|
461
|
+
}
|
|
462
|
+
error(...args) {
|
|
463
|
+
if (_Logger2.LOG_LEVEL < 0) return;
|
|
464
|
+
const str = this.format(...args);
|
|
465
|
+
_Logger2.emit(0, str);
|
|
466
|
+
console.error(CliForeground.RED + str + CliEffects.CLEAR);
|
|
409
467
|
}
|
|
410
468
|
};
|
|
411
|
-
|
|
412
|
-
function
|
|
413
|
-
return new Promise((
|
|
469
|
+
__publicField2(_Logger, "LOG_LEVEL", 4);
|
|
470
|
+
function sleep(ms) {
|
|
471
|
+
return new Promise((res) => setTimeout(res, ms));
|
|
414
472
|
}
|
|
415
|
-
async function
|
|
416
|
-
|
|
473
|
+
async function sleepWhile(fn, checkInterval = 100) {
|
|
474
|
+
while (await fn()) await sleep(checkInterval);
|
|
417
475
|
}
|
|
418
|
-
var $ = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, xt = {}, S = {};
|
|
419
|
-
Object.defineProperty(S, "__esModule", { value: true });
|
|
420
|
-
S.persist = S.Persist = void 0;
|
|
421
|
-
class st {
|
|
422
|
-
/**
|
|
423
|
-
* @param {string} key Primary key value will be stored under
|
|
424
|
-
* @param {PersistOptions<T>} options Configure using {@link PersistOptions}
|
|
425
|
-
*/
|
|
426
|
-
constructor(t, e = {}) {
|
|
427
|
-
c(this, "key");
|
|
428
|
-
c(this, "options");
|
|
429
|
-
c(this, "storage");
|
|
430
|
-
c(this, "watches", {});
|
|
431
|
-
c(this, "_value");
|
|
432
|
-
this.key = t, this.options = e, this.storage = e.storage || localStorage, this.load();
|
|
433
|
-
}
|
|
434
|
-
/** Current value or default if undefined */
|
|
435
|
-
get value() {
|
|
436
|
-
var t;
|
|
437
|
-
return this._value !== void 0 ? this._value : (t = this.options) == null ? void 0 : t.default;
|
|
438
|
-
}
|
|
439
|
-
/** Set value with proxy object wrapper to sync future changes */
|
|
440
|
-
set value(t) {
|
|
441
|
-
t == null || typeof t != "object" ? this._value = t : this._value = new Proxy(t, {
|
|
442
|
-
get: (e, n) => typeof e[n] == "function" ? (...o) => {
|
|
443
|
-
const i = e[n](...o);
|
|
444
|
-
return this.save(), i;
|
|
445
|
-
} : e[n],
|
|
446
|
-
set: (e, n, s) => (e[n] = s, this.save(), true)
|
|
447
|
-
}), this.save();
|
|
448
|
-
}
|
|
449
|
-
/** Notify listeners of change */
|
|
450
|
-
notify(t) {
|
|
451
|
-
Object.values(this.watches).forEach((e) => e(t));
|
|
452
|
-
}
|
|
453
|
-
/** Delete value from storage */
|
|
454
|
-
clear() {
|
|
455
|
-
this.storage.removeItem(this.key);
|
|
456
|
-
}
|
|
457
|
-
/** Save current value to storage */
|
|
458
|
-
save() {
|
|
459
|
-
this._value === void 0 ? this.clear() : this.storage.setItem(this.key, JSON.stringify(this._value)), this.notify(this.value);
|
|
460
|
-
}
|
|
461
|
-
/** Load value from storage */
|
|
462
|
-
load() {
|
|
463
|
-
if (this.storage[this.key] != null) {
|
|
464
|
-
let t = JSON.parse(this.storage.getItem(this.key));
|
|
465
|
-
t != null && typeof t == "object" && this.options.type && (t.__proto__ = this.options.type.prototype), this.value = t;
|
|
466
|
-
} else
|
|
467
|
-
this.value = this.options.default || void 0;
|
|
468
|
-
}
|
|
469
|
-
/**
|
|
470
|
-
* Callback function which is run when there are changes
|
|
471
|
-
*
|
|
472
|
-
* @param {(value: T) => any} fn Callback will run on each change; it's passed the next value & it's return is ignored
|
|
473
|
-
* @returns {() => void} Function which will unsubscribe the watch/callback when called
|
|
474
|
-
*/
|
|
475
|
-
watch(t) {
|
|
476
|
-
const e = Object.keys(this.watches).length;
|
|
477
|
-
return this.watches[e] = t, () => {
|
|
478
|
-
delete this.watches[e];
|
|
479
|
-
};
|
|
480
|
-
}
|
|
481
|
-
/**
|
|
482
|
-
* Return value as JSON string
|
|
483
|
-
*
|
|
484
|
-
* @returns {string} Stringified object as JSON
|
|
485
|
-
*/
|
|
486
|
-
toString() {
|
|
487
|
-
return JSON.stringify(this.value);
|
|
488
|
-
}
|
|
489
|
-
/**
|
|
490
|
-
* Return current value
|
|
491
|
-
*
|
|
492
|
-
* @returns {T} Current value
|
|
493
|
-
*/
|
|
494
|
-
valueOf() {
|
|
495
|
-
return this.value;
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
S.Persist = st;
|
|
499
|
-
function Bt(r) {
|
|
500
|
-
return (t, e) => {
|
|
501
|
-
const n = (r == null ? void 0 : r.key) || `${t.constructor.name}.${e.toString()}`, s = new st(n, r);
|
|
502
|
-
Object.defineProperty(t, e, {
|
|
503
|
-
get: function() {
|
|
504
|
-
return s.value;
|
|
505
|
-
},
|
|
506
|
-
set: function(o) {
|
|
507
|
-
s.value = o;
|
|
508
|
-
}
|
|
509
|
-
});
|
|
510
|
-
};
|
|
511
|
-
}
|
|
512
|
-
S.persist = Bt;
|
|
513
|
-
var L = {};
|
|
514
|
-
Object.defineProperty(L, "__esModule", { value: true });
|
|
515
|
-
L.MemoryStorage = void 0;
|
|
516
|
-
class At {
|
|
517
|
-
get length() {
|
|
518
|
-
return Object.keys(this).length;
|
|
519
|
-
}
|
|
520
|
-
clear() {
|
|
521
|
-
Object.keys(this).forEach((t) => this.removeItem(t));
|
|
522
|
-
}
|
|
523
|
-
getItem(t) {
|
|
524
|
-
return this[t];
|
|
525
|
-
}
|
|
526
|
-
key(t) {
|
|
527
|
-
return Object.keys(this)[t];
|
|
528
|
-
}
|
|
529
|
-
removeItem(t) {
|
|
530
|
-
delete this[t];
|
|
531
|
-
}
|
|
532
|
-
setItem(t, e) {
|
|
533
|
-
this[t] = e;
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
L.MemoryStorage = At;
|
|
537
|
-
(function(r) {
|
|
538
|
-
var t = $ && $.__createBinding || (Object.create ? function(n, s, o, i) {
|
|
539
|
-
i === void 0 && (i = o);
|
|
540
|
-
var a = Object.getOwnPropertyDescriptor(s, o);
|
|
541
|
-
(!a || ("get" in a ? !s.__esModule : a.writable || a.configurable)) && (a = { enumerable: true, get: function() {
|
|
542
|
-
return s[o];
|
|
543
|
-
} }), Object.defineProperty(n, i, a);
|
|
544
|
-
} : function(n, s, o, i) {
|
|
545
|
-
i === void 0 && (i = o), n[i] = s[o];
|
|
546
|
-
}), e = $ && $.__exportStar || function(n, s) {
|
|
547
|
-
for (var o in n) o !== "default" && !Object.prototype.hasOwnProperty.call(s, o) && t(s, n, o);
|
|
548
|
-
};
|
|
549
|
-
Object.defineProperty(r, "__esModule", { value: true }), e(S, r), e(L, r);
|
|
550
|
-
})(xt);
|
|
551
476
|
var extendStatics = function(d, b) {
|
|
552
477
|
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
553
478
|
d2.__proto__ = b2;
|
|
554
479
|
} || function(d2, b2) {
|
|
555
|
-
for (var
|
|
480
|
+
for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p];
|
|
556
481
|
};
|
|
557
482
|
return extendStatics(d, b);
|
|
558
483
|
};
|
|
@@ -955,8 +880,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
955
880
|
var observable = function() {
|
|
956
881
|
return typeof Symbol === "function" && Symbol.observable || "@@observable";
|
|
957
882
|
}();
|
|
958
|
-
function identity(
|
|
959
|
-
return
|
|
883
|
+
function identity(x) {
|
|
884
|
+
return x;
|
|
960
885
|
}
|
|
961
886
|
function pipeFromArray(fns) {
|
|
962
887
|
if (fns.length === 0) {
|
|
@@ -1037,8 +962,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1037
962
|
promiseCtor = getPromiseCtor(promiseCtor);
|
|
1038
963
|
return new promiseCtor(function(resolve, reject) {
|
|
1039
964
|
var value;
|
|
1040
|
-
_this.subscribe(function(
|
|
1041
|
-
return value =
|
|
965
|
+
_this.subscribe(function(x) {
|
|
966
|
+
return value = x;
|
|
1042
967
|
}, function(err) {
|
|
1043
968
|
return reject(err);
|
|
1044
969
|
}, function() {
|
|
@@ -1674,7 +1599,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1674
1599
|
login(spoke, login, password, twoFactor) {
|
|
1675
1600
|
return fetch(`${this.api.url}login`, {
|
|
1676
1601
|
method: "POST",
|
|
1677
|
-
body:
|
|
1602
|
+
body: formData(clean({
|
|
1678
1603
|
realm: spoke.trim(),
|
|
1679
1604
|
login: login.trim(),
|
|
1680
1605
|
password: password.trim(),
|
|
@@ -1683,7 +1608,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1683
1608
|
}))
|
|
1684
1609
|
}).then(async (resp) => {
|
|
1685
1610
|
const data = await resp.json().catch(() => ({}));
|
|
1686
|
-
if (!resp.ok || data["error"]) throw Object.assign(
|
|
1611
|
+
if (!resp.ok || data["error"]) throw Object.assign(errorFromCode(resp.status, data.error) || {}, data);
|
|
1687
1612
|
this.api.token = data["token"];
|
|
1688
1613
|
return data;
|
|
1689
1614
|
});
|
|
@@ -1696,7 +1621,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1696
1621
|
loginGuest() {
|
|
1697
1622
|
return fetch(`${this.api.url}guest`).then(async (resp) => {
|
|
1698
1623
|
const data = await resp.json().catch(() => ({}));
|
|
1699
|
-
if (!resp.ok || data["error"]) throw Object.assign(
|
|
1624
|
+
if (!resp.ok || data["error"]) throw Object.assign(errorFromCode(resp.status, data.error) || {}, data);
|
|
1700
1625
|
this.api.token = data["token"];
|
|
1701
1626
|
return data;
|
|
1702
1627
|
});
|
|
@@ -1788,11 +1713,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1788
1713
|
data.append("", file, file.name);
|
|
1789
1714
|
return fetch(this.url, {
|
|
1790
1715
|
method: "POST",
|
|
1791
|
-
headers:
|
|
1716
|
+
headers: clean({ "Authorization": this.api.token ? `Bearer ${this.api.token}` : "" }),
|
|
1792
1717
|
body: data
|
|
1793
1718
|
}).then(async (resp) => {
|
|
1794
1719
|
const data2 = await resp.json().catch(() => ({}));
|
|
1795
|
-
if (!resp.ok || data2["error"]) throw Object.assign(
|
|
1720
|
+
if (!resp.ok || data2["error"]) throw Object.assign(errorFromCode(resp.status, data2.error) || {}, data2);
|
|
1796
1721
|
return resp;
|
|
1797
1722
|
});
|
|
1798
1723
|
})).then(async (files2) => {
|
|
@@ -2187,7 +2112,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2187
2112
|
new Slice(this.slice, this.api).select().exec().rows().then((rows) => this.cache = rows);
|
|
2188
2113
|
if (!this.unsubscribe) this.unsubscribe = this.api.socket.sliceEvents(this.slice, (event) => {
|
|
2189
2114
|
const ids = [...event.data.new, ...event.data.changed];
|
|
2190
|
-
new Slice(this.slice, this.api).select(ids).exec().rows().then((rows) => this.cache = [...this.cache.filter((
|
|
2115
|
+
new Slice(this.slice, this.api).select(ids).exec().rows().then((rows) => this.cache = [...this.cache.filter((c) => c.id != null && !ids.includes(c.id)), ...rows]);
|
|
2191
2116
|
this.cache = this.cache.filter((v) => v.id && !event.data.lost.includes(v.id));
|
|
2192
2117
|
});
|
|
2193
2118
|
return this.cache$;
|
|
@@ -2340,7 +2265,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2340
2265
|
*/
|
|
2341
2266
|
sliceEvents(slice, callback) {
|
|
2342
2267
|
let cancelled = false;
|
|
2343
|
-
|
|
2268
|
+
sleepWhile(() => !this.connected).then(() => {
|
|
2344
2269
|
if (!cancelled) this.send({ onSliceEvents: slice });
|
|
2345
2270
|
});
|
|
2346
2271
|
const unsubscribe = this.addListener((event) => {
|
|
@@ -2449,21 +2374,20 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2449
2374
|
/** Get session info from JWT payload */
|
|
2450
2375
|
get jwtPayload() {
|
|
2451
2376
|
if (!this.token) return null;
|
|
2452
|
-
return
|
|
2377
|
+
return jwtDecode(this.token);
|
|
2453
2378
|
}
|
|
2454
2379
|
_request(req, options = {}) {
|
|
2455
2380
|
return fetch(this.url, {
|
|
2456
2381
|
method: "POST",
|
|
2457
|
-
headers:
|
|
2382
|
+
headers: clean({
|
|
2458
2383
|
Authorization: this.token ? `Bearer ${this.token}` : void 0,
|
|
2459
2384
|
"Content-Type": "application/json"
|
|
2460
2385
|
}),
|
|
2461
2386
|
body: JSON.stringify(Api.translateTokens(req))
|
|
2462
2387
|
}).then(async (resp) => {
|
|
2463
|
-
|
|
2464
|
-
|
|
2388
|
+
let data = JSONAttemptParse(await resp.text());
|
|
2389
|
+
if (!resp.ok || (data == null ? void 0 : data.error)) throw Object.assign(errorFromCode(resp.status, data.error), data);
|
|
2465
2390
|
if (!options.raw) data = Api.translateTokens(data);
|
|
2466
|
-
if (data["error"]) throw Object.assign(Yt(resp.status, data["error"]) || {}, data);
|
|
2467
2391
|
return data;
|
|
2468
2392
|
});
|
|
2469
2393
|
}
|