@unchainedshop/platform 4.8.3 → 5.0.0-alpha.1

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.
@@ -1,4 +1,4 @@
1
- import { FileDirector } from '@unchainedshop/file-upload';
1
+ import { FileDirector } from '@unchainedshop/core';
2
2
  export const setupUploadHandlers = ({ services, modules }) => {
3
3
  FileDirector.registerFileUploadCallback('user-avatars', async (file) => {
4
4
  return services.users.updateUserAvatarAfterUpload({ file });
@@ -1,5 +1,5 @@
1
1
  import { startAPIServer, roles } from '@unchainedshop/api';
2
- import { initCore } from '@unchainedshop/core';
2
+ 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 { setupAccounts } from "./setup/setupAccounts.js";
@@ -37,15 +37,27 @@ export const startPlatform = async ({ modules, services, options, rolesOptions,
37
37
  const configuredRoles = roles.configureRoles(rolesOptions || {});
38
38
  const db = await initDb();
39
39
  const migrationRepository = createMigrationRepository(db);
40
+ const pluginModuleFactories = pluginRegistry.getModuleFactories();
41
+ const pluginModules = pluginModuleFactories.reduce((acc, factory) => {
42
+ const factoryModules = factory({ db });
43
+ Object.entries(factoryModules).forEach(([key, moduleInstance]) => {
44
+ acc[key] = {
45
+ configure: () => moduleInstance,
46
+ };
47
+ });
48
+ return acc;
49
+ }, {});
50
+ const allModules = { ...pluginModules, ...(modules || {}) };
40
51
  const unchainedAPI = await initCore({
41
52
  db,
42
53
  migrationRepository,
43
54
  bulkImporter,
44
- modules,
55
+ modules: allModules,
45
56
  services,
46
57
  options,
47
58
  bulkExporter,
48
59
  });
60
+ await pluginRegistry.initialize(unchainedAPI);
49
61
  setupAccounts(unchainedAPI);
50
62
  setupTemplates(unchainedAPI);
51
63
  setupUploadHandlers(unchainedAPI);
@@ -77,6 +89,8 @@ export const startPlatform = async ({ modules, services, options, rolesOptions,
77
89
  try {
78
90
  defaultLogger.debug('Stopping Workqueue', { signal });
79
91
  stopWorkqueue();
92
+ defaultLogger.debug('Shutting down plugins', { signal });
93
+ await pluginRegistry.shutdown(unchainedAPI);
80
94
  defaultLogger.debug('Stopping GraphQL server', { signal });
81
95
  await graphqlHandler.dispose();
82
96
  defaultLogger.debug('Stopping DB Connection', { signal });
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": "4.8.3",
4
+ "version": "5.0.0-alpha.1",
5
5
  "main": "lib/platform-index.js",
6
6
  "types": "lib/platform-index.d.ts",
7
7
  "type": "module",
@@ -38,15 +38,14 @@
38
38
  "npm": ">=10.0.0"
39
39
  },
40
40
  "dependencies": {
41
- "@unchainedshop/api": "^4.6.0",
42
- "@unchainedshop/core": "^4.6.0",
43
- "@unchainedshop/events": "^4.6.0",
44
- "@unchainedshop/file-upload": "^4.6.0",
45
- "@unchainedshop/logger": "^4.6.0",
46
- "@unchainedshop/mongodb": "^4.6.0",
47
- "@unchainedshop/plugins": "^4.6.0",
48
- "@unchainedshop/roles": "^4.6.0",
49
- "@unchainedshop/utils": "^4.6.0",
41
+ "@unchainedshop/api": "^5.0.0-alpha.1",
42
+ "@unchainedshop/core": "^5.0.0-alpha.1",
43
+ "@unchainedshop/events": "^5.0.0-alpha.1",
44
+ "@unchainedshop/logger": "^5.0.0-alpha.1",
45
+ "@unchainedshop/mongodb": "^5.0.0-alpha.1",
46
+ "@unchainedshop/plugins": "^5.0.0-alpha.1",
47
+ "@unchainedshop/roles": "^5.0.0-alpha.1",
48
+ "@unchainedshop/utils": "^5.0.0-alpha.1",
50
49
  "safe-stable-stringify": "^2.5.0"
51
50
  },
52
51
  "devDependencies": {