@instantdb/core 0.22.86-experimental.split-store.20243647937.1 → 0.22.86-experimental.split-store.20247691802.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.d.ts.map +1 -1
- package/dist/commonjs/Reactor.js +3 -2
- package/dist/commonjs/Reactor.js.map +1 -1
- package/dist/commonjs/instaml.d.ts.map +1 -1
- package/dist/commonjs/instaml.js +22 -18
- package/dist/commonjs/instaml.js.map +1 -1
- package/dist/commonjs/store.d.ts.map +1 -1
- package/dist/commonjs/store.js +0 -6
- package/dist/commonjs/store.js.map +1 -1
- package/dist/esm/Reactor.d.ts.map +1 -1
- package/dist/esm/Reactor.js +3 -2
- package/dist/esm/Reactor.js.map +1 -1
- package/dist/esm/instaml.d.ts.map +1 -1
- package/dist/esm/instaml.js +22 -18
- package/dist/esm/instaml.js.map +1 -1
- package/dist/esm/store.d.ts.map +1 -1
- package/dist/esm/store.js +0 -6
- package/dist/esm/store.js.map +1 -1
- package/dist/standalone/index.js +127 -125
- package/dist/standalone/index.umd.cjs +2 -2
- package/package.json +2 -2
- package/src/Reactor.js +3 -2
- package/src/instaml.ts +11 -7
- package/src/store.ts +0 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instantdb/core",
|
|
3
|
-
"version": "0.22.86-experimental.split-store.
|
|
3
|
+
"version": "0.22.86-experimental.split-store.20247691802.1",
|
|
4
4
|
"description": "Instant's core local abstraction",
|
|
5
5
|
"homepage": "https://github.com/instantdb/instant/tree/main/client/packages/core",
|
|
6
6
|
"repository": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"mutative": "^1.0.10",
|
|
55
55
|
"uuid": "^11.1.0",
|
|
56
|
-
"@instantdb/version": "0.22.86-experimental.split-store.
|
|
56
|
+
"@instantdb/version": "0.22.86-experimental.split-store.20247691802.1"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"test": "vitest",
|
package/src/Reactor.js
CHANGED
|
@@ -588,8 +588,9 @@ export default class Reactor {
|
|
|
588
588
|
const pageInfo = result?.[0]?.data?.['page-info'];
|
|
589
589
|
const aggregate = result?.[0]?.data?.['aggregate'];
|
|
590
590
|
const triples = extractTriples(result);
|
|
591
|
+
const attrsStore = this.ensureAttrs();
|
|
591
592
|
const store = sts.createStore(
|
|
592
|
-
|
|
593
|
+
attrsStore,
|
|
593
594
|
triples,
|
|
594
595
|
enableCardinalityInference,
|
|
595
596
|
this.config.useDateObjects,
|
|
@@ -602,7 +603,7 @@ export default class Reactor {
|
|
|
602
603
|
}
|
|
603
604
|
prev[hash].result = {
|
|
604
605
|
store,
|
|
605
|
-
attrsStore
|
|
606
|
+
attrsStore,
|
|
606
607
|
pageInfo,
|
|
607
608
|
aggregate,
|
|
608
609
|
processedTxId: msg['processed-tx-id'],
|
package/src/instaml.ts
CHANGED
|
@@ -162,12 +162,14 @@ function expandLink({ attrsStore }: Ctx, [etype, eidA, obj]) {
|
|
|
162
162
|
'add-triple',
|
|
163
163
|
extractLookup(attrsStore, etype, eidA),
|
|
164
164
|
fwdAttr.id,
|
|
165
|
-
//
|
|
166
|
-
|
|
165
|
+
// Uses `!` because if we get here, we should have created the attr if it doesn't
|
|
166
|
+
// already exist
|
|
167
|
+
extractLookup(attrsStore, fwdAttr['reverse-identity']![1], eidB),
|
|
167
168
|
]
|
|
168
169
|
: [
|
|
169
170
|
'add-triple',
|
|
170
|
-
//
|
|
171
|
+
// Uses `!` because if we get here, we should have created the attr if it doesn't
|
|
172
|
+
// already exist
|
|
171
173
|
extractLookup(attrsStore, revAttr!['forward-identity']![1], eidB),
|
|
172
174
|
revAttr?.id,
|
|
173
175
|
extractLookup(attrsStore, etype, eidA),
|
|
@@ -189,12 +191,14 @@ function expandUnlink({ attrsStore }: Ctx, [etype, eidA, obj]) {
|
|
|
189
191
|
'retract-triple',
|
|
190
192
|
extractLookup(attrsStore, etype, eidA),
|
|
191
193
|
fwdAttr.id,
|
|
192
|
-
//
|
|
194
|
+
// Uses `!` because if we get here, we should have created the attr if it doesn't
|
|
195
|
+
// already exist
|
|
193
196
|
extractLookup(attrsStore, fwdAttr!['reverse-identity']![1], eidB),
|
|
194
197
|
]
|
|
195
198
|
: [
|
|
196
199
|
'retract-triple',
|
|
197
|
-
//
|
|
200
|
+
// Uses `!` because if we get here, we should have created the attr if it doesn't
|
|
201
|
+
// already exist
|
|
198
202
|
extractLookup(attrsStore, revAttr!['forward-identity'][1], eidB),
|
|
199
203
|
revAttr!.id,
|
|
200
204
|
extractLookup(attrsStore, etype, eidA),
|
|
@@ -218,7 +222,7 @@ function checkEntityExists(
|
|
|
218
222
|
const ev = store?.aev.get(entity_a);
|
|
219
223
|
if (ev) {
|
|
220
224
|
// This would be a lot more efficient with a ave index
|
|
221
|
-
for (const [
|
|
225
|
+
for (const [_e, _a, v] of allMapValues(ev, 2)) {
|
|
222
226
|
if (v === entity_v) {
|
|
223
227
|
return true;
|
|
224
228
|
}
|
|
@@ -267,7 +271,7 @@ function expandCreate(ctx: Ctx, step) {
|
|
|
267
271
|
const attrTuples = [['id', lookup]]
|
|
268
272
|
.concat(Object.entries(obj))
|
|
269
273
|
.map(([identName, value]: [string, any]) => {
|
|
270
|
-
//
|
|
274
|
+
// Uses `!` because we should have optimistically created the attr if it doesn't exist
|
|
271
275
|
const attr = getAttrByFwdIdentName(attrsStore, etype, identName)!;
|
|
272
276
|
|
|
273
277
|
if (attr['checked-data-type'] === 'date' && ctx.useDateObjects) {
|
package/src/store.ts
CHANGED
|
@@ -100,13 +100,10 @@ export class AttrsStoreClass implements AttrsStore {
|
|
|
100
100
|
return this.attrs[id];
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
// XXX: Might be better to create all of the indexes at once as soon as someone
|
|
104
|
-
// requests one index
|
|
105
103
|
get blobAttrs(): Map<string, Map<string, InstantDBAttr>> {
|
|
106
104
|
if (this._blobAttrs) {
|
|
107
105
|
return this._blobAttrs;
|
|
108
106
|
}
|
|
109
|
-
console.log('blobAttrs');
|
|
110
107
|
this._blobAttrs = new Map();
|
|
111
108
|
for (const attr of Object.values(this.attrs)) {
|
|
112
109
|
if (isBlob(attr)) {
|
|
@@ -121,7 +118,6 @@ export class AttrsStoreClass implements AttrsStore {
|
|
|
121
118
|
if (this._primaryKeys) {
|
|
122
119
|
return this._primaryKeys;
|
|
123
120
|
}
|
|
124
|
-
console.log('primayKeys');
|
|
125
121
|
this._primaryKeys = new Map();
|
|
126
122
|
|
|
127
123
|
for (const attr of Object.values(this.attrs)) {
|
|
@@ -137,7 +133,6 @@ export class AttrsStoreClass implements AttrsStore {
|
|
|
137
133
|
if (this._forwardIdents) {
|
|
138
134
|
return this._forwardIdents;
|
|
139
135
|
}
|
|
140
|
-
console.log('fwdIdents');
|
|
141
136
|
this._forwardIdents = new Map();
|
|
142
137
|
|
|
143
138
|
for (const attr of Object.values(this.attrs)) {
|
|
@@ -152,7 +147,6 @@ export class AttrsStoreClass implements AttrsStore {
|
|
|
152
147
|
if (this._revIdents) {
|
|
153
148
|
return this._revIdents;
|
|
154
149
|
}
|
|
155
|
-
console.log('revIdents');
|
|
156
150
|
this._revIdents = new Map();
|
|
157
151
|
|
|
158
152
|
for (const attr of Object.values(this.attrs)) {
|