@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,144 +0,0 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
- import { homedir } from 'os';
4
-
5
- function loadEnv(): Record<string, string> {
6
- const envPath = path.join(homedir(), '.secrets', 'apilayer.env');
7
- const content = fs.readFileSync(envPath, 'utf-8');
8
- const vars: Record<string, string> = {};
9
- for (const line of content.split('\n')) {
10
- const match = line.match(/^([^=]+)=(.*)$/);
11
- if (match) {
12
- vars[match[1].trim()] = match[2].trim().replace(/^['\"]|[\"']$/g, '');
13
- }
14
- }
15
- return vars;
16
- }
17
-
18
- const env = loadEnv();
19
-
20
- const tests = [
21
- {
22
- name: 'ExchangeRate API',
23
- url: (key: string) => `https://api.apilayer.com/exchangerate?apikey=${key}`,
24
- key: env.APILAYER_EXCHANGERATE_KEY,
25
- method: 'GET'
26
- },
27
- {
28
- name: 'AviationStack API',
29
- url: (key: string) => `https://api.apilayer.com/aviationstack?access_key=${key}`,
30
- key: env.APILAYER_AVIATIONSTACK_KEY,
31
- method: 'GET'
32
- },
33
- {
34
- name: 'ScreenshotLayer API',
35
- url: (key: string) => `https://api.apilayer.com/screenshot?url=https://example.com&access_key=${key}`,
36
- key: env.APILAYER_SCREENSHOTLAYER_KEY,
37
- method: 'GET'
38
- },
39
- {
40
- name: 'Number Verification API',
41
- url: (key: string) => `https://api.apilayer.com/validate?number=1234567890&access_key=${key}`,
42
- key: env.APILAYER_NUMVERIFY_KEY,
43
- method: 'GET'
44
- },
45
- {
46
- name: 'Email Verification API',
47
- url: (key: string) => `https://api.apilayer.com/check?email=test@example.com&access_key=${key}`,
48
- key: env.APILAYER_EMAILVERIFY_KEY,
49
- method: 'GET'
50
- },
51
- {
52
- name: 'Marketstack API',
53
- url: (key: string) => `https://api.apilayer.com/eod?symbols=AAPL&access_key=${key}`,
54
- key: env.APILAYER_MARKETSTACK_KEY,
55
- method: 'GET'
56
- },
57
- {
58
- name: 'VAT Layer API',
59
- url: (key: string) => `https://api.apilayer.com/validate?country_code=SE&access_key=${key}`,
60
- key: env.APILAYER_VATLAYER_KEY,
61
- method: 'GET'
62
- },
63
- {
64
- name: 'Finance News API',
65
- url: (key: string) => `https://api.apilayer.com/financelayer/news?limit=5&apikey=${key}`,
66
- key: env.APILAYER_FINANCENEWS_KEY,
67
- method: 'GET'
68
- },
69
- {
70
- name: 'Image Crop API',
71
- url: (key: string) => `https://api.apilayer.com/smart_crop/url?apikey=${key}`,
72
- key: env.APILAYER_IMAGECROP_KEY,
73
- method: 'GET'
74
- },
75
- {
76
- name: 'Advanced Scraper API',
77
- url: (key: string) => `https://api.apilayer.com/adv_scraper/scraper?url=https://example.com&apikey=${key}`,
78
- key: env.APILAYER_SCRAPER_KEY,
79
- method: 'GET'
80
- },
81
- {
82
- name: 'PDF Layer API',
83
- url: (key: string) => `https://api.pdflayer.com/api`,
84
- key: env.APILAYER_PDFLAYER_KEY,
85
- method: 'POST'
86
- },
87
- {
88
- name: 'World News API',
89
- url: (key: string) => `https://api.apilayer.com/world_news/extract-news?url=https://example.com&apikey=${key}`,
90
- key: env.APILAYER_WORLDNEWS_KEY,
91
- method: 'GET'
92
- },
93
- {
94
- name: 'Skills API',
95
- url: (key: string) => `https://api.apilayer.com/skills?q=test&apikey=${key}`,
96
- key: env.APILAYER_SKILLAPI_KEY,
97
- method: 'GET'
98
- },
99
- {
100
- name: 'Form API',
101
- url: (key: string) => `https://api.apilayer.com/form_api/test?apikey=${key}`,
102
- key: env.APILAYER_FORMAPI_KEY,
103
- method: 'POST'
104
- },
105
- ];
106
-
107
- async function runTests() {
108
- console.log('๐Ÿงช Testing exact endpoints from execute.ts\n');
109
-
110
- let working = 0;
111
- const failed: string[] = [];
112
-
113
- for (const test of tests) {
114
- try {
115
- const startTime = Date.now();
116
- const url = test.url(test.key);
117
- const options: RequestInit = {
118
- method: test.method,
119
- headers: { 'Content-Type': 'application/json' }
120
- };
121
-
122
- const response = await fetch(url, options);
123
- const responseTime = Date.now() - startTime;
124
-
125
- if (response.ok) {
126
- working++;
127
- console.log(`โœ… ${test.name}: ${response.status} (${responseTime}ms)`);
128
- } else {
129
- console.log(`โŒ ${test.name}: ${response.status} (${responseTime}ms)`);
130
- failed.push(`${test.name}: ${response.status}`);
131
- }
132
- } catch (err) {
133
- const errorMsg = err instanceof Error ? err.message : String(err);
134
- console.log(`โŒ ${test.name}: ${errorMsg}`);
135
- failed.push(`${test.name}: ${errorMsg}`);
136
- }
137
- }
138
-
139
- console.log('\n' + '='.repeat(60));
140
- console.log(`โœ… WORKING: ${working}/14`);
141
- console.log(`โŒ NOT WORKING: ${14 - working}/14\n`);
142
- }
143
-
144
- runTests().catch(console.error);
package/test-final.ts DELETED
@@ -1,83 +0,0 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
- import { homedir } from 'os';
4
-
5
- function loadEnv(): Record<string, string> {
6
- const envPath = path.join(homedir(), '.secrets', 'apilayer.env');
7
- const content = fs.readFileSync(envPath, 'utf-8');
8
- const vars: Record<string, string> = {};
9
- for (const line of content.split('\n')) {
10
- const match = line.match(/^([^=]+)=(.*)$/);
11
- if (match) {
12
- vars[match[1].trim()] = match[2].trim().replace(/^['\"]|[\"']$/g, '');
13
- }
14
- }
15
- return vars;
16
- }
17
-
18
- const env = loadEnv();
19
-
20
- const tests = [
21
- { name: 'ExchangeRate API', key: 'APILAYER_EXCHANGERATE_KEY', url: 'https://api.apilayer.com/exchangerates_data/latest?base=USD' },
22
- { name: 'AviationStack API', key: 'APILAYER_AVIATIONSTACK_KEY', url: 'http://api.aviationstack.com/v1/flights' },
23
- { name: 'ScreenshotLayer API', key: 'APILAYER_SCREENSHOTLAYER_KEY', url: 'https://api.screenshotlayer.com/api/capture?url=https://example.com' },
24
- { name: 'Number Verification API', key: 'APILAYER_NUMVERIFY_KEY', url: 'https://api.apilayer.com/number_verification/validate?number=+1234567890' },
25
- { name: 'Email Verification API', key: 'APILAYER_EMAILVERIFY_KEY', url: 'https://api.apilayer.com/email_verification/check?email=test@example.com' },
26
- { name: 'Marketstack API', key: 'APILAYER_MARKETSTACK_KEY', url: 'http://api.marketstack.com/v1/eod?symbols=AAPL' },
27
- { name: 'VAT Layer API', key: 'APILAYER_VATLAYER_KEY', url: 'https://apilayer.net/api/validate?country_code=SE' },
28
- { name: 'Finance News API', key: 'APILAYER_FINANCENEWS_KEY', url: 'https://api.apilayer.com/financelayer/news' },
29
- { name: 'Image Crop API', key: 'APILAYER_IMAGECROP_KEY', url: 'https://api.apilayer.com/smart_crop/url' },
30
- { name: 'Advanced Scraper API', key: 'APILAYER_SCRAPER_KEY', url: 'https://api.apilayer.com/adv_scraper/scraper?url=https://example.com' },
31
- { name: 'PDF Layer API', key: 'APILAYER_PDFLAYER_KEY', url: 'https://api.pdflayer.com/api', method: 'POST' },
32
- { name: 'World News API', key: 'APILAYER_WORLDNEWS_KEY', url: 'https://api.apilayer.com/world_news/extract-news?url=https://example.com' },
33
- { name: 'Skills API', key: 'APILAYER_SKILLAPI_KEY', url: 'https://api.apilayer.com/skills?q=test' },
34
- { name: 'Form API', key: 'APILAYER_FORMAPI_KEY', url: 'https://api.apilayer.com/form_api/test', method: 'POST' },
35
- ];
36
-
37
- async function runTests() {
38
- console.log('๐Ÿงช Testing all 14 APILayer services\n');
39
-
40
- let working = 0;
41
- const failed: string[] = [];
42
-
43
- for (const test of tests) {
44
- try {
45
- const startTime = Date.now();
46
- const key = env[test.key as keyof typeof env];
47
- if (!key) {
48
- console.log(`โŒ ${test.name}: NO KEY`);
49
- failed.push(`${test.name}: NO KEY`);
50
- continue;
51
- }
52
-
53
- const sep = test.url.includes('?') ? '&' : '?';
54
- const keyParam = test.key.includes('MARKETSTACK') || test.key.includes('AVIATIONSTACK') ? 'access_key' : 'apikey';
55
- const fullUrl = `${test.url}${sep}${keyParam}=${key}`;
56
-
57
- const options: RequestInit = {
58
- method: test.method || 'GET',
59
- };
60
-
61
- const response = await fetch(fullUrl, options);
62
- const responseTime = Date.now() - startTime;
63
-
64
- if (response.ok) {
65
- working++;
66
- console.log(`โœ… ${test.name}: ${response.status} (${responseTime}ms)`);
67
- } else {
68
- console.log(`โŒ ${test.name}: ${response.status} (${responseTime}ms)`);
69
- failed.push(`${test.name}: ${response.status}`);
70
- }
71
- } catch (err) {
72
- const errorMsg = err instanceof Error ? err.message : String(err);
73
- console.log(`โŒ ${test.name}: ${errorMsg}`);
74
- failed.push(`${test.name}: ${errorMsg}`);
75
- }
76
- }
77
-
78
- console.log('\n' + '='.repeat(60));
79
- console.log(`โœ… WORKING: ${working}/14`);
80
- console.log(`โŒ NOT WORKING: ${14 - working}/14\n`);
81
- }
82
-
83
- runTests().catch(console.error);
@@ -1,100 +0,0 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
- import { homedir } from 'os';
4
-
5
- // Load credentials
6
- function loadEnv(): Record<string, string> {
7
- const envPath = path.join(homedir(), '.secrets', 'apilayer.env');
8
- try {
9
- const content = fs.readFileSync(envPath, 'utf-8');
10
- const vars: Record<string, string> = {};
11
- for (const line of content.split('\n')) {
12
- const match = line.match(/^([^=]+)=(.*)$/);
13
- if (match) {
14
- vars[match[1].trim()] = match[2].trim();
15
- }
16
- }
17
- return vars;
18
- } catch {
19
- console.error('Failed to load credentials');
20
- return {};
21
- }
22
- }
23
-
24
- const env = loadEnv();
25
-
26
- // Manual test of the 5 failing services
27
- async function testFailing() {
28
- console.log('Testing 5 problematic services:\n');
29
-
30
- const tests = [
31
- {
32
- name: 'Number Verification',
33
- url: 'https://api.apilayer.com/number_verification/validate',
34
- params: { number: '+46701234567' },
35
- key: env.APILAYER_NUMVERIFY_KEY,
36
- },
37
- {
38
- name: 'Image Crop',
39
- url: 'https://api.apilayer.com/smart_crop/url',
40
- params: { url: 'https://example.com/image.jpg' },
41
- key: env.APILAYER_IMAGECROP_KEY,
42
- },
43
- {
44
- name: 'World News',
45
- url: 'https://api.apilayer.com/world_news/extract-news',
46
- params: { url: 'https://example.com', analyze: 'true' },
47
- key: env.APILAYER_WORLDNEWS_KEY,
48
- },
49
- {
50
- name: 'Skills',
51
- url: 'https://api.apilayer.com/skills',
52
- params: { q: 'machine learning' },
53
- key: env.APILAYER_SKILLAPI_KEY,
54
- },
55
- {
56
- name: 'Form API',
57
- url: 'https://api.apilayer.com/form_api/test',
58
- params: {},
59
- key: env.APILAYER_FORMAPI_KEY,
60
- },
61
- ];
62
-
63
- for (const test of tests) {
64
- // Build URL with params
65
- const url = new URL(test.url);
66
- Object.entries(test.params).forEach(([k, v]) => {
67
- url.searchParams.set(k, String(v));
68
- });
69
-
70
- try {
71
- const response = await fetch(url.toString(), {
72
- method: test.url.includes('form_api') ? 'POST' : 'GET',
73
- headers: {
74
- 'apikey': test.key,
75
- 'Content-Type': 'application/json',
76
- },
77
- ...(test.url.includes('form_api') && { body: JSON.stringify({}) }),
78
- });
79
-
80
- const status = response.status;
81
- const headers = response.headers;
82
- const contentType = headers.get('content-type');
83
-
84
- console.log(`${status === 200 ? 'โœ…' : 'โŒ'} ${test.name}: ${status}`);
85
- if (status !== 200) {
86
- try {
87
- const data = await response.json();
88
- console.log(` Error: ${JSON.stringify(data).substring(0, 100)}`);
89
- } catch {
90
- const text = await response.text();
91
- console.log(` Response: ${text.substring(0, 100)}`);
92
- }
93
- }
94
- } catch (err) {
95
- console.log(`โŒ ${test.name}: ${err instanceof Error ? err.message : String(err)}`);
96
- }
97
- }
98
- }
99
-
100
- testFailing().catch(console.error);
@@ -1,217 +0,0 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
- import { homedir } from 'os';
4
-
5
- // Load credentials
6
- function loadEnv(): Record<string, string> {
7
- const envPath = path.join(homedir(), '.secrets', 'apilayer.env');
8
- const content = fs.readFileSync(envPath, 'utf-8');
9
- const vars: Record<string, string> = {};
10
- for (const line of content.split('\n')) {
11
- const match = line.match(/^([^=]+)=(.*)$/);
12
- if (match) {
13
- vars[match[1].trim()] = match[2].trim();
14
- }
15
- }
16
- return vars;
17
- }
18
-
19
- const env = loadEnv();
20
-
21
- const tests = [
22
- {
23
- name: 'ExchangeRate API',
24
- build: () => {
25
- const url = new URL('https://api.apilayer.com/exchangerates_data/latest');
26
- url.searchParams.set('base', 'USD');
27
- return {
28
- url: url.toString(),
29
- options: { method: 'GET', headers: { 'apikey': env.APILAYER_EXCHANGERATE_KEY } }
30
- };
31
- }
32
- },
33
- {
34
- name: 'AviationStack API',
35
- build: () => {
36
- const url = new URL('http://api.aviationstack.com/v1/flights');
37
- url.searchParams.set('access_key', env.APILAYER_AVIATIONSTACK_KEY);
38
- return { url: url.toString(), options: { method: 'GET' } };
39
- }
40
- },
41
- {
42
- name: 'ScreenshotLayer API',
43
- build: () => {
44
- const url = new URL('https://api.screenshotlayer.com/api/capture');
45
- url.searchParams.set('url', 'https://example.com');
46
- url.searchParams.set('access_key', env.APILAYER_SCREENSHOTLAYER_KEY);
47
- return { url: url.toString(), options: { method: 'GET' } };
48
- }
49
- },
50
- {
51
- name: 'Number Verification API',
52
- build: () => {
53
- const url = new URL('https://api.apilayer.com/number_verification/validate');
54
- url.searchParams.set('number', '+1234567890');
55
- return {
56
- url: url.toString(),
57
- options: { method: 'GET', headers: { 'apikey': env.APILAYER_NUMVERIFY_KEY } }
58
- };
59
- }
60
- },
61
- {
62
- name: 'Email Verification API',
63
- build: () => {
64
- const url = new URL('https://api.apilayer.com/email_verification/check');
65
- url.searchParams.set('email', 'test@example.com');
66
- return {
67
- url: url.toString(),
68
- options: { method: 'GET', headers: { 'apikey': env.APILAYER_EMAILVERIFY_KEY } }
69
- };
70
- }
71
- },
72
- {
73
- name: 'Marketstack API',
74
- build: () => {
75
- const url = new URL('http://api.marketstack.com/v1/eod');
76
- url.searchParams.set('access_key', env.APILAYER_MARKETSTACK_KEY);
77
- url.searchParams.set('symbols', 'AAPL');
78
- url.searchParams.set('limit', '10');
79
- return { url: url.toString(), options: { method: 'GET' } };
80
- }
81
- },
82
- {
83
- name: 'VAT Layer API',
84
- build: () => {
85
- const url = new URL('https://apilayer.net/api/validate');
86
- url.searchParams.set('access_key', env.APILAYER_VATLAYER_KEY);
87
- url.searchParams.set('country_code', 'SE');
88
- return { url: url.toString(), options: { method: 'GET' } };
89
- }
90
- },
91
- {
92
- name: 'Finance News API',
93
- build: () => {
94
- const url = new URL('https://api.apilayer.com/financelayer/news');
95
- url.searchParams.set('limit', '5');
96
- return {
97
- url: url.toString(),
98
- options: { method: 'GET', headers: { 'apikey': env.APILAYER_FINANCENEWS_KEY } }
99
- };
100
- }
101
- },
102
- {
103
- name: 'Image Crop API',
104
- build: () => {
105
- const url = new URL('https://api.apilayer.com/smart_crop/url');
106
- url.searchParams.set('url', 'https://example.com/image.jpg');
107
- return {
108
- url: url.toString(),
109
- options: { method: 'GET', headers: { 'apikey': env.APILAYER_IMAGECROP_KEY } }
110
- };
111
- }
112
- },
113
- {
114
- name: 'Advanced Scraper API',
115
- build: () => {
116
- const url = new URL('https://api.apilayer.com/adv_scraper/scraper');
117
- url.searchParams.set('url', 'https://example.com');
118
- return {
119
- url: url.toString(),
120
- options: { method: 'GET', headers: { 'apikey': env.APILAYER_SCRAPER_KEY } }
121
- };
122
- }
123
- },
124
- {
125
- name: 'PDF Layer API',
126
- build: () => {
127
- const url = new URL('https://api.pdflayer.com/api');
128
- return {
129
- url: url.toString(),
130
- options: {
131
- method: 'POST',
132
- headers: { 'apikey': env.APILAYER_PDFLAYER_KEY, 'Content-Type': 'application/json' },
133
- body: JSON.stringify({ document_url: 'https://example.com' })
134
- }
135
- };
136
- }
137
- },
138
- {
139
- name: 'World News API',
140
- build: () => {
141
- const url = new URL('https://api.apilayer.com/world_news/extract-news');
142
- url.searchParams.set('url', 'https://example.com');
143
- url.searchParams.set('analyze', 'true');
144
- return {
145
- url: url.toString(),
146
- options: { method: 'GET', headers: { 'apikey': env.APILAYER_WORLDNEWS_KEY } }
147
- };
148
- }
149
- },
150
- {
151
- name: 'Skills API',
152
- build: () => {
153
- const url = new URL('https://api.apilayer.com/skills');
154
- url.searchParams.set('q', 'machine learning');
155
- return {
156
- url: url.toString(),
157
- options: { method: 'GET', headers: { 'apikey': env.APILAYER_SKILLAPI_KEY } }
158
- };
159
- }
160
- },
161
- {
162
- name: 'Form API',
163
- build: () => {
164
- const url = new URL('https://api.apilayer.com/form_api/test');
165
- return {
166
- url: url.toString(),
167
- options: {
168
- method: 'POST',
169
- headers: { 'apikey': env.APILAYER_FORMAPI_KEY, 'Content-Type': 'application/json' },
170
- body: JSON.stringify({})
171
- }
172
- };
173
- }
174
- },
175
- ];
176
-
177
- async function runTests() {
178
- console.log('๐Ÿงช Testing all 14 APILayer endpoints (with correct auth)\n');
179
-
180
- let working = 0;
181
- const failed: string[] = [];
182
-
183
- for (const test of tests) {
184
- try {
185
- const startTime = Date.now();
186
- const { url, options } = test.build();
187
- const response = await fetch(url, options);
188
- const responseTime = Date.now() - startTime;
189
-
190
- const success = response.ok;
191
- if (success) {
192
- working++;
193
- console.log(`โœ… ${test.name}: ${response.status} (${responseTime}ms)`);
194
- } else {
195
- console.log(`โŒ ${test.name}: ${response.status} (${responseTime}ms)`);
196
- failed.push(`${test.name}: ${response.status}`);
197
- }
198
- } catch (err) {
199
- const errorMsg = err instanceof Error ? err.message : String(err);
200
- console.log(`โŒ ${test.name}: ${errorMsg}`);
201
- failed.push(`${test.name}: ${errorMsg}`);
202
- }
203
- }
204
-
205
- console.log('\n' + '='.repeat(60));
206
- console.log('๐Ÿ“Š FINAL RESULTS');
207
- console.log('='.repeat(60));
208
- console.log(`\nโœ… WORKING: ${working}/14`);
209
- console.log(`โŒ NOT WORKING: ${14 - working}/14\n`);
210
-
211
- if (failed.length > 0) {
212
- console.log('Failed services:');
213
- failed.forEach(f => console.log(` โ€ข ${f}`));
214
- }
215
- }
216
-
217
- runTests().catch(console.error);
@@ -1,41 +0,0 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
- import { homedir } from 'os';
4
-
5
- function loadEnv(): Record<string, string> {
6
- const envPath = path.join(homedir(), '.secrets', 'apilayer.env');
7
- const content = fs.readFileSync(envPath, 'utf-8');
8
- const vars: Record<string, string> = {};
9
- for (const line of content.split('\n')) {
10
- const match = line.match(/^([^=]+)=(.*)$/);
11
- if (match) vars[match[1].trim()] = match[2].trim();
12
- }
13
- return vars;
14
- }
15
-
16
- async function test() {
17
- const env = loadEnv();
18
- const key = env.APILAYER_NUMVERIFY_KEY;
19
- console.log('Testing Number Verification with key:', key.substring(0, 8) + '...');
20
-
21
- const url = new URL('https://api.apilayer.com/number_verification/validate');
22
- url.searchParams.set('number', '+46701234567');
23
-
24
- const response = await fetch(url.toString(), {
25
- method: 'GET',
26
- headers: { 'apikey': key },
27
- });
28
-
29
- console.log('Status:', response.status);
30
- if (response.status === 200) {
31
- console.log('โœ… Number Verification NOW WORKING');
32
- const data = await response.json();
33
- console.log('Response:', JSON.stringify(data).substring(0, 200));
34
- } else {
35
- const data = await response.json();
36
- console.log('โŒ Still failing');
37
- console.log('Error:', data);
38
- }
39
- }
40
-
41
- test().catch(console.error);
@@ -1,92 +0,0 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
- import { homedir } from 'os';
4
-
5
- // Load credentials
6
- function loadEnv(): Record<string, string> {
7
- const envPath = path.join(homedir(), '.secrets', 'apilayer.env');
8
- const content = fs.readFileSync(envPath, 'utf-8');
9
- const vars: Record<string, string> = {};
10
- for (const line of content.split('\n')) {
11
- const match = line.match(/^([^=]+)=(.*)$/);
12
- if (match) {
13
- vars[match[1].trim()] = match[2].trim();
14
- }
15
- }
16
- return vars;
17
- }
18
-
19
- const env = loadEnv();
20
-
21
- // Import handlers directly
22
- const handlers: Record<string, Record<string, any>> = {
23
- apilayer: {
24
- exchange_rates: async (params: any) => {
25
- const key = env.APILAYER_EXCHANGERATE_KEY;
26
- const url = new URL('https://api.apilayer.com/exchangerates_data/latest');
27
- url.searchParams.set('base', 'USD');
28
- return fetch(url.toString(), { method: 'GET', headers: { 'apikey': key } });
29
- },
30
- verify_number: async (params: any) => {
31
- const key = env.APILAYER_NUMVERIFY_KEY;
32
- const url = new URL('https://api.apilayer.com/number_verification/validate');
33
- url.searchParams.set('number', '+46701234567');
34
- return fetch(url.toString(), { method: 'GET', headers: { 'apikey': key } });
35
- },
36
- image_crop: async (params: any) => {
37
- const key = env.APILAYER_IMAGECROP_KEY;
38
- const url = new URL('https://api.apilayer.com/smart_crop/url');
39
- url.searchParams.set('url', 'https://example.com/image.jpg');
40
- return fetch(url.toString(), { method: 'GET', headers: { 'apikey': key } });
41
- },
42
- world_news: async (params: any) => {
43
- const key = env.APILAYER_WORLDNEWS_KEY;
44
- const url = new URL('https://api.apilayer.com/world_news/extract-news');
45
- url.searchParams.set('url', 'https://example.com');
46
- url.searchParams.set('analyze', 'true');
47
- return fetch(url.toString(), { method: 'GET', headers: { 'apikey': key } });
48
- },
49
- skills: async (params: any) => {
50
- const key = env.APILAYER_SKILLAPI_KEY;
51
- const url = new URL('https://api.apilayer.com/skills');
52
- url.searchParams.set('q', 'machine learning');
53
- return fetch(url.toString(), { method: 'GET', headers: { 'apikey': key } });
54
- },
55
- form_submit: async (params: any) => {
56
- const key = env.APILAYER_FORMAPI_KEY;
57
- return fetch('https://api.apilayer.com/form_api/test', {
58
- method: 'POST',
59
- headers: { 'apikey': key, 'Content-Type': 'application/json' },
60
- body: JSON.stringify({}),
61
- });
62
- },
63
- },
64
- };
65
-
66
- async function testHandlers() {
67
- console.log('๐Ÿงช Testing handlers directly\n');
68
-
69
- const tests = [
70
- { name: 'Exchange Rates', action: 'exchange_rates' },
71
- { name: 'Verify Number', action: 'verify_number' },
72
- { name: 'Image Crop', action: 'image_crop' },
73
- { name: 'World News', action: 'world_news' },
74
- { name: 'Skills', action: 'skills' },
75
- { name: 'Form Submit', action: 'form_submit' },
76
- ];
77
-
78
- for (const test of tests) {
79
- try {
80
- const handler = handlers.apilayer[test.action];
81
- const startTime = Date.now();
82
- const response = await handler({});
83
- const responseTime = Date.now() - startTime;
84
- console.log(`${response.ok ? 'โœ…' : 'โŒ'} ${test.name}: ${response.status} (${responseTime}ms)`);
85
- } catch (err) {
86
- const errorMsg = err instanceof Error ? err.message : String(err);
87
- console.log(`โŒ ${test.name}: ${errorMsg}`);
88
- }
89
- }
90
- }
91
-
92
- testHandlers().catch(console.error);