@nordsym/apiclaw 1.7.2 → 1.7.4
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/convex/_generated/api.d.ts +115 -0
- package/convex/_generated/api.js +23 -0
- package/convex/_generated/dataModel.d.ts +60 -0
- package/convex/_generated/server.d.ts +143 -0
- package/convex/_generated/server.js +93 -0
- package/convex/adminActivate.d.ts +3 -0
- package/convex/adminActivate.d.ts.map +1 -0
- package/convex/adminActivate.js +47 -0
- package/convex/adminActivate.js.map +1 -0
- package/convex/adminActivate.ts +54 -0
- package/convex/adminStats.d.ts +3 -0
- package/convex/adminStats.d.ts.map +1 -0
- package/convex/adminStats.js +42 -0
- package/convex/adminStats.js.map +1 -0
- package/convex/adminStats.ts +44 -0
- package/convex/agents.d.ts +76 -0
- package/convex/agents.d.ts.map +1 -0
- package/convex/agents.js +699 -0
- package/convex/agents.js.map +1 -0
- package/convex/agents.ts +814 -0
- package/convex/analytics.d.ts +5 -0
- package/convex/analytics.d.ts.map +1 -0
- package/convex/analytics.js +166 -0
- package/convex/analytics.js.map +1 -0
- package/convex/analytics.ts +186 -0
- package/convex/billing.d.ts +88 -0
- package/convex/billing.d.ts.map +1 -0
- package/convex/billing.js +655 -0
- package/convex/billing.js.map +1 -0
- package/convex/billing.ts +791 -0
- package/convex/capabilities.d.ts +9 -0
- package/convex/capabilities.d.ts.map +1 -0
- package/convex/capabilities.js +145 -0
- package/convex/capabilities.js.map +1 -0
- package/convex/capabilities.ts +157 -0
- package/convex/chains.d.ts +68 -0
- package/convex/chains.d.ts.map +1 -0
- package/convex/chains.js +1105 -0
- package/convex/chains.js.map +1 -0
- package/convex/chains.ts +1318 -0
- package/convex/credits.d.ts +25 -0
- package/convex/credits.d.ts.map +1 -0
- package/convex/credits.js +186 -0
- package/convex/credits.js.map +1 -0
- package/convex/credits.ts +211 -0
- package/convex/crons.d.ts +3 -0
- package/convex/crons.d.ts.map +1 -0
- package/convex/crons.js +17 -0
- package/convex/crons.js.map +1 -0
- package/convex/crons.ts +28 -0
- package/convex/directCall.d.ts +72 -0
- package/convex/directCall.d.ts.map +1 -0
- package/convex/directCall.js +627 -0
- package/convex/directCall.js.map +1 -0
- package/convex/directCall.ts +678 -0
- package/convex/earnProgress.d.ts +58 -0
- package/convex/earnProgress.d.ts.map +1 -0
- package/convex/earnProgress.js +649 -0
- package/convex/earnProgress.js.map +1 -0
- package/convex/earnProgress.ts +753 -0
- package/convex/email.d.ts +14 -0
- package/convex/email.d.ts.map +1 -0
- package/convex/email.js +300 -0
- package/convex/email.js.map +1 -0
- package/convex/email.ts +329 -0
- package/convex/feedback.d.ts +7 -0
- package/convex/feedback.d.ts.map +1 -0
- package/convex/feedback.js +227 -0
- package/convex/feedback.js.map +1 -0
- package/convex/feedback.ts +265 -0
- package/convex/http.d.ts +3 -0
- package/convex/http.d.ts.map +1 -0
- package/convex/http.js +1405 -0
- package/convex/http.js.map +1 -0
- package/convex/http.ts +1577 -0
- package/convex/inbound.d.ts +2 -0
- package/convex/inbound.d.ts.map +1 -0
- package/convex/inbound.js +32 -0
- package/convex/inbound.js.map +1 -0
- package/convex/inbound.ts +32 -0
- package/convex/logs.d.ts +38 -0
- package/convex/logs.d.ts.map +1 -0
- package/convex/logs.js +487 -0
- package/convex/logs.js.map +1 -0
- package/convex/logs.ts +550 -0
- package/convex/mou.d.ts +6 -0
- package/convex/mou.d.ts.map +1 -0
- package/convex/mou.js +82 -0
- package/convex/mou.js.map +1 -0
- package/convex/mou.ts +91 -0
- package/convex/providerKeys.d.ts +31 -0
- package/convex/providerKeys.d.ts.map +1 -0
- package/convex/providerKeys.js +257 -0
- package/convex/providerKeys.js.map +1 -0
- package/convex/providerKeys.ts +289 -0
- package/convex/providers.d.ts +32 -0
- package/convex/providers.d.ts.map +1 -0
- package/convex/providers.js +814 -0
- package/convex/providers.js.map +1 -0
- package/convex/providers.ts +909 -0
- package/convex/purchases.d.ts +7 -0
- package/convex/purchases.d.ts.map +1 -0
- package/convex/purchases.js +157 -0
- package/convex/purchases.js.map +1 -0
- package/convex/purchases.ts +183 -0
- package/convex/ratelimit.d.ts +4 -0
- package/convex/ratelimit.d.ts.map +1 -0
- package/convex/ratelimit.js +91 -0
- package/convex/ratelimit.js.map +1 -0
- package/convex/ratelimit.ts +104 -0
- package/convex/schema.ts +802 -0
- package/convex/searchLogs.d.ts +4 -0
- package/convex/searchLogs.d.ts.map +1 -0
- package/convex/searchLogs.js +129 -0
- package/convex/searchLogs.js.map +1 -0
- package/convex/searchLogs.ts +146 -0
- package/convex/seedAPILayerAPIs.d.ts +7 -0
- package/convex/seedAPILayerAPIs.d.ts.map +1 -0
- package/convex/seedAPILayerAPIs.js +177 -0
- package/convex/seedAPILayerAPIs.js.map +1 -0
- package/convex/seedAPILayerAPIs.ts +191 -0
- package/convex/seedDirectCallConfigs.d.ts +2 -0
- package/convex/seedDirectCallConfigs.d.ts.map +1 -0
- package/convex/seedDirectCallConfigs.js +324 -0
- package/convex/seedDirectCallConfigs.js.map +1 -0
- package/convex/seedDirectCallConfigs.ts +336 -0
- package/convex/seedPratham.d.ts +6 -0
- package/convex/seedPratham.d.ts.map +1 -0
- package/convex/seedPratham.js +150 -0
- package/convex/seedPratham.js.map +1 -0
- package/convex/seedPratham.ts +161 -0
- package/convex/spendAlerts.d.ts +36 -0
- package/convex/spendAlerts.d.ts.map +1 -0
- package/convex/spendAlerts.js +380 -0
- package/convex/spendAlerts.js.map +1 -0
- package/convex/spendAlerts.ts +442 -0
- package/convex/stripeActions.d.ts +19 -0
- package/convex/stripeActions.d.ts.map +1 -0
- package/convex/stripeActions.js +411 -0
- package/convex/stripeActions.js.map +1 -0
- package/convex/stripeActions.ts +512 -0
- package/convex/teams.d.ts +21 -0
- package/convex/teams.d.ts.map +1 -0
- package/convex/teams.js +215 -0
- package/convex/teams.js.map +1 -0
- package/convex/teams.ts +243 -0
- package/convex/telemetry.d.ts +4 -0
- package/convex/telemetry.d.ts.map +1 -0
- package/convex/telemetry.js +74 -0
- package/convex/telemetry.js.map +1 -0
- package/convex/telemetry.ts +81 -0
- package/convex/tsconfig.json +25 -0
- package/convex/updateAPIStatus.d.ts +6 -0
- package/convex/updateAPIStatus.d.ts.map +1 -0
- package/convex/updateAPIStatus.js +40 -0
- package/convex/updateAPIStatus.js.map +1 -0
- package/convex/updateAPIStatus.ts +45 -0
- package/convex/usage.d.ts +27 -0
- package/convex/usage.d.ts.map +1 -0
- package/convex/usage.js +229 -0
- package/convex/usage.js.map +1 -0
- package/convex/usage.ts +260 -0
- package/convex/waitlist.d.ts +4 -0
- package/convex/waitlist.d.ts.map +1 -0
- package/convex/waitlist.js +49 -0
- package/convex/waitlist.js.map +1 -0
- package/convex/waitlist.ts +55 -0
- package/convex/webhooks.d.ts +12 -0
- package/convex/webhooks.d.ts.map +1 -0
- package/convex/webhooks.js +410 -0
- package/convex/webhooks.js.map +1 -0
- package/convex/webhooks.ts +494 -0
- package/convex/workspaces.d.ts +31 -0
- package/convex/workspaces.d.ts.map +1 -0
- package/convex/workspaces.js +975 -0
- package/convex/workspaces.js.map +1 -0
- package/convex/workspaces.ts +1130 -0
- package/dist/bin.js +0 -0
- package/dist/capability-router.js +1 -1
- package/dist/capability-router.js.map +1 -1
- package/dist/execute.d.ts +2 -0
- package/dist/execute.d.ts.map +1 -1
- package/dist/execute.js +18 -4
- package/dist/execute.js.map +1 -1
- package/dist/http-api.js +1 -1
- package/dist/http-api.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp-analytics.d.ts +32 -0
- package/dist/mcp-analytics.d.ts.map +1 -0
- package/dist/mcp-analytics.js +130 -0
- package/dist/mcp-analytics.js.map +1 -0
- package/package.json +1 -1
- package/dist/chain-types.d.ts +0 -187
- package/dist/chain-types.d.ts.map +0 -1
- package/dist/chain-types.js +0 -33
- package/dist/chain-types.js.map +0 -1
- package/dist/registry/apis.json.bak +0 -248811
- package/dist/src/bin.js +0 -17
- package/dist/src/capability-router.js +0 -240
- package/dist/src/chainExecutor.js +0 -451
- package/dist/src/chainResolver.js +0 -518
- package/dist/src/cli/commands/doctor.js +0 -324
- package/dist/src/cli/commands/mcp-install.js +0 -255
- package/dist/src/cli/commands/restore.js +0 -259
- package/dist/src/cli/commands/setup.js +0 -205
- package/dist/src/cli/commands/uninstall.js +0 -188
- package/dist/src/cli/index.js +0 -111
- package/dist/src/cli.js +0 -302
- package/dist/src/confirmation.js +0 -240
- package/dist/src/credentials.js +0 -357
- package/dist/src/credits.js +0 -260
- package/dist/src/crypto.js +0 -66
- package/dist/src/discovery.js +0 -504
- package/dist/src/enterprise/env.js +0 -123
- package/dist/src/enterprise/script-generator.js +0 -460
- package/dist/src/execute-dynamic.js +0 -473
- package/dist/src/execute.js +0 -1727
- package/dist/src/index.js +0 -2062
- package/dist/src/metered.js +0 -80
- package/dist/src/open-apis.js +0 -276
- package/dist/src/proxy.js +0 -28
- package/dist/src/session.js +0 -86
- package/dist/src/stripe.js +0 -407
- package/dist/src/telemetry.js +0 -49
- package/dist/src/types.js +0 -2
- package/dist/src/utils/backup.js +0 -181
- package/dist/src/utils/config.js +0 -220
- package/dist/src/utils/os.js +0 -105
- package/dist/src/utils/paths.js +0 -159
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Send magic link email
|
|
3
|
+
*/
|
|
4
|
+
export declare const sendMagicLinkEmail: any;
|
|
5
|
+
/**
|
|
6
|
+
* Send reminder email
|
|
7
|
+
*/
|
|
8
|
+
export declare const sendReminderEmail: any;
|
|
9
|
+
/**
|
|
10
|
+
* Send limit reached email
|
|
11
|
+
*/
|
|
12
|
+
export declare const sendLimitReachedEmail: any;
|
|
13
|
+
export declare const debugEmailTemplate: any;
|
|
14
|
+
//# sourceMappingURL=email.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["email.ts"],"names":[],"mappings":"AA8IA;;GAEG;AACH,eAAO,MAAM,kBAAkB,KAsD7B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,iBAAiB,KAmC5B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,qBAAqB,KAkChC,CAAC;AAGH,eAAO,MAAM,kBAAkB,KA+C7B,CAAC"}
|
package/convex/email.js
ADDED
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { v } from "convex/values";
|
|
2
|
+
import { action } from "./_generated/server";
|
|
3
|
+
// ============================================
|
|
4
|
+
// EMAIL TEMPLATES
|
|
5
|
+
// ============================================
|
|
6
|
+
const EMAIL_FROM = "APIClaw <noreply@apiclaw.nordsym.com>";
|
|
7
|
+
const APP_URL = "https://apiclaw.nordsym.com";
|
|
8
|
+
// Base email wrapper - using string concat for Convex compatibility
|
|
9
|
+
function wrapEmail(content) {
|
|
10
|
+
const year = new Date().getFullYear();
|
|
11
|
+
return [
|
|
12
|
+
'<!DOCTYPE html>',
|
|
13
|
+
'<html>',
|
|
14
|
+
'<head>',
|
|
15
|
+
'<meta charset="utf-8">',
|
|
16
|
+
'<meta name="viewport" content="width=device-width, initial-scale=1.0">',
|
|
17
|
+
'</head>',
|
|
18
|
+
'<body style="margin: 0; padding: 0; background-color: #f5f5f5; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, sans-serif;">',
|
|
19
|
+
'<table width="100%" cellpadding="0" cellspacing="0" style="background-color: #f5f5f5; padding: 40px 20px;">',
|
|
20
|
+
'<tr>',
|
|
21
|
+
'<td align="center">',
|
|
22
|
+
'<table width="100%" cellpadding="0" cellspacing="0" style="max-width: 500px; background-color: #ffffff; border-radius: 12px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.1);">',
|
|
23
|
+
'<tr>',
|
|
24
|
+
'<td style="padding: 32px 32px 24px; text-align: center; border-bottom: 1px solid #f0f0f0;">',
|
|
25
|
+
'<span style="font-size: 48px;">🦞</span>',
|
|
26
|
+
'<h1 style="margin: 16px 0 0; font-size: 24px; font-weight: 700; color: #0a0a0a;">APIClaw</h1>',
|
|
27
|
+
'</td>',
|
|
28
|
+
'</tr>',
|
|
29
|
+
'<tr>',
|
|
30
|
+
'<td style="padding: 32px;">',
|
|
31
|
+
content,
|
|
32
|
+
'</td>',
|
|
33
|
+
'</tr>',
|
|
34
|
+
'<tr>',
|
|
35
|
+
'<td style="padding: 24px 32px; background-color: #fafafa; border-top: 1px solid #f0f0f0;">',
|
|
36
|
+
'<p style="margin: 0; font-size: 12px; color: #737373; text-align: center;">',
|
|
37
|
+
'<a href="https://apiclaw.nordsym.com" style="color: #ef4444; text-decoration: none;">APIClaw</a> — The API Layer for AI Agents',
|
|
38
|
+
'</p>',
|
|
39
|
+
'<p style="margin: 8px 0 0; font-size: 12px; color: #a3a3a3; text-align: center;">',
|
|
40
|
+
'© ' + year + ' NordSym. Stockholm, Sweden.',
|
|
41
|
+
'</p>',
|
|
42
|
+
'</td>',
|
|
43
|
+
'</tr>',
|
|
44
|
+
'</table>',
|
|
45
|
+
'</td>',
|
|
46
|
+
'</tr>',
|
|
47
|
+
'</table>',
|
|
48
|
+
'</body>',
|
|
49
|
+
'</html>',
|
|
50
|
+
].join('');
|
|
51
|
+
}
|
|
52
|
+
// Magic link email template - ultra simple for Convex
|
|
53
|
+
function magicLinkEmailTemplate(verifyUrl) {
|
|
54
|
+
// Simple inline HTML - no arrays, no template literals
|
|
55
|
+
var html = "<!DOCTYPE html><html><head><meta charset='utf-8'></head>";
|
|
56
|
+
html += "<body style='margin:0;padding:40px;background:#f5f5f5;font-family:Arial,sans-serif;'>";
|
|
57
|
+
html += "<table width='100%' cellpadding='0' cellspacing='0'><tr><td align='center'>";
|
|
58
|
+
html += "<table width='500' cellpadding='0' cellspacing='0' style='background:#fff;border-radius:12px;'>";
|
|
59
|
+
html += "<tr><td style='padding:32px;text-align:center;'>";
|
|
60
|
+
html += "<div style='font-size:48px;'>🦞</div>";
|
|
61
|
+
html += "<h1 style='margin:16px 0;color:#0a0a0a;'>APIClaw</h1>";
|
|
62
|
+
html += "<h2 style='margin:0 0 16px;font-size:20px;color:#0a0a0a;'>An AI Agent Wants to Connect</h2>";
|
|
63
|
+
html += "<p style='margin:0 0 24px;color:#525252;'>Click below to verify your email and activate your workspace.</p>";
|
|
64
|
+
html += "<a href='" + verifyUrl + "' style='display:inline-block;background:#ef4444;color:white;padding:14px 32px;border-radius:8px;text-decoration:none;font-weight:600;'>Verify Email</a>";
|
|
65
|
+
html += "<p style='margin:24px 0 0;font-size:13px;color:#737373;'>Free tier: 50 API calls. This link expires in 1 hour.</p>";
|
|
66
|
+
html += "</td></tr></table>";
|
|
67
|
+
html += "</td></tr></table></body></html>";
|
|
68
|
+
return html;
|
|
69
|
+
}
|
|
70
|
+
// Reminder email template
|
|
71
|
+
function reminderEmailTemplate(verifyUrl) {
|
|
72
|
+
return wrapEmail(`
|
|
73
|
+
<h2 style="margin: 0 0 16px; font-size: 20px; font-weight: 600; color: #0a0a0a; text-align: center;">
|
|
74
|
+
Still Waiting for You 👋
|
|
75
|
+
</h2>
|
|
76
|
+
|
|
77
|
+
<p style="margin: 0 0 24px; font-size: 16px; line-height: 1.6; color: #525252; text-align: center;">
|
|
78
|
+
Your AI agent is patiently waiting for you to verify your email.
|
|
79
|
+
Click below to activate your workspace and let it get to work!
|
|
80
|
+
</p>
|
|
81
|
+
|
|
82
|
+
<table width="100%" cellpadding="0" cellspacing="0">
|
|
83
|
+
<tr>
|
|
84
|
+
<td align="center" style="padding: 8px 0 24px;">
|
|
85
|
+
<a href="${verifyUrl}" style="display: inline-block; background: #ef4444; color: white; text-decoration: none; padding: 14px 32px; border-radius: 8px; font-weight: 600; font-size: 16px;">
|
|
86
|
+
Verify & Get Started
|
|
87
|
+
</a>
|
|
88
|
+
</td>
|
|
89
|
+
</tr>
|
|
90
|
+
</table>
|
|
91
|
+
|
|
92
|
+
<p style="margin: 0; font-size: 13px; color: #737373; text-align: center;">
|
|
93
|
+
This link expires in 1 hour.
|
|
94
|
+
</p>
|
|
95
|
+
`);
|
|
96
|
+
}
|
|
97
|
+
// Limit reached email template
|
|
98
|
+
function limitReachedEmailTemplate(upgradeUrl) {
|
|
99
|
+
return wrapEmail(`
|
|
100
|
+
<h2 style="margin: 0 0 16px; font-size: 20px; font-weight: 600; color: #0a0a0a; text-align: center;">
|
|
101
|
+
Free Tier Limit Reached
|
|
102
|
+
</h2>
|
|
103
|
+
|
|
104
|
+
<p style="margin: 0 0 24px; font-size: 16px; line-height: 1.6; color: #525252; text-align: center;">
|
|
105
|
+
Your AI agent has used all 100 free API calls. Add a payment method to continue using APIClaw.
|
|
106
|
+
</p>
|
|
107
|
+
|
|
108
|
+
<div style="background: #f5f5f5; border-radius: 8px; padding: 20px; margin-bottom: 24px;">
|
|
109
|
+
<p style="margin: 0 0 8px; font-size: 14px; font-weight: 600; color: #0a0a0a;">Pro Plan — $10/month</p>
|
|
110
|
+
<ul style="margin: 0; padding: 0 0 0 20px; font-size: 14px; color: #525252; line-height: 1.8;">
|
|
111
|
+
<li>10,000 API calls/month</li>
|
|
112
|
+
<li>Priority support</li>
|
|
113
|
+
<li>Usage analytics</li>
|
|
114
|
+
</ul>
|
|
115
|
+
</div>
|
|
116
|
+
|
|
117
|
+
<table width="100%" cellpadding="0" cellspacing="0">
|
|
118
|
+
<tr>
|
|
119
|
+
<td align="center" style="padding: 8px 0 24px;">
|
|
120
|
+
<a href="${upgradeUrl}" style="display: inline-block; background: #ef4444; color: white; text-decoration: none; padding: 14px 32px; border-radius: 8px; font-weight: 600; font-size: 16px;">
|
|
121
|
+
Upgrade Now
|
|
122
|
+
</a>
|
|
123
|
+
</td>
|
|
124
|
+
</tr>
|
|
125
|
+
</table>
|
|
126
|
+
|
|
127
|
+
<p style="margin: 0; font-size: 13px; color: #737373; text-align: center;">
|
|
128
|
+
Questions? Reply to this email.
|
|
129
|
+
</p>
|
|
130
|
+
`);
|
|
131
|
+
}
|
|
132
|
+
// ============================================
|
|
133
|
+
// EMAIL SENDING ACTIONS
|
|
134
|
+
// ============================================
|
|
135
|
+
/**
|
|
136
|
+
* Send magic link email
|
|
137
|
+
*/
|
|
138
|
+
export const sendMagicLinkEmail = action({
|
|
139
|
+
args: {
|
|
140
|
+
email: v.string(),
|
|
141
|
+
token: v.string(),
|
|
142
|
+
},
|
|
143
|
+
handler: async (ctx, args) => {
|
|
144
|
+
const RESEND_API_KEY = process.env.RESEND_API_KEY;
|
|
145
|
+
if (!RESEND_API_KEY) {
|
|
146
|
+
throw new Error("RESEND_API_KEY not configured");
|
|
147
|
+
}
|
|
148
|
+
var verifyUrl = APP_URL + "/auth/verify?token=" + args.token;
|
|
149
|
+
// Generate HTML inline (same approach as debug that works)
|
|
150
|
+
var html = "<!DOCTYPE html><html><head><meta charset='utf-8'></head>";
|
|
151
|
+
html += "<body style='margin:0;padding:40px;background:#f5f5f5;font-family:Arial,sans-serif;'>";
|
|
152
|
+
html += "<table width='100%' cellpadding='0' cellspacing='0'><tr><td align='center'>";
|
|
153
|
+
html += "<table width='500' cellpadding='0' cellspacing='0' style='background:#fff;border-radius:12px;'>";
|
|
154
|
+
html += "<tr><td style='padding:32px;text-align:center;'>";
|
|
155
|
+
html += "<div style='font-size:48px;'>🦞</div>";
|
|
156
|
+
html += "<h1 style='margin:16px 0;color:#0a0a0a;'>APIClaw</h1>";
|
|
157
|
+
html += "<h2 style='margin:0 0 16px;font-size:20px;color:#0a0a0a;'>An AI Agent Wants to Connect</h2>";
|
|
158
|
+
html += "<p style='margin:0 0 24px;color:#525252;'>Click below to verify your email and activate your workspace.</p>";
|
|
159
|
+
html += "<a href='" + verifyUrl + "' style='display:inline-block;background:#ef4444;color:white;padding:14px 32px;border-radius:8px;text-decoration:none;font-weight:600;'>Verify Email</a>";
|
|
160
|
+
html += "<p style='margin:24px 0 0;font-size:13px;color:#737373;'>Free tier: 50 API calls. This link expires in 1 hour.</p>";
|
|
161
|
+
html += "</td></tr></table>";
|
|
162
|
+
html += "</td></tr></table></body></html>";
|
|
163
|
+
var textContent = "APIClaw - An AI Agent Wants to Connect\n\n";
|
|
164
|
+
textContent += "Click the link: " + verifyUrl + "\n\n";
|
|
165
|
+
textContent += "Free tier: 50 API calls. Expires in 1 hour.";
|
|
166
|
+
var response = await fetch("https://api.resend.com/emails", {
|
|
167
|
+
method: "POST",
|
|
168
|
+
headers: {
|
|
169
|
+
"Authorization": "Bearer " + RESEND_API_KEY,
|
|
170
|
+
"Content-Type": "application/json",
|
|
171
|
+
},
|
|
172
|
+
body: JSON.stringify({
|
|
173
|
+
from: EMAIL_FROM,
|
|
174
|
+
to: args.email,
|
|
175
|
+
subject: "🦞 An AI Agent Wants to Connect — Verify Your Email",
|
|
176
|
+
html: html,
|
|
177
|
+
text: textContent,
|
|
178
|
+
}),
|
|
179
|
+
});
|
|
180
|
+
if (!response.ok) {
|
|
181
|
+
var errorText = await response.text();
|
|
182
|
+
throw new Error("Failed to send email: " + errorText);
|
|
183
|
+
}
|
|
184
|
+
return { success: true };
|
|
185
|
+
},
|
|
186
|
+
});
|
|
187
|
+
/**
|
|
188
|
+
* Send reminder email
|
|
189
|
+
*/
|
|
190
|
+
export const sendReminderEmail = action({
|
|
191
|
+
args: {
|
|
192
|
+
email: v.string(),
|
|
193
|
+
token: v.string(),
|
|
194
|
+
},
|
|
195
|
+
handler: async (ctx, args) => {
|
|
196
|
+
const RESEND_API_KEY = process.env.RESEND_API_KEY;
|
|
197
|
+
if (!RESEND_API_KEY) {
|
|
198
|
+
throw new Error("RESEND_API_KEY not configured");
|
|
199
|
+
}
|
|
200
|
+
const verifyUrl = `${APP_URL}/auth/verify?token=${args.token}`;
|
|
201
|
+
const html = reminderEmailTemplate(verifyUrl);
|
|
202
|
+
const response = await fetch("https://api.resend.com/emails", {
|
|
203
|
+
method: "POST",
|
|
204
|
+
headers: {
|
|
205
|
+
"Authorization": `Bearer ${RESEND_API_KEY}`,
|
|
206
|
+
"Content-Type": "application/json",
|
|
207
|
+
},
|
|
208
|
+
body: JSON.stringify({
|
|
209
|
+
from: EMAIL_FROM,
|
|
210
|
+
to: args.email,
|
|
211
|
+
subject: "🦞 Your Agent is Still Waiting — Verify Your Email",
|
|
212
|
+
html,
|
|
213
|
+
}),
|
|
214
|
+
});
|
|
215
|
+
if (!response.ok) {
|
|
216
|
+
const error = await response.text();
|
|
217
|
+
throw new Error(`Failed to send email: ${error}`);
|
|
218
|
+
}
|
|
219
|
+
return { success: true };
|
|
220
|
+
},
|
|
221
|
+
});
|
|
222
|
+
/**
|
|
223
|
+
* Send limit reached email
|
|
224
|
+
*/
|
|
225
|
+
export const sendLimitReachedEmail = action({
|
|
226
|
+
args: {
|
|
227
|
+
email: v.string(),
|
|
228
|
+
},
|
|
229
|
+
handler: async (ctx, args) => {
|
|
230
|
+
const RESEND_API_KEY = process.env.RESEND_API_KEY;
|
|
231
|
+
if (!RESEND_API_KEY) {
|
|
232
|
+
throw new Error("RESEND_API_KEY not configured");
|
|
233
|
+
}
|
|
234
|
+
const upgradeUrl = `${APP_URL}/upgrade`;
|
|
235
|
+
const html = limitReachedEmailTemplate(upgradeUrl);
|
|
236
|
+
const response = await fetch("https://api.resend.com/emails", {
|
|
237
|
+
method: "POST",
|
|
238
|
+
headers: {
|
|
239
|
+
"Authorization": `Bearer ${RESEND_API_KEY}`,
|
|
240
|
+
"Content-Type": "application/json",
|
|
241
|
+
},
|
|
242
|
+
body: JSON.stringify({
|
|
243
|
+
from: EMAIL_FROM,
|
|
244
|
+
to: args.email,
|
|
245
|
+
subject: "🦞 Free Tier Limit Reached — Upgrade to Continue",
|
|
246
|
+
html,
|
|
247
|
+
}),
|
|
248
|
+
});
|
|
249
|
+
if (!response.ok) {
|
|
250
|
+
const error = await response.text();
|
|
251
|
+
throw new Error(`Failed to send email: ${error}`);
|
|
252
|
+
}
|
|
253
|
+
return { success: true };
|
|
254
|
+
},
|
|
255
|
+
});
|
|
256
|
+
// Debug: Test email template generation
|
|
257
|
+
export const debugEmailTemplate = action({
|
|
258
|
+
args: { email: v.string() },
|
|
259
|
+
handler: async (ctx, { email }) => {
|
|
260
|
+
const RESEND_API_KEY = process.env.RESEND_API_KEY;
|
|
261
|
+
const testUrl = "https://apiclaw.nordsym.com/auth/verify?token=DEBUG_TEST";
|
|
262
|
+
// Generate HTML using the template
|
|
263
|
+
var html = "<!DOCTYPE html><html><head><meta charset='utf-8'></head>";
|
|
264
|
+
html += "<body style='margin:0;padding:40px;background:#f5f5f5;font-family:Arial,sans-serif;'>";
|
|
265
|
+
html += "<table width='100%' cellpadding='0' cellspacing='0'><tr><td align='center'>";
|
|
266
|
+
html += "<table width='500' cellpadding='0' cellspacing='0' style='background:#fff;border-radius:12px;'>";
|
|
267
|
+
html += "<tr><td style='padding:32px;text-align:center;'>";
|
|
268
|
+
html += "<div style='font-size:48px;'>🦞</div>";
|
|
269
|
+
html += "<h1 style='margin:16px 0;color:#0a0a0a;'>APIClaw DEBUG</h1>";
|
|
270
|
+
html += "<h2 style='margin:0 0 16px;font-size:20px;color:#0a0a0a;'>Debug Email Test</h2>";
|
|
271
|
+
html += "<p style='margin:0 0 24px;color:#525252;'>This is a debug test email.</p>";
|
|
272
|
+
html += "<a href='" + testUrl + "' style='display:inline-block;background:#ef4444;color:white;padding:14px 32px;border-radius:8px;text-decoration:none;font-weight:600;'>Test Link</a>";
|
|
273
|
+
html += "</td></tr></table>";
|
|
274
|
+
html += "</td></tr></table></body></html>";
|
|
275
|
+
console.log("[Debug] HTML length:", html.length);
|
|
276
|
+
console.log("[Debug] HTML:", html);
|
|
277
|
+
const response = await fetch("https://api.resend.com/emails", {
|
|
278
|
+
method: "POST",
|
|
279
|
+
headers: {
|
|
280
|
+
"Authorization": "Bearer " + RESEND_API_KEY,
|
|
281
|
+
"Content-Type": "application/json",
|
|
282
|
+
},
|
|
283
|
+
body: JSON.stringify({
|
|
284
|
+
from: "APIClaw <noreply@apiclaw.nordsym.com>",
|
|
285
|
+
to: email,
|
|
286
|
+
subject: "DEBUG EMAIL FROM CONVEX",
|
|
287
|
+
html: html,
|
|
288
|
+
}),
|
|
289
|
+
});
|
|
290
|
+
const result = await response.text();
|
|
291
|
+
console.log("[Debug] Response:", response.status, result);
|
|
292
|
+
return {
|
|
293
|
+
htmlLength: html.length,
|
|
294
|
+
htmlPreview: html.substring(0, 200),
|
|
295
|
+
resendStatus: response.status,
|
|
296
|
+
resendResult: result
|
|
297
|
+
};
|
|
298
|
+
},
|
|
299
|
+
});
|
|
300
|
+
//# sourceMappingURL=email.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.js","sourceRoot":"","sources":["email.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,MAAM,EAAkB,MAAM,qBAAqB,CAAC;AAE7D,+CAA+C;AAC/C,kBAAkB;AAClB,+CAA+C;AAE/C,MAAM,UAAU,GAAG,uCAAuC,CAAC;AAC3D,MAAM,OAAO,GAAG,6BAA6B,CAAC;AAE9C,oEAAoE;AACpE,SAAS,SAAS,CAAC,OAAe;IAChC,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACtC,OAAO;QACL,iBAAiB;QACjB,QAAQ;QACR,QAAQ;QACR,wBAAwB;QACxB,wEAAwE;QACxE,SAAS;QACT,kKAAkK;QAClK,6GAA6G;QAC7G,MAAM;QACN,qBAAqB;QACrB,yLAAyL;QACzL,MAAM;QACN,6FAA6F;QAC7F,0CAA0C;QAC1C,+FAA+F;QAC/F,OAAO;QACP,OAAO;QACP,MAAM;QACN,6BAA6B;QAC7B,OAAO;QACP,OAAO;QACP,OAAO;QACP,MAAM;QACN,4FAA4F;QAC5F,6EAA6E;QAC7E,gIAAgI;QAChI,MAAM;QACN,mFAAmF;QACnF,IAAI,GAAG,IAAI,GAAG,8BAA8B;QAC5C,MAAM;QACN,OAAO;QACP,OAAO;QACP,UAAU;QACV,OAAO;QACP,OAAO;QACP,UAAU;QACV,SAAS;QACT,SAAS;KACV,CAAC,IAAI,CAAC,EAAE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AC,MAAM,EAAE,MAAM,CAAC,CAAC;QAE1D,OAAO;YACL,UAAU,EAAE,IAAI,CAAC,MAAM;YACvB,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC;YACnC,YAAY,EAAE,QAAQ,CAAC,MAAM;YAC7B,YAAY,EAAE,MAAM;SACrB,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
package/convex/email.ts
ADDED
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import { v } from "convex/values";
|
|
2
|
+
import { action, internalAction } from "./_generated/server";
|
|
3
|
+
|
|
4
|
+
// ============================================
|
|
5
|
+
// EMAIL TEMPLATES
|
|
6
|
+
// ============================================
|
|
7
|
+
|
|
8
|
+
const EMAIL_FROM = "APIClaw <noreply@apiclaw.nordsym.com>";
|
|
9
|
+
const APP_URL = "https://apiclaw.nordsym.com";
|
|
10
|
+
|
|
11
|
+
// Base email wrapper - using string concat for Convex compatibility
|
|
12
|
+
function wrapEmail(content: string): string {
|
|
13
|
+
const year = new Date().getFullYear();
|
|
14
|
+
return [
|
|
15
|
+
'<!DOCTYPE html>',
|
|
16
|
+
'<html>',
|
|
17
|
+
'<head>',
|
|
18
|
+
'<meta charset="utf-8">',
|
|
19
|
+
'<meta name="viewport" content="width=device-width, initial-scale=1.0">',
|
|
20
|
+
'</head>',
|
|
21
|
+
'<body style="margin: 0; padding: 0; background-color: #f5f5f5; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, sans-serif;">',
|
|
22
|
+
'<table width="100%" cellpadding="0" cellspacing="0" style="background-color: #f5f5f5; padding: 40px 20px;">',
|
|
23
|
+
'<tr>',
|
|
24
|
+
'<td align="center">',
|
|
25
|
+
'<table width="100%" cellpadding="0" cellspacing="0" style="max-width: 500px; background-color: #ffffff; border-radius: 12px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.1);">',
|
|
26
|
+
'<tr>',
|
|
27
|
+
'<td style="padding: 32px 32px 24px; text-align: center; border-bottom: 1px solid #f0f0f0;">',
|
|
28
|
+
'<span style="font-size: 48px;">🦞</span>',
|
|
29
|
+
'<h1 style="margin: 16px 0 0; font-size: 24px; font-weight: 700; color: #0a0a0a;">APIClaw</h1>',
|
|
30
|
+
'</td>',
|
|
31
|
+
'</tr>',
|
|
32
|
+
'<tr>',
|
|
33
|
+
'<td style="padding: 32px;">',
|
|
34
|
+
content,
|
|
35
|
+
'</td>',
|
|
36
|
+
'</tr>',
|
|
37
|
+
'<tr>',
|
|
38
|
+
'<td style="padding: 24px 32px; background-color: #fafafa; border-top: 1px solid #f0f0f0;">',
|
|
39
|
+
'<p style="margin: 0; font-size: 12px; color: #737373; text-align: center;">',
|
|
40
|
+
'<a href="https://apiclaw.nordsym.com" style="color: #ef4444; text-decoration: none;">APIClaw</a> — The API Layer for AI Agents',
|
|
41
|
+
'</p>',
|
|
42
|
+
'<p style="margin: 8px 0 0; font-size: 12px; color: #a3a3a3; text-align: center;">',
|
|
43
|
+
'© ' + year + ' NordSym. Stockholm, Sweden.',
|
|
44
|
+
'</p>',
|
|
45
|
+
'</td>',
|
|
46
|
+
'</tr>',
|
|
47
|
+
'</table>',
|
|
48
|
+
'</td>',
|
|
49
|
+
'</tr>',
|
|
50
|
+
'</table>',
|
|
51
|
+
'</body>',
|
|
52
|
+
'</html>',
|
|
53
|
+
].join('');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Magic link email template - ultra simple for Convex
|
|
57
|
+
function magicLinkEmailTemplate(verifyUrl: string): string {
|
|
58
|
+
// Simple inline HTML - no arrays, no template literals
|
|
59
|
+
var html = "<!DOCTYPE html><html><head><meta charset='utf-8'></head>";
|
|
60
|
+
html += "<body style='margin:0;padding:40px;background:#f5f5f5;font-family:Arial,sans-serif;'>";
|
|
61
|
+
html += "<table width='100%' cellpadding='0' cellspacing='0'><tr><td align='center'>";
|
|
62
|
+
html += "<table width='500' cellpadding='0' cellspacing='0' style='background:#fff;border-radius:12px;'>";
|
|
63
|
+
html += "<tr><td style='padding:32px;text-align:center;'>";
|
|
64
|
+
html += "<div style='font-size:48px;'>🦞</div>";
|
|
65
|
+
html += "<h1 style='margin:16px 0;color:#0a0a0a;'>APIClaw</h1>";
|
|
66
|
+
html += "<h2 style='margin:0 0 16px;font-size:20px;color:#0a0a0a;'>An AI Agent Wants to Connect</h2>";
|
|
67
|
+
html += "<p style='margin:0 0 24px;color:#525252;'>Click below to verify your email and activate your workspace.</p>";
|
|
68
|
+
html += "<a href='" + verifyUrl + "' style='display:inline-block;background:#ef4444;color:white;padding:14px 32px;border-radius:8px;text-decoration:none;font-weight:600;'>Verify Email</a>";
|
|
69
|
+
html += "<p style='margin:24px 0 0;font-size:13px;color:#737373;'>Free tier: 50 API calls. This link expires in 1 hour.</p>";
|
|
70
|
+
html += "</td></tr></table>";
|
|
71
|
+
html += "</td></tr></table></body></html>";
|
|
72
|
+
return html;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Reminder email template
|
|
76
|
+
function reminderEmailTemplate(verifyUrl: string): string {
|
|
77
|
+
return wrapEmail(`
|
|
78
|
+
<h2 style="margin: 0 0 16px; font-size: 20px; font-weight: 600; color: #0a0a0a; text-align: center;">
|
|
79
|
+
Still Waiting for You 👋
|
|
80
|
+
</h2>
|
|
81
|
+
|
|
82
|
+
<p style="margin: 0 0 24px; font-size: 16px; line-height: 1.6; color: #525252; text-align: center;">
|
|
83
|
+
Your AI agent is patiently waiting for you to verify your email.
|
|
84
|
+
Click below to activate your workspace and let it get to work!
|
|
85
|
+
</p>
|
|
86
|
+
|
|
87
|
+
<table width="100%" cellpadding="0" cellspacing="0">
|
|
88
|
+
<tr>
|
|
89
|
+
<td align="center" style="padding: 8px 0 24px;">
|
|
90
|
+
<a href="${verifyUrl}" style="display: inline-block; background: #ef4444; color: white; text-decoration: none; padding: 14px 32px; border-radius: 8px; font-weight: 600; font-size: 16px;">
|
|
91
|
+
Verify & Get Started
|
|
92
|
+
</a>
|
|
93
|
+
</td>
|
|
94
|
+
</tr>
|
|
95
|
+
</table>
|
|
96
|
+
|
|
97
|
+
<p style="margin: 0; font-size: 13px; color: #737373; text-align: center;">
|
|
98
|
+
This link expires in 1 hour.
|
|
99
|
+
</p>
|
|
100
|
+
`);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Limit reached email template
|
|
104
|
+
function limitReachedEmailTemplate(upgradeUrl: string): string {
|
|
105
|
+
return wrapEmail(`
|
|
106
|
+
<h2 style="margin: 0 0 16px; font-size: 20px; font-weight: 600; color: #0a0a0a; text-align: center;">
|
|
107
|
+
Free Tier Limit Reached
|
|
108
|
+
</h2>
|
|
109
|
+
|
|
110
|
+
<p style="margin: 0 0 24px; font-size: 16px; line-height: 1.6; color: #525252; text-align: center;">
|
|
111
|
+
Your AI agent has used all 100 free API calls. Add a payment method to continue using APIClaw.
|
|
112
|
+
</p>
|
|
113
|
+
|
|
114
|
+
<div style="background: #f5f5f5; border-radius: 8px; padding: 20px; margin-bottom: 24px;">
|
|
115
|
+
<p style="margin: 0 0 8px; font-size: 14px; font-weight: 600; color: #0a0a0a;">Pro Plan — $10/month</p>
|
|
116
|
+
<ul style="margin: 0; padding: 0 0 0 20px; font-size: 14px; color: #525252; line-height: 1.8;">
|
|
117
|
+
<li>10,000 API calls/month</li>
|
|
118
|
+
<li>Priority support</li>
|
|
119
|
+
<li>Usage analytics</li>
|
|
120
|
+
</ul>
|
|
121
|
+
</div>
|
|
122
|
+
|
|
123
|
+
<table width="100%" cellpadding="0" cellspacing="0">
|
|
124
|
+
<tr>
|
|
125
|
+
<td align="center" style="padding: 8px 0 24px;">
|
|
126
|
+
<a href="${upgradeUrl}" style="display: inline-block; background: #ef4444; color: white; text-decoration: none; padding: 14px 32px; border-radius: 8px; font-weight: 600; font-size: 16px;">
|
|
127
|
+
Upgrade Now
|
|
128
|
+
</a>
|
|
129
|
+
</td>
|
|
130
|
+
</tr>
|
|
131
|
+
</table>
|
|
132
|
+
|
|
133
|
+
<p style="margin: 0; font-size: 13px; color: #737373; text-align: center;">
|
|
134
|
+
Questions? Reply to this email.
|
|
135
|
+
</p>
|
|
136
|
+
`);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// ============================================
|
|
140
|
+
// EMAIL SENDING ACTIONS
|
|
141
|
+
// ============================================
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Send magic link email
|
|
145
|
+
*/
|
|
146
|
+
export const sendMagicLinkEmail = action({
|
|
147
|
+
args: {
|
|
148
|
+
email: v.string(),
|
|
149
|
+
token: v.string(),
|
|
150
|
+
},
|
|
151
|
+
handler: async (ctx, args) => {
|
|
152
|
+
const RESEND_API_KEY = process.env.RESEND_API_KEY;
|
|
153
|
+
if (!RESEND_API_KEY) {
|
|
154
|
+
throw new Error("RESEND_API_KEY not configured");
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
var verifyUrl = APP_URL + "/auth/verify?token=" + args.token;
|
|
158
|
+
|
|
159
|
+
// Generate HTML inline (same approach as debug that works)
|
|
160
|
+
var html = "<!DOCTYPE html><html><head><meta charset='utf-8'></head>";
|
|
161
|
+
html += "<body style='margin:0;padding:40px;background:#f5f5f5;font-family:Arial,sans-serif;'>";
|
|
162
|
+
html += "<table width='100%' cellpadding='0' cellspacing='0'><tr><td align='center'>";
|
|
163
|
+
html += "<table width='500' cellpadding='0' cellspacing='0' style='background:#fff;border-radius:12px;'>";
|
|
164
|
+
html += "<tr><td style='padding:32px;text-align:center;'>";
|
|
165
|
+
html += "<div style='font-size:48px;'>🦞</div>";
|
|
166
|
+
html += "<h1 style='margin:16px 0;color:#0a0a0a;'>APIClaw</h1>";
|
|
167
|
+
html += "<h2 style='margin:0 0 16px;font-size:20px;color:#0a0a0a;'>An AI Agent Wants to Connect</h2>";
|
|
168
|
+
html += "<p style='margin:0 0 24px;color:#525252;'>Click below to verify your email and activate your workspace.</p>";
|
|
169
|
+
html += "<a href='" + verifyUrl + "' style='display:inline-block;background:#ef4444;color:white;padding:14px 32px;border-radius:8px;text-decoration:none;font-weight:600;'>Verify Email</a>";
|
|
170
|
+
html += "<p style='margin:24px 0 0;font-size:13px;color:#737373;'>Free tier: 50 API calls. This link expires in 1 hour.</p>";
|
|
171
|
+
html += "</td></tr></table>";
|
|
172
|
+
html += "</td></tr></table></body></html>";
|
|
173
|
+
|
|
174
|
+
var textContent = "APIClaw - An AI Agent Wants to Connect\n\n";
|
|
175
|
+
textContent += "Click the link: " + verifyUrl + "\n\n";
|
|
176
|
+
textContent += "Free tier: 50 API calls. Expires in 1 hour.";
|
|
177
|
+
|
|
178
|
+
var response = await fetch("https://api.resend.com/emails", {
|
|
179
|
+
method: "POST",
|
|
180
|
+
headers: {
|
|
181
|
+
"Authorization": "Bearer " + RESEND_API_KEY,
|
|
182
|
+
"Content-Type": "application/json",
|
|
183
|
+
},
|
|
184
|
+
body: JSON.stringify({
|
|
185
|
+
from: EMAIL_FROM,
|
|
186
|
+
to: args.email,
|
|
187
|
+
subject: "🦞 An AI Agent Wants to Connect — Verify Your Email",
|
|
188
|
+
html: html,
|
|
189
|
+
text: textContent,
|
|
190
|
+
}),
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
if (!response.ok) {
|
|
194
|
+
var errorText = await response.text();
|
|
195
|
+
throw new Error("Failed to send email: " + errorText);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return { success: true };
|
|
199
|
+
},
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Send reminder email
|
|
204
|
+
*/
|
|
205
|
+
export const sendReminderEmail = action({
|
|
206
|
+
args: {
|
|
207
|
+
email: v.string(),
|
|
208
|
+
token: v.string(),
|
|
209
|
+
},
|
|
210
|
+
handler: async (ctx, args) => {
|
|
211
|
+
const RESEND_API_KEY = process.env.RESEND_API_KEY;
|
|
212
|
+
if (!RESEND_API_KEY) {
|
|
213
|
+
throw new Error("RESEND_API_KEY not configured");
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const verifyUrl = `${APP_URL}/auth/verify?token=${args.token}`;
|
|
217
|
+
const html = reminderEmailTemplate(verifyUrl);
|
|
218
|
+
|
|
219
|
+
const response = await fetch("https://api.resend.com/emails", {
|
|
220
|
+
method: "POST",
|
|
221
|
+
headers: {
|
|
222
|
+
"Authorization": `Bearer ${RESEND_API_KEY}`,
|
|
223
|
+
"Content-Type": "application/json",
|
|
224
|
+
},
|
|
225
|
+
body: JSON.stringify({
|
|
226
|
+
from: EMAIL_FROM,
|
|
227
|
+
to: args.email,
|
|
228
|
+
subject: "🦞 Your Agent is Still Waiting — Verify Your Email",
|
|
229
|
+
html,
|
|
230
|
+
}),
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
if (!response.ok) {
|
|
234
|
+
const error = await response.text();
|
|
235
|
+
throw new Error(`Failed to send email: ${error}`);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return { success: true };
|
|
239
|
+
},
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Send limit reached email
|
|
244
|
+
*/
|
|
245
|
+
export const sendLimitReachedEmail = action({
|
|
246
|
+
args: {
|
|
247
|
+
email: v.string(),
|
|
248
|
+
},
|
|
249
|
+
handler: async (ctx, args) => {
|
|
250
|
+
const RESEND_API_KEY = process.env.RESEND_API_KEY;
|
|
251
|
+
if (!RESEND_API_KEY) {
|
|
252
|
+
throw new Error("RESEND_API_KEY not configured");
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const upgradeUrl = `${APP_URL}/upgrade`;
|
|
256
|
+
const html = limitReachedEmailTemplate(upgradeUrl);
|
|
257
|
+
|
|
258
|
+
const response = await fetch("https://api.resend.com/emails", {
|
|
259
|
+
method: "POST",
|
|
260
|
+
headers: {
|
|
261
|
+
"Authorization": `Bearer ${RESEND_API_KEY}`,
|
|
262
|
+
"Content-Type": "application/json",
|
|
263
|
+
},
|
|
264
|
+
body: JSON.stringify({
|
|
265
|
+
from: EMAIL_FROM,
|
|
266
|
+
to: args.email,
|
|
267
|
+
subject: "🦞 Free Tier Limit Reached — Upgrade to Continue",
|
|
268
|
+
html,
|
|
269
|
+
}),
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
if (!response.ok) {
|
|
273
|
+
const error = await response.text();
|
|
274
|
+
throw new Error(`Failed to send email: ${error}`);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
return { success: true };
|
|
278
|
+
},
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
// Debug: Test email template generation
|
|
282
|
+
export const debugEmailTemplate = action({
|
|
283
|
+
args: { email: v.string() },
|
|
284
|
+
handler: async (ctx, { email }) => {
|
|
285
|
+
const RESEND_API_KEY = process.env.RESEND_API_KEY;
|
|
286
|
+
const testUrl = "https://apiclaw.nordsym.com/auth/verify?token=DEBUG_TEST";
|
|
287
|
+
|
|
288
|
+
// Generate HTML using the template
|
|
289
|
+
var html = "<!DOCTYPE html><html><head><meta charset='utf-8'></head>";
|
|
290
|
+
html += "<body style='margin:0;padding:40px;background:#f5f5f5;font-family:Arial,sans-serif;'>";
|
|
291
|
+
html += "<table width='100%' cellpadding='0' cellspacing='0'><tr><td align='center'>";
|
|
292
|
+
html += "<table width='500' cellpadding='0' cellspacing='0' style='background:#fff;border-radius:12px;'>";
|
|
293
|
+
html += "<tr><td style='padding:32px;text-align:center;'>";
|
|
294
|
+
html += "<div style='font-size:48px;'>🦞</div>";
|
|
295
|
+
html += "<h1 style='margin:16px 0;color:#0a0a0a;'>APIClaw DEBUG</h1>";
|
|
296
|
+
html += "<h2 style='margin:0 0 16px;font-size:20px;color:#0a0a0a;'>Debug Email Test</h2>";
|
|
297
|
+
html += "<p style='margin:0 0 24px;color:#525252;'>This is a debug test email.</p>";
|
|
298
|
+
html += "<a href='" + testUrl + "' style='display:inline-block;background:#ef4444;color:white;padding:14px 32px;border-radius:8px;text-decoration:none;font-weight:600;'>Test Link</a>";
|
|
299
|
+
html += "</td></tr></table>";
|
|
300
|
+
html += "</td></tr></table></body></html>";
|
|
301
|
+
|
|
302
|
+
console.log("[Debug] HTML length:", html.length);
|
|
303
|
+
console.log("[Debug] HTML:", html);
|
|
304
|
+
|
|
305
|
+
const response = await fetch("https://api.resend.com/emails", {
|
|
306
|
+
method: "POST",
|
|
307
|
+
headers: {
|
|
308
|
+
"Authorization": "Bearer " + RESEND_API_KEY,
|
|
309
|
+
"Content-Type": "application/json",
|
|
310
|
+
},
|
|
311
|
+
body: JSON.stringify({
|
|
312
|
+
from: "APIClaw <noreply@apiclaw.nordsym.com>",
|
|
313
|
+
to: email,
|
|
314
|
+
subject: "DEBUG EMAIL FROM CONVEX",
|
|
315
|
+
html: html,
|
|
316
|
+
}),
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
const result = await response.text();
|
|
320
|
+
console.log("[Debug] Response:", response.status, result);
|
|
321
|
+
|
|
322
|
+
return {
|
|
323
|
+
htmlLength: html.length,
|
|
324
|
+
htmlPreview: html.substring(0, 200),
|
|
325
|
+
resendStatus: response.status,
|
|
326
|
+
resendResult: result
|
|
327
|
+
};
|
|
328
|
+
},
|
|
329
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const submitFeedback: any;
|
|
2
|
+
export declare const voteFeedback: any;
|
|
3
|
+
export declare const getFeedback: any;
|
|
4
|
+
export declare const getMyFeedback: any;
|
|
5
|
+
export declare const updateFeedbackStatus: any;
|
|
6
|
+
export declare const deleteFeedback: any;
|
|
7
|
+
//# sourceMappingURL=feedback.d.ts.map
|