@unchainedshop/platform 5.0.0-alpha.1 → 5.0.0-alpha.3

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.
@@ -19,10 +19,13 @@ export async function setupWorkqueue({ unchainedAPI, migrationRepository, ...wor
19
19
  handler.start();
20
20
  });
21
21
  if (workQueueOptions.invalidateProviders ?? !UNCHAINED_DISABLE_PROVIDER_INVALIDATION) {
22
- const orders = await unchainedAPI.modules.orders.findCartsToInvalidate(workQueueOptions.providerInvalidationMaxAgeDays);
23
- await Promise.allSettled(orders.map(async (order) => {
24
- await unchainedAPI.services.orders.updateCalculation(order._id);
25
- }));
22
+ await unchainedAPI.modules.worker.addWorkIfNotExists({
23
+ type: 'INVALIDATE_CARTS',
24
+ input: workQueueOptions.providerInvalidationMaxAgeDays !== undefined
25
+ ? { maxAgeDays: workQueueOptions.providerInvalidationMaxAgeDays }
26
+ : {},
27
+ retries: 0,
28
+ }, (work) => !work.autoscheduled);
26
29
  }
27
30
  if (workQueueOptions.assignCartForUsers ?? Boolean(UNCHAINED_ASSIGN_CART_FOR_USERS)) {
28
31
  const users = await unchainedAPI.modules.users.findUsers({});
@@ -2,6 +2,7 @@ import { startAPIServer, roles } from '@unchainedshop/api';
2
2
  import { initCore, pluginRegistry } from '@unchainedshop/core';
3
3
  import { initDb, mongodb, stopDb } from '@unchainedshop/mongodb';
4
4
  import { defaultLogger } from '@unchainedshop/logger';
5
+ import { getEmitAdapter } from '@unchainedshop/events';
5
6
  import { setupAccounts } from "./setup/setupAccounts.js";
6
7
  import { setupUploadHandlers } from "./setup/setupUploadHandlers.js";
7
8
  import { setupTemplates, MessageTypes } from "./setup/setupTemplates.js";
@@ -91,6 +92,8 @@ export const startPlatform = async ({ modules, services, options, rolesOptions,
91
92
  stopWorkqueue();
92
93
  defaultLogger.debug('Shutting down plugins', { signal });
93
94
  await pluginRegistry.shutdown(unchainedAPI);
95
+ defaultLogger.debug('Shutting down event emitter', { signal });
96
+ await getEmitAdapter()?.shutdown?.();
94
97
  defaultLogger.debug('Stopping GraphQL server', { signal });
95
98
  await graphqlHandler.dispose();
96
99
  defaultLogger.debug('Stopping DB Connection', { signal });
@@ -1,9 +1,9 @@
1
- import { stringify } from 'safe-stable-stringify';
1
+ import { safeStringify } from '@unchainedshop/logger';
2
2
  const { EMAIL_FROM = 'noreply@unchained.local', EMAIL_ERROR_REPORT_RECIPIENT = 'support@unchained.local', EMAIL_WEBSITE_NAME = 'Unchained', ROOT_URL, } = process.env;
3
3
  const formatWorkItems = (workItems) => {
4
4
  return workItems
5
5
  .map(({ _id, type, started, error }) => {
6
- const stringifiedErrors = stringify(error, null, 2);
6
+ const stringifiedErrors = safeStringify(error, null, 2);
7
7
  return `${new Date(started).toLocaleString()} ${type} (${_id}): ${stringifiedErrors}`;
8
8
  })
9
9
  .join('\n');
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.1",
4
+ "version": "5.0.0-alpha.3",
5
5
  "main": "lib/platform-index.js",
6
6
  "types": "lib/platform-index.d.ts",
7
7
  "type": "module",
@@ -45,11 +45,10 @@
45
45
  "@unchainedshop/mongodb": "^5.0.0-alpha.1",
46
46
  "@unchainedshop/plugins": "^5.0.0-alpha.1",
47
47
  "@unchainedshop/roles": "^5.0.0-alpha.1",
48
- "@unchainedshop/utils": "^5.0.0-alpha.1",
49
- "safe-stable-stringify": "^2.5.0"
48
+ "@unchainedshop/utils": "^5.0.0-alpha.1"
50
49
  },
51
50
  "devDependencies": {
52
- "@types/node": "^25.0.0",
51
+ "@types/node": "^26.2.0",
53
52
  "typescript": "^5.8.3"
54
53
  }
55
54
  }