@contentgrowth/content-emailing 0.7.7 → 0.7.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{TemplateManager-Db41KyPN.d.cts → TemplateManager-DbAGIGdI.d.cts} +1 -1
- package/dist/{TemplateManager-Db41KyPN.d.ts → TemplateManager-DbAGIGdI.d.ts} +1 -1
- package/dist/backend/index.cjs +62 -2
- package/dist/backend/index.cjs.map +1 -1
- package/dist/backend/index.js +62 -2
- package/dist/backend/index.js.map +1 -1
- package/dist/backend/routes/index.cjs +90 -60
- package/dist/backend/routes/index.cjs.map +1 -1
- package/dist/backend/routes/index.d.cts +15 -12
- package/dist/backend/routes/index.d.ts +15 -12
- package/dist/backend/routes/index.js +90 -60
- package/dist/backend/routes/index.js.map +1 -1
- package/dist/frontend/index.cjs +4 -4
- package/dist/frontend/index.cjs.map +1 -1
- package/dist/frontend/index.d.cts +1 -1
- package/dist/frontend/index.d.ts +1 -1
- package/dist/frontend/index.js +4 -4
- package/dist/frontend/index.js.map +1 -1
- package/dist/index.cjs +63 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +63 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -30,9 +30,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
var routes_exports = {};
|
|
31
31
|
__export(routes_exports, {
|
|
32
32
|
createEmailRoutes: () => createEmailRoutes,
|
|
33
|
-
createLogRoutes: () =>
|
|
33
|
+
createLogRoutes: () => createLogRoutes,
|
|
34
34
|
createSettingsRoutes: () => createSettingsRoutes,
|
|
35
|
-
createTemplateRoutes: () =>
|
|
35
|
+
createTemplateRoutes: () => createTemplateRoutes,
|
|
36
36
|
createTrackingRoutes: () => createTrackingRoutes
|
|
37
37
|
});
|
|
38
38
|
module.exports = __toCommonJS(routes_exports);
|
|
@@ -40,62 +40,6 @@ var import_hono5 = require("hono");
|
|
|
40
40
|
|
|
41
41
|
// src/backend/routes/settings.js
|
|
42
42
|
var import_hono = require("hono");
|
|
43
|
-
function createSettingsRoutes(config = {}) {
|
|
44
|
-
const app = new import_hono.Hono();
|
|
45
|
-
const tableName = config.tableName || "system_settings";
|
|
46
|
-
const keyPrefix = config.keyPrefix || "system_email.";
|
|
47
|
-
const getSettings = async (db) => {
|
|
48
|
-
try {
|
|
49
|
-
const { results } = await db.prepare(`SELECT * FROM ${tableName} WHERE key LIKE ?`).bind(`${keyPrefix}%`).all();
|
|
50
|
-
const settings = {};
|
|
51
|
-
for (const row of results) {
|
|
52
|
-
const cleanKey = row.key.slice(keyPrefix.length);
|
|
53
|
-
settings[cleanKey] = row.value;
|
|
54
|
-
}
|
|
55
|
-
return settings;
|
|
56
|
-
} catch (e) {
|
|
57
|
-
console.warn(`[Settings] Failed to fetch from ${tableName}:`, e.message);
|
|
58
|
-
return {};
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
app.get("/", async (c) => {
|
|
62
|
-
try {
|
|
63
|
-
const settings = await getSettings(c.env.DB);
|
|
64
|
-
return c.json(settings);
|
|
65
|
-
} catch (error) {
|
|
66
|
-
console.error("Failed to fetch settings:", error);
|
|
67
|
-
return c.json({ error: error.message }, 500);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
app.post("/", async (c) => {
|
|
71
|
-
try {
|
|
72
|
-
const body = await c.req.json();
|
|
73
|
-
const db = c.env.DB;
|
|
74
|
-
const updates = Object.entries(body).map(([k, v]) => ({
|
|
75
|
-
key: `${keyPrefix}${k}`,
|
|
76
|
-
value: v
|
|
77
|
-
}));
|
|
78
|
-
if (updates.length === 0) return c.json({ success: true });
|
|
79
|
-
const stmt = db.prepare(`
|
|
80
|
-
INSERT INTO ${tableName} (key, value, updated_at)
|
|
81
|
-
VALUES (?, ?, strftime('%s', 'now'))
|
|
82
|
-
ON CONFLICT(key) DO UPDATE SET
|
|
83
|
-
value = excluded.value,
|
|
84
|
-
updated_at = excluded.updated_at
|
|
85
|
-
`);
|
|
86
|
-
const batch = updates.map((u) => stmt.bind(u.key, u.value === void 0 || u.value === null ? "" : String(u.value)));
|
|
87
|
-
await db.batch(batch);
|
|
88
|
-
return c.json({ success: true });
|
|
89
|
-
} catch (error) {
|
|
90
|
-
console.error("Failed to save settings:", error);
|
|
91
|
-
return c.json({ error: error.message }, 500);
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
return app;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// src/backend/routes/templates.js
|
|
98
|
-
var import_hono2 = require("hono");
|
|
99
43
|
|
|
100
44
|
// src/backend/EmailService.js
|
|
101
45
|
var import_marked = require("marked");
|
|
@@ -1172,8 +1116,94 @@ var EmailService = class {
|
|
|
1172
1116
|
}
|
|
1173
1117
|
};
|
|
1174
1118
|
|
|
1119
|
+
// src/backend/routes/settings.js
|
|
1120
|
+
function createSettingsRoutes(config = {}) {
|
|
1121
|
+
const app = new import_hono.Hono();
|
|
1122
|
+
const tableName = config.tableName || "system_settings";
|
|
1123
|
+
const keyPrefix = config.keyPrefix || "system_email.";
|
|
1124
|
+
const getSettings = async (db) => {
|
|
1125
|
+
try {
|
|
1126
|
+
const { results } = await db.prepare(`SELECT * FROM ${tableName} WHERE key LIKE ?`).bind(`${keyPrefix}%`).all();
|
|
1127
|
+
const settings = {};
|
|
1128
|
+
for (const row of results) {
|
|
1129
|
+
const cleanKey = row.key.slice(keyPrefix.length);
|
|
1130
|
+
settings[cleanKey] = row.value;
|
|
1131
|
+
}
|
|
1132
|
+
return settings;
|
|
1133
|
+
} catch (e) {
|
|
1134
|
+
console.warn(`[Settings] Failed to fetch from ${tableName}:`, e.message);
|
|
1135
|
+
return {};
|
|
1136
|
+
}
|
|
1137
|
+
};
|
|
1138
|
+
app.get("/", async (c) => {
|
|
1139
|
+
try {
|
|
1140
|
+
const settings = await getSettings(c.env.DB);
|
|
1141
|
+
return c.json(settings);
|
|
1142
|
+
} catch (error) {
|
|
1143
|
+
console.error("Failed to fetch settings:", error);
|
|
1144
|
+
return c.json({ error: error.message }, 500);
|
|
1145
|
+
}
|
|
1146
|
+
});
|
|
1147
|
+
app.post("/", async (c) => {
|
|
1148
|
+
try {
|
|
1149
|
+
const body = await c.req.json();
|
|
1150
|
+
const db = c.env.DB;
|
|
1151
|
+
const updates = Object.entries(body).map(([k, v]) => ({
|
|
1152
|
+
key: `${keyPrefix}${k}`,
|
|
1153
|
+
value: v
|
|
1154
|
+
}));
|
|
1155
|
+
if (updates.length === 0) return c.json({ success: true });
|
|
1156
|
+
const stmt = db.prepare(`
|
|
1157
|
+
INSERT INTO ${tableName} (key, value, updated_at)
|
|
1158
|
+
VALUES (?, ?, strftime('%s', 'now'))
|
|
1159
|
+
ON CONFLICT(key) DO UPDATE SET
|
|
1160
|
+
value = excluded.value,
|
|
1161
|
+
updated_at = excluded.updated_at
|
|
1162
|
+
`);
|
|
1163
|
+
const batch = updates.map((u) => stmt.bind(u.key, u.value === void 0 || u.value === null ? "" : String(u.value)));
|
|
1164
|
+
await db.batch(batch);
|
|
1165
|
+
return c.json({ success: true });
|
|
1166
|
+
} catch (error) {
|
|
1167
|
+
console.error("Failed to save settings:", error);
|
|
1168
|
+
return c.json({ error: error.message }, 500);
|
|
1169
|
+
}
|
|
1170
|
+
});
|
|
1171
|
+
app.post("/test", async (c) => {
|
|
1172
|
+
try {
|
|
1173
|
+
const settings = await c.req.json();
|
|
1174
|
+
const user = c.get("dbUser") || c.get("user");
|
|
1175
|
+
if (!user || !user.email) {
|
|
1176
|
+
return c.json({ error: "User email not found for testing" }, 400);
|
|
1177
|
+
}
|
|
1178
|
+
const emailService = new EmailService(c.env, {
|
|
1179
|
+
...config,
|
|
1180
|
+
settingsLoader: async () => settings
|
|
1181
|
+
});
|
|
1182
|
+
const result = await emailService.sendEmail({
|
|
1183
|
+
to: user.email,
|
|
1184
|
+
subject: "Test Email Configuration",
|
|
1185
|
+
html: "<h1>It Works!</h1><p>Your email settings are configured correctly.</p>",
|
|
1186
|
+
text: "It Works! Your email settings are configured correctly.",
|
|
1187
|
+
profile: "system",
|
|
1188
|
+
// Use system defaults logic in service, but our loader overrides it
|
|
1189
|
+
userId: user.id
|
|
1190
|
+
});
|
|
1191
|
+
if (result.success) {
|
|
1192
|
+
return c.json({ success: true, message: `Test email sent to ${user.email}` });
|
|
1193
|
+
} else {
|
|
1194
|
+
return c.json({ success: false, error: result.error || "Failed to send test email" }, 400);
|
|
1195
|
+
}
|
|
1196
|
+
} catch (error) {
|
|
1197
|
+
console.error("Test settings failed:", error);
|
|
1198
|
+
return c.json({ error: error.message }, 500);
|
|
1199
|
+
}
|
|
1200
|
+
});
|
|
1201
|
+
return app;
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1175
1204
|
// src/backend/routes/templates.js
|
|
1176
|
-
|
|
1205
|
+
var import_hono2 = require("hono");
|
|
1206
|
+
function createTemplateRoutes(config = {}) {
|
|
1177
1207
|
const app = new import_hono2.Hono();
|
|
1178
1208
|
app.get("/", async (c) => {
|
|
1179
1209
|
const emailService = new EmailService(c.env, config);
|
|
@@ -1430,7 +1460,7 @@ function createTrackingRoutes(env, config = {}) {
|
|
|
1430
1460
|
|
|
1431
1461
|
// src/backend/routes/logs.js
|
|
1432
1462
|
var import_hono4 = require("hono");
|
|
1433
|
-
function
|
|
1463
|
+
function createLogRoutes(config = {}) {
|
|
1434
1464
|
const app = new import_hono4.Hono();
|
|
1435
1465
|
app.get("/", async (c) => {
|
|
1436
1466
|
const limit = Math.min(parseInt(c.req.query("limit") || "50"), 100);
|