diff --git a/.changeset/fix-dependency-bundling-issues.md b/.changeset/fix-dependency-bundling-issues.md deleted file mode 100644 index d8580d4cf..000000000 --- a/.changeset/fix-dependency-bundling-issues.md +++ /dev/null @@ -1,23 +0,0 @@ ---- -"@tanstack/offline-transactions": patch -"@tanstack/query-db-collection": patch ---- - -Fix dependency bundling issues by moving @tanstack/db to peerDependencies - -**What Changed:** - -Moved `@tanstack/db` from regular dependencies to peerDependencies in: - -- `@tanstack/offline-transactions` -- `@tanstack/query-db-collection` - -Removed `@opentelemetry/api` dependency from `@tanstack/offline-transactions`. - -**Why:** - -These extension packages incorrectly declared `@tanstack/db` as both a regular dependency AND a peerDependency simultaneously. This caused lock files to develop conflicting versions, resulting in multiple instances of `@tanstack/db` being installed in consuming applications. - -The fix removes `@tanstack/db` from regular dependencies and keeps it only as a peerDependency. This ensures only one version of `@tanstack/db` is installed in the dependency tree, preventing version conflicts. - -For local development, `@tanstack/db` remains in devDependencies so the packages can be built and tested independently. diff --git a/.changeset/fix-findone-joins-type-inference.md b/.changeset/fix-findone-joins-type-inference.md deleted file mode 100644 index f89e970a8..000000000 --- a/.changeset/fix-findone-joins-type-inference.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -"@tanstack/db": patch ---- - -Fix type inference for findOne() when used with join operations - -Previously, using `findOne()` with join operations (leftJoin, innerJoin, etc.) resulted in the query type being inferred as `never`, breaking TypeScript type checking: - -```typescript -const query = useLiveQuery( - (q) => - q - .from({ todo: todoCollection }) - .leftJoin({ todoOptions: todoOptionsCollection }, ...) - .findOne() // Type became 'never' -) -``` - -**The Fix:** - -Fixed the `MergeContextWithJoinType` type definition to conditionally include the `singleResult` property only when it's explicitly `true`, avoiding type conflicts when `findOne()` is called after joins: - -```typescript -// Before (buggy): -singleResult: TContext['singleResult'] extends true ? true : false - -// After (fixed): -type PreserveSingleResultFlag = [TFlag] extends [true] - ? { singleResult: true } - : {} - -// Used as: -} & PreserveSingleResultFlag -``` - -**Why This Works:** - -By using a conditional intersection that omits the property entirely when not needed, we avoid type conflicts. Intersecting `{} & { singleResult: true }` cleanly results in `{ singleResult: true }`, whereas the previous approach created conflicting property types resulting in `never`. The tuple wrapper (`[TFlag]`) ensures robust behavior even if the flag type becomes a union in the future. - -**Impact:** - -- ✅ `findOne()` now works correctly with all join types -- ✅ Type inference works properly in `useLiveQuery` and other contexts -- ✅ Both `findOne()` before and after joins work correctly -- ✅ All tests pass with no breaking changes (8 new type tests added) diff --git a/.changeset/fix-svelte-async-mode.md b/.changeset/fix-svelte-async-mode.md deleted file mode 100644 index 0eb4e072f..000000000 --- a/.changeset/fix-svelte-async-mode.md +++ /dev/null @@ -1,40 +0,0 @@ ---- -"@tanstack/svelte-db": patch ---- - -Fix flushSync error in Svelte 5 async compiler mode - -Previously, `useLiveQuery` threw an error when Svelte 5's async compiler mode was enabled: - -``` -Uncaught Svelte error: flush_sync_in_effect -Cannot use flushSync inside an effect -``` - -This occurred because `flushSync()` was called inside the `onFirstReady` callback, which executes within a `$effect` block. Svelte 5's async compiler enforces a strict rule that `flushSync()` cannot be called inside effects, as documented at svelte.dev/e/flush_sync_in_effect. - -**The Fix:** - -Removed the unnecessary `flushSync()` call from the `onFirstReady` callback. Svelte 5's reactivity system automatically propagates state changes without needing synchronous flushing. This matches the pattern already used in Vue's implementation. - -**Compatibility:** - -- ✅ For users WITHOUT async mode (current default): Works as before -- ✅ For users WITH async mode: Now works instead of throwing error -- ✅ Future-proof: async mode will be default in Svelte 6 -- ✅ All 23 existing tests pass, confirming no regression - -**How to enable async mode:** - -```javascript -// svelte.config.js -export default { - compilerOptions: { - experimental: { - async: true, - }, - }, -} -``` - -Fixes #744 diff --git a/.changeset/prevent-custom-getkey-with-joins.md b/.changeset/prevent-custom-getkey-with-joins.md deleted file mode 100644 index d56a6158f..000000000 --- a/.changeset/prevent-custom-getkey-with-joins.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -"@tanstack/db": patch ---- - -Improve error messages for custom getKey with joined queries - -Enhanced `DuplicateKeySyncError` to provide context-aware guidance when duplicate keys occur with custom `getKey` and joined queries. - -**The Issue:** - -When using custom `getKey` with joins, duplicate keys can occur if the join produces multiple rows with the same key value. This is valid for 1:1 relationships but problematic for 1:many relationships, and the previous error message didn't explain what went wrong or how to fix it. - -**What's New:** - -When a duplicate key error occurs in a live query collection that uses both custom `getKey` and joins, the error message now: - -- Explains that joined queries can produce multiple rows with the same key -- Suggests using a composite key in your `getKey` function -- Provides concrete examples of solutions -- Helps distinguish between correctly structured 1:1 joins vs problematic 1:many joins - -**Example:** - -```typescript -// ✅ Valid - 1:1 relationship with unique keys -const userProfiles = createLiveQueryCollection({ - query: (q) => - q - .from({ profile: profiles }) - .join({ user: users }, ({ profile, user }) => - eq(profile.userId, user.id) - ), - getKey: (profile) => profile.id, // Each profile has unique ID -}) -``` - -```typescript -// ⚠️ Problematic - 1:many relationship with duplicate keys -const userComments = createLiveQueryCollection({ - query: (q) => - q - .from({ user: users }) - .join({ comment: comments }, ({ user, comment }) => - eq(user.id, comment.userId) - ), - getKey: (item) => item.userId, // Multiple comments share same userId! -}) - -// Enhanced error message: -// "Cannot insert document with key "user1" from sync because it already exists. -// This collection uses a custom getKey with joined queries. Joined queries can -// produce multiple rows with the same key when relationships are not 1:1. -// Consider: (1) using a composite key in your getKey function (e.g., `${item.key1}-${item.key2}`), -// (2) ensuring your join produces unique rows per key, or (3) removing the -// custom getKey to use the default composite key behavior." -``` diff --git a/.changeset/query-observer-state-utils.md b/.changeset/query-observer-state-utils.md deleted file mode 100644 index 1d1d3996d..000000000 --- a/.changeset/query-observer-state-utils.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -"@tanstack/query-db-collection": minor -"@tanstack/db": patch ---- - -Add QueryObserver state utilities and convert error utils to getters - -Exposes TanStack Query's QueryObserver state through QueryCollectionUtils, providing visibility into sync status beyond just error states. Also converts existing error state utilities from methods to getters for consistency with TanStack DB/Query patterns. - -**Breaking Changes:** - -- `lastError()`, `isError()`, and `errorCount()` are now getters instead of methods - - Before: `collection.utils.lastError()` - - After: `collection.utils.lastError` - -**New Utilities:** - -- `isFetching` - Check if query is currently fetching (initial or background) -- `isRefetching` - Check if query is refetching in background -- `isLoading` - Check if query is loading for first time -- `dataUpdatedAt` - Get timestamp of last successful data update -- `fetchStatus` - Get current fetch status ('fetching' | 'paused' | 'idle') - -**Use Cases:** - -- Show loading indicators during background refetches -- Implement "Last updated X minutes ago" UI patterns -- Better understanding of query sync behavior - -**Example Usage:** - -```ts -const collection = queryCollectionOptions({ - // ... config -}) - -// Check sync status -if (collection.utils.isFetching) { - console.log("Syncing with server...") -} - -if (collection.utils.isRefetching) { - console.log("Background refresh in progress") -} - -// Show last update time -const lastUpdate = new Date(collection.utils.dataUpdatedAt) -console.log(`Last synced: ${lastUpdate.toLocaleTimeString()}`) - -// Check error state (now using getters) -if (collection.utils.isError) { - console.error("Sync failed:", collection.utils.lastError) - console.log(`Failed ${collection.utils.errorCount} times`) -} -``` diff --git a/examples/react/paced-mutations-demo/CHANGELOG.md b/examples/react/paced-mutations-demo/CHANGELOG.md index ed423ca59..5364f9eba 100644 --- a/examples/react/paced-mutations-demo/CHANGELOG.md +++ b/examples/react/paced-mutations-demo/CHANGELOG.md @@ -1,5 +1,13 @@ # @tanstack/db-example-paced-mutations-demo +## 0.0.7 + +### Patch Changes + +- Updated dependencies [[`6c55e16`](https://github.com/TanStack/db/commit/6c55e16a2545b479b1d47f548b6846d362573d45), [`7805afb`](https://github.com/TanStack/db/commit/7805afb7286b680168b336e77dd4de7dd1b6f06a), [`1367756`](https://github.com/TanStack/db/commit/1367756d0a68447405c5f5c1a3cca30ab0558d74)]: + - @tanstack/db@0.4.20 + - @tanstack/react-db@0.1.43 + ## 0.0.6 ### Patch Changes diff --git a/examples/react/paced-mutations-demo/package.json b/examples/react/paced-mutations-demo/package.json index 6266f8da8..7488ba1ea 100644 --- a/examples/react/paced-mutations-demo/package.json +++ b/examples/react/paced-mutations-demo/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/db-example-paced-mutations-demo", - "version": "0.0.6", + "version": "0.0.7", "private": true, "type": "module", "scripts": { diff --git a/examples/react/todo/CHANGELOG.md b/examples/react/todo/CHANGELOG.md index 146ed2b39..773b90a93 100644 --- a/examples/react/todo/CHANGELOG.md +++ b/examples/react/todo/CHANGELOG.md @@ -1,5 +1,15 @@ # examples/react/todo +## 0.1.23 + +### Patch Changes + +- Updated dependencies [[`503f0b2`](https://github.com/TanStack/db/commit/503f0b2311f3054cda65b10b933d34b03eef6b04), [`1367756`](https://github.com/TanStack/db/commit/1367756d0a68447405c5f5c1a3cca30ab0558d74)]: + - @tanstack/query-db-collection@0.3.0 + - @tanstack/electric-db-collection@0.1.44 + - @tanstack/react-db@0.1.43 + - @tanstack/trailbase-db-collection@0.1.42 + ## 0.1.22 ### Patch Changes diff --git a/examples/react/todo/package.json b/examples/react/todo/package.json index 8a7081a5d..20e1bdee3 100644 --- a/examples/react/todo/package.json +++ b/examples/react/todo/package.json @@ -1,7 +1,7 @@ { "name": "@tanstack/db-example-react-todo", "private": true, - "version": "0.1.22", + "version": "0.1.23", "dependencies": { "@tanstack/electric-db-collection": "workspace:^", "@tanstack/query-core": "^5.90.5", diff --git a/packages/angular-db/CHANGELOG.md b/packages/angular-db/CHANGELOG.md index b1e2f16af..fa2fadfd1 100644 --- a/packages/angular-db/CHANGELOG.md +++ b/packages/angular-db/CHANGELOG.md @@ -1,5 +1,12 @@ # @tanstack/angular-db +## 0.1.25 + +### Patch Changes + +- Updated dependencies [[`6c55e16`](https://github.com/TanStack/db/commit/6c55e16a2545b479b1d47f548b6846d362573d45), [`7805afb`](https://github.com/TanStack/db/commit/7805afb7286b680168b336e77dd4de7dd1b6f06a), [`1367756`](https://github.com/TanStack/db/commit/1367756d0a68447405c5f5c1a3cca30ab0558d74)]: + - @tanstack/db@0.4.20 + ## 0.1.24 ### Patch Changes diff --git a/packages/angular-db/package.json b/packages/angular-db/package.json index e1322ee80..394e0ecd3 100644 --- a/packages/angular-db/package.json +++ b/packages/angular-db/package.json @@ -1,7 +1,7 @@ { "name": "@tanstack/angular-db", "description": "Angular integration for @tanstack/db", - "version": "0.1.24", + "version": "0.1.25", "author": "Ethan McDaniel", "license": "MIT", "repository": { diff --git a/packages/db/CHANGELOG.md b/packages/db/CHANGELOG.md index de4130e84..1479f7098 100644 --- a/packages/db/CHANGELOG.md +++ b/packages/db/CHANGELOG.md @@ -1,5 +1,150 @@ # @tanstack/db +## 0.4.20 + +### Patch Changes + +- Fix type inference for findOne() when used with join operations ([#749](https://github.com/TanStack/db/pull/749)) + + Previously, using `findOne()` with join operations (leftJoin, innerJoin, etc.) resulted in the query type being inferred as `never`, breaking TypeScript type checking: + + ```typescript + const query = useLiveQuery( + (q) => + q + .from({ todo: todoCollection }) + .leftJoin({ todoOptions: todoOptionsCollection }, ...) + .findOne() // Type became 'never' + ) + ``` + + **The Fix:** + + Fixed the `MergeContextWithJoinType` type definition to conditionally include the `singleResult` property only when it's explicitly `true`, avoiding type conflicts when `findOne()` is called after joins: + + ```typescript + // Before (buggy): + singleResult: TContext['singleResult'] extends true ? true : false + + // After (fixed): + type PreserveSingleResultFlag = [TFlag] extends [true] + ? { singleResult: true } + : {} + + // Used as: + } & PreserveSingleResultFlag + ``` + + **Why This Works:** + + By using a conditional intersection that omits the property entirely when not needed, we avoid type conflicts. Intersecting `{} & { singleResult: true }` cleanly results in `{ singleResult: true }`, whereas the previous approach created conflicting property types resulting in `never`. The tuple wrapper (`[TFlag]`) ensures robust behavior even if the flag type becomes a union in the future. + + **Impact:** + - ✅ `findOne()` now works correctly with all join types + - ✅ Type inference works properly in `useLiveQuery` and other contexts + - ✅ Both `findOne()` before and after joins work correctly + - ✅ All tests pass with no breaking changes (8 new type tests added) + +- Improve error messages for custom getKey with joined queries ([#717](https://github.com/TanStack/db/pull/717)) + + Enhanced `DuplicateKeySyncError` to provide context-aware guidance when duplicate keys occur with custom `getKey` and joined queries. + + **The Issue:** + + When using custom `getKey` with joins, duplicate keys can occur if the join produces multiple rows with the same key value. This is valid for 1:1 relationships but problematic for 1:many relationships, and the previous error message didn't explain what went wrong or how to fix it. + + **What's New:** + + When a duplicate key error occurs in a live query collection that uses both custom `getKey` and joins, the error message now: + - Explains that joined queries can produce multiple rows with the same key + - Suggests using a composite key in your `getKey` function + - Provides concrete examples of solutions + - Helps distinguish between correctly structured 1:1 joins vs problematic 1:many joins + + **Example:** + + ```typescript + // ✅ Valid - 1:1 relationship with unique keys + const userProfiles = createLiveQueryCollection({ + query: (q) => + q + .from({ profile: profiles }) + .join({ user: users }, ({ profile, user }) => + eq(profile.userId, user.id) + ), + getKey: (profile) => profile.id, // Each profile has unique ID + }) + ``` + + ```typescript + // ⚠️ Problematic - 1:many relationship with duplicate keys + const userComments = createLiveQueryCollection({ + query: (q) => + q + .from({ user: users }) + .join({ comment: comments }, ({ user, comment }) => + eq(user.id, comment.userId) + ), + getKey: (item) => item.userId, // Multiple comments share same userId! + }) + + // Enhanced error message: + // "Cannot insert document with key "user1" from sync because it already exists. + // This collection uses a custom getKey with joined queries. Joined queries can + // produce multiple rows with the same key when relationships are not 1:1. + // Consider: (1) using a composite key in your getKey function (e.g., `${item.key1}-${item.key2}`), + // (2) ensuring your join produces unique rows per key, or (3) removing the + // custom getKey to use the default composite key behavior." + ``` + +- Add QueryObserver state utilities and convert error utils to getters ([#742](https://github.com/TanStack/db/pull/742)) + + Exposes TanStack Query's QueryObserver state through QueryCollectionUtils, providing visibility into sync status beyond just error states. Also converts existing error state utilities from methods to getters for consistency with TanStack DB/Query patterns. + + **Breaking Changes:** + - `lastError()`, `isError()`, and `errorCount()` are now getters instead of methods + - Before: `collection.utils.lastError()` + - After: `collection.utils.lastError` + + **New Utilities:** + - `isFetching` - Check if query is currently fetching (initial or background) + - `isRefetching` - Check if query is refetching in background + - `isLoading` - Check if query is loading for first time + - `dataUpdatedAt` - Get timestamp of last successful data update + - `fetchStatus` - Get current fetch status ('fetching' | 'paused' | 'idle') + + **Use Cases:** + - Show loading indicators during background refetches + - Implement "Last updated X minutes ago" UI patterns + - Better understanding of query sync behavior + + **Example Usage:** + + ```ts + const collection = queryCollectionOptions({ + // ... config + }) + + // Check sync status + if (collection.utils.isFetching) { + console.log("Syncing with server...") + } + + if (collection.utils.isRefetching) { + console.log("Background refresh in progress") + } + + // Show last update time + const lastUpdate = new Date(collection.utils.dataUpdatedAt) + console.log(`Last synced: ${lastUpdate.toLocaleTimeString()}`) + + // Check error state (now using getters) + if (collection.utils.isError) { + console.error("Sync failed:", collection.utils.lastError) + console.log(`Failed ${collection.utils.errorCount} times`) + } + ``` + ## 0.4.19 ### Patch Changes diff --git a/packages/db/package.json b/packages/db/package.json index 7410c2464..ac315d095 100644 --- a/packages/db/package.json +++ b/packages/db/package.json @@ -1,7 +1,7 @@ { "name": "@tanstack/db", "description": "A reactive client store for building super fast apps on sync", - "version": "0.4.19", + "version": "0.4.20", "dependencies": { "@standard-schema/spec": "^1.0.0", "@tanstack/db-ivm": "workspace:*", diff --git a/packages/electric-db-collection/CHANGELOG.md b/packages/electric-db-collection/CHANGELOG.md index cb8787fb5..21519da60 100644 --- a/packages/electric-db-collection/CHANGELOG.md +++ b/packages/electric-db-collection/CHANGELOG.md @@ -1,5 +1,12 @@ # @tanstack/electric-db-collection +## 0.1.44 + +### Patch Changes + +- Updated dependencies [[`6c55e16`](https://github.com/TanStack/db/commit/6c55e16a2545b479b1d47f548b6846d362573d45), [`7805afb`](https://github.com/TanStack/db/commit/7805afb7286b680168b336e77dd4de7dd1b6f06a), [`1367756`](https://github.com/TanStack/db/commit/1367756d0a68447405c5f5c1a3cca30ab0558d74)]: + - @tanstack/db@0.4.20 + ## 0.1.43 ### Patch Changes diff --git a/packages/electric-db-collection/package.json b/packages/electric-db-collection/package.json index f407794cc..331588704 100644 --- a/packages/electric-db-collection/package.json +++ b/packages/electric-db-collection/package.json @@ -1,7 +1,7 @@ { "name": "@tanstack/electric-db-collection", "description": "ElectricSQL collection for TanStack DB", - "version": "0.1.43", + "version": "0.1.44", "dependencies": { "@electric-sql/client": "^1.1.0", "@standard-schema/spec": "^1.0.0", diff --git a/packages/offline-transactions/CHANGELOG.md b/packages/offline-transactions/CHANGELOG.md index 4c50182ed..e74723920 100644 --- a/packages/offline-transactions/CHANGELOG.md +++ b/packages/offline-transactions/CHANGELOG.md @@ -1,5 +1,30 @@ # @tanstack/offline-transactions +## 0.1.3 + +### Patch Changes + +- Fix dependency bundling issues by moving @tanstack/db to peerDependencies ([#766](https://github.com/TanStack/db/pull/766)) + + **What Changed:** + + Moved `@tanstack/db` from regular dependencies to peerDependencies in: + - `@tanstack/offline-transactions` + - `@tanstack/query-db-collection` + + Removed `@opentelemetry/api` dependency from `@tanstack/offline-transactions`. + + **Why:** + + These extension packages incorrectly declared `@tanstack/db` as both a regular dependency AND a peerDependency simultaneously. This caused lock files to develop conflicting versions, resulting in multiple instances of `@tanstack/db` being installed in consuming applications. + + The fix removes `@tanstack/db` from regular dependencies and keeps it only as a peerDependency. This ensures only one version of `@tanstack/db` is installed in the dependency tree, preventing version conflicts. + + For local development, `@tanstack/db` remains in devDependencies so the packages can be built and tested independently. + +- Updated dependencies [[`6c55e16`](https://github.com/TanStack/db/commit/6c55e16a2545b479b1d47f548b6846d362573d45), [`7805afb`](https://github.com/TanStack/db/commit/7805afb7286b680168b336e77dd4de7dd1b6f06a), [`1367756`](https://github.com/TanStack/db/commit/1367756d0a68447405c5f5c1a3cca30ab0558d74)]: + - @tanstack/db@0.4.20 + ## 0.1.2 ### Patch Changes diff --git a/packages/offline-transactions/package.json b/packages/offline-transactions/package.json index c505927fc..488f1de21 100644 --- a/packages/offline-transactions/package.json +++ b/packages/offline-transactions/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/offline-transactions", - "version": "0.1.2", + "version": "0.1.3", "description": "Offline-first transaction capabilities for TanStack DB", "author": "TanStack", "license": "MIT", diff --git a/packages/powersync-db-collection/CHANGELOG.md b/packages/powersync-db-collection/CHANGELOG.md index ffc322203..8ccb68d86 100644 --- a/packages/powersync-db-collection/CHANGELOG.md +++ b/packages/powersync-db-collection/CHANGELOG.md @@ -1,5 +1,12 @@ # @tanstack/powersync-db-collection +## 0.1.3 + +### Patch Changes + +- Updated dependencies [[`6c55e16`](https://github.com/TanStack/db/commit/6c55e16a2545b479b1d47f548b6846d362573d45), [`7805afb`](https://github.com/TanStack/db/commit/7805afb7286b680168b336e77dd4de7dd1b6f06a), [`1367756`](https://github.com/TanStack/db/commit/1367756d0a68447405c5f5c1a3cca30ab0558d74)]: + - @tanstack/db@0.4.20 + ## 0.1.2 ### Patch Changes diff --git a/packages/powersync-db-collection/package.json b/packages/powersync-db-collection/package.json index dfa2e929e..a59cc2255 100644 --- a/packages/powersync-db-collection/package.json +++ b/packages/powersync-db-collection/package.json @@ -1,7 +1,7 @@ { "name": "@tanstack/powersync-db-collection", "description": "PowerSync collection for TanStack DB", - "version": "0.1.2", + "version": "0.1.3", "dependencies": { "@standard-schema/spec": "^1.0.0", "@tanstack/db": "workspace:*", diff --git a/packages/query-db-collection/CHANGELOG.md b/packages/query-db-collection/CHANGELOG.md index 36feb72a3..c95fb53a4 100644 --- a/packages/query-db-collection/CHANGELOG.md +++ b/packages/query-db-collection/CHANGELOG.md @@ -1,5 +1,80 @@ # @tanstack/query-db-collection +## 0.3.0 + +### Minor Changes + +- Add QueryObserver state utilities and convert error utils to getters ([#742](https://github.com/TanStack/db/pull/742)) + + Exposes TanStack Query's QueryObserver state through QueryCollectionUtils, providing visibility into sync status beyond just error states. Also converts existing error state utilities from methods to getters for consistency with TanStack DB/Query patterns. + + **Breaking Changes:** + - `lastError()`, `isError()`, and `errorCount()` are now getters instead of methods + - Before: `collection.utils.lastError()` + - After: `collection.utils.lastError` + + **New Utilities:** + - `isFetching` - Check if query is currently fetching (initial or background) + - `isRefetching` - Check if query is refetching in background + - `isLoading` - Check if query is loading for first time + - `dataUpdatedAt` - Get timestamp of last successful data update + - `fetchStatus` - Get current fetch status ('fetching' | 'paused' | 'idle') + + **Use Cases:** + - Show loading indicators during background refetches + - Implement "Last updated X minutes ago" UI patterns + - Better understanding of query sync behavior + + **Example Usage:** + + ```ts + const collection = queryCollectionOptions({ + // ... config + }) + + // Check sync status + if (collection.utils.isFetching) { + console.log("Syncing with server...") + } + + if (collection.utils.isRefetching) { + console.log("Background refresh in progress") + } + + // Show last update time + const lastUpdate = new Date(collection.utils.dataUpdatedAt) + console.log(`Last synced: ${lastUpdate.toLocaleTimeString()}`) + + // Check error state (now using getters) + if (collection.utils.isError) { + console.error("Sync failed:", collection.utils.lastError) + console.log(`Failed ${collection.utils.errorCount} times`) + } + ``` + +### Patch Changes + +- Fix dependency bundling issues by moving @tanstack/db to peerDependencies ([#766](https://github.com/TanStack/db/pull/766)) + + **What Changed:** + + Moved `@tanstack/db` from regular dependencies to peerDependencies in: + - `@tanstack/offline-transactions` + - `@tanstack/query-db-collection` + + Removed `@opentelemetry/api` dependency from `@tanstack/offline-transactions`. + + **Why:** + + These extension packages incorrectly declared `@tanstack/db` as both a regular dependency AND a peerDependency simultaneously. This caused lock files to develop conflicting versions, resulting in multiple instances of `@tanstack/db` being installed in consuming applications. + + The fix removes `@tanstack/db` from regular dependencies and keeps it only as a peerDependency. This ensures only one version of `@tanstack/db` is installed in the dependency tree, preventing version conflicts. + + For local development, `@tanstack/db` remains in devDependencies so the packages can be built and tested independently. + +- Updated dependencies [[`6c55e16`](https://github.com/TanStack/db/commit/6c55e16a2545b479b1d47f548b6846d362573d45), [`7805afb`](https://github.com/TanStack/db/commit/7805afb7286b680168b336e77dd4de7dd1b6f06a), [`1367756`](https://github.com/TanStack/db/commit/1367756d0a68447405c5f5c1a3cca30ab0558d74)]: + - @tanstack/db@0.4.20 + ## 0.2.42 ### Patch Changes diff --git a/packages/query-db-collection/package.json b/packages/query-db-collection/package.json index f81fc14e5..02f00b973 100644 --- a/packages/query-db-collection/package.json +++ b/packages/query-db-collection/package.json @@ -1,7 +1,7 @@ { "name": "@tanstack/query-db-collection", "description": "TanStack Query collection for TanStack DB", - "version": "0.2.42", + "version": "0.3.0", "dependencies": { "@standard-schema/spec": "^1.0.0" }, diff --git a/packages/react-db/CHANGELOG.md b/packages/react-db/CHANGELOG.md index 23fabf1fd..d125f996b 100644 --- a/packages/react-db/CHANGELOG.md +++ b/packages/react-db/CHANGELOG.md @@ -1,5 +1,12 @@ # @tanstack/react-db +## 0.1.43 + +### Patch Changes + +- Updated dependencies [[`6c55e16`](https://github.com/TanStack/db/commit/6c55e16a2545b479b1d47f548b6846d362573d45), [`7805afb`](https://github.com/TanStack/db/commit/7805afb7286b680168b336e77dd4de7dd1b6f06a), [`1367756`](https://github.com/TanStack/db/commit/1367756d0a68447405c5f5c1a3cca30ab0558d74)]: + - @tanstack/db@0.4.20 + ## 0.1.42 ### Patch Changes diff --git a/packages/react-db/package.json b/packages/react-db/package.json index 97dd3e9f8..e26bb38b1 100644 --- a/packages/react-db/package.json +++ b/packages/react-db/package.json @@ -1,7 +1,7 @@ { "name": "@tanstack/react-db", "description": "React integration for @tanstack/db", - "version": "0.1.42", + "version": "0.1.43", "author": "Kyle Mathews", "license": "MIT", "repository": { diff --git a/packages/rxdb-db-collection/CHANGELOG.md b/packages/rxdb-db-collection/CHANGELOG.md index e16a9644a..a50e49d9a 100644 --- a/packages/rxdb-db-collection/CHANGELOG.md +++ b/packages/rxdb-db-collection/CHANGELOG.md @@ -1,5 +1,12 @@ # @tanstack/rxdb-db-collection +## 0.1.31 + +### Patch Changes + +- Updated dependencies [[`6c55e16`](https://github.com/TanStack/db/commit/6c55e16a2545b479b1d47f548b6846d362573d45), [`7805afb`](https://github.com/TanStack/db/commit/7805afb7286b680168b336e77dd4de7dd1b6f06a), [`1367756`](https://github.com/TanStack/db/commit/1367756d0a68447405c5f5c1a3cca30ab0558d74)]: + - @tanstack/db@0.4.20 + ## 0.1.30 ### Patch Changes diff --git a/packages/rxdb-db-collection/package.json b/packages/rxdb-db-collection/package.json index cdb802c3d..55a146f6c 100644 --- a/packages/rxdb-db-collection/package.json +++ b/packages/rxdb-db-collection/package.json @@ -1,7 +1,7 @@ { "name": "@tanstack/rxdb-db-collection", "description": "RxDB collection for TanStack DB", - "version": "0.1.30", + "version": "0.1.31", "dependencies": { "rxdb": "16.20.0", "@standard-schema/spec": "^1.0.0", diff --git a/packages/solid-db/CHANGELOG.md b/packages/solid-db/CHANGELOG.md index 11682ae5f..9d8bebb83 100644 --- a/packages/solid-db/CHANGELOG.md +++ b/packages/solid-db/CHANGELOG.md @@ -1,5 +1,12 @@ # @tanstack/react-db +## 0.1.42 + +### Patch Changes + +- Updated dependencies [[`6c55e16`](https://github.com/TanStack/db/commit/6c55e16a2545b479b1d47f548b6846d362573d45), [`7805afb`](https://github.com/TanStack/db/commit/7805afb7286b680168b336e77dd4de7dd1b6f06a), [`1367756`](https://github.com/TanStack/db/commit/1367756d0a68447405c5f5c1a3cca30ab0558d74)]: + - @tanstack/db@0.4.20 + ## 0.1.41 ### Patch Changes diff --git a/packages/solid-db/package.json b/packages/solid-db/package.json index 4ea4335d9..03559e22d 100644 --- a/packages/solid-db/package.json +++ b/packages/solid-db/package.json @@ -1,7 +1,7 @@ { "name": "@tanstack/solid-db", "description": "Solid integration for @tanstack/db", - "version": "0.1.41", + "version": "0.1.42", "author": "Kyle Mathews", "license": "MIT", "repository": { diff --git a/packages/svelte-db/CHANGELOG.md b/packages/svelte-db/CHANGELOG.md index d91a75a9d..16d01c4d0 100644 --- a/packages/svelte-db/CHANGELOG.md +++ b/packages/svelte-db/CHANGELOG.md @@ -1,5 +1,48 @@ # @tanstack/svelte-db +## 0.1.42 + +### Patch Changes + +- Fix flushSync error in Svelte 5 async compiler mode ([#745](https://github.com/TanStack/db/pull/745)) + + Previously, `useLiveQuery` threw an error when Svelte 5's async compiler mode was enabled: + + ``` + Uncaught Svelte error: flush_sync_in_effect + Cannot use flushSync inside an effect + ``` + + This occurred because `flushSync()` was called inside the `onFirstReady` callback, which executes within a `$effect` block. Svelte 5's async compiler enforces a strict rule that `flushSync()` cannot be called inside effects, as documented at svelte.dev/e/flush_sync_in_effect. + + **The Fix:** + + Removed the unnecessary `flushSync()` call from the `onFirstReady` callback. Svelte 5's reactivity system automatically propagates state changes without needing synchronous flushing. This matches the pattern already used in Vue's implementation. + + **Compatibility:** + - ✅ For users WITHOUT async mode (current default): Works as before + - ✅ For users WITH async mode: Now works instead of throwing error + - ✅ Future-proof: async mode will be default in Svelte 6 + - ✅ All 23 existing tests pass, confirming no regression + + **How to enable async mode:** + + ```javascript + // svelte.config.js + export default { + compilerOptions: { + experimental: { + async: true, + }, + }, + } + ``` + + Fixes #744 + +- Updated dependencies [[`6c55e16`](https://github.com/TanStack/db/commit/6c55e16a2545b479b1d47f548b6846d362573d45), [`7805afb`](https://github.com/TanStack/db/commit/7805afb7286b680168b336e77dd4de7dd1b6f06a), [`1367756`](https://github.com/TanStack/db/commit/1367756d0a68447405c5f5c1a3cca30ab0558d74)]: + - @tanstack/db@0.4.20 + ## 0.1.41 ### Patch Changes diff --git a/packages/svelte-db/package.json b/packages/svelte-db/package.json index f59a73664..d122d8e7a 100644 --- a/packages/svelte-db/package.json +++ b/packages/svelte-db/package.json @@ -1,7 +1,7 @@ { "name": "@tanstack/svelte-db", "description": "Svelte integration for @tanstack/db", - "version": "0.1.41", + "version": "0.1.42", "dependencies": { "@tanstack/db": "workspace:*" }, diff --git a/packages/trailbase-db-collection/CHANGELOG.md b/packages/trailbase-db-collection/CHANGELOG.md index 565a47dca..bc50028ad 100644 --- a/packages/trailbase-db-collection/CHANGELOG.md +++ b/packages/trailbase-db-collection/CHANGELOG.md @@ -1,5 +1,12 @@ # @tanstack/trailbase-db-collection +## 0.1.42 + +### Patch Changes + +- Updated dependencies [[`6c55e16`](https://github.com/TanStack/db/commit/6c55e16a2545b479b1d47f548b6846d362573d45), [`7805afb`](https://github.com/TanStack/db/commit/7805afb7286b680168b336e77dd4de7dd1b6f06a), [`1367756`](https://github.com/TanStack/db/commit/1367756d0a68447405c5f5c1a3cca30ab0558d74)]: + - @tanstack/db@0.4.20 + ## 0.1.41 ### Patch Changes diff --git a/packages/trailbase-db-collection/package.json b/packages/trailbase-db-collection/package.json index 3f80f9acd..e4a421f2b 100644 --- a/packages/trailbase-db-collection/package.json +++ b/packages/trailbase-db-collection/package.json @@ -1,7 +1,7 @@ { "name": "@tanstack/trailbase-db-collection", "description": "TrailBase collection for TanStack DB", - "version": "0.1.41", + "version": "0.1.42", "dependencies": { "@standard-schema/spec": "^1.0.0", "@tanstack/db": "workspace:*", diff --git a/packages/vue-db/CHANGELOG.md b/packages/vue-db/CHANGELOG.md index 516aaeb31..79077a0f2 100644 --- a/packages/vue-db/CHANGELOG.md +++ b/packages/vue-db/CHANGELOG.md @@ -1,5 +1,12 @@ # @tanstack/vue-db +## 0.0.75 + +### Patch Changes + +- Updated dependencies [[`6c55e16`](https://github.com/TanStack/db/commit/6c55e16a2545b479b1d47f548b6846d362573d45), [`7805afb`](https://github.com/TanStack/db/commit/7805afb7286b680168b336e77dd4de7dd1b6f06a), [`1367756`](https://github.com/TanStack/db/commit/1367756d0a68447405c5f5c1a3cca30ab0558d74)]: + - @tanstack/db@0.4.20 + ## 0.0.74 ### Patch Changes diff --git a/packages/vue-db/package.json b/packages/vue-db/package.json index b2c9f23bd..47c59c645 100644 --- a/packages/vue-db/package.json +++ b/packages/vue-db/package.json @@ -1,7 +1,7 @@ { "name": "@tanstack/vue-db", "description": "Vue integration for @tanstack/db", - "version": "0.0.74", + "version": "0.0.75", "author": "Kyle Mathews", "license": "MIT", "repository": {