mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-01 17:39:55 +08:00
feat(native): native reader for indexer (#14055)
This commit is contained in:
@@ -7,6 +7,24 @@ import type { Locker } from './lock';
|
||||
import { SingletonLocker } from './lock';
|
||||
import { type Storage } from './storage';
|
||||
|
||||
export interface BlockInfo {
|
||||
blockId: string;
|
||||
flavour: string;
|
||||
content?: string[];
|
||||
blob?: string[];
|
||||
refDocId?: string[];
|
||||
refInfo?: string[];
|
||||
parentFlavour?: string;
|
||||
parentBlockId?: string;
|
||||
additional?: string;
|
||||
}
|
||||
|
||||
export interface CrawlResult {
|
||||
blocks: BlockInfo[];
|
||||
title: string;
|
||||
summary: string;
|
||||
}
|
||||
|
||||
export interface DocClock {
|
||||
docId: string;
|
||||
timestamp: Date;
|
||||
@@ -94,6 +112,8 @@ export interface DocStorage extends Storage {
|
||||
subscribeDocUpdate(
|
||||
callback: (update: DocRecord, origin?: string) => void
|
||||
): () => void;
|
||||
|
||||
crawlDocData?(docId: string): Promise<CrawlResult | null>;
|
||||
}
|
||||
|
||||
export abstract class DocStorageBase<Opts = {}> implements DocStorage {
|
||||
@@ -174,6 +194,10 @@ export abstract class DocStorageBase<Opts = {}> implements DocStorage {
|
||||
};
|
||||
}
|
||||
|
||||
async crawlDocData(_docId: string): Promise<CrawlResult | null> {
|
||||
return null;
|
||||
}
|
||||
|
||||
// REGION: api for internal usage
|
||||
protected on(
|
||||
event: 'update',
|
||||
|
||||
@@ -85,4 +85,7 @@ export class DummyIndexerStorage extends IndexerStorageBase {
|
||||
override refresh<T extends keyof IndexerSchema>(_table: T): Promise<void> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
override async refreshIfNeed(): Promise<void> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,6 +62,7 @@ export interface IndexerStorage extends Storage {
|
||||
): Promise<void>;
|
||||
|
||||
refresh<T extends keyof IndexerSchema>(table: T): Promise<void>;
|
||||
refreshIfNeed(): Promise<void>;
|
||||
}
|
||||
|
||||
type ResultPagination = {
|
||||
@@ -173,4 +174,6 @@ export abstract class IndexerStorageBase implements IndexerStorage {
|
||||
): Promise<void>;
|
||||
|
||||
abstract refresh<T extends keyof IndexerSchema>(table: T): Promise<void>;
|
||||
|
||||
abstract refreshIfNeed(): Promise<void>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user