@unchainedshop/platform 2.5.8 → 2.5.10
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/lib/templates/order-parser/formatAddress.d.ts +2 -0
- package/lib/templates/order-parser/formatAddress.js +14 -0
- package/lib/templates/order-parser/formatAddress.js.map +1 -0
- package/lib/templates/order-parser/formatPrice.d.ts +5 -0
- package/lib/templates/order-parser/formatPrice.js +6 -0
- package/lib/templates/order-parser/formatPrice.js.map +1 -0
- package/lib/templates/order-parser/getOrderPositionsData.d.ts +31 -0
- package/lib/templates/{utils → order-parser}/getOrderPositionsData.js +13 -9
- package/lib/templates/order-parser/getOrderPositionsData.js.map +1 -0
- package/lib/templates/order-parser/getOrderSummaryData.d.ts +47 -0
- package/lib/templates/order-parser/getOrderSummaryData.js +62 -0
- package/lib/templates/order-parser/getOrderSummaryData.js.map +1 -0
- package/lib/templates/order-parser/index.d.ts +4 -0
- package/lib/templates/order-parser/index.js +42 -0
- package/lib/templates/order-parser/index.js.map +1 -0
- package/lib/templates/resolveErrorReportTemplate.js +9 -1
- package/lib/templates/resolveErrorReportTemplate.js.map +1 -1
- package/lib/templates/resolveForwardDeliveryTemplate.js +11 -41
- package/lib/templates/resolveForwardDeliveryTemplate.js.map +1 -1
- package/lib/templates/resolveOrderConfirmationTemplate.js +9 -61
- package/lib/templates/resolveOrderConfirmationTemplate.js.map +1 -1
- package/lib/templates/resolveOrderRejectionTemplate.js +15 -29
- package/lib/templates/resolveOrderRejectionTemplate.js.map +1 -1
- package/package.json +12 -12
- package/src/templates/order-parser/formatAddress.ts +15 -0
- package/src/templates/order-parser/formatPrice.ts +6 -0
- package/src/templates/{utils → order-parser}/getOrderPositionsData.ts +17 -12
- package/src/templates/order-parser/getOrderSummaryData.ts +79 -0
- package/src/templates/order-parser/index.ts +44 -0
- package/src/templates/resolveErrorReportTemplate.ts +10 -1
- package/src/templates/resolveForwardDeliveryTemplate.ts +11 -44
- package/src/templates/resolveOrderConfirmationTemplate.ts +10 -73
- package/src/templates/resolveOrderRejectionTemplate.ts +16 -30
- package/lib/templates/utils/formatWorkItems.d.ts +0 -2
- package/lib/templates/utils/formatWorkItems.js +0 -10
- package/lib/templates/utils/formatWorkItems.js.map +0 -1
- package/lib/templates/utils/getOrderAttachmentsData.d.ts +0 -8
- package/lib/templates/utils/getOrderAttachmentsData.js +0 -21
- package/lib/templates/utils/getOrderAttachmentsData.js.map +0 -1
- package/lib/templates/utils/getOrderPositionsData.d.ts +0 -6
- package/lib/templates/utils/getOrderPositionsData.js.map +0 -1
- package/src/templates/utils/formatWorkItems.ts +0 -10
- package/src/templates/utils/getOrderAttachmentsData.ts +0 -40
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const formatAddress = (address) => {
|
|
2
|
+
return [
|
|
3
|
+
[address.firstName, address.lastName].filter(Boolean).join(' '),
|
|
4
|
+
address.company,
|
|
5
|
+
address.addressLine,
|
|
6
|
+
address.addressLine2,
|
|
7
|
+
[address.postalCode, address.city].filter(Boolean).join(' '),
|
|
8
|
+
address.regionCode,
|
|
9
|
+
[address.countryCode].filter(Boolean).join(''),
|
|
10
|
+
]
|
|
11
|
+
.filter(Boolean)
|
|
12
|
+
.join('\n');
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=formatAddress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatAddress.js","sourceRoot":"","sources":["../../../src/templates/order-parser/formatAddress.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAAgB,EAAE,EAAE;IAChD,OAAO;QACL,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QAC/D,OAAO,CAAC,OAAO;QACf,OAAO,CAAC,WAAW;QACnB,OAAO,CAAC,YAAY;QACpB,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QAC5D,OAAO,CAAC,UAAU;QAClB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;KAC/C;SACE,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatPrice.js","sourceRoot":"","sources":["../../../src/templates/order-parser/formatPrice.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAwC,EAAE,EAAE;IACxF,MAAM,UAAU,GAAG,MAAM,GAAG,GAAG,CAAC;IAChC,OAAO,GAAG,QAAQ,IAAI,UAAU,EAAE,CAAC;AACrC,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Locale } from '@unchainedshop/types/common.js';
|
|
2
|
+
import { UnchainedCore } from '@unchainedshop/types/core.js';
|
|
3
|
+
import { Order } from '@unchainedshop/types/orders.js';
|
|
4
|
+
type PriceFormatter = ({ amount, currency }: {
|
|
5
|
+
amount: number;
|
|
6
|
+
currency: string;
|
|
7
|
+
}) => string;
|
|
8
|
+
export declare const getOrderPositionsData: (order: Order, params: {
|
|
9
|
+
locale?: Locale;
|
|
10
|
+
useNetPrice?: boolean;
|
|
11
|
+
format?: PriceFormatter;
|
|
12
|
+
}, context: UnchainedCore) => Promise<{
|
|
13
|
+
productId: string;
|
|
14
|
+
configuration: import("@unchainedshop/types/common.js").Configuration;
|
|
15
|
+
originalProductTexts: import("@unchainedshop/types/products.js").ProductText;
|
|
16
|
+
productTexts: import("@unchainedshop/types/products.js").ProductText;
|
|
17
|
+
quantity: number;
|
|
18
|
+
rawPrices: {
|
|
19
|
+
unitPrice: {
|
|
20
|
+
amount: number;
|
|
21
|
+
currency: string;
|
|
22
|
+
};
|
|
23
|
+
total: {
|
|
24
|
+
amount: number;
|
|
25
|
+
currency: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
unitPrice: string;
|
|
29
|
+
total: string;
|
|
30
|
+
}[]>;
|
|
31
|
+
export {};
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
+
import formatPrice from './formatPrice.js';
|
|
1
2
|
export const getOrderPositionsData = async (order, params, context) => {
|
|
2
3
|
const { modules } = context;
|
|
4
|
+
const { useNetPrice, format = formatPrice } = params || {};
|
|
3
5
|
const orderPositions = await modules.orders.positions.findOrderPositions({
|
|
4
6
|
orderId: order._id,
|
|
5
7
|
});
|
|
6
|
-
|
|
7
|
-
const fixedPrice = price / 100;
|
|
8
|
-
return `${order.currency} ${fixedPrice}`;
|
|
9
|
-
};
|
|
10
|
-
await Promise.all(orderPositions.map(async (orderPosition) => {
|
|
8
|
+
return Promise.all(orderPositions.map(async (orderPosition) => {
|
|
11
9
|
const productTexts = await modules.products.texts.findLocalizedText({
|
|
12
10
|
productId: orderPosition.productId,
|
|
13
11
|
locale: params.locale?.normalized,
|
|
@@ -16,16 +14,22 @@ export const getOrderPositionsData = async (order, params, context) => {
|
|
|
16
14
|
productId: orderPosition.originalProductId,
|
|
17
15
|
locale: params.locale?.normalized,
|
|
18
16
|
});
|
|
19
|
-
const productTitle = productTexts?.title; // deprecated
|
|
20
17
|
const positionPricing = modules.orders.positions.pricingSheet(orderPosition, order.currency, context);
|
|
21
|
-
const total =
|
|
18
|
+
const total = positionPricing.total({ useNetPrice });
|
|
19
|
+
const unitPrice = positionPricing.unitPrice({ useNetPrice });
|
|
22
20
|
const { quantity } = positionPricing;
|
|
23
21
|
return {
|
|
22
|
+
productId: orderPosition.productId,
|
|
23
|
+
configuration: orderPosition.configuration,
|
|
24
24
|
originalProductTexts,
|
|
25
|
-
product: productTitle,
|
|
26
25
|
productTexts,
|
|
27
26
|
quantity,
|
|
28
|
-
|
|
27
|
+
rawPrices: {
|
|
28
|
+
unitPrice,
|
|
29
|
+
total,
|
|
30
|
+
},
|
|
31
|
+
unitPrice: format(unitPrice),
|
|
32
|
+
total: format(total),
|
|
29
33
|
};
|
|
30
34
|
}));
|
|
31
35
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOrderPositionsData.js","sourceRoot":"","sources":["../../../src/templates/order-parser/getOrderPositionsData.ts"],"names":[],"mappings":"AAGA,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAI3C,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,EACxC,KAAY,EACZ,MAA2E,EAC3E,OAAsB,EACtB,EAAE;IACF,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAC5B,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,WAAW,EAAE,GAAG,MAAM,IAAI,EAAE,CAAC;IAC3D,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,kBAAkB,CAAC;QACvE,OAAO,EAAE,KAAK,CAAC,GAAG;KACnB,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,GAAG,CAChB,cAAc,CAAC,GAAG,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE;QACzC,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,iBAAiB,CAAC;YAClE,SAAS,EAAE,aAAa,CAAC,SAAS;YAClC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU;SAClC,CAAC,CAAC;QACH,MAAM,oBAAoB,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,iBAAiB,CAAC;YAC1E,SAAS,EAAE,aAAa,CAAC,iBAAiB;YAC1C,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU;SAClC,CAAC,CAAC;QAEH,MAAM,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,YAAY,CAC3D,aAAa,EACb,KAAK,CAAC,QAAQ,EACd,OAAO,CACR,CAAC;QACF,MAAM,KAAK,GAAG,eAAe,CAAC,KAAK,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;QACrD,MAAM,SAAS,GAAG,eAAe,CAAC,SAAS,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;QAE7D,MAAM,EAAE,QAAQ,EAAE,GAAG,eAAe,CAAC;QACrC,OAAO;YACL,SAAS,EAAE,aAAa,CAAC,SAAS;YAClC,aAAa,EAAE,aAAa,CAAC,aAAa;YAC1C,oBAAoB;YACpB,YAAY;YACZ,QAAQ;YACR,SAAS,EAAE;gBACT,SAAS;gBACT,KAAK;aACN;YACD,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC;YAC5B,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC;SACrB,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { UnchainedCore } from '@unchainedshop/types/core.js';
|
|
2
|
+
import { Order } from '@unchainedshop/types/orders.js';
|
|
3
|
+
import { Locale } from '@unchainedshop/types/common.js';
|
|
4
|
+
type PriceFormatter = ({ amount, currency }: {
|
|
5
|
+
amount: number;
|
|
6
|
+
currency: string;
|
|
7
|
+
}) => string;
|
|
8
|
+
export declare const getOrderSummaryData: (order: Order, params: {
|
|
9
|
+
locale?: Locale;
|
|
10
|
+
useNetPrice?: boolean;
|
|
11
|
+
format?: PriceFormatter;
|
|
12
|
+
}, context: UnchainedCore) => Promise<{
|
|
13
|
+
rawPrices: {
|
|
14
|
+
items: {
|
|
15
|
+
amount: number;
|
|
16
|
+
currency: string;
|
|
17
|
+
};
|
|
18
|
+
taxes: {
|
|
19
|
+
amount: number;
|
|
20
|
+
currency: string;
|
|
21
|
+
};
|
|
22
|
+
delivery: {
|
|
23
|
+
amount: number;
|
|
24
|
+
currency: string;
|
|
25
|
+
};
|
|
26
|
+
payment: {
|
|
27
|
+
amount: number;
|
|
28
|
+
currency: string;
|
|
29
|
+
};
|
|
30
|
+
gross: {
|
|
31
|
+
amount: number;
|
|
32
|
+
currency: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
prices: {
|
|
36
|
+
items: string;
|
|
37
|
+
taxes: string;
|
|
38
|
+
delivery: string;
|
|
39
|
+
payment: string;
|
|
40
|
+
gross: string;
|
|
41
|
+
};
|
|
42
|
+
payment: string;
|
|
43
|
+
delivery: string;
|
|
44
|
+
deliveryAddress: string;
|
|
45
|
+
billingAddress: string;
|
|
46
|
+
}>;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { OrderPricingRowCategory } from '@unchainedshop/types/orders.pricing.js';
|
|
2
|
+
import formatPrice from './formatPrice.js';
|
|
3
|
+
import { formatAddress } from './formatAddress.js';
|
|
4
|
+
export const getOrderSummaryData = async (order, params, context) => {
|
|
5
|
+
const { modules } = context;
|
|
6
|
+
const { useNetPrice, format = formatPrice } = params || {};
|
|
7
|
+
const orderDelivery = await modules.orders.deliveries.findDelivery({
|
|
8
|
+
orderDeliveryId: order.deliveryId,
|
|
9
|
+
});
|
|
10
|
+
const orderPayment = await modules.orders.payments.findOrderPayment({
|
|
11
|
+
orderPaymentId: order.paymentId,
|
|
12
|
+
});
|
|
13
|
+
const paymentProvider = await modules.payment.paymentProviders.findProvider({
|
|
14
|
+
paymentProviderId: orderPayment.paymentProviderId,
|
|
15
|
+
});
|
|
16
|
+
const deliveryProvider = await modules.delivery.findProvider({
|
|
17
|
+
deliveryProviderId: orderDelivery.deliveryProviderId,
|
|
18
|
+
});
|
|
19
|
+
const deliveryAddress = formatAddress(orderDelivery?.context?.deliveryAddress || order.billingAddress);
|
|
20
|
+
const billingAddress = formatAddress(order.billingAddress);
|
|
21
|
+
const orderPricing = modules.orders.pricingSheet(order);
|
|
22
|
+
const paymentTotal = orderPricing.total({
|
|
23
|
+
category: OrderPricingRowCategory.Payment,
|
|
24
|
+
useNetPrice,
|
|
25
|
+
});
|
|
26
|
+
const deliveryTotal = orderPricing.total({
|
|
27
|
+
category: OrderPricingRowCategory.Delivery,
|
|
28
|
+
useNetPrice,
|
|
29
|
+
});
|
|
30
|
+
const taxesTotal = orderPricing.total({
|
|
31
|
+
category: OrderPricingRowCategory.Taxes,
|
|
32
|
+
useNetPrice,
|
|
33
|
+
});
|
|
34
|
+
const itemsTotal = orderPricing.total({
|
|
35
|
+
category: OrderPricingRowCategory.Items,
|
|
36
|
+
useNetPrice,
|
|
37
|
+
});
|
|
38
|
+
const total = orderPricing.total({ useNetPrice });
|
|
39
|
+
const payment = paymentProvider.adapterKey;
|
|
40
|
+
const delivery = deliveryProvider.adapterKey;
|
|
41
|
+
return {
|
|
42
|
+
rawPrices: {
|
|
43
|
+
items: itemsTotal,
|
|
44
|
+
taxes: taxesTotal,
|
|
45
|
+
delivery: deliveryTotal,
|
|
46
|
+
payment: paymentTotal,
|
|
47
|
+
gross: total,
|
|
48
|
+
},
|
|
49
|
+
prices: {
|
|
50
|
+
items: format(itemsTotal),
|
|
51
|
+
taxes: format(taxesTotal),
|
|
52
|
+
delivery: format(deliveryTotal),
|
|
53
|
+
payment: format(paymentTotal),
|
|
54
|
+
gross: format(total),
|
|
55
|
+
},
|
|
56
|
+
payment,
|
|
57
|
+
delivery,
|
|
58
|
+
deliveryAddress,
|
|
59
|
+
billingAddress,
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=getOrderSummaryData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOrderSummaryData.js","sourceRoot":"","sources":["../../../src/templates/order-parser/getOrderSummaryData.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAEjF,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MA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AAQ;QAC1C,WAAW;KACZ,CAAC,CAAC;IAEH,MAAM,UAAU,GAAG,YAAY,CAAC,KAAK,CAAC;QACpC,QAAQ,EAAE,uBAAuB,CAAC,KAAK;QACvC,WAAW;KACZ,CAAC,CAAC;IAEH,MAAM,UAAU,GAAG,YAAY,CAAC,KAAK,CAAC;QACpC,QAAQ,EAAE,uBAAuB,CAAC,KAAK;QACvC,WAAW;KACZ,CAAC,CAAC;IAEH,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;IAElD,MAAM,OAAO,GAAG,eAAe,CAAC,UAAU,CAAC;IAC3C,MAAM,QAAQ,GAAG,gBAAgB,CAAC,UAAU,CAAC;IAE7C,OAAO;QACL,SAAS,EAAE;YACT,KAAK,EAAE,UAAU;YACjB,KAAK,EAAE,UAAU;YACjB,QAAQ,EAAE,aAAa;YACvB,OAAO,EAAE,YAAY;YACrB,KAAK,EAAE,KAAK;SACb;QACD,MAAM,EAAE;YACN,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC;YACzB,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC;YACzB,QAAQ,EAAE,MAAM,CAAC,aAAa,CAAC;YAC/B,OAAO,EAAE,MAAM,CAAC,YAAY,CAAC;YAC7B,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC;SACrB;QACD,OAAO;QACP,QAAQ;QACR,eAAe;QACf,cAAc;KACf,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { getOrderPositionsData } from './getOrderPositionsData.js';
|
|
2
|
+
import { getOrderSummaryData } from './getOrderSummaryData.js';
|
|
3
|
+
const textTemplate = `Order number: {{orderNumber}}
|
|
4
|
+
Ordered: {{orderDate}}
|
|
5
|
+
Payment method: {{summary.payment}}
|
|
6
|
+
Delivery method: {{summary.delivery}}
|
|
7
|
+
|
|
8
|
+
Delivery address:
|
|
9
|
+
{{summary.deliveryAddress}}
|
|
10
|
+
|
|
11
|
+
Billing address:
|
|
12
|
+
{{summary.billingAddress}}
|
|
13
|
+
|
|
14
|
+
Order Details:
|
|
15
|
+
|
|
16
|
+
Items:
|
|
17
|
+
{{#positions}}
|
|
18
|
+
* {{quantity}} {{productTexts.title}}: {{total}}
|
|
19
|
+
{{/positions}}
|
|
20
|
+
|
|
21
|
+
{{#summary.rawPrices.delivery.amount}}
|
|
22
|
+
Delivery Fees: {{summary.prices.delivery}}
|
|
23
|
+
{{/summary.rawPrices.delivery.amount}}
|
|
24
|
+
{{#summary.rawPrices.payment.amount}}
|
|
25
|
+
Payment Fees: {{summary.prices.payment}}
|
|
26
|
+
{{/summary.rawPrices.payment.amount}}
|
|
27
|
+
Total: {{summary.prices.gross}}
|
|
28
|
+
{{#summary.rawPrices.taxes.amount}}
|
|
29
|
+
(VAT included: {{summary.prices.taxes}})
|
|
30
|
+
{{/summary.rawPrices.taxes.amount}}
|
|
31
|
+
`;
|
|
32
|
+
export const transformOrderToText = async ({ order, locale }, context) => {
|
|
33
|
+
const { modules } = context;
|
|
34
|
+
const data = {
|
|
35
|
+
orderDate: new Date(order.ordered).toLocaleString(),
|
|
36
|
+
orderNumber: order.orderNumber,
|
|
37
|
+
summary: await getOrderSummaryData(order, { locale }, context),
|
|
38
|
+
positions: await getOrderPositionsData(order, { locale }, context),
|
|
39
|
+
};
|
|
40
|
+
return modules.messaging.renderToText(textTemplate, data);
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/templates/order-parser/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BpB,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE;IACvE,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAC5B,MAAM,IAAI,GAAG;QACX,SAAS,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,cAAc,EAAE;QACnD,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,OAAO,EAAE,MAAM,mBAAmB,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC;QAC9D,SAAS,EAAE,MAAM,qBAAqB,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC;KACnE,CAAC;IAEF,OAAO,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;AAC5D,CAAC,CAAC"}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import util from 'util';
|
|
2
2
|
const { EMAIL_FROM = 'noreply@unchained.local', EMAIL_ERROR_REPORT_RECIPIENT = 'support@unchained.local', EMAIL_WEBSITE_NAME = 'Unchained', ROOT_URL, } = process.env;
|
|
3
|
+
const formatWorkItems = (workItems) => {
|
|
4
|
+
return workItems
|
|
5
|
+
.map(({ _id, type, started, error }) => {
|
|
6
|
+
const stringifiedErrors = util.inspect(error, false, 10, false);
|
|
7
|
+
return `${new Date(started).toLocaleString()} ${type} (${_id}): ${stringifiedErrors}`;
|
|
8
|
+
})
|
|
9
|
+
.join('\n');
|
|
10
|
+
};
|
|
3
11
|
const textTemplate = `
|
|
4
12
|
-------------------------
|
|
5
13
|
Unchained Endpoint: {{endpoint}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveErrorReportTemplate.js","sourceRoot":"","sources":["../../src/templates/resolveErrorReportTemplate.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"resolveErrorReportTem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AACJ,CAAC,CAAC;AAEF,OAAO,EAAE,0BAA0B,EAAE,CAAC;AAEtC,eAAe,0BAA0B,CAAC"}
|
|
@@ -1,67 +1,37 @@
|
|
|
1
1
|
import { systemLocale } from '@unchainedshop/utils';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
const { EMAIL_FROM, EMAIL_WEBSITE_NAME, ROOT_URL } = process.env;
|
|
2
|
+
import { transformOrderToText } from './order-parser/index.js';
|
|
3
|
+
const { EMAIL_FROM, EMAIL_WEBSITE_NAME, EMAIL_WEBSITE_URL } = process.env;
|
|
5
4
|
const textTemplate = `
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
\n
|
|
12
|
-
Delivery address:\n
|
|
13
|
-
-----------------\n
|
|
14
|
-
{{address.firstName}} {{address.lastName}}\n
|
|
15
|
-
{{address.company}}\n
|
|
16
|
-
{{address.addressLine}}\n
|
|
17
|
-
{{address.addressLine2}}\n
|
|
18
|
-
{{address.postalCode}} {{address.city}}\n
|
|
19
|
-
{{address.regionCode}}\n
|
|
20
|
-
{{address.countryCode}}\n
|
|
21
|
-
\n
|
|
22
|
-
Articles:\n
|
|
23
|
-
-----------------\n
|
|
24
|
-
{{#items}}
|
|
25
|
-
* {{sku}} - {{name}} CHF {{price}} {{quantity}}\n
|
|
26
|
-
{{/items}}
|
|
5
|
+
New Order received:
|
|
6
|
+
|
|
7
|
+
{{orderDetails}}
|
|
8
|
+
|
|
9
|
+
{{shopName}}: {{shopUrl}}
|
|
27
10
|
`;
|
|
28
11
|
export const resolveForwardDeliveryTemplate = async ({ config, orderId }, context) => {
|
|
29
12
|
const { modules } = context;
|
|
30
13
|
const order = await modules.orders.findOrder({ orderId });
|
|
31
|
-
const orderPricing = modules.orders.pricingSheet(order);
|
|
32
|
-
const orderDate = new Date(order.ordered).toLocaleString();
|
|
33
|
-
const attachments = await getOrderAttachmentsData(order, { fileType: 'DELIVERY_NOTE' }, context);
|
|
34
|
-
const address = order.billingAddress;
|
|
35
14
|
const configObject = config.reduce((acc, { key, value }) => {
|
|
36
15
|
return {
|
|
37
16
|
...acc,
|
|
38
17
|
[key]: value,
|
|
39
18
|
};
|
|
40
19
|
}, {});
|
|
41
|
-
const subject = `${EMAIL_WEBSITE_NAME}
|
|
42
|
-
const adminUILink = `${ROOT_URL}/orders/view/?_id=${order._id}`;
|
|
20
|
+
const subject = `${EMAIL_WEBSITE_NAME} Order ${order.orderNumber}`;
|
|
43
21
|
const data = {
|
|
44
|
-
contact: order.contact || {},
|
|
45
|
-
adminUILink,
|
|
46
|
-
items: getOrderPositionsData(order, { locale: systemLocale }, context),
|
|
47
|
-
orderDate,
|
|
48
|
-
orderNumber: order.orderNumber,
|
|
49
22
|
shopName: EMAIL_WEBSITE_NAME,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
...configObject,
|
|
53
|
-
address,
|
|
23
|
+
shopUrl: EMAIL_WEBSITE_URL,
|
|
24
|
+
orderDetails: await transformOrderToText({ order, locale: systemLocale }, context),
|
|
54
25
|
};
|
|
55
26
|
return [
|
|
56
27
|
{
|
|
57
28
|
type: 'EMAIL',
|
|
58
29
|
input: {
|
|
59
|
-
from: configObject.from || EMAIL_FROM || 'noreply@unchained.local'
|
|
30
|
+
from: `${EMAIL_WEBSITE_NAME} <${configObject.from || EMAIL_FROM || 'noreply@unchained.local'}>`,
|
|
60
31
|
to: configObject.to || 'orders@unchained.local',
|
|
61
32
|
cc: configObject.cc,
|
|
62
33
|
subject,
|
|
63
34
|
text: modules.messaging.renderToText(textTemplate, data),
|
|
64
|
-
attachments,
|
|
65
35
|
},
|
|
66
36
|
},
|
|
67
37
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveForwardDeliveryTemplate.js","sourceRoot":"","sources":["../../src/templates/resolveForwardDeliveryTemplate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,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G;gBAC/F,EAAE,EAAE,YAAY,CAAC,EAAE,IAAI,wBAAwB;gBAC/C,EAAE,EAAE,YAAY,CAAC,EAAE;gBACnB,OAAO;gBACP,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,YAAY,EAAE,IAAI,CAAC;aACzD;SACF;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,84 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getOrderAttachmentsData } from './utils/getOrderAttachmentsData.js';
|
|
3
|
-
import { getOrderPositionsData } from './utils/getOrderPositionsData.js';
|
|
1
|
+
import { transformOrderToText } from './order-parser/index.js';
|
|
4
2
|
const { EMAIL_FROM, EMAIL_WEBSITE_NAME, EMAIL_WEBSITE_URL } = process.env;
|
|
5
3
|
const textTemplate = `
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
{{buttonText}}: {{url}}\n
|
|
12
|
-
-----------------\n
|
|
4
|
+
Thank you very much for your order.
|
|
5
|
+
|
|
6
|
+
{{orderDetails}}
|
|
7
|
+
|
|
8
|
+
{{shopName}}: {{shopUrl}}
|
|
13
9
|
`;
|
|
14
|
-
const texts = {
|
|
15
|
-
en: {
|
|
16
|
-
buttonText: 'Follow purchase order status',
|
|
17
|
-
thankyou: 'Thank you for your order on',
|
|
18
|
-
subject: `${EMAIL_WEBSITE_NAME}: Order confirmation`,
|
|
19
|
-
},
|
|
20
|
-
de: {
|
|
21
|
-
buttonText: 'Bestellstatus verfolgen',
|
|
22
|
-
thankyou: 'Vielen Dank für deine Bestellung bei',
|
|
23
|
-
subject: `${EMAIL_WEBSITE_NAME}: Bestellbestätigung`,
|
|
24
|
-
},
|
|
25
|
-
fr: {
|
|
26
|
-
buttonText: 'Follow purchase order status',
|
|
27
|
-
thankyou: 'Thank you for your order on',
|
|
28
|
-
subject: `${EMAIL_WEBSITE_NAME}: Order confirmation`,
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
10
|
export const resolveOrderConfirmationTemplate = async ({ orderId, locale }, context) => {
|
|
32
11
|
const { modules } = context;
|
|
33
12
|
const order = await modules.orders.findOrder({ orderId });
|
|
34
13
|
if (order.status === 'PENDING') {
|
|
35
14
|
return [];
|
|
36
15
|
}
|
|
37
|
-
const
|
|
38
|
-
const fixedPrice = price / 100;
|
|
39
|
-
return `${order.currency} ${fixedPrice}`;
|
|
40
|
-
};
|
|
41
|
-
// TODO: If order.status is PENDING, we should only send the user
|
|
42
|
-
// a notice that we have received the order but not confirming it
|
|
43
|
-
const attachments = await getOrderAttachmentsData(order, { fileType: 'ORDER_CONFIRMATION' }, context);
|
|
44
|
-
const orderPricing = modules.orders.pricingSheet(order);
|
|
45
|
-
const { subject } = texts[locale.language];
|
|
16
|
+
const subject = `Order ${order.orderNumber}`;
|
|
46
17
|
const data = {
|
|
47
|
-
...texts[locale.language],
|
|
48
18
|
shopName: EMAIL_WEBSITE_NAME,
|
|
49
19
|
shopUrl: EMAIL_WEBSITE_URL,
|
|
50
|
-
|
|
51
|
-
url: `${EMAIL_WEBSITE_URL}/order?_id=${order._id}`,
|
|
52
|
-
summary: {
|
|
53
|
-
items: formatPrice(orderPricing.total({
|
|
54
|
-
category: OrderPricingRowCategory.Items,
|
|
55
|
-
useNetPrice: false,
|
|
56
|
-
}).amount),
|
|
57
|
-
taxes: formatPrice(orderPricing.total({
|
|
58
|
-
category: OrderPricingRowCategory.Taxes,
|
|
59
|
-
useNetPrice: false,
|
|
60
|
-
}).amount),
|
|
61
|
-
delivery: formatPrice(orderPricing.total({
|
|
62
|
-
category: OrderPricingRowCategory.Delivery,
|
|
63
|
-
useNetPrice: false,
|
|
64
|
-
}).amount),
|
|
65
|
-
payment: formatPrice(orderPricing.total({
|
|
66
|
-
category: OrderPricingRowCategory.Payment,
|
|
67
|
-
useNetPrice: false,
|
|
68
|
-
}).amount),
|
|
69
|
-
gross: formatPrice(orderPricing.total({ useNetPrice: false }).amount),
|
|
70
|
-
},
|
|
71
|
-
positions: getOrderPositionsData(order, { locale }, context),
|
|
20
|
+
orderDetails: await transformOrderToText({ order, locale }, context),
|
|
72
21
|
};
|
|
73
22
|
return [
|
|
74
23
|
{
|
|
75
24
|
type: 'EMAIL',
|
|
76
25
|
input: {
|
|
77
|
-
from: EMAIL_FROM || '
|
|
26
|
+
from: `${EMAIL_WEBSITE_NAME} <${EMAIL_FROM || 'noreply@unchained.local'}>`,
|
|
78
27
|
to: order.contact.emailAddress,
|
|
79
28
|
subject,
|
|
80
29
|
text: modules.messaging.renderToText(textTemplate, data),
|
|
81
|
-
attachments,
|
|
82
30
|
},
|
|
83
31
|
},
|
|
84
32
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveOrderConfirmationTemplate.js","sourceRoot":"","sources":["../../src/templates/resolveOrderConfirmationTemplate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"resolveOrderConfirmationTemplate.js","sourceRoot":"","sources":["../../src/templates/resolveOrderConfirmationTemplate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAE/D,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAE1E,MAAM,YAAY,GAAG;;;;;;CAMpB,CAAC;AAEF,MAAM,CAAC,MAAM,gCAAgC,GAAqB,KAAK,EACrE,EAAE,OAAO,EAAE,MAAM,EAAE,EACnB,OAAO,EACP,EAAE;IACF,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAC5B,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAE1D,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,EAAE;QAC9B,OAAO,EAAE,CAAC;KACX;IAED,MAAM,OAAO,GAAG,SAAS,KAAK,CAAC,WAAW,EAAE,CAAC;IAE7C,MAAM,IAAI,GAAG;QACX,QAAQ,EAAE,kBAAkB;QAC5B,OAAO,EAAE,iBAAiB;QAC1B,YAAY,EAAE,MAAM,oBAAoB,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC;KACrE,CAAC;IAEF,OAAO;QACL;YACE,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACL,IAAI,EAAE,GAAG,kBAAkB,KAAK,UAAU,IAAI,yBAAyB,GAAG;gBAC1E,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,YAAY;gBAC9B,OAAO;gBACP,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,YAAY,EAAE,IAAI,CAAC;aACzD;SACF;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,47 +1,33 @@
|
|
|
1
|
+
import { transformOrderToText } from './order-parser/index.js';
|
|
1
2
|
const { EMAIL_FROM, EMAIL_WEBSITE_NAME, EMAIL_WEBSITE_URL } = process.env;
|
|
2
3
|
const textTemplate = `
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
I'm sorry we can't confirm your order.
|
|
5
|
+
|
|
6
|
+
This can happen when the payment was not successful or the order was manually canceled because of product availability or fullfillment issues.
|
|
7
|
+
|
|
8
|
+
The order in question is:
|
|
9
|
+
|
|
10
|
+
{{orderDetails}}
|
|
11
|
+
|
|
12
|
+
{{shopName}}: {{shopUrl}}
|
|
10
13
|
`;
|
|
11
|
-
const texts = {
|
|
12
|
-
en: {
|
|
13
|
-
buttonText: 'Details are available at',
|
|
14
|
-
rejection: 'Your order was cancelled.',
|
|
15
|
-
subject: `${EMAIL_WEBSITE_NAME}: Order cancelled`,
|
|
16
|
-
},
|
|
17
|
-
de: {
|
|
18
|
-
buttonText: 'Details abrufen',
|
|
19
|
-
rejection: 'Deine Bestellung wurde storniert',
|
|
20
|
-
subject: `${EMAIL_WEBSITE_NAME}: Bestellung storniert`,
|
|
21
|
-
},
|
|
22
|
-
fr: {
|
|
23
|
-
buttonText: 'Details are available at',
|
|
24
|
-
rejection: 'Your order was cancelled.',
|
|
25
|
-
subject: `${EMAIL_WEBSITE_NAME}: Order cancelled`,
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
14
|
export const resolveOrderRejectionTemplate = async ({ orderId, locale }, context) => {
|
|
29
15
|
const { modules } = context;
|
|
30
16
|
const order = await modules.orders.findOrder({ orderId });
|
|
31
17
|
if (order.status !== 'REJECTED') {
|
|
32
18
|
return [];
|
|
33
19
|
}
|
|
34
|
-
const
|
|
20
|
+
const subject = `Order rejected ${order.orderNumber}`;
|
|
35
21
|
const data = {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
22
|
+
shopName: EMAIL_WEBSITE_NAME,
|
|
23
|
+
shopUrl: EMAIL_WEBSITE_URL,
|
|
24
|
+
orderDetails: await transformOrderToText({ order, locale }, context),
|
|
39
25
|
};
|
|
40
26
|
return [
|
|
41
27
|
{
|
|
42
28
|
type: 'EMAIL',
|
|
43
29
|
input: {
|
|
44
|
-
from: EMAIL_FROM || '
|
|
30
|
+
from: `${EMAIL_WEBSITE_NAME} <${EMAIL_FROM || 'noreply@unchained.local'}>`,
|
|
45
31
|
to: order.contact.emailAddress,
|
|
46
32
|
subject,
|
|
47
33
|
text: modules.messaging.renderToText(textTemplate, data),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveOrderRejectionTemplate.js","sourceRoot":"","sources":["../../src/templates/resolveOrderRejectionTemplate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolveOrderRejectionTemplate.js","sourceRoot":"","sources":["../../src/templates/resolveOrderRejectionTemplate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAE/D,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAE1E,MAAM,YAAY,GAAG;;;;;;;;;;CAUpB,CAAC;AAEF,MAAM,CAAC,MAAM,6BAA6B,GAAqB,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE;IACpG,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAC5B,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAE1D,IAAI,KAAK,CAAC,MAAM,KAAK,UAAU,EAAE;QAC/B,OAAO,EAAE,CAAC;KACX;IAED,MAAM,OAAO,GAAG,kBAAkB,KAAK,CAAC,WAAW,EAAE,CAAC;IAEtD,MAAM,IAAI,GAAG;QACX,QAAQ,EAAE,kBAAkB;QAC5B,OAAO,EAAE,iBAAiB;QAC1B,YAAY,EAAE,MAAM,oBAAoB,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC;KACrE,CAAC;IAEF,OAAO;QACL;YACE,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACL,IAAI,EAAE,GAAG,kBAAkB,KAAK,UAAU,IAAI,yBAAyB,GAAG;gBAC1E,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,YAAY;gBAC9B,OAAO;gBACP,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,YAAY,EAAE,IAAI,CAAC;aACzD;SACF;KACF,CAAC;AACJ,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/platform",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.10",
|
|
4
4
|
"main": "lib/platform-index.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./lib/platform-index.js",
|
|
@@ -31,22 +31,22 @@
|
|
|
31
31
|
},
|
|
32
32
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@unchainedshop/api": "^2.5.
|
|
35
|
-
"@unchainedshop/core": "^2.5.
|
|
36
|
-
"@unchainedshop/events": "^2.5.
|
|
37
|
-
"@unchainedshop/file-upload": "^2.5.
|
|
38
|
-
"@unchainedshop/logger": "^2.5.
|
|
39
|
-
"@unchainedshop/mongodb": "^2.5.
|
|
40
|
-
"@unchainedshop/plugins": "^2.5.
|
|
41
|
-
"@unchainedshop/roles": "^2.5.
|
|
42
|
-
"@unchainedshop/utils": "^2.5.
|
|
34
|
+
"@unchainedshop/api": "^2.5.10",
|
|
35
|
+
"@unchainedshop/core": "^2.5.10",
|
|
36
|
+
"@unchainedshop/events": "^2.5.10",
|
|
37
|
+
"@unchainedshop/file-upload": "^2.5.10",
|
|
38
|
+
"@unchainedshop/logger": "^2.5.10",
|
|
39
|
+
"@unchainedshop/mongodb": "^2.5.10",
|
|
40
|
+
"@unchainedshop/plugins": "^2.5.10",
|
|
41
|
+
"@unchainedshop/roles": "^2.5.10",
|
|
42
|
+
"@unchainedshop/utils": "^2.5.10",
|
|
43
43
|
"event-iterator": "^2.0.0",
|
|
44
44
|
"JSONStream": "^1.3.5",
|
|
45
45
|
"moniker": "0.1.2"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@types/node": "^
|
|
49
|
-
"@unchainedshop/types": "^2.5.
|
|
48
|
+
"@types/node": "^20.9.0",
|
|
49
|
+
"@unchainedshop/types": "^2.5.10",
|
|
50
50
|
"cross-env": "^7.0.3",
|
|
51
51
|
"jest": "^29.7.0",
|
|
52
52
|
"ts-jest": "^29.1.1",
|