@unchainedshop/platform 5.0.0-alpha.4 → 5.0.0-alpha.5
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/startPlatform.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { type UnchainedServerOptions } from '@unchainedshop/api';
|
|
|
2
2
|
import { type UnchainedCoreOptions } from '@unchainedshop/core';
|
|
3
3
|
import { mongodb } from '@unchainedshop/mongodb';
|
|
4
4
|
import type { UnchainedCore } from '@unchainedshop/core';
|
|
5
|
+
import { type AuditLogOptions } from '@unchainedshop/events';
|
|
5
6
|
import { MessageTypes } from './setup/setupTemplates.ts';
|
|
6
7
|
import { type SetupWorkqueueOptions } from './setup/setupWorkqueue.ts';
|
|
7
8
|
import type { IRoleOptionConfig } from '@unchainedshop/roles';
|
|
@@ -9,8 +10,9 @@ export { MessageTypes };
|
|
|
9
10
|
export type PlatformOptions = {
|
|
10
11
|
rolesOptions?: IRoleOptionConfig;
|
|
11
12
|
workQueueOptions?: SetupWorkqueueOptions;
|
|
13
|
+
auditLog?: AuditLogOptions | false;
|
|
12
14
|
} & Omit<UnchainedCoreOptions, 'migrationRepository' | 'db'> & Omit<UnchainedServerOptions, 'roles' | 'unchainedAPI'>;
|
|
13
|
-
export declare const startPlatform: ({ modules, services, options, rolesOptions, bulkImporter, bulkExporter, workQueueOptions, ...arbitraryAPIServerConfiguration }: PlatformOptions) => Promise<{
|
|
15
|
+
export declare const startPlatform: ({ modules, services, options, rolesOptions, bulkImporter, bulkExporter, workQueueOptions, auditLog: auditLogConfig, ...arbitraryAPIServerConfiguration }: PlatformOptions) => Promise<{
|
|
14
16
|
unchainedAPI: UnchainedCore;
|
|
15
17
|
graphqlHandler: any;
|
|
16
18
|
db: mongodb.Db;
|
package/lib/startPlatform.js
CHANGED
|
@@ -3,6 +3,7 @@ import { initCore, pluginRegistry } from '@unchainedshop/core';
|
|
|
3
3
|
import { initDb, mongodb, stopDb } from '@unchainedshop/mongodb';
|
|
4
4
|
import { defaultLogger } from '@unchainedshop/logger';
|
|
5
5
|
import { getEmitAdapter } from '@unchainedshop/events';
|
|
6
|
+
import { createAuditLog, configureAuditIntegration, setAuditLogInstance, } from '@unchainedshop/events';
|
|
6
7
|
import { setupAccounts } from "./setup/setupAccounts.js";
|
|
7
8
|
import { setupUploadHandlers } from "./setup/setupUploadHandlers.js";
|
|
8
9
|
import { setupTemplates, MessageTypes } from "./setup/setupTemplates.js";
|
|
@@ -31,7 +32,7 @@ const existOnInvalidEnvironmentVariables = () => {
|
|
|
31
32
|
process.exit(1);
|
|
32
33
|
}
|
|
33
34
|
};
|
|
34
|
-
export const startPlatform = async ({ modules, services, options, rolesOptions, bulkImporter, bulkExporter, workQueueOptions, ...arbitraryAPIServerConfiguration }) => {
|
|
35
|
+
export const startPlatform = async ({ modules, services, options, rolesOptions, bulkImporter, bulkExporter, workQueueOptions, auditLog: auditLogConfig, ...arbitraryAPIServerConfiguration }) => {
|
|
35
36
|
const start = performance.now();
|
|
36
37
|
exitOnMissingEnvironmentVariables();
|
|
37
38
|
existOnInvalidEnvironmentVariables();
|
|
@@ -59,6 +60,11 @@ export const startPlatform = async ({ modules, services, options, rolesOptions,
|
|
|
59
60
|
bulkExporter,
|
|
60
61
|
});
|
|
61
62
|
await pluginRegistry.initialize(unchainedAPI);
|
|
63
|
+
let auditLog;
|
|
64
|
+
if (auditLogConfig !== false) {
|
|
65
|
+
auditLog = createAuditLog(auditLogConfig || {});
|
|
66
|
+
setAuditLogInstance(auditLog);
|
|
67
|
+
}
|
|
62
68
|
setupAccounts(unchainedAPI);
|
|
63
69
|
setupTemplates(unchainedAPI);
|
|
64
70
|
setupUploadHandlers(unchainedAPI);
|
|
@@ -67,6 +73,9 @@ export const startPlatform = async ({ modules, services, options, rolesOptions,
|
|
|
67
73
|
roles: configuredRoles,
|
|
68
74
|
...arbitraryAPIServerConfiguration,
|
|
69
75
|
});
|
|
76
|
+
if (auditLog) {
|
|
77
|
+
configureAuditIntegration(auditLog);
|
|
78
|
+
}
|
|
70
79
|
await setupWorkqueue({
|
|
71
80
|
unchainedAPI,
|
|
72
81
|
migrationRepository,
|
|
@@ -96,6 +105,10 @@ export const startPlatform = async ({ modules, services, options, rolesOptions,
|
|
|
96
105
|
await getEmitAdapter()?.shutdown?.();
|
|
97
106
|
defaultLogger.debug('Stopping GraphQL server', { signal });
|
|
98
107
|
await graphqlHandler.dispose();
|
|
108
|
+
if (auditLog) {
|
|
109
|
+
defaultLogger.debug('Closing audit log', { signal });
|
|
110
|
+
await auditLog.close();
|
|
111
|
+
}
|
|
99
112
|
defaultLogger.debug('Stopping DB Connection', { signal });
|
|
100
113
|
await stopDb();
|
|
101
114
|
defaultLogger.debug(`Unchained Engine exiting gracefully`, { signal, version });
|
|
@@ -2,7 +2,7 @@ import { ProductPricingSheet } from '@unchainedshop/core';
|
|
|
2
2
|
import { ch } from '@unchainedshop/utils';
|
|
3
3
|
export const getOrderPositionsData = async (order, params, context) => {
|
|
4
4
|
const { modules } = context;
|
|
5
|
-
const { useNetPrice, format = ch.priceToString } = params || {};
|
|
5
|
+
const { useNetPrice, format = (price) => ch.priceToString({ ...price, locale: params?.locale }) } = params || {};
|
|
6
6
|
const orderPositions = await modules.orders.positions.findOrderPositions({
|
|
7
7
|
orderId: order._id,
|
|
8
8
|
});
|
|
@@ -2,7 +2,7 @@ import { OrderPricingSheet, OrderPricingRowCategory } from '@unchainedshop/core'
|
|
|
2
2
|
import { ch } from '@unchainedshop/utils';
|
|
3
3
|
export const getOrderSummaryData = async (order, params, context) => {
|
|
4
4
|
const { modules } = context;
|
|
5
|
-
const { useNetPrice, format = ch.priceToString } = params || {};
|
|
5
|
+
const { useNetPrice, format = (price) => ch.priceToString({ ...price, locale: params?.locale }) } = params || {};
|
|
6
6
|
const orderDelivery = order.deliveryId &&
|
|
7
7
|
(await modules.orders.deliveries.findDelivery({
|
|
8
8
|
orderDeliveryId: order.deliveryId,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/platform",
|
|
3
3
|
"description": "Complete e-commerce platform bundle for the Unchained Engine",
|
|
4
|
-
"version": "5.0.0-alpha.
|
|
4
|
+
"version": "5.0.0-alpha.5",
|
|
5
5
|
"main": "lib/platform-index.js",
|
|
6
6
|
"types": "lib/platform-index.d.ts",
|
|
7
7
|
"type": "module",
|
|
@@ -38,14 +38,14 @@
|
|
|
38
38
|
"npm": ">=10.0.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@unchainedshop/api": "^5.0.0-alpha.
|
|
42
|
-
"@unchainedshop/core": "^5.0.0-alpha.
|
|
43
|
-
"@unchainedshop/events": "^5.0.0-alpha.
|
|
44
|
-
"@unchainedshop/logger": "^5.0.0-alpha.
|
|
45
|
-
"@unchainedshop/mongodb": "^5.0.0-alpha.
|
|
46
|
-
"@unchainedshop/plugins": "^5.0.0-alpha.
|
|
47
|
-
"@unchainedshop/roles": "^5.0.0-alpha.
|
|
48
|
-
"@unchainedshop/utils": "^5.0.0-alpha.
|
|
41
|
+
"@unchainedshop/api": "^5.0.0-alpha.5",
|
|
42
|
+
"@unchainedshop/core": "^5.0.0-alpha.5",
|
|
43
|
+
"@unchainedshop/events": "^5.0.0-alpha.5",
|
|
44
|
+
"@unchainedshop/logger": "^5.0.0-alpha.5",
|
|
45
|
+
"@unchainedshop/mongodb": "^5.0.0-alpha.5",
|
|
46
|
+
"@unchainedshop/plugins": "^5.0.0-alpha.5",
|
|
47
|
+
"@unchainedshop/roles": "^5.0.0-alpha.5",
|
|
48
|
+
"@unchainedshop/utils": "^5.0.0-alpha.5"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/node": "^26.2.0",
|