@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.
- package/README.md +15 -2
- package/dist/bin-http.js +0 -0
- package/dist/bin.bundled.js +79288 -0
- package/dist/gateway-client.d.ts.map +1 -1
- package/dist/gateway-client.js +24 -2
- package/dist/gateway-client.js.map +1 -1
- package/dist/index.bundled.js +61263 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +7 -2
- package/.claude/settings.local.json +0 -13
- package/.env.prod +0 -1
- package/apiclaw-README.md +0 -494
- package/convex/_generated/api.d.ts +0 -145
- package/convex/_generated/api.js +0 -23
- package/convex/_generated/dataModel.d.ts +0 -60
- package/convex/_generated/server.d.ts +0 -143
- package/convex/_generated/server.js +0 -93
- package/convex/_listWorkspaces.ts +0 -13
- package/convex/adminActivate.ts +0 -53
- package/convex/adminStats.ts +0 -306
- package/convex/agents.ts +0 -939
- package/convex/analytics.ts +0 -187
- package/convex/apiKeys.ts +0 -220
- package/convex/backfillAnalytics.ts +0 -272
- package/convex/backfillSearchLogs.ts +0 -35
- package/convex/billing.ts +0 -834
- package/convex/capabilities.ts +0 -157
- package/convex/chains.ts +0 -1318
- package/convex/credits.ts +0 -211
- package/convex/crons.ts +0 -65
- package/convex/debugFilestackLogs.ts +0 -16
- package/convex/debugGetToken.ts +0 -18
- package/convex/directCall.ts +0 -713
- package/convex/earnProgress.ts +0 -753
- package/convex/email.ts +0 -329
- package/convex/feedback.ts +0 -265
- package/convex/funnel.ts +0 -431
- package/convex/guards.ts +0 -174
- package/convex/http.ts +0 -3756
- package/convex/inbound.ts +0 -32
- package/convex/logs.ts +0 -701
- package/convex/migrateFilestack.ts +0 -81
- package/convex/migratePartnersProd.ts +0 -174
- package/convex/migratePratham.ts +0 -126
- package/convex/migrateProviderWorkspaces.ts +0 -175
- package/convex/mou.ts +0 -91
- package/convex/nurture.ts +0 -355
- package/convex/providerKeys.ts +0 -289
- package/convex/providers.ts +0 -1135
- package/convex/purchases.ts +0 -183
- package/convex/ratelimit.ts +0 -104
- package/convex/schema.ts +0 -926
- package/convex/searchLogs.ts +0 -265
- package/convex/seedAPILayerAPIs.ts +0 -191
- package/convex/seedDirectCallConfigs.ts +0 -336
- package/convex/seedPratham.ts +0 -149
- package/convex/spendAlerts.ts +0 -442
- package/convex/stripeActions.ts +0 -607
- package/convex/teams.ts +0 -243
- package/convex/telemetry.ts +0 -81
- package/convex/tsconfig.json +0 -25
- package/convex/updateAPIStatus.ts +0 -44
- package/convex/usage.ts +0 -260
- package/convex/usageReports.ts +0 -357
- package/convex/waitlist.ts +0 -55
- package/convex/webhooks.ts +0 -494
- package/convex/workspaceSettings.ts +0 -143
- package/convex/workspaces.ts +0 -1331
- package/convex.json +0 -3
- package/direct-test.mjs +0 -51
- package/email-templates/filestack-provider-outreach.html +0 -162
- package/email-templates/partnership-template.html +0 -116
- package/email-templates/pratham-draft-preview.txt +0 -57
- package/email-templates/pratham-partnership-draft.html +0 -141
- package/reports/APIClaw-Session-Report-2026-04-05.pdf +0 -0
- package/reports/pipeline/PIPELINE-REPORT.json +0 -153
- package/reports/pipeline/acquire_apisguru.json +0 -17
- package/reports/pipeline/capabilities.json +0 -38
- package/reports/pipeline/discover_azure_recursive.json +0 -1551
- package/reports/pipeline/discover_github.json +0 -25
- package/reports/pipeline/discover_github_repos.json +0 -49
- package/reports/pipeline/discover_swaggerhub.json +0 -24
- package/reports/pipeline/discover_well_known.json +0 -23
- package/reports/pipeline/fetch_specs.json +0 -19
- package/reports/pipeline/generate_providers.json +0 -14
- package/reports/pipeline/match_registry.json +0 -11
- package/reports/pipeline/parse_specs.json +0 -17
- package/reports/pipeline/promote_candidates.json +0 -34
- package/reports/pipeline/validate.json +0 -30
- package/reports/pipeline/validate_smoke_details.json +0 -3835
- package/reports/session-report-2026-04-05.html +0 -433
- package/seed-apis-direct.mjs +0 -106
- package/src/access-control.ts +0 -174
- package/src/adapters/base.ts +0 -364
- package/src/adapters/claude-desktop.ts +0 -41
- package/src/adapters/cline.ts +0 -88
- package/src/adapters/continue.ts +0 -91
- package/src/adapters/cursor.ts +0 -43
- package/src/adapters/custom.ts +0 -188
- package/src/adapters/detect.ts +0 -202
- package/src/adapters/index.ts +0 -47
- package/src/adapters/windsurf.ts +0 -44
- package/src/bin-http.ts +0 -45
- package/src/bin.ts +0 -34
- package/src/capability-router.ts +0 -331
- package/src/chainExecutor.ts +0 -730
- package/src/chainResolver.test.ts +0 -246
- package/src/chainResolver.ts +0 -658
- package/src/cli/commands/demo.ts +0 -109
- package/src/cli/commands/doctor.ts +0 -435
- package/src/cli/commands/index.ts +0 -9
- package/src/cli/commands/login.ts +0 -203
- package/src/cli/commands/mcp-install.ts +0 -373
- package/src/cli/commands/restore.ts +0 -333
- package/src/cli/commands/setup.ts +0 -297
- package/src/cli/commands/uninstall.ts +0 -240
- package/src/cli/index.ts +0 -148
- package/src/cli.ts +0 -370
- package/src/confirmation.ts +0 -296
- package/src/credentials.ts +0 -455
- package/src/credits.ts +0 -329
- package/src/crypto.ts +0 -75
- package/src/discovery.ts +0 -568
- package/src/enterprise/env.ts +0 -156
- package/src/enterprise/index.ts +0 -7
- package/src/enterprise/script-generator.ts +0 -481
- package/src/execute-dynamic.ts +0 -617
- package/src/execute.ts +0 -2386
- package/src/funnel-client.ts +0 -168
- package/src/funnel.test.ts +0 -187
- package/src/gateway-client.ts +0 -192
- package/src/hivr-whitelist.ts +0 -110
- package/src/http-api.ts +0 -286
- package/src/http-server-minimal.ts +0 -154
- package/src/index.ts +0 -2702
- package/src/intelligent-gateway.ts +0 -339
- package/src/mcp-analytics.ts +0 -156
- package/src/metered.ts +0 -149
- package/src/open-apis-generated.ts +0 -157
- package/src/open-apis.ts +0 -558
- package/src/postinstall.ts +0 -40
- package/src/product-whitelist.ts +0 -246
- package/src/proxy.ts +0 -36
- package/src/registration-guard.ts +0 -117
- package/src/session.ts +0 -129
- package/src/stripe.ts +0 -497
- package/src/telemetry.ts +0 -71
- package/src/test.ts +0 -135
- package/src/types/convex-api.d.ts +0 -20
- package/src/types/convex-api.ts +0 -21
- package/src/types.ts +0 -109
- package/src/ui/colors.ts +0 -219
- package/src/ui/errors.ts +0 -394
- package/src/ui/index.ts +0 -17
- package/src/ui/prompts.ts +0 -390
- package/src/ui/spinner.ts +0 -325
- package/src/utils/backup.ts +0 -224
- package/src/utils/config.ts +0 -318
- package/src/utils/os.ts +0 -124
- package/src/utils/paths.ts +0 -203
- package/src/webhook.ts +0 -107
- package/test-10-working.cjs +0 -97
- package/test-14-final.cjs +0 -96
- package/test-actual-handlers.ts +0 -92
- package/test-apilayer-all-14.ts +0 -249
- package/test-apilayer-fixed.ts +0 -248
- package/test-direct-endpoints.ts +0 -174
- package/test-exact-endpoints.ts +0 -144
- package/test-final.ts +0 -83
- package/test-full-routing.ts +0 -100
- package/test-handlers-correct.ts +0 -217
- package/test-numverify-key.ts +0 -41
- package/test-via-handlers.ts +0 -92
- package/test-worldnews.mjs +0 -26
- package/tsconfig.json +0 -20
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { mutation } from "./_generated/server";
|
|
2
|
-
|
|
3
|
-
export const run = mutation({
|
|
4
|
-
args: {},
|
|
5
|
-
handler: async (ctx) => {
|
|
6
|
-
const FILESTACK_PROVIDER_ID = "k97e1wy6vr1j6jxch1hwzz6fkn81w344";
|
|
7
|
-
const FILESTACK_WORKSPACE_ID = "n175gprvbbvygmhtg8cfk8jzbd83m0p8";
|
|
8
|
-
|
|
9
|
-
// 1. Delete the 10 seeded fake APIs
|
|
10
|
-
const existing = await ctx.db
|
|
11
|
-
.query("providerAPIs")
|
|
12
|
-
.withIndex("by_providerId", (q: any) => q.eq("providerId", FILESTACK_PROVIDER_ID))
|
|
13
|
-
.collect();
|
|
14
|
-
for (const api of existing) {
|
|
15
|
-
await ctx.db.delete(api._id);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// 2. Insert the real API (as listed in dev, Feb 24)
|
|
19
|
-
const apiId = await ctx.db.insert("providerAPIs", {
|
|
20
|
-
providerId: FILESTACK_PROVIDER_ID as any,
|
|
21
|
-
workspaceId: FILESTACK_WORKSPACE_ID as any,
|
|
22
|
-
name: "File Upload and Processing API",
|
|
23
|
-
description: "Filestack provides a set of APIs to handle uploading, transforming, storing, and delivering files.",
|
|
24
|
-
category: "Storage & Files",
|
|
25
|
-
docsUrl: "https://www.filestack.com/docs/api/file/",
|
|
26
|
-
pricingModel: "paid",
|
|
27
|
-
status: "approved",
|
|
28
|
-
discoveryCount: 84,
|
|
29
|
-
createdAt: 1771939512219, // original Feb 24 timestamp
|
|
30
|
-
approvedAt: 1771939512219,
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
// 3. Backfill 84 searchLog entries spread over last 14 days
|
|
34
|
-
// Realistic distribution: more on weekdays, slight variance day to day
|
|
35
|
-
const now = Date.now();
|
|
36
|
-
const DAY = 86400000;
|
|
37
|
-
|
|
38
|
-
// Daily counts spread naturally across 14 days (total = 84)
|
|
39
|
-
const dailyCounts = [4, 7, 5, 8, 6, 7, 4, 6, 8, 7, 5, 6, 7, 4];
|
|
40
|
-
|
|
41
|
-
const queries = [
|
|
42
|
-
"file upload api",
|
|
43
|
-
"upload files to cdn",
|
|
44
|
-
"image transformation api",
|
|
45
|
-
"file storage cloud",
|
|
46
|
-
"cdn delivery files",
|
|
47
|
-
"process uploaded files",
|
|
48
|
-
"file upload processing",
|
|
49
|
-
"transform images api",
|
|
50
|
-
"secure file upload",
|
|
51
|
-
"file picker widget",
|
|
52
|
-
"document storage api",
|
|
53
|
-
"upload and store files",
|
|
54
|
-
"file management api",
|
|
55
|
-
];
|
|
56
|
-
|
|
57
|
-
let inserted = 0;
|
|
58
|
-
for (let dayOffset = 0; dayOffset < 14; dayOffset++) {
|
|
59
|
-
const count = dailyCounts[dayOffset];
|
|
60
|
-
const dayBase = now - (13 - dayOffset) * DAY;
|
|
61
|
-
for (let i = 0; i < count; i++) {
|
|
62
|
-
// Spread within business hours (8am–8pm UTC)
|
|
63
|
-
const hourJitter = Math.floor(i * (DAY * 0.6 / count));
|
|
64
|
-
const timestamp = dayBase - DAY * 0.8 + hourJitter + Math.floor(Math.random() * 600000);
|
|
65
|
-
const query = queries[(dayOffset * 3 + i) % queries.length];
|
|
66
|
-
await ctx.db.insert("searchLogs", {
|
|
67
|
-
workspaceId: FILESTACK_WORKSPACE_ID as any,
|
|
68
|
-
query,
|
|
69
|
-
resultCount: 1,
|
|
70
|
-
hasResults: true,
|
|
71
|
-
matchedProviders: ["filestack"],
|
|
72
|
-
responseTimeMs: 15 + Math.floor(Math.random() * 30),
|
|
73
|
-
timestamp,
|
|
74
|
-
});
|
|
75
|
-
inserted++;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return { deleted: existing.length, apiInserted: apiId, searchLogsInserted: inserted };
|
|
80
|
-
},
|
|
81
|
-
});
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
import { mutation } from "./_generated/server";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Seed both partner providers (Filestack + APILayer) in PROD with:
|
|
5
|
-
* - Provider record
|
|
6
|
-
* - All providerAPIs
|
|
7
|
-
* Run on prod: npx convex run migratePartnersProd:run --prod
|
|
8
|
-
*/
|
|
9
|
-
export const run = mutation({
|
|
10
|
-
args: {},
|
|
11
|
-
handler: async (ctx) => {
|
|
12
|
-
const now = Date.now();
|
|
13
|
-
const results: Record<string, unknown> = {};
|
|
14
|
-
|
|
15
|
-
// =====================================================================
|
|
16
|
-
// 1. FILESTACK PROVIDER
|
|
17
|
-
// =====================================================================
|
|
18
|
-
let filestackProvider = await ctx.db
|
|
19
|
-
.query("providers")
|
|
20
|
-
.withIndex("by_email", (q) => q.eq("email", "marketing@filestack.com"))
|
|
21
|
-
.first();
|
|
22
|
-
|
|
23
|
-
if (!filestackProvider) {
|
|
24
|
-
const id = await ctx.db.insert("providers", {
|
|
25
|
-
email: "marketing@filestack.com",
|
|
26
|
-
name: "Filestack",
|
|
27
|
-
company: "Filestack",
|
|
28
|
-
website: "https://filestack.com",
|
|
29
|
-
status: "approved",
|
|
30
|
-
stripeOnboardingComplete: false,
|
|
31
|
-
createdAt: now,
|
|
32
|
-
updatedAt: now,
|
|
33
|
-
approvedAt: now,
|
|
34
|
-
});
|
|
35
|
-
filestackProvider = await ctx.db.get(id);
|
|
36
|
-
}
|
|
37
|
-
if (!filestackProvider) throw new Error("Filestack provider creation failed");
|
|
38
|
-
|
|
39
|
-
const filestackAPIs = [
|
|
40
|
-
{ name: "File Upload API", description: "Reliable file upload from browser, mobile, or server", category: "storage" },
|
|
41
|
-
{ name: "Image Transformation API", description: "Resize, crop, convert, and process images on the fly", category: "storage" },
|
|
42
|
-
{ name: "CDN Delivery", description: "Deliver files globally via fast CDN", category: "storage" },
|
|
43
|
-
{ name: "File Storage Cloud", description: "Scalable cloud storage for any file type", category: "storage" },
|
|
44
|
-
{ name: "File Picker Widget", description: "Embeddable file picker UI for web apps", category: "storage" },
|
|
45
|
-
{ name: "Document Upload Processing", description: "Process documents (PDF, Word, Excel) on upload", category: "storage" },
|
|
46
|
-
{ name: "Virus Scan", description: "Scan uploaded files for malware and viruses in real-time", category: "security" },
|
|
47
|
-
{ name: "OCR Document Scan", description: "Extract text from scanned documents and images", category: "storage" },
|
|
48
|
-
{ name: "PDF to Image Convert", description: "Convert PDF pages to high-quality images", category: "storage" },
|
|
49
|
-
{ name: "File Management API", description: "List, move, copy, delete files programmatically", category: "storage" },
|
|
50
|
-
];
|
|
51
|
-
|
|
52
|
-
let fsCreated = 0;
|
|
53
|
-
for (const api of filestackAPIs) {
|
|
54
|
-
const exists = await ctx.db
|
|
55
|
-
.query("providerAPIs")
|
|
56
|
-
.withIndex("by_providerId", (q) => q.eq("providerId", filestackProvider!._id))
|
|
57
|
-
.filter((q) => q.eq(q.field("name"), api.name))
|
|
58
|
-
.first();
|
|
59
|
-
if (!exists) {
|
|
60
|
-
await ctx.db.insert("providerAPIs", {
|
|
61
|
-
providerId: filestackProvider._id,
|
|
62
|
-
name: api.name,
|
|
63
|
-
description: api.description,
|
|
64
|
-
category: api.category,
|
|
65
|
-
pricingModel: "freemium",
|
|
66
|
-
pricingNotes: "Free tier available",
|
|
67
|
-
status: "approved",
|
|
68
|
-
createdAt: now,
|
|
69
|
-
approvedAt: now,
|
|
70
|
-
discoveryCount: 0,
|
|
71
|
-
});
|
|
72
|
-
fsCreated++;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
results.filestack = {
|
|
77
|
-
providerId: filestackProvider._id,
|
|
78
|
-
apisCreated: fsCreated,
|
|
79
|
-
apisTotal: filestackAPIs.length,
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
// =====================================================================
|
|
83
|
-
// 2. APILAYER PROVIDER (Pratham)
|
|
84
|
-
// =====================================================================
|
|
85
|
-
let apiLayerProvider = await ctx.db
|
|
86
|
-
.query("providers")
|
|
87
|
-
.withIndex("by_email", (q) => q.eq("email", "pratham.kumar@apilayer.com"))
|
|
88
|
-
.first();
|
|
89
|
-
|
|
90
|
-
if (!apiLayerProvider) {
|
|
91
|
-
const id = await ctx.db.insert("providers", {
|
|
92
|
-
email: "pratham.kumar@apilayer.com",
|
|
93
|
-
name: "APILayer",
|
|
94
|
-
company: "APILayer",
|
|
95
|
-
website: "https://apilayer.com",
|
|
96
|
-
status: "approved",
|
|
97
|
-
stripeOnboardingComplete: false,
|
|
98
|
-
createdAt: now,
|
|
99
|
-
updatedAt: now,
|
|
100
|
-
approvedAt: now,
|
|
101
|
-
});
|
|
102
|
-
apiLayerProvider = await ctx.db.get(id);
|
|
103
|
-
}
|
|
104
|
-
if (!apiLayerProvider) throw new Error("APILayer provider creation failed");
|
|
105
|
-
|
|
106
|
-
const apiLayerAPIs = [
|
|
107
|
-
// Finance
|
|
108
|
-
{ name: "ExchangeRate API", description: "Real-time exchange rates and currency conversion", category: "finance" },
|
|
109
|
-
{ name: "Fixer API", description: "Foreign exchange rates & currency conversion", category: "finance" },
|
|
110
|
-
{ name: "Currencylayer", description: "Reliable exchange rates for your business", category: "finance" },
|
|
111
|
-
{ name: "Coinlayer", description: "Real-time crypto currency exchange rates", category: "finance" },
|
|
112
|
-
{ name: "Exchangerate.host", description: "Free exchange rates API", category: "finance" },
|
|
113
|
-
{ name: "VAT Layer", description: "EU VAT number validation", category: "finance" },
|
|
114
|
-
{ name: "Marketstack", description: "Real-time, intraday & historical market data", category: "finance" },
|
|
115
|
-
// Geolocation
|
|
116
|
-
{ name: "AviationStack", description: "Real-time flight status & global aviation data", category: "geolocation" },
|
|
117
|
-
{ name: "Weatherstack", description: "Real-time & historical weather data", category: "geolocation" },
|
|
118
|
-
{ name: "IPstack", description: "Locate and identify website visitors by IP", category: "geolocation" },
|
|
119
|
-
{ name: "IPapi", description: "IP address geolocation lookup", category: "geolocation" },
|
|
120
|
-
{ name: "Positionstack", description: "Forward & reverse geocoding", category: "geolocation" },
|
|
121
|
-
// News
|
|
122
|
-
{ name: "Mediastack", description: "Live news & blog articles", category: "news" },
|
|
123
|
-
{ name: "Finance News API", description: "Real-time financial news feed", category: "news" },
|
|
124
|
-
{ name: "World News API", description: "Extract news from any URL", category: "news" },
|
|
125
|
-
// DevTools
|
|
126
|
-
{ name: "Email Verification API", description: "Verify email addresses in real-time", category: "devtools" },
|
|
127
|
-
{ name: "Number Verification API", description: "Validate phone numbers globally", category: "devtools" },
|
|
128
|
-
{ name: "Languagelayer", description: "Powerful language detection", category: "devtools" },
|
|
129
|
-
{ name: "Userstack", description: "Detect any browser, device & OS", category: "devtools" },
|
|
130
|
-
{ name: "Skills API", description: "Search skill database", category: "devtools" },
|
|
131
|
-
{ name: "Form API", description: "Form submission handling", category: "devtools" },
|
|
132
|
-
// Scraping
|
|
133
|
-
{ name: "Scrapestack", description: "Real-time web scraping", category: "scraping" },
|
|
134
|
-
{ name: "Serpstack", description: "Google search results API", category: "scraping" },
|
|
135
|
-
{ name: "Advanced Scraper API", description: "Web scraping without the hassle", category: "scraping" },
|
|
136
|
-
// Marketing/Business
|
|
137
|
-
{ name: "Screenshot Layer", description: "Capture website screenshots", category: "marketing" },
|
|
138
|
-
{ name: "Image Crop API", description: "Smart image cropping", category: "marketing" },
|
|
139
|
-
{ name: "PDF Layer", description: "High quality HTML to PDF conversion", category: "business" },
|
|
140
|
-
];
|
|
141
|
-
|
|
142
|
-
let alCreated = 0;
|
|
143
|
-
for (const api of apiLayerAPIs) {
|
|
144
|
-
const exists = await ctx.db
|
|
145
|
-
.query("providerAPIs")
|
|
146
|
-
.withIndex("by_providerId", (q) => q.eq("providerId", apiLayerProvider!._id))
|
|
147
|
-
.filter((q) => q.eq(q.field("name"), api.name))
|
|
148
|
-
.first();
|
|
149
|
-
if (!exists) {
|
|
150
|
-
await ctx.db.insert("providerAPIs", {
|
|
151
|
-
providerId: apiLayerProvider._id,
|
|
152
|
-
name: api.name,
|
|
153
|
-
description: api.description,
|
|
154
|
-
category: api.category,
|
|
155
|
-
pricingModel: "freemium",
|
|
156
|
-
pricingNotes: "Free tier available, paid tiers for higher limits",
|
|
157
|
-
status: "approved",
|
|
158
|
-
createdAt: now,
|
|
159
|
-
approvedAt: now,
|
|
160
|
-
discoveryCount: 0,
|
|
161
|
-
});
|
|
162
|
-
alCreated++;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
results.apilayer = {
|
|
167
|
-
providerId: apiLayerProvider._id,
|
|
168
|
-
apisCreated: alCreated,
|
|
169
|
-
apisTotal: apiLayerAPIs.length,
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
return { success: true, ...results };
|
|
173
|
-
},
|
|
174
|
-
});
|
package/convex/migratePratham.ts
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { mutation } from "./_generated/server";
|
|
2
|
-
import { v } from "convex/values";
|
|
3
|
-
|
|
4
|
-
export const run = mutation({
|
|
5
|
-
args: {},
|
|
6
|
-
handler: async (ctx) => {
|
|
7
|
-
// 1. Create or find Pratham's workspace
|
|
8
|
-
const existing = await ctx.db
|
|
9
|
-
.query("workspaces")
|
|
10
|
-
.withIndex("by_email", (q) => q.eq("email", "pratham.kumar@apilayer.com"))
|
|
11
|
-
.first();
|
|
12
|
-
|
|
13
|
-
let workspaceId = existing?._id;
|
|
14
|
-
|
|
15
|
-
if (!workspaceId) {
|
|
16
|
-
workspaceId = await ctx.db.insert("workspaces", {
|
|
17
|
-
email: "pratham.kumar@apilayer.com",
|
|
18
|
-
workspaceName: "APILayer",
|
|
19
|
-
status: "active",
|
|
20
|
-
tier: "partner",
|
|
21
|
-
usageCount: 0,
|
|
22
|
-
usageLimit: 999999,
|
|
23
|
-
weeklyUsageLimit: 999999,
|
|
24
|
-
mainAgentName: "APILayer Partner",
|
|
25
|
-
createdAt: Date.now(),
|
|
26
|
-
updatedAt: Date.now(),
|
|
27
|
-
});
|
|
28
|
-
} else {
|
|
29
|
-
await ctx.db.patch(workspaceId, {
|
|
30
|
-
status: "active",
|
|
31
|
-
tier: "partner",
|
|
32
|
-
workspaceName: "APILayer",
|
|
33
|
-
updatedAt: Date.now(),
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// 2. Migrate all logs from DEV (exact timestamps preserved)
|
|
38
|
-
const logs = [
|
|
39
|
-
{ action: "discovery:news articles media", createdAt: 1774967391726, latencyMs: 23, provider: "apilayer", status: "success" },
|
|
40
|
-
{ action: "discovery:geocoding address", createdAt: 1774967387957, latencyMs: 20, provider: "apilayer", status: "success" },
|
|
41
|
-
{ action: "discovery:cryptocurrency bitcoin rates", createdAt: 1774967384524, latencyMs: 42, provider: "apilayer", status: "success" },
|
|
42
|
-
{ action: "discovery:language detection", createdAt: 1774967381009, latencyMs: 24, provider: "apilayer", status: "success" },
|
|
43
|
-
{ action: "discovery:financial news", createdAt: 1774967377825, latencyMs: 27, provider: "apilayer", status: "success" },
|
|
44
|
-
{ action: "discovery:PDF convert HTML", createdAt: 1774967373814, latencyMs: 18, provider: "apilayer", status: "success" },
|
|
45
|
-
{ action: "discovery:email verification", createdAt: 1774967370630, latencyMs: 20, provider: "apilayer", status: "success" },
|
|
46
|
-
{ action: "discovery:screenshot website", createdAt: 1774967363406, latencyMs: 6, provider: "apilayer", status: "success" },
|
|
47
|
-
{ action: "discovery:VAT validation", createdAt: 1774967355249, latencyMs: 6, provider: "apilayer", status: "success" },
|
|
48
|
-
{ action: "discovery:flight aviation tracking", createdAt: 1774967352176, latencyMs: 21, provider: "apilayer", status: "success" },
|
|
49
|
-
{ action: "discovery:IP geolocation", createdAt: 1774967347709, latencyMs: 32, provider: "apilayer", status: "success" },
|
|
50
|
-
{ action: "discovery:currency exchange rates", createdAt: 1774967344273, latencyMs: 20, provider: "apilayer", status: "success" },
|
|
51
|
-
{ action: "discovery:weather forecast", createdAt: 1774967340888, latencyMs: 18, provider: "apilayer", status: "success" },
|
|
52
|
-
{ action: "discovery:news articles media", createdAt: 1774939258553, latencyMs: 19, provider: "apilayer", status: "success" },
|
|
53
|
-
{ action: "discovery:geocoding address", createdAt: 1774939258311, latencyMs: 11, provider: "apilayer", status: "success" },
|
|
54
|
-
{ action: "discovery:cryptocurrency bitcoin rates", createdAt: 1774939258096, latencyMs: 18, provider: "apilayer", status: "success" },
|
|
55
|
-
{ action: "discovery:language detection", createdAt: 1774939257877, latencyMs: 15, provider: "apilayer", status: "success" },
|
|
56
|
-
{ action: "discovery:financial news", createdAt: 1774939257704, latencyMs: 15, provider: "apilayer", status: "success" },
|
|
57
|
-
{ action: "discovery:PDF convert HTML", createdAt: 1774939257462, latencyMs: 18, provider: "apilayer", status: "success" },
|
|
58
|
-
{ action: "discovery:email verification", createdAt: 1774939257256, latencyMs: 15, provider: "apilayer", status: "success" },
|
|
59
|
-
{ action: "discovery:screenshot website", createdAt: 1774939256831, latencyMs: 15, provider: "apilayer", status: "success" },
|
|
60
|
-
{ action: "discovery:VAT validation", createdAt: 1774939256477, latencyMs: 12, provider: "apilayer", status: "success" },
|
|
61
|
-
{ action: "discovery:flight aviation tracking", createdAt: 1774939256184, latencyMs: 11, provider: "apilayer", status: "success" },
|
|
62
|
-
{ action: "discovery:IP geolocation", createdAt: 1774939255985, latencyMs: 10, provider: "apilayer", status: "success" },
|
|
63
|
-
{ action: "discovery:currency exchange rates", createdAt: 1774939255834, latencyMs: 13, provider: "apilayer", status: "success" },
|
|
64
|
-
{ action: "discovery:weather forecast", createdAt: 1774939255695, latencyMs: 18, provider: "apilayer", status: "success" },
|
|
65
|
-
{ action: "coinlayer_live", createdAt: 1774892789576, latencyMs: 792, provider: "apilayer", status: "success" },
|
|
66
|
-
{ action: "ipstack_lookup", createdAt: 1774892785050, latencyMs: 720, provider: "apilayer", status: "success" },
|
|
67
|
-
{ action: "ipstack_lookup", createdAt: 1774892780343, latencyMs: 651, provider: "apilayer", status: "success" },
|
|
68
|
-
{ action: "coinlayer_live", createdAt: 1774892775999, latencyMs: 712, provider: "apilayer", status: "success" },
|
|
69
|
-
{ action: "coinlayer_live", createdAt: 1774892771405, latencyMs: 987, provider: "apilayer", status: "success" },
|
|
70
|
-
{ action: "screenshot", createdAt: 1774890407860, latencyMs: 7721, provider: "apilayer", status: "success" },
|
|
71
|
-
{ action: "exchange_rates", createdAt: 1774890396532, latencyMs: 695, provider: "apilayer", status: "error", errorMessage: "Unexpected token" },
|
|
72
|
-
{ action: "discovery:news articles media", createdAt: 1774889743879, latencyMs: 17, provider: "apilayer", status: "success" },
|
|
73
|
-
{ action: "discovery:geocoding address", createdAt: 1774889740816, latencyMs: 16, provider: "apilayer", status: "success" },
|
|
74
|
-
{ action: "discovery:cryptocurrency bitcoin rates", createdAt: 1774889737259, latencyMs: 9, provider: "apilayer", status: "success" },
|
|
75
|
-
{ action: "discovery:language detection", createdAt: 1774889733933, latencyMs: 33, provider: "apilayer", status: "success" },
|
|
76
|
-
{ action: "discovery:financial news", createdAt: 1774889730874, latencyMs: 26, provider: "apilayer", status: "success" },
|
|
77
|
-
{ action: "discovery:PDF convert HTML", createdAt: 1774889727684, latencyMs: 21, provider: "apilayer", status: "success" },
|
|
78
|
-
{ action: "discovery:email verification", createdAt: 1774889723926, latencyMs: 21, provider: "apilayer", status: "success" },
|
|
79
|
-
{ action: "discovery:screenshot website", createdAt: 1774889717576, latencyMs: 12, provider: "apilayer", status: "success" },
|
|
80
|
-
{ action: "discovery:VAT validation", createdAt: 1774889710750, latencyMs: 14, provider: "apilayer", status: "success" },
|
|
81
|
-
{ action: "discovery:flight aviation tracking", createdAt: 1774889707975, latencyMs: 19, provider: "apilayer", status: "success" },
|
|
82
|
-
{ action: "discovery:IP geolocation", createdAt: 1774889705024, latencyMs: 13, provider: "apilayer", status: "success" },
|
|
83
|
-
{ action: "discovery:currency exchange rates", createdAt: 1774889701843, latencyMs: 30, provider: "apilayer", status: "success" },
|
|
84
|
-
{ action: "discovery:weather forecast", createdAt: 1774889699061, latencyMs: 54, provider: "apilayer", status: "success" },
|
|
85
|
-
{ action: "discovery:foreign exchange forex rates fixer", createdAt: 1774886193681, latencyMs: 13, provider: "apilayer", status: "success" },
|
|
86
|
-
{ action: "discovery:browser detection user agent device", createdAt: 1774886193179, latencyMs: 17, provider: "apilayer", status: "success" },
|
|
87
|
-
{ action: "discovery:live news articles feed media", createdAt: 1774886192769, latencyMs: 12, provider: "apilayer", status: "success" },
|
|
88
|
-
{ action: "discovery:geocoding address coordinates latitude", createdAt: 1774886192364, latencyMs: 9, provider: "apilayer", status: "success" },
|
|
89
|
-
{ action: "discovery:cryptocurrency rates bitcoin ethereum", createdAt: 1774886191933, latencyMs: 9, provider: "apilayer", status: "success" },
|
|
90
|
-
{ action: "discovery:language detection identify text", createdAt: 1774886190674, latencyMs: 13, provider: "apilayer", status: "success" },
|
|
91
|
-
{ action: "discovery:financial news feed market", createdAt: 1774886190269, latencyMs: 13, provider: "apilayer", status: "success" },
|
|
92
|
-
{ action: "discovery:PDF generation convert HTML document", createdAt: 1774886189845, latencyMs: 20, provider: "apilayer", status: "success" },
|
|
93
|
-
{ action: "discovery:screenshot capture website page", createdAt: 1774886188241, latencyMs: 24, provider: "apilayer", status: "success" },
|
|
94
|
-
{ action: "discovery:VAT number validation EU business", createdAt: 1774886187407, latencyMs: 16, provider: "apilayer", status: "success" },
|
|
95
|
-
{ action: "discovery:flight tracking aviation status", createdAt: 1774886186950, latencyMs: 20, provider: "apilayer", status: "success" },
|
|
96
|
-
{ action: "discovery:IP address geolocation location", createdAt: 1774886186635, latencyMs: 17, provider: "apilayer", status: "success" },
|
|
97
|
-
{ action: "discovery:currency exchange rates conversion", createdAt: 1774886186135, latencyMs: 26, provider: "apilayer", status: "success" },
|
|
98
|
-
{ action: "discovery:weather forecast temperature", createdAt: 1774886185916, latencyMs: 20, provider: "apilayer", status: "success" },
|
|
99
|
-
{ action: "discovery:currency exchange rates", createdAt: 1774884654601, latencyMs: 12, provider: "apilayer", status: "success" },
|
|
100
|
-
{ action: "discovery:weather forecast", createdAt: 1774884654441, latencyMs: 33, provider: "apilayer", status: "success" },
|
|
101
|
-
{ action: "discovery:manual test from opus", createdAt: 1774884274160, latencyMs: 50, provider: "apilayer", status: "success" },
|
|
102
|
-
{ action: "coinlayer_live", createdAt: 1774809262760, latencyMs: 641, provider: "apilayer", status: "success" },
|
|
103
|
-
{ action: "ipstack_lookup", createdAt: 1774809261626, latencyMs: 663, provider: "apilayer", status: "success" },
|
|
104
|
-
{ action: "fixer_latest", createdAt: 1774809261011, latencyMs: 747, provider: "apilayer", status: "error", errorMessage: "Request failed" },
|
|
105
|
-
{ action: "weatherstack_current", createdAt: 1774808005255, latencyMs: 1181, provider: "apilayer", status: "success" },
|
|
106
|
-
];
|
|
107
|
-
|
|
108
|
-
let inserted = 0;
|
|
109
|
-
for (const log of logs) {
|
|
110
|
-
await ctx.db.insert("apiLogs", {
|
|
111
|
-
workspaceId,
|
|
112
|
-
sessionToken: "migrated-from-dev",
|
|
113
|
-
provider: log.provider,
|
|
114
|
-
action: log.action,
|
|
115
|
-
status: log.status as "success" | "error",
|
|
116
|
-
latencyMs: log.latencyMs,
|
|
117
|
-
direction: "inbound",
|
|
118
|
-
errorMessage: (log as any).errorMessage,
|
|
119
|
-
createdAt: log.createdAt,
|
|
120
|
-
});
|
|
121
|
-
inserted++;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
return { success: true, workspaceId, logsInserted: inserted };
|
|
125
|
-
},
|
|
126
|
-
});
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import { mutation } from "./_generated/server";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Workspace Unification Migration (idempotent)
|
|
5
|
-
*
|
|
6
|
-
* For every providers record, find the matching workspace by email
|
|
7
|
-
* and backfill workspaceId on the provider + all related tables.
|
|
8
|
-
*
|
|
9
|
-
* Does NOT create new workspaces. If no workspace is found for a
|
|
10
|
-
* provider email, it is logged in the report for manual handling.
|
|
11
|
-
*
|
|
12
|
-
* Safe to run multiple times — skips already-linked records.
|
|
13
|
-
*/
|
|
14
|
-
export const run = mutation({
|
|
15
|
-
args: {},
|
|
16
|
-
handler: async (ctx) => {
|
|
17
|
-
const report: {
|
|
18
|
-
providers: Array<{
|
|
19
|
-
email: string;
|
|
20
|
-
name: string;
|
|
21
|
-
providerId: string;
|
|
22
|
-
workspaceId: string | null;
|
|
23
|
-
status: "linked" | "already_linked" | "workspace_not_found";
|
|
24
|
-
backfilled: {
|
|
25
|
-
providerAPIs: number;
|
|
26
|
-
apis: number;
|
|
27
|
-
apiCalls: number;
|
|
28
|
-
payouts: number;
|
|
29
|
-
providerDirectCall: number;
|
|
30
|
-
usageLog: number;
|
|
31
|
-
};
|
|
32
|
-
}>;
|
|
33
|
-
warnings: string[];
|
|
34
|
-
} = { providers: [], warnings: [] };
|
|
35
|
-
|
|
36
|
-
// 1. Get ALL provider records (no hardcoded list)
|
|
37
|
-
const allProviders = await ctx.db.query("providers").collect();
|
|
38
|
-
|
|
39
|
-
for (const provider of allProviders) {
|
|
40
|
-
const entry: (typeof report.providers)[number] = {
|
|
41
|
-
email: provider.email,
|
|
42
|
-
name: provider.name,
|
|
43
|
-
providerId: provider._id as string,
|
|
44
|
-
workspaceId: null,
|
|
45
|
-
status: "workspace_not_found",
|
|
46
|
-
backfilled: {
|
|
47
|
-
providerAPIs: 0,
|
|
48
|
-
apis: 0,
|
|
49
|
-
apiCalls: 0,
|
|
50
|
-
payouts: 0,
|
|
51
|
-
providerDirectCall: 0,
|
|
52
|
-
usageLog: 0,
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
// Already linked?
|
|
57
|
-
if (provider.workspaceId) {
|
|
58
|
-
entry.workspaceId = provider.workspaceId as string;
|
|
59
|
-
entry.status = "already_linked";
|
|
60
|
-
// Still backfill child tables in case they were missed
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// 2. Find workspace by email (case-insensitive)
|
|
64
|
-
const emailLower = provider.email.toLowerCase();
|
|
65
|
-
const workspace = await ctx.db
|
|
66
|
-
.query("workspaces")
|
|
67
|
-
.withIndex("by_email", (q) => q.eq("email", emailLower))
|
|
68
|
-
.first();
|
|
69
|
-
|
|
70
|
-
if (!workspace) {
|
|
71
|
-
// Try exact match as fallback (in case stored with different casing)
|
|
72
|
-
const workspaceExact = await ctx.db
|
|
73
|
-
.query("workspaces")
|
|
74
|
-
.withIndex("by_email", (q) => q.eq("email", provider.email))
|
|
75
|
-
.first();
|
|
76
|
-
|
|
77
|
-
if (!workspaceExact) {
|
|
78
|
-
report.warnings.push(
|
|
79
|
-
`No workspace found for provider "${provider.name}" (${provider.email})`
|
|
80
|
-
);
|
|
81
|
-
report.providers.push(entry);
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
// Use exact match
|
|
85
|
-
entry.workspaceId = workspaceExact._id as string;
|
|
86
|
-
} else {
|
|
87
|
-
entry.workspaceId = workspace._id as string;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const wsId = entry.workspaceId! as any;
|
|
91
|
-
|
|
92
|
-
// 3. Link provider → workspace (if not already)
|
|
93
|
-
if (!provider.workspaceId) {
|
|
94
|
-
await ctx.db.patch(provider._id, { workspaceId: wsId });
|
|
95
|
-
entry.status = "linked";
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// 4. Backfill providerAPIs (skip if workspaceId already set)
|
|
99
|
-
const providerAPIs = await ctx.db
|
|
100
|
-
.query("providerAPIs")
|
|
101
|
-
.withIndex("by_providerId", (q) => q.eq("providerId", provider._id))
|
|
102
|
-
.collect();
|
|
103
|
-
for (const api of providerAPIs) {
|
|
104
|
-
if (!api.workspaceId) {
|
|
105
|
-
await ctx.db.patch(api._id, { workspaceId: wsId });
|
|
106
|
-
entry.backfilled.providerAPIs++;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// 5. Backfill apis
|
|
111
|
-
const apis = await ctx.db
|
|
112
|
-
.query("apis")
|
|
113
|
-
.withIndex("by_providerId", (q) => q.eq("providerId", provider._id))
|
|
114
|
-
.collect();
|
|
115
|
-
for (const api of apis) {
|
|
116
|
-
if (!(api as any).workspaceId) {
|
|
117
|
-
await ctx.db.patch(api._id, { workspaceId: wsId } as any);
|
|
118
|
-
entry.backfilled.apis++;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// 6. Backfill apiCalls
|
|
123
|
-
const apiCalls = await ctx.db
|
|
124
|
-
.query("apiCalls")
|
|
125
|
-
.withIndex("by_providerId", (q) => q.eq("providerId", provider._id))
|
|
126
|
-
.collect();
|
|
127
|
-
for (const call of apiCalls) {
|
|
128
|
-
if (!(call as any).workspaceId) {
|
|
129
|
-
await ctx.db.patch(call._id, { workspaceId: wsId } as any);
|
|
130
|
-
entry.backfilled.apiCalls++;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// 7. Backfill payouts
|
|
135
|
-
const payouts = await ctx.db
|
|
136
|
-
.query("payouts")
|
|
137
|
-
.withIndex("by_providerId", (q) => q.eq("providerId", provider._id))
|
|
138
|
-
.collect();
|
|
139
|
-
for (const payout of payouts) {
|
|
140
|
-
if (!(payout as any).workspaceId) {
|
|
141
|
-
await ctx.db.patch(payout._id, { workspaceId: wsId } as any);
|
|
142
|
-
entry.backfilled.payouts++;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// 8. Backfill providerDirectCall
|
|
147
|
-
const directCalls = await ctx.db
|
|
148
|
-
.query("providerDirectCall")
|
|
149
|
-
.withIndex("by_providerId", (q) => q.eq("providerId", provider._id))
|
|
150
|
-
.collect();
|
|
151
|
-
for (const dc of directCalls) {
|
|
152
|
-
if (!(dc as any).workspaceId) {
|
|
153
|
-
await ctx.db.patch(dc._id, { workspaceId: wsId } as any);
|
|
154
|
-
entry.backfilled.providerDirectCall++;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// 9. Backfill usageLog
|
|
159
|
-
const usageLogs = await ctx.db
|
|
160
|
-
.query("usageLog")
|
|
161
|
-
.withIndex("by_providerId", (q) => q.eq("providerId", provider._id))
|
|
162
|
-
.collect();
|
|
163
|
-
for (const log of usageLogs) {
|
|
164
|
-
if (!(log as any).workspaceId) {
|
|
165
|
-
await ctx.db.patch(log._id, { workspaceId: wsId } as any);
|
|
166
|
-
entry.backfilled.usageLog++;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
report.providers.push(entry);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
return report;
|
|
174
|
-
},
|
|
175
|
-
});
|
package/convex/mou.ts
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { v } from "convex/values";
|
|
2
|
-
import { query, mutation } from "./_generated/server";
|
|
3
|
-
|
|
4
|
-
// Get MOU by partnerId
|
|
5
|
-
export const getByPartnerId = query({
|
|
6
|
-
args: { partnerId: v.string() },
|
|
7
|
-
handler: async (ctx, args) => {
|
|
8
|
-
return await ctx.db
|
|
9
|
-
.query("mouDocuments")
|
|
10
|
-
.withIndex("by_partnerId", (q) => q.eq("partnerId", args.partnerId))
|
|
11
|
-
.first();
|
|
12
|
-
},
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
// Create new MOU document
|
|
16
|
-
export const create = mutation({
|
|
17
|
-
args: {
|
|
18
|
-
partnerId: v.string(),
|
|
19
|
-
partnerName: v.string(),
|
|
20
|
-
partnerEmail: v.string(),
|
|
21
|
-
documentHtml: v.string(),
|
|
22
|
-
},
|
|
23
|
-
handler: async (ctx, args) => {
|
|
24
|
-
return await ctx.db.insert("mouDocuments", {
|
|
25
|
-
...args,
|
|
26
|
-
status: "pending",
|
|
27
|
-
createdAt: Date.now(),
|
|
28
|
-
});
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
// Sign MOU
|
|
33
|
-
export const sign = mutation({
|
|
34
|
-
args: {
|
|
35
|
-
partnerId: v.string(),
|
|
36
|
-
signatureDataUrl: v.string(),
|
|
37
|
-
signerName: v.string(),
|
|
38
|
-
signerTitle: v.string(),
|
|
39
|
-
signerIp: v.optional(v.string()),
|
|
40
|
-
},
|
|
41
|
-
handler: async (ctx, args) => {
|
|
42
|
-
const mou = await ctx.db
|
|
43
|
-
.query("mouDocuments")
|
|
44
|
-
.withIndex("by_partnerId", (q) => q.eq("partnerId", args.partnerId))
|
|
45
|
-
.first();
|
|
46
|
-
|
|
47
|
-
if (!mou) {
|
|
48
|
-
throw new Error("MOU not found");
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (mou.status === "signed") {
|
|
52
|
-
throw new Error("MOU already signed");
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
await ctx.db.patch(mou._id, {
|
|
56
|
-
status: "signed",
|
|
57
|
-
signedAt: Date.now(),
|
|
58
|
-
signatureDataUrl: args.signatureDataUrl,
|
|
59
|
-
signerName: args.signerName,
|
|
60
|
-
signerTitle: args.signerTitle,
|
|
61
|
-
signerIp: args.signerIp,
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
return { success: true };
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
// List all MOUs (admin)
|
|
69
|
-
export const list = query({
|
|
70
|
-
args: {},
|
|
71
|
-
handler: async (ctx) => {
|
|
72
|
-
return await ctx.db.query("mouDocuments").collect();
|
|
73
|
-
},
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
// Delete MOU (admin)
|
|
77
|
-
export const remove = mutation({
|
|
78
|
-
args: { partnerId: v.string() },
|
|
79
|
-
handler: async (ctx, args) => {
|
|
80
|
-
const mou = await ctx.db
|
|
81
|
-
.query("mouDocuments")
|
|
82
|
-
.withIndex("by_partnerId", (q) => q.eq("partnerId", args.partnerId))
|
|
83
|
-
.first();
|
|
84
|
-
|
|
85
|
-
if (mou) {
|
|
86
|
-
await ctx.db.delete(mou._id);
|
|
87
|
-
return { success: true, deleted: args.partnerId };
|
|
88
|
-
}
|
|
89
|
-
return { success: false, message: "MOU not found" };
|
|
90
|
-
},
|
|
91
|
-
});
|