refactor: export restore progress from dto file
This commit is contained in:
parent
1defe461be
commit
4f09420c25
3 changed files with 17 additions and 15 deletions
|
|
@ -1,5 +1,4 @@
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { z } from "zod";
|
|
||||||
import { throttle } from "es-toolkit";
|
import { throttle } from "es-toolkit";
|
||||||
import { findCommonAncestor } from "../../utils/common-ancestor";
|
import { findCommonAncestor } from "../../utils/common-ancestor";
|
||||||
import { addCommonArgs } from "../helpers/add-common-args";
|
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 { type RepositoryConfig, type OverwriteMode } from "../schemas";
|
||||||
import { logger, safeSpawn } from "../../node";
|
import { logger, safeSpawn } from "../../node";
|
||||||
import { createResticError, isResticError, type AnyResticError } from "../error";
|
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 type { ResticDeps } from "../types";
|
||||||
import { Data, Effect } from "effect";
|
import { Data, Effect } from "effect";
|
||||||
import { toMessage } from "../../utils";
|
import { toMessage } from "../../utils";
|
||||||
|
|
@ -19,18 +23,6 @@ class ResticRestoreCommandError extends Data.TaggedError("ResticRestoreCommandEr
|
||||||
message: string;
|
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 = (
|
export const restore = (
|
||||||
config: RepositoryConfig,
|
config: RepositoryConfig,
|
||||||
snapshotId: string,
|
snapshotId: string,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
export * from "./schemas";
|
export * from "./schemas";
|
||||||
export * from "./restic-dto";
|
export * from "./restic-dto";
|
||||||
export { isResticError, ResticError, ResticLockError } from "./error";
|
export { isResticError, ResticError, ResticLockError } from "./error";
|
||||||
export { restoreProgressSchema, type RestoreProgress } from "./commands/restore";
|
|
||||||
export type {
|
export type {
|
||||||
ResticDeps,
|
ResticDeps,
|
||||||
ResticEnv,
|
ResticEnv,
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,16 @@ export const resticRestoreOutputSchema = z.object({
|
||||||
bytes_skipped: z.number().optional(),
|
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({
|
export const resticStatsSchema = z.object({
|
||||||
total_size: z.number().default(0),
|
total_size: z.number().default(0),
|
||||||
total_uncompressed_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 ResticBackupProgressDto = z.infer<typeof resticBackupProgressSchema>;
|
||||||
|
|
||||||
export type ResticRestoreOutputDto = z.infer<typeof resticRestoreOutputSchema>;
|
export type ResticRestoreOutputDto = z.infer<typeof resticRestoreOutputSchema>;
|
||||||
|
export type RestoreProgress = z.infer<typeof restoreProgressSchema>;
|
||||||
export type ResticStatsDto = z.infer<typeof resticStatsSchema>;
|
export type ResticStatsDto = z.infer<typeof resticStatsSchema>;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue