orez-sync-cf-host 0.7.0 → 0.7.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/dist/host.js +23 -0
- package/package.json +2 -2
package/dist/host.js
CHANGED
|
@@ -83,6 +83,28 @@ async function requestObject(request) {
|
|
|
83
83
|
throw requestError('request body must be a JSON object');
|
|
84
84
|
return value;
|
|
85
85
|
}
|
|
86
|
+
// clients always ship their desired queries and treat the server's got ack as
|
|
87
|
+
// authoritative. the query-aware engine acks through its own tracking; a
|
|
88
|
+
// non-query-aware host syncs every visible row, so its ack is an echo of the
|
|
89
|
+
// hash-level desired delta in the same response that carries the rows.
|
|
90
|
+
function withGotQueriesAck(body, queryAware, response) {
|
|
91
|
+
if (queryAware)
|
|
92
|
+
return response;
|
|
93
|
+
const queries = body.queries;
|
|
94
|
+
if (!queries || typeof queries.version !== 'number' || !Array.isArray(queries.patch)) {
|
|
95
|
+
return response;
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
...response,
|
|
99
|
+
gotQueries: {
|
|
100
|
+
version: queries.version,
|
|
101
|
+
patch: queries.patch.map((op) => {
|
|
102
|
+
const entry = op;
|
|
103
|
+
return entry.op === 'put' ? { op: 'put', hash: entry.hash } : op;
|
|
104
|
+
}),
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
}
|
|
86
108
|
function routeAfterNamespace(pathname) {
|
|
87
109
|
const [, , ...parts] = pathname.split('/');
|
|
88
110
|
return `/${parts.join('/')}`;
|
|
@@ -1004,6 +1026,7 @@ export function createSyncDurableObject(config) {
|
|
|
1004
1026
|
return result;
|
|
1005
1027
|
});
|
|
1006
1028
|
transactionMs = performance.now() - txStarted;
|
|
1029
|
+
response = withGotQueriesAck(body, queryAware, response);
|
|
1007
1030
|
}
|
|
1008
1031
|
finally {
|
|
1009
1032
|
this.#pulling.delete(clientID);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orez-sync-cf-host",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"typecheck": "bun run build:dist:platform && tsc --noEmit"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"orez-sync-executor": "0.7.
|
|
58
|
+
"orez-sync-executor": "0.7.1"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@cloudflare/workers-types": "4.20260617.1",
|