Conversation
🦋 Changeset detectedLatest commit: 914c31a The changes in this PR will be included in the next version bump. This PR includes changesets to release 14 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
8c77252 to
b011fe2
Compare
- Make indexing explicit with BasicIndex and BTreeIndex - autoIndex defaults to 'off', dev mode suggestions warn when indexes would help - New @tanstack/db/indexing entry point for tree-shakeable indexing - BasicIndex: lightweight Map + sorted Array for equality and range queries - BTreeIndex: full-featured O(log n) index for large collections - Fix pagination when indexes aren't available - Remove docs folder (now CI-generated) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
b011fe2 to
9c047aa
Compare
More templates
@tanstack/angular-db
@tanstack/db
@tanstack/db-browser-wa-sqlite-persisted-collection
@tanstack/db-capacitor-sqlite-persisted-collection
@tanstack/db-cloudflare-do-sqlite-persisted-collection
@tanstack/db-electron-sqlite-persisted-collection
@tanstack/db-expo-sqlite-persisted-collection
@tanstack/db-ivm
@tanstack/db-node-sqlite-persisted-collection
@tanstack/db-react-native-sqlite-persisted-collection
@tanstack/db-sqlite-persisted-collection-core
@tanstack/db-tauri-sqlite-persisted-collection
@tanstack/electric-db-collection
@tanstack/offline-transactions
@tanstack/powersync-db-collection
@tanstack/query-db-collection
@tanstack/react-db
@tanstack/rxdb-db-collection
@tanstack/solid-db
@tanstack/svelte-db
@tanstack/trailbase-db-collection
@tanstack/vue-db
commit: |
|
Size Change: +1.53 kB (+1.38%) Total Size: 112 kB
ℹ️ View Unchanged
|
|
Size Change: 0 B Total Size: 4.23 kB ℹ️ View Unchanged
|
Tests added on main were calling createIndex() or using autoIndex: 'eager' without setting defaultIndexType, which is now required. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PR Review SummaryOverall this is a well-designed simplification. Replacing Critical
This is a deliberately-requested feature that silently degrades. Consider throwing if (config.autoIndex === 'eager' && !config.defaultIndexType) {
throw new CollectionConfigurationError(
`autoIndex: 'eager' requires defaultIndexType to be set. ` +
`Import an index type and set it:\n` +
` import { BasicIndex } from '@tanstack/db/indexing'\n` +
` createCollection({ defaultIndexType: BasicIndex, autoIndex: 'eager', ... })`
)
}Important
Suggestions
Test Coverage Gaps
Strengths
|
- Throw CollectionConfigurationError at construction when autoIndex: 'eager'
is used without defaultIndexType (was silently degrading in production)
- Use CollectionConfigurationError instead of generic Error in createIndex
- Wrap onSuggestion callback in try-catch to prevent buggy callbacks from
crashing query execution
- Clean up indexedKeys in BasicIndex.remove() catch block to prevent
phantom keys when expression evaluation fails
- Preserve original stack traces with { cause: error } in BasicIndex
- Update tests to provide defaultIndexType where needed
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Test that autoIndex: 'eager' without defaultIndexType throws CollectionConfigurationError at construction time - Test that createIndex() without indexType or defaultIndexType throws CollectionConfigurationError Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Addressed review feedbackCritical
Important
Suggestions
Test coverage
Not addressed (needs discussion)
|
CI will regenerate these docs files after merge. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…Index Tests added on main use autoIndex: 'eager' but didn't set defaultIndexType, which is now required after making indexing opt-in. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Resolve conflicts between opt-in indexing (this branch) and main's additions: virtual props, index metadata/events, collection-subscriber refactoring, SQLite persistence, and includes subqueries. Key conflict resolutions: - Keep synchronous IndexConstructor approach, remove lazy-index.ts - Add index metadata tracking and events to synchronous createIndex - Add simplified removeIndex (accepts BaseIndex | number) - Incorporate virtual props (WithVirtualProps, $synced, $origin, etc.) - Take main's collection-subscriber refactoring (computeOrderedLoadCursor, trackBiggestSentValue, lastLoadRequestKey dedup) - Fix Store.subscribe() return type usage in electric-db-collection - Update tests for opt-in indexing (add defaultIndexType/autoIndex where needed) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Resolve conflicts between opt-in indexing (this branch) and main's additions: virtual props, index metadata/events, collection-subscriber refactoring, SQLite persistence, and includes subqueries. Key conflict resolutions: - Keep synchronous IndexConstructor approach, remove lazy-index.ts - Add index metadata tracking and events to synchronous createIndex - Add simplified removeIndex (accepts BaseIndex | number) - Incorporate virtual props (WithVirtualProps, $synced, $origin, etc.) - Take main's collection-subscriber refactoring (computeOrderedLoadCursor, trackBiggestSentValue, lastLoadRequestKey dedup) - Fix Store.subscribe() return type usage in electric-db-collection - Update tests for opt-in indexing (add defaultIndexType/autoIndex where needed) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
….9.x The Store.subscribe() API changed in @tanstack/store 0.9.x to return a Subscription object with .unsubscribe() instead of a plain function. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The Multi-Column OrderBy with Incremental Loading tests use orderBy + limit which requires indexes for the incremental loading path. Add autoIndex: 'eager' and defaultIndexType to the on-demand collections. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…test The test creates indexes without specifying an indexType. Add defaultIndexType: BasicIndex to the collection config. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
All useLiveInfiniteQuery tests use orderBy + limit which requires indexes for incremental loading. Add autoIndex: 'eager' to all collection configs in the test file. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
BTreeIndex from @tanstack/db/indexing doesn't structurally match IndexConstructor from @tanstack/db in CI builds due to cross-package type resolution. Use 'as any' cast in test helper. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…raints BaseIndex, IndexInterface, and BTreeIndex had TKey constrained to string | number | undefined, but collection keys are always string | number. This caused BTreeIndex to not be assignable to IndexConstructor<string | number> in cross-package type checking. Narrow TKey to string | number across the index hierarchy, matching BasicIndex and ReverseIndex which already used this constraint. Remove as-any casts that were working around the mismatch. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… internals Protected members break structural type compatibility across package boundaries in TypeScript monorepos. When BaseIndex is resolved from different module paths (source vs built .d.ts), protected members make subclasses like BasicIndex/BTreeIndex not assignable to IndexConstructor. Change protected members to public (marked @internal via JSDoc) to enable structural compatibility while preserving the intent that these are implementation details. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ck/db The separate /indexing entry point caused cross-package type incompatibility: TypeScript could resolve BaseIndex through different declaration paths (main entry vs /indexing entry), breaking protected member structural checks in consuming packages. Modern bundlers (Rollup, esbuild, Vite) tree-shake unused exports effectively, so a separate entry point is unnecessary for bundle size. Changes: - Move all exports from src/indexing.ts into src/index.ts - Remove src/indexing.ts - Remove ./indexing from package.json exports map - Remove indexing.ts from vite build entry points - Update all imports from @tanstack/db/indexing to @tanstack/db - Restore protected visibility on BaseIndex internals Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The "should handle GC correctly when queries are ordered and have a LIMIT" test uses orderBy + limit which requires indexes. Add autoIndex: 'eager' and defaultIndexType: BTreeIndex to the collection config. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
All 6 collections (3 eager, 3 on-demand) need autoIndex + defaultIndexType for tests that use orderBy + limit. Without indexes, the requestLimitedSnapshot path throws "no index found", causing tests to hang until CI timeout. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add autoIndex: 'eager' and defaultIndexType: BTreeIndex to the createPersistedCollection helper used by all e2e test collections. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add autoIndex: 'eager' and defaultIndexType: BTreeIndex to collection configs across all e2e test suites that were missing it: - browser-wa-sqlite persisted collection - capacitor-sqlite persisted collection - expo-sqlite persisted collection - react-native-sqlite persisted collection - tauri-sqlite persisted collection - trailbase collection - query-db-collection offline-refresh Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The docs were accidentally deleted in this branch. Restore them from main. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
Makes indexing explicit and opt-in rather than automatic, allowing users to choose the right index type for their use case and enabling better tree-shaking.
Based on #950 with the
ReadOptimizedIndex/WriteOptimizedIndexrenaming reverted — keeps the originalBasicIndex/BTreeIndexnames.Key changes
autoIndexnow defaults tooffinstead ofeagercreateIndex()orautoIndex: 'eager', you must setdefaultIndexTypeon the collectionBundle size impact
Test plan
defaultIndexTypewhere needed🤖 Generated with Claude Code