@live-change/framework 0.8.114 → 0.8.116
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/lib/definition/ModelDefinition.js +5 -4
- package/lib/utils.js +15 -0
- package/package.json +4 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import PropertyDefinition from "./PropertyDefinition.js"
|
|
2
|
-
import { crudChanges } from "../utils.js"
|
|
2
|
+
import { crudChanges, definitionToJSON } from "../utils.js"
|
|
3
3
|
|
|
4
4
|
class ModelDefinition {
|
|
5
5
|
|
|
@@ -44,8 +44,9 @@ class ModelDefinition {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
+
const fixed = definitionToJSON(this, true)
|
|
47
48
|
return {
|
|
48
|
-
...
|
|
49
|
+
...fixed,
|
|
49
50
|
properties,
|
|
50
51
|
indexes
|
|
51
52
|
}
|
|
@@ -62,12 +63,12 @@ class ModelDefinition {
|
|
|
62
63
|
"Index", "index", { model: this.name, storage: this.storage }))
|
|
63
64
|
if(oldModel.search && !this.search) changes.push({ operation: "searchDisabled", model: this.name })
|
|
64
65
|
if(!oldModel.search && this.search) changes.push({ operation: "searchEnabled", model: this.name })
|
|
65
|
-
if(oldModel.search && this.search && JSON.stringify(oldModel.search)
|
|
66
|
+
if(oldModel.search && this.search && JSON.stringify(oldModel.search) !== JSON.stringify(this.search))
|
|
66
67
|
changes.push({ operation: "searchUpdated", model: this.name })
|
|
67
68
|
|
|
68
69
|
const oldStorage = oldModel.storage || {}
|
|
69
70
|
const newStorage = this.storage || {}
|
|
70
|
-
if(JSON.stringify(oldStorage)
|
|
71
|
+
if(JSON.stringify(oldStorage) !== JSON.stringify(newStorage)) {
|
|
71
72
|
changes.push({ operation: "storageChanged", model: this.name, oldStorage, storage: newStorage })
|
|
72
73
|
for(let indexName in this.indexes) {
|
|
73
74
|
changes.push({ operation: "indexStorageChanged", index: indexName, oldStorage, storage: newStorage })
|
package/lib/utils.js
CHANGED
|
@@ -28,6 +28,21 @@ function toJSON(data) {
|
|
|
28
28
|
}))
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
export function definitionToJSON(definition, ignoreRoot = false) {
|
|
32
|
+
if(!definition) return definition
|
|
33
|
+
if(!ignoreRoot) {
|
|
34
|
+
if(typeof definition.getTypeName === 'function')
|
|
35
|
+
return definition.getTypeName()
|
|
36
|
+
if(typeof definition.toJSON === 'function')
|
|
37
|
+
return definition.toJSON()
|
|
38
|
+
}
|
|
39
|
+
if(typeof definition !== 'object') return definition
|
|
40
|
+
if(Array.isArray(definition)) return definition.map(definitionToJSON)
|
|
41
|
+
return Object.fromEntries(Object.entries(definition).map(
|
|
42
|
+
([key, value]) => [key, definitionToJSON(value)])
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
31
46
|
function setDifference(setA, setB) {
|
|
32
47
|
var difference = new Set(setA)
|
|
33
48
|
for (let elem of setB) difference.delete(elem)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/framework",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.116",
|
|
4
4
|
"description": "Live Change Framework - ultimate solution for real time mobile/web apps",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
},
|
|
23
23
|
"homepage": "https://github.com/live-change/live-change-stack",
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@live-change/dao": "^0.8.
|
|
26
|
-
"@live-change/uid": "^0.8.
|
|
25
|
+
"@live-change/dao": "^0.8.116",
|
|
26
|
+
"@live-change/uid": "^0.8.116"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "32131af3707ec744c9d314035676d09512483799"
|
|
29
29
|
}
|