kuzzle 2.30.1-beta.1 → 2.31.0-elasticsearch-8.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.
- package/lib/api/controllers/authController.d.ts +3 -2
- package/lib/api/controllers/memoryStorageController.js +3 -11
- package/lib/config/default.config.js +1 -0
- package/lib/core/backend/backendStorage.d.ts +3 -5
- package/lib/core/backend/backendStorage.js +8 -10
- package/lib/core/plugin/pluginContext.d.ts +2 -3
- package/lib/core/plugin/pluginContext.js +6 -4
- package/lib/core/security/profileRepository.d.ts +14 -5
- package/lib/core/security/profileRepository.js +50 -17
- package/lib/core/security/roleRepository.js +1 -1
- package/lib/core/shared/ObjectRepository.js +1 -1
- package/lib/core/storage/clientAdapter.js +6 -4
- package/lib/core/storage/storageEngine.js +4 -5
- package/lib/kuzzle/kuzzle.js +1 -1
- package/lib/service/storage/{elasticsearch.d.ts → 7/elasticsearch.d.ts} +40 -22
- package/lib/service/storage/{elasticsearch.js → 7/elasticsearch.js} +23 -42
- package/lib/service/storage/{esWrapper.js → 7/esWrapper.js} +6 -4
- package/lib/service/storage/8/elasticsearch.d.ts +972 -0
- package/lib/service/storage/8/elasticsearch.js +2925 -0
- package/lib/service/storage/8/esWrapper.js +303 -0
- package/lib/service/storage/Elasticsearch.d.ts +9 -0
- package/lib/service/storage/Elasticsearch.js +48 -0
- package/lib/service/storage/{queryTranslator.js → commons/queryTranslator.js} +1 -1
- package/lib/types/config/storageEngine/StorageEngineElasticsearchConfiguration.d.ts +6 -2
- package/lib/types/storage/{Elasticsearch.d.ts → 7/Elasticsearch.d.ts} +1 -1
- package/lib/types/storage/8/Elasticsearch.d.ts +59 -0
- package/lib/types/storage/8/Elasticsearch.js +3 -0
- package/package.json +6 -4
- /package/lib/types/storage/{Elasticsearch.js → 7/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;
|
|
49
50
|
const lodash_1 = __importDefault(require("lodash"));
|
|
50
|
-
const
|
|
51
|
+
const sdk_es7_1 = require("sdk-es7");
|
|
51
52
|
const assert_1 = __importDefault(require("assert"));
|
|
52
53
|
const bluebird_1 = __importDefault(require("bluebird"));
|
|
53
54
|
const ms_1 = __importDefault(require("ms"));
|
|
54
55
|
const semver_1 = __importDefault(require("semver"));
|
|
55
|
-
const debug_1 = __importDefault(require("
|
|
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"));
|
|
56
|
+
const debug_1 = __importDefault(require("../../../util/debug"));
|
|
65
57
|
const esWrapper_1 = __importDefault(require("./esWrapper"));
|
|
66
|
-
const queryTranslator_1 = __importDefault(require("
|
|
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");
|
|
67
67
|
(0, debug_1.default)("kuzzle:services:elasticsearch");
|
|
68
68
|
const SCROLL_CACHE_PREFIX = "_docscroll_";
|
|
69
69
|
const ROOT_MAPPING_PROPERTIES = [
|
|
@@ -97,28 +97,9 @@ let esState = esStateEnum.NONE;
|
|
|
97
97
|
* @param {storeScopeEnum} scope
|
|
98
98
|
* @constructor
|
|
99
99
|
*/
|
|
100
|
-
class
|
|
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
|
-
}
|
|
100
|
+
class ES7 {
|
|
120
101
|
constructor(config, scope = storeScopeEnum_1.storeScopeEnum.PUBLIC) {
|
|
121
|
-
|
|
102
|
+
this._config = config;
|
|
122
103
|
this._scope = scope;
|
|
123
104
|
this._indexPrefix =
|
|
124
105
|
scope === storeScopeEnum_1.storeScopeEnum.PRIVATE ? PRIVATE_PREFIX : PUBLIC_PREFIX;
|
|
@@ -175,7 +156,7 @@ class ElasticSearch extends service_1.default {
|
|
|
175
156
|
'See the "services.storageEngine.commonMapping.dynamic" option in the kuzzlerc configuration file to change this value.',
|
|
176
157
|
].join("\n"));
|
|
177
158
|
}
|
|
178
|
-
this._client =
|
|
159
|
+
this._client = new sdk_es7_1.Client(this._config.client);
|
|
179
160
|
await this.waitForElasticsearch();
|
|
180
161
|
this._esWrapper = new esWrapper_1.default(this._client);
|
|
181
162
|
const { body: { version }, } = await this._client.info();
|
|
@@ -619,7 +600,7 @@ class ElasticSearch extends service_1.default {
|
|
|
619
600
|
}
|
|
620
601
|
}
|
|
621
602
|
/**
|
|
622
|
-
* Creates a new document to
|
|
603
|
+
* Creates a new document to Elasticsearch, or replace it if it already exist
|
|
623
604
|
*
|
|
624
605
|
* @param {String} index - Index name
|
|
625
606
|
* @param {String} collection - Collection name
|
|
@@ -757,7 +738,7 @@ class ElasticSearch extends service_1.default {
|
|
|
757
738
|
}
|
|
758
739
|
}
|
|
759
740
|
/**
|
|
760
|
-
* Replaces a document to
|
|
741
|
+
* Replaces a document to Elasticsearch
|
|
761
742
|
*
|
|
762
743
|
* @param {String} index - Index name
|
|
763
744
|
* @param {String} collection - Collection name
|
|
@@ -2468,7 +2449,7 @@ class ElasticSearch extends service_1.default {
|
|
|
2468
2449
|
let notAvailable;
|
|
2469
2450
|
let suffix;
|
|
2470
2451
|
do {
|
|
2471
|
-
suffix = `.${
|
|
2452
|
+
suffix = `.${this._getRandomNumber(100000)}`;
|
|
2472
2453
|
const overflow = Buffer.from(indice + suffix).length - 255;
|
|
2473
2454
|
if (overflow > 0) {
|
|
2474
2455
|
const indiceBuffer = Buffer.from(indice);
|
|
@@ -2574,7 +2555,7 @@ class ElasticSearch extends service_1.default {
|
|
|
2574
2555
|
const schema = {};
|
|
2575
2556
|
for (const alias of aliases) {
|
|
2576
2557
|
const [indexName, collectionName] = alias
|
|
2577
|
-
.
|
|
2558
|
+
.slice(INDEX_PREFIX_POSITION_IN_ALIAS + 1)
|
|
2578
2559
|
.split(NAME_SEPARATOR);
|
|
2579
2560
|
if (alias[INDEX_PREFIX_POSITION_IN_ALIAS] === this._indexPrefix &&
|
|
2580
2561
|
(collectionName !== HIDDEN_COLLECTION || includeHidden)) {
|
|
@@ -2856,8 +2837,11 @@ class ElasticSearch extends service_1.default {
|
|
|
2856
2837
|
}
|
|
2857
2838
|
}
|
|
2858
2839
|
}
|
|
2840
|
+
_getRandomNumber(number) {
|
|
2841
|
+
return (0, name_generator_1.randomNumber)(number);
|
|
2842
|
+
}
|
|
2859
2843
|
}
|
|
2860
|
-
exports.
|
|
2844
|
+
exports.ES7 = ES7;
|
|
2861
2845
|
/**
|
|
2862
2846
|
* Finds paths and values of mappings dynamic properties
|
|
2863
2847
|
*
|
|
@@ -2942,7 +2926,4 @@ function _isObjectNameValid(name) {
|
|
|
2942
2926
|
}
|
|
2943
2927
|
return valid;
|
|
2944
2928
|
}
|
|
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;
|
|
2948
2929
|
//# sourceMappingURL=elasticsearch.js.map
|
|
@@ -25,11 +25,13 @@
|
|
|
25
25
|
|
|
26
26
|
const Bluebird = require("bluebird");
|
|
27
27
|
const _ = require("lodash");
|
|
28
|
-
const es = require("
|
|
28
|
+
const es = require("sdk-es7");
|
|
29
29
|
|
|
30
|
-
const { KuzzleError } = require("
|
|
31
|
-
const debug = require("
|
|
32
|
-
|
|
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");
|
|
33
35
|
|
|
34
36
|
const errorMessagesMapping = [
|
|
35
37
|
{
|