roboto-js 1.9.5 → 1.9.9

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,340 @@ 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
+ /**
1038
+ * Select and link an organization to the current user
1039
+ * This adds the organization to the user's organizations array (if not already there)
1040
+ * and sets it as the current organization preference
1041
+ *
1042
+ * @param {string} orgId - Organization ID to select
1043
+ * @param {string} role - Role for the user in this organization (default: 'owner')
1044
+ * @returns {Promise<RbtObject>} The selected organization
1045
+ */
1046
+ }, {
1047
+ key: "selectCurrentOrganization",
1048
+ value: (function () {
1049
+ var _selectCurrentOrganization = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(orgId) {
1050
+ var role,
1051
+ org,
1052
+ user,
1053
+ userOrgs,
1054
+ orgExists,
1055
+ modData,
1056
+ _args17 = arguments;
1057
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1058
+ while (1) switch (_context17.prev = _context17.next) {
1059
+ case 0:
1060
+ role = _args17.length > 1 && _args17[1] !== undefined ? _args17[1] : 'owner';
1061
+ _context17.prev = 1;
1062
+ if (this.currentUser) {
1063
+ _context17.next = 7;
1064
+ break;
1065
+ }
1066
+ _context17.next = 5;
1067
+ return this.loadCurrentUser();
1068
+ case 5:
1069
+ if (this.currentUser) {
1070
+ _context17.next = 7;
1071
+ break;
1072
+ }
1073
+ throw new Error('Must be logged in to select organization');
1074
+ case 7:
1075
+ _context17.next = 9;
1076
+ return this.get('<@iac.organization>', orgId);
1077
+ case 9:
1078
+ org = _context17.sent;
1079
+ if (org) {
1080
+ _context17.next = 12;
1081
+ break;
1082
+ }
1083
+ throw new Error("Organization ".concat(orgId, " not found or not accessible"));
1084
+ case 12:
1085
+ _context17.next = 14;
1086
+ return this.loadUser(this.currentUser.id);
1087
+ case 14:
1088
+ user = _context17.sent;
1089
+ if (user) {
1090
+ _context17.next = 17;
1091
+ break;
1092
+ }
1093
+ throw new Error('Failed to load user object');
1094
+ case 17:
1095
+ // Update user's organizations array
1096
+ userOrgs = user.get('organizations') || [];
1097
+ orgExists = userOrgs.some(function (o) {
1098
+ return (o === null || o === void 0 ? void 0 : o.id) === orgId;
1099
+ });
1100
+ if (!orgExists) {
1101
+ userOrgs.unshift({
1102
+ id: orgId,
1103
+ roles: [role]
1104
+ });
1105
+ user.set('organizations', userOrgs);
1106
+ } else {}
1107
+
1108
+ // Set as current organization preference - handle both nested path formats
1109
+ modData = user.get('mod') || {};
1110
+ modData.currentOrgId = orgId;
1111
+ user.set('mod', modData);
1112
+
1113
+ // Save user record
1114
+ _context17.next = 25;
1115
+ return user.save();
1116
+ case 25:
1117
+ // Clear cached organization to force reload
1118
+ this.currentOrganization = null;
1119
+
1120
+ // Update the current user reference
1121
+ this.currentUser = user;
1122
+
1123
+ // Set the new current organization
1124
+ this.currentOrganization = org;
1125
+
1126
+ // Update cache
1127
+ if (!this.localStorageAdaptor) {
1128
+ _context17.next = 31;
1129
+ break;
1130
+ }
1131
+ _context17.next = 31;
1132
+ return this.localStorageAdaptor.setItem('currentOrgId', orgId);
1133
+ case 31:
1134
+ return _context17.abrupt("return", org);
1135
+ case 34:
1136
+ _context17.prev = 34;
1137
+ _context17.t0 = _context17["catch"](1);
1138
+ console.error('[RbtApi] Error in selectCurrentOrganization:', _context17.t0);
1139
+ return _context17.abrupt("return", this._handleError(_context17.t0));
1140
+ case 38:
1141
+ case "end":
1142
+ return _context17.stop();
1143
+ }
1144
+ }, _callee17, this, [[1, 34]]);
1145
+ }));
1146
+ function selectCurrentOrganization(_x8) {
1147
+ return _selectCurrentOrganization.apply(this, arguments);
1148
+ }
1149
+ return selectCurrentOrganization;
1150
+ }())
1151
+ }, {
1152
+ key: "loadUser",
1153
+ value: function () {
1154
+ var _loadUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(userId) {
1155
+ var _this5 = this;
1156
+ var params, cacheKey, now, existing, p;
1157
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1158
+ while (1) switch (_context19.prev = _context19.next) {
813
1159
  case 0:
814
1160
  params = {
815
1161
  id: userId
@@ -818,53 +1164,53 @@ var RbtApi = /*#__PURE__*/function () {
818
1164
  now = Date.now();
819
1165
  existing = this.requestCache[cacheKey];
820
1166
  if (!(existing && now - existing.time < 10000)) {
821
- _context15.next = 6;
1167
+ _context19.next = 6;
822
1168
  break;
823
1169
  }
824
- return _context15.abrupt("return", existing.val);
1170
+ return _context19.abrupt("return", existing.val);
825
1171
  case 6:
826
- _context15.prev = 6;
827
- p = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
1172
+ _context19.prev = 6;
1173
+ p = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
828
1174
  var _response$data;
829
1175
  var response, userData, User;
830
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
831
- while (1) switch (_context14.prev = _context14.next) {
1176
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1177
+ while (1) switch (_context18.prev = _context18.next) {
832
1178
  case 0:
833
- _context14.next = 2;
834
- return _this4.axios.post('/user_service/loadUser', [params]);
1179
+ _context18.next = 2;
1180
+ return _this5.axios.post('/user_service/loadUser', [params]);
835
1181
  case 2:
836
- response = _context14.sent;
1182
+ response = _context18.sent;
837
1183
  userData = response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.user;
838
1184
  User = new RbtUser({
839
1185
  id: userData.id
840
- }, _this4.axios);
1186
+ }, _this5.axios);
841
1187
  User.setData(userData);
842
- return _context14.abrupt("return", User);
1188
+ return _context18.abrupt("return", User);
843
1189
  case 7:
844
1190
  case "end":
845
- return _context14.stop();
1191
+ return _context18.stop();
846
1192
  }
847
- }, _callee14);
1193
+ }, _callee18);
848
1194
  }))();
849
1195
  this.requestCache[cacheKey] = {
850
1196
  val: p,
851
1197
  time: now
852
1198
  };
853
- _context15.next = 11;
1199
+ _context19.next = 11;
854
1200
  return p;
855
1201
  case 11:
856
- return _context15.abrupt("return", _context15.sent);
1202
+ return _context19.abrupt("return", _context19.sent);
857
1203
  case 14:
858
- _context15.prev = 14;
859
- _context15.t0 = _context15["catch"](6);
860
- return _context15.abrupt("return", this._handleError(_context15.t0));
1204
+ _context19.prev = 14;
1205
+ _context19.t0 = _context19["catch"](6);
1206
+ return _context19.abrupt("return", this._handleError(_context19.t0));
861
1207
  case 17:
862
1208
  case "end":
863
- return _context15.stop();
1209
+ return _context19.stop();
864
1210
  }
865
- }, _callee15, this, [[6, 14]]);
1211
+ }, _callee19, this, [[6, 14]]);
866
1212
  }));
867
- function loadUser(_x7) {
1213
+ function loadUser(_x9) {
868
1214
  return _loadUser.apply(this, arguments);
869
1215
  }
870
1216
  return loadUser;
@@ -872,53 +1218,53 @@ var RbtApi = /*#__PURE__*/function () {
872
1218
  }, {
873
1219
  key: "refreshAuthToken",
874
1220
  value: function () {
875
- var _refreshAuthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(authtoken) {
1221
+ var _refreshAuthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(authtoken) {
876
1222
  var promise, response;
877
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
878
- while (1) switch (_context16.prev = _context16.next) {
1223
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1224
+ while (1) switch (_context20.prev = _context20.next) {
879
1225
  case 0:
880
1226
  if (this.appServiceHost) {
881
- _context16.next = 2;
1227
+ _context20.next = 2;
882
1228
  break;
883
1229
  }
884
- return _context16.abrupt("return", false);
1230
+ return _context20.abrupt("return", false);
885
1231
  case 2:
886
1232
  if (!this.requestCache[authtoken]) {
887
- _context16.next = 4;
1233
+ _context20.next = 4;
888
1234
  break;
889
1235
  }
890
- return _context16.abrupt("return", this.requestCache[authtoken]);
1236
+ return _context20.abrupt("return", this.requestCache[authtoken]);
891
1237
  case 4:
892
- _context16.prev = 4;
1238
+ _context20.prev = 4;
893
1239
  //console.log('RBTTOK Req', authtoken);
894
1240
  // Create a new promise for the token refresh and store it in the cache
895
1241
  promise = this.axios.post('/user_service/refreshAuthToken', [authtoken]);
896
1242
  this.requestCache[authtoken] = promise;
897
1243
 
898
1244
  // Await the promise to get the response
899
- _context16.next = 9;
1245
+ _context20.next = 9;
900
1246
  return promise;
901
1247
  case 9:
902
- response = _context16.sent;
1248
+ response = _context20.sent;
903
1249
  //console.log('RBTTOK Response ',response);
904
1250
  // Once the promise resolves, delete it from the cache to allow future refreshes
905
1251
  delete this.requestCache[authtoken];
906
1252
 
907
1253
  // Return the response data
908
- return _context16.abrupt("return", response.data);
1254
+ return _context20.abrupt("return", response.data);
909
1255
  case 14:
910
- _context16.prev = 14;
911
- _context16.t0 = _context16["catch"](4);
1256
+ _context20.prev = 14;
1257
+ _context20.t0 = _context20["catch"](4);
912
1258
  // On error, remove the cached promise to allow retries
913
1259
  delete this.requestCache[authtoken];
914
- this._handleError(_context16.t0);
1260
+ this._handleError(_context20.t0);
915
1261
  case 18:
916
1262
  case "end":
917
- return _context16.stop();
1263
+ return _context20.stop();
918
1264
  }
919
- }, _callee16, this, [[4, 14]]);
1265
+ }, _callee20, this, [[4, 14]]);
920
1266
  }));
921
- function refreshAuthToken(_x8) {
1267
+ function refreshAuthToken(_x10) {
922
1268
  return _refreshAuthToken.apply(this, arguments);
923
1269
  }
924
1270
  return refreshAuthToken;
@@ -949,31 +1295,31 @@ var RbtApi = /*#__PURE__*/function () {
949
1295
  }, {
950
1296
  key: "registerUser",
951
1297
  value: function () {
952
- var _registerUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1298
+ var _registerUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
953
1299
  var dataHash,
954
1300
  response,
955
1301
  record,
956
- _args17 = arguments;
957
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
958
- while (1) switch (_context17.prev = _context17.next) {
1302
+ _args21 = arguments;
1303
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1304
+ while (1) switch (_context21.prev = _context21.next) {
959
1305
  case 0:
960
- dataHash = _args17.length > 0 && _args17[0] !== undefined ? _args17[0] : {};
961
- _context17.prev = 1;
962
- _context17.next = 4;
1306
+ dataHash = _args21.length > 0 && _args21[0] !== undefined ? _args21[0] : {};
1307
+ _context21.prev = 1;
1308
+ _context21.next = 4;
963
1309
  return this.axios.post('/user_service/registerUser', [dataHash]);
964
1310
  case 4:
965
- response = _context17.sent;
1311
+ response = _context21.sent;
966
1312
  record = response.data;
967
- return _context17.abrupt("return", new RbtUser(record, this.axios));
1313
+ return _context21.abrupt("return", new RbtUser(record, this.axios));
968
1314
  case 9:
969
- _context17.prev = 9;
970
- _context17.t0 = _context17["catch"](1);
971
- return _context17.abrupt("return", this._handleError(_context17.t0));
1315
+ _context21.prev = 9;
1316
+ _context21.t0 = _context21["catch"](1);
1317
+ return _context21.abrupt("return", this._handleError(_context21.t0));
972
1318
  case 12:
973
1319
  case "end":
974
- return _context17.stop();
1320
+ return _context21.stop();
975
1321
  }
976
- }, _callee17, this, [[1, 9]]);
1322
+ }, _callee21, this, [[1, 9]]);
977
1323
  }));
978
1324
  function registerUser() {
979
1325
  return _registerUser.apply(this, arguments);
@@ -990,32 +1336,32 @@ var RbtApi = /*#__PURE__*/function () {
990
1336
  }, {
991
1337
  key: "createFile",
992
1338
  value: (function () {
993
- var _createFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(dataHash) {
1339
+ var _createFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(dataHash) {
994
1340
  var response, record;
995
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
996
- while (1) switch (_context18.prev = _context18.next) {
1341
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1342
+ while (1) switch (_context22.prev = _context22.next) {
997
1343
  case 0:
998
- _context18.prev = 0;
999
- _context18.next = 3;
1344
+ _context22.prev = 0;
1345
+ _context22.next = 3;
1000
1346
  return this.axios.post('/object_service/createObject', ['<@filekit.file>', dataHash]);
1001
1347
  case 3:
1002
- response = _context18.sent;
1348
+ response = _context22.sent;
1003
1349
  record = response.data;
1004
1350
  if (dataHash) {
1005
1351
  record.data = dataHash;
1006
1352
  }
1007
- return _context18.abrupt("return", new RbtFile(record, this.axios, this.localDb));
1353
+ return _context22.abrupt("return", new RbtFile(record, this.axios, this.localDb));
1008
1354
  case 9:
1009
- _context18.prev = 9;
1010
- _context18.t0 = _context18["catch"](0);
1011
- return _context18.abrupt("return", this._handleError(_context18.t0));
1355
+ _context22.prev = 9;
1356
+ _context22.t0 = _context22["catch"](0);
1357
+ return _context22.abrupt("return", this._handleError(_context22.t0));
1012
1358
  case 12:
1013
1359
  case "end":
1014
- return _context18.stop();
1360
+ return _context22.stop();
1015
1361
  }
1016
- }, _callee18, this, [[0, 9]]);
1362
+ }, _callee22, this, [[0, 9]]);
1017
1363
  }));
1018
- function createFile(_x9) {
1364
+ function createFile(_x11) {
1019
1365
  return _createFile.apply(this, arguments);
1020
1366
  }
1021
1367
  return createFile;
@@ -1023,35 +1369,35 @@ var RbtApi = /*#__PURE__*/function () {
1023
1369
  }, {
1024
1370
  key: "loadFile",
1025
1371
  value: function () {
1026
- var _loadFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(id) {
1372
+ var _loadFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(id) {
1027
1373
  var response, record;
1028
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1029
- while (1) switch (_context19.prev = _context19.next) {
1374
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1375
+ while (1) switch (_context23.prev = _context23.next) {
1030
1376
  case 0:
1031
- _context19.prev = 0;
1032
- _context19.next = 3;
1377
+ _context23.prev = 0;
1378
+ _context23.next = 3;
1033
1379
  return this.load('<@filekit.file>', id);
1034
1380
  case 3:
1035
- response = _context19.sent;
1381
+ response = _context23.sent;
1036
1382
  if (response) {
1037
- _context19.next = 6;
1383
+ _context23.next = 6;
1038
1384
  break;
1039
1385
  }
1040
- return _context19.abrupt("return", null);
1386
+ return _context23.abrupt("return", null);
1041
1387
  case 6:
1042
1388
  record = response.toRecord();
1043
- return _context19.abrupt("return", new RbtFile(record, this.axios, this.localDb));
1389
+ return _context23.abrupt("return", new RbtFile(record, this.axios, this.localDb));
1044
1390
  case 10:
1045
- _context19.prev = 10;
1046
- _context19.t0 = _context19["catch"](0);
1047
- return _context19.abrupt("return", this._handleError(_context19.t0));
1391
+ _context23.prev = 10;
1392
+ _context23.t0 = _context23["catch"](0);
1393
+ return _context23.abrupt("return", this._handleError(_context23.t0));
1048
1394
  case 13:
1049
1395
  case "end":
1050
- return _context19.stop();
1396
+ return _context23.stop();
1051
1397
  }
1052
- }, _callee19, this, [[0, 10]]);
1398
+ }, _callee23, this, [[0, 10]]);
1053
1399
  }));
1054
- function loadFile(_x10) {
1400
+ function loadFile(_x12) {
1055
1401
  return _loadFile.apply(this, arguments);
1056
1402
  }
1057
1403
  return loadFile;
@@ -1059,39 +1405,39 @@ var RbtApi = /*#__PURE__*/function () {
1059
1405
  }, {
1060
1406
  key: "loadFiles",
1061
1407
  value: function () {
1062
- var _loadFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(ids) {
1063
- var _this5 = this;
1408
+ var _loadFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(ids) {
1409
+ var _this6 = this;
1064
1410
  var responses;
1065
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1066
- while (1) switch (_context20.prev = _context20.next) {
1411
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1412
+ while (1) switch (_context24.prev = _context24.next) {
1067
1413
  case 0:
1068
- _context20.prev = 0;
1069
- _context20.next = 3;
1414
+ _context24.prev = 0;
1415
+ _context24.next = 3;
1070
1416
  return this.load('<@filekit.file>', ids);
1071
1417
  case 3:
1072
- responses = _context20.sent;
1418
+ responses = _context24.sent;
1073
1419
  if (!(!responses || !Array.isArray(responses))) {
1074
- _context20.next = 6;
1420
+ _context24.next = 6;
1075
1421
  break;
1076
1422
  }
1077
- return _context20.abrupt("return", []);
1423
+ return _context24.abrupt("return", []);
1078
1424
  case 6:
1079
- return _context20.abrupt("return", responses.map(function (response) {
1425
+ return _context24.abrupt("return", responses.map(function (response) {
1080
1426
  var record = response.toRecord();
1081
- return new RbtFile(record, _this5.axios, _this5.localDb);
1427
+ return new RbtFile(record, _this6.axios, _this6.localDb);
1082
1428
  }));
1083
1429
  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", []);
1430
+ _context24.prev = 9;
1431
+ _context24.t0 = _context24["catch"](0);
1432
+ this._handleError(_context24.t0); // Handle errors (log or process as needed)
1433
+ return _context24.abrupt("return", []);
1088
1434
  case 13:
1089
1435
  case "end":
1090
- return _context20.stop();
1436
+ return _context24.stop();
1091
1437
  }
1092
- }, _callee20, this, [[0, 9]]);
1438
+ }, _callee24, this, [[0, 9]]);
1093
1439
  }));
1094
- function loadFiles(_x11) {
1440
+ function loadFiles(_x13) {
1095
1441
  return _loadFiles.apply(this, arguments);
1096
1442
  }
1097
1443
  return loadFiles;
@@ -1107,42 +1453,42 @@ var RbtApi = /*#__PURE__*/function () {
1107
1453
  }, {
1108
1454
  key: "create",
1109
1455
  value: (function () {
1110
- var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(type) {
1456
+ var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(type) {
1111
1457
  var dataHash,
1112
1458
  options,
1113
1459
  response,
1114
1460
  record,
1115
- _args21 = arguments;
1116
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1117
- while (1) switch (_context21.prev = _context21.next) {
1461
+ _args25 = arguments;
1462
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1463
+ while (1) switch (_context25.prev = _context25.next) {
1118
1464
  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;
1465
+ dataHash = _args25.length > 1 && _args25[1] !== undefined ? _args25[1] : {};
1466
+ options = _args25.length > 2 && _args25[2] !== undefined ? _args25[2] : {};
1467
+ _context25.prev = 2;
1468
+ _context25.next = 5;
1123
1469
  return this.axios.post('/object_service/createObject', [type, dataHash]);
1124
1470
  case 5:
1125
- response = _context21.sent;
1471
+ response = _context25.sent;
1126
1472
  record = response.data;
1127
1473
  if (dataHash) {
1128
1474
  record.data = dataHash;
1129
1475
  }
1130
- return _context21.abrupt("return", new RbtObject(record, this.axios, {
1476
+ return _context25.abrupt("return", new RbtObject(record, this.axios, {
1131
1477
  isNew: true,
1132
1478
  websocketClient: this.websocketClient,
1133
1479
  enableRealtime: options.enableRealtime || false
1134
1480
  }));
1135
1481
  case 11:
1136
- _context21.prev = 11;
1137
- _context21.t0 = _context21["catch"](2);
1138
- return _context21.abrupt("return", this._handleError(_context21.t0));
1482
+ _context25.prev = 11;
1483
+ _context25.t0 = _context25["catch"](2);
1484
+ return _context25.abrupt("return", this._handleError(_context25.t0));
1139
1485
  case 14:
1140
1486
  case "end":
1141
- return _context21.stop();
1487
+ return _context25.stop();
1142
1488
  }
1143
- }, _callee21, this, [[2, 11]]);
1489
+ }, _callee25, this, [[2, 11]]);
1144
1490
  }));
1145
- function create(_x12) {
1491
+ function create(_x14) {
1146
1492
  return _create.apply(this, arguments);
1147
1493
  }
1148
1494
  return create;
@@ -1185,8 +1531,8 @@ var RbtApi = /*#__PURE__*/function () {
1185
1531
  }, {
1186
1532
  key: "query",
1187
1533
  value: (function () {
1188
- var _query = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(type) {
1189
- var _this6 = this;
1534
+ var _query = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(type) {
1535
+ var _this7 = this;
1190
1536
  var params,
1191
1537
  paramsKey,
1192
1538
  validParams,
@@ -1198,12 +1544,12 @@ var RbtApi = /*#__PURE__*/function () {
1198
1544
  cacheEntry,
1199
1545
  responsePromise,
1200
1546
  processingPromise,
1201
- _args22 = arguments;
1202
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1203
- while (1) switch (_context22.prev = _context22.next) {
1547
+ _args26 = arguments;
1548
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
1549
+ while (1) switch (_context26.prev = _context26.next) {
1204
1550
  case 0:
1205
- params = _args22.length > 1 && _args22[1] !== undefined ? _args22[1] : {};
1206
- _context22.prev = 1;
1551
+ params = _args26.length > 1 && _args26[1] !== undefined ? _args26[1] : {};
1552
+ _context26.prev = 1;
1207
1553
  //console.log('RBTAPI.query INIT', type, params);
1208
1554
  // Validate parameters - reject invalid parameter names
1209
1555
  validParams = ['type', 'where', 'orderBy', 'limit', 'resolveReferences', 'requestAttrs', 'excludeAttrs', 'timeout', 'enableRealtime'];
@@ -1211,7 +1557,7 @@ var RbtApi = /*#__PURE__*/function () {
1211
1557
  return !validParams.includes(key);
1212
1558
  });
1213
1559
  if (!(invalidParams.length > 0)) {
1214
- _context22.next = 6;
1560
+ _context26.next = 6;
1215
1561
  break;
1216
1562
  }
1217
1563
  throw new Error("Invalid query parameter(s): ".concat(invalidParams.join(', '), ". Valid parameters are: ").concat(validParams.join(', ')));
@@ -1238,19 +1584,19 @@ var RbtApi = /*#__PURE__*/function () {
1238
1584
  paramsKey = JSON.stringify(mergedParams);
1239
1585
  cacheEntry = this.requestCache[paramsKey];
1240
1586
  if (!(cacheEntry && currentTime - cacheEntry.time < 10000)) {
1241
- _context22.next = 16;
1587
+ _context26.next = 16;
1242
1588
  break;
1243
1589
  }
1244
- return _context22.abrupt("return", cacheEntry.val);
1590
+ return _context26.abrupt("return", cacheEntry.val);
1245
1591
  case 16:
1246
1592
  // Create the response promise
1247
1593
  responsePromise = this.axios.post('/object_service/queryObjects', [mergedParams]); // Cache the promise of processing data, not just the raw response
1248
1594
  processingPromise = responsePromise.then(function (response) {
1249
- return _this6._processResponseData(response, params);
1595
+ return _this7._processResponseData(response, params);
1250
1596
  })["catch"](function (e) {
1251
- delete _this6.requestCache[paramsKey]; // Ensure cache cleanup on failure
1597
+ delete _this7.requestCache[paramsKey]; // Ensure cache cleanup on failure
1252
1598
  //console.log('RBTAPI.query ERROR (Processing)', paramsKey, e);
1253
- return _this6._handleError(e);
1599
+ return _this7._handleError(e);
1254
1600
  }); // Store the promise of the processed data in the cache
1255
1601
  this.requestCache[paramsKey] = {
1256
1602
  val: processingPromise,
@@ -1258,23 +1604,23 @@ var RbtApi = /*#__PURE__*/function () {
1258
1604
  };
1259
1605
 
1260
1606
  // Await the processing promise for this call to get processed data
1261
- _context22.next = 21;
1607
+ _context26.next = 21;
1262
1608
  return processingPromise;
1263
1609
  case 21:
1264
- return _context22.abrupt("return", _context22.sent);
1610
+ return _context26.abrupt("return", _context26.sent);
1265
1611
  case 24:
1266
- _context22.prev = 24;
1267
- _context22.t0 = _context22["catch"](1);
1612
+ _context26.prev = 24;
1613
+ _context26.t0 = _context26["catch"](1);
1268
1614
  delete this.requestCache[paramsKey]; // Ensure cache cleanup on error
1269
1615
  //console.log('RBTAPI.query ERROR', paramsKey, e);
1270
- return _context22.abrupt("return", this._handleError(_context22.t0));
1616
+ return _context26.abrupt("return", this._handleError(_context26.t0));
1271
1617
  case 28:
1272
1618
  case "end":
1273
- return _context22.stop();
1619
+ return _context26.stop();
1274
1620
  }
1275
- }, _callee22, this, [[1, 24]]);
1621
+ }, _callee26, this, [[1, 24]]);
1276
1622
  }));
1277
- function query(_x13) {
1623
+ function query(_x15) {
1278
1624
  return _query.apply(this, arguments);
1279
1625
  }
1280
1626
  return query;
@@ -1282,7 +1628,7 @@ var RbtApi = /*#__PURE__*/function () {
1282
1628
  }, {
1283
1629
  key: "_processResponseData",
1284
1630
  value: function _processResponseData(response) {
1285
- var _this7 = this;
1631
+ var _this8 = this;
1286
1632
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1287
1633
  if (response.data.ok === false) {
1288
1634
  return this._handleError(response);
@@ -1296,7 +1642,7 @@ var RbtApi = /*#__PURE__*/function () {
1296
1642
  websocketClient = this.getWebSocketClient();
1297
1643
  }
1298
1644
  response.data.items = response.data.items.map(function (record) {
1299
- return new RbtObject(record, _this7.axios, {
1645
+ return new RbtObject(record, _this8.axios, {
1300
1646
  websocketClient: websocketClient,
1301
1647
  enableRealtime: options.enableRealtime || false
1302
1648
  });
@@ -1318,8 +1664,8 @@ var RbtApi = /*#__PURE__*/function () {
1318
1664
  }, {
1319
1665
  key: "load",
1320
1666
  value: (function () {
1321
- var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(type, ids) {
1322
- var _this8 = this;
1667
+ var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(type, ids) {
1668
+ var _this9 = this;
1323
1669
  var params,
1324
1670
  mergedParams,
1325
1671
  cachedObjects,
@@ -1351,17 +1697,17 @@ var RbtApi = /*#__PURE__*/function () {
1351
1697
  pendingKey,
1352
1698
  missLogKey,
1353
1699
  loadPromise,
1354
- _args24 = arguments;
1355
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1356
- while (1) switch (_context24.prev = _context24.next) {
1700
+ _args28 = arguments;
1701
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
1702
+ while (1) switch (_context28.prev = _context28.next) {
1357
1703
  case 0:
1358
- params = _args24.length > 2 && _args24[2] !== undefined ? _args24[2] : {};
1704
+ params = _args28.length > 2 && _args28[2] !== undefined ? _args28[2] : {};
1359
1705
  if (type == '<@iac.user>') {
1360
1706
  debugger;
1361
1707
  }
1362
- _context24.prev = 2;
1708
+ _context28.prev = 2;
1363
1709
  if (!Array.isArray(ids)) {
1364
- _context24.next = 25;
1710
+ _context28.next = 25;
1365
1711
  break;
1366
1712
  }
1367
1713
  // For array requests, check cache for each ID and only load missing ones
@@ -1398,7 +1744,7 @@ var RbtApi = /*#__PURE__*/function () {
1398
1744
  }
1399
1745
  loadedObjects = [];
1400
1746
  if (!(missingIds.length > 0)) {
1401
- _context24.next = 19;
1747
+ _context28.next = 19;
1402
1748
  break;
1403
1749
  }
1404
1750
  // Only log bulk cache miss once
@@ -1412,10 +1758,10 @@ var RbtApi = /*#__PURE__*/function () {
1412
1758
  mergedParams = _objectSpread(_objectSpread({}, queryParams), {}, {
1413
1759
  where: "id IN (\"".concat(missingIds.join("\",\""), "\")")
1414
1760
  });
1415
- _context24.next = 16;
1761
+ _context28.next = 16;
1416
1762
  return this.query(type, mergedParams);
1417
1763
  case 16:
1418
- loadedObjects = _context24.sent;
1764
+ loadedObjects = _context28.sent;
1419
1765
  // Cache the newly loaded objects
1420
1766
  _iterator4 = _createForOfIteratorHelper(loadedObjects);
1421
1767
  try {
@@ -1457,13 +1803,13 @@ var RbtApi = /*#__PURE__*/function () {
1457
1803
  } finally {
1458
1804
  _iterator5.f();
1459
1805
  }
1460
- return _context24.abrupt("return", result);
1806
+ return _context28.abrupt("return", result);
1461
1807
  case 25:
1462
1808
  // For single object requests, check cache first
1463
1809
  _cacheKey3 = "".concat(type, ":").concat(ids);
1464
1810
  _cached = this._objectCache.get(_cacheKey3);
1465
1811
  if (!_cached) {
1466
- _context24.next = 32;
1812
+ _context28.next = 32;
1467
1813
  break;
1468
1814
  }
1469
1815
  // Only log cache hits once per object to reduce spam
@@ -1476,18 +1822,18 @@ var RbtApi = /*#__PURE__*/function () {
1476
1822
  if (params.enableRealtime && !_cached._realtime) {
1477
1823
  _cached._initRealtime();
1478
1824
  }
1479
- return _context24.abrupt("return", _cached);
1825
+ return _context28.abrupt("return", _cached);
1480
1826
  case 32:
1481
1827
  // Check if we're already loading this object
1482
1828
  pendingKey = "".concat(type, ":").concat(ids);
1483
1829
  if (!this._pendingLoads.has(pendingKey)) {
1484
- _context24.next = 37;
1830
+ _context28.next = 37;
1485
1831
  break;
1486
1832
  }
1487
- _context24.next = 36;
1833
+ _context28.next = 36;
1488
1834
  return this._pendingLoads.get(pendingKey);
1489
1835
  case 36:
1490
- return _context24.abrupt("return", _context24.sent);
1836
+ return _context28.abrupt("return", _context28.sent);
1491
1837
  case 37:
1492
1838
  // Only log cache miss once per object to reduce spam
1493
1839
  missLogKey = "miss:".concat(_cacheKey3);
@@ -1496,63 +1842,63 @@ var RbtApi = /*#__PURE__*/function () {
1496
1842
  }
1497
1843
 
1498
1844
  // Create the loading promise and store it to prevent duplicate requests
1499
- loadPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
1845
+ loadPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
1500
1846
  var _enableRealtime, _queryParams, res, _obj2, _setLogKey;
1501
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1502
- while (1) switch (_context23.prev = _context23.next) {
1847
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
1848
+ while (1) switch (_context27.prev = _context27.next) {
1503
1849
  case 0:
1504
- _context23.prev = 0;
1850
+ _context27.prev = 0;
1505
1851
  // Remove load-specific params that shouldn't be passed to query
1506
1852
  _enableRealtime = params.enableRealtime, _queryParams = _objectWithoutProperties(params, _excluded2);
1507
1853
  mergedParams = _objectSpread(_objectSpread({}, _queryParams), {}, {
1508
1854
  where: "id=\"".concat(ids, "\"")
1509
1855
  });
1510
- _context23.next = 5;
1511
- return _this8.query(type, mergedParams);
1856
+ _context27.next = 5;
1857
+ return _this9.query(type, mergedParams);
1512
1858
  case 5:
1513
- res = _context23.sent;
1859
+ res = _context27.sent;
1514
1860
  _obj2 = res[0];
1515
1861
  if (_obj2) {
1516
1862
  // Cache the loaded object
1517
- _this8._objectCache.set(_cacheKey3, _obj2);
1863
+ _this9._objectCache.set(_cacheKey3, _obj2);
1518
1864
 
1519
1865
  // Only log cache set once per object to reduce spam
1520
1866
  _setLogKey = "set:".concat(_cacheKey3);
1521
- if (!_this8._loggedCacheEvents.has(_setLogKey)) {
1522
- _this8._loggedCacheEvents.add(_setLogKey);
1867
+ if (!_this9._loggedCacheEvents.has(_setLogKey)) {
1868
+ _this9._loggedCacheEvents.add(_setLogKey);
1523
1869
  }
1524
1870
  }
1525
- return _context23.abrupt("return", _obj2);
1871
+ return _context27.abrupt("return", _obj2);
1526
1872
  case 9:
1527
- _context23.prev = 9;
1873
+ _context27.prev = 9;
1528
1874
  // Remove from pending loads
1529
- _this8._pendingLoads["delete"](pendingKey);
1530
- return _context23.finish(9);
1875
+ _this9._pendingLoads["delete"](pendingKey);
1876
+ return _context27.finish(9);
1531
1877
  case 12:
1532
1878
  case "end":
1533
- return _context23.stop();
1879
+ return _context27.stop();
1534
1880
  }
1535
- }, _callee23, null, [[0,, 9, 12]]);
1881
+ }, _callee27, null, [[0,, 9, 12]]);
1536
1882
  }))(); // Store the promise so other concurrent requests can await it
1537
1883
  this._pendingLoads.set(pendingKey, loadPromise);
1538
- _context24.next = 43;
1884
+ _context28.next = 43;
1539
1885
  return loadPromise;
1540
1886
  case 43:
1541
- return _context24.abrupt("return", _context24.sent);
1887
+ return _context28.abrupt("return", _context28.sent);
1542
1888
  case 44:
1543
- _context24.next = 49;
1889
+ _context28.next = 49;
1544
1890
  break;
1545
1891
  case 46:
1546
- _context24.prev = 46;
1547
- _context24.t0 = _context24["catch"](2);
1548
- return _context24.abrupt("return", this._handleError(_context24.t0));
1892
+ _context28.prev = 46;
1893
+ _context28.t0 = _context28["catch"](2);
1894
+ return _context28.abrupt("return", this._handleError(_context28.t0));
1549
1895
  case 49:
1550
1896
  case "end":
1551
- return _context24.stop();
1897
+ return _context28.stop();
1552
1898
  }
1553
- }, _callee24, this, [[2, 46]]);
1899
+ }, _callee28, this, [[2, 46]]);
1554
1900
  }));
1555
- function load(_x14, _x15) {
1901
+ function load(_x16, _x17) {
1556
1902
  return _load.apply(this, arguments);
1557
1903
  }
1558
1904
  return load;
@@ -1628,11 +1974,11 @@ var RbtApi = /*#__PURE__*/function () {
1628
1974
  }, {
1629
1975
  key: "getCacheStatus",
1630
1976
  value: function getCacheStatus() {
1631
- var cacheEntries = Array.from(this._objectCache.entries()).map(function (_ref6) {
1977
+ var cacheEntries = Array.from(this._objectCache.entries()).map(function (_ref7) {
1632
1978
  var _obj$_internalData;
1633
- var _ref7 = _slicedToArray(_ref6, 2),
1634
- key = _ref7[0],
1635
- obj = _ref7[1];
1979
+ var _ref8 = _slicedToArray(_ref7, 2),
1980
+ key = _ref8[0],
1981
+ obj = _ref8[1];
1636
1982
  return {
1637
1983
  key: key,
1638
1984
  id: obj.id,
@@ -1670,7 +2016,7 @@ var RbtApi = /*#__PURE__*/function () {
1670
2016
  }, {
1671
2017
  key: "runTask",
1672
2018
  value: (function () {
1673
- var _runTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
2019
+ var _runTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
1674
2020
  var params,
1675
2021
  callbacks,
1676
2022
  onProgress,
@@ -1685,20 +2031,20 @@ var RbtApi = /*#__PURE__*/function () {
1685
2031
  message,
1686
2032
  output,
1687
2033
  errorResponse,
1688
- _args25 = arguments;
1689
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1690
- while (1) switch (_context25.prev = _context25.next) {
2034
+ _args29 = arguments;
2035
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2036
+ while (1) switch (_context29.prev = _context29.next) {
1691
2037
  case 0:
1692
- params = _args25.length > 0 && _args25[0] !== undefined ? _args25[0] : {};
1693
- callbacks = _args25.length > 1 && _args25[1] !== undefined ? _args25[1] : {};
2038
+ params = _args29.length > 0 && _args29[0] !== undefined ? _args29[0] : {};
2039
+ callbacks = _args29.length > 1 && _args29[1] !== undefined ? _args29[1] : {};
1694
2040
  onProgress = callbacks.onProgress, onError = callbacks.onError, onStopped = callbacks.onStopped, onWaiting = callbacks.onWaiting, onDone = callbacks.onDone;
1695
- _context25.prev = 3;
1696
- _context25.next = 6;
2041
+ _context29.prev = 3;
2042
+ _context29.next = 6;
1697
2043
  return this.post('/task_service/runChain', params);
1698
2044
  case 6:
1699
- response = _context25.sent;
2045
+ response = _context29.sent;
1700
2046
  if (response) {
1701
- _context25.next = 9;
2047
+ _context29.next = 9;
1702
2048
  break;
1703
2049
  }
1704
2050
  throw new Error('Invalid server response');
@@ -1706,7 +2052,7 @@ var RbtApi = /*#__PURE__*/function () {
1706
2052
  // Validate response structure
1707
2053
  ok = response.ok, jobId = response.jobId, status = response.status, message = response.message, output = response.output;
1708
2054
  if (!(!ok || typeof jobId !== 'string' || typeof status !== 'string')) {
1709
- _context25.next = 12;
2055
+ _context29.next = 12;
1710
2056
  break;
1711
2057
  }
1712
2058
  throw new Error('Invalid response structure');
@@ -1732,7 +2078,7 @@ var RbtApi = /*#__PURE__*/function () {
1732
2078
  //console.log('Finish (request) ',response); s
1733
2079
  onDone(response);
1734
2080
  }
1735
- return _context25.abrupt("return", {
2081
+ return _context29.abrupt("return", {
1736
2082
  ok: ok,
1737
2083
  jobId: jobId,
1738
2084
  status: status,
@@ -1740,21 +2086,21 @@ var RbtApi = /*#__PURE__*/function () {
1740
2086
  output: output
1741
2087
  });
1742
2088
  case 20:
1743
- _context25.prev = 20;
1744
- _context25.t0 = _context25["catch"](3);
2089
+ _context29.prev = 20;
2090
+ _context29.t0 = _context29["catch"](3);
1745
2091
  // Standardize error format to match task response object
1746
2092
  // Support RbtError format with label and message
1747
2093
  errorResponse = {
1748
2094
  ok: false,
1749
2095
  jobId: null,
1750
2096
  status: 'ERROR',
1751
- message: _context25.t0.message || _context25.t0.toString() || 'Unknown error',
1752
- label: _context25.t0.label || _context25.t0.name || 'Error',
2097
+ message: _context29.t0.message || _context29.t0.toString() || 'Unknown error',
2098
+ label: _context29.t0.label || _context29.t0.name || 'Error',
1753
2099
  output: {
1754
- error: _context25.t0.message,
1755
- label: _context25.t0.label,
1756
- stack: _context25.t0.stack,
1757
- originalError: _context25.t0
2100
+ error: _context29.t0.message,
2101
+ label: _context29.t0.label,
2102
+ stack: _context29.t0.stack,
2103
+ originalError: _context29.t0
1758
2104
  }
1759
2105
  };
1760
2106
  if (typeof onError === 'function') {
@@ -1762,12 +2108,12 @@ var RbtApi = /*#__PURE__*/function () {
1762
2108
  } else {
1763
2109
  console.error('Error in runTask:', errorResponse.message);
1764
2110
  }
1765
- return _context25.abrupt("return", errorResponse);
2111
+ return _context29.abrupt("return", errorResponse);
1766
2112
  case 25:
1767
2113
  case "end":
1768
- return _context25.stop();
2114
+ return _context29.stop();
1769
2115
  }
1770
- }, _callee25, this, [[3, 20]]);
2116
+ }, _callee29, this, [[3, 20]]);
1771
2117
  }));
1772
2118
  function runTask() {
1773
2119
  return _runTask.apply(this, arguments);
@@ -1777,37 +2123,37 @@ var RbtApi = /*#__PURE__*/function () {
1777
2123
  }, {
1778
2124
  key: "stopJob",
1779
2125
  value: function () {
1780
- var _stopJob = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
2126
+ var _stopJob = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
1781
2127
  var params,
1782
2128
  callbacks,
1783
2129
  response,
1784
- _args26 = arguments;
1785
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
1786
- while (1) switch (_context26.prev = _context26.next) {
2130
+ _args30 = arguments;
2131
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2132
+ while (1) switch (_context30.prev = _context30.next) {
1787
2133
  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;
2134
+ params = _args30.length > 0 && _args30[0] !== undefined ? _args30[0] : {};
2135
+ callbacks = _args30.length > 1 && _args30[1] !== undefined ? _args30[1] : {};
2136
+ _context30.prev = 2;
2137
+ _context30.next = 5;
1792
2138
  return this.post('/task_service/stopJob', params);
1793
2139
  case 5:
1794
- response = _context26.sent;
2140
+ response = _context30.sent;
1795
2141
  if (response) {
1796
- _context26.next = 8;
2142
+ _context30.next = 8;
1797
2143
  break;
1798
2144
  }
1799
2145
  throw new Error('Invalid server response');
1800
2146
  case 8:
1801
- return _context26.abrupt("return", true);
2147
+ return _context30.abrupt("return", true);
1802
2148
  case 11:
1803
- _context26.prev = 11;
1804
- _context26.t0 = _context26["catch"](2);
2149
+ _context30.prev = 11;
2150
+ _context30.t0 = _context30["catch"](2);
1805
2151
  throw 'Error in stopJob';
1806
2152
  case 14:
1807
2153
  case "end":
1808
- return _context26.stop();
2154
+ return _context30.stop();
1809
2155
  }
1810
- }, _callee26, this, [[2, 11]]);
2156
+ }, _callee30, this, [[2, 11]]);
1811
2157
  }));
1812
2158
  function stopJob() {
1813
2159
  return _stopJob.apply(this, arguments);
@@ -1855,26 +2201,26 @@ var RbtApi = /*#__PURE__*/function () {
1855
2201
  }, {
1856
2202
  key: "pollTaskProgress",
1857
2203
  value: (function () {
1858
- var _pollTaskProgress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(jobId, callbacks) {
1859
- var _this9 = this;
2204
+ var _pollTaskProgress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(jobId, callbacks) {
2205
+ var _this10 = this;
1860
2206
  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) {
2207
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2208
+ while (1) switch (_context32.prev = _context32.next) {
1863
2209
  case 0:
1864
2210
  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;
2211
+ _context32.prev = 1;
1866
2212
  checkProgress = /*#__PURE__*/function () {
1867
- var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
2213
+ var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
1868
2214
  var response;
1869
- return _regeneratorRuntime().wrap(function _callee27$(_context27) {
1870
- while (1) switch (_context27.prev = _context27.next) {
2215
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2216
+ while (1) switch (_context31.prev = _context31.next) {
1871
2217
  case 0:
1872
- _context27.next = 2;
1873
- return _this9.get("/task_service/pollChainProgress", {
2218
+ _context31.next = 2;
2219
+ return _this10.get("/task_service/pollChainProgress", {
1874
2220
  jobId: jobId
1875
2221
  });
1876
2222
  case 2:
1877
- response = _context27.sent;
2223
+ response = _context31.sent;
1878
2224
  // If the task is still in progress, start polling for updates
1879
2225
  if (response.status === 'DONE' && onDone) {
1880
2226
  // Provide the current progress to the callback function
@@ -1883,7 +2229,7 @@ var RbtApi = /*#__PURE__*/function () {
1883
2229
  }
1884
2230
  if (response.status === 'ERROR' && onError) {
1885
2231
  // Normalize error response to have consistent message/label at top level
1886
- onError(_this9._normalizeErrorResponse(response));
2232
+ onError(_this10._normalizeErrorResponse(response));
1887
2233
  }
1888
2234
  if (response.status === 'STOPPED' && onStopped) {
1889
2235
  // Provide the current progress to the callback function
@@ -1905,28 +2251,28 @@ var RbtApi = /*#__PURE__*/function () {
1905
2251
  }
1906
2252
  case 9:
1907
2253
  case "end":
1908
- return _context27.stop();
2254
+ return _context31.stop();
1909
2255
  }
1910
- }, _callee27);
2256
+ }, _callee31);
1911
2257
  }));
1912
2258
  return function checkProgress() {
1913
- return _ref8.apply(this, arguments);
2259
+ return _ref9.apply(this, arguments);
1914
2260
  };
1915
2261
  }();
1916
2262
  checkProgress();
1917
- _context28.next = 9;
2263
+ _context32.next = 9;
1918
2264
  break;
1919
2265
  case 6:
1920
- _context28.prev = 6;
1921
- _context28.t0 = _context28["catch"](1);
1922
- return _context28.abrupt("return", this._handleError(_context28.t0));
2266
+ _context32.prev = 6;
2267
+ _context32.t0 = _context32["catch"](1);
2268
+ return _context32.abrupt("return", this._handleError(_context32.t0));
1923
2269
  case 9:
1924
2270
  case "end":
1925
- return _context28.stop();
2271
+ return _context32.stop();
1926
2272
  }
1927
- }, _callee28, this, [[1, 6]]);
2273
+ }, _callee32, this, [[1, 6]]);
1928
2274
  }));
1929
- function pollTaskProgress(_x16, _x17) {
2275
+ function pollTaskProgress(_x18, _x19) {
1930
2276
  return _pollTaskProgress.apply(this, arguments);
1931
2277
  }
1932
2278
  return pollTaskProgress;
@@ -1947,18 +2293,18 @@ var RbtApi = /*#__PURE__*/function () {
1947
2293
  }, {
1948
2294
  key: "get",
1949
2295
  value: (function () {
1950
- var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(endpoint) {
2296
+ var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(endpoint) {
1951
2297
  var params,
1952
2298
  customHeaders,
1953
2299
  config,
1954
2300
  response,
1955
- _args29 = arguments;
1956
- return _regeneratorRuntime().wrap(function _callee29$(_context29) {
1957
- while (1) switch (_context29.prev = _context29.next) {
2301
+ _args33 = arguments;
2302
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
2303
+ while (1) switch (_context33.prev = _context33.next) {
1958
2304
  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;
2305
+ params = _args33.length > 1 && _args33[1] !== undefined ? _args33[1] : {};
2306
+ customHeaders = _args33.length > 2 && _args33[2] !== undefined ? _args33[2] : null;
2307
+ _context33.prev = 2;
1962
2308
  // Build request config
1963
2309
  config = {
1964
2310
  params: params
@@ -1973,28 +2319,28 @@ var RbtApi = /*#__PURE__*/function () {
1973
2319
  // Otherwise, don't set config.headers at all - let axios use its defaults
1974
2320
 
1975
2321
  // Make the GET request using Axios
1976
- _context29.next = 7;
2322
+ _context33.next = 7;
1977
2323
  return this.axios.get(endpoint, config);
1978
2324
  case 7:
1979
- response = _context29.sent;
2325
+ response = _context33.sent;
1980
2326
  if (!(response.data.ok === false)) {
1981
- _context29.next = 10;
2327
+ _context33.next = 10;
1982
2328
  break;
1983
2329
  }
1984
- return _context29.abrupt("return", this._handleError(response));
2330
+ return _context33.abrupt("return", this._handleError(response));
1985
2331
  case 10:
1986
- return _context29.abrupt("return", response.data);
2332
+ return _context33.abrupt("return", response.data);
1987
2333
  case 13:
1988
- _context29.prev = 13;
1989
- _context29.t0 = _context29["catch"](2);
1990
- return _context29.abrupt("return", this._handleError(_context29.t0));
2334
+ _context33.prev = 13;
2335
+ _context33.t0 = _context33["catch"](2);
2336
+ return _context33.abrupt("return", this._handleError(_context33.t0));
1991
2337
  case 16:
1992
2338
  case "end":
1993
- return _context29.stop();
2339
+ return _context33.stop();
1994
2340
  }
1995
- }, _callee29, this, [[2, 13]]);
2341
+ }, _callee33, this, [[2, 13]]);
1996
2342
  }));
1997
- function get(_x18) {
2343
+ function get(_x20) {
1998
2344
  return _get.apply(this, arguments);
1999
2345
  }
2000
2346
  return get;
@@ -2015,44 +2361,44 @@ var RbtApi = /*#__PURE__*/function () {
2015
2361
  }, {
2016
2362
  key: "post",
2017
2363
  value: (function () {
2018
- var _post = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(endpoint) {
2364
+ var _post = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(endpoint) {
2019
2365
  var data,
2020
2366
  headers,
2021
2367
  response,
2022
- _args30 = arguments;
2023
- return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2024
- while (1) switch (_context30.prev = _context30.next) {
2368
+ _args34 = arguments;
2369
+ return _regeneratorRuntime().wrap(function _callee34$(_context34) {
2370
+ while (1) switch (_context34.prev = _context34.next) {
2025
2371
  case 0:
2026
- data = _args30.length > 1 && _args30[1] !== undefined ? _args30[1] : {};
2027
- _context30.prev = 1;
2372
+ data = _args34.length > 1 && _args34[1] !== undefined ? _args34[1] : {};
2373
+ _context34.prev = 1;
2028
2374
  // Add the authToken to the headers
2029
2375
  headers = {
2030
2376
  authtoken: this.authtoken
2031
2377
  }; // Make the POST request using Axios
2032
- _context30.next = 5;
2378
+ _context34.next = 5;
2033
2379
  return this.axios.post(endpoint, data, {
2034
2380
  headers: headers
2035
2381
  });
2036
2382
  case 5:
2037
- response = _context30.sent;
2383
+ response = _context34.sent;
2038
2384
  if (!(response.data.ok === false)) {
2039
- _context30.next = 8;
2385
+ _context34.next = 8;
2040
2386
  break;
2041
2387
  }
2042
- return _context30.abrupt("return", this._handleError(response));
2388
+ return _context34.abrupt("return", this._handleError(response));
2043
2389
  case 8:
2044
- return _context30.abrupt("return", response.data);
2390
+ return _context34.abrupt("return", response.data);
2045
2391
  case 11:
2046
- _context30.prev = 11;
2047
- _context30.t0 = _context30["catch"](1);
2048
- return _context30.abrupt("return", this._handleError(_context30.t0));
2392
+ _context34.prev = 11;
2393
+ _context34.t0 = _context34["catch"](1);
2394
+ return _context34.abrupt("return", this._handleError(_context34.t0));
2049
2395
  case 14:
2050
2396
  case "end":
2051
- return _context30.stop();
2397
+ return _context34.stop();
2052
2398
  }
2053
- }, _callee30, this, [[1, 11]]);
2399
+ }, _callee34, this, [[1, 11]]);
2054
2400
  }));
2055
- function post(_x19) {
2401
+ function post(_x21) {
2056
2402
  return _post.apply(this, arguments);
2057
2403
  }
2058
2404
  return post;