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