roboto-js 1.8.2 → 1.8.4

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 CHANGED
@@ -1 +1 @@
1
- 2025-10-08T11:01:38.750Z
1
+ 2025-10-09T21:04:42.145Z
@@ -1745,6 +1745,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1745
1745
  status,
1746
1746
  message,
1747
1747
  output,
1748
+ errorResponse,
1748
1749
  _args25 = arguments;
1749
1750
  return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1750
1751
  while (1) switch (_context25.prev = _context25.next) {
@@ -1776,8 +1777,8 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1776
1777
  this.pollTaskProgress(jobId, callbacks);
1777
1778
  }
1778
1779
  if (status === 'ERROR' && onError) {
1779
- // Provide the current progress to the callback function
1780
- onError(response);
1780
+ // Normalize error response to have consistent message/label at top level
1781
+ onError(this._normalizeErrorResponse(response));
1781
1782
  }
1782
1783
  if (status === 'STOPPED' && onStopped) {
1783
1784
  // Provide the current progress to the callback function
@@ -1789,7 +1790,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1789
1790
  }
1790
1791
  if (status === 'DONE' && onDone) {
1791
1792
  // Provide the current progress to the callback function
1792
- //console.log('Finish (request) ',response);
1793
+ //console.log('Finish (request) ',response); s
1793
1794
  onDone(response);
1794
1795
  }
1795
1796
  return _context25.abrupt("return", {
@@ -1802,18 +1803,28 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1802
1803
  case 20:
1803
1804
  _context25.prev = 20;
1804
1805
  _context25.t0 = _context25["catch"](3);
1805
- if (typeof onError === 'function') {
1806
- onError(_context25.t0);
1807
- } else {
1808
- console.error('Error in runTask:', _context25.t0);
1809
- }
1810
- return _context25.abrupt("return", {
1806
+ // Standardize error format to match task response object
1807
+ // Support RbtError format with label and message
1808
+ errorResponse = {
1811
1809
  ok: false,
1812
1810
  jobId: null,
1813
1811
  status: 'ERROR',
1814
- error: _context25.t0.message
1815
- });
1816
- case 24:
1812
+ message: _context25.t0.message || _context25.t0.toString() || 'Unknown error',
1813
+ label: _context25.t0.label || _context25.t0.name || 'Error',
1814
+ output: {
1815
+ error: _context25.t0.message,
1816
+ label: _context25.t0.label,
1817
+ stack: _context25.t0.stack,
1818
+ originalError: _context25.t0
1819
+ }
1820
+ };
1821
+ if (typeof onError === 'function') {
1822
+ onError(errorResponse);
1823
+ } else {
1824
+ console.error('Error in runTask:', errorResponse.message);
1825
+ }
1826
+ return _context25.abrupt("return", errorResponse);
1827
+ case 25:
1817
1828
  case "end":
1818
1829
  return _context25.stop();
1819
1830
  }
@@ -1864,6 +1875,34 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1864
1875
  }
1865
1876
  return stopJob;
1866
1877
  }()
1878
+ /**
1879
+ * Normalize error response to have consistent message/label at top level
1880
+ * Extracts from messages array if present (from chain execution)
1881
+ */
1882
+ }, {
1883
+ key: "_normalizeErrorResponse",
1884
+ value: function _normalizeErrorResponse(response) {
1885
+ // If response already has message/label at top level and no messages array, return as-is
1886
+ if ((response.message || response.label) && !response.messages) {
1887
+ return response;
1888
+ }
1889
+
1890
+ // Extract the most recent error from messages array
1891
+ if (response.messages && response.messages.length > 0) {
1892
+ var lastMessage = response.messages[response.messages.length - 1];
1893
+ return _objectSpread(_objectSpread({}, response), {}, {
1894
+ message: lastMessage.message || response.message || 'Unknown error',
1895
+ label: lastMessage.label || response.label || 'Error'
1896
+ });
1897
+ }
1898
+
1899
+ // Fallback: ensure we have at least message/label fields
1900
+ return _objectSpread(_objectSpread({}, response), {}, {
1901
+ message: response.message || 'Unknown error',
1902
+ label: response.label || 'Error'
1903
+ });
1904
+ }
1905
+
1867
1906
  /**
1868
1907
  * Polls the progress of a long-running task.
1869
1908
  *
@@ -1904,8 +1943,8 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1904
1943
  onDone(response);
1905
1944
  }
1906
1945
  if (response.status === 'ERROR' && onError) {
1907
- // Provide the current progress to the callback function
1908
- onError(response);
1946
+ // Normalize error response to have consistent message/label at top level
1947
+ onError(_this9._normalizeErrorResponse(response));
1909
1948
  }
1910
1949
  if (response.status === 'STOPPED' && onStopped) {
1911
1950
  // Provide the current progress to the callback function
@@ -1917,7 +1956,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1917
1956
  }
1918
1957
 
1919
1958
  // Provide the current progress to the callback function
1920
- if (response.status == 'RUNNING') {
1959
+ if (response.status == 'RUNNING' && onProgress) {
1921
1960
  onProgress(response);
1922
1961
  }
1923
1962
 
@@ -1025,8 +1025,8 @@ export default class RbtApi {
1025
1025
  this.pollTaskProgress(jobId, callbacks);
1026
1026
  }
1027
1027
  if (status === 'ERROR' && onError) {
1028
- // Provide the current progress to the callback function
1029
- onError(response);
1028
+ // Normalize error response to have consistent message/label at top level
1029
+ onError(this._normalizeErrorResponse(response));
1030
1030
  }
1031
1031
  if (status === 'STOPPED' && onStopped) {
1032
1032
  // Provide the current progress to the callback function
@@ -1038,7 +1038,7 @@ export default class RbtApi {
1038
1038
  }
1039
1039
  if (status === 'DONE' && onDone) {
1040
1040
  // Provide the current progress to the callback function
1041
- //console.log('Finish (request) ',response);
1041
+ //console.log('Finish (request) ',response); s
1042
1042
  onDone(response);
1043
1043
  }
1044
1044
  return {
@@ -1049,17 +1049,27 @@ export default class RbtApi {
1049
1049
  output
1050
1050
  };
1051
1051
  } catch (e) {
1052
- if (typeof onError === 'function') {
1053
- onError(e);
1054
- } else {
1055
- console.error('Error in runTask:', e);
1056
- }
1057
- return {
1052
+ // Standardize error format to match task response object
1053
+ // Support RbtError format with label and message
1054
+ const errorResponse = {
1058
1055
  ok: false,
1059
1056
  jobId: null,
1060
1057
  status: 'ERROR',
1061
- error: e.message
1058
+ message: e.message || e.toString() || 'Unknown error',
1059
+ label: e.label || e.name || 'Error',
1060
+ output: {
1061
+ error: e.message,
1062
+ label: e.label,
1063
+ stack: e.stack,
1064
+ originalError: e
1065
+ }
1062
1066
  };
1067
+ if (typeof onError === 'function') {
1068
+ onError(errorResponse);
1069
+ } else {
1070
+ console.error('Error in runTask:', errorResponse.message);
1071
+ }
1072
+ return errorResponse;
1063
1073
  }
1064
1074
  }
1065
1075
  async stopJob(params = {}, callbacks = {}) {
@@ -1075,6 +1085,34 @@ export default class RbtApi {
1075
1085
  }
1076
1086
  }
1077
1087
 
1088
+ /**
1089
+ * Normalize error response to have consistent message/label at top level
1090
+ * Extracts from messages array if present (from chain execution)
1091
+ */
1092
+ _normalizeErrorResponse(response) {
1093
+ // If response already has message/label at top level and no messages array, return as-is
1094
+ if ((response.message || response.label) && !response.messages) {
1095
+ return response;
1096
+ }
1097
+
1098
+ // Extract the most recent error from messages array
1099
+ if (response.messages && response.messages.length > 0) {
1100
+ const lastMessage = response.messages[response.messages.length - 1];
1101
+ return {
1102
+ ...response,
1103
+ message: lastMessage.message || response.message || 'Unknown error',
1104
+ label: lastMessage.label || response.label || 'Error'
1105
+ };
1106
+ }
1107
+
1108
+ // Fallback: ensure we have at least message/label fields
1109
+ return {
1110
+ ...response,
1111
+ message: response.message || 'Unknown error',
1112
+ label: response.label || 'Error'
1113
+ };
1114
+ }
1115
+
1078
1116
  /**
1079
1117
  * Polls the progress of a long-running task.
1080
1118
  *
@@ -1107,8 +1145,8 @@ export default class RbtApi {
1107
1145
  onDone(response);
1108
1146
  }
1109
1147
  if (response.status === 'ERROR' && onError) {
1110
- // Provide the current progress to the callback function
1111
- onError(response);
1148
+ // Normalize error response to have consistent message/label at top level
1149
+ onError(this._normalizeErrorResponse(response));
1112
1150
  }
1113
1151
  if (response.status === 'STOPPED' && onStopped) {
1114
1152
  // Provide the current progress to the callback function
@@ -1120,7 +1158,7 @@ export default class RbtApi {
1120
1158
  }
1121
1159
 
1122
1160
  // Provide the current progress to the callback function
1123
- if (response.status == 'RUNNING') {
1161
+ if (response.status == 'RUNNING' && onProgress) {
1124
1162
  onProgress(response);
1125
1163
  }
1126
1164
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roboto-js",
3
- "version": "1.8.2",
3
+ "version": "1.8.4",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "dist/cjs/index.cjs",
package/src/rbt_api.js CHANGED
@@ -1078,8 +1078,8 @@ export default class RbtApi {
1078
1078
  this.pollTaskProgress(jobId, callbacks);
1079
1079
  }
1080
1080
  if (status === 'ERROR' && onError){
1081
- // Provide the current progress to the callback function
1082
- onError(response);
1081
+ // Normalize error response to have consistent message/label at top level
1082
+ onError(this._normalizeErrorResponse(response));
1083
1083
  }
1084
1084
  if (status === 'STOPPED' && onStopped){
1085
1085
  // Provide the current progress to the callback function
@@ -1091,20 +1091,35 @@ export default class RbtApi {
1091
1091
  }
1092
1092
  if (status === 'DONE' && onDone){
1093
1093
  // Provide the current progress to the callback function
1094
- //console.log('Finish (request) ',response);
1094
+ //console.log('Finish (request) ',response); s
1095
1095
  onDone(response);
1096
1096
  }
1097
1097
 
1098
1098
  return { ok, jobId, status, message, output };
1099
1099
 
1100
1100
  } catch (e) {
1101
+ // Standardize error format to match task response object
1102
+ // Support RbtError format with label and message
1103
+ const errorResponse = {
1104
+ ok: false,
1105
+ jobId: null,
1106
+ status: 'ERROR',
1107
+ message: e.message || e.toString() || 'Unknown error',
1108
+ label: e.label || e.name || 'Error',
1109
+ output: {
1110
+ error: e.message,
1111
+ label: e.label,
1112
+ stack: e.stack,
1113
+ originalError: e
1114
+ }
1115
+ };
1101
1116
 
1102
1117
  if (typeof onError === 'function') {
1103
- onError(e);
1118
+ onError(errorResponse);
1104
1119
  } else {
1105
- console.error('Error in runTask:', e);
1120
+ console.error('Error in runTask:', errorResponse.message);
1106
1121
  }
1107
- return { ok: false, jobId: null, status: 'ERROR', error: e.message };
1122
+ return errorResponse;
1108
1123
 
1109
1124
  }
1110
1125
  }
@@ -1127,6 +1142,34 @@ export default class RbtApi {
1127
1142
  }
1128
1143
 
1129
1144
 
1145
+ /**
1146
+ * Normalize error response to have consistent message/label at top level
1147
+ * Extracts from messages array if present (from chain execution)
1148
+ */
1149
+ _normalizeErrorResponse(response) {
1150
+ // If response already has message/label at top level and no messages array, return as-is
1151
+ if ((response.message || response.label) && !response.messages) {
1152
+ return response;
1153
+ }
1154
+
1155
+ // Extract the most recent error from messages array
1156
+ if (response.messages && response.messages.length > 0) {
1157
+ const lastMessage = response.messages[response.messages.length - 1];
1158
+ return {
1159
+ ...response,
1160
+ message: lastMessage.message || response.message || 'Unknown error',
1161
+ label: lastMessage.label || response.label || 'Error'
1162
+ };
1163
+ }
1164
+
1165
+ // Fallback: ensure we have at least message/label fields
1166
+ return {
1167
+ ...response,
1168
+ message: response.message || 'Unknown error',
1169
+ label: response.label || 'Error'
1170
+ };
1171
+ }
1172
+
1130
1173
  /**
1131
1174
  * Polls the progress of a long-running task.
1132
1175
  *
@@ -1150,8 +1193,8 @@ export default class RbtApi {
1150
1193
  onDone(response);
1151
1194
  }
1152
1195
  if (response.status === 'ERROR' && onError){
1153
- // Provide the current progress to the callback function
1154
- onError(response);
1196
+ // Normalize error response to have consistent message/label at top level
1197
+ onError(this._normalizeErrorResponse(response));
1155
1198
  }
1156
1199
  if (response.status === 'STOPPED' && onStopped){
1157
1200
  // Provide the current progress to the callback function
@@ -1163,7 +1206,7 @@ export default class RbtApi {
1163
1206
  }
1164
1207
 
1165
1208
  // Provide the current progress to the callback function
1166
- if(response.status == 'RUNNING'){
1209
+ if(response.status == 'RUNNING' && onProgress){
1167
1210
  onProgress(response);
1168
1211
  }
1169
1212