@syncular/client 0.15.18 → 0.15.19

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/client.js CHANGED
@@ -1089,13 +1089,13 @@ export class SyncClient {
1089
1089
  }
1090
1090
  const existing = getSubscription(this.#db, input.id);
1091
1091
  if (existing !== undefined) {
1092
- saveSubscription(this.#db, {
1093
- ...existing,
1094
- table: input.table,
1095
- scopes: input.scopes,
1096
- ...(input.params !== undefined ? { params: input.params } : {}),
1097
- });
1098
- this.#emitDiagnostics();
1092
+ const sameIntent = existing.table === input.table &&
1093
+ canonicalScopeJson(existing.scopes) ===
1094
+ canonicalScopeJson(input.scopes) &&
1095
+ existing.params === input.params;
1096
+ if (!sameIntent) {
1097
+ throw new ClientSyncError('client.subscription_intent_mismatch', 'subscribe: the subscription id is already registered for a different table, scopes, or params');
1098
+ }
1099
1099
  return;
1100
1100
  }
1101
1101
  saveSubscription(this.#db, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syncular/client",
3
- "version": "0.15.18",
3
+ "version": "0.15.19",
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",
@@ -81,7 +81,7 @@
81
81
  },
82
82
  "dependencies": {
83
83
  "@sqlite.org/sqlite-wasm": "^3.53.0-build1",
84
- "@syncular/core": "0.15.18"
84
+ "@syncular/core": "0.15.19"
85
85
  },
86
86
  "peerDependencies": {
87
87
  "better-sqlite3": ">=11"
@@ -92,7 +92,7 @@
92
92
  }
93
93
  },
94
94
  "devDependencies": {
95
- "@syncular/server": "0.15.18",
95
+ "@syncular/server": "0.15.19",
96
96
  "@types/better-sqlite3": "^7.6.13",
97
97
  "better-sqlite3": "^12.11.1"
98
98
  }
package/src/client.ts CHANGED
@@ -1739,13 +1739,17 @@ export class SyncClient {
1739
1739
  }
1740
1740
  const existing = getSubscription(this.#db, input.id);
1741
1741
  if (existing !== undefined) {
1742
- saveSubscription(this.#db, {
1743
- ...existing,
1744
- table: input.table,
1745
- scopes: input.scopes,
1746
- ...(input.params !== undefined ? { params: input.params } : {}),
1747
- });
1748
- this.#emitDiagnostics();
1742
+ const sameIntent =
1743
+ existing.table === input.table &&
1744
+ canonicalScopeJson(existing.scopes) ===
1745
+ canonicalScopeJson(input.scopes) &&
1746
+ existing.params === input.params;
1747
+ if (!sameIntent) {
1748
+ throw new ClientSyncError(
1749
+ 'client.subscription_intent_mismatch',
1750
+ 'subscribe: the subscription id is already registered for a different table, scopes, or params',
1751
+ );
1752
+ }
1749
1753
  return;
1750
1754
  }
1751
1755
  saveSubscription(this.#db, {