kuzzle 2.17.2 → 2.17.5

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 (57) hide show
  1. package/README.md +1 -1
  2. package/index.js +5 -1
  3. package/lib/api/controllers/serverController.js +0 -1
  4. package/lib/api/openapi/components/index.js +5 -1
  5. package/lib/api/openapi/index.js +5 -1
  6. package/lib/api/request/index.js +5 -1
  7. package/lib/api/request/kuzzleRequest.js +5 -1
  8. package/lib/api/request/requestContext.js +5 -1
  9. package/lib/api/request/requestInput.js +5 -1
  10. package/lib/api/request/requestResponse.js +11 -2
  11. package/lib/cluster/state.js +5 -1
  12. package/lib/core/backend/backend.js +5 -1
  13. package/lib/core/backend/backendConfig.js +5 -1
  14. package/lib/core/backend/backendController.js +5 -1
  15. package/lib/core/backend/backendErrors.d.ts +11 -8
  16. package/lib/core/backend/backendErrors.js +31 -23
  17. package/lib/core/backend/backendHook.js +5 -1
  18. package/lib/core/backend/backendImport.js +5 -1
  19. package/lib/core/backend/backendPipe.js +5 -1
  20. package/lib/core/backend/backendPlugin.js +5 -1
  21. package/lib/core/backend/backendVault.js +5 -1
  22. package/lib/core/backend/index.js +5 -1
  23. package/lib/core/network/protocols/httpMessage.js +2 -1
  24. package/lib/core/network/protocols/httpwsProtocol.js +7 -5
  25. package/lib/core/plugin/pluginContext.js +5 -1
  26. package/lib/core/realtime/channel.js +5 -1
  27. package/lib/core/realtime/hotelClerk.js +5 -1
  28. package/lib/core/security/profileRepository.js +5 -1
  29. package/lib/core/shared/sdk/embeddedSdk.js +5 -1
  30. package/lib/core/storage/indexCache.js +5 -1
  31. package/lib/kerror/codes/0-core.json +1 -1
  32. package/lib/kerror/codes/1-services.json +1 -1
  33. package/lib/kerror/codes/2-api.json +1 -1
  34. package/lib/kerror/codes/3-network.json +1 -1
  35. package/lib/kerror/codes/4-plugin.json +1 -1
  36. package/lib/kerror/codes/5-validation.json +1 -1
  37. package/lib/kerror/codes/6-protocol.json +1 -1
  38. package/lib/kerror/codes/7-security.json +1 -1
  39. package/lib/kerror/codes/8-cluster.json +1 -1
  40. package/lib/kerror/codes/index.js +7 -7
  41. package/lib/kerror/errors/index.js +5 -1
  42. package/lib/kerror/errors/kuzzleError.d.ts +4 -0
  43. package/lib/kerror/errors/kuzzleError.js +9 -2
  44. package/lib/kerror/index.d.ts +3 -3
  45. package/lib/kerror/index.js +16 -7
  46. package/lib/kuzzle/kuzzle.js +5 -1
  47. package/lib/model/security/profile.js +5 -1
  48. package/lib/model/security/role.js +5 -1
  49. package/lib/model/security/user.js +5 -1
  50. package/lib/types/Plugin.js +5 -1
  51. package/lib/types/errors/ErrorDefinition.d.ts +6 -0
  52. package/lib/types/errors/ErrorDomains.d.ts +2 -2
  53. package/lib/types/index.js +5 -1
  54. package/lib/util/dump-collection.js +5 -1
  55. package/lib/util/mutex.js +5 -1
  56. package/package-lock.json +478 -681
  57. package/package.json +22 -22
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "code": 5,
3
- "subdomains": {
3
+ "subDomains": {
4
4
  "assert": {
5
5
  "code": 1,
6
6
  "errors": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "code": 6,
3
- "subdomains": {
3
+ "subDomains": {
4
4
  "runtime": {
5
5
  "code": 1,
6
6
  "errors": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "code": 7,
3
- "subdomains": {
3
+ "subDomains": {
4
4
  "token": {
5
5
  "code": 1,
6
6
  "errors": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "code": 8,
3
- "subdomains": {
3
+ "subDomains": {
4
4
  "fatal": {
5
5
  "code": 0,
6
6
  "errors": {
@@ -97,8 +97,8 @@ function checkErrors (subdomain, domain, options) {
97
97
  function checkSubdomains (domain, options) {
98
98
  const subdomainCodes = new Set();
99
99
 
100
- for (const subdomainName of Object.keys(domain.subdomains)) {
101
- const subdomain = domain.subdomains[subdomainName];
100
+ for (const subdomainName of Object.keys(domain.subDomains)) {
101
+ const subdomain = domain.subDomains[subdomainName];
102
102
 
103
103
  // Subdomain code for plugins is not required and is automatically set to 0
104
104
  if (! options.plugin) {
@@ -158,11 +158,11 @@ function checkDomains (errorCodesFiles, options = { plugin: false }) {
158
158
  domainCodes.add(domain.code);
159
159
 
160
160
  assert(
161
- has(domain, 'subdomains'),
162
- `Error configuration file : Missing required 'subdomains' field. (domain: '${domainName}').`);
161
+ has(domain, 'subDomains'),
162
+ `Error configuration file : Missing required 'subDomains' field. (domain: '${domainName}').`);
163
163
  assert(
164
- isPlainObject(domain.subdomains),
165
- `Error configuration file : Field 'subdomains' must be an object. (domain: '${domainName}').`);
164
+ isPlainObject(domain.subDomains),
165
+ `Error configuration file : Field 'subDomains' must be an object. (domain: '${domainName}').`);
166
166
 
167
167
  checkSubdomains(domain, options);
168
168
  }
@@ -170,7 +170,7 @@ function checkDomains (errorCodesFiles, options = { plugin: false }) {
170
170
 
171
171
  function loadPluginsErrors (pluginManifest, pluginCode) {
172
172
  // @todo this should be in its own, independant domain
173
- domains.plugin.subdomains[pluginManifest.name] = {
173
+ domains.plugin.subDomains[pluginManifest.name] = {
174
174
  code: pluginCode,
175
175
  errors: pluginManifest.errors
176
176
  };
@@ -21,7 +21,11 @@
21
21
  */
22
22
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
23
23
  if (k2 === undefined) k2 = k;
24
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
24
+ var desc = Object.getOwnPropertyDescriptor(m, k);
25
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
26
+ desc = { enumerable: true, get: function() { return m[k]; } };
27
+ }
28
+ Object.defineProperty(o, k2, desc);
25
29
  }) : (function(o, m, k, k2) {
26
30
  if (k2 === undefined) k2 = k;
27
31
  o[k2] = m[k];
@@ -17,6 +17,10 @@ export declare class KuzzleError extends Error {
17
17
  * Error unique identifier
18
18
  */
19
19
  id: string;
20
+ /**
21
+ * Placeholders used to construct the error message.
22
+ */
23
+ props: string[];
20
24
  constructor(message: string, status: number, id?: string, code?: number);
21
25
  /**
22
26
  * Error class name (e.g: 'NotFoundError')
@@ -21,7 +21,11 @@
21
21
  */
22
22
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
23
23
  if (k2 === undefined) k2 = k;
24
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
24
+ var desc = Object.getOwnPropertyDescriptor(m, k);
25
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
26
+ desc = { enumerable: true, get: function() { return m[k]; } };
27
+ }
28
+ Object.defineProperty(o, k2, desc);
25
29
  }) : (function(o, m, k, k2) {
26
30
  if (k2 === undefined) k2 = k;
27
31
  o[k2] = m[k];
@@ -51,7 +55,9 @@ class KuzzleError extends Error {
51
55
  this.status = status;
52
56
  this.code = code;
53
57
  this.id = id;
54
- if (util.isError(message)) {
58
+ this.props = undefined;
59
+ this.stack = undefined;
60
+ if (util.types.isNativeError(message)) {
55
61
  this.message = message.message;
56
62
  this.stack = message.stack;
57
63
  }
@@ -71,6 +77,7 @@ class KuzzleError extends Error {
71
77
  code: this.code,
72
78
  id: this.id,
73
79
  message: this.message,
80
+ props: this.props,
74
81
  stack: this.stack,
75
82
  status: this.status,
76
83
  };
@@ -4,7 +4,7 @@ import { ErrorDomains } from '../types';
4
4
  /**
5
5
  * Construct and return the corresponding error
6
6
  *
7
- * @param domains - Domains object with subdomains and error names
7
+ * @param domains - Domains object with subDomains and error names
8
8
  * @param domain - Domain (eg: 'external')
9
9
  * @param subdomain - Subdomain (eg: 'elasticsearch')
10
10
  * @param error - Error name: (eg: 'index_not_found')
@@ -15,7 +15,7 @@ export declare function rawGet(domains: ErrorDomains, domain: string, subdomain:
15
15
  /**
16
16
  * Returns a promise rejected with the corresponding error
17
17
  *
18
- * @param domains - Domains object with subdomains and error names
18
+ * @param domains - Domains object with subDomains and error names
19
19
  * @param domain - Domain (eg: 'external')
20
20
  * @param subdomain - Subdomain (eg: 'elasticsearch')
21
21
  * @param error - Error name: (eg: 'index_not_found')
@@ -26,7 +26,7 @@ export declare function rawReject(domains: ErrorDomains, domain: string, subdoma
26
26
  * Construct and return the corresponding error, with its stack
27
27
  * trace derivated from a provided source error
28
28
  *
29
- * @param domains - Domains object with subdomains and error names
29
+ * @param domains - Domains object with subDomains and error names
30
30
  * @param source - Original error
31
31
  * @param domain - Domain (eg: 'external')
32
32
  * @param subdomain - Subdomain (eg: 'elasticsearch')
@@ -21,7 +21,11 @@
21
21
  */
22
22
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
23
23
  if (k2 === undefined) k2 = k;
24
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
24
+ var desc = Object.getOwnPropertyDescriptor(m, k);
25
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
26
+ desc = { enumerable: true, get: function() { return m[k]; } };
27
+ }
28
+ Object.defineProperty(o, k2, desc);
25
29
  }) : (function(o, m, k, k2) {
26
30
  if (k2 === undefined) k2 = k;
27
31
  o[k2] = m[k];
@@ -63,7 +67,7 @@ function _getCurrentFileName() {
63
67
  /**
64
68
  * Construct and return the corresponding error
65
69
  *
66
- * @param domains - Domains object with subdomains and error names
70
+ * @param domains - Domains object with subDomains and error names
67
71
  * @param domain - Domain (eg: 'external')
68
72
  * @param subdomain - Subdomain (eg: 'elasticsearch')
69
73
  * @param error - Error name: (eg: 'index_not_found')
@@ -76,7 +80,7 @@ function rawGet(domains, domain, subdomain, error, ...placeholders) {
76
80
  if (lodash_1.default.isPlainObject(placeholders[placeholders.length - 1])) {
77
81
  options = placeholders.pop();
78
82
  }
79
- const kuzzleError = lodash_1.default.get(domains, `${domain}.subdomains.${subdomain}.errors.${error}`);
83
+ const kuzzleError = lodash_1.default.get(domains, `${domain}.subDomains.${subdomain}.errors.${error}`);
80
84
  if (!kuzzleError) {
81
85
  return get('core', 'fatal', 'unexpected_error', `${domain}.${subdomain}.${error}`);
82
86
  }
@@ -87,15 +91,20 @@ function rawGet(domains, domain, subdomain, error, ...placeholders) {
87
91
  const message = options.message || (0, util_1.format)(kuzzleError.message, ...placeholders);
88
92
  const id = `${domain}.${subdomain}.${error}`;
89
93
  const code = domains[domain].code << 24
90
- | domains[domain].subdomains[subdomain].code << 16
91
- | domains[domain].subdomains[subdomain].errors[error].code;
94
+ | domains[domain].subDomains[subdomain].code << 16
95
+ | domains[domain].subDomains[subdomain].errors[error].code;
92
96
  let kerror;
93
97
  if (kuzzleError.class === 'PartialError' || kuzzleError.class === 'MultipleErrorsError') {
94
98
  kerror = new errors[kuzzleError.class](message, body, id, code);
95
99
  }
100
+ else if (kuzzleError.class === 'KuzzleError') {
101
+ const status = kuzzleError.status || 500;
102
+ kerror = new errors.KuzzleError(message, status, id, code);
103
+ }
96
104
  else {
97
105
  kerror = new errors[kuzzleError.class](message, id, code);
98
106
  }
107
+ kerror.props = placeholders;
99
108
  if (kuzzleError.class !== 'InternalError') {
100
109
  cleanStackTrace(kerror);
101
110
  }
@@ -136,7 +145,7 @@ function cleanStackTrace(error) {
136
145
  /**
137
146
  * Returns a promise rejected with the corresponding error
138
147
  *
139
- * @param domains - Domains object with subdomains and error names
148
+ * @param domains - Domains object with subDomains and error names
140
149
  * @param domain - Domain (eg: 'external')
141
150
  * @param subdomain - Subdomain (eg: 'elasticsearch')
142
151
  * @param error - Error name: (eg: 'index_not_found')
@@ -150,7 +159,7 @@ exports.rawReject = rawReject;
150
159
  * Construct and return the corresponding error, with its stack
151
160
  * trace derivated from a provided source error
152
161
  *
153
- * @param domains - Domains object with subdomains and error names
162
+ * @param domains - Domains object with subDomains and error names
154
163
  * @param source - Original error
155
164
  * @param domain - Domain (eg: 'external')
156
165
  * @param subdomain - Subdomain (eg: 'elasticsearch')
@@ -21,7 +21,11 @@
21
21
  */
22
22
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
23
23
  if (k2 === undefined) k2 = k;
24
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
24
+ var desc = Object.getOwnPropertyDescriptor(m, k);
25
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
26
+ desc = { enumerable: true, get: function() { return m[k]; } };
27
+ }
28
+ Object.defineProperty(o, k2, desc);
25
29
  }) : (function(o, m, k, k2) {
26
30
  if (k2 === undefined) k2 = k;
27
31
  o[k2] = m[k];
@@ -21,7 +21,11 @@
21
21
  */
22
22
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
23
23
  if (k2 === undefined) k2 = k;
24
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
24
+ var desc = Object.getOwnPropertyDescriptor(m, k);
25
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
26
+ desc = { enumerable: true, get: function() { return m[k]; } };
27
+ }
28
+ Object.defineProperty(o, k2, desc);
25
29
  }) : (function(o, m, k, k2) {
26
30
  if (k2 === undefined) k2 = k;
27
31
  o[k2] = m[k];
@@ -21,7 +21,11 @@
21
21
  */
22
22
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
23
23
  if (k2 === undefined) k2 = k;
24
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
24
+ var desc = Object.getOwnPropertyDescriptor(m, k);
25
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
26
+ desc = { enumerable: true, get: function() { return m[k]; } };
27
+ }
28
+ Object.defineProperty(o, k2, desc);
25
29
  }) : (function(o, m, k, k2) {
26
30
  if (k2 === undefined) k2 = k;
27
31
  o[k2] = m[k];
@@ -21,7 +21,11 @@
21
21
  */
22
22
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
23
23
  if (k2 === undefined) k2 = k;
24
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
24
+ var desc = Object.getOwnPropertyDescriptor(m, k);
25
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
26
+ desc = { enumerable: true, get: function() { return m[k]; } };
27
+ }
28
+ Object.defineProperty(o, k2, desc);
25
29
  }) : (function(o, m, k, k2) {
26
30
  if (k2 === undefined) k2 = k;
27
31
  o[k2] = m[k];
@@ -21,7 +21,11 @@
21
21
  */
22
22
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
23
23
  if (k2 === undefined) k2 = k;
24
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
24
+ var desc = Object.getOwnPropertyDescriptor(m, k);
25
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
26
+ desc = { enumerable: true, get: function() { return m[k]; } };
27
+ }
28
+ Object.defineProperty(o, k2, desc);
25
29
  }) : (function(o, m, k, k2) {
26
30
  if (k2 === undefined) k2 = k;
27
31
  o[k2] = m[k];
@@ -24,4 +24,10 @@ export declare type CustomErrorDefinition = {
24
24
  * Error class
25
25
  */
26
26
  class: ErrorClassNames;
27
+ /**
28
+ * Custom HTTP status.
29
+ *
30
+ * Only available for generic KuzzleError.
31
+ */
32
+ status?: number;
27
33
  };
@@ -1,11 +1,11 @@
1
1
  import { ErrorDefinition } from './ErrorDefinition';
2
2
  /**
3
- * Represents the domains, subdomains and error names with associated definitions
3
+ * Represents the domains, subDomains and error names with associated definitions
4
4
  */
5
5
  export declare type ErrorDomains = {
6
6
  [domain: string]: {
7
7
  code: number;
8
- subdomains?: {
8
+ subDomains?: {
9
9
  [subDomain: string]: {
10
10
  code: number;
11
11
  errors: {
@@ -21,7 +21,11 @@
21
21
  */
22
22
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
23
23
  if (k2 === undefined) k2 = k;
24
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
24
+ var desc = Object.getOwnPropertyDescriptor(m, k);
25
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
26
+ desc = { enumerable: true, get: function() { return m[k]; } };
27
+ }
28
+ Object.defineProperty(o, k2, desc);
25
29
  }) : (function(o, m, k, k2) {
26
30
  if (k2 === undefined) k2 = k;
27
31
  o[k2] = m[k];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
package/lib/util/mutex.js CHANGED
@@ -21,7 +21,11 @@
21
21
  */
22
22
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
23
23
  if (k2 === undefined) k2 = k;
24
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
24
+ var desc = Object.getOwnPropertyDescriptor(m, k);
25
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
26
+ desc = { enumerable: true, get: function() { return m[k]; } };
27
+ }
28
+ Object.defineProperty(o, k2, desc);
25
29
  }) : (function(o, m, k, k2) {
26
30
  if (k2 === undefined) k2 = k;
27
31
  o[k2] = m[k];