Graphical PDS migrator for AT Protocol
1/** 2 * Shared types for migration components 3 */ 4 5export interface MigrationStateInfo { 6 state: "up" | "issue" | "maintenance"; 7 message: string; 8 allowMigration: boolean; 9} 10 11export interface MigrationCredentials { 12 service: string; 13 handle: string; 14 email: string; 15 password: string; 16 invite?: string; 17} 18 19export interface StepCommonProps { 20 credentials: MigrationCredentials; 21 onStepComplete: () => void; 22 onStepError: (error: string, isVerificationError?: boolean) => void; 23} 24 25export interface VerificationResult { 26 ready: boolean; 27 reason?: string; 28 activated?: boolean; 29 validDid?: boolean; 30 repoCommit?: boolean; 31 repoRev?: boolean; 32 repoBlocks?: number; 33 expectedRecords?: number; 34 indexedRecords?: number; 35 privateStateValues?: number; 36 expectedBlobs?: number; 37 importedBlobs?: number; 38} 39 40/** 41 * Helper function to verify a migration step 42 */ 43export async function verifyMigrationStep( 44 stepNum: number, 45): Promise<VerificationResult> { 46 const res = await fetch(`/api/migrate/status?step=${stepNum}`); 47 const data = await res.json(); 48 return data; 49} 50 51/** 52 * Helper function to handle API responses with proper error parsing 53 */ 54export function parseApiResponse( 55 responseText: string, 56): { success: boolean; message?: string } { 57 try { 58 const json = JSON.parse(responseText); 59 return { success: json.success !== false, message: json.message }; 60 } catch { 61 return { success: responseText.trim() !== "", message: responseText }; 62 } 63}