diff --git a/frontend/history-ui/src/lib/types/index.ts b/frontend/history-ui/src/lib/types/index.ts index 6377ebda..a2c2b346 100644 --- a/frontend/history-ui/src/lib/types/index.ts +++ b/frontend/history-ui/src/lib/types/index.ts @@ -1,7 +1,9 @@ export type { DocumentVersion } from "./DocumentVersion"; export type { DocumentVersionWithoutContent } from "./DocumentVersionWithoutContent"; export type { FetchLatestDocumentsResponse } from "./FetchLatestDocumentsResponse"; +export type { ListVaultsResponse } from "./ListVaultsResponse"; export type { PingResponse } from "./PingResponse"; +export type { VaultInfo } from "./VaultInfo"; export type { VaultHistoryResponse } from "./VaultHistoryResponse"; export type ActionType = diff --git a/frontend/local-client-cli/src/file-watcher.ts b/frontend/local-client-cli/src/file-watcher.ts index 16f397c5..2e70df02 100644 --- a/frontend/local-client-cli/src/file-watcher.ts +++ b/frontend/local-client-cli/src/file-watcher.ts @@ -69,47 +69,23 @@ export class FileWatcher { } private handleCreate(relativePath: RelativePath): void { - this.client - .syncLocallyCreatedFile(relativePath) - .catch((err: unknown) => { - this.client.logger.error( - `Failed to sync created file ${relativePath}: ${this.formatError(err)}` - ); - }); + this.client.syncLocallyCreatedFile(relativePath); } private handleChange(relativePath: RelativePath): void { - this.client - .syncLocallyUpdatedFile({ relativePath }) - .catch((err: unknown) => { - this.client.logger.error( - `Failed to sync updated file ${relativePath}: ${this.formatError(err)}` - ); - }); + this.client.syncLocallyUpdatedFile({ relativePath }); } private handleDelete(relativePath: RelativePath): void { - this.client - .syncLocallyDeletedFile(relativePath) - .catch((err: unknown) => { - this.client.logger.error( - `Failed to sync deleted file ${relativePath}: ${this.formatError(err)}` - ); - }); + this.client.syncLocallyDeletedFile(relativePath); } private handleRename(oldPath: RelativePath, newPath: RelativePath): void { this.client.logger.info(`File renamed: ${oldPath} -> ${newPath}`); - this.client - .syncLocallyUpdatedFile({ - oldPath, - relativePath: newPath - }) - .catch((err: unknown) => { - this.client.logger.error( - `Failed to sync renamed file ${oldPath} -> ${newPath}: ${this.formatError(err)}` - ); - }); + this.client.syncLocallyUpdatedFile({ + oldPath, + relativePath: newPath + }); } private toRelativePath(absolutePath: string): RelativePath { diff --git a/frontend/obsidian-plugin/src/vault-link-plugin.ts b/frontend/obsidian-plugin/src/vault-link-plugin.ts index 9ad4d2a1..0291e646 100644 --- a/frontend/obsidian-plugin/src/vault-link-plugin.ts +++ b/frontend/obsidian-plugin/src/vault-link-plugin.ts @@ -269,9 +269,9 @@ export default class VaultLinkPlugin extends Plugin { path, rateLimit( async () => - client.syncLocallyUpdatedFile({ + { client.syncLocallyUpdatedFile({ relativePath: path - }), + }); }, MIN_WAIT_BETWEEN_UPDATES_IN_MS ) ); diff --git a/frontend/sync-client/src/errors/http-client-error.ts b/frontend/sync-client/src/errors/http-client-error.ts new file mode 100644 index 00000000..2475cf35 --- /dev/null +++ b/frontend/sync-client/src/errors/http-client-error.ts @@ -0,0 +1,9 @@ +export class HttpClientError extends Error { + public constructor( + public readonly statusCode: number, + message: string + ) { + super(message); + this.name = "HttpClientError"; + } +} diff --git a/frontend/sync-client/src/index.ts b/frontend/sync-client/src/index.ts index c4e4313d..da69f446 100644 --- a/frontend/sync-client/src/index.ts +++ b/frontend/sync-client/src/index.ts @@ -22,7 +22,7 @@ export { export { Logger, LogLevel, LogLine } from "./tracing/logger"; export { type SyncSettings, DEFAULT_SETTINGS } from "./persistence/settings"; export { rateLimit } from "./utils/rate-limit"; -export type { RelativePath, StoredDatabase } from "./persistence/database"; +export type { RelativePath, StoredSyncState as StoredDatabase, DocumentRecord } from "./sync-operations/types"; export type { FileSystemOperations } from "./file-operations/filesystem-operations"; export type { PersistenceProvider } from "./persistence/persistence"; export type { CursorSpan } from "./services/types/CursorSpan"; diff --git a/frontend/sync-client/src/services/fetch-controller.ts b/frontend/sync-client/src/services/fetch-controller.ts index e30739da..cf857dcd 100644 --- a/frontend/sync-client/src/services/fetch-controller.ts +++ b/frontend/sync-client/src/services/fetch-controller.ts @@ -1,5 +1,4 @@ import type { Logger } from "../tracing/logger"; -import { createPromise } from "../utils/create-promise"; import { SyncResetError } from "../errors/sync-reset-error"; /** @@ -13,15 +12,14 @@ export class FetchController { // Promise resolves on the next state change: sync enabled/disabled or reset started/ended private until: Promise; - private resolveUntil: (result: symbol) => unknown; - private rejectUntil: (reason: unknown) => unknown; + private resolveUntil: (value: symbol | PromiseLike) => void; + private rejectUntil: (reason?: unknown) => void; public constructor( private _canFetch: boolean, private readonly logger: Logger ) { - [this.until, this.resolveUntil, this.rejectUntil] = - createPromise(); + ({ promise: this.until, resolve: this.resolveUntil, reject: this.rejectUntil } = Promise.withResolvers()); } /** @@ -42,8 +40,7 @@ export class FetchController { if (!this.isResetting) { const previousResolve = this.resolveUntil; - [this.until, this.resolveUntil, this.rejectUntil] = - createPromise(); + ({ promise: this.until, resolve: this.resolveUntil, reject: this.rejectUntil } = Promise.withResolvers()); previousResolve(FetchController.UNTIL_RESOLUTION); } } @@ -81,7 +78,7 @@ export class FetchController { } this.isResetting = false; - [this.until, this.resolveUntil, this.rejectUntil] = createPromise(); + ({ promise: this.until, resolve: this.resolveUntil, reject: this.rejectUntil } = Promise.withResolvers()); } /** diff --git a/frontend/sync-client/src/sync-operations/file-change-notifier.ts b/frontend/sync-client/src/sync-operations/file-change-notifier.ts index d1e49d62..414c9e91 100644 --- a/frontend/sync-client/src/sync-operations/file-change-notifier.ts +++ b/frontend/sync-client/src/sync-operations/file-change-notifier.ts @@ -1,4 +1,4 @@ -import type { RelativePath } from "../persistence/database"; +import type { RelativePath } from "./types"; import { EventListeners } from "../utils/data-structures/event-listeners"; export class FileChangeNotifier {