Support save archives and copy transfers
This commit is contained in:
1 parent
d19baec90b
commit
c957cecee4
19 files changed
+660
-25
No files matched your search
@@ -18,6 +18,7 @@ export const APP_ERROR_CODES = [
|
||||
'diagnostics_export_failed',
|
||||
'copy_not_found',
|
||||
'save_not_found',
|
||||
'save_archive_invalid',
|
||||
'save_read_only',
|
||||
'save_operation_failed',
|
||||
'save_login_invalid',
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
} from '../schemas/install.ts';
|
||||
import { LabInfoSchema, LaunchStateSchema } from '../schemas/launch.ts';
|
||||
import { MaintenanceInfoSchema, MaintenanceProgressSchema, MaintenanceRequestSchema } from '../schemas/maintenance.ts';
|
||||
import { CurrencyEditsSchema, SaveDetailsSchema, SaveKeysSchema, SaveListSchema, SaveRegistrationSchema } from '../schemas/saves.ts';
|
||||
import { CurrencyEditsSchema, SaveBackupNameSchema, SaveBackupSchema, SaveDetailsSchema, SaveKeysSchema, SaveListSchema, SaveRegistrationSchema, SaveTransferSchema } from '../schemas/saves.ts';
|
||||
import { SettingsPatchSchema, SettingsSchema } from '../schemas/settings.ts';
|
||||
|
||||
/**
|
||||
@@ -148,6 +148,34 @@ export const ipcContract = {
|
||||
input: SaveKeysSchema.extend({ values: CurrencyEditsSchema }),
|
||||
output: SaveDetailsSchema,
|
||||
},
|
||||
'saves:pickArchive': {
|
||||
input: z.void(),
|
||||
output: z.object({ path: z.string().nullable() }),
|
||||
},
|
||||
'saves:export': {
|
||||
input: SaveKeysSchema,
|
||||
output: z.object({ path: z.string().nullable() }),
|
||||
},
|
||||
'saves:transfer': {
|
||||
input: SaveTransferSchema,
|
||||
output: SaveListSchema,
|
||||
},
|
||||
'saves:delete': {
|
||||
input: SaveKeysSchema,
|
||||
output: SaveListSchema,
|
||||
},
|
||||
'saves:listBackups': {
|
||||
input: SaveKeysSchema,
|
||||
output: z.array(SaveBackupSchema),
|
||||
},
|
||||
'saves:takeBackup': {
|
||||
input: SaveKeysSchema,
|
||||
output: z.array(SaveBackupSchema),
|
||||
},
|
||||
'saves:restoreBackup': {
|
||||
input: SaveKeysSchema.extend({ name: SaveBackupNameSchema }),
|
||||
output: SaveDetailsSchema,
|
||||
},
|
||||
'launch:getState': {
|
||||
input: z.void(),
|
||||
output: LaunchStateSchema,
|
||||
|
||||
@@ -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(),
|
||||
|
||||
Reference in new issue
Block a user