@contentgrowth/content-emailing 0.7.7 → 0.7.8

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/index.cjs CHANGED
@@ -37,7 +37,7 @@ __export(index_exports, {
37
37
  createDOCacheProvider: () => createDOCacheProvider,
38
38
  createEmailLoggerCallback: () => createEmailLoggerCallback,
39
39
  createEmailRoutes: () => createEmailRoutes,
40
- createTemplateRoutes: () => createTemplateRoutes2,
40
+ createTemplateRoutes: () => createTemplateRoutes,
41
41
  createTrackingRoutes: () => createTrackingRoutes,
42
42
  encodeTrackingLinks: () => encodeTrackingLinks,
43
43
  extractVariables: () => extractVariables,
@@ -1473,7 +1473,7 @@ function createSettingsRoutes(config = {}) {
1473
1473
 
1474
1474
  // src/backend/routes/templates.js
1475
1475
  var import_hono2 = require("hono");
1476
- function createTemplateRoutes2(config = {}) {
1476
+ function createTemplateRoutes(config = {}) {
1477
1477
  const app = new import_hono2.Hono();
1478
1478
  app.get("/", async (c) => {
1479
1479
  const emailService = new EmailService(c.env, config);
@@ -1730,6 +1730,36 @@ function createTrackingRoutes(env, config = {}) {
1730
1730
 
1731
1731
  // src/backend/routes/logs.js
1732
1732
  var import_hono4 = require("hono");
1733
+ function createLogRoutes(config = {}) {
1734
+ const app = new import_hono4.Hono();
1735
+ app.get("/", async (c) => {
1736
+ const limit = Math.min(parseInt(c.req.query("limit") || "50"), 100);
1737
+ const offset = parseInt(c.req.query("offset") || "0");
1738
+ const env = c.env;
1739
+ try {
1740
+ const table = `${config.emailTablePrefix || "system_email_"}logs`;
1741
+ const { results } = await env.DB.prepare(`
1742
+ SELECT * FROM ${table}
1743
+ ORDER BY created_at DESC
1744
+ LIMIT ? OFFSET ?
1745
+ `).bind(limit, offset).all();
1746
+ const countResult = await env.DB.prepare(`SELECT COUNT(*) as exact_count FROM ${table}`).first();
1747
+ return c.json({
1748
+ logs: results.map((row) => ({
1749
+ ...row,
1750
+ metadata: row.metadata ? JSON.parse(row.metadata) : null
1751
+ })),
1752
+ total: countResult.exact_count,
1753
+ limit,
1754
+ offset
1755
+ });
1756
+ } catch (error) {
1757
+ console.error("Failed to fetch logs:", error);
1758
+ return c.json({ error: "Failed to fetch logs" }, 500);
1759
+ }
1760
+ });
1761
+ return app;
1762
+ }
1733
1763
 
1734
1764
  // src/backend/routes/index.js
1735
1765
  function createEmailRoutes(config = {}, cacheProvider = null) {