@hintergrund/worker 0.1.2 → 0.1.5

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.
Files changed (79) hide show
  1. package/dist/api/cms/handlers/assets.handler.d.ts +24 -1
  2. package/dist/api/cms/handlers/assets.handler.d.ts.map +1 -1
  3. package/dist/api/cms/handlers/assets.handler.js +111 -210
  4. package/dist/api/cms/handlers/auth.handler.d.ts +4 -3
  5. package/dist/api/cms/handlers/auth.handler.d.ts.map +1 -1
  6. package/dist/api/cms/handlers/auth.handler.js +24 -14
  7. package/dist/api/cms/handlers/config.handler.d.ts +4 -0
  8. package/dist/api/cms/handlers/config.handler.d.ts.map +1 -1
  9. package/dist/api/cms/handlers/config.handler.js +20 -71
  10. package/dist/api/cms/handlers/content.handler.d.ts +12 -1
  11. package/dist/api/cms/handlers/content.handler.d.ts.map +1 -1
  12. package/dist/api/cms/handlers/content.handler.js +57 -233
  13. package/dist/api/cms/handlers/dashboard.handler.js +1 -1
  14. package/dist/api/cms/routes/auth.routes.d.ts +2 -1
  15. package/dist/api/cms/routes/auth.routes.d.ts.map +1 -1
  16. package/dist/api/cms/routes/auth.routes.js +7 -0
  17. package/dist/api/cms/routes/index.d.ts +2 -1
  18. package/dist/api/cms/routes/index.d.ts.map +1 -1
  19. package/dist/api/emails/handlers/branding.handler.d.ts +17 -0
  20. package/dist/api/emails/handlers/branding.handler.d.ts.map +1 -0
  21. package/dist/api/emails/handlers/branding.handler.js +120 -0
  22. package/dist/api/emails/handlers/campaigns.handler.d.ts +32 -0
  23. package/dist/api/emails/handlers/campaigns.handler.d.ts.map +1 -0
  24. package/dist/api/emails/handlers/campaigns.handler.js +139 -0
  25. package/dist/api/emails/handlers/contacts.handler.d.ts +37 -0
  26. package/dist/api/emails/handlers/contacts.handler.d.ts.map +1 -0
  27. package/dist/api/emails/handlers/contacts.handler.js +161 -0
  28. package/dist/api/emails/handlers/invoice.handler.d.ts +30 -0
  29. package/dist/api/emails/handlers/invoice.handler.d.ts.map +1 -0
  30. package/dist/api/emails/handlers/invoice.handler.js +463 -0
  31. package/dist/api/emails/handlers/public.handler.d.ts +36 -0
  32. package/dist/api/emails/handlers/public.handler.d.ts.map +1 -0
  33. package/dist/api/emails/handlers/public.handler.js +350 -0
  34. package/dist/api/emails/handlers/send.handler.d.ts +23 -0
  35. package/dist/api/emails/handlers/send.handler.d.ts.map +1 -0
  36. package/dist/api/emails/handlers/send.handler.js +117 -0
  37. package/dist/api/emails/handlers/settings.handler.d.ts +36 -0
  38. package/dist/api/emails/handlers/settings.handler.d.ts.map +1 -0
  39. package/dist/api/emails/handlers/settings.handler.js +312 -0
  40. package/dist/api/emails/handlers/templates.handler.d.ts +32 -0
  41. package/dist/api/emails/handlers/templates.handler.d.ts.map +1 -0
  42. package/dist/api/emails/handlers/templates.handler.js +132 -0
  43. package/dist/api/emails/handlers/webhook.handler.d.ts +10 -0
  44. package/dist/api/emails/handlers/webhook.handler.d.ts.map +1 -0
  45. package/dist/api/emails/handlers/webhook.handler.js +261 -0
  46. package/dist/api/emails/routes/admin.routes.d.ts +9 -0
  47. package/dist/api/emails/routes/admin.routes.d.ts.map +1 -0
  48. package/dist/api/emails/routes/admin.routes.js +77 -0
  49. package/dist/api/emails/routes/index.d.ts +9 -0
  50. package/dist/api/emails/routes/index.d.ts.map +1 -0
  51. package/dist/api/emails/routes/index.js +14 -0
  52. package/dist/api/emails/routes/public.routes.d.ts +9 -0
  53. package/dist/api/emails/routes/public.routes.d.ts.map +1 -0
  54. package/dist/api/emails/routes/public.routes.js +18 -0
  55. package/dist/api/shop/handlers/webhook.handler.d.ts.map +1 -1
  56. package/dist/api/shop/handlers/webhook.handler.js +66 -60
  57. package/dist/api/shop/routes.d.ts.map +1 -1
  58. package/dist/api/shop/routes.js +0 -3
  59. package/dist/hintergrund-assets.d.ts +2 -2
  60. package/dist/hintergrund-assets.d.ts.map +1 -1
  61. package/dist/hintergrund-assets.js +2 -2
  62. package/dist/index.d.ts +20 -19
  63. package/dist/index.d.ts.map +1 -1
  64. package/dist/index.js +4 -7
  65. package/dist/lib/config.d.ts +13 -7
  66. package/dist/lib/config.d.ts.map +1 -1
  67. package/dist/lib/config.js +44 -46
  68. package/dist/lib/email.d.ts +2 -2
  69. package/dist/lib/email.d.ts.map +1 -1
  70. package/dist/lib/email.js +7 -9
  71. package/dist/lib/github.d.ts +124 -0
  72. package/dist/lib/github.d.ts.map +1 -0
  73. package/dist/lib/github.js +286 -0
  74. package/dist/lib/plunk.d.ts +204 -0
  75. package/dist/lib/plunk.d.ts.map +1 -0
  76. package/dist/lib/plunk.js +259 -0
  77. package/dist/middleware/auth.d.ts.map +1 -1
  78. package/dist/middleware/auth.js +2 -5
  79. package/package.json +32 -32
package/dist/index.d.ts CHANGED
@@ -3,32 +3,33 @@ export type Bindings = {
3
3
  HG_CONFIG?: string;
4
4
  HG_SECRET?: string;
5
5
  HG_PASSWORD?: string;
6
- HG_CMS_GIT_TOKEN?: string;
7
- HG_CMS_GIT_OWNER?: string;
8
- HG_CMS_GIT_REPO?: string;
9
- HG_CMS_GIT_BRANCH?: string;
10
- HG_CMS_CONTENT_DIR?: string;
11
- HG_CMS_ASSET_DIR?: string;
12
- HG_NEWSLETTER_EMAIL_PROVIDER?: string;
13
- HG_NEWSLETTER_EMAIL_API_KEY?: string;
14
- HG_NEWSLETTER_FROM_EMAIL?: string;
15
- HG_NEWSLETTER_FROM_NAME?: string;
16
- HG_NEWSLETTER_REPLY_TO?: string;
17
- HG_NEWSLETTER_CONFIRMATION_URL?: string;
6
+ HG_GIT_TOKEN?: string;
7
+ HG_GIT_OWNER?: string;
8
+ HG_GIT_REPO?: string;
9
+ HG_GIT_BRANCH?: string;
10
+ HG_EMAILS_PLUNK_SECRET_KEY?: string;
11
+ HG_EMAILS_PLUNK_PUBLIC_KEY?: string;
12
+ HG_EMAILS_FROM_EMAIL?: string;
13
+ HG_EMAILS_FROM_NAME?: string;
14
+ HG_EMAILS_REPLY_TO?: string;
18
15
  HG_SHOP_STRIPE_SECRET_KEY?: string;
19
16
  HG_SHOP_STRIPE_WEBHOOK_SECRET?: string;
20
17
  HG_SHOP_STRIPE_PUBLISHABLE_KEY?: string;
21
- HG_BUILDER_GEMINI_API_KEY?: string;
22
- HG_BUILDER_GIT_TOKEN?: string;
23
- HG_BUILDER_TEMPLATE_REPO?: string;
24
- HG_BUILDER_GIT_BRANCH?: string;
25
18
  UI_BASE_URL: string;
26
19
  ASSETS: Fetcher;
27
- DB: D1Database;
28
20
  };
29
- export declare function createApp(): Hono<{
21
+ export type Variables = {
22
+ user?: {
23
+ email: string;
24
+ userGroup?: string;
25
+ modules?: string[];
26
+ };
27
+ };
28
+ export type HonoEnv = {
30
29
  Bindings: Bindings;
31
- }, import("hono/types").BlankSchema, "/">;
30
+ Variables: Variables;
31
+ };
32
+ export declare function createApp(): Hono<HonoEnv, import("hono/types").BlankSchema, "/">;
32
33
  export * from './lib/auth/jwt';
33
34
  export * from './lib/auth/crypto';
34
35
  export * from './lib/template';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAS5B,MAAM,MAAM,QAAQ,GAAG;IAEtB,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IAGrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAG1B,4BAA4B,CAAC,EAAE,MAAM,CAAC;IACtC,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,wBAAwB,CAAC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C;IAG5B,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,6BAA6B,CAAC,EAAE,MAAM,CAAC;IACvC,8BAA8B,CAAC,EAAE,MAAM,CAAC;IAGxC,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACvB,IAAI,CAAC,EAAE;QACN,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;KACnB,CAAC;CACF,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,SAAS,EAAE,SAAS,CAAA;CAAE,CAAC;AAEnE,wBAAgB,SAAS,yDA8DxB;AAGD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -1,9 +1,8 @@
1
1
  import { Hono } from 'hono';
2
2
  import { cors } from 'hono/cors';
3
3
  import cmsRoutes from './api/cms/routes';
4
- import newsletterRoutes from './api/newsletter/routes';
4
+ import emailRoutes from './api/emails/routes';
5
5
  import shopRoutes from './api/shop/routes';
6
- // import builderRoutes from './api/builder/routes';
7
6
  import { authMiddleware } from './middleware/auth';
8
7
  import { getTemplate } from './lib/template';
9
8
  export function createApp() {
@@ -14,12 +13,10 @@ export function createApp() {
14
13
  app.get('/login', (c) => c.html(getTemplate('login', c.env.UI_BASE_URL)));
15
14
  // Mount CMS routes under /api/admin
16
15
  app.route('/api/admin', cmsRoutes);
17
- // Mount newsletter routes under /api/email
18
- app.route('/api/email', newsletterRoutes);
16
+ // Mount email routes under /api/email
17
+ app.route('/api/email', emailRoutes);
19
18
  // Mount shop routes under /api/shop
20
19
  app.route('/api/shop', shopRoutes);
21
- // Mount builder routes under /api/builder
22
- // app.route('/api/builder', builderRoutes);
23
20
  // Admin main page (protected)
24
21
  app.get('/admin', async (c) => {
25
22
  // Check authentication
@@ -40,7 +37,7 @@ export function createApp() {
40
37
  }
41
38
  catch (error) {
42
39
  // Fallback to default config if parsing fails
43
- const configParams = 'config=\'{"cms":true,"newsletter":false,"shop":false}\'';
40
+ const configParams = 'config=\'{"cms":true,"emails":false,"shop":false}\'';
44
41
  return c.html(getTemplate('admin', c.env.UI_BASE_URL, configParams));
45
42
  }
46
43
  });
@@ -1,4 +1,4 @@
1
- import type { AppConfig, AdminConfig, CmsModuleConfig, NewsletterModuleConfig, ShopModuleConfig, BuilderModuleConfig } from '@hintergrund/shared';
1
+ import type { AppConfig, AdminConfig, CmsModuleConfig, EmailsModuleConfig, ShopModuleConfig } from '@hintergrund/shared';
2
2
  /**
3
3
  * Load application configuration from environment variables
4
4
  * Supports both new modular env vars and legacy HG_CONFIG format
@@ -14,18 +14,24 @@ export declare function getAdminConfig(appConfig: AppConfig): AdminConfig;
14
14
  */
15
15
  export declare function getCmsConfig(env: Record<string, string | undefined> | any): CmsModuleConfig;
16
16
  /**
17
- * Get Newsletter module configuration
18
- * @throws Error if Newsletter module is not enabled
17
+ * Get Emails module configuration
18
+ * @throws Error if Emails module is not enabled
19
19
  */
20
- export declare function getNewsletterConfig(env: Record<string, string | undefined> | any): NewsletterModuleConfig;
20
+ export declare function getEmailsConfig(env: Record<string, string | undefined> | any): EmailsModuleConfig;
21
21
  /**
22
22
  * Get Shop module configuration
23
23
  * @throws Error if Shop module is not enabled
24
24
  */
25
25
  export declare function getShopConfig(env: Record<string, string | undefined> | any): ShopModuleConfig;
26
26
  /**
27
- * Get Builder module configuration
28
- * @throws Error if Builder module is not enabled
27
+ * Get GitHub configuration from environment variables
28
+ * Used by CMS, emails and other modules for GitHub storage
29
+ * @throws Error if GitHub is not configured (required variables missing)
29
30
  */
30
- export declare function getBuilderConfig(env: Record<string, string | undefined> | any): BuilderModuleConfig;
31
+ export declare function getGitHubConfig(env: Record<string, string | undefined> | any): {
32
+ gitToken: string;
33
+ gitOwner: string;
34
+ gitRepo: string;
35
+ gitBranch: string;
36
+ };
31
37
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,mBAAmB,EAAsC,MAAM,qBAAqB,CAAC;AAEtL;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,GAAG,GAAG,SAAS,CAOnF;AA0HD;;GAEG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,SAAS,GAAG,WAAW,CAShE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,GAAG,GAAG,eAAe,CAQ3F;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,GAAG,GAAG,sBAAsB,CAQzG;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,GAAG,GAAG,gBAAgB,CAQ7F;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,GAAG,GAAG,mBAAmB,CAQnG"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,kBAAkB,EAAE,gBAAgB,EAAsC,MAAM,qBAAqB,CAAC;AAE7J;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,GAAG,GAAG,SAAS,CAOnF;AAmHD;;GAEG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,SAAS,GAAG,WAAW,CAQhE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,GAAG,GAAG,eAAe,CAQ3F;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,GAAG,GAAG,kBAAkB,CAQjG;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,GAAG,GAAG,gBAAgB,CAQ7F;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,GAAG,GAAG;IAC/E,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CAClB,CAYA"}
@@ -22,10 +22,10 @@ function hasAnyVar(env, vars) {
22
22
  return vars.some(varName => !!env[varName]);
23
23
  }
24
24
  // Module required variables definitions
25
- const CMS_REQUIRED_VARS = ['HG_CMS_GIT_TOKEN', 'HG_CMS_GIT_OWNER', 'HG_CMS_GIT_REPO'];
26
- const NEWSLETTER_REQUIRED_VARS = ['HG_NEWSLETTER_EMAIL_API_KEY', 'HG_NEWSLETTER_FROM_EMAIL'];
25
+ const GIT_REQUIRED_VARS = ['HG_GIT_TOKEN', 'HG_GIT_OWNER', 'HG_GIT_REPO'];
26
+ const CMS_REQUIRED_VARS = [...GIT_REQUIRED_VARS];
27
+ const EMAILS_REQUIRED_VARS = ['HG_EMAILS_PLUNK_SECRET_KEY', 'HG_EMAILS_FROM_EMAIL'];
27
28
  const SHOP_REQUIRED_VARS = ['HG_SHOP_STRIPE_SECRET_KEY'];
28
- const BUILDER_REQUIRED_VARS = ['HG_BUILDER_GEMINI_API_KEY', 'HG_BUILDER_GIT_TOKEN'];
29
29
  /**
30
30
  * Parse user groups from environment variable
31
31
  * Format: JSON array of UserGroup objects
@@ -53,10 +53,14 @@ function loadFromEnvVars(env) {
53
53
  // Build auth configuration
54
54
  const loginMethod = env.HG_AUTH_METHOD || 'password';
55
55
  const userGroups = parseUserGroups(env);
56
+ // Parse allowed emails whitelist
57
+ const allowedEmailsRaw = env.HG_AUTH_ALLOWED_EMAILS;
58
+ const allowedEmails = allowedEmailsRaw
59
+ ? allowedEmailsRaw.split(',').map((e) => e.trim()).filter((e) => e.length > 0)
60
+ : undefined;
56
61
  const authConfig = env.HG_AUTH_METHOD ? {
57
62
  loginMethod,
58
- resendApiKey: env.HG_AUTH_RESEND_API_KEY,
59
- fromEmail: env.HG_AUTH_FROM_EMAIL,
63
+ allowedEmails,
60
64
  userGroups,
61
65
  } : undefined;
62
66
  const config = {
@@ -71,24 +75,24 @@ function loadFromEnvVars(env) {
71
75
  if (cmsMissing.length === 0) {
72
76
  config.cms = {
73
77
  enabled: true,
74
- gitToken: env.HG_CMS_GIT_TOKEN || '',
75
- gitOwner: env.HG_CMS_GIT_OWNER || '',
76
- gitRepo: env.HG_CMS_GIT_REPO || '',
77
- gitBranch: env.HG_CMS_GIT_BRANCH || 'main',
78
- contentDir: env.HG_CMS_CONTENT_DIR || 'content',
79
- assetDir: env.HG_CMS_ASSET_DIR || 'assets',
78
+ gitToken: env.HG_GIT_TOKEN || '',
79
+ gitOwner: env.HG_GIT_OWNER || '',
80
+ gitRepo: env.HG_GIT_REPO || '',
81
+ gitBranch: env.HG_GIT_BRANCH || 'main',
82
+ contentDir: 'frontend/src/lib/content',
83
+ assetDir: 'frontend/static',
80
84
  };
81
85
  }
82
- // Load Newsletter module config (auto-detect based on required vars)
83
- const newsletterMissing = getMissingVars(env, NEWSLETTER_REQUIRED_VARS);
84
- if (newsletterMissing.length === 0) {
85
- config.newsletter = {
86
+ // Load Emails module config (auto-detect based on required vars)
87
+ const emailsMissing = getMissingVars(env, EMAILS_REQUIRED_VARS);
88
+ if (emailsMissing.length === 0) {
89
+ config.emails = {
86
90
  enabled: true,
87
- emailProvider: env.HG_NEWSLETTER_EMAIL_PROVIDER || 'resend',
88
- emailApiKey: env.HG_NEWSLETTER_EMAIL_API_KEY || '',
89
- fromEmail: env.HG_NEWSLETTER_FROM_EMAIL || '',
90
- fromName: env.HG_NEWSLETTER_FROM_NAME || '',
91
- replyTo: env.HG_NEWSLETTER_REPLY_TO,
91
+ plunkSecretKey: env.HG_EMAILS_PLUNK_SECRET_KEY || '',
92
+ plunkPublicKey: env.HG_EMAILS_PLUNK_PUBLIC_KEY,
93
+ fromEmail: env.HG_EMAILS_FROM_EMAIL || '',
94
+ fromName: env.HG_EMAILS_FROM_NAME || '',
95
+ replyTo: env.HG_EMAILS_REPLY_TO,
92
96
  };
93
97
  }
94
98
  // Load Shop module config (auto-detect based on required vars)
@@ -102,17 +106,6 @@ function loadFromEnvVars(env) {
102
106
  stripePublishableKey: env.HG_SHOP_STRIPE_PUBLISHABLE_KEY,
103
107
  };
104
108
  }
105
- // Load Builder module config (auto-detect based on required vars)
106
- /* const builderMissing = getMissingVars(env, BUILDER_REQUIRED_VARS);
107
- if (builderMissing.length === 0) {
108
- config.builder = {
109
- enabled: true,
110
- geminiApiKey: env.HG_BUILDER_GEMINI_API_KEY || '',
111
- gitToken: env.HG_BUILDER_GIT_TOKEN || '',
112
- templateRepo: env.HG_BUILDER_TEMPLATE_REPO || 'hintergrund-cloud/demo-shop',
113
- gitBranch: env.HG_BUILDER_GIT_BRANCH || 'main',
114
- };
115
- } */
116
109
  return config;
117
110
  }
118
111
  /**
@@ -121,9 +114,8 @@ function loadFromEnvVars(env) {
121
114
  export function getAdminConfig(appConfig) {
122
115
  return {
123
116
  cms: appConfig.cms?.enabled ?? false,
124
- newsletter: appConfig.newsletter?.enabled ?? false,
117
+ emails: appConfig.emails?.enabled ?? false,
125
118
  shop: appConfig.shop?.enabled ?? false,
126
- builder: false, // appConfig.builder?.enabled ?? false,
127
119
  loginMethod: appConfig.global.auth?.loginMethod ?? 'password',
128
120
  userGroups: appConfig.global.auth?.userGroups?.map(g => g.name),
129
121
  };
@@ -140,15 +132,15 @@ export function getCmsConfig(env) {
140
132
  return config.cms;
141
133
  }
142
134
  /**
143
- * Get Newsletter module configuration
144
- * @throws Error if Newsletter module is not enabled
135
+ * Get Emails module configuration
136
+ * @throws Error if Emails module is not enabled
145
137
  */
146
- export function getNewsletterConfig(env) {
138
+ export function getEmailsConfig(env) {
147
139
  const config = loadConfig(env);
148
- if (!config.newsletter) {
149
- throw new Error('Newsletter module is not enabled');
140
+ if (!config.emails) {
141
+ throw new Error('Emails module is not enabled');
150
142
  }
151
- return config.newsletter;
143
+ return config.emails;
152
144
  }
153
145
  /**
154
146
  * Get Shop module configuration
@@ -162,13 +154,19 @@ export function getShopConfig(env) {
162
154
  return config.shop;
163
155
  }
164
156
  /**
165
- * Get Builder module configuration
166
- * @throws Error if Builder module is not enabled
157
+ * Get GitHub configuration from environment variables
158
+ * Used by CMS, emails and other modules for GitHub storage
159
+ * @throws Error if GitHub is not configured (required variables missing)
167
160
  */
168
- export function getBuilderConfig(env) {
169
- const config = loadConfig(env);
170
- if (!config.builder) {
171
- throw new Error('Builder module is not enabled');
161
+ export function getGitHubConfig(env) {
162
+ const missing = getMissingVars(env, GIT_REQUIRED_VARS);
163
+ if (missing.length > 0) {
164
+ throw new Error(`GitHub not configured. Missing: ${missing.join(', ')}`);
172
165
  }
173
- return config.builder;
166
+ return {
167
+ gitToken: env.HG_GIT_TOKEN,
168
+ gitOwner: env.HG_GIT_OWNER,
169
+ gitRepo: env.HG_GIT_REPO,
170
+ gitBranch: env.HG_GIT_BRANCH || 'main',
171
+ };
174
172
  }
@@ -3,8 +3,8 @@
3
3
  */
4
4
  interface SendMagicLinkParams {
5
5
  to: string;
6
- fromEmail: string;
7
- resendApiKey: string;
6
+ resendApiKey?: string;
7
+ plunkSecretKey: string;
8
8
  magicLinkUrl: string;
9
9
  userGroup?: string;
10
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../src/lib/email.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,UAAU,mBAAmB;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiFnF"}
1
+ {"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../src/lib/email.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,UAAU,mBAAmB;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CA+EnF"}
package/dist/lib/email.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * Send a magic link email for passwordless authentication
6
6
  */
7
7
  export async function sendMagicLinkEmail(params) {
8
- const { to, fromEmail, resendApiKey, magicLinkUrl, userGroup } = params;
8
+ const { to, plunkSecretKey, magicLinkUrl, userGroup } = params;
9
9
  const subject = 'Sign in to hintergrund';
10
10
  const groupInfo = userGroup ? ` as ${userGroup}` : '';
11
11
  const html = `
@@ -52,7 +52,7 @@ export async function sendMagicLinkEmail(params) {
52
52
  </body>
53
53
  </html>
54
54
  `;
55
- const text = `
55
+ const body = `
56
56
  Sign in to hintergrund${groupInfo}
57
57
 
58
58
  Click the link below to sign in. This link will expire in 15 minutes.
@@ -61,23 +61,21 @@ ${magicLinkUrl}
61
61
 
62
62
  If you didn't request this email, you can safely ignore it.
63
63
  `;
64
- const response = await fetch('https://api.resend.com/emails', {
64
+ const response = await fetch('https://api.useplunk.com/v1/send', {
65
65
  method: 'POST',
66
66
  headers: {
67
- 'Authorization': `Bearer ${resendApiKey}`,
67
+ 'Authorization': `Bearer ${plunkSecretKey}`,
68
68
  'Content-Type': 'application/json',
69
69
  },
70
70
  body: JSON.stringify({
71
- from: fromEmail,
72
- to: [to],
71
+ to,
73
72
  subject,
74
- html,
75
- text,
73
+ body: html,
76
74
  }),
77
75
  });
78
76
  if (!response.ok) {
79
77
  const error = await response.text();
80
- console.error('Resend API error:', error);
78
+ console.error('Plunk API error:', error);
81
79
  throw new Error(`Failed to send email: ${response.status}`);
82
80
  }
83
81
  }
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Shared GitHub Utilities
3
+ *
4
+ * Provides common GitHub operations for both CMS and Emails modules.
5
+ * Uses Octokit for GitHub API interactions with proper UTF-8 handling.
6
+ */
7
+ import { Octokit } from '@octokit/rest';
8
+ /**
9
+ * GitHub configuration for a module
10
+ */
11
+ export interface GitHubConfig {
12
+ gitToken: string;
13
+ gitOwner: string;
14
+ gitRepo: string;
15
+ gitBranch: string;
16
+ }
17
+ /**
18
+ * File entry for tree operations
19
+ */
20
+ export interface FileEntry {
21
+ path: string;
22
+ content: string;
23
+ }
24
+ /**
25
+ * File read result
26
+ */
27
+ export interface FileReadResult {
28
+ content: string;
29
+ sha: string;
30
+ }
31
+ /**
32
+ * Decode base64 content to UTF-8 string.
33
+ * atob() decodes to Latin-1, which corrupts multi-byte UTF-8 characters.
34
+ */
35
+ export declare function decodeBase64UTF8(base64: string): string;
36
+ /**
37
+ * Encode UTF-8 string to base64.
38
+ * btoa() only works with Latin-1, which corrupts multi-byte UTF-8 characters like ß.
39
+ */
40
+ export declare function encodeUTF8Base64(str: string): string;
41
+ /**
42
+ * GitHub client wrapper for common operations
43
+ */
44
+ export declare class GitHubClient {
45
+ private octokit;
46
+ private owner;
47
+ private repo;
48
+ private branch;
49
+ constructor(config: GitHubConfig);
50
+ /**
51
+ * Get the current commit SHA of the branch
52
+ */
53
+ getCommitSha(): Promise<string>;
54
+ /**
55
+ * Read a single file from the repository
56
+ * Returns null if file doesn't exist
57
+ */
58
+ readFile(path: string): Promise<FileReadResult | null>;
59
+ /**
60
+ * Read a binary file from the repository (returns raw base64 without UTF-8 decoding)
61
+ * Use this for images, videos, and other binary files
62
+ * Returns null if file doesn't exist
63
+ */
64
+ readFileBinary(path: string): Promise<{
65
+ content: string;
66
+ sha: string;
67
+ } | null>;
68
+ /**
69
+ * Read a JSON file from the repository
70
+ * Returns null if file doesn't exist
71
+ */
72
+ readJsonFile<T>(path: string): Promise<{
73
+ data: T;
74
+ sha: string;
75
+ } | null>;
76
+ /**
77
+ * Read multiple files in parallel
78
+ */
79
+ readFiles(paths: string[]): Promise<Map<string, FileReadResult | null>>;
80
+ /**
81
+ * Write a single file to the repository
82
+ * Creates the file if it doesn't exist, updates if it does
83
+ */
84
+ writeFile(path: string, content: string, message: string): Promise<string>;
85
+ /**
86
+ * Write a JSON file to the repository
87
+ */
88
+ writeJsonFile<T>(path: string, data: T, message: string): Promise<string>;
89
+ /**
90
+ * Write multiple files atomically in a single commit
91
+ * This uses the Git Data API (blob → tree → commit → update ref)
92
+ */
93
+ writeFilesAtomic(files: FileEntry[], message: string, baseCommitSha?: string): Promise<string>;
94
+ /**
95
+ * Delete a file from the repository
96
+ */
97
+ deleteFile(path: string, message: string): Promise<void>;
98
+ /**
99
+ * List files in a directory
100
+ */
101
+ listDirectory(path: string): Promise<string[]>;
102
+ /**
103
+ * Check if commit SHA matches current branch HEAD
104
+ * Returns true if they match (no conflict), false if there's a conflict
105
+ */
106
+ checkNoConflict(expectedSha: string): Promise<boolean>;
107
+ /**
108
+ * Get raw Octokit instance for advanced operations
109
+ */
110
+ getOctokit(): Octokit;
111
+ /**
112
+ * Get repository info
113
+ */
114
+ getRepoInfo(): {
115
+ owner: string;
116
+ repo: string;
117
+ branch: string;
118
+ };
119
+ }
120
+ /**
121
+ * Create a GitHub client from CMS module config
122
+ */
123
+ export declare function createGitHubClient(config: GitHubConfig): GitHubClient;
124
+ //# sourceMappingURL=github.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../src/lib/github.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;CACZ;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAOvD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAOpD;AAED;;GAEG;AACH,qBAAa,YAAY;IACxB,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,EAAE,YAAY;IAOhC;;OAE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