@spooky-sync/core 0.0.1-canary.24 → 0.0.1-canary.25
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 +14 -8
- package/package.json +1 -1
- package/src/modules/sync/sync.ts +12 -0
- package/src/modules/sync/utils.ts +8 -11
package/dist/index.js
CHANGED
|
@@ -1544,14 +1544,12 @@ function diffRecordVersionArray(local, remote) {
|
|
|
1544
1544
|
};
|
|
1545
1545
|
}
|
|
1546
1546
|
function createDiffFromDbOp(op, recordId, version, versions) {
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
};
|
|
1554
|
-
}
|
|
1547
|
+
const old = versions?.find((record) => record[0] === encodeRecordId(recordId));
|
|
1548
|
+
if (old && old[1] >= version) return {
|
|
1549
|
+
added: [],
|
|
1550
|
+
updated: [],
|
|
1551
|
+
removed: []
|
|
1552
|
+
};
|
|
1555
1553
|
if (op === "CREATE") return {
|
|
1556
1554
|
added: [{
|
|
1557
1555
|
id: recordId,
|
|
@@ -1821,6 +1819,14 @@ var SpookySync = class {
|
|
|
1821
1819
|
});
|
|
1822
1820
|
}
|
|
1823
1821
|
async handleRemoteListRefChange(action, queryId, recordId, version) {
|
|
1822
|
+
if (action === "DELETE") {
|
|
1823
|
+
this.logger.debug({
|
|
1824
|
+
queryId: queryId.toString(),
|
|
1825
|
+
recordId: recordId.toString(),
|
|
1826
|
+
Category: "spooky-client::SpookySync::handleRemoteListRefChange"
|
|
1827
|
+
}, "Ignoring DELETE on list_ref — should not happen");
|
|
1828
|
+
return;
|
|
1829
|
+
}
|
|
1824
1830
|
const existing = this.dataModule.getQueryById(queryId);
|
|
1825
1831
|
if (!existing) {
|
|
1826
1832
|
this.logger.warn({
|
package/package.json
CHANGED
package/src/modules/sync/sync.ts
CHANGED
|
@@ -126,6 +126,18 @@ export class SpookySync<S extends SchemaStructure> {
|
|
|
126
126
|
recordId: RecordId,
|
|
127
127
|
version: number
|
|
128
128
|
) {
|
|
129
|
+
if (action === 'DELETE') {
|
|
130
|
+
this.logger.debug(
|
|
131
|
+
{
|
|
132
|
+
queryId: queryId.toString(),
|
|
133
|
+
recordId: recordId.toString(),
|
|
134
|
+
Category: 'spooky-client::SpookySync::handleRemoteListRefChange',
|
|
135
|
+
},
|
|
136
|
+
'Ignoring DELETE on list_ref — should not happen'
|
|
137
|
+
);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
129
141
|
const existing = this.dataModule.getQueryById(queryId);
|
|
130
142
|
|
|
131
143
|
if (!existing) {
|
|
@@ -135,17 +135,14 @@ export function createDiffFromDbOp(
|
|
|
135
135
|
version: number,
|
|
136
136
|
versions?: RecordVersionArray
|
|
137
137
|
): RecordVersionDiff {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
removed: [],
|
|
147
|
-
};
|
|
148
|
-
}
|
|
138
|
+
const old = versions?.find((record) => record[0] === encodeRecordId(recordId));
|
|
139
|
+
|
|
140
|
+
if (old && old[1] >= version) {
|
|
141
|
+
return {
|
|
142
|
+
added: [],
|
|
143
|
+
updated: [],
|
|
144
|
+
removed: [],
|
|
145
|
+
};
|
|
149
146
|
}
|
|
150
147
|
|
|
151
148
|
if (op === 'CREATE') {
|