roboto-js 1.0.4 → 1.0.15
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/babel.config.json +1 -1
- package/babel.esm.config.json +7 -0
- package/client_test.js +5 -2
- package/dist/{rbt_api.js → cjs/index.cjs} +105 -125
- package/dist/cjs/rbt_api.cjs +335 -0
- package/dist/cjs/rbt_file.cjs +599 -0
- package/dist/cjs/rbt_object.cjs +176 -0
- package/dist/{index.js → esm/index.js} +83 -19
- package/dist/esm/rbt_api.js +335 -0
- package/dist/esm/rbt_file.js +599 -0
- package/dist/{rbt_object.js → esm/rbt_object.js} +42 -5
- package/package.json +9 -4
- package/package.next.json +32 -0
- package/postbuild-cjs.js +26 -0
- package/src/index.js +23 -7
- package/src/rbt_api.js +76 -2
- package/src/rbt_file.js +292 -0
- package/src/rbt_object.js +38 -0
package/src/rbt_object.js
CHANGED
|
@@ -21,6 +21,25 @@ export default class RbtObject {
|
|
|
21
21
|
_.set(this._data, path, value);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
getData() {
|
|
25
|
+
return {
|
|
26
|
+
...this._data
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
setData(newData) {
|
|
31
|
+
// Ensure the input is an object
|
|
32
|
+
if (typeof newData !== 'object' || newData === null) {
|
|
33
|
+
throw new Error('setData expects an object');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Iterate over each key in the newData object
|
|
37
|
+
Object.keys(newData).forEach(key => {
|
|
38
|
+
// Update the corresponding key in this._data
|
|
39
|
+
_.set(this._data, key, newData[key]);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
24
43
|
toRecord() {
|
|
25
44
|
return {
|
|
26
45
|
...this._internalData,
|
|
@@ -28,6 +47,20 @@ export default class RbtObject {
|
|
|
28
47
|
};
|
|
29
48
|
}
|
|
30
49
|
|
|
50
|
+
clone() {
|
|
51
|
+
// Create a deep copy of the current object's data
|
|
52
|
+
const clonedData = _.cloneDeep(this._internalData);
|
|
53
|
+
|
|
54
|
+
// Reset unique identifiers to ensure a new ID is generated upon saving
|
|
55
|
+
delete clonedData.id;
|
|
56
|
+
delete clonedData.id_revision;
|
|
57
|
+
|
|
58
|
+
// Create a new instance of RbtObject with the cloned data
|
|
59
|
+
const clonedObject = new RbtObject(clonedData, this._axios);
|
|
60
|
+
|
|
61
|
+
return clonedObject;
|
|
62
|
+
}
|
|
63
|
+
|
|
31
64
|
async save() {
|
|
32
65
|
if (!this._internalData.type) {
|
|
33
66
|
throw new Error('Cannot save object without type');
|
|
@@ -42,6 +75,11 @@ export default class RbtObject {
|
|
|
42
75
|
}
|
|
43
76
|
|
|
44
77
|
this._internalData = response.data;
|
|
78
|
+
|
|
79
|
+
this.id = response.data.id;
|
|
80
|
+
this.id_revision = response.data.id_revision;
|
|
81
|
+
this.type = response.data.type;
|
|
82
|
+
|
|
45
83
|
return this;
|
|
46
84
|
|
|
47
85
|
} catch (e) {
|