@nordsym/apiclaw 1.8.7 → 1.8.9

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 (156) hide show
  1. package/README.md +58 -30
  2. package/convex/adminActivate.d.ts +3 -0
  3. package/convex/adminActivate.d.ts.map +1 -1
  4. package/convex/adminActivate.js +46 -0
  5. package/convex/adminActivate.js.map +1 -1
  6. package/convex/adminActivate.ts +1 -2
  7. package/convex/adminStats.d.ts +9 -0
  8. package/convex/adminStats.d.ts.map +1 -1
  9. package/convex/adminStats.js +282 -0
  10. package/convex/adminStats.js.map +1 -1
  11. package/convex/adminStats.ts +5 -3
  12. package/convex/agents.d.ts +84 -0
  13. package/convex/agents.js +809 -0
  14. package/convex/analytics.d.ts +5 -0
  15. package/convex/analytics.js +167 -0
  16. package/convex/apiKeys.d.ts +6 -0
  17. package/convex/apiKeys.d.ts.map +1 -0
  18. package/convex/apiKeys.js +186 -0
  19. package/convex/apiKeys.js.map +1 -0
  20. package/convex/backfillAnalytics.d.ts +2 -0
  21. package/convex/backfillAnalytics.js +20 -0
  22. package/convex/backfillSearchLogs.d.ts +2 -0
  23. package/convex/backfillSearchLogs.js +29 -0
  24. package/convex/billing.d.ts +88 -0
  25. package/convex/billing.d.ts.map +1 -1
  26. package/convex/billing.js +643 -0
  27. package/convex/billing.js.map +1 -1
  28. package/convex/billing.ts +2 -14
  29. package/convex/capabilities.d.ts +9 -0
  30. package/convex/capabilities.js +145 -0
  31. package/convex/chains.d.ts +68 -0
  32. package/convex/chains.js +1105 -0
  33. package/convex/credits.d.ts +25 -0
  34. package/convex/credits.js +186 -0
  35. package/convex/crons.d.ts +3 -0
  36. package/convex/crons.js +17 -0
  37. package/convex/debugFilestackLogs.d.ts +2 -0
  38. package/convex/debugFilestackLogs.js +17 -0
  39. package/convex/debugGetToken.d.ts +2 -0
  40. package/convex/debugGetToken.js +18 -0
  41. package/convex/directCall.d.ts +72 -0
  42. package/convex/directCall.d.ts.map +1 -1
  43. package/convex/directCall.js +663 -0
  44. package/convex/directCall.js.map +1 -1
  45. package/convex/earnProgress.d.ts +58 -0
  46. package/convex/earnProgress.js +649 -0
  47. package/convex/email.d.ts +14 -0
  48. package/convex/email.js +300 -0
  49. package/convex/email.js.map +1 -1
  50. package/convex/feedback.d.ts +7 -0
  51. package/convex/feedback.js +227 -0
  52. package/convex/http.d.ts +3 -0
  53. package/convex/http.d.ts.map +1 -1
  54. package/convex/http.js +2135 -0
  55. package/convex/http.js.map +1 -1
  56. package/convex/http.ts +275 -3
  57. package/convex/inbound.d.ts +2 -0
  58. package/convex/inbound.js +32 -0
  59. package/convex/logs.d.ts +48 -0
  60. package/convex/logs.d.ts.map +1 -1
  61. package/convex/logs.js +623 -0
  62. package/convex/logs.js.map +1 -1
  63. package/convex/migrateFilestack.d.ts +2 -0
  64. package/convex/migrateFilestack.js +74 -0
  65. package/convex/migratePartnersProd.d.ts +8 -0
  66. package/convex/migratePartnersProd.js +165 -0
  67. package/convex/migratePratham.d.ts +2 -0
  68. package/convex/migratePratham.js +121 -0
  69. package/convex/migrateProviderWorkspaces.d.ts +13 -0
  70. package/convex/migrateProviderWorkspaces.d.ts.map +1 -1
  71. package/convex/migrateProviderWorkspaces.js +141 -0
  72. package/convex/migrateProviderWorkspaces.js.map +1 -1
  73. package/convex/mou.d.ts +6 -0
  74. package/convex/mou.js +82 -0
  75. package/convex/providerKeys.d.ts +31 -0
  76. package/convex/providerKeys.js +257 -0
  77. package/convex/providers.d.ts +35 -0
  78. package/convex/providers.d.ts.map +1 -1
  79. package/convex/providers.js +1027 -0
  80. package/convex/providers.js.map +1 -1
  81. package/convex/purchases.d.ts +7 -0
  82. package/convex/purchases.js +157 -0
  83. package/convex/ratelimit.d.ts +4 -0
  84. package/convex/ratelimit.js +91 -0
  85. package/convex/schema.ts +4 -4
  86. package/convex/searchLogs.d.ts +13 -0
  87. package/convex/searchLogs.d.ts.map +1 -1
  88. package/convex/searchLogs.js +241 -0
  89. package/convex/searchLogs.js.map +1 -1
  90. package/convex/seedAPILayerAPIs.d.ts +7 -0
  91. package/convex/seedAPILayerAPIs.js +177 -0
  92. package/convex/seedDirectCallConfigs.d.ts +2 -0
  93. package/convex/seedDirectCallConfigs.js +324 -0
  94. package/convex/seedPratham.d.ts +6 -0
  95. package/convex/seedPratham.d.ts.map +1 -1
  96. package/convex/seedPratham.js +149 -0
  97. package/convex/seedPratham.js.map +1 -1
  98. package/convex/seedPratham.ts +1 -2
  99. package/convex/spendAlerts.d.ts +36 -0
  100. package/convex/spendAlerts.js +380 -0
  101. package/convex/spendAlerts.js.map +1 -1
  102. package/convex/stripeActions.d.ts +19 -0
  103. package/convex/stripeActions.d.ts.map +1 -1
  104. package/convex/stripeActions.js +432 -0
  105. package/convex/stripeActions.js.map +1 -1
  106. package/convex/stripeActions.ts +25 -3
  107. package/convex/teams.d.ts +21 -0
  108. package/convex/teams.js +215 -0
  109. package/convex/telemetry.d.ts +4 -0
  110. package/convex/telemetry.js +74 -0
  111. package/convex/updateAPIStatus.d.ts +6 -0
  112. package/convex/updateAPIStatus.d.ts.map +1 -1
  113. package/convex/updateAPIStatus.js +39 -0
  114. package/convex/updateAPIStatus.js.map +1 -1
  115. package/convex/usage.d.ts +27 -0
  116. package/convex/usage.js +229 -0
  117. package/convex/waitlist.d.ts +4 -0
  118. package/convex/waitlist.js +49 -0
  119. package/convex/webhooks.d.ts +12 -0
  120. package/convex/webhooks.js +410 -0
  121. package/convex/workspaceSettings.d.ts +7 -0
  122. package/convex/workspaceSettings.d.ts.map +1 -0
  123. package/convex/workspaceSettings.js +128 -0
  124. package/convex/workspaceSettings.js.map +1 -0
  125. package/convex/workspaces.d.ts +33 -0
  126. package/convex/workspaces.d.ts.map +1 -1
  127. package/convex/workspaces.js +989 -0
  128. package/convex/workspaces.js.map +1 -1
  129. package/convex/workspaces.ts +18 -20
  130. package/dist/bin.js +0 -0
  131. package/dist/cli/commands/demo.js +1 -1
  132. package/dist/cli/commands/demo.js.map +1 -1
  133. package/dist/cli/commands/doctor.js.map +1 -1
  134. package/dist/cli/commands/login.js.map +1 -1
  135. package/dist/cli/commands/setup.js.map +1 -1
  136. package/dist/credentials.d.ts.map +1 -1
  137. package/dist/credentials.js +15 -0
  138. package/dist/credentials.js.map +1 -1
  139. package/dist/discovery.js.map +1 -1
  140. package/dist/execute.js.map +1 -1
  141. package/dist/index.js +1 -1
  142. package/dist/index.js.map +1 -1
  143. package/dist/mcp-analytics.js +1 -1
  144. package/dist/mcp-analytics.js.map +1 -1
  145. package/dist/open-apis.d.ts.map +1 -1
  146. package/dist/open-apis.js +94 -2
  147. package/dist/open-apis.js.map +1 -1
  148. package/dist/ui/errors.js.map +1 -1
  149. package/dist/ui/prompts.js.map +1 -1
  150. package/package.json +1 -1
  151. package/src/cli/commands/demo.ts +1 -1
  152. package/src/credentials.ts +16 -0
  153. package/src/index.ts +1 -1
  154. package/src/mcp-analytics.ts +1 -1
  155. package/src/open-apis.ts +114 -4
  156. package/src/types/convex-api.d.ts +20 -0
@@ -7,7 +7,7 @@ import { appendFileSync, existsSync, mkdirSync } from 'fs';
7
7
  import { homedir } from 'os';
8
8
  import { join } from 'path';
9
9
  import { ConvexHttpClient } from 'convex/browser';
10
- import { api } from '../convex/_generated/api.js';
10
+ import { api } from './types/convex-api.js';
11
11
 
12
12
  export interface APICallLog {
13
13
  timestamp: string;
package/src/open-apis.ts CHANGED
@@ -143,11 +143,105 @@ export const openAPIs: Record<string, OpenAPIConfig> = {
143
143
  },
144
144
  };
145
145
 
146
+ /**
147
+ * Generic passthrough provider — proxy any open API without pre-configuration.
148
+ * Enables all 22,000+ indexed APIs to be callable on demand.
149
+ *
150
+ * Usage: call_api("generic", "request", {
151
+ * url: "https://api.example.com/endpoint",
152
+ * method: "GET", // optional, default GET
153
+ * query: { key: "value" }, // optional query params
154
+ * body: { key: "value" }, // optional body (POST/PUT/PATCH)
155
+ * headers: { "X-Foo": "bar" }, // optional extra headers
156
+ * })
157
+ */
158
+
159
+ const SSRF_BLOCKLIST = [
160
+ /^https?:\/\/localhost/i,
161
+ /^https?:\/\/127\./,
162
+ /^https?:\/\/10\./,
163
+ /^https?:\/\/172\.(1[6-9]|2\d|3[01])\./,
164
+ /^https?:\/\/192\.168\./,
165
+ /^https?:\/\/169\.254\./, // link-local / AWS metadata
166
+ /^https?:\/\/metadata\.google/i,
167
+ /^https?:\/\/\[::1\]/, // IPv6 loopback
168
+ ];
169
+
170
+ function isSsrfBlocked(url: string): boolean {
171
+ return SSRF_BLOCKLIST.some(r => r.test(url));
172
+ }
173
+
174
+ async function executeGeneric(
175
+ action: string,
176
+ params: Record<string, any>
177
+ ): Promise<{ success: boolean; provider: string; action: string; data?: any; error?: string }> {
178
+ const url: string = params.url;
179
+ if (!url) {
180
+ return { success: false, provider: 'generic', action, error: 'Missing required param: url' };
181
+ }
182
+
183
+ if (isSsrfBlocked(url)) {
184
+ return { success: false, provider: 'generic', action, error: 'URL is not allowed (private/internal range)' };
185
+ }
186
+
187
+ const method = (params.method || 'GET').toUpperCase();
188
+ const query: Record<string, string> = params.query || {};
189
+ const body = params.body;
190
+ const extraHeaders: Record<string, string> = params.headers || {};
191
+
192
+ // Build URL with query params
193
+ let finalUrl = url;
194
+ const qKeys = Object.keys(query);
195
+ if (qKeys.length > 0) {
196
+ const sep = url.includes('?') ? '&' : '?';
197
+ finalUrl = url + sep + qKeys.map(k => `${encodeURIComponent(k)}=${encodeURIComponent(query[k])}`).join('&');
198
+ }
199
+
200
+ const headers: Record<string, string> = {
201
+ 'Accept': 'application/json',
202
+ 'User-Agent': 'APIClaw/1.0 (+https://apiclaw.cloud)',
203
+ ...extraHeaders,
204
+ };
205
+
206
+ const fetchOpts: RequestInit = { method, headers };
207
+
208
+ if (body && ['POST', 'PUT', 'PATCH'].includes(method)) {
209
+ headers['Content-Type'] = 'application/json';
210
+ fetchOpts.body = JSON.stringify(body);
211
+ }
212
+
213
+ try {
214
+ const res = await fetch(finalUrl, fetchOpts);
215
+ const contentType = res.headers.get('content-type') || '';
216
+
217
+ let data: any;
218
+ if (contentType.includes('application/json')) {
219
+ data = await res.json();
220
+ } else {
221
+ data = await res.text();
222
+ }
223
+
224
+ if (!res.ok) {
225
+ return {
226
+ success: false,
227
+ provider: 'generic',
228
+ action,
229
+ error: `HTTP ${res.status}: ${res.statusText}`,
230
+ data,
231
+ };
232
+ }
233
+
234
+ return { success: true, provider: 'generic', action, data };
235
+ } catch (e: any) {
236
+ return { success: false, provider: 'generic', action, error: e.message || 'Request failed' };
237
+ }
238
+ }
239
+
146
240
  /**
147
241
  * Check if a provider is an open API
148
242
  */
149
243
  export function isOpenAPI(providerId: string): boolean {
150
- return providerId in openAPIs;
244
+ return providerId === 'generic' || providerId in openAPIs;
151
245
  }
152
246
 
153
247
  /**
@@ -165,8 +259,13 @@ export async function executeOpenAPI(
165
259
  action: string,
166
260
  params: Record<string, any>
167
261
  ): Promise<{ success: boolean; provider: string; action: string; data?: any; error?: string }> {
262
+ // Generic passthrough — proxy any open API on demand
263
+ if (providerId === 'generic') {
264
+ return await executeGeneric(action, params);
265
+ }
266
+
168
267
  const config = openAPIs[providerId];
169
-
268
+
170
269
  if (!config) {
171
270
  return {
172
271
  success: false,
@@ -177,7 +276,7 @@ export async function executeOpenAPI(
177
276
  }
178
277
 
179
278
  const actionConfig = config.actions[action];
180
-
279
+
181
280
  if (!actionConfig) {
182
281
  return {
183
282
  success: false,
@@ -188,6 +287,7 @@ export async function executeOpenAPI(
188
287
  }
189
288
 
190
289
  try {
290
+
191
291
  // Special handling for Kroki - use POST to get actual image data
192
292
  if (providerId === 'kroki') {
193
293
  const type = params.type || 'mermaid';
@@ -303,10 +403,20 @@ export async function executeOpenAPI(
303
403
  * List all open APIs with their actions
304
404
  */
305
405
  export function listOpenAPIs(): { provider: string; name: string; description: string; actions: string[] }[] {
306
- return Object.entries(openAPIs).map(([id, config]) => ({
406
+ const curated = Object.entries(openAPIs).map(([id, config]) => ({
307
407
  provider: id,
308
408
  name: config.name,
309
409
  description: config.description,
310
410
  actions: Object.keys(config.actions),
311
411
  }));
412
+
413
+ return [
414
+ {
415
+ provider: 'generic',
416
+ name: 'Generic Passthrough',
417
+ description: 'Proxy any open/public API on demand. Supply url, method, query, body, headers. No pre-configuration needed — unlocks all 22,000+ indexed APIs.',
418
+ actions: ['request'],
419
+ },
420
+ ...curated,
421
+ ];
312
422
  }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Type shim for Convex generated API.
3
+ *
4
+ * Replaces the direct import from `../convex/_generated/api.js` which
5
+ * caused TypeScript to transitively process all convex/*.ts source files
6
+ * under the main tsconfig (NodeNext strict), producing hundreds of
7
+ * irrelevant errors. The convex/ directory has its own tsconfig
8
+ * (Bundler moduleResolution) and is compiled separately via `npx convex deploy`.
9
+ *
10
+ * If you add new api.X.Y usages in the codebase, add the shape here.
11
+ */
12
+
13
+ declare const api: {
14
+ analytics: {
15
+ log: any;
16
+ };
17
+ [key: string]: any; // forward-compatible: won't break on new api.* usage
18
+ };
19
+
20
+ export { api };