@syncular/client 0.60.1 → 0.62.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/index.d.ts CHANGED
@@ -42,4 +42,5 @@ export * from './transport.js';
42
42
  export * from './window.js';
43
43
  export * from './worker-host.js';
44
44
  export * from './worker-protocol.js';
45
+ export { unitId, type UnitScopes } from '@syncular/core';
45
46
  export { ProgressEmitter, type SyncProgress, type SyncProgressListener, } from './progress.js';
package/dist/index.js CHANGED
@@ -35,4 +35,7 @@ export * from './transport.js';
35
35
  export * from './window.js';
36
36
  export * from './worker-host.js';
37
37
  export * from './worker-protocol.js';
38
+ // §4.1: the unit id of a scope map, for `unit(id)` and `unsubscribe(id)`
39
+ // before (or without) a `subscribe`.
40
+ export { unitId } from '@syncular/core';
38
41
  export { ProgressEmitter, } from './progress.js';
@@ -11,9 +11,10 @@
11
11
  * `{$bigint: decimal}`, the convention of the Rust command router. The browser
12
12
  * client and worker entries never import this module.
13
13
  */
14
- import { type ClientSnapshotMethods, type CurrentBaseProof, type MutationInput, type PresencePeer, type PromiseMethods, type QueryReadSpec, type QuerySnapshot, type SecurityLifecycle, type SnapshotRead, type SnapshotReadRequest, type SyncClientConfig, type WindowState } from './client.js';
14
+ import { type ClientSnapshotMethods, type CurrentBaseProof, type MutationInput, type PresencePeer, type PromiseMethods, type QueryReadSpec, type QuerySnapshot, type SecurityLifecycle, type SnapshotRead, type SnapshotReadRequest, type SyncClient, type SyncClientConfig, type UnitCatchup, type WindowState } from './client.js';
15
15
  import type { SqlRow, SqlValue } from './database.js';
16
16
  import type { PresenceErrorCode, UnitScopes } from '@syncular/core';
17
+ export { unitId, type UnitScopes } from '@syncular/core';
17
18
  import { type ClientDiagnosticsListener, type ClientDiagnosticsSnapshot } from './diagnostics.js';
18
19
  import type { EncryptionKeyringConfig } from './encryption.js';
19
20
  import type { ClientChangeListener, InvalidationListener, SyncStatusSnapshot } from './invalidation.js';
@@ -22,6 +23,7 @@ import { type LocalDataRebootstrapInput, type LocalDataRebootstrapResult } from
22
23
  import type { CommitOutcome, CommitOutcomeQuery, ConflictRecord, RejectionRecord, ResolveCommitOutcomeInput } from './outcomes.js';
23
24
  import { type PreviousVersionAudit, type PreviousVersionReadSpec, type PreviousVersionSnapshot } from './previous-version.js';
24
25
  import { type SyncProgress, type SyncProgressListener } from './progress.js';
26
+ import type { UnitRecord } from './state.js';
25
27
  import type { WindowBase } from './window.js';
26
28
  /** A driver-protocol reply: `{result}` on success or `{error}` on failure. */
27
29
  export interface NativeReply {
@@ -87,7 +89,7 @@ export declare function nativeCreateParams(config: NativeCreateConfig, ErrorType
87
89
  * returns a promise from one host round trip; React hooks accept the
88
90
  * canonical snapshot interface directly.
89
91
  */
90
- export declare abstract class NativeBridgeClient implements PromiseMethods<ClientSnapshotMethods> {
92
+ export declare abstract class NativeBridgeClient implements PromiseMethods<ClientSnapshotMethods & Pick<SyncClient, 'unit' | 'units' | 'unitCatchup'>> {
91
93
  #private;
92
94
  /**
93
95
  * `release` detaches the host event listener; the bridge calls it once,
@@ -202,6 +204,11 @@ export declare abstract class NativeBridgeClient implements PromiseMethods<Clien
202
204
  /** Register several units in one local transaction; returns their ids. */
203
205
  subscribeMany(units: readonly UnitScopes[]): Promise<string[]>;
204
206
  unsubscribe(id: string): Promise<void>;
207
+ /** Every unit in registration order (§4.1), including revoked and failed. */
208
+ units(): Promise<UnitRecord[]>;
209
+ unit(id: string): Promise<UnitRecord | undefined>;
210
+ /** §7.5: one unit's persisted catch-up state (never the owner cache). */
211
+ unitCatchup(id: string): Promise<UnitCatchup>;
205
212
  setWindow(base: WindowBase, units: readonly string[]): Promise<void>;
206
213
  windowState(base: WindowBase): Promise<WindowState>;
207
214
  sync(): Promise<unknown>;
@@ -12,6 +12,7 @@
12
12
  * client and worker entries never import this module.
13
13
  */
14
14
  import { SECURITY_PREFLIGHT_REQUIRED_CODE, } from './client.js';
15
+ export { unitId } from '@syncular/core';
15
16
  import { CLIENT_DIAGNOSTICS_VERSION, withClientDiagnosticsHost, } from './diagnostics.js';
16
17
  import { decodeLocalDataRebootstrapResult, } from './local-rebootstrap.js';
17
18
  import { decodePreviousVersionAuditResult, decodePreviousVersionDiscardResult, decodePreviousVersionSnapshot, } from './previous-version.js';
@@ -667,6 +668,18 @@ export class NativeBridgeClient {
667
668
  async unsubscribe(id) {
668
669
  await this.command('unsubscribe', { id });
669
670
  }
671
+ /** Every unit in registration order (§4.1), including revoked and failed. */
672
+ async units() {
673
+ return (await this.command('units', {})).units;
674
+ }
675
+ async unit(id) {
676
+ return ((await this.command('unit', { id }))
677
+ .unit ?? undefined);
678
+ }
679
+ /** §7.5: one unit's persisted catch-up state (never the owner cache). */
680
+ async unitCatchup(id) {
681
+ return (await this.snapshotRead({ statements: [], units: [id] })).units[0];
682
+ }
670
683
  async setWindow(base, units) {
671
684
  await this.command('setWindow', { base, units });
672
685
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syncular/client",
3
- "version": "0.60.1",
3
+ "version": "0.62.0",
4
4
  "description": "Syncular TypeScript client core — offline-first sync over SQLite (WASM/OPFS, Bun, Node)",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Benjamin Kniffler",
@@ -113,11 +113,11 @@
113
113
  },
114
114
  "dependencies": {
115
115
  "@sqlite.org/sqlite-wasm": "^3.53.0-build1",
116
- "@syncular/core": "0.60.1"
116
+ "@syncular/core": "0.62.0"
117
117
  },
118
118
  "devDependencies": {
119
119
  "@electric-sql/pglite": "^0.5.4",
120
- "@syncular/server": "0.60.1",
120
+ "@syncular/server": "0.62.0",
121
121
  "playwright": "1.63.0",
122
122
  "vite": "8.3.4"
123
123
  }
package/src/index.ts CHANGED
@@ -59,6 +59,10 @@ export * from './window';
59
59
  export * from './worker-host';
60
60
  export * from './worker-protocol';
61
61
 
62
+ // §4.1: the unit id of a scope map, for `unit(id)` and `unsubscribe(id)`
63
+ // before (or without) a `subscribe`.
64
+ export { unitId, type UnitScopes } from '@syncular/core';
65
+
62
66
  export {
63
67
  ProgressEmitter,
64
68
  type SyncProgress,
@@ -23,11 +23,14 @@ import {
23
23
  type SecurityLifecycle,
24
24
  type SnapshotRead,
25
25
  type SnapshotReadRequest,
26
+ type SyncClient,
26
27
  type SyncClientConfig,
28
+ type UnitCatchup,
27
29
  type WindowState,
28
30
  } from './client';
29
31
  import type { SqlRow, SqlValue } from './database';
30
32
  import type { PresenceErrorCode, UnitScopes } from '@syncular/core';
33
+ export { unitId, type UnitScopes } from '@syncular/core';
31
34
  import {
32
35
  CLIENT_DIAGNOSTICS_VERSION,
33
36
  type ClientDiagnosticsListener,
@@ -68,6 +71,7 @@ import {
68
71
  type SyncProgress,
69
72
  type SyncProgressListener,
70
73
  } from './progress';
74
+ import type { UnitRecord } from './state';
71
75
  import type { WindowBase } from './window';
72
76
 
73
77
  /** A driver-protocol reply: `{result}` on success or `{error}` on failure. */
@@ -289,7 +293,9 @@ type OutcomeRowValue = ConflictRecord['serverRow'][string];
289
293
  * returns a promise from one host round trip; React hooks accept the
290
294
  * canonical snapshot interface directly.
291
295
  */
292
- export abstract class NativeBridgeClient implements PromiseMethods<ClientSnapshotMethods> {
296
+ export abstract class NativeBridgeClient implements PromiseMethods<
297
+ ClientSnapshotMethods & Pick<SyncClient, 'unit' | 'units' | 'unitCatchup'>
298
+ > {
293
299
  readonly #kind: 'tauri' | 'react-native';
294
300
  readonly #Error: typeof NativeSyncError;
295
301
  readonly #release: () => void;
@@ -1008,6 +1014,23 @@ export abstract class NativeBridgeClient implements PromiseMethods<ClientSnapsho
1008
1014
  await this.command('unsubscribe', { id });
1009
1015
  }
1010
1016
 
1017
+ /** Every unit in registration order (§4.1), including revoked and failed. */
1018
+ async units(): Promise<UnitRecord[]> {
1019
+ return ((await this.command('units', {})) as { units: UnitRecord[] }).units;
1020
+ }
1021
+
1022
+ async unit(id: string): Promise<UnitRecord | undefined> {
1023
+ return (
1024
+ ((await this.command('unit', { id })) as { unit: UnitRecord | null })
1025
+ .unit ?? undefined
1026
+ );
1027
+ }
1028
+
1029
+ /** §7.5: one unit's persisted catch-up state (never the owner cache). */
1030
+ async unitCatchup(id: string): Promise<UnitCatchup> {
1031
+ return (await this.snapshotRead({ statements: [], units: [id] })).units[0]!;
1032
+ }
1033
+
1011
1034
  async setWindow(base: WindowBase, units: readonly string[]): Promise<void> {
1012
1035
  await this.command('setWindow', { base, units });
1013
1036
  }