@quereus/sync-coordinator 1.0.5 → 1.1.0
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.
|
@@ -3,26 +3,29 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Used by both the WebSocket handler and the HTTP routes
|
|
5
5
|
* for consistent wire format.
|
|
6
|
+
*
|
|
7
|
+
* Uint8Array values (blobs) are encoded as `{ __bin: "<base64>" }` so they
|
|
8
|
+
* survive JSON round-trips. See encodeSqlValue / decodeSqlValue in @quereus/sync.
|
|
6
9
|
*/
|
|
7
10
|
import { type ChangeSet, type SnapshotChunk } from '@quereus/sync';
|
|
8
11
|
/**
|
|
9
12
|
* Serialize a ChangeSet for JSON transport.
|
|
10
|
-
* Converts binary fields (siteId, HLCs) to base64 strings.
|
|
13
|
+
* Converts binary fields (siteId, HLCs) and SqlValue blobs to base64 strings.
|
|
11
14
|
*/
|
|
12
15
|
export declare function serializeChangeSet(cs: ChangeSet): object;
|
|
13
16
|
/**
|
|
14
17
|
* Serialize a SnapshotChunk for JSON transport.
|
|
15
|
-
* Converts binary fields (siteId, HLCs) to base64 strings.
|
|
18
|
+
* Converts binary fields (siteId, HLCs) and SqlValue blobs to base64 strings.
|
|
16
19
|
*/
|
|
17
20
|
export declare function serializeSnapshotChunk(chunk: SnapshotChunk): object;
|
|
18
21
|
/**
|
|
19
22
|
* Deserialize a SnapshotChunk from JSON transport format.
|
|
20
|
-
* Converts base64 strings back to binary fields (SiteId, HLC).
|
|
23
|
+
* Converts base64 strings back to binary fields (SiteId, HLC) and decodes SqlValue blobs.
|
|
21
24
|
*/
|
|
22
25
|
export declare function deserializeSnapshotChunk(obj: unknown): SnapshotChunk;
|
|
23
26
|
/**
|
|
24
27
|
* Deserialize a ChangeSet from JSON transport format.
|
|
25
|
-
* Converts base64 strings back to binary fields.
|
|
28
|
+
* Converts base64 strings back to binary fields and decodes SqlValue blobs.
|
|
26
29
|
*/
|
|
27
30
|
export declare function deserializeChangeSet(cs: unknown): ChangeSet;
|
|
28
31
|
//# sourceMappingURL=serialization.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../../src/common/serialization.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../../src/common/serialization.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAON,KAAK,SAAS,EAEd,KAAK,aAAa,EAClB,MAAM,eAAe,CAAC;AAEvB;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,SAAS,GAAG,MAAM,CAuBxD;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CAkCnE;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,OAAO,GAAG,aAAa,CAqCpE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,OAAO,GAAG,SAAS,CAwB3D"}
|
|
@@ -3,21 +3,33 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Used by both the WebSocket handler and the HTTP routes
|
|
5
5
|
* for consistent wire format.
|
|
6
|
+
*
|
|
7
|
+
* Uint8Array values (blobs) are encoded as `{ __bin: "<base64>" }` so they
|
|
8
|
+
* survive JSON round-trips. See encodeSqlValue / decodeSqlValue in @quereus/sync.
|
|
6
9
|
*/
|
|
7
|
-
import { siteIdFromBase64, siteIdToBase64, deserializeHLC, serializeHLC, } from '@quereus/sync';
|
|
10
|
+
import { siteIdFromBase64, siteIdToBase64, deserializeHLC, serializeHLC, encodeSqlValue, decodeSqlValue, } from '@quereus/sync';
|
|
8
11
|
/**
|
|
9
12
|
* Serialize a ChangeSet for JSON transport.
|
|
10
|
-
* Converts binary fields (siteId, HLCs) to base64 strings.
|
|
13
|
+
* Converts binary fields (siteId, HLCs) and SqlValue blobs to base64 strings.
|
|
11
14
|
*/
|
|
12
15
|
export function serializeChangeSet(cs) {
|
|
13
16
|
return {
|
|
14
17
|
siteId: siteIdToBase64(cs.siteId),
|
|
15
18
|
transactionId: cs.transactionId,
|
|
16
19
|
hlc: Buffer.from(serializeHLC(cs.hlc)).toString('base64'),
|
|
17
|
-
changes: cs.changes.map(c =>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
changes: cs.changes.map(c => {
|
|
21
|
+
const base = {
|
|
22
|
+
type: c.type,
|
|
23
|
+
schema: c.schema,
|
|
24
|
+
table: c.table,
|
|
25
|
+
pk: c.pk.map(v => encodeSqlValue(v)),
|
|
26
|
+
hlc: Buffer.from(serializeHLC(c.hlc)).toString('base64'),
|
|
27
|
+
};
|
|
28
|
+
if (c.type === 'column') {
|
|
29
|
+
return { ...base, column: c.column, value: encodeSqlValue(c.value) };
|
|
30
|
+
}
|
|
31
|
+
return base;
|
|
32
|
+
}),
|
|
21
33
|
schemaMigrations: cs.schemaMigrations.map(m => ({
|
|
22
34
|
...m,
|
|
23
35
|
hlc: Buffer.from(serializeHLC(m.hlc)).toString('base64'),
|
|
@@ -26,7 +38,7 @@ export function serializeChangeSet(cs) {
|
|
|
26
38
|
}
|
|
27
39
|
/**
|
|
28
40
|
* Serialize a SnapshotChunk for JSON transport.
|
|
29
|
-
* Converts binary fields (siteId, HLCs) to base64 strings.
|
|
41
|
+
* Converts binary fields (siteId, HLCs) and SqlValue blobs to base64 strings.
|
|
30
42
|
*/
|
|
31
43
|
export function serializeSnapshotChunk(chunk) {
|
|
32
44
|
switch (chunk.type) {
|
|
@@ -47,7 +59,7 @@ export function serializeSnapshotChunk(chunk) {
|
|
|
47
59
|
entries: chunk.entries.map(([key, hlc, value]) => [
|
|
48
60
|
key,
|
|
49
61
|
Buffer.from(serializeHLC(hlc)).toString('base64'),
|
|
50
|
-
value,
|
|
62
|
+
encodeSqlValue(value),
|
|
51
63
|
]),
|
|
52
64
|
};
|
|
53
65
|
case 'schema-migration':
|
|
@@ -65,7 +77,7 @@ export function serializeSnapshotChunk(chunk) {
|
|
|
65
77
|
}
|
|
66
78
|
/**
|
|
67
79
|
* Deserialize a SnapshotChunk from JSON transport format.
|
|
68
|
-
* Converts base64 strings back to binary fields (SiteId, HLC).
|
|
80
|
+
* Converts base64 strings back to binary fields (SiteId, HLC) and decodes SqlValue blobs.
|
|
69
81
|
*/
|
|
70
82
|
export function deserializeSnapshotChunk(obj) {
|
|
71
83
|
const chunk = obj;
|
|
@@ -87,7 +99,7 @@ export function deserializeSnapshotChunk(obj) {
|
|
|
87
99
|
entries: chunk.entries.map(([key, hlc, value]) => [
|
|
88
100
|
key,
|
|
89
101
|
deserializeHLC(Buffer.from(hlc, 'base64')),
|
|
90
|
-
value,
|
|
102
|
+
decodeSqlValue(value),
|
|
91
103
|
]),
|
|
92
104
|
};
|
|
93
105
|
case 'schema-migration': {
|
|
@@ -107,7 +119,7 @@ export function deserializeSnapshotChunk(obj) {
|
|
|
107
119
|
}
|
|
108
120
|
/**
|
|
109
121
|
* Deserialize a ChangeSet from JSON transport format.
|
|
110
|
-
* Converts base64 strings back to binary fields.
|
|
122
|
+
* Converts base64 strings back to binary fields and decodes SqlValue blobs.
|
|
111
123
|
*/
|
|
112
124
|
export function deserializeChangeSet(cs) {
|
|
113
125
|
const obj = cs;
|
|
@@ -115,10 +127,19 @@ export function deserializeChangeSet(cs) {
|
|
|
115
127
|
siteId: siteIdFromBase64(obj.siteId),
|
|
116
128
|
transactionId: obj.transactionId,
|
|
117
129
|
hlc: deserializeHLC(Buffer.from(obj.hlc, 'base64')),
|
|
118
|
-
changes: obj.changes.map(c =>
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
130
|
+
changes: obj.changes.map(c => {
|
|
131
|
+
const base = {
|
|
132
|
+
type: c.type,
|
|
133
|
+
schema: c.schema,
|
|
134
|
+
table: c.table,
|
|
135
|
+
pk: c.pk.map(v => decodeSqlValue(v)),
|
|
136
|
+
hlc: deserializeHLC(Buffer.from(c.hlc, 'base64')),
|
|
137
|
+
};
|
|
138
|
+
if (c.type === 'column') {
|
|
139
|
+
return { ...base, column: c.column, value: decodeSqlValue(c.value) };
|
|
140
|
+
}
|
|
141
|
+
return base;
|
|
142
|
+
}),
|
|
122
143
|
schemaMigrations: (obj.schemaMigrations || []).map(m => ({
|
|
123
144
|
...m,
|
|
124
145
|
hlc: deserializeHLC(Buffer.from(m.hlc, 'base64')),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.js","sourceRoot":"","sources":["../../../src/common/serialization.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"serialization.js","sourceRoot":"","sources":["../../../src/common/serialization.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACN,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,YAAY,EACZ,cAAc,EACd,cAAc,GAId,MAAM,eAAe,CAAC;AAEvB;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,EAAa;IAC/C,OAAO;QACN,MAAM,EAAE,cAAc,CAAC,EAAE,CAAC,MAAM,CAAC;QACjC,aAAa,EAAE,EAAE,CAAC,aAAa;QAC/B,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACzD,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;YAC3B,MAAM,IAAI,GAAG;gBACZ,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,MAAM,EAAE,CAAC,CAAC,MAAM;gBAChB,KAAK,EAAE,CAAC,CAAC,KAAK;gBACd,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;gBACpC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAA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AI,CAAC,CAAC,CAAC,GAAa,EAAE,QAAQ,CAAC,CAAC;aAC3D,CAAC;YACF,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACzB,OAAO,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;YACtE,CAAC;YACD,OAAO,IAAI,CAAC;QACb,CAAC,CAAC;QACF,gBAAgB,EAAE,CAAE,GAAG,CAAC,gBAA8C,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YACvF,GAAG,CAAC;YACJ,GAAG,EAAE,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,GAAa,EAAE,QAAQ,CAAC,CAAC;SAC3D,CAAC,CAAC;KACU,CAAC;AAChB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quereus/sync-coordinator",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Standalone coordinator backend for Quereus Sync - production-ready sync server",
|
|
6
6
|
"keywords": [
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
"@aws-sdk/client-s3": "^3.970.0",
|
|
47
47
|
"@fastify/cors": "^11.2.0",
|
|
48
48
|
"@fastify/websocket": "^11.2.0",
|
|
49
|
-
"@quereus/isolation": "^1.0
|
|
50
|
-
"@quereus/plugin-leveldb": "^1.0
|
|
51
|
-
"@quereus/quereus": "^1.0
|
|
52
|
-
"@quereus/store": "^1.0
|
|
53
|
-
"@quereus/sync": "^1.0
|
|
49
|
+
"@quereus/isolation": "^1.1.0",
|
|
50
|
+
"@quereus/plugin-leveldb": "^1.1.0",
|
|
51
|
+
"@quereus/quereus": "^1.1.0",
|
|
52
|
+
"@quereus/store": "^1.1.0",
|
|
53
|
+
"@quereus/sync": "^1.1.0",
|
|
54
54
|
"commander": "^14.0.2",
|
|
55
55
|
"debug": "^4.4.3",
|
|
56
56
|
"fastify": "^5.7.0"
|