@centia-io/sdk 0.0.56 → 0.0.58
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/centia-io-sdk.cjs +326 -174
- package/dist/centia-io-sdk.d.cts +5 -2
- package/dist/centia-io-sdk.d.cts.map +1 -1
- package/dist/centia-io-sdk.d.ts +5 -2
- package/dist/centia-io-sdk.d.ts.map +1 -1
- package/dist/centia-io-sdk.js +326 -174
- package/dist/centia-io-sdk.js.map +1 -1
- package/dist/centia-io-sdk.umd.js +326 -174
- package/package.json +1 -1
|
@@ -93,14 +93,16 @@
|
|
|
93
93
|
*/
|
|
94
94
|
const generatePkceChallenge = async () => {
|
|
95
95
|
const generateRandomString = () => {
|
|
96
|
+
var _globalThis$crypto;
|
|
96
97
|
const array = new Uint32Array(28);
|
|
97
|
-
if (globalThis.crypto
|
|
98
|
+
if ((_globalThis$crypto = globalThis.crypto) === null || _globalThis$crypto === void 0 ? void 0 : _globalThis$crypto.getRandomValues) crypto.getRandomValues(array);
|
|
98
99
|
else for (let i = 0; i < array.length; i++) array[i] = Math.random() * 4294967295 >>> 0;
|
|
99
100
|
return Array.from(array, (dec) => ("0" + dec.toString(16)).substr(-2)).join("");
|
|
100
101
|
};
|
|
101
102
|
const sha256 = async (plain) => {
|
|
103
|
+
var _globalThis$crypto2;
|
|
102
104
|
const data = new TextEncoder().encode(plain);
|
|
103
|
-
if (globalThis.crypto
|
|
105
|
+
if ((_globalThis$crypto2 = globalThis.crypto) === null || _globalThis$crypto2 === void 0 ? void 0 : _globalThis$crypto2.subtle) return crypto.subtle.digest("SHA-256", data);
|
|
104
106
|
return sha256Fallback(data);
|
|
105
107
|
};
|
|
106
108
|
const base64urlEncode = (str) => {
|
|
@@ -267,7 +269,7 @@
|
|
|
267
269
|
setTokens({
|
|
268
270
|
accessToken: data.access_token,
|
|
269
271
|
refreshToken,
|
|
270
|
-
idToken: data
|
|
272
|
+
idToken: data === null || data === void 0 ? void 0 : data.id_token
|
|
271
273
|
});
|
|
272
274
|
console.log("Access token refreshed");
|
|
273
275
|
} catch (e) {
|
|
@@ -280,16 +282,16 @@
|
|
|
280
282
|
getStorage().setItem("gc2_tokens", JSON.stringify({
|
|
281
283
|
"accessToken": tokens.accessToken,
|
|
282
284
|
"refreshToken": tokens.refreshToken,
|
|
283
|
-
"idToken": tokens
|
|
285
|
+
"idToken": (tokens === null || tokens === void 0 ? void 0 : tokens.idToken) || ""
|
|
284
286
|
}));
|
|
285
287
|
};
|
|
286
288
|
const getTokens = () => {
|
|
287
289
|
const str = getStorage().getItem("gc2_tokens");
|
|
288
290
|
const tokens = str ? JSON.parse(str) : {};
|
|
289
291
|
return {
|
|
290
|
-
accessToken: tokens
|
|
291
|
-
refreshToken: tokens
|
|
292
|
-
idToken: tokens
|
|
292
|
+
accessToken: (tokens === null || tokens === void 0 ? void 0 : tokens.accessToken) || "",
|
|
293
|
+
refreshToken: (tokens === null || tokens === void 0 ? void 0 : tokens.refreshToken) || "",
|
|
294
|
+
idToken: (tokens === null || tokens === void 0 ? void 0 : tokens.idToken) || ""
|
|
293
295
|
};
|
|
294
296
|
};
|
|
295
297
|
const setOptions = (options) => {
|
|
@@ -304,9 +306,9 @@
|
|
|
304
306
|
const str = getStorage().getItem("gc2_options");
|
|
305
307
|
const options = str ? JSON.parse(str) : {};
|
|
306
308
|
return {
|
|
307
|
-
clientId: options
|
|
308
|
-
host: options
|
|
309
|
-
redirectUri: options
|
|
309
|
+
clientId: (options === null || options === void 0 ? void 0 : options.clientId) || "",
|
|
310
|
+
host: (options === null || options === void 0 ? void 0 : options.host) || "",
|
|
311
|
+
redirectUri: (options === null || options === void 0 ? void 0 : options.redirectUri) || ""
|
|
310
312
|
};
|
|
311
313
|
};
|
|
312
314
|
const clearTokens = () => {
|
|
@@ -365,15 +367,19 @@
|
|
|
365
367
|
return response.json();
|
|
366
368
|
}
|
|
367
369
|
async getDeviceCode() {
|
|
368
|
-
|
|
369
|
-
|
|
370
|
+
var _this = this;
|
|
371
|
+
var _this$options$deviceU;
|
|
372
|
+
const path = (_this$options$deviceU = _this.options.deviceUri) !== null && _this$options$deviceU !== void 0 ? _this$options$deviceU : `${_this.host}/api/v4/oauth/device`;
|
|
373
|
+
return _this.request(_this.buildUrl(path), "POST", { client_id: _this.options.clientId });
|
|
370
374
|
}
|
|
371
375
|
async pollToken(deviceCode, interval) {
|
|
372
|
-
|
|
376
|
+
var _this2 = this;
|
|
377
|
+
var _this$options$tokenUr;
|
|
378
|
+
const path = (_this$options$tokenUr = _this2.options.tokenUri) !== null && _this$options$tokenUr !== void 0 ? _this$options$tokenUr : `${_this2.host}/api/v4/oauth`;
|
|
373
379
|
const getToken = async () => {
|
|
374
380
|
try {
|
|
375
|
-
return await
|
|
376
|
-
client_id:
|
|
381
|
+
return await _this2.request(_this2.buildUrl(path), "POST", {
|
|
382
|
+
client_id: _this2.options.clientId,
|
|
377
383
|
device_code: deviceCode,
|
|
378
384
|
grant_type: "device_code"
|
|
379
385
|
});
|
|
@@ -392,10 +398,11 @@
|
|
|
392
398
|
return response;
|
|
393
399
|
}
|
|
394
400
|
getAuthorizationCodeURL(codeChallenge, state) {
|
|
401
|
+
var _this$options$authUri;
|
|
395
402
|
let redirectUri;
|
|
396
403
|
if (this.isCodeFlowOptions(this.options)) redirectUri = this.options.redirectUri;
|
|
397
404
|
else throw new Error("CodeFlow options required for this operation");
|
|
398
|
-
const base = this.options.authUri
|
|
405
|
+
const base = (_this$options$authUri = this.options.authUri) !== null && _this$options$authUri !== void 0 ? _this$options$authUri : `${this.host}/auth/`;
|
|
399
406
|
const params = new URLSearchParams();
|
|
400
407
|
const nonce = getNonce();
|
|
401
408
|
params.set("response_type", "code");
|
|
@@ -409,8 +416,9 @@
|
|
|
409
416
|
return `${base}?${params.toString()}`;
|
|
410
417
|
}
|
|
411
418
|
getSignUpURL() {
|
|
419
|
+
var _this$options$authUri2;
|
|
412
420
|
if (!this.isSignUpOptions(this.options)) throw new Error("CodeFlow options required for this operation");
|
|
413
|
-
const base = this.options.authUri
|
|
421
|
+
const base = (_this$options$authUri2 = this.options.authUri) !== null && _this$options$authUri2 !== void 0 ? _this$options$authUri2 : `${this.host}/signup/`;
|
|
414
422
|
const params = new URLSearchParams();
|
|
415
423
|
params.set("client_id", this.options.clientId);
|
|
416
424
|
params.set("parentdb", this.options.parentDb);
|
|
@@ -418,12 +426,14 @@
|
|
|
418
426
|
return `${base}?${params.toString()}`;
|
|
419
427
|
}
|
|
420
428
|
async getAuthorizationCodeToken(code, codeVerifier) {
|
|
429
|
+
var _this3 = this;
|
|
430
|
+
var _this$options$tokenUr2;
|
|
421
431
|
let redirectUri;
|
|
422
|
-
if (
|
|
432
|
+
if (_this3.isCodeFlowOptions(_this3.options)) redirectUri = _this3.options.redirectUri;
|
|
423
433
|
else throw new Error("CodeFlow options required for this operation");
|
|
424
|
-
const path =
|
|
425
|
-
return
|
|
426
|
-
client_id:
|
|
434
|
+
const path = (_this$options$tokenUr2 = _this3.options.tokenUri) !== null && _this$options$tokenUr2 !== void 0 ? _this$options$tokenUr2 : `${_this3.host}/api/v4/oauth`;
|
|
435
|
+
return _this3.request(_this3.buildUrl(path), "POST", {
|
|
436
|
+
client_id: _this3.options.clientId,
|
|
427
437
|
redirect_uri: redirectUri,
|
|
428
438
|
grant_type: "authorization_code",
|
|
429
439
|
code,
|
|
@@ -431,16 +441,17 @@
|
|
|
431
441
|
}, "application/x-www-form-urlencoded");
|
|
432
442
|
}
|
|
433
443
|
async getPasswordToken() {
|
|
444
|
+
var _this4 = this;
|
|
434
445
|
let username, password, database;
|
|
435
|
-
if (
|
|
436
|
-
username =
|
|
437
|
-
password =
|
|
438
|
-
database =
|
|
446
|
+
if (_this4.isPasswordFlowOptions(_this4.options)) {
|
|
447
|
+
username = _this4.options.username;
|
|
448
|
+
password = _this4.options.password;
|
|
449
|
+
database = _this4.options.database;
|
|
439
450
|
} else throw new Error("PasswordFlow options required for this operation");
|
|
440
|
-
const path = `${
|
|
441
|
-
return
|
|
442
|
-
client_id:
|
|
443
|
-
client_secret:
|
|
451
|
+
const path = `${_this4.host}/api/v4/oauth`;
|
|
452
|
+
return _this4.request(_this4.buildUrl(path), "POST", {
|
|
453
|
+
client_id: _this4.options.clientId,
|
|
454
|
+
client_secret: _this4.options.clientSecret,
|
|
444
455
|
grant_type: "password",
|
|
445
456
|
username,
|
|
446
457
|
password,
|
|
@@ -448,19 +459,22 @@
|
|
|
448
459
|
});
|
|
449
460
|
}
|
|
450
461
|
async getRefreshToken(token) {
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
462
|
+
var _this5 = this;
|
|
463
|
+
var _this$options$tokenUr3;
|
|
464
|
+
const path = (_this$options$tokenUr3 = _this5.options.tokenUri) !== null && _this$options$tokenUr3 !== void 0 ? _this$options$tokenUr3 : `${_this5.host}/api/v4/oauth`;
|
|
465
|
+
return _this5.request(_this5.buildUrl(path), "POST", {
|
|
466
|
+
client_id: _this5.options.clientId,
|
|
454
467
|
grant_type: "refresh_token",
|
|
455
468
|
refresh_token: token
|
|
456
469
|
});
|
|
457
470
|
}
|
|
458
471
|
getSignOutURL() {
|
|
472
|
+
var _this$options$logoutU;
|
|
459
473
|
let redirectUri;
|
|
460
474
|
if (this.isCodeFlowOptions(this.options)) redirectUri = this.options.redirectUri;
|
|
461
475
|
else throw new Error("CodeFlow options required for this operation");
|
|
462
476
|
const params = new URLSearchParams({ redirect_uri: redirectUri });
|
|
463
|
-
return this.options.logoutUri
|
|
477
|
+
return (_this$options$logoutU = this.options.logoutUri) !== null && _this$options$logoutU !== void 0 ? _this$options$logoutU : `${this.host}/signout?${params.toString()}`;
|
|
464
478
|
}
|
|
465
479
|
};
|
|
466
480
|
|
|
@@ -478,6 +492,7 @@
|
|
|
478
492
|
this.service = new Gc2Service(options);
|
|
479
493
|
}
|
|
480
494
|
async redirectHandle() {
|
|
495
|
+
var _this = this;
|
|
481
496
|
const url = window.location.search;
|
|
482
497
|
const queryParams = new URLSearchParams(url);
|
|
483
498
|
if (queryParams.get("error")) throw new Error(`Failed to redirect: ${url}`);
|
|
@@ -485,16 +500,16 @@
|
|
|
485
500
|
if (code) {
|
|
486
501
|
if (queryParams.get("state") !== getStorage().getItem("state")) throw new Error("Possible CSRF attack. Aborting login!");
|
|
487
502
|
try {
|
|
488
|
-
const { access_token, refresh_token, id_token } = await
|
|
503
|
+
const { access_token, refresh_token, id_token } = await _this.service.getAuthorizationCodeToken(code, getStorage().getItem("codeVerifier"));
|
|
489
504
|
setTokens({
|
|
490
505
|
accessToken: access_token,
|
|
491
506
|
refreshToken: refresh_token,
|
|
492
507
|
idToken: id_token
|
|
493
508
|
});
|
|
494
509
|
setOptions({
|
|
495
|
-
clientId:
|
|
496
|
-
host:
|
|
497
|
-
redirectUri:
|
|
510
|
+
clientId: _this.options.clientId,
|
|
511
|
+
host: _this.options.host,
|
|
512
|
+
redirectUri: _this.options.redirectUri
|
|
498
513
|
});
|
|
499
514
|
getStorage().removeItem("state");
|
|
500
515
|
getStorage().removeItem("codeVerifier");
|
|
@@ -509,13 +524,14 @@
|
|
|
509
524
|
throw new Error(e.message);
|
|
510
525
|
}
|
|
511
526
|
}
|
|
512
|
-
return await isLogin(
|
|
527
|
+
return await isLogin(_this.service);
|
|
513
528
|
}
|
|
514
529
|
async signIn() {
|
|
530
|
+
var _this2 = this;
|
|
515
531
|
const { state, codeVerifier, codeChallenge } = await generatePkceChallenge();
|
|
516
532
|
getStorage().setItem("state", state);
|
|
517
533
|
getStorage().setItem("codeVerifier", codeVerifier);
|
|
518
|
-
window.location.assign(
|
|
534
|
+
window.location.assign(_this2.service.getAuthorizationCodeURL(codeChallenge, state));
|
|
519
535
|
}
|
|
520
536
|
signOut() {
|
|
521
537
|
this.clear();
|
|
@@ -542,16 +558,17 @@
|
|
|
542
558
|
this.service = new Gc2Service(options);
|
|
543
559
|
}
|
|
544
560
|
async signIn() {
|
|
545
|
-
|
|
561
|
+
var _this = this;
|
|
562
|
+
const { access_token, refresh_token } = await _this.service.getPasswordToken();
|
|
546
563
|
setTokens({
|
|
547
564
|
accessToken: access_token,
|
|
548
565
|
refreshToken: refresh_token
|
|
549
566
|
});
|
|
550
567
|
setOptions({
|
|
551
|
-
clientId:
|
|
552
|
-
host:
|
|
568
|
+
clientId: _this.options.clientId,
|
|
569
|
+
host: _this.options.host,
|
|
553
570
|
redirectUri: "",
|
|
554
|
-
clientSecret:
|
|
571
|
+
clientSecret: _this.options.clientSecret
|
|
555
572
|
});
|
|
556
573
|
}
|
|
557
574
|
signOut() {
|
|
@@ -596,9 +613,10 @@
|
|
|
596
613
|
*/
|
|
597
614
|
var CentiaHttpClient = class {
|
|
598
615
|
constructor(config) {
|
|
616
|
+
var _config$auth, _config$fetch;
|
|
599
617
|
this.baseUrl = config.baseUrl.replace(/\/+$/, "");
|
|
600
|
-
this.auth = config.auth
|
|
601
|
-
this.fetchFn = config.fetch
|
|
618
|
+
this.auth = (_config$auth = config.auth) !== null && _config$auth !== void 0 ? _config$auth : {};
|
|
619
|
+
this.fetchFn = (_config$fetch = config.fetch) !== null && _config$fetch !== void 0 ? _config$fetch : globalThis.fetch.bind(globalThis);
|
|
602
620
|
this.userAgent = config.userAgent;
|
|
603
621
|
}
|
|
604
622
|
/**
|
|
@@ -613,24 +631,26 @@
|
|
|
613
631
|
* Useful for operations that return Location headers (POST 201, PATCH 303).
|
|
614
632
|
*/
|
|
615
633
|
async requestFull(opts) {
|
|
616
|
-
|
|
617
|
-
const
|
|
634
|
+
var _this2 = this;
|
|
635
|
+
const url = _this2.buildUrl(opts.path, opts.query);
|
|
636
|
+
const headers = await _this2.buildHeaders(opts);
|
|
618
637
|
const init = {
|
|
619
638
|
method: opts.method,
|
|
620
639
|
headers,
|
|
621
640
|
redirect: "manual"
|
|
622
641
|
};
|
|
623
|
-
if (opts.body !== void 0 && opts.body !== null) init.body =
|
|
624
|
-
const response = await
|
|
642
|
+
if (opts.body !== void 0 && opts.body !== null) init.body = _this2.resolveContentType(opts.contentType) === "application/json" ? JSON.stringify(opts.body) : opts.body;
|
|
643
|
+
const response = await _this2.fetchFn(url, init);
|
|
625
644
|
if (response.type === "opaqueredirect") {
|
|
626
|
-
|
|
645
|
+
var _opts$expectedStatus;
|
|
646
|
+
if (((_opts$expectedStatus = opts.expectedStatus) !== null && _opts$expectedStatus !== void 0 ? _opts$expectedStatus : 200) === 303) return {
|
|
627
647
|
body: null,
|
|
628
648
|
status: 303,
|
|
629
649
|
getHeader: (name) => name.toLowerCase() === "location" ? response.url : null
|
|
630
650
|
};
|
|
631
651
|
}
|
|
632
652
|
return {
|
|
633
|
-
body: await
|
|
653
|
+
body: await _this2.handleResponse(response, opts, url),
|
|
634
654
|
status: response.status,
|
|
635
655
|
getHeader: (name) => response.headers.get(name)
|
|
636
656
|
};
|
|
@@ -645,44 +665,50 @@
|
|
|
645
665
|
return url;
|
|
646
666
|
}
|
|
647
667
|
async buildHeaders(opts) {
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
668
|
+
var _this3 = this;
|
|
669
|
+
var _opts$accept;
|
|
670
|
+
const headers = { "Accept": (_opts$accept = opts.accept) !== null && _opts$accept !== void 0 ? _opts$accept : "application/json" };
|
|
671
|
+
if (_this3.auth.getAccessToken) {
|
|
672
|
+
const token = await _this3.auth.getAccessToken();
|
|
651
673
|
if (token) headers["Authorization"] = `Bearer ${token}`;
|
|
652
674
|
}
|
|
653
|
-
if (
|
|
654
|
-
const authHeaders = await
|
|
675
|
+
if (_this3.auth.getHeaders) {
|
|
676
|
+
const authHeaders = await _this3.auth.getHeaders();
|
|
655
677
|
Object.assign(headers, authHeaders);
|
|
656
678
|
}
|
|
657
|
-
if (
|
|
658
|
-
const ct =
|
|
679
|
+
if (_this3.userAgent && typeof navigator === "undefined") headers["User-Agent"] = _this3.userAgent;
|
|
680
|
+
const ct = _this3.resolveContentType(opts.contentType);
|
|
659
681
|
if (ct) headers["Content-Type"] = ct;
|
|
660
682
|
return headers;
|
|
661
683
|
}
|
|
662
684
|
resolveContentType(contentType) {
|
|
663
685
|
if (contentType === null) return null;
|
|
664
|
-
return contentType
|
|
686
|
+
return contentType !== null && contentType !== void 0 ? contentType : "application/json";
|
|
665
687
|
}
|
|
666
688
|
async handleResponse(response, opts, url) {
|
|
667
|
-
|
|
689
|
+
var _opts$expectedStatus2, _parsed;
|
|
690
|
+
const expectedStatus = (_opts$expectedStatus2 = opts.expectedStatus) !== null && _opts$expectedStatus2 !== void 0 ? _opts$expectedStatus2 : 200;
|
|
668
691
|
let bodyText = "";
|
|
669
692
|
try {
|
|
670
693
|
bodyText = await response.text();
|
|
671
|
-
} catch {}
|
|
694
|
+
} catch (_unused) {}
|
|
672
695
|
let parsed = null;
|
|
673
696
|
if (bodyText) try {
|
|
674
697
|
parsed = JSON.parse(bodyText);
|
|
675
|
-
} catch {}
|
|
676
|
-
if (response.status !== expectedStatus)
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
698
|
+
} catch (_unused2) {}
|
|
699
|
+
if (response.status !== expectedStatus) {
|
|
700
|
+
var _ref, _parsed$message, _response$headers$get;
|
|
701
|
+
throw new CentiaApiError({
|
|
702
|
+
message: ((_ref = (_parsed$message = parsed === null || parsed === void 0 ? void 0 : parsed.message) !== null && _parsed$message !== void 0 ? _parsed$message : parsed === null || parsed === void 0 ? void 0 : parsed.error) !== null && _ref !== void 0 ? _ref : bodyText) || `Unexpected status ${response.status}`,
|
|
703
|
+
status: response.status,
|
|
704
|
+
code: parsed === null || parsed === void 0 ? void 0 : parsed.code,
|
|
705
|
+
details: parsed,
|
|
706
|
+
requestId: (_response$headers$get = response.headers.get("x-request-id")) !== null && _response$headers$get !== void 0 ? _response$headers$get : void 0,
|
|
707
|
+
method: opts.method,
|
|
708
|
+
url
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
return (_parsed = parsed) !== null && _parsed !== void 0 ? _parsed : bodyText || null;
|
|
686
712
|
}
|
|
687
713
|
};
|
|
688
714
|
/**
|
|
@@ -737,7 +763,7 @@
|
|
|
737
763
|
//#region src/Sql.ts
|
|
738
764
|
var Sql = class {
|
|
739
765
|
constructor(client) {
|
|
740
|
-
this.client = client
|
|
766
|
+
this.client = client !== null && client !== void 0 ? client : getLegacyClient();
|
|
741
767
|
}
|
|
742
768
|
async exec(request) {
|
|
743
769
|
return this.client.request({
|
|
@@ -767,7 +793,7 @@
|
|
|
767
793
|
//#region src/Rpc.ts
|
|
768
794
|
var Rpc = class {
|
|
769
795
|
constructor(client) {
|
|
770
|
-
this.client = client
|
|
796
|
+
this.client = client !== null && client !== void 0 ? client : getLegacyClient();
|
|
771
797
|
}
|
|
772
798
|
async call(request) {
|
|
773
799
|
return this.client.request({
|
|
@@ -783,11 +809,12 @@
|
|
|
783
809
|
var Gql = class {
|
|
784
810
|
constructor(schema, client) {
|
|
785
811
|
this.schema = schema;
|
|
786
|
-
this.client = client
|
|
812
|
+
this.client = client !== null && client !== void 0 ? client : getLegacyClient();
|
|
787
813
|
}
|
|
788
814
|
async request(request) {
|
|
789
|
-
|
|
790
|
-
|
|
815
|
+
var _this = this;
|
|
816
|
+
return _this.client.request({
|
|
817
|
+
path: `api/graphql/schema/${_this.schema}`,
|
|
791
818
|
method: "POST",
|
|
792
819
|
body: request
|
|
793
820
|
});
|
|
@@ -798,7 +825,7 @@
|
|
|
798
825
|
//#region src/Meta.ts
|
|
799
826
|
var Meta = class {
|
|
800
827
|
constructor(client) {
|
|
801
|
-
this.client = client
|
|
828
|
+
this.client = client !== null && client !== void 0 ? client : getLegacyClient();
|
|
802
829
|
}
|
|
803
830
|
async query(rel) {
|
|
804
831
|
return this.client.request({
|
|
@@ -845,7 +872,7 @@
|
|
|
845
872
|
//#region src/Users.ts
|
|
846
873
|
var Users = class {
|
|
847
874
|
constructor(client) {
|
|
848
|
-
this.client = client
|
|
875
|
+
this.client = client !== null && client !== void 0 ? client : getLegacyClient();
|
|
849
876
|
}
|
|
850
877
|
async get(user) {
|
|
851
878
|
return this.client.request({
|
|
@@ -855,6 +882,72 @@
|
|
|
855
882
|
}
|
|
856
883
|
};
|
|
857
884
|
|
|
885
|
+
//#endregion
|
|
886
|
+
//#region \0@oxc-project+runtime@0.101.0/helpers/typeof.js
|
|
887
|
+
function _typeof(o) {
|
|
888
|
+
"@babel/helpers - typeof";
|
|
889
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
|
|
890
|
+
return typeof o$1;
|
|
891
|
+
} : function(o$1) {
|
|
892
|
+
return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
|
|
893
|
+
}, _typeof(o);
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
//#endregion
|
|
897
|
+
//#region \0@oxc-project+runtime@0.101.0/helpers/toPrimitive.js
|
|
898
|
+
function toPrimitive(t, r) {
|
|
899
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
900
|
+
var e = t[Symbol.toPrimitive];
|
|
901
|
+
if (void 0 !== e) {
|
|
902
|
+
var i = e.call(t, r || "default");
|
|
903
|
+
if ("object" != _typeof(i)) return i;
|
|
904
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
905
|
+
}
|
|
906
|
+
return ("string" === r ? String : Number)(t);
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
//#endregion
|
|
910
|
+
//#region \0@oxc-project+runtime@0.101.0/helpers/toPropertyKey.js
|
|
911
|
+
function toPropertyKey(t) {
|
|
912
|
+
var i = toPrimitive(t, "string");
|
|
913
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
//#endregion
|
|
917
|
+
//#region \0@oxc-project+runtime@0.101.0/helpers/defineProperty.js
|
|
918
|
+
function _defineProperty(e, r, t) {
|
|
919
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
920
|
+
value: t,
|
|
921
|
+
enumerable: !0,
|
|
922
|
+
configurable: !0,
|
|
923
|
+
writable: !0
|
|
924
|
+
}) : e[r] = t, e;
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
//#endregion
|
|
928
|
+
//#region \0@oxc-project+runtime@0.101.0/helpers/objectSpread2.js
|
|
929
|
+
function ownKeys(e, r) {
|
|
930
|
+
var t = Object.keys(e);
|
|
931
|
+
if (Object.getOwnPropertySymbols) {
|
|
932
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
933
|
+
r && (o = o.filter(function(r$1) {
|
|
934
|
+
return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
|
|
935
|
+
})), t.push.apply(t, o);
|
|
936
|
+
}
|
|
937
|
+
return t;
|
|
938
|
+
}
|
|
939
|
+
function _objectSpread2(e) {
|
|
940
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
941
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
942
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r$1) {
|
|
943
|
+
_defineProperty(e, r$1, t[r$1]);
|
|
944
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
|
|
945
|
+
Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
return e;
|
|
949
|
+
}
|
|
950
|
+
|
|
858
951
|
//#endregion
|
|
859
952
|
//#region src/Ws.ts
|
|
860
953
|
/**
|
|
@@ -865,30 +958,28 @@
|
|
|
865
958
|
*/
|
|
866
959
|
var Ws = class {
|
|
867
960
|
constructor(options) {
|
|
961
|
+
var _this$options$wsClien;
|
|
868
962
|
this.ws = null;
|
|
869
963
|
this.listeners = {};
|
|
870
964
|
this.closed = false;
|
|
871
|
-
this.options = {
|
|
965
|
+
this.options = _objectSpread2({
|
|
872
966
|
reconnect: true,
|
|
873
|
-
reconnectInterval: 3e3
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
this.options.wsClient = this.options.wsClient ?? WebSocket;
|
|
967
|
+
reconnectInterval: 3e3
|
|
968
|
+
}, options);
|
|
969
|
+
this.options.wsClient = (_this$options$wsClien = this.options.wsClient) !== null && _this$options$wsClien !== void 0 ? _this$options$wsClien : WebSocket;
|
|
877
970
|
}
|
|
878
971
|
connect() {
|
|
879
972
|
this.closed = false;
|
|
880
973
|
this.doConnect();
|
|
881
974
|
}
|
|
882
975
|
disconnect() {
|
|
976
|
+
var _this$ws;
|
|
883
977
|
this.closed = true;
|
|
884
|
-
this.ws
|
|
978
|
+
(_this$ws = this.ws) === null || _this$ws === void 0 || _this$ws.close();
|
|
885
979
|
this.ws = null;
|
|
886
980
|
}
|
|
887
981
|
subscribe(sub) {
|
|
888
|
-
this.send({
|
|
889
|
-
type: "subscription",
|
|
890
|
-
...sub
|
|
891
|
-
});
|
|
982
|
+
this.send(_objectSpread2({ type: "subscription" }, sub));
|
|
892
983
|
}
|
|
893
984
|
send(data) {
|
|
894
985
|
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) throw new Error("WebSocket is not connected");
|
|
@@ -906,7 +997,8 @@
|
|
|
906
997
|
if (idx !== -1) arr.splice(idx, 1);
|
|
907
998
|
}
|
|
908
999
|
get connected() {
|
|
909
|
-
|
|
1000
|
+
var _this$ws2;
|
|
1001
|
+
return ((_this$ws2 = this.ws) === null || _this$ws2 === void 0 ? void 0 : _this$ws2.readyState) === WebSocket.OPEN;
|
|
910
1002
|
}
|
|
911
1003
|
emit(event, data) {
|
|
912
1004
|
const arr = this.listeners[event];
|
|
@@ -928,7 +1020,7 @@
|
|
|
928
1020
|
let msg;
|
|
929
1021
|
try {
|
|
930
1022
|
msg = JSON.parse(typeof event.data === "string" ? event.data : event.data.toString());
|
|
931
|
-
} catch {
|
|
1023
|
+
} catch (_unused) {
|
|
932
1024
|
return;
|
|
933
1025
|
}
|
|
934
1026
|
switch (msg.type) {
|
|
@@ -960,7 +1052,7 @@
|
|
|
960
1052
|
//#region src/Stats.ts
|
|
961
1053
|
var Stats = class {
|
|
962
1054
|
constructor(client) {
|
|
963
|
-
this.client = client
|
|
1055
|
+
this.client = client !== null && client !== void 0 ? client : getLegacyClient();
|
|
964
1056
|
}
|
|
965
1057
|
async get() {
|
|
966
1058
|
return this.client.request({
|
|
@@ -974,7 +1066,7 @@
|
|
|
974
1066
|
//#region src/Tables.ts
|
|
975
1067
|
var Tables = class {
|
|
976
1068
|
constructor(client) {
|
|
977
|
-
this.client = client
|
|
1069
|
+
this.client = client !== null && client !== void 0 ? client : getLegacyClient();
|
|
978
1070
|
}
|
|
979
1071
|
async get(schema, table) {
|
|
980
1072
|
return this.client.request({
|
|
@@ -1080,7 +1172,8 @@
|
|
|
1080
1172
|
this.service = new Gc2Service(options);
|
|
1081
1173
|
}
|
|
1082
1174
|
async signUp() {
|
|
1083
|
-
|
|
1175
|
+
var _this = this;
|
|
1176
|
+
window.location.assign(_this.service.getSignUpURL());
|
|
1084
1177
|
}
|
|
1085
1178
|
};
|
|
1086
1179
|
|
|
@@ -1281,14 +1374,20 @@
|
|
|
1281
1374
|
function findJoinOn(base, target) {
|
|
1282
1375
|
const bc = base.constraints || [];
|
|
1283
1376
|
const tc = target.constraints || [];
|
|
1284
|
-
for (const c of bc)
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1377
|
+
for (const c of bc) {
|
|
1378
|
+
var _c$columns, _c$referenced_columns;
|
|
1379
|
+
if (c.constraint === "foreign" && c.referenced_table === target.name && ((_c$columns = c.columns) === null || _c$columns === void 0 ? void 0 : _c$columns.length) && ((_c$referenced_columns = c.referenced_columns) === null || _c$referenced_columns === void 0 ? void 0 : _c$referenced_columns.length) && c.columns.length === c.referenced_columns.length) return c.columns.map((col, i) => ({
|
|
1380
|
+
left: String(col),
|
|
1381
|
+
right: String(c.referenced_columns[i])
|
|
1382
|
+
}));
|
|
1383
|
+
}
|
|
1384
|
+
for (const c of tc) {
|
|
1385
|
+
var _c$columns2, _c$referenced_columns2;
|
|
1386
|
+
if (c.constraint === "foreign" && c.referenced_table === base.name && ((_c$columns2 = c.columns) === null || _c$columns2 === void 0 ? void 0 : _c$columns2.length) && ((_c$referenced_columns2 = c.referenced_columns) === null || _c$referenced_columns2 === void 0 ? void 0 : _c$referenced_columns2.length) && c.columns.length === c.referenced_columns.length) return c.referenced_columns.map((rcol, i) => ({
|
|
1387
|
+
left: String(rcol),
|
|
1388
|
+
right: String(c.columns[i])
|
|
1389
|
+
}));
|
|
1390
|
+
}
|
|
1292
1391
|
return null;
|
|
1293
1392
|
}
|
|
1294
1393
|
var TableQueryImpl = class {
|
|
@@ -1869,30 +1968,35 @@
|
|
|
1869
1968
|
this.client = client;
|
|
1870
1969
|
}
|
|
1871
1970
|
async getSchema(schema, opts) {
|
|
1971
|
+
var _this = this;
|
|
1872
1972
|
const path = schema ? `api/v4/schemas/${encodeURIComponent(schema)}` : "api/v4/schemas";
|
|
1873
1973
|
const query = {};
|
|
1874
|
-
if (opts
|
|
1875
|
-
return
|
|
1974
|
+
if (opts === null || opts === void 0 ? void 0 : opts.namesOnly) query.namesOnly = "true";
|
|
1975
|
+
return _this.client.request({
|
|
1876
1976
|
path,
|
|
1877
1977
|
method: "GET",
|
|
1878
1978
|
query: Object.keys(query).length > 0 ? query : void 0
|
|
1879
1979
|
});
|
|
1880
1980
|
}
|
|
1881
1981
|
async postSchema(body) {
|
|
1882
|
-
|
|
1982
|
+
var _this2 = this;
|
|
1983
|
+
var _res$getHeader;
|
|
1984
|
+
return { location: (_res$getHeader = (await _this2.client.requestFull({
|
|
1883
1985
|
path: "api/v4/schemas",
|
|
1884
1986
|
method: "POST",
|
|
1885
1987
|
body,
|
|
1886
1988
|
expectedStatus: 201
|
|
1887
|
-
})).getHeader("Location")
|
|
1989
|
+
})).getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "" };
|
|
1888
1990
|
}
|
|
1889
1991
|
async patchSchema(schema, body) {
|
|
1890
|
-
|
|
1992
|
+
var _this3 = this;
|
|
1993
|
+
var _res$getHeader2;
|
|
1994
|
+
return { location: (_res$getHeader2 = (await _this3.client.requestFull({
|
|
1891
1995
|
path: `api/v4/schemas/${encodeURIComponent(schema)}`,
|
|
1892
1996
|
method: "PATCH",
|
|
1893
1997
|
body,
|
|
1894
1998
|
expectedStatus: 303
|
|
1895
|
-
})).getHeader("Location")
|
|
1999
|
+
})).getHeader("Location")) !== null && _res$getHeader2 !== void 0 ? _res$getHeader2 : "" };
|
|
1896
2000
|
}
|
|
1897
2001
|
async deleteSchema(schema) {
|
|
1898
2002
|
await this.client.request({
|
|
@@ -1913,31 +2017,37 @@
|
|
|
1913
2017
|
return `api/v4/schemas/${encodeURIComponent(schema)}/tables/${encodeURIComponent(table)}/columns`;
|
|
1914
2018
|
}
|
|
1915
2019
|
async getColumn(schema, table, column) {
|
|
1916
|
-
|
|
1917
|
-
|
|
2020
|
+
var _this = this;
|
|
2021
|
+
const path = column ? `${_this.basePath(schema, table)}/${encodeURIComponent(column)}` : _this.basePath(schema, table);
|
|
2022
|
+
return _this.client.request({
|
|
1918
2023
|
path,
|
|
1919
2024
|
method: "GET"
|
|
1920
2025
|
});
|
|
1921
2026
|
}
|
|
1922
2027
|
async postColumn(schema, table, body) {
|
|
1923
|
-
|
|
1924
|
-
|
|
2028
|
+
var _this2 = this;
|
|
2029
|
+
var _res$getHeader;
|
|
2030
|
+
return { location: (_res$getHeader = (await _this2.client.requestFull({
|
|
2031
|
+
path: _this2.basePath(schema, table),
|
|
1925
2032
|
method: "POST",
|
|
1926
2033
|
body,
|
|
1927
2034
|
expectedStatus: 201
|
|
1928
|
-
})).getHeader("Location")
|
|
2035
|
+
})).getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "" };
|
|
1929
2036
|
}
|
|
1930
2037
|
async patchColumn(schema, table, column, body) {
|
|
1931
|
-
|
|
1932
|
-
|
|
2038
|
+
var _this3 = this;
|
|
2039
|
+
var _res$getHeader2;
|
|
2040
|
+
return { location: (_res$getHeader2 = (await _this3.client.requestFull({
|
|
2041
|
+
path: `${_this3.basePath(schema, table)}/${encodeURIComponent(column)}`,
|
|
1933
2042
|
method: "PATCH",
|
|
1934
2043
|
body,
|
|
1935
2044
|
expectedStatus: 303
|
|
1936
|
-
})).getHeader("Location")
|
|
2045
|
+
})).getHeader("Location")) !== null && _res$getHeader2 !== void 0 ? _res$getHeader2 : "" };
|
|
1937
2046
|
}
|
|
1938
2047
|
async deleteColumn(schema, table, column) {
|
|
1939
|
-
|
|
1940
|
-
|
|
2048
|
+
var _this4 = this;
|
|
2049
|
+
await _this4.client.request({
|
|
2050
|
+
path: `${_this4.basePath(schema, table)}/${encodeURIComponent(column)}`,
|
|
1941
2051
|
method: "DELETE",
|
|
1942
2052
|
expectedStatus: 204
|
|
1943
2053
|
});
|
|
@@ -1954,23 +2064,27 @@
|
|
|
1954
2064
|
return `api/v4/schemas/${encodeURIComponent(schema)}/tables/${encodeURIComponent(table)}/constraints`;
|
|
1955
2065
|
}
|
|
1956
2066
|
async getConstraint(schema, table, constraint) {
|
|
1957
|
-
|
|
1958
|
-
|
|
2067
|
+
var _this = this;
|
|
2068
|
+
const path = constraint ? `${_this.basePath(schema, table)}/${encodeURIComponent(constraint)}` : _this.basePath(schema, table);
|
|
2069
|
+
return _this.client.request({
|
|
1959
2070
|
path,
|
|
1960
2071
|
method: "GET"
|
|
1961
2072
|
});
|
|
1962
2073
|
}
|
|
1963
2074
|
async postConstraint(schema, table, body) {
|
|
1964
|
-
|
|
1965
|
-
|
|
2075
|
+
var _this2 = this;
|
|
2076
|
+
var _res$getHeader;
|
|
2077
|
+
return { location: (_res$getHeader = (await _this2.client.requestFull({
|
|
2078
|
+
path: _this2.basePath(schema, table),
|
|
1966
2079
|
method: "POST",
|
|
1967
2080
|
body,
|
|
1968
2081
|
expectedStatus: 201
|
|
1969
|
-
})).getHeader("Location")
|
|
2082
|
+
})).getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "" };
|
|
1970
2083
|
}
|
|
1971
2084
|
async deleteConstraint(schema, table, constraint) {
|
|
1972
|
-
|
|
1973
|
-
|
|
2085
|
+
var _this3 = this;
|
|
2086
|
+
await _this3.client.request({
|
|
2087
|
+
path: `${_this3.basePath(schema, table)}/${encodeURIComponent(constraint)}`,
|
|
1974
2088
|
method: "DELETE",
|
|
1975
2089
|
expectedStatus: 204
|
|
1976
2090
|
});
|
|
@@ -1987,23 +2101,27 @@
|
|
|
1987
2101
|
return `api/v4/schemas/${encodeURIComponent(schema)}/tables/${encodeURIComponent(table)}/indices`;
|
|
1988
2102
|
}
|
|
1989
2103
|
async getIndex(schema, table, index) {
|
|
1990
|
-
|
|
1991
|
-
|
|
2104
|
+
var _this = this;
|
|
2105
|
+
const path = index ? `${_this.basePath(schema, table)}/${encodeURIComponent(index)}` : _this.basePath(schema, table);
|
|
2106
|
+
return _this.client.request({
|
|
1992
2107
|
path,
|
|
1993
2108
|
method: "GET"
|
|
1994
2109
|
});
|
|
1995
2110
|
}
|
|
1996
2111
|
async postIndex(schema, table, body) {
|
|
1997
|
-
|
|
1998
|
-
|
|
2112
|
+
var _this2 = this;
|
|
2113
|
+
var _res$getHeader;
|
|
2114
|
+
return { location: (_res$getHeader = (await _this2.client.requestFull({
|
|
2115
|
+
path: _this2.basePath(schema, table),
|
|
1999
2116
|
method: "POST",
|
|
2000
2117
|
body,
|
|
2001
2118
|
expectedStatus: 201
|
|
2002
|
-
})).getHeader("Location")
|
|
2119
|
+
})).getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "" };
|
|
2003
2120
|
}
|
|
2004
2121
|
async deleteIndex(schema, table, index) {
|
|
2005
|
-
|
|
2006
|
-
|
|
2122
|
+
var _this3 = this;
|
|
2123
|
+
await _this3.client.request({
|
|
2124
|
+
path: `${_this3.basePath(schema, table)}/${encodeURIComponent(index)}`,
|
|
2007
2125
|
method: "DELETE",
|
|
2008
2126
|
expectedStatus: 204
|
|
2009
2127
|
});
|
|
@@ -2020,31 +2138,37 @@
|
|
|
2020
2138
|
return `api/v4/schemas/${encodeURIComponent(schema)}/sequences`;
|
|
2021
2139
|
}
|
|
2022
2140
|
async getSequence(schema, sequence) {
|
|
2023
|
-
|
|
2024
|
-
|
|
2141
|
+
var _this = this;
|
|
2142
|
+
const path = sequence ? `${_this.basePath(schema)}/${encodeURIComponent(sequence)}` : _this.basePath(schema);
|
|
2143
|
+
return _this.client.request({
|
|
2025
2144
|
path,
|
|
2026
2145
|
method: "GET"
|
|
2027
2146
|
});
|
|
2028
2147
|
}
|
|
2029
2148
|
async postSequence(schema, body) {
|
|
2030
|
-
|
|
2031
|
-
|
|
2149
|
+
var _this2 = this;
|
|
2150
|
+
var _res$getHeader;
|
|
2151
|
+
return { location: (_res$getHeader = (await _this2.client.requestFull({
|
|
2152
|
+
path: _this2.basePath(schema),
|
|
2032
2153
|
method: "POST",
|
|
2033
2154
|
body,
|
|
2034
2155
|
expectedStatus: 201
|
|
2035
|
-
})).getHeader("Location")
|
|
2156
|
+
})).getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "" };
|
|
2036
2157
|
}
|
|
2037
2158
|
async patchSequence(schema, sequence, body) {
|
|
2038
|
-
|
|
2039
|
-
|
|
2159
|
+
var _this3 = this;
|
|
2160
|
+
var _res$getHeader2;
|
|
2161
|
+
return { location: (_res$getHeader2 = (await _this3.client.requestFull({
|
|
2162
|
+
path: `${_this3.basePath(schema)}/${encodeURIComponent(sequence)}`,
|
|
2040
2163
|
method: "PATCH",
|
|
2041
2164
|
body,
|
|
2042
2165
|
expectedStatus: 303
|
|
2043
|
-
})).getHeader("Location")
|
|
2166
|
+
})).getHeader("Location")) !== null && _res$getHeader2 !== void 0 ? _res$getHeader2 : "" };
|
|
2044
2167
|
}
|
|
2045
2168
|
async deleteSequence(schema, sequence) {
|
|
2046
|
-
|
|
2047
|
-
|
|
2169
|
+
var _this4 = this;
|
|
2170
|
+
await _this4.client.request({
|
|
2171
|
+
path: `${_this4.basePath(schema)}/${encodeURIComponent(sequence)}`,
|
|
2048
2172
|
method: "DELETE",
|
|
2049
2173
|
expectedStatus: 204
|
|
2050
2174
|
});
|
|
@@ -2060,32 +2184,41 @@
|
|
|
2060
2184
|
basePath(schema) {
|
|
2061
2185
|
return `api/v4/schemas/${encodeURIComponent(schema)}/tables`;
|
|
2062
2186
|
}
|
|
2063
|
-
async getTable(schema, table) {
|
|
2064
|
-
|
|
2065
|
-
|
|
2187
|
+
async getTable(schema, table, opts) {
|
|
2188
|
+
var _this = this;
|
|
2189
|
+
const path = table ? `${_this.basePath(schema)}/${encodeURIComponent(table)}` : _this.basePath(schema);
|
|
2190
|
+
const query = {};
|
|
2191
|
+
if (opts === null || opts === void 0 ? void 0 : opts.namesOnly) query.namesOnly = "true";
|
|
2192
|
+
return _this.client.request({
|
|
2066
2193
|
path,
|
|
2067
|
-
method: "GET"
|
|
2194
|
+
method: "GET",
|
|
2195
|
+
query: Object.keys(query).length > 0 ? query : void 0
|
|
2068
2196
|
});
|
|
2069
2197
|
}
|
|
2070
2198
|
async postTable(schema, body) {
|
|
2071
|
-
|
|
2072
|
-
|
|
2199
|
+
var _this2 = this;
|
|
2200
|
+
var _res$getHeader;
|
|
2201
|
+
return { location: (_res$getHeader = (await _this2.client.requestFull({
|
|
2202
|
+
path: _this2.basePath(schema),
|
|
2073
2203
|
method: "POST",
|
|
2074
2204
|
body,
|
|
2075
2205
|
expectedStatus: 201
|
|
2076
|
-
})).getHeader("Location")
|
|
2206
|
+
})).getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "" };
|
|
2077
2207
|
}
|
|
2078
2208
|
async patchTable(schema, table, body) {
|
|
2079
|
-
|
|
2080
|
-
|
|
2209
|
+
var _this3 = this;
|
|
2210
|
+
var _res$getHeader2;
|
|
2211
|
+
return { location: (_res$getHeader2 = (await _this3.client.requestFull({
|
|
2212
|
+
path: `${_this3.basePath(schema)}/${encodeURIComponent(table)}`,
|
|
2081
2213
|
method: "PATCH",
|
|
2082
2214
|
body,
|
|
2083
2215
|
expectedStatus: 303
|
|
2084
|
-
})).getHeader("Location")
|
|
2216
|
+
})).getHeader("Location")) !== null && _res$getHeader2 !== void 0 ? _res$getHeader2 : "" };
|
|
2085
2217
|
}
|
|
2086
2218
|
async deleteTable(schema, table) {
|
|
2087
|
-
|
|
2088
|
-
|
|
2219
|
+
var _this4 = this;
|
|
2220
|
+
await _this4.client.request({
|
|
2221
|
+
path: `${_this4.basePath(schema)}/${encodeURIComponent(table)}`,
|
|
2089
2222
|
method: "DELETE",
|
|
2090
2223
|
expectedStatus: 204
|
|
2091
2224
|
});
|
|
@@ -2099,27 +2232,32 @@
|
|
|
2099
2232
|
this.client = client;
|
|
2100
2233
|
}
|
|
2101
2234
|
async getUser(name) {
|
|
2235
|
+
var _this = this;
|
|
2102
2236
|
const path = name ? `api/v4/users/${encodeURIComponent(name)}` : "api/v4/users";
|
|
2103
|
-
return
|
|
2237
|
+
return _this.client.request({
|
|
2104
2238
|
path,
|
|
2105
2239
|
method: "GET"
|
|
2106
2240
|
});
|
|
2107
2241
|
}
|
|
2108
2242
|
async postUser(body) {
|
|
2109
|
-
|
|
2243
|
+
var _this2 = this;
|
|
2244
|
+
var _res$getHeader;
|
|
2245
|
+
return { location: (_res$getHeader = (await _this2.client.requestFull({
|
|
2110
2246
|
path: "api/v4/users",
|
|
2111
2247
|
method: "POST",
|
|
2112
2248
|
body,
|
|
2113
2249
|
expectedStatus: 201
|
|
2114
|
-
})).getHeader("Location")
|
|
2250
|
+
})).getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "" };
|
|
2115
2251
|
}
|
|
2116
2252
|
async patchUser(name, body) {
|
|
2117
|
-
|
|
2253
|
+
var _this3 = this;
|
|
2254
|
+
var _res$getHeader2;
|
|
2255
|
+
return { location: (_res$getHeader2 = (await _this3.client.requestFull({
|
|
2118
2256
|
path: `api/v4/users/${encodeURIComponent(name)}`,
|
|
2119
2257
|
method: "PATCH",
|
|
2120
2258
|
body,
|
|
2121
2259
|
expectedStatus: 303
|
|
2122
|
-
})).getHeader("Location")
|
|
2260
|
+
})).getHeader("Location")) !== null && _res$getHeader2 !== void 0 ? _res$getHeader2 : "" };
|
|
2123
2261
|
}
|
|
2124
2262
|
async deleteUser(name) {
|
|
2125
2263
|
await this.client.request({
|
|
@@ -2137,31 +2275,36 @@
|
|
|
2137
2275
|
this.client = client;
|
|
2138
2276
|
}
|
|
2139
2277
|
async getClient(id) {
|
|
2278
|
+
var _this = this;
|
|
2140
2279
|
const path = id ? `api/v4/clients/${encodeURIComponent(id)}` : "api/v4/clients";
|
|
2141
|
-
return
|
|
2280
|
+
return _this.client.request({
|
|
2142
2281
|
path,
|
|
2143
2282
|
method: "GET"
|
|
2144
2283
|
});
|
|
2145
2284
|
}
|
|
2146
2285
|
async postClient(body) {
|
|
2147
|
-
|
|
2286
|
+
var _this2 = this;
|
|
2287
|
+
var _res$getHeader;
|
|
2288
|
+
const res = await _this2.client.requestFull({
|
|
2148
2289
|
path: "api/v4/clients",
|
|
2149
2290
|
method: "POST",
|
|
2150
2291
|
body,
|
|
2151
2292
|
expectedStatus: 201
|
|
2152
2293
|
});
|
|
2153
2294
|
return {
|
|
2154
|
-
location: res.getHeader("Location")
|
|
2295
|
+
location: (_res$getHeader = res.getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "",
|
|
2155
2296
|
secret: res.body.secret
|
|
2156
2297
|
};
|
|
2157
2298
|
}
|
|
2158
2299
|
async patchClient(id, body) {
|
|
2159
|
-
|
|
2300
|
+
var _this3 = this;
|
|
2301
|
+
var _res$getHeader2;
|
|
2302
|
+
return { location: (_res$getHeader2 = (await _this3.client.requestFull({
|
|
2160
2303
|
path: `api/v4/clients/${encodeURIComponent(id)}`,
|
|
2161
2304
|
method: "PATCH",
|
|
2162
2305
|
body,
|
|
2163
2306
|
expectedStatus: 303
|
|
2164
|
-
})).getHeader("Location")
|
|
2307
|
+
})).getHeader("Location")) !== null && _res$getHeader2 !== void 0 ? _res$getHeader2 : "" };
|
|
2165
2308
|
}
|
|
2166
2309
|
async deleteClient(id) {
|
|
2167
2310
|
await this.client.request({
|
|
@@ -2179,8 +2322,9 @@
|
|
|
2179
2322
|
this.client = client;
|
|
2180
2323
|
}
|
|
2181
2324
|
async getRule(id) {
|
|
2325
|
+
var _this = this;
|
|
2182
2326
|
const path = id != null ? `api/v4/rules/${encodeURIComponent(id)}` : "api/v4/rules";
|
|
2183
|
-
return
|
|
2327
|
+
return _this.client.request({
|
|
2184
2328
|
path,
|
|
2185
2329
|
method: "GET"
|
|
2186
2330
|
});
|
|
@@ -2194,12 +2338,14 @@
|
|
|
2194
2338
|
});
|
|
2195
2339
|
}
|
|
2196
2340
|
async patchRule(id, body) {
|
|
2197
|
-
|
|
2341
|
+
var _this3 = this;
|
|
2342
|
+
var _res$getHeader;
|
|
2343
|
+
return { location: (_res$getHeader = (await _this3.client.requestFull({
|
|
2198
2344
|
path: `api/v4/rules/${encodeURIComponent(id)}`,
|
|
2199
2345
|
method: "PATCH",
|
|
2200
2346
|
body,
|
|
2201
2347
|
expectedStatus: 303
|
|
2202
|
-
})).getHeader("Location")
|
|
2348
|
+
})).getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "" };
|
|
2203
2349
|
}
|
|
2204
2350
|
async deleteRule(id) {
|
|
2205
2351
|
await this.client.request({
|
|
@@ -2238,27 +2384,32 @@
|
|
|
2238
2384
|
this.client = client;
|
|
2239
2385
|
}
|
|
2240
2386
|
async getRpc(method) {
|
|
2387
|
+
var _this = this;
|
|
2241
2388
|
const path = method ? `api/v4/methods/${encodeURIComponent(method)}` : "api/v4/methods";
|
|
2242
|
-
return
|
|
2389
|
+
return _this.client.request({
|
|
2243
2390
|
path,
|
|
2244
2391
|
method: "GET"
|
|
2245
2392
|
});
|
|
2246
2393
|
}
|
|
2247
2394
|
async postRpc(body) {
|
|
2248
|
-
|
|
2395
|
+
var _this2 = this;
|
|
2396
|
+
var _res$getHeader;
|
|
2397
|
+
return { location: (_res$getHeader = (await _this2.client.requestFull({
|
|
2249
2398
|
path: "api/v4/methods",
|
|
2250
2399
|
method: "POST",
|
|
2251
2400
|
body,
|
|
2252
2401
|
expectedStatus: 201
|
|
2253
|
-
})).getHeader("Location")
|
|
2402
|
+
})).getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "" };
|
|
2254
2403
|
}
|
|
2255
2404
|
async patchRpc(method, body) {
|
|
2256
|
-
|
|
2405
|
+
var _this3 = this;
|
|
2406
|
+
var _res$getHeader2;
|
|
2407
|
+
return { location: (_res$getHeader2 = (await _this3.client.requestFull({
|
|
2257
2408
|
path: `api/v4/methods/${encodeURIComponent(method)}`,
|
|
2258
2409
|
method: "PATCH",
|
|
2259
2410
|
body,
|
|
2260
2411
|
expectedStatus: 303
|
|
2261
|
-
})).getHeader("Location")
|
|
2412
|
+
})).getHeader("Location")) !== null && _res$getHeader2 !== void 0 ? _res$getHeader2 : "" };
|
|
2262
2413
|
}
|
|
2263
2414
|
async deleteRpc(method) {
|
|
2264
2415
|
await this.client.request({
|
|
@@ -2318,7 +2469,8 @@
|
|
|
2318
2469
|
* sequentially. The server reassembles the file from the chunks.
|
|
2319
2470
|
*/
|
|
2320
2471
|
async postFileUpload(formData, options) {
|
|
2321
|
-
|
|
2472
|
+
var _this = this;
|
|
2473
|
+
if (!(options === null || options === void 0 ? void 0 : options.chunkSize)) return _this.client.request({
|
|
2322
2474
|
path: "api/v4/file/upload",
|
|
2323
2475
|
method: "POST",
|
|
2324
2476
|
body: formData,
|
|
@@ -2336,7 +2488,7 @@
|
|
|
2336
2488
|
const chunk = file.slice(start, end);
|
|
2337
2489
|
const chunkForm = new FormData();
|
|
2338
2490
|
chunkForm.append("filename", chunk, fileName);
|
|
2339
|
-
result = await
|
|
2491
|
+
result = await _this.client.request({
|
|
2340
2492
|
path: "api/v4/file/upload",
|
|
2341
2493
|
method: "POST",
|
|
2342
2494
|
body: chunkForm,
|