@hintergrund/worker 0.3.6 → 0.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/api/cms/handlers/setup.handler.d.ts.map +1 -1
  2. package/dist/api/cms/handlers/setup.handler.js +15 -23
  3. package/dist/api/cms/handlers/website-repo.handler.d.ts +7 -0
  4. package/dist/api/cms/handlers/website-repo.handler.d.ts.map +1 -1
  5. package/dist/api/cms/handlers/website-repo.handler.js +45 -62
  6. package/dist/api/cms/routes/index.d.ts.map +1 -1
  7. package/dist/api/cms/routes/index.js +3 -2
  8. package/dist/api/emails/handlers/campaigns.handler.d.ts +6 -12
  9. package/dist/api/emails/handlers/campaigns.handler.d.ts.map +1 -1
  10. package/dist/api/emails/handlers/campaigns.handler.js +42 -132
  11. package/dist/api/emails/handlers/invoice.handler.d.ts +2 -2
  12. package/dist/api/emails/handlers/invoice.handler.d.ts.map +1 -1
  13. package/dist/api/emails/handlers/invoice.handler.js +3 -2
  14. package/dist/api/emails/handlers/public.handler.d.ts.map +1 -1
  15. package/dist/api/emails/handlers/public.handler.js +5 -9
  16. package/dist/api/emails/handlers/settings.handler.d.ts +5 -46
  17. package/dist/api/emails/handlers/settings.handler.d.ts.map +1 -1
  18. package/dist/api/emails/handlers/settings.handler.js +12 -40
  19. package/dist/api/emails/routes/admin.routes.d.ts.map +1 -1
  20. package/dist/api/emails/routes/admin.routes.js +3 -11
  21. package/dist/api/shop/handlers/products.handler.d.ts +1 -38
  22. package/dist/api/shop/handlers/products.handler.d.ts.map +1 -1
  23. package/dist/api/shop/handlers/products.handler.js +8 -243
  24. package/dist/api/shop/handlers/public.handler.d.ts.map +1 -1
  25. package/dist/api/shop/handlers/public.handler.js +16 -23
  26. package/dist/api/shop/routes.d.ts.map +1 -1
  27. package/dist/api/shop/routes.js +0 -10
  28. package/dist/lib/github.d.ts +19 -3
  29. package/dist/lib/github.d.ts.map +1 -1
  30. package/dist/lib/github.js +39 -6
  31. package/dist/lib/invoice.js +3 -3
  32. package/dist/lib/project-db.d.ts +1 -1
  33. package/dist/lib/project-db.d.ts.map +1 -1
  34. package/dist/lib/project-db.js +5 -9
  35. package/dist/lib/website-i18n.d.ts +1 -1
  36. package/dist/lib/website-i18n.d.ts.map +1 -1
  37. package/dist/lib/website-i18n.js +8 -11
  38. package/package.json +2 -2
@@ -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;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,CAoMzE;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;AAe9C,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,CAqMzE;AAED,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAE7E"}
@@ -3,22 +3,13 @@ import { signWithPayload } from '../../../lib/auth/jwt';
3
3
  import { getGitHubConfig } from '../../../lib/config';
4
4
  import { createGitHubClient } from '../../../lib/github';
5
5
  import { readJsonConfig } from '../../../lib/github-config';
6
- import { DEFAULT_EMAIL_SETTINGS, EMAIL_SETTINGS_PATH } from '../../emails/handlers/settings.handler';
6
+ import { DEFAULT_SHOP_SETTINGS } from '../../shop/handlers/products.handler';
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, CONFIG_PATH as WEBSITE_CONFIG_PATH, SHOP_SETTINGS_PATH, normalizeProjectFeatures, subscriptionAutomation, DEFAULT_SHOP_EMAIL_TEMPLATES } from '@hintergrund/runtime-contracts';
10
+ import { AGENT_PROVIDERS, AGENT_PROVIDER_SECRETS, CONFIG_PATH as WEBSITE_CONFIG_PATH, SHOP_SETTINGS_PATH, EMAIL_SETTINGS_PATH, LEGAL_CONTENT_PATH, normalizeProjectFeatures } from '@hintergrund/runtime-contracts';
11
11
  import { validateI18nConfig, DEFAULT_I18N_CONFIG } from '@hintergrund/runtime-contracts';
12
12
  import { initializeWebsiteLanguages } from '../../../lib/website-i18n';
13
- const DEFAULT_SHOP_SETTINGS = {
14
- currency: 'eur',
15
- enabledPaymentMethods: ['bank_transfer'],
16
- bankTransfer: { accountHolder: '', iban: '', bic: '', bankName: '', instructions: 'Please use your order number as the payment reference.' },
17
- shippingFlatRate: 0,
18
- freeShippingThreshold: 0,
19
- orderNumberPrefix: 'ORD',
20
- invoiceNumberPrefix: 'INV',
21
- };
22
13
  async function hasAdminUsers(c) {
23
14
  const db = await ensureSchema(c.env);
24
15
  const row = await db.prepare('SELECT COUNT(*) AS count FROM admin_users').first();
@@ -80,13 +71,13 @@ export async function setupProject(c) {
80
71
  const paymentProvider = body.paymentProvider === 'stripe' || body.paymentProvider === 'bank_transfer' ? body.paymentProvider : null;
81
72
  const agentProvider = typeof body.agentProvider === 'string' && AGENT_PROVIDERS.includes(body.agentProvider) ? body.agentProvider : null;
82
73
  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);
74
+ const businessInput = body.business && typeof body.business === 'object' && !Array.isArray(body.business) ? body.business : {};
75
+ const business = {};
76
+ for (const key of ['companyName', 'street', 'postalCode', 'city', 'country', 'email', 'phone']) {
77
+ if (typeof businessInput[key] === 'string' && businessInput[key].trim())
78
+ business[key] = businessInput[key].trim().slice(0, 400);
88
79
  }
89
- if (features.sell && (!invoice.companyName || !invoice.companyAddress))
80
+ if (features.sell && (!business.companyName || !business.street || !business.city))
90
81
  return c.json({ error: 'Enter your business name and address for invoices.' }, 400);
91
82
  const footerText = typeof body.footerText === 'string' ? body.footerText.trim().slice(0, 8000) : 'If you have any questions, please contact us.';
92
83
  const footerHtml = `<p>${footerText.replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;').replaceAll('\n', '<br>')}</p>`;
@@ -198,7 +189,6 @@ export async function setupProject(c) {
198
189
  // No shop means no payment method was chosen; leave it empty rather than
199
190
  // implying the shipped default was a decision.
200
191
  enabledPaymentMethods: features.sell && paymentProvider ? [paymentProvider] : [],
201
- ...(features.sell ? { emailTemplates: { ...DEFAULT_SHOP_EMAIL_TEMPLATES, ...shopSettings.emailTemplates } } : {}),
202
192
  bankTransfer: {
203
193
  ...DEFAULT_SHOP_SETTINGS.bankTransfer,
204
194
  ...(shopSettings.bankTransfer ?? {}),
@@ -206,20 +196,22 @@ export async function setupProject(c) {
206
196
  iban,
207
197
  bic: typeof bankTransfer.bic === 'string' ? bankTransfer.bic.trim() : '',
208
198
  bankName: typeof bankTransfer.bankName === 'string' ? bankTransfer.bankName.trim() : '',
209
- instructions: typeof bankTransfer.instructions === 'string' ? bankTransfer.instructions.trim() : DEFAULT_SHOP_SETTINGS.bankTransfer.instructions,
199
+ instructions: typeof bankTransfer.instructions === 'string' ? bankTransfer.instructions.trim() : DEFAULT_SHOP_SETTINGS.bankTransfer?.instructions,
210
200
  },
211
201
  }, 'Configure bank transfer payments [skip ci]', shopCommitSha);
212
- const { data: emailSettings, commitSha } = await readJsonConfig(client, EMAIL_SETTINGS_PATH, DEFAULT_EMAIL_SETTINGS);
202
+ const { data: emailSettings, commitSha } = await readJsonConfig(client, EMAIL_SETTINGS_PATH, {});
213
203
  await stageConfig(client, EMAIL_SETTINGS_PATH, {
214
204
  ...emailSettings,
215
- invoice,
216
205
  footerHtml,
217
- automation: subscriptionAutomation(features.newsletters, emailSettings.automation),
218
206
  fromEmail: typeof body.fromEmail === 'string' ? body.fromEmail.trim() : emailSettings.fromEmail,
219
207
  fromName: typeof body.fromName === 'string' ? body.fromName.trim() : emailSettings.fromName,
220
208
  replyTo: typeof body.replyTo === 'string' ? body.replyTo.trim() : emailSettings.replyTo,
221
- updatedAt: Date.now(),
222
209
  }, 'Configure email sender settings [skip ci]', commitSha);
210
+ // The imprint and invoices name the same business: answered once, kept in one place.
211
+ if (Object.keys(business).length) {
212
+ const { data: legal, commitSha: legalCommitSha } = await readJsonConfig(client, LEGAL_CONTENT_PATH, {});
213
+ await stageConfig(client, LEGAL_CONTENT_PATH, { ...legal, ...business }, 'Record business details [skip ci]', legalCommitSha);
214
+ }
223
215
  // Translate the staged configuration and record the chosen languages. The website's
224
216
  // own content was translated when its demo draft was committed at provisioning.
225
217
  try {
@@ -4,6 +4,13 @@ export declare function isAllowedWebsitePath(path: string): boolean;
4
4
  /** Admin-only access to Git-backed images, including before the next site deployment. */
5
5
  export declare function getWebsiteAsset(c: Context<HonoEnv>): Promise<Response>;
6
6
  export declare function headWebsiteRepo(c: Context<HonoEnv>): Promise<Response>;
7
+ /** Published versions, newest first: what the history lists, never the files they touched. */
8
+ export declare function historyWebsiteRepo(c: Context<HonoEnv>): Promise<Response>;
9
+ /**
10
+ * The working copy at the branch head, or with `ref` the snapshot of an earlier version.
11
+ * The client names the blob SHAs it already holds; only the text of the others is sent,
12
+ * so a sync after one edit reads one blob, not the repository. Images never carry bytes.
13
+ */
7
14
  export declare function syncWebsiteRepo(c: Context<HonoEnv>): Promise<Response>;
8
15
  export declare function commitWebsiteRepo(c: Context<HonoEnv>): Promise<Response>;
9
16
  //# 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;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,CA+D9E"}
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;AAED,yFAAyF;AACzF,wBAAsB,eAAe,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CA6B5E;AAED,wBAAsB,eAAe,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAG5E;AAED,8FAA8F;AAC9F,wBAAsB,kBAAkB,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAK/E;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAiB5E;AAED,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAwD9E"}
@@ -1,7 +1,7 @@
1
1
  import { getGitHubConfig } from '../../../lib/config';
2
2
  import { createGitHubClient } from '../../../lib/github';
3
3
  import { CONFIG_PATH, STATIC_DIR, isDisabledFeaturePath, isWebsitePath, normalizeProjectConfig } from '@hintergrund/runtime-contracts';
4
- import { translateWebsite } from '../../../lib/website-i18n';
4
+ import { translateWebsiteFiles } from '../../../lib/website-i18n';
5
5
  const STATIC_MIME_TYPES = {
6
6
  '.jpg': 'image/jpeg',
7
7
  '.jpeg': 'image/jpeg',
@@ -22,46 +22,19 @@ function getStaticMimeType(path) {
22
22
  const ext = path.slice(((path.lastIndexOf('.') - 1) >>> 0) + 2).toLowerCase();
23
23
  return STATIC_MIME_TYPES['.' + ext] ?? null;
24
24
  }
25
+ /** An earlier version is addressed by its full commit SHA; anything else reads the branch. */
26
+ function commitRef(c) {
27
+ const ref = c.req.query('ref');
28
+ if (!ref)
29
+ return undefined;
30
+ return /^[0-9a-f]{40}$/.test(ref) ? ref : null;
31
+ }
25
32
  function normalizePath(path) {
26
33
  return path.replace(/^\/+/, '').replace(/\\/g, '/');
27
34
  }
28
35
  export function isAllowedWebsitePath(path) {
29
36
  return isWebsitePath(normalizePath(path));
30
37
  }
31
- async function listRepoFiles(c) {
32
- const client = createGitHubClient(getGitHubConfig(c.env));
33
- const { owner, repo, branch } = client.getRepoInfo();
34
- const octokit = await client.getOctokit();
35
- const tree = await octokit.rest.git.getTree({ owner, repo, tree_sha: branch, recursive: 'true' });
36
- const paths = tree.data.tree
37
- .filter((item) => item.type === 'blob' && item.path && isAllowedWebsitePath(item.path))
38
- .filter((item) => !getStaticMimeType(item.path)) // text files only
39
- .map((item) => item.path);
40
- const files = {};
41
- const results = await client.readFiles(paths);
42
- for (const [path, result] of results) {
43
- if (result)
44
- files[path] = result;
45
- }
46
- return files;
47
- }
48
- async function listStaticAssets(c) {
49
- const client = createGitHubClient(getGitHubConfig(c.env));
50
- const { owner, repo, branch } = client.getRepoInfo();
51
- const octokit = await client.getOctokit();
52
- const tree = await octokit.rest.git.getTree({ owner, repo, tree_sha: branch, recursive: 'true' });
53
- const assetPaths = tree.data.tree
54
- .filter((item) => item.type === 'blob' &&
55
- item.path &&
56
- item.path.startsWith(STATIC_DIR) &&
57
- getStaticMimeType(item.path) !== null)
58
- .map((item) => ({ path: item.path, sha: item.sha }));
59
- return assetPaths.map(({ path, sha }) => {
60
- const name = path.split('/').pop();
61
- const mimeType = getStaticMimeType(path);
62
- return { name, path, content: '', mimeType, sha };
63
- });
64
- }
65
38
  /** Admin-only access to Git-backed images, including before the next site deployment. */
66
39
  export async function getWebsiteAsset(c) {
67
40
  const path = c.req.param('path') || '';
@@ -69,9 +42,12 @@ export async function getWebsiteAsset(c) {
69
42
  if (!path.startsWith(STATIC_DIR) || path.split('/').some((part) => !part || part === '.' || part === '..') || /[\\\\\x00-\x1f]/.test(path) || !mimeType) {
70
43
  return c.json({ error: 'Invalid static asset path' }, 400);
71
44
  }
45
+ const ref = commitRef(c);
46
+ if (ref === null)
47
+ return c.json({ error: 'Invalid version' }, 400);
72
48
  const client = createGitHubClient(getGitHubConfig(c.env));
73
49
  try {
74
- const asset = await client.readFileBinary(path, MAX_UPLOAD_BYTES);
50
+ const asset = await client.readFileBinary(path, MAX_UPLOAD_BYTES, ref);
75
51
  if (!asset)
76
52
  return c.notFound();
77
53
  const headers = {
@@ -97,19 +73,36 @@ export async function headWebsiteRepo(c) {
97
73
  const client = createGitHubClient(getGitHubConfig(c.env));
98
74
  return c.json({ commitSha: await client.getCommitSha() });
99
75
  }
76
+ /** Published versions, newest first: what the history lists, never the files they touched. */
77
+ export async function historyWebsiteRepo(c) {
78
+ const page = Math.max(1, Number(c.req.query('page')) || 1);
79
+ const client = createGitHubClient(getGitHubConfig(c.env));
80
+ const versions = await client.listCommits(page, 30);
81
+ return c.json({ versions, hasMore: versions.length === 30 });
82
+ }
83
+ /**
84
+ * The working copy at the branch head, or with `ref` the snapshot of an earlier version.
85
+ * The client names the blob SHAs it already holds; only the text of the others is sent,
86
+ * so a sync after one edit reads one blob, not the repository. Images never carry bytes.
87
+ */
100
88
  export async function syncWebsiteRepo(c) {
89
+ const body = await c.req.json().catch(() => ({}));
90
+ if (body.ref !== undefined && !/^[0-9a-f]{40}$/.test(body.ref))
91
+ return c.json({ error: 'Invalid version' }, 400);
92
+ const known = new Set(Array.isArray(body.known) ? body.known : []);
101
93
  const client = createGitHubClient(getGitHubConfig(c.env));
102
- const [files, commitSha, staticAssets] = await Promise.all([
103
- listRepoFiles(c),
104
- client.getCommitSha(),
105
- listStaticAssets(c),
106
- ]);
107
- const srcFiles = Object.entries(files).map(([path, file]) => ({
108
- path,
109
- content: file.content,
110
- sha: file.sha,
111
- }));
112
- return c.json({ files, srcFiles, staticAssets, commitSha });
94
+ const { commitSha, blobs } = await client.readTree(body.ref);
95
+ const files = blobs
96
+ .filter(({ path }) => isAllowedWebsitePath(path))
97
+ .map(({ path, sha }) => {
98
+ const mimeType = getStaticMimeType(path);
99
+ if (mimeType)
100
+ return path.startsWith(STATIC_DIR) ? { path, sha, encoding: 'base64', mimeType } : null;
101
+ return { path, sha, encoding: 'utf8' };
102
+ })
103
+ .filter((file) => file !== null);
104
+ const contents = await client.readTextBlobs(files.filter((file) => file.encoding === 'utf8' && !known.has(file.sha)).map((file) => file.sha));
105
+ return c.json({ commitSha, files, contents: Object.fromEntries(contents) });
113
106
  }
114
107
  export async function commitWebsiteRepo(c) {
115
108
  const body = await c.req.json();
@@ -157,24 +150,14 @@ export async function commitWebsiteRepo(c) {
157
150
  }
158
151
  }
159
152
  const baseCommitSha = body.baseCommitSha ? String(body.baseCommitSha) : await client.getCommitSha();
160
- let translation = null;
153
+ let output;
161
154
  try {
162
- if (files.some(file => file.path === CONFIG_PATH) || await client.readFile(CONFIG_PATH)) {
163
- const snapshot = await listRepoFiles(c);
164
- const combined = new Map(Object.entries(snapshot).map(([path, file]) => [path, { path, content: file.content }]));
165
- for (const file of files)
166
- combined.set(file.path, file);
167
- for (const path of deletions)
168
- combined.delete(path);
169
- translation = await translateWebsite(combined, c.env);
170
- }
155
+ output = await translateWebsiteFiles(client, files, c.env, baseCommitSha, deletions);
171
156
  }
172
157
  catch (error) {
173
158
  return c.json({ error: error instanceof Error ? error.message : 'Website translation failed. Your changes have not been published.' }, 422);
174
159
  }
175
- const output = new Map(files.map(file => [file.path, file]));
176
- if (translation)
177
- output.set(translation.path, translation);
178
- const commitSha = await client.writeFilesAtomic([...output.values()], String(body.message || 'Publish website changes'), baseCommitSha, deletions.filter(path => !output.has(path)));
179
- return c.json({ success: true, commitSha, generatedFiles: translation ? [translation] : [] });
160
+ const generatedFiles = output.filter((file) => !writtenPaths.has(file.path));
161
+ const commitSha = await client.writeFilesAtomic(output, String(body.message || 'Publish website changes'), baseCommitSha, deletions.filter(path => !output.some((file) => file.path === path)));
162
+ return c.json({ success: true, commitSha, generatedFiles });
180
163
  }
@@ -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;AAe5B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAG9C,QAAA,MAAM,SAAS,sDAAsB,CAAC;AA6BtC,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;AA8BtC,eAAe,SAAS,CAAC"}
@@ -4,7 +4,7 @@ import { authMiddleware } from '../../../middleware/auth';
4
4
  import authRoutes from './auth.routes';
5
5
  import { createAdminUser, deleteAdminUser, listAdminUsers, patchAdminUser, sendUserRecovery } from '../handlers/admin-users.handler';
6
6
  import { getAgentConfig, proxyAgentRequest } from '../handlers/agent-provider.handler';
7
- import { commitWebsiteRepo, getWebsiteAsset, headWebsiteRepo, syncWebsiteRepo } from '../handlers/website-repo.handler';
7
+ import { commitWebsiteRepo, getWebsiteAsset, headWebsiteRepo, historyWebsiteRepo, syncWebsiteRepo } from '../handlers/website-repo.handler';
8
8
  import { deleteGitHubSecret, listGitHubSecrets, upsertGitHubSecret } from '../handlers/github-secrets.handler';
9
9
  import { setupContext, setupProject } from '../handlers/setup.handler';
10
10
  import { testIntegration, testSetupIntegration } from '../handlers/integrations.handler';
@@ -26,7 +26,8 @@ cmsRoutes.delete('/users/:id', deleteAdminUser);
26
26
  cmsRoutes.get('/agent/config', getAgentConfig);
27
27
  cmsRoutes.all('/agent/llm/:path{.+}', proxyAgentRequest);
28
28
  cmsRoutes.get('/website/repo/head', headWebsiteRepo);
29
- cmsRoutes.get('/website/repo/sync', syncWebsiteRepo);
29
+ cmsRoutes.post('/website/repo/sync', syncWebsiteRepo);
30
+ cmsRoutes.get('/website/repo/history', historyWebsiteRepo);
30
31
  cmsRoutes.put('/website/repo/commit', commitWebsiteRepo);
31
32
  cmsRoutes.get('/website/repo/assets/:path{.+}', getWebsiteAsset);
32
33
  cmsRoutes.post('/integrations/:provider/test', testIntegration);
@@ -1,19 +1,13 @@
1
1
  /**
2
- * Campaigns Handler — D1-backed, no Plunk dependency
2
+ * Campaigns are authored in the repository (`emails/campaigns/<id>.json`) and published
3
+ * like any other edit. Sending reads the published draft, records exactly what went out
4
+ * in D1, and removes the draft: a sent campaign is history, not something to edit.
3
5
  */
4
6
  import { Context } from 'hono';
5
- /** GET /api/email/admin/campaigns */
7
+ /** GET /api/email/admin/campaigns — every campaign that was sent, newest first. */
6
8
  export declare function getCampaigns(c: Context): Promise<Response>;
7
- /** GET /api/email/admin/campaigns/:id */
8
- export declare function getCampaign(c: Context): Promise<Response>;
9
- /** POST /api/email/admin/campaigns */
10
- export declare function createCampaign(c: Context): Promise<Response>;
11
- /** PATCH /api/email/admin/campaigns/:id */
12
- export declare function updateCampaign(c: Context): Promise<Response>;
13
- /** DELETE /api/email/admin/campaigns/:id */
14
- export declare function deleteCampaign(c: Context): Promise<Response>;
15
- /** POST /api/email/admin/campaigns/:id/send */
9
+ /** POST /api/email/admin/campaigns/:id/send — sends the published draft to every subscriber. */
16
10
  export declare function sendCampaign(c: Context): Promise<Response>;
17
- /** POST /api/email/admin/campaigns/:id/test */
11
+ /** POST /api/email/admin/campaigns/test — sends the copy being edited, published or not. */
18
12
  export declare function testCampaign(c: Context): Promise<Response>;
19
13
  //# sourceMappingURL=campaigns.handler.d.ts.map
@@ -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,CAyDhE;AAED,+CAA+C;AAC/C,wBAAsB,YAAY,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CA6BhE"}
1
+ {"version":3,"file":"campaigns.handler.d.ts","sourceRoot":"","sources":["../../../../src/api/emails/handlers/campaigns.handler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AA2B/B,mFAAmF;AACnF,wBAAsB,YAAY,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAUhE;AAED,gGAAgG;AAChG,wBAAsB,YAAY,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAmDhE;AAED,4FAA4F;AAC5F,wBAAsB,YAAY,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAiBhE"}
@@ -1,30 +1,35 @@
1
1
  /**
2
- * Campaigns Handler — D1-backed, no Plunk dependency
2
+ * Campaigns are authored in the repository (`emails/campaigns/<id>.json`) and published
3
+ * like any other edit. Sending reads the published draft, records exactly what went out
4
+ * in D1, and removes the draft: a sent campaign is history, not something to edit.
3
5
  */
4
- import { getProjectDb, createId } from '../../../lib/project-db';
6
+ import { getProjectDb } from '../../../lib/project-db';
7
+ import { getGitHubConfig } from '../../../lib/config';
8
+ import { createGitHubClient } from '../../../lib/github';
5
9
  import { sendEmail } from '../../../lib/email';
6
10
  import { renderEmailTemplate } from '../../../lib/email-template';
7
11
  import { readEmailTemplateData } from './settings.handler';
12
+ import { EMAIL_CAMPAIGNS_DIR } from '@hintergrund/runtime-contracts';
13
+ const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
8
14
  function rowToCampaign(row) {
9
15
  return {
10
16
  id: row.id,
11
17
  name: row.name,
12
18
  subject: row.subject,
13
19
  bodyHtml: row.body_html,
14
- status: row.status,
15
20
  recipientCount: row.recipient_count,
16
- scheduledAt: row.scheduled_at,
17
21
  sentAt: row.sent_at,
18
- createdAt: row.created_at,
19
- updatedAt: row.updated_at,
20
22
  };
21
23
  }
22
- /** GET /api/email/admin/campaigns */
24
+ function isDraft(value) {
25
+ const draft = value;
26
+ return !!draft && typeof draft.name === 'string' && typeof draft.subject === 'string' && !!draft.subject.trim() && typeof draft.bodyHtml === 'string' && !!draft.bodyHtml.trim();
27
+ }
28
+ /** GET /api/email/admin/campaigns — every campaign that was sent, newest first. */
23
29
  export async function getCampaigns(c) {
24
30
  try {
25
- const db = getProjectDb(c.env);
26
- const { results } = await db
27
- .prepare('SELECT * FROM campaigns ORDER BY created_at DESC')
31
+ const { results } = await getProjectDb(c.env)
32
+ .prepare('SELECT * FROM campaigns ORDER BY sent_at DESC')
28
33
  .all();
29
34
  return c.json({ campaigns: (results ?? []).map(rowToCampaign) });
30
35
  }
@@ -33,139 +38,53 @@ export async function getCampaigns(c) {
33
38
  return c.json({ success: false, message: 'Failed to fetch campaigns' }, 500);
34
39
  }
35
40
  }
36
- /** GET /api/email/admin/campaigns/:id */
37
- export async function getCampaign(c) {
38
- try {
39
- const id = c.req.param('id');
40
- const db = getProjectDb(c.env);
41
- const row = await db.prepare('SELECT * FROM campaigns WHERE id = ?').bind(id).first();
42
- if (!row)
43
- return c.json({ success: false, message: 'Campaign not found' }, 404);
44
- return c.json({ campaign: rowToCampaign(row) });
45
- }
46
- catch (error) {
47
- console.error('Get campaign error:', error);
48
- return c.json({ success: false, message: 'Failed to fetch campaign' }, 500);
49
- }
50
- }
51
- /** POST /api/email/admin/campaigns */
52
- export async function createCampaign(c) {
53
- try {
54
- const body = await c.req.json();
55
- if (!body.name || !body.subject || !body.bodyHtml) {
56
- return c.json({ success: false, message: 'name, subject, and bodyHtml are required' }, 400);
57
- }
58
- const db = getProjectDb(c.env);
59
- const now = Date.now();
60
- const id = createId('cam');
61
- await db.prepare(`INSERT INTO campaigns (id, name, subject, body_html, status, created_at, updated_at)
62
- VALUES (?, ?, ?, ?, 'draft', ?, ?)`).bind(id, body.name, body.subject, body.bodyHtml, now, now).run();
63
- const row = await db.prepare('SELECT * FROM campaigns WHERE id = ?').bind(id).first();
64
- return c.json({ success: true, campaign: rowToCampaign(row) }, 201);
65
- }
66
- catch (error) {
67
- console.error('Create campaign error:', error);
68
- return c.json({ success: false, message: 'Failed to create campaign' }, 500);
69
- }
70
- }
71
- /** PATCH /api/email/admin/campaigns/:id */
72
- export async function updateCampaign(c) {
73
- try {
74
- const id = c.req.param('id');
75
- const body = await c.req.json();
76
- const db = getProjectDb(c.env);
77
- const now = Date.now();
78
- const existing = await db.prepare('SELECT * FROM campaigns WHERE id = ?').bind(id).first();
79
- if (!existing)
80
- return c.json({ success: false, message: 'Campaign not found' }, 404);
81
- if (existing.status === 'sent')
82
- return c.json({ success: false, message: 'Cannot edit a sent campaign' }, 400);
83
- const sets = ['updated_at = ?'];
84
- const vals = [now];
85
- if (body.name !== undefined) {
86
- sets.push('name = ?');
87
- vals.push(body.name);
88
- }
89
- if (body.subject !== undefined) {
90
- sets.push('subject = ?');
91
- vals.push(body.subject);
92
- }
93
- if (body.bodyHtml !== undefined) {
94
- sets.push('body_html = ?');
95
- vals.push(body.bodyHtml);
96
- }
97
- vals.push(id);
98
- await db.prepare(`UPDATE campaigns SET ${sets.join(', ')} WHERE id = ?`).bind(...vals).run();
99
- const row = await db.prepare('SELECT * FROM campaigns WHERE id = ?').bind(id).first();
100
- return c.json({ success: true, campaign: rowToCampaign(row) });
101
- }
102
- catch (error) {
103
- console.error('Update campaign error:', error);
104
- return c.json({ success: false, message: 'Failed to update campaign' }, 500);
105
- }
106
- }
107
- /** DELETE /api/email/admin/campaigns/:id */
108
- export async function deleteCampaign(c) {
109
- try {
110
- const id = c.req.param('id');
111
- const db = getProjectDb(c.env);
112
- const existing = await db.prepare('SELECT id FROM campaigns WHERE id = ?').bind(id).first();
113
- if (!existing)
114
- return c.json({ success: false, message: 'Campaign not found' }, 404);
115
- await db.prepare('DELETE FROM campaigns WHERE id = ?').bind(id).run();
116
- return c.json({ success: true });
117
- }
118
- catch (error) {
119
- console.error('Delete campaign error:', error);
120
- return c.json({ success: false, message: 'Failed to delete campaign' }, 500);
121
- }
122
- }
123
- /** POST /api/email/admin/campaigns/:id/send */
41
+ /** POST /api/email/admin/campaigns/:id/send — sends the published draft to every subscriber. */
124
42
  export async function sendCampaign(c) {
125
43
  try {
126
- const id = c.req.param('id');
44
+ const id = c.req.param('id') ?? '';
45
+ if (!/^[a-z0-9_-]+$/i.test(id))
46
+ return c.json({ success: false, message: 'Invalid campaign' }, 400);
127
47
  const db = getProjectDb(c.env);
128
- const row = await db.prepare('SELECT * FROM campaigns WHERE id = ?').bind(id).first();
129
- if (!row)
130
- return c.json({ success: false, message: 'Campaign not found' }, 404);
131
- if (row.status === 'sent')
48
+ if (await db.prepare('SELECT id FROM campaigns WHERE id = ?').bind(id).first()) {
132
49
  return c.json({ success: false, message: 'Campaign already sent' }, 400);
133
- // Get all subscribed contacts
50
+ }
51
+ const github = createGitHubClient(getGitHubConfig(c.env));
52
+ const path = `${EMAIL_CAMPAIGNS_DIR}${id}.json`;
53
+ const draft = (await github.readJsonFile(path))?.data;
54
+ if (!isDraft(draft))
55
+ return c.json({ success: false, message: 'Publish this campaign with a subject and body before sending it.' }, 400);
134
56
  const { results: subscribers } = await db
135
57
  .prepare("SELECT email, name FROM subscribers WHERE status = 'subscribed'")
136
58
  .all();
137
59
  if (!subscribers || subscribers.length === 0) {
138
60
  return c.json({ success: false, message: 'No subscribed contacts found' }, 400);
139
61
  }
140
- const now = Date.now();
141
62
  const { settings, logoDataUrl } = await readEmailTemplateData(c.env);
142
- let sentCount = 0;
143
- let lastError;
144
63
  const origin = new URL(c.req.url).origin;
145
- // Send to each subscriber
64
+ let sentCount = 0;
146
65
  for (const subscriber of subscribers) {
147
- const unsubscribeUrl = `${origin}/api/email/unsubscribe?email=${encodeURIComponent(subscriber.email)}`;
148
66
  try {
149
67
  await sendEmail(c.env, {
150
68
  to: subscriber.email,
151
69
  toName: subscriber.name ?? undefined,
152
- subject: row.subject,
70
+ subject: draft.subject,
153
71
  html: renderEmailTemplate({
154
- bodyHtml: row.body_html,
72
+ bodyHtml: draft.bodyHtml,
155
73
  template: settings.emailTemplate, logoDataUrl,
156
- unsubscribeUrl,
74
+ unsubscribeUrl: `${origin}/api/email/unsubscribe?email=${encodeURIComponent(subscriber.email)}`,
157
75
  }),
158
76
  });
159
77
  sentCount++;
160
78
  }
161
79
  catch (err) {
162
80
  console.error(`Failed to send to ${subscriber.email}:`, err);
163
- lastError = err instanceof Error ? err.message : 'Unknown error';
164
81
  }
165
82
  }
166
- const status = sentCount > 0 ? 'sent' : 'failed';
167
- // Update campaign status
168
- await db.prepare('UPDATE campaigns SET status = ?, recipient_count = ?, sent_at = ?, updated_at = ? WHERE id = ?').bind(status, sentCount, now, now, id).run();
83
+ if (sentCount === 0)
84
+ return c.json({ success: false, message: 'No email could be delivered. The draft is unchanged.' }, 502);
85
+ await db.prepare('INSERT INTO campaigns (id, name, subject, body_html, recipient_count, sent_at) VALUES (?, ?, ?, ?, ?, ?)')
86
+ .bind(id, draft.name, draft.subject, draft.bodyHtml, sentCount, Date.now()).run();
87
+ await github.writeFilesAtomic([], `Sent campaign ${draft.name} [skip ci]`, undefined, [path]);
169
88
  return c.json({ success: true, recipientCount: sentCount });
170
89
  }
171
90
  catch (error) {
@@ -173,28 +92,19 @@ export async function sendCampaign(c) {
173
92
  return c.json({ success: false, message: 'Failed to send campaign' }, 500);
174
93
  }
175
94
  }
176
- /** POST /api/email/admin/campaigns/:id/test */
95
+ /** POST /api/email/admin/campaigns/test — sends the copy being edited, published or not. */
177
96
  export async function testCampaign(c) {
178
97
  try {
179
- const id = c.req.param('id');
180
98
  const body = await c.req.json();
181
- if (!body.email)
182
- return c.json({ success: false, message: 'Test email is required' }, 400);
183
- const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
184
- if (!EMAIL_REGEX.test(body.email))
185
- return c.json({ success: false, message: 'Invalid email format' }, 400);
186
- const db = getProjectDb(c.env);
187
- const row = await db.prepare('SELECT * FROM campaigns WHERE id = ?').bind(id).first();
188
- if (!row)
189
- return c.json({ success: false, message: 'Campaign not found' }, 404);
99
+ if (!body.email || !EMAIL_REGEX.test(body.email))
100
+ return c.json({ success: false, message: 'A valid test address is required' }, 400);
101
+ if (!isDraft({ ...body, name: body.name ?? '' }))
102
+ return c.json({ success: false, message: 'A subject and body are required' }, 400);
190
103
  const { settings, logoDataUrl } = await readEmailTemplateData(c.env);
191
104
  await sendEmail(c.env, {
192
105
  to: body.email,
193
- subject: `[TEST] ${row.subject}`,
194
- html: renderEmailTemplate({
195
- bodyHtml: row.body_html,
196
- template: settings.emailTemplate, logoDataUrl,
197
- }),
106
+ subject: `[TEST] ${body.subject}`,
107
+ html: renderEmailTemplate({ bodyHtml: body.bodyHtml, template: settings.emailTemplate, logoDataUrl }),
198
108
  });
199
109
  return c.json({ success: true, message: `Test email sent to ${body.email}` });
200
110
  }
@@ -1,9 +1,9 @@
1
- import { type Design, type InvoiceDesign, type InvoiceConfig, type InvoiceData } from '@hintergrund/runtime-contracts';
1
+ import { type Design, type InvoiceDesign, type BusinessDetails, type InvoiceData } from '@hintergrund/runtime-contracts';
2
2
  export interface InvoiceAssets {
3
3
  logo?: Uint8Array;
4
4
  bodyFont?: Uint8Array;
5
5
  displayFont?: Uint8Array;
6
6
  }
7
7
  /** Same deterministic renderer for preview, downloads and email attachments. */
8
- export declare function generateInvoicePdf(config: InvoiceConfig, data: InvoiceData, design: Design, invoiceDesign: InvoiceDesign, assets?: InvoiceAssets): Promise<Uint8Array>;
8
+ export declare function generateInvoicePdf(business: BusinessDetails, data: InvoiceData, design: Design, invoiceDesign: InvoiceDesign, assets?: InvoiceAssets): Promise<Uint8Array>;
9
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":"AAEA,OAAO,EAAyC,KAAK,MAAM,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE9J,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,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,GAAE,aAAkB,GAAG,OAAO,CAAC,UAAU,CAAC,CA6GhL"}
1
+ {"version":3,"file":"invoice.handler.d.ts","sourceRoot":"","sources":["../../../../src/api/emails/handlers/invoice.handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAyC,KAAK,MAAM,EAAE,KAAK,aAAa,EAAE,KAAK,eAAe,EAAE,KAAK,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAEhK,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,QAAQ,EAAE,eAAe,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,GAAE,aAAkB,GAAG,OAAO,CAAC,UAAU,CAAC,CA8GpL"}
@@ -2,7 +2,7 @@ import { PDFDocument, StandardFonts, rgb } from 'pdf-lib';
2
2
  import fontkit from '@pdf-lib/fontkit';
3
3
  import { validateDesign, validateInvoiceDesign } from '@hintergrund/runtime-contracts';
4
4
  /** Same deterministic renderer for preview, downloads and email attachments. */
5
- export async function generateInvoicePdf(config, data, design, invoiceDesign, assets = {}) {
5
+ export async function generateInvoicePdf(business, data, design, invoiceDesign, assets = {}) {
6
6
  validateDesign(design);
7
7
  validateInvoiceDesign(invoiceDesign);
8
8
  const pdf = await PDFDocument.create();
@@ -72,7 +72,8 @@ export async function generateInvoicePdf(config, data, design, invoiceDesign, as
72
72
  page.drawImage(image, { x, y: y - h, width: w, height: h });
73
73
  y -= h + line;
74
74
  }
75
- for (const value of [config.companyName, config.companyAddress, config.companyEmail, config.companyPhone])
75
+ const locality = [business.postalCode, business.city].filter(Boolean).join(' ');
76
+ for (const value of [business.companyName, business.street, locality, business.country, business.email, business.phone, business.vatId && `VAT ID: ${business.vatId}`])
76
77
  if (value)
77
78
  text(value);
78
79
  y -= line;
@@ -1 +1 @@
1
- {"version":3,"file":"public.handler.d.ts","sourceRoot":"","sources":["../../../../src/api/emails/handlers/public.handler.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAS/B,gCAAgC;AAChC,wBAAsB,SAAS,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAkD7D;AAqBD,6BAA6B;AAC7B,wBAAsB,OAAO,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CA0C3D;AAED,kCAAkC;AAClC,wBAAsB,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAoC/D;AAED,yDAAyD;AACzD,wBAAsB,mBAAmB,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CA2DvE"}
1
+ {"version":3,"file":"public.handler.d.ts","sourceRoot":"","sources":["../../../../src/api/emails/handlers/public.handler.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAQ/B,gCAAgC;AAChC,wBAAsB,SAAS,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAiD7D;AAoBD,6BAA6B;AAC7B,wBAAsB,OAAO,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAyC3D;AAED,kCAAkC;AAClC,wBAAsB,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAoC/D;AAED,yDAAyD;AACzD,wBAAsB,mBAAmB,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CA2DvE"}