roboto-js 1.9.5 → 1.9.7

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.
@@ -1,11 +1,11 @@
1
1
  var _excluded = ["enableRealtime"],
2
2
  _excluded2 = ["enableRealtime"];
3
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
3
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
5
4
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
6
5
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
7
6
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
8
7
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
9
9
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
10
10
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
11
11
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -88,6 +88,8 @@ var RbtApi = /*#__PURE__*/function () {
88
88
  this.requestCache = {};
89
89
  this._loadCurrentUserPromise = null;
90
90
  this._loadCurrentUserExtendedPromise = null;
91
+ this.currentOrganization = null;
92
+ this._loadCurrentOrgPromise = null;
91
93
 
92
94
  // Use the storageAdaptor to get the authToken, if available
93
95
  this.initAuthToken(authtoken);
@@ -493,16 +495,23 @@ var RbtApi = /*#__PURE__*/function () {
493
495
  _context6.next = 16;
494
496
  return this.localStorageAdaptor.setItem('rbtUser', JSON.stringify(this.iac_session.user));
495
497
  case 16:
498
+ // Optionally load organization after login (can be disabled with loadOrganization: false)
499
+ if (params.loadOrganization !== false) {
500
+ // Kick off org load asynchronously but don't wait for it
501
+ this.loadCurrentOrganization()["catch"](function (err) {
502
+ return void 0;
503
+ });
504
+ }
496
505
  return _context6.abrupt("return", response.data);
497
- case 19:
498
- _context6.prev = 19;
506
+ case 20:
507
+ _context6.prev = 20;
499
508
  _context6.t0 = _context6["catch"](0);
500
509
  this._handleError(_context6.t0);
501
- case 22:
510
+ case 23:
502
511
  case "end":
503
512
  return _context6.stop();
504
513
  }
505
- }, _callee6, this, [[0, 19]]);
514
+ }, _callee6, this, [[0, 20]]);
506
515
  }));
507
516
  function login(_x4) {
508
517
  return _login.apply(this, arguments);
@@ -540,16 +549,20 @@ var RbtApi = /*#__PURE__*/function () {
540
549
  _context7.next = 13;
541
550
  return this.localStorageAdaptor.setItem('authtoken', response.authToken);
542
551
  case 13:
552
+ // Load organization after OAuth login
553
+ this.loadCurrentOrganization()["catch"](function (err) {
554
+ return void 0;
555
+ });
543
556
  return _context7.abrupt("return", response);
544
- case 16:
545
- _context7.prev = 16;
557
+ case 17:
558
+ _context7.prev = 17;
546
559
  _context7.t0 = _context7["catch"](0);
547
560
  this._handleError(_context7.t0);
548
- case 19:
561
+ case 20:
549
562
  case "end":
550
563
  return _context7.stop();
551
564
  }
552
- }, _callee7, this, [[0, 16]]);
565
+ }, _callee7, this, [[0, 17]]);
553
566
  }));
554
567
  function loginWithOauth(_x5) {
555
568
  return _loginWithOauth.apply(this, arguments);
@@ -578,6 +591,7 @@ var RbtApi = /*#__PURE__*/function () {
578
591
  // Clear the iac_session and remove the auth token from axios headers
579
592
  this.iac_session = null;
580
593
  this.currentUser = null;
594
+ this.currentOrganization = null;
581
595
  this.authtoken = null;
582
596
  if (this.axios.defaults.headers.common['authtoken']) {
583
597
  delete this.axios.defaults.headers.common['authtoken'];
@@ -585,22 +599,28 @@ var RbtApi = /*#__PURE__*/function () {
585
599
 
586
600
  // Clear localStorage if it's being used
587
601
  if (!this.localStorageAdaptor) {
588
- _context8.next = 13;
602
+ _context8.next = 18;
589
603
  break;
590
604
  }
591
- _context8.next = 13;
605
+ _context8.next = 14;
592
606
  return this.localStorageAdaptor.removeItem('authtoken');
593
- case 13:
594
- return _context8.abrupt("return", response.data);
607
+ case 14:
608
+ _context8.next = 16;
609
+ return this.localStorageAdaptor.removeItem('rbtUser');
595
610
  case 16:
596
- _context8.prev = 16;
611
+ _context8.next = 18;
612
+ return this.localStorageAdaptor.removeItem('currentOrgId');
613
+ case 18:
614
+ return _context8.abrupt("return", response.data);
615
+ case 21:
616
+ _context8.prev = 21;
597
617
  _context8.t0 = _context8["catch"](0);
598
618
  this._handleError(_context8.t0);
599
- case 19:
619
+ case 24:
600
620
  case "end":
601
621
  return _context8.stop();
602
622
  }
603
- }, _callee8, this, [[0, 16]]);
623
+ }, _callee8, this, [[0, 21]]);
604
624
  }));
605
625
  function logout() {
606
626
  return _logout.apply(this, arguments);
@@ -802,14 +822,225 @@ var RbtApi = /*#__PURE__*/function () {
802
822
  }
803
823
  return loadCurrentUserExtended;
804
824
  }()
825
+ /**
826
+ * Load current organization for the authenticated user
827
+ * Organization is determined by:
828
+ * 1. User's mod.currentOrgId preference
829
+ * 2. First organization in user.organizations array
830
+ * 3. null if user has no organizations
831
+ *
832
+ * @param {boolean} forceReload - Force reload from server even if cached
833
+ * @returns {Promise<RbtObject|null>} Organization object or null
834
+ */
805
835
  }, {
806
- key: "loadUser",
807
- value: function () {
808
- var _loadUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(userId) {
836
+ key: "loadCurrentOrganization",
837
+ value: (function () {
838
+ var _loadCurrentOrganization = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
809
839
  var _this4 = this;
810
- var params, cacheKey, now, existing, p;
840
+ var forceReload,
841
+ result,
842
+ _args15 = arguments;
811
843
  return _regeneratorRuntime().wrap(function _callee15$(_context15) {
812
844
  while (1) switch (_context15.prev = _context15.next) {
845
+ case 0:
846
+ forceReload = _args15.length > 0 && _args15[0] !== undefined ? _args15[0] : false;
847
+ _context15.prev = 1;
848
+ if (!(this.currentOrganization && !forceReload)) {
849
+ _context15.next = 4;
850
+ break;
851
+ }
852
+ return _context15.abrupt("return", this.currentOrganization);
853
+ case 4:
854
+ if (!this._loadCurrentOrgPromise) {
855
+ _context15.next = 6;
856
+ break;
857
+ }
858
+ return _context15.abrupt("return", this._loadCurrentOrgPromise);
859
+ case 6:
860
+ this._loadCurrentOrgPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
861
+ var _userData$organizatio, _userData$mod, user, userData, firstOrg, orgId, cachedOrgId, org;
862
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
863
+ while (1) switch (_context14.prev = _context14.next) {
864
+ case 0:
865
+ _context14.prev = 0;
866
+ _context14.next = 3;
867
+ return _this4.loadCurrentUser();
868
+ case 3:
869
+ user = _context14.sent;
870
+ if (user) {
871
+ _context14.next = 6;
872
+ break;
873
+ }
874
+ return _context14.abrupt("return", null);
875
+ case 6:
876
+ // Get organization ID from user preferences or first org
877
+ userData = user.getData(); // organizations array format: [{ id: 'org123', roles: ['owner'] }, ...]
878
+ firstOrg = (_userData$organizatio = userData.organizations) === null || _userData$organizatio === void 0 ? void 0 : _userData$organizatio[0];
879
+ orgId = ((_userData$mod = userData.mod) === null || _userData$mod === void 0 ? void 0 : _userData$mod.currentOrgId) || (_typeof(firstOrg) === 'object' ? firstOrg === null || firstOrg === void 0 ? void 0 : firstOrg.id : firstOrg);
880
+ if (orgId) {
881
+ _context14.next = 11;
882
+ break;
883
+ }
884
+ return _context14.abrupt("return", null);
885
+ case 11:
886
+ if (!_this4.localStorageAdaptor) {
887
+ _context14.next = 16;
888
+ break;
889
+ }
890
+ _context14.next = 14;
891
+ return _this4.localStorageAdaptor.getItem('currentOrgId');
892
+ case 14:
893
+ cachedOrgId = _context14.sent;
894
+ if (cachedOrgId && cachedOrgId !== orgId) {}
895
+ case 16:
896
+ _context14.next = 18;
897
+ return _this4.get('<@iac.organization>', orgId);
898
+ case 18:
899
+ org = _context14.sent;
900
+ if (!org) {
901
+ _context14.next = 26;
902
+ break;
903
+ }
904
+ _this4.currentOrganization = org; // Already an RbtObject
905
+ if (!_this4.localStorageAdaptor) {
906
+ _context14.next = 24;
907
+ break;
908
+ }
909
+ _context14.next = 24;
910
+ return _this4.localStorageAdaptor.setItem('currentOrgId', orgId);
911
+ case 24:
912
+ _context14.next = 26;
913
+ break;
914
+ case 26:
915
+ return _context14.abrupt("return", _this4.currentOrganization);
916
+ case 29:
917
+ _context14.prev = 29;
918
+ _context14.t0 = _context14["catch"](0);
919
+ console.error('[RbtApi] Failed to load current organization:', _context14.t0);
920
+ _this4.currentOrganization = null;
921
+ return _context14.abrupt("return", null);
922
+ case 34:
923
+ case "end":
924
+ return _context14.stop();
925
+ }
926
+ }, _callee14, null, [[0, 29]]);
927
+ }))();
928
+ _context15.next = 9;
929
+ return this._loadCurrentOrgPromise;
930
+ case 9:
931
+ result = _context15.sent;
932
+ this._loadCurrentOrgPromise = null;
933
+ return _context15.abrupt("return", result);
934
+ case 14:
935
+ _context15.prev = 14;
936
+ _context15.t0 = _context15["catch"](1);
937
+ this._loadCurrentOrgPromise = null;
938
+ return _context15.abrupt("return", this._handleError(_context15.t0));
939
+ case 18:
940
+ case "end":
941
+ return _context15.stop();
942
+ }
943
+ }, _callee15, this, [[1, 14]]);
944
+ }));
945
+ function loadCurrentOrganization() {
946
+ return _loadCurrentOrganization.apply(this, arguments);
947
+ }
948
+ return loadCurrentOrganization;
949
+ }()
950
+ /**
951
+ * Switch to a different organization
952
+ * Updates user preference and loads the new organization
953
+ *
954
+ * @param {string} orgId - Organization ID to switch to
955
+ * @returns {Promise<RbtObject>} The new current organization
956
+ */
957
+ )
958
+ }, {
959
+ key: "switchOrganization",
960
+ value: (function () {
961
+ var _switchOrganization = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(orgId) {
962
+ var org, userObj;
963
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
964
+ while (1) switch (_context16.prev = _context16.next) {
965
+ case 0:
966
+ _context16.prev = 0;
967
+ if (this.currentUser) {
968
+ _context16.next = 3;
969
+ break;
970
+ }
971
+ throw new Error('Must be logged in to switch organization');
972
+ case 3:
973
+ _context16.next = 5;
974
+ return this.get('<@iac.organization>', orgId);
975
+ case 5:
976
+ org = _context16.sent;
977
+ if (org) {
978
+ _context16.next = 8;
979
+ break;
980
+ }
981
+ throw new Error("Organization ".concat(orgId, " not found or not accessible"));
982
+ case 8:
983
+ this.currentOrganization = org;
984
+
985
+ // Save preference to user
986
+ _context16.prev = 9;
987
+ _context16.next = 12;
988
+ return this.loadUser(this.currentUser.id);
989
+ case 12:
990
+ userObj = _context16.sent;
991
+ userObj.set('mod.currentOrgId', orgId);
992
+ _context16.next = 16;
993
+ return userObj.save();
994
+ case 16:
995
+ if (!this.localStorageAdaptor) {
996
+ _context16.next = 19;
997
+ break;
998
+ }
999
+ _context16.next = 19;
1000
+ return this.localStorageAdaptor.setItem('currentOrgId', orgId);
1001
+ case 19:
1002
+ _context16.next = 23;
1003
+ break;
1004
+ case 21:
1005
+ _context16.prev = 21;
1006
+ _context16.t0 = _context16["catch"](9);
1007
+ case 23:
1008
+ return _context16.abrupt("return", org);
1009
+ case 26:
1010
+ _context16.prev = 26;
1011
+ _context16.t1 = _context16["catch"](0);
1012
+ return _context16.abrupt("return", this._handleError(_context16.t1));
1013
+ case 29:
1014
+ case "end":
1015
+ return _context16.stop();
1016
+ }
1017
+ }, _callee16, this, [[0, 26], [9, 21]]);
1018
+ }));
1019
+ function switchOrganization(_x7) {
1020
+ return _switchOrganization.apply(this, arguments);
1021
+ }
1022
+ return switchOrganization;
1023
+ }()
1024
+ /**
1025
+ * Get current organization (null-safe)
1026
+ * Returns cached organization without triggering a load
1027
+ *
1028
+ * @returns {RbtObject|null} Current organization or null
1029
+ */
1030
+ )
1031
+ }, {
1032
+ key: "getCurrentOrganization",
1033
+ value: function getCurrentOrganization() {
1034
+ return this.currentOrganization;
1035
+ }
1036
+ }, {
1037
+ key: "loadUser",
1038
+ value: function () {
1039
+ var _loadUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(userId) {
1040
+ var _this5 = this;
1041
+ var params, cacheKey, now, existing, p;
1042
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1043
+ while (1) switch (_context18.prev = _context18.next) {
813
1044
  case 0:
814
1045
  params = {
815
1046
  id: userId
@@ -818,53 +1049,53 @@ var RbtApi = /*#__PURE__*/function () {
818
1049
  now = Date.now();
819
1050
  existing = this.requestCache[cacheKey];
820
1051
  if (!(existing && now - existing.time < 10000)) {
821
- _context15.next = 6;
1052
+ _context18.next = 6;
822
1053
  break;
823
1054
  }
824
- return _context15.abrupt("return", existing.val);
1055
+ return _context18.abrupt("return", existing.val);
825
1056
  case 6:
826
- _context15.prev = 6;
827
- p = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
1057
+ _context18.prev = 6;
1058
+ p = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
828
1059
  var _response$data;
829
1060
  var response, userData, User;
830
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
831
- while (1) switch (_context14.prev = _context14.next) {
1061
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1062
+ while (1) switch (_context17.prev = _context17.next) {
832
1063
  case 0:
833
- _context14.next = 2;
834
- return _this4.axios.post('/user_service/loadUser', [params]);
1064
+ _context17.next = 2;
1065
+ return _this5.axios.post('/user_service/loadUser', [params]);
835
1066
  case 2:
836
- response = _context14.sent;
1067
+ response = _context17.sent;
837
1068
  userData = response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.user;
838
1069
  User = new RbtUser({
839
1070
  id: userData.id
840
- }, _this4.axios);
1071
+ }, _this5.axios);
841
1072
  User.setData(userData);
842
- return _context14.abrupt("return", User);
1073
+ return _context17.abrupt("return", User);
843
1074
  case 7:
844
1075
  case "end":
845
- return _context14.stop();
1076
+ return _context17.stop();
846
1077
  }
847
- }, _callee14);
1078
+ }, _callee17);
848
1079
  }))();
849
1080
  this.requestCache[cacheKey] = {
850
1081
  val: p,
851
1082
  time: now
852
1083
  };
853
- _context15.next = 11;
1084
+ _context18.next = 11;
854
1085
  return p;
855
1086
  case 11:
856
- return _context15.abrupt("return", _context15.sent);
1087
+ return _context18.abrupt("return", _context18.sent);
857
1088
  case 14:
858
- _context15.prev = 14;
859
- _context15.t0 = _context15["catch"](6);
860
- return _context15.abrupt("return", this._handleError(_context15.t0));
1089
+ _context18.prev = 14;
1090
+ _context18.t0 = _context18["catch"](6);
1091
+ return _context18.abrupt("return", this._handleError(_context18.t0));
861
1092
  case 17:
862
1093
  case "end":
863
- return _context15.stop();
1094
+ return _context18.stop();
864
1095
  }
865
- }, _callee15, this, [[6, 14]]);
1096
+ }, _callee18, this, [[6, 14]]);
866
1097
  }));
867
- function loadUser(_x7) {
1098
+ function loadUser(_x8) {
868
1099
  return _loadUser.apply(this, arguments);
869
1100
  }
870
1101
  return loadUser;
@@ -872,53 +1103,53 @@ var RbtApi = /*#__PURE__*/function () {
872
1103
  }, {
873
1104
  key: "refreshAuthToken",
874
1105
  value: function () {
875
- var _refreshAuthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(authtoken) {
1106
+ var _refreshAuthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(authtoken) {
876
1107
  var promise, response;
877
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
878
- while (1) switch (_context16.prev = _context16.next) {
1108
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1109
+ while (1) switch (_context19.prev = _context19.next) {
879
1110
  case 0:
880
1111
  if (this.appServiceHost) {
881
- _context16.next = 2;
1112
+ _context19.next = 2;
882
1113
  break;
883
1114
  }
884
- return _context16.abrupt("return", false);
1115
+ return _context19.abrupt("return", false);
885
1116
  case 2:
886
1117
  if (!this.requestCache[authtoken]) {
887
- _context16.next = 4;
1118
+ _context19.next = 4;
888
1119
  break;
889
1120
  }
890
- return _context16.abrupt("return", this.requestCache[authtoken]);
1121
+ return _context19.abrupt("return", this.requestCache[authtoken]);
891
1122
  case 4:
892
- _context16.prev = 4;
1123
+ _context19.prev = 4;
893
1124
  //console.log('RBTTOK Req', authtoken);
894
1125
  // Create a new promise for the token refresh and store it in the cache
895
1126
  promise = this.axios.post('/user_service/refreshAuthToken', [authtoken]);
896
1127
  this.requestCache[authtoken] = promise;
897
1128
 
898
1129
  // Await the promise to get the response
899
- _context16.next = 9;
1130
+ _context19.next = 9;
900
1131
  return promise;
901
1132
  case 9:
902
- response = _context16.sent;
1133
+ response = _context19.sent;
903
1134
  //console.log('RBTTOK Response ',response);
904
1135
  // Once the promise resolves, delete it from the cache to allow future refreshes
905
1136
  delete this.requestCache[authtoken];
906
1137
 
907
1138
  // Return the response data
908
- return _context16.abrupt("return", response.data);
1139
+ return _context19.abrupt("return", response.data);
909
1140
  case 14:
910
- _context16.prev = 14;
911
- _context16.t0 = _context16["catch"](4);
1141
+ _context19.prev = 14;
1142
+ _context19.t0 = _context19["catch"](4);
912
1143
  // On error, remove the cached promise to allow retries
913
1144
  delete this.requestCache[authtoken];
914
- this._handleError(_context16.t0);
1145
+ this._handleError(_context19.t0);
915
1146
  case 18:
916
1147
  case "end":
917
- return _context16.stop();
1148
+ return _context19.stop();
918
1149
  }
919
- }, _callee16, this, [[4, 14]]);
1150
+ }, _callee19, this, [[4, 14]]);
920
1151
  }));
921
- function refreshAuthToken(_x8) {
1152
+ function refreshAuthToken(_x9) {
922
1153
  return _refreshAuthToken.apply(this, arguments);
923
1154
  }
924
1155
  return refreshAuthToken;
@@ -949,31 +1180,31 @@ var RbtApi = /*#__PURE__*/function () {
949
1180
  }, {
950
1181
  key: "registerUser",
951
1182
  value: function () {
952
- var _registerUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1183
+ var _registerUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
953
1184
  var dataHash,
954
1185
  response,
955
1186
  record,
956
- _args17 = arguments;
957
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
958
- while (1) switch (_context17.prev = _context17.next) {
1187
+ _args20 = arguments;
1188
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1189
+ while (1) switch (_context20.prev = _context20.next) {
959
1190
  case 0:
960
- dataHash = _args17.length > 0 && _args17[0] !== undefined ? _args17[0] : {};
961
- _context17.prev = 1;
962
- _context17.next = 4;
1191
+ dataHash = _args20.length > 0 && _args20[0] !== undefined ? _args20[0] : {};
1192
+ _context20.prev = 1;
1193
+ _context20.next = 4;
963
1194
  return this.axios.post('/user_service/registerUser', [dataHash]);
964
1195
  case 4:
965
- response = _context17.sent;
1196
+ response = _context20.sent;
966
1197
  record = response.data;
967
- return _context17.abrupt("return", new RbtUser(record, this.axios));
1198
+ return _context20.abrupt("return", new RbtUser(record, this.axios));
968
1199
  case 9:
969
- _context17.prev = 9;
970
- _context17.t0 = _context17["catch"](1);
971
- return _context17.abrupt("return", this._handleError(_context17.t0));
1200
+ _context20.prev = 9;
1201
+ _context20.t0 = _context20["catch"](1);
1202
+ return _context20.abrupt("return", this._handleError(_context20.t0));
972
1203
  case 12:
973
1204
  case "end":
974
- return _context17.stop();
1205
+ return _context20.stop();
975
1206
  }
976
- }, _callee17, this, [[1, 9]]);
1207
+ }, _callee20, this, [[1, 9]]);
977
1208
  }));
978
1209
  function registerUser() {
979
1210
  return _registerUser.apply(this, arguments);
@@ -990,32 +1221,32 @@ var RbtApi = /*#__PURE__*/function () {
990
1221
  }, {
991
1222
  key: "createFile",
992
1223
  value: (function () {
993
- var _createFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(dataHash) {
1224
+ var _createFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(dataHash) {
994
1225
  var response, record;
995
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
996
- while (1) switch (_context18.prev = _context18.next) {
1226
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1227
+ while (1) switch (_context21.prev = _context21.next) {
997
1228
  case 0:
998
- _context18.prev = 0;
999
- _context18.next = 3;
1229
+ _context21.prev = 0;
1230
+ _context21.next = 3;
1000
1231
  return this.axios.post('/object_service/createObject', ['<@filekit.file>', dataHash]);
1001
1232
  case 3:
1002
- response = _context18.sent;
1233
+ response = _context21.sent;
1003
1234
  record = response.data;
1004
1235
  if (dataHash) {
1005
1236
  record.data = dataHash;
1006
1237
  }
1007
- return _context18.abrupt("return", new RbtFile(record, this.axios, this.localDb));
1238
+ return _context21.abrupt("return", new RbtFile(record, this.axios, this.localDb));
1008
1239
  case 9:
1009
- _context18.prev = 9;
1010
- _context18.t0 = _context18["catch"](0);
1011
- return _context18.abrupt("return", this._handleError(_context18.t0));
1240
+ _context21.prev = 9;
1241
+ _context21.t0 = _context21["catch"](0);
1242
+ return _context21.abrupt("return", this._handleError(_context21.t0));
1012
1243
  case 12:
1013
1244
  case "end":
1014
- return _context18.stop();
1245
+ return _context21.stop();
1015
1246
  }
1016
- }, _callee18, this, [[0, 9]]);
1247
+ }, _callee21, this, [[0, 9]]);
1017
1248
  }));
1018
- function createFile(_x9) {
1249
+ function createFile(_x10) {
1019
1250
  return _createFile.apply(this, arguments);
1020
1251
  }
1021
1252
  return createFile;
@@ -1023,35 +1254,35 @@ var RbtApi = /*#__PURE__*/function () {
1023
1254
  }, {
1024
1255
  key: "loadFile",
1025
1256
  value: function () {
1026
- var _loadFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(id) {
1257
+ var _loadFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(id) {
1027
1258
  var response, record;
1028
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1029
- while (1) switch (_context19.prev = _context19.next) {
1259
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1260
+ while (1) switch (_context22.prev = _context22.next) {
1030
1261
  case 0:
1031
- _context19.prev = 0;
1032
- _context19.next = 3;
1262
+ _context22.prev = 0;
1263
+ _context22.next = 3;
1033
1264
  return this.load('<@filekit.file>', id);
1034
1265
  case 3:
1035
- response = _context19.sent;
1266
+ response = _context22.sent;
1036
1267
  if (response) {
1037
- _context19.next = 6;
1268
+ _context22.next = 6;
1038
1269
  break;
1039
1270
  }
1040
- return _context19.abrupt("return", null);
1271
+ return _context22.abrupt("return", null);
1041
1272
  case 6:
1042
1273
  record = response.toRecord();
1043
- return _context19.abrupt("return", new RbtFile(record, this.axios, this.localDb));
1274
+ return _context22.abrupt("return", new RbtFile(record, this.axios, this.localDb));
1044
1275
  case 10:
1045
- _context19.prev = 10;
1046
- _context19.t0 = _context19["catch"](0);
1047
- return _context19.abrupt("return", this._handleError(_context19.t0));
1276
+ _context22.prev = 10;
1277
+ _context22.t0 = _context22["catch"](0);
1278
+ return _context22.abrupt("return", this._handleError(_context22.t0));
1048
1279
  case 13:
1049
1280
  case "end":
1050
- return _context19.stop();
1281
+ return _context22.stop();
1051
1282
  }
1052
- }, _callee19, this, [[0, 10]]);
1283
+ }, _callee22, this, [[0, 10]]);
1053
1284
  }));
1054
- function loadFile(_x10) {
1285
+ function loadFile(_x11) {
1055
1286
  return _loadFile.apply(this, arguments);
1056
1287
  }
1057
1288
  return loadFile;
@@ -1059,39 +1290,39 @@ var RbtApi = /*#__PURE__*/function () {
1059
1290
  }, {
1060
1291
  key: "loadFiles",
1061
1292
  value: function () {
1062
- var _loadFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(ids) {
1063
- var _this5 = this;
1293
+ var _loadFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(ids) {
1294
+ var _this6 = this;
1064
1295
  var responses;
1065
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1066
- while (1) switch (_context20.prev = _context20.next) {
1296
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1297
+ while (1) switch (_context23.prev = _context23.next) {
1067
1298
  case 0:
1068
- _context20.prev = 0;
1069
- _context20.next = 3;
1299
+ _context23.prev = 0;
1300
+ _context23.next = 3;
1070
1301
  return this.load('<@filekit.file>', ids);
1071
1302
  case 3:
1072
- responses = _context20.sent;
1303
+ responses = _context23.sent;
1073
1304
  if (!(!responses || !Array.isArray(responses))) {
1074
- _context20.next = 6;
1305
+ _context23.next = 6;
1075
1306
  break;
1076
1307
  }
1077
- return _context20.abrupt("return", []);
1308
+ return _context23.abrupt("return", []);
1078
1309
  case 6:
1079
- return _context20.abrupt("return", responses.map(function (response) {
1310
+ return _context23.abrupt("return", responses.map(function (response) {
1080
1311
  var record = response.toRecord();
1081
- return new RbtFile(record, _this5.axios, _this5.localDb);
1312
+ return new RbtFile(record, _this6.axios, _this6.localDb);
1082
1313
  }));
1083
1314
  case 9:
1084
- _context20.prev = 9;
1085
- _context20.t0 = _context20["catch"](0);
1086
- this._handleError(_context20.t0); // Handle errors (log or process as needed)
1087
- return _context20.abrupt("return", []);
1315
+ _context23.prev = 9;
1316
+ _context23.t0 = _context23["catch"](0);
1317
+ this._handleError(_context23.t0); // Handle errors (log or process as needed)
1318
+ return _context23.abrupt("return", []);
1088
1319
  case 13:
1089
1320
  case "end":
1090
- return _context20.stop();
1321
+ return _context23.stop();
1091
1322
  }
1092
- }, _callee20, this, [[0, 9]]);
1323
+ }, _callee23, this, [[0, 9]]);
1093
1324
  }));
1094
- function loadFiles(_x11) {
1325
+ function loadFiles(_x12) {
1095
1326
  return _loadFiles.apply(this, arguments);
1096
1327
  }
1097
1328
  return loadFiles;
@@ -1107,42 +1338,42 @@ var RbtApi = /*#__PURE__*/function () {
1107
1338
  }, {
1108
1339
  key: "create",
1109
1340
  value: (function () {
1110
- var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(type) {
1341
+ var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(type) {
1111
1342
  var dataHash,
1112
1343
  options,
1113
1344
  response,
1114
1345
  record,
1115
- _args21 = arguments;
1116
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1117
- while (1) switch (_context21.prev = _context21.next) {
1346
+ _args24 = arguments;
1347
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1348
+ while (1) switch (_context24.prev = _context24.next) {
1118
1349
  case 0:
1119
- dataHash = _args21.length > 1 && _args21[1] !== undefined ? _args21[1] : {};
1120
- options = _args21.length > 2 && _args21[2] !== undefined ? _args21[2] : {};
1121
- _context21.prev = 2;
1122
- _context21.next = 5;
1350
+ dataHash = _args24.length > 1 && _args24[1] !== undefined ? _args24[1] : {};
1351
+ options = _args24.length > 2 && _args24[2] !== undefined ? _args24[2] : {};
1352
+ _context24.prev = 2;
1353
+ _context24.next = 5;
1123
1354
  return this.axios.post('/object_service/createObject', [type, dataHash]);
1124
1355
  case 5:
1125
- response = _context21.sent;
1356
+ response = _context24.sent;
1126
1357
  record = response.data;
1127
1358
  if (dataHash) {
1128
1359
  record.data = dataHash;
1129
1360
  }
1130
- return _context21.abrupt("return", new RbtObject(record, this.axios, {
1361
+ return _context24.abrupt("return", new RbtObject(record, this.axios, {
1131
1362
  isNew: true,
1132
1363
  websocketClient: this.websocketClient,
1133
1364
  enableRealtime: options.enableRealtime || false
1134
1365
  }));
1135
1366
  case 11:
1136
- _context21.prev = 11;
1137
- _context21.t0 = _context21["catch"](2);
1138
- return _context21.abrupt("return", this._handleError(_context21.t0));
1367
+ _context24.prev = 11;
1368
+ _context24.t0 = _context24["catch"](2);
1369
+ return _context24.abrupt("return", this._handleError(_context24.t0));
1139
1370
  case 14:
1140
1371
  case "end":
1141
- return _context21.stop();
1372
+ return _context24.stop();
1142
1373
  }
1143
- }, _callee21, this, [[2, 11]]);
1374
+ }, _callee24, this, [[2, 11]]);
1144
1375
  }));
1145
- function create(_x12) {
1376
+ function create(_x13) {
1146
1377
  return _create.apply(this, arguments);
1147
1378
  }
1148
1379
  return create;
@@ -1185,8 +1416,8 @@ var RbtApi = /*#__PURE__*/function () {
1185
1416
  }, {
1186
1417
  key: "query",
1187
1418
  value: (function () {
1188
- var _query = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(type) {
1189
- var _this6 = this;
1419
+ var _query = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(type) {
1420
+ var _this7 = this;
1190
1421
  var params,
1191
1422
  paramsKey,
1192
1423
  validParams,
@@ -1198,12 +1429,12 @@ var RbtApi = /*#__PURE__*/function () {
1198
1429
  cacheEntry,
1199
1430
  responsePromise,
1200
1431
  processingPromise,
1201
- _args22 = arguments;
1202
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1203
- while (1) switch (_context22.prev = _context22.next) {
1432
+ _args25 = arguments;
1433
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1434
+ while (1) switch (_context25.prev = _context25.next) {
1204
1435
  case 0:
1205
- params = _args22.length > 1 && _args22[1] !== undefined ? _args22[1] : {};
1206
- _context22.prev = 1;
1436
+ params = _args25.length > 1 && _args25[1] !== undefined ? _args25[1] : {};
1437
+ _context25.prev = 1;
1207
1438
  //console.log('RBTAPI.query INIT', type, params);
1208
1439
  // Validate parameters - reject invalid parameter names
1209
1440
  validParams = ['type', 'where', 'orderBy', 'limit', 'resolveReferences', 'requestAttrs', 'excludeAttrs', 'timeout', 'enableRealtime'];
@@ -1211,7 +1442,7 @@ var RbtApi = /*#__PURE__*/function () {
1211
1442
  return !validParams.includes(key);
1212
1443
  });
1213
1444
  if (!(invalidParams.length > 0)) {
1214
- _context22.next = 6;
1445
+ _context25.next = 6;
1215
1446
  break;
1216
1447
  }
1217
1448
  throw new Error("Invalid query parameter(s): ".concat(invalidParams.join(', '), ". Valid parameters are: ").concat(validParams.join(', ')));
@@ -1238,19 +1469,19 @@ var RbtApi = /*#__PURE__*/function () {
1238
1469
  paramsKey = JSON.stringify(mergedParams);
1239
1470
  cacheEntry = this.requestCache[paramsKey];
1240
1471
  if (!(cacheEntry && currentTime - cacheEntry.time < 10000)) {
1241
- _context22.next = 16;
1472
+ _context25.next = 16;
1242
1473
  break;
1243
1474
  }
1244
- return _context22.abrupt("return", cacheEntry.val);
1475
+ return _context25.abrupt("return", cacheEntry.val);
1245
1476
  case 16:
1246
1477
  // Create the response promise
1247
1478
  responsePromise = this.axios.post('/object_service/queryObjects', [mergedParams]); // Cache the promise of processing data, not just the raw response
1248
1479
  processingPromise = responsePromise.then(function (response) {
1249
- return _this6._processResponseData(response, params);
1480
+ return _this7._processResponseData(response, params);
1250
1481
  })["catch"](function (e) {
1251
- delete _this6.requestCache[paramsKey]; // Ensure cache cleanup on failure
1482
+ delete _this7.requestCache[paramsKey]; // Ensure cache cleanup on failure
1252
1483
  //console.log('RBTAPI.query ERROR (Processing)', paramsKey, e);
1253
- return _this6._handleError(e);
1484
+ return _this7._handleError(e);
1254
1485
  }); // Store the promise of the processed data in the cache
1255
1486
  this.requestCache[paramsKey] = {
1256
1487
  val: processingPromise,
@@ -1258,23 +1489,23 @@ var RbtApi = /*#__PURE__*/function () {
1258
1489
  };
1259
1490
 
1260
1491
  // Await the processing promise for this call to get processed data
1261
- _context22.next = 21;
1492
+ _context25.next = 21;
1262
1493
  return processingPromise;
1263
1494
  case 21:
1264
- return _context22.abrupt("return", _context22.sent);
1495
+ return _context25.abrupt("return", _context25.sent);
1265
1496
  case 24:
1266
- _context22.prev = 24;
1267
- _context22.t0 = _context22["catch"](1);
1497
+ _context25.prev = 24;
1498
+ _context25.t0 = _context25["catch"](1);
1268
1499
  delete this.requestCache[paramsKey]; // Ensure cache cleanup on error
1269
1500
  //console.log('RBTAPI.query ERROR', paramsKey, e);
1270
- return _context22.abrupt("return", this._handleError(_context22.t0));
1501
+ return _context25.abrupt("return", this._handleError(_context25.t0));
1271
1502
  case 28:
1272
1503
  case "end":
1273
- return _context22.stop();
1504
+ return _context25.stop();
1274
1505
  }
1275
- }, _callee22, this, [[1, 24]]);
1506
+ }, _callee25, this, [[1, 24]]);
1276
1507
  }));
1277
- function query(_x13) {
1508
+ function query(_x14) {
1278
1509
  return _query.apply(this, arguments);
1279
1510
  }
1280
1511
  return query;
@@ -1282,7 +1513,7 @@ var RbtApi = /*#__PURE__*/function () {
1282
1513
  }, {
1283
1514
  key: "_processResponseData",
1284
1515
  value: function _processResponseData(response) {
1285
- var _this7 = this;
1516
+ var _this8 = this;
1286
1517
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1287
1518
  if (response.data.ok === false) {
1288
1519
  return this._handleError(response);
@@ -1296,7 +1527,7 @@ var RbtApi = /*#__PURE__*/function () {
1296
1527
  websocketClient = this.getWebSocketClient();
1297
1528
  }
1298
1529
  response.data.items = response.data.items.map(function (record) {
1299
- return new RbtObject(record, _this7.axios, {
1530
+ return new RbtObject(record, _this8.axios, {
1300
1531
  websocketClient: websocketClient,
1301
1532
  enableRealtime: options.enableRealtime || false
1302
1533
  });
@@ -1318,8 +1549,8 @@ var RbtApi = /*#__PURE__*/function () {
1318
1549
  }, {
1319
1550
  key: "load",
1320
1551
  value: (function () {
1321
- var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(type, ids) {
1322
- var _this8 = this;
1552
+ var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(type, ids) {
1553
+ var _this9 = this;
1323
1554
  var params,
1324
1555
  mergedParams,
1325
1556
  cachedObjects,
@@ -1351,17 +1582,17 @@ var RbtApi = /*#__PURE__*/function () {
1351
1582
  pendingKey,
1352
1583
  missLogKey,
1353
1584
  loadPromise,
1354
- _args24 = arguments;
1355
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1356
- while (1) switch (_context24.prev = _context24.next) {
1585
+ _args27 = arguments;
1586
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
1587
+ while (1) switch (_context27.prev = _context27.next) {
1357
1588
  case 0:
1358
- params = _args24.length > 2 && _args24[2] !== undefined ? _args24[2] : {};
1589
+ params = _args27.length > 2 && _args27[2] !== undefined ? _args27[2] : {};
1359
1590
  if (type == '<@iac.user>') {
1360
1591
  debugger;
1361
1592
  }
1362
- _context24.prev = 2;
1593
+ _context27.prev = 2;
1363
1594
  if (!Array.isArray(ids)) {
1364
- _context24.next = 25;
1595
+ _context27.next = 25;
1365
1596
  break;
1366
1597
  }
1367
1598
  // For array requests, check cache for each ID and only load missing ones
@@ -1398,7 +1629,7 @@ var RbtApi = /*#__PURE__*/function () {
1398
1629
  }
1399
1630
  loadedObjects = [];
1400
1631
  if (!(missingIds.length > 0)) {
1401
- _context24.next = 19;
1632
+ _context27.next = 19;
1402
1633
  break;
1403
1634
  }
1404
1635
  // Only log bulk cache miss once
@@ -1412,10 +1643,10 @@ var RbtApi = /*#__PURE__*/function () {
1412
1643
  mergedParams = _objectSpread(_objectSpread({}, queryParams), {}, {
1413
1644
  where: "id IN (\"".concat(missingIds.join("\",\""), "\")")
1414
1645
  });
1415
- _context24.next = 16;
1646
+ _context27.next = 16;
1416
1647
  return this.query(type, mergedParams);
1417
1648
  case 16:
1418
- loadedObjects = _context24.sent;
1649
+ loadedObjects = _context27.sent;
1419
1650
  // Cache the newly loaded objects
1420
1651
  _iterator4 = _createForOfIteratorHelper(loadedObjects);
1421
1652
  try {
@@ -1457,13 +1688,13 @@ var RbtApi = /*#__PURE__*/function () {
1457
1688
  } finally {
1458
1689
  _iterator5.f();
1459
1690
  }
1460
- return _context24.abrupt("return", result);
1691
+ return _context27.abrupt("return", result);
1461
1692
  case 25:
1462
1693
  // For single object requests, check cache first
1463
1694
  _cacheKey3 = "".concat(type, ":").concat(ids);
1464
1695
  _cached = this._objectCache.get(_cacheKey3);
1465
1696
  if (!_cached) {
1466
- _context24.next = 32;
1697
+ _context27.next = 32;
1467
1698
  break;
1468
1699
  }
1469
1700
  // Only log cache hits once per object to reduce spam
@@ -1476,18 +1707,18 @@ var RbtApi = /*#__PURE__*/function () {
1476
1707
  if (params.enableRealtime && !_cached._realtime) {
1477
1708
  _cached._initRealtime();
1478
1709
  }
1479
- return _context24.abrupt("return", _cached);
1710
+ return _context27.abrupt("return", _cached);
1480
1711
  case 32:
1481
1712
  // Check if we're already loading this object
1482
1713
  pendingKey = "".concat(type, ":").concat(ids);
1483
1714
  if (!this._pendingLoads.has(pendingKey)) {
1484
- _context24.next = 37;
1715
+ _context27.next = 37;
1485
1716
  break;
1486
1717
  }
1487
- _context24.next = 36;
1718
+ _context27.next = 36;
1488
1719
  return this._pendingLoads.get(pendingKey);
1489
1720
  case 36:
1490
- return _context24.abrupt("return", _context24.sent);
1721
+ return _context27.abrupt("return", _context27.sent);
1491
1722
  case 37:
1492
1723
  // Only log cache miss once per object to reduce spam
1493
1724
  missLogKey = "miss:".concat(_cacheKey3);
@@ -1496,63 +1727,63 @@ var RbtApi = /*#__PURE__*/function () {
1496
1727
  }
1497
1728
 
1498
1729
  // Create the loading promise and store it to prevent duplicate requests
1499
- loadPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
1730
+ loadPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
1500
1731
  var _enableRealtime, _queryParams, res, _obj2, _setLogKey;
1501
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1502
- while (1) switch (_context23.prev = _context23.next) {
1732
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
1733
+ while (1) switch (_context26.prev = _context26.next) {
1503
1734
  case 0:
1504
- _context23.prev = 0;
1735
+ _context26.prev = 0;
1505
1736
  // Remove load-specific params that shouldn't be passed to query
1506
1737
  _enableRealtime = params.enableRealtime, _queryParams = _objectWithoutProperties(params, _excluded2);
1507
1738
  mergedParams = _objectSpread(_objectSpread({}, _queryParams), {}, {
1508
1739
  where: "id=\"".concat(ids, "\"")
1509
1740
  });
1510
- _context23.next = 5;
1511
- return _this8.query(type, mergedParams);
1741
+ _context26.next = 5;
1742
+ return _this9.query(type, mergedParams);
1512
1743
  case 5:
1513
- res = _context23.sent;
1744
+ res = _context26.sent;
1514
1745
  _obj2 = res[0];
1515
1746
  if (_obj2) {
1516
1747
  // Cache the loaded object
1517
- _this8._objectCache.set(_cacheKey3, _obj2);
1748
+ _this9._objectCache.set(_cacheKey3, _obj2);
1518
1749
 
1519
1750
  // Only log cache set once per object to reduce spam
1520
1751
  _setLogKey = "set:".concat(_cacheKey3);
1521
- if (!_this8._loggedCacheEvents.has(_setLogKey)) {
1522
- _this8._loggedCacheEvents.add(_setLogKey);
1752
+ if (!_this9._loggedCacheEvents.has(_setLogKey)) {
1753
+ _this9._loggedCacheEvents.add(_setLogKey);
1523
1754
  }
1524
1755
  }
1525
- return _context23.abrupt("return", _obj2);
1756
+ return _context26.abrupt("return", _obj2);
1526
1757
  case 9:
1527
- _context23.prev = 9;
1758
+ _context26.prev = 9;
1528
1759
  // Remove from pending loads
1529
- _this8._pendingLoads["delete"](pendingKey);
1530
- return _context23.finish(9);
1760
+ _this9._pendingLoads["delete"](pendingKey);
1761
+ return _context26.finish(9);
1531
1762
  case 12:
1532
1763
  case "end":
1533
- return _context23.stop();
1764
+ return _context26.stop();
1534
1765
  }
1535
- }, _callee23, null, [[0,, 9, 12]]);
1766
+ }, _callee26, null, [[0,, 9, 12]]);
1536
1767
  }))(); // Store the promise so other concurrent requests can await it
1537
1768
  this._pendingLoads.set(pendingKey, loadPromise);
1538
- _context24.next = 43;
1769
+ _context27.next = 43;
1539
1770
  return loadPromise;
1540
1771
  case 43:
1541
- return _context24.abrupt("return", _context24.sent);
1772
+ return _context27.abrupt("return", _context27.sent);
1542
1773
  case 44:
1543
- _context24.next = 49;
1774
+ _context27.next = 49;
1544
1775
  break;
1545
1776
  case 46:
1546
- _context24.prev = 46;
1547
- _context24.t0 = _context24["catch"](2);
1548
- return _context24.abrupt("return", this._handleError(_context24.t0));
1777
+ _context27.prev = 46;
1778
+ _context27.t0 = _context27["catch"](2);
1779
+ return _context27.abrupt("return", this._handleError(_context27.t0));
1549
1780
  case 49:
1550
1781
  case "end":
1551
- return _context24.stop();
1782
+ return _context27.stop();
1552
1783
  }
1553
- }, _callee24, this, [[2, 46]]);
1784
+ }, _callee27, this, [[2, 46]]);
1554
1785
  }));
1555
- function load(_x14, _x15) {
1786
+ function load(_x15, _x16) {
1556
1787
  return _load.apply(this, arguments);
1557
1788
  }
1558
1789
  return load;
@@ -1628,11 +1859,11 @@ var RbtApi = /*#__PURE__*/function () {
1628
1859
  }, {
1629
1860
  key: "getCacheStatus",
1630
1861
  value: function getCacheStatus() {
1631
- var cacheEntries = Array.from(this._objectCache.entries()).map(function (_ref6) {
1862
+ var cacheEntries = Array.from(this._objectCache.entries()).map(function (_ref7) {
1632
1863
  var _obj$_internalData;
1633
- var _ref7 = _slicedToArray(_ref6, 2),
1634
- key = _ref7[0],
1635
- obj = _ref7[1];
1864
+ var _ref8 = _slicedToArray(_ref7, 2),
1865
+ key = _ref8[0],
1866
+ obj = _ref8[1];
1636
1867
  return {
1637
1868
  key: key,
1638
1869
  id: obj.id,
@@ -1670,7 +1901,7 @@ var RbtApi = /*#__PURE__*/function () {
1670
1901
  }, {
1671
1902
  key: "runTask",
1672
1903
  value: (function () {
1673
- var _runTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
1904
+ var _runTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
1674
1905
  var params,
1675
1906
  callbacks,
1676
1907
  onProgress,
@@ -1685,20 +1916,20 @@ var RbtApi = /*#__PURE__*/function () {
1685
1916
  message,
1686
1917
  output,
1687
1918
  errorResponse,
1688
- _args25 = arguments;
1689
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1690
- while (1) switch (_context25.prev = _context25.next) {
1919
+ _args28 = arguments;
1920
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
1921
+ while (1) switch (_context28.prev = _context28.next) {
1691
1922
  case 0:
1692
- params = _args25.length > 0 && _args25[0] !== undefined ? _args25[0] : {};
1693
- callbacks = _args25.length > 1 && _args25[1] !== undefined ? _args25[1] : {};
1923
+ params = _args28.length > 0 && _args28[0] !== undefined ? _args28[0] : {};
1924
+ callbacks = _args28.length > 1 && _args28[1] !== undefined ? _args28[1] : {};
1694
1925
  onProgress = callbacks.onProgress, onError = callbacks.onError, onStopped = callbacks.onStopped, onWaiting = callbacks.onWaiting, onDone = callbacks.onDone;
1695
- _context25.prev = 3;
1696
- _context25.next = 6;
1926
+ _context28.prev = 3;
1927
+ _context28.next = 6;
1697
1928
  return this.post('/task_service/runChain', params);
1698
1929
  case 6:
1699
- response = _context25.sent;
1930
+ response = _context28.sent;
1700
1931
  if (response) {
1701
- _context25.next = 9;
1932
+ _context28.next = 9;
1702
1933
  break;
1703
1934
  }
1704
1935
  throw new Error('Invalid server response');
@@ -1706,7 +1937,7 @@ var RbtApi = /*#__PURE__*/function () {
1706
1937
  // Validate response structure
1707
1938
  ok = response.ok, jobId = response.jobId, status = response.status, message = response.message, output = response.output;
1708
1939
  if (!(!ok || typeof jobId !== 'string' || typeof status !== 'string')) {
1709
- _context25.next = 12;
1940
+ _context28.next = 12;
1710
1941
  break;
1711
1942
  }
1712
1943
  throw new Error('Invalid response structure');
@@ -1732,7 +1963,7 @@ var RbtApi = /*#__PURE__*/function () {
1732
1963
  //console.log('Finish (request) ',response); s
1733
1964
  onDone(response);
1734
1965
  }
1735
- return _context25.abrupt("return", {
1966
+ return _context28.abrupt("return", {
1736
1967
  ok: ok,
1737
1968
  jobId: jobId,
1738
1969
  status: status,
@@ -1740,21 +1971,21 @@ var RbtApi = /*#__PURE__*/function () {
1740
1971
  output: output
1741
1972
  });
1742
1973
  case 20:
1743
- _context25.prev = 20;
1744
- _context25.t0 = _context25["catch"](3);
1974
+ _context28.prev = 20;
1975
+ _context28.t0 = _context28["catch"](3);
1745
1976
  // Standardize error format to match task response object
1746
1977
  // Support RbtError format with label and message
1747
1978
  errorResponse = {
1748
1979
  ok: false,
1749
1980
  jobId: null,
1750
1981
  status: 'ERROR',
1751
- message: _context25.t0.message || _context25.t0.toString() || 'Unknown error',
1752
- label: _context25.t0.label || _context25.t0.name || 'Error',
1982
+ message: _context28.t0.message || _context28.t0.toString() || 'Unknown error',
1983
+ label: _context28.t0.label || _context28.t0.name || 'Error',
1753
1984
  output: {
1754
- error: _context25.t0.message,
1755
- label: _context25.t0.label,
1756
- stack: _context25.t0.stack,
1757
- originalError: _context25.t0
1985
+ error: _context28.t0.message,
1986
+ label: _context28.t0.label,
1987
+ stack: _context28.t0.stack,
1988
+ originalError: _context28.t0
1758
1989
  }
1759
1990
  };
1760
1991
  if (typeof onError === 'function') {
@@ -1762,12 +1993,12 @@ var RbtApi = /*#__PURE__*/function () {
1762
1993
  } else {
1763
1994
  console.error('Error in runTask:', errorResponse.message);
1764
1995
  }
1765
- return _context25.abrupt("return", errorResponse);
1996
+ return _context28.abrupt("return", errorResponse);
1766
1997
  case 25:
1767
1998
  case "end":
1768
- return _context25.stop();
1999
+ return _context28.stop();
1769
2000
  }
1770
- }, _callee25, this, [[3, 20]]);
2001
+ }, _callee28, this, [[3, 20]]);
1771
2002
  }));
1772
2003
  function runTask() {
1773
2004
  return _runTask.apply(this, arguments);
@@ -1777,37 +2008,37 @@ var RbtApi = /*#__PURE__*/function () {
1777
2008
  }, {
1778
2009
  key: "stopJob",
1779
2010
  value: function () {
1780
- var _stopJob = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
2011
+ var _stopJob = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
1781
2012
  var params,
1782
2013
  callbacks,
1783
2014
  response,
1784
- _args26 = arguments;
1785
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
1786
- while (1) switch (_context26.prev = _context26.next) {
2015
+ _args29 = arguments;
2016
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2017
+ while (1) switch (_context29.prev = _context29.next) {
1787
2018
  case 0:
1788
- params = _args26.length > 0 && _args26[0] !== undefined ? _args26[0] : {};
1789
- callbacks = _args26.length > 1 && _args26[1] !== undefined ? _args26[1] : {};
1790
- _context26.prev = 2;
1791
- _context26.next = 5;
2019
+ params = _args29.length > 0 && _args29[0] !== undefined ? _args29[0] : {};
2020
+ callbacks = _args29.length > 1 && _args29[1] !== undefined ? _args29[1] : {};
2021
+ _context29.prev = 2;
2022
+ _context29.next = 5;
1792
2023
  return this.post('/task_service/stopJob', params);
1793
2024
  case 5:
1794
- response = _context26.sent;
2025
+ response = _context29.sent;
1795
2026
  if (response) {
1796
- _context26.next = 8;
2027
+ _context29.next = 8;
1797
2028
  break;
1798
2029
  }
1799
2030
  throw new Error('Invalid server response');
1800
2031
  case 8:
1801
- return _context26.abrupt("return", true);
2032
+ return _context29.abrupt("return", true);
1802
2033
  case 11:
1803
- _context26.prev = 11;
1804
- _context26.t0 = _context26["catch"](2);
2034
+ _context29.prev = 11;
2035
+ _context29.t0 = _context29["catch"](2);
1805
2036
  throw 'Error in stopJob';
1806
2037
  case 14:
1807
2038
  case "end":
1808
- return _context26.stop();
2039
+ return _context29.stop();
1809
2040
  }
1810
- }, _callee26, this, [[2, 11]]);
2041
+ }, _callee29, this, [[2, 11]]);
1811
2042
  }));
1812
2043
  function stopJob() {
1813
2044
  return _stopJob.apply(this, arguments);
@@ -1855,26 +2086,26 @@ var RbtApi = /*#__PURE__*/function () {
1855
2086
  }, {
1856
2087
  key: "pollTaskProgress",
1857
2088
  value: (function () {
1858
- var _pollTaskProgress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(jobId, callbacks) {
1859
- var _this9 = this;
2089
+ var _pollTaskProgress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(jobId, callbacks) {
2090
+ var _this10 = this;
1860
2091
  var onProgress, onError, onStopped, onWaiting, onDone, _callbacks$pollingInt, pollingInterval, checkProgress;
1861
- return _regeneratorRuntime().wrap(function _callee28$(_context28) {
1862
- while (1) switch (_context28.prev = _context28.next) {
2092
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2093
+ while (1) switch (_context31.prev = _context31.next) {
1863
2094
  case 0:
1864
2095
  onProgress = callbacks.onProgress, onError = callbacks.onError, onStopped = callbacks.onStopped, onWaiting = callbacks.onWaiting, onDone = callbacks.onDone, _callbacks$pollingInt = callbacks.pollingInterval, pollingInterval = _callbacks$pollingInt === void 0 ? 2000 : _callbacks$pollingInt;
1865
- _context28.prev = 1;
2096
+ _context31.prev = 1;
1866
2097
  checkProgress = /*#__PURE__*/function () {
1867
- var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
2098
+ var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
1868
2099
  var response;
1869
- return _regeneratorRuntime().wrap(function _callee27$(_context27) {
1870
- while (1) switch (_context27.prev = _context27.next) {
2100
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2101
+ while (1) switch (_context30.prev = _context30.next) {
1871
2102
  case 0:
1872
- _context27.next = 2;
1873
- return _this9.get("/task_service/pollChainProgress", {
2103
+ _context30.next = 2;
2104
+ return _this10.get("/task_service/pollChainProgress", {
1874
2105
  jobId: jobId
1875
2106
  });
1876
2107
  case 2:
1877
- response = _context27.sent;
2108
+ response = _context30.sent;
1878
2109
  // If the task is still in progress, start polling for updates
1879
2110
  if (response.status === 'DONE' && onDone) {
1880
2111
  // Provide the current progress to the callback function
@@ -1883,7 +2114,7 @@ var RbtApi = /*#__PURE__*/function () {
1883
2114
  }
1884
2115
  if (response.status === 'ERROR' && onError) {
1885
2116
  // Normalize error response to have consistent message/label at top level
1886
- onError(_this9._normalizeErrorResponse(response));
2117
+ onError(_this10._normalizeErrorResponse(response));
1887
2118
  }
1888
2119
  if (response.status === 'STOPPED' && onStopped) {
1889
2120
  // Provide the current progress to the callback function
@@ -1905,28 +2136,28 @@ var RbtApi = /*#__PURE__*/function () {
1905
2136
  }
1906
2137
  case 9:
1907
2138
  case "end":
1908
- return _context27.stop();
2139
+ return _context30.stop();
1909
2140
  }
1910
- }, _callee27);
2141
+ }, _callee30);
1911
2142
  }));
1912
2143
  return function checkProgress() {
1913
- return _ref8.apply(this, arguments);
2144
+ return _ref9.apply(this, arguments);
1914
2145
  };
1915
2146
  }();
1916
2147
  checkProgress();
1917
- _context28.next = 9;
2148
+ _context31.next = 9;
1918
2149
  break;
1919
2150
  case 6:
1920
- _context28.prev = 6;
1921
- _context28.t0 = _context28["catch"](1);
1922
- return _context28.abrupt("return", this._handleError(_context28.t0));
2151
+ _context31.prev = 6;
2152
+ _context31.t0 = _context31["catch"](1);
2153
+ return _context31.abrupt("return", this._handleError(_context31.t0));
1923
2154
  case 9:
1924
2155
  case "end":
1925
- return _context28.stop();
2156
+ return _context31.stop();
1926
2157
  }
1927
- }, _callee28, this, [[1, 6]]);
2158
+ }, _callee31, this, [[1, 6]]);
1928
2159
  }));
1929
- function pollTaskProgress(_x16, _x17) {
2160
+ function pollTaskProgress(_x17, _x18) {
1930
2161
  return _pollTaskProgress.apply(this, arguments);
1931
2162
  }
1932
2163
  return pollTaskProgress;
@@ -1947,18 +2178,18 @@ var RbtApi = /*#__PURE__*/function () {
1947
2178
  }, {
1948
2179
  key: "get",
1949
2180
  value: (function () {
1950
- var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(endpoint) {
2181
+ var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(endpoint) {
1951
2182
  var params,
1952
2183
  customHeaders,
1953
2184
  config,
1954
2185
  response,
1955
- _args29 = arguments;
1956
- return _regeneratorRuntime().wrap(function _callee29$(_context29) {
1957
- while (1) switch (_context29.prev = _context29.next) {
2186
+ _args32 = arguments;
2187
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2188
+ while (1) switch (_context32.prev = _context32.next) {
1958
2189
  case 0:
1959
- params = _args29.length > 1 && _args29[1] !== undefined ? _args29[1] : {};
1960
- customHeaders = _args29.length > 2 && _args29[2] !== undefined ? _args29[2] : null;
1961
- _context29.prev = 2;
2190
+ params = _args32.length > 1 && _args32[1] !== undefined ? _args32[1] : {};
2191
+ customHeaders = _args32.length > 2 && _args32[2] !== undefined ? _args32[2] : null;
2192
+ _context32.prev = 2;
1962
2193
  // Build request config
1963
2194
  config = {
1964
2195
  params: params
@@ -1973,28 +2204,28 @@ var RbtApi = /*#__PURE__*/function () {
1973
2204
  // Otherwise, don't set config.headers at all - let axios use its defaults
1974
2205
 
1975
2206
  // Make the GET request using Axios
1976
- _context29.next = 7;
2207
+ _context32.next = 7;
1977
2208
  return this.axios.get(endpoint, config);
1978
2209
  case 7:
1979
- response = _context29.sent;
2210
+ response = _context32.sent;
1980
2211
  if (!(response.data.ok === false)) {
1981
- _context29.next = 10;
2212
+ _context32.next = 10;
1982
2213
  break;
1983
2214
  }
1984
- return _context29.abrupt("return", this._handleError(response));
2215
+ return _context32.abrupt("return", this._handleError(response));
1985
2216
  case 10:
1986
- return _context29.abrupt("return", response.data);
2217
+ return _context32.abrupt("return", response.data);
1987
2218
  case 13:
1988
- _context29.prev = 13;
1989
- _context29.t0 = _context29["catch"](2);
1990
- return _context29.abrupt("return", this._handleError(_context29.t0));
2219
+ _context32.prev = 13;
2220
+ _context32.t0 = _context32["catch"](2);
2221
+ return _context32.abrupt("return", this._handleError(_context32.t0));
1991
2222
  case 16:
1992
2223
  case "end":
1993
- return _context29.stop();
2224
+ return _context32.stop();
1994
2225
  }
1995
- }, _callee29, this, [[2, 13]]);
2226
+ }, _callee32, this, [[2, 13]]);
1996
2227
  }));
1997
- function get(_x18) {
2228
+ function get(_x19) {
1998
2229
  return _get.apply(this, arguments);
1999
2230
  }
2000
2231
  return get;
@@ -2015,44 +2246,44 @@ var RbtApi = /*#__PURE__*/function () {
2015
2246
  }, {
2016
2247
  key: "post",
2017
2248
  value: (function () {
2018
- var _post = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(endpoint) {
2249
+ var _post = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(endpoint) {
2019
2250
  var data,
2020
2251
  headers,
2021
2252
  response,
2022
- _args30 = arguments;
2023
- return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2024
- while (1) switch (_context30.prev = _context30.next) {
2253
+ _args33 = arguments;
2254
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
2255
+ while (1) switch (_context33.prev = _context33.next) {
2025
2256
  case 0:
2026
- data = _args30.length > 1 && _args30[1] !== undefined ? _args30[1] : {};
2027
- _context30.prev = 1;
2257
+ data = _args33.length > 1 && _args33[1] !== undefined ? _args33[1] : {};
2258
+ _context33.prev = 1;
2028
2259
  // Add the authToken to the headers
2029
2260
  headers = {
2030
2261
  authtoken: this.authtoken
2031
2262
  }; // Make the POST request using Axios
2032
- _context30.next = 5;
2263
+ _context33.next = 5;
2033
2264
  return this.axios.post(endpoint, data, {
2034
2265
  headers: headers
2035
2266
  });
2036
2267
  case 5:
2037
- response = _context30.sent;
2268
+ response = _context33.sent;
2038
2269
  if (!(response.data.ok === false)) {
2039
- _context30.next = 8;
2270
+ _context33.next = 8;
2040
2271
  break;
2041
2272
  }
2042
- return _context30.abrupt("return", this._handleError(response));
2273
+ return _context33.abrupt("return", this._handleError(response));
2043
2274
  case 8:
2044
- return _context30.abrupt("return", response.data);
2275
+ return _context33.abrupt("return", response.data);
2045
2276
  case 11:
2046
- _context30.prev = 11;
2047
- _context30.t0 = _context30["catch"](1);
2048
- return _context30.abrupt("return", this._handleError(_context30.t0));
2277
+ _context33.prev = 11;
2278
+ _context33.t0 = _context33["catch"](1);
2279
+ return _context33.abrupt("return", this._handleError(_context33.t0));
2049
2280
  case 14:
2050
2281
  case "end":
2051
- return _context30.stop();
2282
+ return _context33.stop();
2052
2283
  }
2053
- }, _callee30, this, [[1, 11]]);
2284
+ }, _callee33, this, [[1, 11]]);
2054
2285
  }));
2055
- function post(_x19) {
2286
+ function post(_x20) {
2056
2287
  return _post.apply(this, arguments);
2057
2288
  }
2058
2289
  return post;