@nordsym/apiclaw 2.1.0 โ†’ 2.2.1

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 (185) 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/funnel-client.d.ts +24 -0
  5. package/dist/funnel-client.d.ts.map +1 -0
  6. package/dist/funnel-client.js +131 -0
  7. package/dist/funnel-client.js.map +1 -0
  8. package/dist/funnel.test.d.ts +2 -0
  9. package/dist/funnel.test.d.ts.map +1 -0
  10. package/dist/funnel.test.js +145 -0
  11. package/dist/funnel.test.js.map +1 -0
  12. package/dist/gateway-client.d.ts.map +1 -1
  13. package/dist/gateway-client.js +24 -2
  14. package/dist/gateway-client.js.map +1 -1
  15. package/dist/index.bundled.js +61263 -0
  16. package/dist/index.js +161 -74
  17. package/dist/index.js.map +1 -1
  18. package/dist/postinstall.d.ts +0 -5
  19. package/dist/postinstall.d.ts.map +1 -1
  20. package/dist/postinstall.js +24 -3
  21. package/dist/postinstall.js.map +1 -1
  22. package/dist/registration-guard.d.ts +29 -0
  23. package/dist/registration-guard.d.ts.map +1 -0
  24. package/dist/registration-guard.js +87 -0
  25. package/dist/registration-guard.js.map +1 -0
  26. package/package.json +7 -2
  27. package/.claude/settings.local.json +0 -9
  28. package/.env.prod +0 -1
  29. package/apiclaw-README.md +0 -494
  30. package/convex/_generated/api.d.ts +0 -137
  31. package/convex/_generated/api.js +0 -23
  32. package/convex/_generated/dataModel.d.ts +0 -60
  33. package/convex/_generated/server.d.ts +0 -143
  34. package/convex/_generated/server.js +0 -93
  35. package/convex/adminActivate.ts +0 -53
  36. package/convex/adminStats.ts +0 -306
  37. package/convex/agents.ts +0 -939
  38. package/convex/analytics.ts +0 -187
  39. package/convex/apiKeys.ts +0 -220
  40. package/convex/backfillAnalytics.ts +0 -272
  41. package/convex/backfillSearchLogs.ts +0 -35
  42. package/convex/billing.ts +0 -834
  43. package/convex/capabilities.ts +0 -157
  44. package/convex/chains.ts +0 -1318
  45. package/convex/credits.ts +0 -211
  46. package/convex/crons.ts +0 -50
  47. package/convex/debugFilestackLogs.ts +0 -16
  48. package/convex/debugGetToken.ts +0 -18
  49. package/convex/directCall.ts +0 -713
  50. package/convex/earnProgress.ts +0 -753
  51. package/convex/email.ts +0 -329
  52. package/convex/feedback.ts +0 -265
  53. package/convex/http.ts +0 -3430
  54. package/convex/inbound.ts +0 -32
  55. package/convex/logs.ts +0 -701
  56. package/convex/migrateFilestack.ts +0 -81
  57. package/convex/migratePartnersProd.ts +0 -174
  58. package/convex/migratePratham.ts +0 -126
  59. package/convex/migrateProviderWorkspaces.ts +0 -175
  60. package/convex/mou.ts +0 -91
  61. package/convex/providerKeys.ts +0 -289
  62. package/convex/providers.ts +0 -1135
  63. package/convex/purchases.ts +0 -183
  64. package/convex/ratelimit.ts +0 -104
  65. package/convex/schema.ts +0 -869
  66. package/convex/searchLogs.ts +0 -265
  67. package/convex/seedAPILayerAPIs.ts +0 -191
  68. package/convex/seedDirectCallConfigs.ts +0 -336
  69. package/convex/seedPratham.ts +0 -149
  70. package/convex/spendAlerts.ts +0 -442
  71. package/convex/stripeActions.ts +0 -607
  72. package/convex/teams.ts +0 -243
  73. package/convex/telemetry.ts +0 -81
  74. package/convex/tsconfig.json +0 -25
  75. package/convex/updateAPIStatus.ts +0 -44
  76. package/convex/usage.ts +0 -260
  77. package/convex/usageReports.ts +0 -357
  78. package/convex/waitlist.ts +0 -55
  79. package/convex/webhooks.ts +0 -494
  80. package/convex/workspaceSettings.ts +0 -143
  81. package/convex/workspaces.ts +0 -1331
  82. package/convex.json +0 -3
  83. package/direct-test.mjs +0 -51
  84. package/email-templates/filestack-provider-outreach.html +0 -162
  85. package/email-templates/partnership-template.html +0 -116
  86. package/email-templates/pratham-draft-preview.txt +0 -57
  87. package/email-templates/pratham-partnership-draft.html +0 -141
  88. package/reports/APIClaw-Session-Report-2026-04-05.pdf +0 -0
  89. package/reports/pipeline/PIPELINE-REPORT.json +0 -153
  90. package/reports/pipeline/acquire_apisguru.json +0 -17
  91. package/reports/pipeline/capabilities.json +0 -38
  92. package/reports/pipeline/discover_azure_recursive.json +0 -1551
  93. package/reports/pipeline/discover_github.json +0 -25
  94. package/reports/pipeline/discover_github_repos.json +0 -49
  95. package/reports/pipeline/discover_swaggerhub.json +0 -24
  96. package/reports/pipeline/discover_well_known.json +0 -23
  97. package/reports/pipeline/fetch_specs.json +0 -19
  98. package/reports/pipeline/generate_providers.json +0 -14
  99. package/reports/pipeline/match_registry.json +0 -11
  100. package/reports/pipeline/parse_specs.json +0 -17
  101. package/reports/pipeline/promote_candidates.json +0 -34
  102. package/reports/pipeline/validate.json +0 -30
  103. package/reports/pipeline/validate_smoke_details.json +0 -3835
  104. package/reports/session-report-2026-04-05.html +0 -433
  105. package/seed-apis-direct.mjs +0 -106
  106. package/src/access-control.ts +0 -174
  107. package/src/adapters/base.ts +0 -364
  108. package/src/adapters/claude-desktop.ts +0 -41
  109. package/src/adapters/cline.ts +0 -88
  110. package/src/adapters/continue.ts +0 -91
  111. package/src/adapters/cursor.ts +0 -43
  112. package/src/adapters/custom.ts +0 -188
  113. package/src/adapters/detect.ts +0 -202
  114. package/src/adapters/index.ts +0 -47
  115. package/src/adapters/windsurf.ts +0 -44
  116. package/src/bin-http.ts +0 -45
  117. package/src/bin.ts +0 -34
  118. package/src/capability-router.ts +0 -331
  119. package/src/chainExecutor.ts +0 -730
  120. package/src/chainResolver.test.ts +0 -246
  121. package/src/chainResolver.ts +0 -658
  122. package/src/cli/commands/demo.ts +0 -109
  123. package/src/cli/commands/doctor.ts +0 -435
  124. package/src/cli/commands/index.ts +0 -9
  125. package/src/cli/commands/login.ts +0 -203
  126. package/src/cli/commands/mcp-install.ts +0 -373
  127. package/src/cli/commands/restore.ts +0 -333
  128. package/src/cli/commands/setup.ts +0 -297
  129. package/src/cli/commands/uninstall.ts +0 -240
  130. package/src/cli/index.ts +0 -148
  131. package/src/cli.ts +0 -370
  132. package/src/confirmation.ts +0 -296
  133. package/src/credentials.ts +0 -455
  134. package/src/credits.ts +0 -329
  135. package/src/crypto.ts +0 -75
  136. package/src/discovery.ts +0 -568
  137. package/src/enterprise/env.ts +0 -156
  138. package/src/enterprise/index.ts +0 -7
  139. package/src/enterprise/script-generator.ts +0 -481
  140. package/src/execute-dynamic.ts +0 -617
  141. package/src/execute.ts +0 -2386
  142. package/src/gateway-client.ts +0 -192
  143. package/src/hivr-whitelist.ts +0 -110
  144. package/src/http-api.ts +0 -286
  145. package/src/http-server-minimal.ts +0 -154
  146. package/src/index.ts +0 -2611
  147. package/src/intelligent-gateway.ts +0 -339
  148. package/src/mcp-analytics.ts +0 -156
  149. package/src/metered.ts +0 -149
  150. package/src/open-apis-generated.ts +0 -157
  151. package/src/open-apis.ts +0 -558
  152. package/src/postinstall.ts +0 -18
  153. package/src/product-whitelist.ts +0 -246
  154. package/src/proxy.ts +0 -36
  155. package/src/session.ts +0 -129
  156. package/src/stripe.ts +0 -497
  157. package/src/telemetry.ts +0 -71
  158. package/src/test.ts +0 -135
  159. package/src/types/convex-api.d.ts +0 -20
  160. package/src/types/convex-api.ts +0 -21
  161. package/src/types.ts +0 -109
  162. package/src/ui/colors.ts +0 -219
  163. package/src/ui/errors.ts +0 -394
  164. package/src/ui/index.ts +0 -17
  165. package/src/ui/prompts.ts +0 -390
  166. package/src/ui/spinner.ts +0 -325
  167. package/src/utils/backup.ts +0 -224
  168. package/src/utils/config.ts +0 -318
  169. package/src/utils/os.ts +0 -124
  170. package/src/utils/paths.ts +0 -203
  171. package/src/webhook.ts +0 -107
  172. package/test-10-working.cjs +0 -97
  173. package/test-14-final.cjs +0 -96
  174. package/test-actual-handlers.ts +0 -92
  175. package/test-apilayer-all-14.ts +0 -249
  176. package/test-apilayer-fixed.ts +0 -248
  177. package/test-direct-endpoints.ts +0 -174
  178. package/test-exact-endpoints.ts +0 -144
  179. package/test-final.ts +0 -83
  180. package/test-full-routing.ts +0 -100
  181. package/test-handlers-correct.ts +0 -217
  182. package/test-numverify-key.ts +0 -41
  183. package/test-via-handlers.ts +0 -92
  184. package/test-worldnews.mjs +0 -26
  185. package/tsconfig.json +0 -20
@@ -1,249 +0,0 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
- import { homedir } from 'os';
4
-
5
- interface TestResult {
6
- name: string;
7
- endpoint: string;
8
- status: number | string;
9
- success: boolean;
10
- error?: string;
11
- responseTime: number;
12
- }
13
-
14
- const results: TestResult[] = [];
15
-
16
- // Load credentials
17
- function loadEnvFile(): Record<string, string> {
18
- const envPath = path.join(homedir(), '.secrets', 'apilayer.env');
19
- if (!fs.existsSync(envPath)) {
20
- console.error(`โŒ No credentials file at ${envPath}`);
21
- process.exit(1);
22
- }
23
-
24
- const content = fs.readFileSync(envPath, 'utf-8');
25
- const vars: Record<string, string> = {};
26
- for (const line of content.split('\n')) {
27
- const match = line.match(/^([^=]+)=(.*)$/);
28
- if (match) {
29
- vars[match[1].trim()] = match[2].trim().replace(/^['""]|["'"]$/g, '');
30
- }
31
- }
32
- return vars;
33
- }
34
-
35
- const env = loadEnvFile();
36
-
37
- // Test configurations - ALL 14 APIs
38
- const tests = [
39
- {
40
- name: 'ExchangeRate API',
41
- url: (key: string) => `https://api.apilayer.com/exchangerate?apikey=${key}`,
42
- key: env.APILAYER_EXCHANGERATE_KEY,
43
- method: 'GET',
44
- authType: 'query'
45
- },
46
- {
47
- name: 'AviationStack API',
48
- url: (key: string) => `https://api.apilayer.com/aviationstack?access_key=${key}`,
49
- key: env.APILAYER_AVIATIONSTACK_KEY,
50
- method: 'GET',
51
- authType: 'query'
52
- },
53
- {
54
- name: 'PDF Layer API',
55
- url: (key: string) => `https://api.apilayer.com/pdf?url=https://example.com`,
56
- key: env.APILAYER_PDFLAYER_KEY,
57
- method: 'GET',
58
- authType: 'header'
59
- },
60
- {
61
- name: 'Screenshot Layer API',
62
- url: (key: string) => `https://api.apilayer.com/screenshot?url=https://example.com&access_key=${key}`,
63
- key: env.APILAYER_SCREENSHOTLAYER_KEY,
64
- method: 'GET',
65
- authType: 'query'
66
- },
67
- {
68
- name: 'SkillAPI',
69
- url: (key: string) => `https://api.promptapi.com/skills?q=test`,
70
- key: env.APILAYER_SKILLAPI_KEY,
71
- method: 'GET',
72
- authType: 'header',
73
- domain: 'promptapi.com'
74
- },
75
- {
76
- name: 'Image Crop API',
77
- url: (key: string) => `https://api.apilayer.com/crop?url=https://example.com/image.jpg`,
78
- key: env.APILAYER_IMAGECROP_KEY,
79
- method: 'GET',
80
- authType: 'header'
81
- },
82
- {
83
- name: 'Form API',
84
- url: (key: string) => `https://api.apilayer.com/form`,
85
- key: env.APILAYER_FORMAPI_KEY,
86
- method: 'POST',
87
- authType: 'header',
88
- body: 'Test Form'
89
- },
90
- {
91
- name: 'Number Verification API',
92
- url: (key: string) => `https://api.apilayer.com/validate?number=1234567890&access_key=${key}`,
93
- key: env.APILAYER_NUMVERIFY_KEY,
94
- method: 'GET',
95
- authType: 'query'
96
- },
97
- {
98
- name: 'Email Verification API',
99
- url: (key: string) => `https://api.apilayer.com/check?email=test@example.com&access_key=${key}`,
100
- key: env.APILAYER_EMAILVERIFY_KEY,
101
- method: 'GET',
102
- authType: 'query'
103
- },
104
- {
105
- name: 'Marketstack API',
106
- url: (key: string) => `https://api.apilayer.com/eod?symbols=AAPL&access_key=${key}`,
107
- key: env.APILAYER_MARKETSTACK_KEY,
108
- method: 'GET',
109
- authType: 'query'
110
- },
111
- {
112
- name: 'World News API',
113
- url: (key: string) => `https://api.apilayer.com/worldnews?keywords=test`,
114
- key: env.APILAYER_WORLDNEWS_KEY,
115
- method: 'GET',
116
- authType: 'header'
117
- },
118
- {
119
- name: 'Advanced Scraper API',
120
- url: (key: string) => `https://api.apilayer.com/scraper?url=https://example.com`,
121
- key: env.APILAYER_SCRAPER_KEY,
122
- method: 'GET',
123
- authType: 'header'
124
- },
125
- {
126
- name: 'Finance News API',
127
- url: (key: string) => `https://api.apilayer.com/news?limit=5`,
128
- key: env.APILAYER_FINANCENEWS_KEY,
129
- method: 'GET',
130
- authType: 'header'
131
- },
132
- {
133
- name: 'VAT Layer API',
134
- url: (key: string) => `https://api.apilayer.com/validate?country_code=SE&access_key=${key}`,
135
- key: env.APILAYER_VATLAYER_KEY,
136
- method: 'GET',
137
- authType: 'query'
138
- }
139
- ];
140
-
141
- async function runTests() {
142
- console.log('๐Ÿงช Testing all 14 APILayer services...\n');
143
-
144
- for (const test of tests) {
145
- if (!test.key) {
146
- results.push({
147
- name: test.name,
148
- endpoint: 'N/A',
149
- status: 'NO KEY',
150
- success: false,
151
- responseTime: 0
152
- });
153
- console.log(`โŒ ${test.name}: NO API KEY FOUND`);
154
- continue;
155
- }
156
-
157
- try {
158
- const startTime = Date.now();
159
- const url = test.url(test.key);
160
-
161
- const headers: Record<string, string> = {
162
- 'Content-Type': 'application/json'
163
- };
164
-
165
- // Add API key as header if needed
166
- if (test.authType === 'header') {
167
- headers['apikey'] = test.key;
168
- }
169
-
170
- const options: RequestInit = {
171
- method: test.method,
172
- headers
173
- };
174
-
175
- if (test.body) {
176
- options.body = test.body;
177
- }
178
-
179
- const response = await fetch(url, options);
180
- const responseTime = Date.now() - startTime;
181
-
182
- let success = false;
183
- let error: string | undefined;
184
-
185
- if (response.ok) {
186
- success = true;
187
- console.log(`โœ… ${test.name}: ${response.status} (${responseTime}ms)`);
188
- } else {
189
- let errorMsg = `HTTP ${response.status}`;
190
- try {
191
- const body = await response.json();
192
- if (body.message) {
193
- errorMsg += ` - ${body.message}`;
194
- }
195
- } catch {
196
- // body not JSON
197
- }
198
- error = errorMsg;
199
- console.log(`โŒ ${test.name}: ${errorMsg} (${responseTime}ms)`);
200
- }
201
-
202
- results.push({
203
- name: test.name,
204
- endpoint: url.split('?')[0],
205
- status: response.status,
206
- success,
207
- error,
208
- responseTime
209
- });
210
-
211
- } catch (err) {
212
- const errorMsg = err instanceof Error ? err.message : String(err);
213
- console.log(`โŒ ${test.name}: ${errorMsg}`);
214
-
215
- results.push({
216
- name: test.name,
217
- endpoint: 'N/A',
218
- status: 'ERROR',
219
- success: false,
220
- error: errorMsg,
221
- responseTime: 0
222
- });
223
- }
224
- }
225
-
226
- // Summary
227
- console.log('\n' + '='.repeat(60));
228
- console.log('๐Ÿ“Š SUMMARY');
229
- console.log('='.repeat(60));
230
-
231
- const working = results.filter(r => r.success);
232
- const failed = results.filter(r => !r.success);
233
-
234
- console.log(`\nโœ… Working (${working.length}):`);
235
- working.forEach(r => {
236
- console.log(` โ€ข ${r.name}`);
237
- });
238
-
239
- if (failed.length > 0) {
240
- console.log(`\nโŒ Failed (${failed.length}):`);
241
- failed.forEach(r => {
242
- console.log(` โ€ข ${r.name}: ${r.error}`);
243
- });
244
- }
245
-
246
- console.log(`\n๐Ÿ“ˆ Success rate: ${working.length}/${results.length} (${Math.round(working.length / results.length * 100)}%)`);
247
- }
248
-
249
- runTests().catch(console.error);
@@ -1,248 +0,0 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
- import { homedir } from 'os';
4
-
5
- interface TestResult {
6
- name: string;
7
- endpoint: string;
8
- status: number | string;
9
- success: boolean;
10
- error?: string;
11
- responseTime: number;
12
- }
13
-
14
- const results: TestResult[] = [];
15
-
16
- // Load credentials
17
- function loadEnvFile(): Record<string, string> {
18
- const envPath = path.join(homedir(), '.secrets', 'apilayer.env');
19
- if (!fs.existsSync(envPath)) {
20
- console.error(`โŒ No credentials file at ${envPath}`);
21
- process.exit(1);
22
- }
23
-
24
- const content = fs.readFileSync(envPath, 'utf-8');
25
- const vars: Record<string, string> = {};
26
- for (const line of content.split('\n')) {
27
- const match = line.match(/^([^=]+)=(.*)$/);
28
- if (match) {
29
- vars[match[1].trim()] = match[2].trim().replace(/^['""]|["'"]$/g, '');
30
- }
31
- }
32
- return vars;
33
- }
34
-
35
- const env = loadEnvFile();
36
-
37
- // ALL 14 APIs with CORRECTED endpoints from user documentation
38
- const tests = [
39
- // โœ… 7 KNOWN WORKING (from previous tests)
40
- {
41
- name: 'ExchangeRate API',
42
- url: (key: string) => `https://api.apilayer.com/exchangerate?apikey=${key}`,
43
- key: env.APILAYER_EXCHANGERATE_KEY,
44
- method: 'GET'
45
- },
46
- {
47
- name: 'AviationStack API',
48
- url: (key: string) => `https://api.apilayer.com/aviationstack?access_key=${key}`,
49
- key: env.APILAYER_AVIATIONSTACK_KEY,
50
- method: 'GET'
51
- },
52
- {
53
- name: 'ScreenshotLayer API',
54
- url: (key: string) => `https://api.apilayer.com/screenshot?url=https://example.com&access_key=${key}`,
55
- key: env.APILAYER_SCREENSHOTLAYER_KEY,
56
- method: 'GET'
57
- },
58
- {
59
- name: 'Number Verification API',
60
- url: (key: string) => `https://api.apilayer.com/validate?number=1234567890&access_key=${key}`,
61
- key: env.APILAYER_NUMVERIFY_KEY,
62
- method: 'GET'
63
- },
64
- {
65
- name: 'Email Verification API',
66
- url: (key: string) => `https://api.apilayer.com/check?email=test@example.com&access_key=${key}`,
67
- key: env.APILAYER_EMAILVERIFY_KEY,
68
- method: 'GET'
69
- },
70
- {
71
- name: 'Marketstack API',
72
- url: (key: string) => `https://api.apilayer.com/eod?symbols=AAPL&access_key=${key}`,
73
- key: env.APILAYER_MARKETSTACK_KEY,
74
- method: 'GET'
75
- },
76
- {
77
- name: 'VAT Layer API',
78
- url: (key: string) => `https://api.apilayer.com/validate?country_code=SE&access_key=${key}`,
79
- key: env.APILAYER_VATLAYER_KEY,
80
- method: 'GET'
81
- },
82
-
83
- // ๐Ÿ”ง 4 PREVIOUSLY FAILED - NOW WITH CORRECTED ENDPOINTS from user documentation
84
- {
85
- name: 'Image Crop API',
86
- url: (key: string) => `https://api.apilayer.com/crop?url=https://example.com/image.jpg`,
87
- key: env.APILAYER_IMAGECROP_KEY,
88
- method: 'GET',
89
- authType: 'header'
90
- },
91
- {
92
- name: 'Form API',
93
- url: (key: string) => `https://api.apilayer.com/form`,
94
- key: env.APILAYER_FORMAPI_KEY,
95
- method: 'POST',
96
- authType: 'header',
97
- body: 'Test Form'
98
- },
99
- {
100
- name: 'Advanced Scraper API',
101
- url: (key: string) => `https://api.apilayer.com/scraper?url=https://example.com`,
102
- key: env.APILAYER_SCRAPER_KEY,
103
- method: 'GET',
104
- authType: 'header'
105
- },
106
- {
107
- name: 'Finance News API',
108
- url: (key: string) => `https://api.apilayer.com/news?limit=5`,
109
- key: env.APILAYER_FINANCENEWS_KEY,
110
- method: 'GET',
111
- authType: 'header'
112
- },
113
-
114
- // โŒ 3 AUTH FAILURES (investigating)
115
- {
116
- name: 'PDF Layer API',
117
- url: (key: string) => `https://api.apilayer.com/pdf?url=https://example.com`,
118
- key: env.APILAYER_PDFLAYER_KEY,
119
- method: 'GET',
120
- authType: 'header'
121
- },
122
- {
123
- name: 'SkillAPI',
124
- url: (key: string) => `https://api.promptapi.com/skills?q=test`,
125
- key: env.APILAYER_SKILLAPI_KEY,
126
- method: 'GET',
127
- authType: 'header'
128
- },
129
- {
130
- name: 'World News API',
131
- url: (key: string) => `https://api.apilayer.com/worldnews?keywords=test`,
132
- key: env.APILAYER_WORLDNEWS_KEY,
133
- method: 'GET',
134
- authType: 'header'
135
- }
136
- ];
137
-
138
- async function runTests() {
139
- console.log('๐Ÿงช Testing all 14 APILayer services (WITH CORRECTED ENDPOINTS)\n');
140
-
141
- for (const test of tests) {
142
- if (!test.key) {
143
- results.push({
144
- name: test.name,
145
- endpoint: 'N/A',
146
- status: 'NO KEY',
147
- success: false,
148
- responseTime: 0
149
- });
150
- console.log(`โŒ ${test.name}: NO API KEY FOUND`);
151
- continue;
152
- }
153
-
154
- try {
155
- const startTime = Date.now();
156
- const url = test.url(test.key);
157
-
158
- const headers: Record<string, string> = {
159
- 'Content-Type': 'application/json'
160
- };
161
-
162
- // Add API key as header if needed
163
- const authType = (test as any).authType || 'query';
164
- if (authType === 'header') {
165
- headers['apikey'] = test.key;
166
- }
167
-
168
- const options: RequestInit = {
169
- method: test.method,
170
- headers
171
- };
172
-
173
- if ((test as any).body) {
174
- options.body = (test as any).body;
175
- }
176
-
177
- const response = await fetch(url, options);
178
- const responseTime = Date.now() - startTime;
179
-
180
- let success = false;
181
- let error: string | undefined;
182
-
183
- if (response.ok) {
184
- success = true;
185
- console.log(`โœ… ${test.name}: ${response.status} (${responseTime}ms)`);
186
- } else {
187
- let errorMsg = `HTTP ${response.status}`;
188
- try {
189
- const body = await response.json();
190
- if (body.message) {
191
- errorMsg += ` - ${body.message}`;
192
- }
193
- } catch {
194
- // body not JSON
195
- }
196
- error = errorMsg;
197
- console.log(`โŒ ${test.name}: ${errorMsg} (${responseTime}ms)`);
198
- }
199
-
200
- results.push({
201
- name: test.name,
202
- endpoint: url.split('?')[0],
203
- status: response.status,
204
- success,
205
- error,
206
- responseTime
207
- });
208
-
209
- } catch (err) {
210
- const errorMsg = err instanceof Error ? err.message : String(err);
211
- console.log(`โŒ ${test.name}: ${errorMsg}`);
212
-
213
- results.push({
214
- name: test.name,
215
- endpoint: 'N/A',
216
- status: 'ERROR',
217
- success: false,
218
- error: errorMsg,
219
- responseTime: 0
220
- });
221
- }
222
- }
223
-
224
- // Summary
225
- console.log('\n' + '='.repeat(60));
226
- console.log('๐Ÿ“Š FINAL STATUS');
227
- console.log('='.repeat(60));
228
-
229
- const working = results.filter(r => r.success);
230
- const failed = results.filter(r => !r.success);
231
-
232
- console.log(`\nโœ… WORKING (${working.length}/14):`);
233
- working.forEach(r => {
234
- console.log(` โ€ข ${r.name}`);
235
- });
236
-
237
- if (failed.length > 0) {
238
- console.log(`\nโŒ NOT WORKING (${failed.length}/14):`);
239
- failed.forEach(r => {
240
- console.log(` โ€ข ${r.name}: ${r.error}`);
241
- });
242
- }
243
-
244
- console.log(`\n๐Ÿ“ˆ Success rate: ${working.length}/14 (${Math.round(working.length / results.length * 100)}%)`);
245
- console.log('\n๐Ÿ’พ Ready for Pratham meeting: ' + (working.length >= 10 ? 'โœ… YES' : 'โŒ NO'));
246
- }
247
-
248
- runTests().catch(console.error);
@@ -1,174 +0,0 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
- import { homedir } from 'os';
4
-
5
- interface TestResult {
6
- name: string;
7
- endpoint: string;
8
- method: string;
9
- status: number | string;
10
- success: boolean;
11
- responseTime: number;
12
- }
13
-
14
- // Load credentials
15
- function loadEnv(): Record<string, string> {
16
- const envPath = path.join(homedir(), '.secrets', 'apilayer.env');
17
- const content = fs.readFileSync(envPath, 'utf-8');
18
- const vars: Record<string, string> = {};
19
- for (const line of content.split('\n')) {
20
- const match = line.match(/^([^=]+)=(.*)$/);
21
- if (match) {
22
- vars[match[1].trim()] = match[2].trim();
23
- }
24
- }
25
- return vars;
26
- }
27
-
28
- const env = loadEnv();
29
-
30
- const tests = [
31
- {
32
- name: 'ExchangeRate API',
33
- url: `https://api.apilayer.com/exchangerates_data?apikey=${env.APILAYER_EXCHANGERATE_KEY}`,
34
- method: 'GET',
35
- },
36
- {
37
- name: 'AviationStack API',
38
- url: `https://api.apilayer.com/aviationstack?access_key=${env.APILAYER_AVIATIONSTACK_KEY}`,
39
- method: 'GET',
40
- },
41
- {
42
- name: 'ScreenshotLayer API',
43
- url: `https://api.screenshotlayer.com/api?url=https://example.com&access_key=${env.APILAYER_SCREENSHOTLAYER_KEY}`,
44
- method: 'GET',
45
- },
46
- {
47
- name: 'Number Verification API',
48
- url: `https://api.apilayer.com/validate?number=1234567890&access_key=${env.APILAYER_NUMVERIFY_KEY}`,
49
- method: 'GET',
50
- },
51
- {
52
- name: 'Email Verification API',
53
- url: `https://api.apilayer.com/check?email=test@example.com&access_key=${env.APILAYER_EMAILVERIFY_KEY}`,
54
- method: 'GET',
55
- },
56
- {
57
- name: 'Marketstack API',
58
- url: `https://api.marketstack.com/v1/eod?symbols=AAPL&access_key=${env.APILAYER_MARKETSTACK_KEY}`,
59
- method: 'GET',
60
- },
61
- {
62
- name: 'VAT Layer API',
63
- url: `https://apilayer.net/api/validate?country_code=SE&access_key=${env.APILAYER_VATLAYER_KEY}`,
64
- method: 'GET',
65
- },
66
- {
67
- name: 'Finance News API',
68
- url: `https://api.apilayer.com/financelayer/news?apikey=${env.APILAYER_FINANCENEWS_KEY}`,
69
- method: 'GET',
70
- },
71
- {
72
- name: 'Image Crop API',
73
- url: `https://api.apilayer.com/smart_crop/url?apikey=${env.APILAYER_IMAGECROP_KEY}`,
74
- method: 'GET',
75
- },
76
- {
77
- name: 'Advanced Scraper API',
78
- url: `https://api.apilayer.com/adv_scraper/scraper?url=https://example.com&apikey=${env.APILAYER_SCRAPER_KEY}`,
79
- method: 'GET',
80
- },
81
- {
82
- name: 'PDF Layer API',
83
- url: `https://api.pdflayer.com/api`,
84
- method: 'POST',
85
- headers: { 'apikey': env.APILAYER_PDFLAYER_KEY },
86
- body: JSON.stringify({ document_url: 'https://example.com' }),
87
- },
88
- {
89
- name: 'World News API',
90
- url: `https://api.apilayer.com/world_news/extract-news?url=https://example.com&apikey=${env.APILAYER_WORLDNEWS_KEY}`,
91
- method: 'GET',
92
- },
93
- {
94
- name: 'Skills API',
95
- url: `https://api.apilayer.com/skills?q=machine%20learning&apikey=${env.APILAYER_SKILLAPI_KEY}`,
96
- method: 'GET',
97
- },
98
- {
99
- name: 'Form API',
100
- url: `https://api.apilayer.com/form_api/test`,
101
- method: 'POST',
102
- headers: { 'apikey': env.APILAYER_FORMAPI_KEY },
103
- body: JSON.stringify({}),
104
- },
105
- ];
106
-
107
- async function runTests() {
108
- console.log('๐Ÿงช Testing all 14 APILayer endpoints\n');
109
-
110
- const results: TestResult[] = [];
111
- let working = 0;
112
-
113
- for (const test of tests) {
114
- try {
115
- const startTime = Date.now();
116
- const options: RequestInit = {
117
- method: test.method,
118
- headers: {
119
- 'Content-Type': 'application/json',
120
- ...(test.headers || {}),
121
- },
122
- };
123
-
124
- if ((test as any).body) {
125
- options.body = (test as any).body;
126
- }
127
-
128
- const response = await fetch((test as any).url, options);
129
- const responseTime = Date.now() - startTime;
130
-
131
- const success = response.ok;
132
- if (success) {
133
- working++;
134
- console.log(`โœ… ${test.name}: ${response.status} (${responseTime}ms)`);
135
- } else {
136
- console.log(`โŒ ${test.name}: ${response.status} (${responseTime}ms)`);
137
- }
138
-
139
- results.push({
140
- name: test.name,
141
- endpoint: (test as any).url.split('?')[0],
142
- method: test.method,
143
- status: response.status,
144
- success,
145
- responseTime,
146
- });
147
- } catch (err) {
148
- const errorMsg = err instanceof Error ? err.message : String(err);
149
- console.log(`โŒ ${test.name}: ${errorMsg}`);
150
- results.push({
151
- name: test.name,
152
- endpoint: 'ERROR',
153
- method: test.method,
154
- status: 'ERROR',
155
- success: false,
156
- responseTime: 0,
157
- });
158
- }
159
- }
160
-
161
- console.log('\n' + '='.repeat(60));
162
- console.log('๐Ÿ“Š FINAL RESULTS');
163
- console.log('='.repeat(60));
164
- console.log(`\nโœ… WORKING: ${working}/14`);
165
- console.log(`โŒ NOT WORKING: ${14 - working}/14\n`);
166
-
167
- const failed = results.filter(r => !r.success);
168
- if (failed.length > 0) {
169
- console.log('Failed services:');
170
- failed.forEach(r => console.log(` โ€ข ${r.name}: ${r.status}`));
171
- }
172
- }
173
-
174
- runTests().catch(console.error);