roboto-js 1.4.45 → 1.4.47

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.
@@ -1122,11 +1122,11 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1122
1122
  value: (function () {
1123
1123
  var _pollTaskProgress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(jobId, callbacks) {
1124
1124
  var _this3 = this;
1125
- var onProgress, onError, onStopped, onWaiting, onDone, checkProgress;
1125
+ var onProgress, onError, onStopped, onWaiting, onDone, _callbacks$pollingInt, pollingInterval, checkProgress;
1126
1126
  return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1127
1127
  while (1) switch (_context21.prev = _context21.next) {
1128
1128
  case 0:
1129
- onProgress = callbacks.onProgress, onError = callbacks.onError, onStopped = callbacks.onStopped, onWaiting = callbacks.onWaiting, onDone = callbacks.onDone;
1129
+ 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;
1130
1130
  _context21.prev = 1;
1131
1131
  checkProgress = /*#__PURE__*/function () {
1132
1132
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
@@ -1166,7 +1166,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
1166
1166
 
1167
1167
  // Continue polling if the status is 'RUNNING' or STOPPING
1168
1168
  if (['RUNNING', 'STOPPING'].includes(response.status)) {
1169
- setTimeout(checkProgress, 2000); // Poll every 2 seconds
1169
+ setTimeout(checkProgress, pollingInterval); // Poll every 2 seconds
1170
1170
  }
1171
1171
  case 9:
1172
1172
  case "end":
@@ -151,8 +151,14 @@ var RbtUser = exports["default"] = /*#__PURE__*/function () {
151
151
  value: function _deepUnpackJson(value) {
152
152
  if (typeof value === 'string') {
153
153
  try {
154
- var parsed = JSON.parse(value);
155
- return this._deepUnpackJson(parsed); // Recursively parse if the result is a string, object, or array
154
+ // Only parse as JSON if it's not a large number
155
+ // https://chatgpt.com/c/6745902c-edf4-800c-ab52-31bf27dde2bd
156
+ //
157
+ if (!/^\d{16,}$/.test(value)) {
158
+ var parsed = JSON.parse(value);
159
+ // Recursively parse if the result is a string, object, or array
160
+ return this._deepUnpackJson(parsed);
161
+ }
156
162
  } catch (e) {
157
163
  return value; // Return the original string if parsing fails
158
164
  }
@@ -561,6 +561,7 @@ export default class RbtApi {
561
561
  } = callbacks;
562
562
  try {
563
563
  const response = await this.post('/task_service/runChain', params);
564
+
564
565
  // Check if response and response.data are defined
565
566
  if (!response) {
566
567
  throw new Error('Invalid server response');
@@ -649,7 +650,8 @@ export default class RbtApi {
649
650
  onError,
650
651
  onStopped,
651
652
  onWaiting,
652
- onDone
653
+ onDone,
654
+ pollingInterval = 2000
653
655
  } = callbacks;
654
656
  try {
655
657
  const checkProgress = async () => {
@@ -683,7 +685,7 @@ export default class RbtApi {
683
685
 
684
686
  // Continue polling if the status is 'RUNNING' or STOPPING
685
687
  if (['RUNNING', 'STOPPING'].includes(response.status)) {
686
- setTimeout(checkProgress, 2000); // Poll every 2 seconds
688
+ setTimeout(checkProgress, pollingInterval); // Poll every 2 seconds
687
689
  }
688
690
  };
689
691
  checkProgress();
@@ -92,8 +92,14 @@ export default class RbtUser {
92
92
  _deepUnpackJson(value) {
93
93
  if (typeof value === 'string') {
94
94
  try {
95
- const parsed = JSON.parse(value);
96
- return this._deepUnpackJson(parsed); // Recursively parse if the result is a string, object, or array
95
+ // Only parse as JSON if it's not a large number
96
+ // https://chatgpt.com/c/6745902c-edf4-800c-ab52-31bf27dde2bd
97
+ //
98
+ if (!/^\d{16,}$/.test(value)) {
99
+ const parsed = JSON.parse(value);
100
+ // Recursively parse if the result is a string, object, or array
101
+ return this._deepUnpackJson(parsed);
102
+ }
97
103
  } catch (e) {
98
104
  return value; // Return the original string if parsing fails
99
105
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roboto-js",
3
- "version": "1.4.45",
3
+ "version": "1.4.47",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "dist/cjs/index.cjs",
package/src/rbt_api.js CHANGED
@@ -620,6 +620,7 @@ export default class RbtApi {
620
620
 
621
621
  try {
622
622
  const response = await this.post('/task_service/runChain', params);
623
+
623
624
  // Check if response and response.data are defined
624
625
  if (!response) {
625
626
  throw new Error('Invalid server response');
@@ -696,7 +697,7 @@ export default class RbtApi {
696
697
  * the task is completed or an error occurs.
697
698
  */
698
699
  async pollTaskProgress(jobId, callbacks) {
699
- const { onProgress, onError, onStopped, onWaiting, onDone } = callbacks;
700
+ const { onProgress, onError, onStopped, onWaiting, onDone, pollingInterval = 2000 } = callbacks;
700
701
  try {
701
702
  const checkProgress = async () => {
702
703
  const response = await this.get(`/task_service/pollChainProgress`, { jobId: jobId });
@@ -727,7 +728,7 @@ export default class RbtApi {
727
728
 
728
729
  // Continue polling if the status is 'RUNNING' or STOPPING
729
730
  if (['RUNNING','STOPPING'].includes(response.status)) {
730
- setTimeout(checkProgress, 2000); // Poll every 2 seconds
731
+ setTimeout(checkProgress, pollingInterval); // Poll every 2 seconds
731
732
  }
732
733
  };
733
734
 
package/src/rbt_user.js CHANGED
@@ -112,8 +112,15 @@ export default class RbtUser {
112
112
  _deepUnpackJson(value){
113
113
  if (typeof value === 'string') {
114
114
  try {
115
- const parsed = JSON.parse(value);
116
- return this._deepUnpackJson(parsed); // Recursively parse if the result is a string, object, or array
115
+
116
+ // Only parse as JSON if it's not a large number
117
+ // https://chatgpt.com/c/6745902c-edf4-800c-ab52-31bf27dde2bd
118
+ //
119
+ if (!/^\d{16,}$/.test(value)) {
120
+ const parsed = JSON.parse(value);
121
+ // Recursively parse if the result is a string, object, or array
122
+ return this._deepUnpackJson(parsed);
123
+ }
117
124
  } catch (e) {
118
125
  return value; // Return the original string if parsing fails
119
126
  }