kuzzle 2.15.0 → 2.16.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 (55) hide show
  1. package/lib/api/controllers/serverController.js +24 -4
  2. package/lib/api/funnel.js +19 -0
  3. package/lib/{config → api}/httpRoutes.js +29 -14
  4. package/lib/api/openApiGenerator.d.ts +6 -0
  5. package/lib/api/openApiGenerator.js +167 -126
  6. package/lib/api/openapi/document/count.yaml +47 -0
  7. package/lib/api/openapi/document/create.yaml +46 -0
  8. package/lib/api/openapi/document/createOrReplace.yaml +61 -0
  9. package/lib/api/openapi/document/delete.yaml +67 -0
  10. package/lib/api/openapi/document/deleteByQuery.yaml +90 -0
  11. package/lib/api/openapi/document/exists.yaml +35 -0
  12. package/lib/api/openapi/document/get.yaml +68 -0
  13. package/lib/api/openapi/document/index.d.ts +21 -0
  14. package/lib/api/openapi/document/index.js +57 -0
  15. package/lib/api/openapi/document/replace.yaml +66 -0
  16. package/lib/api/openapi/document/scroll.yaml +49 -0
  17. package/lib/api/openapi/document/update.yaml +78 -0
  18. package/lib/api/openapi/payloads.yaml +32 -0
  19. package/lib/api/request/kuzzleRequest.d.ts +30 -32
  20. package/lib/api/request/kuzzleRequest.js +30 -102
  21. package/lib/api/request/requestContext.d.ts +17 -22
  22. package/lib/api/request/requestContext.js +44 -109
  23. package/lib/api/request/requestInput.d.ts +19 -22
  24. package/lib/api/request/requestInput.js +115 -173
  25. package/lib/api/request/requestResponse.d.ts +12 -8
  26. package/lib/api/request/requestResponse.js +35 -29
  27. package/lib/config/default.config.js +1 -1
  28. package/lib/core/network/router.js +33 -0
  29. package/lib/core/plugin/pluginsManager.js +3 -1
  30. package/lib/core/realtime/hotelClerk.d.ts +7 -0
  31. package/lib/core/realtime/hotelClerk.js +14 -0
  32. package/lib/core/storage/clientAdapter.js +1 -1
  33. package/lib/kuzzle/kuzzle.js +9 -5
  34. package/lib/service/storage/elasticsearch.js +14 -9
  35. package/lib/util/readYamlFile.d.ts +2 -0
  36. package/lib/util/readYamlFile.js +10 -0
  37. package/package-lock.json +173 -188
  38. package/package.json +13 -27
  39. package/.kuzzlerc.sample +0 -988
  40. package/CONTRIBUTING.md +0 -116
  41. package/bin/.lib/colorOutput.js +0 -71
  42. package/bin/.upgrades/connectors/es.js +0 -90
  43. package/bin/.upgrades/connectors/redis.js +0 -112
  44. package/bin/.upgrades/lib/connectorContext.js +0 -38
  45. package/bin/.upgrades/lib/context.js +0 -142
  46. package/bin/.upgrades/lib/formatters.js +0 -103
  47. package/bin/.upgrades/lib/inquirerExtended.js +0 -46
  48. package/bin/.upgrades/lib/logger.js +0 -99
  49. package/bin/.upgrades/lib/progressBar.js +0 -70
  50. package/bin/.upgrades/versions/v1/checkConfiguration.js +0 -85
  51. package/bin/.upgrades/versions/v1/index.js +0 -35
  52. package/bin/.upgrades/versions/v1/upgradeCache.js +0 -149
  53. package/bin/.upgrades/versions/v1/upgradeStorage.js +0 -450
  54. package/protocols/available/.gitignore +0 -4
  55. package/protocols/enabled/.gitignore +0 -4
@@ -270,7 +270,7 @@ class ClientAdapter {
270
270
  `core:storage:${this.scope}:collection:update`,
271
271
  (index, collection, changes) => {
272
272
  this.cache.assertCollectionExists(index, collection);
273
- this.client.updateCollection(index, collection, changes);
273
+ return this.client.updateCollection(index, collection, changes);
274
274
  });
275
275
  }
276
276
 
@@ -54,21 +54,25 @@ const realtime_1 = __importDefault(require("../core/realtime"));
54
54
  const cluster_1 = __importDefault(require("../cluster"));
55
55
  const package_json_1 = require("../../package.json");
56
56
  const BACKEND_IMPORT_KEY = 'backend:init:import';
57
- let _kuzzle = null;
57
+ Reflect.defineProperty(global, '_kuzzle', {
58
+ value: null,
59
+ writable: true,
60
+ });
61
+ /* eslint-disable dot-notation */
58
62
  Reflect.defineProperty(global, 'kuzzle', {
59
63
  configurable: true,
60
64
  enumerable: false,
61
65
  get() {
62
- if (_kuzzle === null) {
66
+ if (global['_kuzzle'] === null) {
63
67
  throw new Error('Kuzzle instance not found. Did you try to use a live-only feature before starting your application?');
64
68
  }
65
- return _kuzzle;
69
+ return global['_kuzzle'];
66
70
  },
67
71
  set(value) {
68
- if (_kuzzle !== null) {
72
+ if (global['_kuzzle'] !== null) {
69
73
  throw new Error('Cannot build a Kuzzle instance: another one already exists');
70
74
  }
71
- _kuzzle = value;
75
+ global['_kuzzle'] = value;
72
76
  },
73
77
  });
74
78
  class Kuzzle extends kuzzleEventEmitter_1.default {
@@ -128,12 +128,11 @@ class ElasticSearch extends Service {
128
128
  '_source_includes'
129
129
  ];
130
130
 
131
- // Forbidden keys in a query
132
- this.scriptKeys = [
133
- 'script',
134
- '_script'
135
- ];
136
-
131
+ /**
132
+ * Only allow stored-scripts in queries
133
+ */
134
+ this.scriptKeys = ['script', '_script'];
135
+ this.scriptAllowedArgs = ['id', 'params'];
137
136
 
138
137
  this.maxScrollDuration = this._loadMsConfig('maxScrollDuration');
139
138
 
@@ -2979,14 +2978,20 @@ class ElasticSearch extends Service {
2979
2978
  }
2980
2979
 
2981
2980
  /**
2982
- * Throw if any script keyword is contained in the object
2981
+ * Throw if a script is used in the query.
2982
+ *
2983
+ * Only Stored Scripts are accepted
2983
2984
  *
2984
2985
  * @param {Object} object
2985
2986
  */
2986
- _scriptCheck(object) {
2987
+ _scriptCheck (object) {
2987
2988
  for (const [key, value] of Object.entries(object)) {
2988
2989
  if (this.scriptKeys.includes(key)) {
2989
- throw kerror.get('invalid_query_keyword', key);
2990
+ for (const scriptArg of Object.keys(value)) {
2991
+ if (! this.scriptAllowedArgs.includes(scriptArg)) {
2992
+ throw kerror.get('invalid_query_keyword', `${key}.${scriptArg}`);
2993
+ }
2994
+ }
2990
2995
  }
2991
2996
  // Every object must be checked here, even the ones nested into an array
2992
2997
  else if (typeof value === 'object' && value !== null) {
@@ -0,0 +1,2 @@
1
+ import { JSONObject } from '../../index';
2
+ export declare function readYamlFile(path: string): JSONObject;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readYamlFile = void 0;
4
+ const fs_1 = require("fs");
5
+ const js_yaml_1 = require("js-yaml");
6
+ function readYamlFile(path) {
7
+ return (0, js_yaml_1.load)((0, fs_1.readFileSync)(path, 'utf-8'));
8
+ }
9
+ exports.readYamlFile = readYamlFile;
10
+ //# sourceMappingURL=readYamlFile.js.map