import type { AppErrorCode } from '@shared/errors.ts'; import type { AccountEdits, SaveAvatarChoices, CurrencyEdits, OfficialImportOptions, OfficialPreview, ResearchBranch, ResearchOperation, SaveDetails, SaveList, SaveResearch } from '@shared/schemas/saves.ts'; interface Location { readonly gameFolder: string; readonly dataFolder: string; } export type SaveTask = Location & ( | { readonly operation: 'list' } | { readonly operation: 'details'; readonly userId: string } | { readonly operation: 'avatars' } | { readonly operation: 'avatarPreview'; readonly avatar: string } | { readonly operation: 'editAccount'; readonly userId: string; readonly edits: AccountEdits } | { readonly operation: 'edit'; readonly userId: string; readonly values: CurrencyEdits } | { readonly operation: 'previewOfficial'; readonly paths: readonly string[] } | { readonly operation: 'importOfficial'; readonly paths: readonly string[]; readonly userId: string; readonly options: OfficialImportOptions; readonly offlineClientCacheFolders?: readonly string[]; } | { readonly operation: 'readResearch'; readonly userId: string; readonly branch?: ResearchBranch } | { readonly operation: 'editResearch'; readonly userId: string; readonly branch: ResearchBranch; readonly action: ResearchOperation } | { readonly operation: 'remove'; readonly userId: string } | { readonly operation: 'filter'; readonly profile: Uint8Array; readonly filter: boolean } | { readonly operation: 'create'; readonly login: string; readonly password: string; readonly nick: string } ); export type SaveResult = SaveList['saves'] | SaveDetails | OfficialPreview | SaveResearch | { userId: string } | Uint8Array | SaveAvatarChoices | string | null; export type SaveReply = { ok: true; result: SaveResult } | { ok: false; error: AppErrorCode };