kuzzle 2.44.0 → 2.46.0

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.
Files changed (42) hide show
  1. package/lib/api/controllers/adminController.js +2 -1
  2. package/lib/api/controllers/authController.d.ts +1 -0
  3. package/lib/api/controllers/authController.js +2 -1
  4. package/lib/api/controllers/securityController.js +22 -20
  5. package/lib/api/funnel.js +30 -10
  6. package/lib/cluster/command.js +3 -2
  7. package/lib/cluster/idCardHandler.d.ts +1 -0
  8. package/lib/cluster/idCardHandler.js +2 -1
  9. package/lib/cluster/node.js +18 -19
  10. package/lib/cluster/subscriber.js +5 -3
  11. package/lib/core/backend/backend.d.ts +4 -6
  12. package/lib/core/backend/backend.js +25 -23
  13. package/lib/core/cache/cacheEngine.js +3 -1
  14. package/lib/core/network/accessLogger.js +3 -2
  15. package/lib/core/network/entryPoint.js +7 -7
  16. package/lib/core/network/protocols/httpwsProtocol.js +7 -7
  17. package/lib/core/network/protocols/mqttProtocol.js +3 -2
  18. package/lib/core/network/router.js +4 -3
  19. package/lib/core/plugin/pluginsManager.js +13 -5
  20. package/lib/core/realtime/hotelClerk.d.ts +1 -0
  21. package/lib/core/realtime/hotelClerk.js +4 -3
  22. package/lib/core/realtime/notifier.js +2 -1
  23. package/lib/core/security/roleRepository.js +3 -2
  24. package/lib/core/security/securityLoader.js +5 -7
  25. package/lib/core/shared/store.d.ts +1 -0
  26. package/lib/core/shared/store.js +2 -1
  27. package/lib/core/statistics/statistics.js +3 -1
  28. package/lib/core/storage/storageEngine.js +6 -1
  29. package/lib/core/validation/validation.js +6 -5
  30. package/lib/kuzzle/Logger.d.ts +1 -1
  31. package/lib/kuzzle/Logger.js +7 -7
  32. package/lib/kuzzle/dumpGenerator.js +17 -16
  33. package/lib/kuzzle/internalIndexHandler.js +3 -1
  34. package/lib/kuzzle/kuzzle.js +5 -7
  35. package/lib/service/cache/redis.js +4 -0
  36. package/lib/service/storage/7/elasticsearch.d.ts +1 -0
  37. package/lib/service/storage/7/elasticsearch.js +5 -4
  38. package/lib/service/storage/8/elasticsearch.d.ts +1 -0
  39. package/lib/service/storage/8/elasticsearch.js +5 -4
  40. package/lib/service/storage/Elasticsearch.d.ts +1 -0
  41. package/lib/service/storage/Elasticsearch.js +1 -1
  42. package/package.json +1 -1
@@ -73,7 +73,6 @@ const kerror = __importStar(require("../kerror"));
73
73
  const asyncStore_1 = __importDefault(require("../util/asyncStore"));
74
74
  const crypto_1 = require("../util/crypto");
75
75
  const mutex_1 = require("../util/mutex");
76
- const name_generator_1 = require("../util/name-generator");
77
76
  const dumpGenerator_1 = __importDefault(require("./dumpGenerator"));
78
77
  const KuzzleEventEmitter_1 = __importDefault(require("./event/KuzzleEventEmitter"));
79
78
  const internalIndexHandler_1 = __importDefault(require("./internalIndexHandler"));
@@ -152,7 +151,7 @@ class Kuzzle extends KuzzleEventEmitter_1.default {
152
151
  await this.internalIndex.init();
153
152
  await new security_1.default().init();
154
153
  // This will init the cluster module if enabled
155
- this.id = await this.initKuzzleNode();
154
+ await this.initKuzzleNode();
156
155
  this.vault = vault_1.default.load(options.vaultKey, options.secretsFile);
157
156
  await this.validation.init();
158
157
  await this.tokenManager.init();
@@ -165,7 +164,6 @@ class Kuzzle extends KuzzleEventEmitter_1.default {
165
164
  await this.debugger.init();
166
165
  this.pluginsManager.application = application;
167
166
  const pluginImports = await this.pluginsManager.init(options.plugins);
168
- this.log.info(`[✔] Successfully loaded ${this.pluginsManager.loadedPlugins.length} plugins: ${this.pluginsManager.loadedPlugins.join(", ")}`);
169
167
  const imports = lodash_1.default.merge({}, pluginImports, options.import);
170
168
  // Authentification plugins must be loaded before users import to avoid
171
169
  // credentials related error which would prevent Kuzzle from starting
@@ -197,16 +195,13 @@ class Kuzzle extends KuzzleEventEmitter_1.default {
197
195
  * This will init the cluster if it's enabled.
198
196
  */
199
197
  async initKuzzleNode() {
200
- let id;
201
198
  if (this.config.cluster.enabled) {
202
- id = await new cluster_1.default().init();
199
+ await new cluster_1.default().init();
203
200
  this.log.info("[✔] Cluster initialized");
204
201
  }
205
202
  else {
206
- id = name_generator_1.NameGenerator.generateRandomName({ prefix: "knode" });
207
203
  this.log.info("[X] Cluster disabled: single node mode.");
208
204
  }
209
- return id;
210
205
  }
211
206
  /**
212
207
  * Gracefully exits after processing remaining requests
@@ -226,6 +221,9 @@ class Kuzzle extends KuzzleEventEmitter_1.default {
226
221
  await bluebird_1.default.delay(1000);
227
222
  }
228
223
  this.log.info("Halted.");
224
+ // flush both application and Kuzzle core loggers before leaving (Could happen even if some core/application components are not initialized)
225
+ await this?.log?.flush?.();
226
+ await this?.pluginsManager?.application?.log?.flush?.();
229
227
  process.exit(0);
230
228
  }
231
229
  /**
@@ -43,6 +43,10 @@ class Redis extends Service {
43
43
  this.commands = {};
44
44
  this.adapterName = name;
45
45
  this.pingIntervalID = null;
46
+
47
+ this.logger = global.kuzzle.log.child // It means we're in the main Kuzzle process
48
+ ? global.kuzzle.log.child("services:cache:redis")
49
+ : global.kuzzle.log;
46
50
  }
47
51
 
48
52
  /**
@@ -24,6 +24,7 @@ export declare class ES7 {
24
24
  maxScrollDuration: number;
25
25
  scrollTTL: number;
26
26
  _config: any;
27
+ private readonly logger;
27
28
  constructor(config: any, scope?: storeScopeEnum);
28
29
  get scope(): storeScopeEnum;
29
30
  /**
@@ -99,6 +99,7 @@ let esState = esStateEnum.NONE;
99
99
  */
100
100
  class ES7 {
101
101
  constructor(config, scope = storeScopeEnum_1.storeScopeEnum.PUBLIC) {
102
+ this.logger = global.kuzzle.log.child("service:storage:elasticsearch:7");
102
103
  this._config = config;
103
104
  this._scope = scope;
104
105
  this._indexPrefix =
@@ -151,7 +152,7 @@ class ES7 {
151
152
  }
152
153
  if (global.NODE_ENV !== "development" &&
153
154
  this._config.commonMapping.dynamic === "true") {
154
- global.kuzzle.log.warn([
155
+ this.logger.warn([
155
156
  "Your dynamic mapping policy is set to 'true' for new fields.",
156
157
  "Elasticsearch will try to automatically infer mapping for new fields, and those cannot be changed afterward.",
157
158
  'See the "services.storageEngine.commonMapping.dynamic" option in the kuzzlerc configuration file to change this value.',
@@ -2768,7 +2769,7 @@ class ES7 {
2768
2769
  return;
2769
2770
  }
2770
2771
  esState = esStateEnum.AWAITING;
2771
- global.kuzzle.log.info("[ℹ] Trying to connect to Elasticsearch...");
2772
+ this.logger.info("[ℹ] Trying to connect to Elasticsearch...");
2772
2773
  while (esState !== esStateEnum.OK) {
2773
2774
  try {
2774
2775
  // Wait for at least 1 shard to be initialized
@@ -2776,11 +2777,11 @@ class ES7 {
2776
2777
  wait_for_no_initializing_shards: true,
2777
2778
  });
2778
2779
  if (health.body.number_of_pending_tasks === 0) {
2779
- global.kuzzle.log.info("[✔] Elasticsearch is ready");
2780
+ this.logger.info("[✔] Elasticsearch is ready");
2780
2781
  esState = esStateEnum.OK;
2781
2782
  }
2782
2783
  else {
2783
- global.kuzzle.log.info(`[ℹ] Still waiting for Elasticsearch: ${health.body.number_of_pending_tasks} cluster tasks remaining`);
2784
+ this.logger.info(`[ℹ] Still waiting for Elasticsearch: ${health.body.number_of_pending_tasks} cluster tasks remaining`);
2784
2785
  await bluebird_1.default.delay(1000);
2785
2786
  }
2786
2787
  }
@@ -23,6 +23,7 @@ export declare class ES8 {
23
23
  maxScrollDuration: number;
24
24
  scrollTTL: number;
25
25
  _config: any;
26
+ private readonly logger;
26
27
  constructor(config: any, scope?: storeScopeEnum);
27
28
  get scope(): storeScopeEnum;
28
29
  /**
@@ -99,6 +99,7 @@ let esState = esStateEnum.NONE;
99
99
  */
100
100
  class ES8 {
101
101
  constructor(config, scope = storeScopeEnum_1.storeScopeEnum.PUBLIC) {
102
+ this.logger = global.kuzzle.log.child("service:storage:elasticsearch:8");
102
103
  this._config = config;
103
104
  this._scope = scope;
104
105
  this._indexPrefix =
@@ -151,7 +152,7 @@ class ES8 {
151
152
  }
152
153
  if (global.NODE_ENV !== "development" &&
153
154
  this._config.commonMapping.dynamic === "true") {
154
- global.kuzzle.log.warn([
155
+ this.logger.warn([
155
156
  "Your dynamic mapping policy is set to 'true' for new fields.",
156
157
  "Elasticsearch will try to automatically infer mapping for new fields, and those cannot be changed afterward.",
157
158
  'See the "services.storageEngine.commonMapping.dynamic" option in the kuzzlerc configuration file to change this value.',
@@ -2758,7 +2759,7 @@ class ES8 {
2758
2759
  return;
2759
2760
  }
2760
2761
  esState = esStateEnum.AWAITING;
2761
- global.kuzzle.log.info("[ℹ] Trying to connect to Elasticsearch...");
2762
+ this.logger.info("[ℹ] Trying to connect to Elasticsearch...");
2762
2763
  while (esState !== esStateEnum.OK) {
2763
2764
  try {
2764
2765
  // Wait for at least 1 shard to be initialized
@@ -2766,11 +2767,11 @@ class ES8 {
2766
2767
  wait_for_no_initializing_shards: true,
2767
2768
  });
2768
2769
  if (health.number_of_pending_tasks === 0) {
2769
- global.kuzzle.log.info("[✔] Elasticsearch is ready");
2770
+ this.logger.info("[✔] Elasticsearch is ready");
2770
2771
  esState = esStateEnum.OK;
2771
2772
  }
2772
2773
  else {
2773
- global.kuzzle.log.info(`[ℹ] Still waiting for Elasticsearch: ${health.number_of_pending_tasks} cluster tasks remaining`);
2774
+ this.logger.info(`[ℹ] Still waiting for Elasticsearch: ${health.number_of_pending_tasks} cluster tasks remaining`);
2774
2775
  await bluebird_1.default.delay(1000);
2775
2776
  }
2776
2777
  }
@@ -2,6 +2,7 @@ import Service from "../service";
2
2
  import { storeScopeEnum } from "../../core/storage/storeScopeEnum";
3
3
  export declare class Elasticsearch extends Service {
4
4
  client: any;
5
+ private readonly logger;
5
6
  constructor(config: any, scope?: storeScopeEnum);
6
7
  static buildClient(config: any, version?: "7" | "8"): any;
7
8
  _initSequence(): Promise<void>;
@@ -13,7 +13,7 @@ const storeScopeEnum_1 = require("../../core/storage/storeScopeEnum");
13
13
  class Elasticsearch extends service_1.default {
14
14
  constructor(config, scope = storeScopeEnum_1.storeScopeEnum.PUBLIC) {
15
15
  super("elasticsearch", config);
16
- global.kuzzle.log.info(`[ℹ] Elasticsearch configuration is set to major version : ${config.majorVersion}`);
16
+ this.logger = global.kuzzle.log.child("service:storage:elasticsearch");
17
17
  if (config.majorVersion === "7") {
18
18
  this.client = new elasticsearch_1.ES7(config, scope);
19
19
  }
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.44.0",
4
+ "version": "2.46.0",
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": {