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
*/
200: {
snapshots: Array<{
duration: number;
paths: Array<string>;
short_id: string;
size: number;
time: number;
}>;
};
200: Array<{
duration: number;
paths: Array<string>;
short_id: string;
size: number;
time: number;
}>;
};
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 StatFs = GetVolumeResponse["statfs"];
@@ -9,3 +15,5 @@ export type User = GetMeResponse["user"];
export type Repository = GetRepositoryResponse;
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>(response, 200);
return c.json<ListSnapshotsDto>(snapshots, 200);
})
.get(
"/:name/snapshots/:snapshotId/files",

View File

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

View File

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