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
text/typescript
/**
* 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;
}