@static-suite/static-suite-data-server 0.0.13 → 0.0.14
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storeManager.d.ts","sourceRoot":"","sources":["../../../src/lib/store/storeManager.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"storeManager.d.ts","sourceRoot":"","sources":["../../../src/lib/store/storeManager.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAuH7C,eAAO,MAAM,YAAY,EAAE,YAmG1B,CAAC"}
|
|
@@ -27,6 +27,7 @@ const setFileIntoStore = (relativeFilepath) => {
|
|
|
27
27
|
let previousStoredData = null;
|
|
28
28
|
const dataToStore = fileContent.json || fileContent.raw;
|
|
29
29
|
const previousData = _1.store.data.get(relativeFilepath);
|
|
30
|
+
let skipUpdating = false;
|
|
30
31
|
if (fileContent.json) {
|
|
31
32
|
// Check if the object already exists to make sure we don't break the reference
|
|
32
33
|
if (dataToStore && typeof dataToStore === 'object') {
|
|
@@ -45,15 +46,26 @@ const setFileIntoStore = (relativeFilepath) => {
|
|
|
45
46
|
_1.store.index.uuid.get(langcode)?.delete(uuid);
|
|
46
47
|
}
|
|
47
48
|
// Delete all referenced object properties and copy them to another object.
|
|
48
|
-
previousStoredData =
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
previousStoredData = previousData.data?.content
|
|
50
|
+
? { data: { content: {} } }
|
|
51
|
+
: {};
|
|
52
|
+
if (previousData.metadata) {
|
|
53
|
+
// We cannot use structuredClone to clone the whole JSON,
|
|
54
|
+
// since proxies used by queries are not supported by structuredClone.
|
|
55
|
+
previousStoredData.metadata = structuredClone(previousData.metadata);
|
|
56
|
+
}
|
|
57
|
+
const previousStoredDataPointer = previousStoredData.data?.content || previousStoredData;
|
|
58
|
+
const previousDataPointer = previousData.data?.content || previousData;
|
|
59
|
+
Object.keys(previousDataPointer).forEach(key => {
|
|
60
|
+
previousStoredDataPointer[key] = previousDataPointer[key];
|
|
61
|
+
delete previousDataPointer[key];
|
|
52
62
|
});
|
|
53
|
-
//
|
|
54
|
-
|
|
55
|
-
|
|
63
|
+
// Hydrate new object properties into referenced object
|
|
64
|
+
const dataToStorePointer = dataToStore.data?.content || dataToStore;
|
|
65
|
+
Object.keys(dataToStorePointer).forEach(key => {
|
|
66
|
+
previousDataPointer[key] = dataToStorePointer[key];
|
|
56
67
|
});
|
|
68
|
+
skipUpdating = true;
|
|
57
69
|
}
|
|
58
70
|
// Add data to UUID index.
|
|
59
71
|
const uuid = dataToStore.data?.content?.uuid;
|
|
@@ -75,7 +87,9 @@ const setFileIntoStore = (relativeFilepath) => {
|
|
|
75
87
|
else {
|
|
76
88
|
previousStoredData = previousData;
|
|
77
89
|
}
|
|
78
|
-
|
|
90
|
+
if (!skipUpdating) {
|
|
91
|
+
_1.store.data.set(relativeFilepath, dataToStore);
|
|
92
|
+
}
|
|
79
93
|
// Remove this path from store.deleted
|
|
80
94
|
_1.store.deleted.delete(relativeFilepath);
|
|
81
95
|
return { fileContent: dataToStore, previousStoredData };
|
package/package.json
CHANGED
|
@@ -35,6 +35,7 @@ const setFileIntoStore = (
|
|
|
35
35
|
|
|
36
36
|
const dataToStore = fileContent.json || fileContent.raw;
|
|
37
37
|
const previousData = store.data.get(relativeFilepath);
|
|
38
|
+
let skipUpdating = false;
|
|
38
39
|
if (fileContent.json) {
|
|
39
40
|
// Check if the object already exists to make sure we don't break the reference
|
|
40
41
|
if (dataToStore && typeof dataToStore === 'object') {
|
|
@@ -59,15 +60,28 @@ const setFileIntoStore = (
|
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
// Delete all referenced object properties and copy them to another object.
|
|
62
|
-
previousStoredData =
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
previousStoredData = previousData.data?.content
|
|
64
|
+
? { data: { content: {} } }
|
|
65
|
+
: {};
|
|
66
|
+
if (previousData.metadata) {
|
|
67
|
+
// We cannot use structuredClone to clone the whole JSON,
|
|
68
|
+
// since proxies used by queries are not supported by structuredClone.
|
|
69
|
+
previousStoredData.metadata = structuredClone(previousData.metadata);
|
|
70
|
+
}
|
|
71
|
+
const previousStoredDataPointer =
|
|
72
|
+
previousStoredData.data?.content || previousStoredData;
|
|
73
|
+
const previousDataPointer = previousData.data?.content || previousData;
|
|
74
|
+
Object.keys(previousDataPointer).forEach(key => {
|
|
75
|
+
previousStoredDataPointer[key] = previousDataPointer[key];
|
|
76
|
+
delete previousDataPointer[key];
|
|
66
77
|
});
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
78
|
+
|
|
79
|
+
// Hydrate new object properties into referenced object
|
|
80
|
+
const dataToStorePointer = dataToStore.data?.content || dataToStore;
|
|
81
|
+
Object.keys(dataToStorePointer).forEach(key => {
|
|
82
|
+
previousDataPointer[key] = dataToStorePointer[key];
|
|
70
83
|
});
|
|
84
|
+
skipUpdating = true;
|
|
71
85
|
}
|
|
72
86
|
|
|
73
87
|
// Add data to UUID index.
|
|
@@ -95,7 +109,10 @@ const setFileIntoStore = (
|
|
|
95
109
|
} else {
|
|
96
110
|
previousStoredData = previousData;
|
|
97
111
|
}
|
|
98
|
-
|
|
112
|
+
|
|
113
|
+
if (!skipUpdating) {
|
|
114
|
+
store.data.set(relativeFilepath, dataToStore);
|
|
115
|
+
}
|
|
99
116
|
|
|
100
117
|
// Remove this path from store.deleted
|
|
101
118
|
store.deleted.delete(relativeFilepath);
|