kuzzle 2.17.0 → 2.17.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 (44) hide show
  1. package/lib/api/controllers/authController.js +1 -1
  2. package/lib/api/controllers/securityController.js +1 -1
  3. package/lib/api/request/kuzzleRequest.js +5 -7
  4. package/lib/cluster/state.js +20 -4
  5. package/lib/core/backend/backend.d.ts +7 -3
  6. package/lib/core/backend/backend.js +10 -9
  7. package/lib/core/backend/backendConfig.js +21 -2
  8. package/lib/core/backend/backendController.js +21 -5
  9. package/lib/core/backend/backendErrors.d.ts +58 -0
  10. package/lib/core/backend/backendErrors.js +121 -0
  11. package/lib/core/backend/backendHook.js +21 -5
  12. package/lib/core/backend/backendImport.js +21 -5
  13. package/lib/core/backend/backendOpenApi.js +1 -1
  14. package/lib/core/backend/backendPipe.js +21 -5
  15. package/lib/core/backend/backendPlugin.js +22 -3
  16. package/lib/core/backend/backendVault.js +21 -2
  17. package/lib/core/backend/index.d.ts +1 -0
  18. package/lib/core/backend/index.js +1 -0
  19. package/lib/core/network/protocols/httpwsProtocol.js +15 -2
  20. package/lib/core/plugin/pluginContext.js +22 -3
  21. package/lib/core/realtime/channel.js +20 -4
  22. package/lib/core/realtime/hotelClerk.js +24 -5
  23. package/lib/core/security/profileRepository.js +26 -7
  24. package/lib/core/shared/sdk/embeddedSdk.js +21 -2
  25. package/lib/core/storage/indexCache.js +20 -4
  26. package/lib/kerror/errors/multipleErrorsError.d.ts +1 -1
  27. package/lib/kerror/errors/multipleErrorsError.js +3 -3
  28. package/lib/kerror/index.d.ts +82 -0
  29. package/lib/kerror/index.js +176 -143
  30. package/lib/kuzzle/kuzzle.js +23 -4
  31. package/lib/model/security/profile.js +24 -5
  32. package/lib/model/security/role.js +21 -5
  33. package/lib/model/security/user.js +21 -2
  34. package/lib/types/Plugin.js +20 -4
  35. package/lib/types/errors/ErrorDefinition.d.ts +27 -0
  36. package/lib/types/errors/ErrorDefinition.js +3 -0
  37. package/lib/types/errors/ErrorDomains.d.ts +17 -0
  38. package/lib/types/errors/ErrorDomains.js +3 -0
  39. package/lib/types/index.d.ts +2 -0
  40. package/lib/types/index.js +2 -0
  41. package/lib/util/dump-collection.js +21 -2
  42. package/lib/util/mutex.js +21 -2
  43. package/package-lock.json +4 -4
  44. package/package.json +1 -1
@@ -11,3 +11,4 @@ export * from './backendStorage';
11
11
  export * from './backendVault';
12
12
  export * from './backendOpenApi';
13
13
  export * from './internalLogger';
14
+ export * from './backendErrors';
@@ -23,4 +23,5 @@ __exportStar(require("./backendStorage"), exports);
23
23
  __exportStar(require("./backendVault"), exports);
24
24
  __exportStar(require("./backendOpenApi"), exports);
25
25
  __exportStar(require("./internalLogger"), exports);
26
+ __exportStar(require("./backendErrors"), exports);
26
27
  //# sourceMappingURL=index.js.map
@@ -77,6 +77,9 @@ const HTTP_ALLOWED_CONTENT_TYPES = [
77
77
  'application/x-www-form-urlencoded',
78
78
  'multipart/form-data',
79
79
  ];
80
+ const HTTP_SKIPPED_HEADERS = [
81
+ 'content-length',
82
+ ];
80
83
  const HTTP_HEADER_CONNECTION = Buffer.from('Connection');
81
84
  const HTTP_HEADER_CONTENT_LENGTH = Buffer.from('Content-Length');
82
85
  const HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN = Buffer.from('Access-Control-Allow-Origin');
@@ -351,7 +354,7 @@ class HttpWsProtocol extends Protocol {
351
354
  request = new Request(parsed, { connection });
352
355
  }
353
356
  catch (e) {
354
- this.wsSendError(socket, connection, e);
357
+ this.wsSendError(socket, connection, e, parsed.requestId);
355
358
  return;
356
359
  }
357
360
 
@@ -392,9 +395,14 @@ class HttpWsProtocol extends Protocol {
392
395
  * @param {uWS.WebSocket} socket
393
396
  * @param {ClientConnection} connection
394
397
  * @param {Error} error
398
+ * @param {String} requestId @optional
395
399
  */
396
- wsSendError (socket, connection, error) {
400
+ wsSendError (socket, connection, error, requestId) {
397
401
  const request = new Request({}, { connection, error });
402
+
403
+ // If a requestId is provided we use it instead of the generated one
404
+ request.id = requestId || request.id;
405
+
398
406
  const sanitized = removeErrorStack(request.response.toJSON()).content;
399
407
 
400
408
  this.wsSend(socket, Buffer.from(JSON.stringify(sanitized)));
@@ -656,6 +664,11 @@ class HttpWsProtocol extends Protocol {
656
664
  }
657
665
 
658
666
  for (const [key, value] of Object.entries(request.response.headers)) {
667
+ // Skip some headers that are not allowed to be sent or modified
668
+ if (HTTP_SKIPPED_HEADERS.includes(key.toLowerCase())) {
669
+ continue;
670
+ }
671
+
659
672
  response.writeHeader(Buffer.from(key), Buffer.from(value.toString()));
660
673
  }
661
674
  }
@@ -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
  };
@@ -33,12 +52,12 @@ const elasticsearch_1 = __importDefault(require("../../service/storage/elasticse
33
52
  const safeObject_1 = require("../../util/safeObject");
34
53
  const promback_1 = __importDefault(require("../../util/promback"));
35
54
  const mutex_1 = require("../../util/mutex");
36
- const kerror_1 = __importDefault(require("../../kerror"));
55
+ const kerror = __importStar(require("../../kerror"));
37
56
  const storeScopeEnum_1 = __importDefault(require("../storage/storeScopeEnum"));
38
57
  const errors_1 = require("../../kerror/errors");
39
58
  const index_1 = require("../../../index");
40
59
  const backend_1 = require("../backend");
41
- const contextError = kerror_1.default.wrap('plugin', 'context');
60
+ const contextError = kerror.wrap('plugin', 'context');
42
61
  class PluginContext {
43
62
  constructor(pluginName) {
44
63
  this.config = JSON.parse(JSON.stringify(global.kuzzle.config));
@@ -60,7 +79,7 @@ class PluginContext {
60
79
  TooManyRequestsError: errors_1.TooManyRequestsError,
61
80
  UnauthorizedError: errors_1.UnauthorizedError,
62
81
  };
63
- this.kerror = kerror_1.default.wrap('plugin', pluginName);
82
+ this.kerror = kerror.wrap('plugin', pluginName);
64
83
  // @deprecated - backward compatibility only
65
84
  this.errorsManager = this.kerror;
66
85
  /* context.secrets ====================================================== */
@@ -19,13 +19,29 @@
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.Channel = void 0;
27
- const kerror_1 = __importDefault(require("../../kerror"));
28
- const realtimeError = kerror_1.default.wrap('core', 'realtime');
43
+ const kerror = __importStar(require("../../kerror"));
44
+ const realtimeError = kerror.wrap('core', 'realtime');
29
45
  /**
30
46
  * A channel define how notifications should be send for a particular realtime
31
47
  * room.
@@ -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
  };
@@ -26,14 +45,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
45
  exports.HotelClerk = void 0;
27
46
  const bluebird_1 = __importDefault(require("bluebird"));
28
47
  const request_1 = require("../../api/request");
29
- const kerror_1 = __importDefault(require("../../kerror"));
48
+ const kerror = __importStar(require("../../kerror"));
30
49
  const debug_1 = __importDefault(require("../../util/debug"));
31
50
  const koncordeCompat_1 = require("../../util/koncordeCompat");
32
51
  const channel_1 = require("./channel");
33
52
  const connectionRooms_1 = require("./connectionRooms");
34
53
  const room_1 = require("./room");
35
54
  const subscription_1 = require("./subscription");
36
- const realtimeError = kerror_1.default.wrap('core', 'realtime');
55
+ const realtimeError = kerror.wrap('core', 'realtime');
37
56
  const debug = (0, debug_1.default)('kuzzle:realtime:hotelClerk');
38
57
  /**
39
58
  * The HotelClerk is responsible of keeping the list of rooms and subscriptions
@@ -168,10 +187,10 @@ class HotelClerk {
168
187
  async subscribe(request) {
169
188
  const { index, collection } = request.input.resource;
170
189
  if (!index) {
171
- return kerror_1.default.reject('api', 'assert', 'missing_argument', 'index');
190
+ return kerror.reject('api', 'assert', 'missing_argument', 'index');
172
191
  }
173
192
  if (!collection) {
174
- return kerror_1.default.reject('api', 'assert', 'missing_argument', 'collection');
193
+ return kerror.reject('api', 'assert', 'missing_argument', 'collection');
175
194
  }
176
195
  /*
177
196
  * /!\ This check is a duplicate to the one already made by the
@@ -192,7 +211,7 @@ class HotelClerk {
192
211
  normalized = this.koncorde.normalize(request.input.body, (0, koncordeCompat_1.toKoncordeIndex)(index, collection));
193
212
  }
194
213
  catch (e) {
195
- throw kerror_1.default.get('api', 'assert', 'koncorde_dsl_error', e.message);
214
+ throw kerror.get('api', 'assert', 'koncorde_dsl_error', e.message);
196
215
  }
197
216
  this.createRoom(normalized);
198
217
  const { channel, subscribed } = await this.subscribeToRoom(normalized.id, request);
@@ -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
  };
@@ -28,7 +47,7 @@ const lodash_1 = require("lodash");
28
47
  const bluebird_1 = __importDefault(require("bluebird"));
29
48
  const profile_1 = require("../../model/security/profile");
30
49
  const repository_1 = __importDefault(require("../shared/repository"));
31
- const kerror_1 = __importDefault(require("../../kerror"));
50
+ const kerror = __importStar(require("../../kerror"));
32
51
  const cacheDbEnum_1 = __importDefault(require("../cache/cacheDbEnum"));
33
52
  /**
34
53
  * @class ProfileRepository
@@ -159,7 +178,7 @@ class ProfileRepository extends repository_1.default {
159
178
  async loadProfiles(profileIds = []) {
160
179
  const profiles = [];
161
180
  if (profileIds.some(p => typeof p !== 'string')) {
162
- throw kerror_1.default.get('api', 'assert', 'invalid_type', 'profileIds', 'string[]');
181
+ throw kerror.get('api', 'assert', 'invalid_type', 'profileIds', 'string[]');
163
182
  }
164
183
  for (const id of profileIds) {
165
184
  let profile = this.profiles.get(id);
@@ -184,7 +203,7 @@ class ProfileRepository extends repository_1.default {
184
203
  }
185
204
  catch (err) {
186
205
  if (err.status === 404) {
187
- throw kerror_1.default.get('security', 'profile', 'not_found', id);
206
+ throw kerror.get('security', 'profile', 'not_found', id);
188
207
  }
189
208
  throw err;
190
209
  }
@@ -283,7 +302,7 @@ class ProfileRepository extends repository_1.default {
283
302
  */
284
303
  async delete(profile, { refresh = 'false', onAssignedUsers = 'fail', userId = '-1', } = {}) {
285
304
  if (['admin', 'default', 'anonymous'].includes(profile._id)) {
286
- throw kerror_1.default.get('security', 'profile', 'cannot_delete');
305
+ throw kerror.get('security', 'profile', 'cannot_delete');
287
306
  }
288
307
  const query = {
289
308
  terms: {
@@ -316,7 +335,7 @@ class ProfileRepository extends repository_1.default {
316
335
  else {
317
336
  const hits = await this.module.user.search({ query }, { from: 0, size: 1 });
318
337
  if (hits.total > 0) {
319
- throw kerror_1.default.get('security', 'profile', 'in_use');
338
+ throw kerror.get('security', 'profile', 'in_use');
320
339
  }
321
340
  }
322
341
  await this.deleteFromDatabase(profile._id, { refresh });
@@ -353,7 +372,7 @@ class ProfileRepository extends repository_1.default {
353
372
  await profile.validateDefinition({ strict });
354
373
  if (profile._id === 'anonymous'
355
374
  && policiesRoles.indexOf('anonymous') === -1) {
356
- throw kerror_1.default.get('security', 'profile', 'missing_anonymous_role');
375
+ throw kerror.get('security', 'profile', 'missing_anonymous_role');
357
376
  }
358
377
  profile.optimizedPolicies = undefined; // Remove optimized policies
359
378
  await super.persistToDatabase(profile, { method, refresh, retryOnConflict });
@@ -380,7 +399,7 @@ class ProfileRepository extends repository_1.default {
380
399
  const roles = await this.module.role.loadRoles(policiesRoles);
381
400
  // Fail if not all roles are found
382
401
  if (roles.some(r => r === null)) {
383
- throw kerror_1.default.get('security', 'profile', 'cannot_hydrate');
402
+ throw kerror.get('security', 'profile', 'cannot_hydrate');
384
403
  }
385
404
  return profile;
386
405
  }
@@ -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.EmbeddedSDK = void 0;
27
46
  const kuzzle_sdk_1 = require("kuzzle-sdk");
28
47
  const funnelProtocol_1 = __importDefault(require("./funnelProtocol"));
29
48
  const safeObject_1 = require("../../../util/safeObject");
30
- const kerror_1 = __importDefault(require("../../../kerror"));
49
+ const kerror = __importStar(require("../../../kerror"));
31
50
  const impersonatedSdk_1 = __importDefault(require("./impersonatedSdk"));
32
- const contextError = kerror_1.default.wrap('plugin', 'context');
51
+ const contextError = kerror.wrap('plugin', 'context');
33
52
  /**
34
53
  * Kuzzle embedded SDK to make API calls inside applications or plugins.
35
54
  */
@@ -19,13 +19,29 @@
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.IndexCache = void 0;
27
- const kerror_1 = __importDefault(require("../../kerror"));
28
- const storageError = kerror_1.default.wrap('services', 'storage');
43
+ const kerror = __importStar(require("../../kerror"));
44
+ const storageError = kerror.wrap('services', 'storage');
29
45
  class IndexCache {
30
46
  constructor() {
31
47
  /**
@@ -2,6 +2,6 @@ import { KuzzleError } from './kuzzleError';
2
2
  export declare class MultipleErrorsError extends KuzzleError {
3
3
  errors: Array<KuzzleError>;
4
4
  count: number;
5
- constructor(message: string, body?: Array<KuzzleError>, id?: string, code?: number);
5
+ constructor(message: string, errors?: KuzzleError[], id?: string, code?: number);
6
6
  toJSON(): import("kuzzle-sdk").JSONObject;
7
7
  }
@@ -23,10 +23,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.MultipleErrorsError = void 0;
24
24
  const kuzzleError_1 = require("./kuzzleError");
25
25
  class MultipleErrorsError extends kuzzleError_1.KuzzleError {
26
- constructor(message, body = [], id, code) {
26
+ constructor(message, errors = [], id, code) {
27
27
  super(message, 400, id, code);
28
- this.errors = body;
29
- this.count = body.length;
28
+ this.errors = errors;
29
+ this.count = errors.length;
30
30
  }
31
31
  toJSON() {
32
32
  const serialized = super.toJSON();
@@ -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
+ };