kuzzle 2.31.0 → 2.32.0-beta.1
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/index.d.ts +1 -0
- package/index.js +1 -0
- package/lib/api/controllers/authController.d.ts +3 -2
- package/lib/api/funnel.js +2 -1
- 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/tokenRepository.d.ts +1 -1
- package/lib/core/security/tokenRepository.js +1 -1
- package/lib/core/shared/ObjectRepository.d.ts +1 -1
- package/lib/core/storage/clientAdapter.js +6 -4
- package/lib/core/storage/storageEngine.js +4 -5
- package/lib/kerror/index.js +1 -1
- package/lib/kuzzle/event/KuzzleEventEmitter.d.ts +70 -0
- package/lib/kuzzle/event/KuzzleEventEmitter.js +328 -0
- package/lib/kuzzle/index.d.ts +3 -0
- package/lib/kuzzle/index.js +7 -4
- package/lib/kuzzle/kuzzle.d.ts +32 -19
- package/lib/kuzzle/kuzzle.js +31 -31
- package/lib/service/storage/{elasticsearch.d.ts → 7/elasticsearch.d.ts} +40 -22
- package/lib/service/storage/{elasticsearch.js → 7/elasticsearch.js} +24 -43
- 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/commons/queryTranslator.d.ts +5 -0
- package/lib/service/storage/commons/queryTranslator.js +189 -0
- package/lib/types/EventHandler.d.ts +29 -1
- package/lib/types/config/KuzzleConfiguration.d.ts +2 -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 +7 -4
- package/lib/kuzzle/event/kuzzleEventEmitter.js +0 -405
- package/lib/service/storage/queryTranslator.js +0 -219
- /package/lib/types/storage/{Elasticsearch.js → 7/Elasticsearch.js} +0 -0
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import _ from "lodash";
|
|
2
|
-
import { RequestParams, Client
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { storeScopeEnum } from "../../core/storage/storeScopeEnum";
|
|
6
|
-
import Service from "../service";
|
|
2
|
+
import { RequestParams, Client } from "sdk-es7";
|
|
3
|
+
import { TypeMapping } from "sdk-es7/api/types";
|
|
4
|
+
import { JSONObject, KRequestBody, KRequestParams } from "../../../types/storage/7/Elasticsearch";
|
|
7
5
|
import ESWrapper from "./esWrapper";
|
|
8
|
-
import QueryTranslator from "
|
|
6
|
+
import { QueryTranslator } from "../commons/queryTranslator";
|
|
7
|
+
import { storeScopeEnum } from "../../../core/storage/storeScopeEnum";
|
|
9
8
|
/**
|
|
10
9
|
* @param {Kuzzle} kuzzle kuzzle instance
|
|
11
10
|
* @param {Object} config Service configuration
|
|
12
11
|
* @param {storeScopeEnum} scope
|
|
13
12
|
* @constructor
|
|
14
13
|
*/
|
|
15
|
-
export
|
|
16
|
-
_client:
|
|
14
|
+
export declare class ES7 {
|
|
15
|
+
_client: Client;
|
|
17
16
|
_scope: storeScopeEnum;
|
|
18
17
|
_indexPrefix: string;
|
|
19
18
|
_esWrapper: ESWrapper;
|
|
@@ -25,12 +24,6 @@ export default class ElasticSearch extends Service {
|
|
|
25
24
|
maxScrollDuration: number;
|
|
26
25
|
scrollTTL: number;
|
|
27
26
|
_config: any;
|
|
28
|
-
/**
|
|
29
|
-
* Returns a new elasticsearch client instance
|
|
30
|
-
*
|
|
31
|
-
* @returns {Object}
|
|
32
|
-
*/
|
|
33
|
-
static buildClient(config: any): StorageClient;
|
|
34
27
|
constructor(config: any, scope?: storeScopeEnum);
|
|
35
28
|
get scope(): storeScopeEnum;
|
|
36
29
|
/**
|
|
@@ -77,7 +70,15 @@ export default class ElasticSearch extends Service {
|
|
|
77
70
|
scrollTTL?: string;
|
|
78
71
|
}): Promise<{
|
|
79
72
|
aggregations: any;
|
|
80
|
-
hits:
|
|
73
|
+
hits: {
|
|
74
|
+
_id: any;
|
|
75
|
+
_score: any;
|
|
76
|
+
_source: any;
|
|
77
|
+
collection: any;
|
|
78
|
+
highlight: any;
|
|
79
|
+
index: any;
|
|
80
|
+
inner_hits: {};
|
|
81
|
+
}[];
|
|
81
82
|
remaining: any;
|
|
82
83
|
scrollId: any;
|
|
83
84
|
suggest: any;
|
|
@@ -104,7 +105,15 @@ export default class ElasticSearch extends Service {
|
|
|
104
105
|
scroll?: string;
|
|
105
106
|
}): Promise<{
|
|
106
107
|
aggregations: any;
|
|
107
|
-
hits:
|
|
108
|
+
hits: {
|
|
109
|
+
_id: any;
|
|
110
|
+
_score: any;
|
|
111
|
+
_source: any;
|
|
112
|
+
collection: any;
|
|
113
|
+
highlight: any;
|
|
114
|
+
index: any;
|
|
115
|
+
inner_hits: {};
|
|
116
|
+
}[];
|
|
108
117
|
remaining: any;
|
|
109
118
|
scrollId: any;
|
|
110
119
|
suggest: any;
|
|
@@ -119,7 +128,15 @@ export default class ElasticSearch extends Service {
|
|
|
119
128
|
_mapTargetsToAlias(targets: any): {};
|
|
120
129
|
_formatSearchResult(body: any, searchInfo?: any): Promise<{
|
|
121
130
|
aggregations: any;
|
|
122
|
-
hits:
|
|
131
|
+
hits: {
|
|
132
|
+
_id: any;
|
|
133
|
+
_score: any;
|
|
134
|
+
_source: any;
|
|
135
|
+
collection: any;
|
|
136
|
+
highlight: any;
|
|
137
|
+
index: any;
|
|
138
|
+
inner_hits: {};
|
|
139
|
+
}[];
|
|
123
140
|
remaining: any;
|
|
124
141
|
scrollId: any;
|
|
125
142
|
suggest: any;
|
|
@@ -187,7 +204,7 @@ export default class ElasticSearch extends Service {
|
|
|
187
204
|
_version: any;
|
|
188
205
|
}>;
|
|
189
206
|
/**
|
|
190
|
-
* Creates a new document to
|
|
207
|
+
* Creates a new document to Elasticsearch, or replace it if it already exist
|
|
191
208
|
*
|
|
192
209
|
* @param {String} index - Index name
|
|
193
210
|
* @param {String} collection - Collection name
|
|
@@ -253,7 +270,7 @@ export default class ElasticSearch extends Service {
|
|
|
253
270
|
created: boolean;
|
|
254
271
|
}>;
|
|
255
272
|
/**
|
|
256
|
-
* Replaces a document to
|
|
273
|
+
* Replaces a document to Elasticsearch
|
|
257
274
|
*
|
|
258
275
|
* @param {String} index - Index name
|
|
259
276
|
* @param {String} collection - Collection name
|
|
@@ -559,7 +576,7 @@ export default class ElasticSearch extends Service {
|
|
|
559
576
|
*
|
|
560
577
|
* @returns {Promise.<String[]>}
|
|
561
578
|
*/
|
|
562
|
-
deleteIndexes(indexes?: string[]): Promise<any>;
|
|
579
|
+
deleteIndexes(indexes?: string[]): Promise<any[]>;
|
|
563
580
|
/**
|
|
564
581
|
* Deletes an index
|
|
565
582
|
*
|
|
@@ -830,7 +847,7 @@ export default class ElasticSearch extends Service {
|
|
|
830
847
|
* @returns {String} Alias name (eg: '@&nepali.liia')
|
|
831
848
|
* @throws If there is not exactly one alias associated that is prefixed with @
|
|
832
849
|
*/
|
|
833
|
-
_getAliasFromIndice(indice:
|
|
850
|
+
_getAliasFromIndice(indice: string): Promise<string[]>;
|
|
834
851
|
/**
|
|
835
852
|
* Check for each indice whether it has an alias or not.
|
|
836
853
|
* When the latter is missing, create one based on the indice name.
|
|
@@ -870,7 +887,7 @@ export default class ElasticSearch extends Service {
|
|
|
870
887
|
*
|
|
871
888
|
* @returns {Object.<String, String[]>} Indexes as key and an array of their collections as value
|
|
872
889
|
*/
|
|
873
|
-
_extractSchema(aliases:
|
|
890
|
+
_extractSchema(aliases: string[], { includeHidden }?: {
|
|
874
891
|
includeHidden?: boolean;
|
|
875
892
|
}): {};
|
|
876
893
|
/**
|
|
@@ -953,4 +970,5 @@ export default class ElasticSearch extends Service {
|
|
|
953
970
|
_checkDynamicProperty(mappings: any): void;
|
|
954
971
|
_setLastActionToKuzzleMeta(esRequest: JSONObject, alias: string, kuzzleMeta: JSONObject): void;
|
|
955
972
|
_setLastActionToKuzzleMetaUpdate(item: JSONObject, kuzzleMeta: JSONObject): void;
|
|
973
|
+
_getRandomNumber(number: number): number;
|
|
956
974
|
}
|
|
@@ -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 =
|
|
58
|
+
const queryTranslator_1 = 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,35 +97,16 @@ 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;
|
|
125
106
|
this._client = null;
|
|
126
107
|
this._esWrapper = null;
|
|
127
108
|
this._esVersion = null;
|
|
128
|
-
this._translator = new queryTranslator_1.
|
|
109
|
+
this._translator = new queryTranslator_1.QueryTranslator();
|
|
129
110
|
// Allowed root key of a search query
|
|
130
111
|
this.searchBodyKeys = [
|
|
131
112
|
"aggregations",
|
|
@@ -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
|
{
|