@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.
- package/README.md +58 -30
- package/convex/adminActivate.d.ts +3 -0
- package/convex/adminActivate.d.ts.map +1 -1
- package/convex/adminActivate.js +46 -0
- package/convex/adminActivate.js.map +1 -1
- package/convex/adminActivate.ts +1 -2
- package/convex/adminStats.d.ts +9 -0
- package/convex/adminStats.d.ts.map +1 -1
- package/convex/adminStats.js +282 -0
- package/convex/adminStats.js.map +1 -1
- package/convex/adminStats.ts +5 -3
- package/convex/agents.d.ts +84 -0
- package/convex/agents.js +809 -0
- package/convex/analytics.d.ts +5 -0
- package/convex/analytics.js +167 -0
- package/convex/apiKeys.d.ts +6 -0
- package/convex/apiKeys.d.ts.map +1 -0
- package/convex/apiKeys.js +186 -0
- package/convex/apiKeys.js.map +1 -0
- package/convex/backfillAnalytics.d.ts +2 -0
- package/convex/backfillAnalytics.js +20 -0
- package/convex/backfillSearchLogs.d.ts +2 -0
- package/convex/backfillSearchLogs.js +29 -0
- package/convex/billing.d.ts +88 -0
- package/convex/billing.d.ts.map +1 -1
- package/convex/billing.js +643 -0
- package/convex/billing.js.map +1 -1
- package/convex/billing.ts +2 -14
- package/convex/capabilities.d.ts +9 -0
- package/convex/capabilities.js +145 -0
- package/convex/chains.d.ts +68 -0
- package/convex/chains.js +1105 -0
- package/convex/credits.d.ts +25 -0
- package/convex/credits.js +186 -0
- package/convex/crons.d.ts +3 -0
- package/convex/crons.js +17 -0
- package/convex/debugFilestackLogs.d.ts +2 -0
- package/convex/debugFilestackLogs.js +17 -0
- package/convex/debugGetToken.d.ts +2 -0
- package/convex/debugGetToken.js +18 -0
- package/convex/directCall.d.ts +72 -0
- package/convex/directCall.d.ts.map +1 -1
- package/convex/directCall.js +663 -0
- package/convex/directCall.js.map +1 -1
- package/convex/earnProgress.d.ts +58 -0
- package/convex/earnProgress.js +649 -0
- package/convex/email.d.ts +14 -0
- package/convex/email.js +300 -0
- package/convex/email.js.map +1 -1
- package/convex/feedback.d.ts +7 -0
- package/convex/feedback.js +227 -0
- package/convex/http.d.ts +3 -0
- package/convex/http.d.ts.map +1 -1
- package/convex/http.js +2135 -0
- package/convex/http.js.map +1 -1
- package/convex/http.ts +275 -3
- package/convex/inbound.d.ts +2 -0
- package/convex/inbound.js +32 -0
- package/convex/logs.d.ts +48 -0
- package/convex/logs.d.ts.map +1 -1
- package/convex/logs.js +623 -0
- package/convex/logs.js.map +1 -1
- package/convex/migrateFilestack.d.ts +2 -0
- package/convex/migrateFilestack.js +74 -0
- package/convex/migratePartnersProd.d.ts +8 -0
- package/convex/migratePartnersProd.js +165 -0
- package/convex/migratePratham.d.ts +2 -0
- package/convex/migratePratham.js +121 -0
- package/convex/migrateProviderWorkspaces.d.ts +13 -0
- package/convex/migrateProviderWorkspaces.d.ts.map +1 -1
- package/convex/migrateProviderWorkspaces.js +141 -0
- package/convex/migrateProviderWorkspaces.js.map +1 -1
- package/convex/mou.d.ts +6 -0
- package/convex/mou.js +82 -0
- package/convex/providerKeys.d.ts +31 -0
- package/convex/providerKeys.js +257 -0
- package/convex/providers.d.ts +35 -0
- package/convex/providers.d.ts.map +1 -1
- package/convex/providers.js +1027 -0
- package/convex/providers.js.map +1 -1
- package/convex/purchases.d.ts +7 -0
- package/convex/purchases.js +157 -0
- package/convex/ratelimit.d.ts +4 -0
- package/convex/ratelimit.js +91 -0
- package/convex/schema.ts +4 -4
- package/convex/searchLogs.d.ts +13 -0
- package/convex/searchLogs.d.ts.map +1 -1
- package/convex/searchLogs.js +241 -0
- package/convex/searchLogs.js.map +1 -1
- package/convex/seedAPILayerAPIs.d.ts +7 -0
- package/convex/seedAPILayerAPIs.js +177 -0
- package/convex/seedDirectCallConfigs.d.ts +2 -0
- package/convex/seedDirectCallConfigs.js +324 -0
- package/convex/seedPratham.d.ts +6 -0
- package/convex/seedPratham.d.ts.map +1 -1
- package/convex/seedPratham.js +149 -0
- package/convex/seedPratham.js.map +1 -1
- package/convex/seedPratham.ts +1 -2
- package/convex/spendAlerts.d.ts +36 -0
- package/convex/spendAlerts.js +380 -0
- package/convex/spendAlerts.js.map +1 -1
- package/convex/stripeActions.d.ts +19 -0
- package/convex/stripeActions.d.ts.map +1 -1
- package/convex/stripeActions.js +432 -0
- package/convex/stripeActions.js.map +1 -1
- package/convex/stripeActions.ts +25 -3
- package/convex/teams.d.ts +21 -0
- package/convex/teams.js +215 -0
- package/convex/telemetry.d.ts +4 -0
- package/convex/telemetry.js +74 -0
- package/convex/updateAPIStatus.d.ts +6 -0
- package/convex/updateAPIStatus.d.ts.map +1 -1
- package/convex/updateAPIStatus.js +39 -0
- package/convex/updateAPIStatus.js.map +1 -1
- package/convex/usage.d.ts +27 -0
- package/convex/usage.js +229 -0
- package/convex/waitlist.d.ts +4 -0
- package/convex/waitlist.js +49 -0
- package/convex/webhooks.d.ts +12 -0
- package/convex/webhooks.js +410 -0
- package/convex/workspaceSettings.d.ts +7 -0
- package/convex/workspaceSettings.d.ts.map +1 -0
- package/convex/workspaceSettings.js +128 -0
- package/convex/workspaceSettings.js.map +1 -0
- package/convex/workspaces.d.ts +33 -0
- package/convex/workspaces.d.ts.map +1 -1
- package/convex/workspaces.js +989 -0
- package/convex/workspaces.js.map +1 -1
- package/convex/workspaces.ts +18 -20
- package/dist/bin.js +0 -0
- package/dist/cli/commands/demo.js +1 -1
- package/dist/cli/commands/demo.js.map +1 -1
- package/dist/cli/commands/doctor.js.map +1 -1
- package/dist/cli/commands/login.js.map +1 -1
- package/dist/cli/commands/setup.js.map +1 -1
- package/dist/credentials.d.ts.map +1 -1
- package/dist/credentials.js +15 -0
- package/dist/credentials.js.map +1 -1
- package/dist/discovery.js.map +1 -1
- package/dist/execute.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp-analytics.js +1 -1
- package/dist/mcp-analytics.js.map +1 -1
- package/dist/open-apis.d.ts.map +1 -1
- package/dist/open-apis.js +94 -2
- package/dist/open-apis.js.map +1 -1
- package/dist/ui/errors.js.map +1 -1
- package/dist/ui/prompts.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/commands/demo.ts +1 -1
- package/src/credentials.ts +16 -0
- package/src/index.ts +1 -1
- package/src/mcp-analytics.ts +1 -1
- package/src/open-apis.ts +114 -4
- package/src/types/convex-api.d.ts +20 -0
package/src/mcp-analytics.ts
CHANGED
|
@@ -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 '
|
|
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
|
-
|
|
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 };
|