kuzzle 2.31.0 → 2.32.0-elasticsearch-8.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/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/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} +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/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/types/storage/{Elasticsearch.js → 7/Elasticsearch.js} +0 -0
package/lib/kuzzle/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/*
|
|
2
3
|
* Kuzzle, a backend software, self-hostable and ready to use
|
|
3
4
|
* to power modern apps
|
|
@@ -18,7 +19,9 @@
|
|
|
18
19
|
* See the License for the specific language governing permissions and
|
|
19
20
|
* limitations under the License.
|
|
20
21
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.Kuzzle = void 0;
|
|
24
|
+
const kuzzle_1 = require("./kuzzle");
|
|
25
|
+
Object.defineProperty(exports, "Kuzzle", { enumerable: true, get: function () { return kuzzle_1.Kuzzle; } });
|
|
26
|
+
exports.default = kuzzle_1.Kuzzle;
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
package/lib/kuzzle/kuzzle.d.ts
CHANGED
|
@@ -1,28 +1,40 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import { Koncorde } from "koncorde";
|
|
3
|
+
import Funnel from "../api/funnel";
|
|
4
|
+
import PassportWrapper from "../core/auth/passportWrapper";
|
|
5
|
+
import { TokenManager } from "../core/auth/tokenManager";
|
|
6
|
+
import EntryPoint from "../core/network/entryPoint";
|
|
7
|
+
import Router from "../core/network/router";
|
|
8
|
+
import PluginsManager from "../core/plugin/pluginsManager";
|
|
9
|
+
import Validation from "../core/validation";
|
|
4
10
|
import { KuzzleConfiguration } from "../types/config/KuzzleConfiguration";
|
|
11
|
+
import AsyncStore from "../util/asyncStore";
|
|
12
|
+
import { ImportConfig, InstallationConfig, StartOptions, SupportConfig } from "./../types/Kuzzle";
|
|
13
|
+
import KuzzleEventEmitter from "./event/KuzzleEventEmitter";
|
|
14
|
+
import InternalIndexHandler from "./internalIndexHandler";
|
|
15
|
+
import Logger from "./log";
|
|
16
|
+
import vault from "./vault";
|
|
5
17
|
export declare const BACKEND_IMPORT_KEY = "backend:init:import";
|
|
6
18
|
declare class Kuzzle extends KuzzleEventEmitter {
|
|
7
|
-
|
|
19
|
+
config: KuzzleConfiguration;
|
|
8
20
|
private _state;
|
|
9
|
-
|
|
21
|
+
log: Logger;
|
|
10
22
|
private rootPath;
|
|
11
23
|
/**
|
|
12
24
|
* Internal index bootstrapper and accessor
|
|
13
25
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
26
|
+
internalIndex: InternalIndexHandler;
|
|
27
|
+
pluginsManager: PluginsManager;
|
|
28
|
+
tokenManager: TokenManager;
|
|
29
|
+
passport: PassportWrapper;
|
|
18
30
|
/**
|
|
19
31
|
* The funnel dispatches messages to API controllers
|
|
20
32
|
*/
|
|
21
|
-
|
|
33
|
+
funnel: Funnel;
|
|
22
34
|
/**
|
|
23
35
|
* The router listens to client requests and pass them to the funnel
|
|
24
36
|
*/
|
|
25
|
-
|
|
37
|
+
router: Router;
|
|
26
38
|
/**
|
|
27
39
|
* Statistics core component
|
|
28
40
|
*/
|
|
@@ -30,11 +42,11 @@ declare class Kuzzle extends KuzzleEventEmitter {
|
|
|
30
42
|
/**
|
|
31
43
|
* Network entry point
|
|
32
44
|
*/
|
|
33
|
-
|
|
45
|
+
entryPoint: EntryPoint;
|
|
34
46
|
/**
|
|
35
47
|
* Validation core component
|
|
36
48
|
*/
|
|
37
|
-
|
|
49
|
+
validation: Validation;
|
|
38
50
|
/**
|
|
39
51
|
* Dump generator
|
|
40
52
|
*/
|
|
@@ -42,11 +54,11 @@ declare class Kuzzle extends KuzzleEventEmitter {
|
|
|
42
54
|
/**
|
|
43
55
|
* Vault component (will be initialized after bootstrap)
|
|
44
56
|
*/
|
|
45
|
-
|
|
57
|
+
vault: vault;
|
|
46
58
|
/**
|
|
47
59
|
* AsyncLocalStorage wrapper
|
|
48
60
|
*/
|
|
49
|
-
|
|
61
|
+
asyncStore: AsyncStore;
|
|
50
62
|
/**
|
|
51
63
|
* Kuzzle internal debugger
|
|
52
64
|
*/
|
|
@@ -60,8 +72,8 @@ declare class Kuzzle extends KuzzleEventEmitter {
|
|
|
60
72
|
* List of differents imports types and their associated method
|
|
61
73
|
*/
|
|
62
74
|
private importTypes;
|
|
63
|
-
|
|
64
|
-
|
|
75
|
+
koncorde: Koncorde;
|
|
76
|
+
secret: string;
|
|
65
77
|
/**
|
|
66
78
|
* Node unique ID amongst other cluster nodes
|
|
67
79
|
*/
|
|
@@ -96,9 +108,9 @@ declare class Kuzzle extends KuzzleEventEmitter {
|
|
|
96
108
|
* @returns {Promise<void>}
|
|
97
109
|
*/
|
|
98
110
|
install(installations: InstallationConfig[]): Promise<void>;
|
|
99
|
-
ask(...args: any
|
|
100
|
-
emit(...args: any[]):
|
|
101
|
-
pipe(...args: any[]): Promise<any>;
|
|
111
|
+
ask(event: string, ...args: [payload?: any, ...rest: any]): Promise<any>;
|
|
112
|
+
emit(event: string, ...args: any[]): boolean;
|
|
113
|
+
pipe(event: string, ...args: any[]): Promise<any>;
|
|
102
114
|
private importUserMappings;
|
|
103
115
|
private importMappings;
|
|
104
116
|
private importFixtures;
|
|
@@ -132,3 +144,4 @@ declare class Kuzzle extends KuzzleEventEmitter {
|
|
|
132
144
|
dumpAndExit(suffix: any): Promise<void>;
|
|
133
145
|
}
|
|
134
146
|
export { Kuzzle };
|
|
147
|
+
export default Kuzzle;
|
package/lib/kuzzle/kuzzle.js
CHANGED
|
@@ -48,39 +48,39 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
48
48
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
49
|
exports.Kuzzle = exports.BACKEND_IMPORT_KEY = void 0;
|
|
50
50
|
const path_1 = __importDefault(require("path"));
|
|
51
|
-
const
|
|
51
|
+
const bluebird_1 = __importDefault(require("bluebird"));
|
|
52
52
|
const json_stable_stringify_1 = __importDefault(require("json-stable-stringify"));
|
|
53
53
|
const koncorde_1 = require("koncorde");
|
|
54
|
-
const bluebird_1 = __importDefault(require("bluebird"));
|
|
55
|
-
const node_segfault_handler_1 = __importDefault(require("node-segfault-handler"));
|
|
56
54
|
const lodash_1 = __importDefault(require("lodash"));
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
const
|
|
55
|
+
const murmurhash_native_1 = require("murmurhash-native");
|
|
56
|
+
const node_segfault_handler_1 = __importDefault(require("node-segfault-handler"));
|
|
57
|
+
const package_json_1 = require("../../package.json");
|
|
60
58
|
const funnel_1 = __importDefault(require("../api/funnel"));
|
|
59
|
+
const openapi_1 = require("../api/openapi");
|
|
60
|
+
const cluster_1 = __importDefault(require("../cluster"));
|
|
61
61
|
const passportWrapper_1 = __importDefault(require("../core/auth/passportWrapper"));
|
|
62
|
-
const
|
|
62
|
+
const tokenManager_1 = require("../core/auth/tokenManager");
|
|
63
|
+
const cacheEngine_1 = __importDefault(require("../core/cache/cacheEngine"));
|
|
64
|
+
const kuzzleDebugger_1 = require("../core/debug/kuzzleDebugger");
|
|
65
|
+
const entryPoint_1 = __importDefault(require("../core/network/entryPoint"));
|
|
63
66
|
const router_1 = __importDefault(require("../core/network/router"));
|
|
67
|
+
const pluginsManager_1 = __importDefault(require("../core/plugin/pluginsManager"));
|
|
68
|
+
const realtime_1 = __importDefault(require("../core/realtime"));
|
|
69
|
+
const security_1 = __importDefault(require("../core/security"));
|
|
64
70
|
const statistics_1 = __importDefault(require("../core/statistics"));
|
|
65
|
-
const
|
|
71
|
+
const storageEngine_1 = __importDefault(require("../core/storage/storageEngine"));
|
|
66
72
|
const validation_1 = __importDefault(require("../core/validation"));
|
|
67
|
-
const
|
|
68
|
-
const vault_1 = __importDefault(require("./vault"));
|
|
69
|
-
const dumpGenerator_1 = __importDefault(require("./dumpGenerator"));
|
|
73
|
+
const kerror = __importStar(require("../kerror"));
|
|
70
74
|
const asyncStore_1 = __importDefault(require("../util/asyncStore"));
|
|
75
|
+
const crypto_1 = require("../util/crypto");
|
|
71
76
|
const mutex_1 = require("../util/mutex");
|
|
72
|
-
const kerror = __importStar(require("../kerror"));
|
|
73
|
-
const internalIndexHandler_1 = __importDefault(require("./internalIndexHandler"));
|
|
74
|
-
const cacheEngine_1 = __importDefault(require("../core/cache/cacheEngine"));
|
|
75
|
-
const storageEngine_1 = __importDefault(require("../core/storage/storageEngine"));
|
|
76
|
-
const security_1 = __importDefault(require("../core/security"));
|
|
77
|
-
const realtime_1 = __importDefault(require("../core/realtime"));
|
|
78
|
-
const cluster_1 = __importDefault(require("../cluster"));
|
|
79
|
-
const package_json_1 = require("../../package.json");
|
|
80
77
|
const name_generator_1 = require("../util/name-generator");
|
|
81
|
-
const
|
|
82
|
-
const
|
|
83
|
-
const
|
|
78
|
+
const dumpGenerator_1 = __importDefault(require("./dumpGenerator"));
|
|
79
|
+
const KuzzleEventEmitter_1 = __importDefault(require("./event/KuzzleEventEmitter"));
|
|
80
|
+
const internalIndexHandler_1 = __importDefault(require("./internalIndexHandler"));
|
|
81
|
+
const kuzzleStateEnum_1 = __importDefault(require("./kuzzleStateEnum"));
|
|
82
|
+
const log_1 = __importDefault(require("./log"));
|
|
83
|
+
const vault_1 = __importDefault(require("./vault"));
|
|
84
84
|
exports.BACKEND_IMPORT_KEY = "backend:init:import";
|
|
85
85
|
let _kuzzle = null;
|
|
86
86
|
Reflect.defineProperty(global, "kuzzle", {
|
|
@@ -99,7 +99,7 @@ Reflect.defineProperty(global, "kuzzle", {
|
|
|
99
99
|
_kuzzle = value;
|
|
100
100
|
},
|
|
101
101
|
});
|
|
102
|
-
class Kuzzle extends
|
|
102
|
+
class Kuzzle extends KuzzleEventEmitter_1.default {
|
|
103
103
|
constructor(config) {
|
|
104
104
|
super(config.plugins.common.maxConcurrentPipes, config.plugins.common.pipesBufferSize);
|
|
105
105
|
this._state = kuzzleStateEnum_1.default.STARTING;
|
|
@@ -240,7 +240,7 @@ class Kuzzle extends kuzzleEventEmitter_1.default {
|
|
|
240
240
|
* @returns {Promise<void>}
|
|
241
241
|
*/
|
|
242
242
|
async install(installations) {
|
|
243
|
-
if (!installations
|
|
243
|
+
if (!installations?.length) {
|
|
244
244
|
return;
|
|
245
245
|
}
|
|
246
246
|
const mutex = new mutex_1.Mutex("backend:installations");
|
|
@@ -269,16 +269,16 @@ class Kuzzle extends kuzzleEventEmitter_1.default {
|
|
|
269
269
|
}
|
|
270
270
|
}
|
|
271
271
|
// For testing purpose
|
|
272
|
-
async ask(...args) {
|
|
273
|
-
return super.ask(...args);
|
|
272
|
+
async ask(event, ...args) {
|
|
273
|
+
return super.ask(event, ...args);
|
|
274
274
|
}
|
|
275
275
|
// For testing purpose
|
|
276
|
-
|
|
277
|
-
return super.emit(...args);
|
|
276
|
+
emit(event, ...args) {
|
|
277
|
+
return super.emit(event, ...args);
|
|
278
278
|
}
|
|
279
279
|
// For testing purpose
|
|
280
|
-
async pipe(...args) {
|
|
281
|
-
return super.pipe(...args);
|
|
280
|
+
async pipe(event, ...args) {
|
|
281
|
+
return super.pipe(event, ...args);
|
|
282
282
|
}
|
|
283
283
|
async importUserMappings(config, status) {
|
|
284
284
|
if (!status.firstCall) {
|
|
@@ -584,5 +584,5 @@ class Kuzzle extends kuzzleEventEmitter_1.default {
|
|
|
584
584
|
}
|
|
585
585
|
}
|
|
586
586
|
exports.Kuzzle = Kuzzle;
|
|
587
|
-
|
|
587
|
+
exports.default = Kuzzle;
|
|
588
588
|
//# sourceMappingURL=kuzzle.js.map
|
|
@@ -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 = __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
|
{
|