kuzzle 2.20.1 → 2.20.2

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.
@@ -116,16 +116,21 @@ class Plugin {
116
116
  }
117
117
 
118
118
  const description = {
119
+ version: this.version,
119
120
  controllers: [],
120
121
  hooks: [],
121
122
  manifest: this.manifest,
122
123
  pipes: [],
123
124
  routes: [],
124
125
  strategies: [],
125
- version: this.version,
126
+ imports: {},
126
127
  };
127
128
  /* eslint-enable sort-keys */
128
129
 
130
+ if (has(this.instance, "imports")) {
131
+ description.imports = Object.keys(this.instance.imports);
132
+ }
133
+
129
134
  if (has(this.instance, "hooks")) {
130
135
  description.hooks = Object.keys(this.instance.hooks);
131
136
  }
@@ -207,7 +207,7 @@ class PluginsManager {
207
207
  *
208
208
  * @throws PluginImplementationError - Throws when an error occurs when registering a plugin
209
209
  */
210
- init(plugins = {}) {
210
+ async init(plugins = {}) {
211
211
  this._plugins = new Map([...this.loadPlugins(plugins), ...this._plugins]);
212
212
 
213
213
  global.kuzzle.on("plugin:hook:loop-error", ({ error, pluginName }) => {
@@ -224,6 +224,7 @@ class PluginsManager {
224
224
 
225
225
  // register regular plugins features
226
226
  const loadPlugins = [];
227
+ const defaultImports = {};
227
228
 
228
229
  for (const plugin of this._plugins.values()) {
229
230
  if (
@@ -301,13 +302,19 @@ class PluginsManager {
301
302
  this.loadedPlugins.push(plugin.name);
302
303
  }
303
304
 
305
+ if (!_.isEmpty(plugin.instance.imports)) {
306
+ _.merge(defaultImports, plugin.instance.imports);
307
+ }
308
+
304
309
  return null;
305
310
  });
306
311
 
307
312
  loadPlugins.push(promise);
308
313
  }
309
314
 
310
- return Promise.all(loadPlugins);
315
+ await Promise.all(loadPlugins);
316
+
317
+ return defaultImports;
311
318
  }
312
319
 
313
320
  /**
@@ -165,11 +165,12 @@ class Kuzzle extends kuzzleEventEmitter_1.default {
165
165
  // before opening connections to external users
166
166
  await this.entryPoint.init();
167
167
  this.pluginsManager.application = application;
168
- await this.pluginsManager.init(options.plugins);
168
+ const pluginImports = await this.pluginsManager.init(options.plugins);
169
169
  this.log.info(`[✔] Successfully loaded ${this.pluginsManager.loadedPlugins.length} plugins: ${this.pluginsManager.loadedPlugins.join(", ")}`);
170
+ const imports = lodash_1.default.merge({}, pluginImports, options.import);
170
171
  // Authentification plugins must be loaded before users import to avoid
171
172
  // credentials related error which would prevent Kuzzle from starting
172
- await this.loadInitialState(options.import, options.support);
173
+ await this.loadInitialState(imports, options.support);
173
174
  await this.ask("core:security:verify");
174
175
  this.router.init();
175
176
  this.log.info("[✔] Core components loaded");
@@ -4,6 +4,7 @@ import { PluginManifest } from "./PluginManifest";
4
4
  import { StrategyDefinition } from "./StrategyDefinition";
5
5
  import { PipeEventHandler, HookEventHandler } from "./EventHandler";
6
6
  import { JSONObject } from "../../index";
7
+ import { ImportConfig } from "./Kuzzle";
7
8
  /**
8
9
  * Allows to define plugins controllers and actions
9
10
  */
@@ -102,6 +103,10 @@ export declare abstract class Plugin {
102
103
  * @see https://docs.kuzzle.io/core/2/plugins/guides/strategies/overview
103
104
  */
104
105
  strategies?: StrategyDefinition;
106
+ /**
107
+ * Define default imports
108
+ */
109
+ imports?: ImportConfig;
105
110
  /**
106
111
  * Plugin initialization method.
107
112
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "kuzzle",
3
3
  "author": "The Kuzzle Team <support@kuzzle.io>",
4
- "version": "2.20.1",
4
+ "version": "2.20.2",
5
5
  "description": "Kuzzle is an open-source solution that handles all the data management through a secured API, with a large choice of protocols.",
6
6
  "bin": "bin/start-kuzzle-server",
7
7
  "scripts": {
@@ -56,7 +56,7 @@
56
56
  "eslint-plugin-kuzzle": "^0.0.6",
57
57
  "eventemitter3": "^4.0.7",
58
58
  "inquirer": "^9.1.4",
59
- "ioredis": "^5.2.4",
59
+ "ioredis": "^5.3.0",
60
60
  "js-yaml": "^4.1.0",
61
61
  "json-stable-stringify": "^1.0.2",
62
62
  "json2yaml": "^1.1.0",
@@ -74,13 +74,13 @@
74
74
  "ndjson": "^2.0.0",
75
75
  "node-segfault-handler": "^1.4.2",
76
76
  "passport": "^0.6.0",
77
- "protobufjs": "~7.1.2",
77
+ "protobufjs": "~7.2.1",
78
78
  "rc": "1.2.8",
79
79
  "semver": "^7.3.8",
80
80
  "sorted-array": "^2.0.4",
81
81
  "uuid": "^9.0.0",
82
82
  "uWebSockets.js": "https://github.com/uNetworking/uWebSockets.js/archive/refs/tags/v20.0.0.tar.gz",
83
- "validator": "^13.7.0",
83
+ "validator": "^13.9.0",
84
84
  "winston": "^3.8.2",
85
85
  "winston-elasticsearch": "0.17.1",
86
86
  "winston-syslog": "^2.7.0",
@@ -93,17 +93,17 @@
93
93
  "url": "git://github.com/kuzzleio/kuzzle.git"
94
94
  },
95
95
  "devDependencies": {
96
- "@jest/globals": "^29.3.1",
97
- "@types/jest": "^29.2.5",
96
+ "@jest/globals": "^29.4.1",
97
+ "@types/jest": "^29.4.0",
98
98
  "@types/js-yaml": "^4.0.5",
99
- "@types/lodash": "^4.14.190",
99
+ "@types/lodash": "^4.14.191",
100
100
  "async": "^3.2.4",
101
101
  "chokidar": "^3.5.3",
102
102
  "codecov": "^3.8.3",
103
103
  "cucumber": "^6.0.5",
104
104
  "ergol": "^1.0.2",
105
- "jest": "^29.3.1",
106
- "mocha": "^10.1.0",
105
+ "jest": "^29.4.1",
106
+ "mocha": "^10.2.0",
107
107
  "mock-require": "^3.0.3",
108
108
  "mqtt": "^4.3.7",
109
109
  "nyc": "^15.1.0",
@@ -116,8 +116,8 @@
116
116
  "strip-json-comments": "https://github.com/sindresorhus/strip-json-comments/archive/refs/tags/v3.1.1.tar.gz",
117
117
  "ts-jest": "^29.0.5",
118
118
  "ts-node": "^10.9.1",
119
- "typescript": "^4.9.3",
120
- "yaml": "^2.1.3"
119
+ "typescript": "^4.9.5",
120
+ "yaml": "^2.2.1"
121
121
  },
122
122
  "engines": {
123
123
  "node": ">= 12.13.0"