kuzzle 2.15.2 → 2.16.3

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 (49) 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 +20 -0
  14. package/lib/api/openapi/document/index.js +55 -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/index.d.ts +2 -0
  19. package/lib/api/openapi/index.js +18 -0
  20. package/lib/api/openapi/payloads.yaml +32 -0
  21. package/lib/api/request/kuzzleRequest.d.ts +32 -0
  22. package/lib/api/request/kuzzleRequest.js +34 -0
  23. package/lib/api/request/requestInput.d.ts +2 -0
  24. package/lib/api/request/requestInput.js +2 -0
  25. package/lib/config/default.config.js +1 -1
  26. package/lib/core/network/router.js +33 -0
  27. package/lib/core/realtime/hotelClerk.d.ts +7 -0
  28. package/lib/core/realtime/hotelClerk.js +14 -0
  29. package/lib/util/readYamlFile.d.ts +2 -0
  30. package/lib/util/readYamlFile.js +10 -0
  31. package/package-lock.json +160 -175
  32. package/package.json +11 -25
  33. package/.kuzzlerc.sample +0 -988
  34. package/CONTRIBUTING.md +0 -116
  35. package/bin/.lib/colorOutput.js +0 -71
  36. package/bin/.upgrades/connectors/es.js +0 -90
  37. package/bin/.upgrades/connectors/redis.js +0 -112
  38. package/bin/.upgrades/lib/connectorContext.js +0 -38
  39. package/bin/.upgrades/lib/context.js +0 -142
  40. package/bin/.upgrades/lib/formatters.js +0 -103
  41. package/bin/.upgrades/lib/inquirerExtended.js +0 -46
  42. package/bin/.upgrades/lib/logger.js +0 -99
  43. package/bin/.upgrades/lib/progressBar.js +0 -70
  44. package/bin/.upgrades/versions/v1/checkConfiguration.js +0 -85
  45. package/bin/.upgrades/versions/v1/index.js +0 -35
  46. package/bin/.upgrades/versions/v1/upgradeCache.js +0 -149
  47. package/bin/.upgrades/versions/v1/upgradeStorage.js +0 -450
  48. package/protocols/available/.gitignore +0 -4
  49. package/protocols/enabled/.gitignore +0 -4
@@ -103,6 +103,38 @@ export declare class KuzzleRequest {
103
103
  data: JSONObject;
104
104
  options: JSONObject;
105
105
  };
106
+ /**
107
+ * Return a POJO representing the request.
108
+ *
109
+ * This can be used to match Koncorde filter rather than the Request object
110
+ * because it has properties defined with invisible unicode characters.
111
+ */
112
+ pojo(): {
113
+ context: {
114
+ connection: import("./requestContext").Connection;
115
+ token: import("../../types").Token;
116
+ user: User;
117
+ };
118
+ deprecations: void | Deprecation[];
119
+ error: KuzzleError;
120
+ id: string;
121
+ input: {
122
+ action: string;
123
+ args: JSONObject;
124
+ body: JSONObject;
125
+ controller: string;
126
+ jwt: string;
127
+ volatile: JSONObject;
128
+ };
129
+ internalId: string;
130
+ response: {
131
+ headers: JSONObject;
132
+ raw: boolean;
133
+ };
134
+ result: any;
135
+ status: number;
136
+ timestamp: number;
137
+ };
106
138
  /**
107
139
  * Returns the `lang` param of the request.
108
140
  *
@@ -277,6 +277,40 @@ class KuzzleRequest {
277
277
  Object.assign(serialized.options, this[_context].toJSON());
278
278
  return serialized;
279
279
  }
280
+ /**
281
+ * Return a POJO representing the request.
282
+ *
283
+ * This can be used to match Koncorde filter rather than the Request object
284
+ * because it has properties defined with invisible unicode characters.
285
+ */
286
+ pojo() {
287
+ return {
288
+ context: {
289
+ connection: this.context.connection,
290
+ token: this.context.token,
291
+ user: this.context.user,
292
+ },
293
+ deprecations: this.deprecations,
294
+ error: this.error,
295
+ id: this.id,
296
+ input: {
297
+ action: this.input.action,
298
+ args: this.input.args,
299
+ body: this.input.body,
300
+ controller: this.input.controller,
301
+ jwt: this.input.jwt,
302
+ volatile: this.input.volatile,
303
+ },
304
+ internalId: this.internalId,
305
+ response: {
306
+ headers: this.response.headers,
307
+ raw: this.response.raw,
308
+ },
309
+ result: this.result,
310
+ status: this.status,
311
+ timestamp: this.timestamp,
312
+ };
313
+ }
280
314
  /**
281
315
  * Returns the `lang` param of the request.
282
316
  *
@@ -157,6 +157,8 @@ export declare class RequestInput {
157
157
  set body(obj: JSONObject);
158
158
  /**
159
159
  * Request headers (Http only).
160
+ *
161
+ * @deprecated Use RequestContext.connection.misc.headers instead
160
162
  */
161
163
  get headers(): JSONObject | null;
162
164
  set headers(obj: JSONObject);
@@ -245,6 +245,8 @@ class RequestInput {
245
245
  }
246
246
  /**
247
247
  * Request headers (Http only).
248
+ *
249
+ * @deprecated Use RequestContext.connection.misc.headers instead
248
250
  */
249
251
  get headers() {
250
252
  return this[_headers];
@@ -46,7 +46,7 @@ module.exports = {
46
46
  (see https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS)
47
47
  */
48
48
  http: {
49
- routes: require('./httpRoutes'),
49
+ routes: require('./../api/httpRoutes'),
50
50
  accessControlAllowOrigin: '*',
51
51
  accessControlAllowOriginUseRegExp: false,
52
52
  accessControlAllowMethods: 'GET,POST,PUT,PATCH,DELETE,OPTIONS,HEAD',
@@ -138,6 +138,39 @@ class Router {
138
138
  this._executeFromHttp(route.verb, request, cb);
139
139
  });
140
140
  }
141
+
142
+ /**
143
+ * Returns inner metrics from the router
144
+ * @returns {Object}
145
+ */
146
+ global.kuzzle.onAsk(
147
+ 'core:network:router:metrics',
148
+ () => this.metrics());
149
+ }
150
+
151
+ /**
152
+ * Returns the metrics of the router
153
+ * @returns {Object}
154
+ */
155
+ metrics () {
156
+ const connectionsByProtocol = {};
157
+
158
+ for (const connection of this.connections.values()) {
159
+ const protocol = connection.connection.protocol.toLowerCase();
160
+ if (protocol === 'internal') {
161
+ continue;
162
+ }
163
+
164
+ if (connectionsByProtocol[protocol] === undefined) {
165
+ connectionsByProtocol[protocol] = 0;
166
+ }
167
+
168
+ connectionsByProtocol[protocol]++;
169
+ }
170
+
171
+ return {
172
+ connections: connectionsByProtocol,
173
+ };
141
174
  }
142
175
 
143
176
  /**
@@ -118,6 +118,13 @@ export declare class HotelClerk {
118
118
  *
119
119
  */
120
120
  unsubscribe(connectionId: string, roomId: string, notify?: boolean): Promise<void>;
121
+ /**
122
+ * Returns inner metrics from the HotelClerk
123
+ */
124
+ metrics(): {
125
+ rooms: number;
126
+ subscriptions: number;
127
+ };
121
128
  /**
122
129
  * Deletes a room if no user has subscribed to it, and removes it also from the
123
130
  * real-time engine
@@ -136,6 +136,11 @@ class HotelClerk {
136
136
  global.kuzzle.onAsk('core:realtime:unsubscribe', (connectionId, roomId, notify) => {
137
137
  return this.unsubscribe(connectionId, roomId, notify);
138
138
  });
139
+ /**
140
+ * Returns inner metrics from the HotelClerk
141
+ * @return {{rooms: number, subscriptions: number}}
142
+ */
143
+ global.kuzzle.onAsk('core:realtime:hotelClerk:metrics', () => this.metrics());
139
144
  /**
140
145
  * Clear the hotel clerk and properly disconnect connections.
141
146
  */
@@ -410,6 +415,15 @@ class HotelClerk {
410
415
  subscription,
411
416
  });
412
417
  }
418
+ /**
419
+ * Returns inner metrics from the HotelClerk
420
+ */
421
+ metrics() {
422
+ return {
423
+ rooms: this.roomsCount,
424
+ subscriptions: this.subscriptions.size,
425
+ };
426
+ }
413
427
  /**
414
428
  * Deletes a room if no user has subscribed to it, and removes it also from the
415
429
  * real-time engine
@@ -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