UNPKG

apx-toolkit

Version:

Automatically discover APIs and generate complete integration packages: code in 12 languages, TypeScript types, test suites, SDK packages, API documentation, mock servers, performance reports, and contract tests. Saves 2-4 weeks of work in seconds.

125 lines (109 loc) โ€ข 4.76 kB
/** * User-Friendly Messages * * Provides clear, helpful messages for users */ export const USER_MESSAGES = { welcome: () => ` ๐Ÿš€ Welcome to APX Toolkit! ========================== APX automatically discovers APIs and generates everything you need: โ€ข Code in 12 languages โ€ข Complete documentation โ€ข Test suites โ€ข SDK packages โ€ข Mock servers โ€ข Performance reports โ€ข And much more! Let's get started! ๐ŸŽฏ `, discovery: { starting: (urlCount: number) => `๐Ÿ” Starting API discovery... (${urlCount} URL${urlCount > 1 ? 's' : ''})`, inProgress: (current: number, total: number) => ` Discovering... ${current}/${total}`, found: (count: number) => `โœ… Found ${count} API endpoint${count !== 1 ? 's' : ''}!`, none: () => `โš ๏ธ No APIs discovered. Try enabling interaction simulation or check your URLs.`, }, processing: { starting: (count: number) => `โšก Processing ${count} API${count !== 1 ? 's' : ''}...`, inProgress: (current: number, total: number) => ` Processing... ${current}/${total}`, complete: (count: number) => `โœ… Processed ${count} API${count !== 1 ? 's' : ''}!`, }, generation: { mockServer: () => `๐Ÿ”„ Generating mock server...`, performance: () => `๐Ÿ“Š Benchmarking performance...`, contracts: () => `๐Ÿงช Generating contract tests...`, mcp: () => `๐Ÿค– Setting up MCP integration...`, x402: () => `๐Ÿ’ณ Detecting payment endpoints...`, dependencyGraph: () => `๐Ÿ”— Analyzing dependencies...`, complete: (feature: string) => `โœ… ${feature} complete!`, }, output: { summary: (items: number) => `๐Ÿ“ฆ Generated ${items} output item${items !== 1 ? 's' : ''}`, location: (location: string) => `๐Ÿ“ Output saved to: ${location}`, nextSteps: () => ` ๐Ÿ“‹ Next Steps: 1. Check the Dataset tab for all outputs 2. Download the dataset to get all files 3. Use the generated code, docs, and tools 4. Check the different views for organized outputs `, }, errors: { invalidUrl: (url: string) => `โŒ Invalid URL: "${url}". Please check the URL format.`, noUrls: () => `โŒ No start URLs provided. Please add at least one URL to start.`, discoveryFailed: (url: string, reason: string) => `โš ๏ธ Could not discover APIs from ${url}. ${reason}`, processingFailed: (url: string) => `โš ๏ธ Could not process ${url}. Continuing with other APIs...`, validation: (field: string, message: string) => `โŒ Invalid ${field}: ${message}`, suggestion: (suggestion: string) => `๐Ÿ’ก Tip: ${suggestion}`, }, tips: { betterDiscovery: () => `๐Ÿ’ก Tip: Enable "Interaction Simulation" to discover more APIs by clicking buttons and scrolling.`, fasterProcessing: () => `๐Ÿ’ก Tip: Increase "Max Concurrency" for faster processing (but may hit rate limits).`, moreApis: () => `๐Ÿ’ก Tip: Try multiple start URLs or increase "Max Pages" to discover more APIs.`, authentication: () => `๐Ÿ’ก Tip: Add authentication headers or tokens if the API requires login.`, }, success: { complete: () => `๐ŸŽ‰ All done! Your API integration package is ready!`, features: (count: number) => `โœจ Generated ${count} feature${count !== 1 ? 's' : ''}!`, }, }; /** * Format progress message */ export function formatProgress(current: number, total: number, label: string): string { const percentage = Math.round((current / total) * 100); const barLength = 20; const filled = Math.round((percentage / 100) * barLength); const empty = barLength - filled; const bar = 'โ–ˆ'.repeat(filled) + 'โ–‘'.repeat(empty); return `${label} [${bar}] ${percentage}% (${current}/${total})`; } /** * Format time estimate */ export function formatTimeEstimate(seconds: number): string { if (seconds < 60) { return `~${Math.round(seconds)} seconds`; } else { const minutes = Math.round(seconds / 60); return `~${minutes} minute${minutes !== 1 ? 's' : ''}`; } } /** * Get helpful suggestion based on error */ export function getSuggestion(error: string): string | null { if (error.includes('URL') || error.includes('url')) { return USER_MESSAGES.tips.betterDiscovery(); } if (error.includes('timeout') || error.includes('slow')) { return USER_MESSAGES.tips.fasterProcessing(); } if (error.includes('auth') || error.includes('401') || error.includes('403')) { return USER_MESSAGES.tips.authentication(); } if (error.includes('no APIs') || error.includes('discover')) { return USER_MESSAGES.tips.moreApis(); } return null; }