@hartl-services/medusa-base 1.0.0 → 2.0.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/.medusa/server/src/admin/index.js +117 -1
- package/.medusa/server/src/admin/index.mjs +118 -2
- package/.medusa/server/src/documents/plugin-features.js +15 -1
- package/.medusa/server/src/documents/templates/financial-document.js +69 -51
- package/.medusa/server/src/documents/templates/format.js +44 -2
- package/.medusa/server/src/documents/templates/html-factory.js +7 -5
- package/.medusa/server/src/documents/templates/html-utils.js +12 -2
- package/.medusa/server/src/documents/templates/layout.js +115 -70
- package/.medusa/server/src/documents/templates/packing-list.js +10 -8
- package/.medusa/server/src/documents/utils/document-merchant.js +5 -5
- package/.medusa/server/src/documents/utils/document-render-settings.js +59 -0
- package/.medusa/server/src/email/application/handle-invite-event.js +8 -2
- package/.medusa/server/src/email/application/handle-password-reset-event.js +16 -4
- package/.medusa/server/src/email/domain/order-summary.js +103 -0
- package/.medusa/server/src/email/domain/refund-summary.js +43 -0
- package/.medusa/server/src/email/domain/return-summary.js +118 -0
- package/.medusa/server/src/email/domain/shipment-summary.js +74 -0
- package/.medusa/server/src/email/plugin-features.js +9 -1
- package/.medusa/server/src/email/rendering/default-templates.js +693 -65
- package/.medusa/server/src/email/rendering/load-email-shop-details.js +36 -0
- package/.medusa/server/src/email/rendering/render-email.js +16 -3
- package/.medusa/server/src/email/rendering/resolve-shop-configuration.js +20 -1
- package/.medusa/server/src/email/types/template-data.js +155 -2
- package/.medusa/server/src/modules/documents/domain/merchant.js +2 -33
- package/.medusa/server/src/modules/documents/domain/options.js +1 -7
- package/.medusa/server/src/modules/plugin-features/domain/plugin-settings.js +4 -3
- package/.medusa/server/src/public/descriptor.js +3 -1
- package/.medusa/server/src/public/shop-master-data.js +7 -7
- package/.medusa/server/src/shop-config/build-food-shop-config.js +6 -6
- package/.medusa/server/src/shop-config/options.js +5 -15
- package/.medusa/server/src/workflows/documents/issue-cancellation-after-refund.js +2 -3
- package/.medusa/server/src/workflows/documents/issue-document.js +6 -5
- package/.medusa/server/src/workflows/documents/issue-packing-list.js +9 -3
- package/.medusa/server/src/workflows/email/dispatch-email-message.js +4 -2
- package/.medusa/server/src/workflows/email/prepare-order-canceled-email.js +42 -4
- package/.medusa/server/src/workflows/email/prepare-order-received-email.js +31 -5
- package/.medusa/server/src/workflows/email/prepare-refund-email.js +25 -1
- package/.medusa/server/src/workflows/email/prepare-return-email.js +64 -3
- package/.medusa/server/src/workflows/email/prepare-shipment-email.js +36 -3
- package/README.md +180 -43
- package/dist/admin-components/features/plugin-features/components/ImageSettingInput.d.ts +15 -0
- package/dist/admin-components/features/plugin-features/components/ImageSettingInput.js +42 -0
- package/dist/admin-components/features/plugin-features/components/PluginSettingsForm.js +4 -2
- package/dist/admin-components/features/plugin-features/hooks/usePluginFeatureEnabled.d.ts +1 -1
- package/dist/admin-components/features/plugin-features/hooks/usePluginFeatures.d.ts +4 -4
- package/dist/admin-components/features/plugin-features/hooks/usePluginSettingsForm.d.ts +1 -1
- package/dist/admin-components/features/plugin-features/lib/image-upload.d.ts +6 -0
- package/dist/admin-components/features/plugin-features/lib/image-upload.js +17 -0
- package/dist/admin-components/features/plugin-features/lib/plugin-features-admin-client.d.ts +4 -4
- package/dist/admin-components/i18n/texts.d.ts +6 -0
- package/dist/admin-components/i18n/texts.js +6 -0
- package/dist/documents/templates/financial-document.d.ts +3 -3
- package/dist/documents/templates/financial-document.js +68 -50
- package/dist/documents/templates/format.d.ts +14 -0
- package/dist/documents/templates/format.js +43 -1
- package/dist/documents/templates/html-factory.d.ts +6 -2
- package/dist/documents/templates/html-factory.js +6 -4
- package/dist/documents/templates/html-utils.d.ts +6 -0
- package/dist/documents/templates/html-utils.js +11 -1
- package/dist/documents/templates/layout.d.ts +21 -3
- package/dist/documents/templates/layout.js +114 -69
- package/dist/documents/templates/packing-list.js +9 -7
- package/dist/documents/types/documents.d.ts +11 -16
- package/dist/documents/types/html-factory.d.ts +1 -0
- package/dist/email/types/shop-configuration.d.ts +25 -0
- package/dist/email/types/template-data.d.ts +509 -0
- package/dist/email/types/template-data.js +154 -1
- package/dist/modules/documents/domain/options.d.ts +1 -9
- package/dist/modules/documents/domain/options.js +0 -6
- package/dist/public/descriptor.js +2 -0
- package/dist/public/shop-master-data.d.ts +5 -6
- package/dist/public/shop-master-data.js +6 -6
- package/dist/public/types.d.ts +2 -1
- package/dist/shop-config/build-food-shop-config.js +5 -5
- package/dist/shop-config/options.d.ts +13 -8
- package/dist/shop-config/options.js +4 -14
- package/package.json +2 -2
- package/dist/modules/documents/domain/merchant.d.ts +0 -22
- package/dist/modules/documents/domain/merchant.js +0 -85
|
@@ -10,15 +10,15 @@ const renderBatchAllocations = (line, timeZone) => {
|
|
|
10
10
|
return line.batch_allocations
|
|
11
11
|
.map((allocation) => `<div class="packing-batch">
|
|
12
12
|
<strong>${(0, html_utils_1.escapeHtml)(allocation.lot_number)}</strong>
|
|
13
|
-
<span>MHD: ${(0, format_1.
|
|
13
|
+
<span>MHD: ${(0, html_utils_1.escapeHtml)((0, format_1.formatDocumentDate)(allocation.expiry_date, timeZone))}</span>
|
|
14
14
|
<span>Menge: ${(0, html_utils_1.escapeHtml)(allocation.quantity)}</span>
|
|
15
15
|
</div>`)
|
|
16
16
|
.join("");
|
|
17
17
|
};
|
|
18
18
|
const renderLines = (input, timeZone) => input.lines
|
|
19
19
|
.map((line) => `<tr>
|
|
20
|
-
<td>
|
|
21
|
-
<
|
|
20
|
+
<td class="item">
|
|
21
|
+
<div class="item-title">${(0, html_utils_1.escapeHtml)(line.title)}</div>
|
|
22
22
|
${line.sku ? `<div class="sku">SKU: ${(0, html_utils_1.escapeHtml)(line.sku)}</div>` : ""}
|
|
23
23
|
</td>
|
|
24
24
|
<td>${renderBatchAllocations(line, timeZone)}</td>
|
|
@@ -26,12 +26,13 @@ const renderLines = (input, timeZone) => input.lines
|
|
|
26
26
|
</tr>`)
|
|
27
27
|
.join("");
|
|
28
28
|
const renderPackingList = (input, layout, timeZone) => layout({
|
|
29
|
-
body: `<table>
|
|
30
|
-
<thead><tr><th>Bezeichnung</th><th>Charge</th><th class="number">Benötigte Menge</th></tr></thead>
|
|
31
|
-
<tbody>${renderLines(input, timeZone)}</tbody>
|
|
29
|
+
body: `<table class="items packing-items">
|
|
30
|
+
<thead><tr><th class="item">Bezeichnung</th><th>Charge</th><th class="number">Benötigte Menge</th></tr></thead>
|
|
31
|
+
<tbody class="lines">${renderLines(input, timeZone)}</tbody>
|
|
32
32
|
</table>`,
|
|
33
33
|
documentTitle: "Packliste",
|
|
34
34
|
metadata: [
|
|
35
|
+
{ label: "Packlistennummer", value: input.document.number },
|
|
35
36
|
{
|
|
36
37
|
label: "Bestellung",
|
|
37
38
|
value: (0, html_utils_1.formatOrderReference)(input.order.display_id),
|
|
@@ -39,11 +40,12 @@ const renderPackingList = (input, layout, timeZone) => layout({
|
|
|
39
40
|
{ label: "Fulfillment", value: input.fulfillment.id },
|
|
40
41
|
{
|
|
41
42
|
label: "Erstellungsdatum",
|
|
42
|
-
value: (0, format_1.
|
|
43
|
+
value: (0, format_1.formatDocumentDate)(input.document.generated_at, timeZone),
|
|
43
44
|
},
|
|
44
45
|
{ label: "Lagerplatz", value: input.fulfillment.location_name },
|
|
45
46
|
],
|
|
46
47
|
number: input.document.number,
|
|
47
48
|
pageTitle: "Packliste",
|
|
49
|
+
recipient: null,
|
|
48
50
|
});
|
|
49
51
|
exports.renderPackingList = renderPackingList;
|
|
@@ -144,28 +144,23 @@ export type DocumentMerchant = {
|
|
|
144
144
|
company_register_number: string | null;
|
|
145
145
|
company_register_court: string | null;
|
|
146
146
|
};
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
address1: string;
|
|
157
|
-
address2?: string;
|
|
158
|
-
city: string;
|
|
159
|
-
countryCode: string;
|
|
160
|
-
postalCode: string;
|
|
161
|
-
};
|
|
162
|
-
vatNumber?: string;
|
|
147
|
+
export type DocumentRenderSettings = {
|
|
148
|
+
/**
|
|
149
|
+
* The uploaded logo as a `data:` URL, ready for `<img src>`; `null` when no
|
|
150
|
+
* logo is set or it could not be loaded (the document then shows the
|
|
151
|
+
* merchant's legal name instead).
|
|
152
|
+
*/
|
|
153
|
+
logo_src: string | null;
|
|
154
|
+
/** Payment terms printed below the totals of an invoice; `null` = none. */
|
|
155
|
+
payment_terms: string | null;
|
|
163
156
|
};
|
|
164
157
|
export type FinancialDocumentRenderInput = DocumentTemplateInput & {
|
|
165
158
|
merchant: DocumentMerchant;
|
|
159
|
+
settings: DocumentRenderSettings;
|
|
166
160
|
};
|
|
167
161
|
export type PackingListRenderInput = PackingListTemplateInput & {
|
|
168
162
|
merchant: DocumentMerchant;
|
|
163
|
+
settings: DocumentRenderSettings;
|
|
169
164
|
};
|
|
170
165
|
export type DocumentRenderInput = FinancialDocumentRenderInput | PackingListRenderInput;
|
|
171
166
|
export type DocumentPdfOptions = {
|
|
@@ -5,3 +5,4 @@ import type { DocumentRenderInput } from "./documents";
|
|
|
5
5
|
*/
|
|
6
6
|
export type DocumentHtmlFactory = (input: DocumentRenderInput) => string | Promise<string>;
|
|
7
7
|
export declare const defineDocumentHtmlFactory: (factory: DocumentHtmlFactory) => DocumentHtmlFactory;
|
|
8
|
+
export type { DocumentTheme } from "../templates/layout";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ShopMasterData } from "../../public";
|
|
1
2
|
import type { EmailKind } from "./email-kinds";
|
|
2
3
|
import type { EmailRenderDataMap } from "./template-data";
|
|
3
4
|
export type EmailTemplateContent = Readonly<{
|
|
@@ -5,10 +6,22 @@ export type EmailTemplateContent = Readonly<{
|
|
|
5
6
|
subject: string;
|
|
6
7
|
text: string;
|
|
7
8
|
}>;
|
|
9
|
+
/**
|
|
10
|
+
* The shop's master data ("Shop-Stammdaten") plus the `logo` URL of the
|
|
11
|
+
* E-Mail settings, read when the mail is sent. Every field may be missing; a
|
|
12
|
+
* layout shows what is there instead of failing.
|
|
13
|
+
*/
|
|
14
|
+
export type EmailShopDetails = Readonly<ShopMasterData & {
|
|
15
|
+
logo?: string;
|
|
16
|
+
}>;
|
|
17
|
+
/** Who reads a mail: a customer or the shop's own team. */
|
|
18
|
+
export type EmailAudience = "customer" | "shop";
|
|
8
19
|
export type EmailLayout = (input: Readonly<{
|
|
20
|
+
audience: EmailAudience;
|
|
9
21
|
bodyHtml: string;
|
|
10
22
|
preheader: string;
|
|
11
23
|
subject: string;
|
|
24
|
+
shop: EmailShopDetails;
|
|
12
25
|
}>) => string;
|
|
13
26
|
export type EmailRendererMap = {
|
|
14
27
|
readonly [Kind in EmailKind]: (data: EmailRenderDataMap[Kind]) => EmailTemplateContent;
|
|
@@ -19,6 +32,13 @@ export type EmailRendererMap = {
|
|
|
19
32
|
* partial `renderers` map replaces only the listed kinds.
|
|
20
33
|
*/
|
|
21
34
|
export type ShopEmailConfiguration = Readonly<{
|
|
35
|
+
/**
|
|
36
|
+
* Link to an order in the Medusa Admin; the shop's order notification shows
|
|
37
|
+
* an "Im Admin öffnen" button only when it is set.
|
|
38
|
+
*/
|
|
39
|
+
adminOrderUrl?: (input: Readonly<{
|
|
40
|
+
orderId: string;
|
|
41
|
+
}>) => string;
|
|
22
42
|
affiliatePortalUrl: string;
|
|
23
43
|
displayName: string;
|
|
24
44
|
inviteUrl: (input: Readonly<{
|
|
@@ -30,6 +50,11 @@ export type ShopEmailConfiguration = Readonly<{
|
|
|
30
50
|
locale: string | null;
|
|
31
51
|
}>) => string;
|
|
32
52
|
renderers?: Partial<EmailRendererMap>;
|
|
53
|
+
/**
|
|
54
|
+
* IANA time zone of dates in the default templates (e.g. the order time in
|
|
55
|
+
* the shop's order notification); without it they are left out.
|
|
56
|
+
*/
|
|
57
|
+
timeZone?: string;
|
|
33
58
|
}>;
|
|
34
59
|
/** A `ShopEmailConfiguration` with the defaults merged in; used internally. */
|
|
35
60
|
export type ResolvedShopEmailConfiguration = Readonly<Omit<ShopEmailConfiguration, "layout" | "renderers"> & {
|