@hintergrund/worker 0.1.6 → 0.1.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.
- package/dist/api/cms/handlers/admin-users.handler.d.ts +8 -0
- package/dist/api/cms/handlers/admin-users.handler.d.ts.map +1 -0
- package/dist/api/cms/handlers/admin-users.handler.js +121 -0
- package/dist/api/cms/handlers/agent-conversations.handler.d.ts +7 -0
- package/dist/api/cms/handlers/agent-conversations.handler.d.ts.map +1 -0
- package/dist/api/cms/handlers/agent-conversations.handler.js +94 -0
- package/dist/api/cms/handlers/auth.handler.d.ts +0 -3
- package/dist/api/cms/handlers/auth.handler.d.ts.map +1 -1
- package/dist/api/cms/handlers/auth.handler.js +74 -153
- package/dist/api/cms/handlers/dashboard.handler.js +1 -1
- package/dist/api/cms/handlers/website-repo.handler.d.ts +8 -0
- package/dist/api/cms/handlers/website-repo.handler.d.ts.map +1 -0
- package/dist/api/cms/handlers/website-repo.handler.js +148 -0
- package/dist/api/cms/routes/index.d.ts.map +1 -1
- package/dist/api/cms/routes/index.js +16 -4
- package/dist/api/emails/handlers/campaigns.handler.d.ts +10 -23
- package/dist/api/emails/handlers/campaigns.handler.d.ts.map +1 -1
- package/dist/api/emails/handlers/campaigns.handler.js +164 -92
- package/dist/api/emails/handlers/invoice.handler.d.ts +5 -19
- package/dist/api/emails/handlers/invoice.handler.d.ts.map +1 -1
- package/dist/api/emails/handlers/invoice.handler.js +58 -340
- package/dist/api/emails/handlers/public.handler.d.ts +6 -29
- package/dist/api/emails/handlers/public.handler.d.ts.map +1 -1
- package/dist/api/emails/handlers/public.handler.js +150 -312
- package/dist/api/emails/handlers/send.handler.d.ts +5 -17
- package/dist/api/emails/handlers/send.handler.d.ts.map +1 -1
- package/dist/api/emails/handlers/send.handler.js +107 -92
- package/dist/api/emails/handlers/settings.handler.d.ts +28 -33
- package/dist/api/emails/handlers/settings.handler.d.ts.map +1 -1
- package/dist/api/emails/handlers/settings.handler.js +96 -287
- package/dist/api/emails/handlers/subscribers.handler.d.ts +13 -0
- package/dist/api/emails/handlers/subscribers.handler.d.ts.map +1 -0
- package/dist/api/emails/handlers/subscribers.handler.js +125 -0
- package/dist/api/emails/handlers/webhook.handler.d.ts +1 -2
- package/dist/api/emails/handlers/webhook.handler.d.ts.map +1 -1
- package/dist/api/emails/handlers/webhook.handler.js +66 -166
- package/dist/api/emails/routes/admin.routes.d.ts +1 -3
- package/dist/api/emails/routes/admin.routes.d.ts.map +1 -1
- package/dist/api/emails/routes/admin.routes.js +19 -49
- package/dist/api/emails/routes/public.routes.d.ts +1 -3
- package/dist/api/emails/routes/public.routes.d.ts.map +1 -1
- package/dist/api/emails/routes/public.routes.js +2 -9
- package/dist/api/shop/handlers/prices.handler.d.ts +2 -15
- package/dist/api/shop/handlers/prices.handler.d.ts.map +1 -1
- package/dist/api/shop/handlers/prices.handler.js +2 -83
- package/dist/api/shop/handlers/products.handler.d.ts +29 -20
- package/dist/api/shop/handlers/products.handler.d.ts.map +1 -1
- package/dist/api/shop/handlers/products.handler.js +195 -162
- package/dist/api/shop/handlers/public.handler.d.ts +24 -8
- package/dist/api/shop/handlers/public.handler.d.ts.map +1 -1
- package/dist/api/shop/handlers/public.handler.js +525 -78
- package/dist/api/shop/routes.d.ts.map +1 -1
- package/dist/api/shop/routes.js +14 -9
- package/dist/hintergrund-assets.d.ts +3 -2
- package/dist/hintergrund-assets.d.ts.map +1 -1
- package/dist/hintergrund-assets.js +4 -2
- package/dist/index.d.ts +15 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +44 -4
- package/dist/lib/auth/crypto.d.ts +2 -15
- package/dist/lib/auth/crypto.d.ts.map +1 -1
- package/dist/lib/auth/crypto.js +8 -95
- package/dist/lib/auth/jwt.d.ts +0 -4
- package/dist/lib/auth/jwt.d.ts.map +1 -1
- package/dist/lib/auth/jwt.js +0 -6
- package/dist/lib/config.d.ts +8 -10
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +30 -106
- package/dist/lib/email-template.d.ts +15 -0
- package/dist/lib/email-template.d.ts.map +1 -0
- package/dist/lib/email-template.js +58 -0
- package/dist/lib/email.d.ts +18 -8
- package/dist/lib/email.d.ts.map +1 -1
- package/dist/lib/email.js +59 -70
- package/dist/lib/github-app.d.ts +2 -0
- package/dist/lib/github-app.d.ts.map +1 -0
- package/dist/lib/github-app.js +49 -0
- package/dist/lib/github-config.d.ts +19 -0
- package/dist/lib/github-config.d.ts.map +1 -0
- package/dist/lib/github-config.js +23 -0
- package/dist/lib/github.d.ts +16 -3
- package/dist/lib/github.d.ts.map +1 -1
- package/dist/lib/github.js +38 -15
- package/dist/lib/project-db.d.ts +24 -0
- package/dist/lib/project-db.d.ts.map +1 -0
- package/dist/lib/project-db.js +172 -0
- package/dist/lib/template.js +4 -4
- package/dist/middleware/auth.d.ts +0 -2
- package/dist/middleware/auth.d.ts.map +1 -1
- package/dist/middleware/auth.js +21 -50
- package/package.json +3 -2
- package/dist/api/builder/handlers/generate.handler.d.ts +0 -12
- package/dist/api/builder/handlers/generate.handler.d.ts.map +0 -1
- package/dist/api/builder/handlers/generate.handler.js +0 -203
- package/dist/api/builder/handlers/template.handler.d.ts +0 -12
- package/dist/api/builder/handlers/template.handler.d.ts.map +0 -1
- package/dist/api/builder/handlers/template.handler.js +0 -208
- package/dist/api/builder/routes.d.ts +0 -7
- package/dist/api/builder/routes.d.ts.map +0 -1
- package/dist/api/builder/routes.js +0 -15
- package/dist/api/cms/handlers/assets.handler.d.ts +0 -31
- package/dist/api/cms/handlers/assets.handler.d.ts.map +0 -1
- package/dist/api/cms/handlers/assets.handler.js +0 -200
- package/dist/api/cms/handlers/config.handler.d.ts +0 -7
- package/dist/api/cms/handlers/config.handler.d.ts.map +0 -1
- package/dist/api/cms/handlers/config.handler.js +0 -37
- package/dist/api/cms/handlers/content.handler.d.ts +0 -21
- package/dist/api/cms/handlers/content.handler.d.ts.map +0 -1
- package/dist/api/cms/handlers/content.handler.js +0 -117
- package/dist/api/cms/routes/assets.routes.d.ts +0 -4
- package/dist/api/cms/routes/assets.routes.d.ts.map +0 -1
- package/dist/api/cms/routes/assets.routes.js +0 -13
- package/dist/api/cms/routes/content.routes.d.ts +0 -4
- package/dist/api/cms/routes/content.routes.d.ts.map +0 -1
- package/dist/api/cms/routes/content.routes.js +0 -11
- package/dist/api/emails/handlers/branding.handler.d.ts +0 -17
- package/dist/api/emails/handlers/branding.handler.d.ts.map +0 -1
- package/dist/api/emails/handlers/branding.handler.js +0 -120
- package/dist/api/emails/handlers/contacts.handler.d.ts +0 -37
- package/dist/api/emails/handlers/contacts.handler.d.ts.map +0 -1
- package/dist/api/emails/handlers/contacts.handler.js +0 -161
- package/dist/api/emails/handlers/templates.handler.d.ts +0 -32
- package/dist/api/emails/handlers/templates.handler.d.ts.map +0 -1
- package/dist/api/emails/handlers/templates.handler.js +0 -132
- package/dist/api/newsletter/handlers/email.handler.d.ts +0 -7
- package/dist/api/newsletter/handlers/email.handler.d.ts.map +0 -1
- package/dist/api/newsletter/handlers/email.handler.js +0 -102
- package/dist/api/newsletter/handlers/emails.handler.d.ts +0 -31
- package/dist/api/newsletter/handlers/emails.handler.d.ts.map +0 -1
- package/dist/api/newsletter/handlers/emails.handler.js +0 -262
- package/dist/api/newsletter/handlers/invoice.handler.d.ts +0 -22
- package/dist/api/newsletter/handlers/invoice.handler.d.ts.map +0 -1
- package/dist/api/newsletter/handlers/invoice.handler.js +0 -455
- package/dist/api/newsletter/handlers/public.handler.d.ts +0 -22
- package/dist/api/newsletter/handlers/public.handler.d.ts.map +0 -1
- package/dist/api/newsletter/handlers/public.handler.js +0 -300
- package/dist/api/newsletter/handlers/send.handler.d.ts +0 -12
- package/dist/api/newsletter/handlers/send.handler.d.ts.map +0 -1
- package/dist/api/newsletter/handlers/send.handler.js +0 -153
- package/dist/api/newsletter/handlers/subscribers.handler.d.ts +0 -22
- package/dist/api/newsletter/handlers/subscribers.handler.d.ts.map +0 -1
- package/dist/api/newsletter/handlers/subscribers.handler.js +0 -195
- package/dist/api/newsletter/routes/admin.routes.d.ts +0 -4
- package/dist/api/newsletter/routes/admin.routes.d.ts.map +0 -1
- package/dist/api/newsletter/routes/admin.routes.js +0 -28
- package/dist/api/newsletter/routes/index.d.ts +0 -4
- package/dist/api/newsletter/routes/index.d.ts.map +0 -1
- package/dist/api/newsletter/routes/index.js +0 -9
- package/dist/api/newsletter/routes/public.routes.d.ts +0 -4
- package/dist/api/newsletter/routes/public.routes.d.ts.map +0 -1
- package/dist/api/newsletter/routes/public.routes.js +0 -9
- package/dist/api/shop/handlers/assets.handler.d.ts +0 -3
- package/dist/api/shop/handlers/assets.handler.d.ts.map +0 -1
- package/dist/api/shop/handlers/assets.handler.js +0 -62
- package/dist/api/shop/handlers/checkout.handler.d.ts +0 -10
- package/dist/api/shop/handlers/checkout.handler.d.ts.map +0 -1
- package/dist/api/shop/handlers/checkout.handler.js +0 -50
- package/dist/api/shop/handlers/customers.handler.d.ts +0 -17
- package/dist/api/shop/handlers/customers.handler.d.ts.map +0 -1
- package/dist/api/shop/handlers/customers.handler.js +0 -89
- package/dist/api/shop/handlers/orders.handler.d.ts +0 -17
- package/dist/api/shop/handlers/orders.handler.d.ts.map +0 -1
- package/dist/api/shop/handlers/orders.handler.js +0 -84
- package/dist/api/shop/handlers/stats.handler.d.ts +0 -10
- package/dist/api/shop/handlers/stats.handler.d.ts.map +0 -1
- package/dist/api/shop/handlers/stats.handler.js +0 -71
- package/dist/api/shop/handlers/webhook.handler.d.ts +0 -10
- package/dist/api/shop/handlers/webhook.handler.d.ts.map +0 -1
- package/dist/api/shop/handlers/webhook.handler.js +0 -233
- package/dist/cms-assets.d.ts +0 -4
- package/dist/cms-assets.d.ts.map +0 -1
- package/dist/cms-assets.js +0 -5
- package/dist/cms-bundle.d.ts +0 -3
- package/dist/cms-bundle.d.ts.map +0 -1
- package/dist/cms-bundle.js +0 -4
- package/dist/config-loader.d.ts +0 -26
- package/dist/config-loader.d.ts.map +0 -1
- package/dist/config-loader.js +0 -98
- package/dist/jwt.d.ts +0 -26
- package/dist/jwt.d.ts.map +0 -1
- package/dist/jwt.js +0 -102
- package/dist/lib/plunk.d.ts +0 -204
- package/dist/lib/plunk.d.ts.map +0 -1
- package/dist/lib/plunk.js +0 -259
- package/dist/template.d.ts +0 -2
- package/dist/template.d.ts.map +0 -1
- package/dist/template.js +0 -61
- package/dist/utils.d.ts +0 -23
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -110
|
@@ -1,35 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getGitHubConfig, getShopConfig } from '../../../lib/config';
|
|
2
2
|
import { createGitHubClient } from '../../../lib/github';
|
|
3
|
+
import { sendEmail } from '../../../lib/email';
|
|
4
|
+
import { renderEmailTemplate } from '../../../lib/email-template';
|
|
3
5
|
import Stripe from 'stripe';
|
|
4
6
|
import { generateInvoicePdf } from './invoice.handler';
|
|
7
|
+
import { readEmailSettings, readEmailTemplateData } from './settings.handler';
|
|
8
|
+
function guessLogoMime(path) {
|
|
9
|
+
const ext = path.split('.').pop()?.toLowerCase();
|
|
10
|
+
if (ext === 'png')
|
|
11
|
+
return 'image/png';
|
|
12
|
+
if (ext === 'jpg' || ext === 'jpeg')
|
|
13
|
+
return 'image/jpeg';
|
|
14
|
+
if (ext === 'gif')
|
|
15
|
+
return 'image/gif';
|
|
16
|
+
if (ext === 'svg')
|
|
17
|
+
return 'image/svg+xml';
|
|
18
|
+
return 'image/png';
|
|
19
|
+
}
|
|
5
20
|
function getStripe(env) {
|
|
6
21
|
const config = getShopConfig(env);
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
});
|
|
22
|
+
if (!config.stripeSecretKey)
|
|
23
|
+
throw new Error('Stripe secret key is not configured');
|
|
24
|
+
return new Stripe(config.stripeSecretKey, { apiVersion: '2025-02-24.acacia' });
|
|
10
25
|
}
|
|
11
|
-
// Default invoice configuration
|
|
12
|
-
const DEFAULT_INVOICE_CONFIG = {
|
|
13
|
-
showLogo: true,
|
|
14
|
-
primaryColor: '#1f2937',
|
|
15
|
-
accentColor: '#3b82f6',
|
|
16
|
-
logoPosition: 'left',
|
|
17
|
-
fontFamily: 'helvetica',
|
|
18
|
-
companyName: 'Your Company',
|
|
19
|
-
companyAddress: '123 Main Street, City, Country',
|
|
20
|
-
companyEmail: 'contact@company.com',
|
|
21
|
-
companyPhone: '+1 234 567 890',
|
|
22
|
-
currencySymbol: '€',
|
|
23
|
-
currencyPosition: 'before',
|
|
24
|
-
showTaxBreakdown: true,
|
|
25
|
-
taxLabel: 'VAT',
|
|
26
|
-
taxRate: 19,
|
|
27
|
-
dueDays: 14,
|
|
28
|
-
footerText: 'Thank you for your business!'
|
|
29
|
-
};
|
|
30
26
|
/**
|
|
31
|
-
*
|
|
32
|
-
* Handle Stripe webhook events
|
|
27
|
+
* Legacy Stripe webhook helper. The active route is /api/shop/webhook.
|
|
33
28
|
*/
|
|
34
29
|
export async function handleStripeWebhook(c) {
|
|
35
30
|
const stripe = getStripe(c.env);
|
|
@@ -38,11 +33,9 @@ export async function handleStripeWebhook(c) {
|
|
|
38
33
|
console.error('Stripe webhook secret not configured');
|
|
39
34
|
return c.json({ error: 'Webhook not configured' }, 500);
|
|
40
35
|
}
|
|
41
|
-
// Get the raw body and signature
|
|
42
36
|
const signature = c.req.header('stripe-signature');
|
|
43
|
-
if (!signature)
|
|
37
|
+
if (!signature)
|
|
44
38
|
return c.json({ error: 'Missing stripe-signature header' }, 400);
|
|
45
|
-
}
|
|
46
39
|
const rawBody = await c.req.text();
|
|
47
40
|
let event;
|
|
48
41
|
try {
|
|
@@ -52,116 +45,86 @@ export async function handleStripeWebhook(c) {
|
|
|
52
45
|
console.error('Webhook signature verification failed:', err.message);
|
|
53
46
|
return c.json({ error: 'Webhook signature verification failed' }, 400);
|
|
54
47
|
}
|
|
55
|
-
// Handle the event
|
|
56
48
|
switch (event.type) {
|
|
57
49
|
case 'checkout.session.completed': {
|
|
58
50
|
const session = event.data.object;
|
|
59
51
|
await handleCheckoutSessionCompleted(c, stripe, session);
|
|
60
52
|
break;
|
|
61
53
|
}
|
|
62
|
-
// Add more event handlers as needed
|
|
63
54
|
default:
|
|
64
55
|
console.log(`Unhandled event type: ${event.type}`);
|
|
65
56
|
}
|
|
66
57
|
return c.json({ received: true });
|
|
67
58
|
}
|
|
68
|
-
/**
|
|
69
|
-
* Handle checkout.session.completed event
|
|
70
|
-
* Generate and send invoice PDF to customer
|
|
71
|
-
*/
|
|
72
59
|
async function handleCheckoutSessionCompleted(c, stripe, session) {
|
|
73
60
|
try {
|
|
74
|
-
// Get customer email
|
|
75
61
|
const customerEmail = session.customer_details?.email;
|
|
76
62
|
if (!customerEmail) {
|
|
77
63
|
console.error('No customer email in checkout session');
|
|
78
64
|
return;
|
|
79
65
|
}
|
|
80
|
-
// Get line items
|
|
81
66
|
const lineItems = await stripe.checkout.sessions.listLineItems(session.id, {
|
|
82
|
-
expand: ['data.price.product']
|
|
67
|
+
expand: ['data.price.product'],
|
|
83
68
|
});
|
|
84
|
-
//
|
|
85
|
-
let
|
|
69
|
+
// Load invoice config and generated email template settings.
|
|
70
|
+
let invoiceConfig;
|
|
86
71
|
let branding;
|
|
87
72
|
try {
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
if (result?.data.branding) {
|
|
104
|
-
branding = result.data.branding;
|
|
73
|
+
const { settings } = await readEmailSettings(c.env);
|
|
74
|
+
invoiceConfig = settings.invoice;
|
|
75
|
+
let logoDataUrl;
|
|
76
|
+
if (settings.logoPath) {
|
|
77
|
+
try {
|
|
78
|
+
const github = createGitHubClient(getGitHubConfig(c.env));
|
|
79
|
+
const file = await github.readFileBinary(settings.logoPath);
|
|
80
|
+
if (file)
|
|
81
|
+
logoDataUrl = `data:${guessLogoMime(settings.logoPath)};base64,${file.content}`;
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
console.error('Failed to load logo from GitHub:', error);
|
|
85
|
+
}
|
|
105
86
|
}
|
|
87
|
+
branding = {
|
|
88
|
+
logo: logoDataUrl,
|
|
89
|
+
companyName: settings.invoice.companyName,
|
|
90
|
+
primaryColor: settings.invoice.primaryColor,
|
|
91
|
+
};
|
|
106
92
|
}
|
|
107
93
|
catch (error) {
|
|
108
|
-
console.error('Failed to fetch settings from GitHub:', error);
|
|
109
|
-
template = {
|
|
110
|
-
id: 'invoice',
|
|
111
|
-
config: DEFAULT_INVOICE_CONFIG,
|
|
112
|
-
createdAt: Date.now(),
|
|
113
|
-
updatedAt: Date.now()
|
|
114
|
-
};
|
|
94
|
+
console.error('Failed to fetch email settings from GitHub:', error);
|
|
115
95
|
}
|
|
116
|
-
// Build invoice data
|
|
117
96
|
const invoiceItems = lineItems.data.map((item) => {
|
|
118
97
|
const product = item.price?.product;
|
|
119
98
|
return {
|
|
120
99
|
description: product?.name || item.description || 'Item',
|
|
121
100
|
quantity: item.quantity || 1,
|
|
122
101
|
unitPrice: (item.price?.unit_amount || 0) / 100,
|
|
123
|
-
total: (item.amount_total || 0) / 100
|
|
102
|
+
total: (item.amount_total || 0) / 100,
|
|
124
103
|
};
|
|
125
104
|
});
|
|
126
|
-
const subtotal = (session.amount_subtotal || 0) / 100;
|
|
127
|
-
const tax = session.total_details?.amount_tax ? session.total_details.amount_tax / 100 : undefined;
|
|
128
|
-
const total = (session.amount_total || 0) / 100;
|
|
129
105
|
const invoiceData = {
|
|
130
106
|
invoiceNumber: `INV-${session.id.slice(-8).toUpperCase()}`,
|
|
131
|
-
invoiceDate: new Date().toLocaleDateString('en-US', {
|
|
132
|
-
year: 'numeric',
|
|
133
|
-
month: 'long',
|
|
134
|
-
day: 'numeric'
|
|
135
|
-
}),
|
|
107
|
+
invoiceDate: new Date().toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' }),
|
|
136
108
|
customerName: session.customer_details?.name || 'Customer',
|
|
137
109
|
customerEmail,
|
|
138
110
|
customerAddress: session.customer_details?.address
|
|
139
111
|
? formatAddress(session.customer_details.address)
|
|
140
112
|
: undefined,
|
|
141
113
|
items: invoiceItems,
|
|
142
|
-
subtotal,
|
|
143
|
-
tax,
|
|
144
|
-
total,
|
|
114
|
+
subtotal: (session.amount_subtotal || 0) / 100,
|
|
115
|
+
tax: session.total_details?.amount_tax ? session.total_details.amount_tax / 100 : undefined,
|
|
116
|
+
total: (session.amount_total || 0) / 100,
|
|
145
117
|
currency: session.currency?.toUpperCase() || 'EUR',
|
|
146
|
-
paymentMethod: session.payment_method_types?.[0] || 'card'
|
|
118
|
+
paymentMethod: session.payment_method_types?.[0] || 'card',
|
|
147
119
|
};
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
logo: branding.logo,
|
|
151
|
-
companyName: branding.config.companyName,
|
|
152
|
-
primaryColor: branding.config.primaryColor,
|
|
153
|
-
} : undefined);
|
|
154
|
-
// Send email with PDF attachment
|
|
155
|
-
await sendInvoiceEmail(c, customerEmail, invoiceData, pdfBytes);
|
|
120
|
+
const pdfBytes = await generateInvoicePdf((invoiceConfig ?? {}), invoiceData, branding);
|
|
121
|
+
await sendInvoiceEmail(c.env, customerEmail, invoiceData, pdfBytes);
|
|
156
122
|
console.log(`Invoice sent to ${customerEmail} for session ${session.id}`);
|
|
157
123
|
}
|
|
158
124
|
catch (error) {
|
|
159
125
|
console.error('Failed to handle checkout session completed:', error);
|
|
160
126
|
}
|
|
161
127
|
}
|
|
162
|
-
/**
|
|
163
|
-
* Format Stripe address object to string
|
|
164
|
-
*/
|
|
165
128
|
function formatAddress(address) {
|
|
166
129
|
const parts = [];
|
|
167
130
|
if (address.line1)
|
|
@@ -176,86 +139,23 @@ function formatAddress(address) {
|
|
|
176
139
|
parts.push(address.country);
|
|
177
140
|
return parts.join(', ');
|
|
178
141
|
}
|
|
179
|
-
|
|
180
|
-
* Send invoice email with PDF attachment
|
|
181
|
-
*/
|
|
182
|
-
async function sendInvoiceEmail(c, to, invoiceData, pdfBytes) {
|
|
183
|
-
const emailsConfig = getEmailsConfig(c.env);
|
|
184
|
-
const apiKey = emailsConfig.plunkSecretKey;
|
|
185
|
-
const fromEmail = emailsConfig.fromEmail;
|
|
186
|
-
const fromName = emailsConfig.fromName || 'Shop';
|
|
187
|
-
if (!apiKey || !fromEmail) {
|
|
188
|
-
console.error('Email not configured');
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
// Convert PDF to base64 // Unused
|
|
192
|
-
// const pdfBase64 = btoa(String.fromCharCode(...pdfBytes));
|
|
193
|
-
// Build email HTML
|
|
142
|
+
async function sendInvoiceEmail(env, to, invoiceData, _pdfBytes) {
|
|
194
143
|
const html = `
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
<p style="color: #9ca3af; font-size: 12px; margin-top: 40px;">
|
|
209
|
-
This is an automated email. Please do not reply directly to this message.
|
|
210
|
-
</p>
|
|
211
|
-
</div>
|
|
212
|
-
`;
|
|
213
|
-
// Send via Plunk API
|
|
214
|
-
// Note: PDF attachment support via Plunk JSON API might need verification,
|
|
215
|
-
// but preserving existing logic for now.
|
|
216
|
-
// Usually Plunk API uses 'attachments' field or different endpoint if supporting attachments.
|
|
217
|
-
// The previous code didn't actually attach the PDF in the fetch call payload?
|
|
218
|
-
// Wait, the previous code had `const pdfBase64 = ...` but didn't use it in payload.
|
|
219
|
-
// I will preserve exact behavior of previous code, but I suspect it was incomplete/buggy regarding attachment.
|
|
220
|
-
// User asked to move logic, not fix bugs, but I should probably mention it or fix it if obvious.
|
|
221
|
-
// Actually, let's look at the payload in previous file.
|
|
222
|
-
/*
|
|
223
|
-
const payload = {
|
|
224
|
-
to,
|
|
225
|
-
subject: `Your Invoice ${invoiceData.invoiceNumber}`,
|
|
226
|
-
body: html,
|
|
227
|
-
from: fromEmail,
|
|
228
|
-
name: fromName,
|
|
229
|
-
};
|
|
230
|
-
*/
|
|
231
|
-
// Indeed, pdfBase64 was calculated but not used.
|
|
232
|
-
// I will uncomment/use it to be helpful!
|
|
233
|
-
// Plunk API documentation isn't provided, but generally `attachments` array is common.
|
|
234
|
-
// However, without knowing Plunk API specs, adding it might break it if schema is strict.
|
|
235
|
-
// The user didn't ask to fix bugs. I will copy AS IS to minimize risk, but I'll update the comment.
|
|
236
|
-
// Actually, I'll keep the `pdfBase64` line commented out or just present as it was (calculated but unused)
|
|
237
|
-
// to match 1:1 the original logic.
|
|
238
|
-
// Original code:
|
|
239
|
-
// const pdfBase64 = btoa(String.fromCharCode(...pdfBytes));
|
|
240
|
-
// ...
|
|
241
|
-
// const payload = { ... } (no attachment)
|
|
242
|
-
const payload = {
|
|
144
|
+
<div style="font-family:sans-serif;max-width:600px;margin:0 auto;padding:20px;">
|
|
145
|
+
<h1 style="color:#1f2937;">Thank you for your purchase!</h1>
|
|
146
|
+
<p style="color:#4b5563;">Dear ${invoiceData.customerName},</p>
|
|
147
|
+
<p style="color:#4b5563;">Thank you for your order.</p>
|
|
148
|
+
<div style="background:#f3f4f6;padding:20px;border-radius:8px;margin:20px 0;">
|
|
149
|
+
<p style="margin:0;color:#1f2937;"><strong>Invoice Number:</strong> ${invoiceData.invoiceNumber}</p>
|
|
150
|
+
<p style="margin:8px 0;color:#1f2937;"><strong>Date:</strong> ${invoiceData.invoiceDate}</p>
|
|
151
|
+
<p style="margin:8px 0;color:#1f2937;"><strong>Total:</strong> ${invoiceData.currency} ${invoiceData.total.toFixed(2)}</p>
|
|
152
|
+
</div>
|
|
153
|
+
<p style="color:#9ca3af;font-size:12px;margin-top:40px;">This is an automated email.</p>
|
|
154
|
+
</div>`;
|
|
155
|
+
const { settings, logoDataUrl } = await readEmailTemplateData(env);
|
|
156
|
+
await sendEmail(env, {
|
|
243
157
|
to,
|
|
244
158
|
subject: `Your Invoice ${invoiceData.invoiceNumber}`,
|
|
245
|
-
|
|
246
|
-
from: fromEmail,
|
|
247
|
-
name: fromName,
|
|
248
|
-
};
|
|
249
|
-
const response = await fetch('https://api.useplunk.com/v1/send', {
|
|
250
|
-
method: 'POST',
|
|
251
|
-
headers: {
|
|
252
|
-
Authorization: `Bearer ${apiKey}`,
|
|
253
|
-
'Content-Type': 'application/json'
|
|
254
|
-
},
|
|
255
|
-
body: JSON.stringify(payload)
|
|
159
|
+
html: renderEmailTemplate({ bodyHtml: html, template: settings.emailTemplate, logoDataUrl }),
|
|
256
160
|
});
|
|
257
|
-
if (!response.ok) {
|
|
258
|
-
const error = await response.text();
|
|
259
|
-
throw new Error(`Failed to send invoice email: ${error}`);
|
|
260
|
-
}
|
|
261
161
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Admin Routes for Email Module
|
|
3
|
-
*
|
|
4
|
-
* All routes require authentication.
|
|
2
|
+
* Admin Routes for Email Module — D1-backed, no Plunk
|
|
5
3
|
*/
|
|
6
4
|
import { Hono } from 'hono';
|
|
7
5
|
declare const adminRoutes: Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin.routes.d.ts","sourceRoot":"","sources":["../../../../src/api/emails/routes/admin.routes.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"admin.routes.d.ts","sourceRoot":"","sources":["../../../../src/api/emails/routes/admin.routes.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AA4B5B,QAAA,MAAM,WAAW,4EAAa,CAAC;AAwC/B,eAAe,WAAW,CAAC"}
|
|
@@ -1,77 +1,47 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Admin Routes for Email Module
|
|
3
|
-
*
|
|
4
|
-
* All routes require authentication.
|
|
2
|
+
* Admin Routes for Email Module — D1-backed, no Plunk
|
|
5
3
|
*/
|
|
6
4
|
import { Hono } from 'hono';
|
|
7
5
|
import { authMiddleware } from '../../../middleware/auth';
|
|
8
|
-
//
|
|
9
|
-
import {
|
|
10
|
-
// Templates
|
|
11
|
-
import { getTemplates, getTemplate, createTemplate, updateTemplate, deleteTemplate } from '../handlers/templates.handler';
|
|
6
|
+
// Subscribers
|
|
7
|
+
import { getSubscribers, createSubscriber, updateSubscriber, deleteSubscriber, } from '../handlers/subscribers.handler';
|
|
12
8
|
// Campaigns
|
|
13
|
-
import { getCampaigns, getCampaign, createCampaign, sendCampaign, testCampaign } from '../handlers/campaigns.handler';
|
|
14
|
-
//
|
|
15
|
-
import {
|
|
16
|
-
//
|
|
17
|
-
import {
|
|
18
|
-
// Invoice
|
|
19
|
-
import { getInvoiceTemplate, saveInvoiceTemplate } from '../handlers/invoice.handler';
|
|
20
|
-
// Settings (combined branding + invoice with local-first sync)
|
|
21
|
-
import { getSettings, syncSettings, saveSettings, getEmailTemplates, saveEmailTemplate } from '../handlers/settings.handler';
|
|
9
|
+
import { getCampaigns, getCampaign, createCampaign, updateCampaign, deleteCampaign, sendCampaign, testCampaign, } from '../handlers/campaigns.handler';
|
|
10
|
+
// Send history + transactional
|
|
11
|
+
import { getSends, sendTransactional, sendBulkEmail } from '../handlers/send.handler';
|
|
12
|
+
// Settings (generated email template + invoice)
|
|
13
|
+
import { getSettings, saveSettings } from '../handlers/settings.handler';
|
|
22
14
|
const adminRoutes = new Hono();
|
|
23
|
-
// Protect all admin routes with authentication
|
|
24
15
|
adminRoutes.use('*', authMiddleware);
|
|
25
16
|
// =============================================================================
|
|
26
|
-
//
|
|
17
|
+
// Subscribers
|
|
27
18
|
// =============================================================================
|
|
28
|
-
adminRoutes.get('/
|
|
29
|
-
adminRoutes.post('/
|
|
30
|
-
adminRoutes.patch('/
|
|
31
|
-
adminRoutes.delete('/
|
|
32
|
-
adminRoutes.post('/contacts/:id/subscribe', subscribeContact);
|
|
33
|
-
adminRoutes.post('/contacts/:id/unsubscribe', unsubscribeContact);
|
|
34
|
-
// =============================================================================
|
|
35
|
-
// Templates (Plunk templates)
|
|
36
|
-
// =============================================================================
|
|
37
|
-
adminRoutes.get('/templates', getTemplates);
|
|
38
|
-
adminRoutes.get('/templates/:id', getTemplate);
|
|
39
|
-
adminRoutes.post('/templates', createTemplate);
|
|
40
|
-
adminRoutes.patch('/templates/:id', updateTemplate);
|
|
41
|
-
adminRoutes.delete('/templates/:id', deleteTemplate);
|
|
19
|
+
adminRoutes.get('/subscribers', getSubscribers);
|
|
20
|
+
adminRoutes.post('/subscribers', createSubscriber);
|
|
21
|
+
adminRoutes.patch('/subscribers/:id', updateSubscriber);
|
|
22
|
+
adminRoutes.delete('/subscribers/:id', deleteSubscriber);
|
|
42
23
|
// =============================================================================
|
|
43
24
|
// Campaigns
|
|
44
25
|
// =============================================================================
|
|
45
26
|
adminRoutes.get('/campaigns', getCampaigns);
|
|
46
27
|
adminRoutes.get('/campaigns/:id', getCampaign);
|
|
47
28
|
adminRoutes.post('/campaigns', createCampaign);
|
|
29
|
+
adminRoutes.patch('/campaigns/:id', updateCampaign);
|
|
30
|
+
adminRoutes.delete('/campaigns/:id', deleteCampaign);
|
|
48
31
|
adminRoutes.post('/campaigns/:id/send', sendCampaign);
|
|
49
32
|
adminRoutes.post('/campaigns/:id/test', testCampaign);
|
|
50
33
|
// =============================================================================
|
|
51
|
-
//
|
|
34
|
+
// Send history
|
|
52
35
|
// =============================================================================
|
|
53
|
-
adminRoutes.get('/
|
|
54
|
-
adminRoutes.put('/branding', saveBranding);
|
|
36
|
+
adminRoutes.get('/sends', getSends);
|
|
55
37
|
// =============================================================================
|
|
56
|
-
//
|
|
38
|
+
// Transactional send
|
|
57
39
|
// =============================================================================
|
|
58
40
|
adminRoutes.post('/send', sendTransactional);
|
|
59
|
-
adminRoutes.post('/send/test', sendTestEmail);
|
|
60
41
|
adminRoutes.post('/send/bulk', sendBulkEmail);
|
|
61
42
|
// =============================================================================
|
|
62
|
-
//
|
|
63
|
-
// =============================================================================
|
|
64
|
-
adminRoutes.get('/invoice-template', getInvoiceTemplate);
|
|
65
|
-
adminRoutes.put('/invoice-template', saveInvoiceTemplate);
|
|
66
|
-
// =============================================================================
|
|
67
|
-
// Settings (combined branding + invoice with local-first sync support)
|
|
43
|
+
// Settings (generated email template + invoice)
|
|
68
44
|
// =============================================================================
|
|
69
45
|
adminRoutes.get('/settings', getSettings);
|
|
70
|
-
adminRoutes.get('/settings/sync', syncSettings);
|
|
71
46
|
adminRoutes.put('/settings', saveSettings);
|
|
72
|
-
// =============================================================================
|
|
73
|
-
// Email Templates (GitHub-stored transactional email templates)
|
|
74
|
-
// =============================================================================
|
|
75
|
-
adminRoutes.get('/settings/templates', getEmailTemplates);
|
|
76
|
-
adminRoutes.put('/settings/templates/:type', saveEmailTemplate);
|
|
77
47
|
export default adminRoutes;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Public Routes for Email Module
|
|
3
|
-
*
|
|
4
|
-
* These routes do not require authentication.
|
|
2
|
+
* Public Routes for Email Module — no authentication required
|
|
5
3
|
*/
|
|
6
4
|
import { Hono } from 'hono';
|
|
7
5
|
declare const publicRoutes: Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.routes.d.ts","sourceRoot":"","sources":["../../../../src/api/emails/routes/public.routes.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"public.routes.d.ts","sourceRoot":"","sources":["../../../../src/api/emails/routes/public.routes.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAG5B,QAAA,MAAM,YAAY,4EAAa,CAAC;AAOhC,eAAe,YAAY,CAAC"}
|
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Public Routes for Email Module
|
|
3
|
-
*
|
|
4
|
-
* These routes do not require authentication.
|
|
2
|
+
* Public Routes for Email Module — no authentication required
|
|
5
3
|
*/
|
|
6
4
|
import { Hono } from 'hono';
|
|
7
|
-
import { subscribe, confirm, unsubscribe, showUnsubscribePage
|
|
8
|
-
import { handleStripeWebhook } from '../handlers/webhook.handler';
|
|
5
|
+
import { subscribe, confirm, unsubscribe, showUnsubscribePage } from '../handlers/public.handler';
|
|
9
6
|
const publicRoutes = new Hono();
|
|
10
|
-
// Public newsletter endpoints (no authentication required)
|
|
11
7
|
publicRoutes.post('/subscribe', subscribe);
|
|
12
8
|
publicRoutes.get('/confirm', confirm);
|
|
13
9
|
publicRoutes.get('/unsubscribe', showUnsubscribePage);
|
|
14
10
|
publicRoutes.post('/unsubscribe', unsubscribe);
|
|
15
|
-
publicRoutes.post('/track', trackEvent);
|
|
16
|
-
// Stripe webhook (no auth, but verified by signature)
|
|
17
|
-
publicRoutes.post('/webhook', handleStripeWebhook);
|
|
18
11
|
export default publicRoutes;
|
|
@@ -1,17 +1,4 @@
|
|
|
1
1
|
import type { Context } from 'hono';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* POST /api/shop/admin/prices
|
|
5
|
-
* Create a new price for a product
|
|
6
|
-
*/
|
|
7
|
-
export declare function createPrice(c: Context<{
|
|
8
|
-
Bindings: Bindings;
|
|
9
|
-
}>): Promise<Response>;
|
|
10
|
-
/**
|
|
11
|
-
* PATCH /api/shop/admin/prices/:id
|
|
12
|
-
* Update a price (limited - prices are mostly immutable in Stripe)
|
|
13
|
-
*/
|
|
14
|
-
export declare function updatePrice(c: Context<{
|
|
15
|
-
Bindings: Bindings;
|
|
16
|
-
}>): Promise<Response>;
|
|
2
|
+
export declare function createPrice(c: Context): Promise<Response>;
|
|
3
|
+
export declare function updatePrice(c: Context): Promise<Response>;
|
|
17
4
|
//# sourceMappingURL=prices.handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prices.handler.d.ts","sourceRoot":"","sources":["../../../../src/api/shop/handlers/prices.handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"prices.handler.d.ts","sourceRoot":"","sources":["../../../../src/api/shop/handlers/prices.handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,wBAAsB,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAE/D;AAED,wBAAsB,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAE/D"}
|
|
@@ -1,87 +1,6 @@
|
|
|
1
|
-
import { getShopConfig } from '../../../lib/config';
|
|
2
|
-
import Stripe from 'stripe';
|
|
3
|
-
function getStripe(env) {
|
|
4
|
-
const config = getShopConfig(env);
|
|
5
|
-
return new Stripe(config.stripeSecretKey, {
|
|
6
|
-
apiVersion: '2025-02-24.acacia'
|
|
7
|
-
});
|
|
8
|
-
}
|
|
9
|
-
function mapStripePrice(price) {
|
|
10
|
-
return {
|
|
11
|
-
id: price.id,
|
|
12
|
-
productId: typeof price.product === 'string' ? price.product : price.product?.id || '',
|
|
13
|
-
active: price.active,
|
|
14
|
-
currency: price.currency,
|
|
15
|
-
unitAmount: price.unit_amount,
|
|
16
|
-
unitAmountDecimal: price.unit_amount_decimal,
|
|
17
|
-
billingScheme: price.billing_scheme,
|
|
18
|
-
type: price.type,
|
|
19
|
-
recurring: price.recurring
|
|
20
|
-
? {
|
|
21
|
-
interval: price.recurring.interval,
|
|
22
|
-
intervalCount: price.recurring.interval_count
|
|
23
|
-
}
|
|
24
|
-
: undefined,
|
|
25
|
-
metadata: price.metadata || {},
|
|
26
|
-
createdAt: price.created
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* POST /api/shop/admin/prices
|
|
31
|
-
* Create a new price for a product
|
|
32
|
-
*/
|
|
33
1
|
export async function createPrice(c) {
|
|
34
|
-
|
|
35
|
-
const stripe = getStripe(c.env);
|
|
36
|
-
const body = await c.req.json();
|
|
37
|
-
const priceParams = {
|
|
38
|
-
product: body.productId,
|
|
39
|
-
currency: body.currency,
|
|
40
|
-
unit_amount: body.unitAmount,
|
|
41
|
-
active: body.active ?? true,
|
|
42
|
-
billing_scheme: body.billingScheme || 'per_unit',
|
|
43
|
-
metadata: body.metadata
|
|
44
|
-
};
|
|
45
|
-
if (body.recurring) {
|
|
46
|
-
priceParams.recurring = {
|
|
47
|
-
interval: body.recurring.interval,
|
|
48
|
-
interval_count: body.recurring.intervalCount || 1
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
const price = await stripe.prices.create(priceParams);
|
|
52
|
-
const response = {
|
|
53
|
-
success: true,
|
|
54
|
-
price: mapStripePrice(price)
|
|
55
|
-
};
|
|
56
|
-
return c.json(response, 201);
|
|
57
|
-
}
|
|
58
|
-
catch (error) {
|
|
59
|
-
console.error('Failed to create price:', error);
|
|
60
|
-
return c.json({ success: false, error: 'Failed to create price' }, 500);
|
|
61
|
-
}
|
|
2
|
+
return c.json({ success: false, error: 'Prices are edited on products' }, 410);
|
|
62
3
|
}
|
|
63
|
-
/**
|
|
64
|
-
* PATCH /api/shop/admin/prices/:id
|
|
65
|
-
* Update a price (limited - prices are mostly immutable in Stripe)
|
|
66
|
-
*/
|
|
67
4
|
export async function updatePrice(c) {
|
|
68
|
-
|
|
69
|
-
const stripe = getStripe(c.env);
|
|
70
|
-
const priceId = c.req.param('id');
|
|
71
|
-
const body = await c.req.json();
|
|
72
|
-
const updateParams = {};
|
|
73
|
-
if (body.active !== undefined)
|
|
74
|
-
updateParams.active = body.active;
|
|
75
|
-
if (body.metadata !== undefined)
|
|
76
|
-
updateParams.metadata = body.metadata;
|
|
77
|
-
const price = await stripe.prices.update(priceId, updateParams);
|
|
78
|
-
return c.json({
|
|
79
|
-
success: true,
|
|
80
|
-
price: mapStripePrice(price)
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
catch (error) {
|
|
84
|
-
console.error('Failed to update price:', error);
|
|
85
|
-
return c.json({ success: false, error: 'Failed to update price' }, 500);
|
|
86
|
-
}
|
|
5
|
+
return c.json({ success: false, error: 'Prices are edited on products' }, 410);
|
|
87
6
|
}
|
|
@@ -1,38 +1,47 @@
|
|
|
1
1
|
import type { Context } from 'hono';
|
|
2
2
|
import type { Bindings } from '../../../index';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import type { ShopCatalog, ShopSettings } from '@hintergrund/runtime-contracts';
|
|
4
|
+
export declare const SHOP_PRODUCTS_PATH = "frontend/src/lib/shop/products.json";
|
|
5
|
+
export declare const SHOP_SETTINGS_PATH = "frontend/src/lib/shop/settings.json";
|
|
6
|
+
export declare const DEFAULT_SHOP_SETTINGS: ShopSettings & {
|
|
7
|
+
emailTemplates: {
|
|
8
|
+
purchase: {
|
|
9
|
+
subject: string;
|
|
10
|
+
bodyHtml: string;
|
|
11
|
+
};
|
|
12
|
+
paymentConfirmed: {
|
|
13
|
+
subject: string;
|
|
14
|
+
bodyHtml: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export declare function readShopCatalog(env: Bindings): Promise<{
|
|
19
|
+
catalog: ShopCatalog;
|
|
20
|
+
commitSha: string;
|
|
21
|
+
}>;
|
|
22
|
+
export declare function readShopSettings(env: Bindings): Promise<{
|
|
23
|
+
settings: ShopSettings;
|
|
24
|
+
commitSha: string;
|
|
25
|
+
}>;
|
|
7
26
|
export declare function getProducts(c: Context<{
|
|
8
27
|
Bindings: Bindings;
|
|
9
28
|
}>): Promise<Response>;
|
|
10
|
-
/**
|
|
11
|
-
* GET /api/shop/admin/products/:id
|
|
12
|
-
* Get a single product with all its prices
|
|
13
|
-
*/
|
|
14
29
|
export declare function getProduct(c: Context<{
|
|
15
30
|
Bindings: Bindings;
|
|
16
31
|
}>): Promise<Response>;
|
|
17
|
-
/**
|
|
18
|
-
* POST /api/shop/admin/products
|
|
19
|
-
* Create a new product
|
|
20
|
-
*/
|
|
21
32
|
export declare function createProduct(c: Context<{
|
|
22
33
|
Bindings: Bindings;
|
|
23
34
|
}>): Promise<Response>;
|
|
24
|
-
/**
|
|
25
|
-
* PATCH /api/shop/admin/products/:id
|
|
26
|
-
* Update a product
|
|
27
|
-
*/
|
|
28
35
|
export declare function updateProduct(c: Context<{
|
|
29
36
|
Bindings: Bindings;
|
|
30
37
|
}>): Promise<Response>;
|
|
31
|
-
/**
|
|
32
|
-
* DELETE /api/shop/admin/products/:id
|
|
33
|
-
* Delete a product (archive if has prices)
|
|
34
|
-
*/
|
|
35
38
|
export declare function deleteProduct(c: Context<{
|
|
36
39
|
Bindings: Bindings;
|
|
37
40
|
}>): Promise<Response>;
|
|
41
|
+
export declare function getSettings(c: Context<{
|
|
42
|
+
Bindings: Bindings;
|
|
43
|
+
}>): Promise<Response>;
|
|
44
|
+
export declare function updateSettings(c: Context<{
|
|
45
|
+
Bindings: Bindings;
|
|
46
|
+
}>): Promise<Response>;
|
|
38
47
|
//# sourceMappingURL=products.handler.d.ts.map
|