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.
Files changed (41) hide show
  1. package/index.d.ts +1 -0
  2. package/index.js +1 -0
  3. package/lib/api/controllers/authController.d.ts +3 -2
  4. package/lib/api/funnel.js +2 -1
  5. package/lib/config/default.config.js +1 -0
  6. package/lib/core/backend/backendStorage.d.ts +3 -5
  7. package/lib/core/backend/backendStorage.js +8 -10
  8. package/lib/core/plugin/pluginContext.d.ts +2 -3
  9. package/lib/core/plugin/pluginContext.js +6 -4
  10. package/lib/core/security/tokenRepository.d.ts +1 -1
  11. package/lib/core/security/tokenRepository.js +1 -1
  12. package/lib/core/shared/ObjectRepository.d.ts +1 -1
  13. package/lib/core/storage/clientAdapter.js +6 -4
  14. package/lib/core/storage/storageEngine.js +4 -5
  15. package/lib/kerror/index.js +1 -1
  16. package/lib/kuzzle/event/KuzzleEventEmitter.d.ts +70 -0
  17. package/lib/kuzzle/event/KuzzleEventEmitter.js +328 -0
  18. package/lib/kuzzle/index.d.ts +3 -0
  19. package/lib/kuzzle/index.js +7 -4
  20. package/lib/kuzzle/kuzzle.d.ts +32 -19
  21. package/lib/kuzzle/kuzzle.js +31 -31
  22. package/lib/service/storage/{elasticsearch.d.ts → 7/elasticsearch.d.ts} +40 -22
  23. package/lib/service/storage/{elasticsearch.js → 7/elasticsearch.js} +24 -43
  24. package/lib/service/storage/{esWrapper.js → 7/esWrapper.js} +6 -4
  25. package/lib/service/storage/8/elasticsearch.d.ts +972 -0
  26. package/lib/service/storage/8/elasticsearch.js +2925 -0
  27. package/lib/service/storage/8/esWrapper.js +303 -0
  28. package/lib/service/storage/Elasticsearch.d.ts +9 -0
  29. package/lib/service/storage/Elasticsearch.js +48 -0
  30. package/lib/service/storage/commons/queryTranslator.d.ts +5 -0
  31. package/lib/service/storage/commons/queryTranslator.js +189 -0
  32. package/lib/types/EventHandler.d.ts +29 -1
  33. package/lib/types/config/KuzzleConfiguration.d.ts +2 -1
  34. package/lib/types/config/storageEngine/StorageEngineElasticsearchConfiguration.d.ts +6 -2
  35. package/lib/types/storage/{Elasticsearch.d.ts → 7/Elasticsearch.d.ts} +1 -1
  36. package/lib/types/storage/8/Elasticsearch.d.ts +59 -0
  37. package/lib/types/storage/8/Elasticsearch.js +3 -0
  38. package/package.json +7 -4
  39. package/lib/kuzzle/event/kuzzleEventEmitter.js +0 -405
  40. package/lib/service/storage/queryTranslator.js +0 -219
  41. /package/lib/types/storage/{Elasticsearch.js → 7/Elasticsearch.js} +0 -0
@@ -0,0 +1,328 @@
1
+ "use strict";
2
+ /*
3
+ * Kuzzle, a backend software, self-hostable and ready to use
4
+ * to power modern apps
5
+ *
6
+ * Copyright 2015-2022 Kuzzle
7
+ * mailto: support AT kuzzle.io
8
+ * website: http://kuzzle.io
9
+ *
10
+ * Licensed under the Apache License, Version 2.0 (the "License");
11
+ * you may not use this file except in compliance with the License.
12
+ * You may obtain a copy of the License at
13
+ *
14
+ * https://www.apache.org/licenses/LICENSE-2.0
15
+ *
16
+ * Unless required by applicable law or agreed to in writing, software
17
+ * distributed under the License is distributed on an "AS IS" BASIS,
18
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ * See the License for the specific language governing permissions and
20
+ * limitations under the License.
21
+ */
22
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
23
+ if (k2 === undefined) k2 = k;
24
+ var desc = Object.getOwnPropertyDescriptor(m, k);
25
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
26
+ desc = { enumerable: true, get: function() { return m[k]; } };
27
+ }
28
+ Object.defineProperty(o, k2, desc);
29
+ }) : (function(o, m, k, k2) {
30
+ if (k2 === undefined) k2 = k;
31
+ o[k2] = m[k];
32
+ }));
33
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
34
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
35
+ }) : function(o, v) {
36
+ o["default"] = v;
37
+ });
38
+ var __importStar = (this && this.__importStar) || function (mod) {
39
+ if (mod && mod.__esModule) return mod;
40
+ var result = {};
41
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
42
+ __setModuleDefault(result, mod);
43
+ return result;
44
+ };
45
+ var __importDefault = (this && this.__importDefault) || function (mod) {
46
+ return (mod && mod.__esModule) ? mod : { "default": mod };
47
+ };
48
+ Object.defineProperty(exports, "__esModule", { value: true });
49
+ // Most of the functions exposed in this file should be viewed as
50
+ // critical section of code.
51
+ const assert_1 = __importDefault(require("assert"));
52
+ const bluebird_1 = __importDefault(require("bluebird"));
53
+ const eventemitter3_1 = __importDefault(require("eventemitter3"));
54
+ const uuid_1 = require("uuid");
55
+ const debug_1 = __importDefault(require("../../util/debug"));
56
+ const kerror = __importStar(require("../../kerror"));
57
+ const memoize_1 = __importDefault(require("../../util/memoize"));
58
+ const promback_1 = __importDefault(require("../../util/promback"));
59
+ const pipeRunner_1 = __importDefault(require("./pipeRunner"));
60
+ const debug = (0, debug_1.default)("kuzzle:events");
61
+ class PluginPipeDefinition {
62
+ constructor(event, handler, pipeId = null) {
63
+ this.event = event;
64
+ this.handler = handler;
65
+ this.pipeId = pipeId || (0, uuid_1.v4)();
66
+ }
67
+ }
68
+ class KuzzleEventEmitter extends eventemitter3_1.default {
69
+ constructor(maxConcurrentPipes, pipesBufferSize) {
70
+ super();
71
+ this.superEmit = super.emit;
72
+ this.pipeRunner = new pipeRunner_1.default(maxConcurrentPipes, pipesBufferSize);
73
+ /**
74
+ * Map of plugin pipe handler functions by event
75
+ */
76
+ this.pluginPipes = new Map();
77
+ /**
78
+ * Map of plugin pipe definitions by pipeId
79
+ */
80
+ this.pluginPipeDefinitions = new Map();
81
+ this.corePipes = new Map();
82
+ this.coreAnswerers = new Map();
83
+ this.coreSyncedAnswerers = new Map();
84
+ }
85
+ /**
86
+ * Registers a core method on a pipe
87
+ * Note: core methods cannot listen to wildcarded events, only exact matching
88
+ * works here.
89
+ */
90
+ onPipe(event, fn) {
91
+ (0, assert_1.default)(typeof fn === "function", `Cannot listen to pipe event ${event}: "${fn}" is not a function`);
92
+ if (!this.corePipes.has(event)) {
93
+ this.corePipes.set(event, []);
94
+ }
95
+ this.corePipes.get(event).push(fn);
96
+ }
97
+ /**
98
+ * Registers a core 'ask' event answerer
99
+ * There can only be 0 or 1 answerer per ask event.
100
+ */
101
+ onAsk(event, fn) {
102
+ (0, assert_1.default)(typeof fn === "function", `Cannot listen to ask event "${event}": "${fn}" is not a function`);
103
+ (0, assert_1.default)(!this.coreAnswerers.has(event), `Cannot add a listener to the ask event "${event}": event has already an answerer`);
104
+ this.coreAnswerers.set(event, fn);
105
+ }
106
+ /**
107
+ * Registers a core 'callback' answerer
108
+ * There can only be 0 or 1 answerer per callback event.
109
+ */
110
+ onCall(event, fn) {
111
+ (0, assert_1.default)(typeof fn === "function", `Cannot register callback for event "${event}": "${fn}" is not a function`);
112
+ (0, assert_1.default)(!this.coreSyncedAnswerers.has(event), `Cannot register callback for event "${event}": a callback has already been registered`);
113
+ this.coreSyncedAnswerers.set(event, fn);
114
+ }
115
+ /**
116
+ * Emits an event and all its wildcarded versions
117
+ *
118
+ * @warning Critical section of code
119
+ */
120
+ emit(event, ...args) {
121
+ const events = getWildcardEvents(event);
122
+ debug('Triggering event "%s" with data: %o', event, args);
123
+ if (events.length === 0) {
124
+ debug('No listeners for event "%s"', event);
125
+ return false;
126
+ }
127
+ for (const element of events) {
128
+ super.emit(element, ...args);
129
+ }
130
+ return true;
131
+ }
132
+ /**
133
+ * Emits a pipe event, which triggers the following, in that order:
134
+ * 1. Plugin pipes are invoked one after another (waterfall). Each plugin must
135
+ * resolve the pipe (with a callback or a promise) with a similar payload
136
+ * than the one received
137
+ * 2. Core pipes are invoked in parallel. They are awaited for (promises-only)
138
+ * but their responses are neither evaluated nor used
139
+ * 3. Hooks are invoked in parallel. They are not awaited.
140
+ *
141
+ * Accepts a callback argument (to be used by pipes invoked before the funnel
142
+ * overload-protection mechanism). If a callback is provided, this method
143
+ * doesn't return a promise.
144
+ *
145
+ * @warning Critical section of code
146
+ */
147
+ pipe(event, ...payload) {
148
+ debug('Triggering pipe "%s" with payload: %o', event, payload);
149
+ let callback = null;
150
+ // safe: a pipe's payload can never contain functions
151
+ if (payload.length > 0 &&
152
+ typeof payload[payload.length - 1] === "function") {
153
+ callback = payload.pop();
154
+ }
155
+ const events = getWildcardEvents(event);
156
+ const funcs = [];
157
+ for (const element of events) {
158
+ const targets = this.pluginPipes.get(element);
159
+ if (targets) {
160
+ for (const t of targets) {
161
+ funcs.push(t);
162
+ }
163
+ }
164
+ }
165
+ // Create a context for the emitPluginPipe callback
166
+ const promback = new promback_1.default(callback);
167
+ const callbackContext = {
168
+ events,
169
+ instance: this,
170
+ promback,
171
+ targetEvent: event,
172
+ };
173
+ if (funcs.length === 0) {
174
+ pipeCallback.call(callbackContext, null, ...payload);
175
+ }
176
+ else {
177
+ this.pipeRunner.run(funcs, payload, pipeCallback, callbackContext);
178
+ }
179
+ return promback.deferred;
180
+ }
181
+ /**
182
+ * Emits an "ask" event to get information about the provided payload
183
+ */
184
+ async ask(event, ...args) {
185
+ debug('Triggering ask "%s" with payload: %o', event, args);
186
+ const fn = this.coreAnswerers.get(event);
187
+ if (!fn) {
188
+ throw kerror.get("core", "fatal", "assertion_failed", `the requested ask event '${event}' doesn't have an answerer`);
189
+ }
190
+ const response = await fn(...args);
191
+ for (const ev of getWildcardEvents(event)) {
192
+ super.emit(ev, {
193
+ args,
194
+ response,
195
+ });
196
+ }
197
+ return response;
198
+ }
199
+ /**
200
+ * Calls a callback to get information about the provided payload
201
+ */
202
+ call(event, ...args) {
203
+ debug('Triggering callback "%s" with payload: %o', event, args);
204
+ const fn = this.coreSyncedAnswerers.get(event);
205
+ if (!fn) {
206
+ throw kerror.get("core", "fatal", "assertion_failed", `the requested callback event '${event}' doesn't have an answerer`);
207
+ }
208
+ const response = fn(...args);
209
+ for (const ev of getWildcardEvents(event)) {
210
+ super.emit(ev, {
211
+ args,
212
+ response,
213
+ });
214
+ }
215
+ return response;
216
+ }
217
+ /**
218
+ * Registers a plugin hook.
219
+ * Catch any error in the handler and emit the hook:onError event.
220
+ */
221
+ registerPluginHook(pluginName, event, fn) {
222
+ this.on(event, (...args) => {
223
+ try {
224
+ const ret = fn(...args, event);
225
+ if (typeof ret === "object" && typeof ret.catch === "function") {
226
+ ret.catch((error) => {
227
+ if (event !== "hook:onError") {
228
+ this.emit("hook:onError", { error, event, pluginName });
229
+ }
230
+ else {
231
+ this.emit("plugin:hook:loop-error", { error, pluginName });
232
+ }
233
+ });
234
+ }
235
+ }
236
+ catch (error) {
237
+ if (event !== "hook:onError") {
238
+ this.emit("hook:onError", { error, event, pluginName });
239
+ }
240
+ else {
241
+ this.emit("plugin:hook:loop-error", { error, pluginName });
242
+ }
243
+ }
244
+ });
245
+ }
246
+ registerPluginPipe(event, handler) {
247
+ if (!this.pluginPipes.has(event)) {
248
+ this.pluginPipes.set(event, []);
249
+ }
250
+ this.pluginPipes.get(event).push(handler);
251
+ const definition = new PluginPipeDefinition(event, handler);
252
+ this.pluginPipeDefinitions.set(definition.pipeId, definition);
253
+ return definition.pipeId;
254
+ }
255
+ unregisterPluginPipe(pipeId) {
256
+ const definition = this.pluginPipeDefinitions.get(pipeId);
257
+ if (!definition) {
258
+ throw kerror.get("plugin", "runtime", "unknown_pipe", pipeId);
259
+ }
260
+ const handlers = this.pluginPipes.get(definition.event);
261
+ handlers.splice(handlers.indexOf(definition.handler), 1);
262
+ if (handlers.length > 0) {
263
+ this.pluginPipes.set(definition.event, handlers);
264
+ }
265
+ else {
266
+ this.pluginPipes.delete(definition.event);
267
+ }
268
+ this.pluginPipeDefinitions.delete(pipeId);
269
+ }
270
+ /**
271
+ * Checks if an ask event has an answerer
272
+ */
273
+ hasAskAnswerer(event) {
274
+ return this.coreAnswerers.has(event);
275
+ }
276
+ }
277
+ /**
278
+ * We declare the callback used by Kuzzle.pipe one time instead
279
+ * of redeclaring a closure each time we want to run the pipes.
280
+ *
281
+ * The context of this callback must be bound to this following object:
282
+ * { instance: (kuzzle instance), promback, events }
283
+ *
284
+ * @warning Critical section of code
285
+ */
286
+ async function pipeCallback(error, ...updated) {
287
+ /* eslint-disable no-invalid-this */
288
+ if (error) {
289
+ this.promback.reject(error);
290
+ return;
291
+ }
292
+ const corePipes = this.instance.corePipes.get(this.targetEvent);
293
+ if (corePipes) {
294
+ await bluebird_1.default.map(corePipes, (fn) => fn(...updated));
295
+ }
296
+ for (const element of this.events) {
297
+ this.instance.superEmit(element, ...updated);
298
+ }
299
+ this.promback.resolve(updated[0]);
300
+ /* eslint-enable no-invalid-this */
301
+ }
302
+ /**
303
+ * For a specific event, returns the event and all its wildcarded versions
304
+ * @example
305
+ * getWildcardEvents('data:create') // return ['data:create', 'data:*']
306
+ * getWildcardEvents('data:beforeCreate') // return ['data:beforeCreate',
307
+ * // 'data:*', 'data:before*']
308
+ *
309
+ * @warning Critical section of code
310
+ */
311
+ const getWildcardEvents = (0, memoize_1.default)((event) => {
312
+ const events = [event];
313
+ const delimIndex = event.lastIndexOf(":");
314
+ if (delimIndex === -1) {
315
+ return events;
316
+ }
317
+ const scope = event.slice(0, delimIndex);
318
+ const name = event.slice(delimIndex + 1);
319
+ for (const prefix of ["before", "after"]) {
320
+ if (name.startsWith(prefix)) {
321
+ events.push(`${scope}:${prefix}*`);
322
+ }
323
+ }
324
+ events.push(`${scope}:*`);
325
+ return events;
326
+ });
327
+ exports.default = KuzzleEventEmitter;
328
+ //# sourceMappingURL=KuzzleEventEmitter.js.map
@@ -0,0 +1,3 @@
1
+ import { Kuzzle } from "./kuzzle";
2
+ export { Kuzzle };
3
+ export default Kuzzle;
@@ -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
- "use strict";
23
-
24
- module.exports = require("./kuzzle");
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
@@ -1,28 +1,40 @@
1
1
  /// <reference types="node" />
2
- import KuzzleEventEmitter from "./event/kuzzleEventEmitter";
3
- import { InstallationConfig, ImportConfig, SupportConfig, StartOptions } from "./../types/Kuzzle";
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
- private config;
19
+ config: KuzzleConfiguration;
8
20
  private _state;
9
- private log;
21
+ log: Logger;
10
22
  private rootPath;
11
23
  /**
12
24
  * Internal index bootstrapper and accessor
13
25
  */
14
- private internalIndex;
15
- private pluginsManager;
16
- private tokenManager;
17
- private passport;
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
- private funnel;
33
+ funnel: Funnel;
22
34
  /**
23
35
  * The router listens to client requests and pass them to the funnel
24
36
  */
25
- private router;
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
- private entryPoint;
45
+ entryPoint: EntryPoint;
34
46
  /**
35
47
  * Validation core component
36
48
  */
37
- private validation;
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
- private vault;
57
+ vault: vault;
46
58
  /**
47
59
  * AsyncLocalStorage wrapper
48
60
  */
49
- private asyncStore;
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
- private koncorde;
64
- private secret;
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[]): Promise<any>;
100
- emit(...args: any[]): Promise<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;
@@ -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 murmurhash_native_1 = require("murmurhash-native");
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 kuzzleStateEnum_1 = __importDefault(require("./kuzzleStateEnum"));
58
- const kuzzleEventEmitter_1 = __importDefault(require("./event/kuzzleEventEmitter"));
59
- const entryPoint_1 = __importDefault(require("../core/network/entryPoint"));
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 pluginsManager_1 = __importDefault(require("../core/plugin/pluginsManager"));
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 tokenManager_1 = require("../core/auth/tokenManager");
71
+ const storageEngine_1 = __importDefault(require("../core/storage/storageEngine"));
66
72
  const validation_1 = __importDefault(require("../core/validation"));
67
- const log_1 = __importDefault(require("./log"));
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 openapi_1 = require("../api/openapi");
82
- const crypto_1 = require("../util/crypto");
83
- const kuzzleDebugger_1 = require("../core/debug/kuzzleDebugger");
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 kuzzleEventEmitter_1.default {
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 || !installations.length) {
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
- async emit(...args) {
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
- module.exports = Kuzzle;
587
+ exports.default = Kuzzle;
588
588
  //# sourceMappingURL=kuzzle.js.map