kuzzle 2.17.0 → 2.17.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 (58) hide show
  1. package/lib/api/controllers/authController.js +1 -1
  2. package/lib/api/controllers/securityController.js +1 -1
  3. package/lib/api/controllers/serverController.js +0 -1
  4. package/lib/api/funnel.js +4 -0
  5. package/lib/api/request/kuzzleRequest.js +5 -7
  6. package/lib/api/request/requestResponse.js +6 -1
  7. package/lib/cluster/state.js +20 -4
  8. package/lib/core/backend/backend.d.ts +7 -3
  9. package/lib/core/backend/backend.js +10 -9
  10. package/lib/core/backend/backendConfig.js +21 -2
  11. package/lib/core/backend/backendController.js +21 -5
  12. package/lib/core/backend/backendErrors.d.ts +58 -0
  13. package/lib/core/backend/backendErrors.js +121 -0
  14. package/lib/core/backend/backendHook.js +21 -5
  15. package/lib/core/backend/backendImport.js +21 -5
  16. package/lib/core/backend/backendOpenApi.js +1 -1
  17. package/lib/core/backend/backendPipe.js +21 -5
  18. package/lib/core/backend/backendPlugin.js +22 -3
  19. package/lib/core/backend/backendVault.js +21 -2
  20. package/lib/core/backend/index.d.ts +1 -0
  21. package/lib/core/backend/index.js +1 -0
  22. package/lib/core/network/protocols/httpMessage.js +2 -1
  23. package/lib/core/network/protocols/httpwsProtocol.js +31 -8
  24. package/lib/core/plugin/pluginContext.js +22 -3
  25. package/lib/core/realtime/channel.js +20 -4
  26. package/lib/core/realtime/hotelClerk.js +24 -5
  27. package/lib/core/security/profileRepository.js +26 -7
  28. package/lib/core/shared/sdk/embeddedSdk.js +21 -2
  29. package/lib/core/storage/indexCache.js +20 -4
  30. package/lib/kerror/codes/0-core.json +1 -1
  31. package/lib/kerror/codes/1-services.json +1 -1
  32. package/lib/kerror/codes/2-api.json +1 -1
  33. package/lib/kerror/codes/3-network.json +1 -1
  34. package/lib/kerror/codes/4-plugin.json +1 -1
  35. package/lib/kerror/codes/5-validation.json +1 -1
  36. package/lib/kerror/codes/6-protocol.json +1 -1
  37. package/lib/kerror/codes/7-security.json +1 -1
  38. package/lib/kerror/codes/8-cluster.json +1 -1
  39. package/lib/kerror/codes/index.js +7 -7
  40. package/lib/kerror/errors/multipleErrorsError.d.ts +1 -1
  41. package/lib/kerror/errors/multipleErrorsError.js +3 -3
  42. package/lib/kerror/index.d.ts +82 -0
  43. package/lib/kerror/index.js +180 -143
  44. package/lib/kuzzle/kuzzle.js +23 -4
  45. package/lib/model/security/profile.js +24 -5
  46. package/lib/model/security/role.js +21 -5
  47. package/lib/model/security/user.js +21 -2
  48. package/lib/types/Plugin.js +20 -4
  49. package/lib/types/errors/ErrorDefinition.d.ts +33 -0
  50. package/lib/types/errors/ErrorDefinition.js +3 -0
  51. package/lib/types/errors/ErrorDomains.d.ts +17 -0
  52. package/lib/types/errors/ErrorDomains.js +3 -0
  53. package/lib/types/index.d.ts +2 -0
  54. package/lib/types/index.js +2 -0
  55. package/lib/util/dump-collection.js +21 -2
  56. package/lib/util/mutex.js +21 -2
  57. package/package-lock.json +4 -4
  58. package/package.json +1 -1
@@ -0,0 +1,82 @@
1
+ import * as errors from './errors';
2
+ import { KuzzleError } from './errors';
3
+ import { ErrorDomains } from '../types';
4
+ /**
5
+ * Construct and return the corresponding error
6
+ *
7
+ * @param domains - Domains object with subDomains and error names
8
+ * @param domain - Domain (eg: 'external')
9
+ * @param subdomain - Subdomain (eg: 'elasticsearch')
10
+ * @param error - Error name: (eg: 'index_not_found')
11
+ * @param placeholders - Placeholders value to inject in error message
12
+ * @param options - Last param can be additional options { message }
13
+ */
14
+ export declare function rawGet(domains: ErrorDomains, domain: string, subdomain: string, error: string, ...placeholders: any[]): KuzzleError;
15
+ /**
16
+ * Returns a promise rejected with the corresponding error
17
+ *
18
+ * @param domains - Domains object with subDomains and error names
19
+ * @param domain - Domain (eg: 'external')
20
+ * @param subdomain - Subdomain (eg: 'elasticsearch')
21
+ * @param error - Error name: (eg: 'index_not_found')
22
+ * @param placeholders - Placeholders value to inject in error message
23
+ */
24
+ export declare function rawReject(domains: ErrorDomains, domain: string, subdomain: string, error: string, ...placeholders: any[]): Promise<any>;
25
+ /**
26
+ * Construct and return the corresponding error, with its stack
27
+ * trace derivated from a provided source error
28
+ *
29
+ * @param domains - Domains object with subDomains and error names
30
+ * @param source - Original error
31
+ * @param domain - Domain (eg: 'external')
32
+ * @param subdomain - Subdomain (eg: 'elasticsearch')
33
+ * @param error - Error name: (eg: 'index_not_found')
34
+ * @param placeholders - Placeholders value to inject in error message
35
+ */
36
+ export declare function rawGetFrom(domains: ErrorDomains, source: Error, domain: string, subdomain: string, error: string, ...placeholders: any[]): KuzzleError;
37
+ /**
38
+ * Wrap error functions with the provided domain and subdomain.
39
+ */
40
+ export declare function rawWrap(domains: ErrorDomains, domain: string, subdomain: string): {
41
+ get: (error: any, ...placeholders: any[]) => errors.KuzzleError;
42
+ getFrom: (source: any, error: any, ...placeholders: any[]) => errors.KuzzleError;
43
+ reject: (error: any, ...placeholders: any[]) => Promise<any>;
44
+ };
45
+ /**
46
+ * Construct and return the corresponding error
47
+ *
48
+ * @param domain - Domain (eg: 'external')
49
+ * @param subdomain - Subdomain (eg: 'elasticsearch')
50
+ * @param error - Error name: (eg: 'index_not_found')
51
+ * @param placeholders - Placeholders value to inject in error message
52
+ * @param options - Last param can be additional options { message }
53
+ */
54
+ export declare function get(domain: string, subdomain: string, error: string, ...placeholders: any[]): KuzzleError;
55
+ /**
56
+ * Returns a promise rejected with the corresponding error
57
+ *
58
+ * @param domain - Domain (eg: 'external')
59
+ * @param subdomain - Subdomain (eg: 'elasticsearch')
60
+ * @param error - Error name: (eg: 'index_not_found')
61
+ * @param placeholders - Placeholders value to inject in error message
62
+ */
63
+ export declare function reject(domain: string, subdomain: string, error: string, ...placeholders: any[]): Promise<any>;
64
+ /**
65
+ * Construct and return the corresponding error, with its stack
66
+ * trace derivated from a provided source error
67
+ *
68
+ * @param source - Original error
69
+ * @param domain - Domain (eg: 'external')
70
+ * @param subdomain - Subdomain (eg: 'elasticsearch')
71
+ * @param error - Error name: (eg: 'index_not_found')
72
+ * @param placeholders - Placeholders value to inject in error message
73
+ */
74
+ export declare function getFrom(source: Error, domain: string, subdomain: string, error: string, ...placeholders: any[]): KuzzleError;
75
+ /**
76
+ * Wrap error functions with the provided domain and subdomain.
77
+ */
78
+ export declare function wrap(domain: string, subdomain: string): {
79
+ get: (error: any, ...placeholders: any[]) => errors.KuzzleError;
80
+ getFrom: (source: any, error: any, ...placeholders: any[]) => errors.KuzzleError;
81
+ reject: (error: any, ...placeholders: any[]) => Promise<any>;
82
+ };
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /*
2
3
  * Kuzzle, a backend software, self-hostable and ready to use
3
4
  * to power modern apps
@@ -18,83 +19,93 @@
18
19
  * See the License for the specific language governing permissions and
19
20
  * limitations under the License.
20
21
  */
21
-
22
- 'use strict';
23
-
24
- const { format } = require('util');
25
-
26
- const Bluebird = require('bluebird');
27
- const _ = require('lodash');
28
-
29
- const { domains } = require('./codes');
30
- const errors = require('./errors');
31
- const { hilightUserCode } = require('../util/stackTrace');
32
-
22
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
23
+ if (k2 === undefined) k2 = k;
24
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
25
+ }) : (function(o, m, k, k2) {
26
+ if (k2 === undefined) k2 = k;
27
+ o[k2] = m[k];
28
+ }));
29
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
30
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
31
+ }) : function(o, v) {
32
+ o["default"] = v;
33
+ });
34
+ var __importStar = (this && this.__importStar) || function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
41
+ var __importDefault = (this && this.__importDefault) || function (mod) {
42
+ return (mod && mod.__esModule) ? mod : { "default": mod };
43
+ };
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.wrap = exports.getFrom = exports.reject = exports.get = exports.rawWrap = exports.rawGetFrom = exports.rawReject = exports.rawGet = void 0;
46
+ const util_1 = require("util");
47
+ const lodash_1 = __importDefault(require("lodash"));
48
+ const codes_1 = require("./codes");
49
+ const errors = __importStar(require("./errors"));
50
+ const stackTrace_1 = require("../util/stackTrace");
33
51
  /**
34
52
  * Gets this file name in the exact same format than the one printed in the
35
53
  * stacktraces (used to clean kerror lines from stacktraces)
36
54
  */
37
55
  let _currentFileName = null;
38
- function _getCurrentFileName () {
39
- if (_currentFileName !== null) {
56
+ function _getCurrentFileName() {
57
+ if (_currentFileName !== null) {
58
+ return _currentFileName;
59
+ }
60
+ _currentFileName = module.filename.substr(process.cwd().length + 1);
40
61
  return _currentFileName;
41
- }
42
-
43
- _currentFileName = module.filename.substr(process.cwd().length + 1);
44
-
45
- return _currentFileName;
46
62
  }
47
-
48
63
  /**
49
64
  * Construct and return the corresponding error
50
65
  *
51
- * @param {string} domain - Domain (eg: 'external')
52
- * @param {string} subdomain - Subdomain (eg: 'elasticsearch')
53
- * @param {string} error - Error name: (eg: 'index_not_found')
54
- * @param {...any} placeholders - Placeholders value to inject in error message
55
- * @param {object} options - Last param can be additional options { message }
66
+ * @param domains - Domains object with subDomains and error names
67
+ * @param domain - Domain (eg: 'external')
68
+ * @param subdomain - Subdomain (eg: 'elasticsearch')
69
+ * @param error - Error name: (eg: 'index_not_found')
70
+ * @param placeholders - Placeholders value to inject in error message
71
+ * @param options - Last param can be additional options { message }
56
72
  */
57
- function get (domain, subdomain, error, ...placeholders) {
58
- let options = {};
59
-
60
- // extract options object from the placeholders
61
- if (_.isPlainObject(placeholders[placeholders.length - 1])) {
62
- options = placeholders.pop();
63
- }
64
-
65
- const kuzzleError = _.get(domains, `${domain}.subdomains.${subdomain}.errors.${error}`);
66
-
67
- if (! kuzzleError) {
68
- return get('core', 'fatal', 'unexpected_error', `${domain}.${subdomain}.${error}`);
69
- }
70
-
71
- let body = null;
72
-
73
- if (kuzzleError.class === 'PartialError' || kuzzleError.class === 'MultipleErrorsError') {
74
- body = placeholders.splice(-1)[0];
75
- }
76
-
77
- const message = options.message || format(kuzzleError.message, ...placeholders);
78
- const id = `${domain}.${subdomain}.${error}`;
79
- const code = domains[domain].code << 24
80
- | domains[domain].subdomains[subdomain].code << 16
81
- | domains[domain].subdomains[subdomain].errors[error].code;
82
-
83
- let kerror;
84
- if (kuzzleError.class === 'PartialError' || kuzzleError.class === 'MultipleErrorsError') {
85
- kerror = new errors[kuzzleError.class](message, body, id, code);
86
- }
87
- else {
88
- kerror = new errors[kuzzleError.class](message, id, code);
89
- }
90
-
91
- if (error.name !== 'InternalError') {
92
- cleanStackTrace(kerror);
93
- }
94
-
95
- return kerror;
73
+ function rawGet(domains, domain, subdomain, error, ...placeholders) {
74
+ let options = {};
75
+ // extract options object from the placeholders
76
+ if (lodash_1.default.isPlainObject(placeholders[placeholders.length - 1])) {
77
+ options = placeholders.pop();
78
+ }
79
+ const kuzzleError = lodash_1.default.get(domains, `${domain}.subDomains.${subdomain}.errors.${error}`);
80
+ if (!kuzzleError) {
81
+ return get('core', 'fatal', 'unexpected_error', `${domain}.${subdomain}.${error}`);
82
+ }
83
+ let body = null;
84
+ if (kuzzleError.class === 'PartialError' || kuzzleError.class === 'MultipleErrorsError') {
85
+ body = placeholders.splice(-1)[0];
86
+ }
87
+ const message = options.message || (0, util_1.format)(kuzzleError.message, ...placeholders);
88
+ const id = `${domain}.${subdomain}.${error}`;
89
+ const code = domains[domain].code << 24
90
+ | domains[domain].subDomains[subdomain].code << 16
91
+ | domains[domain].subDomains[subdomain].errors[error].code;
92
+ let kerror;
93
+ if (kuzzleError.class === 'PartialError' || kuzzleError.class === 'MultipleErrorsError') {
94
+ kerror = new errors[kuzzleError.class](message, body, id, code);
95
+ }
96
+ else if (kuzzleError.class === 'KuzzleError') {
97
+ const status = kuzzleError.status || 500;
98
+ kerror = new errors.KuzzleError(message, status, id, code);
99
+ }
100
+ else {
101
+ kerror = new errors[kuzzleError.class](message, id, code);
102
+ }
103
+ if (kuzzleError.class !== 'InternalError') {
104
+ cleanStackTrace(kerror);
105
+ }
106
+ return kerror;
96
107
  }
97
-
108
+ exports.rawGet = rawGet;
98
109
  /**
99
110
  * Removes the first lines of the stacktrace because they are related
100
111
  * to internal mechanisms.
@@ -106,98 +117,124 @@ function get (domain, subdomain, error, ...placeholders) {
106
117
  * // Line that triggered the error =>
107
118
  * at ControllerManager.add (kuzzle/lib/core/backend/backend.ts:226:34)
108
119
  */
109
-
110
- function cleanStackTrace (error) {
111
- // Keep the original error message
112
- const messageLength = error.message.split('\n').length;
113
- const currentFileName = _getCurrentFileName();
114
-
115
- // we keep the new error instantiation line ("new ...Error (") on purpose:
116
- // this will allow us to replace it without inserting a new line in the array,
117
- // saving us from building a new array
118
- const newStack = error.stack.split('\n')
119
- .filter((line, index) => {
120
- if (index < messageLength) {
121
- return true;
122
- }
123
-
124
- // filter all lines related to the kerror object
125
- return ! line.includes(currentFileName);
120
+ function cleanStackTrace(error) {
121
+ // Keep the original error message
122
+ const messageLength = error.message.split('\n').length;
123
+ const currentFileName = _getCurrentFileName();
124
+ // we keep the new error instantiation line ("new ...Error (") on purpose:
125
+ // this will allow us to replace it without inserting a new line in the array,
126
+ // saving us from building a new array
127
+ const newStack = error.stack.split('\n')
128
+ .filter((line, index) => {
129
+ if (index < messageLength) {
130
+ return true;
131
+ }
132
+ // filter all lines related to the kerror object
133
+ return !line.includes(currentFileName);
126
134
  })
127
- .map(hilightUserCode);
128
-
129
- // insert a deletion message in place of the new error instantiation line
130
- newStack[messageLength] = ' [...Kuzzle internal calls deleted...]';
131
-
132
- error.stack = newStack.join('\n');
135
+ .map(stackTrace_1.hilightUserCode);
136
+ // insert a deletion message in place of the new error instantiation line
137
+ newStack[messageLength] = ' [...Kuzzle internal calls deleted...]';
138
+ error.stack = newStack.join('\n');
133
139
  }
134
-
135
140
  /**
136
141
  * Returns a promise rejected with the corresponding error
137
142
  *
138
- * @param {string} domain - Domain (eg: 'external')
139
- * @param {string} subdomain - Subdomain (eg: 'elasticsearch')
140
- * @param {string} error - Error name: (eg: 'index_not_found')
141
- * @param {...any} placeholders - Placeholders value to inject in error message
143
+ * @param domains - Domains object with subDomains and error names
144
+ * @param domain - Domain (eg: 'external')
145
+ * @param subdomain - Subdomain (eg: 'elasticsearch')
146
+ * @param error - Error name: (eg: 'index_not_found')
147
+ * @param placeholders - Placeholders value to inject in error message
142
148
  */
143
- function reject (domain, subdomain, error, ...placeholders) {
144
- return Bluebird.reject(get(domain, subdomain, error, ...placeholders));
149
+ function rawReject(domains, domain, subdomain, error, ...placeholders) {
150
+ return Promise.reject(rawGet(domains, domain, subdomain, error, ...placeholders));
145
151
  }
146
-
152
+ exports.rawReject = rawReject;
147
153
  /**
148
154
  * Construct and return the corresponding error, with its stack
149
155
  * trace derivated from a provided source error
150
156
  *
151
- * @param {Error} source
152
- * @param {string} domain - Domain (eg: 'external')
153
- * @param {string} subdomain - Subdomain (eg: 'elasticsearch')
154
- * @param {string} error - Error name: (eg: 'index_not_found')
155
- * @param {...any} placeholders - Placeholders value to inject in error message
157
+ * @param domains - Domains object with subDomains and error names
158
+ * @param source - Original error
159
+ * @param domain - Domain (eg: 'external')
160
+ * @param subdomain - Subdomain (eg: 'elasticsearch')
161
+ * @param error - Error name: (eg: 'index_not_found')
162
+ * @param placeholders - Placeholders value to inject in error message
156
163
  */
157
- function getFrom (source, domain, subdomain, error, ...placeholders) {
158
- const derivedError = get(domain, subdomain, error, ...placeholders);
159
-
160
- // If a stacktrace is present, we need to modify the first line because it
161
- // still contains the original error message
162
- if (derivedError.stack && derivedError.stack.length) {
163
- const stackArray = source.stack.split('\n');
164
- stackArray.shift();
165
- derivedError.stack = [
166
- `${derivedError.constructor.name}: ${derivedError.message}`,
167
- ...stackArray
168
- ].join('\n');
169
- }
170
-
171
- return derivedError;
164
+ function rawGetFrom(domains, source, domain, subdomain, error, ...placeholders) {
165
+ const derivedError = rawGet(domains, domain, subdomain, error, ...placeholders);
166
+ // If a stacktrace is present, we need to modify the first line because it
167
+ // still contains the original error message
168
+ if (derivedError.stack && derivedError.stack.length) {
169
+ const stackArray = source.stack.split('\n');
170
+ stackArray.shift();
171
+ derivedError.stack = [
172
+ `${derivedError.constructor.name}: ${derivedError.message}`,
173
+ ...stackArray
174
+ ].join('\n');
175
+ }
176
+ return derivedError;
172
177
  }
173
-
178
+ exports.rawGetFrom = rawGetFrom;
174
179
  /**
175
180
  * Wrap error functions with the provided domain and subdomain.
176
181
  */
177
- function wrap (domain, subdomain) {
178
- return {
179
- get: (error, ...placeholders) => get(
180
- domain,
181
- subdomain,
182
- error,
183
- ...placeholders),
184
- getFrom: (source, error, ...placeholders) => getFrom(
185
- source,
186
- domain,
187
- subdomain,
188
- error,
189
- ...placeholders),
190
- reject: (error, ...placeholders) => reject(
191
- domain,
192
- subdomain,
193
- error,
194
- ...placeholders),
195
- };
182
+ function rawWrap(domains, domain, subdomain) {
183
+ return {
184
+ get: (error, ...placeholders) => rawGet(domains, domain, subdomain, error, ...placeholders),
185
+ getFrom: (source, error, ...placeholders) => rawGetFrom(domains, source, domain, subdomain, error, ...placeholders),
186
+ reject: (error, ...placeholders) => rawReject(domains, domain, subdomain, error, ...placeholders),
187
+ };
196
188
  }
197
-
198
- module.exports = {
199
- get,
200
- getFrom,
201
- reject,
202
- wrap,
203
- };
189
+ exports.rawWrap = rawWrap;
190
+ /**
191
+ * Construct and return the corresponding error
192
+ *
193
+ * @param domain - Domain (eg: 'external')
194
+ * @param subdomain - Subdomain (eg: 'elasticsearch')
195
+ * @param error - Error name: (eg: 'index_not_found')
196
+ * @param placeholders - Placeholders value to inject in error message
197
+ * @param options - Last param can be additional options { message }
198
+ */
199
+ function get(domain, subdomain, error, ...placeholders) {
200
+ return rawGet(codes_1.domains, domain, subdomain, error, ...placeholders);
201
+ }
202
+ exports.get = get;
203
+ /**
204
+ * Returns a promise rejected with the corresponding error
205
+ *
206
+ * @param domain - Domain (eg: 'external')
207
+ * @param subdomain - Subdomain (eg: 'elasticsearch')
208
+ * @param error - Error name: (eg: 'index_not_found')
209
+ * @param placeholders - Placeholders value to inject in error message
210
+ */
211
+ function reject(domain, subdomain, error, ...placeholders) {
212
+ return rawReject(codes_1.domains, domain, subdomain, error, ...placeholders);
213
+ }
214
+ exports.reject = reject;
215
+ /**
216
+ * Construct and return the corresponding error, with its stack
217
+ * trace derivated from a provided source error
218
+ *
219
+ * @param source - Original error
220
+ * @param domain - Domain (eg: 'external')
221
+ * @param subdomain - Subdomain (eg: 'elasticsearch')
222
+ * @param error - Error name: (eg: 'index_not_found')
223
+ * @param placeholders - Placeholders value to inject in error message
224
+ */
225
+ function getFrom(source, domain, subdomain, error, ...placeholders) {
226
+ return rawGetFrom(codes_1.domains, source, domain, subdomain, error, ...placeholders);
227
+ }
228
+ exports.getFrom = getFrom;
229
+ /**
230
+ * Wrap error functions with the provided domain and subdomain.
231
+ */
232
+ function wrap(domain, subdomain) {
233
+ return {
234
+ get: (error, ...placeholders) => get(domain, subdomain, error, ...placeholders),
235
+ getFrom: (source, error, ...placeholders) => getFrom(source, domain, subdomain, error, ...placeholders),
236
+ reject: (error, ...placeholders) => reject(domain, subdomain, error, ...placeholders),
237
+ };
238
+ }
239
+ exports.wrap = wrap;
240
+ //# sourceMappingURL=index.js.map
@@ -19,6 +19,25 @@
19
19
  * See the License for the specific language governing permissions and
20
20
  * limitations under the License.
21
21
  */
22
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
23
+ if (k2 === undefined) k2 = k;
24
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
25
+ }) : (function(o, m, k, k2) {
26
+ if (k2 === undefined) k2 = k;
27
+ o[k2] = m[k];
28
+ }));
29
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
30
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
31
+ }) : function(o, v) {
32
+ o["default"] = v;
33
+ });
34
+ var __importStar = (this && this.__importStar) || function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
22
41
  var __importDefault = (this && this.__importDefault) || function (mod) {
23
42
  return (mod && mod.__esModule) ? mod : { "default": mod };
24
43
  };
@@ -45,7 +64,7 @@ const vault_1 = __importDefault(require("./vault"));
45
64
  const dumpGenerator_1 = __importDefault(require("./dumpGenerator"));
46
65
  const asyncStore_1 = __importDefault(require("../util/asyncStore"));
47
66
  const mutex_1 = require("../util/mutex");
48
- const kerror_1 = __importDefault(require("../kerror"));
67
+ const kerror = __importStar(require("../kerror"));
49
68
  const internalIndexHandler_1 = __importDefault(require("./internalIndexHandler"));
50
69
  const cacheEngine_1 = __importDefault(require("../core/cache/cacheEngine"));
51
70
  const storageEngine_1 = __importDefault(require("../core/storage/storageEngine"));
@@ -224,7 +243,7 @@ class Kuzzle extends kuzzleEventEmitter_1.default {
224
243
  await installation.handler();
225
244
  }
226
245
  catch (error) {
227
- throw kerror_1.default.get('plugin', 'runtime', 'unexpected_installation_error', installation.id, error);
246
+ throw kerror.get('plugin', 'runtime', 'unexpected_installation_error', installation.id, error);
228
247
  }
229
248
  await this.ask('core:storage:private:document:create', 'kuzzle', 'installations', {
230
249
  description: installation.description,
@@ -266,7 +285,7 @@ class Kuzzle extends kuzzleEventEmitter_1.default {
266
285
  const toImport = config.toImport;
267
286
  const toSupport = config.toSupport;
268
287
  if (!lodash_1.default.isEmpty(toSupport.mappings) && !lodash_1.default.isEmpty(toImport.mappings)) {
269
- throw kerror_1.default.get('plugin', 'runtime', 'incompatible', '_support.mappings', 'import.mappings');
288
+ throw kerror.get('plugin', 'runtime', 'incompatible', '_support.mappings', 'import.mappings');
270
289
  }
271
290
  else if (!lodash_1.default.isEmpty(toSupport.mappings)) {
272
291
  await this.ask('core:storage:public:mappings:import', toSupport.mappings, {
@@ -318,7 +337,7 @@ class Kuzzle extends kuzzleEventEmitter_1.default {
318
337
  && lodash_1.default.isEmpty(toSupport.securities.roles)
319
338
  && lodash_1.default.isEmpty(toSupport.securities.users));
320
339
  if (isPermissionsToSupport && isPermissionsToImport) {
321
- throw kerror_1.default.get('plugin', 'runtime', 'incompatible', '_support.securities', 'import profiles roles or users');
340
+ throw kerror.get('plugin', 'runtime', 'incompatible', '_support.securities', 'import profiles roles or users');
322
341
  }
323
342
  else if (isPermissionsToSupport) {
324
343
  await this.ask('core:security:load', toSupport.securities, {
@@ -19,6 +19,25 @@
19
19
  * See the License for the specific language governing permissions and
20
20
  * limitations under the License.
21
21
  */
22
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
23
+ if (k2 === undefined) k2 = k;
24
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
25
+ }) : (function(o, m, k, k2) {
26
+ if (k2 === undefined) k2 = k;
27
+ o[k2] = m[k];
28
+ }));
29
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
30
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
31
+ }) : function(o, v) {
32
+ o["default"] = v;
33
+ });
34
+ var __importStar = (this && this.__importStar) || function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
22
41
  var __importDefault = (this && this.__importDefault) || function (mod) {
23
42
  return (mod && mod.__esModule) ? mod : { "default": mod };
24
43
  };
@@ -27,9 +46,9 @@ exports.Profile = void 0;
27
46
  const lodash_1 = __importDefault(require("lodash"));
28
47
  const bluebird_1 = __importDefault(require("bluebird"));
29
48
  const rights_1 = __importDefault(require("./rights"));
30
- const kerror_1 = __importDefault(require("../../kerror"));
49
+ const kerror = __importStar(require("../../kerror"));
31
50
  const safeObject_1 = require("../../util/safeObject");
32
- const assertionError = kerror_1.default.wrap('api', 'assert');
51
+ const assertionError = kerror.wrap('api', 'assert');
33
52
  /**
34
53
  * @class Profile
35
54
  */
@@ -47,7 +66,7 @@ class Profile {
47
66
  */
48
67
  async getPolicies() {
49
68
  if (!global.kuzzle) {
50
- throw kerror_1.default.get('security', 'profile', 'uninitialized', this._id);
69
+ throw kerror.get('security', 'profile', 'uninitialized', this._id);
51
70
  }
52
71
  return bluebird_1.default.map(this.optimizedPolicies, async ({ restrictedTo, roleId }) => {
53
72
  const role = await global.kuzzle.ask('core:security:role:get', roleId);
@@ -121,7 +140,7 @@ class Profile {
121
140
  if (strict) {
122
141
  const indexExists = await global.kuzzle.ask('core:storage:public:index:exist', restriction.index);
123
142
  if (!indexExists) {
124
- throw kerror_1.default.get('services', 'storage', 'unknown_index', restriction.index);
143
+ throw kerror.get('services', 'storage', 'unknown_index', restriction.index);
125
144
  }
126
145
  }
127
146
  if (restriction.collections !== undefined
@@ -138,7 +157,7 @@ class Profile {
138
157
  }
139
158
  }
140
159
  if (invalidCollections.length > 0) {
141
- throw kerror_1.default.get('services', 'storage', 'unknown_collection', restriction.index, invalidCollections);
160
+ throw kerror.get('services', 'storage', 'unknown_collection', restriction.index, invalidCollections);
142
161
  }
143
162
  }
144
163
  }
@@ -19,15 +19,31 @@
19
19
  * See the License for the specific language governing permissions and
20
20
  * limitations under the License.
21
21
  */
22
- var __importDefault = (this && this.__importDefault) || function (mod) {
23
- return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
23
+ if (k2 === undefined) k2 = k;
24
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
25
+ }) : (function(o, m, k, k2) {
26
+ if (k2 === undefined) k2 = k;
27
+ o[k2] = m[k];
28
+ }));
29
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
30
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
31
+ }) : function(o, v) {
32
+ o["default"] = v;
33
+ });
34
+ var __importStar = (this && this.__importStar) || function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
38
+ __setModuleDefault(result, mod);
39
+ return result;
24
40
  };
25
41
  Object.defineProperty(exports, "__esModule", { value: true });
26
42
  exports.Role = void 0;
27
- const kerror_1 = __importDefault(require("../../kerror"));
43
+ const kerror = __importStar(require("../../kerror"));
28
44
  const safeObject_1 = require("../../util/safeObject");
29
45
  const array_1 = require("../../util/array");
30
- const assertionError = kerror_1.default.wrap('api', 'assert');
46
+ const assertionError = kerror.wrap('api', 'assert');
31
47
  /**
32
48
  * @class Role
33
49
  */
@@ -41,7 +57,7 @@ class Role {
41
57
  */
42
58
  isActionAllowed(request) {
43
59
  if (!global.kuzzle) {
44
- throw kerror_1.default.get('security', 'role', 'uninitialized', this._id);
60
+ throw kerror.get('security', 'role', 'uninitialized', this._id);
45
61
  }
46
62
  if (this.controllers === undefined || this.controllers === null) {
47
63
  return false;