Support save archives and copy transfers

This commit is contained in:
N0VAN0M4LY committed 2026-11-29 15:55:23 +08:00
1 parent d19baec90b
commit c957cecee4
19 files changed
+660 -25

No files matched your search

+14
View File
@@ -40,6 +40,20 @@ export const SaveRegistrationSchema = z.object({
copyId: CopyIdSchema, login: z.string(), password: z.string(), nick: z.string(),
});
export const SaveTransferSchema = SaveRegistrationSchema.extend({
source: z.discriminatedUnion('kind', [
z.object({ kind: z.literal('save'), copyId: CopyIdSchema, userId: LocalUserIdSchema }),
z.object({ kind: z.literal('file'), path: z.string().min(1) }),
]),
});
export const SaveBackupNameSchema = z.string().regex(/^\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}-\d{3}Z\.(manual|launch|restore)\.[0-9a-f-]{36}\.zip$/);
export const SaveBackupSchema = z.object({
name: SaveBackupNameSchema, createdAt: z.string(), type: z.enum(['manual', 'launch', 'restore']), size: z.number().int().nonnegative(),
});
export type SaveTransfer = z.output<typeof SaveTransferSchema>;
export type SaveBackup = z.output<typeof SaveBackupSchema>;
export type SaveList = z.output<typeof SaveListSchema>;
export type SaveDetails = z.output<typeof SaveDetailsSchema>;
export type CurrencyEdits = z.output<typeof CurrencyEditsSchema>;
@@ -16,6 +16,7 @@ export const SettingsSchema = z.object({
officialWallpapers: z.boolean().default(true),
windowClose: WindowCloseSchema.default('quit'),
afterGameStarts: AfterGameStartsSchema.default('minimize'),
autoSaveBackups: z.boolean().default(true),
developerMode: z.boolean().default(true),
labStockPath: LabPathSchema.default(null),
labDataPath: LabPathSchema.default(null),
@@ -30,6 +31,7 @@ export const SettingsPatchSchema = z.object({
officialWallpapers: z.boolean().optional(),
windowClose: WindowCloseSchema.optional(),
afterGameStarts: AfterGameStartsSchema.optional(),
autoSaveBackups: z.boolean().optional(),
developerMode: z.boolean().optional(),
labStockPath: LabPathSchema.optional(),
labDataPath: LabPathSchema.optional(),