teamplay 0.4.0-alpha.54 → 0.4.0-alpha.55
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/orm/dataTree.js +80 -8
- package/package.json +2 -2
package/orm/dataTree.js
CHANGED
|
@@ -155,7 +155,16 @@ export async function setPublicDoc (segments, value, deleteValue = false) {
|
|
|
155
155
|
const idFields = getIdFieldsForSegments([collection, docId])
|
|
156
156
|
if (segments.length >= 3 && idFields.includes(segments[segments.length - 1])) return
|
|
157
157
|
const doc = getConnection().get(collection, docId)
|
|
158
|
-
|
|
158
|
+
let docState = resolvePublicDocState({ collection, docId, doc, idFields, hydrateCompatDocData: true })
|
|
159
|
+
if (!docState.exists && segments.length > 2) {
|
|
160
|
+
docState = await resolvePublicDocStateWithCompatFetchFallback({
|
|
161
|
+
collection,
|
|
162
|
+
docId,
|
|
163
|
+
doc,
|
|
164
|
+
idFields,
|
|
165
|
+
hydrateCompatDocData: true
|
|
166
|
+
})
|
|
167
|
+
}
|
|
159
168
|
if (!docState.exists && deleteValue) throw Error(ERRORS.deleteNonExistentDoc(segments))
|
|
160
169
|
// make sure that the value is not observable to not trigger extra reads. And clone it
|
|
161
170
|
value = raw(value)
|
|
@@ -235,7 +244,16 @@ export async function setPublicDocReplace (segments, value) {
|
|
|
235
244
|
const idFields = getIdFieldsForSegments([collection, docId])
|
|
236
245
|
if (segments.length >= 3 && idFields.includes(segments[segments.length - 1])) return
|
|
237
246
|
const doc = getConnection().get(collection, docId)
|
|
238
|
-
|
|
247
|
+
let docState = resolvePublicDocState({ collection, docId, doc, idFields, hydrateCompatDocData: true })
|
|
248
|
+
if (!docState.exists && segments.length > 2) {
|
|
249
|
+
docState = await resolvePublicDocStateWithCompatFetchFallback({
|
|
250
|
+
collection,
|
|
251
|
+
docId,
|
|
252
|
+
doc,
|
|
253
|
+
idFields,
|
|
254
|
+
hydrateCompatDocData: true
|
|
255
|
+
})
|
|
256
|
+
}
|
|
239
257
|
// make sure that the value is not observable to not trigger extra reads. And clone it
|
|
240
258
|
value = raw(value)
|
|
241
259
|
if (value != null) {
|
|
@@ -344,6 +362,24 @@ function resolvePublicDocState ({
|
|
|
344
362
|
return { exists: true, snapshot: localSnapshot, source: 'local' }
|
|
345
363
|
}
|
|
346
364
|
|
|
365
|
+
async function resolvePublicDocStateWithCompatFetchFallback ({
|
|
366
|
+
collection,
|
|
367
|
+
docId,
|
|
368
|
+
doc,
|
|
369
|
+
idFields,
|
|
370
|
+
hydrateCompatDocData = false
|
|
371
|
+
}) {
|
|
372
|
+
let docState = resolvePublicDocState({ collection, docId, doc, idFields, hydrateCompatDocData })
|
|
373
|
+
if (docState.exists || !isCompatEnv()) return docState
|
|
374
|
+
|
|
375
|
+
await new Promise((resolve, reject) => {
|
|
376
|
+
doc.fetch(err => err ? reject(err) : resolve())
|
|
377
|
+
})
|
|
378
|
+
|
|
379
|
+
docState = resolvePublicDocState({ collection, docId, doc, idFields, hydrateCompatDocData })
|
|
380
|
+
return docState
|
|
381
|
+
}
|
|
382
|
+
|
|
347
383
|
function ensureLocalDocSyncedWithShareDoc ({
|
|
348
384
|
collection,
|
|
349
385
|
docId,
|
|
@@ -463,7 +499,13 @@ export async function incrementPublic (segments, byNumber) {
|
|
|
463
499
|
if (!(collection && docId)) throw Error(ERRORS.publicDoc(segments))
|
|
464
500
|
const doc = getConnection().get(collection, docId)
|
|
465
501
|
const idFields = getIdFieldsForSegments([collection, docId])
|
|
466
|
-
const docState =
|
|
502
|
+
const docState = await resolvePublicDocStateWithCompatFetchFallback({
|
|
503
|
+
collection,
|
|
504
|
+
docId,
|
|
505
|
+
doc,
|
|
506
|
+
idFields,
|
|
507
|
+
hydrateCompatDocData: true
|
|
508
|
+
})
|
|
467
509
|
if (!docState.exists) throw Error(ERRORS.nonExistingDoc(segments))
|
|
468
510
|
const relativePath = segments.slice(2)
|
|
469
511
|
const op = [{ p: relativePath, na: byNumber }]
|
|
@@ -490,7 +532,13 @@ export async function arrayInsertPublic (segments, index, values) {
|
|
|
490
532
|
if (!(collection && docId)) throw Error(ERRORS.publicDoc(segments))
|
|
491
533
|
const doc = getConnection().get(collection, docId)
|
|
492
534
|
const idFields = getIdFieldsForSegments([collection, docId])
|
|
493
|
-
const docState =
|
|
535
|
+
const docState = await resolvePublicDocStateWithCompatFetchFallback({
|
|
536
|
+
collection,
|
|
537
|
+
docId,
|
|
538
|
+
doc,
|
|
539
|
+
idFields,
|
|
540
|
+
hydrateCompatDocData: true
|
|
541
|
+
})
|
|
494
542
|
if (!docState.exists) throw Error(ERRORS.nonExistingDoc(segments))
|
|
495
543
|
let current = getRaw(segments)
|
|
496
544
|
if (current == null) {
|
|
@@ -539,7 +587,13 @@ export async function arrayRemovePublic (segments, index, howMany = 1) {
|
|
|
539
587
|
if (!(collection && docId)) throw Error(ERRORS.publicDoc(segments))
|
|
540
588
|
const doc = getConnection().get(collection, docId)
|
|
541
589
|
const idFields = getIdFieldsForSegments([collection, docId])
|
|
542
|
-
const docState =
|
|
590
|
+
const docState = await resolvePublicDocStateWithCompatFetchFallback({
|
|
591
|
+
collection,
|
|
592
|
+
docId,
|
|
593
|
+
doc,
|
|
594
|
+
idFields,
|
|
595
|
+
hydrateCompatDocData: true
|
|
596
|
+
})
|
|
543
597
|
if (!docState.exists) throw Error(ERRORS.nonExistingDoc(segments))
|
|
544
598
|
const arr = getRaw(segments) || []
|
|
545
599
|
const removed = arr.slice(index, index + howMany)
|
|
@@ -557,7 +611,13 @@ export async function arrayMovePublic (segments, from, to, howMany = 1) {
|
|
|
557
611
|
if (!(collection && docId)) throw Error(ERRORS.publicDoc(segments))
|
|
558
612
|
const doc = getConnection().get(collection, docId)
|
|
559
613
|
const idFields = getIdFieldsForSegments([collection, docId])
|
|
560
|
-
const docState =
|
|
614
|
+
const docState = await resolvePublicDocStateWithCompatFetchFallback({
|
|
615
|
+
collection,
|
|
616
|
+
docId,
|
|
617
|
+
doc,
|
|
618
|
+
idFields,
|
|
619
|
+
hydrateCompatDocData: true
|
|
620
|
+
})
|
|
561
621
|
if (!docState.exists) throw Error(ERRORS.nonExistingDoc(segments))
|
|
562
622
|
const arr = getRaw(segments) || []
|
|
563
623
|
const len = arr.length
|
|
@@ -623,7 +683,13 @@ export async function stringInsertPublic (segments, index, text) {
|
|
|
623
683
|
if (!(collection && docId)) throw Error(ERRORS.publicDoc(segments))
|
|
624
684
|
const doc = getConnection().get(collection, docId)
|
|
625
685
|
const idFields = getIdFieldsForSegments([collection, docId])
|
|
626
|
-
const docState =
|
|
686
|
+
const docState = await resolvePublicDocStateWithCompatFetchFallback({
|
|
687
|
+
collection,
|
|
688
|
+
docId,
|
|
689
|
+
doc,
|
|
690
|
+
idFields,
|
|
691
|
+
hydrateCompatDocData: true
|
|
692
|
+
})
|
|
627
693
|
if (!docState.exists) throw Error(ERRORS.nonExistingDoc(segments))
|
|
628
694
|
const relativePath = segments.slice(2)
|
|
629
695
|
const previous = getRaw(segments)
|
|
@@ -646,7 +712,13 @@ export async function stringRemovePublic (segments, index, howMany) {
|
|
|
646
712
|
if (!(collection && docId)) throw Error(ERRORS.publicDoc(segments))
|
|
647
713
|
const doc = getConnection().get(collection, docId)
|
|
648
714
|
const idFields = getIdFieldsForSegments([collection, docId])
|
|
649
|
-
const docState =
|
|
715
|
+
const docState = await resolvePublicDocStateWithCompatFetchFallback({
|
|
716
|
+
collection,
|
|
717
|
+
docId,
|
|
718
|
+
doc,
|
|
719
|
+
idFields,
|
|
720
|
+
hydrateCompatDocData: true
|
|
721
|
+
})
|
|
650
722
|
if (!docState.exists) throw Error(ERRORS.nonExistingDoc(segments))
|
|
651
723
|
const relativePath = segments.slice(2)
|
|
652
724
|
const previous = getRaw(segments)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "teamplay",
|
|
3
|
-
"version": "0.4.0-alpha.
|
|
3
|
+
"version": "0.4.0-alpha.55",
|
|
4
4
|
"description": "Full-stack signals ORM with multiplayer",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
]
|
|
84
84
|
},
|
|
85
85
|
"license": "MIT",
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "da3ed74a87ba96c378b96c8df7ebd7073b32607e"
|
|
87
87
|
}
|