@hintergrund/worker 0.2.3 → 0.3.1

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 (111) hide show
  1. package/dist/api/cms/handlers/admin-users.handler.d.ts +1 -0
  2. package/dist/api/cms/handlers/admin-users.handler.d.ts.map +1 -1
  3. package/dist/api/cms/handlers/admin-users.handler.js +60 -79
  4. package/dist/api/cms/handlers/auth.handler.d.ts +1 -1
  5. package/dist/api/cms/handlers/auth.handler.d.ts.map +1 -1
  6. package/dist/api/cms/handlers/auth.handler.js +13 -94
  7. package/dist/api/cms/handlers/dashboard.handler.d.ts +1 -1
  8. package/dist/api/cms/handlers/dashboard.handler.d.ts.map +1 -1
  9. package/dist/api/cms/handlers/dashboard.handler.js +1 -1
  10. package/dist/api/cms/handlers/github-secrets.handler.d.ts.map +1 -1
  11. package/dist/api/cms/handlers/github-secrets.handler.js +8 -1
  12. package/dist/api/cms/handlers/integrations.handler.d.ts +5 -0
  13. package/dist/api/cms/handlers/integrations.handler.d.ts.map +1 -0
  14. package/dist/api/cms/handlers/integrations.handler.js +24 -0
  15. package/dist/api/cms/handlers/recovery.handler.d.ts +5 -0
  16. package/dist/api/cms/handlers/recovery.handler.d.ts.map +1 -0
  17. package/dist/api/cms/handlers/recovery.handler.js +53 -0
  18. package/dist/api/cms/handlers/setup.handler.d.ts.map +1 -1
  19. package/dist/api/cms/handlers/setup.handler.js +97 -35
  20. package/dist/api/cms/handlers/website-repo.handler.d.ts +2 -1
  21. package/dist/api/cms/handlers/website-repo.handler.d.ts.map +1 -1
  22. package/dist/api/cms/handlers/website-repo.handler.js +64 -55
  23. package/dist/api/cms/routes/auth.routes.d.ts +1 -1
  24. package/dist/api/cms/routes/auth.routes.d.ts.map +1 -1
  25. package/dist/api/cms/routes/auth.routes.js +7 -2
  26. package/dist/api/cms/routes/index.d.ts +1 -1
  27. package/dist/api/cms/routes/index.d.ts.map +1 -1
  28. package/dist/api/cms/routes/index.js +7 -11
  29. package/dist/api/emails/handlers/campaigns.handler.d.ts.map +1 -1
  30. package/dist/api/emails/handlers/campaigns.handler.js +3 -4
  31. package/dist/api/emails/handlers/invoice.handler.d.ts +8 -15
  32. package/dist/api/emails/handlers/invoice.handler.d.ts.map +1 -1
  33. package/dist/api/emails/handlers/invoice.handler.js +142 -170
  34. package/dist/api/emails/handlers/public.handler.d.ts.map +1 -1
  35. package/dist/api/emails/handlers/public.handler.js +27 -8
  36. package/dist/api/emails/handlers/send.handler.d.ts +1 -3
  37. package/dist/api/emails/handlers/send.handler.d.ts.map +1 -1
  38. package/dist/api/emails/handlers/send.handler.js +18 -65
  39. package/dist/api/emails/handlers/settings.handler.d.ts +60 -12
  40. package/dist/api/emails/handlers/settings.handler.d.ts.map +1 -1
  41. package/dist/api/emails/handlers/settings.handler.js +35 -94
  42. package/dist/api/emails/routes/admin.routes.d.ts.map +1 -1
  43. package/dist/api/emails/routes/admin.routes.js +5 -6
  44. package/dist/api/emails/routes/mail.routes.d.ts +5 -0
  45. package/dist/api/emails/routes/mail.routes.d.ts.map +1 -0
  46. package/dist/api/emails/routes/mail.routes.js +188 -0
  47. package/dist/api/shop/handlers/products.handler.d.ts +2 -2
  48. package/dist/api/shop/handlers/products.handler.d.ts.map +1 -1
  49. package/dist/api/shop/handlers/products.handler.js +21 -8
  50. package/dist/api/shop/handlers/public.handler.d.ts.map +1 -1
  51. package/dist/api/shop/handlers/public.handler.js +17 -66
  52. package/dist/index.d.ts +10 -2
  53. package/dist/index.d.ts.map +1 -1
  54. package/dist/index.js +26 -18
  55. package/dist/lib/auth/crypto.d.ts +0 -1
  56. package/dist/lib/auth/crypto.d.ts.map +1 -1
  57. package/dist/lib/auth/crypto.js +1 -4
  58. package/dist/lib/brand.d.ts +6 -0
  59. package/dist/lib/brand.d.ts.map +1 -0
  60. package/dist/lib/brand.js +31 -0
  61. package/dist/lib/config.d.ts +1 -2
  62. package/dist/lib/config.d.ts.map +1 -1
  63. package/dist/lib/config.js +1 -8
  64. package/dist/lib/email-template.d.ts +4 -7
  65. package/dist/lib/email-template.d.ts.map +1 -1
  66. package/dist/lib/email-template.js +9 -31
  67. package/dist/lib/email.d.ts +20 -11
  68. package/dist/lib/email.d.ts.map +1 -1
  69. package/dist/lib/email.js +29 -19
  70. package/dist/lib/github.d.ts +1 -1
  71. package/dist/lib/github.d.ts.map +1 -1
  72. package/dist/lib/github.js +13 -4
  73. package/dist/lib/integration-health.d.ts +18 -0
  74. package/dist/lib/integration-health.d.ts.map +1 -0
  75. package/dist/lib/integration-health.js +51 -0
  76. package/dist/lib/invoice.d.ts +13 -0
  77. package/dist/lib/invoice.d.ts.map +1 -0
  78. package/dist/lib/invoice.js +41 -0
  79. package/dist/lib/mail-schema.d.ts +2 -0
  80. package/dist/lib/mail-schema.d.ts.map +1 -0
  81. package/dist/lib/mail-schema.js +56 -0
  82. package/dist/lib/mail.d.ts +83 -0
  83. package/dist/lib/mail.d.ts.map +1 -0
  84. package/dist/lib/mail.js +211 -0
  85. package/dist/lib/project-db.d.ts +3 -4
  86. package/dist/lib/project-db.d.ts.map +1 -1
  87. package/dist/lib/project-db.js +14 -43
  88. package/dist/lib/template.d.ts.map +1 -1
  89. package/dist/lib/template.js +28 -0
  90. package/dist/lib/user-recovery.d.ts +9 -0
  91. package/dist/lib/user-recovery.d.ts.map +1 -0
  92. package/dist/lib/user-recovery.js +42 -0
  93. package/dist/lib/website-i18n.d.ts +10 -0
  94. package/dist/lib/website-i18n.d.ts.map +1 -0
  95. package/dist/lib/website-i18n.js +195 -0
  96. package/dist/middleware/auth.d.ts +3 -1
  97. package/dist/middleware/auth.d.ts.map +1 -1
  98. package/dist/middleware/auth.js +8 -4
  99. package/package.json +4 -2
  100. package/dist/api/cms/handlers/agent-conversations.handler.d.ts +0 -6
  101. package/dist/api/cms/handlers/agent-conversations.handler.d.ts.map +0 -1
  102. package/dist/api/cms/handlers/agent-conversations.handler.js +0 -87
  103. package/dist/api/cms/handlers/website-templates.handler.d.ts +0 -6
  104. package/dist/api/cms/handlers/website-templates.handler.d.ts.map +0 -1
  105. package/dist/api/cms/handlers/website-templates.handler.js +0 -53
  106. package/dist/api/shop/handlers/prices.handler.d.ts +0 -4
  107. package/dist/api/shop/handlers/prices.handler.d.ts.map +0 -1
  108. package/dist/api/shop/handlers/prices.handler.js +0 -6
  109. package/dist/hintergrund-assets.d.ts +0 -5
  110. package/dist/hintergrund-assets.d.ts.map +0 -1
  111. package/dist/hintergrund-assets.js +0 -11
@@ -2,13 +2,14 @@ import { hashPw } from '../../../lib/auth/crypto';
2
2
  import { signWithPayload } from '../../../lib/auth/jwt';
3
3
  import { getGitHubConfig } from '../../../lib/config';
4
4
  import { createGitHubClient } from '../../../lib/github';
5
- import { readJsonConfig, writeJsonConfig } from '../../../lib/github-config';
5
+ import { readJsonConfig } from '../../../lib/github-config';
6
6
  import { DEFAULT_EMAIL_SETTINGS, EMAIL_SETTINGS_PATH } from '../../emails/handlers/settings.handler';
7
7
  import Stripe from 'stripe';
8
+ import { checkIntegrationKey } from '../../../lib/integration-health';
8
9
  import { createId, ensureSchema, issueSessionForUser, nowSeconds } from '../../../lib/project-db';
9
- import { resolveModuleDependencies } from '@hintergrund/runtime-contracts';
10
- const WEBSITE_SETUP_PATH = 'frontend/src/lib/website/setup.json';
11
- const SHOP_SETTINGS_PATH = 'frontend/src/lib/shop/settings.json';
10
+ import { AGENT_PROVIDERS, AGENT_PROVIDER_SECRETS, SETUP_PATH as WEBSITE_SETUP_PATH, SHOP_SETTINGS_PATH, normalizeProjectGoals, subscriptionAutomation, DEFAULT_SHOP_EMAIL_TEMPLATES } from '@hintergrund/runtime-contracts';
11
+ import { validateI18nConfig, DEFAULT_I18N_CONFIG } from '@hintergrund/runtime-contracts';
12
+ import { initializeWebsiteLanguages } from '../../../lib/website-i18n';
12
13
  const DEFAULT_SHOP_SETTINGS = {
13
14
  currency: 'eur',
14
15
  enabledPaymentMethods: ['bank_transfer'],
@@ -58,40 +59,68 @@ export async function setupProject(c) {
58
59
  if (!(await hasValidSetupToken(c.env, body.setupToken)))
59
60
  return c.json({ error: 'Invalid setup link.' }, 403);
60
61
  const email = typeof body.email === 'string' ? body.email.trim().toLowerCase() : '';
61
- // Modules chosen during setup decide which of the remaining answers are required.
62
- const requestedModules = typeof body.modules === 'object' && body.modules !== null ? body.modules : {};
63
- const modules = resolveModuleDependencies({
64
- shop: requestedModules.shop !== false,
65
- emails: requestedModules.emails !== false,
66
- });
67
- // The owner signs in with email codes when the project sends email, but always sets a
68
- // password too: it is the way back in if email delivery ever fails.
69
- const loginMethod = modules.emails ? 'otp' : 'password';
62
+ if (!body.goals || typeof body.goals !== 'object' || Array.isArray(body.goals)
63
+ || typeof body.goals.sell !== 'boolean'
64
+ || typeof body.goals.newsletters !== 'boolean') {
65
+ return c.json({ error: 'Choose your project goals.' }, 400);
66
+ }
67
+ let languages;
68
+ try {
69
+ languages = validateI18nConfig(body.languages ?? DEFAULT_I18N_CONFIG);
70
+ }
71
+ catch (error) {
72
+ return c.json({ error: error instanceof Error ? error.message : 'Invalid website languages.' }, 400);
73
+ }
74
+ const goals = normalizeProjectGoals(body.goals);
75
+ const needsEmail = goals.sell || goals.newsletters;
70
76
  const MIN_PASSWORD_LENGTH = 12;
71
77
  const password = typeof body.password === 'string' ? body.password : '';
72
78
  const plunkApiKey = typeof body.plunkApiKey === 'string' ? body.plunkApiKey.trim() : '';
73
79
  const fromEmail = typeof body.fromEmail === 'string' ? body.fromEmail.trim() : '';
74
80
  const paymentProvider = body.paymentProvider === 'stripe' || body.paymentProvider === 'bank_transfer' ? body.paymentProvider : null;
81
+ const agentProvider = typeof body.agentProvider === 'string' && AGENT_PROVIDERS.includes(body.agentProvider) ? body.agentProvider : null;
82
+ const agentProviderKey = typeof body.agentProviderKey === 'string' ? body.agentProviderKey.trim() : '';
83
+ const invoiceInput = body.invoice && typeof body.invoice === 'object' && !Array.isArray(body.invoice) ? body.invoice : {};
84
+ const invoice = { companyName: '', companyAddress: '', companyEmail: '', companyPhone: '', dueDays: 14 };
85
+ for (const key of ['companyName', 'companyAddress', 'companyEmail', 'companyPhone']) {
86
+ if (typeof invoiceInput[key] === 'string')
87
+ invoice[key] = invoiceInput[key].trim().slice(0, 4000);
88
+ }
89
+ if (goals.sell && (!invoice.companyName || !invoice.companyAddress))
90
+ return c.json({ error: 'Enter your business name and address for invoices.' }, 400);
91
+ const footerText = typeof body.footerText === 'string' ? body.footerText.trim().slice(0, 8000) : 'If you have any questions, please contact us.';
92
+ const footerHtml = `<p>${footerText.replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;').replaceAll('\n', '<br>')}</p>`;
75
93
  if (!email)
76
94
  return c.json({ error: 'An email address is required.' }, 400);
77
95
  if (password.length < MIN_PASSWORD_LENGTH) {
78
96
  return c.json({ error: `Choose a password of at least ${MIN_PASSWORD_LENGTH} characters.` }, 400);
79
97
  }
80
- if (modules.emails && (!plunkApiKey || !fromEmail)) {
98
+ if (needsEmail && (!plunkApiKey || !fromEmail)) {
81
99
  return c.json({ error: 'An email provider API key and sender address are required.' }, 400);
82
100
  }
83
- if (modules.shop && !paymentProvider)
101
+ if (!agentProvider || !agentProviderKey)
102
+ return c.json({ error: 'Choose an AI provider and enter its API key.' }, 400);
103
+ if (goals.sell && !paymentProvider)
84
104
  return c.json({ error: 'Choose a payment provider.' }, 400);
85
105
  const bankTransfer = typeof body.bankTransfer === 'object' && body.bankTransfer !== null ? body.bankTransfer : {};
86
106
  const accountHolder = typeof bankTransfer.accountHolder === 'string' ? bankTransfer.accountHolder.trim() : '';
87
107
  const iban = typeof bankTransfer.iban === 'string' ? bankTransfer.iban.trim() : '';
88
- const stripeSecretKey = paymentProvider === 'stripe' && typeof body.stripeSecretKey === 'string' ? body.stripeSecretKey.trim() : '';
89
- if (modules.shop && paymentProvider === 'bank_transfer' && (!accountHolder || !iban)) {
108
+ const stripeSecretKey = goals.sell && paymentProvider === 'stripe' && typeof body.stripeSecretKey === 'string' ? body.stripeSecretKey.trim() : '';
109
+ if (goals.sell && paymentProvider === 'bank_transfer' && (!accountHolder || !iban)) {
90
110
  return c.json({ error: 'An account holder and IBAN are required for bank transfers.' }, 400);
91
111
  }
92
- if (modules.shop && paymentProvider === 'stripe' && !stripeSecretKey) {
112
+ if (goals.sell && paymentProvider === 'stripe' && !stripeSecretKey) {
93
113
  return c.json({ error: 'Your Stripe secret key is required for card payments.' }, 400);
94
114
  }
115
+ // Validate credentials before creating an administrator or changing the repository.
116
+ const health = await Promise.all([
117
+ checkIntegrationKey(agentProvider, agentProviderKey),
118
+ ...(needsEmail ? [checkIntegrationKey('plunk', plunkApiKey)] : []),
119
+ ...(stripeSecretKey ? [checkIntegrationKey('stripe', stripeSecretKey)] : []),
120
+ ]);
121
+ const failed = health.find(result => !result.valid);
122
+ if (failed)
123
+ return c.json({ error: failed.message }, 400);
95
124
  // Do not consume the one-time setup route until GitHub is reachable. A project
96
125
  // without its repository cannot complete setup and must remain retryable.
97
126
  let client;
@@ -103,14 +132,16 @@ export async function setupProject(c) {
103
132
  console.error('Project setup GitHub preflight failed:', error);
104
133
  return c.json({ error: 'GitHub repository is unavailable. Check the project GitHub App configuration and try again.' }, 503);
105
134
  }
135
+ // The website itself arrives with the repository: it is committed at provisioning
136
+ // from the site the owner built in the demo. Setup only stages the configuration
137
+ // that depends on the answers given here.
138
+ const staged = { files: [], deletions: [] };
106
139
  const db = await ensureSchema(c.env);
107
140
  const now = nowSeconds();
108
141
  const user = {
109
142
  id: createId('user'),
110
143
  email,
111
144
  name: null,
112
- login_method: loginMethod,
113
- // Always stored, including for an email-code owner: this is the fallback credential.
114
145
  password_hash: await hashPw(password, c.env.SECRET ?? ''),
115
146
  initial_admin: 1,
116
147
  disabled_at: null,
@@ -118,8 +149,8 @@ export async function setupProject(c) {
118
149
  updated_at: now,
119
150
  };
120
151
  try {
121
- await db.prepare(`INSERT INTO admin_users (id, email, password_hash, login_method, initial_admin, disabled_at, created_at, updated_at) VALUES (?, ?, ?, ?, 1, NULL, ?, ?)`)
122
- .bind(user.id, user.email, user.password_hash, user.login_method, now, now).run();
152
+ await db.prepare(`INSERT INTO admin_users (id, email, password_hash, login_method, initial_admin, disabled_at, created_at, updated_at) VALUES (?, ?, ?, 'password', 1, NULL, ?, ?)`)
153
+ .bind(user.id, user.email, user.password_hash, now, now).run();
123
154
  }
124
155
  catch (error) {
125
156
  console.error('Initial admin creation failed', error);
@@ -135,34 +166,41 @@ export async function setupProject(c) {
135
166
  });
136
167
  stripeWebhookSecret = webhook.secret ?? '';
137
168
  }
138
- catch (error) {
139
- console.error('Stripe webhook setup failed:', error);
169
+ catch {
170
+ throw new Error('Stripe webhook configuration failed. Check webhook permissions on the Stripe key.');
140
171
  }
141
172
  }
173
+ // Setup keeps the selected website private in D1 until the first publish.
174
+ const stageConfig = async (_client, path, value, _message, _sha) => {
175
+ staged.files.push({ path, content: JSON.stringify(value, null, 2), encoding: 'utf8' });
176
+ };
142
177
  const secrets = {};
143
178
  for (const [name, value] of [
144
- ['API_KEY', plunkApiKey],
179
+ ['API_KEY', needsEmail ? plunkApiKey : ''],
145
180
  ['STRIPE_SECRET_KEY', stripeSecretKey],
146
- ['STRIPE_WEBHOOK_SECRET', stripeWebhookSecret],
181
+ ['STRIPE_WEBHOOK_SECRET', goals.sell && paymentProvider === 'stripe' ? stripeWebhookSecret : ''],
182
+ [AGENT_PROVIDER_SECRETS[agentProvider], agentProviderKey],
147
183
  ]) {
148
184
  if (typeof value === 'string' && value)
149
185
  secrets[name] = value;
150
186
  }
151
187
  await Promise.all(Object.entries(secrets).map(([secretName, value]) => client.setActionsSecret(secretName, value)));
152
188
  const { data: setupState, commitSha: setupCommitSha } = await readJsonConfig(client, WEBSITE_SETUP_PATH, {});
153
- await writeJsonConfig(client, WEBSITE_SETUP_PATH, {
189
+ await stageConfig(client, WEBSITE_SETUP_PATH, {
154
190
  ...setupState,
155
191
  version: 1,
156
- modules,
192
+ complete: true,
193
+ goals,
157
194
  updatedAt: Date.now(),
158
- }, 'Record enabled modules [skip ci]', setupCommitSha);
195
+ }, 'Record project goals [skip ci]', setupCommitSha);
159
196
  const { data: shopSettings, commitSha: shopCommitSha } = await readJsonConfig(client, SHOP_SETTINGS_PATH, DEFAULT_SHOP_SETTINGS);
160
- await writeJsonConfig(client, SHOP_SETTINGS_PATH, {
197
+ await stageConfig(client, SHOP_SETTINGS_PATH, {
161
198
  ...DEFAULT_SHOP_SETTINGS,
162
199
  ...shopSettings,
163
200
  // No shop means no payment method was chosen; leave it empty rather than
164
201
  // implying the shipped default was a decision.
165
- enabledPaymentMethods: modules.shop && paymentProvider ? [paymentProvider] : [],
202
+ enabledPaymentMethods: goals.sell && paymentProvider ? [paymentProvider] : [],
203
+ ...(goals.sell ? { emailTemplates: { ...DEFAULT_SHOP_EMAIL_TEMPLATES, ...shopSettings.emailTemplates } } : {}),
166
204
  bankTransfer: {
167
205
  ...DEFAULT_SHOP_SETTINGS.bankTransfer,
168
206
  ...(shopSettings.bankTransfer ?? {}),
@@ -174,14 +212,41 @@ export async function setupProject(c) {
174
212
  },
175
213
  }, 'Configure bank transfer payments [skip ci]', shopCommitSha);
176
214
  const { data: emailSettings, commitSha } = await readJsonConfig(client, EMAIL_SETTINGS_PATH, DEFAULT_EMAIL_SETTINGS);
177
- await writeJsonConfig(client, EMAIL_SETTINGS_PATH, {
215
+ await stageConfig(client, EMAIL_SETTINGS_PATH, {
178
216
  ...emailSettings,
217
+ invoice,
218
+ footerHtml,
219
+ automation: subscriptionAutomation(goals.newsletters, emailSettings.automation),
179
220
  fromEmail: typeof body.fromEmail === 'string' ? body.fromEmail.trim() : emailSettings.fromEmail,
180
221
  fromName: typeof body.fromName === 'string' ? body.fromName.trim() : emailSettings.fromName,
181
222
  replyTo: typeof body.replyTo === 'string' ? body.replyTo.trim() : emailSettings.replyTo,
182
223
  updatedAt: Date.now(),
183
224
  }, 'Configure email sender settings [skip ci]', commitSha);
225
+ // Translate the staged configuration and record the chosen languages. The website's
226
+ // own content was translated when its demo draft was committed at provisioning.
227
+ try {
228
+ await initializeWebsiteLanguages(staged.files, languages, {
229
+ ...c.env, GEMINI_API_KEY: agentProvider === 'google' ? agentProviderKey : undefined,
230
+ DEEPSEEK_API_KEY: agentProvider === 'deepseek' ? agentProviderKey : undefined,
231
+ });
232
+ }
233
+ catch (error) {
234
+ console.error('Setup translation failed:', error);
235
+ return c.json({ error: `Website preparation failed: ${error instanceof Error ? error.message : 'Please retry.'}` }, 502);
236
+ }
237
+ const baseCommitSha = await client.getCommitSha();
238
+ // Deploy secrets/admin runtime against the existing scaffold, never the draft website.
184
239
  await deploy(c, client);
240
+ const token = await signWithPayload(c.env.SECRET ?? '', await issueSessionForUser({ ...user, password_hash: user.password_hash }));
241
+ const secureCookie = c.req.url.startsWith('https://') ? '; Secure' : '';
242
+ return c.json({
243
+ success: true,
244
+ draft: {
245
+ files: staged.files,
246
+ deletions: staged.deletions,
247
+ baseCommitSha,
248
+ },
249
+ }, 201, { 'Set-Cookie': `token=${token}; HttpOnly; Path=/; SameSite=Strict${secureCookie}` });
185
250
  }
186
251
  catch (error) {
187
252
  console.error('Project setup integrations could not be saved:', error);
@@ -193,9 +258,6 @@ export async function setupProject(c) {
193
258
  }
194
259
  return c.json({ error: 'Project setup could not be completed. No administrator was created; fix the integration error and try again.' }, 502);
195
260
  }
196
- const token = await signWithPayload(c.env.SECRET ?? '', issueSessionForUser({ ...user, password_hash: user.password_hash }));
197
- const secureCookie = c.req.url.startsWith('https://') ? '; Secure' : '';
198
- return c.json({ success: true }, 201, { 'Set-Cookie': `token=${token}; HttpOnly; Path=/; SameSite=Strict${secureCookie}` });
199
261
  }
200
262
  export async function projectNeedsSetup(c) {
201
263
  return !(await hasAdminUsers(c));
@@ -1,8 +1,9 @@
1
1
  import type { Context } from 'hono';
2
2
  import type { HonoEnv } from '../../../index';
3
3
  export declare function isAllowedWebsitePath(path: string): boolean;
4
+ /** Admin-only access to Git-backed images, including before the next site deployment. */
5
+ export declare function getWebsiteAsset(c: Context<HonoEnv>): Promise<Response>;
4
6
  export declare function headWebsiteRepo(c: Context<HonoEnv>): Promise<Response>;
5
7
  export declare function syncWebsiteRepo(c: Context<HonoEnv>): Promise<Response>;
6
8
  export declare function commitWebsiteRepo(c: Context<HonoEnv>): Promise<Response>;
7
- export declare function uploadWebsiteAsset(c: Context<HonoEnv>): Promise<Response>;
8
9
  //# sourceMappingURL=website-repo.handler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"website-repo.handler.d.ts","sourceRoot":"","sources":["../../../../src/api/cms/handlers/website-repo.handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAyB9C,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAI1D;AA4CD,wBAAsB,eAAe,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAI5E;AAED,wBAAsB,eAAe,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAc5E;AAED,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAwC9E;AASD,wBAAsB,kBAAkB,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CA6C/E"}
1
+ {"version":3,"file":"website-repo.handler.d.ts","sourceRoot":"","sources":["../../../../src/api/cms/handlers/website-repo.handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAgC9C,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE1D;AA4CD,yFAAyF;AACzF,wBAAsB,eAAe,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CA0B5E;AAED,wBAAsB,eAAe,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAG5E;AAED,wBAAsB,eAAe,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAc5E;AAED,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAqD9E"}
@@ -1,5 +1,7 @@
1
1
  import { getGitHubConfig } from '../../../lib/config';
2
2
  import { createGitHubClient } from '../../../lib/github';
3
+ import { I18N_CONFIG_PATH, STATIC_DIR, isWebsitePath } from '@hintergrund/runtime-contracts';
4
+ import { translateWebsite } from '../../../lib/website-i18n';
3
5
  const STATIC_MIME_TYPES = {
4
6
  '.jpg': 'image/jpeg',
5
7
  '.jpeg': 'image/jpeg',
@@ -8,6 +10,12 @@ const STATIC_MIME_TYPES = {
8
10
  '.svg': 'image/svg+xml',
9
11
  '.webp': 'image/webp',
10
12
  '.ico': 'image/x-icon',
13
+ '.avif': 'image/avif',
14
+ '.bmp': 'image/bmp',
15
+ '.woff': 'font/woff',
16
+ '.woff2': 'font/woff2',
17
+ '.ttf': 'font/ttf',
18
+ '.otf': 'font/otf',
11
19
  };
12
20
  const MAX_UPLOAD_BYTES = 10 * 1024 * 1024;
13
21
  function getStaticMimeType(path) {
@@ -18,10 +26,7 @@ function normalizePath(path) {
18
26
  return path.replace(/^\/+/, '').replace(/\\/g, '/');
19
27
  }
20
28
  export function isAllowedWebsitePath(path) {
21
- const normalized = normalizePath(path);
22
- if (normalized.includes('..'))
23
- return false;
24
- return normalized.startsWith('frontend/');
29
+ return isWebsitePath(normalizePath(path));
25
30
  }
26
31
  async function listRepoFiles(c) {
27
32
  const client = createGitHubClient(getGitHubConfig(c.env));
@@ -48,19 +53,49 @@ async function listStaticAssets(c) {
48
53
  const assetPaths = tree.data.tree
49
54
  .filter((item) => item.type === 'blob' &&
50
55
  item.path &&
51
- item.path.startsWith('frontend/static/') &&
56
+ item.path.startsWith(STATIC_DIR) &&
52
57
  getStaticMimeType(item.path) !== null)
53
- .map((item) => item.path);
54
- return assetPaths.map((path) => {
58
+ .map((item) => ({ path: item.path, sha: item.sha }));
59
+ return assetPaths.map(({ path, sha }) => {
55
60
  const name = path.split('/').pop();
56
61
  const mimeType = getStaticMimeType(path);
57
- return { name, path, content: '', mimeType };
62
+ return { name, path, content: '', mimeType, sha };
58
63
  });
59
64
  }
65
+ /** Admin-only access to Git-backed images, including before the next site deployment. */
66
+ export async function getWebsiteAsset(c) {
67
+ const path = c.req.param('path') || '';
68
+ const mimeType = getStaticMimeType(path);
69
+ if (!path.startsWith(STATIC_DIR) || path.split('/').some((part) => !part || part === '.' || part === '..') || /[\\\\\x00-\x1f]/.test(path) || !mimeType) {
70
+ return c.json({ error: 'Invalid static asset path' }, 400);
71
+ }
72
+ const client = createGitHubClient(getGitHubConfig(c.env));
73
+ try {
74
+ const asset = await client.readFileBinary(path, MAX_UPLOAD_BYTES);
75
+ if (!asset)
76
+ return c.notFound();
77
+ const headers = {
78
+ 'Content-Type': mimeType,
79
+ 'Cache-Control': 'private, no-cache',
80
+ 'ETag': `"${asset.sha}"`,
81
+ 'X-Content-Type-Options': 'nosniff',
82
+ // SVGs may be opened directly; never allow repository scripts to execute.
83
+ 'Content-Security-Policy': "default-src 'none'; sandbox",
84
+ };
85
+ if (c.req.header('If-None-Match') === headers.ETag)
86
+ return new Response(null, { status: 304, headers });
87
+ const bytes = Uint8Array.from(atob(asset.content), (char) => char.charCodeAt(0));
88
+ return new Response(bytes, { headers });
89
+ }
90
+ catch (error) {
91
+ if (error instanceof RangeError)
92
+ return c.json({ error: 'Asset exceeds 10 MB limit' }, 413);
93
+ throw error;
94
+ }
95
+ }
60
96
  export async function headWebsiteRepo(c) {
61
97
  const client = createGitHubClient(getGitHubConfig(c.env));
62
- const commitSha = await client.getCommitSha();
63
- return c.json({ commitSha });
98
+ return c.json({ commitSha: await client.getCommitSha() });
64
99
  }
65
100
  export async function syncWebsiteRepo(c) {
66
101
  const client = createGitHubClient(getGitHubConfig(c.env));
@@ -105,51 +140,25 @@ export async function commitWebsiteRepo(c) {
105
140
  return c.json({ conflict: true, message: 'Repository changed since the last sync' }, 409);
106
141
  }
107
142
  }
108
- const commitSha = await client.writeFilesAtomic(files, String(body.message || 'Publish website changes'), body.baseCommitSha ? String(body.baseCommitSha) : undefined, deletions);
109
- return c.json({ success: true, commitSha });
110
- }
111
- function sanitizeFilename(name) {
112
- const lower = name.toLowerCase();
113
- const sanitized = lower.replace(/[^a-z0-9._-]/g, '-');
114
- const trimmed = sanitized.replace(/^\.+|\.+$/g, '').replace(/^-+|-+$/g, '');
115
- return trimmed.slice(0, 200) || 'file';
116
- }
117
- export async function uploadWebsiteAsset(c) {
118
- const formData = await c.req.formData();
119
- const moduleVal = formData.get('module');
120
- const fileVal = formData.get('file');
121
- const nameOverride = formData.get('name');
122
- if (typeof moduleVal !== 'string' || !['cms', 'shop', 'builder', 'email'].includes(moduleVal)) {
123
- return c.json({ error: 'module must be cms, shop, builder, or email' }, 400);
124
- }
125
- const module = moduleVal;
126
- if (!fileVal || typeof fileVal === 'string') {
127
- return c.json({ error: 'file field is required' }, 400);
128
- }
129
- const uploadedFile = fileVal;
130
- if (uploadedFile.size > MAX_UPLOAD_BYTES) {
131
- return c.json({ error: 'File exceeds 10 MB limit' }, 400);
143
+ const baseCommitSha = body.baseCommitSha ? String(body.baseCommitSha) : await client.getCommitSha();
144
+ let translation = null;
145
+ try {
146
+ if (files.some(file => file.path === I18N_CONFIG_PATH) || await client.readFile(I18N_CONFIG_PATH)) {
147
+ const snapshot = await listRepoFiles(c);
148
+ const combined = new Map(Object.entries(snapshot).map(([path, file]) => [path, { path, content: file.content }]));
149
+ for (const file of files)
150
+ combined.set(file.path, file);
151
+ for (const path of deletions)
152
+ combined.delete(path);
153
+ translation = await translateWebsite(combined, c.env);
154
+ }
132
155
  }
133
- const rawName = typeof nameOverride === 'string' && nameOverride.trim()
134
- ? nameOverride.trim()
135
- : uploadedFile.name;
136
- const name = sanitizeFilename(rawName);
137
- const mimeType = uploadedFile.type || getStaticMimeType(name) || 'application/octet-stream';
138
- const arrayBuffer = await uploadedFile.arrayBuffer();
139
- const bytes = new Uint8Array(arrayBuffer);
140
- let binaryString = '';
141
- for (let i = 0; i < bytes.length; i++) {
142
- binaryString += String.fromCharCode(bytes[i]);
156
+ catch (error) {
157
+ return c.json({ error: error instanceof Error ? error.message : 'Website translation failed. Your changes have not been published.' }, 422);
143
158
  }
144
- const contentBase64 = btoa(binaryString);
145
- const staticDir = module === 'email' ? 'emails' : module === 'shop' ? 'shop' : 'cms';
146
- const path = `frontend/static/${staticDir}/${name}`;
147
- return c.json({
148
- success: true,
149
- path,
150
- name,
151
- mimeType,
152
- contentBase64,
153
- size: uploadedFile.size,
154
- });
159
+ const output = new Map(files.map(file => [file.path, file]));
160
+ if (translation)
161
+ output.set(translation.path, translation);
162
+ const commitSha = await client.writeFilesAtomic([...output.values()], String(body.message || 'Publish website changes'), baseCommitSha, deletions.filter(path => !output.has(path)));
163
+ return c.json({ success: true, commitSha, generatedFiles: translation ? [translation] : [] });
155
164
  }
@@ -1,5 +1,5 @@
1
1
  import { Hono } from 'hono';
2
- import { HonoEnv } from '../../../index';
2
+ import type { HonoEnv } from '../../../index';
3
3
  declare const authRoutes: Hono<HonoEnv, import("hono/types").BlankSchema, "/">;
4
4
  export default authRoutes;
5
5
  //# sourceMappingURL=auth.routes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.routes.d.ts","sourceRoot":"","sources":["../../../../src/api/cms/routes/auth.routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAGzC,QAAA,MAAM,UAAU,sDAAsB,CAAC;AAYvC,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"auth.routes.d.ts","sourceRoot":"","sources":["../../../../src/api/cms/routes/auth.routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAM9C,QAAA,MAAM,UAAU,sDAAsB,CAAC;AAcvC,eAAe,UAAU,CAAC"}
@@ -1,9 +1,14 @@
1
1
  import { Hono } from 'hono';
2
2
  import { login, logout } from '../handlers/auth.handler';
3
+ import { requestPasswordReset, completePasswordReset } from '../handlers/recovery.handler';
4
+ import { bodyLimit } from 'hono/body-limit';
5
+ import { authMiddleware } from '../../../middleware/auth';
3
6
  const authRoutes = new Hono();
4
- authRoutes.post('/login', login);
7
+ authRoutes.post('/password-reset/request', bodyLimit({ maxSize: 4096 }), requestPasswordReset);
8
+ authRoutes.post('/password-reset/complete', bodyLimit({ maxSize: 4096 }), completePasswordReset);
9
+ authRoutes.post('/login', bodyLimit({ maxSize: 4096 }), login);
5
10
  authRoutes.post('/logout', logout);
6
- authRoutes.get('/me', (c) => {
11
+ authRoutes.get('/me', authMiddleware, (c) => {
7
12
  const user = c.get('user');
8
13
  if (user) {
9
14
  return c.json({ success: true, user });
@@ -1,5 +1,5 @@
1
1
  import { Hono } from 'hono';
2
- import { HonoEnv } from '../../../index';
2
+ import type { HonoEnv } from '../../../index';
3
3
  declare const cmsRoutes: Hono<HonoEnv, import("hono/types").BlankSchema, "/">;
4
4
  export default cmsRoutes;
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/api/cms/routes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAoB5B,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,QAAA,MAAM,SAAS,sDAAsB,CAAC;AAgCtC,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/api/cms/routes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAe5B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAG9C,QAAA,MAAM,SAAS,sDAAsB,CAAC;AA6BtC,eAAe,SAAS,CAAC"}
@@ -2,13 +2,12 @@ import { Hono } from 'hono';
2
2
  import { getDashboard } from '../handlers/dashboard.handler';
3
3
  import { authMiddleware } from '../../../middleware/auth';
4
4
  import authRoutes from './auth.routes';
5
- import { createAdminUser, deleteAdminUser, listAdminUsers, patchAdminUser } from '../handlers/admin-users.handler';
6
- import { deleteConversation, listConversations, upsertConversation } from '../handlers/agent-conversations.handler';
5
+ import { createAdminUser, deleteAdminUser, listAdminUsers, patchAdminUser, sendUserRecovery } from '../handlers/admin-users.handler';
7
6
  import { getAgentConfig, proxyAgentRequest } from '../handlers/agent-provider.handler';
8
- import { commitWebsiteRepo, headWebsiteRepo, syncWebsiteRepo, uploadWebsiteAsset } from '../handlers/website-repo.handler';
9
- import { getWebsiteTemplateFile, getWebsiteTemplateManifest, listWebsiteTemplates } from '../handlers/website-templates.handler';
7
+ import { commitWebsiteRepo, getWebsiteAsset, headWebsiteRepo, syncWebsiteRepo } from '../handlers/website-repo.handler';
10
8
  import { deleteGitHubSecret, listGitHubSecrets, upsertGitHubSecret } from '../handlers/github-secrets.handler';
11
9
  import { setupContext, setupProject } from '../handlers/setup.handler';
10
+ import { testIntegration, testSetupIntegration } from '../handlers/integrations.handler';
12
11
  const cmsRoutes = new Hono();
13
12
  // Dashboard route (protected)
14
13
  cmsRoutes.get('/', authMiddleware, getDashboard);
@@ -16,24 +15,21 @@ cmsRoutes.get('/', authMiddleware, getDashboard);
16
15
  cmsRoutes.route('/', authRoutes);
17
16
  cmsRoutes.get('/setup', setupContext);
18
17
  cmsRoutes.post('/setup', setupProject);
18
+ cmsRoutes.post('/setup/integrations/:provider/test', testSetupIntegration);
19
19
  // Protected routes
20
20
  cmsRoutes.use('/*', authMiddleware);
21
21
  cmsRoutes.get('/users', listAdminUsers);
22
22
  cmsRoutes.post('/users', createAdminUser);
23
+ cmsRoutes.post('/users/:id/recovery', sendUserRecovery);
23
24
  cmsRoutes.patch('/users/:id', patchAdminUser);
24
25
  cmsRoutes.delete('/users/:id', deleteAdminUser);
25
- cmsRoutes.get('/agent/conversations', listConversations);
26
- cmsRoutes.post('/agent/conversations', upsertConversation);
27
- cmsRoutes.delete('/agent/conversations/:id', deleteConversation);
28
26
  cmsRoutes.get('/agent/config', getAgentConfig);
29
27
  cmsRoutes.all('/agent/llm/:path{.+}', proxyAgentRequest);
30
28
  cmsRoutes.get('/website/repo/head', headWebsiteRepo);
31
29
  cmsRoutes.get('/website/repo/sync', syncWebsiteRepo);
32
30
  cmsRoutes.put('/website/repo/commit', commitWebsiteRepo);
33
- cmsRoutes.put('/website/repo/upload', uploadWebsiteAsset);
34
- cmsRoutes.get('/website/templates', listWebsiteTemplates);
35
- cmsRoutes.get('/website/templates/:templateId/:version/manifest', getWebsiteTemplateManifest);
36
- cmsRoutes.get('/website/templates/:templateId/:version/files/*', getWebsiteTemplateFile);
31
+ cmsRoutes.get('/website/repo/assets/:path{.+}', getWebsiteAsset);
32
+ cmsRoutes.post('/integrations/:provider/test', testIntegration);
37
33
  cmsRoutes.get('/github/secrets', listGitHubSecrets);
38
34
  cmsRoutes.put('/github/secrets/:name', upsertGitHubSecret);
39
35
  cmsRoutes.delete('/github/secrets/:name', deleteGitHubSecret);
@@ -1 +1 @@
1
- {"version":3,"file":"campaigns.handler.d.ts","sourceRoot":"","sources":["../../../../src/api/emails/handlers/campaigns.handler.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAsB/B,qCAAqC;AACrC,wBAAsB,YAAY,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAWhE;AAED,yCAAyC;AACzC,wBAAsB,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAW/D;AAED,sCAAsC;AACtC,wBAAsB,cAAc,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAuBlE;AAED,2CAA2C;AAC3C,wBAAsB,cAAc,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CA2BlE;AAED,4CAA4C;AAC5C,wBAAsB,cAAc,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAYlE;AAED,+CAA+C;AAC/C,wBAAsB,YAAY,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAiEhE;AAED,+CAA+C;AAC/C,wBAAsB,YAAY,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CA8BhE"}
1
+ {"version":3,"file":"campaigns.handler.d.ts","sourceRoot":"","sources":["../../../../src/api/emails/handlers/campaigns.handler.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAsB/B,qCAAqC;AACrC,wBAAsB,YAAY,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAWhE;AAED,yCAAyC;AACzC,wBAAsB,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAW/D;AAED,sCAAsC;AACtC,wBAAsB,cAAc,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAuBlE;AAED,2CAA2C;AAC3C,wBAAsB,cAAc,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CA2BlE;AAED,4CAA4C;AAC5C,wBAAsB,cAAc,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAYlE;AAED,+CAA+C;AAC/C,wBAAsB,YAAY,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CA6DhE;AAED,+CAA+C;AAC/C,wBAAsB,YAAY,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CA8BhE"}
@@ -138,8 +138,10 @@ export async function sendCampaign(c) {
138
138
  return c.json({ success: false, message: 'No subscribed contacts found' }, 400);
139
139
  }
140
140
  const now = Date.now();
141
- const sendId = createId('snd');
142
141
  const { settings, logoDataUrl } = await readEmailTemplateData(c.env);
142
+ if (settings.automation?.newsletterEnabled === false) {
143
+ return c.json({ success: false, message: 'Newsletters are disabled.' }, 403);
144
+ }
143
145
  let sentCount = 0;
144
146
  let lastError;
145
147
  const origin = new URL(c.req.url).origin;
@@ -168,9 +170,6 @@ export async function sendCampaign(c) {
168
170
  const status = sentCount > 0 ? 'sent' : 'failed';
169
171
  // Update campaign status
170
172
  await db.prepare('UPDATE campaigns SET status = ?, recipient_count = ?, sent_at = ?, updated_at = ? WHERE id = ?').bind(status, sentCount, now, now, id).run();
171
- // Record send history
172
- await db.prepare(`INSERT INTO email_sends (id, type, campaign_id, subject, recipient_count, status, error, sent_at, created_at)
173
- VALUES (?, 'campaign', ?, ?, ?, ?, ?, ?, ?)`).bind(sendId, id, row.subject, sentCount, status, lastError ?? null, now, now).run();
174
173
  return c.json({ success: true, recipientCount: sentCount });
175
174
  }
176
175
  catch (error) {
@@ -1,16 +1,9 @@
1
- /**
2
- * Invoice Handler
3
- *
4
- * PDF generation for shop invoices. Invoice config is now read from D1 email_settings.
5
- */
6
- import type { InvoiceConfig, InvoiceData } from '@hintergrund/runtime-contracts';
7
- /**
8
- * Generate PDF invoice from InvoiceConfig + InvoiceData.
9
- * Optionally provide logo (base64 data URL) and invoice company styling.
10
- */
11
- export declare function generateInvoicePdf(config: InvoiceConfig, data: InvoiceData, branding?: {
12
- logo?: string;
13
- companyName?: string;
14
- primaryColor?: string;
15
- }): Promise<Uint8Array>;
1
+ import { type Brand, type InvoiceDesign, type InvoiceConfig, type InvoiceData } from '@hintergrund/runtime-contracts';
2
+ export interface InvoiceAssets {
3
+ logo?: Uint8Array;
4
+ bodyFont?: Uint8Array;
5
+ displayFont?: Uint8Array;
6
+ }
7
+ /** Same deterministic renderer for preview, downloads and email attachments. */
8
+ export declare function generateInvoicePdf(config: InvoiceConfig, data: InvoiceData, brand: Brand, design: InvoiceDesign, assets?: InvoiceAssets): Promise<Uint8Array>;
16
9
  //# sourceMappingURL=invoice.handler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"invoice.handler.d.ts","sourceRoot":"","sources":["../../../../src/api/emails/handlers/invoice.handler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAsCjF;;;GAGG;AACH,wBAAsB,kBAAkB,CACvC,MAAM,EAAE,aAAa,EACrB,IAAI,EAAE,WAAW,EACjB,QAAQ,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,GACvE,OAAO,CAAC,UAAU,CAAC,CA0JrB"}
1
+ {"version":3,"file":"invoice.handler.d.ts","sourceRoot":"","sources":["../../../../src/api/emails/handlers/invoice.handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwC,KAAK,KAAK,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE5J,MAAM,WAAW,aAAa;IAAG,IAAI,CAAC,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,EAAE,UAAU,CAAC;IAAC,WAAW,CAAC,EAAE,UAAU,CAAA;CAAE;AAErG,gFAAgF;AAChF,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAE,aAAkB,GAAG,OAAO,CAAC,UAAU,CAAC,CA4GvK"}