/* Copyright 2022 New Vector Ltd Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ declare module "matrix-seshat" { interface IConfig { language?: string; passphrase?: string; } /* eslint-disable camelcase */ interface IMatrixEvent { event_id: string; sender: string; room_id: string; origin_server_ts: number; content: Record; } interface IMatrixProfile { displayname?: string; avatar_url?: string; } interface ISearchArgs { searchTerm: number; limit: number; before_limit: number; after_limit: number; order_by_recency: boolean; next_batch?: string; } interface ISearchContext { events_before: IMatrixEvent[]; events_after: IMatrixEvent[]; profile_info: { [userId: string]: IMatrixProfile }; } interface ISearchResult { next_batch: string; count: number; results: Array<{ rank: number; result: IMatrixEvent; context: ISearchContext; }>; } /* eslint-enable camelcase */ interface ICheckpoint { roomId: string; token: string; fullCrawl: boolean; direction: "b" | "f"; } interface IDatabaseStats { size: number; eventCount: number; roomCount: number; } interface ILoadArgs { roomId: string; limit: number; fromEvent: string; direction: "b" | "f"; } interface ILoadResult { event: IMatrixEvent; matrixProfile: IMatrixProfile; } export class Seshat { constructor(path: string, config?: IConfig); public addEvent(matrixEvent: IMatrixEvent, profile?: IMatrixProfile): void; public deleteEvent(eventId: string): Promise; public commit(force?: boolean): Promise; public commitSync(wait?: boolean, force?: boolean): number; public reload(): void; public search(args: ISearchArgs): Promise; public searchSync( term: string, limit?: number, beforeLimit?: number, afterLimit?: number, orderByRecency?: boolean, ): ISearchResult; public addHistoricEventsSync( events: IMatrixEvent[], newCheckpoint?: ICheckpoint, oldCheckpoint?: ICheckpoint, ): boolean; public addHistoricEvents( events: IMatrixEvent[], newCheckpoint?: ICheckpoint, oldCheckpoint?: ICheckpoint, ): Promise; public addCrawlerCheckpoint(checkpoint: ICheckpoint): Promise; public removeCrawlerCheckpoint(checkpoint: ICheckpoint): Promise; public loadCheckpoints(): Promise; public getSize(): Promise; public getStats(): Promise; public delete(): Promise; public shutdown(): Promise; public changePassphrase(newPassphrase: string): Promise; public isEmpty(): Promise; public isRoomIndexed(roomId: string): Promise; public getUserVersion(): Promise; public setUserVersion(version: number): Promise; public loadFileEvents(args: ILoadArgs): Promise; } interface IRecoveryInfo { totalEvents: number; reindexedEvents: number; done: number; } export class SeshatRecovery { constructor(path: string, config?: IConfig); public info(): IRecoveryInfo; public getUserVersion(): Promise; public shutdown(): Promise; public reindex(): Promise; } export class ReindexError extends Error { constructor(message?: string); } }