@unchainedshop/platform 1.2.10 → 1.2.17
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 +1 -1
- package/lib/bulk-importer/createBulkImporter.js +8 -8
- package/lib/bulk-importer/createBulkImporter.js.map +1 -1
- package/lib/context/setAccessToken.js.map +1 -1
- package/lib/migrations/createMigrationRunner.js +2 -0
- package/lib/migrations/createMigrationRunner.js.map +1 -1
- package/lib/migrations/migrationRepository.d.ts +2 -2
- package/lib/migrations/runMigrations.d.ts +2 -3
- package/lib/migrations/runMigrations.js.map +1 -1
- package/lib/setup/setupAccounts.d.ts +2 -2
- package/lib/setup/setupAccounts.js +6 -10
- package/lib/setup/setupAccounts.js.map +1 -1
- package/lib/setup/setupCarts.d.ts +2 -2
- package/lib/setup/setupCarts.js.map +1 -1
- package/lib/setup/setupWorkqueue.d.ts +2 -2
- package/lib/setup/setupWorkqueue.js.map +1 -1
- package/lib/startPlatform.d.ts +1 -1
- package/lib/startPlatform.js +3 -8
- package/lib/startPlatform.js.map +1 -1
- package/lib/templates/resolveForwardDeliveryTemplate.js +7 -10
- package/lib/templates/resolveForwardDeliveryTemplate.js.map +1 -1
- package/package.json +14 -15
- package/src/bulk-importer/createBulkImporter.ts +10 -10
- package/src/context/setAccessToken.ts +1 -1
- package/src/migrations/createMigrationRunner.ts +4 -0
- package/src/migrations/migrationRepository.ts +2 -2
- package/src/migrations/runMigrations.ts +2 -3
- package/src/setup/setupAccounts.ts +8 -12
- package/src/setup/setupCarts.ts +2 -2
- package/src/setup/setupWorkqueue.ts +2 -2
- package/src/startPlatform.ts +22 -29
- package/src/templates/resolveForwardDeliveryTemplate.ts +7 -13
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { BulkImportOperation } from '@unchainedshop/types/platform';
|
|
2
2
|
import { BulkImporter } from '@unchainedshop/types/core';
|
|
3
3
|
export declare const getOperation: (entity: string, operation: string) => BulkImportOperation;
|
|
4
|
-
export declare const createBulkImporterFactory: (db: any,
|
|
4
|
+
export declare const createBulkImporterFactory: (db: any, bulkImporterOptions: any) => BulkImporter;
|
|
@@ -14,7 +14,7 @@ export const getOperation = (entity, operation) => {
|
|
|
14
14
|
}
|
|
15
15
|
return entityOperation;
|
|
16
16
|
};
|
|
17
|
-
export const createBulkImporterFactory = (db,
|
|
17
|
+
export const createBulkImporterFactory = (db, bulkImporterOptions) => {
|
|
18
18
|
// Increase the chunk size to 5MB to get around chunk sorting limits of mongodb (weird error above 100 MB)
|
|
19
19
|
const BulkImportPayloads = new mongodb.GridFSBucket(db, {
|
|
20
20
|
bucketName: 'bulk_import_payloads',
|
|
@@ -24,9 +24,9 @@ export const createBulkImporterFactory = (db, additionalHandlers) => {
|
|
|
24
24
|
ASSORTMENT: AssortmentHandlers,
|
|
25
25
|
PRODUCT: ProductHandlers,
|
|
26
26
|
FILTER: FilterHandlers,
|
|
27
|
-
...
|
|
27
|
+
...(bulkImporterOptions?.handlers || {}),
|
|
28
28
|
};
|
|
29
|
-
const createBulkImporter = (options
|
|
29
|
+
const createBulkImporter = (options) => {
|
|
30
30
|
const bulkOperations = {};
|
|
31
31
|
const preparationIssues = [];
|
|
32
32
|
const processedOperations = {};
|
|
@@ -38,7 +38,7 @@ export const createBulkImporterFactory = (db, additionalHandlers) => {
|
|
|
38
38
|
};
|
|
39
39
|
logger.info(`Configure event import with options: createShouldUpsertIfIDExists=${createShouldUpsertIfIDExists} skipCacheInvalidation=${skipCacheInvalidation}`);
|
|
40
40
|
return {
|
|
41
|
-
prepare: async (event) => {
|
|
41
|
+
prepare: async (event, unchainedAPI) => {
|
|
42
42
|
const entity = event.entity.toUpperCase();
|
|
43
43
|
const operation = event.operation.toLowerCase();
|
|
44
44
|
const handler = getOperation(entity, operation);
|
|
@@ -48,7 +48,7 @@ export const createBulkImporterFactory = (db, additionalHandlers) => {
|
|
|
48
48
|
level: 'verbose',
|
|
49
49
|
});
|
|
50
50
|
try {
|
|
51
|
-
await handler(event.payload, { bulk, ...options },
|
|
51
|
+
await handler(event.payload, { bulk, ...options }, unchainedAPI);
|
|
52
52
|
if (!processedOperations[entity])
|
|
53
53
|
processedOperations[entity] = {};
|
|
54
54
|
if (!processedOperations[entity][operation])
|
|
@@ -86,11 +86,11 @@ export const createBulkImporterFactory = (db, additionalHandlers) => {
|
|
|
86
86
|
logger.info(`Import finished without errors`);
|
|
87
87
|
return [operationResults, null];
|
|
88
88
|
},
|
|
89
|
-
invalidateCaches: async () => {
|
|
89
|
+
invalidateCaches: async (unchainedAPI) => {
|
|
90
90
|
if (skipCacheInvalidation)
|
|
91
91
|
return;
|
|
92
|
-
await
|
|
93
|
-
await
|
|
92
|
+
await unchainedAPI.modules.assortments.invalidateCache({});
|
|
93
|
+
await unchainedAPI.modules.filters.invalidateCache({}, unchainedAPI);
|
|
94
94
|
},
|
|
95
95
|
};
|
|
96
96
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBulkImporter.js","sourceRoot":"","sources":["../../src/bulk-importer/createBulkImporter.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAG9B,OAAO,KAAK,kBAAkB,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,cAAc,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,eAAe,MAAM,oBAAoB,CAAC;AAEtD,IAAI,qBAAqB,GAAsC,EAAE,CAAC;AAElE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,MAAc,EAAE,SAAiB,EAAuB,EAAE;IACrF,MAAM,QAAQ,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAC/C,IAAI,CAAC,QAAQ,EAAE;QACb,MAAM,IAAI,KAAK,CAAC,UAAU,MAAM,UAAU,CAAC,CAAC;KAC7C;IAED,MAAM,eAAe,GAAG,QAAQ,CAAC,SAAS,CAAwB,CAAC;IAEnE,IAAI,CAAC,eAAe,IAAI,OAAO,eA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C,UAAU,CACzC,EAAE,QAAQ,EAAE,EACZ;QACE,IAAI,EAAE;YACJ,gBAAgB,EAAE;gBAChB,MAAM;aACP;SACF;
|
|
1
|
+
{"version":3,"file":"setAccessToken.js","sourceRoot":"","sources":["../../src/context/setAccessToken.ts"],"names":[],"mappings":"AAEA,eAAe,KAAK,EAAE,YAAqB,EAAE,QAAgB,EAAE,MAAc,EAAE,EAAE;IAC/E,MAAM,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,CACzC,EAAE,QAAQ,EAAE,EACZ;QACE,IAAI,EAAE;YACJ,gBAAgB,EAAE;gBAChB,MAAM;aACP;SACF;KACK,EACR,EAAE,CACH,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createMigrationRunner.js","sourceRoot":"","sources":["../../src/migrations/createMigrationRunner.ts"],"names":[],"mappings":"AAAA,MAAM,cAAe,SAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"createMigrationRunner.js","sourceRoot":"","sources":["../../src/migrations/createMigrationRunner.ts"],"names":[],"mappings":"AAAA,MAAM,cAAe,SAAQ,KAAK;IACzB,WAAW,CAAC;IAEZ,IAAI,CAAO;IAElB,YAAY,WAAW,GAAG,IAAI,EAAE,GAAG,MAAM;QACvC,kFAAkF;QAClF,KAAK,CAAC,GAAG,MAAM,CAAC,CAAC;QAEjB,qFAAqF;QACrF,IAAI,KAAK,CAAC,iBAAiB,EAAE;YAC3B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;SAC/C;QAED,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;IACzB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,EACpC,SAAS,EACT,MAAM,GAAG,OAAO,EAChB,mBAAm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C;YACxB,OAAO,CAAC,CAAC,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;SAC9B;IACH,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Migration } from '@unchainedshop/types/
|
|
2
|
-
import {
|
|
1
|
+
import { Migration, MigrationRepository } from '@unchainedshop/types/core';
|
|
2
|
+
import { Db } from '@unchainedshop/types/common';
|
|
3
3
|
export declare const createMigrationRepository: (db: Db) => MigrationRepository<Migration>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { MigrationRepository } from '@unchainedshop/types/common';
|
|
1
|
+
import { Migration, UnchainedCore, MigrationRepository } from '@unchainedshop/types/core';
|
|
3
2
|
export declare const runMigrations: ({ migrationRepository, logger, unchainedAPI, }: {
|
|
4
3
|
migrationRepository: MigrationRepository<Migration>;
|
|
5
4
|
logger?: any;
|
|
6
|
-
unchainedAPI:
|
|
5
|
+
unchainedAPI: UnchainedCore;
|
|
7
6
|
}) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runMigrations.js","sourceRoot":"","sources":["../../src/migrations/runMigrations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runMigrations.js","sourceRoot":"","sources":["../../src/migrations/runMigrations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAAE,EAClC,mBAAmB,EACnB,MAAM,GAAG,YAAY,CAAC,sBAAsB,CAAC,EAC7C,YAAY,GAKb,EAAE,EAAE;IACH,MAAM,aAAa,GAAG,mBAAmB,CAAC,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAE1E,MAAM,aAA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eAAe,EAAE,CAAC,CAAC;SACnG;aAAM;YACL,MAAM,CAAC,IAAI,CAAC,4CAA4C,SAAS,EAAE,CAAC,CAAC;SACtE;KACF;SAAM;QACL,MAAM,CAAC,IAAI,CAAC,+CAA+C,eAAe,EAAE,CAAC,CAAC;KAC/E;AACH,CAAC,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const setupAccounts: (unchainedAPI:
|
|
1
|
+
import { UnchainedCore } from '@unchainedshop/types/core';
|
|
2
|
+
export declare const setupAccounts: (unchainedAPI: UnchainedCore) => any;
|
|
@@ -23,7 +23,7 @@ export const setupAccounts = (unchainedAPI) => {
|
|
|
23
23
|
type: 'MESSAGE',
|
|
24
24
|
retries: 0,
|
|
25
25
|
input,
|
|
26
|
-
},
|
|
26
|
+
}, undefined);
|
|
27
27
|
};
|
|
28
28
|
accountsServer.services.guest = {
|
|
29
29
|
async authenticate(params) {
|
|
@@ -50,29 +50,25 @@ export const setupAccounts = (unchainedAPI) => {
|
|
|
50
50
|
countryContext,
|
|
51
51
|
});
|
|
52
52
|
const user = await unchainedAPI.modules.users.findUserById(userId);
|
|
53
|
-
const context = {
|
|
54
|
-
...unchainedAPI,
|
|
55
|
-
countryContext,
|
|
56
|
-
userId,
|
|
57
|
-
user,
|
|
58
|
-
};
|
|
59
53
|
if (userIdBeforeLogin) {
|
|
60
54
|
const userBeforeLogin = await unchainedAPI.modules.users.findUserById(userIdBeforeLogin);
|
|
61
55
|
await unchainedAPI.services.orders.migrateOrderCarts({
|
|
62
56
|
fromUser: userBeforeLogin,
|
|
63
57
|
toUser: user,
|
|
64
58
|
shouldMerge: accountsSettings.mergeUserCartsOnLogin,
|
|
65
|
-
|
|
59
|
+
countryContext,
|
|
60
|
+
}, unchainedAPI);
|
|
66
61
|
await unchainedAPI.services.bookmarks.migrateBookmarks({
|
|
67
62
|
fromUser: userBeforeLogin,
|
|
68
63
|
toUser: user,
|
|
69
64
|
shouldMerge: accountsSettings.mergeUserCartsOnLogin,
|
|
70
|
-
|
|
65
|
+
countryContext,
|
|
66
|
+
}, unchainedAPI);
|
|
71
67
|
}
|
|
72
68
|
await unchainedAPI.modules.orders.ensureCartForUser({
|
|
73
69
|
user,
|
|
74
70
|
countryCode: countryContext,
|
|
75
|
-
},
|
|
71
|
+
}, unchainedAPI);
|
|
76
72
|
});
|
|
77
73
|
accountsServer.on('ResetPasswordSuccess', async (user) => {
|
|
78
74
|
await unchainedAPI.modules.users.updateInitialPassword(user, false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setupAccounts.js","sourceRoot":"","sources":["../../src/setup/setupAccounts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"setupAccounts.js","sourceRoot":"","sources":["../../src/setup/setupAccounts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,OAAO,MAAM,SAAS,CAAC;AAG9B,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,YAA2B,EAAE,EAAE;IAC3D,MAAM,cAAc,GAAG,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,EAAE,CAAC;IAEzE,cAAc,CAAC,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC;IAElD,cAAc,CAAC,OAAO,CAAC,WAAW,GAAG,CACnC,EAAU,EACV,KAAa,EACb,IAA2B,EAC3B,YAAoB,EACpB,EAAE;QACF,OAAO;YACL,QAAQ,EAAE,gBAAgB;YAC1B,cAAc,EAAE,EAAE;YAClB,MAAM,EAAE,YAAY;YACpB,MAAM,EAAE,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,GAAG;YAC3B,KAAK;YACL,aAAa,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,YAAY,KAAK,cAAc;SAC/D,CAAC;IACJ,CAAC,CAAC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tE,CAAC,CAAC,CAAC;IAEH,cAAc,CAAC,EAAE,CAAC,eAAe,EAAE,KAAK,EAAE,MAAuC,EAAE,EAAE;QACnF,IAAI,MAAM,CAAC,OAAO,KAAK,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE;YACnD,MAAM,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;SAClE;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;IAEH,OAAO,cAAc,CAAC;AACxB,CAAC,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UnchainedCore } from '@unchainedshop/types/core';
|
|
2
2
|
import { SetupCartsOptions } from '@unchainedshop/types/platform';
|
|
3
|
-
export declare const setupCarts: (unchainedAPI:
|
|
3
|
+
export declare const setupCarts: (unchainedAPI: UnchainedCore, options?: SetupCartsOptions) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setupCarts.js","sourceRoot":"","sources":["../../src/setup/setupCarts.ts"],"names":[],"mappings":"AAGA,MAAM,EAAE,uCAAuC,EAAE,+BAA+B,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAEjG,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"setupCarts.js","sourceRoot":"","sources":["../../src/setup/setupCarts.ts"],"names":[],"mappings":"AAGA,MAAM,EAAE,uCAAuC,EAAE,+BAA+B,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAEjG,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAAE,YAA2B,EAAE,UAA6B,EAAE,EAAE,EAAE;IAC/F,IAAI,OAAO,CAAC,mBAAmB,IAAI,CAAC,uCAAuC,EAAE;QAC3E,MAAM,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,mBAAmB,CACnD,YAAY,EACZ,OAAO,CAAC,8BAA8B,CACvC,CAAC;KACH;IAED,IAAI,OAAO,CAAC,kBAAkB,IAAI,OAAO,CAAC,+BAA+B,CAAC,EAAE;QAC1E,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;QAE7D,MAAM,OAAO,CAAC,GAAG,CACf,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;YACjB,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YAC3D,OAAO,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAClD,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,CAAC,OAAO,EAAE,EACrC,YAAY,CACb,CAAC;QACJ,CAAC,CAAC,CACH,CAAC;KACH;AACH,CAAC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Context } from '@unchainedshop/types/api';
|
|
2
1
|
import { SetupWorkqueueOptions } from '@unchainedshop/types/platform';
|
|
3
|
-
|
|
2
|
+
import { UnchainedCore } from '@unchainedshop/types/core';
|
|
3
|
+
export declare const setupWorkqueue: (unchainedAPI: UnchainedCore, { workerId, batchCount, schedule }?: SetupWorkqueueOptions) => {
|
|
4
4
|
start: () => void;
|
|
5
5
|
stop: () => void;
|
|
6
6
|
}[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setupWorkqueue.js","sourceRoot":"","sources":["../../src/setup/setupWorkqueue.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"setupWorkqueue.js","sourceRoot":"","sources":["../../src/setup/setupWorkqueue.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAGpG,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,YAA2B,EAC3B,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,KAA4B,EAAE,EAC9D,EAAE;IACF,MAAM,QAAQ,GAAG;QACf,iBAAiB,CAAC,OAAO,CAAC,YAAY,CAAC;QACvC,mBAAmB,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,EAAE,YAAY,CAAC;QACvD,cAAc,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,YAAY,CAAC;KACzE,CAAC;IAEF,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;IAC/C,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC"}
|
package/lib/startPlatform.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { PlatformOptions, MessageTypes } from '@unchainedshop/types/platform';
|
|
2
2
|
export { MessageTypes };
|
|
3
3
|
export declare const queueWorkers: any[];
|
|
4
|
-
export declare const startPlatform: ({ modules, services, typeDefs, resolvers, options, rolesOptions, expressApp, bulkImporter: bulkImporterOptions, schema, plugins, cache, workQueueOptions, context, introspection, playground, tracing, cacheControl, corsOrigins, }
|
|
4
|
+
export declare const startPlatform: ({ modules, services, typeDefs, resolvers, options, rolesOptions, expressApp, bulkImporter: bulkImporterOptions, schema, plugins, cache, workQueueOptions, context, introspection, playground, tracing, cacheControl, corsOrigins, }: PlatformOptions) => Promise<import("@unchainedshop/types/core").UnchainedCore>;
|
package/lib/startPlatform.js
CHANGED
|
@@ -30,19 +30,13 @@ const checkWorkQueueEnabled = (options) => {
|
|
|
30
30
|
return !UNCHAINED_DISABLE_WORKER;
|
|
31
31
|
};
|
|
32
32
|
export const queueWorkers = [];
|
|
33
|
-
export const startPlatform = async ({ modules = {}, services = {}, typeDefs = [], resolvers = [], options = {}, rolesOptions = {}, expressApp, bulkImporter: bulkImporterOptions, schema, plugins, cache, workQueueOptions, context, introspection, playground, tracing, cacheControl, corsOrigins, }
|
|
34
|
-
modules: {},
|
|
35
|
-
services: {},
|
|
36
|
-
typeDefs: [],
|
|
37
|
-
resolvers: [],
|
|
38
|
-
options: {},
|
|
39
|
-
}) => {
|
|
33
|
+
export const startPlatform = async ({ modules = {}, services = {}, typeDefs = [], resolvers = [], options = {}, rolesOptions = {}, expressApp, bulkImporter: bulkImporterOptions, schema, plugins, cache, workQueueOptions, context, introspection, playground, tracing, cacheControl, corsOrigins, }) => {
|
|
40
34
|
exitOnMissingEnvironmentVariables();
|
|
41
35
|
// Configure database
|
|
42
36
|
const db = await initDb();
|
|
43
37
|
// Prepare Migrations
|
|
44
38
|
const migrationRepository = createMigrationRepository(db);
|
|
45
|
-
const bulkImporter = createBulkImporterFactory(db, bulkImporterOptions
|
|
39
|
+
const bulkImporter = createBulkImporterFactory(db, bulkImporterOptions);
|
|
46
40
|
// Initialise core api using the database
|
|
47
41
|
const unchainedAPI = await initCore({
|
|
48
42
|
db,
|
|
@@ -51,6 +45,7 @@ export const startPlatform = async ({ modules = {}, services = {}, typeDefs = []
|
|
|
51
45
|
modules,
|
|
52
46
|
services,
|
|
53
47
|
options,
|
|
48
|
+
roleOptions: rolesOptions,
|
|
54
49
|
});
|
|
55
50
|
const isWorkQueueEnabled = checkWorkQueueEnabled(workQueueOptions);
|
|
56
51
|
if (isWorkQueueEnabled) {
|
package/lib/startPlatform.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startPlatform.js","sourceRoot":"","sources":["../src/startPlatform.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACrG,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,O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C/C,YAAY,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,EAAE,YAAY,CAAC,CAAC,CAAC;KACpF;IAED,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import moment from 'moment';
|
|
2
1
|
import { systemLocale } from '@unchainedshop/utils';
|
|
3
2
|
import { getOrderAttachmentsData } from './utils/getOrderAttachmentsData';
|
|
4
3
|
import { getOrderPositionsData } from './utils/getOrderPositionsData';
|
|
@@ -14,7 +13,7 @@ const mjmlTemplate = `
|
|
|
14
13
|
<mj-text align="left" font-size="20px" color="#232323" font-family="Helvetica Neue" font-weight="200">
|
|
15
14
|
<span>Order number: {{orderNumber}}</span><br/>
|
|
16
15
|
<span>Order date: {{orderDate}}</span>
|
|
17
|
-
<a href="{{
|
|
16
|
+
<a href="{{adminUILink}}">{{adminUILink}}</a>
|
|
18
17
|
</mj-text>
|
|
19
18
|
<mj-text align="left" font-size="20px" color="#232323">Delivery address</mj-text>
|
|
20
19
|
<mj-text align="left">
|
|
@@ -49,7 +48,7 @@ const textTemplate = `
|
|
|
49
48
|
\n
|
|
50
49
|
Order number: {{orderNumber}}\n
|
|
51
50
|
Order date: {{orderDate}}\n
|
|
52
|
-
Link: {{
|
|
51
|
+
Link: {{adminUILink}}\n
|
|
53
52
|
\n
|
|
54
53
|
Delivery address:\n
|
|
55
54
|
-----------------\n
|
|
@@ -67,15 +66,13 @@ const textTemplate = `
|
|
|
67
66
|
* {{sku}} - {{name}} CHF {{price}} {{quantity}}\n
|
|
68
67
|
{{/items}}
|
|
69
68
|
`;
|
|
70
|
-
export const resolveForwardDeliveryTemplate = async ({ config, orderId
|
|
69
|
+
export const resolveForwardDeliveryTemplate = async ({ config, orderId }, context) => {
|
|
71
70
|
const { modules } = context;
|
|
72
71
|
const order = await modules.orders.findOrder({ orderId });
|
|
73
72
|
const orderPricing = modules.orders.pricingSheet(order);
|
|
74
|
-
const
|
|
75
|
-
momentDate.locale(systemLocale.normalized);
|
|
76
|
-
const orderDate = momentDate.format('lll');
|
|
73
|
+
const orderDate = new Date(order.ordered).toLocaleString();
|
|
77
74
|
const attachments = await getOrderAttachmentsData(order, { fileType: 'DELIVERY_NOTE' }, context);
|
|
78
|
-
const address =
|
|
75
|
+
const address = order.billingAddress;
|
|
79
76
|
const configObject = config.reduce((acc, { key, value }) => {
|
|
80
77
|
return {
|
|
81
78
|
...acc,
|
|
@@ -83,10 +80,10 @@ export const resolveForwardDeliveryTemplate = async ({ config, orderId, transact
|
|
|
83
80
|
};
|
|
84
81
|
}, {});
|
|
85
82
|
const subject = `${EMAIL_WEBSITE_NAME}: New Order / ${order.orderNumber}`;
|
|
86
|
-
const
|
|
83
|
+
const adminUILink = `${ROOT_URL}/orders/view/?_id=${order._id}`;
|
|
87
84
|
const data = {
|
|
88
85
|
contact: order.contact || {},
|
|
89
|
-
|
|
86
|
+
adminUILink,
|
|
90
87
|
items: getOrderPositionsData(order, { locale: systemLocale }, context),
|
|
91
88
|
orderDate,
|
|
92
89
|
orderNumber: order.orderNumber,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveForwardDeliveryTemplate.js","sourceRoot":"","sources":["../../src/templates/resolveForwardDeliveryTemplate.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"resolveForwardDeliveryTemplate.js","sourceRoot":"","sources":["../../src/templates/resolveForwardDeliveryTemplate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAEjE,MAAM,YAAY,GAAG;;;;;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AE,EAAE,OAAO,CAAC;QACtE,SAAS;QACT,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,QAAQ,EAAE,kBAAkB;QAC5B,OAAO;QACP,KAAK,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,GAAG,GAAG;QAC9D,GAAG,YAAY;QACf,OAAO;KACR,CAAC;IAEF,OAAO;QACL;YACE,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACL,IAAI,EAAE,YAAY,CAAC,IAAI,IAAI,UAAU,IAAI,yBAAyB;gBAClE,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;gBACxD,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,gBAAgB,CAAC,YAAY,EAAE,IAAI,CAAC;gBAC5D,WAAW;aACZ;SACF;KACF,CAAC;AACJ,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/platform",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.17",
|
|
4
4
|
"main": "lib/platform-index.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./lib/platform-index.js",
|
|
@@ -30,27 +30,26 @@
|
|
|
30
30
|
},
|
|
31
31
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@unchainedshop/api": "1.
|
|
34
|
-
"@unchainedshop/core": "1.
|
|
35
|
-
"@unchainedshop/events": "1.
|
|
36
|
-
"@unchainedshop/file-upload": "1.
|
|
37
|
-
"@unchainedshop/logger": "1.
|
|
38
|
-
"@unchainedshop/mongodb": "1.
|
|
39
|
-
"@unchainedshop/plugins": "1.
|
|
40
|
-
"@unchainedshop/roles": "1.
|
|
41
|
-
"@unchainedshop/utils": "1.
|
|
33
|
+
"@unchainedshop/api": "^1.2.17",
|
|
34
|
+
"@unchainedshop/core": "^1.2.17",
|
|
35
|
+
"@unchainedshop/events": "^1.2.17",
|
|
36
|
+
"@unchainedshop/file-upload": "^1.2.17",
|
|
37
|
+
"@unchainedshop/logger": "^1.2.17",
|
|
38
|
+
"@unchainedshop/mongodb": "^1.2.17",
|
|
39
|
+
"@unchainedshop/plugins": "^1.2.17",
|
|
40
|
+
"@unchainedshop/roles": "^1.2.17",
|
|
41
|
+
"@unchainedshop/utils": "^1.2.17",
|
|
42
42
|
"event-iterator": "^2.0.0",
|
|
43
43
|
"JSONStream": "^1.3.5",
|
|
44
44
|
"moniker": "0.1.2",
|
|
45
45
|
"open": "^8.4.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@types/
|
|
49
|
-
"@types
|
|
50
|
-
"@unchainedshop/types": "1.x",
|
|
48
|
+
"@types/node": "^16.11.49",
|
|
49
|
+
"@unchainedshop/types": "^1.2.17",
|
|
51
50
|
"cross-env": "^7.0.3",
|
|
52
|
-
"jest": "^28.1.
|
|
53
|
-
"ts-jest": "^28.0.
|
|
51
|
+
"jest": "^28.1.3",
|
|
52
|
+
"ts-jest": "^28.0.8",
|
|
54
53
|
"typescript": "^4.7.4"
|
|
55
54
|
}
|
|
56
55
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import mongodb from 'mongodb';
|
|
2
2
|
import { BulkImportHandler, BulkImportOperation } from '@unchainedshop/types/platform';
|
|
3
|
-
import { BulkImporter } from '@unchainedshop/types/core';
|
|
3
|
+
import { BulkImporter, UnchainedCore } from '@unchainedshop/types/core';
|
|
4
4
|
import * as AssortmentHandlers from './handlers/assortment';
|
|
5
5
|
import * as FilterHandlers from './handlers/filter';
|
|
6
6
|
import * as ProductHandlers from './handlers/product';
|
|
@@ -22,7 +22,7 @@ export const getOperation = (entity: string, operation: string): BulkImportOpera
|
|
|
22
22
|
return entityOperation;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
export const createBulkImporterFactory = (db,
|
|
25
|
+
export const createBulkImporterFactory = (db, bulkImporterOptions: any): BulkImporter => {
|
|
26
26
|
// Increase the chunk size to 5MB to get around chunk sorting limits of mongodb (weird error above 100 MB)
|
|
27
27
|
const BulkImportPayloads = new mongodb.GridFSBucket(db, {
|
|
28
28
|
bucketName: 'bulk_import_payloads',
|
|
@@ -30,13 +30,13 @@ export const createBulkImporterFactory = (db, additionalHandlers): BulkImporter
|
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
bulkOperationHandlers = {
|
|
33
|
-
ASSORTMENT: AssortmentHandlers
|
|
33
|
+
ASSORTMENT: AssortmentHandlers,
|
|
34
34
|
PRODUCT: ProductHandlers,
|
|
35
35
|
FILTER: FilterHandlers,
|
|
36
|
-
...
|
|
36
|
+
...(bulkImporterOptions?.handlers || {}),
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
const createBulkImporter: BulkImporter['createBulkImporter'] = (options
|
|
39
|
+
const createBulkImporter: BulkImporter['createBulkImporter'] = (options) => {
|
|
40
40
|
const bulkOperations = {};
|
|
41
41
|
const preparationIssues = [];
|
|
42
42
|
const processedOperations = {};
|
|
@@ -53,7 +53,7 @@ export const createBulkImporterFactory = (db, additionalHandlers): BulkImporter
|
|
|
53
53
|
);
|
|
54
54
|
|
|
55
55
|
return {
|
|
56
|
-
prepare: async (event) => {
|
|
56
|
+
prepare: async (event, unchainedAPI: UnchainedCore) => {
|
|
57
57
|
const entity = event.entity.toUpperCase();
|
|
58
58
|
const operation = event.operation.toLowerCase();
|
|
59
59
|
|
|
@@ -67,7 +67,7 @@ export const createBulkImporterFactory = (db, additionalHandlers): BulkImporter
|
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
try {
|
|
70
|
-
await handler(event.payload, { bulk, ...options },
|
|
70
|
+
await handler(event.payload, { bulk, ...options }, unchainedAPI);
|
|
71
71
|
if (!processedOperations[entity]) processedOperations[entity] = {};
|
|
72
72
|
if (!processedOperations[entity][operation]) processedOperations[entity][operation] = [];
|
|
73
73
|
processedOperations[entity][operation].push(payloadId);
|
|
@@ -105,10 +105,10 @@ export const createBulkImporterFactory = (db, additionalHandlers): BulkImporter
|
|
|
105
105
|
logger.info(`Import finished without errors`);
|
|
106
106
|
return [operationResults, null];
|
|
107
107
|
},
|
|
108
|
-
invalidateCaches: async () => {
|
|
108
|
+
invalidateCaches: async (unchainedAPI: UnchainedCore) => {
|
|
109
109
|
if (skipCacheInvalidation) return;
|
|
110
|
-
await
|
|
111
|
-
await
|
|
110
|
+
await unchainedAPI.modules.assortments.invalidateCache({});
|
|
111
|
+
await unchainedAPI.modules.filters.invalidateCache({}, unchainedAPI);
|
|
112
112
|
},
|
|
113
113
|
};
|
|
114
114
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Migration } from '@unchainedshop/types/
|
|
2
|
-
import {
|
|
1
|
+
import { Migration, MigrationRepository } from '@unchainedshop/types/core';
|
|
2
|
+
import { Db } from '@unchainedshop/types/common';
|
|
3
3
|
|
|
4
4
|
export const createMigrationRepository = (db: Db): MigrationRepository<Migration> => {
|
|
5
5
|
const migrations = new Map();
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { MigrationRepository } from '@unchainedshop/types/common';
|
|
1
|
+
import { Migration, UnchainedCore, MigrationRepository } from '@unchainedshop/types/core';
|
|
3
2
|
import { createLogger } from '@unchainedshop/logger';
|
|
4
3
|
import { generateDbFilterById } from '@unchainedshop/utils';
|
|
5
4
|
import { createMigrationRunner } from './createMigrationRunner';
|
|
@@ -11,7 +10,7 @@ export const runMigrations = async ({
|
|
|
11
10
|
}: {
|
|
12
11
|
migrationRepository: MigrationRepository<Migration>;
|
|
13
12
|
logger?: any;
|
|
14
|
-
unchainedAPI:
|
|
13
|
+
unchainedAPI: UnchainedCore;
|
|
15
14
|
}) => {
|
|
16
15
|
const LastMigration = migrationRepository.db.collection('last-migration');
|
|
17
16
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Context } from '@unchainedshop/types/api';
|
|
2
1
|
import { User } from '@unchainedshop/types/user';
|
|
3
2
|
import { randomValueHex } from '@unchainedshop/utils';
|
|
4
3
|
import { accountsSettings } from '@unchainedshop/core-accountsjs';
|
|
5
4
|
import moniker from 'moniker';
|
|
5
|
+
import { UnchainedCore } from '@unchainedshop/types/core';
|
|
6
6
|
|
|
7
|
-
export const setupAccounts = (unchainedAPI:
|
|
7
|
+
export const setupAccounts = (unchainedAPI: UnchainedCore) => {
|
|
8
8
|
const accountsServer = unchainedAPI.modules.accounts.getAccountsServer();
|
|
9
9
|
|
|
10
10
|
accountsServer.users = unchainedAPI.modules.users;
|
|
@@ -35,7 +35,7 @@ export const setupAccounts = (unchainedAPI: Context) => {
|
|
|
35
35
|
retries: 0,
|
|
36
36
|
input,
|
|
37
37
|
},
|
|
38
|
-
|
|
38
|
+
undefined,
|
|
39
39
|
);
|
|
40
40
|
};
|
|
41
41
|
|
|
@@ -72,12 +72,6 @@ export const setupAccounts = (unchainedAPI: Context) => {
|
|
|
72
72
|
});
|
|
73
73
|
|
|
74
74
|
const user = await unchainedAPI.modules.users.findUserById(userId);
|
|
75
|
-
const context = {
|
|
76
|
-
...unchainedAPI,
|
|
77
|
-
countryContext,
|
|
78
|
-
userId,
|
|
79
|
-
user,
|
|
80
|
-
};
|
|
81
75
|
|
|
82
76
|
if (userIdBeforeLogin) {
|
|
83
77
|
const userBeforeLogin = await unchainedAPI.modules.users.findUserById(userIdBeforeLogin);
|
|
@@ -87,8 +81,9 @@ export const setupAccounts = (unchainedAPI: Context) => {
|
|
|
87
81
|
fromUser: userBeforeLogin,
|
|
88
82
|
toUser: user,
|
|
89
83
|
shouldMerge: accountsSettings.mergeUserCartsOnLogin,
|
|
84
|
+
countryContext,
|
|
90
85
|
},
|
|
91
|
-
|
|
86
|
+
unchainedAPI,
|
|
92
87
|
);
|
|
93
88
|
|
|
94
89
|
await unchainedAPI.services.bookmarks.migrateBookmarks(
|
|
@@ -96,8 +91,9 @@ export const setupAccounts = (unchainedAPI: Context) => {
|
|
|
96
91
|
fromUser: userBeforeLogin,
|
|
97
92
|
toUser: user,
|
|
98
93
|
shouldMerge: accountsSettings.mergeUserCartsOnLogin,
|
|
94
|
+
countryContext,
|
|
99
95
|
},
|
|
100
|
-
|
|
96
|
+
unchainedAPI,
|
|
101
97
|
);
|
|
102
98
|
}
|
|
103
99
|
|
|
@@ -106,7 +102,7 @@ export const setupAccounts = (unchainedAPI: Context) => {
|
|
|
106
102
|
user,
|
|
107
103
|
countryCode: countryContext,
|
|
108
104
|
},
|
|
109
|
-
|
|
105
|
+
unchainedAPI,
|
|
110
106
|
);
|
|
111
107
|
});
|
|
112
108
|
|
package/src/setup/setupCarts.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UnchainedCore } from '@unchainedshop/types/core';
|
|
2
2
|
import { SetupCartsOptions } from '@unchainedshop/types/platform';
|
|
3
3
|
|
|
4
4
|
const { UNCHAINED_DISABLE_PROVIDER_INVALIDATION, UNCHAINED_ASSIGN_CART_FOR_USERS } = process.env;
|
|
5
5
|
|
|
6
|
-
export const setupCarts = async (unchainedAPI:
|
|
6
|
+
export const setupCarts = async (unchainedAPI: UnchainedCore, options: SetupCartsOptions = {}) => {
|
|
7
7
|
if (options.invalidateProviders ?? !UNCHAINED_DISABLE_PROVIDER_INVALIDATION) {
|
|
8
8
|
await unchainedAPI.modules.orders.invalidateProviders(
|
|
9
9
|
unchainedAPI,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Context } from '@unchainedshop/types/api';
|
|
2
1
|
import { SetupWorkqueueOptions } from '@unchainedshop/types/platform';
|
|
3
2
|
import { EventListenerWorker, FailedRescheduler, IntervalWorker } from '@unchainedshop/core-worker';
|
|
3
|
+
import { UnchainedCore } from '@unchainedshop/types/core';
|
|
4
4
|
|
|
5
5
|
export const setupWorkqueue = (
|
|
6
|
-
unchainedAPI:
|
|
6
|
+
unchainedAPI: UnchainedCore,
|
|
7
7
|
{ workerId, batchCount, schedule }: SetupWorkqueueOptions = {},
|
|
8
8
|
) => {
|
|
9
9
|
const handlers = [
|
package/src/startPlatform.ts
CHANGED
|
@@ -37,34 +37,26 @@ const checkWorkQueueEnabled = (options: SetupWorkqueueOptions) => {
|
|
|
37
37
|
|
|
38
38
|
export const queueWorkers = [];
|
|
39
39
|
|
|
40
|
-
export const startPlatform = async (
|
|
41
|
-
{
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}: PlatformOptions = {
|
|
61
|
-
modules: {},
|
|
62
|
-
services: {},
|
|
63
|
-
typeDefs: [],
|
|
64
|
-
resolvers: [],
|
|
65
|
-
options: {},
|
|
66
|
-
},
|
|
67
|
-
) => {
|
|
40
|
+
export const startPlatform = async ({
|
|
41
|
+
modules = {},
|
|
42
|
+
services = {},
|
|
43
|
+
typeDefs = [],
|
|
44
|
+
resolvers = [],
|
|
45
|
+
options = {},
|
|
46
|
+
rolesOptions = {},
|
|
47
|
+
expressApp,
|
|
48
|
+
bulkImporter: bulkImporterOptions,
|
|
49
|
+
schema,
|
|
50
|
+
plugins,
|
|
51
|
+
cache,
|
|
52
|
+
workQueueOptions,
|
|
53
|
+
context,
|
|
54
|
+
introspection,
|
|
55
|
+
playground,
|
|
56
|
+
tracing,
|
|
57
|
+
cacheControl,
|
|
58
|
+
corsOrigins,
|
|
59
|
+
}: PlatformOptions) => {
|
|
68
60
|
exitOnMissingEnvironmentVariables();
|
|
69
61
|
|
|
70
62
|
// Configure database
|
|
@@ -72,7 +64,7 @@ export const startPlatform = async (
|
|
|
72
64
|
|
|
73
65
|
// Prepare Migrations
|
|
74
66
|
const migrationRepository = createMigrationRepository(db);
|
|
75
|
-
const bulkImporter = createBulkImporterFactory(db, bulkImporterOptions
|
|
67
|
+
const bulkImporter = createBulkImporterFactory(db, bulkImporterOptions);
|
|
76
68
|
|
|
77
69
|
// Initialise core api using the database
|
|
78
70
|
const unchainedAPI = await initCore({
|
|
@@ -82,6 +74,7 @@ export const startPlatform = async (
|
|
|
82
74
|
modules,
|
|
83
75
|
services,
|
|
84
76
|
options,
|
|
77
|
+
roleOptions: rolesOptions,
|
|
85
78
|
});
|
|
86
79
|
|
|
87
80
|
const isWorkQueueEnabled = checkWorkQueueEnabled(workQueueOptions);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { TemplateResolver } from '@unchainedshop/types/messaging';
|
|
2
|
-
import moment from 'moment';
|
|
3
2
|
import { systemLocale } from '@unchainedshop/utils';
|
|
4
3
|
import { getOrderAttachmentsData } from './utils/getOrderAttachmentsData';
|
|
5
4
|
import { getOrderPositionsData } from './utils/getOrderPositionsData';
|
|
@@ -17,7 +16,7 @@ const mjmlTemplate = `
|
|
|
17
16
|
<mj-text align="left" font-size="20px" color="#232323" font-family="Helvetica Neue" font-weight="200">
|
|
18
17
|
<span>Order number: {{orderNumber}}</span><br/>
|
|
19
18
|
<span>Order date: {{orderDate}}</span>
|
|
20
|
-
<a href="{{
|
|
19
|
+
<a href="{{adminUILink}}">{{adminUILink}}</a>
|
|
21
20
|
</mj-text>
|
|
22
21
|
<mj-text align="left" font-size="20px" color="#232323">Delivery address</mj-text>
|
|
23
22
|
<mj-text align="left">
|
|
@@ -53,7 +52,7 @@ const textTemplate = `
|
|
|
53
52
|
\n
|
|
54
53
|
Order number: {{orderNumber}}\n
|
|
55
54
|
Order date: {{orderDate}}\n
|
|
56
|
-
Link: {{
|
|
55
|
+
Link: {{adminUILink}}\n
|
|
57
56
|
\n
|
|
58
57
|
Delivery address:\n
|
|
59
58
|
-----------------\n
|
|
@@ -72,21 +71,16 @@ const textTemplate = `
|
|
|
72
71
|
{{/items}}
|
|
73
72
|
`;
|
|
74
73
|
|
|
75
|
-
export const resolveForwardDeliveryTemplate: TemplateResolver = async (
|
|
76
|
-
{ config, orderId, transactionContext },
|
|
77
|
-
context,
|
|
78
|
-
) => {
|
|
74
|
+
export const resolveForwardDeliveryTemplate: TemplateResolver = async ({ config, orderId }, context) => {
|
|
79
75
|
const { modules } = context;
|
|
80
76
|
const order = await modules.orders.findOrder({ orderId });
|
|
81
77
|
const orderPricing = modules.orders.pricingSheet(order);
|
|
82
78
|
|
|
83
|
-
const
|
|
84
|
-
momentDate.locale(systemLocale.normalized);
|
|
85
|
-
const orderDate = momentDate.format('lll');
|
|
79
|
+
const orderDate = new Date(order.ordered).toLocaleString();
|
|
86
80
|
|
|
87
81
|
const attachments = await getOrderAttachmentsData(order, { fileType: 'DELIVERY_NOTE' }, context);
|
|
88
82
|
|
|
89
|
-
const address =
|
|
83
|
+
const address = order.billingAddress;
|
|
90
84
|
const configObject = config.reduce((acc, { key, value }) => {
|
|
91
85
|
return {
|
|
92
86
|
...acc,
|
|
@@ -96,11 +90,11 @@ export const resolveForwardDeliveryTemplate: TemplateResolver = async (
|
|
|
96
90
|
|
|
97
91
|
const subject = `${EMAIL_WEBSITE_NAME}: New Order / ${order.orderNumber}`;
|
|
98
92
|
|
|
99
|
-
const
|
|
93
|
+
const adminUILink = `${ROOT_URL}/orders/view/?_id=${order._id}`;
|
|
100
94
|
|
|
101
95
|
const data = {
|
|
102
96
|
contact: order.contact || {},
|
|
103
|
-
|
|
97
|
+
adminUILink,
|
|
104
98
|
items: getOrderPositionsData(order, { locale: systemLocale }, context),
|
|
105
99
|
orderDate,
|
|
106
100
|
orderNumber: order.orderNumber,
|