70 lines
1.9 KiB
TypeScript
70 lines
1.9 KiB
TypeScript
import { type } from "arktype";
|
|
import { describeRoute, resolver } from "hono-openapi";
|
|
|
|
const secretsModeSchema = type("'exclude' | 'encrypted' | 'cleartext'");
|
|
|
|
export const fullExportBodySchema = type({
|
|
/** Include metadata (IDs, timestamps, runtime state) in export (default: false) */
|
|
"includeMetadata?": "boolean",
|
|
/** How to handle secrets: exclude, encrypted, or cleartext (default: exclude) */
|
|
"secretsMode?": secretsModeSchema,
|
|
/** Password required for authentication */
|
|
password: "string",
|
|
/** Include the recovery key (requires password) */
|
|
"includeRecoveryKey?": "boolean",
|
|
/** Include the admin password hash */
|
|
"includePasswordHash?": "boolean",
|
|
});
|
|
|
|
export type FullExportBody = typeof fullExportBodySchema.infer;
|
|
export type SecretsMode = typeof secretsModeSchema.infer;
|
|
|
|
const exportResponseSchema = type({
|
|
"version?": "number",
|
|
"exportedAt?": "string",
|
|
"volumes?": "unknown[]",
|
|
"repositories?": "unknown[]",
|
|
"backupSchedules?": "unknown[]",
|
|
"notificationDestinations?": "unknown[]",
|
|
"admin?": type({
|
|
username: "string",
|
|
"passwordHash?": "string",
|
|
"recoveryKey?": "string",
|
|
}).or("null"),
|
|
});
|
|
|
|
const errorResponseSchema = type({
|
|
error: "string",
|
|
});
|
|
|
|
export const fullExportDto = describeRoute({
|
|
description: "Export full configuration including all volumes, repositories, backup schedules, and notifications",
|
|
operationId: "exportFullConfig",
|
|
tags: ["Config Export"],
|
|
responses: {
|
|
200: {
|
|
description: "Full configuration export",
|
|
content: {
|
|
"application/json": {
|
|
schema: resolver(exportResponseSchema),
|
|
},
|
|
},
|
|
},
|
|
401: {
|
|
description: "Password required for sensitive export options",
|
|
content: {
|
|
"application/json": {
|
|
schema: resolver(errorResponseSchema),
|
|
},
|
|
},
|
|
},
|
|
500: {
|
|
description: "Export failed",
|
|
content: {
|
|
"application/json": {
|
|
schema: resolver(errorResponseSchema),
|
|
},
|
|
},
|
|
},
|
|
},
|
|
});
|