@unchainedshop/platform 4.0.0-rc.9 → 4.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/lib/bulk-importer/createBulkImporter.d.ts +7 -8
- package/lib/bulk-importer/createBulkImporter.d.ts.map +1 -1
- package/lib/bulk-importer/createBulkImporter.js +15 -13
- package/lib/bulk-importer/createBulkImporter.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/create.d.ts +1 -1
- package/lib/bulk-importer/handlers/assortment/create.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/assortment/create.js +7 -9
- package/lib/bulk-importer/handlers/assortment/create.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/remove.d.ts +1 -1
- package/lib/bulk-importer/handlers/assortment/remove.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/assortment/update.d.ts +1 -1
- package/lib/bulk-importer/handlers/assortment/update.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/assortment/update.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.d.ts +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.d.ts +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.d.ts +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertMedia.d.ts +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertMedia.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/filter/create.d.ts +1 -1
- package/lib/bulk-importer/handlers/filter/create.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/filter/create.js +8 -12
- package/lib/bulk-importer/handlers/filter/create.js.map +1 -1
- package/lib/bulk-importer/handlers/filter/remove.d.ts +1 -1
- package/lib/bulk-importer/handlers/filter/remove.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/filter/update.d.ts +1 -1
- package/lib/bulk-importer/handlers/filter/update.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/filter/update.js +7 -11
- package/lib/bulk-importer/handlers/filter/update.js.map +1 -1
- package/lib/bulk-importer/handlers/product/create.d.ts +1 -1
- package/lib/bulk-importer/handlers/product/create.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/product/create.js +7 -9
- package/lib/bulk-importer/handlers/product/create.js.map +1 -1
- package/lib/bulk-importer/handlers/product/remove.d.ts +1 -1
- package/lib/bulk-importer/handlers/product/remove.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/product/remove.js +1 -1
- package/lib/bulk-importer/handlers/product/remove.js.map +1 -1
- package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/product/update.d.ts +1 -1
- package/lib/bulk-importer/handlers/product/update.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/product/upsertMedia.d.ts +1 -1
- package/lib/bulk-importer/handlers/product/upsertMedia.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/product/upsertVariations.d.ts +1 -1
- package/lib/bulk-importer/handlers/product/upsertVariations.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/product/upsertVariations.js +11 -17
- package/lib/bulk-importer/handlers/product/upsertVariations.js.map +1 -1
- package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.d.ts.map +1 -1
- package/lib/bulk-importer/upsertAsset.d.ts +2 -2
- package/lib/bulk-importer/upsertAsset.d.ts.map +1 -1
- package/lib/bulk-importer/upsertAsset.js +1 -1
- package/lib/bulk-importer/upsertAsset.js.map +1 -1
- package/lib/context/withAccessToken.d.ts +4 -0
- package/lib/context/withAccessToken.d.ts.map +1 -0
- package/lib/context/withAccessToken.js +42 -0
- package/lib/context/withAccessToken.js.map +1 -0
- package/lib/migrations/createMigrationRunner.d.ts +1 -1
- package/lib/migrations/migrationRepository.d.ts.map +1 -1
- package/lib/migrations/migrationRepository.js +3 -0
- package/lib/migrations/migrationRepository.js.map +1 -1
- package/lib/migrations/runMigrations.d.ts.map +1 -1
- package/lib/migrations/runMigrations.js.map +1 -1
- package/lib/platform-index.d.ts +1 -1
- package/lib/platform-index.d.ts.map +1 -1
- package/lib/platform-index.js +1 -1
- package/lib/platform-index.js.map +1 -1
- package/lib/setup/setupAccounts.d.ts.map +1 -1
- package/lib/setup/setupAccounts.js +3 -8
- package/lib/setup/setupAccounts.js.map +1 -1
- package/lib/setup/setupCarts.d.ts +8 -0
- package/lib/setup/setupCarts.d.ts.map +1 -0
- package/lib/setup/setupCarts.js +17 -0
- package/lib/setup/setupCarts.js.map +1 -0
- package/lib/setup/setupTemplates.d.ts.map +1 -1
- package/lib/setup/setupTemplates.js +9 -24
- package/lib/setup/setupTemplates.js.map +1 -1
- package/lib/setup/setupUploadHandlers.js +1 -1
- package/lib/setup/setupUploadHandlers.js.map +1 -1
- package/lib/setup/setupWorkqueue.d.ts.map +1 -1
- package/lib/setup/setupWorkqueue.js +2 -0
- package/lib/setup/setupWorkqueue.js.map +1 -1
- package/lib/startPlatform.d.ts +2 -6
- package/lib/startPlatform.d.ts.map +1 -1
- package/lib/startPlatform.js +3 -5
- package/lib/startPlatform.js.map +1 -1
- package/lib/templates/order-parser/formatAddress.d.ts +3 -0
- package/lib/templates/order-parser/formatAddress.d.ts.map +1 -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 +6 -0
- package/lib/templates/order-parser/formatPrice.d.ts.map +1 -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 +1 -1
- package/lib/templates/order-parser/getOrderSummaryData.d.ts +2 -2
- package/lib/templates/order-parser/getOrderSummaryData.d.ts.map +1 -1
- package/lib/templates/order-parser/getOrderSummaryData.js +14 -8
- package/lib/templates/order-parser/getOrderSummaryData.js.map +1 -1
- package/lib/templates/order-parser/index.d.ts.map +1 -1
- package/lib/templates/order-parser/index.js +50 -36
- package/lib/templates/order-parser/index.js.map +1 -1
- package/lib/templates/resolveAccountActionTemplate.d.ts.map +1 -1
- package/lib/templates/resolveAccountActionTemplate.js +13 -13
- package/lib/templates/resolveAccountActionTemplate.js.map +1 -1
- package/lib/templates/resolveEnrollmentStatusTemplate.d.ts.map +1 -1
- package/lib/templates/resolveEnrollmentStatusTemplate.js +10 -16
- package/lib/templates/resolveEnrollmentStatusTemplate.js.map +1 -1
- package/lib/templates/resolveErrorReportTemplate.d.ts.map +1 -1
- package/lib/templates/resolveErrorReportTemplate.js +6 -11
- package/lib/templates/resolveErrorReportTemplate.js.map +1 -1
- package/lib/templates/resolveForwardDeliveryTemplate.d.ts.map +1 -1
- package/lib/templates/resolveForwardDeliveryTemplate.js +8 -13
- package/lib/templates/resolveForwardDeliveryTemplate.js.map +1 -1
- package/lib/templates/resolveOrderConfirmationTemplate.d.ts.map +1 -1
- package/lib/templates/resolveOrderConfirmationTemplate.js +8 -13
- package/lib/templates/resolveOrderConfirmationTemplate.js.map +1 -1
- package/lib/templates/resolveOrderRejectionTemplate.d.ts.map +1 -1
- package/lib/templates/resolveOrderRejectionTemplate.js +11 -16
- package/lib/templates/resolveOrderRejectionTemplate.js.map +1 -1
- package/lib/templates/resolveQuotationStatusTemplate.d.ts.map +1 -1
- package/lib/templates/resolveQuotationStatusTemplate.js +11 -17
- package/lib/templates/resolveQuotationStatusTemplate.js.map +1 -1
- package/package.json +10 -12
- package/src/migrations/migrationRepository.ts +5 -0
- package/src/migrations/runMigrations.ts +6 -1
- package/src/platform-index.ts +1 -1
- package/src/setup/setupAccounts.ts +3 -8
- package/src/setup/setupTemplates.ts +9 -24
- package/src/setup/setupUploadHandlers.ts +1 -1
- package/src/setup/setupWorkqueue.ts +1 -0
- package/src/startPlatform.ts +5 -10
- package/src/templates/order-parser/getOrderSummaryData.ts +18 -8
- package/src/templates/order-parser/index.ts +53 -43
- package/src/templates/resolveAccountActionTemplate.ts +25 -21
- package/src/templates/resolveEnrollmentStatusTemplate.ts +12 -26
- package/src/templates/resolveErrorReportTemplate.ts +7 -17
- package/src/templates/resolveForwardDeliveryTemplate.ts +9 -19
- package/src/templates/resolveOrderConfirmationTemplate.ts +9 -19
- package/src/templates/resolveOrderRejectionTemplate.ts +13 -23
- package/src/templates/resolveQuotationStatusTemplate.ts +11 -26
- package/src/bulk-importer/createBulkImporter.ts +0 -134
- package/src/bulk-importer/handlers/assortment/create.ts +0 -86
- package/src/bulk-importer/handlers/assortment/index.ts +0 -3
- package/src/bulk-importer/handlers/assortment/remove.ts +0 -15
- package/src/bulk-importer/handlers/assortment/update.ts +0 -88
- package/src/bulk-importer/handlers/assortment/upsertAssortmentChildren.ts +0 -49
- package/src/bulk-importer/handlers/assortment/upsertAssortmentFilters.ts +0 -42
- package/src/bulk-importer/handlers/assortment/upsertAssortmentProducts.ts +0 -50
- package/src/bulk-importer/handlers/assortment/upsertMedia.ts +0 -54
- package/src/bulk-importer/handlers/filter/create.ts +0 -76
- package/src/bulk-importer/handlers/filter/index.ts +0 -3
- package/src/bulk-importer/handlers/filter/remove.ts +0 -16
- package/src/bulk-importer/handlers/filter/update.ts +0 -67
- package/src/bulk-importer/handlers/product/create.ts +0 -69
- package/src/bulk-importer/handlers/product/index.ts +0 -3
- package/src/bulk-importer/handlers/product/remove.ts +0 -16
- package/src/bulk-importer/handlers/product/transformSpecificationToProductStructure.ts +0 -22
- package/src/bulk-importer/handlers/product/update.ts +0 -65
- package/src/bulk-importer/handlers/product/upsertMedia.ts +0 -60
- package/src/bulk-importer/handlers/product/upsertVariations.ts +0 -68
- package/src/bulk-importer/handlers/utils/convertTagsToLowerCase.ts +0 -4
- package/src/bulk-importer/upsertAsset.ts +0 -41
|
@@ -36,14 +36,9 @@ export const setupTemplates = (unchainedAPI: UnchainedCore) => {
|
|
|
36
36
|
|
|
37
37
|
if (order.status === OrderStatus.PENDING) {
|
|
38
38
|
// We only send the "confirmation" when pending, else we let the other events handle it
|
|
39
|
-
await unchainedAPI.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
input: {
|
|
43
|
-
locale: locale.baseName,
|
|
44
|
-
template: MessageTypes.ORDER_CONFIRMATION,
|
|
45
|
-
orderId: order._id,
|
|
46
|
-
},
|
|
39
|
+
await unchainedAPI.services.worker.addMessage(MessageTypes.ORDER_CONFIRMATION, {
|
|
40
|
+
locale: locale.baseName,
|
|
41
|
+
orderId: order._id,
|
|
47
42
|
});
|
|
48
43
|
}
|
|
49
44
|
});
|
|
@@ -53,14 +48,9 @@ export const setupTemplates = (unchainedAPI: UnchainedCore) => {
|
|
|
53
48
|
const user = await unchainedAPI.modules.users.findUserById(order.userId);
|
|
54
49
|
const locale = unchainedAPI.modules.users.userLocale(user);
|
|
55
50
|
|
|
56
|
-
await unchainedAPI.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
input: {
|
|
60
|
-
locale: locale.baseName,
|
|
61
|
-
template: MessageTypes.ORDER_CONFIRMATION,
|
|
62
|
-
orderId: order._id,
|
|
63
|
-
},
|
|
51
|
+
await unchainedAPI.services.worker.addMessage(MessageTypes.ORDER_CONFIRMATION, {
|
|
52
|
+
locale: locale.baseName,
|
|
53
|
+
orderId: order._id,
|
|
64
54
|
});
|
|
65
55
|
});
|
|
66
56
|
|
|
@@ -69,14 +59,9 @@ export const setupTemplates = (unchainedAPI: UnchainedCore) => {
|
|
|
69
59
|
const user = await unchainedAPI.modules.users.findUserById(order.userId);
|
|
70
60
|
const locale = unchainedAPI.modules.users.userLocale(user);
|
|
71
61
|
|
|
72
|
-
await unchainedAPI.
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
input: {
|
|
76
|
-
locale: locale.baseName,
|
|
77
|
-
template: MessageTypes.ORDER_REJECTION,
|
|
78
|
-
orderId: order._id,
|
|
79
|
-
},
|
|
62
|
+
await unchainedAPI.services.worker.addMessage(MessageTypes.ORDER_REJECTION, {
|
|
63
|
+
locale: locale.baseName,
|
|
64
|
+
orderId: order._id,
|
|
80
65
|
});
|
|
81
66
|
});
|
|
82
67
|
};
|
|
@@ -15,7 +15,7 @@ export const setupUploadHandlers = ({ services, modules }: UnchainedCore) => {
|
|
|
15
15
|
|
|
16
16
|
FileDirector.registerFileUploadCallback('assortment-media', async (file) => {
|
|
17
17
|
await modules.assortments.media.create({
|
|
18
|
-
assortmentId: file.meta
|
|
18
|
+
assortmentId: file.meta?.assortmentId as string,
|
|
19
19
|
mediaId: file._id,
|
|
20
20
|
});
|
|
21
21
|
});
|
|
@@ -75,6 +75,7 @@ export async function setupWorkqueue({
|
|
|
75
75
|
await Promise.all(
|
|
76
76
|
users.map((user) => {
|
|
77
77
|
const locale = unchainedAPI.modules.users.userLocale(user);
|
|
78
|
+
if (!locale.region) return null;
|
|
78
79
|
return unchainedAPI.services.orders.nextUserCart({
|
|
79
80
|
user,
|
|
80
81
|
countryCode: locale.region,
|
package/src/startPlatform.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { initCore, UnchainedCoreOptions } from '@unchainedshop/core';
|
|
|
3
3
|
import { initDb, mongodb, stopDb } from '@unchainedshop/mongodb';
|
|
4
4
|
import { defaultLogger } from '@unchainedshop/logger';
|
|
5
5
|
import { UnchainedCore } from '@unchainedshop/core';
|
|
6
|
-
import { BulkImportHandler, createBulkImporterFactory } from './bulk-importer/createBulkImporter.js';
|
|
7
6
|
import { setupAccounts } from './setup/setupAccounts.js';
|
|
8
7
|
import { setupUploadHandlers } from './setup/setupUploadHandlers.js';
|
|
9
8
|
import { setupTemplates, MessageTypes } from './setup/setupTemplates.js';
|
|
@@ -14,12 +13,9 @@ import { IRoleOptionConfig } from '@unchainedshop/roles';
|
|
|
14
13
|
export { MessageTypes };
|
|
15
14
|
|
|
16
15
|
export type PlatformOptions = {
|
|
17
|
-
bulkImporter?: {
|
|
18
|
-
handlers?: Record<string, BulkImportHandler>;
|
|
19
|
-
};
|
|
20
16
|
rolesOptions?: IRoleOptionConfig;
|
|
21
17
|
workQueueOptions?: SetupWorkqueueOptions;
|
|
22
|
-
} & Omit<UnchainedCoreOptions, '
|
|
18
|
+
} & Omit<UnchainedCoreOptions, 'migrationRepository' | 'db'> &
|
|
23
19
|
Omit<UnchainedServerOptions, 'roles' | 'unchainedAPI'>;
|
|
24
20
|
|
|
25
21
|
const REQUIRED_ENV_VARIABLES = [
|
|
@@ -51,8 +47,8 @@ export const startPlatform = async ({
|
|
|
51
47
|
modules,
|
|
52
48
|
services,
|
|
53
49
|
options,
|
|
54
|
-
rolesOptions
|
|
55
|
-
bulkImporter
|
|
50
|
+
rolesOptions,
|
|
51
|
+
bulkImporter,
|
|
56
52
|
workQueueOptions,
|
|
57
53
|
...arbitraryAPIServerConfiguration
|
|
58
54
|
}: PlatformOptions): Promise<{
|
|
@@ -63,14 +59,13 @@ export const startPlatform = async ({
|
|
|
63
59
|
exitOnMissingEnvironmentVariables();
|
|
64
60
|
existOnInvalidEnvironmentVariables();
|
|
65
61
|
|
|
66
|
-
const configuredRoles = roles.configureRoles(rolesOptions);
|
|
62
|
+
const configuredRoles = roles.configureRoles(rolesOptions || {});
|
|
67
63
|
|
|
68
64
|
// Configure database
|
|
69
65
|
const db = await initDb();
|
|
70
66
|
|
|
71
67
|
// Prepare Migrations
|
|
72
68
|
const migrationRepository = createMigrationRepository(db);
|
|
73
|
-
const bulkImporter = createBulkImporterFactory(db, bulkImporterOptions);
|
|
74
69
|
|
|
75
70
|
// Initialise core api using the database
|
|
76
71
|
const unchainedAPI = await initCore({
|
|
@@ -117,7 +112,7 @@ export const startPlatform = async ({
|
|
|
117
112
|
await graphqlHandler.dispose();
|
|
118
113
|
defaultLogger.debug('Stopping DB Connection', { signal });
|
|
119
114
|
await stopDb();
|
|
120
|
-
defaultLogger.
|
|
115
|
+
defaultLogger.debug(`Unchained Engine exiting`, { signal, version: packageJson.version });
|
|
121
116
|
process.exit(0);
|
|
122
117
|
};
|
|
123
118
|
|
|
@@ -11,12 +11,22 @@ export const getOrderSummaryData = async (
|
|
|
11
11
|
) => {
|
|
12
12
|
const { modules } = context;
|
|
13
13
|
const { useNetPrice, format = ch.priceToString } = params || {};
|
|
14
|
-
const orderDelivery =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
const orderDelivery =
|
|
15
|
+
order.deliveryId &&
|
|
16
|
+
(await modules.orders.deliveries.findDelivery({
|
|
17
|
+
orderDeliveryId: order.deliveryId,
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
if (!orderDelivery) throw new Error('Order delivery not found');
|
|
21
|
+
|
|
22
|
+
const orderPayment =
|
|
23
|
+
order.paymentId &&
|
|
24
|
+
(await modules.orders.payments.findOrderPayment({
|
|
25
|
+
orderPaymentId: order.paymentId,
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
if (!orderPayment) throw new Error('Order payment not found');
|
|
29
|
+
|
|
20
30
|
const paymentProvider = await modules.payment.paymentProviders.findProvider({
|
|
21
31
|
paymentProviderId: orderPayment.paymentProviderId,
|
|
22
32
|
});
|
|
@@ -55,8 +65,8 @@ export const getOrderSummaryData = async (
|
|
|
55
65
|
|
|
56
66
|
const total = orderPricing.total({ useNetPrice });
|
|
57
67
|
|
|
58
|
-
const payment = paymentProvider
|
|
59
|
-
const delivery = deliveryProvider
|
|
68
|
+
const payment = paymentProvider?.adapterKey;
|
|
69
|
+
const delivery = deliveryProvider?.adapterKey;
|
|
60
70
|
|
|
61
71
|
return {
|
|
62
72
|
rawPrices: {
|
|
@@ -3,53 +3,63 @@ import { getOrderSummaryData } from './getOrderSummaryData.js';
|
|
|
3
3
|
import { Order } from '@unchainedshop/core-orders';
|
|
4
4
|
import { UnchainedCore } from '@unchainedshop/core';
|
|
5
5
|
|
|
6
|
-
import mustache from 'mustache';
|
|
7
|
-
|
|
8
|
-
const textTemplate = `Order number: {{orderNumber}}
|
|
9
|
-
Ordered: {{orderDate}}
|
|
10
|
-
Payment method: {{summary.payment}}
|
|
11
|
-
Delivery method: {{summary.delivery}}
|
|
12
|
-
|
|
13
|
-
Delivery address:
|
|
14
|
-
{{summary.deliveryAddress}}
|
|
15
|
-
|
|
16
|
-
Billing address:
|
|
17
|
-
{{summary.billingAddress}}
|
|
18
|
-
|
|
19
|
-
Order Details:
|
|
20
|
-
|
|
21
|
-
Items:
|
|
22
|
-
{{#positions}}
|
|
23
|
-
* {{quantity}} {{productTexts.title}}: {{total}}
|
|
24
|
-
{{/positions}}
|
|
25
|
-
|
|
26
|
-
{{#summary.rawPrices.delivery.amount}}
|
|
27
|
-
Delivery Fees: {{summary.prices.delivery}}
|
|
28
|
-
{{/summary.rawPrices.delivery.amount}}
|
|
29
|
-
{{#summary.rawPrices.payment.amount}}
|
|
30
|
-
Payment Fees: {{summary.prices.payment}}
|
|
31
|
-
{{/summary.rawPrices.payment.amount}}
|
|
32
|
-
Total: {{summary.prices.gross}}
|
|
33
|
-
{{#summary.rawPrices.taxes.amount}}
|
|
34
|
-
(VAT included: {{summary.prices.taxes}})
|
|
35
|
-
{{/summary.rawPrices.taxes.amount}}
|
|
36
|
-
`;
|
|
37
|
-
|
|
38
6
|
export const transformOrderToText = async (
|
|
39
7
|
{ order, locale }: { order: Order; locale: Intl.Locale },
|
|
40
8
|
context: UnchainedCore,
|
|
41
9
|
) => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
10
|
+
const orderDate = new Date(order.ordered!).toLocaleString();
|
|
11
|
+
const orderNumber = order.orderNumber;
|
|
12
|
+
const summary = await getOrderSummaryData(order, { locale }, context);
|
|
13
|
+
const positions = await getOrderPositionsData(order, { locale }, context);
|
|
14
|
+
|
|
15
|
+
const positionsText = positions
|
|
16
|
+
.map((pos) => ` ${pos.quantity}x ${pos.productTexts.title} ${pos.total}`)
|
|
17
|
+
.join('\n');
|
|
18
|
+
|
|
19
|
+
const subtotalText = summary.rawPrices.items.amount ? ` Subtotal ${summary.prices.items}\n` : '';
|
|
20
|
+
const deliveryFeesText = summary.rawPrices.delivery.amount
|
|
21
|
+
? ` Delivery ${summary.prices.delivery}\n`
|
|
22
|
+
: '';
|
|
23
|
+
const paymentFeesText = summary.rawPrices.payment.amount
|
|
24
|
+
? ` Payment ${summary.prices.payment}\n`
|
|
25
|
+
: '';
|
|
26
|
+
const totalLine = ` ${'─'.repeat(50)}\n Order Total ${summary.prices.gross}`;
|
|
27
|
+
const taxesText = summary.rawPrices.taxes.amount ? `\n (incl. VAT ${summary.prices.taxes})` : '';
|
|
28
|
+
|
|
29
|
+
return `═════════════════════════════════════════════════════
|
|
30
|
+
ORDER CONFIRMATION
|
|
31
|
+
═════════════════════════════════════════════════════
|
|
32
|
+
|
|
33
|
+
Order Number: ${orderNumber}
|
|
34
|
+
Order Date: ${orderDate}
|
|
35
|
+
|
|
36
|
+
─────────────────────────────────────────────────────
|
|
37
|
+
DELIVERY INFORMATION
|
|
38
|
+
─────────────────────────────────────────────────────
|
|
39
|
+
|
|
40
|
+
Delivery Method: ${summary.delivery}
|
|
41
|
+
|
|
42
|
+
Delivery Address:
|
|
43
|
+
${summary.deliveryAddress}
|
|
44
|
+
|
|
45
|
+
─────────────────────────────────────────────────────
|
|
46
|
+
PAYMENT INFORMATION
|
|
47
|
+
─────────────────────────────────────────────────────
|
|
48
|
+
|
|
49
|
+
Payment Method: ${summary.payment}
|
|
50
|
+
|
|
51
|
+
Billing Address:
|
|
52
|
+
${summary.billingAddress}
|
|
53
|
+
|
|
54
|
+
─────────────────────────────────────────────────────
|
|
55
|
+
ORDER DETAILS
|
|
56
|
+
─────────────────────────────────────────────────────
|
|
57
|
+
|
|
58
|
+
${positionsText}
|
|
59
|
+
|
|
60
|
+
${subtotalText}${deliveryFeesText}${paymentFeesText}${totalLine}${taxesText}
|
|
61
|
+
═════════════════════════════════════════════════════
|
|
62
|
+
`;
|
|
53
63
|
};
|
|
54
64
|
|
|
55
65
|
export { getOrderPositionsData, getOrderSummaryData };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { TemplateResolver } from '@unchainedshop/core';
|
|
2
|
-
import mustache from 'mustache';
|
|
3
2
|
|
|
4
3
|
const { EMAIL_FROM, EMAIL_WEBSITE_URL, EMAIL_WEBSITE_NAME } = process.env;
|
|
5
4
|
|
|
@@ -16,15 +15,26 @@ const passwordChangedEmailEnglishConfig = {
|
|
|
16
15
|
subject: `${EMAIL_WEBSITE_NAME}: Your password has been changed`,
|
|
17
16
|
};
|
|
18
17
|
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
const buildTextTemplate = ({
|
|
19
|
+
message,
|
|
20
|
+
buttonText,
|
|
21
|
+
url,
|
|
22
|
+
}: {
|
|
23
|
+
message: string;
|
|
24
|
+
buttonText: string;
|
|
25
|
+
url: string | null;
|
|
26
|
+
}) => {
|
|
27
|
+
const urlSection = url
|
|
28
|
+
? `
|
|
29
|
+
|
|
30
|
+
-----------------
|
|
31
|
+
${buttonText}: ${url}
|
|
32
|
+
-----------------
|
|
33
|
+
`
|
|
34
|
+
: '';
|
|
35
|
+
|
|
36
|
+
return ` ${message}${urlSection}`;
|
|
37
|
+
};
|
|
28
38
|
|
|
29
39
|
const emailConfig = {
|
|
30
40
|
'enroll-account': {
|
|
@@ -97,17 +107,11 @@ export const resolveAccountActionTemplate: TemplateResolver = async (
|
|
|
97
107
|
const { url } = emailConfig[action];
|
|
98
108
|
const { subject, message, buttonText } = emailConfig[action][locale.language];
|
|
99
109
|
|
|
100
|
-
const text =
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
subject,
|
|
106
|
-
url: url(token),
|
|
107
|
-
},
|
|
108
|
-
undefined,
|
|
109
|
-
{ escape: (t) => t },
|
|
110
|
-
);
|
|
110
|
+
const text = buildTextTemplate({
|
|
111
|
+
buttonText,
|
|
112
|
+
message,
|
|
113
|
+
url: url(token),
|
|
114
|
+
});
|
|
111
115
|
|
|
112
116
|
return [
|
|
113
117
|
{
|
|
@@ -1,38 +1,24 @@
|
|
|
1
1
|
import { TemplateResolver } from '@unchainedshop/core';
|
|
2
|
-
import mustache from 'mustache';
|
|
3
|
-
const { EMAIL_FROM, EMAIL_WEBSITE_NAME, EMAIL_WEBSITE_URL } = process.env;
|
|
4
2
|
|
|
5
|
-
const
|
|
6
|
-
{{subject}}\n
|
|
7
|
-
\n
|
|
8
|
-
Status: {{enrollment.status}}
|
|
9
|
-
\n
|
|
10
|
-
-----------------\n
|
|
11
|
-
Show: {{url}}\n
|
|
12
|
-
-----------------\n
|
|
13
|
-
`;
|
|
3
|
+
const { EMAIL_FROM, EMAIL_WEBSITE_NAME, EMAIL_WEBSITE_URL } = process.env;
|
|
14
4
|
|
|
15
|
-
export const resolveEnrollmentStatusTemplate: TemplateResolver = async (
|
|
16
|
-
{ enrollmentId, locale },
|
|
17
|
-
context,
|
|
18
|
-
) => {
|
|
5
|
+
export const resolveEnrollmentStatusTemplate: TemplateResolver = async ({ enrollmentId }, context) => {
|
|
19
6
|
const { modules } = context;
|
|
20
7
|
const enrollment = await modules.enrollments.findEnrollment({ enrollmentId });
|
|
21
8
|
const user = await modules.users.findUserById(enrollment.userId);
|
|
22
9
|
|
|
23
10
|
const subject = `${EMAIL_WEBSITE_NAME}: Updated Enrollment / ${enrollment.enrollmentNumber}`;
|
|
11
|
+
const url = `${EMAIL_WEBSITE_URL}/enrollment?_id=${enrollment._id}`;
|
|
24
12
|
|
|
25
|
-
const text =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
{ escape: (t) => t },
|
|
35
|
-
);
|
|
13
|
+
const text = `
|
|
14
|
+
${subject}\n
|
|
15
|
+
\n
|
|
16
|
+
Status: ${enrollment.status}
|
|
17
|
+
\n
|
|
18
|
+
-----------------\n
|
|
19
|
+
Show: ${url}\n
|
|
20
|
+
-----------------\n
|
|
21
|
+
`;
|
|
36
22
|
|
|
37
23
|
return [
|
|
38
24
|
{
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { TemplateResolver } from '@unchainedshop/core';
|
|
2
2
|
import { stringify } from 'safe-stable-stringify';
|
|
3
|
-
import mustache from 'mustache';
|
|
4
3
|
|
|
5
4
|
const {
|
|
6
5
|
EMAIL_FROM = 'noreply@unchained.local',
|
|
@@ -18,27 +17,18 @@ const formatWorkItems = (workItems) => {
|
|
|
18
17
|
.join('\n');
|
|
19
18
|
};
|
|
20
19
|
|
|
21
|
-
const
|
|
20
|
+
const resolveErrorReportTemplate: TemplateResolver = async ({ workItems }) => {
|
|
21
|
+
const content = formatWorkItems(workItems);
|
|
22
|
+
|
|
23
|
+
const text = `
|
|
22
24
|
-------------------------
|
|
23
|
-
Unchained Endpoint: {
|
|
24
|
-
Shop Name: {
|
|
25
|
+
Unchained Endpoint: ${ROOT_URL}
|
|
26
|
+
Shop Name: ${EMAIL_WEBSITE_NAME}
|
|
25
27
|
-------------------------
|
|
26
28
|
|
|
27
|
-
{
|
|
29
|
+
${content}
|
|
28
30
|
`;
|
|
29
31
|
|
|
30
|
-
const resolveErrorReportTemplate: TemplateResolver = async ({ workItems }) => {
|
|
31
|
-
const text = mustache.render(
|
|
32
|
-
textTemplate,
|
|
33
|
-
{
|
|
34
|
-
endpoint: ROOT_URL,
|
|
35
|
-
content: formatWorkItems(workItems),
|
|
36
|
-
name: EMAIL_WEBSITE_NAME,
|
|
37
|
-
},
|
|
38
|
-
undefined,
|
|
39
|
-
{ escape: (t) => t },
|
|
40
|
-
);
|
|
41
|
-
|
|
42
32
|
return [
|
|
43
33
|
{
|
|
44
34
|
type: 'EMAIL',
|
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
import { TemplateResolver } from '@unchainedshop/core';
|
|
2
2
|
import { systemLocale } from '@unchainedshop/utils';
|
|
3
3
|
import { transformOrderToText } from './order-parser/index.js';
|
|
4
|
-
import mustache from 'mustache';
|
|
5
4
|
|
|
6
5
|
const { EMAIL_FROM, EMAIL_WEBSITE_NAME, EMAIL_WEBSITE_URL } = process.env;
|
|
7
6
|
|
|
8
|
-
const textTemplate = `
|
|
9
|
-
New Order received:
|
|
10
|
-
|
|
11
|
-
{{orderDetails}}
|
|
12
|
-
|
|
13
|
-
{{shopName}}: {{shopUrl}}
|
|
14
|
-
`;
|
|
15
|
-
|
|
16
7
|
export const resolveForwardDeliveryTemplate: TemplateResolver = async ({ config, orderId }, context) => {
|
|
17
8
|
const { modules } = context;
|
|
18
9
|
const order = await modules.orders.findOrder({ orderId });
|
|
@@ -26,16 +17,15 @@ export const resolveForwardDeliveryTemplate: TemplateResolver = async ({ config,
|
|
|
26
17
|
|
|
27
18
|
const subject = `${EMAIL_WEBSITE_NAME} Order ${order.orderNumber}`;
|
|
28
19
|
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
);
|
|
20
|
+
const orderDetails = await transformOrderToText({ order, locale: systemLocale }, context);
|
|
21
|
+
|
|
22
|
+
const text = `
|
|
23
|
+
New Order received:
|
|
24
|
+
|
|
25
|
+
${orderDetails}
|
|
26
|
+
|
|
27
|
+
${EMAIL_WEBSITE_NAME}: ${EMAIL_WEBSITE_URL}
|
|
28
|
+
`;
|
|
39
29
|
|
|
40
30
|
return [
|
|
41
31
|
{
|
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
import { TemplateResolver } from '@unchainedshop/core';
|
|
2
2
|
import { transformOrderToText } from './order-parser/index.js';
|
|
3
|
-
import mustache from 'mustache';
|
|
4
3
|
|
|
5
4
|
const { EMAIL_FROM, EMAIL_WEBSITE_NAME, EMAIL_WEBSITE_URL } = process.env;
|
|
6
5
|
|
|
7
|
-
const textTemplate = `
|
|
8
|
-
Thank you very much for your order.
|
|
9
|
-
|
|
10
|
-
{{orderDetails}}
|
|
11
|
-
|
|
12
|
-
{{shopName}}: {{shopUrl}}
|
|
13
|
-
`;
|
|
14
|
-
|
|
15
6
|
export const resolveOrderConfirmationTemplate: TemplateResolver<{
|
|
16
7
|
orderId: string;
|
|
17
8
|
locale: string;
|
|
@@ -25,16 +16,15 @@ export const resolveOrderConfirmationTemplate: TemplateResolver<{
|
|
|
25
16
|
|
|
26
17
|
const subject = `Order ${order.orderNumber}`;
|
|
27
18
|
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
);
|
|
19
|
+
const orderDetails = await transformOrderToText({ order, locale: new Intl.Locale(locale) }, context);
|
|
20
|
+
|
|
21
|
+
const text = `
|
|
22
|
+
Thank you very much for your order.
|
|
23
|
+
|
|
24
|
+
${orderDetails}
|
|
25
|
+
|
|
26
|
+
${EMAIL_WEBSITE_NAME}: ${EMAIL_WEBSITE_URL}
|
|
27
|
+
`;
|
|
38
28
|
|
|
39
29
|
return [
|
|
40
30
|
{
|
|
@@ -1,21 +1,8 @@
|
|
|
1
1
|
import { TemplateResolver } from '@unchainedshop/core';
|
|
2
2
|
import { transformOrderToText } from './order-parser/index.js';
|
|
3
|
-
import mustache from 'mustache';
|
|
4
3
|
|
|
5
4
|
const { EMAIL_FROM, EMAIL_WEBSITE_NAME, EMAIL_WEBSITE_URL } = process.env;
|
|
6
5
|
|
|
7
|
-
const textTemplate = `
|
|
8
|
-
I'm sorry we can't confirm your order.
|
|
9
|
-
|
|
10
|
-
This can happen when the payment was not successful or the order was manually canceled because of product availability or fullfillment issues.
|
|
11
|
-
|
|
12
|
-
The order in question is:
|
|
13
|
-
|
|
14
|
-
{{orderDetails}}
|
|
15
|
-
|
|
16
|
-
{{shopName}}: {{shopUrl}}
|
|
17
|
-
`;
|
|
18
|
-
|
|
19
6
|
export const resolveOrderRejectionTemplate: TemplateResolver = async ({ orderId, locale }, context) => {
|
|
20
7
|
const { modules } = context;
|
|
21
8
|
const order = await modules.orders.findOrder({ orderId });
|
|
@@ -26,16 +13,19 @@ export const resolveOrderRejectionTemplate: TemplateResolver = async ({ orderId,
|
|
|
26
13
|
|
|
27
14
|
const subject = `Order rejected ${order.orderNumber}`;
|
|
28
15
|
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
16
|
+
const orderDetails = await transformOrderToText({ order, locale: new Intl.Locale(locale) }, context);
|
|
17
|
+
|
|
18
|
+
const text = `
|
|
19
|
+
I'm sorry we can't confirm your order.
|
|
20
|
+
|
|
21
|
+
This can happen when the payment was not successful or the order was manually canceled because of product availability or fullfillment issues.
|
|
22
|
+
|
|
23
|
+
The order in question is:
|
|
24
|
+
|
|
25
|
+
${orderDetails}
|
|
26
|
+
|
|
27
|
+
${EMAIL_WEBSITE_NAME}: ${EMAIL_WEBSITE_URL}
|
|
28
|
+
`;
|
|
39
29
|
|
|
40
30
|
return [
|
|
41
31
|
{
|
|
@@ -1,22 +1,8 @@
|
|
|
1
1
|
import { TemplateResolver } from '@unchainedshop/core';
|
|
2
|
-
import mustache from 'mustache';
|
|
3
2
|
|
|
4
3
|
const { EMAIL_FROM, EMAIL_WEBSITE_NAME, EMAIL_WEBSITE_URL } = process.env;
|
|
5
4
|
|
|
6
|
-
const
|
|
7
|
-
{{subject}}\n
|
|
8
|
-
\n
|
|
9
|
-
Status: {{quotation.status}}
|
|
10
|
-
\n
|
|
11
|
-
-----------------\n
|
|
12
|
-
Show: {{url}}\n
|
|
13
|
-
-----------------\n
|
|
14
|
-
`;
|
|
15
|
-
|
|
16
|
-
export const resolveQuotationStatusTemplate: TemplateResolver = async (
|
|
17
|
-
{ quotationId, locale },
|
|
18
|
-
{ modules },
|
|
19
|
-
) => {
|
|
5
|
+
export const resolveQuotationStatusTemplate: TemplateResolver = async ({ quotationId }, { modules }) => {
|
|
20
6
|
const quotation = await modules.quotations.findQuotation({ quotationId });
|
|
21
7
|
const user = await modules.users.findUserById(quotation.userId);
|
|
22
8
|
const attachments = (
|
|
@@ -32,18 +18,17 @@ export const resolveQuotationStatusTemplate: TemplateResolver = async (
|
|
|
32
18
|
}));
|
|
33
19
|
|
|
34
20
|
const subject = `${EMAIL_WEBSITE_NAME}: Updated Quotation / ${quotation.quotationNumber}`;
|
|
21
|
+
const url = `${EMAIL_WEBSITE_URL}/quotation?_id=${quotation._id}`;
|
|
35
22
|
|
|
36
|
-
const text =
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
{ escape: (t) => t },
|
|
46
|
-
);
|
|
23
|
+
const text = `
|
|
24
|
+
${subject}\n
|
|
25
|
+
\n
|
|
26
|
+
Status: ${quotation.status}
|
|
27
|
+
\n
|
|
28
|
+
-----------------\n
|
|
29
|
+
Show: ${url}\n
|
|
30
|
+
-----------------\n
|
|
31
|
+
`;
|
|
47
32
|
|
|
48
33
|
return [
|
|
49
34
|
{
|