@instantdb/core 0.22.86-experimental.split-store.20247643606.1 → 0.22.86-experimental.split-store.20249342206.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.
- package/__tests__/src/store.test.ts +18 -0
- package/dist/commonjs/Reactor.js +2 -2
- package/dist/commonjs/Reactor.js.map +1 -1
- package/dist/esm/Reactor.js +2 -2
- package/dist/esm/Reactor.js.map +1 -1
- package/dist/standalone/index.js +3 -3
- package/dist/standalone/index.umd.cjs +2 -2
- package/package.json +2 -2
- package/src/Reactor.js +2 -2
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
getAttrByFwdIdentName,
|
|
12
12
|
Store,
|
|
13
13
|
AttrsStore,
|
|
14
|
+
attrsStoreFromJSON,
|
|
14
15
|
} from '../../src/store';
|
|
15
16
|
import query from '../../src/instaql';
|
|
16
17
|
import uuid from '../../src/utils/uuid';
|
|
@@ -691,3 +692,20 @@ test('date conversion', () => {
|
|
|
691
692
|
expect(result.data.todos[0].createdAt).toBeTypeOf('number');
|
|
692
693
|
}).not.toThrow();
|
|
693
694
|
});
|
|
695
|
+
|
|
696
|
+
test('v0 store restores', () => {
|
|
697
|
+
function toJSONOld(store) {
|
|
698
|
+
return {
|
|
699
|
+
__type: store.__type,
|
|
700
|
+
attrs: store.attrs,
|
|
701
|
+
triples: allMapValues(store.eav, 3),
|
|
702
|
+
cardinalityInference: store.cardinalityInference,
|
|
703
|
+
linkIndex: store.linkIndex,
|
|
704
|
+
useDateObjects: store.useDateObjects,
|
|
705
|
+
};
|
|
706
|
+
}
|
|
707
|
+
const v0Json = toJSONOld({ ...store, attrs: zenecaAttrsStore.attrs });
|
|
708
|
+
const attrsStore = attrsStoreFromJSON(null, v0Json);
|
|
709
|
+
const restored = fromJSON(attrsStore!, v0Json);
|
|
710
|
+
expect(restored).toEqual(store);
|
|
711
|
+
});
|
package/dist/commonjs/Reactor.js
CHANGED
|
@@ -792,7 +792,7 @@ class Reactor {
|
|
|
792
792
|
}
|
|
793
793
|
}
|
|
794
794
|
if (newAttrs.length) {
|
|
795
|
-
const existingAttrs = Object.values(this.ensureAttrs());
|
|
795
|
+
const existingAttrs = Object.values(this.ensureAttrs().attrs);
|
|
796
796
|
this._setAttrs([...existingAttrs, ...newAttrs]);
|
|
797
797
|
this._setAttrs(newAttrs);
|
|
798
798
|
}
|
|
@@ -1600,7 +1600,7 @@ class Reactor {
|
|
|
1600
1600
|
if (!this.attrs)
|
|
1601
1601
|
return;
|
|
1602
1602
|
const oas = this.optimisticAttrs();
|
|
1603
|
-
this.attrsCbs.forEach((cb) => cb(oas));
|
|
1603
|
+
this.attrsCbs.forEach((cb) => cb(oas.attrs));
|
|
1604
1604
|
}
|
|
1605
1605
|
notifyConnectionStatusSubs(status) {
|
|
1606
1606
|
this.connectionStatusCbs.forEach((cb) => cb(status));
|