@centia-io/sdk 0.0.56 → 0.0.57
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 +321 -172
- package/dist/centia-io-sdk.d.ts.map +1 -1
- package/dist/centia-io-sdk.js +321 -172
- package/dist/centia-io-sdk.js.map +1 -1
- package/dist/centia-io-sdk.umd.js +321 -172
- package/package.json +1 -1
package/dist/centia-io-sdk.cjs
CHANGED
|
@@ -88,14 +88,16 @@ function getStorage() {
|
|
|
88
88
|
*/
|
|
89
89
|
const generatePkceChallenge = async () => {
|
|
90
90
|
const generateRandomString = () => {
|
|
91
|
+
var _globalThis$crypto;
|
|
91
92
|
const array = new Uint32Array(28);
|
|
92
|
-
if (globalThis.crypto
|
|
93
|
+
if ((_globalThis$crypto = globalThis.crypto) === null || _globalThis$crypto === void 0 ? void 0 : _globalThis$crypto.getRandomValues) crypto.getRandomValues(array);
|
|
93
94
|
else for (let i = 0; i < array.length; i++) array[i] = Math.random() * 4294967295 >>> 0;
|
|
94
95
|
return Array.from(array, (dec) => ("0" + dec.toString(16)).substr(-2)).join("");
|
|
95
96
|
};
|
|
96
97
|
const sha256 = async (plain) => {
|
|
98
|
+
var _globalThis$crypto2;
|
|
97
99
|
const data = new TextEncoder().encode(plain);
|
|
98
|
-
if (globalThis.crypto
|
|
100
|
+
if ((_globalThis$crypto2 = globalThis.crypto) === null || _globalThis$crypto2 === void 0 ? void 0 : _globalThis$crypto2.subtle) return crypto.subtle.digest("SHA-256", data);
|
|
99
101
|
return sha256Fallback(data);
|
|
100
102
|
};
|
|
101
103
|
const base64urlEncode = (str) => {
|
|
@@ -262,7 +264,7 @@ const isLogin = async (gc2) => {
|
|
|
262
264
|
setTokens({
|
|
263
265
|
accessToken: data.access_token,
|
|
264
266
|
refreshToken,
|
|
265
|
-
idToken: data
|
|
267
|
+
idToken: data === null || data === void 0 ? void 0 : data.id_token
|
|
266
268
|
});
|
|
267
269
|
console.log("Access token refreshed");
|
|
268
270
|
} catch (e) {
|
|
@@ -275,16 +277,16 @@ const setTokens = (tokens) => {
|
|
|
275
277
|
getStorage().setItem("gc2_tokens", JSON.stringify({
|
|
276
278
|
"accessToken": tokens.accessToken,
|
|
277
279
|
"refreshToken": tokens.refreshToken,
|
|
278
|
-
"idToken": tokens
|
|
280
|
+
"idToken": (tokens === null || tokens === void 0 ? void 0 : tokens.idToken) || ""
|
|
279
281
|
}));
|
|
280
282
|
};
|
|
281
283
|
const getTokens = () => {
|
|
282
284
|
const str = getStorage().getItem("gc2_tokens");
|
|
283
285
|
const tokens = str ? JSON.parse(str) : {};
|
|
284
286
|
return {
|
|
285
|
-
accessToken: tokens
|
|
286
|
-
refreshToken: tokens
|
|
287
|
-
idToken: tokens
|
|
287
|
+
accessToken: (tokens === null || tokens === void 0 ? void 0 : tokens.accessToken) || "",
|
|
288
|
+
refreshToken: (tokens === null || tokens === void 0 ? void 0 : tokens.refreshToken) || "",
|
|
289
|
+
idToken: (tokens === null || tokens === void 0 ? void 0 : tokens.idToken) || ""
|
|
288
290
|
};
|
|
289
291
|
};
|
|
290
292
|
const setOptions = (options) => {
|
|
@@ -299,9 +301,9 @@ const getOptions = () => {
|
|
|
299
301
|
const str = getStorage().getItem("gc2_options");
|
|
300
302
|
const options = str ? JSON.parse(str) : {};
|
|
301
303
|
return {
|
|
302
|
-
clientId: options
|
|
303
|
-
host: options
|
|
304
|
-
redirectUri: options
|
|
304
|
+
clientId: (options === null || options === void 0 ? void 0 : options.clientId) || "",
|
|
305
|
+
host: (options === null || options === void 0 ? void 0 : options.host) || "",
|
|
306
|
+
redirectUri: (options === null || options === void 0 ? void 0 : options.redirectUri) || ""
|
|
305
307
|
};
|
|
306
308
|
};
|
|
307
309
|
const clearTokens = () => {
|
|
@@ -360,15 +362,19 @@ var Gc2Service = class {
|
|
|
360
362
|
return response.json();
|
|
361
363
|
}
|
|
362
364
|
async getDeviceCode() {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
+
var _this = this;
|
|
366
|
+
var _this$options$deviceU;
|
|
367
|
+
const path = (_this$options$deviceU = _this.options.deviceUri) !== null && _this$options$deviceU !== void 0 ? _this$options$deviceU : `${_this.host}/api/v4/oauth/device`;
|
|
368
|
+
return _this.request(_this.buildUrl(path), "POST", { client_id: _this.options.clientId });
|
|
365
369
|
}
|
|
366
370
|
async pollToken(deviceCode, interval) {
|
|
367
|
-
|
|
371
|
+
var _this2 = this;
|
|
372
|
+
var _this$options$tokenUr;
|
|
373
|
+
const path = (_this$options$tokenUr = _this2.options.tokenUri) !== null && _this$options$tokenUr !== void 0 ? _this$options$tokenUr : `${_this2.host}/api/v4/oauth`;
|
|
368
374
|
const getToken = async () => {
|
|
369
375
|
try {
|
|
370
|
-
return await
|
|
371
|
-
client_id:
|
|
376
|
+
return await _this2.request(_this2.buildUrl(path), "POST", {
|
|
377
|
+
client_id: _this2.options.clientId,
|
|
372
378
|
device_code: deviceCode,
|
|
373
379
|
grant_type: "device_code"
|
|
374
380
|
});
|
|
@@ -387,10 +393,11 @@ var Gc2Service = class {
|
|
|
387
393
|
return response;
|
|
388
394
|
}
|
|
389
395
|
getAuthorizationCodeURL(codeChallenge, state) {
|
|
396
|
+
var _this$options$authUri;
|
|
390
397
|
let redirectUri;
|
|
391
398
|
if (this.isCodeFlowOptions(this.options)) redirectUri = this.options.redirectUri;
|
|
392
399
|
else throw new Error("CodeFlow options required for this operation");
|
|
393
|
-
const base = this.options.authUri
|
|
400
|
+
const base = (_this$options$authUri = this.options.authUri) !== null && _this$options$authUri !== void 0 ? _this$options$authUri : `${this.host}/auth/`;
|
|
394
401
|
const params = new URLSearchParams();
|
|
395
402
|
const nonce = getNonce();
|
|
396
403
|
params.set("response_type", "code");
|
|
@@ -404,8 +411,9 @@ var Gc2Service = class {
|
|
|
404
411
|
return `${base}?${params.toString()}`;
|
|
405
412
|
}
|
|
406
413
|
getSignUpURL() {
|
|
414
|
+
var _this$options$authUri2;
|
|
407
415
|
if (!this.isSignUpOptions(this.options)) throw new Error("CodeFlow options required for this operation");
|
|
408
|
-
const base = this.options.authUri
|
|
416
|
+
const base = (_this$options$authUri2 = this.options.authUri) !== null && _this$options$authUri2 !== void 0 ? _this$options$authUri2 : `${this.host}/signup/`;
|
|
409
417
|
const params = new URLSearchParams();
|
|
410
418
|
params.set("client_id", this.options.clientId);
|
|
411
419
|
params.set("parentdb", this.options.parentDb);
|
|
@@ -413,12 +421,14 @@ var Gc2Service = class {
|
|
|
413
421
|
return `${base}?${params.toString()}`;
|
|
414
422
|
}
|
|
415
423
|
async getAuthorizationCodeToken(code, codeVerifier) {
|
|
424
|
+
var _this3 = this;
|
|
425
|
+
var _this$options$tokenUr2;
|
|
416
426
|
let redirectUri;
|
|
417
|
-
if (
|
|
427
|
+
if (_this3.isCodeFlowOptions(_this3.options)) redirectUri = _this3.options.redirectUri;
|
|
418
428
|
else throw new Error("CodeFlow options required for this operation");
|
|
419
|
-
const path =
|
|
420
|
-
return
|
|
421
|
-
client_id:
|
|
429
|
+
const path = (_this$options$tokenUr2 = _this3.options.tokenUri) !== null && _this$options$tokenUr2 !== void 0 ? _this$options$tokenUr2 : `${_this3.host}/api/v4/oauth`;
|
|
430
|
+
return _this3.request(_this3.buildUrl(path), "POST", {
|
|
431
|
+
client_id: _this3.options.clientId,
|
|
422
432
|
redirect_uri: redirectUri,
|
|
423
433
|
grant_type: "authorization_code",
|
|
424
434
|
code,
|
|
@@ -426,16 +436,17 @@ var Gc2Service = class {
|
|
|
426
436
|
}, "application/x-www-form-urlencoded");
|
|
427
437
|
}
|
|
428
438
|
async getPasswordToken() {
|
|
439
|
+
var _this4 = this;
|
|
429
440
|
let username, password, database;
|
|
430
|
-
if (
|
|
431
|
-
username =
|
|
432
|
-
password =
|
|
433
|
-
database =
|
|
441
|
+
if (_this4.isPasswordFlowOptions(_this4.options)) {
|
|
442
|
+
username = _this4.options.username;
|
|
443
|
+
password = _this4.options.password;
|
|
444
|
+
database = _this4.options.database;
|
|
434
445
|
} else throw new Error("PasswordFlow options required for this operation");
|
|
435
|
-
const path = `${
|
|
436
|
-
return
|
|
437
|
-
client_id:
|
|
438
|
-
client_secret:
|
|
446
|
+
const path = `${_this4.host}/api/v4/oauth`;
|
|
447
|
+
return _this4.request(_this4.buildUrl(path), "POST", {
|
|
448
|
+
client_id: _this4.options.clientId,
|
|
449
|
+
client_secret: _this4.options.clientSecret,
|
|
439
450
|
grant_type: "password",
|
|
440
451
|
username,
|
|
441
452
|
password,
|
|
@@ -443,19 +454,22 @@ var Gc2Service = class {
|
|
|
443
454
|
});
|
|
444
455
|
}
|
|
445
456
|
async getRefreshToken(token) {
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
457
|
+
var _this5 = this;
|
|
458
|
+
var _this$options$tokenUr3;
|
|
459
|
+
const path = (_this$options$tokenUr3 = _this5.options.tokenUri) !== null && _this$options$tokenUr3 !== void 0 ? _this$options$tokenUr3 : `${_this5.host}/api/v4/oauth`;
|
|
460
|
+
return _this5.request(_this5.buildUrl(path), "POST", {
|
|
461
|
+
client_id: _this5.options.clientId,
|
|
449
462
|
grant_type: "refresh_token",
|
|
450
463
|
refresh_token: token
|
|
451
464
|
});
|
|
452
465
|
}
|
|
453
466
|
getSignOutURL() {
|
|
467
|
+
var _this$options$logoutU;
|
|
454
468
|
let redirectUri;
|
|
455
469
|
if (this.isCodeFlowOptions(this.options)) redirectUri = this.options.redirectUri;
|
|
456
470
|
else throw new Error("CodeFlow options required for this operation");
|
|
457
471
|
const params = new URLSearchParams({ redirect_uri: redirectUri });
|
|
458
|
-
return this.options.logoutUri
|
|
472
|
+
return (_this$options$logoutU = this.options.logoutUri) !== null && _this$options$logoutU !== void 0 ? _this$options$logoutU : `${this.host}/signout?${params.toString()}`;
|
|
459
473
|
}
|
|
460
474
|
};
|
|
461
475
|
|
|
@@ -473,6 +487,7 @@ var CodeFlow = class {
|
|
|
473
487
|
this.service = new Gc2Service(options);
|
|
474
488
|
}
|
|
475
489
|
async redirectHandle() {
|
|
490
|
+
var _this = this;
|
|
476
491
|
const url = window.location.search;
|
|
477
492
|
const queryParams = new URLSearchParams(url);
|
|
478
493
|
if (queryParams.get("error")) throw new Error(`Failed to redirect: ${url}`);
|
|
@@ -480,16 +495,16 @@ var CodeFlow = class {
|
|
|
480
495
|
if (code) {
|
|
481
496
|
if (queryParams.get("state") !== getStorage().getItem("state")) throw new Error("Possible CSRF attack. Aborting login!");
|
|
482
497
|
try {
|
|
483
|
-
const { access_token, refresh_token, id_token } = await
|
|
498
|
+
const { access_token, refresh_token, id_token } = await _this.service.getAuthorizationCodeToken(code, getStorage().getItem("codeVerifier"));
|
|
484
499
|
setTokens({
|
|
485
500
|
accessToken: access_token,
|
|
486
501
|
refreshToken: refresh_token,
|
|
487
502
|
idToken: id_token
|
|
488
503
|
});
|
|
489
504
|
setOptions({
|
|
490
|
-
clientId:
|
|
491
|
-
host:
|
|
492
|
-
redirectUri:
|
|
505
|
+
clientId: _this.options.clientId,
|
|
506
|
+
host: _this.options.host,
|
|
507
|
+
redirectUri: _this.options.redirectUri
|
|
493
508
|
});
|
|
494
509
|
getStorage().removeItem("state");
|
|
495
510
|
getStorage().removeItem("codeVerifier");
|
|
@@ -504,13 +519,14 @@ var CodeFlow = class {
|
|
|
504
519
|
throw new Error(e.message);
|
|
505
520
|
}
|
|
506
521
|
}
|
|
507
|
-
return await isLogin(
|
|
522
|
+
return await isLogin(_this.service);
|
|
508
523
|
}
|
|
509
524
|
async signIn() {
|
|
525
|
+
var _this2 = this;
|
|
510
526
|
const { state, codeVerifier, codeChallenge } = await generatePkceChallenge();
|
|
511
527
|
getStorage().setItem("state", state);
|
|
512
528
|
getStorage().setItem("codeVerifier", codeVerifier);
|
|
513
|
-
window.location.assign(
|
|
529
|
+
window.location.assign(_this2.service.getAuthorizationCodeURL(codeChallenge, state));
|
|
514
530
|
}
|
|
515
531
|
signOut() {
|
|
516
532
|
this.clear();
|
|
@@ -537,16 +553,17 @@ var PasswordFlow = class {
|
|
|
537
553
|
this.service = new Gc2Service(options);
|
|
538
554
|
}
|
|
539
555
|
async signIn() {
|
|
540
|
-
|
|
556
|
+
var _this = this;
|
|
557
|
+
const { access_token, refresh_token } = await _this.service.getPasswordToken();
|
|
541
558
|
setTokens({
|
|
542
559
|
accessToken: access_token,
|
|
543
560
|
refreshToken: refresh_token
|
|
544
561
|
});
|
|
545
562
|
setOptions({
|
|
546
|
-
clientId:
|
|
547
|
-
host:
|
|
563
|
+
clientId: _this.options.clientId,
|
|
564
|
+
host: _this.options.host,
|
|
548
565
|
redirectUri: "",
|
|
549
|
-
clientSecret:
|
|
566
|
+
clientSecret: _this.options.clientSecret
|
|
550
567
|
});
|
|
551
568
|
}
|
|
552
569
|
signOut() {
|
|
@@ -591,9 +608,10 @@ function isCentiaApiError(e) {
|
|
|
591
608
|
*/
|
|
592
609
|
var CentiaHttpClient = class {
|
|
593
610
|
constructor(config) {
|
|
611
|
+
var _config$auth, _config$fetch;
|
|
594
612
|
this.baseUrl = config.baseUrl.replace(/\/+$/, "");
|
|
595
|
-
this.auth = config.auth
|
|
596
|
-
this.fetchFn = config.fetch
|
|
613
|
+
this.auth = (_config$auth = config.auth) !== null && _config$auth !== void 0 ? _config$auth : {};
|
|
614
|
+
this.fetchFn = (_config$fetch = config.fetch) !== null && _config$fetch !== void 0 ? _config$fetch : globalThis.fetch.bind(globalThis);
|
|
597
615
|
this.userAgent = config.userAgent;
|
|
598
616
|
}
|
|
599
617
|
/**
|
|
@@ -608,24 +626,26 @@ var CentiaHttpClient = class {
|
|
|
608
626
|
* Useful for operations that return Location headers (POST 201, PATCH 303).
|
|
609
627
|
*/
|
|
610
628
|
async requestFull(opts) {
|
|
611
|
-
|
|
612
|
-
const
|
|
629
|
+
var _this2 = this;
|
|
630
|
+
const url = _this2.buildUrl(opts.path, opts.query);
|
|
631
|
+
const headers = await _this2.buildHeaders(opts);
|
|
613
632
|
const init = {
|
|
614
633
|
method: opts.method,
|
|
615
634
|
headers,
|
|
616
635
|
redirect: "manual"
|
|
617
636
|
};
|
|
618
|
-
if (opts.body !== void 0 && opts.body !== null) init.body =
|
|
619
|
-
const response = await
|
|
637
|
+
if (opts.body !== void 0 && opts.body !== null) init.body = _this2.resolveContentType(opts.contentType) === "application/json" ? JSON.stringify(opts.body) : opts.body;
|
|
638
|
+
const response = await _this2.fetchFn(url, init);
|
|
620
639
|
if (response.type === "opaqueredirect") {
|
|
621
|
-
|
|
640
|
+
var _opts$expectedStatus;
|
|
641
|
+
if (((_opts$expectedStatus = opts.expectedStatus) !== null && _opts$expectedStatus !== void 0 ? _opts$expectedStatus : 200) === 303) return {
|
|
622
642
|
body: null,
|
|
623
643
|
status: 303,
|
|
624
644
|
getHeader: (name) => name.toLowerCase() === "location" ? response.url : null
|
|
625
645
|
};
|
|
626
646
|
}
|
|
627
647
|
return {
|
|
628
|
-
body: await
|
|
648
|
+
body: await _this2.handleResponse(response, opts, url),
|
|
629
649
|
status: response.status,
|
|
630
650
|
getHeader: (name) => response.headers.get(name)
|
|
631
651
|
};
|
|
@@ -640,44 +660,50 @@ var CentiaHttpClient = class {
|
|
|
640
660
|
return url;
|
|
641
661
|
}
|
|
642
662
|
async buildHeaders(opts) {
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
663
|
+
var _this3 = this;
|
|
664
|
+
var _opts$accept;
|
|
665
|
+
const headers = { "Accept": (_opts$accept = opts.accept) !== null && _opts$accept !== void 0 ? _opts$accept : "application/json" };
|
|
666
|
+
if (_this3.auth.getAccessToken) {
|
|
667
|
+
const token = await _this3.auth.getAccessToken();
|
|
646
668
|
if (token) headers["Authorization"] = `Bearer ${token}`;
|
|
647
669
|
}
|
|
648
|
-
if (
|
|
649
|
-
const authHeaders = await
|
|
670
|
+
if (_this3.auth.getHeaders) {
|
|
671
|
+
const authHeaders = await _this3.auth.getHeaders();
|
|
650
672
|
Object.assign(headers, authHeaders);
|
|
651
673
|
}
|
|
652
|
-
if (
|
|
653
|
-
const ct =
|
|
674
|
+
if (_this3.userAgent && typeof navigator === "undefined") headers["User-Agent"] = _this3.userAgent;
|
|
675
|
+
const ct = _this3.resolveContentType(opts.contentType);
|
|
654
676
|
if (ct) headers["Content-Type"] = ct;
|
|
655
677
|
return headers;
|
|
656
678
|
}
|
|
657
679
|
resolveContentType(contentType) {
|
|
658
680
|
if (contentType === null) return null;
|
|
659
|
-
return contentType
|
|
681
|
+
return contentType !== null && contentType !== void 0 ? contentType : "application/json";
|
|
660
682
|
}
|
|
661
683
|
async handleResponse(response, opts, url) {
|
|
662
|
-
|
|
684
|
+
var _opts$expectedStatus2, _parsed;
|
|
685
|
+
const expectedStatus = (_opts$expectedStatus2 = opts.expectedStatus) !== null && _opts$expectedStatus2 !== void 0 ? _opts$expectedStatus2 : 200;
|
|
663
686
|
let bodyText = "";
|
|
664
687
|
try {
|
|
665
688
|
bodyText = await response.text();
|
|
666
|
-
} catch {}
|
|
689
|
+
} catch (_unused) {}
|
|
667
690
|
let parsed = null;
|
|
668
691
|
if (bodyText) try {
|
|
669
692
|
parsed = JSON.parse(bodyText);
|
|
670
|
-
} catch {}
|
|
671
|
-
if (response.status !== expectedStatus)
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
693
|
+
} catch (_unused2) {}
|
|
694
|
+
if (response.status !== expectedStatus) {
|
|
695
|
+
var _ref, _parsed$message, _response$headers$get;
|
|
696
|
+
throw new CentiaApiError({
|
|
697
|
+
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}`,
|
|
698
|
+
status: response.status,
|
|
699
|
+
code: parsed === null || parsed === void 0 ? void 0 : parsed.code,
|
|
700
|
+
details: parsed,
|
|
701
|
+
requestId: (_response$headers$get = response.headers.get("x-request-id")) !== null && _response$headers$get !== void 0 ? _response$headers$get : void 0,
|
|
702
|
+
method: opts.method,
|
|
703
|
+
url
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
return (_parsed = parsed) !== null && _parsed !== void 0 ? _parsed : bodyText || null;
|
|
681
707
|
}
|
|
682
708
|
};
|
|
683
709
|
/**
|
|
@@ -732,7 +758,7 @@ function getLegacyClient() {
|
|
|
732
758
|
//#region src/Sql.ts
|
|
733
759
|
var Sql = class {
|
|
734
760
|
constructor(client) {
|
|
735
|
-
this.client = client
|
|
761
|
+
this.client = client !== null && client !== void 0 ? client : getLegacyClient();
|
|
736
762
|
}
|
|
737
763
|
async exec(request) {
|
|
738
764
|
return this.client.request({
|
|
@@ -762,7 +788,7 @@ var SqlNoToken = class {
|
|
|
762
788
|
//#region src/Rpc.ts
|
|
763
789
|
var Rpc = class {
|
|
764
790
|
constructor(client) {
|
|
765
|
-
this.client = client
|
|
791
|
+
this.client = client !== null && client !== void 0 ? client : getLegacyClient();
|
|
766
792
|
}
|
|
767
793
|
async call(request) {
|
|
768
794
|
return this.client.request({
|
|
@@ -778,11 +804,12 @@ var Rpc = class {
|
|
|
778
804
|
var Gql = class {
|
|
779
805
|
constructor(schema, client) {
|
|
780
806
|
this.schema = schema;
|
|
781
|
-
this.client = client
|
|
807
|
+
this.client = client !== null && client !== void 0 ? client : getLegacyClient();
|
|
782
808
|
}
|
|
783
809
|
async request(request) {
|
|
784
|
-
|
|
785
|
-
|
|
810
|
+
var _this = this;
|
|
811
|
+
return _this.client.request({
|
|
812
|
+
path: `api/graphql/schema/${_this.schema}`,
|
|
786
813
|
method: "POST",
|
|
787
814
|
body: request
|
|
788
815
|
});
|
|
@@ -793,7 +820,7 @@ var Gql = class {
|
|
|
793
820
|
//#region src/Meta.ts
|
|
794
821
|
var Meta = class {
|
|
795
822
|
constructor(client) {
|
|
796
|
-
this.client = client
|
|
823
|
+
this.client = client !== null && client !== void 0 ? client : getLegacyClient();
|
|
797
824
|
}
|
|
798
825
|
async query(rel) {
|
|
799
826
|
return this.client.request({
|
|
@@ -840,7 +867,7 @@ var Claims = class {
|
|
|
840
867
|
//#region src/Users.ts
|
|
841
868
|
var Users = class {
|
|
842
869
|
constructor(client) {
|
|
843
|
-
this.client = client
|
|
870
|
+
this.client = client !== null && client !== void 0 ? client : getLegacyClient();
|
|
844
871
|
}
|
|
845
872
|
async get(user) {
|
|
846
873
|
return this.client.request({
|
|
@@ -850,6 +877,72 @@ var Users = class {
|
|
|
850
877
|
}
|
|
851
878
|
};
|
|
852
879
|
|
|
880
|
+
//#endregion
|
|
881
|
+
//#region \0@oxc-project+runtime@0.101.0/helpers/typeof.js
|
|
882
|
+
function _typeof(o) {
|
|
883
|
+
"@babel/helpers - typeof";
|
|
884
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
|
|
885
|
+
return typeof o$1;
|
|
886
|
+
} : function(o$1) {
|
|
887
|
+
return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
|
|
888
|
+
}, _typeof(o);
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
//#endregion
|
|
892
|
+
//#region \0@oxc-project+runtime@0.101.0/helpers/toPrimitive.js
|
|
893
|
+
function toPrimitive(t, r) {
|
|
894
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
895
|
+
var e = t[Symbol.toPrimitive];
|
|
896
|
+
if (void 0 !== e) {
|
|
897
|
+
var i = e.call(t, r || "default");
|
|
898
|
+
if ("object" != _typeof(i)) return i;
|
|
899
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
900
|
+
}
|
|
901
|
+
return ("string" === r ? String : Number)(t);
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
//#endregion
|
|
905
|
+
//#region \0@oxc-project+runtime@0.101.0/helpers/toPropertyKey.js
|
|
906
|
+
function toPropertyKey(t) {
|
|
907
|
+
var i = toPrimitive(t, "string");
|
|
908
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
//#endregion
|
|
912
|
+
//#region \0@oxc-project+runtime@0.101.0/helpers/defineProperty.js
|
|
913
|
+
function _defineProperty(e, r, t) {
|
|
914
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
915
|
+
value: t,
|
|
916
|
+
enumerable: !0,
|
|
917
|
+
configurable: !0,
|
|
918
|
+
writable: !0
|
|
919
|
+
}) : e[r] = t, e;
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
//#endregion
|
|
923
|
+
//#region \0@oxc-project+runtime@0.101.0/helpers/objectSpread2.js
|
|
924
|
+
function ownKeys(e, r) {
|
|
925
|
+
var t = Object.keys(e);
|
|
926
|
+
if (Object.getOwnPropertySymbols) {
|
|
927
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
928
|
+
r && (o = o.filter(function(r$1) {
|
|
929
|
+
return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
|
|
930
|
+
})), t.push.apply(t, o);
|
|
931
|
+
}
|
|
932
|
+
return t;
|
|
933
|
+
}
|
|
934
|
+
function _objectSpread2(e) {
|
|
935
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
936
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
937
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r$1) {
|
|
938
|
+
_defineProperty(e, r$1, t[r$1]);
|
|
939
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
|
|
940
|
+
Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
|
|
941
|
+
});
|
|
942
|
+
}
|
|
943
|
+
return e;
|
|
944
|
+
}
|
|
945
|
+
|
|
853
946
|
//#endregion
|
|
854
947
|
//#region src/Ws.ts
|
|
855
948
|
/**
|
|
@@ -860,30 +953,28 @@ var Users = class {
|
|
|
860
953
|
*/
|
|
861
954
|
var Ws = class {
|
|
862
955
|
constructor(options) {
|
|
956
|
+
var _this$options$wsClien;
|
|
863
957
|
this.ws = null;
|
|
864
958
|
this.listeners = {};
|
|
865
959
|
this.closed = false;
|
|
866
|
-
this.options = {
|
|
960
|
+
this.options = _objectSpread2({
|
|
867
961
|
reconnect: true,
|
|
868
|
-
reconnectInterval: 3e3
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
this.options.wsClient = this.options.wsClient ?? WebSocket;
|
|
962
|
+
reconnectInterval: 3e3
|
|
963
|
+
}, options);
|
|
964
|
+
this.options.wsClient = (_this$options$wsClien = this.options.wsClient) !== null && _this$options$wsClien !== void 0 ? _this$options$wsClien : WebSocket;
|
|
872
965
|
}
|
|
873
966
|
connect() {
|
|
874
967
|
this.closed = false;
|
|
875
968
|
this.doConnect();
|
|
876
969
|
}
|
|
877
970
|
disconnect() {
|
|
971
|
+
var _this$ws;
|
|
878
972
|
this.closed = true;
|
|
879
|
-
this.ws
|
|
973
|
+
(_this$ws = this.ws) === null || _this$ws === void 0 || _this$ws.close();
|
|
880
974
|
this.ws = null;
|
|
881
975
|
}
|
|
882
976
|
subscribe(sub) {
|
|
883
|
-
this.send({
|
|
884
|
-
type: "subscription",
|
|
885
|
-
...sub
|
|
886
|
-
});
|
|
977
|
+
this.send(_objectSpread2({ type: "subscription" }, sub));
|
|
887
978
|
}
|
|
888
979
|
send(data) {
|
|
889
980
|
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) throw new Error("WebSocket is not connected");
|
|
@@ -901,7 +992,8 @@ var Ws = class {
|
|
|
901
992
|
if (idx !== -1) arr.splice(idx, 1);
|
|
902
993
|
}
|
|
903
994
|
get connected() {
|
|
904
|
-
|
|
995
|
+
var _this$ws2;
|
|
996
|
+
return ((_this$ws2 = this.ws) === null || _this$ws2 === void 0 ? void 0 : _this$ws2.readyState) === WebSocket.OPEN;
|
|
905
997
|
}
|
|
906
998
|
emit(event, data) {
|
|
907
999
|
const arr = this.listeners[event];
|
|
@@ -923,7 +1015,7 @@ var Ws = class {
|
|
|
923
1015
|
let msg;
|
|
924
1016
|
try {
|
|
925
1017
|
msg = JSON.parse(typeof event.data === "string" ? event.data : event.data.toString());
|
|
926
|
-
} catch {
|
|
1018
|
+
} catch (_unused) {
|
|
927
1019
|
return;
|
|
928
1020
|
}
|
|
929
1021
|
switch (msg.type) {
|
|
@@ -955,7 +1047,7 @@ var Ws = class {
|
|
|
955
1047
|
//#region src/Stats.ts
|
|
956
1048
|
var Stats = class {
|
|
957
1049
|
constructor(client) {
|
|
958
|
-
this.client = client
|
|
1050
|
+
this.client = client !== null && client !== void 0 ? client : getLegacyClient();
|
|
959
1051
|
}
|
|
960
1052
|
async get() {
|
|
961
1053
|
return this.client.request({
|
|
@@ -969,7 +1061,7 @@ var Stats = class {
|
|
|
969
1061
|
//#region src/Tables.ts
|
|
970
1062
|
var Tables = class {
|
|
971
1063
|
constructor(client) {
|
|
972
|
-
this.client = client
|
|
1064
|
+
this.client = client !== null && client !== void 0 ? client : getLegacyClient();
|
|
973
1065
|
}
|
|
974
1066
|
async get(schema, table) {
|
|
975
1067
|
return this.client.request({
|
|
@@ -1075,7 +1167,8 @@ var SignUp = class {
|
|
|
1075
1167
|
this.service = new Gc2Service(options);
|
|
1076
1168
|
}
|
|
1077
1169
|
async signUp() {
|
|
1078
|
-
|
|
1170
|
+
var _this = this;
|
|
1171
|
+
window.location.assign(_this.service.getSignUpURL());
|
|
1079
1172
|
}
|
|
1080
1173
|
};
|
|
1081
1174
|
|
|
@@ -1276,14 +1369,20 @@ function validateInArrayValues(col, key, values, op) {
|
|
|
1276
1369
|
function findJoinOn(base, target) {
|
|
1277
1370
|
const bc = base.constraints || [];
|
|
1278
1371
|
const tc = target.constraints || [];
|
|
1279
|
-
for (const c of bc)
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1372
|
+
for (const c of bc) {
|
|
1373
|
+
var _c$columns, _c$referenced_columns;
|
|
1374
|
+
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) => ({
|
|
1375
|
+
left: String(col),
|
|
1376
|
+
right: String(c.referenced_columns[i])
|
|
1377
|
+
}));
|
|
1378
|
+
}
|
|
1379
|
+
for (const c of tc) {
|
|
1380
|
+
var _c$columns2, _c$referenced_columns2;
|
|
1381
|
+
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) => ({
|
|
1382
|
+
left: String(rcol),
|
|
1383
|
+
right: String(c.columns[i])
|
|
1384
|
+
}));
|
|
1385
|
+
}
|
|
1287
1386
|
return null;
|
|
1288
1387
|
}
|
|
1289
1388
|
var TableQueryImpl = class {
|
|
@@ -1864,30 +1963,35 @@ var Schemas = class {
|
|
|
1864
1963
|
this.client = client;
|
|
1865
1964
|
}
|
|
1866
1965
|
async getSchema(schema, opts) {
|
|
1966
|
+
var _this = this;
|
|
1867
1967
|
const path = schema ? `api/v4/schemas/${encodeURIComponent(schema)}` : "api/v4/schemas";
|
|
1868
1968
|
const query = {};
|
|
1869
|
-
if (opts
|
|
1870
|
-
return
|
|
1969
|
+
if (opts === null || opts === void 0 ? void 0 : opts.namesOnly) query.namesOnly = "true";
|
|
1970
|
+
return _this.client.request({
|
|
1871
1971
|
path,
|
|
1872
1972
|
method: "GET",
|
|
1873
1973
|
query: Object.keys(query).length > 0 ? query : void 0
|
|
1874
1974
|
});
|
|
1875
1975
|
}
|
|
1876
1976
|
async postSchema(body) {
|
|
1877
|
-
|
|
1977
|
+
var _this2 = this;
|
|
1978
|
+
var _res$getHeader;
|
|
1979
|
+
return { location: (_res$getHeader = (await _this2.client.requestFull({
|
|
1878
1980
|
path: "api/v4/schemas",
|
|
1879
1981
|
method: "POST",
|
|
1880
1982
|
body,
|
|
1881
1983
|
expectedStatus: 201
|
|
1882
|
-
})).getHeader("Location")
|
|
1984
|
+
})).getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "" };
|
|
1883
1985
|
}
|
|
1884
1986
|
async patchSchema(schema, body) {
|
|
1885
|
-
|
|
1987
|
+
var _this3 = this;
|
|
1988
|
+
var _res$getHeader2;
|
|
1989
|
+
return { location: (_res$getHeader2 = (await _this3.client.requestFull({
|
|
1886
1990
|
path: `api/v4/schemas/${encodeURIComponent(schema)}`,
|
|
1887
1991
|
method: "PATCH",
|
|
1888
1992
|
body,
|
|
1889
1993
|
expectedStatus: 303
|
|
1890
|
-
})).getHeader("Location")
|
|
1994
|
+
})).getHeader("Location")) !== null && _res$getHeader2 !== void 0 ? _res$getHeader2 : "" };
|
|
1891
1995
|
}
|
|
1892
1996
|
async deleteSchema(schema) {
|
|
1893
1997
|
await this.client.request({
|
|
@@ -1908,31 +2012,37 @@ var Columns = class {
|
|
|
1908
2012
|
return `api/v4/schemas/${encodeURIComponent(schema)}/tables/${encodeURIComponent(table)}/columns`;
|
|
1909
2013
|
}
|
|
1910
2014
|
async getColumn(schema, table, column) {
|
|
1911
|
-
|
|
1912
|
-
|
|
2015
|
+
var _this = this;
|
|
2016
|
+
const path = column ? `${_this.basePath(schema, table)}/${encodeURIComponent(column)}` : _this.basePath(schema, table);
|
|
2017
|
+
return _this.client.request({
|
|
1913
2018
|
path,
|
|
1914
2019
|
method: "GET"
|
|
1915
2020
|
});
|
|
1916
2021
|
}
|
|
1917
2022
|
async postColumn(schema, table, body) {
|
|
1918
|
-
|
|
1919
|
-
|
|
2023
|
+
var _this2 = this;
|
|
2024
|
+
var _res$getHeader;
|
|
2025
|
+
return { location: (_res$getHeader = (await _this2.client.requestFull({
|
|
2026
|
+
path: _this2.basePath(schema, table),
|
|
1920
2027
|
method: "POST",
|
|
1921
2028
|
body,
|
|
1922
2029
|
expectedStatus: 201
|
|
1923
|
-
})).getHeader("Location")
|
|
2030
|
+
})).getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "" };
|
|
1924
2031
|
}
|
|
1925
2032
|
async patchColumn(schema, table, column, body) {
|
|
1926
|
-
|
|
1927
|
-
|
|
2033
|
+
var _this3 = this;
|
|
2034
|
+
var _res$getHeader2;
|
|
2035
|
+
return { location: (_res$getHeader2 = (await _this3.client.requestFull({
|
|
2036
|
+
path: `${_this3.basePath(schema, table)}/${encodeURIComponent(column)}`,
|
|
1928
2037
|
method: "PATCH",
|
|
1929
2038
|
body,
|
|
1930
2039
|
expectedStatus: 303
|
|
1931
|
-
})).getHeader("Location")
|
|
2040
|
+
})).getHeader("Location")) !== null && _res$getHeader2 !== void 0 ? _res$getHeader2 : "" };
|
|
1932
2041
|
}
|
|
1933
2042
|
async deleteColumn(schema, table, column) {
|
|
1934
|
-
|
|
1935
|
-
|
|
2043
|
+
var _this4 = this;
|
|
2044
|
+
await _this4.client.request({
|
|
2045
|
+
path: `${_this4.basePath(schema, table)}/${encodeURIComponent(column)}`,
|
|
1936
2046
|
method: "DELETE",
|
|
1937
2047
|
expectedStatus: 204
|
|
1938
2048
|
});
|
|
@@ -1949,23 +2059,27 @@ var Constraints = class {
|
|
|
1949
2059
|
return `api/v4/schemas/${encodeURIComponent(schema)}/tables/${encodeURIComponent(table)}/constraints`;
|
|
1950
2060
|
}
|
|
1951
2061
|
async getConstraint(schema, table, constraint) {
|
|
1952
|
-
|
|
1953
|
-
|
|
2062
|
+
var _this = this;
|
|
2063
|
+
const path = constraint ? `${_this.basePath(schema, table)}/${encodeURIComponent(constraint)}` : _this.basePath(schema, table);
|
|
2064
|
+
return _this.client.request({
|
|
1954
2065
|
path,
|
|
1955
2066
|
method: "GET"
|
|
1956
2067
|
});
|
|
1957
2068
|
}
|
|
1958
2069
|
async postConstraint(schema, table, body) {
|
|
1959
|
-
|
|
1960
|
-
|
|
2070
|
+
var _this2 = this;
|
|
2071
|
+
var _res$getHeader;
|
|
2072
|
+
return { location: (_res$getHeader = (await _this2.client.requestFull({
|
|
2073
|
+
path: _this2.basePath(schema, table),
|
|
1961
2074
|
method: "POST",
|
|
1962
2075
|
body,
|
|
1963
2076
|
expectedStatus: 201
|
|
1964
|
-
})).getHeader("Location")
|
|
2077
|
+
})).getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "" };
|
|
1965
2078
|
}
|
|
1966
2079
|
async deleteConstraint(schema, table, constraint) {
|
|
1967
|
-
|
|
1968
|
-
|
|
2080
|
+
var _this3 = this;
|
|
2081
|
+
await _this3.client.request({
|
|
2082
|
+
path: `${_this3.basePath(schema, table)}/${encodeURIComponent(constraint)}`,
|
|
1969
2083
|
method: "DELETE",
|
|
1970
2084
|
expectedStatus: 204
|
|
1971
2085
|
});
|
|
@@ -1982,23 +2096,27 @@ var Indices = class {
|
|
|
1982
2096
|
return `api/v4/schemas/${encodeURIComponent(schema)}/tables/${encodeURIComponent(table)}/indices`;
|
|
1983
2097
|
}
|
|
1984
2098
|
async getIndex(schema, table, index) {
|
|
1985
|
-
|
|
1986
|
-
|
|
2099
|
+
var _this = this;
|
|
2100
|
+
const path = index ? `${_this.basePath(schema, table)}/${encodeURIComponent(index)}` : _this.basePath(schema, table);
|
|
2101
|
+
return _this.client.request({
|
|
1987
2102
|
path,
|
|
1988
2103
|
method: "GET"
|
|
1989
2104
|
});
|
|
1990
2105
|
}
|
|
1991
2106
|
async postIndex(schema, table, body) {
|
|
1992
|
-
|
|
1993
|
-
|
|
2107
|
+
var _this2 = this;
|
|
2108
|
+
var _res$getHeader;
|
|
2109
|
+
return { location: (_res$getHeader = (await _this2.client.requestFull({
|
|
2110
|
+
path: _this2.basePath(schema, table),
|
|
1994
2111
|
method: "POST",
|
|
1995
2112
|
body,
|
|
1996
2113
|
expectedStatus: 201
|
|
1997
|
-
})).getHeader("Location")
|
|
2114
|
+
})).getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "" };
|
|
1998
2115
|
}
|
|
1999
2116
|
async deleteIndex(schema, table, index) {
|
|
2000
|
-
|
|
2001
|
-
|
|
2117
|
+
var _this3 = this;
|
|
2118
|
+
await _this3.client.request({
|
|
2119
|
+
path: `${_this3.basePath(schema, table)}/${encodeURIComponent(index)}`,
|
|
2002
2120
|
method: "DELETE",
|
|
2003
2121
|
expectedStatus: 204
|
|
2004
2122
|
});
|
|
@@ -2015,31 +2133,37 @@ var Sequences = class {
|
|
|
2015
2133
|
return `api/v4/schemas/${encodeURIComponent(schema)}/sequences`;
|
|
2016
2134
|
}
|
|
2017
2135
|
async getSequence(schema, sequence) {
|
|
2018
|
-
|
|
2019
|
-
|
|
2136
|
+
var _this = this;
|
|
2137
|
+
const path = sequence ? `${_this.basePath(schema)}/${encodeURIComponent(sequence)}` : _this.basePath(schema);
|
|
2138
|
+
return _this.client.request({
|
|
2020
2139
|
path,
|
|
2021
2140
|
method: "GET"
|
|
2022
2141
|
});
|
|
2023
2142
|
}
|
|
2024
2143
|
async postSequence(schema, body) {
|
|
2025
|
-
|
|
2026
|
-
|
|
2144
|
+
var _this2 = this;
|
|
2145
|
+
var _res$getHeader;
|
|
2146
|
+
return { location: (_res$getHeader = (await _this2.client.requestFull({
|
|
2147
|
+
path: _this2.basePath(schema),
|
|
2027
2148
|
method: "POST",
|
|
2028
2149
|
body,
|
|
2029
2150
|
expectedStatus: 201
|
|
2030
|
-
})).getHeader("Location")
|
|
2151
|
+
})).getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "" };
|
|
2031
2152
|
}
|
|
2032
2153
|
async patchSequence(schema, sequence, body) {
|
|
2033
|
-
|
|
2034
|
-
|
|
2154
|
+
var _this3 = this;
|
|
2155
|
+
var _res$getHeader2;
|
|
2156
|
+
return { location: (_res$getHeader2 = (await _this3.client.requestFull({
|
|
2157
|
+
path: `${_this3.basePath(schema)}/${encodeURIComponent(sequence)}`,
|
|
2035
2158
|
method: "PATCH",
|
|
2036
2159
|
body,
|
|
2037
2160
|
expectedStatus: 303
|
|
2038
|
-
})).getHeader("Location")
|
|
2161
|
+
})).getHeader("Location")) !== null && _res$getHeader2 !== void 0 ? _res$getHeader2 : "" };
|
|
2039
2162
|
}
|
|
2040
2163
|
async deleteSequence(schema, sequence) {
|
|
2041
|
-
|
|
2042
|
-
|
|
2164
|
+
var _this4 = this;
|
|
2165
|
+
await _this4.client.request({
|
|
2166
|
+
path: `${_this4.basePath(schema)}/${encodeURIComponent(sequence)}`,
|
|
2043
2167
|
method: "DELETE",
|
|
2044
2168
|
expectedStatus: 204
|
|
2045
2169
|
});
|
|
@@ -2056,31 +2180,37 @@ var ProvisioningTables = class {
|
|
|
2056
2180
|
return `api/v4/schemas/${encodeURIComponent(schema)}/tables`;
|
|
2057
2181
|
}
|
|
2058
2182
|
async getTable(schema, table) {
|
|
2059
|
-
|
|
2060
|
-
|
|
2183
|
+
var _this = this;
|
|
2184
|
+
const path = table ? `${_this.basePath(schema)}/${encodeURIComponent(table)}` : _this.basePath(schema);
|
|
2185
|
+
return _this.client.request({
|
|
2061
2186
|
path,
|
|
2062
2187
|
method: "GET"
|
|
2063
2188
|
});
|
|
2064
2189
|
}
|
|
2065
2190
|
async postTable(schema, body) {
|
|
2066
|
-
|
|
2067
|
-
|
|
2191
|
+
var _this2 = this;
|
|
2192
|
+
var _res$getHeader;
|
|
2193
|
+
return { location: (_res$getHeader = (await _this2.client.requestFull({
|
|
2194
|
+
path: _this2.basePath(schema),
|
|
2068
2195
|
method: "POST",
|
|
2069
2196
|
body,
|
|
2070
2197
|
expectedStatus: 201
|
|
2071
|
-
})).getHeader("Location")
|
|
2198
|
+
})).getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "" };
|
|
2072
2199
|
}
|
|
2073
2200
|
async patchTable(schema, table, body) {
|
|
2074
|
-
|
|
2075
|
-
|
|
2201
|
+
var _this3 = this;
|
|
2202
|
+
var _res$getHeader2;
|
|
2203
|
+
return { location: (_res$getHeader2 = (await _this3.client.requestFull({
|
|
2204
|
+
path: `${_this3.basePath(schema)}/${encodeURIComponent(table)}`,
|
|
2076
2205
|
method: "PATCH",
|
|
2077
2206
|
body,
|
|
2078
2207
|
expectedStatus: 303
|
|
2079
|
-
})).getHeader("Location")
|
|
2208
|
+
})).getHeader("Location")) !== null && _res$getHeader2 !== void 0 ? _res$getHeader2 : "" };
|
|
2080
2209
|
}
|
|
2081
2210
|
async deleteTable(schema, table) {
|
|
2082
|
-
|
|
2083
|
-
|
|
2211
|
+
var _this4 = this;
|
|
2212
|
+
await _this4.client.request({
|
|
2213
|
+
path: `${_this4.basePath(schema)}/${encodeURIComponent(table)}`,
|
|
2084
2214
|
method: "DELETE",
|
|
2085
2215
|
expectedStatus: 204
|
|
2086
2216
|
});
|
|
@@ -2094,27 +2224,32 @@ var ProvisioningUsers = class {
|
|
|
2094
2224
|
this.client = client;
|
|
2095
2225
|
}
|
|
2096
2226
|
async getUser(name) {
|
|
2227
|
+
var _this = this;
|
|
2097
2228
|
const path = name ? `api/v4/users/${encodeURIComponent(name)}` : "api/v4/users";
|
|
2098
|
-
return
|
|
2229
|
+
return _this.client.request({
|
|
2099
2230
|
path,
|
|
2100
2231
|
method: "GET"
|
|
2101
2232
|
});
|
|
2102
2233
|
}
|
|
2103
2234
|
async postUser(body) {
|
|
2104
|
-
|
|
2235
|
+
var _this2 = this;
|
|
2236
|
+
var _res$getHeader;
|
|
2237
|
+
return { location: (_res$getHeader = (await _this2.client.requestFull({
|
|
2105
2238
|
path: "api/v4/users",
|
|
2106
2239
|
method: "POST",
|
|
2107
2240
|
body,
|
|
2108
2241
|
expectedStatus: 201
|
|
2109
|
-
})).getHeader("Location")
|
|
2242
|
+
})).getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "" };
|
|
2110
2243
|
}
|
|
2111
2244
|
async patchUser(name, body) {
|
|
2112
|
-
|
|
2245
|
+
var _this3 = this;
|
|
2246
|
+
var _res$getHeader2;
|
|
2247
|
+
return { location: (_res$getHeader2 = (await _this3.client.requestFull({
|
|
2113
2248
|
path: `api/v4/users/${encodeURIComponent(name)}`,
|
|
2114
2249
|
method: "PATCH",
|
|
2115
2250
|
body,
|
|
2116
2251
|
expectedStatus: 303
|
|
2117
|
-
})).getHeader("Location")
|
|
2252
|
+
})).getHeader("Location")) !== null && _res$getHeader2 !== void 0 ? _res$getHeader2 : "" };
|
|
2118
2253
|
}
|
|
2119
2254
|
async deleteUser(name) {
|
|
2120
2255
|
await this.client.request({
|
|
@@ -2132,31 +2267,36 @@ var ProvisioningClients = class {
|
|
|
2132
2267
|
this.client = client;
|
|
2133
2268
|
}
|
|
2134
2269
|
async getClient(id) {
|
|
2270
|
+
var _this = this;
|
|
2135
2271
|
const path = id ? `api/v4/clients/${encodeURIComponent(id)}` : "api/v4/clients";
|
|
2136
|
-
return
|
|
2272
|
+
return _this.client.request({
|
|
2137
2273
|
path,
|
|
2138
2274
|
method: "GET"
|
|
2139
2275
|
});
|
|
2140
2276
|
}
|
|
2141
2277
|
async postClient(body) {
|
|
2142
|
-
|
|
2278
|
+
var _this2 = this;
|
|
2279
|
+
var _res$getHeader;
|
|
2280
|
+
const res = await _this2.client.requestFull({
|
|
2143
2281
|
path: "api/v4/clients",
|
|
2144
2282
|
method: "POST",
|
|
2145
2283
|
body,
|
|
2146
2284
|
expectedStatus: 201
|
|
2147
2285
|
});
|
|
2148
2286
|
return {
|
|
2149
|
-
location: res.getHeader("Location")
|
|
2287
|
+
location: (_res$getHeader = res.getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "",
|
|
2150
2288
|
secret: res.body.secret
|
|
2151
2289
|
};
|
|
2152
2290
|
}
|
|
2153
2291
|
async patchClient(id, body) {
|
|
2154
|
-
|
|
2292
|
+
var _this3 = this;
|
|
2293
|
+
var _res$getHeader2;
|
|
2294
|
+
return { location: (_res$getHeader2 = (await _this3.client.requestFull({
|
|
2155
2295
|
path: `api/v4/clients/${encodeURIComponent(id)}`,
|
|
2156
2296
|
method: "PATCH",
|
|
2157
2297
|
body,
|
|
2158
2298
|
expectedStatus: 303
|
|
2159
|
-
})).getHeader("Location")
|
|
2299
|
+
})).getHeader("Location")) !== null && _res$getHeader2 !== void 0 ? _res$getHeader2 : "" };
|
|
2160
2300
|
}
|
|
2161
2301
|
async deleteClient(id) {
|
|
2162
2302
|
await this.client.request({
|
|
@@ -2174,8 +2314,9 @@ var Rules = class {
|
|
|
2174
2314
|
this.client = client;
|
|
2175
2315
|
}
|
|
2176
2316
|
async getRule(id) {
|
|
2317
|
+
var _this = this;
|
|
2177
2318
|
const path = id != null ? `api/v4/rules/${encodeURIComponent(id)}` : "api/v4/rules";
|
|
2178
|
-
return
|
|
2319
|
+
return _this.client.request({
|
|
2179
2320
|
path,
|
|
2180
2321
|
method: "GET"
|
|
2181
2322
|
});
|
|
@@ -2189,12 +2330,14 @@ var Rules = class {
|
|
|
2189
2330
|
});
|
|
2190
2331
|
}
|
|
2191
2332
|
async patchRule(id, body) {
|
|
2192
|
-
|
|
2333
|
+
var _this3 = this;
|
|
2334
|
+
var _res$getHeader;
|
|
2335
|
+
return { location: (_res$getHeader = (await _this3.client.requestFull({
|
|
2193
2336
|
path: `api/v4/rules/${encodeURIComponent(id)}`,
|
|
2194
2337
|
method: "PATCH",
|
|
2195
2338
|
body,
|
|
2196
2339
|
expectedStatus: 303
|
|
2197
|
-
})).getHeader("Location")
|
|
2340
|
+
})).getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "" };
|
|
2198
2341
|
}
|
|
2199
2342
|
async deleteRule(id) {
|
|
2200
2343
|
await this.client.request({
|
|
@@ -2233,27 +2376,32 @@ var RpcMethods = class {
|
|
|
2233
2376
|
this.client = client;
|
|
2234
2377
|
}
|
|
2235
2378
|
async getRpc(method) {
|
|
2379
|
+
var _this = this;
|
|
2236
2380
|
const path = method ? `api/v4/methods/${encodeURIComponent(method)}` : "api/v4/methods";
|
|
2237
|
-
return
|
|
2381
|
+
return _this.client.request({
|
|
2238
2382
|
path,
|
|
2239
2383
|
method: "GET"
|
|
2240
2384
|
});
|
|
2241
2385
|
}
|
|
2242
2386
|
async postRpc(body) {
|
|
2243
|
-
|
|
2387
|
+
var _this2 = this;
|
|
2388
|
+
var _res$getHeader;
|
|
2389
|
+
return { location: (_res$getHeader = (await _this2.client.requestFull({
|
|
2244
2390
|
path: "api/v4/methods",
|
|
2245
2391
|
method: "POST",
|
|
2246
2392
|
body,
|
|
2247
2393
|
expectedStatus: 201
|
|
2248
|
-
})).getHeader("Location")
|
|
2394
|
+
})).getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "" };
|
|
2249
2395
|
}
|
|
2250
2396
|
async patchRpc(method, body) {
|
|
2251
|
-
|
|
2397
|
+
var _this3 = this;
|
|
2398
|
+
var _res$getHeader2;
|
|
2399
|
+
return { location: (_res$getHeader2 = (await _this3.client.requestFull({
|
|
2252
2400
|
path: `api/v4/methods/${encodeURIComponent(method)}`,
|
|
2253
2401
|
method: "PATCH",
|
|
2254
2402
|
body,
|
|
2255
2403
|
expectedStatus: 303
|
|
2256
|
-
})).getHeader("Location")
|
|
2404
|
+
})).getHeader("Location")) !== null && _res$getHeader2 !== void 0 ? _res$getHeader2 : "" };
|
|
2257
2405
|
}
|
|
2258
2406
|
async deleteRpc(method) {
|
|
2259
2407
|
await this.client.request({
|
|
@@ -2313,7 +2461,8 @@ var FileImport = class {
|
|
|
2313
2461
|
* sequentially. The server reassembles the file from the chunks.
|
|
2314
2462
|
*/
|
|
2315
2463
|
async postFileUpload(formData, options) {
|
|
2316
|
-
|
|
2464
|
+
var _this = this;
|
|
2465
|
+
if (!(options === null || options === void 0 ? void 0 : options.chunkSize)) return _this.client.request({
|
|
2317
2466
|
path: "api/v4/file/upload",
|
|
2318
2467
|
method: "POST",
|
|
2319
2468
|
body: formData,
|
|
@@ -2331,7 +2480,7 @@ var FileImport = class {
|
|
|
2331
2480
|
const chunk = file.slice(start, end);
|
|
2332
2481
|
const chunkForm = new FormData();
|
|
2333
2482
|
chunkForm.append("filename", chunk, fileName);
|
|
2334
|
-
result = await
|
|
2483
|
+
result = await _this.client.request({
|
|
2335
2484
|
path: "api/v4/file/upload",
|
|
2336
2485
|
method: "POST",
|
|
2337
2486
|
body: chunkForm,
|