@hintergrund/worker 0.3.0 → 0.3.2

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 (53) hide show
  1. package/dist/api/cms/handlers/setup.handler.d.ts.map +1 -1
  2. package/dist/api/cms/handlers/setup.handler.js +19 -63
  3. package/dist/api/cms/handlers/website-repo.handler.d.ts +0 -1
  4. package/dist/api/cms/handlers/website-repo.handler.d.ts.map +1 -1
  5. package/dist/api/cms/handlers/website-repo.handler.js +5 -104
  6. package/dist/api/cms/routes/index.d.ts.map +1 -1
  7. package/dist/api/cms/routes/index.js +1 -8
  8. package/dist/api/emails/handlers/settings.handler.d.ts.map +1 -1
  9. package/dist/api/emails/handlers/settings.handler.js +0 -3
  10. package/dist/api/shop/handlers/products.handler.d.ts.map +1 -1
  11. package/dist/api/shop/handlers/products.handler.js +0 -9
  12. package/dist/index.d.ts +0 -1
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/lib/auth/crypto.d.ts +0 -1
  15. package/dist/lib/auth/crypto.d.ts.map +1 -1
  16. package/dist/lib/auth/crypto.js +1 -4
  17. package/dist/lib/brand.d.ts.map +1 -1
  18. package/dist/lib/brand.js +5 -3
  19. package/dist/lib/config.d.ts +1 -2
  20. package/dist/lib/config.d.ts.map +1 -1
  21. package/dist/lib/config.js +0 -4
  22. package/dist/lib/email-template.d.ts +3 -3
  23. package/dist/lib/email-template.d.ts.map +1 -1
  24. package/dist/lib/email-template.js +5 -6
  25. package/dist/lib/mail-schema.d.ts +0 -3
  26. package/dist/lib/mail-schema.d.ts.map +1 -1
  27. package/dist/lib/mail-schema.js +0 -6
  28. package/dist/lib/project-db.d.ts +1 -1
  29. package/dist/lib/project-db.d.ts.map +1 -1
  30. package/dist/lib/project-db.js +1 -15
  31. package/dist/lib/website-i18n.js +1 -1
  32. package/package.json +37 -37
  33. package/dist/api/cms/handlers/agent-conversations.handler.d.ts +0 -6
  34. package/dist/api/cms/handlers/agent-conversations.handler.d.ts.map +0 -1
  35. package/dist/api/cms/handlers/agent-conversations.handler.js +0 -87
  36. package/dist/api/cms/handlers/website-templates.handler.d.ts +0 -8
  37. package/dist/api/cms/handlers/website-templates.handler.d.ts.map +0 -1
  38. package/dist/api/cms/handlers/website-templates.handler.js +0 -73
  39. package/dist/api/emails/routes/mail-events.routes.d.ts +0 -5
  40. package/dist/api/emails/routes/mail-events.routes.d.ts.map +0 -1
  41. package/dist/api/emails/routes/mail-events.routes.js +0 -29
  42. package/dist/api/shop/handlers/prices.handler.d.ts +0 -4
  43. package/dist/api/shop/handlers/prices.handler.d.ts.map +0 -1
  44. package/dist/api/shop/handlers/prices.handler.js +0 -6
  45. package/dist/lib/launch-draft.d.ts +0 -14
  46. package/dist/lib/launch-draft.d.ts.map +0 -1
  47. package/dist/lib/launch-draft.js +0 -45
  48. package/dist/lib/launch.d.ts +0 -3
  49. package/dist/lib/launch.d.ts.map +0 -1
  50. package/dist/lib/launch.js +0 -18
  51. package/dist/lib/template-installer.d.ts +0 -9
  52. package/dist/lib/template-installer.d.ts.map +0 -1
  53. package/dist/lib/template-installer.js +0 -97
@@ -1 +1 @@
1
- {"version":3,"file":"setup.handler.d.ts","sourceRoot":"","sources":["../../../../src/api/cms/handlers/setup.handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAYpC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAwB9C,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAQtG;AAQD,uFAAuF;AACvF,wBAAsB,YAAY,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAUzE;AAED,wBAAsB,YAAY,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CA6NzE;AAED,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAE7E"}
1
+ {"version":3,"file":"setup.handler.d.ts","sourceRoot":"","sources":["../../../../src/api/cms/handlers/setup.handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAWpC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAyB9C,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAQtG;AAQD,uFAAuF;AACvF,wBAAsB,YAAY,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAIzE;AAED,wBAAsB,YAAY,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAsMzE;AAED,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAE7E"}
@@ -7,8 +7,7 @@ import { DEFAULT_EMAIL_SETTINGS, EMAIL_SETTINGS_PATH } from '../../emails/handle
7
7
  import Stripe from 'stripe';
8
8
  import { checkIntegrationKey } from '../../../lib/integration-health';
9
9
  import { createId, ensureSchema, issueSessionForUser, nowSeconds } from '../../../lib/project-db';
10
- import { AGENT_PROVIDERS, AGENT_PROVIDER_SECRETS, BRAND_CSS_PATH, BRAND_PATH, SETUP_PATH as WEBSITE_SETUP_PATH, SHOP_SETTINGS_PATH, DEFAULT_BRAND, brandCss, normalizeProjectGoals, subscriptionAutomation, validateBrand, DEFAULT_SHOP_EMAIL_TEMPLATES } from '@hintergrund/runtime-contracts';
11
- import { installSetupTemplate, setupTemplateCatalog } from '../../../lib/template-installer';
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';
12
11
  import { validateI18nConfig, DEFAULT_I18N_CONFIG } from '@hintergrund/runtime-contracts';
13
12
  import { initializeWebsiteLanguages } from '../../../lib/website-i18n';
14
13
  const DEFAULT_SHOP_SETTINGS = {
@@ -51,14 +50,7 @@ export async function setupContext(c) {
51
50
  return c.json({ error: 'Project setup has already been completed.' }, 409);
52
51
  if (!(await hasValidSetupToken(c.env, c.req.query('token'))))
53
52
  return c.json({ error: 'Invalid setup link.' }, 403);
54
- try {
55
- const catalog = await setupTemplateCatalog(c.env.TEMPLATE_REGISTRY_URL);
56
- return c.json({ suggestedEmail: c.env.SETUP_ADMIN_EMAIL?.trim() || undefined, templates: catalog.templates });
57
- }
58
- catch (error) {
59
- console.error('Setup template catalog failed:', error);
60
- return c.json({ error: 'Website templates are temporarily unavailable.' }, 503);
61
- }
53
+ return c.json({ suggestedEmail: c.env.SETUP_ADMIN_EMAIL?.trim() || undefined });
62
54
  }
63
55
  export async function setupProject(c) {
64
56
  if (await hasAdminUsers(c))
@@ -88,34 +80,6 @@ export async function setupProject(c) {
88
80
  const paymentProvider = body.paymentProvider === 'stripe' || body.paymentProvider === 'bank_transfer' ? body.paymentProvider : null;
89
81
  const agentProvider = typeof body.agentProvider === 'string' && AGENT_PROVIDERS.includes(body.agentProvider) ? body.agentProvider : null;
90
82
  const agentProviderKey = typeof body.agentProviderKey === 'string' ? body.agentProviderKey.trim() : '';
91
- const templateId = typeof body.templateId === 'string' ? body.templateId.trim() : '';
92
- const templateVersion = typeof body.templateVersion === 'string' ? body.templateVersion.trim() : '';
93
- let logo = null;
94
- if (body.logo !== undefined && body.logo !== null) {
95
- try {
96
- const input = body.logo;
97
- if (typeof input.content !== 'string' || input.content.length > 2_800_000 || !/^[A-Za-z0-9+/]*={0,2}$/.test(input.content))
98
- throw new Error();
99
- const bytes = atob(input.content);
100
- if (bytes.length > 2 * 1024 * 1024 || bytes.length < 8)
101
- throw new Error();
102
- const png = input.mimeType === 'image/png' && bytes.startsWith('\x89PNG\r\n\x1a\n');
103
- const jpeg = input.mimeType === 'image/jpeg' && bytes.charCodeAt(0) === 255 && bytes.charCodeAt(1) === 216 && bytes.charCodeAt(2) === 255;
104
- if (!png && !jpeg)
105
- throw new Error();
106
- logo = { content: input.content, path: `frontend/static/brand/logo.${png ? 'png' : 'jpg'}` };
107
- }
108
- catch {
109
- return c.json({ error: 'Use a valid PNG or JPEG logo up to 2 MB.' }, 400);
110
- }
111
- }
112
- let brand;
113
- try {
114
- brand = validateBrand({ ...DEFAULT_BRAND, colors: body.brandColors, bodyFont: body.bodyFont ?? DEFAULT_BRAND.bodyFont, displayFont: body.displayFont ?? DEFAULT_BRAND.displayFont, cornerRadius: body.cornerRadius ?? DEFAULT_BRAND.cornerRadius, logoPath: logo?.path ?? null });
115
- }
116
- catch {
117
- return c.json({ error: 'Choose valid brand colors, fonts and corners.' }, 400);
118
- }
119
83
  const invoiceInput = body.invoice && typeof body.invoice === 'object' && !Array.isArray(body.invoice) ? body.invoice : {};
120
84
  const invoice = { companyName: '', companyAddress: '', companyEmail: '', companyPhone: '', dueDays: 14 };
121
85
  for (const key of ['companyName', 'companyAddress', 'companyEmail', 'companyPhone']) {
@@ -136,8 +100,6 @@ export async function setupProject(c) {
136
100
  }
137
101
  if (!agentProvider || !agentProviderKey)
138
102
  return c.json({ error: 'Choose an AI provider and enter its API key.' }, 400);
139
- if (!templateId || !templateVersion)
140
- return c.json({ error: 'Choose a website template.' }, 400);
141
103
  if (goals.sell && !paymentProvider)
142
104
  return c.json({ error: 'Choose a payment provider.' }, 400);
143
105
  const bankTransfer = typeof body.bankTransfer === 'object' && body.bankTransfer !== null ? body.bankTransfer : {};
@@ -170,20 +132,10 @@ export async function setupProject(c) {
170
132
  console.error('Project setup GitHub preflight failed:', error);
171
133
  return c.json({ error: 'GitHub repository is unavailable. Check the project GitHub App configuration and try again.' }, 503);
172
134
  }
173
- // Translation is the longest setup operation. Finish it before consuming the
174
- // setup link so a timeout/disconnect cannot leave a half-created administrator.
175
- let staged;
176
- try {
177
- staged = await installSetupTemplate(client, templateId, templateVersion, c.env.TEMPLATE_REGISTRY_URL, true);
178
- await initializeWebsiteLanguages(staged.files, languages, {
179
- ...c.env, GEMINI_API_KEY: agentProvider === 'google' ? agentProviderKey : undefined,
180
- DEEPSEEK_API_KEY: agentProvider === 'deepseek' ? agentProviderKey : undefined,
181
- });
182
- }
183
- catch (error) {
184
- console.error('Setup template translation failed:', error);
185
- return c.json({ error: `Website preparation failed: ${error instanceof Error ? error.message : 'Please retry.'} No administrator was created.` }, 502);
186
- }
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: [] };
187
139
  const db = await ensureSchema(c.env);
188
140
  const now = nowSeconds();
189
141
  const user = {
@@ -218,16 +170,10 @@ export async function setupProject(c) {
218
170
  throw new Error('Stripe webhook configuration failed. Check webhook permissions on the Stripe key.');
219
171
  }
220
172
  }
221
- // Setup keeps the selected website private in D1 until the explicit first launch.
173
+ // Setup keeps the selected website private in D1 until the first publish.
222
174
  const stageConfig = async (_client, path, value, _message, _sha) => {
223
175
  staged.files.push({ path, content: JSON.stringify(value, null, 2), encoding: 'utf8' });
224
176
  };
225
- if (logo)
226
- staged.files.push({ path: logo.path, content: logo.content, encoding: 'base64' });
227
- staged.files.push(...[
228
- { path: BRAND_PATH, content: JSON.stringify(brand, null, 2) },
229
- { path: BRAND_CSS_PATH, content: brandCss(brand) },
230
- ]);
231
177
  const secrets = {};
232
178
  for (const [name, value] of [
233
179
  ['API_KEY', needsEmail ? plunkApiKey : ''],
@@ -240,13 +186,11 @@ export async function setupProject(c) {
240
186
  }
241
187
  await Promise.all(Object.entries(secrets).map(([secretName, value]) => client.setActionsSecret(secretName, value)));
242
188
  const { data: setupState, commitSha: setupCommitSha } = await readJsonConfig(client, WEBSITE_SETUP_PATH, {});
243
- delete setupState.modules;
244
189
  await stageConfig(client, WEBSITE_SETUP_PATH, {
245
190
  ...setupState,
246
191
  version: 1,
247
192
  complete: true,
248
193
  goals,
249
- template: { id: templateId, version: templateVersion },
250
194
  updatedAt: Date.now(),
251
195
  }, 'Record project goals [skip ci]', setupCommitSha);
252
196
  const { data: shopSettings, commitSha: shopCommitSha } = await readJsonConfig(client, SHOP_SETTINGS_PATH, DEFAULT_SHOP_SETTINGS);
@@ -278,6 +222,18 @@ export async function setupProject(c) {
278
222
  replyTo: typeof body.replyTo === 'string' ? body.replyTo.trim() : emailSettings.replyTo,
279
223
  updatedAt: Date.now(),
280
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
+ }
281
237
  const baseCommitSha = await client.getCommitSha();
282
238
  // Deploy secrets/admin runtime against the existing scaffold, never the draft website.
283
239
  await deploy(c, client);
@@ -6,5 +6,4 @@ export declare function getWebsiteAsset(c: Context<HonoEnv>): Promise<Response>;
6
6
  export declare function headWebsiteRepo(c: Context<HonoEnv>): Promise<Response>;
7
7
  export declare function syncWebsiteRepo(c: Context<HonoEnv>): Promise<Response>;
8
8
  export declare function commitWebsiteRepo(c: Context<HonoEnv>): Promise<Response>;
9
- export declare function uploadWebsiteAsset(c: Context<HonoEnv>): Promise<Response>;
10
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;AAuC9C,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,CAO5E;AAED,wBAAsB,eAAe,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAe5E;AAED,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAyF9E;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,8 +1,6 @@
1
1
  import { getGitHubConfig } from '../../../lib/config';
2
2
  import { createGitHubClient } from '../../../lib/github';
3
- import { isLaunchPending } from '../../../lib/launch';
4
- import { I18N_CONFIG_PATH, launchTasks, LAUNCH_PATH, launchJson, SETUP_PATH, SHOP_SETTINGS_PATH, STATIC_DIR, isWebsitePath } from '@hintergrund/runtime-contracts';
5
- import { checkIntegrationKey } from '../../../lib/integration-health';
3
+ import { I18N_CONFIG_PATH, STATIC_DIR, isWebsitePath } from '@hintergrund/runtime-contracts';
6
4
  import { translateWebsite } from '../../../lib/website-i18n';
7
5
  const STATIC_MIME_TYPES = {
8
6
  '.jpg': 'image/jpeg',
@@ -20,10 +18,6 @@ const STATIC_MIME_TYPES = {
20
18
  '.otf': 'font/otf',
21
19
  };
22
20
  const MAX_UPLOAD_BYTES = 10 * 1024 * 1024;
23
- function integrationStatus(c) {
24
- const configured = (value) => !!value?.trim() && value !== 'NOT_CONFIGURED';
25
- return { plunk: configured(c.env.API_KEY || c.env.PLUNK_SECRET_KEY), stripe: configured(c.env.STRIPE_SECRET_KEY), stripeWebhook: configured(c.env.STRIPE_WEBHOOK_SECRET) };
26
- }
27
21
  function getStaticMimeType(path) {
28
22
  const ext = path.slice(((path.lastIndexOf('.') - 1) >>> 0) + 2).toLowerCase();
29
23
  return STATIC_MIME_TYPES['.' + ext] ?? null;
@@ -101,26 +95,21 @@ export async function getWebsiteAsset(c) {
101
95
  }
102
96
  export async function headWebsiteRepo(c) {
103
97
  const client = createGitHubClient(getGitHubConfig(c.env));
104
- const [commitSha, launchPending] = await Promise.all([
105
- client.getCommitSha(),
106
- isLaunchPending(client),
107
- ]);
108
- return c.json({ commitSha, launchPending, integrations: integrationStatus(c) });
98
+ return c.json({ commitSha: await client.getCommitSha() });
109
99
  }
110
100
  export async function syncWebsiteRepo(c) {
111
101
  const client = createGitHubClient(getGitHubConfig(c.env));
112
- const [files, commitSha, staticAssets, launchPending] = await Promise.all([
102
+ const [files, commitSha, staticAssets] = await Promise.all([
113
103
  listRepoFiles(c),
114
104
  client.getCommitSha(),
115
105
  listStaticAssets(c),
116
- isLaunchPending(client),
117
106
  ]);
118
107
  const srcFiles = Object.entries(files).map(([path, file]) => ({
119
108
  path,
120
109
  content: file.content,
121
110
  sha: file.sha,
122
111
  }));
123
- return c.json({ files, srcFiles, staticAssets, commitSha, launchPending, integrations: integrationStatus(c) });
112
+ return c.json({ files, srcFiles, staticAssets, commitSha });
124
113
  }
125
114
  export async function commitWebsiteRepo(c) {
126
115
  const body = await c.req.json();
@@ -141,7 +130,7 @@ export async function commitWebsiteRepo(c) {
141
130
  if (deletions.some((path) => writtenPaths.has(path))) {
142
131
  return c.json({ error: 'A path cannot be written and deleted in the same commit' }, 400);
143
132
  }
144
- if (files.length === 0 && deletions.length === 0 && body.launch !== true) {
133
+ if (files.length === 0 && deletions.length === 0) {
145
134
  return c.json({ error: 'No files to commit' }, 400);
146
135
  }
147
136
  const client = createGitHubClient(getGitHubConfig(c.env));
@@ -151,49 +140,6 @@ export async function commitWebsiteRepo(c) {
151
140
  return c.json({ conflict: true, message: 'Repository changed since the last sync' }, 409);
152
141
  }
153
142
  }
154
- const launchPending = await isLaunchPending(client);
155
- if (launchPending) {
156
- if (body.launch !== true)
157
- return c.json({ error: 'Complete the launch checklist and explicitly launch the website before its first Git push.' }, 422);
158
- const snapshot = await listRepoFiles(c);
159
- const combined = new Map(Object.entries(snapshot).map(([path, file]) => [path, { path, content: file.content }]));
160
- for (const file of files)
161
- combined.set(file.path, file);
162
- for (const path of deletions)
163
- combined.delete(path);
164
- const read = (path) => combined.get(path)?.content ?? null;
165
- const missing = launchTasks(read, [...combined.keys()]).filter(task => !task.complete);
166
- if (missing.length)
167
- return c.json({ error: `Finish launch tasks: ${missing.map(task => task.label).join(', ')}` }, 422);
168
- const setup = launchJson(read, SETUP_PATH), shop = launchJson(read, SHOP_SETTINGS_PATH);
169
- const checks = await Promise.all([
170
- ...(setup.goals?.sell || setup.goals?.newsletters ? [checkIntegrationKey('plunk', c.env.API_KEY || c.env.PLUNK_SECRET_KEY || '')] : []),
171
- ...(setup.goals?.sell && shop.enabledPaymentMethods?.includes('stripe') ? [checkIntegrationKey('stripe', c.env.STRIPE_SECRET_KEY || '')] : []),
172
- ]);
173
- const failed = checks.find(check => !check.valid || check.status === 'warning');
174
- if (failed)
175
- return c.json({ error: failed.message }, 422);
176
- if (setup.goals?.sell && shop.enabledPaymentMethods?.includes('stripe') && (!c.env.STRIPE_WEBHOOK_SECRET || c.env.STRIPE_WEBHOOK_SECRET === 'NOT_CONFIGURED'))
177
- return c.json({ error: 'Configure the Stripe webhook secret before launching.' }, 422);
178
- let translation;
179
- try {
180
- translation = await translateWebsite(combined, c.env);
181
- }
182
- catch (error) {
183
- return c.json({ error: error instanceof Error ? error.message : 'Website translation failed. Retry your changes.' }, 422);
184
- }
185
- if (translation)
186
- combined.set(translation.path, translation);
187
- const receipt = launchJson(read, LAUNCH_PATH);
188
- const baseCommitSha = body.baseCommitSha ? String(body.baseCommitSha) : await client.getCommitSha();
189
- combined.set(LAUNCH_PATH, { path: LAUNCH_PATH, content: JSON.stringify({ ...receipt, launchedAt: Date.now(), launchBaseCommitSha: baseCommitSha }, null, 2) });
190
- const written = new Set(files.map(file => file.path));
191
- written.add(LAUNCH_PATH);
192
- if (translation)
193
- written.add(translation.path);
194
- const commitSha = await client.writeFilesAtomic([...combined.values()].filter(file => written.has(file.path)), 'Launch website', baseCommitSha, deletions.filter(path => !combined.has(path)));
195
- return c.json({ success: true, commitSha, launched: true, generatedFiles: translation ? [translation] : [] });
196
- }
197
143
  const baseCommitSha = body.baseCommitSha ? String(body.baseCommitSha) : await client.getCommitSha();
198
144
  let translation = null;
199
145
  try {
@@ -216,48 +162,3 @@ export async function commitWebsiteRepo(c) {
216
162
  const commitSha = await client.writeFilesAtomic([...output.values()], String(body.message || 'Publish website changes'), baseCommitSha, deletions.filter(path => !output.has(path)));
217
163
  return c.json({ success: true, commitSha, generatedFiles: translation ? [translation] : [] });
218
164
  }
219
- function sanitizeFilename(name) {
220
- const lower = name.toLowerCase();
221
- const sanitized = lower.replace(/[^a-z0-9._-]/g, '-');
222
- const trimmed = sanitized.replace(/^\.+|\.+$/g, '').replace(/^-+|-+$/g, '');
223
- return trimmed.slice(0, 200) || 'file';
224
- }
225
- export async function uploadWebsiteAsset(c) {
226
- const formData = await c.req.formData();
227
- const moduleVal = formData.get('module');
228
- const fileVal = formData.get('file');
229
- const nameOverride = formData.get('name');
230
- if (typeof moduleVal !== 'string' || !['cms', 'shop', 'builder', 'email'].includes(moduleVal)) {
231
- return c.json({ error: 'module must be cms, shop, builder, or email' }, 400);
232
- }
233
- const module = moduleVal;
234
- if (!fileVal || typeof fileVal === 'string') {
235
- return c.json({ error: 'file field is required' }, 400);
236
- }
237
- const uploadedFile = fileVal;
238
- if (uploadedFile.size > MAX_UPLOAD_BYTES) {
239
- return c.json({ error: 'File exceeds 10 MB limit' }, 400);
240
- }
241
- const rawName = typeof nameOverride === 'string' && nameOverride.trim()
242
- ? nameOverride.trim()
243
- : uploadedFile.name;
244
- const name = sanitizeFilename(rawName);
245
- const mimeType = uploadedFile.type || getStaticMimeType(name) || 'application/octet-stream';
246
- const arrayBuffer = await uploadedFile.arrayBuffer();
247
- const bytes = new Uint8Array(arrayBuffer);
248
- let binaryString = '';
249
- for (let i = 0; i < bytes.length; i++) {
250
- binaryString += String.fromCharCode(bytes[i]);
251
- }
252
- const contentBase64 = btoa(binaryString);
253
- const staticDir = module === 'email' ? 'emails' : module === 'shop' ? 'shop' : 'cms';
254
- const path = `${STATIC_DIR}${staticDir}/${name}`;
255
- return c.json({
256
- success: true,
257
- path,
258
- name,
259
- mimeType,
260
- contentBase64,
261
- size: uploadedFile.size,
262
- });
263
- }
@@ -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;AAiB5B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAG9C,QAAA,MAAM,SAAS,sDAAsB,CAAC;AAkCtC,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"}
@@ -1,12 +1,10 @@
1
1
  import { Hono } from 'hono';
2
- import { bodyLimit } from 'hono/body-limit';
3
2
  import { getDashboard } from '../handlers/dashboard.handler';
4
3
  import { authMiddleware } from '../../../middleware/auth';
5
4
  import authRoutes from './auth.routes';
6
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, getWebsiteAsset, headWebsiteRepo, syncWebsiteRepo, uploadWebsiteAsset } from '../handlers/website-repo.handler';
9
- import { getWebsiteTemplateFile, getWebsiteTemplateManifest, listWebsiteTemplates, prepareWebsiteTemplateLanguages } 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';
12
10
  import { testIntegration, testSetupIntegration } from '../handlers/integrations.handler';
@@ -30,12 +28,7 @@ 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
31
  cmsRoutes.get('/website/repo/assets/:path{.+}', getWebsiteAsset);
35
- cmsRoutes.post('/website/i18n/prepare-template', bodyLimit({ maxSize: 2 * 1024 * 1024 }), prepareWebsiteTemplateLanguages);
36
- cmsRoutes.get('/website/templates', listWebsiteTemplates);
37
- cmsRoutes.get('/website/templates/:templateId/:version/manifest', getWebsiteTemplateManifest);
38
- cmsRoutes.get('/website/templates/:templateId/:version/files/:path{.+}', getWebsiteTemplateFile);
39
32
  cmsRoutes.post('/integrations/:provider/test', testIntegration);
40
33
  cmsRoutes.get('/github/secrets', listGitHubSecrets);
41
34
  cmsRoutes.put('/github/secrets/:name', upsertGitHubSecret);
@@ -1 +1 @@
1
- {"version":3,"file":"settings.handler.d.ts","sourceRoot":"","sources":["../../../../src/api/emails/handlers/settings.handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAE5E,OAAO,EAAE,mBAAmB,EAAyC,KAAK,aAAa,EAAE,KAAK,aAAa,EAAiC,MAAM,gCAAgC,CAAC;AAInL,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAC/B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B,EAAE,aAA0D,CAAC;AAEhG,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAKxH;AACD,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,QAAQ;;;;;;;;;;;;;6BAElC,CAAC;uBAA8B,CAAC;wBAA+B,CAAC;;;;mBAEnE,CAAC;;;;;;;;;;;;GAEhB;AACD,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,QAAQ;;;;;;;;;;;;;6BALtC,CAAC;uBAA8B,CAAC;wBAA+B,CAAC;;;;mBAEnE,CAAC;;;;;;;;;;;;GAOhB;AACD,wBAAsB,WAAW,CAAC,CAAC,EAAE,OAAO,CAAC;IAAE,QAAQ,EAAE,QAAQ,CAAA;CAAE,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAMvF;AACD,wBAAsB,YAAY,CAAC,CAAC,EAAE,OAAO,CAAC;IAAE,QAAQ,EAAE,QAAQ,CAAA;CAAE,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAkBxF"}
@@ -3,7 +3,6 @@ import { createGitHubClient } from '../../../lib/github';
3
3
  import { readJsonConfig, writeJsonConfig, ConfigConflictError } from '../../../lib/github-config';
4
4
  import { EMAIL_SETTINGS_PATH, emailTemplateFromBrand, validateBrand } from '@hintergrund/runtime-contracts';
5
5
  import { readBrand } from '../../../lib/brand';
6
- import { isLaunchPending } from '../../../lib/launch';
7
6
  export { EMAIL_SETTINGS_PATH };
8
7
  export const DEFAULT_INVOICE = { companyName: '', companyAddress: '', companyEmail: '', companyPhone: '', dueDays: 14 };
9
8
  export const DEFAULT_EMAIL_SETTINGS = { invoice: DEFAULT_INVOICE, updatedAt: 0 };
@@ -40,8 +39,6 @@ export async function getSettings(c) {
40
39
  }
41
40
  export async function saveSettings(c) {
42
41
  const github = createGitHubClient(getGitHubConfig(c.env));
43
- if (await isLaunchPending(github))
44
- return c.json({ error: 'Stage settings in the workspace and complete the first-launch checklist before pushing to GitHub.' }, 422);
45
42
  try {
46
43
  const body = await c.req.json();
47
44
  const { data: current } = await readJsonConfig(github, EMAIL_SETTINGS_PATH, DEFAULT_EMAIL_SETTINGS);
@@ -1 +1 @@
1
- {"version":3,"file":"products.handler.d.ts","sourceRoot":"","sources":["../../../../src/api/shop/handlers/products.handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAM/C,OAAO,KAAK,EAOX,WAAW,EAEX,YAAY,EAKZ,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACxF,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,CAAC;AAGlD,eAAO,MAAM,qBAAqB,EAAE,YAAY,GAAG;IAClD,cAAc,EAAE;QACf,QAAQ,EAAE;YAAE,OAAO,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAA;SAAE,CAAC;QAChD,gBAAgB,EAAE;YAAE,OAAO,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAA;SAAE,CAAC;KACxD,CAAC;CAyBF,CAAC;AA+BF,wBAAsB,eAAe,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,WAAW,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAIzG;AAED,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC;IAAE,QAAQ,EAAE,YAAY,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAc5G;AA6DD,wBAAsB,WAAW,CAAC,CAAC,EAAE,OAAO,CAAC;IAAE,QAAQ,EAAE,QAAQ,CAAA;CAAE,CAAC,GAAG,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,WAAW,CAAC,CAAC,EAAE,OAAO,CAAC;IAAE,QAAQ,EAAE,QAAQ,CAAA;CAAE,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAavF;AAED,wBAAsB,cAAc,CAAC,CAAC,EAAE,OAAO,CAAC;IAAE,QAAQ,EAAE,QAAQ,CAAA;CAAE,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAiC1F"}
@@ -1,5 +1,4 @@
1
1
  import { getGitHubConfig } from '../../../lib/config';
2
- import { isLaunchPending } from '../../../lib/launch';
3
2
  import { translateWebsiteFiles } from '../../../lib/website-i18n';
4
3
  import { createGitHubClient } from '../../../lib/github';
5
4
  import { ConfigConflictError, readJsonConfig, writeJsonConfig } from '../../../lib/github-config';
@@ -154,8 +153,6 @@ export async function getProduct(c) {
154
153
  }
155
154
  }
156
155
  export async function createProduct(c) {
157
- if (await isLaunchPending(getGitHub(c)))
158
- return c.json({ error: 'Edit products locally until the first launch.' }, 422);
159
156
  try {
160
157
  const github = getGitHub(c);
161
158
  const body = await c.req.json();
@@ -178,8 +175,6 @@ export async function createProduct(c) {
178
175
  }
179
176
  }
180
177
  export async function updateProduct(c) {
181
- if (await isLaunchPending(getGitHub(c)))
182
- return c.json({ error: 'Edit products locally until the first launch.' }, 422);
183
178
  try {
184
179
  const github = getGitHub(c);
185
180
  const productId = c.req.param('id');
@@ -206,8 +201,6 @@ export async function updateProduct(c) {
206
201
  }
207
202
  }
208
203
  export async function deleteProduct(c) {
209
- if (await isLaunchPending(getGitHub(c)))
210
- return c.json({ error: 'Edit products locally until the first launch.' }, 422);
211
204
  try {
212
205
  const github = getGitHub(c);
213
206
  const productId = c.req.param('id');
@@ -245,8 +238,6 @@ export async function getSettings(c) {
245
238
  }
246
239
  }
247
240
  export async function updateSettings(c) {
248
- if (await isLaunchPending(getGitHub(c)))
249
- return c.json({ error: 'Complete the launch checklist before pushing settings to GitHub.' }, 422);
250
241
  try {
251
242
  const github = getGitHub(c);
252
243
  const body = await c.req.json();
package/dist/index.d.ts CHANGED
@@ -27,7 +27,6 @@ export type Bindings = {
27
27
  STRIPE_WEBHOOK_SECRET?: string;
28
28
  GEMINI_API_KEY?: string;
29
29
  DEEPSEEK_API_KEY?: string;
30
- TEMPLATE_REGISTRY_URL?: string;
31
30
  UI_BASE_URL: string;
32
31
  ASSETS: Fetcher;
33
32
  PROJECT_DB?: D1Database;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAK5B,OAAO,EAAE,YAAY,EAAiB,MAAM,YAAY,CAAC;AAQzD,MAAM,MAAM,QAAQ,GAAG;IAEtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iFAAiF;IACjF,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,4EAA4E;IAC5E,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAG7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAG1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,2DAA2D;IAC3D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,QAAQ,CAAC;IAGxB,iBAAiB,CAAC,EAAE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}
@@ -1,6 +1,5 @@
1
1
  import { decrypt, readRequestBody } from '@hintergrund/auth';
2
2
  export { decrypt, readRequestBody };
3
- export declare function generateRandomToken(): string;
4
3
  export declare function hashPw(password: string, pepper: string): Promise<string>;
5
4
  /**
6
5
  * Verify a password against an encrypted password
@@ -1 +1 @@
1
- {"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../../src/lib/auth/crypto.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,OAAO,EAGP,eAAe,EAEf,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC;AAEpC,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C;AAED,wBAAsB,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAE9E;AAED;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,iBAAiB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAU5G"}
1
+ {"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../../src/lib/auth/crypto.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,OAAO,EAEP,eAAe,EAEf,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC;AAGpC,wBAAsB,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAE9E;AAED;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,iBAAiB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAU5G"}
@@ -1,8 +1,5 @@
1
- import { decrypt, generateRandomSecret, hashPassword, readRequestBody, verifyPassword } from '@hintergrund/auth';
1
+ import { decrypt, hashPassword, readRequestBody, verifyPassword } from '@hintergrund/auth';
2
2
  export { decrypt, readRequestBody };
3
- export function generateRandomToken() {
4
- return generateRandomSecret();
5
- }
6
3
  export async function hashPw(password, pepper) {
7
4
  return hashPassword(password, pepper);
8
5
  }
@@ -1 +1 @@
1
- {"version":3,"file":"brand.d.ts","sourceRoot":"","sources":["../../src/lib/brand.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAKzC,wBAAsB,SAAS,CAAC,GAAG,EAAE,QAAQ,2DAI5C;AACD,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,QAAQ,mEAIpD;AACD,wBAAsB,cAAc,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAMrF;AACD,wBAAgB,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAIhD"}
1
+ {"version":3,"file":"brand.d.ts","sourceRoot":"","sources":["../../src/lib/brand.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAKzC,wBAAsB,SAAS,CAAC,GAAG,EAAE,QAAQ,2DAK5C;AACD,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,QAAQ,mEAIpD;AACD,wBAAsB,cAAc,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAMrF;AACD,wBAAgB,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAIhD"}
package/dist/lib/brand.js CHANGED
@@ -1,11 +1,13 @@
1
- import { BRAND_PATH, DEFAULT_BRAND, validateBrand, INVOICE_DESIGN_PATH, DEFAULT_INVOICE_DESIGN, validateInvoiceDesign, publicAssetPath } from '@hintergrund/runtime-contracts';
1
+ import { BRAND_PATH, validateBrand, INVOICE_DESIGN_PATH, DEFAULT_INVOICE_DESIGN, validateInvoiceDesign, publicAssetPath } from '@hintergrund/runtime-contracts';
2
2
  import { createGitHubClient } from './github';
3
3
  import { getGitHubConfig } from './config';
4
4
  import { readJsonConfig } from './github-config';
5
5
  export async function readBrand(env) {
6
6
  const github = createGitHubClient(getGitHubConfig(env));
7
- const { data } = await readJsonConfig(github, BRAND_PATH, DEFAULT_BRAND);
8
- return validateBrand(data);
7
+ const file = await github.readJsonFileIfExists(BRAND_PATH);
8
+ if (!file)
9
+ throw new Error(`Missing ${BRAND_PATH}. Every website template ships one.`);
10
+ return validateBrand(file.data);
9
11
  }
10
12
  export async function readInvoiceDesign(env) {
11
13
  const github = createGitHubClient(getGitHubConfig(env));
@@ -1,4 +1,4 @@
1
- import type { AppConfig, AdminConfig, EmailsModuleConfig, ShopModuleConfig } from '@hintergrund/runtime-contracts';
1
+ import type { AppConfig, AdminConfig, EmailsModuleConfig } from '@hintergrund/runtime-contracts';
2
2
  /**
3
3
  * Load application configuration from environment variables
4
4
  * Reads the modular Worker environment bindings.
@@ -12,7 +12,6 @@ export declare function getAdminConfig(): AdminConfig;
12
12
  /** Get Emails module configuration. */
13
13
  export declare function getEmailsConfig(env: Record<string, string | undefined> | any): EmailsModuleConfig;
14
14
  /** Get Shop module configuration. */
15
- export declare function getShopConfig(env: Record<string, string | undefined> | any): ShopModuleConfig;
16
15
  /**
17
16
  * Get GitHub configuration from environment variables
18
17
  * Used by CMS, emails and other modules for GitHub storage
@@ -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,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAEnH;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,GAAG,GAAG,SAAS,CAOnF;AAwCD;;;GAGG;AACH,wBAAgB,cAAc,IAAI,WAAW,C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@@ -3,7 +3,6 @@
3
3
  * Reads the modular Worker environment bindings.
4
4
  */
5
5
  export function loadConfig(env) {
6
- // Try new env vars first - need either legacy password or new auth config
7
6
  if (env.SECRET) {
8
7
  return loadFromEnvVars(env);
9
8
  }
@@ -56,9 +55,6 @@ export function getEmailsConfig(env) {
56
55
  return loadConfig(env).emails;
57
56
  }
58
57
  /** Get Shop module configuration. */
59
- export function getShopConfig(env) {
60
- return loadConfig(env).shop;
61
- }
62
58
  /**
63
59
  * Get GitHub configuration from environment variables
64
60
  * Used by CMS, emails and other modules for GitHub storage
@@ -1,12 +1,12 @@
1
- import { type EmailTemplateConfig } from '@hintergrund/runtime-contracts';
1
+ import type { EmailTemplateConfig } from '@hintergrund/runtime-contracts';
2
2
  export interface RenderEmailTemplateOptions {
3
3
  bodyHtml: string;
4
- template?: Partial<EmailTemplateConfig>;
4
+ /** Always derived from the project's brand via emailTemplateFromBrand. */
5
+ template: EmailTemplateConfig;
5
6
  logoDataUrl?: string;
6
7
  unsubscribeUrl?: string;
7
8
  footerHtml?: string;
8
9
  }
9
10
  export type { EmailTemplateConfig } from '@hintergrund/runtime-contracts';
10
- export declare const DEFAULT_EMAIL_TEMPLATE: EmailTemplateConfig;
11
11
  export declare function renderEmailTemplate(options: RenderEmailTemplateOptions): string;
12
12
  //# sourceMappingURL=email-template.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"email-template.d.ts","sourceRoot":"","sources":["../../src/lib/email-template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyC,KAAK,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAEjH,MAAM,WAAW,0BAA0B;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACxC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,YAAY,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAE1E,eAAO,MAAM,sBAAsB,EAAE,mBAA2D,CAAC;AAoBjG,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,MAAM,CAkB/E"}
1
+ {"version":3,"file":"email-template.d.ts","sourceRoot":"","sources":["../../src/lib/email-template.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAE1E,MAAM,WAAW,0BAA0B;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,0EAA0E;IAC1E,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,YAAY,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAqB1E,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,MAAM,CAkB/E"}
@@ -1,7 +1,6 @@
1
- import { DEFAULT_BRAND, emailTemplateFromBrand } from '@hintergrund/runtime-contracts';
2
- export const DEFAULT_EMAIL_TEMPLATE = emailTemplateFromBrand(DEFAULT_BRAND);
3
- function cleanCssValue(value, fallback) {
4
- return value && !/[<>"']/.test(value) ? value : fallback;
1
+ /** Brand colors are validated as #rrggbb; refuse anything else rather than interpolate it into style="". */
2
+ function safeColor(value) {
3
+ return value && /^#[\da-f]{6}$/i.test(value) ? value : 'inherit';
5
4
  }
6
5
  function styleEmailBody(bodyHtml, primaryColor, headingFont) {
7
6
  return bodyHtml
@@ -18,8 +17,8 @@ function styleEmailBody(bodyHtml, primaryColor, headingFont) {
18
17
  });
19
18
  }
20
19
  export function renderEmailTemplate(options) {
21
- const template = { ...DEFAULT_EMAIL_TEMPLATE, ...(options.template ?? {}) };
22
- const primaryColor = cleanCssValue(template.primaryColor, DEFAULT_EMAIL_TEMPLATE.primaryColor);
20
+ const template = options.template;
21
+ const primaryColor = safeColor(template.primaryColor);
23
22
  const bodyHtml = styleEmailBody(options.bodyHtml, primaryColor, template.headingFont);
24
23
  const logoHtml = options.logoDataUrl
25
24
  ? `<div style="text-align:center;margin:0 0 20px 0;"><img src="${options.logoDataUrl}" alt="Logo" style="max-width:120px;max-height:80px;height:auto;"></div>`
@@ -1,5 +1,2 @@
1
- /** Additive schema: safe for existing project databases; no destructive migrations. */
2
1
  export declare const MAIL_SCHEMA_SQL = "\nCREATE TABLE IF NOT EXISTS user_recovery (\n user_id TEXT PRIMARY KEY REFERENCES admin_users(id) ON DELETE CASCADE,\n token_hash TEXT NOT NULL UNIQUE,\n expires_at INTEGER NOT NULL,\n created_at INTEGER NOT NULL\n);\nCREATE TABLE IF NOT EXISTS auth_rate_limits (\n key TEXT PRIMARY KEY,\n count INTEGER NOT NULL,\n expires_at INTEGER NOT NULL\n);\nCREATE TABLE IF NOT EXISTS mailboxes (\n address TEXT PRIMARY KEY,\n name TEXT NOT NULL,\n created_at INTEGER NOT NULL,\n last_received_at INTEGER,\n -- Exactly one mailbox per project receives mail addressed to any other\n -- address on the domain. Created on the first unmatched delivery so a project\n -- never silently rejects mail to its own domain.\n catch_all INTEGER NOT NULL DEFAULT 0\n);\nCREATE TABLE IF NOT EXISTS mail_messages (\n id TEXT PRIMARY KEY,\n thread_id TEXT NOT NULL,\n mailbox TEXT NOT NULL REFERENCES mailboxes(address),\n direction TEXT NOT NULL CHECK(direction IN ('inbound','outbound')),\n status TEXT NOT NULL CHECK(status IN ('received','draft','queued','sending','accepted','delivered','bounced','complained','failed','uncertain')),\n sender TEXT NOT NULL,\n reply_address TEXT,\n recipient TEXT NOT NULL,\n subject TEXT NOT NULL,\n body_text TEXT NOT NULL,\n message_id TEXT,\n in_reply_to TEXT,\n references_json TEXT NOT NULL DEFAULT '[]',\n raw_key TEXT,\n attachments_json TEXT NOT NULL DEFAULT '[]',\n provider_id TEXT,\n error TEXT,\n read_at INTEGER,\n archived_at INTEGER,\n spam INTEGER NOT NULL DEFAULT 0,\n attempts INTEGER NOT NULL DEFAULT 0,\n next_attempt_at INTEGER,\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL,\n -- Keyed on the delivered address, not the storing mailbox: with a catch-all,\n -- one message addressed to two unmatched addresses is two real deliveries.\n UNIQUE(recipient, message_id, direction)\n);\nCREATE INDEX IF NOT EXISTS idx_mail_folder ON mail_messages(direction, status, created_at DESC);\nCREATE INDEX IF NOT EXISTS idx_mail_thread ON mail_messages(thread_id, created_at);\nCREATE INDEX IF NOT EXISTS idx_mail_outbox ON mail_messages(status, next_attempt_at);\nCREATE UNIQUE INDEX IF NOT EXISTS idx_mailbox_catch_all ON mailboxes(catch_all) WHERE catch_all = 1;\n";
3
- /** Additive migrations for pre-existing databases. Executed best-effort. */
4
- export declare const MAIL_ALTER_SQL: string[];
5
2
  //# sourceMappingURL=mail-schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mail-schema.d.ts","sourceRoot":"","sources":["../../src/lib/mail-schema.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,eAAO,MAAM,eAAe,kqEAuD3B,CAAC;AAEF,4EAA4E;AAC5E,eAAO,MAAM,cAAc,UAG1B,CAAC"}
1
+ {"version":3,"file":"mail-schema.d.ts","sourceRoot":"","sources":["../../src/lib/mail-schema.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,kqEAuD3B,CAAC"}
@@ -1,4 +1,3 @@
1
- /** Additive schema: safe for existing project databases; no destructive migrations. */
2
1
  export const MAIL_SCHEMA_SQL = `
3
2
  CREATE TABLE IF NOT EXISTS user_recovery (
4
3
  user_id TEXT PRIMARY KEY REFERENCES admin_users(id) ON DELETE CASCADE,
@@ -55,8 +54,3 @@ CREATE INDEX IF NOT EXISTS idx_mail_thread ON mail_messages(thread_id, created_a
55
54
  CREATE INDEX IF NOT EXISTS idx_mail_outbox ON mail_messages(status, next_attempt_at);
56
55
  CREATE UNIQUE INDEX IF NOT EXISTS idx_mailbox_catch_all ON mailboxes(catch_all) WHERE catch_all = 1;
57
56
  `;
58
- /** Additive migrations for pre-existing databases. Executed best-effort. */
59
- export const MAIL_ALTER_SQL = [
60
- `ALTER TABLE mailboxes ADD COLUMN last_received_at INTEGER`,
61
- `ALTER TABLE mailboxes ADD COLUMN catch_all INTEGER NOT NULL DEFAULT 0`,
62
- ];