roboto-js 1.1.2 → 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.
- package/dist/cjs/rbt_api.cjs +2 -7
- package/dist/cjs/rbt_object.cjs +3 -3
- package/dist/cjs/rbt_user.cjs +26 -6
- package/dist/esm/rbt_api.js +2 -7
- 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 +3 -9
- package/src/rbt_object.js +2 -2
- package/src/rbt_user.js +22 -5
package/dist/cjs/rbt_api.cjs
CHANGED
|
@@ -270,7 +270,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
270
270
|
if (dataHash) {
|
|
271
271
|
record.data = dataHash;
|
|
272
272
|
}
|
|
273
|
-
return _context6.abrupt("return", new
|
|
273
|
+
return _context6.abrupt("return", new _rbt_user["default"](record, this.axios));
|
|
274
274
|
case 10:
|
|
275
275
|
_context6.prev = 10;
|
|
276
276
|
_context6.t0 = _context6["catch"](1);
|
|
@@ -825,7 +825,6 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
825
825
|
}, {
|
|
826
826
|
key: "_handleError",
|
|
827
827
|
value: function _handleError(err) {
|
|
828
|
-
debugger;
|
|
829
828
|
// Invoke the custom error handler if provided
|
|
830
829
|
if (this.customErrorHandler) {
|
|
831
830
|
var res = this.customErrorHandler(err);
|
|
@@ -833,11 +832,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
833
832
|
}
|
|
834
833
|
if (_lodash["default"].isObject(err) && _lodash["default"].get(err, 'response')) {
|
|
835
834
|
var msg = _lodash["default"].get(err, 'response.data.message', 'Error in API response');
|
|
836
|
-
|
|
837
|
-
throw new Error(msg.key);
|
|
838
|
-
} else {
|
|
839
|
-
throw new Error(msg);
|
|
840
|
-
}
|
|
835
|
+
throw new Error(msg);
|
|
841
836
|
} else {
|
|
842
837
|
throw new Error(err.message || 'Unknown error');
|
|
843
838
|
}
|
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
|
@@ -270,7 +270,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
270
270
|
if (dataHash) {
|
|
271
271
|
record.data = dataHash;
|
|
272
272
|
}
|
|
273
|
-
return _context6.abrupt("return", new
|
|
273
|
+
return _context6.abrupt("return", new _rbt_user["default"](record, this.axios));
|
|
274
274
|
case 10:
|
|
275
275
|
_context6.prev = 10;
|
|
276
276
|
_context6.t0 = _context6["catch"](1);
|
|
@@ -825,7 +825,6 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
825
825
|
}, {
|
|
826
826
|
key: "_handleError",
|
|
827
827
|
value: function _handleError(err) {
|
|
828
|
-
debugger;
|
|
829
828
|
// Invoke the custom error handler if provided
|
|
830
829
|
if (this.customErrorHandler) {
|
|
831
830
|
var res = this.customErrorHandler(err);
|
|
@@ -833,11 +832,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
833
832
|
}
|
|
834
833
|
if (_lodash["default"].isObject(err) && _lodash["default"].get(err, 'response')) {
|
|
835
834
|
var msg = _lodash["default"].get(err, 'response.data.message', 'Error in API response');
|
|
836
|
-
|
|
837
|
-
throw new Error(msg.key);
|
|
838
|
-
} else {
|
|
839
|
-
throw new Error(msg);
|
|
840
|
-
}
|
|
835
|
+
throw new Error(msg);
|
|
841
836
|
} else {
|
|
842
837
|
throw new Error(err.message || 'Unknown error');
|
|
843
838
|
}
|
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
|
@@ -2,7 +2,7 @@ import axios from 'axios';
|
|
|
2
2
|
import CryptoJS from 'crypto-js';
|
|
3
3
|
import RbtObject from './rbt_object.js';
|
|
4
4
|
import RbtUser from './rbt_user.js';
|
|
5
|
-
import RbtFile from './rbt_file.js';
|
|
5
|
+
import RbtFile from './rbt_file.js';
|
|
6
6
|
import _ from 'lodash';
|
|
7
7
|
import { openDB } from 'idb';
|
|
8
8
|
|
|
@@ -159,7 +159,7 @@ export default class RbtApi {
|
|
|
159
159
|
if(dataHash){
|
|
160
160
|
record.data = dataHash;
|
|
161
161
|
}
|
|
162
|
-
return new
|
|
162
|
+
return new RbtUser(record, this.axios);
|
|
163
163
|
} catch (e) {
|
|
164
164
|
debugger;
|
|
165
165
|
return this._handleError(e);
|
|
@@ -478,7 +478,6 @@ export default class RbtApi {
|
|
|
478
478
|
|
|
479
479
|
_handleError(err) {
|
|
480
480
|
|
|
481
|
-
debugger;
|
|
482
481
|
// Invoke the custom error handler if provided
|
|
483
482
|
if (this.customErrorHandler) {
|
|
484
483
|
let res = this.customErrorHandler(err);
|
|
@@ -487,13 +486,8 @@ export default class RbtApi {
|
|
|
487
486
|
|
|
488
487
|
if (_.isObject(err) && _.get(err, 'response')) {
|
|
489
488
|
const msg = _.get(err, 'response.data.message', 'Error in API response');
|
|
489
|
+
throw new Error(msg);
|
|
490
490
|
|
|
491
|
-
if(msg.key){
|
|
492
|
-
throw new Error(msg.key);
|
|
493
|
-
}
|
|
494
|
-
else{
|
|
495
|
-
throw new Error(msg);
|
|
496
|
-
}
|
|
497
491
|
} else {
|
|
498
492
|
throw new Error(err.message || 'Unknown error');
|
|
499
493
|
}
|
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');
|