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