roboto-js 1.1.3 → 1.1.5
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/rbt_api.cjs +5 -1
- package/dist/cjs/rbt_object.cjs +3 -3
- package/dist/cjs/rbt_user.cjs +26 -6
- package/dist/esm/rbt_api.js +5 -1
- package/dist/esm/rbt_object.js +3 -3
- package/dist/esm/rbt_user.js +26 -6
- package/package.json +1 -1
- package/src/rbt_api.js +7 -2
- package/src/rbt_object.js +2 -2
- package/src/rbt_user.js +22 -5
package/dist/cjs/rbt_api.cjs
CHANGED
|
@@ -832,7 +832,11 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
832
832
|
}
|
|
833
833
|
if (_lodash["default"].isObject(err) && _lodash["default"].get(err, 'response')) {
|
|
834
834
|
var msg = _lodash["default"].get(err, 'response.data.message', 'Error in API response');
|
|
835
|
-
|
|
835
|
+
if (msg.key) {
|
|
836
|
+
throw new Error(msg.key);
|
|
837
|
+
} else {
|
|
838
|
+
throw new Error(msg);
|
|
839
|
+
}
|
|
836
840
|
} else {
|
|
837
841
|
throw new Error(err.message || 'Unknown error');
|
|
838
842
|
}
|
package/dist/cjs/rbt_object.cjs
CHANGED
|
@@ -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(
|
|
139
|
+
console.log('RbtObject.save.error:', _context.t0);
|
|
140
|
+
//console.log(e.response.data);
|
|
141
141
|
throw _context.t0;
|
|
142
|
-
case
|
|
142
|
+
case 21:
|
|
143
143
|
case "end":
|
|
144
144
|
return _context.stop();
|
|
145
145
|
}
|
package/dist/cjs/rbt_user.cjs
CHANGED
|
@@ -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 ?
|
|
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(
|
|
135
|
+
console.log('RbtUser.save.error:', _context.t0);
|
|
136
|
+
//console.log(e.response.data);
|
|
137
137
|
throw _context.t0;
|
|
138
|
-
case
|
|
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
|
-
}()
|
|
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/dist/esm/rbt_api.js
CHANGED
|
@@ -832,7 +832,11 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
832
832
|
}
|
|
833
833
|
if (_lodash["default"].isObject(err) && _lodash["default"].get(err, 'response')) {
|
|
834
834
|
var msg = _lodash["default"].get(err, 'response.data.message', 'Error in API response');
|
|
835
|
-
|
|
835
|
+
if (msg.key) {
|
|
836
|
+
throw new Error(msg.key);
|
|
837
|
+
} else {
|
|
838
|
+
throw new Error(msg);
|
|
839
|
+
}
|
|
836
840
|
} else {
|
|
837
841
|
throw new Error(err.message || 'Unknown error');
|
|
838
842
|
}
|
package/dist/esm/rbt_object.js
CHANGED
|
@@ -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(
|
|
139
|
+
console.log('RbtObject.save.error:', _context.t0);
|
|
140
|
+
//console.log(e.response.data);
|
|
141
141
|
throw _context.t0;
|
|
142
|
-
case
|
|
142
|
+
case 21:
|
|
143
143
|
case "end":
|
|
144
144
|
return _context.stop();
|
|
145
145
|
}
|
package/dist/esm/rbt_user.js
CHANGED
|
@@ -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 ?
|
|
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(
|
|
135
|
+
console.log('RbtUser.save.error:', _context.t0);
|
|
136
|
+
//console.log(e.response.data);
|
|
137
137
|
throw _context.t0;
|
|
138
|
-
case
|
|
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
|
-
}()
|
|
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
package/src/rbt_api.js
CHANGED
|
@@ -68,7 +68,6 @@ export default class RbtApi {
|
|
|
68
68
|
localStorage.setItem('authtoken', response.data.authToken);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
|
|
72
71
|
return response.data;
|
|
73
72
|
} catch (e) {
|
|
74
73
|
|
|
@@ -486,7 +485,13 @@ export default class RbtApi {
|
|
|
486
485
|
|
|
487
486
|
if (_.isObject(err) && _.get(err, 'response')) {
|
|
488
487
|
const msg = _.get(err, 'response.data.message', 'Error in API response');
|
|
489
|
-
|
|
488
|
+
|
|
489
|
+
if(msg.key){
|
|
490
|
+
throw new Error(msg.key);
|
|
491
|
+
}
|
|
492
|
+
else{
|
|
493
|
+
throw new Error(msg);
|
|
494
|
+
}
|
|
490
495
|
|
|
491
496
|
} else {
|
|
492
497
|
throw new Error(err.message || 'Unknown error');
|
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 ?
|
|
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');
|