@syncular/server 0.79.3 → 0.81.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.
- package/dist/realtime.d.ts +10 -0
- package/dist/realtime.js +19 -0
- package/package.json +2 -2
- package/src/realtime.ts +21 -0
package/dist/realtime.d.ts
CHANGED
|
@@ -198,6 +198,8 @@ export declare class RealtimeSession {
|
|
|
198
198
|
refreshAfterPull(): Promise<void>;
|
|
199
199
|
refreshRegistrations(failClosed: boolean): Promise<void>;
|
|
200
200
|
sendHeartbeat(): void;
|
|
201
|
+
/** §8.7: the `scopes` announcement, which changes no session state. */
|
|
202
|
+
sendScopes(): void;
|
|
201
203
|
sendWake(reason: WakeReason): void;
|
|
202
204
|
/** Called by the hub for every applied commit notification. */
|
|
203
205
|
deliverCommit(commit: StoredCommit): void;
|
|
@@ -314,6 +316,14 @@ export declare class RealtimeHub {
|
|
|
314
316
|
* on until the next round. Presence is reconciled exactly as at round end.
|
|
315
317
|
*/
|
|
316
318
|
refreshScopes(partition: string, actorId?: string): Promise<void>;
|
|
319
|
+
/**
|
|
320
|
+
* Host announcement (§8.7): tell the connected sessions of `actorIds` on
|
|
321
|
+
* the partition that their grant widened, so each client's app runs its
|
|
322
|
+
* discovery and registers the units it did not know. Sends one `scopes`
|
|
323
|
+
* event per session and changes no registration; a narrowed grant needs
|
|
324
|
+
* `refreshScopes`.
|
|
325
|
+
*/
|
|
326
|
+
announceScopes(partition: string, actorIds: readonly string[]): void;
|
|
317
327
|
/** Broadcast a wake-up (host-initiated resync, schema rollover, §8.3). */
|
|
318
328
|
wake(partition: string, reason: WakeReason): void;
|
|
319
329
|
/** Wake every session on every partition (fanout listener gap, §8.3). */
|
package/dist/realtime.js
CHANGED
|
@@ -702,6 +702,10 @@ export class RealtimeSession {
|
|
|
702
702
|
sendHeartbeat() {
|
|
703
703
|
this.#sendSafe(encodeHeartbeat(this.#clock()));
|
|
704
704
|
}
|
|
705
|
+
/** §8.7: the `scopes` announcement, which changes no session state. */
|
|
706
|
+
sendScopes() {
|
|
707
|
+
this.#sendSafe(JSON.stringify({ event: 'scopes', data: { timestamp: this.#clock() } }));
|
|
708
|
+
}
|
|
705
709
|
sendWake(reason) {
|
|
706
710
|
this.#deferredDeltas = [];
|
|
707
711
|
this.#deferredBytes = 0;
|
|
@@ -1222,6 +1226,21 @@ export class RealtimeHub {
|
|
|
1222
1226
|
await session.refreshRegistrations(true);
|
|
1223
1227
|
}
|
|
1224
1228
|
}
|
|
1229
|
+
/**
|
|
1230
|
+
* Host announcement (§8.7): tell the connected sessions of `actorIds` on
|
|
1231
|
+
* the partition that their grant widened, so each client's app runs its
|
|
1232
|
+
* discovery and registers the units it did not know. Sends one `scopes`
|
|
1233
|
+
* event per session and changes no registration; a narrowed grant needs
|
|
1234
|
+
* `refreshScopes`.
|
|
1235
|
+
*/
|
|
1236
|
+
announceScopes(partition, actorIds) {
|
|
1237
|
+
for (const session of this.#sessions) {
|
|
1238
|
+
if (session.partition !== partition)
|
|
1239
|
+
continue;
|
|
1240
|
+
if (actorIds.includes(session.actorId))
|
|
1241
|
+
session.sendScopes();
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1225
1244
|
/** Broadcast a wake-up (host-initiated resync, schema rollover, §8.3). */
|
|
1226
1245
|
wake(partition, reason) {
|
|
1227
1246
|
for (const session of this.#sessions) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@syncular/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.81.0",
|
|
4
4
|
"description": "Syncular server: handleSyncRequest + storage/auth interfaces for the sync protocol",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Benjamin Kniffler",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"verify:node": "cd ../.. && bun build ./packages/server/test/sqlite-runtime/verify-node.mjs --target=node --conditions=bun --outfile=./packages/server/.verify-node.built.mjs && node ./packages/server/.verify-node.built.mjs"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@syncular/core": "0.
|
|
71
|
+
"@syncular/core": "0.81.0"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@electric-sql/pglite": "^0.5.4"
|
package/src/realtime.ts
CHANGED
|
@@ -945,6 +945,13 @@ export class RealtimeSession {
|
|
|
945
945
|
this.#sendSafe(encodeHeartbeat(this.#clock()));
|
|
946
946
|
}
|
|
947
947
|
|
|
948
|
+
/** §8.7: the `scopes` announcement, which changes no session state. */
|
|
949
|
+
sendScopes(): void {
|
|
950
|
+
this.#sendSafe(
|
|
951
|
+
JSON.stringify({ event: 'scopes', data: { timestamp: this.#clock() } }),
|
|
952
|
+
);
|
|
953
|
+
}
|
|
954
|
+
|
|
948
955
|
sendWake(reason: WakeReason): void {
|
|
949
956
|
this.#deferredDeltas = [];
|
|
950
957
|
this.#deferredBytes = 0;
|
|
@@ -1578,6 +1585,20 @@ export class RealtimeHub {
|
|
|
1578
1585
|
}
|
|
1579
1586
|
}
|
|
1580
1587
|
|
|
1588
|
+
/**
|
|
1589
|
+
* Host announcement (§8.7): tell the connected sessions of `actorIds` on
|
|
1590
|
+
* the partition that their grant widened, so each client's app runs its
|
|
1591
|
+
* discovery and registers the units it did not know. Sends one `scopes`
|
|
1592
|
+
* event per session and changes no registration; a narrowed grant needs
|
|
1593
|
+
* `refreshScopes`.
|
|
1594
|
+
*/
|
|
1595
|
+
announceScopes(partition: string, actorIds: readonly string[]): void {
|
|
1596
|
+
for (const session of this.#sessions) {
|
|
1597
|
+
if (session.partition !== partition) continue;
|
|
1598
|
+
if (actorIds.includes(session.actorId)) session.sendScopes();
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1581
1602
|
/** Broadcast a wake-up (host-initiated resync, schema rollover, §8.3). */
|
|
1582
1603
|
wake(partition: string, reason: WakeReason): void {
|
|
1583
1604
|
for (const session of this.#sessions) {
|