refactor: snapshots flat response

This commit is contained in:
Nicolas Meienberger
2025-11-03 21:54:31 +01:00
parent acc5f44565
commit f2643436b0
5 changed files with 19 additions and 17 deletions

View File

@@ -791,15 +791,13 @@ export type ListSnapshotsResponses = {
/** /**
* List of snapshots * List of snapshots
*/ */
200: { 200: Array<{
snapshots: Array<{ duration: number;
duration: number; paths: Array<string>;
paths: Array<string>; short_id: string;
short_id: string; size: number;
size: number; time: number;
time: number; }>;
}>;
};
}; };
export type ListSnapshotsResponse = ListSnapshotsResponses[keyof ListSnapshotsResponses]; export type ListSnapshotsResponse = ListSnapshotsResponses[keyof ListSnapshotsResponses];

View File

@@ -1,4 +1,10 @@
import type { GetBackupScheduleResponse, GetMeResponse, GetRepositoryResponse, GetVolumeResponse } from "~/api-client"; import type {
GetBackupScheduleResponse,
GetMeResponse,
GetRepositoryResponse,
GetVolumeResponse,
ListSnapshotsResponse,
} from "~/api-client";
export type Volume = GetVolumeResponse["volume"]; export type Volume = GetVolumeResponse["volume"];
export type StatFs = GetVolumeResponse["statfs"]; export type StatFs = GetVolumeResponse["statfs"];
@@ -9,3 +15,5 @@ export type User = GetMeResponse["user"];
export type Repository = GetRepositoryResponse; export type Repository = GetRepositoryResponse;
export type BackupSchedule = GetBackupScheduleResponse; export type BackupSchedule = GetBackupScheduleResponse;
export type Snapshot = ListSnapshotsResponse[number];

View File

@@ -69,9 +69,7 @@ export const repositoriesController = new Hono()
}; };
}); });
const response = { snapshots }; return c.json<ListSnapshotsDto>(snapshots, 200);
return c.json<ListSnapshotsDto>(response, 200);
}) })
.get( .get(
"/:name/snapshots/:snapshotId/files", "/:name/snapshots/:snapshotId/files",

View File

@@ -139,9 +139,7 @@ export const snapshotSchema = type({
duration: "number", duration: "number",
}); });
const listSnapshotsResponse = type({ const listSnapshotsResponse = snapshotSchema.array();
snapshots: snapshotSchema.array(),
});
export type ListSnapshotsDto = typeof listSnapshotsResponse.infer; export type ListSnapshotsDto = typeof listSnapshotsResponse.infer;

View File

@@ -1,7 +1,7 @@
import { defaultPlugins, defineConfig } from "@hey-api/openapi-ts"; import { defaultPlugins, defineConfig } from "@hey-api/openapi-ts";
export default defineConfig({ export default defineConfig({
input: "http://localhost:4096/api/v1/openapi.json", input: "http://192.168.2.42:4096/api/v1/openapi.json",
output: { output: {
path: "./apps/client/app/api-client", path: "./apps/client/app/api-client",
format: "biome", format: "biome",