roboto-js 3.0.0 → 3.0.2

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.
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = void 0;
7
7
  var _axios = _interopRequireDefault(require("axios"));
8
- var _cryptoJs = _interopRequireDefault(require("crypto-js"));
9
8
  var _rbt_object = _interopRequireDefault(require("./rbt_object.cjs"));
10
9
  var _rbt_user = _interopRequireDefault(require("./rbt_user.cjs"));
11
10
  var _rbt_file = _interopRequireDefault(require("./rbt_file.cjs"));
@@ -35,6 +34,29 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
35
34
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
36
35
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
37
36
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
37
+ /** IAC working org preference lives under module-scoped settings (`mod.iac`). Legacy reads still honor `mod.currentOrgId`. */
38
+ var USER_MOD_CURRENT_ORG_IAC = 'mod.iac.currentOrgId';
39
+ var USER_MOD_CURRENT_ORG_LEGACY = 'mod.currentOrgId';
40
+
41
+ /** @param {import('./rbt_user.cjs').default|null|undefined} user */
42
+ function readUserCurrentOrgPreference(user) {
43
+ var _$get;
44
+ if (!user || typeof user.get !== 'function') return '';
45
+ var v = user.get(USER_MOD_CURRENT_ORG_IAC);
46
+ if (v != null && String(v).trim() !== '') return String(v).trim();
47
+ v = user.get(USER_MOD_CURRENT_ORG_LEGACY);
48
+ if (v != null && String(v).trim() !== '') return String(v).trim();
49
+ var d = typeof user.getData === 'function' ? user.getData() : {};
50
+ v = (_$get = _lodash["default"].get(d, 'mod.iac.currentOrgId')) !== null && _$get !== void 0 ? _$get : _lodash["default"].get(d, 'mod.currentOrgId');
51
+ if (v != null && String(v).trim() !== '') return String(v).trim();
52
+ return '';
53
+ }
54
+
55
+ /** @param {import('./rbt_user.cjs').default} user */
56
+ function persistUserCurrentOrgPreference(user, orgId) {
57
+ if (!(user !== null && user !== void 0 && user.set) || orgId == null || String(orgId).trim() === '') return;
58
+ user.set(USER_MOD_CURRENT_ORG_IAC, String(orgId).trim());
59
+ }
38
60
  var RbtApi = exports["default"] = /*#__PURE__*/function () {
39
61
  function RbtApi(_ref) {
40
62
  var baseUrl = _ref.baseUrl,
@@ -476,14 +498,11 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
476
498
  case 0:
477
499
  _context6.prev = 0;
478
500
  _context6.next = 3;
479
- return this.axios.post('/api/iac/loginUser', [{
501
+ return this.axios.post('/api/iac/login', {
480
502
  email: params.email,
481
- password: params.password ? _cryptoJs["default"].MD5(params.password).toString(_cryptoJs["default"].enc.Hex) : null,
482
- // legacy hash password (md5)
483
- passwd: params.password || null,
484
- // current password
485
- code: params.code || null // single-use signon code (password resets)
486
- }]);
503
+ password: params.password || null,
504
+ code: params.code || null
505
+ });
487
506
  case 3:
488
507
  response = _context6.sent;
489
508
  if (!(response.data.ok === false)) {
@@ -744,94 +763,254 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
744
763
  }
745
764
  return loadCurrentUser;
746
765
  }()
766
+ /**
767
+ * Confirm email with either legacy composite string or { email, code } (6-digit from mod-iac-flows).
768
+ * @param {string|{ email: string, code: string }|{ emailConfirmCode: string }} confirmCodeOrParams
769
+ */
747
770
  }, {
748
771
  key: "confirmUserEmail",
749
- value: function () {
750
- var _confirmUserEmail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(confirmCode) {
751
- var params, response;
772
+ value: (function () {
773
+ var _confirmUserEmail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(confirmCodeOrParams) {
774
+ var params, email, code, emailConfirmCode, err, _err, response;
752
775
  return _regeneratorRuntime().wrap(function _callee11$(_context11) {
753
776
  while (1) switch (_context11.prev = _context11.next) {
754
777
  case 0:
778
+ if (!(typeof confirmCodeOrParams === 'string')) {
779
+ _context11.next = 4;
780
+ break;
781
+ }
755
782
  params = {
756
- emailConfirmCode: confirmCode
783
+ emailConfirmCode: confirmCodeOrParams
757
784
  };
758
- _context11.prev = 1;
759
- _context11.next = 4;
760
- return this.axios.post('/api/iac/confirmUserEmail', [params]);
785
+ _context11.next = 20;
786
+ break;
761
787
  case 4:
788
+ if (!(confirmCodeOrParams && _typeof(confirmCodeOrParams) === 'object')) {
789
+ _context11.next = 18;
790
+ break;
791
+ }
792
+ email = confirmCodeOrParams.email, code = confirmCodeOrParams.code, emailConfirmCode = confirmCodeOrParams.emailConfirmCode;
793
+ if (!(email && code != null && String(code).length > 0)) {
794
+ _context11.next = 10;
795
+ break;
796
+ }
797
+ params = {
798
+ email: email,
799
+ code: String(code)
800
+ };
801
+ _context11.next = 16;
802
+ break;
803
+ case 10:
804
+ if (!emailConfirmCode) {
805
+ _context11.next = 14;
806
+ break;
807
+ }
808
+ params = {
809
+ emailConfirmCode: emailConfirmCode
810
+ };
811
+ _context11.next = 16;
812
+ break;
813
+ case 14:
814
+ err = new Error('confirmUserEmail: pass a legacy string, { emailConfirmCode }, or { email, code }');
815
+ return _context11.abrupt("return", this._handleError(err));
816
+ case 16:
817
+ _context11.next = 20;
818
+ break;
819
+ case 18:
820
+ _err = new Error('confirmUserEmail: invalid argument');
821
+ return _context11.abrupt("return", this._handleError(_err));
822
+ case 20:
823
+ _context11.prev = 20;
824
+ _context11.next = 23;
825
+ return this.axios.post('/api/iac/confirmUserEmail', [params]);
826
+ case 23:
762
827
  response = _context11.sent;
763
828
  if (!(response.data.ok === false)) {
764
- _context11.next = 7;
829
+ _context11.next = 26;
765
830
  break;
766
831
  }
767
832
  return _context11.abrupt("return", this._handleError(response));
768
- case 7:
833
+ case 26:
769
834
  return _context11.abrupt("return", response.data);
770
- case 10:
771
- _context11.prev = 10;
772
- _context11.t0 = _context11["catch"](1);
835
+ case 29:
836
+ _context11.prev = 29;
837
+ _context11.t0 = _context11["catch"](20);
773
838
  return _context11.abrupt("return", this._handleError(_context11.t0));
774
- case 13:
839
+ case 32:
775
840
  case "end":
776
841
  return _context11.stop();
777
842
  }
778
- }, _callee11, this, [[1, 10]]);
843
+ }, _callee11, this, [[20, 29]]);
779
844
  }));
780
845
  function confirmUserEmail(_x6) {
781
846
  return _confirmUserEmail.apply(this, arguments);
782
847
  }
783
848
  return confirmUserEmail;
849
+ }() /** Password reset email — use mod-iac-flows (not deprecated /api/iac/sendPasswordReset). */)
850
+ }, {
851
+ key: "sendResetEmailViaFlows",
852
+ value: (function () {
853
+ var _sendResetEmailViaFlows = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(email) {
854
+ var response;
855
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
856
+ while (1) switch (_context12.prev = _context12.next) {
857
+ case 0:
858
+ _context12.next = 2;
859
+ return this.axios.post('/api/iac-flows/sendResetEmail', {
860
+ email: email
861
+ });
862
+ case 2:
863
+ response = _context12.sent;
864
+ return _context12.abrupt("return", response.data);
865
+ case 4:
866
+ case "end":
867
+ return _context12.stop();
868
+ }
869
+ }, _callee12, this);
870
+ }));
871
+ function sendResetEmailViaFlows(_x7) {
872
+ return _sendResetEmailViaFlows.apply(this, arguments);
873
+ }
874
+ return sendResetEmailViaFlows;
875
+ }())
876
+ }, {
877
+ key: "sendRegistrationVerificationEmail",
878
+ value: function () {
879
+ var _sendRegistrationVerificationEmail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(email) {
880
+ var response;
881
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
882
+ while (1) switch (_context13.prev = _context13.next) {
883
+ case 0:
884
+ _context13.next = 2;
885
+ return this.axios.post('/api/iac-flows/sendRegistrationVerification', {
886
+ email: email
887
+ });
888
+ case 2:
889
+ response = _context13.sent;
890
+ return _context13.abrupt("return", response.data);
891
+ case 4:
892
+ case "end":
893
+ return _context13.stop();
894
+ }
895
+ }, _callee13, this);
896
+ }));
897
+ function sendRegistrationVerificationEmail(_x8) {
898
+ return _sendRegistrationVerificationEmail.apply(this, arguments);
899
+ }
900
+ return sendRegistrationVerificationEmail;
901
+ }()
902
+ }, {
903
+ key: "resendRegistrationCode",
904
+ value: function () {
905
+ var _resendRegistrationCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(email) {
906
+ var response;
907
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
908
+ while (1) switch (_context14.prev = _context14.next) {
909
+ case 0:
910
+ _context14.next = 2;
911
+ return this.axios.post('/api/iac-flows/resendRegistrationCode', {
912
+ email: email
913
+ });
914
+ case 2:
915
+ response = _context14.sent;
916
+ return _context14.abrupt("return", response.data);
917
+ case 4:
918
+ case "end":
919
+ return _context14.stop();
920
+ }
921
+ }, _callee14, this);
922
+ }));
923
+ function resendRegistrationCode(_x9) {
924
+ return _resendRegistrationCode.apply(this, arguments);
925
+ }
926
+ return resendRegistrationCode;
927
+ }()
928
+ }, {
929
+ key: "completePasswordReset",
930
+ value: function () {
931
+ var _completePasswordReset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(_ref3) {
932
+ var _response$data;
933
+ var email, code, newPassword, response;
934
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
935
+ while (1) switch (_context15.prev = _context15.next) {
936
+ case 0:
937
+ email = _ref3.email, code = _ref3.code, newPassword = _ref3.newPassword;
938
+ _context15.next = 3;
939
+ return this.axios.post('/api/iac/completePasswordReset', [{
940
+ email: email,
941
+ code: code,
942
+ newPassword: newPassword
943
+ }]);
944
+ case 3:
945
+ response = _context15.sent;
946
+ if (!(((_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.ok) === false)) {
947
+ _context15.next = 6;
948
+ break;
949
+ }
950
+ return _context15.abrupt("return", this._handleError(response));
951
+ case 6:
952
+ return _context15.abrupt("return", response.data);
953
+ case 7:
954
+ case "end":
955
+ return _context15.stop();
956
+ }
957
+ }, _callee15, this);
958
+ }));
959
+ function completePasswordReset(_x10) {
960
+ return _completePasswordReset.apply(this, arguments);
961
+ }
962
+ return completePasswordReset;
784
963
  }()
785
964
  }, {
786
965
  key: "loadCurrentUserExtended",
787
966
  value: function () {
788
- var _loadCurrentUserExtended = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
967
+ var _loadCurrentUserExtended = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
789
968
  var _this3 = this;
790
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
791
- while (1) switch (_context13.prev = _context13.next) {
969
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
970
+ while (1) switch (_context17.prev = _context17.next) {
792
971
  case 0:
793
972
  if (!this._loadCurrentUserExtendedPromise) {
794
- _context13.next = 2;
973
+ _context17.next = 2;
795
974
  break;
796
975
  }
797
- return _context13.abrupt("return", this._loadCurrentUserExtendedPromise);
976
+ return _context17.abrupt("return", this._loadCurrentUserExtendedPromise);
798
977
  case 2:
799
- this._loadCurrentUserExtendedPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
978
+ this._loadCurrentUserExtendedPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
800
979
  var currentUser;
801
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
802
- while (1) switch (_context12.prev = _context12.next) {
980
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
981
+ while (1) switch (_context16.prev = _context16.next) {
803
982
  case 0:
804
- _context12.next = 2;
983
+ _context16.next = 2;
805
984
  return _this3.loadCurrentUser();
806
985
  case 2:
807
- currentUser = _context12.sent;
986
+ currentUser = _context16.sent;
808
987
  if (!currentUser) {
809
- _context12.next = 7;
988
+ _context16.next = 7;
810
989
  break;
811
990
  }
812
- return _context12.abrupt("return", _this3.loadUser(currentUser.id));
991
+ return _context16.abrupt("return", _this3.loadUser(currentUser.id));
813
992
  case 7:
814
- return _context12.abrupt("return", null);
993
+ return _context16.abrupt("return", null);
815
994
  case 8:
816
995
  case "end":
817
- return _context12.stop();
996
+ return _context16.stop();
818
997
  }
819
- }, _callee12);
998
+ }, _callee16);
820
999
  }))();
821
- _context13.prev = 3;
822
- _context13.next = 6;
1000
+ _context17.prev = 3;
1001
+ _context17.next = 6;
823
1002
  return this._loadCurrentUserExtendedPromise;
824
1003
  case 6:
825
- return _context13.abrupt("return", _context13.sent);
1004
+ return _context17.abrupt("return", _context17.sent);
826
1005
  case 7:
827
- _context13.prev = 7;
1006
+ _context17.prev = 7;
828
1007
  this._loadCurrentUserExtendedPromise = null;
829
- return _context13.finish(7);
1008
+ return _context17.finish(7);
830
1009
  case 10:
831
1010
  case "end":
832
- return _context13.stop();
1011
+ return _context17.stop();
833
1012
  }
834
- }, _callee13, this, [[3,, 7, 10]]);
1013
+ }, _callee17, this, [[3,, 7, 10]]);
835
1014
  }));
836
1015
  function loadCurrentUserExtended() {
837
1016
  return _loadCurrentUserExtended.apply(this, arguments);
@@ -839,127 +1018,140 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
839
1018
  return loadCurrentUserExtended;
840
1019
  }()
841
1020
  /**
842
- * Load current organization for the authenticated user
843
- * Organization is determined by:
844
- * 1. User's mod.currentOrgId preference
845
- * 2. First organization in user.organizations array
846
- * 3. null if user has no organizations
847
- *
848
- * @param {boolean} forceReload - Force reload from server even if cached
1021
+ * Load current organization for the authenticated user.
1022
+ *
1023
+ * Returns an organization **only when** `user.mod.iac.currentOrgId` is set (explicit selection via
1024
+ * `switchOrganization` / `selectCurrentOrganization`; legacy reads also accept `mod.currentOrgId`).
1025
+ * There is no fallback to “first org”; callers must guide the user to select an org first.
1026
+ *
1027
+ * @param {boolean} forceReload - Force reload from server even if cached ID matches preference
849
1028
  * @returns {Promise<RbtObject|null>} Organization object or null
850
1029
  */
851
1030
  }, {
852
1031
  key: "loadCurrentOrganization",
853
1032
  value: (function () {
854
- var _loadCurrentOrganization = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
1033
+ var _loadCurrentOrganization = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
855
1034
  var _this4 = this;
856
1035
  var forceReload,
857
1036
  result,
858
- _args15 = arguments;
859
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
860
- while (1) switch (_context15.prev = _context15.next) {
1037
+ _args19 = arguments;
1038
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1039
+ while (1) switch (_context19.prev = _context19.next) {
861
1040
  case 0:
862
- forceReload = _args15.length > 0 && _args15[0] !== undefined ? _args15[0] : false;
863
- _context15.prev = 1;
864
- if (!(this.currentOrganization && !forceReload)) {
865
- _context15.next = 4;
866
- break;
867
- }
868
- return _context15.abrupt("return", this.currentOrganization);
869
- case 4:
1041
+ forceReload = _args19.length > 0 && _args19[0] !== undefined ? _args19[0] : false;
1042
+ _context19.prev = 1;
870
1043
  if (!this._loadCurrentOrgPromise) {
871
- _context15.next = 6;
1044
+ _context19.next = 4;
872
1045
  break;
873
1046
  }
874
- return _context15.abrupt("return", this._loadCurrentOrgPromise);
875
- case 6:
876
- this._loadCurrentOrgPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
877
- var _userData$organizatio, _userData$mod, user, userData, firstOrg, orgId, cachedOrgId, org;
878
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
879
- while (1) switch (_context14.prev = _context14.next) {
1047
+ return _context19.abrupt("return", this._loadCurrentOrgPromise);
1048
+ case 4:
1049
+ this._loadCurrentOrgPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1050
+ var user, orgId, cachedOrgId, org;
1051
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1052
+ while (1) switch (_context18.prev = _context18.next) {
880
1053
  case 0:
881
- _context14.prev = 0;
882
- _context14.next = 3;
1054
+ _context18.prev = 0;
1055
+ _context18.next = 3;
883
1056
  return _this4.loadCurrentUser();
884
1057
  case 3:
885
- user = _context14.sent;
1058
+ user = _context18.sent;
886
1059
  if (user) {
887
- _context14.next = 6;
1060
+ _context18.next = 7;
888
1061
  break;
889
1062
  }
890
- return _context14.abrupt("return", null);
891
- case 6:
892
- // Get organization ID from user preferences or first org
893
- userData = user.getData(); // organizations array format: [{ id: 'org123', roles: ['owner'] }, ...]
894
- firstOrg = (_userData$organizatio = userData.organizations) === null || _userData$organizatio === void 0 ? void 0 : _userData$organizatio[0];
895
- 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);
1063
+ _this4.currentOrganization = null;
1064
+ return _context18.abrupt("return", null);
1065
+ case 7:
1066
+ orgId = readUserCurrentOrgPreference(user);
896
1067
  if (orgId) {
897
- _context14.next = 11;
1068
+ _context18.next = 19;
898
1069
  break;
899
1070
  }
900
- return _context14.abrupt("return", null);
901
- case 11:
1071
+ //console.log('[RbtApi] No current organization selected (mod.iac.currentOrgId unset)');
1072
+ _this4.currentOrganization = null;
902
1073
  if (!_this4.localStorageAdaptor) {
903
- _context14.next = 16;
1074
+ _context18.next = 18;
904
1075
  break;
905
1076
  }
906
- _context14.next = 14;
907
- return _this4.localStorageAdaptor.getItem('currentOrgId');
1077
+ _context18.prev = 11;
1078
+ _context18.next = 14;
1079
+ return _this4.localStorageAdaptor.removeItem('currentOrgId');
908
1080
  case 14:
909
- cachedOrgId = _context14.sent;
910
- if (cachedOrgId && cachedOrgId !== orgId) {}
1081
+ _context18.next = 18;
1082
+ break;
911
1083
  case 16:
912
- _context14.next = 18;
913
- return _this4.get('<@iac.organization>', orgId);
1084
+ _context18.prev = 16;
1085
+ _context18.t0 = _context18["catch"](11);
914
1086
  case 18:
915
- org = _context14.sent;
1087
+ return _context18.abrupt("return", null);
1088
+ case 19:
1089
+ if (!(!forceReload && _this4.currentOrganization && String(_this4.currentOrganization.id) === orgId)) {
1090
+ _context18.next = 21;
1091
+ break;
1092
+ }
1093
+ return _context18.abrupt("return", _this4.currentOrganization);
1094
+ case 21:
1095
+ if (!_this4.localStorageAdaptor) {
1096
+ _context18.next = 26;
1097
+ break;
1098
+ }
1099
+ _context18.next = 24;
1100
+ return _this4.localStorageAdaptor.getItem('currentOrgId');
1101
+ case 24:
1102
+ cachedOrgId = _context18.sent;
1103
+ if (cachedOrgId && cachedOrgId !== orgId) {}
1104
+ case 26:
1105
+ _context18.next = 28;
1106
+ return _this4.load('<@iac.organization>', orgId);
1107
+ case 28:
1108
+ org = _context18.sent;
916
1109
  if (!org) {
917
- _context14.next = 26;
1110
+ _context18.next = 36;
918
1111
  break;
919
1112
  }
920
- _this4.currentOrganization = org; // Already an RbtObject
921
- //console.log('[RbtApi] Current organization loaded:', org.get('name'));
922
-
923
- // Cache in storage if available
1113
+ _this4.currentOrganization = org;
924
1114
  if (!_this4.localStorageAdaptor) {
925
- _context14.next = 24;
1115
+ _context18.next = 34;
926
1116
  break;
927
1117
  }
928
- _context14.next = 24;
1118
+ _context18.next = 34;
929
1119
  return _this4.localStorageAdaptor.setItem('currentOrgId', orgId);
930
- case 24:
931
- _context14.next = 26;
1120
+ case 34:
1121
+ _context18.next = 37;
932
1122
  break;
933
- case 26:
934
- return _context14.abrupt("return", _this4.currentOrganization);
935
- case 29:
936
- _context14.prev = 29;
937
- _context14.t0 = _context14["catch"](0);
938
- console.error('[RbtApi] Failed to load current organization:', _context14.t0);
1123
+ case 36:
939
1124
  _this4.currentOrganization = null;
940
- return _context14.abrupt("return", null);
941
- case 34:
1125
+ case 37:
1126
+ return _context18.abrupt("return", _this4.currentOrganization);
1127
+ case 40:
1128
+ _context18.prev = 40;
1129
+ _context18.t1 = _context18["catch"](0);
1130
+ console.error('[RbtApi] Failed to load current organization:', _context18.t1);
1131
+ _this4.currentOrganization = null;
1132
+ return _context18.abrupt("return", null);
1133
+ case 45:
942
1134
  case "end":
943
- return _context14.stop();
1135
+ return _context18.stop();
944
1136
  }
945
- }, _callee14, null, [[0, 29]]);
1137
+ }, _callee18, null, [[0, 40], [11, 16]]);
946
1138
  }))();
947
- _context15.next = 9;
1139
+ _context19.next = 7;
948
1140
  return this._loadCurrentOrgPromise;
949
- case 9:
950
- result = _context15.sent;
1141
+ case 7:
1142
+ result = _context19.sent;
951
1143
  this._loadCurrentOrgPromise = null;
952
- return _context15.abrupt("return", result);
953
- case 14:
954
- _context15.prev = 14;
955
- _context15.t0 = _context15["catch"](1);
1144
+ return _context19.abrupt("return", result);
1145
+ case 12:
1146
+ _context19.prev = 12;
1147
+ _context19.t0 = _context19["catch"](1);
956
1148
  this._loadCurrentOrgPromise = null;
957
- return _context15.abrupt("return", this._handleError(_context15.t0));
958
- case 18:
1149
+ return _context19.abrupt("return", this._handleError(_context19.t0));
1150
+ case 16:
959
1151
  case "end":
960
- return _context15.stop();
1152
+ return _context19.stop();
961
1153
  }
962
- }, _callee15, this, [[1, 14]]);
1154
+ }, _callee19, this, [[1, 12]]);
963
1155
  }));
964
1156
  function loadCurrentOrganization() {
965
1157
  return _loadCurrentOrganization.apply(this, arguments);
@@ -977,24 +1169,24 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
977
1169
  }, {
978
1170
  key: "switchOrganization",
979
1171
  value: (function () {
980
- var _switchOrganization = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(orgId) {
1172
+ var _switchOrganization = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(orgId) {
981
1173
  var org, userObj;
982
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
983
- while (1) switch (_context16.prev = _context16.next) {
1174
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1175
+ while (1) switch (_context20.prev = _context20.next) {
984
1176
  case 0:
985
- _context16.prev = 0;
1177
+ _context20.prev = 0;
986
1178
  if (this.currentUser) {
987
- _context16.next = 3;
1179
+ _context20.next = 3;
988
1180
  break;
989
1181
  }
990
1182
  throw new Error('Must be logged in to switch organization');
991
1183
  case 3:
992
- _context16.next = 5;
993
- return this.get('<@iac.organization>', orgId);
1184
+ _context20.next = 5;
1185
+ return this.load('<@iac.organization>', orgId);
994
1186
  case 5:
995
- org = _context16.sent;
1187
+ org = _context20.sent;
996
1188
  if (org) {
997
- _context16.next = 8;
1189
+ _context20.next = 8;
998
1190
  break;
999
1191
  }
1000
1192
  throw new Error("Organization ".concat(orgId, " not found or not accessible"));
@@ -1002,55 +1194,59 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1002
1194
  this.currentOrganization = org;
1003
1195
 
1004
1196
  // Save preference to user
1005
- _context16.prev = 9;
1006
- _context16.next = 12;
1197
+ _context20.prev = 9;
1198
+ _context20.next = 12;
1007
1199
  return this.loadUser(this.currentUser.id);
1008
1200
  case 12:
1009
- userObj = _context16.sent;
1010
- userObj.set('mod.currentOrgId', orgId);
1011
- _context16.next = 16;
1201
+ userObj = _context20.sent;
1202
+ persistUserCurrentOrgPreference(userObj, orgId);
1203
+ _context20.next = 16;
1012
1204
  return userObj.save();
1013
1205
  case 16:
1014
1206
  if (!this.localStorageAdaptor) {
1015
- _context16.next = 19;
1207
+ _context20.next = 19;
1016
1208
  break;
1017
1209
  }
1018
- _context16.next = 19;
1210
+ _context20.next = 19;
1019
1211
  return this.localStorageAdaptor.setItem('currentOrgId', orgId);
1020
1212
  case 19:
1021
- _context16.next = 23;
1213
+ _context20.next = 23;
1022
1214
  break;
1023
1215
  case 21:
1024
- _context16.prev = 21;
1025
- _context16.t0 = _context16["catch"](9);
1216
+ _context20.prev = 21;
1217
+ _context20.t0 = _context20["catch"](9);
1026
1218
  case 23:
1027
- return _context16.abrupt("return", org);
1219
+ return _context20.abrupt("return", org);
1028
1220
  case 26:
1029
- _context16.prev = 26;
1030
- _context16.t1 = _context16["catch"](0);
1031
- return _context16.abrupt("return", this._handleError(_context16.t1));
1221
+ _context20.prev = 26;
1222
+ _context20.t1 = _context20["catch"](0);
1223
+ return _context20.abrupt("return", this._handleError(_context20.t1));
1032
1224
  case 29:
1033
1225
  case "end":
1034
- return _context16.stop();
1226
+ return _context20.stop();
1035
1227
  }
1036
- }, _callee16, this, [[0, 26], [9, 21]]);
1228
+ }, _callee20, this, [[0, 26], [9, 21]]);
1037
1229
  }));
1038
- function switchOrganization(_x7) {
1230
+ function switchOrganization(_x11) {
1039
1231
  return _switchOrganization.apply(this, arguments);
1040
1232
  }
1041
1233
  return switchOrganization;
1042
1234
  }()
1043
1235
  /**
1044
- * Get current organization (null-safe)
1045
- * Returns cached organization without triggering a load
1046
- *
1047
- * @returns {RbtObject|null} Current organization or null
1236
+ * Get cached current organization (sync, null-safe).
1237
+ * Returns **null** unless `mod.iac.currentOrgId` (or legacy `mod.currentOrgId`) matches `currentOrganization`.
1048
1238
  */
1049
1239
  )
1050
1240
  }, {
1051
1241
  key: "getCurrentOrganization",
1052
1242
  value: function getCurrentOrganization() {
1053
- return this.currentOrganization;
1243
+ var org = this.currentOrganization;
1244
+ if (!org) return null;
1245
+ var user = this.currentUser;
1246
+ var selected = readUserCurrentOrgPreference(user);
1247
+ if (!selected) return null;
1248
+ if (String(org.id) !== selected) return null;
1249
+ return org;
1054
1250
  }
1055
1251
 
1056
1252
  /**
@@ -1065,48 +1261,47 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1065
1261
  }, {
1066
1262
  key: "selectCurrentOrganization",
1067
1263
  value: (function () {
1068
- var _selectCurrentOrganization = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(orgId) {
1264
+ var _selectCurrentOrganization = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(orgId) {
1069
1265
  var role,
1070
1266
  org,
1071
1267
  user,
1072
1268
  userOrgs,
1073
1269
  orgExists,
1074
- modData,
1075
- _args17 = arguments;
1076
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1077
- while (1) switch (_context17.prev = _context17.next) {
1270
+ _args21 = arguments;
1271
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1272
+ while (1) switch (_context21.prev = _context21.next) {
1078
1273
  case 0:
1079
- role = _args17.length > 1 && _args17[1] !== undefined ? _args17[1] : 'owner';
1080
- _context17.prev = 1;
1274
+ role = _args21.length > 1 && _args21[1] !== undefined ? _args21[1] : 'owner';
1275
+ _context21.prev = 1;
1081
1276
  if (this.currentUser) {
1082
- _context17.next = 7;
1277
+ _context21.next = 7;
1083
1278
  break;
1084
1279
  }
1085
- _context17.next = 5;
1280
+ _context21.next = 5;
1086
1281
  return this.loadCurrentUser();
1087
1282
  case 5:
1088
1283
  if (this.currentUser) {
1089
- _context17.next = 7;
1284
+ _context21.next = 7;
1090
1285
  break;
1091
1286
  }
1092
1287
  throw new Error('Must be logged in to select organization');
1093
1288
  case 7:
1094
- _context17.next = 9;
1095
- return this.get('<@iac.organization>', orgId);
1289
+ _context21.next = 9;
1290
+ return this.load('<@iac.organization>', orgId);
1096
1291
  case 9:
1097
- org = _context17.sent;
1292
+ org = _context21.sent;
1098
1293
  if (org) {
1099
- _context17.next = 12;
1294
+ _context21.next = 12;
1100
1295
  break;
1101
1296
  }
1102
1297
  throw new Error("Organization ".concat(orgId, " not found or not accessible"));
1103
1298
  case 12:
1104
- _context17.next = 14;
1299
+ _context21.next = 14;
1105
1300
  return this.loadUser(this.currentUser.id);
1106
1301
  case 14:
1107
- user = _context17.sent;
1302
+ user = _context21.sent;
1108
1303
  if (user) {
1109
- _context17.next = 17;
1304
+ _context21.next = 17;
1110
1305
  break;
1111
1306
  }
1112
1307
  throw new Error('Failed to load user object');
@@ -1128,16 +1323,14 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1128
1323
  //console.log('[RbtApi] Organization already in user organizations array');
1129
1324
  }
1130
1325
 
1131
- // Set as current organization preference - handle both nested path formats
1132
- modData = user.get('mod') || {};
1133
- modData.currentOrgId = orgId;
1134
- user.set('mod', modData);
1326
+ // Set current organization preference under mod.iac (module-namespaced settings)
1327
+ persistUserCurrentOrgPreference(user, orgId);
1135
1328
 
1136
1329
  // Save user record
1137
1330
  //console.log('[RbtApi] Saving user with organization:', orgId);
1138
- _context17.next = 25;
1331
+ _context21.next = 23;
1139
1332
  return user.save();
1140
- case 25:
1333
+ case 23:
1141
1334
  //console.log('[RbtApi] User saved successfully');
1142
1335
 
1143
1336
  // Clear cached organization to force reload
@@ -1151,25 +1344,25 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1151
1344
 
1152
1345
  // Update cache
1153
1346
  if (!this.localStorageAdaptor) {
1154
- _context17.next = 31;
1347
+ _context21.next = 29;
1155
1348
  break;
1156
1349
  }
1157
- _context17.next = 31;
1350
+ _context21.next = 29;
1158
1351
  return this.localStorageAdaptor.setItem('currentOrgId', orgId);
1159
- case 31:
1160
- return _context17.abrupt("return", org);
1161
- case 34:
1162
- _context17.prev = 34;
1163
- _context17.t0 = _context17["catch"](1);
1164
- console.error('[RbtApi] Error in selectCurrentOrganization:', _context17.t0);
1165
- return _context17.abrupt("return", this._handleError(_context17.t0));
1166
- case 38:
1352
+ case 29:
1353
+ return _context21.abrupt("return", org);
1354
+ case 32:
1355
+ _context21.prev = 32;
1356
+ _context21.t0 = _context21["catch"](1);
1357
+ console.error('[RbtApi] Error in selectCurrentOrganization:', _context21.t0);
1358
+ return _context21.abrupt("return", this._handleError(_context21.t0));
1359
+ case 36:
1167
1360
  case "end":
1168
- return _context17.stop();
1361
+ return _context21.stop();
1169
1362
  }
1170
- }, _callee17, this, [[1, 34]]);
1363
+ }, _callee21, this, [[1, 32]]);
1171
1364
  }));
1172
- function selectCurrentOrganization(_x8) {
1365
+ function selectCurrentOrganization(_x12) {
1173
1366
  return _selectCurrentOrganization.apply(this, arguments);
1174
1367
  }
1175
1368
  return selectCurrentOrganization;
@@ -1177,11 +1370,11 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1177
1370
  }, {
1178
1371
  key: "loadUser",
1179
1372
  value: function () {
1180
- var _loadUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(userId) {
1373
+ var _loadUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(userId) {
1181
1374
  var _this5 = this;
1182
1375
  var params, cacheKey, now, existing, p;
1183
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1184
- while (1) switch (_context19.prev = _context19.next) {
1376
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1377
+ while (1) switch (_context23.prev = _context23.next) {
1185
1378
  case 0:
1186
1379
  params = {
1187
1380
  id: userId
@@ -1190,53 +1383,53 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1190
1383
  now = Date.now();
1191
1384
  existing = this.requestCache[cacheKey];
1192
1385
  if (!(existing && now - existing.time < 10000)) {
1193
- _context19.next = 6;
1386
+ _context23.next = 6;
1194
1387
  break;
1195
1388
  }
1196
- return _context19.abrupt("return", existing.val);
1389
+ return _context23.abrupt("return", existing.val);
1197
1390
  case 6:
1198
- _context19.prev = 6;
1199
- p = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1200
- var _response$data;
1391
+ _context23.prev = 6;
1392
+ p = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
1393
+ var _response$data2;
1201
1394
  var response, userData, User;
1202
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1203
- while (1) switch (_context18.prev = _context18.next) {
1395
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1396
+ while (1) switch (_context22.prev = _context22.next) {
1204
1397
  case 0:
1205
- _context18.next = 2;
1398
+ _context22.next = 2;
1206
1399
  return _this5.axios.post('/api/iac/loadUser', [params]);
1207
1400
  case 2:
1208
- response = _context18.sent;
1209
- userData = response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.user;
1401
+ response = _context22.sent;
1402
+ userData = response === null || response === void 0 || (_response$data2 = response.data) === null || _response$data2 === void 0 ? void 0 : _response$data2.user;
1210
1403
  User = new _rbt_user["default"]({
1211
1404
  id: userData.id
1212
1405
  }, _this5.axios);
1213
1406
  User.setData(userData);
1214
- return _context18.abrupt("return", User);
1407
+ return _context22.abrupt("return", User);
1215
1408
  case 7:
1216
1409
  case "end":
1217
- return _context18.stop();
1410
+ return _context22.stop();
1218
1411
  }
1219
- }, _callee18);
1412
+ }, _callee22);
1220
1413
  }))();
1221
1414
  this.requestCache[cacheKey] = {
1222
1415
  val: p,
1223
1416
  time: now
1224
1417
  };
1225
- _context19.next = 11;
1418
+ _context23.next = 11;
1226
1419
  return p;
1227
1420
  case 11:
1228
- return _context19.abrupt("return", _context19.sent);
1421
+ return _context23.abrupt("return", _context23.sent);
1229
1422
  case 14:
1230
- _context19.prev = 14;
1231
- _context19.t0 = _context19["catch"](6);
1232
- return _context19.abrupt("return", this._handleError(_context19.t0));
1423
+ _context23.prev = 14;
1424
+ _context23.t0 = _context23["catch"](6);
1425
+ return _context23.abrupt("return", this._handleError(_context23.t0));
1233
1426
  case 17:
1234
1427
  case "end":
1235
- return _context19.stop();
1428
+ return _context23.stop();
1236
1429
  }
1237
- }, _callee19, this, [[6, 14]]);
1430
+ }, _callee23, this, [[6, 14]]);
1238
1431
  }));
1239
- function loadUser(_x9) {
1432
+ function loadUser(_x13) {
1240
1433
  return _loadUser.apply(this, arguments);
1241
1434
  }
1242
1435
  return loadUser;
@@ -1244,53 +1437,53 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1244
1437
  }, {
1245
1438
  key: "refreshAuthToken",
1246
1439
  value: function () {
1247
- var _refreshAuthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(authtoken) {
1440
+ var _refreshAuthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(authtoken) {
1248
1441
  var promise, response;
1249
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1250
- while (1) switch (_context20.prev = _context20.next) {
1442
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1443
+ while (1) switch (_context24.prev = _context24.next) {
1251
1444
  case 0:
1252
1445
  if (this.appServiceHost) {
1253
- _context20.next = 2;
1446
+ _context24.next = 2;
1254
1447
  break;
1255
1448
  }
1256
- return _context20.abrupt("return", false);
1449
+ return _context24.abrupt("return", false);
1257
1450
  case 2:
1258
1451
  if (!this.requestCache[authtoken]) {
1259
- _context20.next = 4;
1452
+ _context24.next = 4;
1260
1453
  break;
1261
1454
  }
1262
- return _context20.abrupt("return", this.requestCache[authtoken]);
1455
+ return _context24.abrupt("return", this.requestCache[authtoken]);
1263
1456
  case 4:
1264
- _context20.prev = 4;
1457
+ _context24.prev = 4;
1265
1458
  //console.log('RBTTOK Req', authtoken);
1266
1459
  // Create a new promise for the token refresh and store it in the cache
1267
1460
  promise = this.axios.post('/api/iac/refreshAuthToken', [authtoken]);
1268
1461
  this.requestCache[authtoken] = promise;
1269
1462
 
1270
1463
  // Await the promise to get the response
1271
- _context20.next = 9;
1464
+ _context24.next = 9;
1272
1465
  return promise;
1273
1466
  case 9:
1274
- response = _context20.sent;
1467
+ response = _context24.sent;
1275
1468
  //console.log('RBTTOK Response ',response);
1276
1469
  // Once the promise resolves, delete it from the cache to allow future refreshes
1277
1470
  delete this.requestCache[authtoken];
1278
1471
 
1279
1472
  // Return the response data
1280
- return _context20.abrupt("return", response.data);
1473
+ return _context24.abrupt("return", response.data);
1281
1474
  case 14:
1282
- _context20.prev = 14;
1283
- _context20.t0 = _context20["catch"](4);
1475
+ _context24.prev = 14;
1476
+ _context24.t0 = _context24["catch"](4);
1284
1477
  // On error, remove the cached promise to allow retries
1285
1478
  delete this.requestCache[authtoken];
1286
- this._handleError(_context20.t0);
1479
+ this._handleError(_context24.t0);
1287
1480
  case 18:
1288
1481
  case "end":
1289
- return _context20.stop();
1482
+ return _context24.stop();
1290
1483
  }
1291
- }, _callee20, this, [[4, 14]]);
1484
+ }, _callee24, this, [[4, 14]]);
1292
1485
  }));
1293
- function refreshAuthToken(_x10) {
1486
+ function refreshAuthToken(_x14) {
1294
1487
  return _refreshAuthToken.apply(this, arguments);
1295
1488
  }
1296
1489
  return refreshAuthToken;
@@ -1321,31 +1514,31 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1321
1514
  }, {
1322
1515
  key: "registerUser",
1323
1516
  value: function () {
1324
- var _registerUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
1517
+ var _registerUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
1325
1518
  var dataHash,
1326
1519
  response,
1327
1520
  record,
1328
- _args21 = arguments;
1329
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1330
- while (1) switch (_context21.prev = _context21.next) {
1521
+ _args25 = arguments;
1522
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1523
+ while (1) switch (_context25.prev = _context25.next) {
1331
1524
  case 0:
1332
- dataHash = _args21.length > 0 && _args21[0] !== undefined ? _args21[0] : {};
1333
- _context21.prev = 1;
1334
- _context21.next = 4;
1525
+ dataHash = _args25.length > 0 && _args25[0] !== undefined ? _args25[0] : {};
1526
+ _context25.prev = 1;
1527
+ _context25.next = 4;
1335
1528
  return this.axios.post('/api/iac/registerUser', [dataHash]);
1336
1529
  case 4:
1337
- response = _context21.sent;
1530
+ response = _context25.sent;
1338
1531
  record = response.data;
1339
- return _context21.abrupt("return", new _rbt_user["default"](record, this.axios));
1532
+ return _context25.abrupt("return", new _rbt_user["default"](record, this.axios));
1340
1533
  case 9:
1341
- _context21.prev = 9;
1342
- _context21.t0 = _context21["catch"](1);
1343
- return _context21.abrupt("return", this._handleError(_context21.t0));
1534
+ _context25.prev = 9;
1535
+ _context25.t0 = _context25["catch"](1);
1536
+ return _context25.abrupt("return", this._handleError(_context25.t0));
1344
1537
  case 12:
1345
1538
  case "end":
1346
- return _context21.stop();
1539
+ return _context25.stop();
1347
1540
  }
1348
- }, _callee21, this, [[1, 9]]);
1541
+ }, _callee25, this, [[1, 9]]);
1349
1542
  }));
1350
1543
  function registerUser() {
1351
1544
  return _registerUser.apply(this, arguments);
@@ -1362,32 +1555,32 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1362
1555
  }, {
1363
1556
  key: "createFile",
1364
1557
  value: (function () {
1365
- var _createFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(dataHash) {
1558
+ var _createFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(dataHash) {
1366
1559
  var response, record;
1367
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1368
- while (1) switch (_context22.prev = _context22.next) {
1560
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
1561
+ while (1) switch (_context26.prev = _context26.next) {
1369
1562
  case 0:
1370
- _context22.prev = 0;
1371
- _context22.next = 3;
1563
+ _context26.prev = 0;
1564
+ _context26.next = 3;
1372
1565
  return this.axios.post('/object_service/createObject', ['<@filekit.file>', dataHash]);
1373
1566
  case 3:
1374
- response = _context22.sent;
1567
+ response = _context26.sent;
1375
1568
  record = response.data;
1376
1569
  if (dataHash) {
1377
1570
  record.data = dataHash;
1378
1571
  }
1379
- return _context22.abrupt("return", new _rbt_file["default"](record, this.axios, this.localDb));
1572
+ return _context26.abrupt("return", new _rbt_file["default"](record, this.axios, this.localDb));
1380
1573
  case 9:
1381
- _context22.prev = 9;
1382
- _context22.t0 = _context22["catch"](0);
1383
- return _context22.abrupt("return", this._handleError(_context22.t0));
1574
+ _context26.prev = 9;
1575
+ _context26.t0 = _context26["catch"](0);
1576
+ return _context26.abrupt("return", this._handleError(_context26.t0));
1384
1577
  case 12:
1385
1578
  case "end":
1386
- return _context22.stop();
1579
+ return _context26.stop();
1387
1580
  }
1388
- }, _callee22, this, [[0, 9]]);
1581
+ }, _callee26, this, [[0, 9]]);
1389
1582
  }));
1390
- function createFile(_x11) {
1583
+ function createFile(_x15) {
1391
1584
  return _createFile.apply(this, arguments);
1392
1585
  }
1393
1586
  return createFile;
@@ -1395,35 +1588,35 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1395
1588
  }, {
1396
1589
  key: "loadFile",
1397
1590
  value: function () {
1398
- var _loadFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(id) {
1591
+ var _loadFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(id) {
1399
1592
  var response, record;
1400
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1401
- while (1) switch (_context23.prev = _context23.next) {
1593
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
1594
+ while (1) switch (_context27.prev = _context27.next) {
1402
1595
  case 0:
1403
- _context23.prev = 0;
1404
- _context23.next = 3;
1596
+ _context27.prev = 0;
1597
+ _context27.next = 3;
1405
1598
  return this.load('<@filekit.file>', id);
1406
1599
  case 3:
1407
- response = _context23.sent;
1600
+ response = _context27.sent;
1408
1601
  if (response) {
1409
- _context23.next = 6;
1602
+ _context27.next = 6;
1410
1603
  break;
1411
1604
  }
1412
- return _context23.abrupt("return", null);
1605
+ return _context27.abrupt("return", null);
1413
1606
  case 6:
1414
1607
  record = response.toRecord();
1415
- return _context23.abrupt("return", new _rbt_file["default"](record, this.axios, this.localDb));
1608
+ return _context27.abrupt("return", new _rbt_file["default"](record, this.axios, this.localDb));
1416
1609
  case 10:
1417
- _context23.prev = 10;
1418
- _context23.t0 = _context23["catch"](0);
1419
- return _context23.abrupt("return", this._handleError(_context23.t0));
1610
+ _context27.prev = 10;
1611
+ _context27.t0 = _context27["catch"](0);
1612
+ return _context27.abrupt("return", this._handleError(_context27.t0));
1420
1613
  case 13:
1421
1614
  case "end":
1422
- return _context23.stop();
1615
+ return _context27.stop();
1423
1616
  }
1424
- }, _callee23, this, [[0, 10]]);
1617
+ }, _callee27, this, [[0, 10]]);
1425
1618
  }));
1426
- function loadFile(_x12) {
1619
+ function loadFile(_x16) {
1427
1620
  return _loadFile.apply(this, arguments);
1428
1621
  }
1429
1622
  return loadFile;
@@ -1431,39 +1624,39 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1431
1624
  }, {
1432
1625
  key: "loadFiles",
1433
1626
  value: function () {
1434
- var _loadFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(ids) {
1627
+ var _loadFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(ids) {
1435
1628
  var _this6 = this;
1436
1629
  var responses;
1437
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1438
- while (1) switch (_context24.prev = _context24.next) {
1630
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
1631
+ while (1) switch (_context28.prev = _context28.next) {
1439
1632
  case 0:
1440
- _context24.prev = 0;
1441
- _context24.next = 3;
1633
+ _context28.prev = 0;
1634
+ _context28.next = 3;
1442
1635
  return this.load('<@filekit.file>', ids);
1443
1636
  case 3:
1444
- responses = _context24.sent;
1637
+ responses = _context28.sent;
1445
1638
  if (!(!responses || !Array.isArray(responses))) {
1446
- _context24.next = 6;
1639
+ _context28.next = 6;
1447
1640
  break;
1448
1641
  }
1449
- return _context24.abrupt("return", []);
1642
+ return _context28.abrupt("return", []);
1450
1643
  case 6:
1451
- return _context24.abrupt("return", responses.map(function (response) {
1644
+ return _context28.abrupt("return", responses.map(function (response) {
1452
1645
  var record = response.toRecord();
1453
1646
  return new _rbt_file["default"](record, _this6.axios, _this6.localDb);
1454
1647
  }));
1455
1648
  case 9:
1456
- _context24.prev = 9;
1457
- _context24.t0 = _context24["catch"](0);
1458
- this._handleError(_context24.t0); // Handle errors (log or process as needed)
1459
- return _context24.abrupt("return", []);
1649
+ _context28.prev = 9;
1650
+ _context28.t0 = _context28["catch"](0);
1651
+ this._handleError(_context28.t0); // Handle errors (log or process as needed)
1652
+ return _context28.abrupt("return", []);
1460
1653
  case 13:
1461
1654
  case "end":
1462
- return _context24.stop();
1655
+ return _context28.stop();
1463
1656
  }
1464
- }, _callee24, this, [[0, 9]]);
1657
+ }, _callee28, this, [[0, 9]]);
1465
1658
  }));
1466
- function loadFiles(_x13) {
1659
+ function loadFiles(_x17) {
1467
1660
  return _loadFiles.apply(this, arguments);
1468
1661
  }
1469
1662
  return loadFiles;
@@ -1479,42 +1672,42 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1479
1672
  }, {
1480
1673
  key: "create",
1481
1674
  value: (function () {
1482
- var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(type) {
1675
+ var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(type) {
1483
1676
  var dataHash,
1484
1677
  options,
1485
1678
  response,
1486
1679
  record,
1487
- _args25 = arguments;
1488
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1489
- while (1) switch (_context25.prev = _context25.next) {
1680
+ _args29 = arguments;
1681
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
1682
+ while (1) switch (_context29.prev = _context29.next) {
1490
1683
  case 0:
1491
- dataHash = _args25.length > 1 && _args25[1] !== undefined ? _args25[1] : {};
1492
- options = _args25.length > 2 && _args25[2] !== undefined ? _args25[2] : {};
1493
- _context25.prev = 2;
1494
- _context25.next = 5;
1684
+ dataHash = _args29.length > 1 && _args29[1] !== undefined ? _args29[1] : {};
1685
+ options = _args29.length > 2 && _args29[2] !== undefined ? _args29[2] : {};
1686
+ _context29.prev = 2;
1687
+ _context29.next = 5;
1495
1688
  return this.axios.post('/object_service/createObject', [type, dataHash]);
1496
1689
  case 5:
1497
- response = _context25.sent;
1690
+ response = _context29.sent;
1498
1691
  record = response.data;
1499
1692
  if (dataHash) {
1500
1693
  record.data = dataHash;
1501
1694
  }
1502
- return _context25.abrupt("return", new _rbt_object["default"](record, this.axios, {
1695
+ return _context29.abrupt("return", new _rbt_object["default"](record, this.axios, {
1503
1696
  isNew: true,
1504
1697
  websocketClient: this.websocketClient,
1505
1698
  enableRealtime: options.enableRealtime || false
1506
1699
  }));
1507
1700
  case 11:
1508
- _context25.prev = 11;
1509
- _context25.t0 = _context25["catch"](2);
1510
- return _context25.abrupt("return", this._handleError(_context25.t0));
1701
+ _context29.prev = 11;
1702
+ _context29.t0 = _context29["catch"](2);
1703
+ return _context29.abrupt("return", this._handleError(_context29.t0));
1511
1704
  case 14:
1512
1705
  case "end":
1513
- return _context25.stop();
1706
+ return _context29.stop();
1514
1707
  }
1515
- }, _callee25, this, [[2, 11]]);
1708
+ }, _callee29, this, [[2, 11]]);
1516
1709
  }));
1517
- function create(_x14) {
1710
+ function create(_x18) {
1518
1711
  return _create.apply(this, arguments);
1519
1712
  }
1520
1713
  return create;
@@ -1539,6 +1732,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1539
1732
  * - excludeAttrs: An array of attribute paths to exclude from the response (e.g., ['details.log', 'internalData']).
1540
1733
  * Excludes the specified paths and all their subpaths.
1541
1734
  * - resolveReferences: An array of attribute names whose references should be resolved in the returned objects.
1735
+ * - resolveAttrs: Attribute paths whose mod / reference values should be resolved (e.g., ['configs.mod.guide.completion']).
1542
1736
  * - timeout: A numerical value in milliseconds to set a maximum time limit for the query execution.
1543
1737
  * - cache: Boolean. When true, enables a 10-second response cache for identical queries. Default: false (no caching).
1544
1738
  *
@@ -1550,6 +1744,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1550
1744
  * requestAttrs: ['id', 'configs.title'],
1551
1745
  * excludeAttrs: ['details.log'],
1552
1746
  * resolveReferences: ['translatableContent'],
1747
+ * resolveAttrs: ['configs.mod.guide.completion'],
1553
1748
  * cache: true // opt-in to 10s response caching
1554
1749
  * });
1555
1750
  *
@@ -1559,7 +1754,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1559
1754
  }, {
1560
1755
  key: "query",
1561
1756
  value: (function () {
1562
- var _query = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(type) {
1757
+ var _query = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(type) {
1563
1758
  var _this7 = this;
1564
1759
  var params,
1565
1760
  paramsKey,
@@ -1573,20 +1768,20 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1573
1768
  cacheEntry,
1574
1769
  responsePromise,
1575
1770
  processingPromise,
1576
- _args26 = arguments;
1577
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
1578
- while (1) switch (_context26.prev = _context26.next) {
1771
+ _args30 = arguments;
1772
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
1773
+ while (1) switch (_context30.prev = _context30.next) {
1579
1774
  case 0:
1580
- params = _args26.length > 1 && _args26[1] !== undefined ? _args26[1] : {};
1581
- _context26.prev = 1;
1775
+ params = _args30.length > 1 && _args30[1] !== undefined ? _args30[1] : {};
1776
+ _context30.prev = 1;
1582
1777
  //console.log('RBTAPI.query INIT', type, params);
1583
1778
  // Validate parameters - reject invalid parameter names
1584
- validParams = ['type', 'where', 'orderBy', 'limit', 'resolveReferences', 'requestAttrs', 'excludeAttrs', 'timeout', 'enableRealtime', 'cache'];
1779
+ validParams = ['type', 'where', 'orderBy', 'limit', 'resolveReferences', 'resolveAttrs', 'requestAttrs', 'excludeAttrs', 'timeout', 'enableRealtime', 'cache'];
1585
1780
  invalidParams = Object.keys(params).filter(function (key) {
1586
1781
  return !validParams.includes(key);
1587
1782
  });
1588
1783
  if (!(invalidParams.length > 0)) {
1589
- _context26.next = 6;
1784
+ _context30.next = 6;
1590
1785
  break;
1591
1786
  }
1592
1787
  throw new Error("Invalid query parameter(s): ".concat(invalidParams.join(', '), ". Valid parameters are: ").concat(validParams.join(', ')));
@@ -1614,15 +1809,15 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1614
1809
  currentTime = Date.now();
1615
1810
  paramsKey = JSON.stringify(mergedParams);
1616
1811
  if (!useCache) {
1617
- _context26.next = 19;
1812
+ _context30.next = 19;
1618
1813
  break;
1619
1814
  }
1620
1815
  cacheEntry = this.requestCache[paramsKey];
1621
1816
  if (!(cacheEntry && currentTime - cacheEntry.time < 10000)) {
1622
- _context26.next = 19;
1817
+ _context30.next = 19;
1623
1818
  break;
1624
1819
  }
1625
- return _context26.abrupt("return", cacheEntry.val);
1820
+ return _context30.abrupt("return", cacheEntry.val);
1626
1821
  case 19:
1627
1822
  // Create the response promise
1628
1823
  responsePromise = this.axios.post('/object_service/queryObjects', [mergedParams]); // Cache the promise of processing data, not just the raw response
@@ -1640,23 +1835,23 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1640
1835
  }
1641
1836
 
1642
1837
  // Await the processing promise for this call to get processed data
1643
- _context26.next = 24;
1838
+ _context30.next = 24;
1644
1839
  return processingPromise;
1645
1840
  case 24:
1646
- return _context26.abrupt("return", _context26.sent);
1841
+ return _context30.abrupt("return", _context30.sent);
1647
1842
  case 27:
1648
- _context26.prev = 27;
1649
- _context26.t0 = _context26["catch"](1);
1843
+ _context30.prev = 27;
1844
+ _context30.t0 = _context30["catch"](1);
1650
1845
  delete this.requestCache[paramsKey]; // Ensure cache cleanup on error
1651
1846
  //console.log('RBTAPI.query ERROR', paramsKey, e);
1652
- return _context26.abrupt("return", this._handleError(_context26.t0));
1847
+ return _context30.abrupt("return", this._handleError(_context30.t0));
1653
1848
  case 31:
1654
1849
  case "end":
1655
- return _context26.stop();
1850
+ return _context30.stop();
1656
1851
  }
1657
- }, _callee26, this, [[1, 27]]);
1852
+ }, _callee30, this, [[1, 27]]);
1658
1853
  }));
1659
- function query(_x15) {
1854
+ function query(_x19) {
1660
1855
  return _query.apply(this, arguments);
1661
1856
  }
1662
1857
  return query;
@@ -1700,7 +1895,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1700
1895
  }, {
1701
1896
  key: "load",
1702
1897
  value: (function () {
1703
- var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(type, ids) {
1898
+ var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(type, ids) {
1704
1899
  var _this9 = this;
1705
1900
  var params,
1706
1901
  mergedParams,
@@ -1733,17 +1928,17 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1733
1928
  pendingKey,
1734
1929
  missLogKey,
1735
1930
  loadPromise,
1736
- _args28 = arguments;
1737
- return _regeneratorRuntime().wrap(function _callee28$(_context28) {
1738
- while (1) switch (_context28.prev = _context28.next) {
1931
+ _args32 = arguments;
1932
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
1933
+ while (1) switch (_context32.prev = _context32.next) {
1739
1934
  case 0:
1740
- params = _args28.length > 2 && _args28[2] !== undefined ? _args28[2] : {};
1935
+ params = _args32.length > 2 && _args32[2] !== undefined ? _args32[2] : {};
1741
1936
  if (type == '<@iac.user>') {
1742
1937
  debugger;
1743
1938
  }
1744
- _context28.prev = 2;
1939
+ _context32.prev = 2;
1745
1940
  if (!Array.isArray(ids)) {
1746
- _context28.next = 25;
1941
+ _context32.next = 25;
1747
1942
  break;
1748
1943
  }
1749
1944
  // For array requests, check cache for each ID and only load missing ones
@@ -1782,7 +1977,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1782
1977
  }
1783
1978
  loadedObjects = [];
1784
1979
  if (!(missingIds.length > 0)) {
1785
- _context28.next = 19;
1980
+ _context32.next = 19;
1786
1981
  break;
1787
1982
  }
1788
1983
  // Only log bulk cache miss once
@@ -1797,10 +1992,10 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1797
1992
  mergedParams = _objectSpread(_objectSpread({}, queryParams), {}, {
1798
1993
  where: "id IN (\"".concat(missingIds.join("\",\""), "\")")
1799
1994
  });
1800
- _context28.next = 16;
1995
+ _context32.next = 16;
1801
1996
  return this.query(type, mergedParams);
1802
1997
  case 16:
1803
- loadedObjects = _context28.sent;
1998
+ loadedObjects = _context32.sent;
1804
1999
  // Cache the newly loaded objects
1805
2000
  _iterator4 = _createForOfIteratorHelper(loadedObjects);
1806
2001
  try {
@@ -1843,13 +2038,13 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1843
2038
  } finally {
1844
2039
  _iterator5.f();
1845
2040
  }
1846
- return _context28.abrupt("return", result);
2041
+ return _context32.abrupt("return", result);
1847
2042
  case 25:
1848
2043
  // For single object requests, check cache first
1849
2044
  _cacheKey3 = "".concat(type, ":").concat(ids);
1850
2045
  _cached = this._objectCache.get(_cacheKey3);
1851
2046
  if (!_cached) {
1852
- _context28.next = 32;
2047
+ _context32.next = 32;
1853
2048
  break;
1854
2049
  }
1855
2050
  // Only log cache hits once per object to reduce spam
@@ -1863,18 +2058,18 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1863
2058
  //console.log('[AgentProviderSync] 🔄 Upgrading cached object to realtime:', { type, id: ids });
1864
2059
  _cached._initRealtime();
1865
2060
  }
1866
- return _context28.abrupt("return", _cached);
2061
+ return _context32.abrupt("return", _cached);
1867
2062
  case 32:
1868
2063
  // Check if we're already loading this object
1869
2064
  pendingKey = "".concat(type, ":").concat(ids);
1870
2065
  if (!this._pendingLoads.has(pendingKey)) {
1871
- _context28.next = 37;
2066
+ _context32.next = 37;
1872
2067
  break;
1873
2068
  }
1874
- _context28.next = 36;
2069
+ _context32.next = 36;
1875
2070
  return this._pendingLoads.get(pendingKey);
1876
2071
  case 36:
1877
- return _context28.abrupt("return", _context28.sent);
2072
+ return _context32.abrupt("return", _context32.sent);
1878
2073
  case 37:
1879
2074
  // Only log cache miss once per object to reduce spam
1880
2075
  missLogKey = "miss:".concat(_cacheKey3);
@@ -1884,21 +2079,21 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1884
2079
  }
1885
2080
 
1886
2081
  // Create the loading promise and store it to prevent duplicate requests
1887
- loadPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
2082
+ loadPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
1888
2083
  var _enableRealtime, _queryParams, res, _obj2, _setLogKey;
1889
- return _regeneratorRuntime().wrap(function _callee27$(_context27) {
1890
- while (1) switch (_context27.prev = _context27.next) {
2084
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2085
+ while (1) switch (_context31.prev = _context31.next) {
1891
2086
  case 0:
1892
- _context27.prev = 0;
2087
+ _context31.prev = 0;
1893
2088
  // Remove load-specific params that shouldn't be passed to query
1894
2089
  _enableRealtime = params.enableRealtime, _queryParams = _objectWithoutProperties(params, _excluded2);
1895
2090
  mergedParams = _objectSpread(_objectSpread({}, _queryParams), {}, {
1896
2091
  where: "id=\"".concat(ids, "\"")
1897
2092
  });
1898
- _context27.next = 5;
2093
+ _context31.next = 5;
1899
2094
  return _this9.query(type, mergedParams);
1900
2095
  case 5:
1901
- res = _context27.sent;
2096
+ res = _context31.sent;
1902
2097
  _obj2 = res[0];
1903
2098
  if (_obj2) {
1904
2099
  // Cache the loaded object
@@ -1911,37 +2106,37 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1911
2106
  _this9._loggedCacheEvents.add(_setLogKey);
1912
2107
  }
1913
2108
  }
1914
- return _context27.abrupt("return", _obj2);
2109
+ return _context31.abrupt("return", _obj2);
1915
2110
  case 9:
1916
- _context27.prev = 9;
2111
+ _context31.prev = 9;
1917
2112
  // Remove from pending loads
1918
2113
  _this9._pendingLoads["delete"](pendingKey);
1919
- return _context27.finish(9);
2114
+ return _context31.finish(9);
1920
2115
  case 12:
1921
2116
  case "end":
1922
- return _context27.stop();
2117
+ return _context31.stop();
1923
2118
  }
1924
- }, _callee27, null, [[0,, 9, 12]]);
2119
+ }, _callee31, null, [[0,, 9, 12]]);
1925
2120
  }))(); // Store the promise so other concurrent requests can await it
1926
2121
  this._pendingLoads.set(pendingKey, loadPromise);
1927
- _context28.next = 43;
2122
+ _context32.next = 43;
1928
2123
  return loadPromise;
1929
2124
  case 43:
1930
- return _context28.abrupt("return", _context28.sent);
2125
+ return _context32.abrupt("return", _context32.sent);
1931
2126
  case 44:
1932
- _context28.next = 49;
2127
+ _context32.next = 49;
1933
2128
  break;
1934
2129
  case 46:
1935
- _context28.prev = 46;
1936
- _context28.t0 = _context28["catch"](2);
1937
- return _context28.abrupt("return", this._handleError(_context28.t0));
2130
+ _context32.prev = 46;
2131
+ _context32.t0 = _context32["catch"](2);
2132
+ return _context32.abrupt("return", this._handleError(_context32.t0));
1938
2133
  case 49:
1939
2134
  case "end":
1940
- return _context28.stop();
2135
+ return _context32.stop();
1941
2136
  }
1942
- }, _callee28, this, [[2, 46]]);
2137
+ }, _callee32, this, [[2, 46]]);
1943
2138
  }));
1944
- function load(_x16, _x17) {
2139
+ function load(_x20, _x21) {
1945
2140
  return _load.apply(this, arguments);
1946
2141
  }
1947
2142
  return load;
@@ -2022,11 +2217,11 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
2022
2217
  }, {
2023
2218
  key: "getCacheStatus",
2024
2219
  value: function getCacheStatus() {
2025
- var cacheEntries = Array.from(this._objectCache.entries()).map(function (_ref7) {
2220
+ var cacheEntries = Array.from(this._objectCache.entries()).map(function (_ref8) {
2026
2221
  var _obj$_internalData;
2027
- var _ref8 = _slicedToArray(_ref7, 2),
2028
- key = _ref8[0],
2029
- obj = _ref8[1];
2222
+ var _ref9 = _slicedToArray(_ref8, 2),
2223
+ key = _ref9[0],
2224
+ obj = _ref9[1];
2030
2225
  return {
2031
2226
  key: key,
2032
2227
  id: obj.id,
@@ -2064,7 +2259,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
2064
2259
  }, {
2065
2260
  key: "runTask",
2066
2261
  value: (function () {
2067
- var _runTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
2262
+ var _runTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
2068
2263
  var params,
2069
2264
  callbacks,
2070
2265
  onProgress,
@@ -2079,20 +2274,20 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
2079
2274
  message,
2080
2275
  output,
2081
2276
  errorResponse,
2082
- _args29 = arguments;
2083
- return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2084
- while (1) switch (_context29.prev = _context29.next) {
2277
+ _args33 = arguments;
2278
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
2279
+ while (1) switch (_context33.prev = _context33.next) {
2085
2280
  case 0:
2086
- params = _args29.length > 0 && _args29[0] !== undefined ? _args29[0] : {};
2087
- callbacks = _args29.length > 1 && _args29[1] !== undefined ? _args29[1] : {};
2281
+ params = _args33.length > 0 && _args33[0] !== undefined ? _args33[0] : {};
2282
+ callbacks = _args33.length > 1 && _args33[1] !== undefined ? _args33[1] : {};
2088
2283
  onProgress = callbacks.onProgress, onError = callbacks.onError, onStopped = callbacks.onStopped, onWaiting = callbacks.onWaiting, onDone = callbacks.onDone;
2089
- _context29.prev = 3;
2090
- _context29.next = 6;
2284
+ _context33.prev = 3;
2285
+ _context33.next = 6;
2091
2286
  return this.post('/task_service/runChain', params);
2092
2287
  case 6:
2093
- response = _context29.sent;
2288
+ response = _context33.sent;
2094
2289
  if (response) {
2095
- _context29.next = 9;
2290
+ _context33.next = 9;
2096
2291
  break;
2097
2292
  }
2098
2293
  throw new Error('Invalid server response');
@@ -2100,7 +2295,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
2100
2295
  // Validate response structure
2101
2296
  ok = response.ok, jobId = response.jobId, status = response.status, message = response.message, output = response.output;
2102
2297
  if (!(!ok || typeof jobId !== 'string' || typeof status !== 'string')) {
2103
- _context29.next = 12;
2298
+ _context33.next = 12;
2104
2299
  break;
2105
2300
  }
2106
2301
  throw new Error('Invalid response structure');
@@ -2126,7 +2321,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
2126
2321
  //console.log('Finish (request) ',response); s
2127
2322
  onDone(response);
2128
2323
  }
2129
- return _context29.abrupt("return", {
2324
+ return _context33.abrupt("return", {
2130
2325
  ok: ok,
2131
2326
  jobId: jobId,
2132
2327
  status: status,
@@ -2134,21 +2329,21 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
2134
2329
  output: output
2135
2330
  });
2136
2331
  case 20:
2137
- _context29.prev = 20;
2138
- _context29.t0 = _context29["catch"](3);
2332
+ _context33.prev = 20;
2333
+ _context33.t0 = _context33["catch"](3);
2139
2334
  // Standardize error format to match task response object
2140
2335
  // Support RbtError format with label and message
2141
2336
  errorResponse = {
2142
2337
  ok: false,
2143
2338
  jobId: null,
2144
2339
  status: 'ERROR',
2145
- message: _context29.t0.message || _context29.t0.toString() || 'Unknown error',
2146
- label: _context29.t0.label || _context29.t0.name || 'Error',
2340
+ message: _context33.t0.message || _context33.t0.toString() || 'Unknown error',
2341
+ label: _context33.t0.label || _context33.t0.name || 'Error',
2147
2342
  output: {
2148
- error: _context29.t0.message,
2149
- label: _context29.t0.label,
2150
- stack: _context29.t0.stack,
2151
- originalError: _context29.t0
2343
+ error: _context33.t0.message,
2344
+ label: _context33.t0.label,
2345
+ stack: _context33.t0.stack,
2346
+ originalError: _context33.t0
2152
2347
  }
2153
2348
  };
2154
2349
  if (typeof onError === 'function') {
@@ -2156,12 +2351,12 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
2156
2351
  } else {
2157
2352
  console.error('Error in runTask:', errorResponse.message);
2158
2353
  }
2159
- return _context29.abrupt("return", errorResponse);
2354
+ return _context33.abrupt("return", errorResponse);
2160
2355
  case 25:
2161
2356
  case "end":
2162
- return _context29.stop();
2357
+ return _context33.stop();
2163
2358
  }
2164
- }, _callee29, this, [[3, 20]]);
2359
+ }, _callee33, this, [[3, 20]]);
2165
2360
  }));
2166
2361
  function runTask() {
2167
2362
  return _runTask.apply(this, arguments);
@@ -2171,37 +2366,37 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
2171
2366
  }, {
2172
2367
  key: "stopJob",
2173
2368
  value: function () {
2174
- var _stopJob = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
2369
+ var _stopJob = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
2175
2370
  var params,
2176
2371
  callbacks,
2177
2372
  response,
2178
- _args30 = arguments;
2179
- return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2180
- while (1) switch (_context30.prev = _context30.next) {
2373
+ _args34 = arguments;
2374
+ return _regeneratorRuntime().wrap(function _callee34$(_context34) {
2375
+ while (1) switch (_context34.prev = _context34.next) {
2181
2376
  case 0:
2182
- params = _args30.length > 0 && _args30[0] !== undefined ? _args30[0] : {};
2183
- callbacks = _args30.length > 1 && _args30[1] !== undefined ? _args30[1] : {};
2184
- _context30.prev = 2;
2185
- _context30.next = 5;
2377
+ params = _args34.length > 0 && _args34[0] !== undefined ? _args34[0] : {};
2378
+ callbacks = _args34.length > 1 && _args34[1] !== undefined ? _args34[1] : {};
2379
+ _context34.prev = 2;
2380
+ _context34.next = 5;
2186
2381
  return this.post('/task_service/stopJob', params);
2187
2382
  case 5:
2188
- response = _context30.sent;
2383
+ response = _context34.sent;
2189
2384
  if (response) {
2190
- _context30.next = 8;
2385
+ _context34.next = 8;
2191
2386
  break;
2192
2387
  }
2193
2388
  throw new Error('Invalid server response');
2194
2389
  case 8:
2195
- return _context30.abrupt("return", true);
2390
+ return _context34.abrupt("return", true);
2196
2391
  case 11:
2197
- _context30.prev = 11;
2198
- _context30.t0 = _context30["catch"](2);
2392
+ _context34.prev = 11;
2393
+ _context34.t0 = _context34["catch"](2);
2199
2394
  throw 'Error in stopJob';
2200
2395
  case 14:
2201
2396
  case "end":
2202
- return _context30.stop();
2397
+ return _context34.stop();
2203
2398
  }
2204
- }, _callee30, this, [[2, 11]]);
2399
+ }, _callee34, this, [[2, 11]]);
2205
2400
  }));
2206
2401
  function stopJob() {
2207
2402
  return _stopJob.apply(this, arguments);
@@ -2249,26 +2444,26 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
2249
2444
  }, {
2250
2445
  key: "pollTaskProgress",
2251
2446
  value: (function () {
2252
- var _pollTaskProgress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(jobId, callbacks) {
2447
+ var _pollTaskProgress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(jobId, callbacks) {
2253
2448
  var _this10 = this;
2254
2449
  var onProgress, onError, onStopped, onWaiting, onDone, _callbacks$pollingInt, pollingInterval, checkProgress;
2255
- return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2256
- while (1) switch (_context32.prev = _context32.next) {
2450
+ return _regeneratorRuntime().wrap(function _callee36$(_context36) {
2451
+ while (1) switch (_context36.prev = _context36.next) {
2257
2452
  case 0:
2258
2453
  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;
2259
- _context32.prev = 1;
2454
+ _context36.prev = 1;
2260
2455
  checkProgress = /*#__PURE__*/function () {
2261
- var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
2456
+ var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {
2262
2457
  var response;
2263
- return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2264
- while (1) switch (_context31.prev = _context31.next) {
2458
+ return _regeneratorRuntime().wrap(function _callee35$(_context35) {
2459
+ while (1) switch (_context35.prev = _context35.next) {
2265
2460
  case 0:
2266
- _context31.next = 2;
2461
+ _context35.next = 2;
2267
2462
  return _this10.get("/task_service/pollChainProgress", {
2268
2463
  jobId: jobId
2269
2464
  });
2270
2465
  case 2:
2271
- response = _context31.sent;
2466
+ response = _context35.sent;
2272
2467
  // If the task is still in progress, start polling for updates
2273
2468
  if (response.status === 'DONE' && onDone) {
2274
2469
  // Provide the current progress to the callback function
@@ -2299,28 +2494,28 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
2299
2494
  }
2300
2495
  case 9:
2301
2496
  case "end":
2302
- return _context31.stop();
2497
+ return _context35.stop();
2303
2498
  }
2304
- }, _callee31);
2499
+ }, _callee35);
2305
2500
  }));
2306
2501
  return function checkProgress() {
2307
- return _ref9.apply(this, arguments);
2502
+ return _ref10.apply(this, arguments);
2308
2503
  };
2309
2504
  }();
2310
2505
  checkProgress();
2311
- _context32.next = 9;
2506
+ _context36.next = 9;
2312
2507
  break;
2313
2508
  case 6:
2314
- _context32.prev = 6;
2315
- _context32.t0 = _context32["catch"](1);
2316
- return _context32.abrupt("return", this._handleError(_context32.t0));
2509
+ _context36.prev = 6;
2510
+ _context36.t0 = _context36["catch"](1);
2511
+ return _context36.abrupt("return", this._handleError(_context36.t0));
2317
2512
  case 9:
2318
2513
  case "end":
2319
- return _context32.stop();
2514
+ return _context36.stop();
2320
2515
  }
2321
- }, _callee32, this, [[1, 6]]);
2516
+ }, _callee36, this, [[1, 6]]);
2322
2517
  }));
2323
- function pollTaskProgress(_x18, _x19) {
2518
+ function pollTaskProgress(_x22, _x23) {
2324
2519
  return _pollTaskProgress.apply(this, arguments);
2325
2520
  }
2326
2521
  return pollTaskProgress;
@@ -2341,18 +2536,18 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
2341
2536
  }, {
2342
2537
  key: "get",
2343
2538
  value: (function () {
2344
- var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(endpoint) {
2539
+ var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(endpoint) {
2345
2540
  var params,
2346
2541
  customHeaders,
2347
2542
  config,
2348
2543
  response,
2349
- _args33 = arguments;
2350
- return _regeneratorRuntime().wrap(function _callee33$(_context33) {
2351
- while (1) switch (_context33.prev = _context33.next) {
2544
+ _args37 = arguments;
2545
+ return _regeneratorRuntime().wrap(function _callee37$(_context37) {
2546
+ while (1) switch (_context37.prev = _context37.next) {
2352
2547
  case 0:
2353
- params = _args33.length > 1 && _args33[1] !== undefined ? _args33[1] : {};
2354
- customHeaders = _args33.length > 2 && _args33[2] !== undefined ? _args33[2] : null;
2355
- _context33.prev = 2;
2548
+ params = _args37.length > 1 && _args37[1] !== undefined ? _args37[1] : {};
2549
+ customHeaders = _args37.length > 2 && _args37[2] !== undefined ? _args37[2] : null;
2550
+ _context37.prev = 2;
2356
2551
  // Build request config
2357
2552
  config = {
2358
2553
  params: params
@@ -2367,28 +2562,28 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
2367
2562
  // Otherwise, don't set config.headers at all - let axios use its defaults
2368
2563
 
2369
2564
  // Make the GET request using Axios
2370
- _context33.next = 7;
2565
+ _context37.next = 7;
2371
2566
  return this.axios.get(endpoint, config);
2372
2567
  case 7:
2373
- response = _context33.sent;
2568
+ response = _context37.sent;
2374
2569
  if (!(response.data.ok === false)) {
2375
- _context33.next = 10;
2570
+ _context37.next = 10;
2376
2571
  break;
2377
2572
  }
2378
- return _context33.abrupt("return", this._handleError(response));
2573
+ return _context37.abrupt("return", this._handleError(response));
2379
2574
  case 10:
2380
- return _context33.abrupt("return", response.data);
2575
+ return _context37.abrupt("return", response.data);
2381
2576
  case 13:
2382
- _context33.prev = 13;
2383
- _context33.t0 = _context33["catch"](2);
2384
- return _context33.abrupt("return", this._handleError(_context33.t0));
2577
+ _context37.prev = 13;
2578
+ _context37.t0 = _context37["catch"](2);
2579
+ return _context37.abrupt("return", this._handleError(_context37.t0));
2385
2580
  case 16:
2386
2581
  case "end":
2387
- return _context33.stop();
2582
+ return _context37.stop();
2388
2583
  }
2389
- }, _callee33, this, [[2, 13]]);
2584
+ }, _callee37, this, [[2, 13]]);
2390
2585
  }));
2391
- function get(_x20) {
2586
+ function get(_x24) {
2392
2587
  return _get.apply(this, arguments);
2393
2588
  }
2394
2589
  return get;
@@ -2409,44 +2604,44 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
2409
2604
  }, {
2410
2605
  key: "post",
2411
2606
  value: (function () {
2412
- var _post = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(endpoint) {
2607
+ var _post = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(endpoint) {
2413
2608
  var data,
2414
2609
  headers,
2415
2610
  response,
2416
- _args34 = arguments;
2417
- return _regeneratorRuntime().wrap(function _callee34$(_context34) {
2418
- while (1) switch (_context34.prev = _context34.next) {
2611
+ _args38 = arguments;
2612
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
2613
+ while (1) switch (_context38.prev = _context38.next) {
2419
2614
  case 0:
2420
- data = _args34.length > 1 && _args34[1] !== undefined ? _args34[1] : {};
2421
- _context34.prev = 1;
2615
+ data = _args38.length > 1 && _args38[1] !== undefined ? _args38[1] : {};
2616
+ _context38.prev = 1;
2422
2617
  // Add the authToken to the headers
2423
2618
  headers = {
2424
2619
  authtoken: this.authtoken
2425
2620
  }; // Make the POST request using Axios
2426
- _context34.next = 5;
2621
+ _context38.next = 5;
2427
2622
  return this.axios.post(endpoint, data, {
2428
2623
  headers: headers
2429
2624
  });
2430
2625
  case 5:
2431
- response = _context34.sent;
2626
+ response = _context38.sent;
2432
2627
  if (!(response.data.ok === false)) {
2433
- _context34.next = 8;
2628
+ _context38.next = 8;
2434
2629
  break;
2435
2630
  }
2436
- return _context34.abrupt("return", this._handleError(response));
2631
+ return _context38.abrupt("return", this._handleError(response));
2437
2632
  case 8:
2438
- return _context34.abrupt("return", response.data);
2633
+ return _context38.abrupt("return", response.data);
2439
2634
  case 11:
2440
- _context34.prev = 11;
2441
- _context34.t0 = _context34["catch"](1);
2442
- return _context34.abrupt("return", this._handleError(_context34.t0));
2635
+ _context38.prev = 11;
2636
+ _context38.t0 = _context38["catch"](1);
2637
+ return _context38.abrupt("return", this._handleError(_context38.t0));
2443
2638
  case 14:
2444
2639
  case "end":
2445
- return _context34.stop();
2640
+ return _context38.stop();
2446
2641
  }
2447
- }, _callee34, this, [[1, 11]]);
2642
+ }, _callee38, this, [[1, 11]]);
2448
2643
  }));
2449
- function post(_x21) {
2644
+ function post(_x25) {
2450
2645
  return _post.apply(this, arguments);
2451
2646
  }
2452
2647
  return post;