@syncular/tauri 0.47.0 → 0.49.1

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
@@ -51,6 +51,8 @@ export interface TauriApi {
51
51
  }
52
52
  /** The plugin's Tauri event name — mirror of `tauri-plugin-syncular`. */
53
53
  export declare const SYNCULAR_EVENT = "syncular://event";
54
+ /** SPEC §12 local authority lifecycle state. */
55
+ export type LocalAuthorityState = 'local' | 'attaching' | 'attached';
54
56
  /** Config for {@link createTauriSyncClient}. */
55
57
  export interface TauriSyncClientConfig {
56
58
  /** The generated schema JSON (the app passes `schema` from typegen). */
@@ -229,6 +231,21 @@ export declare class TauriSyncClient implements PromiseMethods<ClientSnapshotMet
229
231
  * the replica and outbox stay in place.
230
232
  */
231
233
  resetClientId(): Promise<string>;
234
+ /**
235
+ * SPEC §12 local authority state: `local` while rounds run against the
236
+ * in-process authority, `attaching` during an attach, `attached` once rounds
237
+ * run against `base_url`, and `null` when the plugin configured no
238
+ * `local_authority_path`.
239
+ */
240
+ localAuthorityState(): Promise<LocalAuthorityState | null>;
241
+ /**
242
+ * Upload the local authority's live rows to the `base_url` server (§12.3).
243
+ * Rejects with `sync.attach_rejected` (`details.reason`) when the server
244
+ * refuses; call {@link abandonLocalAuthorityAttach} to roll back.
245
+ */
246
+ attachLocalAuthority(): Promise<void>;
247
+ /** Roll back an attach that did not complete and return to `local`. */
248
+ abandonLocalAuthorityAttach(): Promise<void>;
232
249
  syncUntilIdle(maxRounds?: number): Promise<unknown>;
233
250
  conflicts(): Promise<readonly ConflictRecord[]>;
234
251
  rejections(): Promise<readonly RejectionRecord[]>;
package/dist/index.js CHANGED
@@ -246,6 +246,7 @@ export class TauriSyncClient {
246
246
  'previousVersionDiscard',
247
247
  'localRevision',
248
248
  'statusSnapshot',
249
+ 'localAuthorityState',
249
250
  'shutdown',
250
251
  ].includes(method)) {
251
252
  this.#throwSecurityPreflight();
@@ -696,6 +697,28 @@ export class TauriSyncClient {
696
697
  const result = (await this.#command('resetClientId', {}));
697
698
  return result.clientId;
698
699
  }
700
+ /**
701
+ * SPEC §12 local authority state: `local` while rounds run against the
702
+ * in-process authority, `attaching` during an attach, `attached` once rounds
703
+ * run against `base_url`, and `null` when the plugin configured no
704
+ * `local_authority_path`.
705
+ */
706
+ async localAuthorityState() {
707
+ const result = (await this.#command('localAuthorityState', {}));
708
+ return result.state;
709
+ }
710
+ /**
711
+ * Upload the local authority's live rows to the `base_url` server (§12.3).
712
+ * Rejects with `sync.attach_rejected` (`details.reason`) when the server
713
+ * refuses; call {@link abandonLocalAuthorityAttach} to roll back.
714
+ */
715
+ async attachLocalAuthority() {
716
+ await this.#command('attachLocalAuthority', {});
717
+ }
718
+ /** Roll back an attach that did not complete and return to `local`. */
719
+ async abandonLocalAuthorityAttach() {
720
+ await this.#command('abandonLocalAuthorityAttach', {});
721
+ }
699
722
  async syncUntilIdle(maxRounds) {
700
723
  return this.#command('syncUntilIdle', {
701
724
  ...(maxRounds !== undefined ? { maxRounds } : {}),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syncular/tauri",
3
- "version": "0.47.0",
3
+ "version": "0.49.1",
4
4
  "description": "Tauri integration for the Syncular client",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Benjamin Kniffler",
@@ -56,13 +56,13 @@
56
56
  "test": "bun test"
57
57
  },
58
58
  "dependencies": {
59
- "@syncular/client": "0.47.0"
59
+ "@syncular/client": "0.49.1"
60
60
  },
61
61
  "peerDependencies": {
62
62
  "@tauri-apps/api": ">=2.0.0"
63
63
  },
64
64
  "devDependencies": {
65
- "@syncular/react": "0.47.0",
66
- "@syncular/server": "0.47.0"
65
+ "@syncular/react": "0.49.1",
66
+ "@syncular/server": "0.49.1"
67
67
  }
68
68
  }
package/src/index.ts CHANGED
@@ -124,6 +124,9 @@ export const SYNCULAR_EVENT = 'syncular://event';
124
124
 
125
125
  const PLUGIN = 'plugin:syncular|';
126
126
 
127
+ /** SPEC §12 local authority lifecycle state. */
128
+ export type LocalAuthorityState = 'local' | 'attaching' | 'attached';
129
+
127
130
  /** Config for {@link createTauriSyncClient}. */
128
131
  export interface TauriSyncClientConfig {
129
132
  /** The generated schema JSON (the app passes `schema` from typegen). */
@@ -464,6 +467,7 @@ export class TauriSyncClient implements PromiseMethods<ClientSnapshotMethods> {
464
467
  'previousVersionDiscard',
465
468
  'localRevision',
466
469
  'statusSnapshot',
470
+ 'localAuthorityState',
467
471
  'shutdown',
468
472
  ].includes(method)
469
473
  ) {
@@ -1113,6 +1117,33 @@ export class TauriSyncClient implements PromiseMethods<ClientSnapshotMethods> {
1113
1117
  return result.clientId;
1114
1118
  }
1115
1119
 
1120
+ /**
1121
+ * SPEC §12 local authority state: `local` while rounds run against the
1122
+ * in-process authority, `attaching` during an attach, `attached` once rounds
1123
+ * run against `base_url`, and `null` when the plugin configured no
1124
+ * `local_authority_path`.
1125
+ */
1126
+ async localAuthorityState(): Promise<LocalAuthorityState | null> {
1127
+ const result = (await this.#command('localAuthorityState', {})) as {
1128
+ state: LocalAuthorityState | null;
1129
+ };
1130
+ return result.state;
1131
+ }
1132
+
1133
+ /**
1134
+ * Upload the local authority's live rows to the `base_url` server (§12.3).
1135
+ * Rejects with `sync.attach_rejected` (`details.reason`) when the server
1136
+ * refuses; call {@link abandonLocalAuthorityAttach} to roll back.
1137
+ */
1138
+ async attachLocalAuthority(): Promise<void> {
1139
+ await this.#command('attachLocalAuthority', {});
1140
+ }
1141
+
1142
+ /** Roll back an attach that did not complete and return to `local`. */
1143
+ async abandonLocalAuthorityAttach(): Promise<void> {
1144
+ await this.#command('abandonLocalAuthorityAttach', {});
1145
+ }
1146
+
1116
1147
  async syncUntilIdle(maxRounds?: number): Promise<unknown> {
1117
1148
  return this.#command('syncUntilIdle', {
1118
1149
  ...(maxRounds !== undefined ? { maxRounds } : {}),