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
@@ -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,7 +46,7 @@ exports.User = void 0;
27
46
  const rights_1 = __importDefault(require("./rights"));
28
47
  const bluebird_1 = __importDefault(require("bluebird"));
29
48
  const lodash_1 = __importDefault(require("lodash"));
30
- const kerror_1 = __importDefault(require("../../kerror"));
49
+ const kerror = __importStar(require("../../kerror"));
31
50
  /**
32
51
  * @class User
33
52
  */
@@ -41,7 +60,7 @@ class User {
41
60
  */
42
61
  getProfiles() {
43
62
  if (!global.kuzzle) {
44
- return kerror_1.default.reject('security', 'user', 'uninitialized', this._id);
63
+ return kerror.reject('security', 'user', 'uninitialized', this._id);
45
64
  }
46
65
  return global.kuzzle.ask('core:security:profile:mGet', this.profileIds);
47
66
  }
@@ -19,12 +19,28 @@
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.Plugin = 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
  /**
30
46
  * Plugins must implements this abstract class.
@@ -36,7 +52,7 @@ class Plugin {
36
52
  constructor(manifest) {
37
53
  if (!(0, safeObject_1.has)(manifest, 'kuzzleVersion')) {
38
54
  // eslint-disable-next-line new-cap
39
- throw new kerror_1.default.get('plugin', 'manifest', 'missing_version');
55
+ throw kerror.get('plugin', 'manifest', 'missing_version');
40
56
  }
41
57
  this._manifest = manifest;
42
58
  }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Available error class
3
+ */
4
+ export declare type ErrorClassNames = 'BadRequestError' | 'ExternalServiceError' | 'ForbiddenError' | 'GatewayTimeoutError' | 'InternalError' | 'KuzzleError' | 'MultipleErrorsError' | 'NotFoundError' | 'PartialError' | 'PluginImplementationError' | 'ServiceUnavailableError' | 'SizeLimitError' | 'UnauthorizedError' | 'PreconditionError' | 'TooManyRequestsError';
5
+ /**
6
+ * Represents a standardized error definition
7
+ */
8
+ export declare type ErrorDefinition = CustomErrorDefinition & {
9
+ code: number;
10
+ };
11
+ /**
12
+ * Represents a custom standardized error definition
13
+ */
14
+ export declare type CustomErrorDefinition = {
15
+ /**
16
+ * Error description for documentation purpose
17
+ */
18
+ description: string;
19
+ /**
20
+ * Error message
21
+ */
22
+ message: string;
23
+ /**
24
+ * Error class
25
+ */
26
+ class: ErrorClassNames;
27
+ /**
28
+ * Custom HTTP status.
29
+ *
30
+ * Only available for generic KuzzleError.
31
+ */
32
+ status?: number;
33
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ErrorDefinition.js.map
@@ -0,0 +1,17 @@
1
+ import { ErrorDefinition } from './ErrorDefinition';
2
+ /**
3
+ * Represents the domains, subDomains and error names with associated definitions
4
+ */
5
+ export declare type ErrorDomains = {
6
+ [domain: string]: {
7
+ code: number;
8
+ subDomains?: {
9
+ [subDomain: string]: {
10
+ code: number;
11
+ errors: {
12
+ [errorName: string]: ErrorDefinition;
13
+ };
14
+ };
15
+ };
16
+ };
17
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ErrorDomains.js.map
@@ -35,3 +35,5 @@ export * from './config/internalCache/InternalCacheRedisConfiguration';
35
35
  export * from './config/storageEngine/StorageEngineElasticsearchConfiguration';
36
36
  export * from './config/DumpConfiguration';
37
37
  export * from './OpenApiDefinition';
38
+ export * from './errors/ErrorDefinition';
39
+ export * from './errors/ErrorDomains';
@@ -67,4 +67,6 @@ __exportStar(require("./config/internalCache/InternalCacheRedisConfiguration"),
67
67
  __exportStar(require("./config/storageEngine/StorageEngineElasticsearchConfiguration"), exports);
68
68
  __exportStar(require("./config/DumpConfiguration"), exports);
69
69
  __exportStar(require("./OpenApiDefinition"), exports);
70
+ __exportStar(require("./errors/ErrorDefinition"), exports);
71
+ __exportStar(require("./errors/ErrorDomains"), exports);
70
72
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,23 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
2
21
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
22
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
23
  };
@@ -7,7 +26,7 @@ exports.dumpCollectionDocuments = void 0;
7
26
  const ndjson_1 = __importDefault(require("ndjson"));
8
27
  const get_1 = __importDefault(require("lodash/get"));
9
28
  const isObject_1 = __importDefault(require("lodash/isObject"));
10
- const kerror_1 = __importDefault(require("../kerror"));
29
+ const kerror = __importStar(require("../kerror"));
11
30
  const bufferedPassThrough_1 = require("./bufferedPassThrough");
12
31
  const types_1 = require("../types");
13
32
  /**
@@ -104,7 +123,7 @@ class AbstractDumper {
104
123
  this.writeStream = writeStream;
105
124
  this.options = options;
106
125
  if (!writeStream) {
107
- throw kerror_1.default.get('api', 'assert', 'missing_argument', 'writeStream');
126
+ throw kerror.get('api', 'assert', 'missing_argument', 'writeStream');
108
127
  }
109
128
  }
110
129
  /**
package/lib/util/mutex.js CHANGED
@@ -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,11 +45,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
45
  exports.Mutex = void 0;
27
46
  const crypto_1 = require("crypto");
28
47
  const bluebird_1 = __importDefault(require("bluebird"));
29
- const kerror_1 = __importDefault(require("../kerror"));
48
+ const kerror = __importStar(require("../kerror"));
30
49
  const debug_1 = __importDefault(require("./debug"));
31
50
  require("../types/Global");
32
51
  const debug = (0, debug_1.default)('kuzzle:mutex');
33
- const fatal = kerror_1.default.wrap('core', 'fatal');
52
+ const fatal = kerror.wrap('core', 'fatal');
34
53
  // LUA script for Redis: we want our mutexes to only delete the lock they
35
54
  // acquired. Prevents removing locks acquired by other processes if unlocking
36
55
  // occurs after the lock expires
package/package-lock.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kuzzle",
3
- "version": "2.17.0",
3
+ "version": "2.17.3",
4
4
  "lockfileVersion": 1,
5
5
  "requires": true,
6
6
  "dependencies": {
@@ -5919,7 +5919,7 @@
5919
5919
  },
5920
5920
  "passport-local": {
5921
5921
  "version": "1.0.0",
5922
- "resolved": "https://registry.npmjs.org/passport-local/-/passport-local-1.0.0.tgz",
5922
+ "resolved": "https://packages.app.kuzzle.io/passport-local/-/passport-local-1.0.0.tgz",
5923
5923
  "integrity": "sha1-H+YyaMkudWBmJkN+O5BmYsFbpu4=",
5924
5924
  "requires": {
5925
5925
  "passport-strategy": "1.x.x"
@@ -6584,7 +6584,7 @@
6584
6584
  },
6585
6585
  "argparse": {
6586
6586
  "version": "1.0.10",
6587
- "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
6587
+ "resolved": "https://packages.app.kuzzle.io/argparse/-/argparse-1.0.10.tgz",
6588
6588
  "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
6589
6589
  "dev": true,
6590
6590
  "requires": {
@@ -6845,7 +6845,7 @@
6845
6845
  },
6846
6846
  "js-yaml": {
6847
6847
  "version": "3.14.1",
6848
- "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz",
6848
+ "resolved": "https://packages.app.kuzzle.io/js-yaml/-/js-yaml-3.14.1.tgz",
6849
6849
  "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==",
6850
6850
  "dev": true,
6851
6851
  "requires": {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "kuzzle",
3
3
  "author": "The Kuzzle Team <support@kuzzle.io>",
4
- "version": "2.17.0",
4
+ "version": "2.17.3",
5
5
  "description": "Kuzzle is an open-source solution that handles all the data management through a secured API, with a large choice of protocols.",
6
6
  "bin": {
7
7
  "kuzzle": "bin/start-kuzzle-server"