@kyro-cms/admin 0.2.4 → 0.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 +46 -272
- package/package.json +37 -10
- package/src/blocks/examples/sample-block-2.tsx +27 -0
- package/src/blocks/examples/sample-block.tsx +26 -0
- package/src/blocks/index.ts +14 -0
- package/src/blocks/registry.ts +38 -0
- package/src/blocks/types.ts +23 -0
- package/src/components/Admin.tsx +1 -1
- package/src/components/ApiKeysManager.tsx +1 -1
- package/src/components/AuditLogsPage.tsx +1 -1
- package/src/components/AutoForm.tsx +2 -2
- package/src/components/BrandingHub.tsx +1 -1
- package/src/components/CreateView.tsx +1 -1
- package/src/components/DetailView.tsx +1 -1
- package/src/components/DeveloperCenter.tsx +1 -1
- package/src/components/EnhancedListView.tsx +1 -1
- package/src/components/ListView.tsx +1 -1
- package/src/components/LoginPage.tsx +1 -1
- package/src/components/MediaGallery.tsx +1 -1
- package/src/components/UserManagement.tsx +1 -1
- package/src/components/WebhookManager.tsx +2 -2
- package/src/components/fields/RelationshipBlockField.tsx +1 -1
- package/src/components/fields/RelationshipField.tsx +1 -1
- package/src/components/fields/UploadField.tsx +1 -6
- package/src/components/ui/CommandPalette.tsx +1 -1
- package/src/fields/examples/sample-field-2.tsx +30 -0
- package/src/fields/examples/sample-field.tsx +30 -0
- package/src/fields/index.ts +33 -0
- package/src/fields/registry.tsx +46 -0
- package/src/fields/types.ts +24 -0
- package/src/hooks/data.ts +116 -0
- package/src/hooks/examples/sample-hook-2.ts +13 -0
- package/src/hooks/examples/sample-hook.ts +12 -0
- package/src/hooks/index.ts +19 -0
- package/src/hooks/lifecycle.ts +81 -0
- package/src/hooks/types.ts +40 -0
- package/src/index.ts +78 -0
- package/src/integration.ts +52 -0
- package/src/pages/api/[collection]/[id]/publish.ts +2 -2
- package/src/pages/api/[collection]/[id]/unpublish.ts +2 -2
- package/src/pages/api/[collection]/[id]/versions.ts +1 -1
- package/src/pages/api/[collection]/[id].ts +2 -2
- package/src/pages/api/[collection]/index.ts +2 -2
- package/src/pages/api/collections.ts +1 -1
- package/src/pages/api/globals/[slug].ts +2 -2
- package/src/pages/api/graphql.ts +3 -3
- package/src/pages/api/media/folders.ts +1 -1
- package/src/pages/api/media/index.ts +1 -1
- package/src/pages/api/media/resize.ts +1 -1
- package/src/pages/api/slug-availability.ts +2 -2
- package/src/pages/api/storage-config.ts +1 -1
- package/src/pages/api/storage-status.ts +1 -1
- package/src/pages/api/upload.ts +1 -1
- package/src/plugins/examples/sample-plugin-2.ts +21 -0
- package/src/plugins/examples/sample-plugin.ts +21 -0
- package/src/plugins/index.ts +10 -0
- package/src/plugins/registry.ts +36 -0
- package/src/plugins/types.ts +22 -0
- package/src/styles/main.css +2 -41
- package/src/theme/ThemeProvider.tsx +238 -0
- package/src/theme/index.ts +20 -0
- package/src/theme/tokens.ts +222 -0
- package/src/components/Modal.tsx +0 -206
- package/src/components/index.ts +0 -29
- package/src/env.ts +0 -20
- package/src/lib/i18n.tsx +0 -353
- package/src/lib/validation.ts +0 -250
- package/src/pages/api/globals/[slug]/test.ts +0 -171
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import type { APIRoute } from "astro";
|
|
2
|
-
import { dataStore } from "../../../../../lib/dataStore";
|
|
3
|
-
import nodemailer, { createTransport } from "nodemailer";
|
|
4
|
-
|
|
5
|
-
export const POST: APIRoute = async ({ params, request }) => {
|
|
6
|
-
const slug = params.slug as string;
|
|
7
|
-
|
|
8
|
-
let body;
|
|
9
|
-
try {
|
|
10
|
-
body = await request.json();
|
|
11
|
-
} catch (e) {
|
|
12
|
-
body = {};
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
try {
|
|
16
|
-
const globalConfig = await dataStore.findGlobal(slug);
|
|
17
|
-
|
|
18
|
-
const testEmail = body?.email || globalConfig?.testEmail;
|
|
19
|
-
|
|
20
|
-
if (!testEmail) {
|
|
21
|
-
return new Response(
|
|
22
|
-
JSON.stringify({ error: "Please enter a test email address" }),
|
|
23
|
-
{ status: 400, headers: { "Content-Type": "application/json" } },
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
28
|
-
if (!emailRegex.test(testEmail)) {
|
|
29
|
-
return new Response(
|
|
30
|
-
JSON.stringify({ error: "Invalid email address format" }),
|
|
31
|
-
{ status: 400, headers: { "Content-Type": "application/json" } },
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const emailSettings = globalConfig;
|
|
36
|
-
const provider = emailSettings?.provider;
|
|
37
|
-
|
|
38
|
-
if (!provider) {
|
|
39
|
-
return new Response(
|
|
40
|
-
JSON.stringify({
|
|
41
|
-
error:
|
|
42
|
-
"No email provider configured. Please configure your email settings first.",
|
|
43
|
-
}),
|
|
44
|
-
{ status: 400, headers: { "Content-Type": "application/json" } },
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
let transporter;
|
|
49
|
-
|
|
50
|
-
const transporterOptions = {
|
|
51
|
-
timeout: 10000, // 10 second timeout
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
if (provider === "smtp" && emailSettings?.smtp) {
|
|
55
|
-
transporter = createTransport({
|
|
56
|
-
...transporterOptions,
|
|
57
|
-
host: emailSettings.smtp.host,
|
|
58
|
-
port: parseInt(emailSettings.smtp.port) || 587,
|
|
59
|
-
secure: emailSettings.smtp.secure || false,
|
|
60
|
-
auth: {
|
|
61
|
-
user: emailSettings.smtp.username,
|
|
62
|
-
pass: emailSettings.smtp.password,
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
} else if (provider === "ses" && emailSettings?.ses) {
|
|
66
|
-
transporter = createTransport({
|
|
67
|
-
...transporterOptions,
|
|
68
|
-
host: `email-smtp.${emailSettings.ses.region}.amazonaws.com`,
|
|
69
|
-
port: 587,
|
|
70
|
-
secure: false,
|
|
71
|
-
auth: {
|
|
72
|
-
user: emailSettings.ses.accessKeyId,
|
|
73
|
-
pass: emailSettings.ses.secretAccessKey,
|
|
74
|
-
},
|
|
75
|
-
});
|
|
76
|
-
} else if (provider === "resend" && emailSettings?.resend?.apiKey) {
|
|
77
|
-
transporter = createTransport({
|
|
78
|
-
...transporterOptions,
|
|
79
|
-
host: "smtp.resend.com",
|
|
80
|
-
port: 587,
|
|
81
|
-
secure: false,
|
|
82
|
-
auth: {
|
|
83
|
-
user: "resend",
|
|
84
|
-
pass: emailSettings.resend.apiKey,
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
} else if (provider === "sendgrid" && emailSettings?.sendgrid?.apiKey) {
|
|
88
|
-
transporter = createTransport({
|
|
89
|
-
...transporterOptions,
|
|
90
|
-
host: "smtp.sendgrid.net",
|
|
91
|
-
port: 587,
|
|
92
|
-
secure: false,
|
|
93
|
-
auth: {
|
|
94
|
-
user: "apikey",
|
|
95
|
-
pass: emailSettings.sendgrid.apiKey,
|
|
96
|
-
},
|
|
97
|
-
});
|
|
98
|
-
} else {
|
|
99
|
-
return new Response(
|
|
100
|
-
JSON.stringify({
|
|
101
|
-
error: `Provider ${provider} not supported or not configured`,
|
|
102
|
-
}),
|
|
103
|
-
{ status: 400, headers: { "Content-Type": "application/json" } },
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const fromEmail =
|
|
108
|
-
emailSettings?.fromEmail || emailSettings?.from || "noreply@example.com";
|
|
109
|
-
const fromName = emailSettings?.fromName || "Kyro CMS";
|
|
110
|
-
|
|
111
|
-
const info = await transporter.sendMail({
|
|
112
|
-
from: `"${fromName}" <${fromEmail}>`,
|
|
113
|
-
to: testEmail,
|
|
114
|
-
subject: "Test Email - Kyro CMS",
|
|
115
|
-
html: `
|
|
116
|
-
<!DOCTYPE html>
|
|
117
|
-
<html>
|
|
118
|
-
<head>
|
|
119
|
-
<meta charset="utf-8">
|
|
120
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
121
|
-
<title>Test Email</title>
|
|
122
|
-
</head>
|
|
123
|
-
<body style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; line-height: 1.6; color: #333;">
|
|
124
|
-
<div style="max-width:600px; margin:0 auto; padding:20px;">
|
|
125
|
-
<h1 style="color:#0b1222;">Test Email Successful!</h1>
|
|
126
|
-
<p>This is a test email from <strong>Kyro CMS</strong>.</p>
|
|
127
|
-
<p>If you received this email, your email settings are configured correctly.</p>
|
|
128
|
-
<hr style="border:none; border-top:1px solid #e2e8f0; margin:20px 0;">
|
|
129
|
-
<p style="font-size:12px; color:#666;">
|
|
130
|
-
Sent to: ${testEmail}<br>
|
|
131
|
-
Provider: ${provider}
|
|
132
|
-
</p>
|
|
133
|
-
</div>
|
|
134
|
-
</body>
|
|
135
|
-
</html>
|
|
136
|
-
`,
|
|
137
|
-
text: `Test Email Successful!\n\nThis is a test email from Kyro CMS.\nIf you received this email, your email settings are configured correctly.\n\nSent to: ${testEmail}\nProvider: ${provider}`,
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
console.log(info);
|
|
141
|
-
return new Response(
|
|
142
|
-
JSON.stringify({
|
|
143
|
-
success: true,
|
|
144
|
-
message: `Test email sent to ${testEmail}`,
|
|
145
|
-
messageId: info.messageId,
|
|
146
|
-
}),
|
|
147
|
-
{ status: 200, headers: { "Content-Type": "application/json" } },
|
|
148
|
-
);
|
|
149
|
-
} catch (error: any) {
|
|
150
|
-
console.log(error);
|
|
151
|
-
let errorMessage = "Failed to send test email";
|
|
152
|
-
|
|
153
|
-
if (error.code === "ECONNREFUSED") {
|
|
154
|
-
errorMessage = "Connection refused. Check your SMTP host and port.";
|
|
155
|
-
} else if (error.code === "ETIMEDOUT") {
|
|
156
|
-
errorMessage = "Connection timed out. Check your SMTP host and port.";
|
|
157
|
-
} else if (error.code === "ENOTFOUND") {
|
|
158
|
-
errorMessage = "Host not found. Check your SMTP hostname.";
|
|
159
|
-
} else if (error.code === "EAUTH") {
|
|
160
|
-
errorMessage = "Authentication failed. Check your username/password.";
|
|
161
|
-
} else if (error.message) {
|
|
162
|
-
errorMessage = error.message;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
console.error("[test-email] Error:", errorMessage, error.stack);
|
|
166
|
-
return new Response(JSON.stringify({ error: errorMessage }), {
|
|
167
|
-
status: 500,
|
|
168
|
-
headers: { "Content-Type": "application/json" },
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
};
|