@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.
@@ -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?.getRandomValues) crypto.getRandomValues(array);
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?.subtle) return crypto.subtle.digest("SHA-256", data);
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?.id_token
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?.idToken || ""
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?.accessToken || "",
291
- refreshToken: tokens?.refreshToken || "",
292
- idToken: tokens?.idToken || ""
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?.clientId || "",
308
- host: options?.host || "",
309
- redirectUri: options?.redirectUri || ""
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
- const path = this.options.deviceUri ?? `${this.host}/api/v4/oauth/device`;
369
- return this.request(this.buildUrl(path), "POST", { client_id: this.options.clientId });
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
- const path = this.options.tokenUri ?? `${this.host}/api/v4/oauth`;
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 this.request(this.buildUrl(path), "POST", {
376
- client_id: this.options.clientId,
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 ?? `${this.host}/auth/`;
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 ?? `${this.host}/signup/`;
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 (this.isCodeFlowOptions(this.options)) redirectUri = this.options.redirectUri;
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 = this.options.tokenUri ?? `${this.host}/api/v4/oauth`;
425
- return this.request(this.buildUrl(path), "POST", {
426
- client_id: this.options.clientId,
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 (this.isPasswordFlowOptions(this.options)) {
436
- username = this.options.username;
437
- password = this.options.password;
438
- database = this.options.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 = `${this.host}/api/v4/oauth`;
441
- return this.request(this.buildUrl(path), "POST", {
442
- client_id: this.options.clientId,
443
- client_secret: this.options.clientSecret,
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
- const path = this.options.tokenUri ?? `${this.host}/api/v4/oauth`;
452
- return this.request(this.buildUrl(path), "POST", {
453
- client_id: this.options.clientId,
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 ?? `${this.host}/signout?${params.toString()}`;
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 this.service.getAuthorizationCodeToken(code, getStorage().getItem("codeVerifier"));
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: this.options.clientId,
496
- host: this.options.host,
497
- redirectUri: this.options.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(this.service);
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(this.service.getAuthorizationCodeURL(codeChallenge, state));
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
- const { access_token, refresh_token } = await this.service.getPasswordToken();
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: this.options.clientId,
552
- host: this.options.host,
568
+ clientId: _this.options.clientId,
569
+ host: _this.options.host,
553
570
  redirectUri: "",
554
- clientSecret: this.options.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 ?? globalThis.fetch.bind(globalThis);
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
- const url = this.buildUrl(opts.path, opts.query);
617
- const headers = await this.buildHeaders(opts);
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 = this.resolveContentType(opts.contentType) === "application/json" ? JSON.stringify(opts.body) : opts.body;
624
- const response = await this.fetchFn(url, init);
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
- if ((opts.expectedStatus ?? 200) === 303) return {
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 this.handleResponse(response, opts, url),
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
- const headers = { "Accept": opts.accept ?? "application/json" };
649
- if (this.auth.getAccessToken) {
650
- const token = await this.auth.getAccessToken();
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 (this.auth.getHeaders) {
654
- const authHeaders = await this.auth.getHeaders();
675
+ if (_this3.auth.getHeaders) {
676
+ const authHeaders = await _this3.auth.getHeaders();
655
677
  Object.assign(headers, authHeaders);
656
678
  }
657
- if (this.userAgent && typeof navigator === "undefined") headers["User-Agent"] = this.userAgent;
658
- const ct = this.resolveContentType(opts.contentType);
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 ?? "application/json";
686
+ return contentType !== null && contentType !== void 0 ? contentType : "application/json";
665
687
  }
666
688
  async handleResponse(response, opts, url) {
667
- const expectedStatus = opts.expectedStatus ?? 200;
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) throw new CentiaApiError({
677
- message: (parsed?.message ?? parsed?.error ?? bodyText) || `Unexpected status ${response.status}`,
678
- status: response.status,
679
- code: parsed?.code,
680
- details: parsed,
681
- requestId: response.headers.get("x-request-id") ?? void 0,
682
- method: opts.method,
683
- url
684
- });
685
- return parsed ?? (bodyText || null);
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 ?? getLegacyClient();
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 ?? getLegacyClient();
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 ?? getLegacyClient();
812
+ this.client = client !== null && client !== void 0 ? client : getLegacyClient();
787
813
  }
788
814
  async request(request) {
789
- return this.client.request({
790
- path: `api/graphql/schema/${this.schema}`,
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 ?? getLegacyClient();
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 ?? getLegacyClient();
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
- ...options
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?.close();
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
- return this.ws?.readyState === WebSocket.OPEN;
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 ?? getLegacyClient();
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 ?? getLegacyClient();
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
- window.location.assign(this.service.getSignUpURL());
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) 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) => ({
1285
- left: String(col),
1286
- right: String(c.referenced_columns[i])
1287
- }));
1288
- 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) => ({
1289
- left: String(rcol),
1290
- right: String(c.columns[i])
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?.namesOnly) query.namesOnly = "true";
1875
- return this.client.request({
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
- return { location: (await this.client.requestFull({
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
- return { location: (await this.client.requestFull({
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
- const path = column ? `${this.basePath(schema, table)}/${encodeURIComponent(column)}` : this.basePath(schema, table);
1917
- return this.client.request({
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
- return { location: (await this.client.requestFull({
1924
- path: this.basePath(schema, table),
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
- return { location: (await this.client.requestFull({
1932
- path: `${this.basePath(schema, table)}/${encodeURIComponent(column)}`,
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
- await this.client.request({
1940
- path: `${this.basePath(schema, table)}/${encodeURIComponent(column)}`,
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
- const path = constraint ? `${this.basePath(schema, table)}/${encodeURIComponent(constraint)}` : this.basePath(schema, table);
1958
- return this.client.request({
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
- return { location: (await this.client.requestFull({
1965
- path: this.basePath(schema, table),
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
- await this.client.request({
1973
- path: `${this.basePath(schema, table)}/${encodeURIComponent(constraint)}`,
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
- const path = index ? `${this.basePath(schema, table)}/${encodeURIComponent(index)}` : this.basePath(schema, table);
1991
- return this.client.request({
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
- return { location: (await this.client.requestFull({
1998
- path: this.basePath(schema, table),
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
- await this.client.request({
2006
- path: `${this.basePath(schema, table)}/${encodeURIComponent(index)}`,
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
- const path = sequence ? `${this.basePath(schema)}/${encodeURIComponent(sequence)}` : this.basePath(schema);
2024
- return this.client.request({
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
- return { location: (await this.client.requestFull({
2031
- path: this.basePath(schema),
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
- return { location: (await this.client.requestFull({
2039
- path: `${this.basePath(schema)}/${encodeURIComponent(sequence)}`,
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
- await this.client.request({
2047
- path: `${this.basePath(schema)}/${encodeURIComponent(sequence)}`,
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
  });
@@ -2061,31 +2185,37 @@
2061
2185
  return `api/v4/schemas/${encodeURIComponent(schema)}/tables`;
2062
2186
  }
2063
2187
  async getTable(schema, table) {
2064
- const path = table ? `${this.basePath(schema)}/${encodeURIComponent(table)}` : this.basePath(schema);
2065
- return this.client.request({
2188
+ var _this = this;
2189
+ const path = table ? `${_this.basePath(schema)}/${encodeURIComponent(table)}` : _this.basePath(schema);
2190
+ return _this.client.request({
2066
2191
  path,
2067
2192
  method: "GET"
2068
2193
  });
2069
2194
  }
2070
2195
  async postTable(schema, body) {
2071
- return { location: (await this.client.requestFull({
2072
- path: this.basePath(schema),
2196
+ var _this2 = this;
2197
+ var _res$getHeader;
2198
+ return { location: (_res$getHeader = (await _this2.client.requestFull({
2199
+ path: _this2.basePath(schema),
2073
2200
  method: "POST",
2074
2201
  body,
2075
2202
  expectedStatus: 201
2076
- })).getHeader("Location") ?? "" };
2203
+ })).getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "" };
2077
2204
  }
2078
2205
  async patchTable(schema, table, body) {
2079
- return { location: (await this.client.requestFull({
2080
- path: `${this.basePath(schema)}/${encodeURIComponent(table)}`,
2206
+ var _this3 = this;
2207
+ var _res$getHeader2;
2208
+ return { location: (_res$getHeader2 = (await _this3.client.requestFull({
2209
+ path: `${_this3.basePath(schema)}/${encodeURIComponent(table)}`,
2081
2210
  method: "PATCH",
2082
2211
  body,
2083
2212
  expectedStatus: 303
2084
- })).getHeader("Location") ?? "" };
2213
+ })).getHeader("Location")) !== null && _res$getHeader2 !== void 0 ? _res$getHeader2 : "" };
2085
2214
  }
2086
2215
  async deleteTable(schema, table) {
2087
- await this.client.request({
2088
- path: `${this.basePath(schema)}/${encodeURIComponent(table)}`,
2216
+ var _this4 = this;
2217
+ await _this4.client.request({
2218
+ path: `${_this4.basePath(schema)}/${encodeURIComponent(table)}`,
2089
2219
  method: "DELETE",
2090
2220
  expectedStatus: 204
2091
2221
  });
@@ -2099,27 +2229,32 @@
2099
2229
  this.client = client;
2100
2230
  }
2101
2231
  async getUser(name) {
2232
+ var _this = this;
2102
2233
  const path = name ? `api/v4/users/${encodeURIComponent(name)}` : "api/v4/users";
2103
- return this.client.request({
2234
+ return _this.client.request({
2104
2235
  path,
2105
2236
  method: "GET"
2106
2237
  });
2107
2238
  }
2108
2239
  async postUser(body) {
2109
- return { location: (await this.client.requestFull({
2240
+ var _this2 = this;
2241
+ var _res$getHeader;
2242
+ return { location: (_res$getHeader = (await _this2.client.requestFull({
2110
2243
  path: "api/v4/users",
2111
2244
  method: "POST",
2112
2245
  body,
2113
2246
  expectedStatus: 201
2114
- })).getHeader("Location") ?? "" };
2247
+ })).getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "" };
2115
2248
  }
2116
2249
  async patchUser(name, body) {
2117
- return { location: (await this.client.requestFull({
2250
+ var _this3 = this;
2251
+ var _res$getHeader2;
2252
+ return { location: (_res$getHeader2 = (await _this3.client.requestFull({
2118
2253
  path: `api/v4/users/${encodeURIComponent(name)}`,
2119
2254
  method: "PATCH",
2120
2255
  body,
2121
2256
  expectedStatus: 303
2122
- })).getHeader("Location") ?? "" };
2257
+ })).getHeader("Location")) !== null && _res$getHeader2 !== void 0 ? _res$getHeader2 : "" };
2123
2258
  }
2124
2259
  async deleteUser(name) {
2125
2260
  await this.client.request({
@@ -2137,31 +2272,36 @@
2137
2272
  this.client = client;
2138
2273
  }
2139
2274
  async getClient(id) {
2275
+ var _this = this;
2140
2276
  const path = id ? `api/v4/clients/${encodeURIComponent(id)}` : "api/v4/clients";
2141
- return this.client.request({
2277
+ return _this.client.request({
2142
2278
  path,
2143
2279
  method: "GET"
2144
2280
  });
2145
2281
  }
2146
2282
  async postClient(body) {
2147
- const res = await this.client.requestFull({
2283
+ var _this2 = this;
2284
+ var _res$getHeader;
2285
+ const res = await _this2.client.requestFull({
2148
2286
  path: "api/v4/clients",
2149
2287
  method: "POST",
2150
2288
  body,
2151
2289
  expectedStatus: 201
2152
2290
  });
2153
2291
  return {
2154
- location: res.getHeader("Location") ?? "",
2292
+ location: (_res$getHeader = res.getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "",
2155
2293
  secret: res.body.secret
2156
2294
  };
2157
2295
  }
2158
2296
  async patchClient(id, body) {
2159
- return { location: (await this.client.requestFull({
2297
+ var _this3 = this;
2298
+ var _res$getHeader2;
2299
+ return { location: (_res$getHeader2 = (await _this3.client.requestFull({
2160
2300
  path: `api/v4/clients/${encodeURIComponent(id)}`,
2161
2301
  method: "PATCH",
2162
2302
  body,
2163
2303
  expectedStatus: 303
2164
- })).getHeader("Location") ?? "" };
2304
+ })).getHeader("Location")) !== null && _res$getHeader2 !== void 0 ? _res$getHeader2 : "" };
2165
2305
  }
2166
2306
  async deleteClient(id) {
2167
2307
  await this.client.request({
@@ -2179,8 +2319,9 @@
2179
2319
  this.client = client;
2180
2320
  }
2181
2321
  async getRule(id) {
2322
+ var _this = this;
2182
2323
  const path = id != null ? `api/v4/rules/${encodeURIComponent(id)}` : "api/v4/rules";
2183
- return this.client.request({
2324
+ return _this.client.request({
2184
2325
  path,
2185
2326
  method: "GET"
2186
2327
  });
@@ -2194,12 +2335,14 @@
2194
2335
  });
2195
2336
  }
2196
2337
  async patchRule(id, body) {
2197
- return { location: (await this.client.requestFull({
2338
+ var _this3 = this;
2339
+ var _res$getHeader;
2340
+ return { location: (_res$getHeader = (await _this3.client.requestFull({
2198
2341
  path: `api/v4/rules/${encodeURIComponent(id)}`,
2199
2342
  method: "PATCH",
2200
2343
  body,
2201
2344
  expectedStatus: 303
2202
- })).getHeader("Location") ?? "" };
2345
+ })).getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "" };
2203
2346
  }
2204
2347
  async deleteRule(id) {
2205
2348
  await this.client.request({
@@ -2238,27 +2381,32 @@
2238
2381
  this.client = client;
2239
2382
  }
2240
2383
  async getRpc(method) {
2384
+ var _this = this;
2241
2385
  const path = method ? `api/v4/methods/${encodeURIComponent(method)}` : "api/v4/methods";
2242
- return this.client.request({
2386
+ return _this.client.request({
2243
2387
  path,
2244
2388
  method: "GET"
2245
2389
  });
2246
2390
  }
2247
2391
  async postRpc(body) {
2248
- return { location: (await this.client.requestFull({
2392
+ var _this2 = this;
2393
+ var _res$getHeader;
2394
+ return { location: (_res$getHeader = (await _this2.client.requestFull({
2249
2395
  path: "api/v4/methods",
2250
2396
  method: "POST",
2251
2397
  body,
2252
2398
  expectedStatus: 201
2253
- })).getHeader("Location") ?? "" };
2399
+ })).getHeader("Location")) !== null && _res$getHeader !== void 0 ? _res$getHeader : "" };
2254
2400
  }
2255
2401
  async patchRpc(method, body) {
2256
- return { location: (await this.client.requestFull({
2402
+ var _this3 = this;
2403
+ var _res$getHeader2;
2404
+ return { location: (_res$getHeader2 = (await _this3.client.requestFull({
2257
2405
  path: `api/v4/methods/${encodeURIComponent(method)}`,
2258
2406
  method: "PATCH",
2259
2407
  body,
2260
2408
  expectedStatus: 303
2261
- })).getHeader("Location") ?? "" };
2409
+ })).getHeader("Location")) !== null && _res$getHeader2 !== void 0 ? _res$getHeader2 : "" };
2262
2410
  }
2263
2411
  async deleteRpc(method) {
2264
2412
  await this.client.request({
@@ -2318,7 +2466,8 @@
2318
2466
  * sequentially. The server reassembles the file from the chunks.
2319
2467
  */
2320
2468
  async postFileUpload(formData, options) {
2321
- if (!options?.chunkSize) return this.client.request({
2469
+ var _this = this;
2470
+ if (!(options === null || options === void 0 ? void 0 : options.chunkSize)) return _this.client.request({
2322
2471
  path: "api/v4/file/upload",
2323
2472
  method: "POST",
2324
2473
  body: formData,
@@ -2336,7 +2485,7 @@
2336
2485
  const chunk = file.slice(start, end);
2337
2486
  const chunkForm = new FormData();
2338
2487
  chunkForm.append("filename", chunk, fileName);
2339
- result = await this.client.request({
2488
+ result = await _this.client.request({
2340
2489
  path: "api/v4/file/upload",
2341
2490
  method: "POST",
2342
2491
  body: chunkForm,