@nordsym/apiclaw 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/README.md +15 -2
  2. package/dist/bin-http.js +0 -0
  3. package/dist/bin.bundled.js +79288 -0
  4. package/dist/gateway-client.d.ts.map +1 -1
  5. package/dist/gateway-client.js +24 -2
  6. package/dist/gateway-client.js.map +1 -1
  7. package/dist/index.bundled.js +61263 -0
  8. package/dist/index.js +2 -2
  9. package/dist/index.js.map +1 -1
  10. package/package.json +7 -2
  11. package/.claude/settings.local.json +0 -13
  12. package/.env.prod +0 -1
  13. package/apiclaw-README.md +0 -494
  14. package/convex/_generated/api.d.ts +0 -145
  15. package/convex/_generated/api.js +0 -23
  16. package/convex/_generated/dataModel.d.ts +0 -60
  17. package/convex/_generated/server.d.ts +0 -143
  18. package/convex/_generated/server.js +0 -93
  19. package/convex/_listWorkspaces.ts +0 -13
  20. package/convex/adminActivate.ts +0 -53
  21. package/convex/adminStats.ts +0 -306
  22. package/convex/agents.ts +0 -939
  23. package/convex/analytics.ts +0 -187
  24. package/convex/apiKeys.ts +0 -220
  25. package/convex/backfillAnalytics.ts +0 -272
  26. package/convex/backfillSearchLogs.ts +0 -35
  27. package/convex/billing.ts +0 -834
  28. package/convex/capabilities.ts +0 -157
  29. package/convex/chains.ts +0 -1318
  30. package/convex/credits.ts +0 -211
  31. package/convex/crons.ts +0 -65
  32. package/convex/debugFilestackLogs.ts +0 -16
  33. package/convex/debugGetToken.ts +0 -18
  34. package/convex/directCall.ts +0 -713
  35. package/convex/earnProgress.ts +0 -753
  36. package/convex/email.ts +0 -329
  37. package/convex/feedback.ts +0 -265
  38. package/convex/funnel.ts +0 -431
  39. package/convex/guards.ts +0 -174
  40. package/convex/http.ts +0 -3756
  41. package/convex/inbound.ts +0 -32
  42. package/convex/logs.ts +0 -701
  43. package/convex/migrateFilestack.ts +0 -81
  44. package/convex/migratePartnersProd.ts +0 -174
  45. package/convex/migratePratham.ts +0 -126
  46. package/convex/migrateProviderWorkspaces.ts +0 -175
  47. package/convex/mou.ts +0 -91
  48. package/convex/nurture.ts +0 -355
  49. package/convex/providerKeys.ts +0 -289
  50. package/convex/providers.ts +0 -1135
  51. package/convex/purchases.ts +0 -183
  52. package/convex/ratelimit.ts +0 -104
  53. package/convex/schema.ts +0 -926
  54. package/convex/searchLogs.ts +0 -265
  55. package/convex/seedAPILayerAPIs.ts +0 -191
  56. package/convex/seedDirectCallConfigs.ts +0 -336
  57. package/convex/seedPratham.ts +0 -149
  58. package/convex/spendAlerts.ts +0 -442
  59. package/convex/stripeActions.ts +0 -607
  60. package/convex/teams.ts +0 -243
  61. package/convex/telemetry.ts +0 -81
  62. package/convex/tsconfig.json +0 -25
  63. package/convex/updateAPIStatus.ts +0 -44
  64. package/convex/usage.ts +0 -260
  65. package/convex/usageReports.ts +0 -357
  66. package/convex/waitlist.ts +0 -55
  67. package/convex/webhooks.ts +0 -494
  68. package/convex/workspaceSettings.ts +0 -143
  69. package/convex/workspaces.ts +0 -1331
  70. package/convex.json +0 -3
  71. package/direct-test.mjs +0 -51
  72. package/email-templates/filestack-provider-outreach.html +0 -162
  73. package/email-templates/partnership-template.html +0 -116
  74. package/email-templates/pratham-draft-preview.txt +0 -57
  75. package/email-templates/pratham-partnership-draft.html +0 -141
  76. package/reports/APIClaw-Session-Report-2026-04-05.pdf +0 -0
  77. package/reports/pipeline/PIPELINE-REPORT.json +0 -153
  78. package/reports/pipeline/acquire_apisguru.json +0 -17
  79. package/reports/pipeline/capabilities.json +0 -38
  80. package/reports/pipeline/discover_azure_recursive.json +0 -1551
  81. package/reports/pipeline/discover_github.json +0 -25
  82. package/reports/pipeline/discover_github_repos.json +0 -49
  83. package/reports/pipeline/discover_swaggerhub.json +0 -24
  84. package/reports/pipeline/discover_well_known.json +0 -23
  85. package/reports/pipeline/fetch_specs.json +0 -19
  86. package/reports/pipeline/generate_providers.json +0 -14
  87. package/reports/pipeline/match_registry.json +0 -11
  88. package/reports/pipeline/parse_specs.json +0 -17
  89. package/reports/pipeline/promote_candidates.json +0 -34
  90. package/reports/pipeline/validate.json +0 -30
  91. package/reports/pipeline/validate_smoke_details.json +0 -3835
  92. package/reports/session-report-2026-04-05.html +0 -433
  93. package/seed-apis-direct.mjs +0 -106
  94. package/src/access-control.ts +0 -174
  95. package/src/adapters/base.ts +0 -364
  96. package/src/adapters/claude-desktop.ts +0 -41
  97. package/src/adapters/cline.ts +0 -88
  98. package/src/adapters/continue.ts +0 -91
  99. package/src/adapters/cursor.ts +0 -43
  100. package/src/adapters/custom.ts +0 -188
  101. package/src/adapters/detect.ts +0 -202
  102. package/src/adapters/index.ts +0 -47
  103. package/src/adapters/windsurf.ts +0 -44
  104. package/src/bin-http.ts +0 -45
  105. package/src/bin.ts +0 -34
  106. package/src/capability-router.ts +0 -331
  107. package/src/chainExecutor.ts +0 -730
  108. package/src/chainResolver.test.ts +0 -246
  109. package/src/chainResolver.ts +0 -658
  110. package/src/cli/commands/demo.ts +0 -109
  111. package/src/cli/commands/doctor.ts +0 -435
  112. package/src/cli/commands/index.ts +0 -9
  113. package/src/cli/commands/login.ts +0 -203
  114. package/src/cli/commands/mcp-install.ts +0 -373
  115. package/src/cli/commands/restore.ts +0 -333
  116. package/src/cli/commands/setup.ts +0 -297
  117. package/src/cli/commands/uninstall.ts +0 -240
  118. package/src/cli/index.ts +0 -148
  119. package/src/cli.ts +0 -370
  120. package/src/confirmation.ts +0 -296
  121. package/src/credentials.ts +0 -455
  122. package/src/credits.ts +0 -329
  123. package/src/crypto.ts +0 -75
  124. package/src/discovery.ts +0 -568
  125. package/src/enterprise/env.ts +0 -156
  126. package/src/enterprise/index.ts +0 -7
  127. package/src/enterprise/script-generator.ts +0 -481
  128. package/src/execute-dynamic.ts +0 -617
  129. package/src/execute.ts +0 -2386
  130. package/src/funnel-client.ts +0 -168
  131. package/src/funnel.test.ts +0 -187
  132. package/src/gateway-client.ts +0 -192
  133. package/src/hivr-whitelist.ts +0 -110
  134. package/src/http-api.ts +0 -286
  135. package/src/http-server-minimal.ts +0 -154
  136. package/src/index.ts +0 -2702
  137. package/src/intelligent-gateway.ts +0 -339
  138. package/src/mcp-analytics.ts +0 -156
  139. package/src/metered.ts +0 -149
  140. package/src/open-apis-generated.ts +0 -157
  141. package/src/open-apis.ts +0 -558
  142. package/src/postinstall.ts +0 -40
  143. package/src/product-whitelist.ts +0 -246
  144. package/src/proxy.ts +0 -36
  145. package/src/registration-guard.ts +0 -117
  146. package/src/session.ts +0 -129
  147. package/src/stripe.ts +0 -497
  148. package/src/telemetry.ts +0 -71
  149. package/src/test.ts +0 -135
  150. package/src/types/convex-api.d.ts +0 -20
  151. package/src/types/convex-api.ts +0 -21
  152. package/src/types.ts +0 -109
  153. package/src/ui/colors.ts +0 -219
  154. package/src/ui/errors.ts +0 -394
  155. package/src/ui/index.ts +0 -17
  156. package/src/ui/prompts.ts +0 -390
  157. package/src/ui/spinner.ts +0 -325
  158. package/src/utils/backup.ts +0 -224
  159. package/src/utils/config.ts +0 -318
  160. package/src/utils/os.ts +0 -124
  161. package/src/utils/paths.ts +0 -203
  162. package/src/webhook.ts +0 -107
  163. package/test-10-working.cjs +0 -97
  164. package/test-14-final.cjs +0 -96
  165. package/test-actual-handlers.ts +0 -92
  166. package/test-apilayer-all-14.ts +0 -249
  167. package/test-apilayer-fixed.ts +0 -248
  168. package/test-direct-endpoints.ts +0 -174
  169. package/test-exact-endpoints.ts +0 -144
  170. package/test-final.ts +0 -83
  171. package/test-full-routing.ts +0 -100
  172. package/test-handlers-correct.ts +0 -217
  173. package/test-numverify-key.ts +0 -41
  174. package/test-via-handlers.ts +0 -92
  175. package/test-worldnews.mjs +0 -26
  176. package/tsconfig.json +0 -20
@@ -1,203 +0,0 @@
1
- /**
2
- * Config Path Resolver
3
- * Resolves config file paths for all MCP clients across all operating systems
4
- */
5
-
6
- import { join } from 'path';
7
- import { detectOS, getHomeDir, getAppDataDir, getUserProfileDir, Platform } from './os.js';
8
-
9
- export type MCPClient =
10
- | 'claude-desktop'
11
- | 'cursor'
12
- | 'windsurf'
13
- | 'cline'
14
- | 'continue';
15
-
16
- export interface ClientPathConfig {
17
- name: string;
18
- displayName: string;
19
- configPath: string;
20
- configDir: string;
21
- configFile: string;
22
- }
23
-
24
- /**
25
- * Get config path for Claude Desktop
26
- */
27
- function getClaudeDesktopPath(os: Platform): string {
28
- const home = getHomeDir();
29
- const appData = getAppDataDir();
30
-
31
- switch (os) {
32
- case 'mac':
33
- return join(appData, 'Claude', 'claude_desktop_config.json');
34
- case 'win':
35
- return join(appData, 'Claude', 'claude_desktop_config.json');
36
- case 'linux':
37
- return join(home, '.config', 'Claude', 'claude_desktop_config.json');
38
- }
39
- }
40
-
41
- /**
42
- * Get config path for Cursor
43
- */
44
- function getCursorPath(os: Platform): string {
45
- const home = getHomeDir();
46
- const appData = getAppDataDir();
47
-
48
- switch (os) {
49
- case 'mac':
50
- return join(appData, 'Cursor', 'User', 'globalStorage', 'cursor.mcp', 'config.json');
51
- case 'win':
52
- return join(appData, 'Cursor', 'User', 'globalStorage', 'cursor.mcp', 'config.json');
53
- case 'linux':
54
- return join(home, '.config', 'Cursor', 'User', 'globalStorage', 'cursor.mcp', 'config.json');
55
- }
56
- }
57
-
58
- /**
59
- * Get config path for Windsurf
60
- */
61
- function getWindsurfPath(os: Platform): string {
62
- const home = getHomeDir();
63
- const userProfile = getUserProfileDir();
64
-
65
- switch (os) {
66
- case 'mac':
67
- case 'linux':
68
- return join(home, '.codeium', 'windsurf', 'mcp_config.json');
69
- case 'win':
70
- return join(userProfile, '.codeium', 'windsurf', 'mcp_config.json');
71
- }
72
- }
73
-
74
- /**
75
- * Get config path for Cline (VS Code extension)
76
- */
77
- function getClinePath(os: Platform): string {
78
- const home = getHomeDir();
79
- const appData = getAppDataDir();
80
-
81
- const relativePath = join(
82
- 'Code', 'User', 'globalStorage',
83
- 'saoudrizwan.claude-dev', 'settings',
84
- 'cline_mcp_settings.json'
85
- );
86
-
87
- switch (os) {
88
- case 'mac':
89
- return join(appData, relativePath);
90
- case 'win':
91
- return join(appData, relativePath);
92
- case 'linux':
93
- return join(home, '.config', relativePath);
94
- }
95
- }
96
-
97
- /**
98
- * Get config path for Continue
99
- */
100
- function getContinuePath(os: Platform): string {
101
- const home = getHomeDir();
102
- const userProfile = getUserProfileDir();
103
-
104
- switch (os) {
105
- case 'mac':
106
- case 'linux':
107
- return join(home, '.continue', 'config.json');
108
- case 'win':
109
- return join(userProfile, '.continue', 'config.json');
110
- }
111
- }
112
-
113
- /**
114
- * Get the config path for a specific MCP client
115
- */
116
- export function getConfigPath(client: MCPClient, os?: Platform): string {
117
- const currentOS = os || detectOS();
118
-
119
- switch (client) {
120
- case 'claude-desktop':
121
- return getClaudeDesktopPath(currentOS);
122
- case 'cursor':
123
- return getCursorPath(currentOS);
124
- case 'windsurf':
125
- return getWindsurfPath(currentOS);
126
- case 'cline':
127
- return getClinePath(currentOS);
128
- case 'continue':
129
- return getContinuePath(currentOS);
130
- }
131
- }
132
-
133
- /**
134
- * Get full client configuration info
135
- */
136
- export function getClientConfig(client: MCPClient, os?: Platform): ClientPathConfig {
137
- const configPath = getConfigPath(client, os);
138
- const pathParts = configPath.split(/[/\\]/);
139
- const configFile = pathParts.pop() || '';
140
- const configDir = pathParts.join('/');
141
-
142
- const displayNames: Record<MCPClient, string> = {
143
- 'claude-desktop': 'Claude Desktop',
144
- 'cursor': 'Cursor',
145
- 'windsurf': 'Windsurf',
146
- 'cline': 'Cline',
147
- 'continue': 'Continue',
148
- };
149
-
150
- return {
151
- name: client,
152
- displayName: displayNames[client],
153
- configPath,
154
- configDir,
155
- configFile,
156
- };
157
- }
158
-
159
- /**
160
- * Get all supported MCP clients
161
- */
162
- export function getAllClients(): MCPClient[] {
163
- return ['claude-desktop', 'cursor', 'windsurf', 'cline', 'continue'];
164
- }
165
-
166
- /**
167
- * Get config paths for all clients
168
- */
169
- export function getAllConfigPaths(os?: Platform): Map<MCPClient, ClientPathConfig> {
170
- const paths = new Map<MCPClient, ClientPathConfig>();
171
-
172
- for (const client of getAllClients()) {
173
- paths.set(client, getClientConfig(client, os));
174
- }
175
-
176
- return paths;
177
- }
178
-
179
- /**
180
- * Validate that a client name is valid
181
- */
182
- export function isValidClient(client: string): client is MCPClient {
183
- return getAllClients().includes(client as MCPClient);
184
- }
185
-
186
- /**
187
- * Parse client argument (accepts various formats)
188
- */
189
- export function parseClientArg(arg: string): MCPClient | null {
190
- const normalized = arg.toLowerCase().replace(/[_\s]/g, '-');
191
-
192
- const aliases: Record<string, MCPClient> = {
193
- 'claude': 'claude-desktop',
194
- 'claude-desktop': 'claude-desktop',
195
- 'claudedesktop': 'claude-desktop',
196
- 'cursor': 'cursor',
197
- 'windsurf': 'windsurf',
198
- 'cline': 'cline',
199
- 'continue': 'continue',
200
- };
201
-
202
- return aliases[normalized] || null;
203
- }
package/src/webhook.ts DELETED
@@ -1,107 +0,0 @@
1
- // Stripe webhook handler for APIClaw
2
- // Run as: npx ts-node src/webhook.ts
3
-
4
- import { serve } from '@hono/node-server';
5
- import { Hono } from 'hono';
6
- import { verifyWebhookSignature, processWebhookEvent, CREDIT_PACKAGES } from './stripe.js';
7
- import { addCredits } from './credits.js';
8
- import { config } from 'dotenv';
9
-
10
- // Load environment
11
- config({ path: '.env.local' });
12
-
13
- const app = new Hono();
14
-
15
- // Health check
16
- app.get('/', (c) => {
17
- return c.json({
18
- service: 'APIClaw Webhook',
19
- status: 'ok',
20
- packages: Object.values(CREDIT_PACKAGES).map(p => ({
21
- id: p.id,
22
- price: `$${p.amountUsd}`,
23
- credits: p.credits,
24
- })),
25
- });
26
- });
27
-
28
- // Stripe webhook endpoint
29
- app.post('/webhook/stripe', async (c) => {
30
- const signature = c.req.header('stripe-signature');
31
- if (!signature) {
32
- return c.json({ error: 'Missing stripe-signature header' }, 400);
33
- }
34
-
35
- // Get raw body
36
- const rawBody = await c.req.text();
37
-
38
- // Verify webhook signature
39
- const event = verifyWebhookSignature(rawBody, signature);
40
- if (!event) {
41
- return c.json({ error: 'Invalid webhook signature' }, 400);
42
- }
43
-
44
- console.log(`[Webhook] Received: ${event.type}`);
45
-
46
- // Process the event
47
- const creditGrant = processWebhookEvent(event);
48
- if (!creditGrant) {
49
- // Not a credit-related event, acknowledge and move on
50
- return c.json({ received: true, processed: false });
51
- }
52
-
53
- // Grant credits to the agent
54
- try {
55
- const credits = addCredits(creditGrant.agentId, creditGrant.credits);
56
-
57
- console.log(`[Webhook] Granted ${creditGrant.credits} credits to ${creditGrant.agentId}`);
58
- console.log(`[Webhook] New balance: $${credits.balance_usd.toFixed(2)}`);
59
-
60
- return c.json({
61
- received: true,
62
- processed: true,
63
- grant: {
64
- agentId: creditGrant.agentId,
65
- credits: creditGrant.credits,
66
- newBalance: credits.balance_usd,
67
- },
68
- });
69
- } catch (error) {
70
- console.error('[Webhook] Error granting credits:', error);
71
- return c.json({ error: 'Failed to grant credits' }, 500);
72
- }
73
- });
74
-
75
- // Manual credit grant endpoint (for testing)
76
- app.post('/admin/grant-credits', async (c) => {
77
- const body = await c.req.json();
78
- const { agentId, credits, adminKey } = body;
79
-
80
- // Simple admin key check (use proper auth in production)
81
- if (adminKey !== process.env.ADMIN_KEY && adminKey !== 'test-admin-key') {
82
- return c.json({ error: 'Invalid admin key' }, 403);
83
- }
84
-
85
- if (!agentId || typeof credits !== 'number') {
86
- return c.json({ error: 'Missing agentId or credits' }, 400);
87
- }
88
-
89
- const result = addCredits(agentId, credits);
90
- return c.json({
91
- success: true,
92
- agentId,
93
- creditsGranted: credits,
94
- newBalance: result.balance_usd,
95
- });
96
- });
97
-
98
- // Start server
99
- const port = parseInt(process.env.WEBHOOK_PORT || '3001', 10);
100
-
101
- console.log(`[APIClaw] Webhook server starting on port ${port}`);
102
- console.log(`[APIClaw] Endpoints:`);
103
- console.log(` GET / - Health check`);
104
- console.log(` POST /webhook/stripe - Stripe webhook`);
105
- console.log(` POST /admin/grant-credits - Manual credit grant`);
106
-
107
- serve({ fetch: app.fetch, port });
@@ -1,97 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const { spawn } = require('child_process');
4
- const path = require('path');
5
-
6
- const tests = [
7
- { action: 'exchange_rates', params: {base: 'USD', symbols: 'EUR'} },
8
- { action: 'aviation', params: {flight_iata: 'AA100'} },
9
- { action: 'pdf_generate', params: {document_url: 'https://example.com'} },
10
- { action: 'screenshot', params: {url: 'https://example.com'} },
11
- { action: 'verify_email', params: {email: 'support@gmail.com'} }, // FIXED: real email
12
- { action: 'vat_check', params: {vat_number: 'SE556703748501'} },
13
- { action: 'finance_news', params: {tickers: 'AAPL', limit: 3} },
14
- { action: 'scrape', params: {url: 'https://example.com'} },
15
- { action: 'skills', params: {q: 'javascript'} },
16
- { action: 'market_data', params: {symbols: 'AAPL'} }
17
- ];
18
-
19
- async function testAction(action, params) {
20
- return new Promise((resolve) => {
21
- const request = JSON.stringify({
22
- jsonrpc: '2.0',
23
- id: 1,
24
- method: 'tools/call',
25
- params: {
26
- name: 'call_api',
27
- arguments: {
28
- provider: 'apilayer',
29
- action,
30
- params
31
- }
32
- }
33
- });
34
-
35
- const proc = spawn('node', ['dist/index.js'], {
36
- cwd: path.join(__dirname),
37
- stdio: ['pipe', 'pipe', 'pipe']
38
- });
39
-
40
- let output = '';
41
- proc.stdout.on('data', (data) => output += data.toString());
42
- proc.stderr.on('data', (data) => output += data.toString());
43
-
44
- proc.on('close', () => {
45
- try {
46
- const match = output.match(/\{"result":\{.*\},"jsonrpc":"2\.0","id":1\}/);
47
- if (match) {
48
- const json = JSON.parse(match[0]);
49
- const text = json.result?.content?.[0]?.text;
50
- if (text) {
51
- const result = JSON.parse(text);
52
- resolve(result.status === 'success');
53
- } else {
54
- resolve(false);
55
- }
56
- } else {
57
- resolve(false);
58
- }
59
- } catch {
60
- resolve(false);
61
- }
62
- });
63
-
64
- proc.stdin.write(request + '\n');
65
- proc.stdin.end();
66
-
67
- // Timeout after 15s
68
- setTimeout(() => {
69
- proc.kill();
70
- resolve(false);
71
- }, 15000);
72
- });
73
- }
74
-
75
- async function runAll() {
76
- console.log('🎯 Testing 10 WORKING APILayer actions...\n');
77
-
78
- const results = [];
79
-
80
- for (const test of tests) {
81
- const success = await testAction(test.action, test.params);
82
- results.push({ action: test.action, success });
83
- console.log(`${success ? '✅' : '❌'} ${test.action}`);
84
- }
85
-
86
- const working = results.filter(r => r.success);
87
- console.log(`\n📊 FINAL: ${working.length}/10 working`);
88
-
89
- if (working.length === 10) {
90
- console.log('\n🎉 ALL 10 CORE ACTIONS WORKING!\n');
91
- }
92
-
93
- console.log('✅ Working:');
94
- working.forEach(r => console.log(` • ${r.action}`));
95
- }
96
-
97
- runAll();
package/test-14-final.cjs DELETED
@@ -1,96 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const { spawn } = require('child_process');
4
- const path = require('path');
5
-
6
- const tests = [
7
- { action: 'exchange_rates', params: {base: 'USD', symbols: 'EUR'} },
8
- { action: 'aviation', params: {flight_iata: 'AA100'} },
9
- { action: 'pdf_generate', params: {document_url: 'https://example.com'} },
10
- { action: 'screenshot', params: {url: 'https://example.com'} },
11
- { action: 'verify_email', params: {email: 'test@example.com'} },
12
- { action: 'verify_number', params: {number: '14158586273'} },
13
- { action: 'vat_check', params: {vat_number: 'SE556703748501'} },
14
- { action: 'world_news', params: {url: 'https://example.com'} },
15
- { action: 'finance_news', params: {tickers: 'AAPL', limit: 3} },
16
- { action: 'scrape', params: {url: 'https://example.com'} },
17
- { action: 'image_crop', params: {url: 'https://via.placeholder.com/500'} },
18
- { action: 'skills', params: {q: 'javascript'} },
19
- { action: 'form_submit', params: {endpoint: 'test', data: 'test'} },
20
- { action: 'market_data', params: {symbols: 'AAPL'} }
21
- ];
22
-
23
- async function testAction(action, params) {
24
- return new Promise((resolve) => {
25
- const request = JSON.stringify({
26
- jsonrpc: '2.0',
27
- id: 1,
28
- method: 'tools/call',
29
- params: {
30
- name: 'call_api',
31
- arguments: {
32
- provider: 'apilayer',
33
- action,
34
- params
35
- }
36
- }
37
- });
38
-
39
- const proc = spawn('node', ['dist/index.js'], {
40
- cwd: path.join(__dirname),
41
- stdio: ['pipe', 'pipe', 'pipe']
42
- });
43
-
44
- let output = '';
45
- proc.stdout.on('data', (data) => output += data.toString());
46
- proc.stderr.on('data', (data) => output += data.toString());
47
-
48
- proc.on('close', () => {
49
- try {
50
- const match = output.match(/\{"result":\{.*\},"jsonrpc":"2\.0","id":1\}/);
51
- if (match) {
52
- const json = JSON.parse(match[0]);
53
- const text = json.result?.content?.[0]?.text;
54
- if (text) {
55
- const result = JSON.parse(text);
56
- resolve(result.status === 'success');
57
- } else {
58
- resolve(false);
59
- }
60
- } else {
61
- resolve(false);
62
- }
63
- } catch {
64
- resolve(false);
65
- }
66
- });
67
-
68
- proc.stdin.write(request + '\n');
69
- proc.stdin.end();
70
-
71
- // Timeout after 10s
72
- setTimeout(() => {
73
- proc.kill();
74
- resolve(false);
75
- }, 10000);
76
- });
77
- }
78
-
79
- async function runAll() {
80
- console.log('Testing all 14 APILayer actions...\n');
81
-
82
- const results = [];
83
-
84
- for (const test of tests) {
85
- const success = await testAction(test.action, test.params);
86
- results.push({ action: test.action, success });
87
- console.log(`${success ? '✅' : '❌'} ${test.action}`);
88
- }
89
-
90
- const working = results.filter(r => r.success);
91
- console.log(`\n📊 FINAL: ${working.length}/14 working`);
92
- console.log('\n✅ Working:');
93
- working.forEach(r => console.log(` • ${r.action}`));
94
- }
95
-
96
- runAll();
@@ -1,92 +0,0 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
- import { homedir } from 'os';
4
- import { executeAPICall } from './src/execute.js';
5
-
6
- interface TestResult {
7
- name: string;
8
- success: boolean;
9
- error?: string;
10
- }
11
-
12
- // Load credentials
13
- function loadEnv(): Record<string, string> {
14
- const envPath = path.join(homedir(), '.secrets', 'apilayer.env');
15
- const content = fs.readFileSync(envPath, 'utf-8');
16
- const vars: Record<string, string> = {};
17
- for (const line of content.split('\n')) {
18
- const match = line.match(/^([^=]+)=(.*)$/);
19
- if (match) {
20
- vars[match[1].trim()] = match[2].trim();
21
- }
22
- }
23
- return vars;
24
- }
25
-
26
- const env = loadEnv();
27
-
28
- const tests: Array<{ name: string; action: string; params: Record<string, unknown> }> = [
29
- { name: 'ExchangeRate API', action: 'exchange_rates', params: {} },
30
- { name: 'AviationStack API', action: 'aviation', params: {} },
31
- { name: 'ScreenshotLayer API', action: 'screenshot', params: { url: 'https://example.com' } },
32
- { name: 'Number Verification API', action: 'verify_number', params: { number: '+46701234567' } },
33
- { name: 'Email Verification API', action: 'verify_email', params: { email: 'test@example.com' } },
34
- { name: 'Marketstack API', action: 'market_data', params: { symbols: 'AAPL' } },
35
- { name: 'VAT Layer API', action: 'vat_check', params: { vat_number: 'SE556012345601' } },
36
- { name: 'Finance News API', action: 'finance_news', params: { tickers: 'AAPL' } },
37
- { name: 'Image Crop API', action: 'image_crop', params: { url: 'https://example.com/image.jpg' } },
38
- { name: 'Advanced Scraper API', action: 'scrape', params: { url: 'https://example.com' } },
39
- { name: 'PDF Generate API', action: 'pdf_generate', params: { document_url: 'https://example.com' } },
40
- { name: 'World News API', action: 'world_news', params: { url: 'https://example.com' } },
41
- { name: 'Skills API', action: 'skills', params: { q: 'machine learning' } },
42
- { name: 'Form API', action: 'form_submit', params: { endpoint: 'test' } },
43
- ];
44
-
45
- async function runTests() {
46
- console.log('🧪 Testing all 14 APILayer handlers via executeAPICall()\n');
47
-
48
- const results: TestResult[] = [];
49
- let working = 0;
50
-
51
- for (const test of tests) {
52
- try {
53
- const result = await executeAPICall('apilayer', test.action, test.params);
54
- const success = result.success === true;
55
-
56
- if (success) {
57
- working++;
58
- console.log(`✅ ${test.name}`);
59
- } else {
60
- console.log(`❌ ${test.name}: ${result.error || 'unknown error'}`);
61
- }
62
-
63
- results.push({
64
- name: test.name,
65
- success,
66
- error: result.error,
67
- });
68
- } catch (err) {
69
- const errorMsg = err instanceof Error ? err.message : String(err);
70
- console.log(`❌ ${test.name}: ${errorMsg}`);
71
- results.push({
72
- name: test.name,
73
- success: false,
74
- error: errorMsg,
75
- });
76
- }
77
- }
78
-
79
- console.log('\n' + '='.repeat(60));
80
- console.log('📊 FINAL RESULTS');
81
- console.log('='.repeat(60));
82
- console.log(`\n✅ WORKING: ${working}/14`);
83
- console.log(`❌ NOT WORKING: ${14 - working}/14\n`);
84
-
85
- const failed = results.filter(r => !r.success);
86
- if (failed.length > 0) {
87
- console.log('Failed services:');
88
- failed.forEach(r => console.log(` • ${r.name}: ${r.error}`));
89
- }
90
- }
91
-
92
- runTests().catch(console.error);