mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-11 05:58:56 +08:00
feat(nbstore): add indexer storage (#10953)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
export * from './awareness';
|
||||
export * from './blob';
|
||||
export * from './doc';
|
||||
export * from './indexer';
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import type { IndexerStorage } from '../storage';
|
||||
import type { IndexerSync } from '../sync/indexer';
|
||||
|
||||
export class IndexerFrontend {
|
||||
constructor(
|
||||
public readonly storage: IndexerStorage,
|
||||
public readonly sync: IndexerSync
|
||||
) {}
|
||||
|
||||
get state$() {
|
||||
return this.sync.state$;
|
||||
}
|
||||
|
||||
docState$(docId: string) {
|
||||
return this.sync.docState$(docId);
|
||||
}
|
||||
|
||||
search = this.storage.search.bind(this.storage);
|
||||
aggregate = this.storage.aggregate.bind(this.storage);
|
||||
// eslint-disable-next-line rxjs/finnish
|
||||
search$ = this.storage.search$.bind(this.storage);
|
||||
// eslint-disable-next-line rxjs/finnish
|
||||
aggregate$ = this.storage.aggregate$.bind(this.storage);
|
||||
|
||||
addPriority(docId: string, priority: number) {
|
||||
return this.sync.addPriority(docId, priority);
|
||||
}
|
||||
|
||||
waitForCompleted(signal?: AbortSignal) {
|
||||
return this.sync.waitForCompleted(signal);
|
||||
}
|
||||
|
||||
waitForDocCompleted(docId: string, signal?: AbortSignal) {
|
||||
return this.sync.waitForDocCompleted(docId, signal);
|
||||
}
|
||||
|
||||
waitForDocCompletedWithPriority(
|
||||
docId: string,
|
||||
priority: number,
|
||||
signal?: AbortSignal
|
||||
) {
|
||||
const undo = this.addPriority(docId, priority);
|
||||
return this.sync.waitForDocCompleted(docId, signal).finally(() => undo());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user