kuzzle 2.20.1 → 2.20.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.
@@ -420,6 +420,7 @@ const defaultConfig = {
420
420
  onUpdateConflictRetries: 0,
421
421
  scrollTTL: "15s",
422
422
  },
423
+ generateMissingAliases: true,
423
424
  },
424
425
  },
425
426
  stats: {
@@ -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
  /**
@@ -175,10 +175,12 @@ class ClientAdapter {
175
175
  /**
176
176
  * Populates the index cache with existing index/collection.
177
177
  * Also checks for duplicated index names.
178
- *
179
- * @returns {Promise}
180
178
  */
181
179
  async populateCache() {
180
+ if (global.kuzzle.config.services.storageEngine.generateMissingAliases) {
181
+ await this.client.generateMissingAliases();
182
+ }
183
+
182
184
  const schema = await this.client.getSchema();
183
185
 
184
186
  for (const [index, collections] of Object.entries(schema)) {
@@ -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");
@@ -1894,10 +1894,6 @@ class ElasticSearch extends Service {
1894
1894
  * @returns {Object.<String, String[]>} Object<index, collections>
1895
1895
  */
1896
1896
  async getSchema() {
1897
- // This check avoids a breaking change for those who were using Kuzzle before
1898
- // alias attribution for each indice was the standard ('auto-version')
1899
- await this._ensureAliasConsistency();
1900
-
1901
1897
  let body;
1902
1898
  try {
1903
1899
  ({ body } = await this._client.cat.aliases({ format: "json" }));
@@ -3044,9 +3040,9 @@ class ElasticSearch extends Service {
3044
3040
  * When the latter is missing, create one based on the indice name.
3045
3041
  *
3046
3042
  * This check avoids a breaking change for those who were using Kuzzle before
3047
- * alias attribution for each indice turned into a standard ('auto-version').
3043
+ * alias attribution for each indice turned into a standard (appear in 2.14.0).
3048
3044
  */
3049
- async _ensureAliasConsistency() {
3045
+ async generateMissingAliases() {
3050
3046
  try {
3051
3047
  const { body } = await this._client.cat.indices({ format: "json" });
3052
3048
  const indices = body.map(({ index: indice }) => indice);
@@ -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
  *
@@ -318,9 +318,21 @@ export type StorageEngineElasticsearch = {
318
318
  };
319
319
  };
320
320
  };
321
- maxScrollDuration: "1m";
321
+ maxScrollDuration: string;
322
322
  defaults: {
323
- onUpdateConflictRetries: 0;
324
- scrollTTL: "15s";
323
+ onUpdateConflictRetries: number;
324
+ scrollTTL: string;
325
325
  };
326
+ /**
327
+ * If true, Kuzzle will generate aliases for collections that don't have one.
328
+ *
329
+ * Typically, if an indice named `&platform.devices` does not have an alias
330
+ * named `@&platform.devices` and pointing on the indice then it will be generated
331
+ * even if another alias already exists on the indice.
332
+ *
333
+ * This option should be true only for retro-compatibility with Kuzzle < 2.14.0
334
+ *
335
+ * Also see https://github.com/kuzzleio/kuzzle/pull/2117
336
+ */
337
+ generateMissingAliases: boolean;
326
338
  };
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.3",
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"