roboto-js 1.3.18 → 1.4.1

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.
@@ -91,6 +91,11 @@ var Roboto = exports["default"] = /*#__PURE__*/function () {
91
91
  this.api.setErrorHandler(customErrorHandler);
92
92
  }
93
93
  }
94
+ }, {
95
+ key: "recordToInstance",
96
+ value: function recordToInstance(recordHash) {
97
+ return new _rbt_object["default"](recordHash, this.api.axios);
98
+ }
94
99
  }, {
95
100
  key: "_stripHttpsForDomains",
96
101
  value: function _stripHttpsForDomains(baseUrl, domains) {
@@ -24,6 +24,7 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
24
24
  _classCallCheck(this, RbtObject);
25
25
  this._axios = axiosInstance;
26
26
  this._internalData = record;
27
+ this.isRbtObject = true;
27
28
  this.id = record.id;
28
29
  this.id_revision = record.id_revision;
29
30
  this.rpcMeta = {
@@ -85,6 +86,17 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
85
86
  rpcMeta: this.rpcMeta
86
87
  });
87
88
  }
89
+ }, {
90
+ key: "serialize",
91
+ value: function serialize() {
92
+ return JSON.stringify(this.toRecord());
93
+ }
94
+ }, {
95
+ key: "deserialize",
96
+ value: function deserialize(strRecord) {
97
+ var record = JSON.parse(strRecord);
98
+ return new RbtObject(record, this._axios);
99
+ }
88
100
  }, {
89
101
  key: "clone",
90
102
  value: function clone() {
package/dist/esm/index.js CHANGED
@@ -56,6 +56,9 @@ export default class Roboto {
56
56
  this.api.setErrorHandler(customErrorHandler);
57
57
  }
58
58
  }
59
+ recordToInstance(recordHash) {
60
+ return new RbtObject(recordHash, this.api.axios);
61
+ }
59
62
  _stripHttpsForDomains(baseUrl, domains) {
60
63
  return baseUrl.replace(new RegExp(`^https://(${domains.map(domain => domain.replace(/\./g, '\\.')).join('|')})`), 'http://$1');
61
64
  }
@@ -3,6 +3,7 @@ export default class RbtObject {
3
3
  constructor(record, axiosInstance, options = {}) {
4
4
  this._axios = axiosInstance;
5
5
  this._internalData = record;
6
+ this.isRbtObject = true;
6
7
  this.id = record.id;
7
8
  this.id_revision = record.id_revision;
8
9
  this.rpcMeta = {
@@ -54,6 +55,13 @@ export default class RbtObject {
54
55
  rpcMeta: this.rpcMeta
55
56
  };
56
57
  }
58
+ serialize() {
59
+ return JSON.stringify(this.toRecord());
60
+ }
61
+ deserialize(strRecord) {
62
+ let record = JSON.parse(strRecord);
63
+ return new RbtObject(record, this._axios);
64
+ }
57
65
  clone() {
58
66
  // Create a deep copy of the current object's data
59
67
  const clonedData = _.cloneDeep(this._internalData);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roboto-js",
3
- "version": "1.3.18",
3
+ "version": "1.4.1",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "dist/cjs/index.cjs",
package/src/index.js CHANGED
@@ -68,6 +68,12 @@ export default class Roboto{
68
68
  }
69
69
  }
70
70
 
71
+ recordToInstance(recordHash){
72
+
73
+ return new RbtObject(recordHash, this.api.axios);
74
+
75
+ }
76
+
71
77
  _stripHttpsForDomains(baseUrl, domains) {
72
78
  return baseUrl.replace(new RegExp(`^https://(${domains.map(domain => domain.replace(/\./g, '\\.')).join('|')})`), 'http://$1');
73
79
  }
package/src/rbt_object.js CHANGED
@@ -5,6 +5,7 @@ export default class RbtObject {
5
5
  constructor(record, axiosInstance, options = {}) {
6
6
  this._axios = axiosInstance;
7
7
  this._internalData = record;
8
+ this.isRbtObject = true;
8
9
  this.id = record.id;
9
10
  this.id_revision = record.id_revision;
10
11
  this.rpcMeta = {
@@ -66,6 +67,16 @@ export default class RbtObject {
66
67
  };
67
68
  }
68
69
 
70
+
71
+ serialize(){
72
+ return JSON.stringify(this.toRecord());
73
+ }
74
+
75
+ deserialize(strRecord){
76
+ let record = JSON.parse(strRecord);
77
+ return new RbtObject(record, this._axios);
78
+ }
79
+
69
80
  clone() {
70
81
  // Create a deep copy of the current object's data
71
82
  const clonedData = _.cloneDeep(this._internalData);