@absolutejs/commerce 0.3.0-beta.0 → 0.5.0-beta.0
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/core/email.d.ts +51 -0
- package/dist/drizzle/index.d.ts +1737 -424
- package/dist/drizzle/index.js +163 -2
- package/dist/drizzle/queries.d.ts +1784 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +79 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -26,6 +26,78 @@ var formatPrice = (value, currency = "USD") => {
|
|
|
26
26
|
const code = currency.toUpperCase();
|
|
27
27
|
return code === "USD" ? `$${value.toFixed(2)}` : `${value.toFixed(2)} ${code}`;
|
|
28
28
|
};
|
|
29
|
+
|
|
30
|
+
// src/core/email.ts
|
|
31
|
+
var DEFAULT_EMAIL_THEME = {
|
|
32
|
+
brandName: "AbsoluteJS Commerce",
|
|
33
|
+
colors: {
|
|
34
|
+
accent: "#1f6f5c",
|
|
35
|
+
card: "#fffdf8",
|
|
36
|
+
gold: "#b5862f",
|
|
37
|
+
hairline: "#e6ddcb",
|
|
38
|
+
ink: "#1a1712",
|
|
39
|
+
muted: "#7a7264",
|
|
40
|
+
paper: "#efece4"
|
|
41
|
+
},
|
|
42
|
+
footerNote: "Questions? Just reply to this email."
|
|
43
|
+
};
|
|
44
|
+
var orderNumber = (sessionId) => `#${sessionId.slice(-8).toUpperCase()}`;
|
|
45
|
+
var formatMoneyCents = (cents, currency = "usd") => {
|
|
46
|
+
if (cents === null)
|
|
47
|
+
return "\u2014";
|
|
48
|
+
const code = (currency ?? "usd").toUpperCase();
|
|
49
|
+
const value = fromCents(cents).toFixed(2);
|
|
50
|
+
return code === "USD" ? `$${value}` : `${value} ${code}`;
|
|
51
|
+
};
|
|
52
|
+
var carrierTrackingUrl = (carrier, trackingNumber) => {
|
|
53
|
+
const slug = carrier.toLowerCase();
|
|
54
|
+
if (slug.includes("usps"))
|
|
55
|
+
return `https://tools.usps.com/go/TrackConfirmAction?tLabels=${trackingNumber}`;
|
|
56
|
+
if (slug.includes("ups"))
|
|
57
|
+
return `https://www.ups.com/track?tracknum=${trackingNumber}`;
|
|
58
|
+
if (slug.includes("fedex"))
|
|
59
|
+
return `https://www.fedex.com/fedextrack/?trknbr=${trackingNumber}`;
|
|
60
|
+
return "";
|
|
61
|
+
};
|
|
62
|
+
var emailButton = (theme, href, label) => `<a href="${href}" style="display:inline-block;background:${theme.colors.accent};color:#ffffff;text-decoration:none;font-weight:700;font-size:14px;padding:12px 22px;border-radius:6px;">${label}</a>`;
|
|
63
|
+
var emailLineItems = (theme, items, options = {}) => {
|
|
64
|
+
const { colors } = theme;
|
|
65
|
+
const rows = items.map((item) => `<tr>
|
|
66
|
+
<td style="padding:8px 0;border-bottom:1px solid ${colors.hairline};font-size:14px;color:${colors.ink};">${item.label}</td>
|
|
67
|
+
<td style="padding:8px 0;border-bottom:1px solid ${colors.hairline};text-align:right;font-family:monospace;font-size:14px;color:${colors.ink};">${formatMoneyCents(item.amountCents, options.currency)}</td>
|
|
68
|
+
</tr>`).join("");
|
|
69
|
+
const total = options.totalCents === undefined ? "" : `<tr>
|
|
70
|
+
<td style="padding:12px 0 0;font-weight:700;font-size:15px;color:${colors.ink};">${options.totalLabel ?? "Total"}</td>
|
|
71
|
+
<td style="padding:12px 0 0;text-align:right;font-weight:700;font-family:monospace;font-size:15px;color:${colors.ink};">${formatMoneyCents(options.totalCents, options.currency)}</td>
|
|
72
|
+
</tr>`;
|
|
73
|
+
return `<table width="100%" cellpadding="0" cellspacing="0" style="border-collapse:collapse;margin:18px 0;">${rows}${total}</table>`;
|
|
74
|
+
};
|
|
75
|
+
var renderEmail = (theme, { preheader, heading, intro, inner = "" }) => {
|
|
76
|
+
const { colors } = theme;
|
|
77
|
+
const tagline = theme.tagline ? ` \xB7 ${theme.tagline}` : "";
|
|
78
|
+
const footer = theme.footerNote ?? "";
|
|
79
|
+
return `
|
|
80
|
+
<div style="display:none;max-height:0;overflow:hidden;opacity:0;">${preheader}</div>
|
|
81
|
+
<div style="margin:0;padding:24px 12px;background:${colors.paper};font-family:'Helvetica Neue',Arial,sans-serif;">
|
|
82
|
+
<table width="100%" cellpadding="0" cellspacing="0"><tr><td align="center">
|
|
83
|
+
<table width="560" cellpadding="0" cellspacing="0" style="max-width:560px;width:100%;background:${colors.card};border:1.5px solid ${colors.ink};">
|
|
84
|
+
<tr><td style="height:6px;background:${colors.accent};font-size:0;line-height:0;"> </td></tr>
|
|
85
|
+
<tr><td style="padding:24px 28px 4px;">
|
|
86
|
+
<span style="font-family:'Courier New',monospace;font-size:11px;letter-spacing:0.22em;text-transform:uppercase;color:${colors.gold};font-weight:700;">${theme.brandName}</span>
|
|
87
|
+
</td></tr>
|
|
88
|
+
<tr><td style="padding:8px 28px 28px;">
|
|
89
|
+
<h1 style="margin:0 0 10px;font-size:26px;line-height:1.15;color:${colors.accent};">${heading}</h1>
|
|
90
|
+
<p style="margin:0 0 4px;font-size:15px;line-height:1.55;color:${colors.ink};">${intro}</p>
|
|
91
|
+
${inner}
|
|
92
|
+
</td></tr>
|
|
93
|
+
<tr><td style="padding:18px 28px;border-top:1px solid ${colors.hairline};font-family:'Courier New',monospace;font-size:11px;line-height:1.6;color:${colors.muted};">
|
|
94
|
+
${theme.brandName}${tagline}<br/>
|
|
95
|
+
${footer}
|
|
96
|
+
</td></tr>
|
|
97
|
+
</table>
|
|
98
|
+
</td></tr></table>
|
|
99
|
+
</div>`;
|
|
100
|
+
};
|
|
29
101
|
// src/core/orders.ts
|
|
30
102
|
var clampPercent = (percent) => Math.min(100, Math.max(0, percent));
|
|
31
103
|
var depositCents = (totalCents, percent) => percent > 0 ? Math.round(totalCents * clampPercent(percent) / 100) : 0;
|
|
@@ -56,19 +128,26 @@ export {
|
|
|
56
128
|
toProductionStage,
|
|
57
129
|
toCents,
|
|
58
130
|
roundMoney,
|
|
131
|
+
renderEmail,
|
|
59
132
|
quantityDiscount,
|
|
60
133
|
prevStage,
|
|
134
|
+
orderNumber,
|
|
61
135
|
nextStage,
|
|
62
136
|
nextQuantityBreak,
|
|
63
137
|
lineTotal,
|
|
64
138
|
isDiscountValid,
|
|
65
139
|
fromCents,
|
|
66
140
|
formatPrice,
|
|
141
|
+
formatMoneyCents,
|
|
142
|
+
emailLineItems,
|
|
143
|
+
emailButton,
|
|
67
144
|
discountAmountCents,
|
|
68
145
|
depositCents,
|
|
69
146
|
cartSubtotal,
|
|
70
147
|
cartSetupTotal,
|
|
71
148
|
cartCount,
|
|
149
|
+
carrierTrackingUrl,
|
|
72
150
|
PRODUCTION_STAGES,
|
|
151
|
+
DEFAULT_EMAIL_THEME,
|
|
73
152
|
DEFAULT_APPAREL_PARCEL
|
|
74
153
|
};
|
package/package.json
CHANGED