@syncular/client 0.59.0 → 0.60.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/README.md +27 -27
- package/dist/apply.d.ts +6 -5
- package/dist/apply.js +52 -25
- package/dist/authority.js +21 -16
- package/dist/blob.d.ts +4 -4
- package/dist/bun-database.js +3 -16
- package/dist/client.d.ts +57 -66
- package/dist/client.js +701 -796
- package/dist/devtools.d.ts +2 -2
- package/dist/devtools.js +3 -3
- package/dist/diagnostics.d.ts +17 -28
- package/dist/diagnostics.js +1 -2
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +1 -1
- package/dist/failed-overlay.js +4 -1
- package/dist/http.js +10 -4
- package/dist/invalidation.d.ts +3 -4
- package/dist/invalidation.js +9 -22
- package/dist/native-bridge.d.ts +7 -16
- package/dist/native-bridge.js +16 -41
- package/dist/node-database.js +16 -25
- package/dist/outbox.js +1 -0
- package/dist/progress.d.ts +2 -2
- package/dist/query-guard.d.ts +15 -6
- package/dist/query-guard.js +38 -6
- package/dist/reactive-store.js +2 -2
- package/dist/remote.js +9 -9
- package/dist/schema.d.ts +3 -2
- package/dist/schema.js +28 -12
- package/dist/state.d.ts +69 -36
- package/dist/state.js +178 -89
- package/dist/sync-scheduler.js +2 -2
- package/dist/transport.d.ts +2 -2
- package/dist/window.d.ts +30 -52
- package/dist/window.js +33 -77
- package/dist/worker-core.js +6 -6
- package/dist/worker-host.d.ts +9 -8
- package/dist/worker-host.js +11 -11
- package/dist/worker-protocol.d.ts +9 -8
- package/package.json +3 -3
- package/src/apply.ts +87 -33
- package/src/authority.ts +31 -17
- package/src/blob.ts +4 -3
- package/src/bun-database.ts +9 -14
- package/src/client.ts +886 -1037
- package/src/devtools.ts +5 -5
- package/src/diagnostics.ts +17 -37
- package/src/errors.ts +1 -1
- package/src/failed-overlay.ts +6 -1
- package/src/http.ts +13 -8
- package/src/invalidation.ts +9 -29
- package/src/native-bridge.ts +22 -58
- package/src/node-database.ts +26 -27
- package/src/outbox.ts +1 -0
- package/src/progress.ts +2 -2
- package/src/query-guard.ts +45 -8
- package/src/reactive-store.ts +2 -2
- package/src/remote.ts +12 -16
- package/src/schema.ts +48 -13
- package/src/state.ts +246 -125
- package/src/sync-scheduler.ts +2 -2
- package/src/transport.ts +2 -2
- package/src/window.ts +55 -134
- package/src/worker-core.ts +6 -6
- package/src/worker-host.ts +13 -16
- package/src/worker-protocol.ts +8 -8
package/src/sync-scheduler.ts
CHANGED
|
@@ -45,7 +45,7 @@ export function installSyncScheduler(
|
|
|
45
45
|
let backgroundReady = false;
|
|
46
46
|
let backgroundDue = Number.POSITIVE_INFINITY;
|
|
47
47
|
let cancelBackground: (() => void) | undefined;
|
|
48
|
-
// §7.
|
|
48
|
+
// §7.7 backoff for drives that end without a client retry intent.
|
|
49
49
|
let retryDelayMs = 250;
|
|
50
50
|
|
|
51
51
|
const report = (error: unknown): void => {
|
|
@@ -103,7 +103,7 @@ export function installSyncScheduler(
|
|
|
103
103
|
.catch((error: unknown) => {
|
|
104
104
|
if (stopped) return;
|
|
105
105
|
report(error);
|
|
106
|
-
// §7.
|
|
106
|
+
// §7.8: a retryable drive rejection owes another drive. A retryable
|
|
107
107
|
// round failure already handed this loop its background intent; the
|
|
108
108
|
// drive deadline did not. An unreachable endpoint waits for the
|
|
109
109
|
// host's connectivity resume (§1.8).
|
package/src/transport.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* One combined push+pull round trip: SSP2 request bytes → response bytes.
|
|
10
|
-
* `signal` aborts when the `syncUntilIdle` deadline elapses (§7.
|
|
10
|
+
* `signal` aborts when the `syncUntilIdle` deadline elapses (§7.8); a
|
|
11
11
|
* transport that honors it releases the round instead of holding it open.
|
|
12
12
|
*/
|
|
13
13
|
export type SyncTransport = (
|
|
@@ -45,7 +45,7 @@ export interface SegmentFetchRequest {
|
|
|
45
45
|
*/
|
|
46
46
|
readonly byteLength?: number;
|
|
47
47
|
readonly onProgress?: (bytesReceived: number) => void;
|
|
48
|
-
/** Aborts with the round when the `syncUntilIdle` deadline elapses (§7.
|
|
48
|
+
/** Aborts with the round when the `syncUntilIdle` deadline elapses (§7.8). */
|
|
49
49
|
readonly signal?: AbortSignal;
|
|
50
50
|
}
|
|
51
51
|
|
package/src/window.ts
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
export const PENDING_EVICTIONS = '
|
|
1
|
+
export const PENDING_EVICTIONS = '_syncular_pending_evictions';
|
|
2
2
|
export const WINDOWS_TABLE = '_syncular_windows';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Windows (SPEC.md §4.8).
|
|
5
5
|
*
|
|
6
6
|
* A window is a partial local replica keyed by scope VALUES: the client
|
|
7
|
-
* holds
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* mutation of one — so it needs zero wire or server changes.
|
|
7
|
+
* holds the units of a chosen set of values of a window BASE (one scope
|
|
8
|
+
* variable plus fixed values). Windowing is a set difference on §4.1 units,
|
|
9
|
+
* never a mutation of one, so it needs no wire or server change.
|
|
11
10
|
*
|
|
12
|
-
* This module owns the registry bookkeeping
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* transaction and the invalidation choke point.
|
|
11
|
+
* This module owns the registry bookkeeping. The eviction that fuses with a
|
|
12
|
+
* shrink (E1–E4) lives on the client, which holds the DB transaction and the
|
|
13
|
+
* invalidation choke point.
|
|
16
14
|
*/
|
|
17
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
canonicalUnitJson,
|
|
17
|
+
type ScopeMap,
|
|
18
|
+
type UnitScopes,
|
|
19
|
+
} from '@syncular/core';
|
|
18
20
|
import type { ClientDatabase } from './database';
|
|
19
21
|
import { invalidRequest } from './errors';
|
|
20
22
|
|
|
@@ -80,173 +82,92 @@ export function last(
|
|
|
80
82
|
}
|
|
81
83
|
|
|
82
84
|
/**
|
|
83
|
-
* A window base:
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
* subscription verbatim.
|
|
85
|
+
* A window base (§4.8): the selected scope variable plus the fixed scope
|
|
86
|
+
* values every unit of its family shares. A base names no table: each unit
|
|
87
|
+
* covers every table declaring its variables (§4.1).
|
|
87
88
|
*/
|
|
88
89
|
export interface WindowBase {
|
|
89
|
-
readonly table: string;
|
|
90
90
|
/** The scope variable whose values are the window units. */
|
|
91
91
|
readonly variable: string;
|
|
92
|
-
/**
|
|
93
|
-
readonly fixedScopes?:
|
|
94
|
-
readonly params?: string;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/** A live unit in the registry: its value and the subscription it drives. */
|
|
98
|
-
export interface WindowUnit {
|
|
99
|
-
readonly unit: string;
|
|
100
|
-
readonly subId: string;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export interface RegisteredWindowUnit extends WindowUnit {
|
|
104
|
-
readonly baseKey: string;
|
|
92
|
+
/** One value per other variable, shared by every unit. */
|
|
93
|
+
readonly fixedScopes?: UnitScopes;
|
|
105
94
|
}
|
|
106
95
|
|
|
107
|
-
/**
|
|
108
|
-
* A stable, server-opaque key for a window base — table + variable +
|
|
109
|
-
* canonical fixed scopes. Two `setWindow` calls with the same base
|
|
110
|
-
* address the same registry rows.
|
|
111
|
-
*/
|
|
96
|
+
/** A stable key for a window base: variable + canonical fixed scopes. */
|
|
112
97
|
export function windowBaseKey(base: WindowBase): string {
|
|
113
|
-
|
|
114
|
-
return `${base.table}\0${base.variable}\0${fixed}`;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/** The full requested scope map for one unit (fixed scopes + the unit). */
|
|
118
|
-
export function unitScopes(base: WindowBase, unit: string): ScopeMap {
|
|
119
|
-
const scopes: ScopeMap = {};
|
|
120
|
-
for (const [variable, values] of Object.entries(base.fixedScopes ?? {})) {
|
|
121
|
-
scopes[variable] = [...values];
|
|
122
|
-
}
|
|
123
|
-
scopes[base.variable] = [unit];
|
|
124
|
-
return scopes;
|
|
98
|
+
return `${base.variable}\0${canonicalUnitJson(base.fixedScopes ?? {})}`;
|
|
125
99
|
}
|
|
126
100
|
|
|
127
|
-
/**
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
* not interpreted by the server (§4.1), so the exact hash is pure client
|
|
131
|
-
* convention; SHA-256 matches the SPEC's worked example.
|
|
132
|
-
*/
|
|
133
|
-
export async function deriveSubId(
|
|
134
|
-
base: WindowBase,
|
|
135
|
-
unit: string,
|
|
136
|
-
): Promise<string> {
|
|
137
|
-
const canonical = canonicalScopeJson(unitScopes(base, unit));
|
|
138
|
-
const digest = await crypto.subtle.digest(
|
|
139
|
-
'SHA-256',
|
|
140
|
-
new TextEncoder().encode(canonical),
|
|
141
|
-
);
|
|
142
|
-
let hex = '';
|
|
143
|
-
for (const byte of new Uint8Array(digest)) {
|
|
144
|
-
hex += byte.toString(16).padStart(2, '0');
|
|
145
|
-
}
|
|
146
|
-
return `w:${base.table}:${hex.slice(0, 16)}`;
|
|
101
|
+
/** The unit of one window value: the fixed scopes plus the value. */
|
|
102
|
+
export function windowUnitScopes(base: WindowBase, value: string): UnitScopes {
|
|
103
|
+
return { ...base.fixedScopes, [base.variable]: value };
|
|
147
104
|
}
|
|
148
105
|
|
|
149
|
-
/**
|
|
106
|
+
/** Registry rows for a base, ordered by value: value → unit id. */
|
|
150
107
|
export function loadWindowUnits(
|
|
151
108
|
db: ClientDatabase,
|
|
152
109
|
baseKey: string,
|
|
153
|
-
):
|
|
110
|
+
): { readonly value: string; readonly unitId: string }[] {
|
|
154
111
|
return db
|
|
155
112
|
.query(
|
|
156
113
|
`SELECT unit,sub_id FROM ${WINDOWS_TABLE} WHERE base=? ORDER BY unit`,
|
|
157
114
|
[baseKey],
|
|
158
115
|
)
|
|
159
|
-
.map((row) => ({
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
export function getWindowUnitBySubId(
|
|
164
|
-
db: ClientDatabase,
|
|
165
|
-
subId: string,
|
|
166
|
-
): RegisteredWindowUnit | undefined {
|
|
167
|
-
const row = db.query(
|
|
168
|
-
`SELECT base, unit, sub_id FROM ${WINDOWS_TABLE}
|
|
169
|
-
WHERE sub_id = ? LIMIT 1`,
|
|
170
|
-
[subId],
|
|
171
|
-
)[0];
|
|
172
|
-
return row === undefined
|
|
173
|
-
? undefined
|
|
174
|
-
: {
|
|
175
|
-
baseKey: row.base as string,
|
|
176
|
-
unit: row.unit as string,
|
|
177
|
-
subId: row.sub_id as string,
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
export function insertWindowUnit(
|
|
182
|
-
db: ClientDatabase,
|
|
183
|
-
baseKey: string,
|
|
184
|
-
unit: string,
|
|
185
|
-
subId: string,
|
|
186
|
-
): void {
|
|
187
|
-
db.exec(
|
|
188
|
-
`INSERT OR REPLACE INTO ${WINDOWS_TABLE}(base,unit,sub_id)VALUES(?,?,?)`,
|
|
189
|
-
[baseKey, unit, subId],
|
|
190
|
-
);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
export function deleteWindowUnit(
|
|
194
|
-
db: ClientDatabase,
|
|
195
|
-
baseKey: string,
|
|
196
|
-
unit: string,
|
|
197
|
-
): void {
|
|
198
|
-
db.exec(`DELETE FROM ${WINDOWS_TABLE} WHERE base=? AND unit=?`, [
|
|
199
|
-
baseKey,
|
|
200
|
-
unit,
|
|
201
|
-
]);
|
|
116
|
+
.map((row) => ({
|
|
117
|
+
value: row.unit as string,
|
|
118
|
+
unitId: row.sub_id as string,
|
|
119
|
+
}));
|
|
202
120
|
}
|
|
203
121
|
|
|
204
|
-
/**
|
|
205
|
-
export function
|
|
122
|
+
/** Every window registry row that references a unit (§4.1 references). */
|
|
123
|
+
export function windowRefs(
|
|
206
124
|
db: ClientDatabase,
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
baseKey,
|
|
213
|
-
unit,
|
|
214
|
-
|
|
215
|
-
);
|
|
125
|
+
unitId: string,
|
|
126
|
+
): { readonly baseKey: string; readonly value: string }[] {
|
|
127
|
+
return db
|
|
128
|
+
.query(`SELECT base,unit FROM ${WINDOWS_TABLE} WHERE sub_id=?`, [unitId])
|
|
129
|
+
.map((row) => ({
|
|
130
|
+
baseKey: row.base as string,
|
|
131
|
+
value: row.unit as string,
|
|
132
|
+
}));
|
|
216
133
|
}
|
|
217
134
|
|
|
218
135
|
// ---------------------------------------------------------------------------
|
|
219
|
-
// Deferred eviction (E1)
|
|
136
|
+
// Deferred eviction (E1): per-table scopes of units that left with rows left
|
|
220
137
|
// ---------------------------------------------------------------------------
|
|
221
138
|
|
|
222
139
|
export interface PendingEviction {
|
|
223
|
-
readonly
|
|
140
|
+
readonly unitId: string;
|
|
224
141
|
readonly table: string;
|
|
225
142
|
readonly effective: ScopeMap;
|
|
226
143
|
}
|
|
227
144
|
|
|
228
145
|
export function savePendingEviction(
|
|
229
146
|
db: ClientDatabase,
|
|
230
|
-
|
|
231
|
-
table: string,
|
|
232
|
-
effective: ScopeMap,
|
|
147
|
+
entry: PendingEviction,
|
|
233
148
|
): void {
|
|
234
149
|
db.exec(
|
|
235
|
-
`INSERT OR REPLACE INTO ${PENDING_EVICTIONS}(
|
|
236
|
-
|
|
237
|
-
[subId, table, JSON.stringify(effective)],
|
|
150
|
+
`INSERT OR REPLACE INTO ${PENDING_EVICTIONS}(unit_id,tbl,effective_scopes)VALUES(?,?,?)`,
|
|
151
|
+
[entry.unitId, entry.table, JSON.stringify(entry.effective)],
|
|
238
152
|
);
|
|
239
153
|
}
|
|
240
154
|
|
|
241
|
-
export function deletePendingEviction(
|
|
242
|
-
db
|
|
155
|
+
export function deletePendingEviction(
|
|
156
|
+
db: ClientDatabase,
|
|
157
|
+
unitId: string,
|
|
158
|
+
table?: string,
|
|
159
|
+
): void {
|
|
160
|
+
db.exec(
|
|
161
|
+
`DELETE FROM ${PENDING_EVICTIONS} WHERE unit_id=?${table === undefined ? '' : ' AND tbl=?'}`,
|
|
162
|
+
table === undefined ? [unitId] : [unitId, table],
|
|
163
|
+
);
|
|
243
164
|
}
|
|
244
165
|
|
|
245
166
|
export function loadPendingEvictions(db: ClientDatabase): PendingEviction[] {
|
|
246
167
|
return db
|
|
247
|
-
.query(`SELECT
|
|
168
|
+
.query(`SELECT unit_id,tbl,effective_scopes FROM ${PENDING_EVICTIONS}`)
|
|
248
169
|
.map((row) => ({
|
|
249
|
-
|
|
170
|
+
unitId: row.unit_id as string,
|
|
250
171
|
table: row.tbl as string,
|
|
251
172
|
effective: JSON.parse(row.effective_scopes as string) as ScopeMap,
|
|
252
173
|
}));
|
package/src/worker-core.ts
CHANGED
|
@@ -228,7 +228,7 @@ export function startSyncWorkerCore(
|
|
|
228
228
|
let autoSyncScheduled = false;
|
|
229
229
|
let cancelBackground: (() => void) | undefined;
|
|
230
230
|
let backgroundDue = Number.POSITIVE_INFINITY;
|
|
231
|
-
// §7.
|
|
231
|
+
// §7.7 backoff for drives that end without a client retry intent.
|
|
232
232
|
let retryDelayMs = 250;
|
|
233
233
|
const scheduleBackground =
|
|
234
234
|
overrides.scheduleBackground ??
|
|
@@ -282,7 +282,7 @@ export function startSyncWorkerCore(
|
|
|
282
282
|
t: 'event',
|
|
283
283
|
event: { kind: 'synced', error: toErrorShape(error) },
|
|
284
284
|
});
|
|
285
|
-
// §7.
|
|
285
|
+
// §7.8: a retryable drive rejection owes another drive. A retryable
|
|
286
286
|
// round failure already handed this loop its background intent; the
|
|
287
287
|
// drive deadline did not. An unreachable endpoint waits for the
|
|
288
288
|
// host's connectivity resume (§1.8).
|
|
@@ -545,8 +545,8 @@ export function startSyncWorkerCore(
|
|
|
545
545
|
'commitOutcomes',
|
|
546
546
|
'resolveCommitOutcome',
|
|
547
547
|
'pendingCommits',
|
|
548
|
-
'
|
|
549
|
-
'
|
|
548
|
+
'units',
|
|
549
|
+
'unit',
|
|
550
550
|
'connectRealtime',
|
|
551
551
|
'disconnectRealtime',
|
|
552
552
|
'setPresence',
|
|
@@ -607,7 +607,7 @@ export function startSyncWorkerCore(
|
|
|
607
607
|
},
|
|
608
608
|
resetClientId: () => requireClient().resetClientId(),
|
|
609
609
|
localRevision: () => requireClient().localRevision,
|
|
610
|
-
diagnosticsSnapshot: (
|
|
610
|
+
diagnosticsSnapshot: () => {
|
|
611
611
|
const running = requireClient();
|
|
612
612
|
// The first pull makes the worker a push source: no tab has asked for
|
|
613
613
|
// diagnostics before it, so no snapshot is built per revision until then.
|
|
@@ -615,7 +615,7 @@ export function startSyncWorkerCore(
|
|
|
615
615
|
pushingDiagnostics = true;
|
|
616
616
|
running.onDiagnostics(postDiagnostics);
|
|
617
617
|
}
|
|
618
|
-
return workerDiagnostics(running.diagnosticsSnapshot(
|
|
618
|
+
return workerDiagnostics(running.diagnosticsSnapshot());
|
|
619
619
|
},
|
|
620
620
|
setHeaders: (next) => {
|
|
621
621
|
headers = next;
|
package/src/worker-host.ts
CHANGED
|
@@ -44,7 +44,6 @@ import type {
|
|
|
44
44
|
SecurityLifecycle,
|
|
45
45
|
SnapshotRead,
|
|
46
46
|
SnapshotReadRequest,
|
|
47
|
-
SubscribeInput,
|
|
48
47
|
SyncClientConfig,
|
|
49
48
|
SyncClientLimits,
|
|
50
49
|
SyncSummary,
|
|
@@ -57,7 +56,6 @@ import type { DevtoolsRegistrar } from './devtools';
|
|
|
57
56
|
import {
|
|
58
57
|
ClientDiagnosticsEmitter,
|
|
59
58
|
type ClientDiagnosticsListener,
|
|
60
|
-
type ClientDiagnosticsRequest,
|
|
61
59
|
type ClientDiagnosticsSnapshot,
|
|
62
60
|
type RealtimePolicy,
|
|
63
61
|
withClientDiagnosticsHost,
|
|
@@ -110,7 +108,8 @@ import {
|
|
|
110
108
|
type PreviousVersionSnapshot,
|
|
111
109
|
} from './previous-version';
|
|
112
110
|
import type { ClientSchema } from './schema';
|
|
113
|
-
import type {
|
|
111
|
+
import type { UnitScopes } from '@syncular/core';
|
|
112
|
+
import type { UnitRecord } from './state';
|
|
114
113
|
import type { WindowBase } from './window';
|
|
115
114
|
import {
|
|
116
115
|
type LocalAuthorityState,
|
|
@@ -398,7 +397,7 @@ export class SyncClientHandle implements PromiseMethods<WorkerApi> {
|
|
|
398
397
|
clientId: () => this.#clientId,
|
|
399
398
|
role: () => this.#role,
|
|
400
399
|
outbox: async () => (await this.statusSnapshot()).outbox,
|
|
401
|
-
|
|
400
|
+
units: () => this.units(),
|
|
402
401
|
conflicts: async () => (await this.conflicts()).length,
|
|
403
402
|
rejections: async () => (await this.rejections()).length,
|
|
404
403
|
syncNeeded: async () => (await this.statusSnapshot()).syncNeeded,
|
|
@@ -599,12 +598,12 @@ export class SyncClientHandle implements PromiseMethods<WorkerApi> {
|
|
|
599
598
|
>;
|
|
600
599
|
}
|
|
601
600
|
|
|
602
|
-
subscribe(
|
|
603
|
-
return this.#call('subscribe', [
|
|
601
|
+
subscribe(scopes: UnitScopes): Promise<string> {
|
|
602
|
+
return this.#call('subscribe', [scopes]);
|
|
604
603
|
}
|
|
605
604
|
|
|
606
|
-
subscribeMany(
|
|
607
|
-
return this.#call('subscribeMany', [
|
|
605
|
+
subscribeMany(units: readonly UnitScopes[]): Promise<string[]> {
|
|
606
|
+
return this.#call('subscribeMany', [units]);
|
|
608
607
|
}
|
|
609
608
|
|
|
610
609
|
securityLifecycle(): Promise<SecurityLifecycle> {
|
|
@@ -742,10 +741,8 @@ export class SyncClientHandle implements PromiseMethods<WorkerApi> {
|
|
|
742
741
|
return this.#call('statusSnapshot', []);
|
|
743
742
|
}
|
|
744
743
|
|
|
745
|
-
async diagnosticsSnapshot(
|
|
746
|
-
|
|
747
|
-
): Promise<ClientDiagnosticsSnapshot> {
|
|
748
|
-
const snapshot = await this.#call('diagnosticsSnapshot', [request]);
|
|
744
|
+
async diagnosticsSnapshot(): Promise<ClientDiagnosticsSnapshot> {
|
|
745
|
+
const snapshot = await this.#call('diagnosticsSnapshot', []);
|
|
749
746
|
return withClientDiagnosticsHost(snapshot, {
|
|
750
747
|
...snapshot.host,
|
|
751
748
|
kind: 'worker',
|
|
@@ -782,12 +779,12 @@ export class SyncClientHandle implements PromiseMethods<WorkerApi> {
|
|
|
782
779
|
return this.#call('pendingCommits', []);
|
|
783
780
|
}
|
|
784
781
|
|
|
785
|
-
|
|
786
|
-
return this.#call('
|
|
782
|
+
units(): Promise<UnitRecord[]> {
|
|
783
|
+
return this.#call('units', []);
|
|
787
784
|
}
|
|
788
785
|
|
|
789
|
-
|
|
790
|
-
return this.#call('
|
|
786
|
+
unit(id: string): Promise<UnitRecord | undefined> {
|
|
787
|
+
return this.#call('unit', [id]);
|
|
791
788
|
}
|
|
792
789
|
|
|
793
790
|
connectRealtime(): Promise<void> {
|
package/src/worker-protocol.ts
CHANGED
|
@@ -28,7 +28,6 @@ import type {
|
|
|
28
28
|
QueryReadSpec,
|
|
29
29
|
QuerySnapshot,
|
|
30
30
|
SecurityLifecycle,
|
|
31
|
-
SubscribeInput,
|
|
32
31
|
SyncClientConfig,
|
|
33
32
|
SyncClientLimits,
|
|
34
33
|
SyncSummary,
|
|
@@ -53,7 +52,8 @@ import type {
|
|
|
53
52
|
PreviousVersionSnapshot,
|
|
54
53
|
} from './previous-version';
|
|
55
54
|
import type { ClientSchema } from './schema';
|
|
56
|
-
import type {
|
|
55
|
+
import type { UnitScopes } from '@syncular/core';
|
|
56
|
+
import type { UnitRecord } from './state';
|
|
57
57
|
import type { WindowBase } from './window';
|
|
58
58
|
|
|
59
59
|
// ---------------------------------------------------------------------------
|
|
@@ -183,12 +183,12 @@ export interface WorkerApi extends Omit<
|
|
|
183
183
|
securityLifecycle(): SecurityLifecycle;
|
|
184
184
|
beginSecurityPreflight(): Promise<void>;
|
|
185
185
|
activateSecurity(options?: WorkerSecurityActivation): Promise<void>;
|
|
186
|
-
subscribe(
|
|
187
|
-
subscribeMany(
|
|
186
|
+
subscribe(scopes: UnitScopes): string;
|
|
187
|
+
subscribeMany(units: readonly UnitScopes[]): string[];
|
|
188
188
|
unsubscribe(id: string): void;
|
|
189
|
-
/** §4.8
|
|
189
|
+
/** §4.8 windows: set the windowed-in values of a base. */
|
|
190
190
|
setWindow(base: WindowBase, units: readonly string[]): Promise<void>;
|
|
191
|
-
/** §4.8 completeness oracle
|
|
191
|
+
/** §4.8 completeness oracle: the windowed-in values of a base. */
|
|
192
192
|
windowState(base: WindowBase): WindowState;
|
|
193
193
|
mutate(mutations: readonly MutationInput[]): string;
|
|
194
194
|
/** Partial-update convenience: read-merge-write one full-row upsert. */
|
|
@@ -224,8 +224,8 @@ export interface WorkerApi extends Omit<
|
|
|
224
224
|
querySnapshot(spec: QueryReadSpec): QuerySnapshot;
|
|
225
225
|
localRevision(): LocalRevision;
|
|
226
226
|
pendingCommits(): OutboxCommit[];
|
|
227
|
-
|
|
228
|
-
|
|
227
|
+
units(): UnitRecord[];
|
|
228
|
+
unit(id: string): UnitRecord | undefined;
|
|
229
229
|
connectRealtime(): Promise<void>;
|
|
230
230
|
disconnectRealtime(): void;
|
|
231
231
|
/** §8.6 presence: publish/clear a scope-keyed presence document. */
|