kuzzle 2.45.0 → 2.46.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/check-node-version.js +1 -0
- package/lib/core/backend/backend.d.ts +1 -4
- package/lib/core/backend/backend.js +25 -23
- package/lib/core/plugin/pluginContext.d.ts +5 -0
- package/lib/core/plugin/pluginContext.js +8 -6
- package/lib/kuzzle/Logger.d.ts +1 -1
- package/lib/kuzzle/Logger.js +7 -7
- package/lib/kuzzle/kuzzle.js +6 -7
- package/lib/service/storage/7/elasticsearch.js +6 -0
- package/lib/service/storage/8/elasticsearch.js +6 -0
- package/package.json +19 -19
package/check-node-version.js
CHANGED
|
@@ -133,6 +133,7 @@ export declare class Backend {
|
|
|
133
133
|
*
|
|
134
134
|
*/
|
|
135
135
|
_support: JSONObject;
|
|
136
|
+
private readonly nodeId;
|
|
136
137
|
/**
|
|
137
138
|
* Instantiates a new Kuzzle application
|
|
138
139
|
*
|
|
@@ -170,10 +171,6 @@ export declare class Backend {
|
|
|
170
171
|
* EmbeddedSDK instance
|
|
171
172
|
*/
|
|
172
173
|
get sdk(): EmbeddedSDK;
|
|
173
|
-
/**
|
|
174
|
-
* Cluster node ID
|
|
175
|
-
*/
|
|
176
|
-
get nodeId(): string;
|
|
177
174
|
private get _instanceProxy();
|
|
178
175
|
get started(): boolean;
|
|
179
176
|
protected set started(started: boolean);
|
|
@@ -51,7 +51,9 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
51
51
|
const kuzzle_1 = __importDefault(require("../../kuzzle"));
|
|
52
52
|
const embeddedSdk_1 = require("../shared/sdk/embeddedSdk");
|
|
53
53
|
const kerror = __importStar(require("../../kerror"));
|
|
54
|
-
const index_1 = require("
|
|
54
|
+
const index_1 = require("../../../index");
|
|
55
|
+
const index_2 = require("./index");
|
|
56
|
+
const Logger_1 = require("../../kuzzle/Logger");
|
|
55
57
|
const assertionError = kerror.wrap("plugin", "assert");
|
|
56
58
|
const runtimeError = kerror.wrap("plugin", "runtime");
|
|
57
59
|
let _app = null;
|
|
@@ -115,12 +117,21 @@ class Backend {
|
|
|
115
117
|
throw assertionError.get("invalid_application_name", name);
|
|
116
118
|
}
|
|
117
119
|
this._name = name;
|
|
120
|
+
this.nodeId = index_1.NameGenerator.generateRandomName({ prefix: "knode" });
|
|
118
121
|
Reflect.defineProperty(this, "_kuzzle", {
|
|
119
122
|
writable: true,
|
|
120
123
|
});
|
|
121
124
|
Reflect.defineProperty(this, "_sdk", {
|
|
122
125
|
writable: true,
|
|
123
126
|
});
|
|
127
|
+
Reflect.defineProperty(global, "nodeId", {
|
|
128
|
+
get: () => {
|
|
129
|
+
return this.nodeId;
|
|
130
|
+
},
|
|
131
|
+
set: () => {
|
|
132
|
+
throw new Error("nodeId is read-only");
|
|
133
|
+
},
|
|
134
|
+
});
|
|
124
135
|
/**
|
|
125
136
|
* Set the "started" property in this event so developers can use runtime
|
|
126
137
|
* features in pipes/hooks attached to this event.
|
|
@@ -138,18 +149,19 @@ class Backend {
|
|
|
138
149
|
// Silent if no version can be found
|
|
139
150
|
}
|
|
140
151
|
global.app = this;
|
|
141
|
-
this.pipe = new
|
|
142
|
-
this.hook = new
|
|
143
|
-
this.config = new
|
|
144
|
-
this.vault = new
|
|
145
|
-
this.controller = new
|
|
146
|
-
this.plugin = new
|
|
147
|
-
this.storage = new
|
|
148
|
-
this.import = new
|
|
149
|
-
this.cluster = new
|
|
150
|
-
this.openApi = new
|
|
151
|
-
this.errors = new
|
|
152
|
-
this.subscription = new
|
|
152
|
+
this.pipe = new index_2.BackendPipe(this);
|
|
153
|
+
this.hook = new index_2.BackendHook(this);
|
|
154
|
+
this.config = new index_2.BackendConfig(this);
|
|
155
|
+
this.vault = new index_2.BackendVault(this);
|
|
156
|
+
this.controller = new index_2.BackendController(this);
|
|
157
|
+
this.plugin = new index_2.BackendPlugin(this);
|
|
158
|
+
this.storage = new index_2.BackendStorage(this);
|
|
159
|
+
this.import = new index_2.BackendImport(this);
|
|
160
|
+
this.cluster = new index_2.BackendCluster();
|
|
161
|
+
this.openApi = new index_2.BackendOpenApi(this);
|
|
162
|
+
this.errors = new index_2.BackendErrors(this);
|
|
163
|
+
this.subscription = new index_2.BackendSubscription(this);
|
|
164
|
+
this.log = new Logger_1.Logger(this.config.content, "kuzzle:app");
|
|
153
165
|
this.kerror = kerror;
|
|
154
166
|
try {
|
|
155
167
|
this.commit = this._readCommit();
|
|
@@ -166,7 +178,6 @@ class Backend {
|
|
|
166
178
|
throw runtimeError.get("already_started", "start");
|
|
167
179
|
}
|
|
168
180
|
this._kuzzle = new kuzzle_1.default(this.config.content);
|
|
169
|
-
this.log = this._kuzzle.log.child(`app`);
|
|
170
181
|
for (const plugin of this.config.content.plugins.common.include) {
|
|
171
182
|
const { default: PluginClass } = await Promise.resolve(`${plugin}`).then(s => __importStar(require(s)));
|
|
172
183
|
this.plugin.use(new PluginClass(), {
|
|
@@ -246,15 +257,6 @@ class Backend {
|
|
|
246
257
|
}
|
|
247
258
|
return this._sdk;
|
|
248
259
|
}
|
|
249
|
-
/**
|
|
250
|
-
* Cluster node ID
|
|
251
|
-
*/
|
|
252
|
-
get nodeId() {
|
|
253
|
-
if (!this.started) {
|
|
254
|
-
throw runtimeError.get("unavailable_before_start", "nodeId");
|
|
255
|
-
}
|
|
256
|
-
return this._kuzzle.id;
|
|
257
|
-
}
|
|
258
260
|
get _instanceProxy() {
|
|
259
261
|
return {
|
|
260
262
|
api: this._controllers,
|
|
@@ -4,6 +4,7 @@ import { KuzzleRequest, RequestContext, RequestInput } from "../../../index";
|
|
|
4
4
|
import { Mutex } from "../../util/mutex";
|
|
5
5
|
import { BackendCluster } from "../backend";
|
|
6
6
|
import { EmbeddedSDK } from "../shared/sdk/embeddedSdk";
|
|
7
|
+
import { KuzzleLogger } from "kuzzle-logger/dist";
|
|
7
8
|
export interface Repository {
|
|
8
9
|
create(document: JSONObject, options: any): Promise<any>;
|
|
9
10
|
createOrReplace(document: JSONObject, options: any): Promise<any>;
|
|
@@ -139,6 +140,10 @@ export declare class PluginContext {
|
|
|
139
140
|
* Decrypted secrets from Kuzzle Vault
|
|
140
141
|
*/
|
|
141
142
|
secrets: JSONObject;
|
|
143
|
+
/**
|
|
144
|
+
* Logger instance
|
|
145
|
+
*/
|
|
146
|
+
logger: KuzzleLogger;
|
|
142
147
|
/**
|
|
143
148
|
* Internal Logger
|
|
144
149
|
*/
|
|
@@ -125,14 +125,16 @@ class PluginContext {
|
|
|
125
125
|
RequestInput: index_1.RequestInput,
|
|
126
126
|
};
|
|
127
127
|
Object.freeze(this.constructors);
|
|
128
|
+
this.logger = globalThis.kuzzle.log.child(`${pluginName}`);
|
|
128
129
|
/* context.log ======================================================== */
|
|
130
|
+
// @deprecated backward compatibility only
|
|
129
131
|
this.log = {
|
|
130
|
-
debug: (msg) =>
|
|
131
|
-
error: (msg) =>
|
|
132
|
-
info: (msg) =>
|
|
133
|
-
silly: (msg) =>
|
|
134
|
-
verbose: (msg) =>
|
|
135
|
-
warn: (msg) =>
|
|
132
|
+
debug: (msg) => this.logger.debug(`[${pluginName}] ${msg}`),
|
|
133
|
+
error: (msg) => this.logger.error(`[${pluginName}] ${msg}`),
|
|
134
|
+
info: (msg) => this.logger.info(`[${pluginName}] ${msg}`),
|
|
135
|
+
silly: (msg) => this.logger.trace(`[${pluginName}] ${msg}`),
|
|
136
|
+
verbose: (msg) => this.logger.trace(`[${pluginName}] ${msg}`),
|
|
137
|
+
warn: (msg) => this.logger.warn(`[${pluginName}] ${msg}`),
|
|
136
138
|
};
|
|
137
139
|
Object.freeze(this.log);
|
|
138
140
|
/* context.accessors ================================================== */
|
package/lib/kuzzle/Logger.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { KuzzleConfiguration } from "../../";
|
|
|
6
6
|
export declare class Logger extends KuzzleLogger {
|
|
7
7
|
private warnedForSillyDeprecation;
|
|
8
8
|
private warnedForVerboseDeprecation;
|
|
9
|
-
constructor(kuzzleConfig: KuzzleConfiguration);
|
|
9
|
+
constructor(kuzzleConfig: KuzzleConfiguration, namespace?: string);
|
|
10
10
|
/**
|
|
11
11
|
* Logs a message with the "silly" level.
|
|
12
12
|
*
|
package/lib/kuzzle/Logger.js
CHANGED
|
@@ -26,15 +26,18 @@ const kuzzle_logger_1 = require("kuzzle-logger");
|
|
|
26
26
|
* The Logger class provides logging functionality for Kuzzle.
|
|
27
27
|
*/
|
|
28
28
|
class Logger extends kuzzle_logger_1.KuzzleLogger {
|
|
29
|
-
constructor(kuzzleConfig) {
|
|
29
|
+
constructor(kuzzleConfig, namespace = "kuzzle") {
|
|
30
30
|
const config = kuzzleConfig.server.appLogs;
|
|
31
31
|
const deprecatedConfig = kuzzleConfig.plugins["kuzzle-plugin-logger"];
|
|
32
32
|
const getMergingObject = () => {
|
|
33
33
|
const mergingObject = {};
|
|
34
|
-
mergingObject.namespace =
|
|
34
|
+
mergingObject.namespace = namespace;
|
|
35
35
|
mergingObject.failsafeMode = Boolean(kuzzleConfig.plugins.common.failsafeMode);
|
|
36
|
-
if (global.
|
|
37
|
-
mergingObject.nodeId = global.
|
|
36
|
+
if (global.nodeId) {
|
|
37
|
+
mergingObject.nodeId = global.nodeId;
|
|
38
|
+
}
|
|
39
|
+
if (namespace !== "kuzzle") {
|
|
40
|
+
return mergingObject;
|
|
38
41
|
}
|
|
39
42
|
if (global.kuzzle.asyncStore?.exists() &&
|
|
40
43
|
global.kuzzle.asyncStore?.has("REQUEST")) {
|
|
@@ -74,9 +77,6 @@ class Logger extends kuzzle_logger_1.KuzzleLogger {
|
|
|
74
77
|
if (deprecatedConfig) {
|
|
75
78
|
this.warn("[DEPRECATED] The plugins.kuzzle-plugin-logger configuration is deprecated, use server.logs instead.");
|
|
76
79
|
}
|
|
77
|
-
global.kuzzle.onPipe("kuzzle:shutdown", async () => {
|
|
78
|
-
await this.flush();
|
|
79
|
-
});
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
82
|
* Logs a message with the "silly" level.
|
package/lib/kuzzle/kuzzle.js
CHANGED
|
@@ -73,7 +73,6 @@ const kerror = __importStar(require("../kerror"));
|
|
|
73
73
|
const asyncStore_1 = __importDefault(require("../util/asyncStore"));
|
|
74
74
|
const crypto_1 = require("../util/crypto");
|
|
75
75
|
const mutex_1 = require("../util/mutex");
|
|
76
|
-
const name_generator_1 = require("../util/name-generator");
|
|
77
76
|
const dumpGenerator_1 = __importDefault(require("./dumpGenerator"));
|
|
78
77
|
const KuzzleEventEmitter_1 = __importDefault(require("./event/KuzzleEventEmitter"));
|
|
79
78
|
const internalIndexHandler_1 = __importDefault(require("./internalIndexHandler"));
|
|
@@ -152,7 +151,7 @@ class Kuzzle extends KuzzleEventEmitter_1.default {
|
|
|
152
151
|
await this.internalIndex.init();
|
|
153
152
|
await new security_1.default().init();
|
|
154
153
|
// This will init the cluster module if enabled
|
|
155
|
-
|
|
154
|
+
await this.initKuzzleNode();
|
|
156
155
|
this.vault = vault_1.default.load(options.vaultKey, options.secretsFile);
|
|
157
156
|
await this.validation.init();
|
|
158
157
|
await this.tokenManager.init();
|
|
@@ -180,7 +179,7 @@ class Kuzzle extends KuzzleEventEmitter_1.default {
|
|
|
180
179
|
await this.pipe("kuzzle:state:live");
|
|
181
180
|
await this.entryPoint.startListening();
|
|
182
181
|
await this.pipe("kuzzle:state:ready");
|
|
183
|
-
this.log.info(`[✔] Kuzzle ${this.version} is ready (node name: ${
|
|
182
|
+
this.log.info(`[✔] Kuzzle ${this.version} is ready (node name: ${global.nodeId})`);
|
|
184
183
|
// @deprecated
|
|
185
184
|
this.emit("core:kuzzleStart", "Kuzzle is ready to accept requests");
|
|
186
185
|
this._state = kuzzleStateEnum_1.default.RUNNING;
|
|
@@ -196,16 +195,13 @@ class Kuzzle extends KuzzleEventEmitter_1.default {
|
|
|
196
195
|
* This will init the cluster if it's enabled.
|
|
197
196
|
*/
|
|
198
197
|
async initKuzzleNode() {
|
|
199
|
-
let id;
|
|
200
198
|
if (this.config.cluster.enabled) {
|
|
201
|
-
|
|
199
|
+
await new cluster_1.default().init();
|
|
202
200
|
this.log.info("[✔] Cluster initialized");
|
|
203
201
|
}
|
|
204
202
|
else {
|
|
205
|
-
id = name_generator_1.NameGenerator.generateRandomName({ prefix: "knode" });
|
|
206
203
|
this.log.info("[X] Cluster disabled: single node mode.");
|
|
207
204
|
}
|
|
208
|
-
return id;
|
|
209
205
|
}
|
|
210
206
|
/**
|
|
211
207
|
* Gracefully exits after processing remaining requests
|
|
@@ -225,6 +221,9 @@ class Kuzzle extends KuzzleEventEmitter_1.default {
|
|
|
225
221
|
await bluebird_1.default.delay(1000);
|
|
226
222
|
}
|
|
227
223
|
this.log.info("Halted.");
|
|
224
|
+
// flush both application and Kuzzle core loggers before leaving (Could happen even if some core/application components are not initialized)
|
|
225
|
+
await this?.log?.flush?.();
|
|
226
|
+
await this?.pluginsManager?.application?.log?.flush?.();
|
|
228
227
|
process.exit(0);
|
|
229
228
|
}
|
|
230
229
|
/**
|
|
@@ -2329,6 +2329,9 @@ class ES7 {
|
|
|
2329
2329
|
_processExtract(prepareMUpsert, prepareMGet, metadata, document, extractedDocuments, documentsToGet) {
|
|
2330
2330
|
let extractedDocument;
|
|
2331
2331
|
if (prepareMUpsert) {
|
|
2332
|
+
if (document.changes !== undefined && document.changes !== null) {
|
|
2333
|
+
delete document.changes._kuzzle_info;
|
|
2334
|
+
}
|
|
2332
2335
|
extractedDocument = {
|
|
2333
2336
|
_source: {
|
|
2334
2337
|
// Do not use destructuring, it's 10x slower
|
|
@@ -2338,6 +2341,9 @@ class ES7 {
|
|
|
2338
2341
|
};
|
|
2339
2342
|
}
|
|
2340
2343
|
else {
|
|
2344
|
+
if (document.body !== undefined && document.body !== null) {
|
|
2345
|
+
delete document.body._kuzzle_info;
|
|
2346
|
+
}
|
|
2341
2347
|
extractedDocument = {
|
|
2342
2348
|
// Do not use destructuring, it's 10x slower
|
|
2343
2349
|
_source: Object.assign({}, metadata, document.body),
|
|
@@ -2322,6 +2322,9 @@ class ES8 {
|
|
|
2322
2322
|
_processExtract(prepareMUpsert, prepareMGet, metadata, document, extractedDocuments, documentsToGet) {
|
|
2323
2323
|
let extractedDocument;
|
|
2324
2324
|
if (prepareMUpsert) {
|
|
2325
|
+
if (document.changes !== undefined && document.changes !== null) {
|
|
2326
|
+
delete document.changes._kuzzle_info;
|
|
2327
|
+
}
|
|
2325
2328
|
extractedDocument = {
|
|
2326
2329
|
_source: {
|
|
2327
2330
|
// Do not use destructuring, it's 10x slower
|
|
@@ -2331,6 +2334,9 @@ class ES8 {
|
|
|
2331
2334
|
};
|
|
2332
2335
|
}
|
|
2333
2336
|
else {
|
|
2337
|
+
if (document.body !== undefined && document.body !== null) {
|
|
2338
|
+
delete document.body._kuzzle_info;
|
|
2339
|
+
}
|
|
2334
2340
|
extractedDocument = {
|
|
2335
2341
|
// Do not use destructuring, it's 10x slower
|
|
2336
2342
|
_source: Object.assign({}, metadata, document.body),
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kuzzle",
|
|
3
3
|
"author": "The Kuzzle Team <support@kuzzle.io>",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.46.0-beta.1",
|
|
5
5
|
"description": "Kuzzle is an open-source solution that handles all the data management through a secured API, with a large choice of protocols.",
|
|
6
6
|
"bin": "bin/start-kuzzle-server",
|
|
7
7
|
"scripts": {
|
|
@@ -33,21 +33,21 @@
|
|
|
33
33
|
"bluebird": "3.7.2",
|
|
34
34
|
"cli-color": "2.0.4",
|
|
35
35
|
"cookie": "1.0.2",
|
|
36
|
-
"debug": "4.4.
|
|
36
|
+
"debug": "4.4.3",
|
|
37
37
|
"denque": "2.1.0",
|
|
38
38
|
"didyoumean": "1.2.2",
|
|
39
39
|
"dumpme": "2.0.0",
|
|
40
40
|
"eventemitter3": "5.0.1",
|
|
41
|
-
"inquirer": "12.
|
|
42
|
-
"ioredis": "5.
|
|
41
|
+
"inquirer": "12.9.6",
|
|
42
|
+
"ioredis": "5.8.0",
|
|
43
43
|
"js-yaml": "4.1.0",
|
|
44
44
|
"json-stable-stringify": "1.3.0",
|
|
45
45
|
"json2yaml": "1.1.0",
|
|
46
46
|
"jsonwebtoken": "9.0.2",
|
|
47
47
|
"koncorde": "4.6.0",
|
|
48
|
-
"kuzzle-logger": "1.
|
|
48
|
+
"kuzzle-logger": "1.4.0",
|
|
49
49
|
"kuzzle-plugin-auth-passport-local": "6.4.1",
|
|
50
|
-
"kuzzle-sdk": ">=7.15.
|
|
50
|
+
"kuzzle-sdk": ">=7.15.1",
|
|
51
51
|
"kuzzle-vault": "2.1.0",
|
|
52
52
|
"lodash": "4.17.21",
|
|
53
53
|
"long": "5.3.2",
|
|
@@ -59,9 +59,9 @@
|
|
|
59
59
|
"pino-caller": "4.0.0",
|
|
60
60
|
"pino-elasticsearch": "8.1.0",
|
|
61
61
|
"pino-loki": "2.6.0",
|
|
62
|
-
"pino-pretty": "13.
|
|
62
|
+
"pino-pretty": "13.1.1",
|
|
63
63
|
"pino-transport-ecs": "1.1.0",
|
|
64
|
-
"protobufjs": "7.5.
|
|
64
|
+
"protobufjs": "7.5.4",
|
|
65
65
|
"rc": "1.2.8",
|
|
66
66
|
"sdk-es7": "npm:@elastic/elasticsearch@7.13.0",
|
|
67
67
|
"sdk-es8": "npm:@elastic/elasticsearch@8.17.1",
|
|
@@ -82,9 +82,9 @@
|
|
|
82
82
|
"url": "git://github.com/kuzzleio/kuzzle.git"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
|
-
"@commitlint/cli": "
|
|
86
|
-
"@commitlint/config-conventional": "
|
|
87
|
-
"@jest/globals": "30.
|
|
85
|
+
"@commitlint/cli": "20.0.0",
|
|
86
|
+
"@commitlint/config-conventional": "20.0.0",
|
|
87
|
+
"@jest/globals": "30.1.2",
|
|
88
88
|
"@types/bluebird": "3.5.42",
|
|
89
89
|
"@types/cookie": "1.0.0",
|
|
90
90
|
"@types/jest": "30.0.0",
|
|
@@ -96,10 +96,10 @@
|
|
|
96
96
|
"cucumber": "6.0.7",
|
|
97
97
|
"cz-conventional-changelog": "3.3.0",
|
|
98
98
|
"eslint-plugin-kuzzle": "0.0.14",
|
|
99
|
-
"jest": "30.
|
|
100
|
-
"mocha": "11.7.
|
|
99
|
+
"jest": "30.1.3",
|
|
100
|
+
"mocha": "11.7.2",
|
|
101
101
|
"mock-require": "3.0.3",
|
|
102
|
-
"mqtt": "5.
|
|
102
|
+
"mqtt": "5.14.1",
|
|
103
103
|
"nyc": "17.1.0",
|
|
104
104
|
"request": "2.88.2",
|
|
105
105
|
"request-promise": "4.2.6",
|
|
@@ -109,16 +109,16 @@
|
|
|
109
109
|
"should-sinon": "0.0.6",
|
|
110
110
|
"sinon": "21.0.0",
|
|
111
111
|
"strip-json-comments": "https://github.com/sindresorhus/strip-json-comments/archive/refs/tags/v3.1.1.tar.gz",
|
|
112
|
-
"ts-jest": "29.4.
|
|
112
|
+
"ts-jest": "29.4.4",
|
|
113
113
|
"ts-node": "10.9.2",
|
|
114
|
-
"tsx": "4.20.
|
|
115
|
-
"typescript": "5.
|
|
116
|
-
"yaml": "2.8.
|
|
114
|
+
"tsx": "4.20.6",
|
|
115
|
+
"typescript": "5.4.5",
|
|
116
|
+
"yaml": "2.8.1"
|
|
117
117
|
},
|
|
118
118
|
"engines": {
|
|
119
119
|
"node": ">=18.0.0 <23.0.0"
|
|
120
120
|
},
|
|
121
|
-
"packageManager": "npm@11.
|
|
121
|
+
"packageManager": "npm@11.6.1",
|
|
122
122
|
"engineStrict": true,
|
|
123
123
|
"license": "Apache-2.0",
|
|
124
124
|
"files": [
|