roboto-js 1.1.3 → 1.1.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.
@@ -136,10 +136,10 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
136
136
  case 17:
137
137
  _context.prev = 17;
138
138
  _context.t0 = _context["catch"](2);
139
- console.log('RbtObject.save.error:');
140
- console.log(_context.t0.response.data);
139
+ console.log('RbtObject.save.error:', _context.t0);
140
+ //console.log(e.response.data);
141
141
  throw _context.t0;
142
- case 22:
142
+ case 21:
143
143
  case "end":
144
144
  return _context.stop();
145
145
  }
@@ -31,9 +31,9 @@ var RbtUser = exports["default"] = /*#__PURE__*/function () {
31
31
  isNew: options.isNew || false
32
32
  };
33
33
  if (record.data) {
34
- this._data = record.data;
34
+ this._data = this._deepUnpackJson(record.data);
35
35
  } else {
36
- this._data = record.dataJson ? JSON.parse(record.dataJson) : {};
36
+ this._data = record.dataJson ? this._deepUnpackJson(record.dataJson) : {};
37
37
  }
38
38
  }
39
39
  _createClass(RbtUser, [{
@@ -132,10 +132,10 @@ var RbtUser = exports["default"] = /*#__PURE__*/function () {
132
132
  case 17:
133
133
  _context.prev = 17;
134
134
  _context.t0 = _context["catch"](0);
135
- console.log('RbtUser.save.error:');
136
- console.log(_context.t0.response.data);
135
+ console.log('RbtUser.save.error:', _context.t0);
136
+ //console.log(e.response.data);
137
137
  throw _context.t0;
138
- case 22:
138
+ case 21:
139
139
  case "end":
140
140
  return _context.stop();
141
141
  }
@@ -145,7 +145,27 @@ var RbtUser = exports["default"] = /*#__PURE__*/function () {
145
145
  return _save.apply(this, arguments);
146
146
  }
147
147
  return save;
148
- }() //async delete() {
148
+ }()
149
+ }, {
150
+ key: "_deepUnpackJson",
151
+ value: function _deepUnpackJson(value) {
152
+ if (typeof value === 'string') {
153
+ try {
154
+ var parsed = JSON.parse(value);
155
+ return this._deepUnpackJson(parsed); // Recursively parse if the result is a string, object, or array
156
+ } catch (e) {
157
+ return value; // Return the original string if parsing fails
158
+ }
159
+ } else if (value !== null && _typeof(value) === 'object') {
160
+ // If it's an object (including arrays), recursively parse each value
161
+ for (var key in value) {
162
+ value[key] = this._deepUnpackJson(value[key]);
163
+ }
164
+ }
165
+ return value;
166
+ }
167
+
168
+ //async delete() {
149
169
  // if (!this._internalData.type) {
150
170
  // throw new Error('Cannot delete object without type');
151
171
  // }
@@ -136,10 +136,10 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
136
136
  case 17:
137
137
  _context.prev = 17;
138
138
  _context.t0 = _context["catch"](2);
139
- console.log('RbtObject.save.error:');
140
- console.log(_context.t0.response.data);
139
+ console.log('RbtObject.save.error:', _context.t0);
140
+ //console.log(e.response.data);
141
141
  throw _context.t0;
142
- case 22:
142
+ case 21:
143
143
  case "end":
144
144
  return _context.stop();
145
145
  }
@@ -31,9 +31,9 @@ var RbtUser = exports["default"] = /*#__PURE__*/function () {
31
31
  isNew: options.isNew || false
32
32
  };
33
33
  if (record.data) {
34
- this._data = record.data;
34
+ this._data = this._deepUnpackJson(record.data);
35
35
  } else {
36
- this._data = record.dataJson ? JSON.parse(record.dataJson) : {};
36
+ this._data = record.dataJson ? this._deepUnpackJson(record.dataJson) : {};
37
37
  }
38
38
  }
39
39
  _createClass(RbtUser, [{
@@ -132,10 +132,10 @@ var RbtUser = exports["default"] = /*#__PURE__*/function () {
132
132
  case 17:
133
133
  _context.prev = 17;
134
134
  _context.t0 = _context["catch"](0);
135
- console.log('RbtUser.save.error:');
136
- console.log(_context.t0.response.data);
135
+ console.log('RbtUser.save.error:', _context.t0);
136
+ //console.log(e.response.data);
137
137
  throw _context.t0;
138
- case 22:
138
+ case 21:
139
139
  case "end":
140
140
  return _context.stop();
141
141
  }
@@ -145,7 +145,27 @@ var RbtUser = exports["default"] = /*#__PURE__*/function () {
145
145
  return _save.apply(this, arguments);
146
146
  }
147
147
  return save;
148
- }() //async delete() {
148
+ }()
149
+ }, {
150
+ key: "_deepUnpackJson",
151
+ value: function _deepUnpackJson(value) {
152
+ if (typeof value === 'string') {
153
+ try {
154
+ var parsed = JSON.parse(value);
155
+ return this._deepUnpackJson(parsed); // Recursively parse if the result is a string, object, or array
156
+ } catch (e) {
157
+ return value; // Return the original string if parsing fails
158
+ }
159
+ } else if (value !== null && _typeof(value) === 'object') {
160
+ // If it's an object (including arrays), recursively parse each value
161
+ for (var key in value) {
162
+ value[key] = this._deepUnpackJson(value[key]);
163
+ }
164
+ }
165
+ return value;
166
+ }
167
+
168
+ //async delete() {
149
169
  // if (!this._internalData.type) {
150
170
  // throw new Error('Cannot delete object without type');
151
171
  // }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roboto-js",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "dist/cjs/index.cjs",
package/src/rbt_object.js CHANGED
@@ -104,8 +104,8 @@ export default class RbtObject {
104
104
  return this;
105
105
 
106
106
  } catch (e) {
107
- console.log('RbtObject.save.error:');
108
- console.log(e.response.data);
107
+ console.log('RbtObject.save.error:', e);
108
+ //console.log(e.response.data);
109
109
  throw e;
110
110
  }
111
111
  }
package/src/rbt_user.js CHANGED
@@ -13,11 +13,11 @@ export default class RbtUser {
13
13
  };
14
14
 
15
15
  if(record.data){
16
- this._data = record.data;
16
+ this._data = this._deepUnpackJson(record.data);
17
17
  } else {
18
- this._data = record.dataJson ? JSON.parse(record.dataJson) : {};
18
+ this._data = record.dataJson ? this._deepUnpackJson(record.dataJson) : {};
19
19
  }
20
-
20
+
21
21
  }
22
22
 
23
23
  get(path) {
@@ -103,12 +103,29 @@ export default class RbtUser {
103
103
  return this;
104
104
 
105
105
  } catch (e) {
106
- console.log('RbtUser.save.error:');
107
- console.log(e.response.data);
106
+ console.log('RbtUser.save.error:', e);
107
+ //console.log(e.response.data);
108
108
  throw e;
109
109
  }
110
110
  }
111
111
 
112
+ _deepUnpackJson(value){
113
+ if (typeof value === 'string') {
114
+ try {
115
+ const parsed = JSON.parse(value);
116
+ return this._deepUnpackJson(parsed); // Recursively parse if the result is a string, object, or array
117
+ } catch (e) {
118
+ return value; // Return the original string if parsing fails
119
+ }
120
+ } else if (value !== null && typeof value === 'object') {
121
+ // If it's an object (including arrays), recursively parse each value
122
+ for (const key in value) {
123
+ value[key] = this._deepUnpackJson(value[key]);
124
+ }
125
+ }
126
+ return value;
127
+ }
128
+
112
129
  //async delete() {
113
130
  // if (!this._internalData.type) {
114
131
  // throw new Error('Cannot delete object without type');