roboto-js 1.4.49 → 1.5.0
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/dist/cjs/index.cjs +77 -58
- package/dist/cjs/rbt_api.cjs +198 -160
- package/dist/cjs/rbt_file.cjs +70 -426
- package/dist/esm/index.js +3 -0
- package/dist/esm/rbt_api.js +24 -5
- package/dist/esm/rbt_file.js +61 -166
- package/package.json +3 -2
- package/src/index.js +3 -0
- package/src/rbt_api.js +26 -5
- package/src/rbt_file.js +64 -210
package/dist/cjs/rbt_api.cjs
CHANGED
|
@@ -507,41 +507,39 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
507
507
|
return _context11.abrupt("return", false);
|
|
508
508
|
case 3:
|
|
509
509
|
if (!this.requestCache[authtoken]) {
|
|
510
|
-
_context11.next =
|
|
510
|
+
_context11.next = 5;
|
|
511
511
|
break;
|
|
512
512
|
}
|
|
513
|
-
// If there's already a pending promise to refresh this token, return it
|
|
514
|
-
console.log('RBTTOK Using cached promise for token refresh');
|
|
515
513
|
return _context11.abrupt("return", this.requestCache[authtoken]);
|
|
516
|
-
case
|
|
517
|
-
_context11.prev =
|
|
518
|
-
console.log('RBTTOK Req', authtoken);
|
|
514
|
+
case 5:
|
|
515
|
+
_context11.prev = 5;
|
|
516
|
+
//console.log('RBTTOK Req', authtoken);
|
|
519
517
|
// Create a new promise for the token refresh and store it in the cache
|
|
520
518
|
promise = this.axios.post('/user_service/refreshAuthToken', [authtoken]);
|
|
521
519
|
this.requestCache[authtoken] = promise;
|
|
522
520
|
|
|
523
521
|
// Await the promise to get the response
|
|
524
|
-
_context11.next =
|
|
522
|
+
_context11.next = 10;
|
|
525
523
|
return promise;
|
|
526
|
-
case
|
|
524
|
+
case 10:
|
|
527
525
|
response = _context11.sent;
|
|
528
|
-
console.log('RBTTOK Response ',
|
|
526
|
+
//console.log('RBTTOK Response ',response);
|
|
529
527
|
// Once the promise resolves, delete it from the cache to allow future refreshes
|
|
530
528
|
delete this.requestCache[authtoken];
|
|
531
529
|
|
|
532
530
|
// Return the response data
|
|
533
531
|
return _context11.abrupt("return", response.data);
|
|
534
|
-
case
|
|
535
|
-
_context11.prev =
|
|
536
|
-
_context11.t0 = _context11["catch"](
|
|
532
|
+
case 15:
|
|
533
|
+
_context11.prev = 15;
|
|
534
|
+
_context11.t0 = _context11["catch"](5);
|
|
537
535
|
// On error, remove the cached promise to allow retries
|
|
538
536
|
delete this.requestCache[authtoken];
|
|
539
537
|
this._handleError(_context11.t0);
|
|
540
|
-
case
|
|
538
|
+
case 19:
|
|
541
539
|
case "end":
|
|
542
540
|
return _context11.stop();
|
|
543
541
|
}
|
|
544
|
-
}, _callee11, this, [[
|
|
542
|
+
}, _callee11, this, [[5, 15]]);
|
|
545
543
|
}));
|
|
546
544
|
function refreshAuthToken(_x7) {
|
|
547
545
|
return _refreshAuthToken.apply(this, arguments);
|
|
@@ -681,6 +679,46 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
681
679
|
}
|
|
682
680
|
return loadFile;
|
|
683
681
|
}()
|
|
682
|
+
}, {
|
|
683
|
+
key: "loadFiles",
|
|
684
|
+
value: function () {
|
|
685
|
+
var _loadFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(ids) {
|
|
686
|
+
var _this = this;
|
|
687
|
+
var responses;
|
|
688
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
689
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
690
|
+
case 0:
|
|
691
|
+
_context15.prev = 0;
|
|
692
|
+
_context15.next = 3;
|
|
693
|
+
return this.load('<@filekit.file>', ids);
|
|
694
|
+
case 3:
|
|
695
|
+
responses = _context15.sent;
|
|
696
|
+
if (!(!responses || !Array.isArray(responses))) {
|
|
697
|
+
_context15.next = 6;
|
|
698
|
+
break;
|
|
699
|
+
}
|
|
700
|
+
return _context15.abrupt("return", []);
|
|
701
|
+
case 6:
|
|
702
|
+
return _context15.abrupt("return", responses.map(function (response) {
|
|
703
|
+
var record = response.toRecord();
|
|
704
|
+
return new _rbt_file["default"](record, _this.axios, _this.localDb);
|
|
705
|
+
}));
|
|
706
|
+
case 9:
|
|
707
|
+
_context15.prev = 9;
|
|
708
|
+
_context15.t0 = _context15["catch"](0);
|
|
709
|
+
this._handleError(_context15.t0); // Handle errors (log or process as needed)
|
|
710
|
+
return _context15.abrupt("return", []);
|
|
711
|
+
case 13:
|
|
712
|
+
case "end":
|
|
713
|
+
return _context15.stop();
|
|
714
|
+
}
|
|
715
|
+
}, _callee15, this, [[0, 9]]);
|
|
716
|
+
}));
|
|
717
|
+
function loadFiles(_x10) {
|
|
718
|
+
return _loadFiles.apply(this, arguments);
|
|
719
|
+
}
|
|
720
|
+
return loadFiles;
|
|
721
|
+
}()
|
|
684
722
|
/**
|
|
685
723
|
* Creates a new object of the given type.
|
|
686
724
|
*
|
|
@@ -691,40 +729,40 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
691
729
|
}, {
|
|
692
730
|
key: "create",
|
|
693
731
|
value: (function () {
|
|
694
|
-
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
732
|
+
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(type) {
|
|
695
733
|
var dataHash,
|
|
696
734
|
response,
|
|
697
735
|
record,
|
|
698
|
-
|
|
699
|
-
return _regeneratorRuntime().wrap(function
|
|
700
|
-
while (1) switch (
|
|
736
|
+
_args16 = arguments;
|
|
737
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
738
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
701
739
|
case 0:
|
|
702
|
-
dataHash =
|
|
703
|
-
|
|
740
|
+
dataHash = _args16.length > 1 && _args16[1] !== undefined ? _args16[1] : {};
|
|
741
|
+
_context16.prev = 1;
|
|
704
742
|
debugger;
|
|
705
|
-
|
|
743
|
+
_context16.next = 5;
|
|
706
744
|
return this.axios.post('/object_service/createObject', [type, dataHash]);
|
|
707
745
|
case 5:
|
|
708
|
-
response =
|
|
746
|
+
response = _context16.sent;
|
|
709
747
|
record = response.data;
|
|
710
748
|
if (dataHash) {
|
|
711
749
|
record.data = dataHash;
|
|
712
750
|
}
|
|
713
751
|
debugger;
|
|
714
|
-
return
|
|
752
|
+
return _context16.abrupt("return", new _rbt_object["default"](record, this.axios, {
|
|
715
753
|
isNew: true
|
|
716
754
|
}));
|
|
717
755
|
case 12:
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
return
|
|
756
|
+
_context16.prev = 12;
|
|
757
|
+
_context16.t0 = _context16["catch"](1);
|
|
758
|
+
return _context16.abrupt("return", this._handleError(_context16.t0));
|
|
721
759
|
case 15:
|
|
722
760
|
case "end":
|
|
723
|
-
return
|
|
761
|
+
return _context16.stop();
|
|
724
762
|
}
|
|
725
|
-
},
|
|
763
|
+
}, _callee16, this, [[1, 12]]);
|
|
726
764
|
}));
|
|
727
|
-
function create(
|
|
765
|
+
function create(_x11) {
|
|
728
766
|
return _create.apply(this, arguments);
|
|
729
767
|
}
|
|
730
768
|
return create;
|
|
@@ -803,8 +841,8 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
803
841
|
}, {
|
|
804
842
|
key: "query",
|
|
805
843
|
value: (function () {
|
|
806
|
-
var _query = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
807
|
-
var
|
|
844
|
+
var _query = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(type) {
|
|
845
|
+
var _this2 = this;
|
|
808
846
|
var params,
|
|
809
847
|
defaultOrderBy,
|
|
810
848
|
defaultLimit,
|
|
@@ -814,12 +852,12 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
814
852
|
cacheEntry,
|
|
815
853
|
responsePromise,
|
|
816
854
|
processingPromise,
|
|
817
|
-
|
|
818
|
-
return _regeneratorRuntime().wrap(function
|
|
819
|
-
while (1) switch (
|
|
855
|
+
_args17 = arguments;
|
|
856
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
857
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
820
858
|
case 0:
|
|
821
|
-
params =
|
|
822
|
-
|
|
859
|
+
params = _args17.length > 1 && _args17[1] !== undefined ? _args17[1] : {};
|
|
860
|
+
_context17.prev = 1;
|
|
823
861
|
//console.log('RBTAPI.query INIT', type, params);
|
|
824
862
|
params.type = type;
|
|
825
863
|
|
|
@@ -841,19 +879,19 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
841
879
|
_paramsKey = JSON.stringify(mergedParams);
|
|
842
880
|
cacheEntry = this.requestCache[_paramsKey];
|
|
843
881
|
if (!(cacheEntry && currentTime - cacheEntry.time < 10000)) {
|
|
844
|
-
|
|
882
|
+
_context17.next = 11;
|
|
845
883
|
break;
|
|
846
884
|
}
|
|
847
|
-
return
|
|
885
|
+
return _context17.abrupt("return", cacheEntry.val);
|
|
848
886
|
case 11:
|
|
849
887
|
// Create the response promise
|
|
850
888
|
responsePromise = this.axios.post('/object_service/queryObjects', [mergedParams]); // Cache the promise of processing data, not just the raw response
|
|
851
889
|
processingPromise = responsePromise.then(function (response) {
|
|
852
|
-
return
|
|
890
|
+
return _this2._processResponseData(response);
|
|
853
891
|
})["catch"](function (e) {
|
|
854
|
-
delete
|
|
892
|
+
delete _this2.requestCache[_paramsKey]; // Ensure cache cleanup on failure
|
|
855
893
|
//console.log('RBTAPI.query ERROR (Processing)', paramsKey, e);
|
|
856
|
-
return
|
|
894
|
+
return _this2._handleError(e);
|
|
857
895
|
}); // Store the promise of the processed data in the cache
|
|
858
896
|
this.requestCache[_paramsKey] = {
|
|
859
897
|
val: processingPromise,
|
|
@@ -861,23 +899,23 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
861
899
|
};
|
|
862
900
|
|
|
863
901
|
// Await the processing promise for this call to get processed data
|
|
864
|
-
|
|
902
|
+
_context17.next = 16;
|
|
865
903
|
return processingPromise;
|
|
866
904
|
case 16:
|
|
867
|
-
return
|
|
905
|
+
return _context17.abrupt("return", _context17.sent);
|
|
868
906
|
case 19:
|
|
869
|
-
|
|
870
|
-
|
|
907
|
+
_context17.prev = 19;
|
|
908
|
+
_context17.t0 = _context17["catch"](1);
|
|
871
909
|
delete this.requestCache[paramsKey]; // Ensure cache cleanup on error
|
|
872
910
|
//console.log('RBTAPI.query ERROR', paramsKey, e);
|
|
873
|
-
return
|
|
911
|
+
return _context17.abrupt("return", this._handleError(_context17.t0));
|
|
874
912
|
case 23:
|
|
875
913
|
case "end":
|
|
876
|
-
return
|
|
914
|
+
return _context17.stop();
|
|
877
915
|
}
|
|
878
|
-
},
|
|
916
|
+
}, _callee17, this, [[1, 19]]);
|
|
879
917
|
}));
|
|
880
|
-
function query(
|
|
918
|
+
function query(_x12) {
|
|
881
919
|
return _query.apply(this, arguments);
|
|
882
920
|
}
|
|
883
921
|
return query;
|
|
@@ -885,14 +923,14 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
885
923
|
}, {
|
|
886
924
|
key: "_processResponseData",
|
|
887
925
|
value: function _processResponseData(response) {
|
|
888
|
-
var
|
|
926
|
+
var _this3 = this;
|
|
889
927
|
if (response.data.ok === false) {
|
|
890
928
|
return this._handleError(response);
|
|
891
929
|
}
|
|
892
930
|
if (Array.isArray(response.data.items)) {
|
|
893
931
|
//console.log('RBTAPI.query RESPONSE PRE', response.data.items);
|
|
894
932
|
response.data.items = response.data.items.map(function (record) {
|
|
895
|
-
return new _rbt_object["default"](record,
|
|
933
|
+
return new _rbt_object["default"](record, _this3.axios, {
|
|
896
934
|
isNew: true
|
|
897
935
|
});
|
|
898
936
|
});
|
|
@@ -913,47 +951,47 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
913
951
|
}, {
|
|
914
952
|
key: "load",
|
|
915
953
|
value: (function () {
|
|
916
|
-
var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
954
|
+
var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(type, ids) {
|
|
917
955
|
var params,
|
|
918
956
|
mergedParams,
|
|
919
957
|
res,
|
|
920
|
-
|
|
921
|
-
return _regeneratorRuntime().wrap(function
|
|
922
|
-
while (1) switch (
|
|
958
|
+
_args18 = arguments;
|
|
959
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
960
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
923
961
|
case 0:
|
|
924
|
-
params =
|
|
925
|
-
|
|
962
|
+
params = _args18.length > 2 && _args18[2] !== undefined ? _args18[2] : {};
|
|
963
|
+
_context18.prev = 1;
|
|
926
964
|
if (!Array.isArray(ids)) {
|
|
927
|
-
|
|
965
|
+
_context18.next = 7;
|
|
928
966
|
break;
|
|
929
967
|
}
|
|
930
968
|
mergedParams = _objectSpread(_objectSpread({}, params), {}, {
|
|
931
969
|
where: "id IN (\"".concat(ids.join("\",\""), "\")")
|
|
932
970
|
});
|
|
933
|
-
return
|
|
971
|
+
return _context18.abrupt("return", this.query(type, mergedParams));
|
|
934
972
|
case 7:
|
|
935
973
|
mergedParams = _objectSpread(_objectSpread({}, params), {}, {
|
|
936
974
|
where: "id=\"".concat(ids, "\"")
|
|
937
975
|
});
|
|
938
|
-
|
|
976
|
+
_context18.next = 10;
|
|
939
977
|
return this.query(type, mergedParams);
|
|
940
978
|
case 10:
|
|
941
|
-
res =
|
|
942
|
-
return
|
|
979
|
+
res = _context18.sent;
|
|
980
|
+
return _context18.abrupt("return", res[0]);
|
|
943
981
|
case 12:
|
|
944
|
-
|
|
982
|
+
_context18.next = 17;
|
|
945
983
|
break;
|
|
946
984
|
case 14:
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
return
|
|
985
|
+
_context18.prev = 14;
|
|
986
|
+
_context18.t0 = _context18["catch"](1);
|
|
987
|
+
return _context18.abrupt("return", this._handleError(_context18.t0));
|
|
950
988
|
case 17:
|
|
951
989
|
case "end":
|
|
952
|
-
return
|
|
990
|
+
return _context18.stop();
|
|
953
991
|
}
|
|
954
|
-
},
|
|
992
|
+
}, _callee18, this, [[1, 14]]);
|
|
955
993
|
}));
|
|
956
|
-
function load(
|
|
994
|
+
function load(_x13, _x14) {
|
|
957
995
|
return _load.apply(this, arguments);
|
|
958
996
|
}
|
|
959
997
|
return load;
|
|
@@ -980,7 +1018,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
980
1018
|
}, {
|
|
981
1019
|
key: "runTask",
|
|
982
1020
|
value: (function () {
|
|
983
|
-
var _runTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1021
|
+
var _runTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
|
984
1022
|
var params,
|
|
985
1023
|
callbacks,
|
|
986
1024
|
onProgress,
|
|
@@ -994,20 +1032,20 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
994
1032
|
status,
|
|
995
1033
|
message,
|
|
996
1034
|
output,
|
|
997
|
-
|
|
998
|
-
return _regeneratorRuntime().wrap(function
|
|
999
|
-
while (1) switch (
|
|
1035
|
+
_args19 = arguments;
|
|
1036
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1037
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1000
1038
|
case 0:
|
|
1001
|
-
params =
|
|
1002
|
-
callbacks =
|
|
1039
|
+
params = _args19.length > 0 && _args19[0] !== undefined ? _args19[0] : {};
|
|
1040
|
+
callbacks = _args19.length > 1 && _args19[1] !== undefined ? _args19[1] : {};
|
|
1003
1041
|
onProgress = callbacks.onProgress, onError = callbacks.onError, onStopped = callbacks.onStopped, onWaiting = callbacks.onWaiting, onDone = callbacks.onDone;
|
|
1004
|
-
|
|
1005
|
-
|
|
1042
|
+
_context19.prev = 3;
|
|
1043
|
+
_context19.next = 6;
|
|
1006
1044
|
return this.post('/task_service/runChain', params);
|
|
1007
1045
|
case 6:
|
|
1008
|
-
response =
|
|
1046
|
+
response = _context19.sent;
|
|
1009
1047
|
if (response) {
|
|
1010
|
-
|
|
1048
|
+
_context19.next = 9;
|
|
1011
1049
|
break;
|
|
1012
1050
|
}
|
|
1013
1051
|
throw new Error('Invalid server response');
|
|
@@ -1015,7 +1053,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1015
1053
|
// Validate response structure
|
|
1016
1054
|
ok = response.ok, jobId = response.jobId, status = response.status, message = response.message, output = response.output;
|
|
1017
1055
|
if (!(!ok || typeof jobId !== 'string' || typeof status !== 'string')) {
|
|
1018
|
-
|
|
1056
|
+
_context19.next = 12;
|
|
1019
1057
|
break;
|
|
1020
1058
|
}
|
|
1021
1059
|
throw new Error('Invalid response structure');
|
|
@@ -1038,10 +1076,10 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1038
1076
|
}
|
|
1039
1077
|
if (status === 'DONE' && onDone) {
|
|
1040
1078
|
// Provide the current progress to the callback function
|
|
1041
|
-
console.log('Finish (request) ',
|
|
1079
|
+
//console.log('Finish (request) ',response);
|
|
1042
1080
|
onDone(response);
|
|
1043
1081
|
}
|
|
1044
|
-
return
|
|
1082
|
+
return _context19.abrupt("return", {
|
|
1045
1083
|
ok: ok,
|
|
1046
1084
|
jobId: jobId,
|
|
1047
1085
|
status: status,
|
|
@@ -1049,24 +1087,24 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1049
1087
|
output: output
|
|
1050
1088
|
});
|
|
1051
1089
|
case 20:
|
|
1052
|
-
|
|
1053
|
-
|
|
1090
|
+
_context19.prev = 20;
|
|
1091
|
+
_context19.t0 = _context19["catch"](3);
|
|
1054
1092
|
if (typeof onError === 'function') {
|
|
1055
|
-
onError(
|
|
1093
|
+
onError(_context19.t0);
|
|
1056
1094
|
} else {
|
|
1057
|
-
console.error('Error in runTask:',
|
|
1095
|
+
console.error('Error in runTask:', _context19.t0);
|
|
1058
1096
|
}
|
|
1059
|
-
return
|
|
1097
|
+
return _context19.abrupt("return", {
|
|
1060
1098
|
ok: false,
|
|
1061
1099
|
jobId: null,
|
|
1062
1100
|
status: 'ERROR',
|
|
1063
|
-
error:
|
|
1101
|
+
error: _context19.t0.message
|
|
1064
1102
|
});
|
|
1065
1103
|
case 24:
|
|
1066
1104
|
case "end":
|
|
1067
|
-
return
|
|
1105
|
+
return _context19.stop();
|
|
1068
1106
|
}
|
|
1069
|
-
},
|
|
1107
|
+
}, _callee19, this, [[3, 20]]);
|
|
1070
1108
|
}));
|
|
1071
1109
|
function runTask() {
|
|
1072
1110
|
return _runTask.apply(this, arguments);
|
|
@@ -1076,37 +1114,37 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1076
1114
|
}, {
|
|
1077
1115
|
key: "stopJob",
|
|
1078
1116
|
value: function () {
|
|
1079
|
-
var _stopJob = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1117
|
+
var _stopJob = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
1080
1118
|
var params,
|
|
1081
1119
|
callbacks,
|
|
1082
1120
|
response,
|
|
1083
|
-
|
|
1084
|
-
return _regeneratorRuntime().wrap(function
|
|
1085
|
-
while (1) switch (
|
|
1121
|
+
_args20 = arguments;
|
|
1122
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1123
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1086
1124
|
case 0:
|
|
1087
|
-
params =
|
|
1088
|
-
callbacks =
|
|
1089
|
-
|
|
1090
|
-
|
|
1125
|
+
params = _args20.length > 0 && _args20[0] !== undefined ? _args20[0] : {};
|
|
1126
|
+
callbacks = _args20.length > 1 && _args20[1] !== undefined ? _args20[1] : {};
|
|
1127
|
+
_context20.prev = 2;
|
|
1128
|
+
_context20.next = 5;
|
|
1091
1129
|
return this.post('/task_service/stopJob', params);
|
|
1092
1130
|
case 5:
|
|
1093
|
-
response =
|
|
1131
|
+
response = _context20.sent;
|
|
1094
1132
|
if (response) {
|
|
1095
|
-
|
|
1133
|
+
_context20.next = 8;
|
|
1096
1134
|
break;
|
|
1097
1135
|
}
|
|
1098
1136
|
throw new Error('Invalid server response');
|
|
1099
1137
|
case 8:
|
|
1100
|
-
return
|
|
1138
|
+
return _context20.abrupt("return", true);
|
|
1101
1139
|
case 11:
|
|
1102
|
-
|
|
1103
|
-
|
|
1140
|
+
_context20.prev = 11;
|
|
1141
|
+
_context20.t0 = _context20["catch"](2);
|
|
1104
1142
|
throw 'Error in stopJob';
|
|
1105
1143
|
case 14:
|
|
1106
1144
|
case "end":
|
|
1107
|
-
return
|
|
1145
|
+
return _context20.stop();
|
|
1108
1146
|
}
|
|
1109
|
-
},
|
|
1147
|
+
}, _callee20, this, [[2, 11]]);
|
|
1110
1148
|
}));
|
|
1111
1149
|
function stopJob() {
|
|
1112
1150
|
return _stopJob.apply(this, arguments);
|
|
@@ -1126,30 +1164,30 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1126
1164
|
}, {
|
|
1127
1165
|
key: "pollTaskProgress",
|
|
1128
1166
|
value: (function () {
|
|
1129
|
-
var _pollTaskProgress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1130
|
-
var
|
|
1167
|
+
var _pollTaskProgress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(jobId, callbacks) {
|
|
1168
|
+
var _this4 = this;
|
|
1131
1169
|
var onProgress, onError, onStopped, onWaiting, onDone, _callbacks$pollingInt, pollingInterval, checkProgress;
|
|
1132
|
-
return _regeneratorRuntime().wrap(function
|
|
1133
|
-
while (1) switch (
|
|
1170
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
1171
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1134
1172
|
case 0:
|
|
1135
1173
|
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;
|
|
1136
|
-
|
|
1174
|
+
_context22.prev = 1;
|
|
1137
1175
|
checkProgress = /*#__PURE__*/function () {
|
|
1138
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1176
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
1139
1177
|
var response;
|
|
1140
|
-
return _regeneratorRuntime().wrap(function
|
|
1141
|
-
while (1) switch (
|
|
1178
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1179
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1142
1180
|
case 0:
|
|
1143
|
-
|
|
1144
|
-
return
|
|
1181
|
+
_context21.next = 2;
|
|
1182
|
+
return _this4.get("/task_service/pollChainProgress", {
|
|
1145
1183
|
jobId: jobId
|
|
1146
1184
|
});
|
|
1147
1185
|
case 2:
|
|
1148
|
-
response =
|
|
1186
|
+
response = _context21.sent;
|
|
1149
1187
|
// If the task is still in progress, start polling for updates
|
|
1150
1188
|
if (response.status === 'DONE' && onDone) {
|
|
1151
1189
|
// Provide the current progress to the callback function
|
|
1152
|
-
console.log('Finish (progress) ',
|
|
1190
|
+
//console.log('Finish (progress) ',response);
|
|
1153
1191
|
onDone(response);
|
|
1154
1192
|
}
|
|
1155
1193
|
if (response.status === 'ERROR' && onError) {
|
|
@@ -1176,28 +1214,28 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1176
1214
|
}
|
|
1177
1215
|
case 9:
|
|
1178
1216
|
case "end":
|
|
1179
|
-
return
|
|
1217
|
+
return _context21.stop();
|
|
1180
1218
|
}
|
|
1181
|
-
},
|
|
1219
|
+
}, _callee21);
|
|
1182
1220
|
}));
|
|
1183
1221
|
return function checkProgress() {
|
|
1184
1222
|
return _ref2.apply(this, arguments);
|
|
1185
1223
|
};
|
|
1186
1224
|
}();
|
|
1187
1225
|
checkProgress();
|
|
1188
|
-
|
|
1226
|
+
_context22.next = 9;
|
|
1189
1227
|
break;
|
|
1190
1228
|
case 6:
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
return
|
|
1229
|
+
_context22.prev = 6;
|
|
1230
|
+
_context22.t0 = _context22["catch"](1);
|
|
1231
|
+
return _context22.abrupt("return", this._handleError(_context22.t0));
|
|
1194
1232
|
case 9:
|
|
1195
1233
|
case "end":
|
|
1196
|
-
return
|
|
1234
|
+
return _context22.stop();
|
|
1197
1235
|
}
|
|
1198
|
-
},
|
|
1236
|
+
}, _callee22, this, [[1, 6]]);
|
|
1199
1237
|
}));
|
|
1200
|
-
function pollTaskProgress(
|
|
1238
|
+
function pollTaskProgress(_x15, _x16) {
|
|
1201
1239
|
return _pollTaskProgress.apply(this, arguments);
|
|
1202
1240
|
}
|
|
1203
1241
|
return pollTaskProgress;
|
|
@@ -1217,45 +1255,45 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1217
1255
|
}, {
|
|
1218
1256
|
key: "get",
|
|
1219
1257
|
value: (function () {
|
|
1220
|
-
var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1258
|
+
var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(endpoint) {
|
|
1221
1259
|
var params,
|
|
1222
1260
|
headers,
|
|
1223
1261
|
response,
|
|
1224
|
-
|
|
1225
|
-
return _regeneratorRuntime().wrap(function
|
|
1226
|
-
while (1) switch (
|
|
1262
|
+
_args23 = arguments;
|
|
1263
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
1264
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1227
1265
|
case 0:
|
|
1228
|
-
params =
|
|
1229
|
-
|
|
1266
|
+
params = _args23.length > 1 && _args23[1] !== undefined ? _args23[1] : {};
|
|
1267
|
+
_context23.prev = 1;
|
|
1230
1268
|
// Add the authToken to the headers
|
|
1231
1269
|
headers = {
|
|
1232
1270
|
authtoken: this.authtoken
|
|
1233
1271
|
}; // Make the GET request using Axios
|
|
1234
|
-
|
|
1272
|
+
_context23.next = 5;
|
|
1235
1273
|
return this.axios.get(endpoint, {
|
|
1236
1274
|
params: params,
|
|
1237
1275
|
headers: headers
|
|
1238
1276
|
});
|
|
1239
1277
|
case 5:
|
|
1240
|
-
response =
|
|
1278
|
+
response = _context23.sent;
|
|
1241
1279
|
if (!(response.data.ok === false)) {
|
|
1242
|
-
|
|
1280
|
+
_context23.next = 8;
|
|
1243
1281
|
break;
|
|
1244
1282
|
}
|
|
1245
|
-
return
|
|
1283
|
+
return _context23.abrupt("return", this._handleError(response));
|
|
1246
1284
|
case 8:
|
|
1247
|
-
return
|
|
1285
|
+
return _context23.abrupt("return", response.data);
|
|
1248
1286
|
case 11:
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
return
|
|
1287
|
+
_context23.prev = 11;
|
|
1288
|
+
_context23.t0 = _context23["catch"](1);
|
|
1289
|
+
return _context23.abrupt("return", this._handleError(_context23.t0));
|
|
1252
1290
|
case 14:
|
|
1253
1291
|
case "end":
|
|
1254
|
-
return
|
|
1292
|
+
return _context23.stop();
|
|
1255
1293
|
}
|
|
1256
|
-
},
|
|
1294
|
+
}, _callee23, this, [[1, 11]]);
|
|
1257
1295
|
}));
|
|
1258
|
-
function get(
|
|
1296
|
+
function get(_x17) {
|
|
1259
1297
|
return _get.apply(this, arguments);
|
|
1260
1298
|
}
|
|
1261
1299
|
return get;
|
|
@@ -1276,44 +1314,44 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
1276
1314
|
}, {
|
|
1277
1315
|
key: "post",
|
|
1278
1316
|
value: (function () {
|
|
1279
|
-
var _post = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1317
|
+
var _post = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(endpoint) {
|
|
1280
1318
|
var data,
|
|
1281
1319
|
headers,
|
|
1282
1320
|
response,
|
|
1283
|
-
|
|
1284
|
-
return _regeneratorRuntime().wrap(function
|
|
1285
|
-
while (1) switch (
|
|
1321
|
+
_args24 = arguments;
|
|
1322
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
1323
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1286
1324
|
case 0:
|
|
1287
|
-
data =
|
|
1288
|
-
|
|
1325
|
+
data = _args24.length > 1 && _args24[1] !== undefined ? _args24[1] : {};
|
|
1326
|
+
_context24.prev = 1;
|
|
1289
1327
|
// Add the authToken to the headers
|
|
1290
1328
|
headers = {
|
|
1291
1329
|
authtoken: this.authtoken
|
|
1292
1330
|
}; // Make the POST request using Axios
|
|
1293
|
-
|
|
1331
|
+
_context24.next = 5;
|
|
1294
1332
|
return this.axios.post(endpoint, data, {
|
|
1295
1333
|
headers: headers
|
|
1296
1334
|
});
|
|
1297
1335
|
case 5:
|
|
1298
|
-
response =
|
|
1336
|
+
response = _context24.sent;
|
|
1299
1337
|
if (!(response.data.ok === false)) {
|
|
1300
|
-
|
|
1338
|
+
_context24.next = 8;
|
|
1301
1339
|
break;
|
|
1302
1340
|
}
|
|
1303
|
-
return
|
|
1341
|
+
return _context24.abrupt("return", this._handleError(response));
|
|
1304
1342
|
case 8:
|
|
1305
|
-
return
|
|
1343
|
+
return _context24.abrupt("return", response.data);
|
|
1306
1344
|
case 11:
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
return
|
|
1345
|
+
_context24.prev = 11;
|
|
1346
|
+
_context24.t0 = _context24["catch"](1);
|
|
1347
|
+
return _context24.abrupt("return", this._handleError(_context24.t0));
|
|
1310
1348
|
case 14:
|
|
1311
1349
|
case "end":
|
|
1312
|
-
return
|
|
1350
|
+
return _context24.stop();
|
|
1313
1351
|
}
|
|
1314
|
-
},
|
|
1352
|
+
}, _callee24, this, [[1, 11]]);
|
|
1315
1353
|
}));
|
|
1316
|
-
function post(
|
|
1354
|
+
function post(_x18) {
|
|
1317
1355
|
return _post.apply(this, arguments);
|
|
1318
1356
|
}
|
|
1319
1357
|
return post;
|