@hintergrund/worker 0.1.6 → 0.1.7

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 (186) hide show
  1. package/dist/api/cms/handlers/admin-users.handler.d.ts +8 -0
  2. package/dist/api/cms/handlers/admin-users.handler.d.ts.map +1 -0
  3. package/dist/api/cms/handlers/admin-users.handler.js +121 -0
  4. package/dist/api/cms/handlers/agent-conversations.handler.d.ts +7 -0
  5. package/dist/api/cms/handlers/agent-conversations.handler.d.ts.map +1 -0
  6. package/dist/api/cms/handlers/agent-conversations.handler.js +94 -0
  7. package/dist/api/cms/handlers/auth.handler.d.ts +0 -3
  8. package/dist/api/cms/handlers/auth.handler.d.ts.map +1 -1
  9. package/dist/api/cms/handlers/auth.handler.js +74 -153
  10. package/dist/api/cms/handlers/website-repo.handler.d.ts +8 -0
  11. package/dist/api/cms/handlers/website-repo.handler.d.ts.map +1 -0
  12. package/dist/api/cms/handlers/website-repo.handler.js +148 -0
  13. package/dist/api/cms/routes/index.d.ts.map +1 -1
  14. package/dist/api/cms/routes/index.js +16 -4
  15. package/dist/api/emails/handlers/campaigns.handler.d.ts +10 -23
  16. package/dist/api/emails/handlers/campaigns.handler.d.ts.map +1 -1
  17. package/dist/api/emails/handlers/campaigns.handler.js +164 -92
  18. package/dist/api/emails/handlers/invoice.handler.d.ts +5 -19
  19. package/dist/api/emails/handlers/invoice.handler.d.ts.map +1 -1
  20. package/dist/api/emails/handlers/invoice.handler.js +58 -340
  21. package/dist/api/emails/handlers/public.handler.d.ts +6 -29
  22. package/dist/api/emails/handlers/public.handler.d.ts.map +1 -1
  23. package/dist/api/emails/handlers/public.handler.js +150 -312
  24. package/dist/api/emails/handlers/send.handler.d.ts +5 -17
  25. package/dist/api/emails/handlers/send.handler.d.ts.map +1 -1
  26. package/dist/api/emails/handlers/send.handler.js +107 -92
  27. package/dist/api/emails/handlers/settings.handler.d.ts +28 -33
  28. package/dist/api/emails/handlers/settings.handler.d.ts.map +1 -1
  29. package/dist/api/emails/handlers/settings.handler.js +96 -287
  30. package/dist/api/emails/handlers/subscribers.handler.d.ts +13 -0
  31. package/dist/api/emails/handlers/subscribers.handler.d.ts.map +1 -0
  32. package/dist/api/emails/handlers/subscribers.handler.js +125 -0
  33. package/dist/api/emails/handlers/webhook.handler.d.ts +1 -2
  34. package/dist/api/emails/handlers/webhook.handler.d.ts.map +1 -1
  35. package/dist/api/emails/handlers/webhook.handler.js +66 -166
  36. package/dist/api/emails/routes/admin.routes.d.ts +1 -3
  37. package/dist/api/emails/routes/admin.routes.d.ts.map +1 -1
  38. package/dist/api/emails/routes/admin.routes.js +19 -49
  39. package/dist/api/emails/routes/public.routes.d.ts +1 -3
  40. package/dist/api/emails/routes/public.routes.d.ts.map +1 -1
  41. package/dist/api/emails/routes/public.routes.js +2 -9
  42. package/dist/api/shop/handlers/prices.handler.d.ts +2 -15
  43. package/dist/api/shop/handlers/prices.handler.d.ts.map +1 -1
  44. package/dist/api/shop/handlers/prices.handler.js +2 -83
  45. package/dist/api/shop/handlers/products.handler.d.ts +29 -20
  46. package/dist/api/shop/handlers/products.handler.d.ts.map +1 -1
  47. package/dist/api/shop/handlers/products.handler.js +195 -162
  48. package/dist/api/shop/handlers/public.handler.d.ts +24 -8
  49. package/dist/api/shop/handlers/public.handler.d.ts.map +1 -1
  50. package/dist/api/shop/handlers/public.handler.js +525 -78
  51. package/dist/api/shop/routes.d.ts.map +1 -1
  52. package/dist/api/shop/routes.js +14 -9
  53. package/dist/hintergrund-assets.d.ts +3 -2
  54. package/dist/hintergrund-assets.d.ts.map +1 -1
  55. package/dist/hintergrund-assets.js +4 -2
  56. package/dist/index.d.ts +14 -7
  57. package/dist/index.d.ts.map +1 -1
  58. package/dist/index.js +44 -4
  59. package/dist/lib/auth/crypto.d.ts +2 -15
  60. package/dist/lib/auth/crypto.d.ts.map +1 -1
  61. package/dist/lib/auth/crypto.js +8 -95
  62. package/dist/lib/auth/jwt.d.ts +0 -4
  63. package/dist/lib/auth/jwt.d.ts.map +1 -1
  64. package/dist/lib/auth/jwt.js +0 -6
  65. package/dist/lib/config.d.ts +1 -1
  66. package/dist/lib/config.d.ts.map +1 -1
  67. package/dist/lib/config.js +42 -86
  68. package/dist/lib/email-template.d.ts +15 -0
  69. package/dist/lib/email-template.d.ts.map +1 -0
  70. package/dist/lib/email-template.js +58 -0
  71. package/dist/lib/email.d.ts +18 -8
  72. package/dist/lib/email.d.ts.map +1 -1
  73. package/dist/lib/email.js +59 -70
  74. package/dist/lib/github-config.d.ts +19 -0
  75. package/dist/lib/github-config.d.ts.map +1 -0
  76. package/dist/lib/github-config.js +23 -0
  77. package/dist/lib/github.d.ts +10 -0
  78. package/dist/lib/github.d.ts.map +1 -1
  79. package/dist/lib/github.js +20 -2
  80. package/dist/lib/project-db.d.ts +24 -0
  81. package/dist/lib/project-db.d.ts.map +1 -0
  82. package/dist/lib/project-db.js +172 -0
  83. package/dist/lib/template.js +4 -4
  84. package/dist/middleware/auth.d.ts +0 -2
  85. package/dist/middleware/auth.d.ts.map +1 -1
  86. package/dist/middleware/auth.js +21 -50
  87. package/package.json +3 -2
  88. package/dist/api/builder/handlers/generate.handler.d.ts +0 -12
  89. package/dist/api/builder/handlers/generate.handler.d.ts.map +0 -1
  90. package/dist/api/builder/handlers/generate.handler.js +0 -203
  91. package/dist/api/builder/handlers/template.handler.d.ts +0 -12
  92. package/dist/api/builder/handlers/template.handler.d.ts.map +0 -1
  93. package/dist/api/builder/handlers/template.handler.js +0 -208
  94. package/dist/api/builder/routes.d.ts +0 -7
  95. package/dist/api/builder/routes.d.ts.map +0 -1
  96. package/dist/api/builder/routes.js +0 -15
  97. package/dist/api/cms/handlers/assets.handler.d.ts +0 -31
  98. package/dist/api/cms/handlers/assets.handler.d.ts.map +0 -1
  99. package/dist/api/cms/handlers/assets.handler.js +0 -200
  100. package/dist/api/cms/handlers/config.handler.d.ts +0 -7
  101. package/dist/api/cms/handlers/config.handler.d.ts.map +0 -1
  102. package/dist/api/cms/handlers/config.handler.js +0 -37
  103. package/dist/api/cms/handlers/content.handler.d.ts +0 -21
  104. package/dist/api/cms/handlers/content.handler.d.ts.map +0 -1
  105. package/dist/api/cms/handlers/content.handler.js +0 -117
  106. package/dist/api/cms/routes/assets.routes.d.ts +0 -4
  107. package/dist/api/cms/routes/assets.routes.d.ts.map +0 -1
  108. package/dist/api/cms/routes/assets.routes.js +0 -13
  109. package/dist/api/cms/routes/content.routes.d.ts +0 -4
  110. package/dist/api/cms/routes/content.routes.d.ts.map +0 -1
  111. package/dist/api/cms/routes/content.routes.js +0 -11
  112. package/dist/api/emails/handlers/branding.handler.d.ts +0 -17
  113. package/dist/api/emails/handlers/branding.handler.d.ts.map +0 -1
  114. package/dist/api/emails/handlers/branding.handler.js +0 -120
  115. package/dist/api/emails/handlers/contacts.handler.d.ts +0 -37
  116. package/dist/api/emails/handlers/contacts.handler.d.ts.map +0 -1
  117. package/dist/api/emails/handlers/contacts.handler.js +0 -161
  118. package/dist/api/emails/handlers/templates.handler.d.ts +0 -32
  119. package/dist/api/emails/handlers/templates.handler.d.ts.map +0 -1
  120. package/dist/api/emails/handlers/templates.handler.js +0 -132
  121. package/dist/api/newsletter/handlers/email.handler.d.ts +0 -7
  122. package/dist/api/newsletter/handlers/email.handler.d.ts.map +0 -1
  123. package/dist/api/newsletter/handlers/email.handler.js +0 -102
  124. package/dist/api/newsletter/handlers/emails.handler.d.ts +0 -31
  125. package/dist/api/newsletter/handlers/emails.handler.d.ts.map +0 -1
  126. package/dist/api/newsletter/handlers/emails.handler.js +0 -262
  127. package/dist/api/newsletter/handlers/invoice.handler.d.ts +0 -22
  128. package/dist/api/newsletter/handlers/invoice.handler.d.ts.map +0 -1
  129. package/dist/api/newsletter/handlers/invoice.handler.js +0 -455
  130. package/dist/api/newsletter/handlers/public.handler.d.ts +0 -22
  131. package/dist/api/newsletter/handlers/public.handler.d.ts.map +0 -1
  132. package/dist/api/newsletter/handlers/public.handler.js +0 -300
  133. package/dist/api/newsletter/handlers/send.handler.d.ts +0 -12
  134. package/dist/api/newsletter/handlers/send.handler.d.ts.map +0 -1
  135. package/dist/api/newsletter/handlers/send.handler.js +0 -153
  136. package/dist/api/newsletter/handlers/subscribers.handler.d.ts +0 -22
  137. package/dist/api/newsletter/handlers/subscribers.handler.d.ts.map +0 -1
  138. package/dist/api/newsletter/handlers/subscribers.handler.js +0 -195
  139. package/dist/api/newsletter/routes/admin.routes.d.ts +0 -4
  140. package/dist/api/newsletter/routes/admin.routes.d.ts.map +0 -1
  141. package/dist/api/newsletter/routes/admin.routes.js +0 -28
  142. package/dist/api/newsletter/routes/index.d.ts +0 -4
  143. package/dist/api/newsletter/routes/index.d.ts.map +0 -1
  144. package/dist/api/newsletter/routes/index.js +0 -9
  145. package/dist/api/newsletter/routes/public.routes.d.ts +0 -4
  146. package/dist/api/newsletter/routes/public.routes.d.ts.map +0 -1
  147. package/dist/api/newsletter/routes/public.routes.js +0 -9
  148. package/dist/api/shop/handlers/assets.handler.d.ts +0 -3
  149. package/dist/api/shop/handlers/assets.handler.d.ts.map +0 -1
  150. package/dist/api/shop/handlers/assets.handler.js +0 -62
  151. package/dist/api/shop/handlers/checkout.handler.d.ts +0 -10
  152. package/dist/api/shop/handlers/checkout.handler.d.ts.map +0 -1
  153. package/dist/api/shop/handlers/checkout.handler.js +0 -50
  154. package/dist/api/shop/handlers/customers.handler.d.ts +0 -17
  155. package/dist/api/shop/handlers/customers.handler.d.ts.map +0 -1
  156. package/dist/api/shop/handlers/customers.handler.js +0 -89
  157. package/dist/api/shop/handlers/orders.handler.d.ts +0 -17
  158. package/dist/api/shop/handlers/orders.handler.d.ts.map +0 -1
  159. package/dist/api/shop/handlers/orders.handler.js +0 -84
  160. package/dist/api/shop/handlers/stats.handler.d.ts +0 -10
  161. package/dist/api/shop/handlers/stats.handler.d.ts.map +0 -1
  162. package/dist/api/shop/handlers/stats.handler.js +0 -71
  163. package/dist/api/shop/handlers/webhook.handler.d.ts +0 -10
  164. package/dist/api/shop/handlers/webhook.handler.d.ts.map +0 -1
  165. package/dist/api/shop/handlers/webhook.handler.js +0 -233
  166. package/dist/cms-assets.d.ts +0 -4
  167. package/dist/cms-assets.d.ts.map +0 -1
  168. package/dist/cms-assets.js +0 -5
  169. package/dist/cms-bundle.d.ts +0 -3
  170. package/dist/cms-bundle.d.ts.map +0 -1
  171. package/dist/cms-bundle.js +0 -4
  172. package/dist/config-loader.d.ts +0 -26
  173. package/dist/config-loader.d.ts.map +0 -1
  174. package/dist/config-loader.js +0 -98
  175. package/dist/jwt.d.ts +0 -26
  176. package/dist/jwt.d.ts.map +0 -1
  177. package/dist/jwt.js +0 -102
  178. package/dist/lib/plunk.d.ts +0 -204
  179. package/dist/lib/plunk.d.ts.map +0 -1
  180. package/dist/lib/plunk.js +0 -259
  181. package/dist/template.d.ts +0 -2
  182. package/dist/template.d.ts.map +0 -1
  183. package/dist/template.js +0 -61
  184. package/dist/utils.d.ts +0 -23
  185. package/dist/utils.d.ts.map +0 -1
  186. package/dist/utils.js +0 -110
@@ -1,455 +0,0 @@
1
- import { PDFDocument, rgb, StandardFonts } from 'pdf-lib';
2
- // Default invoice configuration
3
- const DEFAULT_INVOICE_CONFIG = {
4
- primaryColor: '#1f2937',
5
- accentColor: '#3b82f6',
6
- fontFamily: 'helvetica',
7
- logoPosition: 'left',
8
- showLogo: true,
9
- companyName: 'Your Company',
10
- companyAddress: '123 Main Street, City, Country',
11
- companyEmail: 'contact@company.com',
12
- companyPhone: '+1 234 567 890',
13
- footerText: 'Thank you for your business!',
14
- currencySymbol: '€',
15
- currencyPosition: 'before',
16
- showTaxBreakdown: true,
17
- taxLabel: 'VAT',
18
- taxRate: 19,
19
- dueDays: 14
20
- };
21
- /**
22
- * GET /api/email/admin/invoice-template
23
- * Fetch the invoice template configuration
24
- */
25
- export async function getInvoiceTemplate(c) {
26
- try {
27
- const db = c.env.DB;
28
- if (!db) {
29
- return c.json({ success: false, error: 'Database not configured' }, 500);
30
- }
31
- const result = await db
32
- .prepare("SELECT * FROM templates WHERE type = 'invoice'")
33
- .first();
34
- if (!result) {
35
- // Return default template if none exists
36
- const template = {
37
- id: 'invoice',
38
- config: DEFAULT_INVOICE_CONFIG,
39
- createdAt: Date.now(),
40
- updatedAt: Date.now()
41
- };
42
- return c.json({ success: true, template });
43
- }
44
- const template = {
45
- id: result.id,
46
- config: JSON.parse(result.config),
47
- logo: result.logo,
48
- createdAt: result.created_at,
49
- updatedAt: result.updated_at
50
- };
51
- return c.json({ success: true, template });
52
- }
53
- catch (error) {
54
- console.error('Failed to fetch invoice template:', error);
55
- return c.json({ success: false, error: 'Failed to fetch invoice template' }, 500);
56
- }
57
- }
58
- /**
59
- * POST /api/email/admin/invoice-template
60
- * Save the invoice template configuration
61
- */
62
- export async function saveInvoiceTemplate(c) {
63
- try {
64
- const db = c.env.DB;
65
- if (!db) {
66
- return c.json({ success: false, error: 'Database not configured' }, 500);
67
- }
68
- const body = await c.req.json();
69
- const { config, logo } = body;
70
- if (!config) {
71
- return c.json({ success: false, error: 'Config is required' }, 400);
72
- }
73
- const now = Date.now();
74
- const configJson = JSON.stringify(config);
75
- // Check if template exists
76
- const existing = await db
77
- .prepare("SELECT id FROM templates WHERE type = 'invoice'")
78
- .first();
79
- if (existing) {
80
- // Update existing template
81
- await db
82
- .prepare(`UPDATE templates
83
- SET config = ?, logo = ?, updated_at = ?
84
- WHERE type = 'invoice'`)
85
- .bind(configJson, logo || null, now)
86
- .run();
87
- }
88
- else {
89
- // Insert new template
90
- await db
91
- .prepare(`INSERT INTO templates (id, type, config, logo, created_at, updated_at)
92
- VALUES ('invoice', 'invoice', ?, ?, ?, ?)`)
93
- .bind(configJson, logo || null, now, now)
94
- .run();
95
- }
96
- const template = {
97
- id: 'invoice',
98
- config,
99
- logo,
100
- createdAt: existing ? existing.created_at : now,
101
- updatedAt: now
102
- };
103
- return c.json({ success: true, template });
104
- }
105
- catch (error) {
106
- console.error('Failed to save invoice template:', error);
107
- return c.json({ success: false, error: 'Failed to save invoice template' }, 500);
108
- }
109
- }
110
- /**
111
- * Helper to parse hex color to RGB values
112
- */
113
- function hexToRgb(hex) {
114
- const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
115
- return result
116
- ? {
117
- r: parseInt(result[1], 16) / 255,
118
- g: parseInt(result[2], 16) / 255,
119
- b: parseInt(result[3], 16) / 255
120
- }
121
- : { r: 0, g: 0, b: 0 };
122
- }
123
- /**
124
- * Format currency amount
125
- */
126
- function formatCurrency(amount, symbol, position) {
127
- const formattedAmount = amount.toFixed(2);
128
- return position === 'before' ? `${symbol}${formattedAmount}` : `${formattedAmount}${symbol}`;
129
- }
130
- /**
131
- * Generate PDF invoice
132
- */
133
- export async function generateInvoicePdf(template, data) {
134
- const pdfDoc = await PDFDocument.create();
135
- const page = pdfDoc.addPage([595.28, 841.89]); // A4 size in points
136
- const { width, height } = page.getSize();
137
- // Get fonts
138
- const config = template.config;
139
- let font;
140
- let boldFont;
141
- switch (config.fontFamily) {
142
- case 'times':
143
- font = await pdfDoc.embedFont(StandardFonts.TimesRoman);
144
- boldFont = await pdfDoc.embedFont(StandardFonts.TimesRomanBold);
145
- break;
146
- case 'courier':
147
- font = await pdfDoc.embedFont(StandardFonts.Courier);
148
- boldFont = await pdfDoc.embedFont(StandardFonts.CourierBold);
149
- break;
150
- default:
151
- font = await pdfDoc.embedFont(StandardFonts.Helvetica);
152
- boldFont = await pdfDoc.embedFont(StandardFonts.HelveticaBold);
153
- }
154
- const primaryColor = hexToRgb(config.primaryColor);
155
- const accentColor = hexToRgb(config.accentColor);
156
- const margin = 50;
157
- let yPos = height - margin;
158
- // Logo (if available and enabled)
159
- if (config.showLogo && template.logo) {
160
- try {
161
- // Try to embed logo
162
- const logoData = template.logo.split(',')[1]; // Remove data:image/... prefix
163
- const logoBytes = Uint8Array.from(atob(logoData), (c) => c.charCodeAt(0));
164
- let logoImage;
165
- if (template.logo.includes('image/png')) {
166
- logoImage = await pdfDoc.embedPng(logoBytes);
167
- }
168
- else {
169
- logoImage = await pdfDoc.embedJpg(logoBytes);
170
- }
171
- const logoMaxHeight = 50;
172
- const logoMaxWidth = 150;
173
- const scale = Math.min(logoMaxWidth / logoImage.width, logoMaxHeight / logoImage.height);
174
- const logoWidth = logoImage.width * scale;
175
- const logoHeight = logoImage.height * scale;
176
- let logoX = margin;
177
- if (config.logoPosition === 'center') {
178
- logoX = (width - logoWidth) / 2;
179
- }
180
- else if (config.logoPosition === 'right') {
181
- logoX = width - margin - logoWidth;
182
- }
183
- page.drawImage(logoImage, {
184
- x: logoX,
185
- y: yPos - logoHeight,
186
- width: logoWidth,
187
- height: logoHeight
188
- });
189
- yPos -= logoHeight + 20;
190
- }
191
- catch (e) {
192
- console.error('Failed to embed logo:', e);
193
- }
194
- }
195
- // Company info (right-aligned)
196
- const companyInfoX = width - margin;
197
- page.drawText(config.companyName, {
198
- x: companyInfoX - boldFont.widthOfTextAtSize(config.companyName, 12),
199
- y: yPos,
200
- size: 12,
201
- font: boldFont,
202
- color: rgb(primaryColor.r, primaryColor.g, primaryColor.b)
203
- });
204
- yPos -= 15;
205
- const addressLines = config.companyAddress.split(',').map((s) => s.trim());
206
- for (const line of addressLines) {
207
- page.drawText(line, {
208
- x: companyInfoX - font.widthOfTextAtSize(line, 10),
209
- y: yPos,
210
- size: 10,
211
- font,
212
- color: rgb(primaryColor.r, primaryColor.g, primaryColor.b)
213
- });
214
- yPos -= 12;
215
- }
216
- if (config.companyEmail) {
217
- page.drawText(config.companyEmail, {
218
- x: companyInfoX - font.widthOfTextAtSize(config.companyEmail, 10),
219
- y: yPos,
220
- size: 10,
221
- font,
222
- color: rgb(primaryColor.r, primaryColor.g, primaryColor.b)
223
- });
224
- yPos -= 12;
225
- }
226
- if (config.companyPhone) {
227
- page.drawText(config.companyPhone, {
228
- x: companyInfoX - font.widthOfTextAtSize(config.companyPhone, 10),
229
- y: yPos,
230
- size: 10,
231
- font,
232
- color: rgb(primaryColor.r, primaryColor.g, primaryColor.b)
233
- });
234
- yPos -= 12;
235
- }
236
- yPos -= 30;
237
- // Invoice title
238
- page.drawText('INVOICE', {
239
- x: margin,
240
- y: yPos,
241
- size: 24,
242
- font: boldFont,
243
- color: rgb(accentColor.r, accentColor.g, accentColor.b)
244
- });
245
- yPos -= 30;
246
- // Invoice details
247
- page.drawText(`Invoice #: ${data.invoiceNumber}`, {
248
- x: margin,
249
- y: yPos,
250
- size: 10,
251
- font,
252
- color: rgb(primaryColor.r, primaryColor.g, primaryColor.b)
253
- });
254
- yPos -= 15;
255
- page.drawText(`Date: ${data.invoiceDate}`, {
256
- x: margin,
257
- y: yPos,
258
- size: 10,
259
- font,
260
- color: rgb(primaryColor.r, primaryColor.g, primaryColor.b)
261
- });
262
- yPos -= 30;
263
- // Bill To
264
- page.drawText('Bill To:', {
265
- x: margin,
266
- y: yPos,
267
- size: 10,
268
- font: boldFont,
269
- color: rgb(primaryColor.r, primaryColor.g, primaryColor.b)
270
- });
271
- yPos -= 15;
272
- page.drawText(data.customerName, {
273
- x: margin,
274
- y: yPos,
275
- size: 10,
276
- font,
277
- color: rgb(primaryColor.r, primaryColor.g, primaryColor.b)
278
- });
279
- yPos -= 12;
280
- page.drawText(data.customerEmail, {
281
- x: margin,
282
- y: yPos,
283
- size: 10,
284
- font,
285
- color: rgb(primaryColor.r, primaryColor.g, primaryColor.b)
286
- });
287
- yPos -= 12;
288
- if (data.customerAddress) {
289
- page.drawText(data.customerAddress, {
290
- x: margin,
291
- y: yPos,
292
- size: 10,
293
- font,
294
- color: rgb(primaryColor.r, primaryColor.g, primaryColor.b)
295
- });
296
- yPos -= 12;
297
- }
298
- yPos -= 30;
299
- // Table header
300
- const tableTop = yPos;
301
- const tableHeaderHeight = 25;
302
- const colDescription = margin;
303
- const colQty = width - margin - 200;
304
- const colPrice = width - margin - 120;
305
- const colTotal = width - margin - 40;
306
- // Header background
307
- page.drawRectangle({
308
- x: margin,
309
- y: yPos - tableHeaderHeight,
310
- width: width - 2 * margin,
311
- height: tableHeaderHeight,
312
- color: rgb(accentColor.r, accentColor.g, accentColor.b)
313
- });
314
- // Header text
315
- page.drawText('Description', {
316
- x: colDescription + 10,
317
- y: yPos - 17,
318
- size: 10,
319
- font: boldFont,
320
- color: rgb(1, 1, 1)
321
- });
322
- page.drawText('Qty', {
323
- x: colQty,
324
- y: yPos - 17,
325
- size: 10,
326
- font: boldFont,
327
- color: rgb(1, 1, 1)
328
- });
329
- page.drawText('Price', {
330
- x: colPrice,
331
- y: yPos - 17,
332
- size: 10,
333
- font: boldFont,
334
- color: rgb(1, 1, 1)
335
- });
336
- page.drawText('Total', {
337
- x: colTotal - font.widthOfTextAtSize('Total', 10),
338
- y: yPos - 17,
339
- size: 10,
340
- font: boldFont,
341
- color: rgb(1, 1, 1)
342
- });
343
- yPos -= tableHeaderHeight + 15;
344
- // Table rows
345
- for (const item of data.items) {
346
- page.drawText(item.description, {
347
- x: colDescription + 10,
348
- y: yPos,
349
- size: 10,
350
- font,
351
- color: rgb(primaryColor.r, primaryColor.g, primaryColor.b)
352
- });
353
- page.drawText(item.quantity.toString(), {
354
- x: colQty,
355
- y: yPos,
356
- size: 10,
357
- font,
358
- color: rgb(primaryColor.r, primaryColor.g, primaryColor.b)
359
- });
360
- const priceStr = formatCurrency(item.unitPrice, config.currencySymbol, config.currencyPosition);
361
- page.drawText(priceStr, {
362
- x: colPrice,
363
- y: yPos,
364
- size: 10,
365
- font,
366
- color: rgb(primaryColor.r, primaryColor.g, primaryColor.b)
367
- });
368
- const totalStr = formatCurrency(item.total, config.currencySymbol, config.currencyPosition);
369
- page.drawText(totalStr, {
370
- x: colTotal - font.widthOfTextAtSize(totalStr, 10),
371
- y: yPos,
372
- size: 10,
373
- font,
374
- color: rgb(primaryColor.r, primaryColor.g, primaryColor.b)
375
- });
376
- yPos -= 20;
377
- }
378
- // Line separator
379
- yPos -= 10;
380
- page.drawLine({
381
- start: { x: margin, y: yPos },
382
- end: { x: width - margin, y: yPos },
383
- thickness: 1,
384
- color: rgb(0.8, 0.8, 0.8)
385
- });
386
- yPos -= 20;
387
- // Subtotal
388
- if (config.showTaxBreakdown) {
389
- const subtotalLabel = 'Subtotal:';
390
- const subtotalValue = formatCurrency(data.subtotal, config.currencySymbol, config.currencyPosition);
391
- page.drawText(subtotalLabel, {
392
- x: colPrice - font.widthOfTextAtSize(subtotalLabel, 10),
393
- y: yPos,
394
- size: 10,
395
- font,
396
- color: rgb(primaryColor.r, primaryColor.g, primaryColor.b)
397
- });
398
- page.drawText(subtotalValue, {
399
- x: colTotal - font.widthOfTextAtSize(subtotalValue, 10),
400
- y: yPos,
401
- size: 10,
402
- font,
403
- color: rgb(primaryColor.r, primaryColor.g, primaryColor.b)
404
- });
405
- yPos -= 15;
406
- // Tax
407
- if (data.tax !== undefined) {
408
- const taxLabel = `${config.taxLabel} (${config.taxRate}%):`;
409
- const taxValue = formatCurrency(data.tax, config.currencySymbol, config.currencyPosition);
410
- page.drawText(taxLabel, {
411
- x: colPrice - font.widthOfTextAtSize(taxLabel, 10),
412
- y: yPos,
413
- size: 10,
414
- font,
415
- color: rgb(primaryColor.r, primaryColor.g, primaryColor.b)
416
- });
417
- page.drawText(taxValue, {
418
- x: colTotal - font.widthOfTextAtSize(taxValue, 10),
419
- y: yPos,
420
- size: 10,
421
- font,
422
- color: rgb(primaryColor.r, primaryColor.g, primaryColor.b)
423
- });
424
- yPos -= 15;
425
- }
426
- }
427
- // Total
428
- const totalLabel = 'Total:';
429
- const totalValue = formatCurrency(data.total, config.currencySymbol, config.currencyPosition);
430
- page.drawText(totalLabel, {
431
- x: colPrice - boldFont.widthOfTextAtSize(totalLabel, 12),
432
- y: yPos,
433
- size: 12,
434
- font: boldFont,
435
- color: rgb(primaryColor.r, primaryColor.g, primaryColor.b)
436
- });
437
- page.drawText(totalValue, {
438
- x: colTotal - boldFont.widthOfTextAtSize(totalValue, 12),
439
- y: yPos,
440
- size: 12,
441
- font: boldFont,
442
- color: rgb(accentColor.r, accentColor.g, accentColor.b)
443
- });
444
- // Footer
445
- if (config.footerText) {
446
- page.drawText(config.footerText, {
447
- x: (width - font.widthOfTextAtSize(config.footerText, 10)) / 2,
448
- y: margin,
449
- size: 10,
450
- font,
451
- color: rgb(0.5, 0.5, 0.5)
452
- });
453
- }
454
- return await pdfDoc.save();
455
- }
@@ -1,22 +0,0 @@
1
- import { Context } from 'hono';
2
- /**
3
- * POST /api/email/subscribe
4
- * Public endpoint to subscribe to newsletter
5
- */
6
- export declare function subscribe(c: Context): Promise<Response>;
7
- /**
8
- * GET /api/email/confirm?token=xxx
9
- * Public endpoint to confirm subscription
10
- */
11
- export declare function confirm(c: Context): Promise<Response>;
12
- /**
13
- * GET /api/email/unsubscribe?token=xxx
14
- * Public endpoint to show unsubscribe confirmation page
15
- */
16
- export declare function showUnsubscribePage(c: Context): Promise<Response>;
17
- /**
18
- * POST /api/email/unsubscribe
19
- * Public endpoint to unsubscribe from newsletter
20
- */
21
- export declare function unsubscribe(c: Context): Promise<Response>;
22
- //# sourceMappingURL=public.handler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"public.handler.d.ts","sourceRoot":"","sources":["../../../../src/api/newsletter/handlers/public.handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AA0F/B;;;GAGG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAuH7D;AAED;;;GAGG;AACH,wBAAsB,OAAO,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CA8F3D;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAcvE;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAqD/D"}