@spooky-sync/core 0.0.1-canary.83 → 0.0.1-canary.84
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/dist/index.js +4 -4
- package/package.json +3 -3
- package/src/modules/sync/engine.ts +18 -14
package/dist/index.js
CHANGED
|
@@ -2455,8 +2455,8 @@ var SyncEngine = class {
|
|
|
2455
2455
|
}, "Checking removed records");
|
|
2456
2456
|
let existingRemoteIds;
|
|
2457
2457
|
try {
|
|
2458
|
-
const [existing] = await this.remote.query("SELECT id FROM $ids", { ids: removed });
|
|
2459
|
-
existingRemoteIds = new Set((existing ?? []).map((
|
|
2458
|
+
const [existing] = await this.remote.query("SELECT VALUE id FROM $ids", { ids: removed });
|
|
2459
|
+
existingRemoteIds = new Set((existing ?? []).filter((id) => id != null).map((id) => encodeRecordId(id)));
|
|
2460
2460
|
} catch (err) {
|
|
2461
2461
|
this.logger.warn({
|
|
2462
2462
|
err,
|
|
@@ -3343,8 +3343,8 @@ function parseBackendInfo(raw) {
|
|
|
3343
3343
|
|
|
3344
3344
|
//#endregion
|
|
3345
3345
|
//#region src/modules/devtools/index.ts
|
|
3346
|
-
const CORE_VERSION = "0.0.1-canary.
|
|
3347
|
-
const WASM_VERSION = "0.0.1-canary.
|
|
3346
|
+
const CORE_VERSION = "0.0.1-canary.84";
|
|
3347
|
+
const WASM_VERSION = "0.0.1-canary.84";
|
|
3348
3348
|
const SURREAL_VERSION = "3.0.3";
|
|
3349
3349
|
var DevToolsService = class {
|
|
3350
3350
|
eventsHistory = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spooky-sync/core",
|
|
3
|
-
"version": "0.0.1-canary.
|
|
3
|
+
"version": "0.0.1-canary.84",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@spooky-sync/query-builder": "0.0.1-canary.
|
|
63
|
-
"@spooky-sync/ssp-wasm": "0.0.1-canary.
|
|
62
|
+
"@spooky-sync/query-builder": "0.0.1-canary.84",
|
|
63
|
+
"@spooky-sync/ssp-wasm": "0.0.1-canary.84",
|
|
64
64
|
"@surrealdb/wasm": "^3.0.3",
|
|
65
65
|
"fast-json-patch": "^3.1.1",
|
|
66
66
|
"loro-crdt": "^1.5.6",
|
|
@@ -160,26 +160,30 @@ export class SyncEngine {
|
|
|
160
160
|
);
|
|
161
161
|
|
|
162
162
|
// Confirm which of the "removed" ids still exist remotely by selecting the
|
|
163
|
-
// records directly
|
|
164
|
-
// FROM target).
|
|
163
|
+
// records directly from the id array (the records ARE the FROM target).
|
|
165
164
|
//
|
|
166
|
-
//
|
|
167
|
-
//
|
|
168
|
-
//
|
|
169
|
-
//
|
|
170
|
-
//
|
|
171
|
-
//
|
|
172
|
-
//
|
|
173
|
-
//
|
|
174
|
-
//
|
|
165
|
+
// The exact query form matters on SurrealDB v3.x:
|
|
166
|
+
// - `WHERE id IN $ids` is broken: record-id `IN` matches nothing, so every
|
|
167
|
+
// removed id looked gone and live local records got deleted (a fresh
|
|
168
|
+
// collection vanished mid-session). Do NOT use `IN`.
|
|
169
|
+
// - `SELECT id FROM $ids` — a FIELD projection over a record-id ARRAY —
|
|
170
|
+
// errors "Specify a database to use" on the deployed engine. The catch
|
|
171
|
+
// below then swallowed it and skipped EVERY deletion, so nothing could be
|
|
172
|
+
// deleted anywhere (games, comments, …). Do NOT project a field over the
|
|
173
|
+
// array. (`SELECT * FROM $ids` works but pulls full records — wasteful.)
|
|
174
|
+
// - `SELECT VALUE id FROM $ids` works: a flat array of ids with a NONE entry
|
|
175
|
+
// for each id that no longer exists. We filter the NONE entries out; the
|
|
176
|
+
// survivors are the ids still present upstream.
|
|
175
177
|
let existingRemoteIds: Set<string>;
|
|
176
178
|
try {
|
|
177
|
-
const [existing] = await this.remote.query<[
|
|
178
|
-
'SELECT id FROM $ids',
|
|
179
|
+
const [existing] = await this.remote.query<[(RecordId | null | undefined)[]]>(
|
|
180
|
+
'SELECT VALUE id FROM $ids',
|
|
179
181
|
{ ids: removed }
|
|
180
182
|
);
|
|
181
183
|
existingRemoteIds = new Set(
|
|
182
|
-
(existing ?? [])
|
|
184
|
+
(existing ?? [])
|
|
185
|
+
.filter((id): id is RecordId => id != null)
|
|
186
|
+
.map((id) => encodeRecordId(id))
|
|
183
187
|
);
|
|
184
188
|
} catch (err) {
|
|
185
189
|
// Verification failed. Skip deletion entirely — the next sync
|