Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove support for old index providers #1224

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/base/core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* BREAKING: `SyncManager` was moved to `@signaldb/sync`
* BREAKING: `ReplicatedCollection` was removed entirely
* BREAKING: `options` parameter was removed from `combinePersistenceAdapters`
* BREAKING: support for old `IndexProviders` was removed
13 changes: 0 additions & 13 deletions packages/base/core/src/Collection/getIndexInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,6 @@ export function getMergedIndexInfo<T extends BaseItem<I> = BaseItem, I = any>(
positions: number[],
optimizedSelector: FlatSelector<T>,
}>((memo, indexProvider) => {
/* istanbul ignore if -- @preserve */ // ignored because it's deprecated
if (indexProvider.getItemPositions) {
const result = indexProvider.getItemPositions(selector)
if (result == null) return memo
return {
matched: true,
positions: memo.matched
? intersection(memo.positions, result)
: result,
optimizedSelector: memo.optimizedSelector,
}
}

const info = indexProvider.query(selector)
if (!info.matched) return memo

Expand Down
14 changes: 1 addition & 13 deletions packages/base/core/src/types/IndexProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,11 @@ type IndexResult = {
matched: false,
}

interface OldIndexProvider<T extends BaseItem<I> = BaseItem, I = any> {
/**
* @deprecated Use `query` instead
*/
getItemPositions(selector: FlatSelector<T>): null | number[],
rebuild(items: T[]): void,
}

interface NewIndexProvider<T extends BaseItem<I> = BaseItem, I = any> {
getItemPositions?: never,
interface IndexProvider<T extends BaseItem<I> = BaseItem, I = any> {
query(selector: FlatSelector<T>): IndexResult,
rebuild(items: T[]): void,
}

type IndexProvider<T extends BaseItem<I> = BaseItem, I = any> = OldIndexProvider<T, I>
| NewIndexProvider<T, I>

export type LowLevelIndexProvider<
T extends BaseItem<I> = BaseItem,
I = any,
Expand Down
Loading