@quereus/sync-coordinator 0.3.4 → 0.3.6
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/README.md +7 -1
- package/package.json +3 -3
- package/dist/src/bin/sync-coordinator.d.ts +0 -6
- package/dist/src/bin/sync-coordinator.d.ts.map +0 -1
- package/dist/src/bin/sync-coordinator.js +0 -85
- package/dist/src/bin/sync-coordinator.js.map +0 -1
- package/dist/src/common/index.d.ts +0 -5
- package/dist/src/common/index.d.ts.map +0 -1
- package/dist/src/common/index.js +0 -5
- package/dist/src/common/index.js.map +0 -1
- package/dist/src/common/logger.d.ts +0 -20
- package/dist/src/common/logger.d.ts.map +0 -1
- package/dist/src/common/logger.js +0 -24
- package/dist/src/common/logger.js.map +0 -1
- package/dist/src/config/index.d.ts +0 -6
- package/dist/src/config/index.d.ts.map +0 -1
- package/dist/src/config/index.js +0 -6
- package/dist/src/config/index.js.map +0 -1
- package/dist/src/config/loader.d.ts +0 -27
- package/dist/src/config/loader.d.ts.map +0 -1
- package/dist/src/config/loader.js +0 -144
- package/dist/src/config/loader.js.map +0 -1
- package/dist/src/config/types.d.ts +0 -74
- package/dist/src/config/types.d.ts.map +0 -1
- package/dist/src/config/types.js +0 -27
- package/dist/src/config/types.js.map +0 -1
- package/dist/src/index.d.ts +0 -21
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -26
- package/dist/src/index.js.map +0 -1
- package/dist/src/metrics/coordinator-metrics.d.ts +0 -27
- package/dist/src/metrics/coordinator-metrics.d.ts.map +0 -1
- package/dist/src/metrics/coordinator-metrics.js +0 -57
- package/dist/src/metrics/coordinator-metrics.js.map +0 -1
- package/dist/src/metrics/index.d.ts +0 -7
- package/dist/src/metrics/index.d.ts.map +0 -1
- package/dist/src/metrics/index.js +0 -7
- package/dist/src/metrics/index.js.map +0 -1
- package/dist/src/metrics/registry.d.ts +0 -53
- package/dist/src/metrics/registry.d.ts.map +0 -1
- package/dist/src/metrics/registry.js +0 -158
- package/dist/src/metrics/registry.js.map +0 -1
- package/dist/src/metrics/types.d.ts +0 -62
- package/dist/src/metrics/types.d.ts.map +0 -1
- package/dist/src/metrics/types.js +0 -16
- package/dist/src/metrics/types.js.map +0 -1
- package/dist/src/server/index.d.ts +0 -7
- package/dist/src/server/index.d.ts.map +0 -1
- package/dist/src/server/index.js +0 -7
- package/dist/src/server/index.js.map +0 -1
- package/dist/src/server/routes.d.ts +0 -10
- package/dist/src/server/routes.d.ts.map +0 -1
- package/dist/src/server/routes.js +0 -153
- package/dist/src/server/routes.js.map +0 -1
- package/dist/src/server/server.d.ts +0 -34
- package/dist/src/server/server.d.ts.map +0 -1
- package/dist/src/server/server.js +0 -57
- package/dist/src/server/server.js.map +0 -1
- package/dist/src/server/websocket.d.ts +0 -10
- package/dist/src/server/websocket.d.ts.map +0 -1
- package/dist/src/server/websocket.js +0 -159
- package/dist/src/server/websocket.js.map +0 -1
- package/dist/src/service/coordinator-service.d.ts +0 -114
- package/dist/src/service/coordinator-service.d.ts.map +0 -1
- package/dist/src/service/coordinator-service.js +0 -373
- package/dist/src/service/coordinator-service.js.map +0 -1
- package/dist/src/service/index.d.ts +0 -6
- package/dist/src/service/index.d.ts.map +0 -1
- package/dist/src/service/index.js +0 -5
- package/dist/src/service/index.js.map +0 -1
- package/dist/src/service/types.d.ts +0 -142
- package/dist/src/service/types.d.ts.map +0 -1
- package/dist/src/service/types.js +0 -5
- package/dist/src/service/types.js.map +0 -1
|
@@ -1,373 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CoordinatorService - Main service layer for sync coordination.
|
|
3
|
-
*
|
|
4
|
-
* Wraps SyncManager with validation hooks and client session management.
|
|
5
|
-
*/
|
|
6
|
-
import { randomUUID } from 'node:crypto';
|
|
7
|
-
import { LevelDBStore, StoreEventEmitter } from '@quereus/plugin-store';
|
|
8
|
-
import { createSyncModule, siteIdFromBase64, siteIdEquals, siteIdToBase64, serializeHLC, } from '@quereus/plugin-sync';
|
|
9
|
-
import { serviceLog, authLog } from '../common/logger.js';
|
|
10
|
-
import { createCoordinatorMetrics, } from '../metrics/index.js';
|
|
11
|
-
/**
|
|
12
|
-
* Coordinator service that manages sync operations with hooks.
|
|
13
|
-
*/
|
|
14
|
-
export class CoordinatorService {
|
|
15
|
-
config;
|
|
16
|
-
hooks;
|
|
17
|
-
metrics;
|
|
18
|
-
syncManager;
|
|
19
|
-
kvStore;
|
|
20
|
-
/** Active WebSocket sessions by connection ID */
|
|
21
|
-
sessions = new Map();
|
|
22
|
-
/** Connection IDs by site ID for broadcasting */
|
|
23
|
-
siteIdToConnections = new Map();
|
|
24
|
-
initialized = false;
|
|
25
|
-
constructor(options) {
|
|
26
|
-
this.config = options.config;
|
|
27
|
-
this.hooks = options.hooks || {};
|
|
28
|
-
this.metrics = options.metrics || createCoordinatorMetrics();
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Initialize the service (open store, create sync manager).
|
|
32
|
-
*/
|
|
33
|
-
async initialize() {
|
|
34
|
-
if (this.initialized)
|
|
35
|
-
return;
|
|
36
|
-
serviceLog('Initializing CoordinatorService with dataDir: %s', this.config.dataDir);
|
|
37
|
-
// Open LevelDB store
|
|
38
|
-
this.kvStore = await LevelDBStore.open({
|
|
39
|
-
path: this.config.dataDir,
|
|
40
|
-
createIfMissing: true,
|
|
41
|
-
});
|
|
42
|
-
// Create sync module
|
|
43
|
-
const storeEvents = new StoreEventEmitter();
|
|
44
|
-
const { syncManager } = await createSyncModule(this.kvStore, storeEvents, {
|
|
45
|
-
tombstoneTTL: this.config.sync.tombstoneTTL,
|
|
46
|
-
batchSize: this.config.sync.batchSize,
|
|
47
|
-
});
|
|
48
|
-
this.syncManager = syncManager;
|
|
49
|
-
this.initialized = true;
|
|
50
|
-
serviceLog('CoordinatorService initialized, siteId: %s', siteIdToBase64(syncManager.getSiteId()));
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Shutdown the service.
|
|
54
|
-
*/
|
|
55
|
-
async shutdown() {
|
|
56
|
-
if (!this.initialized)
|
|
57
|
-
return;
|
|
58
|
-
serviceLog('Shutting down CoordinatorService');
|
|
59
|
-
// Close all WebSocket connections
|
|
60
|
-
for (const session of this.sessions.values()) {
|
|
61
|
-
session.socket.close(1001, 'Server shutting down');
|
|
62
|
-
}
|
|
63
|
-
this.sessions.clear();
|
|
64
|
-
this.siteIdToConnections.clear();
|
|
65
|
-
// Close KV store
|
|
66
|
-
await this.kvStore.close();
|
|
67
|
-
this.initialized = false;
|
|
68
|
-
}
|
|
69
|
-
// ============================================================================
|
|
70
|
-
// Authentication & Authorization
|
|
71
|
-
// ============================================================================
|
|
72
|
-
/**
|
|
73
|
-
* Authenticate a request/connection.
|
|
74
|
-
*/
|
|
75
|
-
async authenticate(context) {
|
|
76
|
-
authLog('Authenticating request, siteId: %s', context.siteIdRaw?.slice(0, 16));
|
|
77
|
-
this.metrics.registry.incCounter(this.metrics.authAttemptsTotal);
|
|
78
|
-
try {
|
|
79
|
-
// Token-whitelist mode
|
|
80
|
-
if (this.config.auth.mode === 'token-whitelist') {
|
|
81
|
-
if (!context.token) {
|
|
82
|
-
throw new Error('Authentication required');
|
|
83
|
-
}
|
|
84
|
-
if (!this.config.auth.tokens?.includes(context.token)) {
|
|
85
|
-
throw new Error('Invalid token');
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
// Custom hook
|
|
89
|
-
if (this.hooks.onAuthenticate) {
|
|
90
|
-
return await this.hooks.onAuthenticate(context);
|
|
91
|
-
}
|
|
92
|
-
// Default: allow all, use provided siteId
|
|
93
|
-
if (!context.siteId && context.siteIdRaw) {
|
|
94
|
-
context.siteId = siteIdFromBase64(context.siteIdRaw);
|
|
95
|
-
}
|
|
96
|
-
if (!context.siteId) {
|
|
97
|
-
throw new Error('Site ID required');
|
|
98
|
-
}
|
|
99
|
-
return { siteId: context.siteId };
|
|
100
|
-
}
|
|
101
|
-
catch (err) {
|
|
102
|
-
this.metrics.registry.incCounter(this.metrics.authFailuresTotal);
|
|
103
|
-
throw err;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Authorize an operation for a client.
|
|
108
|
-
*/
|
|
109
|
-
async authorize(client, operation) {
|
|
110
|
-
if (this.hooks.onAuthorize) {
|
|
111
|
-
const allowed = await this.hooks.onAuthorize(client, operation);
|
|
112
|
-
if (!allowed) {
|
|
113
|
-
authLog('Authorization denied for %s: %O', siteIdToBase64(client.siteId), operation);
|
|
114
|
-
}
|
|
115
|
-
return allowed;
|
|
116
|
-
}
|
|
117
|
-
return true; // Default: allow all
|
|
118
|
-
}
|
|
119
|
-
// ============================================================================
|
|
120
|
-
// Sync Operations
|
|
121
|
-
// ============================================================================
|
|
122
|
-
/**
|
|
123
|
-
* Get this coordinator's site ID.
|
|
124
|
-
*/
|
|
125
|
-
getSiteId() {
|
|
126
|
-
return this.syncManager.getSiteId();
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Get current HLC.
|
|
130
|
-
*/
|
|
131
|
-
getCurrentHLC() {
|
|
132
|
-
return this.syncManager.getCurrentHLC();
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Get changes since a given HLC for a client.
|
|
136
|
-
*/
|
|
137
|
-
async getChangesSince(client, sinceHLC) {
|
|
138
|
-
serviceLog('getChangesSince for %s, sinceHLC: %O', siteIdToBase64(client.siteId), sinceHLC);
|
|
139
|
-
const endTimer = this.metrics.registry.startTimer(this.metrics.getChangesDuration);
|
|
140
|
-
// Authorize
|
|
141
|
-
const allowed = await this.authorize(client, { type: 'get_changes', sinceHLC });
|
|
142
|
-
if (!allowed) {
|
|
143
|
-
throw new Error('Not authorized');
|
|
144
|
-
}
|
|
145
|
-
const changes = await this.syncManager.getChangesSince(client.siteId, sinceHLC);
|
|
146
|
-
endTimer();
|
|
147
|
-
return changes;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Apply changes from a client.
|
|
151
|
-
*/
|
|
152
|
-
async applyChanges(client, changes) {
|
|
153
|
-
serviceLog('applyChanges from %s, count: %d', siteIdToBase64(client.siteId), changes.length);
|
|
154
|
-
const endTimer = this.metrics.registry.startTimer(this.metrics.applyChangesDuration);
|
|
155
|
-
this.metrics.registry.incCounter(this.metrics.changesReceivedTotal, {}, changes.length);
|
|
156
|
-
this.metrics.registry.observeHistogram(this.metrics.changeBatchSize, changes.length);
|
|
157
|
-
// Authorize
|
|
158
|
-
const allowed = await this.authorize(client, {
|
|
159
|
-
type: 'apply_changes',
|
|
160
|
-
changeCount: changes.length
|
|
161
|
-
});
|
|
162
|
-
if (!allowed) {
|
|
163
|
-
throw new Error('Not authorized');
|
|
164
|
-
}
|
|
165
|
-
// Validate changes
|
|
166
|
-
let approvedChanges = changes;
|
|
167
|
-
if (this.hooks.onBeforeApplyChanges) {
|
|
168
|
-
const result = await this.hooks.onBeforeApplyChanges(client, changes);
|
|
169
|
-
approvedChanges = result.approved;
|
|
170
|
-
if (result.rejected.length > 0) {
|
|
171
|
-
serviceLog('Rejected %d changes from %s', result.rejected.length, siteIdToBase64(client.siteId));
|
|
172
|
-
this.metrics.registry.incCounter(this.metrics.changesRejectedTotal, {}, result.rejected.length);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
// Log changes before applying for debugging
|
|
176
|
-
for (const cs of approvedChanges) {
|
|
177
|
-
serviceLog('ChangeSet has %d changes, %d schemaMigrations', cs.changes.length, cs.schemaMigrations?.length ?? 0);
|
|
178
|
-
for (const c of cs.changes) {
|
|
179
|
-
if (c.type === 'column') {
|
|
180
|
-
serviceLog(' Column: %s.%s.%s = %O', c.schema, c.table, c.column, c.value);
|
|
181
|
-
}
|
|
182
|
-
else if (c.type === 'delete') {
|
|
183
|
-
serviceLog(' Delete: %s.%s pk=%O', c.schema, c.table, c.pk);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
// Apply
|
|
188
|
-
const result = await this.syncManager.applyChanges(approvedChanges);
|
|
189
|
-
serviceLog('Apply result: applied=%d, skipped=%d, conflicts=%d', result.applied, result.skipped, result.conflicts);
|
|
190
|
-
endTimer();
|
|
191
|
-
this.metrics.registry.incCounter(this.metrics.changesAppliedTotal, {}, result.applied);
|
|
192
|
-
// Post-apply hook
|
|
193
|
-
if (this.hooks.onAfterApplyChanges) {
|
|
194
|
-
this.hooks.onAfterApplyChanges(client, approvedChanges, result);
|
|
195
|
-
}
|
|
196
|
-
// Broadcast to other connected clients
|
|
197
|
-
if (result.applied > 0) {
|
|
198
|
-
serviceLog('Broadcasting %d changes to other clients', approvedChanges.length);
|
|
199
|
-
this.broadcastChanges(client.siteId, approvedChanges);
|
|
200
|
-
}
|
|
201
|
-
else {
|
|
202
|
-
serviceLog('No changes applied, not broadcasting');
|
|
203
|
-
}
|
|
204
|
-
return result;
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Stream a full snapshot.
|
|
208
|
-
*/
|
|
209
|
-
async *getSnapshotStream(client, chunkSize) {
|
|
210
|
-
serviceLog('getSnapshotStream for %s', siteIdToBase64(client.siteId));
|
|
211
|
-
this.metrics.registry.incCounter(this.metrics.snapshotRequestsTotal);
|
|
212
|
-
// Authorize
|
|
213
|
-
const allowed = await this.authorize(client, { type: 'get_snapshot' });
|
|
214
|
-
if (!allowed) {
|
|
215
|
-
throw new Error('Not authorized');
|
|
216
|
-
}
|
|
217
|
-
for await (const chunk of this.syncManager.getSnapshotStream(chunkSize)) {
|
|
218
|
-
this.metrics.registry.incCounter(this.metrics.snapshotChunksTotal);
|
|
219
|
-
yield chunk;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Check if delta sync is possible.
|
|
224
|
-
*/
|
|
225
|
-
async canDeltaSync(client, sinceHLC) {
|
|
226
|
-
return this.syncManager.canDeltaSync(client.siteId, sinceHLC);
|
|
227
|
-
}
|
|
228
|
-
// ============================================================================
|
|
229
|
-
// WebSocket Session Management
|
|
230
|
-
// ============================================================================
|
|
231
|
-
/**
|
|
232
|
-
* Register a new WebSocket client session.
|
|
233
|
-
*/
|
|
234
|
-
async registerSession(socket, identity) {
|
|
235
|
-
const connectionId = randomUUID();
|
|
236
|
-
const siteIdKey = siteIdToBase64(identity.siteId);
|
|
237
|
-
// Call connect hook
|
|
238
|
-
if (this.hooks.onClientConnect) {
|
|
239
|
-
const allowed = await this.hooks.onClientConnect(identity, socket);
|
|
240
|
-
if (!allowed) {
|
|
241
|
-
throw new Error('Connection rejected');
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
const session = {
|
|
245
|
-
connectionId,
|
|
246
|
-
siteId: identity.siteId,
|
|
247
|
-
identity,
|
|
248
|
-
lastSyncHLC: undefined,
|
|
249
|
-
connectedAt: Date.now(),
|
|
250
|
-
socket,
|
|
251
|
-
};
|
|
252
|
-
this.sessions.set(connectionId, session);
|
|
253
|
-
// Track by siteId for broadcasting
|
|
254
|
-
let connections = this.siteIdToConnections.get(siteIdKey);
|
|
255
|
-
if (!connections) {
|
|
256
|
-
connections = new Set();
|
|
257
|
-
this.siteIdToConnections.set(siteIdKey, connections);
|
|
258
|
-
}
|
|
259
|
-
connections.add(connectionId);
|
|
260
|
-
// Update metrics
|
|
261
|
-
this.metrics.registry.incCounter(this.metrics.wsConnectionsTotal);
|
|
262
|
-
this.metrics.registry.incGauge(this.metrics.wsConnectionsActive);
|
|
263
|
-
serviceLog('Session registered: %s (site: %s)', connectionId.slice(0, 8), siteIdKey);
|
|
264
|
-
return session;
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* Unregister a WebSocket client session.
|
|
268
|
-
*/
|
|
269
|
-
unregisterSession(connectionId) {
|
|
270
|
-
const session = this.sessions.get(connectionId);
|
|
271
|
-
if (!session)
|
|
272
|
-
return;
|
|
273
|
-
const siteIdKey = siteIdToBase64(session.siteId);
|
|
274
|
-
// Call disconnect hook
|
|
275
|
-
if (this.hooks.onClientDisconnect) {
|
|
276
|
-
this.hooks.onClientDisconnect(session.identity);
|
|
277
|
-
}
|
|
278
|
-
this.sessions.delete(connectionId);
|
|
279
|
-
// Remove from siteId tracking
|
|
280
|
-
const connections = this.siteIdToConnections.get(siteIdKey);
|
|
281
|
-
if (connections) {
|
|
282
|
-
connections.delete(connectionId);
|
|
283
|
-
if (connections.size === 0) {
|
|
284
|
-
this.siteIdToConnections.delete(siteIdKey);
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
// Update metrics
|
|
288
|
-
this.metrics.registry.decGauge(this.metrics.wsConnectionsActive);
|
|
289
|
-
serviceLog('Session unregistered: %s', connectionId.slice(0, 8));
|
|
290
|
-
}
|
|
291
|
-
/**
|
|
292
|
-
* Get a session by connection ID.
|
|
293
|
-
*/
|
|
294
|
-
getSession(connectionId) {
|
|
295
|
-
return this.sessions.get(connectionId);
|
|
296
|
-
}
|
|
297
|
-
/**
|
|
298
|
-
* Update the last sync HLC for a session.
|
|
299
|
-
*/
|
|
300
|
-
updateSessionSyncState(connectionId, hlc) {
|
|
301
|
-
const session = this.sessions.get(connectionId);
|
|
302
|
-
if (session) {
|
|
303
|
-
session.lastSyncHLC = hlc;
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
/**
|
|
307
|
-
* Broadcast changes to all connected clients except the sender.
|
|
308
|
-
*/
|
|
309
|
-
broadcastChanges(senderSiteId, changes) {
|
|
310
|
-
// Serialize changesets for JSON transport
|
|
311
|
-
const serializedChangeSets = changes.map(cs => this.serializeChangeSet(cs));
|
|
312
|
-
const message = JSON.stringify({
|
|
313
|
-
type: 'push_changes',
|
|
314
|
-
changeSets: serializedChangeSets,
|
|
315
|
-
});
|
|
316
|
-
let broadcastCount = 0;
|
|
317
|
-
for (const session of this.sessions.values()) {
|
|
318
|
-
// Don't send to the originator
|
|
319
|
-
if (siteIdEquals(session.siteId, senderSiteId)) {
|
|
320
|
-
continue;
|
|
321
|
-
}
|
|
322
|
-
if (session.socket.readyState === 1) { // WebSocket.OPEN
|
|
323
|
-
session.socket.send(message);
|
|
324
|
-
broadcastCount++;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
if (broadcastCount > 0) {
|
|
328
|
-
this.metrics.registry.incCounter(this.metrics.changesBroadcastTotal, {}, changes.length * broadcastCount);
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* Serialize a ChangeSet for JSON transport.
|
|
333
|
-
*/
|
|
334
|
-
serializeChangeSet(cs) {
|
|
335
|
-
const hlcBytes = serializeHLC(cs.hlc);
|
|
336
|
-
return {
|
|
337
|
-
siteId: siteIdToBase64(cs.siteId),
|
|
338
|
-
transactionId: cs.transactionId,
|
|
339
|
-
hlc: Buffer.from(hlcBytes).toString('base64'),
|
|
340
|
-
changes: cs.changes.map(c => {
|
|
341
|
-
const chlcBytes = serializeHLC(c.hlc);
|
|
342
|
-
return {
|
|
343
|
-
...c,
|
|
344
|
-
hlc: Buffer.from(chlcBytes).toString('base64'),
|
|
345
|
-
};
|
|
346
|
-
}),
|
|
347
|
-
schemaMigrations: cs.schemaMigrations.map(m => {
|
|
348
|
-
const mhlcBytes = serializeHLC(m.hlc);
|
|
349
|
-
return {
|
|
350
|
-
...m,
|
|
351
|
-
hlc: Buffer.from(mhlcBytes).toString('base64'),
|
|
352
|
-
};
|
|
353
|
-
}),
|
|
354
|
-
};
|
|
355
|
-
}
|
|
356
|
-
/**
|
|
357
|
-
* Get server status and stats.
|
|
358
|
-
*/
|
|
359
|
-
getStatus() {
|
|
360
|
-
return {
|
|
361
|
-
siteId: siteIdToBase64(this.syncManager.getSiteId()),
|
|
362
|
-
connectedClients: this.sessions.size,
|
|
363
|
-
uptime: process.uptime(),
|
|
364
|
-
};
|
|
365
|
-
}
|
|
366
|
-
/**
|
|
367
|
-
* Get the metrics registry for this service.
|
|
368
|
-
*/
|
|
369
|
-
getMetrics() {
|
|
370
|
-
return this.metrics;
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
//# sourceMappingURL=coordinator-service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"coordinator-service.js","sourceRoot":"","sources":["../../../src/service/coordinator-service.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EACL,gBAAgB,EAOhB,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,YAAY,GACb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,EACL,wBAAwB,GAEzB,MAAM,qBAAqB,CAAC;AAqB7B;;GAEG;AACH,MAAM,OAAO,kBAAkB;IACZ,MAAM,CAAoB;IAC1B,KAAK,CAAmB;IACxB,OAAO,CAAqB;IACrC,WAAW,CAAe;IAC1B,OAAO,CAAgB;IAE/B,iDAAiD;IAChC,QAAQ,GAAG,IAAI,GAAG,EAAyB,CAAC;IAC7D,iDAAiD;IAChC,mBAAmB,GAAG,IAAI,GAAG,EAAuB,CAAC;IAE9D,WAAW,GAAG,KAAK,CAAC;IAE5B,YAAY,OAAkC;QAC5C,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,wBAAwB,EAAE,CAAC;IAC/D,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU;QACd,IAAI,IAAI,CAAC,WAAW;YAAE,OAAO;QAE7B,UAAU,CAAC,kDAAkD,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAEpF,qBAAqB;QACrB,IAAI,CAAC,OAAO,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC;YACrC,IAAI,E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S,EAAE,CAAC;YACpD,gBAAgB,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI;YACpC,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE;SACzB,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Service layer exports.
|
|
3
|
-
*/
|
|
4
|
-
export { type ClientIdentity, type ClientSession, type AuthContext, type SyncOperation, type RejectedChange, type ValidationResult, type CoordinatorHooks, } from './types.js';
|
|
5
|
-
export { CoordinatorService, type CoordinatorServiceOptions, } from './coordinator-service.js';
|
|
6
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/service/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,GACtB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,kBAAkB,EAClB,KAAK,yBAAyB,GAC/B,MAAM,0BAA0B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/service/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAYH,OAAO,EACL,kBAAkB,GAEnB,MAAM,0BAA0B,CAAC"}
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Service layer types - hooks, sessions, and operations.
|
|
3
|
-
*/
|
|
4
|
-
import type { WebSocket } from 'ws';
|
|
5
|
-
import type { FastifyRequest } from 'fastify';
|
|
6
|
-
import type { SiteId, HLC, ChangeSet, ApplyResult } from '@quereus/plugin-sync';
|
|
7
|
-
/**
|
|
8
|
-
* Authenticated client identity.
|
|
9
|
-
* Extend this interface for custom auth data.
|
|
10
|
-
*/
|
|
11
|
-
export interface ClientIdentity {
|
|
12
|
-
/** Client's site ID for sync */
|
|
13
|
-
siteId: SiteId;
|
|
14
|
-
/** Optional user ID from authentication */
|
|
15
|
-
userId?: string;
|
|
16
|
-
/** Optional additional metadata */
|
|
17
|
-
metadata?: Record<string, unknown>;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Active WebSocket client session.
|
|
21
|
-
*/
|
|
22
|
-
export interface ClientSession {
|
|
23
|
-
/** Unique connection identifier */
|
|
24
|
-
connectionId: string;
|
|
25
|
-
/** Client's replica site ID */
|
|
26
|
-
siteId: SiteId;
|
|
27
|
-
/** Authenticated identity */
|
|
28
|
-
identity: ClientIdentity;
|
|
29
|
-
/** Last HLC client synced to */
|
|
30
|
-
lastSyncHLC: HLC | undefined;
|
|
31
|
-
/** Connection timestamp */
|
|
32
|
-
connectedAt: number;
|
|
33
|
-
/** The WebSocket connection */
|
|
34
|
-
socket: WebSocket;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Context provided to authentication hook.
|
|
38
|
-
*/
|
|
39
|
-
export interface AuthContext {
|
|
40
|
-
/** Authorization header value */
|
|
41
|
-
token?: string;
|
|
42
|
-
/** Client-provided site ID */
|
|
43
|
-
siteId?: SiteId;
|
|
44
|
-
/** Raw site ID string from header */
|
|
45
|
-
siteIdRaw?: string;
|
|
46
|
-
/** Original HTTP request (if available) */
|
|
47
|
-
request?: FastifyRequest;
|
|
48
|
-
/** WebSocket connection (if WebSocket auth) */
|
|
49
|
-
socket?: WebSocket;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Sync operations that can be authorized.
|
|
53
|
-
*/
|
|
54
|
-
export type SyncOperation = {
|
|
55
|
-
type: 'get_changes';
|
|
56
|
-
sinceHLC?: HLC;
|
|
57
|
-
} | {
|
|
58
|
-
type: 'apply_changes';
|
|
59
|
-
changeCount: number;
|
|
60
|
-
} | {
|
|
61
|
-
type: 'get_snapshot';
|
|
62
|
-
} | {
|
|
63
|
-
type: 'resume_snapshot';
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* A change that was rejected during validation.
|
|
67
|
-
*/
|
|
68
|
-
export interface RejectedChange {
|
|
69
|
-
/** The rejected change */
|
|
70
|
-
change: ChangeSet;
|
|
71
|
-
/** Reason for rejection */
|
|
72
|
-
reason: string;
|
|
73
|
-
/** Error code for programmatic handling */
|
|
74
|
-
code?: string;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Result of change validation.
|
|
78
|
-
*/
|
|
79
|
-
export interface ValidationResult {
|
|
80
|
-
/** Changes approved for application */
|
|
81
|
-
approved: ChangeSet[];
|
|
82
|
-
/** Changes that were rejected */
|
|
83
|
-
rejected: RejectedChange[];
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Coordinator service hooks for customization.
|
|
87
|
-
* All hooks are optional; defaults allow all operations.
|
|
88
|
-
*/
|
|
89
|
-
export interface CoordinatorHooks {
|
|
90
|
-
/**
|
|
91
|
-
* Authenticate an incoming request/connection.
|
|
92
|
-
* Called before any sync operation.
|
|
93
|
-
*
|
|
94
|
-
* @param context - Auth context with token and request info
|
|
95
|
-
* @returns Client identity on success
|
|
96
|
-
* @throws Error to reject authentication
|
|
97
|
-
*/
|
|
98
|
-
onAuthenticate?(context: AuthContext): Promise<ClientIdentity>;
|
|
99
|
-
/**
|
|
100
|
-
* Authorize a specific operation for a client.
|
|
101
|
-
* Called after authentication, before executing the operation.
|
|
102
|
-
*
|
|
103
|
-
* @param client - Authenticated client identity
|
|
104
|
-
* @param operation - The operation being requested
|
|
105
|
-
* @returns true to allow, false to deny
|
|
106
|
-
*/
|
|
107
|
-
onAuthorize?(client: ClientIdentity, operation: SyncOperation): Promise<boolean>;
|
|
108
|
-
/**
|
|
109
|
-
* Validate changes before applying them.
|
|
110
|
-
* Can modify, filter, or reject changes.
|
|
111
|
-
*
|
|
112
|
-
* @param client - Authenticated client identity
|
|
113
|
-
* @param changes - Changes to validate
|
|
114
|
-
* @returns Approved and rejected changes
|
|
115
|
-
*/
|
|
116
|
-
onBeforeApplyChanges?(client: ClientIdentity, changes: ChangeSet[]): Promise<ValidationResult>;
|
|
117
|
-
/**
|
|
118
|
-
* Called after changes are successfully applied.
|
|
119
|
-
* Useful for logging, metrics, or triggering side effects.
|
|
120
|
-
*
|
|
121
|
-
* @param client - Authenticated client identity
|
|
122
|
-
* @param changes - Changes that were applied
|
|
123
|
-
* @param result - Result of the apply operation
|
|
124
|
-
*/
|
|
125
|
-
onAfterApplyChanges?(client: ClientIdentity, changes: ChangeSet[], result: ApplyResult): void;
|
|
126
|
-
/**
|
|
127
|
-
* Called when a WebSocket client connects.
|
|
128
|
-
* Return false to reject the connection.
|
|
129
|
-
*
|
|
130
|
-
* @param client - Authenticated client identity
|
|
131
|
-
* @param socket - The WebSocket connection
|
|
132
|
-
* @returns true to accept, false to reject
|
|
133
|
-
*/
|
|
134
|
-
onClientConnect?(client: ClientIdentity, socket: WebSocket): Promise<boolean>;
|
|
135
|
-
/**
|
|
136
|
-
* Called when a WebSocket client disconnects.
|
|
137
|
-
*
|
|
138
|
-
* @param client - Client identity of disconnected client
|
|
139
|
-
*/
|
|
140
|
-
onClientDisconnect?(client: ClientIdentity): void;
|
|
141
|
-
}
|
|
142
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/service/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,KAAK,EACV,MAAM,EACN,GAAG,EACH,SAAS,EACT,WAAW,EACZ,MAAM,sBAAsB,CAAC;AAM9B;;;GAGG;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