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