kuzzle 2.16.4 → 2.16.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.
Files changed (44) hide show
  1. package/lib/api/controllers/authController.js +2 -2
  2. package/lib/api/controllers/collectionController.js +2 -8
  3. package/lib/api/controllers/serverController.js +27 -14
  4. package/lib/config/default.config.d.ts +13 -0
  5. package/lib/config/default.config.js +363 -362
  6. package/lib/config/index.js +7 -5
  7. package/lib/core/backend/backendConfig.d.ts +3 -3
  8. package/lib/core/backend/backendConfig.js +2 -2
  9. package/lib/model/security/profile.js +10 -10
  10. package/lib/model/security/role.js +3 -3
  11. package/lib/service/cache/redis.js +33 -0
  12. package/lib/service/storage/elasticsearch.js +6 -0
  13. package/lib/types/PasswordPolicy.d.ts +77 -0
  14. package/lib/types/PasswordPolicy.js +3 -0
  15. package/lib/types/ProfileDefinition.d.ts +48 -0
  16. package/lib/types/ProfileDefinition.js +3 -0
  17. package/lib/types/RoleDefinition.d.ts +27 -0
  18. package/lib/types/RoleDefinition.js +3 -0
  19. package/lib/types/config/DumpConfiguration.d.ts +42 -0
  20. package/lib/types/config/DumpConfiguration.js +3 -0
  21. package/lib/types/config/HttpConfiguration.d.ts +43 -0
  22. package/lib/types/config/HttpConfiguration.js +9 -0
  23. package/lib/types/config/KuzzleConfiguration.d.ts +123 -0
  24. package/lib/types/config/KuzzleConfiguration.js +3 -0
  25. package/lib/types/config/LimitsConfiguration.d.ts +111 -0
  26. package/lib/types/config/LimitsConfiguration.js +3 -0
  27. package/lib/types/config/PluginsConfiguration.d.ts +177 -0
  28. package/lib/types/config/PluginsConfiguration.js +3 -0
  29. package/lib/types/config/SecurityConfiguration.d.ts +182 -0
  30. package/lib/types/config/SecurityConfiguration.js +3 -0
  31. package/lib/types/config/ServerConfiguration.d.ts +195 -0
  32. package/lib/types/config/ServerConfiguration.js +3 -0
  33. package/lib/types/config/ServicesConfiguration.d.ts +41 -0
  34. package/lib/types/config/ServicesConfiguration.js +3 -0
  35. package/lib/types/config/StorageService/StorageServiceElasticsearchConfiguration.d.ts +217 -0
  36. package/lib/types/config/StorageService/StorageServiceElasticsearchConfiguration.js +3 -0
  37. package/lib/types/config/internalCache/InternalCacheRedisConfiguration.d.ts +111 -0
  38. package/lib/types/config/internalCache/InternalCacheRedisConfiguration.js +3 -0
  39. package/lib/types/config/publicCache/PublicCacheRedisConfiguration.d.ts +31 -0
  40. package/lib/types/config/publicCache/PublicCacheRedisConfiguration.js +3 -0
  41. package/lib/types/index.d.ts +17 -0
  42. package/lib/types/index.js +17 -0
  43. package/package-lock.json +1 -1
  44. package/package.json +1 -1
@@ -430,11 +430,11 @@ class AuthController extends NativeController {
430
430
  token = request.input.jwt;
431
431
  }
432
432
  else {
433
- token = request.getBodyString('token');
433
+ token = request.getBodyString('token', '') || null;
434
434
  }
435
435
 
436
436
  try {
437
- const { expiresAt, userId } = await this.ask('core:security:token:verify', token);
437
+ const { expiresAt = -1, userId } = await this.ask('core:security:token:verify', token);
438
438
 
439
439
  return { expiresAt, kuid: userId, valid: true };
440
440
  }
@@ -269,7 +269,7 @@ class CollectionController extends NativeController {
269
269
  }
270
270
 
271
271
  /**
272
- * Reset a collection by removing all documents
272
+ * Reset a collection by removing all documents while keeping the existing mapping
273
273
  *
274
274
  * @param {KuzzleRequest} request
275
275
  * @returns {Promise.<Object>}
@@ -277,13 +277,7 @@ class CollectionController extends NativeController {
277
277
  async truncate (request) {
278
278
  const { index, collection } = request.getIndexAndCollection();
279
279
 
280
- await this.ask('core:storage:public:collection:refresh', index, collection);
281
- await this.ask(
282
- 'core:storage:public:document:deleteByQuery',
283
- index,
284
- collection,
285
- {},
286
- { fetch: false, refresh: 'wait_for' });
280
+ await this.ask('core:storage:public:collection:truncate', index, collection);
287
281
 
288
282
  return {
289
283
  acknowledged: true
@@ -47,7 +47,11 @@ class ServerController extends NativeController {
47
47
  'publicApi',
48
48
  'openapi',
49
49
  ]);
50
- this._docOpenapi = generateOpenApi();
50
+
51
+ this._openApiDefinition = {
52
+ json: null,
53
+ yaml: null,
54
+ };
51
55
  }
52
56
 
53
57
  /**
@@ -55,7 +59,7 @@ class ServerController extends NativeController {
55
59
  *
56
60
  * @param {Request} request
57
61
  * @returns {Promise<Object>}
58
- *
62
+ *
59
63
  * @deprecated
60
64
  */
61
65
  getStats (request) {
@@ -66,7 +70,7 @@ class ServerController extends NativeController {
66
70
  * Returns the last statistics frame
67
71
  *
68
72
  * @returns {Promise<Object>}
69
- *
73
+ *
70
74
  * @deprecated
71
75
  */
72
76
  getLastStats () {
@@ -77,7 +81,7 @@ class ServerController extends NativeController {
77
81
  * Returns all stored statistics frames
78
82
  *
79
83
  * @returns {Promise<Object>}
80
- *
84
+ *
81
85
  * @deprecated
82
86
  */
83
87
  getAllStats () {
@@ -242,25 +246,34 @@ class ServerController extends NativeController {
242
246
  }
243
247
 
244
248
  async openapi (request) {
245
- const format = request.input.args.format
246
- ? request.input.args.format
247
- : 'json';
248
- const contentType = format === 'yaml'
249
- ? 'application/yaml'
250
- : 'application/json';
251
- const specifications = format === 'yaml'
252
- ? jsonToYaml.stringify(this._docOpenapi)
253
- : this._docOpenapi;
249
+ const format = request.getString('format', 'json');
250
+ const specifications = this.getOpenApiDefinition(format);
254
251
 
255
252
  request.response.configure({
256
253
  format: 'raw',
257
- headers: { 'Content-Type': contentType },
254
+ headers: { 'Content-Type': `application/${format}` },
258
255
  status: 200,
259
256
  });
260
257
 
261
258
  return specifications;
262
259
  }
263
260
 
261
+ /**
262
+ * Lazy loading of OpenAPI definition.
263
+ *
264
+ * Mainly because we need to wait all plugin to be loaded
265
+ * to generate the definition.
266
+ */
267
+ getOpenApiDefinition (format) {
268
+ if (! this._openApiDefinition[format]) {
269
+ this._openApiDefinition[format] = format === 'json'
270
+ ? generateOpenApi()
271
+ : jsonToYaml.stringify(generateOpenApi());
272
+ }
273
+
274
+ return this._openApiDefinition[format];
275
+ }
276
+
264
277
  /**
265
278
  * Fetches and returns Kuzzle core metrics
266
279
  * @returns {Promise<Object>}
@@ -0,0 +1,13 @@
1
+ import { KuzzleConfiguration } from '../types/config/KuzzleConfiguration';
2
+ /**
3
+ * /!\ DO NOT MODIFY THIS FILE
4
+ *
5
+ * To customize your Kuzzle installation, create a
6
+ * ".kuzzlerc" file and put your overrides there.
7
+ * Please check the ".kuzzlerc.sample" file to get
8
+ * started.
9
+ *
10
+ * @class KuzzleConfiguration
11
+ */
12
+ declare const defaultConfig: KuzzleConfiguration;
13
+ export default defaultConfig;