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
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -31,4 +31,5 @@ __exportStar(require("./lib/core/shared/ObjectRepository"), exports);
|
|
|
31
31
|
__exportStar(require("./lib/core/shared/store"), exports);
|
|
32
32
|
__exportStar(require("./lib/core/cache/cacheDbEnum"), exports);
|
|
33
33
|
__exportStar(require("./lib/core/storage/storeScopeEnum"), exports);
|
|
34
|
+
__exportStar(require("./lib/service/storage/commons/queryTranslator"), exports);
|
|
34
35
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import Bluebird from "bluebird";
|
|
1
2
|
import { KuzzleRequest } from "../request";
|
|
2
3
|
import { NativeController } from "./baseController";
|
|
3
4
|
export declare class AuthController extends NativeController {
|
|
@@ -78,7 +79,7 @@ export declare class AuthController extends NativeController {
|
|
|
78
79
|
* @param {KuzzleRequest} request
|
|
79
80
|
* @returns {Promise<Object>}
|
|
80
81
|
*/
|
|
81
|
-
getCurrentUser(request: any): any
|
|
82
|
+
getCurrentUser(request: any): Bluebird<any>;
|
|
82
83
|
/**
|
|
83
84
|
* Returns the rights of the user identified by the given jwt token
|
|
84
85
|
*
|
|
@@ -115,7 +116,7 @@ export declare class AuthController extends NativeController {
|
|
|
115
116
|
*
|
|
116
117
|
* @returns {Promise.<string[]>}
|
|
117
118
|
*/
|
|
118
|
-
getStrategies(): any
|
|
119
|
+
getStrategies(): Bluebird<any>;
|
|
119
120
|
/**
|
|
120
121
|
* @param {KuzzleRequest} request
|
|
121
122
|
* @returns {Promise.<Object>}
|
package/lib/api/funnel.js
CHANGED
|
@@ -754,7 +754,8 @@ class Funnel {
|
|
|
754
754
|
async executePluginRequest(request) {
|
|
755
755
|
try {
|
|
756
756
|
if (request.input.triggerEvents) {
|
|
757
|
-
|
|
757
|
+
const response = await this.processRequest(request);
|
|
758
|
+
return { ...response.result };
|
|
758
759
|
}
|
|
759
760
|
return await doAction(this.getController(request), request);
|
|
760
761
|
} catch (e) {
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ApplicationManager, Backend } from "./index";
|
|
1
|
+
import { ApplicationManager } from "./index";
|
|
3
2
|
export declare class BackendStorage extends ApplicationManager {
|
|
4
3
|
private _client;
|
|
5
4
|
private _Client;
|
|
6
|
-
constructor(application: Backend);
|
|
7
5
|
/**
|
|
8
6
|
* Storage client constructor.
|
|
9
7
|
* (Currently Elasticsearch)
|
|
10
8
|
*
|
|
11
9
|
* @param clientConfig Overload configuration for the underlaying storage client
|
|
12
10
|
*/
|
|
13
|
-
get StorageClient(): new (clientConfig?: any) =>
|
|
11
|
+
get StorageClient(): new (clientConfig?: any) => any;
|
|
14
12
|
/**
|
|
15
13
|
* Access to the underlaying storage engine client.
|
|
16
14
|
* (Currently Elasticsearch)
|
|
17
15
|
*/
|
|
18
|
-
get storageClient():
|
|
16
|
+
get storageClient(): any;
|
|
19
17
|
}
|
|
@@ -19,16 +19,13 @@
|
|
|
19
19
|
* See the License for the specific language governing permissions and
|
|
20
20
|
* limitations under the License.
|
|
21
21
|
*/
|
|
22
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
-
};
|
|
25
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
23
|
exports.BackendStorage = void 0;
|
|
27
|
-
const
|
|
24
|
+
const Elasticsearch_1 = require("../../service/storage/Elasticsearch");
|
|
28
25
|
const index_1 = require("./index");
|
|
29
26
|
class BackendStorage extends index_1.ApplicationManager {
|
|
30
|
-
constructor(
|
|
31
|
-
super(
|
|
27
|
+
constructor() {
|
|
28
|
+
super(...arguments);
|
|
32
29
|
this._client = null;
|
|
33
30
|
this._Client = null;
|
|
34
31
|
}
|
|
@@ -39,13 +36,13 @@ class BackendStorage extends index_1.ApplicationManager {
|
|
|
39
36
|
* @param clientConfig Overload configuration for the underlaying storage client
|
|
40
37
|
*/
|
|
41
38
|
get StorageClient() {
|
|
39
|
+
const kuzzle = this._kuzzle;
|
|
42
40
|
if (!this._Client) {
|
|
43
|
-
const kuzzle = this._kuzzle;
|
|
44
41
|
this._Client = function ESClient(clientConfig = {}) {
|
|
45
|
-
return
|
|
42
|
+
return Elasticsearch_1.Elasticsearch.buildClient({
|
|
46
43
|
...kuzzle.config.services.storageEngine.client,
|
|
47
44
|
...clientConfig,
|
|
48
|
-
});
|
|
45
|
+
}, kuzzle.config.services.storageEngine.majorVersion);
|
|
49
46
|
};
|
|
50
47
|
}
|
|
51
48
|
return this._Client;
|
|
@@ -55,8 +52,9 @@ class BackendStorage extends index_1.ApplicationManager {
|
|
|
55
52
|
* (Currently Elasticsearch)
|
|
56
53
|
*/
|
|
57
54
|
get storageClient() {
|
|
55
|
+
const kuzzle = this._kuzzle;
|
|
58
56
|
if (!this._client) {
|
|
59
|
-
this._client =
|
|
57
|
+
this._client = Elasticsearch_1.Elasticsearch.buildClient(kuzzle.config.services.storageEngine.client, kuzzle.config.services.storageEngine.majorVersion);
|
|
60
58
|
}
|
|
61
59
|
return this._client;
|
|
62
60
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Client } from "@elastic/elasticsearch";
|
|
2
|
-
import { JSONObject } from "kuzzle-sdk";
|
|
3
1
|
import { Koncorde } from "../shared/KoncordeWrapper";
|
|
2
|
+
import { JSONObject } from "kuzzle-sdk";
|
|
4
3
|
import { KuzzleRequest, RequestContext, RequestInput } from "../../../index";
|
|
5
4
|
import { Mutex } from "../../util/mutex";
|
|
6
5
|
import { BackendCluster } from "../backend";
|
|
@@ -122,7 +121,7 @@ export declare class PluginContext {
|
|
|
122
121
|
/**
|
|
123
122
|
* Constructor for Elasticsearch SDK Client
|
|
124
123
|
*/
|
|
125
|
-
ESClient:
|
|
124
|
+
ESClient: new () => any;
|
|
126
125
|
};
|
|
127
126
|
/**
|
|
128
127
|
* @deprecated import directly: `import { BadRequestError, ... } from 'kuzzle'`
|
|
@@ -52,7 +52,7 @@ const KoncordeWrapper_1 = require("../shared/KoncordeWrapper");
|
|
|
52
52
|
const index_1 = require("../../../index");
|
|
53
53
|
const kerror = __importStar(require("../../kerror"));
|
|
54
54
|
const errors_1 = require("../../kerror/errors");
|
|
55
|
-
const
|
|
55
|
+
const Elasticsearch_1 = require("../../service/storage/Elasticsearch");
|
|
56
56
|
const mutex_1 = require("../../util/mutex");
|
|
57
57
|
const promback_1 = __importDefault(require("../../util/promback"));
|
|
58
58
|
const safeObject_1 = require("../../util/safeObject");
|
|
@@ -111,9 +111,8 @@ class PluginContext {
|
|
|
111
111
|
update: (...args) => pluginRepository.update(...args),
|
|
112
112
|
};
|
|
113
113
|
}
|
|
114
|
-
// eslint-disable-next-line no-inner-declarations
|
|
115
114
|
function PluginContextESClient() {
|
|
116
|
-
return
|
|
115
|
+
return Elasticsearch_1.Elasticsearch.buildClient(global.kuzzle.config.services.storageEngine.client);
|
|
117
116
|
}
|
|
118
117
|
this.constructors = {
|
|
119
118
|
BaseValidationType: require("../validation/baseType"),
|
|
@@ -252,7 +251,10 @@ function instantiateRequest(request, data, options = {}) {
|
|
|
252
251
|
target.input.jwt = _request.input.jwt;
|
|
253
252
|
}
|
|
254
253
|
if (_data) {
|
|
255
|
-
target.input.volatile =
|
|
254
|
+
target.input.volatile = {
|
|
255
|
+
..._request.input.volatile,
|
|
256
|
+
..._data.volatile,
|
|
257
|
+
};
|
|
256
258
|
}
|
|
257
259
|
else {
|
|
258
260
|
target.input.volatile = _request.input.volatile;
|
|
@@ -374,7 +374,7 @@ class TokenRepository extends ObjectRepository_1.ObjectRepository {
|
|
|
374
374
|
*
|
|
375
375
|
* So we need to override the TTL auto-refresh function to disable it
|
|
376
376
|
*/
|
|
377
|
-
refreshCacheTTL() {
|
|
377
|
+
async refreshCacheTTL() {
|
|
378
378
|
// This comment is here to please Sonarqube. It requires a comment
|
|
379
379
|
// explaining why a function is empty, but there is no sense
|
|
380
380
|
// duplicating what has been just said in the JSDoc.
|
|
@@ -117,7 +117,7 @@ export declare class ObjectRepository<TObject extends {
|
|
|
117
117
|
refreshCacheTTL(object: JSONObject, options?: {
|
|
118
118
|
key?: string;
|
|
119
119
|
ttl?: number;
|
|
120
|
-
}): any
|
|
120
|
+
}): Promise<any>;
|
|
121
121
|
/**
|
|
122
122
|
* @param object
|
|
123
123
|
* @param options.key - if provided, stores the object to the given key instead of the default one (<collection>/<id>)
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
"use strict";
|
|
23
23
|
|
|
24
|
-
const Elasticsearch = require("../../service/storage/
|
|
24
|
+
const { Elasticsearch } = require("../../service/storage/Elasticsearch");
|
|
25
25
|
const { IndexCache } = require("./indexCache");
|
|
26
26
|
const { isPlainObject } = require("../../util/safeObject");
|
|
27
27
|
const kerror = require("../../kerror");
|
|
@@ -38,16 +38,17 @@ class ClientAdapter {
|
|
|
38
38
|
* @param {storeScopeEnum} scope
|
|
39
39
|
*/
|
|
40
40
|
constructor(scope) {
|
|
41
|
-
this.
|
|
41
|
+
this.es = new Elasticsearch(
|
|
42
42
|
global.kuzzle.config.services.storageEngine,
|
|
43
43
|
scope,
|
|
44
44
|
);
|
|
45
|
+
this.client = this.es.client;
|
|
45
46
|
this.scope = scope;
|
|
46
47
|
this.cache = new IndexCache();
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
async init() {
|
|
50
|
-
await this.
|
|
51
|
+
await this.es.init();
|
|
51
52
|
await this.populateCache();
|
|
52
53
|
|
|
53
54
|
this.registerCollectionEvents();
|
|
@@ -202,6 +203,7 @@ class ClientAdapter {
|
|
|
202
203
|
* @return {Promise}
|
|
203
204
|
* @throws
|
|
204
205
|
*/
|
|
206
|
+
|
|
205
207
|
global.kuzzle.onAsk(
|
|
206
208
|
`core:storage:${this.scope}:collection:create`,
|
|
207
209
|
(index, collection, opts, creationOptions) =>
|
|
@@ -454,7 +456,7 @@ class ClientAdapter {
|
|
|
454
456
|
* @param {string} collection
|
|
455
457
|
* @param {Object} query
|
|
456
458
|
* @param {Object} [opts] -- see Elasticsearch "deleteByQuery" options
|
|
457
|
-
* @returns {Promise.<{ documents, total, deleted, failures: [
|
|
459
|
+
* @returns {Promise.<{ documents, total, deleted, failures: [ id, reason ] }>}
|
|
458
460
|
*/
|
|
459
461
|
global.kuzzle.onAsk(
|
|
460
462
|
`core:storage:${this.scope}:document:deleteByQuery`,
|
|
@@ -21,8 +21,6 @@
|
|
|
21
21
|
|
|
22
22
|
"use strict";
|
|
23
23
|
|
|
24
|
-
const Bluebird = require("bluebird");
|
|
25
|
-
|
|
26
24
|
const kerror = require("../../kerror").wrap("services", "storage");
|
|
27
25
|
const ClientAdapter = require("./clientAdapter");
|
|
28
26
|
const { storeScopeEnum } = require("./storeScopeEnum");
|
|
@@ -42,11 +40,12 @@ class StorageEngine {
|
|
|
42
40
|
* @returns {Promise}
|
|
43
41
|
*/
|
|
44
42
|
async init() {
|
|
45
|
-
await
|
|
43
|
+
await Promise.all([this.public.init(), this.private.init()]);
|
|
46
44
|
|
|
47
|
-
const privateIndexes =
|
|
45
|
+
const privateIndexes = this.private.cache.listIndexes();
|
|
46
|
+
const publicIndexes = this.public.cache.listIndexes();
|
|
48
47
|
|
|
49
|
-
for (const publicIndex of
|
|
48
|
+
for (const publicIndex of publicIndexes) {
|
|
50
49
|
if (privateIndexes.includes(publicIndex)) {
|
|
51
50
|
throw kerror.get("index_already_exists", "public", publicIndex);
|
|
52
51
|
}
|
package/lib/kerror/index.js
CHANGED
|
@@ -169,7 +169,7 @@ function rawGetFrom(domains, source, domain, subdomain, error, ...placeholders)
|
|
|
169
169
|
const derivedError = rawGet(domains, domain, subdomain, error, ...placeholders);
|
|
170
170
|
// If a stacktrace is present, we need to modify the first line because it
|
|
171
171
|
// still contains the original error message
|
|
172
|
-
if (derivedError
|
|
172
|
+
if (derivedError?.stack?.length && source?.stack) {
|
|
173
173
|
const stackArray = source.stack.split("\n");
|
|
174
174
|
stackArray.shift();
|
|
175
175
|
derivedError.stack = [
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import EventEmitter from "eventemitter3";
|
|
2
|
+
import { AskEventDefinition, AskEventHandler, CallEventHandler, EventDefinition, HookEventHandler, PipeEventHandler } from "../../types/EventHandler";
|
|
3
|
+
declare class KuzzleEventEmitter extends EventEmitter {
|
|
4
|
+
private coreAnswerers;
|
|
5
|
+
private coreSyncedAnswerers;
|
|
6
|
+
private corePipes;
|
|
7
|
+
private pipeRunner;
|
|
8
|
+
private pluginPipes;
|
|
9
|
+
private pluginPipeDefinitions;
|
|
10
|
+
private superEmit;
|
|
11
|
+
constructor(maxConcurrentPipes: number, pipesBufferSize: number);
|
|
12
|
+
/**
|
|
13
|
+
* Registers a core method on a pipe
|
|
14
|
+
* Note: core methods cannot listen to wildcarded events, only exact matching
|
|
15
|
+
* works here.
|
|
16
|
+
*/
|
|
17
|
+
onPipe<TEventDefinition extends EventDefinition = EventDefinition>(event: TEventDefinition["name"], fn: PipeEventHandler<TEventDefinition>): void;
|
|
18
|
+
/**
|
|
19
|
+
* Registers a core 'ask' event answerer
|
|
20
|
+
* There can only be 0 or 1 answerer per ask event.
|
|
21
|
+
*/
|
|
22
|
+
onAsk<TAskEventDefinition extends AskEventDefinition = AskEventDefinition>(event: TAskEventDefinition["name"], fn: AskEventHandler<TAskEventDefinition>): void;
|
|
23
|
+
/**
|
|
24
|
+
* Registers a core 'callback' answerer
|
|
25
|
+
* There can only be 0 or 1 answerer per callback event.
|
|
26
|
+
*/
|
|
27
|
+
onCall<TAskEventDefinition extends AskEventDefinition = AskEventDefinition>(event: TAskEventDefinition["name"], fn: CallEventHandler<TAskEventDefinition>): void;
|
|
28
|
+
/**
|
|
29
|
+
* Emits an event and all its wildcarded versions
|
|
30
|
+
*
|
|
31
|
+
* @warning Critical section of code
|
|
32
|
+
*/
|
|
33
|
+
emit(event: string | symbol, ...args: any[]): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Emits a pipe event, which triggers the following, in that order:
|
|
36
|
+
* 1. Plugin pipes are invoked one after another (waterfall). Each plugin must
|
|
37
|
+
* resolve the pipe (with a callback or a promise) with a similar payload
|
|
38
|
+
* than the one received
|
|
39
|
+
* 2. Core pipes are invoked in parallel. They are awaited for (promises-only)
|
|
40
|
+
* but their responses are neither evaluated nor used
|
|
41
|
+
* 3. Hooks are invoked in parallel. They are not awaited.
|
|
42
|
+
*
|
|
43
|
+
* Accepts a callback argument (to be used by pipes invoked before the funnel
|
|
44
|
+
* overload-protection mechanism). If a callback is provided, this method
|
|
45
|
+
* doesn't return a promise.
|
|
46
|
+
*
|
|
47
|
+
* @warning Critical section of code
|
|
48
|
+
*/
|
|
49
|
+
pipe<TEventDefinition extends EventDefinition = EventDefinition>(event: TEventDefinition["name"], ...payload: TEventDefinition["args"]): Promise<TEventDefinition["args"][0]> | null;
|
|
50
|
+
/**
|
|
51
|
+
* Emits an "ask" event to get information about the provided payload
|
|
52
|
+
*/
|
|
53
|
+
ask<TAskEventDefinition extends AskEventDefinition = AskEventDefinition>(event: TAskEventDefinition["name"], ...args: [payload?: TAskEventDefinition["payload"], ...rest: any]): Promise<TAskEventDefinition["result"]>;
|
|
54
|
+
/**
|
|
55
|
+
* Calls a callback to get information about the provided payload
|
|
56
|
+
*/
|
|
57
|
+
call<TAskEventDefinition extends AskEventDefinition = AskEventDefinition>(event: TAskEventDefinition["name"], ...args: [payload?: TAskEventDefinition["payload"], ...rest: any]): TAskEventDefinition["result"];
|
|
58
|
+
/**
|
|
59
|
+
* Registers a plugin hook.
|
|
60
|
+
* Catch any error in the handler and emit the hook:onError event.
|
|
61
|
+
*/
|
|
62
|
+
registerPluginHook<TEventDefinition extends EventDefinition = EventDefinition>(pluginName: string, event: TEventDefinition["name"], fn: HookEventHandler<TEventDefinition>): void;
|
|
63
|
+
registerPluginPipe<TEventDefinition extends EventDefinition = EventDefinition>(event: TEventDefinition["name"], handler: PipeEventHandler<TEventDefinition>): string;
|
|
64
|
+
unregisterPluginPipe(pipeId: string): void;
|
|
65
|
+
/**
|
|
66
|
+
* Checks if an ask event has an answerer
|
|
67
|
+
*/
|
|
68
|
+
hasAskAnswerer(event: string): boolean;
|
|
69
|
+
}
|
|
70
|
+
export default KuzzleEventEmitter;
|