roboto-js 3.0.0 → 3.0.1

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