asch/fix-everything #188

Open
andras wants to merge 114 commits from asch/fix-everything into main
7 changed files with 27 additions and 43 deletions
Showing only changes of commit 64ca5a82ef - Show all commits

Fix lints

Andras Schmelczer 2026-04-06 11:17:18 +01:00

View file

@ -1,7 +1,9 @@
export type { DocumentVersion } from "./DocumentVersion"; export type { DocumentVersion } from "./DocumentVersion";
export type { DocumentVersionWithoutContent } from "./DocumentVersionWithoutContent"; export type { DocumentVersionWithoutContent } from "./DocumentVersionWithoutContent";
export type { FetchLatestDocumentsResponse } from "./FetchLatestDocumentsResponse"; export type { FetchLatestDocumentsResponse } from "./FetchLatestDocumentsResponse";
export type { ListVaultsResponse } from "./ListVaultsResponse";
export type { PingResponse } from "./PingResponse"; export type { PingResponse } from "./PingResponse";
export type { VaultInfo } from "./VaultInfo";
export type { VaultHistoryResponse } from "./VaultHistoryResponse"; export type { VaultHistoryResponse } from "./VaultHistoryResponse";
export type ActionType = export type ActionType =

View file

@ -69,46 +69,22 @@ export class FileWatcher {
} }
private handleCreate(relativePath: RelativePath): void { private handleCreate(relativePath: RelativePath): void {
this.client this.client.syncLocallyCreatedFile(relativePath);
.syncLocallyCreatedFile(relativePath)
.catch((err: unknown) => {
this.client.logger.error(
`Failed to sync created file ${relativePath}: ${this.formatError(err)}`
);
});
} }
private handleChange(relativePath: RelativePath): void { private handleChange(relativePath: RelativePath): void {
this.client this.client.syncLocallyUpdatedFile({ relativePath });
.syncLocallyUpdatedFile({ relativePath })
.catch((err: unknown) => {
this.client.logger.error(
`Failed to sync updated file ${relativePath}: ${this.formatError(err)}`
);
});
} }
private handleDelete(relativePath: RelativePath): void { private handleDelete(relativePath: RelativePath): void {
this.client this.client.syncLocallyDeletedFile(relativePath);
.syncLocallyDeletedFile(relativePath)
.catch((err: unknown) => {
this.client.logger.error(
`Failed to sync deleted file ${relativePath}: ${this.formatError(err)}`
);
});
} }
private handleRename(oldPath: RelativePath, newPath: RelativePath): void { private handleRename(oldPath: RelativePath, newPath: RelativePath): void {
this.client.logger.info(`File renamed: ${oldPath} -> ${newPath}`); this.client.logger.info(`File renamed: ${oldPath} -> ${newPath}`);
this.client this.client.syncLocallyUpdatedFile({
.syncLocallyUpdatedFile({
oldPath, oldPath,
relativePath: newPath relativePath: newPath
})
.catch((err: unknown) => {
this.client.logger.error(
`Failed to sync renamed file ${oldPath} -> ${newPath}: ${this.formatError(err)}`
);
}); });
} }

View file

@ -269,9 +269,9 @@ export default class VaultLinkPlugin extends Plugin {
path, path,
rateLimit( rateLimit(
async () => async () =>
client.syncLocallyUpdatedFile({ { client.syncLocallyUpdatedFile({
relativePath: path relativePath: path
}), }); },
MIN_WAIT_BETWEEN_UPDATES_IN_MS MIN_WAIT_BETWEEN_UPDATES_IN_MS
) )
); );

View file

@ -0,0 +1,9 @@
export class HttpClientError extends Error {
public constructor(
public readonly statusCode: number,
message: string
) {
super(message);
this.name = "HttpClientError";
}
}

View file

@ -22,7 +22,7 @@ export {
export { Logger, LogLevel, LogLine } from "./tracing/logger"; export { Logger, LogLevel, LogLine } from "./tracing/logger";
export { type SyncSettings, DEFAULT_SETTINGS } from "./persistence/settings"; export { type SyncSettings, DEFAULT_SETTINGS } from "./persistence/settings";
export { rateLimit } from "./utils/rate-limit"; 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 { FileSystemOperations } from "./file-operations/filesystem-operations";
export type { PersistenceProvider } from "./persistence/persistence"; export type { PersistenceProvider } from "./persistence/persistence";
export type { CursorSpan } from "./services/types/CursorSpan"; export type { CursorSpan } from "./services/types/CursorSpan";

View file

@ -1,5 +1,4 @@
import type { Logger } from "../tracing/logger"; import type { Logger } from "../tracing/logger";
import { createPromise } from "../utils/create-promise";
import { SyncResetError } from "../errors/sync-reset-error"; 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 // Promise resolves on the next state change: sync enabled/disabled or reset started/ended
private until: Promise<symbol>; private until: Promise<symbol>;
private resolveUntil: (result: symbol) => unknown; private resolveUntil: (value: symbol | PromiseLike<symbol>) => void;
private rejectUntil: (reason: unknown) => unknown; private rejectUntil: (reason?: unknown) => void;
public constructor( public constructor(
private _canFetch: boolean, private _canFetch: boolean,
private readonly logger: Logger private readonly logger: Logger
) { ) {
[this.until, this.resolveUntil, this.rejectUntil] = ({ promise: this.until, resolve: this.resolveUntil, reject: this.rejectUntil } = Promise.withResolvers<symbol>());
createPromise<symbol>();
} }
/** /**
@ -42,8 +40,7 @@ export class FetchController {
if (!this.isResetting) { if (!this.isResetting) {
const previousResolve = this.resolveUntil; const previousResolve = this.resolveUntil;
[this.until, this.resolveUntil, this.rejectUntil] = ({ promise: this.until, resolve: this.resolveUntil, reject: this.rejectUntil } = Promise.withResolvers<symbol>());
createPromise<symbol>();
previousResolve(FetchController.UNTIL_RESOLUTION); previousResolve(FetchController.UNTIL_RESOLUTION);
} }
} }
@ -81,7 +78,7 @@ export class FetchController {
} }
this.isResetting = false; this.isResetting = false;
[this.until, this.resolveUntil, this.rejectUntil] = createPromise(); ({ promise: this.until, resolve: this.resolveUntil, reject: this.rejectUntil } = Promise.withResolvers<symbol>());
} }
/** /**

View file

@ -1,4 +1,4 @@
import type { RelativePath } from "../persistence/database"; import type { RelativePath } from "./types";
import { EventListeners } from "../utils/data-structures/event-listeners"; import { EventListeners } from "../utils/data-structures/event-listeners";
export class FileChangeNotifier { export class FileChangeNotifier {