Fix persistence provider types
This commit is contained in:
parent
5ba898df7d
commit
9f46af4a65
4 changed files with 18 additions and 15 deletions
|
|
@ -11,7 +11,7 @@ export interface DocumentMetadata {
|
|||
import type { Logger } from "src/tracing/logger";
|
||||
|
||||
export interface StoredDatabase {
|
||||
documents: Map<RelativePath, DocumentMetadata>;
|
||||
documents: Record<RelativePath, DocumentMetadata>;
|
||||
lastSeenUpdateId: VaultUpdateId | undefined;
|
||||
}
|
||||
|
||||
|
|
@ -22,15 +22,14 @@ export class Database {
|
|||
public constructor(
|
||||
private readonly logger: Logger,
|
||||
initialState: Partial<StoredDatabase> | undefined,
|
||||
private readonly saveData: (data: unknown) => Promise<void>
|
||||
private readonly saveData: (data: StoredDatabase) => Promise<void>
|
||||
) {
|
||||
initialState ??= {};
|
||||
if (initialState.documents) {
|
||||
for (const [relativePath, metadata] of Object.entries(
|
||||
initialState.documents
|
||||
)) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
||||
this.documents.set(relativePath, metadata as DocumentMetadata);
|
||||
this.documents.set(relativePath, metadata);
|
||||
}
|
||||
}
|
||||
this.logger.debug(`Loaded ${this.documents.size} documents`);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
export interface PersistenceProvider {
|
||||
load: () => Promise<unknown>;
|
||||
save: (data: unknown) => Promise<void>;
|
||||
export interface PersistenceProvider<T extends object> {
|
||||
load: () => Promise<T | undefined>;
|
||||
save: (data: T | undefined) => Promise<void>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ export class Settings {
|
|||
public constructor(
|
||||
private readonly logger: Logger,
|
||||
initialState: Partial<SyncSettings> | undefined,
|
||||
private readonly saveData: (data: unknown) => Promise<void>
|
||||
private readonly saveData: (data: SyncSettings) => Promise<void>
|
||||
) {
|
||||
this.settings = {
|
||||
...DEFAULT_SETTINGS,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue