@synclib-io/sync 0.1.0 → 0.2.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.mts CHANGED
@@ -668,6 +668,24 @@ declare class SyncClient {
668
668
  * Wait for WebSocket connection with timeout
669
669
  */
670
670
  private waitForConnection;
671
+ /**
672
+ * Null out the `seqnum` column on every row of the given tables so the next
673
+ * sync treats them as needing a full pull. Also clears the in-memory
674
+ * `tableSeqnums` cache entry for each table so `getPerTableSeqnums` falls
675
+ * back to the local `MAX(seqnum)` query (which now returns null).
676
+ *
677
+ * Use after an event that changes the user's access claims (e.g. a
678
+ * subscription purchase): combined with a fresh-JWT reconnect, the server
679
+ * re-runs `sanitize_row` against the new claims and the affected tables
680
+ * come back unstripped on the next autosync.
681
+ *
682
+ * Resumability requires the server to stream rows in `seqnum ASC` order
683
+ * (see `apply_seqnum_filter/2` in sync_server). Without ordered pagination,
684
+ * an interrupted pull leaves permanent gaps.
685
+ *
686
+ * Tables without a `seqnum` column are skipped silently.
687
+ */
688
+ nullOutSeqnums(tables: string[]): void;
671
689
  /**
672
690
  * Get per-table seqnums for incremental sync
673
691
  */
package/dist/index.d.ts CHANGED
@@ -668,6 +668,24 @@ declare class SyncClient {
668
668
  * Wait for WebSocket connection with timeout
669
669
  */
670
670
  private waitForConnection;
671
+ /**
672
+ * Null out the `seqnum` column on every row of the given tables so the next
673
+ * sync treats them as needing a full pull. Also clears the in-memory
674
+ * `tableSeqnums` cache entry for each table so `getPerTableSeqnums` falls
675
+ * back to the local `MAX(seqnum)` query (which now returns null).
676
+ *
677
+ * Use after an event that changes the user's access claims (e.g. a
678
+ * subscription purchase): combined with a fresh-JWT reconnect, the server
679
+ * re-runs `sanitize_row` against the new claims and the affected tables
680
+ * come back unstripped on the next autosync.
681
+ *
682
+ * Resumability requires the server to stream rows in `seqnum ASC` order
683
+ * (see `apply_seqnum_filter/2` in sync_server). Without ordered pagination,
684
+ * an interrupted pull leaves permanent gaps.
685
+ *
686
+ * Tables without a `seqnum` column are skipped silently.
687
+ */
688
+ nullOutSeqnums(tables: string[]): void;
671
689
  /**
672
690
  * Get per-table seqnums for incremental sync
673
691
  */
package/dist/index.js CHANGED
@@ -1250,6 +1250,32 @@ var SyncClient = class {
1250
1250
  });
1251
1251
  });
1252
1252
  }
1253
+ /**
1254
+ * Null out the `seqnum` column on every row of the given tables so the next
1255
+ * sync treats them as needing a full pull. Also clears the in-memory
1256
+ * `tableSeqnums` cache entry for each table so `getPerTableSeqnums` falls
1257
+ * back to the local `MAX(seqnum)` query (which now returns null).
1258
+ *
1259
+ * Use after an event that changes the user's access claims (e.g. a
1260
+ * subscription purchase): combined with a fresh-JWT reconnect, the server
1261
+ * re-runs `sanitize_row` against the new claims and the affected tables
1262
+ * come back unstripped on the next autosync.
1263
+ *
1264
+ * Resumability requires the server to stream rows in `seqnum ASC` order
1265
+ * (see `apply_seqnum_filter/2` in sync_server). Without ordered pagination,
1266
+ * an interrupted pull leaves permanent gaps.
1267
+ *
1268
+ * Tables without a `seqnum` column are skipped silently.
1269
+ */
1270
+ nullOutSeqnums(tables) {
1271
+ for (const table of tables) {
1272
+ try {
1273
+ this.db.exec(`UPDATE ${this.quoteId(table)} SET "seqnum" = NULL`);
1274
+ this.tableSeqnums.delete(table);
1275
+ } catch (e) {
1276
+ }
1277
+ }
1278
+ }
1253
1279
  /**
1254
1280
  * Get per-table seqnums for incremental sync
1255
1281
  */
package/dist/index.mjs CHANGED
@@ -1217,6 +1217,32 @@ var SyncClient = class {
1217
1217
  });
1218
1218
  });
1219
1219
  }
1220
+ /**
1221
+ * Null out the `seqnum` column on every row of the given tables so the next
1222
+ * sync treats them as needing a full pull. Also clears the in-memory
1223
+ * `tableSeqnums` cache entry for each table so `getPerTableSeqnums` falls
1224
+ * back to the local `MAX(seqnum)` query (which now returns null).
1225
+ *
1226
+ * Use after an event that changes the user's access claims (e.g. a
1227
+ * subscription purchase): combined with a fresh-JWT reconnect, the server
1228
+ * re-runs `sanitize_row` against the new claims and the affected tables
1229
+ * come back unstripped on the next autosync.
1230
+ *
1231
+ * Resumability requires the server to stream rows in `seqnum ASC` order
1232
+ * (see `apply_seqnum_filter/2` in sync_server). Without ordered pagination,
1233
+ * an interrupted pull leaves permanent gaps.
1234
+ *
1235
+ * Tables without a `seqnum` column are skipped silently.
1236
+ */
1237
+ nullOutSeqnums(tables) {
1238
+ for (const table of tables) {
1239
+ try {
1240
+ this.db.exec(`UPDATE ${this.quoteId(table)} SET "seqnum" = NULL`);
1241
+ this.tableSeqnums.delete(table);
1242
+ } catch (e) {
1243
+ }
1244
+ }
1245
+ }
1220
1246
  /**
1221
1247
  * Get per-table seqnums for incremental sync
1222
1248
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synclib-io/sync",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "TypeScript/JavaScript sync client for coordinating database changes with Elixir Phoenix server",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -18,12 +18,6 @@
18
18
  "files": [
19
19
  "dist"
20
20
  ],
21
- "scripts": {
22
- "build": "tsup src/index.ts --format cjs,esm --dts --clean",
23
- "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
24
- "test": "vitest",
25
- "prepublishOnly": "pnpm run build"
26
- },
27
21
  "keywords": [
28
22
  "sync",
29
23
  "websocket",
@@ -51,5 +45,10 @@
51
45
  "repository": {
52
46
  "type": "git",
53
47
  "url": "https://github.com/synclib-io/synclib"
48
+ },
49
+ "scripts": {
50
+ "build": "tsup src/index.ts --format cjs,esm --dts --clean",
51
+ "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
52
+ "test": "vitest"
54
53
  }
55
- }
54
+ }