kuzzle 2.26.3 → 2.27.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.
@@ -4,7 +4,7 @@ import { KuzzleConfiguration } from "../types/config/KuzzleConfiguration";
4
4
  *
5
5
  * To customize your Kuzzle installation, create a
6
6
  * ".kuzzlerc" file and put your overrides there.
7
- * Please check the ".kuzzlerc.sample" file to get
7
+ * Please check the ".kuzzlerc.sample.jsonc" file to get
8
8
  * started.
9
9
  *
10
10
  * @class KuzzleConfiguration
@@ -10,7 +10,7 @@ const httpRoutes_js_1 = __importDefault(require("../api/httpRoutes.js"));
10
10
  *
11
11
  * To customize your Kuzzle installation, create a
12
12
  * ".kuzzlerc" file and put your overrides there.
13
- * Please check the ".kuzzlerc.sample" file to get
13
+ * Please check the ".kuzzlerc.sample.jsonc" file to get
14
14
  * started.
15
15
  *
16
16
  * @class KuzzleConfiguration
@@ -234,6 +234,8 @@ const defaultConfig = {
234
234
  compression: false,
235
235
  rateLimit: 0,
236
236
  realtimeNotifications: true,
237
+ resetIdleTimeoutOnSend: false,
238
+ sendPingsAutomatically: false,
237
239
  },
238
240
  },
239
241
  strictSdkVersion: true,
@@ -197,7 +197,15 @@ function checkWebSocketOptions(config) {
197
197
  );
198
198
  assert(
199
199
  typeof cfg.compression === "boolean",
200
- `[websocket] "compression" parameter: invalid value "${cfg.compression}" (boolean value expected)`
200
+ `[websocket] "compression" parameter: invalid value "${cfg.compression}" (boolean expected)`
201
+ );
202
+ assert(
203
+ typeof cfg.sendPingsAutomatically === "boolean",
204
+ `[websocket] "sendPingsAutomatically" parameter: invalid value "${cfg.sendPingsAutomatically}" (boolean expected)`
205
+ );
206
+ assert(
207
+ typeof cfg.resetIdleTimeoutOnSend === "boolean",
208
+ `[websocket] "resetIdleTimeoutOnSend" parameter: invalid value "${cfg.resetIdleTimeoutOnSend}" (boolean expected)`
201
209
  );
202
210
  }
203
211
 
@@ -334,7 +342,7 @@ function preprocessProtocolsOptions(config) {
334
342
 
335
343
  function preprocessRedisOptions(redisConfig) {
336
344
  // @deprecated Remove those lines for Kuzzle v3 then
337
- // remove also 'database' from .kuzzlerc.sample and default.config
345
+ // remove also 'database' from .kuzzlerc.sample.jsonc and default.config
338
346
  if (redisConfig.database) {
339
347
  redisConfig.options = { db: redisConfig.database, ...redisConfig.options };
340
348
  }
@@ -33,10 +33,10 @@ class HttpMessage {
33
33
  this.connection = connection;
34
34
  this._content = null;
35
35
  this.ips = connection.ips;
36
- this.query = request.getQuery() || "";
36
+ this.query = request.getQuery();
37
37
  this.path = request.getUrl();
38
38
 
39
- if (this.query.length > 0) {
39
+ if (this.query && this.query.length > 0) {
40
40
  this.path = `${request.getUrl()}?${this.query}`;
41
41
  } else {
42
42
  this.path = request.getUrl();
@@ -498,23 +498,30 @@ class HttpWsProtocol extends Protocol {
498
498
  return;
499
499
  }
500
500
 
501
- const contentType = message.headers["content-type"];
501
+ const contentTypeHeader = message.headers["content-type"];
502
502
 
503
- if (
504
- contentType &&
505
- !this.httpConfig.opts.allowedContentTypes.some((allowed) =>
506
- contentType.includes(allowed)
507
- )
508
- ) {
509
- this.httpSendError(
510
- message,
511
- response,
512
- kerrorHTTP.get("unsupported_content", contentType)
513
- );
514
- return;
503
+ if (contentTypeHeader) {
504
+ const contentTypeParamIndex = contentTypeHeader.indexOf(";");
505
+ const contentType =
506
+ contentTypeParamIndex !== -1
507
+ ? contentTypeHeader.slice(0, contentTypeParamIndex).trim()
508
+ : contentTypeHeader.trim();
509
+
510
+ if (
511
+ !this.httpConfig.opts.allowedContentTypes.some(
512
+ (allowed) => contentType === allowed
513
+ )
514
+ ) {
515
+ this.httpSendError(
516
+ message,
517
+ response,
518
+ kerrorHTTP.get("unsupported_content", contentType)
519
+ );
520
+ return;
521
+ }
515
522
  }
516
523
 
517
- const encoding = CHARSET_REGEX.exec(contentType);
524
+ const encoding = CHARSET_REGEX.exec(contentTypeHeader);
518
525
 
519
526
  if (encoding !== null && encoding[1].toLowerCase() !== "utf-8") {
520
527
  this.httpSendError(
@@ -1162,6 +1169,8 @@ class HttpWsProtocol extends Protocol {
1162
1169
  compression,
1163
1170
  idleTimeout: idleTimeoutInSecond,
1164
1171
  maxPayloadLength: this.maxRequestSize,
1172
+ resetIdleTimeoutOnSend: cfg.resetIdleTimeoutOnSend,
1173
+ sendPingsAutomatically: cfg.sendPingsAutomatically,
1165
1174
  },
1166
1175
  rateLimit: cfg.rateLimit,
1167
1176
  };
@@ -118,6 +118,7 @@ class ElasticSearch extends Service {
118
118
  "aggs",
119
119
  "collapse",
120
120
  "explain",
121
+ "fields",
121
122
  "from",
122
123
  "highlight",
123
124
  "query",
@@ -2260,8 +2261,6 @@ class ElasticSearch extends Service {
2260
2261
  reason: "document already exists",
2261
2262
  status: 400,
2262
2263
  });
2263
-
2264
- idx++;
2265
2264
  } else {
2266
2265
  esRequest.body.push({
2267
2266
  index: {
@@ -2273,6 +2272,7 @@ class ElasticSearch extends Service {
2273
2272
 
2274
2273
  toImport.push(document);
2275
2274
  }
2275
+ idx++;
2276
2276
  } else {
2277
2277
  esRequest.body.push({ index: { _index: alias } });
2278
2278
  esRequest.body.push(document._source);
@@ -198,6 +198,18 @@ export type ServerConfiguration = {
198
198
  * @default true
199
199
  */
200
200
  realtimeNotifications: boolean;
201
+ /**
202
+ * Whether or not we should automatically send pings to uphold a stable connection given whatever idleTimeout.
203
+ *
204
+ * @default false
205
+ */
206
+ sendPingsAutomatically: boolean;
207
+ /**
208
+ * Whether or not we should reset the idle timeout on every message received.
209
+ *
210
+ * @default false
211
+ */
212
+ resetIdleTimeoutOnSend: boolean;
201
213
  };
202
214
  };
203
215
  /**
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.26.3",
4
+ "version": "2.27.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": {