refactor: export restore progress from dto file

This commit is contained in:
Nicolas Meienberger 2026-05-31 19:26:51 +02:00
parent 1defe461be
commit 4f09420c25
No known key found for this signature in database
3 changed files with 17 additions and 15 deletions

View file

@ -1,5 +1,4 @@
import path from "node:path";
import { z } from "zod";
import { throttle } from "es-toolkit";
import { findCommonAncestor } from "../../utils/common-ancestor";
import { addCommonArgs } from "../helpers/add-common-args";
@ -9,7 +8,12 @@ import { cleanupTemporaryKeys } from "../helpers/cleanup-temporary-keys";
import { type RepositoryConfig, type OverwriteMode } from "../schemas";
import { logger, safeSpawn } from "../../node";
import { createResticError, isResticError, type AnyResticError } from "../error";
import { resticRestoreOutputSchema, type ResticRestoreOutputDto } from "../restic-dto";
import {
restoreProgressSchema,
resticRestoreOutputSchema,
type RestoreProgress,
type ResticRestoreOutputDto,
} from "../restic-dto";
import type { ResticDeps } from "../types";
import { Data, Effect } from "effect";
import { toMessage } from "../../utils";
@ -19,18 +23,6 @@ class ResticRestoreCommandError extends Data.TaggedError("ResticRestoreCommandEr
message: string;
}> {}
export const restoreProgressSchema = z.object({
message_type: z.enum(["status", "summary"]),
seconds_elapsed: z.number().default(0),
percent_done: z.number().default(0),
total_files: z.number().default(0),
files_restored: z.number().default(0),
total_bytes: z.number().default(0),
bytes_restored: z.number().default(0),
});
export type RestoreProgress = z.infer<typeof restoreProgressSchema>;
export const restore = (
config: RepositoryConfig,
snapshotId: string,

View file

@ -1,7 +1,6 @@
export * from "./schemas";
export * from "./restic-dto";
export { isResticError, ResticError, ResticLockError } from "./error";
export { restoreProgressSchema, type RestoreProgress } from "./commands/restore";
export type {
ResticDeps,
ResticEnv,

View file

@ -54,6 +54,16 @@ export const resticRestoreOutputSchema = z.object({
bytes_skipped: z.number().optional(),
});
export const restoreProgressSchema = z.object({
message_type: z.enum(["status", "summary"]),
seconds_elapsed: z.number().default(0),
percent_done: z.number().default(0),
total_files: z.number().default(0),
files_restored: z.number().default(0),
total_bytes: z.number().default(0),
bytes_restored: z.number().default(0),
});
export const resticStatsSchema = z.object({
total_size: z.number().default(0),
total_uncompressed_size: z.number().default(0),
@ -70,4 +80,5 @@ export type ResticBackupProgressMetricsDto = z.infer<typeof resticBackupProgress
export type ResticBackupProgressDto = z.infer<typeof resticBackupProgressSchema>;
export type ResticRestoreOutputDto = z.infer<typeof resticRestoreOutputSchema>;
export type RestoreProgress = z.infer<typeof restoreProgressSchema>;
export type ResticStatsDto = z.infer<typeof resticStatsSchema>;