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
@@ -110,7 +110,7 @@ class AuthController extends NativeController {
110
110
  async createApiKey (request) {
111
111
  const expiresIn = request.input.args.expiresIn || -1;
112
112
  const refresh = request.getRefresh('wait_for');
113
- const apiKeyId = request.getId({ ifMissing: 'ignore' });
113
+ const apiKeyId = request.getId({ ifMissing: 'generate' });
114
114
  const description = request.getBodyString('description');
115
115
 
116
116
  const user = request.context.user;
@@ -136,7 +136,7 @@ class SecurityController extends NativeController {
136
136
  const expiresIn = request.input.args.expiresIn || -1;
137
137
  const refresh = request.getRefresh('wait_for');
138
138
  const userId = request.getString('userId');
139
- const apiKeyId = request.getId({ ifMissing: 'ignore' });
139
+ const apiKeyId = request.getId({ ifMissing: 'generate' });
140
140
  const description = request.getBodyString('description');
141
141
 
142
142
  const user = await this.ask('core:security:user:get', userId);
@@ -314,7 +314,6 @@ class ServerController extends NativeController {
314
314
  request.response.configure({
315
315
  format: 'raw',
316
316
  headers: { 'Content-Type': `application/${format}` },
317
- status: 200,
318
317
  });
319
318
 
320
319
  return format === 'json' ? definition : jsonToYaml.stringify(definition);
package/lib/api/funnel.js CHANGED
@@ -896,6 +896,10 @@ class Funnel {
896
896
  _isOriginAuthorized (origin) {
897
897
  const httpConfig = global.kuzzle.config.http;
898
898
 
899
+ if (! origin) {
900
+ return true;
901
+ }
902
+
899
903
  if (global.kuzzle.config.internal.allowAllOrigins) {
900
904
  return true;
901
905
  }
@@ -38,9 +38,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
38
38
  __setModuleDefault(result, mod);
39
39
  return result;
40
40
  };
41
- var __importDefault = (this && this.__importDefault) || function (mod) {
42
- return (mod && mod.__esModule) ? mod : { "default": mod };
43
- };
44
41
  Object.defineProperty(exports, "__esModule", { value: true });
45
42
  exports.Request = exports.KuzzleRequest = void 0;
46
43
  const uuid = __importStar(require("uuid"));
@@ -49,12 +46,12 @@ const requestInput_1 = require("./requestInput");
49
46
  const requestResponse_1 = require("./requestResponse");
50
47
  const requestContext_1 = require("./requestContext");
51
48
  const errors_1 = require("../../kerror/errors");
52
- const kerror_1 = __importDefault(require("../../kerror"));
49
+ const kerror = __importStar(require("../../kerror"));
53
50
  const types_1 = require("../../types");
54
51
  const assert = __importStar(require("../../util/assertType"));
55
52
  const safeObject_1 = require("../../util/safeObject");
56
53
  const lodash_1 = require("lodash");
57
- const assertionError = kerror_1.default.wrap('api', 'assert');
54
+ const assertionError = kerror.wrap('api', 'assert');
58
55
  // private properties
59
56
  // \u200b is a zero width space, used to masquerade console.log output
60
57
  const _internalId = 'internalId\u200b';
@@ -219,7 +216,7 @@ class KuzzleRequest {
219
216
  throw new errors_1.InternalError('cannot set an error as a request\'s response');
220
217
  }
221
218
  if (this.context.connection.protocol !== 'http' && result instanceof types_1.HttpStream) {
222
- throw kerror_1.default.get('api', 'assert', 'forbidden_stream');
219
+ throw kerror.get('api', 'assert', 'forbidden_stream');
223
220
  }
224
221
  this.status = options.status || 200;
225
222
  if (options.headers) {
@@ -324,7 +321,7 @@ class KuzzleRequest {
324
321
  getLangParam() {
325
322
  const lang = this.getString('lang', 'elasticsearch');
326
323
  if (lang !== 'elasticsearch' && lang !== 'koncorde') {
327
- throw kerror_1.default.get('api', 'assert', 'invalid_argument', 'lang', '"elasticsearch" or "koncorde"');
324
+ throw kerror.get('api', 'assert', 'invalid_argument', 'lang', '"elasticsearch" or "koncorde"');
328
325
  }
329
326
  return lang;
330
327
  }
@@ -589,6 +586,7 @@ class KuzzleRequest {
589
586
  */
590
587
  getId(options = { generator: uuid.v4, ifMissing: 'error' }) {
591
588
  const id = this.input.args._id;
589
+ options.generator = options.generator || uuid.v4; // Default to uuid v4
592
590
  if (!id) {
593
591
  if (options.ifMissing === 'generate') {
594
592
  return options.generator();
@@ -251,7 +251,12 @@ class RequestResponse {
251
251
  if (options.headers) {
252
252
  this.setHeaders(options.headers);
253
253
  }
254
- this.status = options.status || 200;
254
+ if (options.status) {
255
+ this.status = options.status;
256
+ }
257
+ else if (this.status === 102) {
258
+ this.status = 200;
259
+ }
255
260
  switch (options.format) {
256
261
  case 'raw':
257
262
  this.raw = true;
@@ -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
  const koncorde_1 = require("koncorde");
27
- const kerror_1 = __importDefault(require("../kerror"));
43
+ const kerror = __importStar(require("../kerror"));
28
44
  require("../types/Global");
29
45
  const koncordeCompat_1 = require("../util/koncordeCompat");
30
- const errorFatal = kerror_1.default.wrap('cluster', 'fatal');
46
+ const errorFatal = kerror.wrap('cluster', 'fatal');
31
47
  /**
32
48
  * Private class aiming at maintaining both the number of a node's subscriptions
33
49
  * to a room, and the node's last message ID to detect desyncs.
@@ -1,6 +1,6 @@
1
1
  import { EmbeddedSDK } from '../shared/sdk/embeddedSdk';
2
2
  import { JSONObject } from '../../../index';
3
- import { BackendCluster, BackendConfig, BackendController, BackendHook, BackendImport, BackendPipe, BackendPlugin, BackendStorage, BackendVault, BackendOpenApi, InternalLogger } from './index';
3
+ import { BackendCluster, BackendConfig, BackendController, BackendHook, BackendImport, BackendPipe, BackendPlugin, BackendStorage, BackendVault, BackendOpenApi, InternalLogger, BackendErrors } from './index';
4
4
  export declare class Backend {
5
5
  private _kuzzle;
6
6
  private _name;
@@ -117,14 +117,18 @@ export declare class Backend {
117
117
  * OpenApi manager
118
118
  */
119
119
  openApi: BackendOpenApi;
120
+ /**
121
+ * Standard errors
122
+ */
123
+ errors: BackendErrors;
120
124
  /**
121
125
  * @deprecated
122
126
  *
127
+ * Use the app.import.xxx() feature instead.
128
+ *
123
129
  * Support for old features available before Kuzzle as a framework
124
130
  * to avoid breaking existing deployments.
125
131
  *
126
- * Do not use this property unless you know exactly what you are doing,
127
- * this property can be removed in future releases.
128
132
  */
129
133
  _support: JSONObject;
130
134
  /**
@@ -46,10 +46,10 @@ exports.Backend = void 0;
46
46
  const fs_1 = __importDefault(require("fs"));
47
47
  const kuzzle_1 = __importDefault(require("../../kuzzle"));
48
48
  const embeddedSdk_1 = require("../shared/sdk/embeddedSdk");
49
- const kerror_1 = __importDefault(require("../../kerror"));
49
+ const kerror = __importStar(require("../../kerror"));
50
50
  const index_1 = require("./index");
51
- const assertionError = kerror_1.default.wrap('plugin', 'assert');
52
- const runtimeError = kerror_1.default.wrap('plugin', 'runtime');
51
+ const assertionError = kerror.wrap('plugin', 'assert');
52
+ const runtimeError = kerror.wrap('plugin', 'runtime');
53
53
  let _app = null;
54
54
  Reflect.defineProperty(global, 'app', {
55
55
  configurable: true,
@@ -95,11 +95,11 @@ class Backend {
95
95
  /**
96
96
  * @deprecated
97
97
  *
98
+ * Use the app.import.xxx() feature instead.
99
+ *
98
100
  * Support for old features available before Kuzzle as a framework
99
101
  * to avoid breaking existing deployments.
100
102
  *
101
- * Do not use this property unless you know exactly what you are doing,
102
- * this property can be removed in future releases.
103
103
  */
104
104
  this._support = {};
105
105
  /**
@@ -146,7 +146,8 @@ class Backend {
146
146
  this.log = new index_1.InternalLogger(this);
147
147
  this.cluster = new index_1.BackendCluster();
148
148
  this.openApi = new index_1.BackendOpenApi(this);
149
- this.kerror = kerror_1.default;
149
+ this.errors = new index_1.BackendErrors(this);
150
+ this.kerror = kerror;
150
151
  try {
151
152
  this.commit = this._readCommit();
152
153
  }
@@ -213,13 +214,13 @@ class Backend {
213
214
  throw runtimeError.get('already_started', 'install');
214
215
  }
215
216
  if (typeof id !== 'string') {
216
- throw kerror_1.default.get('validation', 'assert', 'invalid_type', 'id', 'string');
217
+ throw kerror.get('validation', 'assert', 'invalid_type', 'id', 'string');
217
218
  }
218
219
  if (typeof handler !== 'function') {
219
- throw kerror_1.default.get('validation', 'assert', 'invalid_type', 'handler', 'function');
220
+ throw kerror.get('validation', 'assert', 'invalid_type', 'handler', 'function');
220
221
  }
221
222
  if (description && typeof description !== 'string') {
222
- throw kerror_1.default.get('validation', 'assert', 'invalid_type', 'id', 'string');
223
+ throw kerror.get('validation', 'assert', 'invalid_type', 'id', 'string');
223
224
  }
224
225
  this._installationsWaitingList.push({ description, handler, id });
225
226
  }
@@ -19,16 +19,35 @@
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
  };
25
44
  Object.defineProperty(exports, "__esModule", { value: true });
26
45
  exports.BackendConfig = void 0;
27
46
  const lodash_1 = __importDefault(require("lodash"));
28
- const kerror_1 = __importDefault(require("../../kerror"));
47
+ const kerror = __importStar(require("../../kerror"));
29
48
  const index_1 = require("./index");
30
49
  const index_js_1 = require("../../config/index.js");
31
- const runtimeError = kerror_1.default.wrap('plugin', 'runtime');
50
+ const runtimeError = kerror.wrap('plugin', 'runtime');
32
51
  class BackendConfig extends index_1.ApplicationManager {
33
52
  constructor(application) {
34
53
  super(application);
@@ -19,16 +19,32 @@
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.BackendController = void 0;
27
43
  const inflector_1 = require("../../util/inflector");
28
- const kerror_1 = __importDefault(require("../../kerror"));
44
+ const kerror = __importStar(require("../../kerror"));
29
45
  const index_1 = require("./index");
30
- const assertionError = kerror_1.default.wrap('plugin', 'assert');
31
- const runtimeError = kerror_1.default.wrap('plugin', 'runtime');
46
+ const assertionError = kerror.wrap('plugin', 'assert');
47
+ const runtimeError = kerror.wrap('plugin', 'runtime');
32
48
  class BackendController extends index_1.ApplicationManager {
33
49
  /**
34
50
  * Registers a new controller.
@@ -0,0 +1,58 @@
1
+ import { KuzzleError } from '../../kerror/errors';
2
+ import { ApplicationManager, Backend } from './index';
3
+ import { CustomErrorDefinition } from '../../types';
4
+ export declare class BackendErrors extends ApplicationManager {
5
+ private domains;
6
+ private subDomains;
7
+ constructor(application: Backend);
8
+ /**
9
+ * Register a new standard KuzzleError
10
+ *
11
+ * @param subDomain Subdomain name
12
+ * @param name Standard error name
13
+ * @param definition Standard error definition
14
+ *
15
+ * @example
16
+ * ```
17
+ * app.errors.register('api', 'custom', {
18
+ * class: 'BadRequestError',
19
+ * description: 'This is a custom error from API subdomain',
20
+ * message: 'Custom API error: %s',
21
+ * });
22
+ * ```
23
+ */
24
+ register(subDomain: string, name: string, definition: CustomErrorDefinition): void;
25
+ /**
26
+ * Get a standardized KuzzleError
27
+ *
28
+ * @param subDomain Subdomain name
29
+ * @param name Standard error name
30
+ * @param placeholders Other placeholder arguments
31
+ *
32
+ * @example throw app.errors.get('api', 'custom', 'Tbilisi');
33
+ *
34
+ * @returns Standardized KuzzleError
35
+ */
36
+ get(subDomain: string, name: string, ...placeholders: any[]): KuzzleError;
37
+ /**
38
+ * Get a standardized KuzzleError from an existing error to keep the stacktrace
39
+ *
40
+ * @param source Original error
41
+ * @param subDomain Subdomain name
42
+ * @param name Standard error name
43
+ * @param placeholders Other placeholder arguments
44
+ *
45
+ * @returns Standardized KuzzleError
46
+ */
47
+ getFrom(source: Error, subDomain: string, name: string, ...placeholders: any[]): KuzzleError;
48
+ /**
49
+ * Wrap an error manager on the subDomain
50
+ *
51
+ * @param subDomain Subdomain to wrap to
52
+ */
53
+ wrap(subDomain: string): {
54
+ get: (error: any, ...placeholders: any[]) => KuzzleError;
55
+ getFrom: (source: any, error: any, ...placeholders: any[]) => KuzzleError;
56
+ reject: (error: any, ...placeholders: any[]) => Promise<any>;
57
+ };
58
+ }
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ /*
3
+ * Kuzzle, a backend software, self-hostable and ready to use
4
+ * to power modern apps
5
+ *
6
+ * Copyright 2015-2020 Kuzzle
7
+ * mailto: support AT kuzzle.io
8
+ * website: http://kuzzle.io
9
+ *
10
+ * Licensed under the Apache License, Version 2.0 (the "License");
11
+ * you may not use this file except in compliance with the License.
12
+ * You may obtain a copy of the License at
13
+ *
14
+ * https://www.apache.org/licenses/LICENSE-2.0
15
+ *
16
+ * Unless required by applicable law or agreed to in writing, software
17
+ * distributed under the License is distributed on an "AS IS" BASIS,
18
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ * See the License for the specific language governing permissions and
20
+ * limitations under the License.
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
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.BackendErrors = void 0;
43
+ const kerror = __importStar(require("../../kerror"));
44
+ const index_1 = require("./index");
45
+ class BackendErrors extends index_1.ApplicationManager {
46
+ constructor(application) {
47
+ super(application);
48
+ this.domains = {
49
+ app: {
50
+ code: 9,
51
+ subDomains: {},
52
+ }
53
+ };
54
+ this.subDomains = 0;
55
+ }
56
+ /**
57
+ * Register a new standard KuzzleError
58
+ *
59
+ * @param subDomain Subdomain name
60
+ * @param name Standard error name
61
+ * @param definition Standard error definition
62
+ *
63
+ * @example
64
+ * ```
65
+ * app.errors.register('api', 'custom', {
66
+ * class: 'BadRequestError',
67
+ * description: 'This is a custom error from API subdomain',
68
+ * message: 'Custom API error: %s',
69
+ * });
70
+ * ```
71
+ */
72
+ register(subDomain, name, definition) {
73
+ if (!this.domains.app.subDomains[subDomain]) {
74
+ this.domains.app.subDomains[subDomain] = {
75
+ code: this.subDomains++,
76
+ errors: {},
77
+ };
78
+ }
79
+ this.domains.app.subDomains[subDomain].errors[name] = {
80
+ code: Object.keys(this.domains.app.subDomains[subDomain].errors).length,
81
+ ...definition,
82
+ };
83
+ }
84
+ /**
85
+ * Get a standardized KuzzleError
86
+ *
87
+ * @param subDomain Subdomain name
88
+ * @param name Standard error name
89
+ * @param placeholders Other placeholder arguments
90
+ *
91
+ * @example throw app.errors.get('api', 'custom', 'Tbilisi');
92
+ *
93
+ * @returns Standardized KuzzleError
94
+ */
95
+ get(subDomain, name, ...placeholders) {
96
+ return kerror.rawGet(this.domains, 'app', subDomain, name, ...placeholders);
97
+ }
98
+ /**
99
+ * Get a standardized KuzzleError from an existing error to keep the stacktrace
100
+ *
101
+ * @param source Original error
102
+ * @param subDomain Subdomain name
103
+ * @param name Standard error name
104
+ * @param placeholders Other placeholder arguments
105
+ *
106
+ * @returns Standardized KuzzleError
107
+ */
108
+ getFrom(source, subDomain, name, ...placeholders) {
109
+ return kerror.rawGetFrom(this.domains, source, 'app', subDomain, name, ...placeholders);
110
+ }
111
+ /**
112
+ * Wrap an error manager on the subDomain
113
+ *
114
+ * @param subDomain Subdomain to wrap to
115
+ */
116
+ wrap(subDomain) {
117
+ return kerror.rawWrap(this.domains, 'app', subDomain);
118
+ }
119
+ }
120
+ exports.BackendErrors = BackendErrors;
121
+ //# sourceMappingURL=backendErrors.js.map
@@ -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.BackendHook = void 0;
27
- const kerror_1 = __importDefault(require("../../kerror"));
43
+ const kerror = __importStar(require("../../kerror"));
28
44
  const index_1 = require("./index");
29
- const assertionError = kerror_1.default.wrap('plugin', 'assert');
30
- const runtimeError = kerror_1.default.wrap('plugin', 'runtime');
45
+ const assertionError = kerror.wrap('plugin', 'assert');
46
+ const runtimeError = kerror.wrap('plugin', 'runtime');
31
47
  class BackendHook extends index_1.ApplicationManager {
32
48
  /**
33
49
  * Registers a new hook on an event
@@ -19,16 +19,32 @@
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.BackendImport = void 0;
27
- const kerror_1 = __importDefault(require("../../kerror"));
43
+ const kerror = __importStar(require("../../kerror"));
28
44
  const index_1 = require("./index");
29
45
  const safeObject_1 = require("../../../lib/util/safeObject");
30
- const assertionError = kerror_1.default.wrap('validation', 'assert');
31
- const runtimeError = kerror_1.default.wrap('plugin', 'runtime');
46
+ const assertionError = kerror.wrap('validation', 'assert');
47
+ const runtimeError = kerror.wrap('plugin', 'runtime');
32
48
  class BackendImport extends index_1.ApplicationManager {
33
49
  /**
34
50
  * Import mappings.
@@ -27,7 +27,7 @@ class BackendOpenApi extends index_1.ApplicationManager {
27
27
  super(application);
28
28
  /* eslint-disable sort-keys */
29
29
  this.definition = {
30
- swagger: '2.0',
30
+ openapi: '3.0.0',
31
31
  info: {
32
32
  title: `${application.name} API`,
33
33
  description: `${application.name} HTTP API definition`,
@@ -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.BackendPipe = void 0;
27
- const kerror_1 = __importDefault(require("../../kerror"));
43
+ const kerror = __importStar(require("../../kerror"));
28
44
  const index_1 = require("./index");
29
- const assertionError = kerror_1.default.wrap('plugin', 'assert');
30
- const runtimeError = kerror_1.default.wrap('plugin', 'runtime');
45
+ const assertionError = kerror.wrap('plugin', 'assert');
46
+ const runtimeError = kerror.wrap('plugin', 'runtime');
31
47
  class BackendPipe extends index_1.ApplicationManager {
32
48
  /**
33
49
  * Registers a new pipe on an event
@@ -19,17 +19,36 @@
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
  };
25
44
  Object.defineProperty(exports, "__esModule", { value: true });
26
45
  exports.BackendPlugin = void 0;
27
46
  const inflector_1 = require("../../util/inflector");
28
- const kerror_1 = __importDefault(require("../../kerror"));
47
+ const kerror = __importStar(require("../../kerror"));
29
48
  const index_1 = require("./index");
30
49
  const didYouMean_1 = __importDefault(require("../../util/didYouMean"));
31
- const assertionError = kerror_1.default.wrap('plugin', 'assert');
32
- const runtimeError = kerror_1.default.wrap('plugin', 'runtime');
50
+ const assertionError = kerror.wrap('plugin', 'assert');
51
+ const runtimeError = kerror.wrap('plugin', 'runtime');
33
52
  class BackendPlugin extends index_1.ApplicationManager {
34
53
  /**
35
54
  * Uses a plugin in this application.