From a1a484ec4d2331d702ab9c4b7e5b02622c76b3dd Mon Sep 17 00:00:00 2001 From: Sam Willis Date: Thu, 4 Dec 2025 16:47:08 +0000 Subject: [PATCH 01/42] fix(query-db-collection): use deep equality for object field comparison (#967) * test: add test for object field update rollback issue Add test that verifies object field updates with refetch: false don't rollback to previous values after server response. * fix: use deep equality for object field comparison in query observer Replace shallow equality (===) with deep equality when comparing items in the query observer callback. This fixes an issue where updating object fields with refetch: false would cause rollback to previous values every other update. * chore: add changeset for object field update rollback fix --- .../fix-object-field-update-rollback.md | 8 ++ packages/db/src/index.ts | 1 + packages/query-db-collection/src/query.ts | 28 +----- .../query-db-collection/tests/query.test.ts | 92 +++++++++++++++++++ 4 files changed, 103 insertions(+), 26 deletions(-) create mode 100644 .changeset/fix-object-field-update-rollback.md diff --git a/.changeset/fix-object-field-update-rollback.md b/.changeset/fix-object-field-update-rollback.md new file mode 100644 index 000000000..ef2f3eb5c --- /dev/null +++ b/.changeset/fix-object-field-update-rollback.md @@ -0,0 +1,8 @@ +--- +"@tanstack/query-db-collection": patch +"@tanstack/db": patch +--- + +fix(query-db-collection): use deep equality for object field comparison in query observer + +Fixed an issue where updating object fields (non-primitives) with `refetch: false` in `onUpdate` handlers would cause the value to rollback to the previous state every other update. The query observer was using shallow equality (`===`) to compare items, which compares object properties by reference rather than by value. This caused the observer to incorrectly detect differences and write stale data back to syncedData. Now uses `deepEquals` for proper value comparison. diff --git a/packages/db/src/index.ts b/packages/db/src/index.ts index 638e21514..550df0c6c 100644 --- a/packages/db/src/index.ts +++ b/packages/db/src/index.ts @@ -13,6 +13,7 @@ export * from "./optimistic-action" export * from "./local-only" export * from "./local-storage" export * from "./errors" +export { deepEquals } from "./utils" export * from "./paced-mutations" export * from "./strategies/index.js" diff --git a/packages/query-db-collection/src/query.ts b/packages/query-db-collection/src/query.ts index 8b98ec570..8cfb6efc3 100644 --- a/packages/query-db-collection/src/query.ts +++ b/packages/query-db-collection/src/query.ts @@ -1,4 +1,5 @@ import { QueryObserver, hashKey } from "@tanstack/query-core" +import { deepEquals } from "@tanstack/db" import { GetKeyRequiredError, QueryClientRequiredError, @@ -799,26 +800,6 @@ export function queryCollectionOptions( begin() - // Helper function for shallow equality check of objects - const shallowEqual = ( - obj1: Record, - obj2: Record - ): boolean => { - // Get all keys from both objects - const keys1 = Object.keys(obj1) - const keys2 = Object.keys(obj2) - - // If number of keys is different, objects are not equal - if (keys1.length !== keys2.length) return false - - // Check if all keys in obj1 have the same values in obj2 - return keys1.every((key) => { - // Skip comparing functions and complex objects deeply - if (typeof obj1[key] === `function`) return true - return obj1[key] === obj2[key] - }) - } - currentSyncedItems.forEach((oldItem, key) => { const newItem = newItemsMap.get(key) if (!newItem) { @@ -826,12 +807,7 @@ export function queryCollectionOptions( if (needToRemove) { write({ type: `delete`, value: oldItem }) } - } else if ( - !shallowEqual( - oldItem as Record, - newItem as Record - ) - ) { + } else if (!deepEquals(oldItem, newItem)) { // Only update if there are actual differences in the properties write({ type: `update`, value: newItem }) } diff --git a/packages/query-db-collection/tests/query.test.ts b/packages/query-db-collection/tests/query.test.ts index 0c4408646..df879d032 100644 --- a/packages/query-db-collection/tests/query.test.ts +++ b/packages/query-db-collection/tests/query.test.ts @@ -2112,6 +2112,98 @@ describe(`QueryCollection`, () => { expect(todo?.id).toBe(1) expect(todo?.id).not.toBe(clientId) }) + + it(`should not rollback object field updates after server response with refetch: false`, async () => { + const queryKey = [`object-field-update-test`] + + type Todo = { + id: string + metadata: { createdBy: string } + } + + const serverTodos: Array = [ + { id: `1`, metadata: { createdBy: `user1` } }, + ] + + const queryFn = vi + .fn() + .mockImplementation(() => Promise.resolve([...serverTodos])) + + async function updateTodo(id: string, changes: Partial) { + await new Promise((resolve) => setTimeout(resolve, 10)) + const todo = serverTodos.find((t) => t.id === id) + if (todo) { + Object.assign(todo, changes) + } + return todo + } + + const todosCollection = createCollection( + queryCollectionOptions({ + id: `object-field-update-test`, + queryKey, + queryFn, + queryClient, + getKey: (item: Todo) => item.id, + startSync: true, + onUpdate: async ({ transaction }) => { + const updates = transaction.mutations.map((m) => ({ + id: m.key as string, + changes: m.changes, + })) + + const serverItems = await Promise.all( + updates.map((update) => updateTodo(update.id, update.changes)) + ) + + todosCollection.utils.writeBatch(() => { + serverItems.forEach((serverItem) => { + if (serverItem) { + todosCollection.utils.writeUpdate(serverItem) + } + }) + }) + + return { refetch: false } + }, + }) + ) + + await vi.waitFor(() => { + expect(todosCollection.status).toBe(`ready`) + }) + + // Verify initial state + expect(todosCollection.get(`1`)?.metadata.createdBy).toBe(`user1`) + + // Update 1: change metadata from user1 to user456 + todosCollection.update(`1`, (draft) => { + draft.metadata = { createdBy: `user456` } + }) + + // Wait for mutation to complete + await new Promise((resolve) => setTimeout(resolve, 50)) + + // Verify Update 1 worked + expect(todosCollection.get(`1`)?.metadata.createdBy).toBe(`user456`) + expect( + todosCollection._state.syncedData.get(`1`)?.metadata.createdBy + ).toBe(`user456`) + + // Update 2: change metadata from user456 to user789 + todosCollection.update(`1`, (draft) => { + draft.metadata = { createdBy: `user789` } + }) + + // Wait for mutation to complete + await new Promise((resolve) => setTimeout(resolve, 50)) + + // Verify Update 2 persisted correctly + expect( + todosCollection._state.syncedData.get(`1`)?.metadata.createdBy + ).toBe(`user789`) + expect(todosCollection.get(`1`)?.metadata.createdBy).toBe(`user789`) + }) }) it(`should call markReady when queryFn returns an empty array`, async () => { From c6ea2542c3a2ee8475b5250570d43210fcb5836f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 4 Dec 2025 10:50:10 -0700 Subject: [PATCH 02/42] ci: Version Packages (#961) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .changeset/fix-filter-expression-compile.md | 7 ------- .changeset/fix-isready-disabled-queries.md | 13 ------------- .changeset/fix-object-field-update-rollback.md | 8 -------- .changeset/fix-tanstack-db-peerdeps.md | 6 ------ examples/react/offline-transactions/package.json | 6 +++--- examples/react/projects/package.json | 4 ++-- packages/angular-db/CHANGELOG.md | 13 +++++++++++++ packages/angular-db/package.json | 2 +- packages/db-collection-e2e/CHANGELOG.md | 9 +++++++++ packages/db-collection-e2e/package.json | 2 +- packages/db/CHANGELOG.md | 12 ++++++++++++ packages/db/package.json | 2 +- packages/electric-db-collection/CHANGELOG.md | 7 +++++++ packages/electric-db-collection/package.json | 2 +- packages/offline-transactions/CHANGELOG.md | 9 +++++++++ packages/offline-transactions/package.json | 2 +- packages/powersync-db-collection/CHANGELOG.md | 7 +++++++ packages/powersync-db-collection/package.json | 2 +- packages/query-db-collection/CHANGELOG.md | 13 +++++++++++++ packages/query-db-collection/package.json | 2 +- packages/react-db/CHANGELOG.md | 13 +++++++++++++ packages/react-db/package.json | 2 +- packages/rxdb-db-collection/CHANGELOG.md | 7 +++++++ packages/rxdb-db-collection/package.json | 2 +- packages/solid-db/CHANGELOG.md | 13 +++++++++++++ packages/solid-db/package.json | 2 +- packages/svelte-db/CHANGELOG.md | 13 +++++++++++++ packages/svelte-db/package.json | 2 +- packages/trailbase-db-collection/CHANGELOG.md | 7 +++++++ packages/trailbase-db-collection/package.json | 2 +- packages/vue-db/CHANGELOG.md | 13 +++++++++++++ packages/vue-db/package.json | 2 +- 32 files changed, 154 insertions(+), 52 deletions(-) delete mode 100644 .changeset/fix-filter-expression-compile.md delete mode 100644 .changeset/fix-isready-disabled-queries.md delete mode 100644 .changeset/fix-object-field-update-rollback.md delete mode 100644 .changeset/fix-tanstack-db-peerdeps.md diff --git a/.changeset/fix-filter-expression-compile.md b/.changeset/fix-filter-expression-compile.md deleted file mode 100644 index 8d637937e..000000000 --- a/.changeset/fix-filter-expression-compile.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -"@tanstack/db": patch ---- - -fix(db): compile filter expression once in createFilterFunctionFromExpression - -Fixed a performance issue in `createFilterFunctionFromExpression` where the expression was being recompiled on every filter call. This only affected realtime change event filtering for pushed-down predicates at the collection level when using orderBy + limit. The core query engine was not affected as it already compiled predicates once. diff --git a/.changeset/fix-isready-disabled-queries.md b/.changeset/fix-isready-disabled-queries.md deleted file mode 100644 index 132902238..000000000 --- a/.changeset/fix-isready-disabled-queries.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -"@tanstack/react-db": patch -"@tanstack/solid-db": patch -"@tanstack/vue-db": patch -"@tanstack/svelte-db": patch -"@tanstack/angular-db": patch ---- - -Fixed `isReady` to return `true` for disabled queries in `useLiveQuery`/`injectLiveQuery` across all framework packages. When a query function returns `null` or `undefined` (disabling the query), there's no async operation to wait for, so the hook should be considered "ready" immediately. - -Additionally, all frameworks now have proper TypeScript overloads that explicitly support returning `undefined | null` from query functions, making the disabled query pattern type-safe. - -This fixes the common pattern where users conditionally enable queries and don't want to show loading states when the query is disabled. diff --git a/.changeset/fix-object-field-update-rollback.md b/.changeset/fix-object-field-update-rollback.md deleted file mode 100644 index ef2f3eb5c..000000000 --- a/.changeset/fix-object-field-update-rollback.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -"@tanstack/query-db-collection": patch -"@tanstack/db": patch ---- - -fix(query-db-collection): use deep equality for object field comparison in query observer - -Fixed an issue where updating object fields (non-primitives) with `refetch: false` in `onUpdate` handlers would cause the value to rollback to the previous state every other update. The query observer was using shallow equality (`===`) to compare items, which compares object properties by reference rather than by value. This caused the observer to incorrectly detect differences and write stale data back to syncedData. Now uses `deepEquals` for proper value comparison. diff --git a/.changeset/fix-tanstack-db-peerdeps.md b/.changeset/fix-tanstack-db-peerdeps.md deleted file mode 100644 index 26b0248bb..000000000 --- a/.changeset/fix-tanstack-db-peerdeps.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"@tanstack/query-db-collection": patch -"@tanstack/offline-transactions": patch ---- - -Use regular dependency for @tanstack/db instead of peerDependency to match the standard pattern used by other TanStack DB packages and prevent duplicate installations diff --git a/examples/react/offline-transactions/package.json b/examples/react/offline-transactions/package.json index 81c85c2ef..8d4cbfd08 100644 --- a/examples/react/offline-transactions/package.json +++ b/examples/react/offline-transactions/package.json @@ -9,9 +9,9 @@ "start": "node .output/server/index.mjs" }, "dependencies": { - "@tanstack/offline-transactions": ">=1.0.0", - "@tanstack/query-db-collection": ">=1.0.5", - "@tanstack/react-db": ">=0.1.54", + "@tanstack/offline-transactions": ">=1.0.1", + "@tanstack/query-db-collection": ">=1.0.6", + "@tanstack/react-db": ">=0.1.55", "@tanstack/react-query": "^5.90.11", "@tanstack/react-router": "^1.139.12", "@tanstack/react-router-devtools": "^1.139.12", diff --git a/examples/react/projects/package.json b/examples/react/projects/package.json index 8fb7374a4..e395d8a9f 100644 --- a/examples/react/projects/package.json +++ b/examples/react/projects/package.json @@ -17,8 +17,8 @@ "dependencies": { "@tailwindcss/vite": "^4.1.17", "@tanstack/query-core": "^5.90.11", - "@tanstack/query-db-collection": ">=1.0.5", - "@tanstack/react-db": ">=0.1.54", + "@tanstack/query-db-collection": ">=1.0.6", + "@tanstack/react-db": ">=0.1.55", "@tanstack/react-router": "^1.139.12", "@tanstack/react-router-devtools": "^1.139.12", "@tanstack/react-router-with-query": "^1.130.17", diff --git a/packages/angular-db/CHANGELOG.md b/packages/angular-db/CHANGELOG.md index 34feccfeb..12bf38dec 100644 --- a/packages/angular-db/CHANGELOG.md +++ b/packages/angular-db/CHANGELOG.md @@ -1,5 +1,18 @@ # @tanstack/angular-db +## 0.1.37 + +### Patch Changes + +- Fixed `isReady` to return `true` for disabled queries in `useLiveQuery`/`injectLiveQuery` across all framework packages. When a query function returns `null` or `undefined` (disabling the query), there's no async operation to wait for, so the hook should be considered "ready" immediately. ([#886](https://github.com/TanStack/db/pull/886)) + + Additionally, all frameworks now have proper TypeScript overloads that explicitly support returning `undefined | null` from query functions, making the disabled query pattern type-safe. + + This fixes the common pattern where users conditionally enable queries and don't want to show loading states when the query is disabled. + +- Updated dependencies [[`c4b9399`](https://github.com/TanStack/db/commit/c4b93997432743d974749683059bf68a082d3e5b), [`a1a484e`](https://github.com/TanStack/db/commit/a1a484ec4d2331d702ab9c4b7e5b02622c76b3dd)]: + - @tanstack/db@0.5.11 + ## 0.1.36 ### Patch Changes diff --git a/packages/angular-db/package.json b/packages/angular-db/package.json index d5e7f24dd..671de4367 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.36", + "version": "0.1.37", "author": "Ethan McDaniel", "license": "MIT", "repository": { diff --git a/packages/db-collection-e2e/CHANGELOG.md b/packages/db-collection-e2e/CHANGELOG.md index 00ff7f4a7..d30a8bf19 100644 --- a/packages/db-collection-e2e/CHANGELOG.md +++ b/packages/db-collection-e2e/CHANGELOG.md @@ -1,5 +1,14 @@ # @tanstack/db-collection-e2e +## 0.0.14 + +### Patch Changes + +- Updated dependencies [[`c4b9399`](https://github.com/TanStack/db/commit/c4b93997432743d974749683059bf68a082d3e5b), [`a1a484e`](https://github.com/TanStack/db/commit/a1a484ec4d2331d702ab9c4b7e5b02622c76b3dd), [`f458e05`](https://github.com/TanStack/db/commit/f458e05bb6f5b577ba1d1032a48b46cf860f3c9d)]: + - @tanstack/db@0.5.11 + - @tanstack/query-db-collection@1.0.6 + - @tanstack/electric-db-collection@0.2.12 + ## 0.0.13 ### Patch Changes diff --git a/packages/db-collection-e2e/package.json b/packages/db-collection-e2e/package.json index 7137b5910..a658c1cfe 100644 --- a/packages/db-collection-e2e/package.json +++ b/packages/db-collection-e2e/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/db-collection-e2e", - "version": "0.0.13", + "version": "0.0.14", "private": true, "description": "End-to-end test suite for TanStack DB collections", "type": "module", diff --git a/packages/db/CHANGELOG.md b/packages/db/CHANGELOG.md index 437efe2b7..111e5c57d 100644 --- a/packages/db/CHANGELOG.md +++ b/packages/db/CHANGELOG.md @@ -1,5 +1,17 @@ # @tanstack/db +## 0.5.11 + +### Patch Changes + +- fix(db): compile filter expression once in createFilterFunctionFromExpression ([#954](https://github.com/TanStack/db/pull/954)) + + Fixed a performance issue in `createFilterFunctionFromExpression` where the expression was being recompiled on every filter call. This only affected realtime change event filtering for pushed-down predicates at the collection level when using orderBy + limit. The core query engine was not affected as it already compiled predicates once. + +- fix(query-db-collection): use deep equality for object field comparison in query observer ([#967](https://github.com/TanStack/db/pull/967)) + + Fixed an issue where updating object fields (non-primitives) with `refetch: false` in `onUpdate` handlers would cause the value to rollback to the previous state every other update. The query observer was using shallow equality (`===`) to compare items, which compares object properties by reference rather than by value. This caused the observer to incorrectly detect differences and write stale data back to syncedData. Now uses `deepEquals` for proper value comparison. + ## 0.5.10 ### Patch Changes diff --git a/packages/db/package.json b/packages/db/package.json index a9cf4d7fb..b8d569f65 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.5.10", + "version": "0.5.11", "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 3dbbb8924..63bea6055 100644 --- a/packages/electric-db-collection/CHANGELOG.md +++ b/packages/electric-db-collection/CHANGELOG.md @@ -1,5 +1,12 @@ # @tanstack/electric-db-collection +## 0.2.12 + +### Patch Changes + +- Updated dependencies [[`c4b9399`](https://github.com/TanStack/db/commit/c4b93997432743d974749683059bf68a082d3e5b), [`a1a484e`](https://github.com/TanStack/db/commit/a1a484ec4d2331d702ab9c4b7e5b02622c76b3dd)]: + - @tanstack/db@0.5.11 + ## 0.2.11 ### Patch Changes diff --git a/packages/electric-db-collection/package.json b/packages/electric-db-collection/package.json index 7a4b7af9c..d07debd17 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.2.11", + "version": "0.2.12", "dependencies": { "@electric-sql/client": "^1.2.0", "@standard-schema/spec": "^1.0.0", diff --git a/packages/offline-transactions/CHANGELOG.md b/packages/offline-transactions/CHANGELOG.md index 0c12f3ce2..dacc07563 100644 --- a/packages/offline-transactions/CHANGELOG.md +++ b/packages/offline-transactions/CHANGELOG.md @@ -1,5 +1,14 @@ # @tanstack/offline-transactions +## 1.0.1 + +### Patch Changes + +- Use regular dependency for @tanstack/db instead of peerDependency to match the standard pattern used by other TanStack DB packages and prevent duplicate installations ([#952](https://github.com/TanStack/db/pull/952)) + +- Updated dependencies [[`c4b9399`](https://github.com/TanStack/db/commit/c4b93997432743d974749683059bf68a082d3e5b), [`a1a484e`](https://github.com/TanStack/db/commit/a1a484ec4d2331d702ab9c4b7e5b02622c76b3dd)]: + - @tanstack/db@0.5.11 + ## 1.0.0 ### Patch Changes diff --git a/packages/offline-transactions/package.json b/packages/offline-transactions/package.json index 23b3619a4..c5701d406 100644 --- a/packages/offline-transactions/package.json +++ b/packages/offline-transactions/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/offline-transactions", - "version": "1.0.0", + "version": "1.0.1", "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 64392d49a..ec84ad2bf 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.15 + +### Patch Changes + +- Updated dependencies [[`c4b9399`](https://github.com/TanStack/db/commit/c4b93997432743d974749683059bf68a082d3e5b), [`a1a484e`](https://github.com/TanStack/db/commit/a1a484ec4d2331d702ab9c4b7e5b02622c76b3dd)]: + - @tanstack/db@0.5.11 + ## 0.1.14 ### Patch Changes diff --git a/packages/powersync-db-collection/package.json b/packages/powersync-db-collection/package.json index 3fa99e04e..87444212b 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.14", + "version": "0.1.15", "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 c5f50f8f1..280ea645c 100644 --- a/packages/query-db-collection/CHANGELOG.md +++ b/packages/query-db-collection/CHANGELOG.md @@ -1,5 +1,18 @@ # @tanstack/query-db-collection +## 1.0.6 + +### Patch Changes + +- fix(query-db-collection): use deep equality for object field comparison in query observer ([#967](https://github.com/TanStack/db/pull/967)) + + Fixed an issue where updating object fields (non-primitives) with `refetch: false` in `onUpdate` handlers would cause the value to rollback to the previous state every other update. The query observer was using shallow equality (`===`) to compare items, which compares object properties by reference rather than by value. This caused the observer to incorrectly detect differences and write stale data back to syncedData. Now uses `deepEquals` for proper value comparison. + +- Use regular dependency for @tanstack/db instead of peerDependency to match the standard pattern used by other TanStack DB packages and prevent duplicate installations ([#952](https://github.com/TanStack/db/pull/952)) + +- Updated dependencies [[`c4b9399`](https://github.com/TanStack/db/commit/c4b93997432743d974749683059bf68a082d3e5b), [`a1a484e`](https://github.com/TanStack/db/commit/a1a484ec4d2331d702ab9c4b7e5b02622c76b3dd)]: + - @tanstack/db@0.5.11 + ## 1.0.5 ### Patch Changes diff --git a/packages/query-db-collection/package.json b/packages/query-db-collection/package.json index 43124de0a..aa0bdb7ea 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": "1.0.5", + "version": "1.0.6", "dependencies": { "@standard-schema/spec": "^1.0.0", "@tanstack/db": "workspace:*" diff --git a/packages/react-db/CHANGELOG.md b/packages/react-db/CHANGELOG.md index 9e71ef76d..0ce029709 100644 --- a/packages/react-db/CHANGELOG.md +++ b/packages/react-db/CHANGELOG.md @@ -1,5 +1,18 @@ # @tanstack/react-db +## 0.1.55 + +### Patch Changes + +- Fixed `isReady` to return `true` for disabled queries in `useLiveQuery`/`injectLiveQuery` across all framework packages. When a query function returns `null` or `undefined` (disabling the query), there's no async operation to wait for, so the hook should be considered "ready" immediately. ([#886](https://github.com/TanStack/db/pull/886)) + + Additionally, all frameworks now have proper TypeScript overloads that explicitly support returning `undefined | null` from query functions, making the disabled query pattern type-safe. + + This fixes the common pattern where users conditionally enable queries and don't want to show loading states when the query is disabled. + +- Updated dependencies [[`c4b9399`](https://github.com/TanStack/db/commit/c4b93997432743d974749683059bf68a082d3e5b), [`a1a484e`](https://github.com/TanStack/db/commit/a1a484ec4d2331d702ab9c4b7e5b02622c76b3dd)]: + - @tanstack/db@0.5.11 + ## 0.1.54 ### Patch Changes diff --git a/packages/react-db/package.json b/packages/react-db/package.json index 5bf8272c8..92c37b7f3 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.54", + "version": "0.1.55", "author": "Kyle Mathews", "license": "MIT", "repository": { diff --git a/packages/rxdb-db-collection/CHANGELOG.md b/packages/rxdb-db-collection/CHANGELOG.md index ec41bb803..7df583aa3 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.43 + +### Patch Changes + +- Updated dependencies [[`c4b9399`](https://github.com/TanStack/db/commit/c4b93997432743d974749683059bf68a082d3e5b), [`a1a484e`](https://github.com/TanStack/db/commit/a1a484ec4d2331d702ab9c4b7e5b02622c76b3dd)]: + - @tanstack/db@0.5.11 + ## 0.1.42 ### Patch Changes diff --git a/packages/rxdb-db-collection/package.json b/packages/rxdb-db-collection/package.json index 56b2504c2..25d6b129e 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.42", + "version": "0.1.43", "dependencies": { "rxdb": "16.21.0", "@standard-schema/spec": "^1.0.0", diff --git a/packages/solid-db/CHANGELOG.md b/packages/solid-db/CHANGELOG.md index ecacfad5f..507ca1942 100644 --- a/packages/solid-db/CHANGELOG.md +++ b/packages/solid-db/CHANGELOG.md @@ -1,5 +1,18 @@ # @tanstack/react-db +## 0.1.54 + +### Patch Changes + +- Fixed `isReady` to return `true` for disabled queries in `useLiveQuery`/`injectLiveQuery` across all framework packages. When a query function returns `null` or `undefined` (disabling the query), there's no async operation to wait for, so the hook should be considered "ready" immediately. ([#886](https://github.com/TanStack/db/pull/886)) + + Additionally, all frameworks now have proper TypeScript overloads that explicitly support returning `undefined | null` from query functions, making the disabled query pattern type-safe. + + This fixes the common pattern where users conditionally enable queries and don't want to show loading states when the query is disabled. + +- Updated dependencies [[`c4b9399`](https://github.com/TanStack/db/commit/c4b93997432743d974749683059bf68a082d3e5b), [`a1a484e`](https://github.com/TanStack/db/commit/a1a484ec4d2331d702ab9c4b7e5b02622c76b3dd)]: + - @tanstack/db@0.5.11 + ## 0.1.53 ### Patch Changes diff --git a/packages/solid-db/package.json b/packages/solid-db/package.json index 84b027be8..c8cb39cee 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.53", + "version": "0.1.54", "author": "Kyle Mathews", "license": "MIT", "repository": { diff --git a/packages/svelte-db/CHANGELOG.md b/packages/svelte-db/CHANGELOG.md index 846f70554..facfc25c5 100644 --- a/packages/svelte-db/CHANGELOG.md +++ b/packages/svelte-db/CHANGELOG.md @@ -1,5 +1,18 @@ # @tanstack/svelte-db +## 0.1.54 + +### Patch Changes + +- Fixed `isReady` to return `true` for disabled queries in `useLiveQuery`/`injectLiveQuery` across all framework packages. When a query function returns `null` or `undefined` (disabling the query), there's no async operation to wait for, so the hook should be considered "ready" immediately. ([#886](https://github.com/TanStack/db/pull/886)) + + Additionally, all frameworks now have proper TypeScript overloads that explicitly support returning `undefined | null` from query functions, making the disabled query pattern type-safe. + + This fixes the common pattern where users conditionally enable queries and don't want to show loading states when the query is disabled. + +- Updated dependencies [[`c4b9399`](https://github.com/TanStack/db/commit/c4b93997432743d974749683059bf68a082d3e5b), [`a1a484e`](https://github.com/TanStack/db/commit/a1a484ec4d2331d702ab9c4b7e5b02622c76b3dd)]: + - @tanstack/db@0.5.11 + ## 0.1.53 ### Patch Changes diff --git a/packages/svelte-db/package.json b/packages/svelte-db/package.json index 9a1bea95c..cfdd52669 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.53", + "version": "0.1.54", "dependencies": { "@tanstack/db": "workspace:*" }, diff --git a/packages/trailbase-db-collection/CHANGELOG.md b/packages/trailbase-db-collection/CHANGELOG.md index 0a3f128d1..0f3f4f256 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.55 + +### Patch Changes + +- Updated dependencies [[`c4b9399`](https://github.com/TanStack/db/commit/c4b93997432743d974749683059bf68a082d3e5b), [`a1a484e`](https://github.com/TanStack/db/commit/a1a484ec4d2331d702ab9c4b7e5b02622c76b3dd)]: + - @tanstack/db@0.5.11 + ## 0.1.54 ### Patch Changes diff --git a/packages/trailbase-db-collection/package.json b/packages/trailbase-db-collection/package.json index b227f99d4..9cc1f080a 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.54", + "version": "0.1.55", "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 63cc10379..2596b2115 100644 --- a/packages/vue-db/CHANGELOG.md +++ b/packages/vue-db/CHANGELOG.md @@ -1,5 +1,18 @@ # @tanstack/vue-db +## 0.0.87 + +### Patch Changes + +- Fixed `isReady` to return `true` for disabled queries in `useLiveQuery`/`injectLiveQuery` across all framework packages. When a query function returns `null` or `undefined` (disabling the query), there's no async operation to wait for, so the hook should be considered "ready" immediately. ([#886](https://github.com/TanStack/db/pull/886)) + + Additionally, all frameworks now have proper TypeScript overloads that explicitly support returning `undefined | null` from query functions, making the disabled query pattern type-safe. + + This fixes the common pattern where users conditionally enable queries and don't want to show loading states when the query is disabled. + +- Updated dependencies [[`c4b9399`](https://github.com/TanStack/db/commit/c4b93997432743d974749683059bf68a082d3e5b), [`a1a484e`](https://github.com/TanStack/db/commit/a1a484ec4d2331d702ab9c4b7e5b02622c76b3dd)]: + - @tanstack/db@0.5.11 + ## 0.0.86 ### Patch Changes diff --git a/packages/vue-db/package.json b/packages/vue-db/package.json index df2283445..a7bb974a3 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.86", + "version": "0.0.87", "author": "Kyle Mathews", "license": "MIT", "repository": { From 9dba1c17e16aa7fc39d99dd6d8e919226b545ea1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 4 Dec 2025 11:05:04 -0700 Subject: [PATCH 03/42] docs: regenerate API documentation (#969) Co-authored-by: github-actions[bot] --- .../reference/functions/injectLiveQuery.md | 64 +++++++- .../interfaces/InjectLiveQueryResult.md | 8 +- .../solid/reference/functions/useLiveQuery.md | 150 +++++++++++++++++- .../vue/reference/functions/useLiveQuery.md | 90 ++++++++++- docs/reference/functions/deepEquals.md | 45 ++++++ docs/reference/index.md | 1 + .../functions/queryCollectionOptions.md | 8 +- .../interfaces/QueryCollectionConfig.md | 22 +-- .../interfaces/QueryCollectionUtils.md | 32 ++-- 9 files changed, 378 insertions(+), 42 deletions(-) create mode 100644 docs/reference/functions/deepEquals.md diff --git a/docs/framework/angular/reference/functions/injectLiveQuery.md b/docs/framework/angular/reference/functions/injectLiveQuery.md index 4b3209aca..f5becd93c 100644 --- a/docs/framework/angular/reference/functions/injectLiveQuery.md +++ b/docs/framework/angular/reference/functions/injectLiveQuery.md @@ -42,7 +42,7 @@ Defined in: [index.ts:51](https://github.com/TanStack/db/blob/main/packages/angu ## Call Signature ```ts -function injectLiveQuery(queryFn): InjectLiveQueryResult<{ [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }>; +function injectLiveQuery(options): InjectLiveQueryResult<{ [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }>; ``` Defined in: [index.ts:61](https://github.com/TanStack/db/blob/main/packages/angular-db/src/index.ts#L61) @@ -53,6 +53,40 @@ Defined in: [index.ts:61](https://github.com/TanStack/db/blob/main/packages/angu `TContext` *extends* `Context` +#### TParams + +`TParams` *extends* `unknown` + +### Parameters + +#### options + +##### params + +() => `TParams` + +##### query + +(`args`) => `QueryBuilder`\<`TContext`\> \| `null` \| `undefined` + +### Returns + +[`InjectLiveQueryResult`](../../interfaces/InjectLiveQueryResult.md)\<\{ \[K in string \| number \| symbol\]: (TContext\["result"\] extends object ? any\[any\] : TContext\["hasJoins"\] extends true ? TContext\["schema"\] : TContext\["schema"\]\[TContext\["fromSourceName"\]\])\[K\] \}\> + +## Call Signature + +```ts +function injectLiveQuery(queryFn): InjectLiveQueryResult<{ [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }>; +``` + +Defined in: [index.ts:71](https://github.com/TanStack/db/blob/main/packages/angular-db/src/index.ts#L71) + +### Type Parameters + +#### TContext + +`TContext` *extends* `Context` + ### Parameters #### queryFn @@ -65,11 +99,35 @@ Defined in: [index.ts:61](https://github.com/TanStack/db/blob/main/packages/angu ## Call Signature +```ts +function injectLiveQuery(queryFn): InjectLiveQueryResult<{ [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }>; +``` + +Defined in: [index.ts:74](https://github.com/TanStack/db/blob/main/packages/angular-db/src/index.ts#L74) + +### Type Parameters + +#### TContext + +`TContext` *extends* `Context` + +### Parameters + +#### queryFn + +(`q`) => `QueryBuilder`\<`TContext`\> \| `null` \| `undefined` + +### Returns + +[`InjectLiveQueryResult`](../../interfaces/InjectLiveQueryResult.md)\<\{ \[K in string \| number \| symbol\]: (TContext\["result"\] extends object ? any\[any\] : TContext\["hasJoins"\] extends true ? TContext\["schema"\] : TContext\["schema"\]\[TContext\["fromSourceName"\]\])\[K\] \}\> + +## Call Signature + ```ts function injectLiveQuery(config): InjectLiveQueryResult<{ [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }>; ``` -Defined in: [index.ts:64](https://github.com/TanStack/db/blob/main/packages/angular-db/src/index.ts#L64) +Defined in: [index.ts:77](https://github.com/TanStack/db/blob/main/packages/angular-db/src/index.ts#L77) ### Type Parameters @@ -93,7 +151,7 @@ Defined in: [index.ts:64](https://github.com/TanStack/db/blob/main/packages/angu function injectLiveQuery(liveQueryCollection): InjectLiveQueryResult; ``` -Defined in: [index.ts:67](https://github.com/TanStack/db/blob/main/packages/angular-db/src/index.ts#L67) +Defined in: [index.ts:80](https://github.com/TanStack/db/blob/main/packages/angular-db/src/index.ts#L80) ### Type Parameters diff --git a/docs/framework/angular/reference/interfaces/InjectLiveQueryResult.md b/docs/framework/angular/reference/interfaces/InjectLiveQueryResult.md index aa45218bc..2e00287c2 100644 --- a/docs/framework/angular/reference/interfaces/InjectLiveQueryResult.md +++ b/docs/framework/angular/reference/interfaces/InjectLiveQueryResult.md @@ -30,12 +30,14 @@ Contains reactive signals for the query state and data. ### collection ```ts -collection: Signal, TResult>>; +collection: Signal< + | Collection, TResult> +| null>; ``` Defined in: [index.ts:36](https://github.com/TanStack/db/blob/main/packages/angular-db/src/index.ts#L36) -A signal containing the underlying collection instance +A signal containing the underlying collection instance (null for disabled queries) *** @@ -126,7 +128,7 @@ A signal containing the complete state map of results keyed by their ID ### status ```ts -status: Signal; +status: Signal; ``` Defined in: [index.ts:38](https://github.com/TanStack/db/blob/main/packages/angular-db/src/index.ts#L38) diff --git a/docs/framework/solid/reference/functions/useLiveQuery.md b/docs/framework/solid/reference/functions/useLiveQuery.md index 2291a4b34..4de59fe3f 100644 --- a/docs/framework/solid/reference/functions/useLiveQuery.md +++ b/docs/framework/solid/reference/functions/useLiveQuery.md @@ -11,7 +11,7 @@ title: useLiveQuery function useLiveQuery(queryFn): object; ``` -Defined in: [useLiveQuery.ts:80](https://github.com/TanStack/db/blob/main/packages/solid-db/src/useLiveQuery.ts#L80) +Defined in: [useLiveQuery.ts:84](https://github.com/TanStack/db/blob/main/packages/solid-db/src/useLiveQuery.ts#L84) Create a live query using a query function @@ -149,11 +149,155 @@ return ( ## Call Signature +```ts +function useLiveQuery(queryFn): object; +``` + +Defined in: [useLiveQuery.ts:99](https://github.com/TanStack/db/blob/main/packages/solid-db/src/useLiveQuery.ts#L99) + +Create a live query using a query function + +### Type Parameters + +#### TContext + +`TContext` *extends* `Context` + +### Parameters + +#### queryFn + +(`q`) => `QueryBuilder`\<`TContext`\> \| `null` \| `undefined` + +Query function that defines what data to fetch + +### Returns + +`object` + +Object with reactive data, state, and status information + +#### collection + +```ts +collection: Accessor< + | Collection<{ [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }, string | number, { +}, StandardSchemaV1, { [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }> +| null>; +``` + +#### data + +```ts +data: { [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }[]; +``` + +#### isCleanedUp + +```ts +isCleanedUp: Accessor; +``` + +#### isError + +```ts +isError: Accessor; +``` + +#### isIdle + +```ts +isIdle: Accessor; +``` + +#### isLoading + +```ts +isLoading: Accessor; +``` + +#### isReady + +```ts +isReady: Accessor; +``` + +#### state + +```ts +state: ReactiveMap; +``` + +#### status + +```ts +status: Accessor; +``` + +### Examples + +```ts +// Basic query with object syntax +const todosQuery = useLiveQuery((q) => + q.from({ todos: todosCollection }) + .where(({ todos }) => eq(todos.completed, false)) + .select(({ todos }) => ({ id: todos.id, text: todos.text })) +) +``` + +```ts +// With dependencies that trigger re-execution +const todosQuery = useLiveQuery( + (q) => q.from({ todos: todosCollection }) + .where(({ todos }) => gt(todos.priority, minPriority())), +) +``` + +```ts +// Join pattern +const personIssues = useLiveQuery((q) => + q.from({ issues: issueCollection }) + .join({ persons: personCollection }, ({ issues, persons }) => + eq(issues.userId, persons.id) + ) + .select(({ issues, persons }) => ({ + id: issues.id, + title: issues.title, + userName: persons.name + })) +) +``` + +```ts +// Handle loading and error states +const todosQuery = useLiveQuery((q) => + q.from({ todos: todoCollection }) +) + +return ( + + +
Loading...
+
+ +
Error: {todosQuery.status()}
+
+ + + {(todo) =>
  • {todo.text}
  • } +
    +
    +
    +) +``` + +## Call Signature + ```ts function useLiveQuery(config): object; ``` -Defined in: [useLiveQuery.ts:135](https://github.com/TanStack/db/blob/main/packages/solid-db/src/useLiveQuery.ts#L135) +Defined in: [useLiveQuery.ts:158](https://github.com/TanStack/db/blob/main/packages/solid-db/src/useLiveQuery.ts#L158) Create a live query using configuration object @@ -279,7 +423,7 @@ return ( function useLiveQuery(liveQueryCollection): object; ``` -Defined in: [useLiveQuery.ts:185](https://github.com/TanStack/db/blob/main/packages/solid-db/src/useLiveQuery.ts#L185) +Defined in: [useLiveQuery.ts:208](https://github.com/TanStack/db/blob/main/packages/solid-db/src/useLiveQuery.ts#L208) Subscribe to an existing live query collection diff --git a/docs/framework/vue/reference/functions/useLiveQuery.md b/docs/framework/vue/reference/functions/useLiveQuery.md index d233b05ed..b9a384cd8 100644 --- a/docs/framework/vue/reference/functions/useLiveQuery.md +++ b/docs/framework/vue/reference/functions/useLiveQuery.md @@ -93,11 +93,97 @@ const { data, isLoading, isError, status } = useLiveQuery((q) => ## Call Signature +```ts +function useLiveQuery(queryFn, deps?): UseLiveQueryReturn<{ [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }>; +``` + +Defined in: [useLiveQuery.ts:120](https://github.com/TanStack/db/blob/main/packages/vue-db/src/useLiveQuery.ts#L120) + +Create a live query using a query function + +### Type Parameters + +#### TContext + +`TContext` *extends* `Context` + +### Parameters + +#### queryFn + +(`q`) => `QueryBuilder`\<`TContext`\> \| `null` \| `undefined` + +Query function that defines what data to fetch + +#### deps? + +`unknown`[] + +Array of reactive dependencies that trigger query re-execution when changed + +### Returns + +[`UseLiveQueryReturn`](../../interfaces/UseLiveQueryReturn.md)\<\{ \[K in string \| number \| symbol\]: (TContext\["result"\] extends object ? any\[any\] : TContext\["hasJoins"\] extends true ? TContext\["schema"\] : TContext\["schema"\]\[TContext\["fromSourceName"\]\])\[K\] \}\> + +Reactive object with query data, state, and status information + +### Examples + +```ts +// Basic query with object syntax +const { data, isLoading } = useLiveQuery((q) => + q.from({ todos: todosCollection }) + .where(({ todos }) => eq(todos.completed, false)) + .select(({ todos }) => ({ id: todos.id, text: todos.text })) +) +``` + +```ts +// With reactive dependencies +const minPriority = ref(5) +const { data, state } = useLiveQuery( + (q) => q.from({ todos: todosCollection }) + .where(({ todos }) => gt(todos.priority, minPriority.value)), + [minPriority] // Re-run when minPriority changes +) +``` + +```ts +// Join pattern +const { data } = useLiveQuery((q) => + q.from({ issues: issueCollection }) + .join({ persons: personCollection }, ({ issues, persons }) => + eq(issues.userId, persons.id) + ) + .select(({ issues, persons }) => ({ + id: issues.id, + title: issues.title, + userName: persons.name + })) +) +``` + +```ts +// Handle loading and error states in template +const { data, isLoading, isError, status } = useLiveQuery((q) => + q.from({ todos: todoCollection }) +) + +// In template: +//
    Loading...
    +//
    Error: {{ status }}
    +//
      +//
    • {{ todo.text }}
    • +//
    +``` + +## Call Signature + ```ts function useLiveQuery(config, deps?): UseLiveQueryReturn<{ [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }>; ``` -Defined in: [useLiveQuery.ts:152](https://github.com/TanStack/db/blob/main/packages/vue-db/src/useLiveQuery.ts#L152) +Defined in: [useLiveQuery.ts:160](https://github.com/TanStack/db/blob/main/packages/vue-db/src/useLiveQuery.ts#L160) Create a live query using configuration object @@ -165,7 +251,7 @@ const { data, isLoading, isReady, isError } = useLiveQuery({ function useLiveQuery(liveQueryCollection): UseLiveQueryReturnWithCollection; ``` -Defined in: [useLiveQuery.ts:197](https://github.com/TanStack/db/blob/main/packages/vue-db/src/useLiveQuery.ts#L197) +Defined in: [useLiveQuery.ts:205](https://github.com/TanStack/db/blob/main/packages/vue-db/src/useLiveQuery.ts#L205) Subscribe to an existing query collection (can be reactive) diff --git a/docs/reference/functions/deepEquals.md b/docs/reference/functions/deepEquals.md new file mode 100644 index 000000000..c95964693 --- /dev/null +++ b/docs/reference/functions/deepEquals.md @@ -0,0 +1,45 @@ +--- +id: deepEquals +title: deepEquals +--- + +# Function: deepEquals() + +```ts +function deepEquals(a, b): boolean; +``` + +Defined in: [packages/db/src/utils.ts:29](https://github.com/TanStack/db/blob/main/packages/db/src/utils.ts#L29) + +Deep equality function that compares two values recursively +Handles primitives, objects, arrays, Date, RegExp, Map, Set, TypedArrays, and Temporal objects + +## Parameters + +### a + +`any` + +First value to compare + +### b + +`any` + +Second value to compare + +## Returns + +`boolean` + +True if the values are deeply equal, false otherwise + +## Example + +```typescript +deepEquals({ a: 1, b: 2 }, { b: 2, a: 1 }) // true (property order doesn't matter) +deepEquals([1, { x: 2 }], [1, { x: 2 }]) // true +deepEquals({ a: 1 }, { a: 2 }) // false +deepEquals(new Date('2023-01-01'), new Date('2023-01-01')) // true +deepEquals(new Map([['a', 1]]), new Map([['a', 1]])) // true +``` diff --git a/docs/reference/index.md b/docs/reference/index.md index a04fc672b..fa0ec0312 100644 --- a/docs/reference/index.md +++ b/docs/reference/index.md @@ -236,6 +236,7 @@ title: "@tanstack/db" - [createPacedMutations](../functions/createPacedMutations.md) - [createTransaction](../functions/createTransaction.md) - [debounceStrategy](../functions/debounceStrategy.md) +- [deepEquals](../functions/deepEquals.md) - [eq](../functions/eq.md) - [extractFieldPath](../functions/extractFieldPath.md) - [extractSimpleComparisons](../functions/extractSimpleComparisons.md) diff --git a/docs/reference/query-db-collection/functions/queryCollectionOptions.md b/docs/reference/query-db-collection/functions/queryCollectionOptions.md index 36fe817f4..b8a20f242 100644 --- a/docs/reference/query-db-collection/functions/queryCollectionOptions.md +++ b/docs/reference/query-db-collection/functions/queryCollectionOptions.md @@ -11,7 +11,7 @@ title: queryCollectionOptions function queryCollectionOptions(config): CollectionConfig, TKey, T, QueryCollectionUtils, TKey, InferSchemaInput, TError>> & object; ``` -Defined in: [packages/query-db-collection/src/query.ts:393](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L393) +Defined in: [packages/query-db-collection/src/query.ts:394](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L394) Creates query collection options for use with a standard Collection. This integrates TanStack Query with TanStack DB for automatic synchronization. @@ -151,7 +151,7 @@ const todosCollection = createCollection( function queryCollectionOptions(config): CollectionConfig> & object; ``` -Defined in: [packages/query-db-collection/src/query.ts:428](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L428) +Defined in: [packages/query-db-collection/src/query.ts:429](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L429) Creates query collection options for use with a standard Collection. This integrates TanStack Query with TanStack DB for automatic synchronization. @@ -291,7 +291,7 @@ const todosCollection = createCollection( function queryCollectionOptions(config): CollectionConfig, TKey, T, QueryCollectionUtils, TKey, InferSchemaInput, TError>> & object; ``` -Defined in: [packages/query-db-collection/src/query.ts:461](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L461) +Defined in: [packages/query-db-collection/src/query.ts:462](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L462) Creates query collection options for use with a standard Collection. This integrates TanStack Query with TanStack DB for automatic synchronization. @@ -423,7 +423,7 @@ const todosCollection = createCollection( function queryCollectionOptions(config): CollectionConfig> & object; ``` -Defined in: [packages/query-db-collection/src/query.ts:495](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L495) +Defined in: [packages/query-db-collection/src/query.ts:496](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L496) Creates query collection options for use with a standard Collection. This integrates TanStack Query with TanStack DB for automatic synchronization. diff --git a/docs/reference/query-db-collection/interfaces/QueryCollectionConfig.md b/docs/reference/query-db-collection/interfaces/QueryCollectionConfig.md index f2c1b8498..710db1ee9 100644 --- a/docs/reference/query-db-collection/interfaces/QueryCollectionConfig.md +++ b/docs/reference/query-db-collection/interfaces/QueryCollectionConfig.md @@ -5,7 +5,7 @@ title: QueryCollectionConfig # Interface: QueryCollectionConfig\ -Defined in: [packages/query-db-collection/src/query.ts:59](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L59) +Defined in: [packages/query-db-collection/src/query.ts:60](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L60) Configuration options for creating a Query Collection @@ -63,7 +63,7 @@ The schema type for validation optional enabled: boolean; ``` -Defined in: [packages/query-db-collection/src/query.ts:85](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L85) +Defined in: [packages/query-db-collection/src/query.ts:86](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L86) Whether the query should automatically run (default: true) @@ -75,7 +75,7 @@ Whether the query should automatically run (default: true) optional meta: Record; ``` -Defined in: [packages/query-db-collection/src/query.ts:135](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L135) +Defined in: [packages/query-db-collection/src/query.ts:136](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L136) Metadata to pass to the query. Available in queryFn via context.meta @@ -107,7 +107,7 @@ meta: { queryClient: QueryClient; ``` -Defined in: [packages/query-db-collection/src/query.ts:81](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L81) +Defined in: [packages/query-db-collection/src/query.ts:82](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L82) The TanStack Query client instance @@ -119,7 +119,7 @@ The TanStack Query client instance queryFn: TQueryFn extends (context) => Promise ? (context) => Promise : TQueryFn; ``` -Defined in: [packages/query-db-collection/src/query.ts:73](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L73) +Defined in: [packages/query-db-collection/src/query.ts:74](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L74) Function that fetches data from the server. Must return the complete collection state @@ -131,7 +131,7 @@ Function that fetches data from the server. Must return the complete collection queryKey: TQueryKey | TQueryKeyBuilder; ``` -Defined in: [packages/query-db-collection/src/query.ts:71](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L71) +Defined in: [packages/query-db-collection/src/query.ts:72](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L72) The query key used by TanStack Query to identify this query @@ -143,7 +143,7 @@ The query key used by TanStack Query to identify this query optional refetchInterval: number | false | (query) => number | false | undefined; ``` -Defined in: [packages/query-db-collection/src/query.ts:86](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L86) +Defined in: [packages/query-db-collection/src/query.ts:87](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L87) *** @@ -153,7 +153,7 @@ Defined in: [packages/query-db-collection/src/query.ts:86](https://github.com/Ta optional retry: RetryValue; ``` -Defined in: [packages/query-db-collection/src/query.ts:93](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L93) +Defined in: [packages/query-db-collection/src/query.ts:94](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L94) *** @@ -163,7 +163,7 @@ Defined in: [packages/query-db-collection/src/query.ts:93](https://github.com/Ta optional retryDelay: RetryDelayValue; ``` -Defined in: [packages/query-db-collection/src/query.ts:100](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L100) +Defined in: [packages/query-db-collection/src/query.ts:101](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L101) *** @@ -173,7 +173,7 @@ Defined in: [packages/query-db-collection/src/query.ts:100](https://github.com/T optional select: (data) => T[]; ``` -Defined in: [packages/query-db-collection/src/query.ts:79](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L79) +Defined in: [packages/query-db-collection/src/query.ts:80](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L80) #### Parameters @@ -193,4 +193,4 @@ Defined in: [packages/query-db-collection/src/query.ts:79](https://github.com/Ta optional staleTime: StaleTimeFunction; ``` -Defined in: [packages/query-db-collection/src/query.ts:107](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L107) +Defined in: [packages/query-db-collection/src/query.ts:108](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L108) diff --git a/docs/reference/query-db-collection/interfaces/QueryCollectionUtils.md b/docs/reference/query-db-collection/interfaces/QueryCollectionUtils.md index 47cb7ea56..2385eca11 100644 --- a/docs/reference/query-db-collection/interfaces/QueryCollectionUtils.md +++ b/docs/reference/query-db-collection/interfaces/QueryCollectionUtils.md @@ -5,7 +5,7 @@ title: QueryCollectionUtils # Interface: QueryCollectionUtils\ -Defined in: [packages/query-db-collection/src/query.ts:154](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L154) +Defined in: [packages/query-db-collection/src/query.ts:155](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L155) Utility methods available on Query Collections for direct writes and manual operations. Direct writes bypass the normal query/mutation flow and write directly to the synced data store. @@ -54,7 +54,7 @@ The type of errors that can occur during queries clearError: () => Promise; ``` -Defined in: [packages/query-db-collection/src/query.ts:199](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L199) +Defined in: [packages/query-db-collection/src/query.ts:200](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L200) Clear the error state and trigger a refetch of the query @@ -76,7 +76,7 @@ Error if the refetch fails dataUpdatedAt: number; ``` -Defined in: [packages/query-db-collection/src/query.ts:190](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L190) +Defined in: [packages/query-db-collection/src/query.ts:191](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L191) Get timestamp of last successful data update (in milliseconds) @@ -88,7 +88,7 @@ Get timestamp of last successful data update (in milliseconds) errorCount: number; ``` -Defined in: [packages/query-db-collection/src/query.ts:182](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L182) +Defined in: [packages/query-db-collection/src/query.ts:183](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L183) Get the number of consecutive sync failures. Incremented only when query fails completely (not per retry attempt); reset on success. @@ -101,7 +101,7 @@ Incremented only when query fails completely (not per retry attempt); reset on s fetchStatus: "idle" | "fetching" | "paused"; ``` -Defined in: [packages/query-db-collection/src/query.ts:192](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L192) +Defined in: [packages/query-db-collection/src/query.ts:193](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L193) Get current fetch status @@ -113,7 +113,7 @@ Get current fetch status isError: boolean; ``` -Defined in: [packages/query-db-collection/src/query.ts:177](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L177) +Defined in: [packages/query-db-collection/src/query.ts:178](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L178) Check if the collection is in an error state @@ -125,7 +125,7 @@ Check if the collection is in an error state isFetching: boolean; ``` -Defined in: [packages/query-db-collection/src/query.ts:184](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L184) +Defined in: [packages/query-db-collection/src/query.ts:185](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L185) Check if query is currently fetching (initial or background) @@ -137,7 +137,7 @@ Check if query is currently fetching (initial or background) isLoading: boolean; ``` -Defined in: [packages/query-db-collection/src/query.ts:188](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L188) +Defined in: [packages/query-db-collection/src/query.ts:189](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L189) Check if query is loading for the first time (no data yet) @@ -149,7 +149,7 @@ Check if query is loading for the first time (no data yet) isRefetching: boolean; ``` -Defined in: [packages/query-db-collection/src/query.ts:186](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L186) +Defined in: [packages/query-db-collection/src/query.ts:187](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L187) Check if query is refetching in background (not initial fetch) @@ -161,7 +161,7 @@ Check if query is refetching in background (not initial fetch) lastError: TError | undefined; ``` -Defined in: [packages/query-db-collection/src/query.ts:175](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L175) +Defined in: [packages/query-db-collection/src/query.ts:176](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L176) Get the last error encountered by the query (if any); reset on success @@ -173,7 +173,7 @@ Get the last error encountered by the query (if any); reset on success refetch: RefetchFn; ``` -Defined in: [packages/query-db-collection/src/query.ts:161](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L161) +Defined in: [packages/query-db-collection/src/query.ts:162](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L162) Manually trigger a refetch of the query @@ -185,7 +185,7 @@ Manually trigger a refetch of the query writeBatch: (callback) => void; ``` -Defined in: [packages/query-db-collection/src/query.ts:171](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L171) +Defined in: [packages/query-db-collection/src/query.ts:172](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L172) Execute multiple write operations as a single atomic batch to the synced data store @@ -207,7 +207,7 @@ Execute multiple write operations as a single atomic batch to the synced data st writeDelete: (keys) => void; ``` -Defined in: [packages/query-db-collection/src/query.ts:167](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L167) +Defined in: [packages/query-db-collection/src/query.ts:168](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L168) Delete one or more items directly from the synced data store without triggering a query refetch or optimistic update @@ -229,7 +229,7 @@ Delete one or more items directly from the synced data store without triggering writeInsert: (data) => void; ``` -Defined in: [packages/query-db-collection/src/query.ts:163](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L163) +Defined in: [packages/query-db-collection/src/query.ts:164](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L164) Insert one or more items directly into the synced data store without triggering a query refetch or optimistic update @@ -251,7 +251,7 @@ Insert one or more items directly into the synced data store without triggering writeUpdate: (updates) => void; ``` -Defined in: [packages/query-db-collection/src/query.ts:165](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L165) +Defined in: [packages/query-db-collection/src/query.ts:166](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L166) Update one or more items directly in the synced data store without triggering a query refetch or optimistic update @@ -273,7 +273,7 @@ Update one or more items directly in the synced data store without triggering a writeUpsert: (data) => void; ``` -Defined in: [packages/query-db-collection/src/query.ts:169](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L169) +Defined in: [packages/query-db-collection/src/query.ts:170](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L170) Insert or update one or more items directly in the synced data store without triggering a query refetch or optimistic update From 8a6a2a2188d3a6848bb0eee23f5a8abfe2a31687 Mon Sep 17 00:00:00 2001 From: Lachlan Collins <1667261+lachlancollins@users.noreply.github.com> Date: Fri, 5 Dec 2025 20:49:52 +1100 Subject: [PATCH 04/42] ci: run prettier autofix action (#972) * ci: prettier auto-fix * Sync prettier config with other TanStack projects * Fix lockfile --- .github/ISSUE_TEMPLATE/bug_report.md | 6 +- .github/workflows/autofix.yml | 6 +- .github/workflows/docs-sync.yml | 2 +- .github/workflows/e2e-tests.yml | 4 +- .github/workflows/pr.yml | 16 +- .github/workflows/release.yml | 4 +- .pnpmfile.cjs | 12 +- .prettierrc | 5 - AGENTS.md | 20 +- eslint.config.js | 26 +- examples/angular/todos/src/app/app.config.ts | 8 +- examples/angular/todos/src/app/app.routes.ts | 4 +- examples/angular/todos/src/app/app.ts | 36 +-- .../todos/src/collections/todos-collection.ts | 14 +- examples/angular/todos/src/main.ts | 8 +- examples/angular/todos/tailwind.config.js | 2 +- .../src/components/DefaultCatchBoundary.tsx | 4 +- .../src/components/NotFound.tsx | 2 +- .../src/components/TodoDemo.tsx | 8 +- .../offline-transactions/src/db/todos.ts | 40 ++-- .../react/offline-transactions/src/router.tsx | 10 +- .../src/routes/__root.tsx | 18 +- .../src/routes/api/todos.$todoId.ts | 12 +- .../src/routes/api/todos.ts | 10 +- .../src/routes/api/users.$userId.ts | 8 +- .../src/routes/api/users.ts | 10 +- .../offline-transactions/src/routes/index.tsx | 2 +- .../src/routes/indexeddb.tsx | 8 +- .../src/routes/localstorage.tsx | 8 +- .../src/utils/loggingMiddleware.tsx | 2 +- .../src/utils/queryClient.ts | 2 +- .../offline-transactions/src/utils/todos.ts | 2 +- .../offline-transactions/tailwind.config.mjs | 2 +- .../react/offline-transactions/vite.config.ts | 14 +- .../react/paced-mutations-demo/src/App.tsx | 16 +- .../react/paced-mutations-demo/src/index.css | 10 +- .../react/paced-mutations-demo/src/main.tsx | 10 +- .../react/paced-mutations-demo/vite.config.ts | 4 +- examples/react/projects/README.md | 32 +-- examples/react/projects/docker-compose.yaml | 4 +- examples/react/projects/drizzle.config.ts | 4 +- examples/react/projects/eslint.config.mjs | 38 +-- examples/react/projects/src/db/auth-schema.ts | 82 +++---- examples/react/projects/src/db/connection.ts | 4 +- examples/react/projects/src/db/schema.ts | 26 +- .../react/projects/src/lib/auth-client.ts | 2 +- examples/react/projects/src/lib/auth.ts | 16 +- .../react/projects/src/lib/collections.ts | 22 +- .../react/projects/src/lib/trpc-client.ts | 8 +- examples/react/projects/src/lib/trpc.ts | 8 +- .../react/projects/src/lib/trpc/projects.ts | 22 +- examples/react/projects/src/lib/trpc/todos.ts | 18 +- examples/react/projects/src/lib/trpc/users.ts | 14 +- examples/react/projects/src/router.tsx | 6 +- examples/react/projects/src/routes/__root.tsx | 8 +- .../projects/src/routes/_authenticated.tsx | 10 +- .../src/routes/_authenticated/index.tsx | 10 +- .../_authenticated/project/$projectId.tsx | 12 +- .../react/projects/src/routes/api/auth.ts | 4 +- .../react/projects/src/routes/api/trpc/$.ts | 16 +- examples/react/projects/src/routes/login.tsx | 8 +- examples/react/projects/src/start.tsx | 2 +- examples/react/projects/src/styles.css | 8 +- examples/react/projects/vite.config.ts | 10 +- examples/react/todo/docker-compose.yml | 10 +- examples/react/todo/drizzle.config.ts | 2 +- examples/react/todo/scripts/migrate.ts | 8 +- examples/react/todo/src/api/server.ts | 12 +- .../react/todo/src/components/NotFound.tsx | 2 +- .../react/todo/src/components/TodoApp.tsx | 18 +- examples/react/todo/src/db/index.ts | 6 +- examples/react/todo/src/db/postgres.ts | 2 +- examples/react/todo/src/db/schema.ts | 2 +- examples/react/todo/src/db/validation.ts | 6 +- examples/react/todo/src/index.css | 4 +- examples/react/todo/src/lib/api.ts | 20 +- examples/react/todo/src/lib/collections.ts | 42 ++-- examples/react/todo/src/main.tsx | 12 +- examples/react/todo/src/router.tsx | 8 +- examples/react/todo/src/routes/__root.tsx | 6 +- .../react/todo/src/routes/api/config.$id.ts | 16 +- examples/react/todo/src/routes/api/config.ts | 14 +- .../react/todo/src/routes/api/todos.$id.ts | 16 +- examples/react/todo/src/routes/api/todos.ts | 14 +- examples/react/todo/src/routes/electric.tsx | 22 +- examples/react/todo/src/routes/index.tsx | 4 +- examples/react/todo/src/routes/query.tsx | 22 +- examples/react/todo/src/routes/trailbase.tsx | 14 +- examples/react/todo/src/server.ts | 2 +- examples/react/todo/src/start.tsx | 2 +- examples/react/todo/src/styles.css | 8 +- examples/react/todo/vite.config.ts | 10 +- examples/solid/todo/docker-compose.yml | 10 +- examples/solid/todo/drizzle.config.ts | 2 +- examples/solid/todo/scripts/migrate.ts | 8 +- examples/solid/todo/src/api/server.ts | 12 +- .../solid/todo/src/components/NotFound.tsx | 2 +- .../solid/todo/src/components/TodoApp.tsx | 18 +- examples/solid/todo/src/db/index.ts | 6 +- examples/solid/todo/src/db/postgres.ts | 2 +- examples/solid/todo/src/db/schema.ts | 2 +- examples/solid/todo/src/db/validation.ts | 6 +- examples/solid/todo/src/index.css | 4 +- examples/solid/todo/src/lib/api.ts | 20 +- examples/solid/todo/src/lib/collections.ts | 42 ++-- examples/solid/todo/src/main.tsx | 10 +- examples/solid/todo/src/router.tsx | 10 +- examples/solid/todo/src/routes/__root.tsx | 4 +- .../solid/todo/src/routes/api/config.$id.ts | 16 +- examples/solid/todo/src/routes/api/config.ts | 14 +- .../solid/todo/src/routes/api/todos.$id.ts | 16 +- examples/solid/todo/src/routes/api/todos.ts | 14 +- examples/solid/todo/src/routes/electric.tsx | 12 +- examples/solid/todo/src/routes/index.tsx | 2 +- examples/solid/todo/src/routes/query.tsx | 12 +- examples/solid/todo/src/routes/trailbase.tsx | 12 +- examples/solid/todo/src/styles.css | 8 +- examples/solid/todo/vite.config.ts | 10 +- package.json | 9 +- packages/angular-db/src/index.ts | 24 +- .../tests/inject-live-query.test.ts | 68 +++--- packages/angular-db/tests/test-setup.ts | 10 +- packages/angular-db/vite.config.ts | 8 +- packages/db-collection-e2e/README.md | 46 ++-- .../docker/docker-compose.yml | 10 +- .../src/fixtures/seed-data.ts | 4 +- .../src/fixtures/test-schema.ts | 4 +- packages/db-collection-e2e/src/index.ts | 28 +-- .../src/suites/collation.suite.ts | 16 +- .../src/suites/deduplication.suite.ts | 60 ++--- .../src/suites/joins.suite.ts | 54 ++--- .../src/suites/live-updates.suite.ts | 30 +-- .../src/suites/mutations.suite.ts | 28 +-- .../src/suites/pagination.suite.ts | 44 ++-- .../src/suites/predicates.suite.ts | 128 +++++----- .../src/suites/progressive.suite.ts | 42 ++-- packages/db-collection-e2e/src/types.ts | 4 +- .../db-collection-e2e/src/utils/assertions.ts | 40 ++-- .../db-collection-e2e/src/utils/helpers.ts | 24 +- .../db-collection-e2e/support/global-setup.ts | 52 ++-- .../db-collection-e2e/support/test-context.ts | 52 ++-- packages/db-collection-e2e/vite.config.ts | 12 +- packages/db-ivm/CHANGELOG.md | 4 +- packages/db-ivm/README.md | 6 +- packages/db-ivm/src/d2.ts | 8 +- packages/db-ivm/src/graph.ts | 12 +- packages/db-ivm/src/hashing/hash.ts | 6 +- packages/db-ivm/src/hashing/index.ts | 4 +- packages/db-ivm/src/index.ts | 8 +- packages/db-ivm/src/indexes.ts | 16 +- packages/db-ivm/src/multiset.ts | 10 +- packages/db-ivm/src/operators/concat.ts | 12 +- packages/db-ivm/src/operators/consolidate.ts | 12 +- packages/db-ivm/src/operators/count.ts | 18 +- packages/db-ivm/src/operators/debug.ts | 16 +- packages/db-ivm/src/operators/distinct.ts | 22 +- packages/db-ivm/src/operators/filter.ts | 16 +- packages/db-ivm/src/operators/filterBy.ts | 14 +- packages/db-ivm/src/operators/groupBy.ts | 44 ++-- packages/db-ivm/src/operators/index.ts | 38 +-- packages/db-ivm/src/operators/join.ts | 46 ++-- packages/db-ivm/src/operators/keying.ts | 8 +- packages/db-ivm/src/operators/map.ts | 16 +- packages/db-ivm/src/operators/negate.ts | 12 +- packages/db-ivm/src/operators/orderBy.ts | 52 ++-- packages/db-ivm/src/operators/orderByBTree.ts | 14 +- packages/db-ivm/src/operators/output.ts | 18 +- packages/db-ivm/src/operators/pipe.ts | 2 +- packages/db-ivm/src/operators/reduce.ts | 18 +- packages/db-ivm/src/operators/tap.ts | 16 +- packages/db-ivm/src/operators/topK.ts | 16 +- .../src/operators/topKWithFractionalIndex.ts | 48 ++-- .../operators/topKWithFractionalIndexBTree.ts | 32 +-- packages/db-ivm/src/types.ts | 44 ++-- packages/db-ivm/src/utils.ts | 8 +- packages/db-ivm/tests/graph.test.ts | 8 +- packages/db-ivm/tests/indexes.test.ts | 4 +- packages/db-ivm/tests/multiset.test.ts | 4 +- .../db-ivm/tests/operators/concat.test.ts | 32 +-- .../tests/operators/consolidate.test.ts | 30 +-- packages/db-ivm/tests/operators/count.test.ts | 42 ++-- packages/db-ivm/tests/operators/debug.test.ts | 20 +- .../db-ivm/tests/operators/distinct.test.ts | 46 ++-- .../db-ivm/tests/operators/filter.test.ts | 20 +- .../db-ivm/tests/operators/filterBy.test.ts | 44 ++-- .../db-ivm/tests/operators/groupBy.test.ts | 96 ++++---- .../db-ivm/tests/operators/join-types.test.ts | 90 +++---- packages/db-ivm/tests/operators/join.test.ts | 66 +++--- .../tests/operators/keying-types.test.ts | 10 +- .../db-ivm/tests/operators/keying.test.ts | 10 +- packages/db-ivm/tests/operators/map.test.ts | 20 +- .../db-ivm/tests/operators/negate.test.ts | 24 +- .../db-ivm/tests/operators/orderBy.test.ts | 58 ++--- .../orderByWithFractionalIndex.test.ts | 128 +++++----- .../tests/operators/orderByWithIndex.test.ts | 60 ++--- .../db-ivm/tests/operators/output.test.ts | 16 +- packages/db-ivm/tests/operators/pipe.test.ts | 14 +- .../db-ivm/tests/operators/reduce.test.ts | 96 ++++---- packages/db-ivm/tests/operators/topK.test.ts | 64 ++--- .../operators/topKWithFractionalIndex.test.ts | 218 ++++++++--------- .../tests/operators/topKWithIndex.test.ts | 58 ++--- packages/db-ivm/tests/test-utils.ts | 40 ++-- packages/db-ivm/tests/utils.test.ts | 6 +- packages/db-ivm/vite.config.ts | 8 +- packages/db/CHANGELOG.md | 56 ++--- packages/db/src/SortedMap.ts | 2 +- packages/db/src/collection/change-events.ts | 40 ++-- packages/db/src/collection/changes.ts | 24 +- packages/db/src/collection/events.ts | 20 +- packages/db/src/collection/index.ts | 92 +++---- packages/db/src/collection/indexes.ts | 28 +-- packages/db/src/collection/lifecycle.ts | 32 +-- packages/db/src/collection/mutations.ts | 36 +-- packages/db/src/collection/state.ts | 58 ++--- packages/db/src/collection/subscription.ts | 30 +-- packages/db/src/collection/sync.ts | 26 +- packages/db/src/duplicate-instance-check.ts | 2 +- packages/db/src/errors.ts | 80 +++---- packages/db/src/event-emitter.ts | 10 +- packages/db/src/index.ts | 42 ++-- packages/db/src/indexes/auto-index.ts | 22 +- packages/db/src/indexes/base-index.ts | 26 +- packages/db/src/indexes/btree-index.ts | 24 +- packages/db/src/indexes/index-options.ts | 6 +- packages/db/src/indexes/lazy-index.ts | 16 +- packages/db/src/indexes/reverse-index.ts | 10 +- packages/db/src/local-only.ts | 24 +- packages/db/src/local-storage.ts | 34 +-- packages/db/src/optimistic-action.ts | 10 +- packages/db/src/paced-mutations.ts | 12 +- packages/db/src/proxy.ts | 86 +++---- packages/db/src/query/builder/functions.ts | 56 ++--- packages/db/src/query/builder/index.ts | 44 ++-- packages/db/src/query/builder/ref-proxy.ts | 8 +- packages/db/src/query/builder/types.ts | 16 +- packages/db/src/query/compiler/evaluators.ts | 18 +- packages/db/src/query/compiler/expressions.ts | 12 +- packages/db/src/query/compiler/group-by.ts | 48 ++-- packages/db/src/query/compiler/index.ts | 88 +++---- packages/db/src/query/compiler/joins.ts | 74 +++--- packages/db/src/query/compiler/order-by.ts | 56 ++--- packages/db/src/query/compiler/select.ts | 26 +- packages/db/src/query/compiler/types.ts | 4 +- packages/db/src/query/expression-helpers.ts | 32 +-- packages/db/src/query/index.ts | 18 +- packages/db/src/query/ir.ts | 26 +- .../db/src/query/live-query-collection.ts | 30 +-- .../query/live/collection-config-builder.ts | 106 ++++----- .../db/src/query/live/collection-registry.ts | 12 +- .../src/query/live/collection-subscriber.ts | 58 ++--- packages/db/src/query/live/internal.ts | 2 +- packages/db/src/query/live/types.ts | 8 +- packages/db/src/query/optimizer.ts | 58 ++--- packages/db/src/query/predicate-utils.ts | 88 +++---- packages/db/src/query/subset-dedupe.ts | 12 +- packages/db/src/scheduler.ts | 6 +- .../db/src/strategies/debounceStrategy.ts | 12 +- packages/db/src/strategies/index.ts | 8 +- packages/db/src/strategies/queueStrategy.ts | 10 +- .../db/src/strategies/throttleStrategy.ts | 12 +- packages/db/src/strategies/types.ts | 4 +- packages/db/src/transactions.ts | 18 +- packages/db/src/types.ts | 22 +- packages/db/src/utils.ts | 8 +- packages/db/src/utils/array-utils.ts | 2 +- packages/db/src/utils/browser-polyfills.ts | 4 +- packages/db/src/utils/btree.ts | 44 ++-- packages/db/src/utils/comparison.ts | 6 +- packages/db/src/utils/index-optimization.ts | 28 +-- packages/db/tests/SortedMap.test.ts | 4 +- packages/db/tests/apply-mutations.test.ts | 6 +- .../db/tests/collection-auto-index.test.ts | 40 ++-- .../db/tests/collection-change-events.test.ts | 40 ++-- packages/db/tests/collection-errors.test.ts | 61 ++--- packages/db/tests/collection-events.test.ts | 8 +- packages/db/tests/collection-getters.test.ts | 20 +- packages/db/tests/collection-indexes.test.ts | 80 +++---- .../db/tests/collection-lifecycle.test.ts | 4 +- packages/db/tests/collection-schema.test.ts | 56 ++--- .../collection-subscribe-changes.test.ts | 50 ++-- .../db/tests/collection-subscription.test.ts | 6 +- packages/db/tests/collection-truncate.test.ts | 10 +- packages/db/tests/collection.test-d.ts | 10 +- packages/db/tests/collection.test.ts | 58 ++--- packages/db/tests/deferred.test.ts | 6 +- packages/db/tests/errors.test.ts | 4 +- .../uint8array-id-comparison.test.ts | 26 +- packages/db/tests/local-only.test-d.ts | 22 +- packages/db/tests/local-only.test.ts | 50 ++-- packages/db/tests/local-storage.test-d.ts | 28 +-- packages/db/tests/local-storage.test.ts | 138 +++++------ packages/db/tests/optimistic-action.test.ts | 12 +- packages/db/tests/paced-mutations.test.ts | 12 +- packages/db/tests/proxy.test.ts | 18 +- packages/db/tests/query/basic.test-d.ts | 28 +-- packages/db/tests/query/basic.test.ts | 35 +-- .../db/tests/query/builder/buildQuery.test.ts | 22 +- .../query/builder/callback-types.test-d.ts | 58 ++--- packages/db/tests/query/builder/from.test.ts | 18 +- .../query/builder/functional-variants.test.ts | 22 +- .../db/tests/query/builder/functions.test.ts | 12 +- .../db/tests/query/builder/group-by.test.ts | 8 +- packages/db/tests/query/builder/join.test.ts | 52 ++-- .../db/tests/query/builder/order-by.test.ts | 10 +- .../db/tests/query/builder/ref-proxy.test.ts | 10 +- .../db/tests/query/builder/select.test.ts | 8 +- .../tests/query/builder/subqueries.test-d.ts | 20 +- packages/db/tests/query/builder/where.test.ts | 16 +- .../db/tests/query/compiler/basic.test.ts | 36 +-- .../tests/query/compiler/evaluators.test.ts | 14 +- .../db/tests/query/compiler/group-by.test.ts | 14 +- .../db/tests/query/compiler/select.test.ts | 8 +- .../tests/query/compiler/subqueries.test.ts | 42 ++-- .../query/compiler/subquery-caching.test.ts | 32 +-- packages/db/tests/query/composables.test.ts | 32 +-- packages/db/tests/query/distinct.test.ts | 55 ++--- .../db/tests/query/expression-helpers.test.ts | 16 +- .../db/tests/query/findone-joins.test-d.ts | 34 +-- .../tests/query/functional-variants.test-d.ts | 24 +- .../tests/query/functional-variants.test.ts | 22 +- packages/db/tests/query/group-by.test-d.ts | 16 +- packages/db/tests/query/group-by.test.ts | 58 ++--- packages/db/tests/query/indexes.test.ts | 52 ++-- .../db/tests/query/join-subquery.test-d.ts | 28 +-- packages/db/tests/query/join-subquery.test.ts | 54 ++--- packages/db/tests/query/join.test-d.ts | 84 +++---- packages/db/tests/query/join.test.ts | 154 ++++++------ .../tests/query/live-query-collection.test.ts | 128 +++++----- .../db/tests/query/nested-props.test-d.ts | 16 +- packages/db/tests/query/optimizer.test.ts | 153 ++++++------ .../query/optional-fields-negative.test-d.ts | 16 +- .../query/optional-fields-runtime.test.ts | 16 +- packages/db/tests/query/order-by.test.ts | 224 +++++++++--------- .../db/tests/query/predicate-utils.test.ts | 146 ++++++------ .../tests/query/query-while-syncing.test.ts | 18 +- packages/db/tests/query/scheduler.test.ts | 38 +-- .../db/tests/query/select-spread.test-d.ts | 12 +- packages/db/tests/query/select-spread.test.ts | 36 +-- packages/db/tests/query/select.test-d.ts | 18 +- packages/db/tests/query/select.test.ts | 18 +- packages/db/tests/query/subquery.test-d.ts | 10 +- packages/db/tests/query/subquery.test.ts | 16 +- packages/db/tests/query/subset-dedupe.test.ts | 18 +- .../db/tests/query/validate-aliases.test.ts | 20 +- packages/db/tests/query/where.test.ts | 98 ++++---- packages/db/tests/test-setup.ts | 2 +- packages/db/tests/transaction-types.test.ts | 6 +- packages/db/tests/transactions.test.ts | 14 +- packages/db/tests/utility-exposure.test.ts | 8 +- packages/db/tests/utils.test.ts | 8 +- packages/db/tests/utils.ts | 14 +- packages/db/vite.config.ts | 8 +- packages/electric-db-collection/CHANGELOG.md | 22 +- .../e2e/electric.e2e.test.ts | 56 ++--- .../electric-db-collection/src/electric.ts | 102 ++++---- packages/electric-db-collection/src/errors.ts | 2 +- packages/electric-db-collection/src/index.ts | 4 +- .../src/sql-compiler.ts | 20 +- .../tests/electric-live-query.test.ts | 44 ++-- .../tests/electric.test-d.ts | 28 +-- .../tests/electric.test.ts | 71 +++--- .../tests/pg-serializer.test.ts | 12 +- .../electric-db-collection/vite.config.ts | 8 +- .../vitest.e2e.config.ts | 2 +- packages/offline-transactions/CHANGELOG.md | 8 +- packages/offline-transactions/README.md | 28 +-- .../src/OfflineExecutor.ts | 52 ++-- .../src/api/OfflineAction.ts | 12 +- .../src/api/OfflineTransaction.ts | 12 +- .../src/connectivity/OnlineDetector.ts | 4 +- .../coordination/BroadcastChannelLeader.ts | 2 +- .../src/coordination/LeaderElection.ts | 2 +- .../src/coordination/WebLocksLeader.ts | 6 +- .../src/executor/KeyScheduler.ts | 24 +- .../src/executor/TransactionExecutor.ts | 44 ++-- packages/offline-transactions/src/index.ts | 32 +-- .../src/outbox/OutboxManager.ts | 34 +-- .../src/outbox/TransactionSerializer.ts | 14 +- .../src/retry/NonRetriableError.ts | 2 +- .../src/retry/RetryPolicy.ts | 6 +- .../src/storage/IndexedDBAdapter.ts | 6 +- .../src/storage/LocalStorageAdapter.ts | 6 +- .../src/storage/StorageAdapter.ts | 2 +- .../src/telemetry/tracer.ts | 6 +- packages/offline-transactions/src/types.ts | 6 +- .../tests/OfflineExecutor.test.ts | 8 +- .../offline-transactions/tests/harness.ts | 16 +- .../tests/leader-failover.test.ts | 10 +- .../tests/offline-e2e.test.ts | 24 +- packages/offline-transactions/tests/setup.ts | 2 +- .../tests/storage-failure.test.ts | 26 +- packages/offline-transactions/vite.config.ts | 8 +- .../offline-transactions/vitest.config.ts | 2 +- .../src/PendingOperationStore.ts | 6 +- .../src/PowerSyncTransactor.ts | 56 ++--- .../src/definitions.ts | 10 +- .../powersync-db-collection/src/helpers.ts | 4 +- packages/powersync-db-collection/src/index.ts | 6 +- .../powersync-db-collection/src/powersync.ts | 56 ++--- .../powersync-db-collection/src/schema.ts | 14 +- .../src/serialization.ts | 14 +- .../tests/collection-schema.test.ts | 32 +-- .../tests/powersync.test.ts | 46 ++-- .../tests/schema.test.ts | 8 +- .../powersync-db-collection/vite.config.ts | 8 +- packages/query-db-collection/CHANGELOG.md | 34 +-- .../query-db-collection/e2e/query-filter.ts | 34 +-- .../query-db-collection/e2e/query.e2e.test.ts | 26 +- packages/query-db-collection/src/errors.ts | 4 +- packages/query-db-collection/src/global.ts | 4 +- packages/query-db-collection/src/index.ts | 8 +- .../query-db-collection/src/manual-sync.ts | 22 +- packages/query-db-collection/src/query.ts | 70 +++--- .../query-db-collection/src/serialization.ts | 6 +- .../query-db-collection/tests/query.test-d.ts | 24 +- .../query-db-collection/tests/query.test.ts | 104 ++++---- packages/query-db-collection/vite.config.ts | 8 +- .../query-db-collection/vitest.e2e.config.ts | 2 +- packages/react-db/CHANGELOG.md | 14 +- packages/react-db/src/index.ts | 14 +- packages/react-db/src/useLiveInfiniteQuery.ts | 28 +-- packages/react-db/src/useLiveQuery.ts | 38 +-- packages/react-db/src/useLiveSuspenseQuery.ts | 18 +- packages/react-db/src/usePacedMutations.ts | 8 +- packages/react-db/tests/test-setup.ts | 6 +- .../tests/useLiveInfiniteQuery.test.tsx | 98 ++++---- .../react-db/tests/useLiveQuery.test-d.tsx | 24 +- packages/react-db/tests/useLiveQuery.test.tsx | 141 +++++------ .../tests/useLiveSuspenseQuery.test.tsx | 88 +++---- .../react-db/tests/usePacedMutations.test.tsx | 26 +- packages/react-db/vite.config.ts | 8 +- packages/rxdb-db-collection/src/index.ts | 4 +- packages/rxdb-db-collection/src/rxdb.ts | 36 +-- .../rxdb-db-collection/tests/rxdb.test.ts | 30 +-- packages/rxdb-db-collection/vite.config.ts | 8 +- packages/solid-db/src/index.ts | 8 +- packages/solid-db/src/useLiveQuery.ts | 36 +-- packages/solid-db/tests/test-setup.ts | 6 +- packages/solid-db/tests/useLiveQuery.test.tsx | 109 ++++----- packages/solid-db/vite.config.ts | 10 +- packages/svelte-db/src/index.ts | 8 +- packages/svelte-db/src/useLiveQuery.svelte.ts | 24 +- packages/svelte-db/svelte.config.js | 2 +- .../tests/useLiveQuery.svelte.test.ts | 92 +++---- packages/svelte-db/vite.config.ts | 6 +- packages/trailbase-db-collection/CHANGELOG.md | 12 +- .../trailbase-db-collection/src/errors.ts | 2 +- packages/trailbase-db-collection/src/index.ts | 4 +- .../trailbase-db-collection/src/trailbase.ts | 28 +-- .../tests/trailbase.test.ts | 24 +- .../trailbase-db-collection/vite.config.ts | 8 +- packages/vue-db/src/index.ts | 8 +- packages/vue-db/src/useLiveQuery.ts | 28 +-- packages/vue-db/tests/useLiveQuery.test.ts | 96 ++++---- packages/vue-db/vite.config.ts | 10 +- pnpm-lock.yaml | 29 +-- prettier.config.js | 10 + scripts/{generateDocs.ts => generate-docs.ts} | 24 +- scripts/verify-links.ts | 14 +- tsconfig.json | 4 +- 460 files changed, 5753 insertions(+), 5767 deletions(-) delete mode 100644 .prettierrc create mode 100644 prettier.config.js rename scripts/{generateDocs.ts => generate-docs.ts} (89%) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 8fbf8f760..b39f31408 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,9 +1,9 @@ --- name: 🐛 Bug Report about: Create a report to help us improve -title: "" -labels: "" -assignees: "" +title: '' +labels: '' +assignees: '' --- - [ ] I've validated the bug against the latest version of DB packages diff --git a/.github/workflows/autofix.yml b/.github/workflows/autofix.yml index d783ef32d..554769b60 100644 --- a/.github/workflows/autofix.yml +++ b/.github/workflows/autofix.yml @@ -24,10 +24,8 @@ jobs: - name: Setup Tools uses: tanstack/config/.github/setup@main - name: Fix formatting - run: pnpm prettier --ignore-unknown . --check - - name: Run ESLint - run: pnpm run lint + run: pnpm format - name: Apply fixes uses: autofix-ci/action@635ffb0c9798bd160680f18fd73371e355b85f27 with: - commit-message: "ci: apply automated fixes" + commit-message: 'ci: apply automated fixes' diff --git a/.github/workflows/docs-sync.yml b/.github/workflows/docs-sync.yml index fdbcb9ba2..a53823435 100644 --- a/.github/workflows/docs-sync.yml +++ b/.github/workflows/docs-sync.yml @@ -3,7 +3,7 @@ name: Sync Generated Docs on: schedule: # Run daily at 2 AM UTC - - cron: "0 2 * * *" + - cron: '0 2 * * *' # Allows you to run this workflow manually from the Actions tab workflow_dispatch: diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 2c5ac83b0..781738da4 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -23,8 +23,8 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: "20" - cache: "pnpm" + node-version: '20' + cache: 'pnpm' - name: Install dependencies run: pnpm install --frozen-lockfile diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 9d789f762..21fee0463 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -51,17 +51,17 @@ jobs: - name: Compressed Size Action - DB Package uses: preactjs/compressed-size-action@v2 with: - repo-token: "${{ secrets.GITHUB_TOKEN }}" - pattern: "./packages/db/dist/**/*.{js,mjs}" - comment-key: "db-package-size" - build-script: "build:minified" + repo-token: '${{ secrets.GITHUB_TOKEN }}' + pattern: './packages/db/dist/**/*.{js,mjs}' + comment-key: 'db-package-size' + build-script: 'build:minified' - name: Compressed Size Action - React DB Package uses: preactjs/compressed-size-action@v2 with: - repo-token: "${{ secrets.GITHUB_TOKEN }}" - pattern: "./packages/react-db/dist/**/*.{js,mjs}" - comment-key: "react-db-package-size" - build-script: "build:minified" + repo-token: '${{ secrets.GITHUB_TOKEN }}' + pattern: './packages/react-db/dist/**/*.{js,mjs}' + comment-key: 'react-db-package-size' + build-script: 'build:minified' build-example: name: Build Example Site runs-on: ubuntu-latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 11042f7b0..cad12d577 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -36,8 +36,8 @@ jobs: with: version: pnpm run changeset:version publish: pnpm run changeset:publish - commit: "ci: Version Packages" - title: "ci: Version Packages" + commit: 'ci: Version Packages' + title: 'ci: Version Packages' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.pnpmfile.cjs b/.pnpmfile.cjs index f154da33d..70392f0a0 100644 --- a/.pnpmfile.cjs +++ b/.pnpmfile.cjs @@ -1,17 +1,17 @@ function readPackage(pkg, context) { // Force all @tanstack/db dependencies to resolve to workspace version - if (pkg.dependencies && pkg.dependencies["@tanstack/db"]) { - pkg.dependencies["@tanstack/db"] = "workspace:*" + if (pkg.dependencies && pkg.dependencies['@tanstack/db']) { + pkg.dependencies['@tanstack/db'] = 'workspace:*' context.log(`Overriding @tanstack/db dependency in ${pkg.name}`) } - if (pkg.devDependencies && pkg.devDependencies["@tanstack/db"]) { - pkg.devDependencies["@tanstack/db"] = "workspace:*" + if (pkg.devDependencies && pkg.devDependencies['@tanstack/db']) { + pkg.devDependencies['@tanstack/db'] = 'workspace:*' context.log(`Overriding @tanstack/db devDependency in ${pkg.name}`) } - if (pkg.peerDependencies && pkg.peerDependencies["@tanstack/db"]) { - pkg.peerDependencies["@tanstack/db"] = "workspace:*" + if (pkg.peerDependencies && pkg.peerDependencies['@tanstack/db']) { + pkg.peerDependencies['@tanstack/db'] = 'workspace:*' context.log(`Overriding @tanstack/db peerDependency in ${pkg.name}`) } diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index eaff0359c..000000000 --- a/.prettierrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "trailingComma": "es5", - "semi": false, - "tabWidth": 2 -} diff --git a/AGENTS.md b/AGENTS.md index ee8056447..6654f89bf 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -36,7 +36,7 @@ function processData(data: unknown) { if (isDataObject(data)) { return data.value } - throw new Error("Invalid data") + throw new Error('Invalid data') } const result: TQueryData = someOperation() @@ -58,12 +58,12 @@ const result: TQueryData = someOperation() ```typescript // Duplicated logic in multiple places function processA() { - const key = typeof value === "number" ? `__number__${value}` : String(value) + const key = typeof value === 'number' ? `__number__${value}` : String(value) // ... } function processB() { - const key = typeof value === "number" ? `__number__${value}` : String(value) + const key = typeof value === 'number' ? `__number__${value}` : String(value) // ... } ``` @@ -72,7 +72,7 @@ function processB() { ```typescript function serializeKey(value: string | number): string { - return typeof value === "number" ? `__number__${value}` : String(value) + return typeof value === 'number' ? `__number__${value}` : String(value) } function processA() { @@ -161,7 +161,7 @@ readyJobs.forEach(processJob) ```typescript // O(n) lookup for each check -const items = ["foo", "bar", "baz" /* hundreds more */] +const items = ['foo', 'bar', 'baz' /* hundreds more */] if (items.includes(searchValue)) { // ... } @@ -171,7 +171,7 @@ if (items.includes(searchValue)) { ```typescript // O(1) lookup -const items = new Set(["foo", "bar", "baz" /* hundreds more */]) +const items = new Set(['foo', 'bar', 'baz' /* hundreds more */]) if (items.has(searchValue)) { // ... } @@ -194,7 +194,7 @@ if (items.has(searchValue)) { // Intending to check if subset limit is more restrictive than superset function isLimitSubset( subset: number | undefined, - superset: number | undefined + superset: number | undefined, ) { return subset === undefined || superset === undefined || subset <= superset } @@ -207,7 +207,7 @@ function isLimitSubset( ```typescript function isLimitSubset( subset: number | undefined, - superset: number | undefined + superset: number | undefined, ) { // Subset with no limit cannot be a subset of one with a limit return superset === undefined || (subset !== undefined && subset <= superset) @@ -361,7 +361,7 @@ const dependentBuilders = [] // Accurately describes dependents ```typescript // Found a bug with fetchSnapshot resolving after up-to-date message // Should add a test: -test("ignores snapshot that resolves after up-to-date message", async () => { +test('ignores snapshot that resolves after up-to-date message', async () => { // Reproduce the corner case // Verify it's handled correctly }) @@ -520,7 +520,7 @@ const filtered = items.filter((item) => item.value > 0) ```typescript // ❌ Bad: numeric 1 and string "__number__1" collide - const key = typeof val === "number" ? `__number__${val}` : String(val) + const key = typeof val === 'number' ? `__number__${val}` : String(val) // ✅ Good: proper encoding with type prefix const key = `${typeof val}_${String(val)}` diff --git a/eslint.config.js b/eslint.config.js index 1f40676a4..02e6c5438 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,7 +1,4 @@ -import prettierPlugin from "eslint-plugin-prettier" -import prettierConfig from "eslint-config-prettier" -import stylisticPlugin from "@stylistic/eslint-plugin" -import { tanstackConfig } from "@tanstack/config/eslint" +import { tanstackConfig } from '@tanstack/config/eslint' export default [ ...tanstackConfig, @@ -15,31 +12,24 @@ export default [ ], }, { - plugins: { - stylistic: stylisticPlugin, - prettier: prettierPlugin, - }, settings: { // import-x/* settings required for import/no-cycle. - "import-x/resolver": { typescript: true }, - "import-x/extensions": [".ts", ".tsx", ".js", ".jsx", ".cjs", ".mjs"], + 'import-x/resolver': { typescript: true }, + 'import-x/extensions': ['.ts', '.tsx', '.js', '.jsx', '.cjs', '.mjs'], }, rules: { - "prettier/prettier": `error`, - "stylistic/quotes": [`error`, `backtick`], - "pnpm/enforce-catalog": `off`, - "pnpm/json-enforce-catalog": `off`, - ...prettierConfig.rules, + 'pnpm/enforce-catalog': `off`, + 'pnpm/json-enforce-catalog': `off`, }, }, { files: [`**/*.ts`, `**/*.tsx`], rules: { - "@typescript-eslint/no-unused-vars": [ + '@typescript-eslint/no-unused-vars': [ `error`, { argsIgnorePattern: `^_`, varsIgnorePattern: `^_` }, ], - "@typescript-eslint/naming-convention": [ + '@typescript-eslint/naming-convention': [ `error`, { selector: `typeParameter`, @@ -47,7 +37,7 @@ export default [ leadingUnderscore: `allow`, }, ], - "import/no-cycle": `error`, + 'import/no-cycle': `error`, }, }, ] diff --git a/examples/angular/todos/src/app/app.config.ts b/examples/angular/todos/src/app/app.config.ts index 414eeaeb8..a690ebc33 100644 --- a/examples/angular/todos/src/app/app.config.ts +++ b/examples/angular/todos/src/app/app.config.ts @@ -2,10 +2,10 @@ import { ApplicationConfig, provideBrowserGlobalErrorListeners, provideZoneChangeDetection, -} from '@angular/core'; -import { provideRouter } from '@angular/router'; +} from '@angular/core' +import { provideRouter } from '@angular/router' -import { routes } from './app.routes'; +import { routes } from './app.routes' export const appConfig: ApplicationConfig = { providers: [ @@ -13,4 +13,4 @@ export const appConfig: ApplicationConfig = { provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes), ], -}; +} diff --git a/examples/angular/todos/src/app/app.routes.ts b/examples/angular/todos/src/app/app.routes.ts index c4dcbaef3..5281a3272 100644 --- a/examples/angular/todos/src/app/app.routes.ts +++ b/examples/angular/todos/src/app/app.routes.ts @@ -1,5 +1,5 @@ -import { Routes } from '@angular/router'; +import { Routes } from '@angular/router' export const routes: Routes = [ // Add your routes here -]; +] diff --git a/examples/angular/todos/src/app/app.ts b/examples/angular/todos/src/app/app.ts index 55c59b7f2..46b1609d0 100644 --- a/examples/angular/todos/src/app/app.ts +++ b/examples/angular/todos/src/app/app.ts @@ -1,9 +1,9 @@ -import { Component, signal } from '@angular/core'; -import { injectLiveQuery } from '@tanstack/angular-db'; -import { eq } from '@tanstack/db'; -import { todosCollection } from '../collections/todos-collection'; -import { FormsModule } from '@angular/forms'; -import { CommonModule } from '@angular/common'; +import { Component, signal } from '@angular/core' +import { injectLiveQuery } from '@tanstack/angular-db' +import { eq } from '@tanstack/db' +import { todosCollection } from '../collections/todos-collection' +import { FormsModule } from '@angular/forms' +import { CommonModule } from '@angular/common' @Component({ selector: 'app-root', @@ -140,20 +140,20 @@ export class App { projects = [ { id: 1, name: 'Work' }, { id: 2, name: 'Home' }, - ]; + ] - selectedProjectId = signal(2); + selectedProjectId = signal(2) todoQuery = injectLiveQuery({ params: () => ({ projectID: this.selectedProjectId() }), query: ({ params, q }) => q.from({ todo: todosCollection }).where(({ todo }) => eq(todo.projectID, params.projectID)), - }); + }) - newTodoText = ''; + newTodoText = '' addTodo() { - if (!this.newTodoText.trim()) return; + if (!this.newTodoText.trim()) return const newTodo = { id: Date.now(), @@ -161,23 +161,23 @@ export class App { projectID: this.selectedProjectId(), completed: false, created_at: new Date(), - }; + } - todosCollection.insert(newTodo); - this.newTodoText = ''; + todosCollection.insert(newTodo) + this.newTodoText = '' } toggleTodo(id: number) { todosCollection.update(id, (draft: any) => { - draft.completed = !draft.completed; - }); + draft.completed = !draft.completed + }) } deleteTodo(id: number) { - todosCollection.delete(id); + todosCollection.delete(id) } getCompletedCount(): number { - return this.todoQuery.data().filter((todo) => todo.completed).length; + return this.todoQuery.data().filter((todo) => todo.completed).length } } diff --git a/examples/angular/todos/src/collections/todos-collection.ts b/examples/angular/todos/src/collections/todos-collection.ts index 1aa97d796..70e2fbb89 100644 --- a/examples/angular/todos/src/collections/todos-collection.ts +++ b/examples/angular/todos/src/collections/todos-collection.ts @@ -1,11 +1,11 @@ -import { createCollection, localOnlyCollectionOptions } from '@tanstack/db'; +import { createCollection, localOnlyCollectionOptions } from '@tanstack/db' interface Todo { - id: number; - text: string; - projectID: number; - completed: boolean; - created_at: Date; + id: number + text: string + projectID: number + completed: boolean + created_at: Date } export const todosCollection = createCollection( @@ -42,4 +42,4 @@ export const todosCollection = createCollection( }, ], }), -); +) diff --git a/examples/angular/todos/src/main.ts b/examples/angular/todos/src/main.ts index 190f3418d..8192dca69 100644 --- a/examples/angular/todos/src/main.ts +++ b/examples/angular/todos/src/main.ts @@ -1,5 +1,5 @@ -import { bootstrapApplication } from '@angular/platform-browser'; -import { appConfig } from './app/app.config'; -import { App } from './app/app'; +import { bootstrapApplication } from '@angular/platform-browser' +import { appConfig } from './app/app.config' +import { App } from './app/app' -bootstrapApplication(App, appConfig).catch((err) => console.error(err)); +bootstrapApplication(App, appConfig).catch((err) => console.error(err)) diff --git a/examples/angular/todos/tailwind.config.js b/examples/angular/todos/tailwind.config.js index 0cc494f78..cf64e228a 100644 --- a/examples/angular/todos/tailwind.config.js +++ b/examples/angular/todos/tailwind.config.js @@ -5,4 +5,4 @@ module.exports = { extend: {}, }, plugins: [], -}; +} diff --git a/examples/react/offline-transactions/src/components/DefaultCatchBoundary.tsx b/examples/react/offline-transactions/src/components/DefaultCatchBoundary.tsx index 63e20524f..ae1b64f67 100644 --- a/examples/react/offline-transactions/src/components/DefaultCatchBoundary.tsx +++ b/examples/react/offline-transactions/src/components/DefaultCatchBoundary.tsx @@ -4,8 +4,8 @@ import { rootRouteId, useMatch, useRouter, -} from "@tanstack/react-router" -import type { ErrorComponentProps } from "@tanstack/react-router" +} from '@tanstack/react-router' +import type { ErrorComponentProps } from '@tanstack/react-router' export function DefaultCatchBoundary({ error }: ErrorComponentProps) { const router = useRouter() diff --git a/examples/react/offline-transactions/src/components/NotFound.tsx b/examples/react/offline-transactions/src/components/NotFound.tsx index b29bf8dc7..7b54fa568 100644 --- a/examples/react/offline-transactions/src/components/NotFound.tsx +++ b/examples/react/offline-transactions/src/components/NotFound.tsx @@ -1,4 +1,4 @@ -import { Link } from "@tanstack/react-router" +import { Link } from '@tanstack/react-router' export function NotFound({ children }: { children?: any }) { return ( diff --git a/examples/react/offline-transactions/src/components/TodoDemo.tsx b/examples/react/offline-transactions/src/components/TodoDemo.tsx index 4a4bd3259..fcdf088da 100644 --- a/examples/react/offline-transactions/src/components/TodoDemo.tsx +++ b/examples/react/offline-transactions/src/components/TodoDemo.tsx @@ -1,6 +1,6 @@ -import React, { useEffect, useMemo, useState } from "react" -import { useLiveQuery } from "@tanstack/react-db" -import { createTodoActions, todoCollection } from "~/db/todos" +import React, { useEffect, useMemo, useState } from 'react' +import { useLiveQuery } from '@tanstack/react-db' +import { createTodoActions, todoCollection } from '~/db/todos' interface TodoDemoProps { title: string @@ -28,7 +28,7 @@ export function TodoDemo({ const { data: todoList = [], isLoading } = useLiveQuery((q) => q .from({ todo: todoCollection }) - .orderBy(({ todo }) => todo.createdAt, `desc`) + .orderBy(({ todo }) => todo.createdAt, `desc`), ) // Monitor online status diff --git a/examples/react/offline-transactions/src/db/todos.ts b/examples/react/offline-transactions/src/db/todos.ts index bc50377f4..1d8be0340 100644 --- a/examples/react/offline-transactions/src/db/todos.ts +++ b/examples/react/offline-transactions/src/db/todos.ts @@ -1,14 +1,14 @@ -import { createCollection } from "@tanstack/react-db" -import { queryCollectionOptions } from "@tanstack/query-db-collection" +import { createCollection } from '@tanstack/react-db' +import { queryCollectionOptions } from '@tanstack/query-db-collection' import { IndexedDBAdapter, LocalStorageAdapter, startOfflineExecutor, -} from "@tanstack/offline-transactions" -import { z } from "zod" -import type { PendingMutation } from "@tanstack/db" -import type { Todo } from "~/utils/todos" -import { queryClient } from "~/utils/queryClient" +} from '@tanstack/offline-transactions' +import { z } from 'zod' +import type { PendingMutation } from '@tanstack/db' +import type { Todo } from '~/utils/todos' +import { queryClient } from '~/utils/queryClient' /** * A utility function to fetch data from a URL with built-in retry logic for non-200 responses. @@ -29,7 +29,7 @@ import { queryClient } from "~/utils/queryClient" export async function fetchWithRetry( url: string, options: RequestInit = {}, - retryConfig: { retries?: number; delay?: number; backoff?: number } = {} + retryConfig: { retries?: number; delay?: number; backoff?: number } = {}, ): Promise { const { retries = 6, delay = 1000, backoff = 2 } = retryConfig @@ -45,7 +45,7 @@ export async function fetchWithRetry( // If it's a non-200 response, log the status and prepare to retry console.warn( - `Fetch attempt ${i + 1} failed with status: ${response.status}. Retrying...` + `Fetch attempt ${i + 1} failed with status: ${response.status}. Retrying...`, ) // Wait before the next attempt, with exponential backoff @@ -57,7 +57,7 @@ export async function fetchWithRetry( // Catch network errors and log a message console.error( `Fetch attempt ${i + 1} failed due to a network error:`, - error + error, ) // Wait before the next attempt, with exponential backoff @@ -104,7 +104,7 @@ export const todoCollection = createCollection( }, getKey: (item) => item.id, schema: todoSchema, - }) + }), ) // API client functions @@ -127,8 +127,8 @@ export const todoAPI = { const response = await fetchWithRetry(`/api/todos`, { method: `POST`, headers: { - "Content-Type": `application/json`, - "Idempotency-Key": idempotencyKey, + 'Content-Type': `application/json`, + 'Idempotency-Key': idempotencyKey, }, body: JSON.stringify({ text: todoData.text, @@ -149,14 +149,14 @@ export const todoAPI = { { method: `PUT`, headers: { - "Content-Type": `application/json`, - "Idempotency-Key": idempotencyKey, + 'Content-Type': `application/json`, + 'Idempotency-Key': idempotencyKey, }, body: JSON.stringify({ text: todoData.text, completed: todoData.completed, }), - } + }, ) if (!response.ok) { @@ -171,9 +171,9 @@ export const todoAPI = { { method: `DELETE`, headers: { - "Idempotency-Key": idempotencyKey, + 'Idempotency-Key': idempotencyKey, }, - } + }, ) if (!response.ok) { @@ -265,7 +265,7 @@ export async function createIndexedDBOfflineExecutor() { code: diagnostic.code, message: diagnostic.message, error: diagnostic.error, - } + }, ) }, }) @@ -297,7 +297,7 @@ export async function createLocalStorageOfflineExecutor() { code: diagnostic.code, message: diagnostic.message, error: diagnostic.error, - } + }, ) }, }) diff --git a/examples/react/offline-transactions/src/router.tsx b/examples/react/offline-transactions/src/router.tsx index e15333a99..d5579a802 100644 --- a/examples/react/offline-transactions/src/router.tsx +++ b/examples/react/offline-transactions/src/router.tsx @@ -1,7 +1,7 @@ -import { createRouter as createTanStackRouter } from "@tanstack/react-router" -import { routeTree } from "./routeTree.gen" -import { DefaultCatchBoundary } from "./components/DefaultCatchBoundary" -import { NotFound } from "./components/NotFound" +import { createRouter as createTanStackRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +import { DefaultCatchBoundary } from './components/DefaultCatchBoundary' +import { NotFound } from './components/NotFound' export function createRouter() { const router = createTanStackRouter({ @@ -15,7 +15,7 @@ export function createRouter() { return router } -declare module "@tanstack/react-router" { +declare module '@tanstack/react-router' { interface Register { router: ReturnType } diff --git a/examples/react/offline-transactions/src/routes/__root.tsx b/examples/react/offline-transactions/src/routes/__root.tsx index ae2487fb4..89588bacb 100644 --- a/examples/react/offline-transactions/src/routes/__root.tsx +++ b/examples/react/offline-transactions/src/routes/__root.tsx @@ -4,15 +4,15 @@ import { Link, Scripts, createRootRoute, -} from "@tanstack/react-router" -import { TanStackRouterDevtools } from "@tanstack/react-router-devtools" -import { QueryClientProvider } from "@tanstack/react-query" -import * as React from "react" -import { DefaultCatchBoundary } from "~/components/DefaultCatchBoundary" -import { NotFound } from "~/components/NotFound" -import appCss from "~/styles/app.css?url" -import { seo } from "~/utils/seo" -import { queryClient } from "~/utils/queryClient" +} from '@tanstack/react-router' +import { TanStackRouterDevtools } from '@tanstack/react-router-devtools' +import { QueryClientProvider } from '@tanstack/react-query' +import * as React from 'react' +import { DefaultCatchBoundary } from '~/components/DefaultCatchBoundary' +import { NotFound } from '~/components/NotFound' +import appCss from '~/styles/app.css?url' +import { seo } from '~/utils/seo' +import { queryClient } from '~/utils/queryClient' export const Route = createRootRoute({ head: () => ({ diff --git a/examples/react/offline-transactions/src/routes/api/todos.$todoId.ts b/examples/react/offline-transactions/src/routes/api/todos.$todoId.ts index e55263518..21b293645 100644 --- a/examples/react/offline-transactions/src/routes/api/todos.$todoId.ts +++ b/examples/react/offline-transactions/src/routes/api/todos.$todoId.ts @@ -1,7 +1,7 @@ -import { createServerFileRoute } from "@tanstack/react-start/server" -import { json } from "@tanstack/react-start" -import type { TodoUpdate } from "~/utils/todos" -import { todoService } from "~/utils/todos" +import { createServerFileRoute } from '@tanstack/react-start/server' +import { json } from '@tanstack/react-start' +import type { TodoUpdate } from '~/utils/todos' +import { todoService } from '~/utils/todos' export const ServerRoute = createServerFileRoute(`/api/todos/$todoId`).methods({ GET: async ({ params, request }) => { @@ -45,7 +45,7 @@ export const ServerRoute = createServerFileRoute(`/api/todos/$todoId`).methods({ if (error instanceof Error && error.message.includes(`Simulated`)) { return json( { error: `Network error - please try again` }, - { status: 503 } + { status: 503 }, ) } return json({ error: `Failed to update todo` }, { status: 500 }) @@ -71,7 +71,7 @@ export const ServerRoute = createServerFileRoute(`/api/todos/$todoId`).methods({ if (error instanceof Error && error.message.includes(`Simulated`)) { return json( { error: `Network error - please try again` }, - { status: 503 } + { status: 503 }, ) } return json({ error: `Failed to delete todo` }, { status: 500 }) diff --git a/examples/react/offline-transactions/src/routes/api/todos.ts b/examples/react/offline-transactions/src/routes/api/todos.ts index 76623dd3c..8b6d1f8d7 100644 --- a/examples/react/offline-transactions/src/routes/api/todos.ts +++ b/examples/react/offline-transactions/src/routes/api/todos.ts @@ -1,7 +1,7 @@ -import { createServerFileRoute } from "@tanstack/react-start/server" -import { json } from "@tanstack/react-start" -import type { TodoInput } from "~/utils/todos" -import { todoService } from "~/utils/todos" +import { createServerFileRoute } from '@tanstack/react-start/server' +import { json } from '@tanstack/react-start' +import type { TodoInput } from '~/utils/todos' +import { todoService } from '~/utils/todos' export const ServerRoute = createServerFileRoute(`/api/todos`).methods({ GET: async ({ request }) => { @@ -43,7 +43,7 @@ export const ServerRoute = createServerFileRoute(`/api/todos`).methods({ if (error instanceof Error && error.message.includes(`Simulated`)) { return json( { error: `Network error - please try again` }, - { status: 503 } + { status: 503 }, ) } return json({ error: `Failed to create todo` }, { status: 500 }) diff --git a/examples/react/offline-transactions/src/routes/api/users.$userId.ts b/examples/react/offline-transactions/src/routes/api/users.$userId.ts index 8f966de20..19426fbbf 100644 --- a/examples/react/offline-transactions/src/routes/api/users.$userId.ts +++ b/examples/react/offline-transactions/src/routes/api/users.$userId.ts @@ -1,13 +1,13 @@ -import { createServerFileRoute } from "@tanstack/react-start/server" -import { json } from "@tanstack/react-start" -import type { User } from "~/utils/users" +import { createServerFileRoute } from '@tanstack/react-start/server' +import { json } from '@tanstack/react-start' +import type { User } from '~/utils/users' export const ServerRoute = createServerFileRoute(`/api/users/$userId`).methods({ GET: async ({ params, request }) => { console.info(`Fetching users by id=${params.userId}... @`, request.url) try { const res = await fetch( - `https://jsonplaceholder.typicode.com/users/` + params.userId + `https://jsonplaceholder.typicode.com/users/` + params.userId, ) if (!res.ok) { throw new Error(`Failed to fetch user`) diff --git a/examples/react/offline-transactions/src/routes/api/users.ts b/examples/react/offline-transactions/src/routes/api/users.ts index d92e39318..b627c2f1f 100644 --- a/examples/react/offline-transactions/src/routes/api/users.ts +++ b/examples/react/offline-transactions/src/routes/api/users.ts @@ -1,9 +1,9 @@ import { createServerFileRoute, getRequestHeaders, -} from "@tanstack/react-start/server" -import { createMiddleware, json } from "@tanstack/react-start" -import type { User } from "~/utils/users" +} from '@tanstack/react-start/server' +import { createMiddleware, json } from '@tanstack/react-start' +import type { User } from '~/utils/users' const userLoggerMiddleware = createMiddleware({ type: `request` }).server( async ({ next, _request }) => { @@ -13,7 +13,7 @@ const userLoggerMiddleware = createMiddleware({ type: `request` }).server( result.response.headers.set(`x-users`, `true`) console.info(`Out: /users`) return result - } + }, ) const testParentMiddleware = createMiddleware({ type: `request` }).server( @@ -23,7 +23,7 @@ const testParentMiddleware = createMiddleware({ type: `request` }).server( result.response.headers.set(`x-test-parent`, `true`) console.info(`Out: testParentMiddleware`) return result - } + }, ) const testMiddleware = createMiddleware({ type: `request` }) diff --git a/examples/react/offline-transactions/src/routes/index.tsx b/examples/react/offline-transactions/src/routes/index.tsx index bb1db6612..6e9141e5d 100644 --- a/examples/react/offline-transactions/src/routes/index.tsx +++ b/examples/react/offline-transactions/src/routes/index.tsx @@ -1,4 +1,4 @@ -import { Link, createFileRoute } from "@tanstack/react-router" +import { Link, createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute(`/`)({ component: Home, diff --git a/examples/react/offline-transactions/src/routes/indexeddb.tsx b/examples/react/offline-transactions/src/routes/indexeddb.tsx index 5ab1db0d3..de3b88db9 100644 --- a/examples/react/offline-transactions/src/routes/indexeddb.tsx +++ b/examples/react/offline-transactions/src/routes/indexeddb.tsx @@ -1,7 +1,7 @@ -import { createFileRoute } from "@tanstack/react-router" -import { useEffect, useState } from "react" -import { TodoDemo } from "~/components/TodoDemo" -import { createIndexedDBOfflineExecutor } from "~/db/todos" +import { createFileRoute } from '@tanstack/react-router' +import { useEffect, useState } from 'react' +import { TodoDemo } from '~/components/TodoDemo' +import { createIndexedDBOfflineExecutor } from '~/db/todos' export const Route = createFileRoute(`/indexeddb`)({ component: IndexedDBDemo, diff --git a/examples/react/offline-transactions/src/routes/localstorage.tsx b/examples/react/offline-transactions/src/routes/localstorage.tsx index a9db81c5c..91ee02bff 100644 --- a/examples/react/offline-transactions/src/routes/localstorage.tsx +++ b/examples/react/offline-transactions/src/routes/localstorage.tsx @@ -1,7 +1,7 @@ -import { createFileRoute } from "@tanstack/react-router" -import { useEffect, useState } from "react" -import { TodoDemo } from "~/components/TodoDemo" -import { createLocalStorageOfflineExecutor } from "~/db/todos" +import { createFileRoute } from '@tanstack/react-router' +import { useEffect, useState } from 'react' +import { TodoDemo } from '~/components/TodoDemo' +import { createLocalStorageOfflineExecutor } from '~/db/todos' export const Route = createFileRoute(`/localstorage`)({ component: LocalStorageDemo, diff --git a/examples/react/offline-transactions/src/utils/loggingMiddleware.tsx b/examples/react/offline-transactions/src/utils/loggingMiddleware.tsx index 2c516283b..336587007 100644 --- a/examples/react/offline-transactions/src/utils/loggingMiddleware.tsx +++ b/examples/react/offline-transactions/src/utils/loggingMiddleware.tsx @@ -1,4 +1,4 @@ -import { createMiddleware } from "@tanstack/react-start" +import { createMiddleware } from '@tanstack/react-start' const preLogMiddleware = createMiddleware({ type: `function` }) .client(async (ctx) => { diff --git a/examples/react/offline-transactions/src/utils/queryClient.ts b/examples/react/offline-transactions/src/utils/queryClient.ts index 3706eed12..5ca414ef7 100644 --- a/examples/react/offline-transactions/src/utils/queryClient.ts +++ b/examples/react/offline-transactions/src/utils/queryClient.ts @@ -1,4 +1,4 @@ -import { QueryClient } from "@tanstack/react-query" +import { QueryClient } from '@tanstack/react-query' export const queryClient = new QueryClient({ defaultOptions: { diff --git a/examples/react/offline-transactions/src/utils/todos.ts b/examples/react/offline-transactions/src/utils/todos.ts index 935a7f565..419683556 100644 --- a/examples/react/offline-transactions/src/utils/todos.ts +++ b/examples/react/offline-transactions/src/utils/todos.ts @@ -28,7 +28,7 @@ export const todoService = { getAll(): Array { return Array.from(todosStore.values()).sort( (a, b) => - new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime() + new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime(), ) }, diff --git a/examples/react/offline-transactions/tailwind.config.mjs b/examples/react/offline-transactions/tailwind.config.mjs index 6765f75b2..e49f4eb77 100644 --- a/examples/react/offline-transactions/tailwind.config.mjs +++ b/examples/react/offline-transactions/tailwind.config.mjs @@ -1,4 +1,4 @@ /** @type {import('tailwindcss').Config} */ export default { - content: ["./src/**/*.{js,jsx,ts,tsx}"], + content: ['./src/**/*.{js,jsx,ts,tsx}'], } diff --git a/examples/react/offline-transactions/vite.config.ts b/examples/react/offline-transactions/vite.config.ts index f730c1bf5..7c7d0e77c 100644 --- a/examples/react/offline-transactions/vite.config.ts +++ b/examples/react/offline-transactions/vite.config.ts @@ -1,9 +1,9 @@ -import path from "node:path" -import { tanstackStart } from "@tanstack/react-start/plugin/vite" -import { defineConfig } from "vite" -import tsConfigPaths from "vite-tsconfig-paths" -import viteReact from "@vitejs/plugin-react" -import chokidar from "chokidar" +import path from 'node:path' +import { tanstackStart } from '@tanstack/react-start/plugin/vite' +import { defineConfig } from 'vite' +import tsConfigPaths from 'vite-tsconfig-paths' +import viteReact from '@vitejs/plugin-react' +import chokidar from 'chokidar' function watchWorkspacePackages() { return { @@ -27,7 +27,7 @@ function watchWorkspacePackages() { watcher.on(`ready`, () => { console.log( - `[watch-workspace] Initial scan complete. Watching for changes...` + `[watch-workspace] Initial scan complete. Watching for changes...`, ) const watchedPaths = watcher.getWatched() console.log(`[watch-workspace] Currently watching:`, watchedPaths) diff --git a/examples/react/paced-mutations-demo/src/App.tsx b/examples/react/paced-mutations-demo/src/App.tsx index 57f1ad33c..26781446c 100644 --- a/examples/react/paced-mutations-demo/src/App.tsx +++ b/examples/react/paced-mutations-demo/src/App.tsx @@ -1,13 +1,13 @@ -import { useEffect, useMemo, useState } from "react" -import mitt from "mitt" +import { useEffect, useMemo, useState } from 'react' +import mitt from 'mitt' import { createCollection, debounceStrategy, queueStrategy, throttleStrategy, usePacedMutations, -} from "@tanstack/react-db" -import type { PendingMutation, Transaction } from "@tanstack/react-db" +} from '@tanstack/react-db' +import type { PendingMutation, Transaction } from '@tanstack/react-db' interface Item { id: number @@ -86,7 +86,7 @@ export function App() { const [trailing, setTrailing] = useState(true) const [transactions, setTransactions] = useState>( - [] + [], ) const [optimisticState, setOptimisticState] = useState(null) const [syncedState, setSyncedState] = useState(fakeServer.get(1)!) @@ -130,7 +130,7 @@ export function App() { return { ...t, state: `executing` as const, executingAt } } return t - }) + }), ) // Simulate network delay to fake server (random 100-600ms) @@ -200,7 +200,7 @@ export function App() { } } return t - }) + }), ) // Update optimistic state after completion setOptimisticState(itemCollection.get(1)) @@ -213,7 +213,7 @@ export function App() { return { ...t, state: `failed` as const, completedAt: Date.now() } } return t - }) + }), ) // Update optimistic state after failure setOptimisticState(itemCollection.get(1)) diff --git a/examples/react/paced-mutations-demo/src/index.css b/examples/react/paced-mutations-demo/src/index.css index d863dbaf4..e315d3e3d 100644 --- a/examples/react/paced-mutations-demo/src/index.css +++ b/examples/react/paced-mutations-demo/src/index.css @@ -6,8 +6,8 @@ body { font-family: - -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", - "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; + -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', + 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; background: #f5f5f5; @@ -16,7 +16,7 @@ body { code { font-family: - source-code-pro, Menlo, Monaco, Consolas, "Courier New", monospace; + source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace; background: #f0f0f0; padding: 2px 6px; border-radius: 3px; @@ -74,7 +74,7 @@ h1 { } .control-group select, -.control-group input[type="number"] { +.control-group input[type='number'] { width: 100%; padding: 8px; border: 1px solid #ddd; @@ -89,7 +89,7 @@ h1 { margin-bottom: 8px; } -.checkbox-group input[type="checkbox"] { +.checkbox-group input[type='checkbox'] { width: 16px; height: 16px; } diff --git a/examples/react/paced-mutations-demo/src/main.tsx b/examples/react/paced-mutations-demo/src/main.tsx index 8def6fa63..950701bda 100644 --- a/examples/react/paced-mutations-demo/src/main.tsx +++ b/examples/react/paced-mutations-demo/src/main.tsx @@ -1,10 +1,10 @@ -import React from "react" -import ReactDOM from "react-dom/client" -import { App } from "./App" -import "./index.css" +import React from 'react' +import ReactDOM from 'react-dom/client' +import { App } from './App' +import './index.css' ReactDOM.createRoot(document.getElementById(`root`)!).render( - + , ) diff --git a/examples/react/paced-mutations-demo/vite.config.ts b/examples/react/paced-mutations-demo/vite.config.ts index ea1889ae7..9ffcc6757 100644 --- a/examples/react/paced-mutations-demo/vite.config.ts +++ b/examples/react/paced-mutations-demo/vite.config.ts @@ -1,5 +1,5 @@ -import { defineConfig } from "vite" -import react from "@vitejs/plugin-react" +import { defineConfig } from 'vite' +import react from '@vitejs/plugin-react' export default defineConfig({ plugins: [react()], diff --git a/examples/react/projects/README.md b/examples/react/projects/README.md index 3bfe71853..7a122431d 100644 --- a/examples/react/projects/README.md +++ b/examples/react/projects/README.md @@ -78,7 +78,7 @@ Now that you have two routes you can use a `Link` component to navigate between To use SPA (Single Page Application) navigation you will need to import the `Link` component from `@tanstack/react-router`. ```tsx -import { Link } from "@tanstack/react-router" +import { Link } from '@tanstack/react-router' ``` Then anywhere in your JSX you can use it like so: @@ -98,10 +98,10 @@ In the File Based Routing setup the layout is located in `src/routes/__root.tsx` Here is an example layout that includes a header: ```tsx -import { Outlet, createRootRoute } from "@tanstack/react-router" -import { TanStackRouterDevtools } from "@tanstack/react-router-devtools" +import { Outlet, createRootRoute } from '@tanstack/react-router' +import { TanStackRouterDevtools } from '@tanstack/react-router-devtools' -import { Link } from "@tanstack/react-router" +import { Link } from '@tanstack/react-router' export const Route = createRootRoute({ component: () => ( @@ -132,9 +132,9 @@ For example: ```tsx const peopleRoute = createRoute({ getParentRoute: () => rootRoute, - path: "/people", + path: '/people', loader: async () => { - const response = await fetch("https://swapi.dev/api/people") + const response = await fetch('https://swapi.dev/api/people') return response.json() as Promise<{ results: { name: string @@ -180,16 +180,16 @@ Built on a TypeScript implementation of differential dataflow, TanStack DB provi This example uses Query Collections for server-state synchronization with tRPC: ```tsx -import { createCollection } from "@tanstack/react-db" -import { queryCollectionOptions } from "@tanstack/query-db-collection" -import { QueryClient } from "@tanstack/query-core" +import { createCollection } from '@tanstack/react-db' +import { queryCollectionOptions } from '@tanstack/query-db-collection' +import { QueryClient } from '@tanstack/query-core' const queryClient = new QueryClient() export const todoCollection = createCollection( queryCollectionOptions({ - id: "todos", - queryKey: ["todos"], + id: 'todos', + queryKey: ['todos'], queryFn: async () => { const todos = await trpc.todos.getAll.query() return todos.map((todo) => ({ @@ -224,7 +224,7 @@ const AddTodo = () => { onClick={() => todoCollection.insert({ id: crypto.randomUUID(), - text: "🔥 Make app faster", + text: '🔥 Make app faster', completed: false, }) } @@ -238,7 +238,7 @@ const AddTodo = () => { Use live queries to read data reactively across collections: ```tsx -import { useLiveQuery } from "@tanstack/react-db" +import { useLiveQuery } from '@tanstack/react-db' const Todos = () => { // Read data using live queries with cross-collection joins @@ -246,12 +246,12 @@ const Todos = () => { query .from({ t: todoCollection }) .join({ - type: "inner", + type: 'inner', from: { l: listCollection }, on: [`@l.id`, `=`, `@t.list_id`], }) - .where("@l.active", "=", true) - .select("@t.id", "@t.text", "@t.status", "@l.name") + .where('@l.active', '=', true) + .select('@t.id', '@t.text', '@t.status', '@l.name') ) return ( diff --git a/examples/react/projects/docker-compose.yaml b/examples/react/projects/docker-compose.yaml index 6da89ad48..42a8aca0d 100644 --- a/examples/react/projects/docker-compose.yaml +++ b/examples/react/projects/docker-compose.yaml @@ -1,5 +1,5 @@ -version: "3.3" -name: "tanstack-start-db-projects" +version: '3.3' +name: 'tanstack-start-db-projects' services: postgres: diff --git a/examples/react/projects/drizzle.config.ts b/examples/react/projects/drizzle.config.ts index 6a6f388fd..30ae9a282 100644 --- a/examples/react/projects/drizzle.config.ts +++ b/examples/react/projects/drizzle.config.ts @@ -1,5 +1,5 @@ -import "dotenv/config" -import { defineConfig } from "drizzle-kit" +import 'dotenv/config' +import { defineConfig } from 'drizzle-kit' export default defineConfig({ out: `./src/db/out`, diff --git a/examples/react/projects/eslint.config.mjs b/examples/react/projects/eslint.config.mjs index e3c217b91..29a94ce29 100644 --- a/examples/react/projects/eslint.config.mjs +++ b/examples/react/projects/eslint.config.mjs @@ -1,19 +1,19 @@ -import js from "@eslint/js" -import tsParser from "@typescript-eslint/parser" -import tsPlugin from "@typescript-eslint/eslint-plugin" -import reactPlugin from "eslint-plugin-react" -import prettierPlugin from "eslint-plugin-prettier" -import prettierConfig from "eslint-config-prettier" -import globals from "globals" -import { includeIgnoreFile } from "@eslint/compat" -import { fileURLToPath } from "url" +import js from '@eslint/js' +import tsParser from '@typescript-eslint/parser' +import tsPlugin from '@typescript-eslint/eslint-plugin' +import reactPlugin from 'eslint-plugin-react' +import prettierPlugin from 'eslint-plugin-prettier' +import prettierConfig from 'eslint-config-prettier' +import globals from 'globals' +import { includeIgnoreFile } from '@eslint/compat' +import { fileURLToPath } from 'url' -const gitignorePath = fileURLToPath(new URL(".gitignore", import.meta.url)) +const gitignorePath = fileURLToPath(new URL('.gitignore', import.meta.url)) export default [ - includeIgnoreFile(gitignorePath, "Imported .gitignore patterns"), + includeIgnoreFile(gitignorePath, 'Imported .gitignore patterns'), { - files: ["src/**/*.{js,jsx,ts,tsx,mjs}"], + files: ['src/**/*.{js,jsx,ts,tsx,mjs}'], languageOptions: { ecmaVersion: 2022, sourceType: `module`, @@ -35,7 +35,7 @@ export default [ }, }, plugins: { - "@typescript-eslint": tsPlugin, + '@typescript-eslint': tsPlugin, react: reactPlugin, prettier: prettierPlugin, }, @@ -44,12 +44,12 @@ export default [ ...tsPlugin.configs.recommended.rules, ...reactPlugin.configs.recommended.rules, ...prettierConfig.rules, - "prettier/prettier": `error`, - "react/react-in-jsx-scope": `off`, - "react/jsx-uses-react": `off`, - "no-undef": `off`, - "@typescript-eslint/no-undef": "off", - "@typescript-eslint/no-unused-vars": [ + 'prettier/prettier': `error`, + 'react/react-in-jsx-scope': `off`, + 'react/jsx-uses-react': `off`, + 'no-undef': `off`, + '@typescript-eslint/no-undef': 'off', + '@typescript-eslint/no-unused-vars': [ `error`, { argsIgnorePattern: `^_`, diff --git a/examples/react/projects/src/db/auth-schema.ts b/examples/react/projects/src/db/auth-schema.ts index c0ff607e2..ac78b4658 100644 --- a/examples/react/projects/src/db/auth-schema.ts +++ b/examples/react/projects/src/db/auth-schema.ts @@ -1,61 +1,61 @@ -import { pgTable, text, timestamp, boolean } from "drizzle-orm/pg-core" +import { pgTable, text, timestamp, boolean } from 'drizzle-orm/pg-core' -export const users = pgTable("users", { - id: text("id").primaryKey(), - name: text("name").notNull(), - email: text("email").notNull().unique(), - emailVerified: boolean("email_verified") +export const users = pgTable('users', { + id: text('id').primaryKey(), + name: text('name').notNull(), + email: text('email').notNull().unique(), + emailVerified: boolean('email_verified') .$defaultFn(() => false) .notNull(), - image: text("image"), - createdAt: timestamp("created_at") + image: text('image'), + createdAt: timestamp('created_at') .$defaultFn(() => /* @__PURE__ */ new Date()) .notNull(), - updatedAt: timestamp("updated_at") + updatedAt: timestamp('updated_at') .$defaultFn(() => /* @__PURE__ */ new Date()) .notNull(), }) -export const sessions = pgTable("sessions", { - id: text("id").primaryKey(), - expiresAt: timestamp("expires_at").notNull(), - token: text("token").notNull().unique(), - createdAt: timestamp("created_at").notNull(), - updatedAt: timestamp("updated_at").notNull(), - ipAddress: text("ip_address"), - userAgent: text("user_agent"), - userId: text("user_id") +export const sessions = pgTable('sessions', { + id: text('id').primaryKey(), + expiresAt: timestamp('expires_at').notNull(), + token: text('token').notNull().unique(), + createdAt: timestamp('created_at').notNull(), + updatedAt: timestamp('updated_at').notNull(), + ipAddress: text('ip_address'), + userAgent: text('user_agent'), + userId: text('user_id') .notNull() - .references(() => users.id, { onDelete: "cascade" }), + .references(() => users.id, { onDelete: 'cascade' }), }) -export const accounts = pgTable("accounts", { - id: text("id").primaryKey(), - accountId: text("account_id").notNull(), - providerId: text("provider_id").notNull(), - userId: text("user_id") +export const accounts = pgTable('accounts', { + id: text('id').primaryKey(), + accountId: text('account_id').notNull(), + providerId: text('provider_id').notNull(), + userId: text('user_id') .notNull() - .references(() => users.id, { onDelete: "cascade" }), - accessToken: text("access_token"), - refreshToken: text("refresh_token"), - idToken: text("id_token"), - accessTokenExpiresAt: timestamp("access_token_expires_at"), - refreshTokenExpiresAt: timestamp("refresh_token_expires_at"), - scope: text("scope"), - password: text("password"), - createdAt: timestamp("created_at").notNull(), - updatedAt: timestamp("updated_at").notNull(), + .references(() => users.id, { onDelete: 'cascade' }), + accessToken: text('access_token'), + refreshToken: text('refresh_token'), + idToken: text('id_token'), + accessTokenExpiresAt: timestamp('access_token_expires_at'), + refreshTokenExpiresAt: timestamp('refresh_token_expires_at'), + scope: text('scope'), + password: text('password'), + createdAt: timestamp('created_at').notNull(), + updatedAt: timestamp('updated_at').notNull(), }) -export const verifications = pgTable("verifications", { - id: text("id").primaryKey(), - identifier: text("identifier").notNull(), - value: text("value").notNull(), - expiresAt: timestamp("expires_at").notNull(), - createdAt: timestamp("created_at").$defaultFn( +export const verifications = pgTable('verifications', { + id: text('id').primaryKey(), + identifier: text('identifier').notNull(), + value: text('value').notNull(), + expiresAt: timestamp('expires_at').notNull(), + createdAt: timestamp('created_at').$defaultFn( () => /* @__PURE__ */ new Date() ), - updatedAt: timestamp("updated_at").$defaultFn( + updatedAt: timestamp('updated_at').$defaultFn( () => /* @__PURE__ */ new Date() ), }) diff --git a/examples/react/projects/src/db/connection.ts b/examples/react/projects/src/db/connection.ts index 5a8ea8beb..2712baa58 100644 --- a/examples/react/projects/src/db/connection.ts +++ b/examples/react/projects/src/db/connection.ts @@ -1,4 +1,4 @@ -import "dotenv/config" -import { drizzle } from "drizzle-orm/node-postgres" +import 'dotenv/config' +import { drizzle } from 'drizzle-orm/node-postgres' export const db = drizzle(process.env.DATABASE_URL!, { casing: `snake_case` }) diff --git a/examples/react/projects/src/db/schema.ts b/examples/react/projects/src/db/schema.ts index 34df19e6a..cdd205c0a 100644 --- a/examples/react/projects/src/db/schema.ts +++ b/examples/react/projects/src/db/schema.ts @@ -5,11 +5,11 @@ import { timestamp, varchar, text, -} from "drizzle-orm/pg-core" -import { createSchemaFactory } from "drizzle-zod" -import { z } from "zod" -export * from "./auth-schema" -import { users } from "./auth-schema" +} from 'drizzle-orm/pg-core' +import { createSchemaFactory } from 'drizzle-zod' +import { z } from 'zod' +export * from './auth-schema' +import { users } from './auth-schema' const { createInsertSchema, createSelectSchema, createUpdateSchema } = createSchemaFactory({ zodInstance: z }) @@ -18,11 +18,11 @@ export const projectsTable = pgTable(`projects`, { id: integer().primaryKey().generatedAlwaysAsIdentity(), name: varchar({ length: 255 }).notNull(), description: text(), - shared_user_ids: text("shared_user_ids").array().notNull().default([]), + shared_user_ids: text('shared_user_ids').array().notNull().default([]), created_at: timestamp({ withTimezone: true }).notNull().defaultNow(), - owner_id: text("owner_id") + owner_id: text('owner_id') .notNull() - .references(() => users.id, { onDelete: "cascade" }), + .references(() => users.id, { onDelete: 'cascade' }), }) export const todosTable = pgTable(`todos`, { @@ -30,13 +30,13 @@ export const todosTable = pgTable(`todos`, { text: varchar({ length: 500 }).notNull(), completed: boolean().notNull().default(false), created_at: timestamp({ withTimezone: true }).notNull().defaultNow(), - user_id: text("user_id") + user_id: text('user_id') .notNull() - .references(() => users.id, { onDelete: "cascade" }), - project_id: integer("project_id") + .references(() => users.id, { onDelete: 'cascade' }), + project_id: integer('project_id') .notNull() - .references(() => projectsTable.id, { onDelete: "cascade" }), - user_ids: text("user_ids").array().notNull().default([]), + .references(() => projectsTable.id, { onDelete: 'cascade' }), + user_ids: text('user_ids').array().notNull().default([]), }) export const selectProjectSchema = createSelectSchema(projectsTable) diff --git a/examples/react/projects/src/lib/auth-client.ts b/examples/react/projects/src/lib/auth-client.ts index 8665c3b11..939114361 100644 --- a/examples/react/projects/src/lib/auth-client.ts +++ b/examples/react/projects/src/lib/auth-client.ts @@ -1,2 +1,2 @@ -import { createAuthClient } from "better-auth/react" +import { createAuthClient } from 'better-auth/react' export const authClient = createAuthClient() diff --git a/examples/react/projects/src/lib/auth.ts b/examples/react/projects/src/lib/auth.ts index f423c5fdc..22426df53 100644 --- a/examples/react/projects/src/lib/auth.ts +++ b/examples/react/projects/src/lib/auth.ts @@ -1,11 +1,11 @@ -import { betterAuth } from "better-auth" -import { drizzleAdapter } from "better-auth/adapters/drizzle" -import { db } from "@/db/connection" // your drizzle instance -import * as schema from "@/db/auth-schema" +import { betterAuth } from 'better-auth' +import { drizzleAdapter } from 'better-auth/adapters/drizzle' +import { db } from '@/db/connection' // your drizzle instance +import * as schema from '@/db/auth-schema' export const auth = betterAuth({ database: drizzleAdapter(db, { - provider: "pg", + provider: 'pg', usePlural: true, schema, // debugLogs: true, @@ -13,10 +13,10 @@ export const auth = betterAuth({ emailAndPassword: { enabled: true, // Disable signup in production, allow in dev - disableSignUp: process.env.NODE_ENV === "production", - minPasswordLength: process.env.NODE_ENV === "production" ? 8 : 1, + disableSignUp: process.env.NODE_ENV === 'production', + minPasswordLength: process.env.NODE_ENV === 'production' ? 8 : 1, }, trustedOrigins: [ - "http://localhost:5173", // Vite dev server + 'http://localhost:5173', // Vite dev server ], }) diff --git a/examples/react/projects/src/lib/collections.ts b/examples/react/projects/src/lib/collections.ts index 336466dbe..235969dd2 100644 --- a/examples/react/projects/src/lib/collections.ts +++ b/examples/react/projects/src/lib/collections.ts @@ -1,20 +1,20 @@ -import { createCollection } from "@tanstack/react-db" -import { queryCollectionOptions } from "@tanstack/query-db-collection" -import { QueryClient } from "@tanstack/query-core" +import { createCollection } from '@tanstack/react-db' +import { queryCollectionOptions } from '@tanstack/query-db-collection' +import { QueryClient } from '@tanstack/query-core' import { selectTodoSchema, selectProjectSchema, selectUsersSchema, -} from "@/db/schema" -import { trpc } from "@/lib/trpc-client" +} from '@/db/schema' +import { trpc } from '@/lib/trpc-client' // Create a query client for query collections const queryClient = new QueryClient() export const usersCollection = createCollection( queryCollectionOptions({ - id: "users", - queryKey: ["users"], + id: 'users', + queryKey: ['users'], // Poll for updates every 5 seconds refetchInterval: 5000, queryFn: async () => { @@ -32,8 +32,8 @@ export const usersCollection = createCollection( ) export const projectCollection = createCollection( queryCollectionOptions({ - id: "projects", - queryKey: ["projects"], + id: 'projects', + queryKey: ['projects'], // Poll for updates every 5 seconds refetchInterval: 5000, queryFn: async () => { @@ -78,8 +78,8 @@ export const projectCollection = createCollection( export const todoCollection = createCollection( queryCollectionOptions({ - id: "todos", - queryKey: ["todos"], + id: 'todos', + queryKey: ['todos'], // Poll for updates every 5 seconds refetchInterval: 5000, queryFn: async () => { diff --git a/examples/react/projects/src/lib/trpc-client.ts b/examples/react/projects/src/lib/trpc-client.ts index d03bf6922..11b29a321 100644 --- a/examples/react/projects/src/lib/trpc-client.ts +++ b/examples/react/projects/src/lib/trpc-client.ts @@ -1,13 +1,13 @@ -import { createTRPCProxyClient, httpBatchLink } from "@trpc/client" -import type { AppRouter } from "@/routes/api/trpc/$" +import { createTRPCProxyClient, httpBatchLink } from '@trpc/client' +import type { AppRouter } from '@/routes/api/trpc/$' export const trpc = createTRPCProxyClient({ links: [ httpBatchLink({ - url: "/api/trpc", + url: '/api/trpc', async headers() { return { - cookie: typeof document !== "undefined" ? document.cookie : "", + cookie: typeof document !== 'undefined' ? document.cookie : '', } }, }), diff --git a/examples/react/projects/src/lib/trpc.ts b/examples/react/projects/src/lib/trpc.ts index 8843140d1..98e498464 100644 --- a/examples/react/projects/src/lib/trpc.ts +++ b/examples/react/projects/src/lib/trpc.ts @@ -1,6 +1,6 @@ -import { initTRPC, TRPCError } from "@trpc/server" -import { auth } from "@/lib/auth" -import { db } from "@/db/connection" +import { initTRPC, TRPCError } from '@trpc/server' +import { auth } from '@/lib/auth' +import { db } from '@/db/connection' export type Context = { session: Awaited> @@ -15,7 +15,7 @@ export const middleware = t.middleware export const isAuthed = middleware(async ({ ctx, next }) => { if (!ctx.session?.user) { - throw new TRPCError({ code: "UNAUTHORIZED" }) + throw new TRPCError({ code: 'UNAUTHORIZED' }) } return next({ ctx: { diff --git a/examples/react/projects/src/lib/trpc/projects.ts b/examples/react/projects/src/lib/trpc/projects.ts index fd9de7132..dcf6e7a45 100644 --- a/examples/react/projects/src/lib/trpc/projects.ts +++ b/examples/react/projects/src/lib/trpc/projects.ts @@ -1,12 +1,12 @@ -import { router, authedProcedure } from "@/lib/trpc" -import { z } from "zod" -import { TRPCError } from "@trpc/server" -import { eq, and, sql } from "drizzle-orm" +import { router, authedProcedure } from '@/lib/trpc' +import { z } from 'zod' +import { TRPCError } from '@trpc/server' +import { eq, and, sql } from 'drizzle-orm' import { projectsTable, createProjectSchema, updateProjectSchema, -} from "@/db/schema" +} from '@/db/schema' export const projectsRouter = router({ getAll: authedProcedure.query(async ({ ctx }) => { @@ -24,8 +24,8 @@ export const projectsRouter = router({ .mutation(async ({ ctx, input }) => { if (input.owner_id !== ctx.session.user.id) { throw new TRPCError({ - code: "FORBIDDEN", - message: "You can only create projects you own", + code: 'FORBIDDEN', + message: 'You can only create projects you own', }) } @@ -58,9 +58,9 @@ export const projectsRouter = router({ if (!updatedItem) { throw new TRPCError({ - code: "NOT_FOUND", + code: 'NOT_FOUND', message: - "Project not found or you do not have permission to update it", + 'Project not found or you do not have permission to update it', }) } @@ -82,9 +82,9 @@ export const projectsRouter = router({ if (!deletedItem) { throw new TRPCError({ - code: "NOT_FOUND", + code: 'NOT_FOUND', message: - "Project not found or you do not have permission to delete it", + 'Project not found or you do not have permission to delete it', }) } diff --git a/examples/react/projects/src/lib/trpc/todos.ts b/examples/react/projects/src/lib/trpc/todos.ts index 127d36cca..d6825804e 100644 --- a/examples/react/projects/src/lib/trpc/todos.ts +++ b/examples/react/projects/src/lib/trpc/todos.ts @@ -1,8 +1,8 @@ -import { router, authedProcedure } from "@/lib/trpc" -import { z } from "zod" -import { TRPCError } from "@trpc/server" -import { eq, and, arrayContains } from "drizzle-orm" -import { todosTable, createTodoSchema, updateTodoSchema } from "@/db/schema" +import { router, authedProcedure } from '@/lib/trpc' +import { z } from 'zod' +import { TRPCError } from '@trpc/server' +import { eq, and, arrayContains } from 'drizzle-orm' +import { todosTable, createTodoSchema, updateTodoSchema } from '@/db/schema' export const todosRouter = router({ getAll: authedProcedure.query(async ({ ctx }) => { @@ -44,8 +44,8 @@ export const todosRouter = router({ if (!updatedItem) { throw new TRPCError({ - code: "NOT_FOUND", - message: "Todo not found or you do not have permission to update it", + code: 'NOT_FOUND', + message: 'Todo not found or you do not have permission to update it', }) } @@ -67,8 +67,8 @@ export const todosRouter = router({ if (!deletedItem) { throw new TRPCError({ - code: "NOT_FOUND", - message: "Todo not found or you do not have permission to delete it", + code: 'NOT_FOUND', + message: 'Todo not found or you do not have permission to delete it', }) } diff --git a/examples/react/projects/src/lib/trpc/users.ts b/examples/react/projects/src/lib/trpc/users.ts index 86f887753..13c730bdd 100644 --- a/examples/react/projects/src/lib/trpc/users.ts +++ b/examples/react/projects/src/lib/trpc/users.ts @@ -1,7 +1,7 @@ -import { router, authedProcedure } from "@/lib/trpc" -import { z } from "zod" -import { TRPCError } from "@trpc/server" -import { users } from "@/db/schema" +import { router, authedProcedure } from '@/lib/trpc' +import { z } from 'zod' +import { TRPCError } from '@trpc/server' +import { users } from '@/db/schema' export const usersRouter = router({ getAll: authedProcedure.query(async ({ ctx }) => { @@ -11,7 +11,7 @@ export const usersRouter = router({ create: authedProcedure.input(z.any()).mutation(async () => { throw new TRPCError({ - code: "FORBIDDEN", + code: 'FORBIDDEN', message: "Can't create new users through API", }) }), @@ -20,7 +20,7 @@ export const usersRouter = router({ .input(z.object({ id: z.string(), data: z.any() })) .mutation(async () => { throw new TRPCError({ - code: "FORBIDDEN", + code: 'FORBIDDEN', message: "Can't edit users through API", }) }), @@ -29,7 +29,7 @@ export const usersRouter = router({ .input(z.object({ id: z.string() })) .mutation(async () => { throw new TRPCError({ - code: "FORBIDDEN", + code: 'FORBIDDEN', message: "Can't delete users through API", }) }), diff --git a/examples/react/projects/src/router.tsx b/examples/react/projects/src/router.tsx index e025c0f7f..50504c678 100644 --- a/examples/react/projects/src/router.tsx +++ b/examples/react/projects/src/router.tsx @@ -1,9 +1,9 @@ -import { createRouter as createTanstackRouter } from "@tanstack/react-router" +import { createRouter as createTanstackRouter } from '@tanstack/react-router' // Import the generated route tree -import { routeTree } from "./routeTree.gen" +import { routeTree } from './routeTree.gen' -import "./styles.css" +import './styles.css' // Create a new router instance export function getRouter() { diff --git a/examples/react/projects/src/routes/__root.tsx b/examples/react/projects/src/routes/__root.tsx index bb4aa1c89..477a34019 100644 --- a/examples/react/projects/src/routes/__root.tsx +++ b/examples/react/projects/src/routes/__root.tsx @@ -1,13 +1,13 @@ -import * as React from "react" +import * as React from 'react' import { HeadContent, Outlet, Scripts, createRootRoute, -} from "@tanstack/react-router" -import { TanStackRouterDevtools } from "@tanstack/react-router-devtools" +} from '@tanstack/react-router' +import { TanStackRouterDevtools } from '@tanstack/react-router-devtools' -import appCss from "../styles.css?url" +import appCss from '../styles.css?url' export const Route = createRootRoute({ head: () => ({ diff --git a/examples/react/projects/src/routes/_authenticated.tsx b/examples/react/projects/src/routes/_authenticated.tsx index 749668ea4..c119ed40c 100644 --- a/examples/react/projects/src/routes/_authenticated.tsx +++ b/examples/react/projects/src/routes/_authenticated.tsx @@ -1,13 +1,13 @@ -import { useEffect, useState } from "react" +import { useEffect, useState } from 'react' import { Link, Outlet, createFileRoute, useNavigate, -} from "@tanstack/react-router" -import { useLiveQuery } from "@tanstack/react-db" -import { authClient } from "@/lib/auth-client" -import { projectCollection } from "@/lib/collections" +} from '@tanstack/react-router' +import { useLiveQuery } from '@tanstack/react-db' +import { authClient } from '@/lib/auth-client' +import { projectCollection } from '@/lib/collections' export const Route = createFileRoute(`/_authenticated`)({ component: AuthenticatedLayout, diff --git a/examples/react/projects/src/routes/_authenticated/index.tsx b/examples/react/projects/src/routes/_authenticated/index.tsx index bc3990cd2..a8f8cb9ab 100644 --- a/examples/react/projects/src/routes/_authenticated/index.tsx +++ b/examples/react/projects/src/routes/_authenticated/index.tsx @@ -1,8 +1,8 @@ -import { useEffect } from "react" -import { createFileRoute, redirect, useNavigate } from "@tanstack/react-router" -import { useLiveQuery } from "@tanstack/react-db" -import { projectCollection, todoCollection } from "@/lib/collections" -import { authClient } from "@/lib/auth-client" +import { useEffect } from 'react' +import { createFileRoute, redirect, useNavigate } from '@tanstack/react-router' +import { useLiveQuery } from '@tanstack/react-db' +import { projectCollection, todoCollection } from '@/lib/collections' +import { authClient } from '@/lib/auth-client' export const Route = createFileRoute(`/_authenticated/`)({ component: IndexRedirect, diff --git a/examples/react/projects/src/routes/_authenticated/project/$projectId.tsx b/examples/react/projects/src/routes/_authenticated/project/$projectId.tsx index 3a648964f..7c3084f23 100644 --- a/examples/react/projects/src/routes/_authenticated/project/$projectId.tsx +++ b/examples/react/projects/src/routes/_authenticated/project/$projectId.tsx @@ -1,13 +1,13 @@ -import { createFileRoute } from "@tanstack/react-router" -import { eq, useLiveQuery } from "@tanstack/react-db" -import { useState } from "react" -import type { Todo } from "@/db/schema" -import { authClient } from "@/lib/auth-client" +import { createFileRoute } from '@tanstack/react-router' +import { eq, useLiveQuery } from '@tanstack/react-db' +import { useState } from 'react' +import type { Todo } from '@/db/schema' +import { authClient } from '@/lib/auth-client' import { projectCollection, todoCollection, usersCollection, -} from "@/lib/collections" +} from '@/lib/collections' export const Route = createFileRoute(`/_authenticated/project/$projectId`)({ component: ProjectPage, diff --git a/examples/react/projects/src/routes/api/auth.ts b/examples/react/projects/src/routes/api/auth.ts index c8d288f8b..4b3b9bfbf 100644 --- a/examples/react/projects/src/routes/api/auth.ts +++ b/examples/react/projects/src/routes/api/auth.ts @@ -1,5 +1,5 @@ -import { createFileRoute } from "@tanstack/react-router" -import { auth } from "@/lib/auth" +import { createFileRoute } from '@tanstack/react-router' +import { auth } from '@/lib/auth' const serve = ({ request }: { request: Request }) => { return auth.handler(request) diff --git a/examples/react/projects/src/routes/api/trpc/$.ts b/examples/react/projects/src/routes/api/trpc/$.ts index e7438e56b..eb6071a4a 100644 --- a/examples/react/projects/src/routes/api/trpc/$.ts +++ b/examples/react/projects/src/routes/api/trpc/$.ts @@ -1,11 +1,11 @@ -import { createFileRoute } from "@tanstack/react-router" -import { fetchRequestHandler } from "@trpc/server/adapters/fetch" -import { router } from "@/lib/trpc" -import { projectsRouter } from "@/lib/trpc/projects" -import { todosRouter } from "@/lib/trpc/todos" -import { usersRouter } from "@/lib/trpc/users" -import { db } from "@/db/connection" -import { auth } from "@/lib/auth" +import { createFileRoute } from '@tanstack/react-router' +import { fetchRequestHandler } from '@trpc/server/adapters/fetch' +import { router } from '@/lib/trpc' +import { projectsRouter } from '@/lib/trpc/projects' +import { todosRouter } from '@/lib/trpc/todos' +import { usersRouter } from '@/lib/trpc/users' +import { db } from '@/db/connection' +import { auth } from '@/lib/auth' export const appRouter = router({ projects: projectsRouter, diff --git a/examples/react/projects/src/routes/login.tsx b/examples/react/projects/src/routes/login.tsx index 09512463c..1f2a039c1 100644 --- a/examples/react/projects/src/routes/login.tsx +++ b/examples/react/projects/src/routes/login.tsx @@ -1,7 +1,7 @@ -import { useState } from "react" -import { createFileRoute } from "@tanstack/react-router" -import type { FormEvent } from "react" -import { authClient } from "@/lib/auth-client" +import { useState } from 'react' +import { createFileRoute } from '@tanstack/react-router' +import type { FormEvent } from 'react' +import { authClient } from '@/lib/auth-client' export const Route = createFileRoute(`/login`)({ component: Layout, diff --git a/examples/react/projects/src/start.tsx b/examples/react/projects/src/start.tsx index de7b170ed..9e8694bab 100644 --- a/examples/react/projects/src/start.tsx +++ b/examples/react/projects/src/start.tsx @@ -1,4 +1,4 @@ -import { createStart } from "@tanstack/react-start" +import { createStart } from '@tanstack/react-start' export const startInstance = createStart(() => { return { diff --git a/examples/react/projects/src/styles.css b/examples/react/projects/src/styles.css index 80cb92ada..06f1bca4b 100644 --- a/examples/react/projects/src/styles.css +++ b/examples/react/projects/src/styles.css @@ -1,15 +1,15 @@ -@import "tailwindcss"; +@import 'tailwindcss'; body { @apply m-0; font-family: - -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", - "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; + -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', + 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } code { font-family: - source-code-pro, Menlo, Monaco, Consolas, "Courier New", monospace; + source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace; } diff --git a/examples/react/projects/vite.config.ts b/examples/react/projects/vite.config.ts index 6708900ed..7307fb0e8 100644 --- a/examples/react/projects/vite.config.ts +++ b/examples/react/projects/vite.config.ts @@ -1,8 +1,8 @@ -import { defineConfig } from "vite" -import { tanstackStart } from "@tanstack/react-start/plugin/vite" -import viteTsConfigPaths from "vite-tsconfig-paths" -import tailwindcss from "@tailwindcss/vite" -import react from "@vitejs/plugin-react" +import { defineConfig } from 'vite' +import { tanstackStart } from '@tanstack/react-start/plugin/vite' +import viteTsConfigPaths from 'vite-tsconfig-paths' +import tailwindcss from '@tailwindcss/vite' +import react from '@vitejs/plugin-react' const config = defineConfig({ plugins: [ diff --git a/examples/react/todo/docker-compose.yml b/examples/react/todo/docker-compose.yml index 9b6ddcffe..cb03bb1b3 100644 --- a/examples/react/todo/docker-compose.yml +++ b/examples/react/todo/docker-compose.yml @@ -1,4 +1,4 @@ -version: "3.8" +version: '3.8' services: postgres: image: postgres:17-alpine @@ -7,7 +7,7 @@ services: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres ports: - - "54322:5432" + - '54322:5432' volumes: - ./postgres.conf:/etc/postgresql/postgresql.conf:ro tmpfs: @@ -18,7 +18,7 @@ services: - -c - config_file=/etc/postgresql/postgresql.conf healthcheck: - test: ["CMD-SHELL", "pg_isready -U postgres"] + test: ['CMD-SHELL', 'pg_isready -U postgres'] interval: 5s timeout: 5s retries: 5 @@ -37,11 +37,11 @@ services: trailbase: image: trailbase/trailbase:latest ports: - - "${PORT:-4000}:4000" + - '${PORT:-4000}:4000' restart: unless-stopped volumes: - ./traildepot:/app/traildepot - command: "/app/trail --data-dir /app/traildepot run --address 0.0.0.0:4000 --dev" + command: '/app/trail --data-dir /app/traildepot run --address 0.0.0.0:4000 --dev' volumes: postgres_data: diff --git a/examples/react/todo/drizzle.config.ts b/examples/react/todo/drizzle.config.ts index 550633431..486be88c9 100644 --- a/examples/react/todo/drizzle.config.ts +++ b/examples/react/todo/drizzle.config.ts @@ -1,4 +1,4 @@ -import type { Config } from "drizzle-kit" +import type { Config } from 'drizzle-kit' export default { schema: `./src/db/schema.ts`, diff --git a/examples/react/todo/scripts/migrate.ts b/examples/react/todo/scripts/migrate.ts index ee0089f38..d58ebc44e 100644 --- a/examples/react/todo/scripts/migrate.ts +++ b/examples/react/todo/scripts/migrate.ts @@ -1,7 +1,7 @@ -import { drizzle } from "drizzle-orm/node-postgres" -import { migrate } from "drizzle-orm/node-postgres/migrator" -import pkg from "pg" -import * as dotenv from "dotenv" +import { drizzle } from 'drizzle-orm/node-postgres' +import { migrate } from 'drizzle-orm/node-postgres/migrator' +import pkg from 'pg' +import * as dotenv from 'dotenv' dotenv.config() diff --git a/examples/react/todo/src/api/server.ts b/examples/react/todo/src/api/server.ts index 4aa55431d..948d2442e 100644 --- a/examples/react/todo/src/api/server.ts +++ b/examples/react/todo/src/api/server.ts @@ -1,14 +1,14 @@ -import express from "express" -import cors from "cors" -import { sql } from "../db/postgres" +import express from 'express' +import cors from 'cors' +import { sql } from '../db/postgres' import { validateInsertConfig, validateInsertTodo, validateUpdateConfig, validateUpdateTodo, -} from "../db/validation" -import type { Express } from "express" -import type { Txid } from "@tanstack/electric-db-collection" +} from '../db/validation' +import type { Express } from 'express' +import type { Txid } from '@tanstack/electric-db-collection' // Create Express app const app: Express = express() diff --git a/examples/react/todo/src/components/NotFound.tsx b/examples/react/todo/src/components/NotFound.tsx index 2e892fafd..60caed4d7 100644 --- a/examples/react/todo/src/components/NotFound.tsx +++ b/examples/react/todo/src/components/NotFound.tsx @@ -1,4 +1,4 @@ -import { Link } from "@tanstack/react-router" +import { Link } from '@tanstack/react-router' export function NotFound() { return ( diff --git a/examples/react/todo/src/components/TodoApp.tsx b/examples/react/todo/src/components/TodoApp.tsx index 0fbcb65ed..9a0225436 100644 --- a/examples/react/todo/src/components/TodoApp.tsx +++ b/examples/react/todo/src/components/TodoApp.tsx @@ -1,11 +1,11 @@ -import React, { useState } from "react" -import { Link } from "@tanstack/react-router" -import { debounceStrategy, usePacedMutations } from "@tanstack/react-db" -import type { FormEvent } from "react" -import type { Collection, Transaction } from "@tanstack/react-db" +import React, { useState } from 'react' +import { Link } from '@tanstack/react-router' +import { debounceStrategy, usePacedMutations } from '@tanstack/react-db' +import type { FormEvent } from 'react' +import type { Collection, Transaction } from '@tanstack/react-db' -import type { SelectConfig, SelectTodo } from "@/db/validation" -import { getComplementaryColor } from "@/lib/color" +import type { SelectConfig, SelectTodo } from '@/db/validation' +import { getComplementaryColor } from '@/lib/color' interface TodoAppProps { todos: Array @@ -165,8 +165,8 @@ export function TodoApp({ todosToToggle.map((todo) => todo.id), (drafts) => drafts.forEach( - (draft) => (draft.completed = !draft.completed) - ) + (draft) => (draft.completed = !draft.completed), + ), ) }} > diff --git a/examples/react/todo/src/db/index.ts b/examples/react/todo/src/db/index.ts index 5a856e693..fbd0af99d 100644 --- a/examples/react/todo/src/db/index.ts +++ b/examples/react/todo/src/db/index.ts @@ -1,6 +1,6 @@ -import { drizzle } from "drizzle-orm/node-postgres" -import { Pool } from "pg" -import * as schema from "./schema" +import { drizzle } from 'drizzle-orm/node-postgres' +import { Pool } from 'pg' +import * as schema from './schema' // Create a PostgreSQL pool const pool = new Pool({ diff --git a/examples/react/todo/src/db/postgres.ts b/examples/react/todo/src/db/postgres.ts index 674348433..9a0c0437c 100644 --- a/examples/react/todo/src/db/postgres.ts +++ b/examples/react/todo/src/db/postgres.ts @@ -1,4 +1,4 @@ -import postgres from "postgres" +import postgres from 'postgres' // Create a postgres instance export const sql = postgres({ diff --git a/examples/react/todo/src/db/schema.ts b/examples/react/todo/src/db/schema.ts index 4bf9e0d0a..bed8f98a8 100644 --- a/examples/react/todo/src/db/schema.ts +++ b/examples/react/todo/src/db/schema.ts @@ -1,4 +1,4 @@ -import { boolean, pgTable, serial, text, timestamp } from "drizzle-orm/pg-core" +import { boolean, pgTable, serial, text, timestamp } from 'drizzle-orm/pg-core' export const todos = pgTable(`todos`, { id: serial(`id`).primaryKey(), diff --git a/examples/react/todo/src/db/validation.ts b/examples/react/todo/src/db/validation.ts index 404afd0d4..2fa8408af 100644 --- a/examples/react/todo/src/db/validation.ts +++ b/examples/react/todo/src/db/validation.ts @@ -1,6 +1,6 @@ -import { createInsertSchema, createSelectSchema } from "drizzle-zod" -import { config, todos } from "./schema" -import type { z } from "zod" +import { createInsertSchema, createSelectSchema } from 'drizzle-zod' +import { config, todos } from './schema' +import type { z } from 'zod' // Auto-generated schemas from Drizzle schema (omit auto-generated fields) export const insertTodoSchema = createInsertSchema(todos).omit({ diff --git a/examples/react/todo/src/index.css b/examples/react/todo/src/index.css index 5211a0414..6dafed23c 100644 --- a/examples/react/todo/src/index.css +++ b/examples/react/todo/src/index.css @@ -1,4 +1,4 @@ -@import "tailwindcss"; +@import 'tailwindcss'; html, body { @@ -21,7 +21,7 @@ button { body { font: - 14px "Helvetica Neue", + 14px 'Helvetica Neue', Helvetica, Arial, sans-serif; diff --git a/examples/react/todo/src/lib/api.ts b/examples/react/todo/src/lib/api.ts index c6e070b31..e066cdbe6 100644 --- a/examples/react/todo/src/lib/api.ts +++ b/examples/react/todo/src/lib/api.ts @@ -1,4 +1,4 @@ -import type { SelectConfig, SelectTodo } from "../db/validation" +import type { SelectConfig, SelectTodo } from '../db/validation' // API helper for todos and config const API_BASE_URL = `/api` @@ -19,11 +19,11 @@ export const api = { return response.json() }, create: async ( - todo: Partial + todo: Partial, ): Promise<{ todo: SelectTodo; txid: number }> => { const response = await fetch(`${API_BASE_URL}/todos`, { method: `POST`, - headers: { "Content-Type": `application/json` }, + headers: { 'Content-Type': `application/json` }, body: JSON.stringify(todo), }) if (!response.ok) @@ -32,11 +32,11 @@ export const api = { }, update: async ( id: unknown, - changes: Partial + changes: Partial, ): Promise<{ todo: SelectTodo; txid: number }> => { const response = await fetch(`${API_BASE_URL}/todos/${id}`, { method: `PUT`, - headers: { "Content-Type": `application/json` }, + headers: { 'Content-Type': `application/json` }, body: JSON.stringify(changes), }) if (!response.ok) @@ -44,7 +44,7 @@ export const api = { return response.json() }, delete: async ( - id: unknown + id: unknown, ): Promise<{ success: boolean; txid: number }> => { const response = await fetch(`${API_BASE_URL}/todos/${id}`, { method: `DELETE`, @@ -70,11 +70,11 @@ export const api = { return response.json() }, create: async ( - config: Partial + config: Partial, ): Promise<{ config: SelectConfig; txid: number }> => { const response = await fetch(`${API_BASE_URL}/config`, { method: `POST`, - headers: { "Content-Type": `application/json` }, + headers: { 'Content-Type': `application/json` }, body: JSON.stringify(config), }) if (!response.ok) @@ -83,11 +83,11 @@ export const api = { }, update: async ( id: number, - changes: Partial + changes: Partial, ): Promise<{ config: SelectConfig; txid: number }> => { const response = await fetch(`${API_BASE_URL}/config/${id}`, { method: `PUT`, - headers: { "Content-Type": `application/json` }, + headers: { 'Content-Type': `application/json` }, body: JSON.stringify(changes), }) if (!response.ok) diff --git a/examples/react/todo/src/lib/collections.ts b/examples/react/todo/src/lib/collections.ts index 5e41bac92..689372b80 100644 --- a/examples/react/todo/src/lib/collections.ts +++ b/examples/react/todo/src/lib/collections.ts @@ -1,12 +1,12 @@ -import { createCollection } from "@tanstack/react-db" -import { electricCollectionOptions } from "@tanstack/electric-db-collection" -import { queryCollectionOptions } from "@tanstack/query-db-collection" -import { trailBaseCollectionOptions } from "@tanstack/trailbase-db-collection" -import { QueryClient } from "@tanstack/query-core" -import { initClient } from "trailbase" -import { selectConfigSchema, selectTodoSchema } from "../db/validation" -import { api } from "./api" -import type { SelectConfig, SelectTodo } from "../db/validation" +import { createCollection } from '@tanstack/react-db' +import { electricCollectionOptions } from '@tanstack/electric-db-collection' +import { queryCollectionOptions } from '@tanstack/query-db-collection' +import { trailBaseCollectionOptions } from '@tanstack/trailbase-db-collection' +import { QueryClient } from '@tanstack/query-core' +import { initClient } from 'trailbase' +import { selectConfigSchema, selectTodoSchema } from '../db/validation' +import { api } from './api' +import type { SelectConfig, SelectTodo } from '../db/validation' // Create a query client for query collections const queryClient = new QueryClient() @@ -48,7 +48,7 @@ export const electricTodoCollection = createCollection( } const response = await api.todos.update(original.id, changes) return response.txid - }) + }), ) return { txid: txids } }, @@ -61,11 +61,11 @@ export const electricTodoCollection = createCollection( } const response = await api.todos.delete(original.id) return response.txid - }) + }), ) return { txid: txids } }, - }) + }), ) // Query Todo Collection @@ -102,7 +102,7 @@ export const queryTodoCollection = createCollection( throw new Error(`Original todo not found for update`) } return await api.todos.update(original.id, changes) - }) + }), ) }, onDelete: async ({ transaction }) => { @@ -113,10 +113,10 @@ export const queryTodoCollection = createCollection( throw new Error(`Original todo not found for delete`) } await api.todos.delete(original.id) - }) + }), ) }, - }) + }), ) type Todo = { @@ -143,7 +143,7 @@ export const trailBaseTodoCollection = createCollection( created_at: (date) => Math.floor(date.valueOf() / 1000), updated_at: (date) => Math.floor(date.valueOf() / 1000), }, - }) + }), ) // Electric Config Collection @@ -175,11 +175,11 @@ export const electricConfigCollection = createCollection( } const response = await api.config.update(original.id, changes) return response.txid - }) + }), ) return { txid: txids } }, - }) + }), ) // Query Config Collection @@ -213,11 +213,11 @@ export const queryConfigCollection = createCollection( } const response = await api.config.update(original.id, changes) return response.txid - }) + }), ) return { txid: txids } }, - }) + }), ) type Config = { @@ -244,5 +244,5 @@ export const trailBaseConfigCollection = createCollection( created_at: (date) => Math.floor(date.valueOf() / 1000), updated_at: (date) => Math.floor(date.valueOf() / 1000), }, - }) + }), ) diff --git a/examples/react/todo/src/main.tsx b/examples/react/todo/src/main.tsx index 0218796d3..5368d1602 100644 --- a/examples/react/todo/src/main.tsx +++ b/examples/react/todo/src/main.tsx @@ -1,13 +1,13 @@ -import { StrictMode } from "react" -import { createRoot } from "react-dom/client" -import { RouterProvider } from "@tanstack/react-router" -import { getRouter } from "./router" -import "./index.css" +import { StrictMode } from 'react' +import { createRoot } from 'react-dom/client' +import { RouterProvider } from '@tanstack/react-router' +import { getRouter } from './router' +import './index.css' const router = getRouter() createRoot(document.getElementById(`root`)!).render( - + , ) diff --git a/examples/react/todo/src/router.tsx b/examples/react/todo/src/router.tsx index 75e151354..e4dfe3766 100644 --- a/examples/react/todo/src/router.tsx +++ b/examples/react/todo/src/router.tsx @@ -1,10 +1,10 @@ -import { createRouter as createTanstackRouter } from "@tanstack/react-router" +import { createRouter as createTanstackRouter } from '@tanstack/react-router' // Import the generated route tree -import { routeTree } from "./routeTree.gen" -import { NotFound } from "./components/NotFound" +import { routeTree } from './routeTree.gen' +import { NotFound } from './components/NotFound' -import "./styles.css" +import './styles.css' // Create a new router instance export function getRouter() { diff --git a/examples/react/todo/src/routes/__root.tsx b/examples/react/todo/src/routes/__root.tsx index 94dd0b516..e57101152 100644 --- a/examples/react/todo/src/routes/__root.tsx +++ b/examples/react/todo/src/routes/__root.tsx @@ -1,12 +1,12 @@ -import * as React from "react" +import * as React from 'react' import { HeadContent, Outlet, Scripts, createRootRoute, -} from "@tanstack/react-router" +} from '@tanstack/react-router' -import appCss from "../styles.css?url" +import appCss from '../styles.css?url' export const Route = createRootRoute({ head: () => ({ diff --git a/examples/react/todo/src/routes/api/config.$id.ts b/examples/react/todo/src/routes/api/config.$id.ts index 9acfec234..f60ef9a64 100644 --- a/examples/react/todo/src/routes/api/config.$id.ts +++ b/examples/react/todo/src/routes/api/config.$id.ts @@ -1,8 +1,8 @@ -import { createFileRoute } from "@tanstack/react-router" -import { json } from "@tanstack/react-start" -import { sql } from "../../db/postgres" -import { validateUpdateConfig } from "../../db/validation" -import type { Txid } from "@tanstack/electric-db-collection" +import { createFileRoute } from '@tanstack/react-router' +import { json } from '@tanstack/react-start' +import { sql } from '../../db/postgres' +import { validateUpdateConfig } from '../../db/validation' +import type { Txid } from '@tanstack/electric-db-collection' // Generate a transaction ID async function generateTxId(tx: any): Promise { @@ -36,7 +36,7 @@ export const Route = createFileRoute(`/api/config/$id`)({ error: `Failed to fetch config`, details: error instanceof Error ? error.message : String(error), }, - { status: 500 } + { status: 500 }, ) } }, @@ -76,7 +76,7 @@ export const Route = createFileRoute(`/api/config/$id`)({ error: `Failed to update config`, details: error instanceof Error ? error.message : String(error), }, - { status: 500 } + { status: 500 }, ) } }, @@ -111,7 +111,7 @@ export const Route = createFileRoute(`/api/config/$id`)({ error: `Failed to delete config`, details: error instanceof Error ? error.message : String(error), }, - { status: 500 } + { status: 500 }, ) } }, diff --git a/examples/react/todo/src/routes/api/config.ts b/examples/react/todo/src/routes/api/config.ts index 2224720c2..c4ae48cc1 100644 --- a/examples/react/todo/src/routes/api/config.ts +++ b/examples/react/todo/src/routes/api/config.ts @@ -1,8 +1,8 @@ -import { createFileRoute } from "@tanstack/react-router" -import { json } from "@tanstack/react-start" -import { sql } from "../../db/postgres" -import { validateInsertConfig } from "../../db/validation" -import type { Txid } from "@tanstack/electric-db-collection" +import { createFileRoute } from '@tanstack/react-router' +import { json } from '@tanstack/react-start' +import { sql } from '../../db/postgres' +import { validateInsertConfig } from '../../db/validation' +import type { Txid } from '@tanstack/electric-db-collection' // Generate a transaction ID async function generateTxId(tx: any): Promise { @@ -30,7 +30,7 @@ export const Route = createFileRoute(`/api/config`)({ error: `Failed to fetch config`, details: error instanceof Error ? error.message : String(error), }, - { status: 500 } + { status: 500 }, ) } }, @@ -59,7 +59,7 @@ export const Route = createFileRoute(`/api/config`)({ error: `Failed to create config`, details: error instanceof Error ? error.message : String(error), }, - { status: 500 } + { status: 500 }, ) } }, diff --git a/examples/react/todo/src/routes/api/todos.$id.ts b/examples/react/todo/src/routes/api/todos.$id.ts index 12b4cf9e2..5f57126cd 100644 --- a/examples/react/todo/src/routes/api/todos.$id.ts +++ b/examples/react/todo/src/routes/api/todos.$id.ts @@ -1,8 +1,8 @@ -import { createFileRoute } from "@tanstack/react-router" -import { json } from "@tanstack/react-start" -import { sql } from "../../db/postgres" -import { validateUpdateTodo } from "../../db/validation" -import type { Txid } from "@tanstack/electric-db-collection" +import { createFileRoute } from '@tanstack/react-router' +import { json } from '@tanstack/react-start' +import { sql } from '../../db/postgres' +import { validateUpdateTodo } from '../../db/validation' +import type { Txid } from '@tanstack/electric-db-collection' // Generate a transaction ID async function generateTxId(tx: any): Promise { @@ -36,7 +36,7 @@ export const Route = createFileRoute(`/api/todos/$id`)({ error: `Failed to fetch todo`, details: error instanceof Error ? error.message : String(error), }, - { status: 500 } + { status: 500 }, ) } }, @@ -76,7 +76,7 @@ export const Route = createFileRoute(`/api/todos/$id`)({ error: `Failed to update todo`, details: error instanceof Error ? error.message : String(error), }, - { status: 500 } + { status: 500 }, ) } }, @@ -111,7 +111,7 @@ export const Route = createFileRoute(`/api/todos/$id`)({ error: `Failed to delete todo`, details: error instanceof Error ? error.message : String(error), }, - { status: 500 } + { status: 500 }, ) } }, diff --git a/examples/react/todo/src/routes/api/todos.ts b/examples/react/todo/src/routes/api/todos.ts index 72b45f3e8..22fe77953 100644 --- a/examples/react/todo/src/routes/api/todos.ts +++ b/examples/react/todo/src/routes/api/todos.ts @@ -1,8 +1,8 @@ -import { createFileRoute } from "@tanstack/react-router" -import { json } from "@tanstack/react-start" -import { sql } from "../../db/postgres" -import { validateInsertTodo } from "../../db/validation" -import type { Txid } from "@tanstack/electric-db-collection" +import { createFileRoute } from '@tanstack/react-router' +import { json } from '@tanstack/react-start' +import { sql } from '../../db/postgres' +import { validateInsertTodo } from '../../db/validation' +import type { Txid } from '@tanstack/electric-db-collection' // Generate a transaction ID async function generateTxId(tx: any): Promise { @@ -34,7 +34,7 @@ export const Route = createFileRoute(`/api/todos`)({ error: `Failed to fetch todos`, details: error instanceof Error ? error.message : String(error), }, - { status: 500 } + { status: 500 }, ) } }, @@ -62,7 +62,7 @@ export const Route = createFileRoute(`/api/todos`)({ error: `Failed to create todo`, details: error instanceof Error ? error.message : String(error), }, - { status: 500 } + { status: 500 }, ) } }, diff --git a/examples/react/todo/src/routes/electric.tsx b/examples/react/todo/src/routes/electric.tsx index 461af9ecb..61629b81f 100644 --- a/examples/react/todo/src/routes/electric.tsx +++ b/examples/react/todo/src/routes/electric.tsx @@ -1,13 +1,13 @@ -import * as React from "react" -import { createFileRoute } from "@tanstack/react-router" -import { useLiveQuery } from "@tanstack/react-db" +import * as React from 'react' +import { createFileRoute } from '@tanstack/react-router' +import { useLiveQuery } from '@tanstack/react-db' import { electricConfigCollection, electricTodoCollection, -} from "../lib/collections" -import { TodoApp } from "../components/TodoApp" -import { api } from "../lib/api" -import type { Transaction } from "@tanstack/react-db" +} from '../lib/collections' +import { TodoApp } from '../components/TodoApp' +import { api } from '../lib/api' +import type { Transaction } from '@tanstack/react-db' export const Route = createFileRoute(`/electric`)({ component: ElectricPage, @@ -27,11 +27,11 @@ function ElectricPage() { const { data: todos } = useLiveQuery((q) => q .from({ todo: electricTodoCollection }) - .orderBy(({ todo }) => todo.created_at, `asc`) + .orderBy(({ todo }) => todo.created_at, `asc`), ) const { data: configData } = useLiveQuery((q) => - q.from({ config: electricConfigCollection }) + q.from({ config: electricConfigCollection }), ) // Electric collections use txid to track sync @@ -57,14 +57,14 @@ function ElectricPage() { } const response = await api.config.update( mutation.original.id, - mutation.changes + mutation.changes, ) txids.push(response.txid) } // Wait for all txids to sync back to the collection await Promise.all( - txids.map((txid) => electricConfigCollection.utils.awaitTxid(txid)) + txids.map((txid) => electricConfigCollection.utils.awaitTxid(txid)), ) } diff --git a/examples/react/todo/src/routes/index.tsx b/examples/react/todo/src/routes/index.tsx index 0986beb69..34e259689 100644 --- a/examples/react/todo/src/routes/index.tsx +++ b/examples/react/todo/src/routes/index.tsx @@ -1,5 +1,5 @@ -import * as React from "react" -import { Link, createFileRoute } from "@tanstack/react-router" +import * as React from 'react' +import { Link, createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute(`/`)({ component: HomePage, diff --git a/examples/react/todo/src/routes/query.tsx b/examples/react/todo/src/routes/query.tsx index f6a620296..62c0ad37d 100644 --- a/examples/react/todo/src/routes/query.tsx +++ b/examples/react/todo/src/routes/query.tsx @@ -1,10 +1,10 @@ -import * as React from "react" -import { createFileRoute } from "@tanstack/react-router" -import { useLiveQuery } from "@tanstack/react-db" -import { queryConfigCollection, queryTodoCollection } from "../lib/collections" -import { TodoApp } from "../components/TodoApp" -import { api } from "../lib/api" -import type { Transaction } from "@tanstack/react-db" +import * as React from 'react' +import { createFileRoute } from '@tanstack/react-router' +import { useLiveQuery } from '@tanstack/react-db' +import { queryConfigCollection, queryTodoCollection } from '../lib/collections' +import { TodoApp } from '../components/TodoApp' +import { api } from '../lib/api' +import type { Transaction } from '@tanstack/react-db' export const Route = createFileRoute(`/query`)({ component: QueryPage, @@ -24,11 +24,11 @@ function QueryPage() { const { data: todos } = useLiveQuery((q) => q .from({ todo: queryTodoCollection }) - .orderBy(({ todo }) => todo.created_at, `asc`) + .orderBy(({ todo }) => todo.created_at, `asc`), ) const { data: configData } = useLiveQuery((q) => - q.from({ config: queryConfigCollection }) + q.from({ config: queryConfigCollection }), ) // Query collections automatically refetch after handler completes @@ -42,7 +42,7 @@ function QueryPage() { await Promise.all( inserts.map(async (mutation) => { await api.config.create(mutation.modified) - }) + }), ) // Handle updates @@ -53,7 +53,7 @@ function QueryPage() { throw new Error(`Original config not found for update`) } await api.config.update(mutation.original.id, mutation.changes) - }) + }), ) // Trigger refetch to get confirmed server state diff --git a/examples/react/todo/src/routes/trailbase.tsx b/examples/react/todo/src/routes/trailbase.tsx index 4c4370eba..96e05e11a 100644 --- a/examples/react/todo/src/routes/trailbase.tsx +++ b/examples/react/todo/src/routes/trailbase.tsx @@ -1,11 +1,11 @@ -import * as React from "react" -import { createFileRoute } from "@tanstack/react-router" -import { useLiveQuery } from "@tanstack/react-db" +import * as React from 'react' +import { createFileRoute } from '@tanstack/react-router' +import { useLiveQuery } from '@tanstack/react-db' import { trailBaseConfigCollection, trailBaseTodoCollection, -} from "../lib/collections" -import { TodoApp } from "../components/TodoApp" +} from '../lib/collections' +import { TodoApp } from '../components/TodoApp' export const Route = createFileRoute(`/trailbase`)({ component: TrailBasePage, @@ -25,11 +25,11 @@ function TrailBasePage() { const { data: todos } = useLiveQuery((q) => q .from({ todo: trailBaseTodoCollection }) - .orderBy(({ todo }) => todo.created_at, `asc`) + .orderBy(({ todo }) => todo.created_at, `asc`), ) const { data: configData } = useLiveQuery((q) => - q.from({ config: trailBaseConfigCollection }) + q.from({ config: trailBaseConfigCollection }), ) // Note: TrailBase collections use recordApi internally, which is not exposed diff --git a/examples/react/todo/src/server.ts b/examples/react/todo/src/server.ts index 1f8997f3e..130fbb5a9 100644 --- a/examples/react/todo/src/server.ts +++ b/examples/react/todo/src/server.ts @@ -1,4 +1,4 @@ -import handler from "@tanstack/react-start/server-entry" +import handler from '@tanstack/react-start/server-entry' export default { fetch(request: Request) { diff --git a/examples/react/todo/src/start.tsx b/examples/react/todo/src/start.tsx index de7b170ed..9e8694bab 100644 --- a/examples/react/todo/src/start.tsx +++ b/examples/react/todo/src/start.tsx @@ -1,4 +1,4 @@ -import { createStart } from "@tanstack/react-start" +import { createStart } from '@tanstack/react-start' export const startInstance = createStart(() => { return { diff --git a/examples/react/todo/src/styles.css b/examples/react/todo/src/styles.css index 80cb92ada..06f1bca4b 100644 --- a/examples/react/todo/src/styles.css +++ b/examples/react/todo/src/styles.css @@ -1,15 +1,15 @@ -@import "tailwindcss"; +@import 'tailwindcss'; body { @apply m-0; font-family: - -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", - "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; + -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', + 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } code { font-family: - source-code-pro, Menlo, Monaco, Consolas, "Courier New", monospace; + source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace; } diff --git a/examples/react/todo/vite.config.ts b/examples/react/todo/vite.config.ts index ab0b541fd..3bf6a06e3 100644 --- a/examples/react/todo/vite.config.ts +++ b/examples/react/todo/vite.config.ts @@ -1,8 +1,8 @@ -import { defineConfig } from "vite" -import react from "@vitejs/plugin-react" -import tailwindcss from "@tailwindcss/vite" -import { tanstackStart } from "@tanstack/react-start/plugin/vite" -import viteTsConfigPaths from "vite-tsconfig-paths" +import { defineConfig } from 'vite' +import react from '@vitejs/plugin-react' +import tailwindcss from '@tailwindcss/vite' +import { tanstackStart } from '@tanstack/react-start/plugin/vite' +import viteTsConfigPaths from 'vite-tsconfig-paths' // https://vitejs.dev/config/ export default defineConfig({ diff --git a/examples/solid/todo/docker-compose.yml b/examples/solid/todo/docker-compose.yml index 9b6ddcffe..cb03bb1b3 100644 --- a/examples/solid/todo/docker-compose.yml +++ b/examples/solid/todo/docker-compose.yml @@ -1,4 +1,4 @@ -version: "3.8" +version: '3.8' services: postgres: image: postgres:17-alpine @@ -7,7 +7,7 @@ services: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres ports: - - "54322:5432" + - '54322:5432' volumes: - ./postgres.conf:/etc/postgresql/postgresql.conf:ro tmpfs: @@ -18,7 +18,7 @@ services: - -c - config_file=/etc/postgresql/postgresql.conf healthcheck: - test: ["CMD-SHELL", "pg_isready -U postgres"] + test: ['CMD-SHELL', 'pg_isready -U postgres'] interval: 5s timeout: 5s retries: 5 @@ -37,11 +37,11 @@ services: trailbase: image: trailbase/trailbase:latest ports: - - "${PORT:-4000}:4000" + - '${PORT:-4000}:4000' restart: unless-stopped volumes: - ./traildepot:/app/traildepot - command: "/app/trail --data-dir /app/traildepot run --address 0.0.0.0:4000 --dev" + command: '/app/trail --data-dir /app/traildepot run --address 0.0.0.0:4000 --dev' volumes: postgres_data: diff --git a/examples/solid/todo/drizzle.config.ts b/examples/solid/todo/drizzle.config.ts index 550633431..486be88c9 100644 --- a/examples/solid/todo/drizzle.config.ts +++ b/examples/solid/todo/drizzle.config.ts @@ -1,4 +1,4 @@ -import type { Config } from "drizzle-kit" +import type { Config } from 'drizzle-kit' export default { schema: `./src/db/schema.ts`, diff --git a/examples/solid/todo/scripts/migrate.ts b/examples/solid/todo/scripts/migrate.ts index ee0089f38..d58ebc44e 100644 --- a/examples/solid/todo/scripts/migrate.ts +++ b/examples/solid/todo/scripts/migrate.ts @@ -1,7 +1,7 @@ -import { drizzle } from "drizzle-orm/node-postgres" -import { migrate } from "drizzle-orm/node-postgres/migrator" -import pkg from "pg" -import * as dotenv from "dotenv" +import { drizzle } from 'drizzle-orm/node-postgres' +import { migrate } from 'drizzle-orm/node-postgres/migrator' +import pkg from 'pg' +import * as dotenv from 'dotenv' dotenv.config() diff --git a/examples/solid/todo/src/api/server.ts b/examples/solid/todo/src/api/server.ts index 4aa55431d..948d2442e 100644 --- a/examples/solid/todo/src/api/server.ts +++ b/examples/solid/todo/src/api/server.ts @@ -1,14 +1,14 @@ -import express from "express" -import cors from "cors" -import { sql } from "../db/postgres" +import express from 'express' +import cors from 'cors' +import { sql } from '../db/postgres' import { validateInsertConfig, validateInsertTodo, validateUpdateConfig, validateUpdateTodo, -} from "../db/validation" -import type { Express } from "express" -import type { Txid } from "@tanstack/electric-db-collection" +} from '../db/validation' +import type { Express } from 'express' +import type { Txid } from '@tanstack/electric-db-collection' // Create Express app const app: Express = express() diff --git a/examples/solid/todo/src/components/NotFound.tsx b/examples/solid/todo/src/components/NotFound.tsx index 04619d4e8..3304c4195 100644 --- a/examples/solid/todo/src/components/NotFound.tsx +++ b/examples/solid/todo/src/components/NotFound.tsx @@ -1,4 +1,4 @@ -import { Link } from "@tanstack/solid-router" +import { Link } from '@tanstack/solid-router' export function NotFound() { return ( diff --git a/examples/solid/todo/src/components/TodoApp.tsx b/examples/solid/todo/src/components/TodoApp.tsx index 1e69d592c..c8cc0df58 100644 --- a/examples/solid/todo/src/components/TodoApp.tsx +++ b/examples/solid/todo/src/components/TodoApp.tsx @@ -1,8 +1,8 @@ -import { Link } from "@tanstack/solid-router" -import { For, Show, createSignal } from "solid-js" -import type { JSX } from "solid-js" -import type { Collection } from "@tanstack/solid-db" -import type { SelectConfig, SelectTodo } from "../db/validation" +import { Link } from '@tanstack/solid-router' +import { For, Show, createSignal } from 'solid-js' +import type { JSX } from 'solid-js' +import type { Collection } from '@tanstack/solid-db' +import type { SelectConfig, SelectTodo } from '../db/validation' interface TodoAppProps { todos: Array @@ -121,7 +121,7 @@ export function TodoApp(props: TodoAppProps) { return (
    @@ -193,9 +193,9 @@ export function TodoApp(props: TodoAppProps) { todosToToggle.map((todo) => todo.id), (drafts) => { drafts.forEach( - (draft) => (draft.completed = !allCompleted) + (draft) => (draft.completed = !allCompleted), ) - } + }, ) }} > @@ -262,7 +262,7 @@ export function TodoApp(props: TodoAppProps) {