making project ids 1 based

This commit is contained in:
C-West8
2026-10-23 11:32:30 -05:00
parent a9e31acaa4
commit fbd81b0b45
33 changed files with 215 additions and 160 deletions

View File

@@ -31,7 +31,7 @@ export interface ProjectServiceDeps {
items: ItemRepository;
sourceResolver: SourceRootResolver;
targetResolver: TargetRootResolver;
activity: { isRunning(projectId: string): boolean };
activity: { isRunning(projectId: number): boolean };
maxAttempts: number;
}
@@ -53,7 +53,7 @@ export class ProjectService {
});
}
async update(id: string, edit: ProjectEdit): Promise<void> {
async update(id: number, edit: ProjectEdit): Promise<void> {
const project = await this.require(id);
const changes: ProjectChanges = { name: validName(edit.name), enabled: edit.enabled };
const sourceInput = edit.sourceInput?.trim();
@@ -73,24 +73,24 @@ export class ProjectService {
await this.deps.projects.update(id, changes);
}
async resume(id: string): Promise<void> {
async resume(id: number): Promise<void> {
await this.require(id);
await this.deps.projects.resume(id);
}
/** Forget all sync state; the next run starts from a full listing and roots unlock. */
async reset(id: string): Promise<void> {
async reset(id: number): Promise<void> {
await this.requireIdle(id);
await this.deps.projects.reset(id);
}
async delete(id: string): Promise<void> {
async delete(id: number): Promise<void> {
await this.requireIdle(id);
await this.deps.projects.delete(id);
}
/** Give a failed item a fresh set of attempts on the next run. */
async retryItem(projectId: string, sourceId: string): Promise<void> {
async retryItem(projectId: number, sourceId: string): Promise<void> {
await this.requireIdle(projectId);
const item = await this.deps.items.get(projectId, sourceId);
if (!item) throw new InvalidRequestError('That file is no longer tracked.');
@@ -99,13 +99,13 @@ export class ProjectService {
await this.deps.items.save(projectId, [fresh]);
}
private async require(id: string): Promise<Project> {
private async require(id: number): Promise<Project> {
const project = await this.deps.projects.get(id);
if (!project) throw new InvalidRequestError('Project not found.');
return project;
}
private async requireIdle(id: string): Promise<Project> {
private async requireIdle(id: number): Promise<Project> {
const project = await this.require(id);
if (this.deps.activity.isRunning(id)) throw new InvalidRequestError(BUSY);
return project;