kuzzle 2.31.0-elasticsearch-8.1 → 2.31.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 (32) hide show
  1. package/lib/api/controllers/authController.d.ts +2 -3
  2. package/lib/api/controllers/memoryStorageController.js +11 -3
  3. package/lib/api/funnel.js +3 -0
  4. package/lib/api/request/requestInput.d.ts +2 -0
  5. package/lib/api/request/requestInput.js +9 -0
  6. package/lib/config/default.config.js +0 -1
  7. package/lib/core/backend/backendStorage.d.ts +5 -3
  8. package/lib/core/backend/backendStorage.js +10 -8
  9. package/lib/core/plugin/pluginContext.d.ts +3 -2
  10. package/lib/core/plugin/pluginContext.js +4 -6
  11. package/lib/core/security/profileRepository.d.ts +5 -14
  12. package/lib/core/security/profileRepository.js +17 -50
  13. package/lib/core/security/roleRepository.js +1 -1
  14. package/lib/core/shared/ObjectRepository.js +1 -1
  15. package/lib/core/storage/clientAdapter.js +4 -6
  16. package/lib/core/storage/storageEngine.js +5 -4
  17. package/lib/kuzzle/kuzzle.js +1 -1
  18. package/lib/service/storage/{7/elasticsearch.d.ts → elasticsearch.d.ts} +22 -40
  19. package/lib/service/storage/{7/elasticsearch.js → elasticsearch.js} +42 -23
  20. package/lib/service/storage/{7/esWrapper.js → esWrapper.js} +4 -6
  21. package/lib/service/storage/{commons/queryTranslator.js → queryTranslator.js} +1 -1
  22. package/lib/types/config/storageEngine/StorageEngineElasticsearchConfiguration.d.ts +2 -6
  23. package/lib/types/storage/{7/Elasticsearch.d.ts → Elasticsearch.d.ts} +1 -1
  24. package/package.json +5 -7
  25. package/lib/service/storage/8/elasticsearch.d.ts +0 -972
  26. package/lib/service/storage/8/elasticsearch.js +0 -2925
  27. package/lib/service/storage/8/esWrapper.js +0 -303
  28. package/lib/service/storage/Elasticsearch.d.ts +0 -9
  29. package/lib/service/storage/Elasticsearch.js +0 -47
  30. package/lib/types/storage/8/Elasticsearch.d.ts +0 -59
  31. package/lib/types/storage/8/Elasticsearch.js +0 -3
  32. /package/lib/types/storage/{7/Elasticsearch.js → Elasticsearch.js} +0 -0
@@ -46,24 +46,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
46
46
  return (mod && mod.__esModule) ? mod : { "default": mod };
47
47
  };
48
48
  Object.defineProperty(exports, "__esModule", { value: true });
49
- exports.ES7 = void 0;
50
49
  const lodash_1 = __importDefault(require("lodash"));
51
- const sdk_es7_1 = require("sdk-es7");
50
+ const elasticsearch_1 = require("@elastic/elasticsearch");
52
51
  const assert_1 = __importDefault(require("assert"));
53
52
  const bluebird_1 = __importDefault(require("bluebird"));
54
53
  const ms_1 = __importDefault(require("ms"));
55
54
  const semver_1 = __importDefault(require("semver"));
56
- const debug_1 = __importDefault(require("../../../util/debug"));
55
+ const debug_1 = __importDefault(require("../../util/debug"));
56
+ const storeScopeEnum_1 = require("../../core/storage/storeScopeEnum");
57
+ const kerror = __importStar(require("../../kerror"));
58
+ const didYouMean_1 = __importDefault(require("../../util/didYouMean"));
59
+ const extractFields_1 = __importDefault(require("../../util/extractFields"));
60
+ const mutex_1 = require("../../util/mutex");
61
+ const name_generator_1 = require("../../util/name-generator");
62
+ const requestAssertions_1 = require("../../util/requestAssertions");
63
+ const safeObject_1 = require("../../util/safeObject");
64
+ const service_1 = __importDefault(require("../service"));
57
65
  const esWrapper_1 = __importDefault(require("./esWrapper"));
58
- const queryTranslator_1 = __importDefault(require("../commons/queryTranslator"));
59
- const didYouMean_1 = __importDefault(require("../../../util/didYouMean"));
60
- const kerror = __importStar(require("../../../kerror"));
61
- const requestAssertions_1 = require("../../../util/requestAssertions");
62
- const safeObject_1 = require("../../../util/safeObject");
63
- const extractFields_1 = __importDefault(require("../../../util/extractFields"));
64
- const mutex_1 = require("../../../util/mutex");
65
- const name_generator_1 = require("../../../util/name-generator");
66
- const storeScopeEnum_1 = require("../../../core/storage/storeScopeEnum");
66
+ const queryTranslator_1 = __importDefault(require("./queryTranslator"));
67
67
  (0, debug_1.default)("kuzzle:services:elasticsearch");
68
68
  const SCROLL_CACHE_PREFIX = "_docscroll_";
69
69
  const ROOT_MAPPING_PROPERTIES = [
@@ -97,9 +97,28 @@ let esState = esStateEnum.NONE;
97
97
  * @param {storeScopeEnum} scope
98
98
  * @constructor
99
99
  */
100
- class ES7 {
100
+ class ElasticSearch extends service_1.default {
101
+ /**
102
+ * Returns a new elasticsearch client instance
103
+ *
104
+ * @returns {Object}
105
+ */
106
+ static buildClient(config) {
107
+ // Passed to Elasticsearch's client to make it use
108
+ // Bluebird instead of ES6 promises
109
+ const defer = function defer() {
110
+ let resolve;
111
+ let reject;
112
+ const promise = new bluebird_1.default((res, rej) => {
113
+ resolve = res;
114
+ reject = rej;
115
+ });
116
+ return { promise, reject, resolve };
117
+ };
118
+ return new elasticsearch_1.Client({ defer, ...config });
119
+ }
101
120
  constructor(config, scope = storeScopeEnum_1.storeScopeEnum.PUBLIC) {
102
- this._config = config;
121
+ super("elasticsearch", config);
103
122
  this._scope = scope;
104
123
  this._indexPrefix =
105
124
  scope === storeScopeEnum_1.storeScopeEnum.PRIVATE ? PRIVATE_PREFIX : PUBLIC_PREFIX;
@@ -156,7 +175,7 @@ class ES7 {
156
175
  'See the "services.storageEngine.commonMapping.dynamic" option in the kuzzlerc configuration file to change this value.',
157
176
  ].join("\n"));
158
177
  }
159
- this._client = new sdk_es7_1.Client(this._config.client);
178
+ this._client = ElasticSearch.buildClient(this._config.client);
160
179
  await this.waitForElasticsearch();
161
180
  this._esWrapper = new esWrapper_1.default(this._client);
162
181
  const { body: { version }, } = await this._client.info();
@@ -600,7 +619,7 @@ class ES7 {
600
619
  }
601
620
  }
602
621
  /**
603
- * Creates a new document to Elasticsearch, or replace it if it already exist
622
+ * Creates a new document to ElasticSearch, or replace it if it already exist
604
623
  *
605
624
  * @param {String} index - Index name
606
625
  * @param {String} collection - Collection name
@@ -738,7 +757,7 @@ class ES7 {
738
757
  }
739
758
  }
740
759
  /**
741
- * Replaces a document to Elasticsearch
760
+ * Replaces a document to ElasticSearch
742
761
  *
743
762
  * @param {String} index - Index name
744
763
  * @param {String} collection - Collection name
@@ -2449,7 +2468,7 @@ class ES7 {
2449
2468
  let notAvailable;
2450
2469
  let suffix;
2451
2470
  do {
2452
- suffix = `.${this._getRandomNumber(100000)}`;
2471
+ suffix = `.${(0, name_generator_1.randomNumber)(100000)}`;
2453
2472
  const overflow = Buffer.from(indice + suffix).length - 255;
2454
2473
  if (overflow > 0) {
2455
2474
  const indiceBuffer = Buffer.from(indice);
@@ -2555,7 +2574,7 @@ class ES7 {
2555
2574
  const schema = {};
2556
2575
  for (const alias of aliases) {
2557
2576
  const [indexName, collectionName] = alias
2558
- .slice(INDEX_PREFIX_POSITION_IN_ALIAS + 1)
2577
+ .substr(INDEX_PREFIX_POSITION_IN_ALIAS + 1, alias.length)
2559
2578
  .split(NAME_SEPARATOR);
2560
2579
  if (alias[INDEX_PREFIX_POSITION_IN_ALIAS] === this._indexPrefix &&
2561
2580
  (collectionName !== HIDDEN_COLLECTION || includeHidden)) {
@@ -2837,11 +2856,8 @@ class ES7 {
2837
2856
  }
2838
2857
  }
2839
2858
  }
2840
- _getRandomNumber(number) {
2841
- return (0, name_generator_1.randomNumber)(number);
2842
- }
2843
2859
  }
2844
- exports.ES7 = ES7;
2860
+ exports.default = ElasticSearch;
2845
2861
  /**
2846
2862
  * Finds paths and values of mappings dynamic properties
2847
2863
  *
@@ -2926,4 +2942,7 @@ function _isObjectNameValid(name) {
2926
2942
  }
2927
2943
  return valid;
2928
2944
  }
2945
+ // TODO: Remove this function when we move to Jest
2946
+ // This is kept because we use an old ReRequire that use require() instead of import
2947
+ module.exports = ElasticSearch;
2929
2948
  //# sourceMappingURL=elasticsearch.js.map
@@ -25,13 +25,11 @@
25
25
 
26
26
  const Bluebird = require("bluebird");
27
27
  const _ = require("lodash");
28
- const es = require("sdk-es7");
28
+ const es = require("@elastic/elasticsearch");
29
29
 
30
- const { KuzzleError } = require("../../../kerror/errors");
31
- const debug = require("../../../util/debug")(
32
- "kuzzle:services:storage:ESCommon",
33
- );
34
- const kerror = require("../../../kerror").wrap("services", "storage");
30
+ const { KuzzleError } = require("../../kerror/errors");
31
+ const debug = require("../../util/debug")("kuzzle:services:storage:ESCommon");
32
+ const kerror = require("../../kerror").wrap("services", "storage");
35
33
 
36
34
  const errorMessagesMapping = [
37
35
  {
@@ -21,7 +21,7 @@
21
21
 
22
22
  "use strict";
23
23
 
24
- const kerror = require("../../../kerror");
24
+ const kerror = require("../../kerror");
25
25
 
26
26
  class KeywordError extends Error {
27
27
  constructor(type, name) {
@@ -1,9 +1,5 @@
1
+ import { ClientOptions } from "@elastic/elasticsearch";
1
2
  export type StorageEngineElasticsearch = {
2
- /**
3
- * Elasticsearch major version
4
- * @default "7"
5
- */
6
- majorVersion: "7" | "8";
7
3
  /**
8
4
  * @default ['storageEngine']
9
5
  */
@@ -26,7 +22,7 @@ export type StorageEngineElasticsearch = {
26
22
  * }
27
23
  *
28
24
  */
29
- client: any;
25
+ client: ClientOptions;
30
26
  /**
31
27
  * Default policy against new fields that are not referenced in the
32
28
  * collection mapping.
@@ -1,4 +1,4 @@
1
- import { ByteSize, ClusterNodesStats } from "sdk-es7/api/types";
1
+ import { ByteSize, ClusterNodesStats } from "@elastic/elasticsearch/api/types";
2
2
  export type InfoResult = {
3
3
  type: string;
4
4
  version: string;
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.31.0-elasticsearch-8.1",
4
+ "version": "2.31.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": {
@@ -12,7 +12,7 @@
12
12
  "dev": "ergol docker/scripts/start-kuzzle-dev.ts -c ./config/ergol.config.json",
13
13
  "doc-error-codes": "node -r ts-node/register doc/build-error-codes",
14
14
  "prepublishOnly": "npm run build",
15
- "prettier": "prettier ./lib ./test ./features ./plugins/available/functional-test-plugin --write",
15
+ "prettier": "prettier ./lib ./test ./bin ./features ./plugins/available/functional-test-plugin --write",
16
16
  "test:functional:http": "KUZZLE_PROTOCOL=http cucumber-js --profile http",
17
17
  "test:functional:jest": "jest",
18
18
  "test:functional:legacy:http": "cucumber-js --format progress-bar --profile http ./features-legacy",
@@ -29,6 +29,7 @@
29
29
  "lib": "lib"
30
30
  },
31
31
  "dependencies": {
32
+ "@elastic/elasticsearch": "https://github.com/elastic/elasticsearch-js/archive/refs/tags/v7.13.0.tar.gz",
32
33
  "aedes": "0.46.3",
33
34
  "bluebird": "3.7.2",
34
35
  "cli-color": "2.0.3",
@@ -47,7 +48,7 @@
47
48
  "koncorde": "4.3.0",
48
49
  "kuzzle-plugin-auth-passport-local": "6.4.0",
49
50
  "kuzzle-plugin-logger": "3.0.3",
50
- "kuzzle-sdk": "7.11.1",
51
+ "kuzzle-sdk": "^7.11.3",
51
52
  "kuzzle-vault": "2.0.4",
52
53
  "lodash": "4.17.21",
53
54
  "long": "5.2.3",
@@ -59,9 +60,7 @@
59
60
  "passport": "0.7.0",
60
61
  "protobufjs": "7.2.5",
61
62
  "rc": "1.2.8",
62
- "sdk-es7": "https://github.com/elastic/elasticsearch-js/archive/refs/tags/v7.13.0.tar.gz",
63
- "sdk-es8": "npm:@elastic/elasticsearch@8.12.1",
64
- "semver": "7.6.0",
63
+ "semver": "7.5.4",
65
64
  "sorted-array": "2.0.4",
66
65
  "uuid": "9.0.1",
67
66
  "uWebSockets.js": "https://github.com/uNetworking/uWebSockets.js/archive/refs/tags/v20.34.0.tar.gz",
@@ -85,7 +84,6 @@
85
84
  "@semantic-release/commit-analyzer": "^10.0.1",
86
85
  "@semantic-release/git": "^10.0.1",
87
86
  "@semantic-release/release-notes-generator": "^11.0.4",
88
- "@types/bluebird": "^3.5.42",
89
87
  "@types/jest": "29.5.10",
90
88
  "@types/js-yaml": "4.0.9",
91
89
  "@types/lodash": "4.14.202",