roboto-js 1.4.43 → 1.4.45

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.
@@ -335,7 +335,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
335
335
  key: "loadCurrentUser",
336
336
  value: function () {
337
337
  var _loadCurrentUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
338
- var _response$user, response;
338
+ var response, _response$user;
339
339
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
340
340
  while (1) switch (_context7.prev = _context7.next) {
341
341
  case 0:
@@ -347,7 +347,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
347
347
  return _context7.abrupt("return", this.currentUser);
348
348
  case 3:
349
349
  if (!this.authtoken) {
350
- _context7.next = 12;
350
+ _context7.next = 13;
351
351
  break;
352
352
  }
353
353
  _context7.next = 6;
@@ -360,23 +360,26 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
360
360
  }
361
361
  return _context7.abrupt("return", null);
362
362
  case 9:
363
- this.currentUser = new _rbt_user["default"]({
364
- id: response === null || response === void 0 || (_response$user = response.user) === null || _response$user === void 0 ? void 0 : _response$user.id
365
- }, this.axios);
366
- this.currentUser.setData(response.user);
363
+ if (response !== null && response !== void 0 && response.user) {
364
+ this.currentUser = new _rbt_user["default"]({
365
+ id: response === null || response === void 0 || (_response$user = response.user) === null || _response$user === void 0 ? void 0 : _response$user.id
366
+ }, this.axios);
367
+ this.currentUser.setData(response.user);
368
+ }
367
369
  return _context7.abrupt("return", this.currentUser);
368
- case 12:
370
+ case 13:
369
371
  this.currentUser = null;
372
+ case 14:
370
373
  return _context7.abrupt("return", null);
371
- case 16:
372
- _context7.prev = 16;
374
+ case 17:
375
+ _context7.prev = 17;
373
376
  _context7.t0 = _context7["catch"](0);
374
377
  return _context7.abrupt("return", this._handleError(_context7.t0));
375
- case 19:
378
+ case 20:
376
379
  case "end":
377
380
  return _context7.stop();
378
381
  }
379
- }, _callee7, this, [[0, 16]]);
382
+ }, _callee7, this, [[0, 17]]);
380
383
  }));
381
384
  function loadCurrentUser() {
382
385
  return _loadCurrentUser.apply(this, arguments);
@@ -692,26 +695,28 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
692
695
  case 0:
693
696
  dataHash = _args15.length > 1 && _args15[1] !== undefined ? _args15[1] : {};
694
697
  _context15.prev = 1;
695
- _context15.next = 4;
698
+ debugger;
699
+ _context15.next = 5;
696
700
  return this.axios.post('/object_service/createObject', [type, dataHash]);
697
- case 4:
701
+ case 5:
698
702
  response = _context15.sent;
699
703
  record = response.data;
700
704
  if (dataHash) {
701
705
  record.data = dataHash;
702
706
  }
707
+ debugger;
703
708
  return _context15.abrupt("return", new _rbt_object["default"](record, this.axios, {
704
709
  isNew: true
705
710
  }));
706
- case 10:
707
- _context15.prev = 10;
711
+ case 12:
712
+ _context15.prev = 12;
708
713
  _context15.t0 = _context15["catch"](1);
709
714
  return _context15.abrupt("return", this._handleError(_context15.t0));
710
- case 13:
715
+ case 15:
711
716
  case "end":
712
717
  return _context15.stop();
713
718
  }
714
- }, _callee15, this, [[1, 10]]);
719
+ }, _callee15, this, [[1, 12]]);
715
720
  }));
716
721
  function create(_x10) {
717
722
  return _create.apply(this, arguments);
@@ -322,8 +322,14 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
322
322
  value: function _deepUnpackJson(value) {
323
323
  if (typeof value === 'string') {
324
324
  try {
325
- var parsed = JSON.parse(value);
326
- return this._deepUnpackJson(parsed); // Recursively parse if the result is a string, object, or array
325
+ // Only parse as JSON if it's not a large number
326
+ // https://chatgpt.com/c/6745902c-edf4-800c-ab52-31bf27dde2bd
327
+ //
328
+ if (!/^\d{16,}$/.test(value)) {
329
+ var parsed = JSON.parse(value);
330
+ // Recursively parse if the result is a string, object, or array
331
+ return this._deepUnpackJson(parsed);
332
+ }
327
333
  } catch (e) {
328
334
  return value; // Return the original string if parsing fails
329
335
  }
@@ -167,16 +167,18 @@ export default class RbtApi {
167
167
  if (this.authtoken) {
168
168
  let response = await this.refreshAuthToken(this.authtoken);
169
169
  if (!response) return null;
170
- this.currentUser = new RbtUser({
171
- id: response?.user?.id
172
- }, this.axios);
173
- this.currentUser.setData(response.user);
170
+ if (response?.user) {
171
+ this.currentUser = new RbtUser({
172
+ id: response?.user?.id
173
+ }, this.axios);
174
+ this.currentUser.setData(response.user);
175
+ }
174
176
  return this.currentUser;
175
-
176
177
  //this.currentOrg = new RbtObject(response.organization, this.axios);
177
178
  //this.currentOrg.type = '<@iac.organization>';
179
+ } else {
180
+ this.currentUser = null;
178
181
  }
179
- this.currentUser = null;
180
182
  return null;
181
183
  } catch (e) {
182
184
  return this._handleError(e);
@@ -325,11 +327,13 @@ export default class RbtApi {
325
327
  */
326
328
  async create(type, dataHash = {}) {
327
329
  try {
330
+ debugger;
328
331
  const response = await this.axios.post('/object_service/createObject', [type, dataHash]);
329
332
  const record = response.data;
330
333
  if (dataHash) {
331
334
  record.data = dataHash;
332
335
  }
336
+ debugger;
333
337
  return new RbtObject(record, this.axios, {
334
338
  isNew: true
335
339
  });
@@ -220,8 +220,14 @@ export default class RbtObject {
220
220
  _deepUnpackJson(value) {
221
221
  if (typeof value === 'string') {
222
222
  try {
223
- const parsed = JSON.parse(value);
224
- return this._deepUnpackJson(parsed); // Recursively parse if the result is a string, object, or array
223
+ // Only parse as JSON if it's not a large number
224
+ // https://chatgpt.com/c/6745902c-edf4-800c-ab52-31bf27dde2bd
225
+ //
226
+ if (!/^\d{16,}$/.test(value)) {
227
+ const parsed = JSON.parse(value);
228
+ // Recursively parse if the result is a string, object, or array
229
+ return this._deepUnpackJson(parsed);
230
+ }
225
231
  } catch (e) {
226
232
  return value; // Return the original string if parsing fails
227
233
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roboto-js",
3
- "version": "1.4.43",
3
+ "version": "1.4.45",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "dist/cjs/index.cjs",
package/src/rbt_api.js CHANGED
@@ -208,16 +208,21 @@ export default class RbtApi {
208
208
  let response = await this.refreshAuthToken(this.authtoken);
209
209
  if(!response) return null;
210
210
 
211
- this.currentUser = new RbtUser({ id: response?.user?.id }, this.axios);
212
- this.currentUser.setData(response.user);
213
- return this.currentUser;
211
+ if(response?.user){
212
+
213
+ this.currentUser = new RbtUser({ id: response?.user?.id }, this.axios);
214
+ this.currentUser.setData(response.user);
215
+
216
+ }
214
217
 
218
+ return this.currentUser;
215
219
  //this.currentOrg = new RbtObject(response.organization, this.axios);
216
220
  //this.currentOrg.type = '<@iac.organization>';
217
221
 
218
222
  }
219
-
220
- this.currentUser = null;
223
+ else{
224
+ this.currentUser = null;
225
+ }
221
226
  return null;
222
227
 
223
228
  }
@@ -403,12 +408,14 @@ export default class RbtApi {
403
408
  */
404
409
  async create(type, dataHash={}) {
405
410
  try {
411
+ debugger;
406
412
  const response = await this.axios.post('/object_service/createObject', [type, dataHash]);
407
413
  const record = response.data;
408
414
 
409
415
  if(dataHash){
410
416
  record.data = dataHash;
411
417
  }
418
+ debugger;
412
419
  return new RbtObject(record, this.axios, { isNew: true });
413
420
  } catch (e) {
414
421
  return this._handleError(e);
package/src/rbt_object.js CHANGED
@@ -249,8 +249,15 @@ export default class RbtObject {
249
249
  _deepUnpackJson(value){
250
250
  if (typeof value === 'string') {
251
251
  try {
252
- const parsed = JSON.parse(value);
253
- return this._deepUnpackJson(parsed); // Recursively parse if the result is a string, object, or array
252
+
253
+ // Only parse as JSON if it's not a large number
254
+ // https://chatgpt.com/c/6745902c-edf4-800c-ab52-31bf27dde2bd
255
+ //
256
+ if (!/^\d{16,}$/.test(value)) {
257
+ const parsed = JSON.parse(value);
258
+ // Recursively parse if the result is a string, object, or array
259
+ return this._deepUnpackJson(parsed);
260
+ }
254
261
  } catch (e) {
255
262
  return value; // Return the original string if parsing fails
256
263
  }