@gonvex/expo-sqlite 0.5.1 → 0.5.2-staging.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
@@ -19,6 +19,7 @@ export declare class ExpoSQLiteLocalReplicaStorage implements LocalReplicaStorag
19
19
  private migrateSchema;
20
20
  load(scope?: ReplicaScope): Promise<ReplicaSnapshot | undefined>;
21
21
  applyTransaction(transaction: ReplicaTransaction, _snapshot: ReplicaSnapshot, scope?: ReplicaScope): Promise<void>;
22
+ advanceWatermark(windows: readonly ReplicaWindow[], cursor: ReplicaSnapshot["cursor"], scope?: ReplicaScope): Promise<void>;
22
23
  replaceSnapshot(snapshot: ReplicaSnapshot, scope?: ReplicaScope): Promise<void>;
23
24
  replaceWindow(window: ReplicaWindow, snapshot: ReplicaSnapshot, scope?: ReplicaScope): Promise<void>;
24
25
  applyWindowDelta(window: ReplicaWindow, _delta: {
package/dist/index.js CHANGED
@@ -118,6 +118,21 @@ export class ExpoSQLiteLocalReplicaStorage {
118
118
  ON CONFLICT(scope, key) DO UPDATE SET value = excluded.value`, scope, JSON.stringify(transaction.cursor));
119
119
  });
120
120
  }
121
+ async advanceWatermark(windows, cursor, scope = defaultReplicaScope) {
122
+ await this.initialize();
123
+ // Watermarks carry no row changes. Keep this transaction metadata-only so
124
+ // advancing many retained windows does not rewrite the normalized corpus.
125
+ await this.database.withTransactionAsync(async () => {
126
+ for (const window of windows) {
127
+ await this.database.runAsync(`INSERT INTO _gonvex_replica_queries (scope, signature, value) VALUES (?, ?, ?)
128
+ ON CONFLICT(scope, signature) DO UPDATE SET value = excluded.value`, scope, window.signature, JSON.stringify(normalizeWindow(window)));
129
+ }
130
+ if (cursor) {
131
+ await this.database.runAsync(`INSERT INTO _gonvex_replica_meta (scope, key, value) VALUES (?, 'cursor', ?)
132
+ ON CONFLICT(scope, key) DO UPDATE SET value = excluded.value`, scope, JSON.stringify(cursor));
133
+ }
134
+ });
135
+ }
121
136
  async replaceSnapshot(snapshot, scope = defaultReplicaScope) {
122
137
  await this.initialize();
123
138
  await this.database.withTransactionAsync(async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gonvex/expo-sqlite",
3
- "version": "0.5.1",
3
+ "version": "0.5.2-staging.1",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -18,7 +18,7 @@
18
18
  "README.md"
19
19
  ],
20
20
  "dependencies": {
21
- "@gonvex/client": "0.5.1"
21
+ "@gonvex/client": "0.5.2-staging.1"
22
22
  },
23
23
  "devDependencies": {
24
24
  "typescript": "^6.0.3",