kuzzle 2.19.6 → 2.19.8

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.
@@ -85,12 +85,6 @@ class NativeController extends BaseController {
85
85
  throw assertionError.get("invalid_type", "body.query", "object");
86
86
  }
87
87
 
88
- try {
89
- global.kuzzle.koncorde.validate(koncordeFilters);
90
- } catch (error) {
91
- throw assertionError.getFrom(error, "koncorde_dsl_error", error.message);
92
- }
93
-
94
88
  try {
95
89
  return await this.ask("core:storage:public:translate", koncordeFilters);
96
90
  } catch (error) {
@@ -290,6 +290,10 @@ const defaultConfig = {
290
290
  },
291
291
  },
292
292
  },
293
+ defaultSettings: {
294
+ number_of_replicas: 1,
295
+ number_of_shards: 1,
296
+ },
293
297
  internalIndex: {
294
298
  name: "kuzzle",
295
299
  collections: {
@@ -69,7 +69,7 @@ export declare class EmbeddedSDK extends Kuzzle {
69
69
  * @param request - API request (https://docs.kuzzle.io/core/2/guides/main-concepts/1-api#other-protocols)
70
70
  * @param options - Optional arguments
71
71
  */
72
- query<TRequest extends BaseRequest, TResult>(request: TRequest, options?: {
72
+ query<TRequest extends BaseRequest = BaseRequest, TResult extends JSONObject = JSONObject>(request: TRequest, options?: {
73
73
  propagate?: boolean;
74
74
  }): Promise<ResponsePayload<TResult>>;
75
75
  }
@@ -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.stack && derivedError.stack.length) {
172
+ if (derivedError.stack && derivedError.stack.length && source.stack) {
173
173
  const stackArray = source.stack.split("\n");
174
174
  stackArray.shift();
175
175
  derivedError.stack = [
@@ -1395,6 +1395,14 @@ class ElasticSearch extends Service {
1395
1395
  ),
1396
1396
  };
1397
1397
 
1398
+ esRequest.body.settings.number_of_replicas =
1399
+ esRequest.body.settings.number_of_replicas ||
1400
+ this.config.defaultSettings.number_of_replicas;
1401
+
1402
+ esRequest.body.settings.number_of_shards =
1403
+ esRequest.body.settings.number_of_shards ||
1404
+ this.config.defaultSettings.number_of_shards;
1405
+
1398
1406
  try {
1399
1407
  await this._client.indices.create(esRequest);
1400
1408
  } catch (error) {
@@ -3141,8 +3149,8 @@ class ElasticSearch extends Service {
3141
3149
  [this._getAlias(index, HIDDEN_COLLECTION)]: {},
3142
3150
  },
3143
3151
  settings: {
3144
- number_of_replicas: 1,
3145
- number_of_shards: 1,
3152
+ number_of_replicas: this.config.defaultSettings.number_of_replicas,
3153
+ number_of_shards: this.config.defaultSettings.number_of_shards,
3146
3154
  },
3147
3155
  },
3148
3156
  index: await this._getAvailableIndice(index, HIDDEN_COLLECTION),
@@ -232,6 +232,10 @@ class ESWrapper {
232
232
  _handleNotFoundError(error, message) {
233
233
  let errorMessage = message;
234
234
 
235
+ if (!error.body._index) {
236
+ return kerror.get("unexpected_not_found", errorMessage);
237
+ }
238
+
235
239
  // _index= "&nyc-open-data.yellow-taxi"
236
240
  const index = error.body._index.split(".")[0].slice(1);
237
241
  const collection = error.body._index.split(".")[1];
@@ -84,7 +84,6 @@ const KONCORDE_CLAUSES_TO_ES = {
84
84
  ...content,
85
85
  },
86
86
  }),
87
- regexp: undefined,
88
87
  };
89
88
 
90
89
  const KONCORDE_OPERATORS_TO_ES = {
@@ -145,7 +144,9 @@ class QueryTranslator {
145
144
  const converter = KONCORDE_CLAUSES_TO_ES[clause];
146
145
 
147
146
  if (converter === undefined) {
148
- throw new KeywordError("clause", clause);
147
+ return {
148
+ [clause]: content,
149
+ };
149
150
  }
150
151
 
151
152
  return converter(content);
@@ -95,6 +95,24 @@ export declare type StorageEngineElasticsearch = {
95
95
  };
96
96
  };
97
97
  };
98
+ /**
99
+ * Global settings to apply by default (if not overridden by user request ones)
100
+ * @default
101
+ * {
102
+ * number_of_shards: 1,
103
+ * number_of_replicas: 1
104
+ * }
105
+ */
106
+ defaultSettings: {
107
+ /**
108
+ * @default 1
109
+ */
110
+ number_of_shards: number;
111
+ /**
112
+ * @default 1
113
+ */
114
+ number_of_replicas: number;
115
+ };
98
116
  internalIndex: {
99
117
  /**
100
118
  * @default "kuzzle"
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.19.6",
4
+ "version": "2.19.8",
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": {
@@ -26,6 +26,7 @@
26
26
  "test:functional:legacy:mqtt": "npx cucumber-js --format progress-bar --profile mqtt ./features-legacy",
27
27
  "cucumber": "cucumber.js --fail-fast",
28
28
  "codecov": "codecov",
29
+ "prettier": "npx prettier ./lib ./test ./bin ./features ./plugins/available/functional-test-plugin --write",
29
30
  "test:lint": "npm run test:lint:js && npm run test:lint:ts",
30
31
  "test:lint:ts": "eslint --max-warnings=0 ./lib --ext .ts --config .eslintc-ts.json",
31
32
  "test:lint:ts:fix": "eslint --max-warnings=0 --fix ./lib --ext .ts --config .eslintc-ts.json",