kuzzle 2.16.11 → 2.17.2

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 (187) hide show
  1. package/lib/api/controllers/adminController.js +3 -3
  2. package/lib/api/controllers/authController.js +12 -12
  3. package/lib/api/controllers/baseController.js +60 -3
  4. package/lib/api/controllers/clusterController.js +1 -1
  5. package/lib/api/controllers/collectionController.js +7 -5
  6. package/lib/api/controllers/documentController.js +130 -17
  7. package/lib/api/controllers/indexController.js +1 -1
  8. package/lib/api/controllers/memoryStorageController.js +39 -38
  9. package/lib/api/controllers/realtimeController.js +1 -1
  10. package/lib/api/controllers/securityController.js +50 -50
  11. package/lib/api/controllers/serverController.js +73 -27
  12. package/lib/api/documentExtractor.js +3 -3
  13. package/lib/api/funnel.js +44 -21
  14. package/lib/api/httpRoutes.js +9 -4
  15. package/lib/api/openapi/OpenApiManager.d.ts +11 -0
  16. package/lib/api/openapi/OpenApiManager.js +96 -0
  17. package/lib/api/openapi/{document → components/document}/count.yaml +2 -2
  18. package/lib/api/openapi/{document → components/document}/create.yaml +2 -2
  19. package/lib/api/openapi/{document → components/document}/createOrReplace.yaml +2 -2
  20. package/lib/api/openapi/{document → components/document}/delete.yaml +1 -1
  21. package/lib/api/openapi/{document → components/document}/deleteByQuery.yaml +2 -2
  22. package/lib/api/openapi/{document → components/document}/exists.yaml +1 -1
  23. package/lib/api/openapi/{document → components/document}/get.yaml +1 -1
  24. package/lib/api/openapi/{document → components/document}/index.d.ts +2 -0
  25. package/lib/api/openapi/{document → components/document}/index.js +7 -2
  26. package/lib/api/openapi/{document → components/document}/replace.yaml +2 -2
  27. package/lib/api/openapi/{document → components/document}/scroll.yaml +1 -1
  28. package/lib/api/openapi/{document → components/document}/update.yaml +2 -2
  29. package/lib/api/openapi/components/document/validate.yaml +42 -0
  30. package/lib/api/openapi/components/index.d.ts +2 -0
  31. package/lib/api/openapi/components/index.js +18 -0
  32. package/lib/api/openapi/{payloads.yaml → components/payloads.yaml} +0 -0
  33. package/lib/api/openapi/index.d.ts +1 -2
  34. package/lib/api/openapi/index.js +1 -5
  35. package/lib/api/openapi/openApiGenerator.d.ts +7 -0
  36. package/lib/api/openapi/openApiGenerator.js +133 -0
  37. package/lib/api/request/kuzzleRequest.js +8 -6
  38. package/lib/cluster/node.js +9 -9
  39. package/lib/cluster/publisher.js +1 -1
  40. package/lib/cluster/state.js +20 -4
  41. package/lib/cluster/subscriber.js +1 -1
  42. package/lib/cluster/workers/IDCardRenewer.js +2 -2
  43. package/lib/config/default.config.js +1 -0
  44. package/lib/config/index.js +6 -6
  45. package/lib/core/auth/passportResponse.js +6 -6
  46. package/lib/core/auth/passportWrapper.js +5 -5
  47. package/lib/core/backend/backend.d.ts +11 -3
  48. package/lib/core/backend/backend.js +22 -17
  49. package/lib/core/backend/backendConfig.d.ts +5 -1
  50. package/lib/core/backend/backendConfig.js +25 -2
  51. package/lib/core/backend/backendController.js +21 -5
  52. package/lib/core/backend/backendErrors.d.ts +58 -0
  53. package/lib/core/backend/backendErrors.js +121 -0
  54. package/lib/core/backend/backendHook.js +21 -5
  55. package/lib/core/backend/backendImport.js +21 -5
  56. package/lib/core/backend/backendOpenApi.d.ts +9 -0
  57. package/lib/core/backend/backendOpenApi.js +69 -0
  58. package/lib/core/backend/backendPipe.js +21 -5
  59. package/lib/core/backend/backendPlugin.js +22 -3
  60. package/lib/core/backend/backendVault.js +21 -2
  61. package/lib/core/backend/index.d.ts +2 -0
  62. package/lib/core/backend/index.js +2 -0
  63. package/lib/core/network/accessLogger.js +6 -6
  64. package/lib/core/network/clientConnection.js +1 -1
  65. package/lib/core/network/entryPoint.js +5 -5
  66. package/lib/core/network/httpRouter/index.js +5 -5
  67. package/lib/core/network/httpRouter/routeHandler.js +3 -3
  68. package/lib/core/network/httpRouter/routePart.js +5 -5
  69. package/lib/core/network/protocolManifest.js +1 -1
  70. package/lib/core/network/protocols/httpMessage.js +2 -2
  71. package/lib/core/network/protocols/httpwsProtocol.js +228 -50
  72. package/lib/core/network/protocols/mqttProtocol.js +3 -3
  73. package/lib/core/network/protocols/protocol.js +3 -3
  74. package/lib/core/network/router.js +7 -6
  75. package/lib/core/plugin/plugin.js +38 -64
  76. package/lib/core/plugin/pluginContext.js +22 -3
  77. package/lib/core/plugin/pluginManifest.js +3 -3
  78. package/lib/core/plugin/pluginRepository.js +5 -5
  79. package/lib/core/plugin/pluginsManager.js +29 -28
  80. package/lib/core/realtime/channel.js +20 -4
  81. package/lib/core/realtime/hotelClerk.js +24 -5
  82. package/lib/core/realtime/notification/server.js +1 -1
  83. package/lib/core/realtime/notification/user.js +1 -1
  84. package/lib/core/realtime/notifier.js +5 -5
  85. package/lib/core/security/index.js +1 -1
  86. package/lib/core/security/profileRepository.d.ts +176 -0
  87. package/lib/core/security/profileRepository.js +445 -443
  88. package/lib/core/security/roleRepository.js +16 -16
  89. package/lib/core/security/securityLoader.js +2 -2
  90. package/lib/core/security/tokenRepository.js +11 -11
  91. package/lib/core/security/userRepository.js +8 -8
  92. package/lib/core/shared/abstractManifest.js +4 -4
  93. package/lib/core/shared/repository.js +5 -5
  94. package/lib/core/shared/sdk/embeddedSdk.js +21 -2
  95. package/lib/core/shared/sdk/funnelProtocol.js +1 -1
  96. package/lib/core/shared/sdk/impersonatedSdk.js +1 -1
  97. package/lib/core/shared/store.js +30 -23
  98. package/lib/core/statistics/statistics.js +17 -17
  99. package/lib/core/storage/clientAdapter.js +45 -10
  100. package/lib/core/storage/indexCache.js +20 -4
  101. package/lib/core/validation/baseType.js +5 -5
  102. package/lib/core/validation/types/anything.js +1 -1
  103. package/lib/core/validation/types/boolean.js +2 -2
  104. package/lib/core/validation/types/date.js +9 -9
  105. package/lib/core/validation/types/email.js +5 -5
  106. package/lib/core/validation/types/enum.js +6 -6
  107. package/lib/core/validation/types/geoPoint.js +2 -2
  108. package/lib/core/validation/types/geoShape.js +28 -25
  109. package/lib/core/validation/types/integer.js +4 -4
  110. package/lib/core/validation/types/ipAddress.js +7 -6
  111. package/lib/core/validation/types/numeric.js +4 -4
  112. package/lib/core/validation/types/object.js +5 -5
  113. package/lib/core/validation/types/string.js +5 -5
  114. package/lib/core/validation/types/url.js +7 -6
  115. package/lib/core/validation/validation.js +95 -84
  116. package/lib/kerror/codes/1-services.json +12 -0
  117. package/lib/kerror/codes/2-api.json +12 -0
  118. package/lib/kerror/codes/3-network.json +12 -0
  119. package/lib/kerror/codes/4-plugin.json +6 -0
  120. package/lib/kerror/codes/index.js +11 -11
  121. package/lib/kerror/errors/multipleErrorsError.d.ts +1 -1
  122. package/lib/kerror/errors/multipleErrorsError.js +3 -3
  123. package/lib/kerror/index.d.ts +82 -0
  124. package/lib/kerror/index.js +176 -143
  125. package/lib/kuzzle/dumpGenerator.js +3 -3
  126. package/lib/kuzzle/event/kuzzleEventEmitter.js +4 -4
  127. package/lib/kuzzle/event/pipeRunner.js +1 -1
  128. package/lib/kuzzle/event/waterfall.js +6 -6
  129. package/lib/kuzzle/kuzzle.js +59 -9
  130. package/lib/kuzzle/log.js +3 -3
  131. package/lib/kuzzle/vault.js +3 -3
  132. package/lib/model/security/profile.d.ts +54 -0
  133. package/lib/model/security/profile.js +192 -232
  134. package/lib/model/security/rights.js +1 -1
  135. package/lib/model/security/role.d.ts +40 -0
  136. package/lib/model/security/role.js +174 -190
  137. package/lib/model/security/user.d.ts +29 -0
  138. package/lib/model/security/user.js +103 -52
  139. package/lib/model/storage/apiKey.js +2 -2
  140. package/lib/model/storage/baseModel.js +3 -3
  141. package/lib/service/cache/redis.js +7 -7
  142. package/lib/service/storage/elasticsearch.js +152 -90
  143. package/lib/service/storage/esWrapper.js +2 -3
  144. package/lib/types/ControllerDefinition.d.ts +3 -3
  145. package/lib/types/ControllerRights.d.ts +22 -0
  146. package/lib/types/ControllerRights.js +23 -0
  147. package/lib/types/HttpStream.d.ts +32 -0
  148. package/lib/types/HttpStream.js +70 -0
  149. package/lib/types/OpenApiDefinition.d.ts +43 -0
  150. package/lib/types/{config/StorageService/StorageServiceElasticsearchConfiguration.js → OpenApiDefinition.js} +1 -1
  151. package/lib/types/Plugin.js +20 -4
  152. package/lib/types/Policy.d.ts +25 -0
  153. package/lib/types/{InternalLogger.js → Policy.js} +2 -2
  154. package/lib/types/PolicyRestrictions.d.ts +21 -0
  155. package/lib/types/PolicyRestrictions.js +23 -0
  156. package/lib/types/Target.d.ts +15 -0
  157. package/lib/types/Target.js +23 -0
  158. package/lib/types/config/KuzzleConfiguration.d.ts +4 -0
  159. package/lib/types/config/ServicesConfiguration.d.ts +2 -2
  160. package/lib/types/config/{StorageService/StorageServiceElasticsearchConfiguration.d.ts → storageEngine/StorageEngineElasticsearchConfiguration.d.ts} +10 -3
  161. package/lib/types/config/storageEngine/StorageEngineElasticsearchConfiguration.js +3 -0
  162. package/lib/types/errors/ErrorDefinition.d.ts +27 -0
  163. package/lib/types/errors/ErrorDefinition.js +3 -0
  164. package/lib/types/errors/ErrorDomains.d.ts +17 -0
  165. package/lib/types/errors/ErrorDomains.js +3 -0
  166. package/lib/types/index.d.ts +9 -1
  167. package/lib/types/index.js +9 -1
  168. package/lib/util/array.d.ts +11 -0
  169. package/lib/util/array.js +57 -0
  170. package/lib/util/assertType.js +6 -6
  171. package/lib/util/bufferedPassThrough.d.ts +76 -0
  172. package/lib/util/bufferedPassThrough.js +161 -0
  173. package/lib/util/deprecate.js +7 -5
  174. package/lib/util/didYouMean.js +1 -1
  175. package/lib/util/dump-collection.d.ts +3 -0
  176. package/lib/util/dump-collection.js +284 -0
  177. package/lib/util/extractFields.js +2 -2
  178. package/lib/util/inflector.d.ts +8 -0
  179. package/lib/util/inflector.js +16 -0
  180. package/lib/util/mutex.js +21 -2
  181. package/lib/util/requestAssertions.js +7 -7
  182. package/lib/util/wildcard.js +55 -0
  183. package/package-lock.json +535 -75
  184. package/package.json +5 -3
  185. package/lib/api/openApiGenerator.d.ts +0 -7
  186. package/lib/api/openApiGenerator.js +0 -197
  187. package/lib/types/InternalLogger.d.ts +0 -25
@@ -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.
@@ -0,0 +1,9 @@
1
+ import { ApplicationManager, Backend } from './index';
2
+ import { OpenApiDefinition } from '../../types';
3
+ export declare class BackendOpenApi extends ApplicationManager {
4
+ /**
5
+ * Application Open API definition
6
+ */
7
+ definition: Partial<OpenApiDefinition>;
8
+ constructor(application: Backend);
9
+ }
@@ -0,0 +1,69 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.BackendOpenApi = void 0;
24
+ const index_1 = require("./index");
25
+ class BackendOpenApi extends index_1.ApplicationManager {
26
+ constructor(application) {
27
+ super(application);
28
+ /* eslint-disable sort-keys */
29
+ this.definition = {
30
+ openapi: '3.0.0',
31
+ info: {
32
+ title: `${application.name} API`,
33
+ description: `${application.name} HTTP API definition`,
34
+ contact: {
35
+ name: 'Kuzzle team',
36
+ url: 'https://kuzzle.io',
37
+ email: 'support@kuzzle.io',
38
+ discord: 'http://join.discord.kuzzle.io'
39
+ },
40
+ license: {
41
+ name: 'Apache 2',
42
+ url: 'http://opensource.org/licenses/apache2.0'
43
+ },
44
+ version: application.version
45
+ },
46
+ externalDocs: {
47
+ description: 'Kuzzle API Documentation',
48
+ url: 'https://docs.kuzzle.io/core/2/api/'
49
+ },
50
+ servers: [
51
+ {
52
+ url: 'https://{baseUrl}:{port}',
53
+ description: `${application.name} Base Url`,
54
+ variables: {
55
+ baseUrl: { default: 'localhost' },
56
+ port: { default: 7512 },
57
+ }
58
+ }
59
+ ],
60
+ tags: [],
61
+ schemes: ['https', 'http'],
62
+ paths: {},
63
+ components: {}
64
+ };
65
+ /* eslint-enable sort-keys */
66
+ }
67
+ }
68
+ exports.BackendOpenApi = BackendOpenApi;
69
+ //# sourceMappingURL=backendOpenApi.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.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.
@@ -19,15 +19,34 @@
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.BackendVault = void 0;
27
46
  const vault_1 = __importDefault(require("../../kuzzle/vault"));
28
- const kerror_1 = __importDefault(require("../../kerror"));
47
+ const kerror = __importStar(require("../../kerror"));
29
48
  const index_1 = require("./index");
30
- const runtimeError = kerror_1.default.wrap('plugin', 'runtime');
49
+ const runtimeError = kerror.wrap('plugin', 'runtime');
31
50
  class BackendVault extends index_1.ApplicationManager {
32
51
  constructor() {
33
52
  super(...arguments);
@@ -9,4 +9,6 @@ export * from './backendPipe';
9
9
  export * from './backendPlugin';
10
10
  export * from './backendStorage';
11
11
  export * from './backendVault';
12
+ export * from './backendOpenApi';
12
13
  export * from './internalLogger';
14
+ export * from './backendErrors';
@@ -21,5 +21,7 @@ __exportStar(require("./backendPipe"), exports);
21
21
  __exportStar(require("./backendPlugin"), exports);
22
22
  __exportStar(require("./backendStorage"), exports);
23
23
  __exportStar(require("./backendVault"), exports);
24
+ __exportStar(require("./backendOpenApi"), exports);
24
25
  __exportStar(require("./internalLogger"), exports);
26
+ __exportStar(require("./backendErrors"), exports);
25
27
  //# sourceMappingURL=index.js.map
@@ -54,15 +54,15 @@ class AccessLogger {
54
54
  const config = global.kuzzle.config.server;
55
55
 
56
56
  for (const out of config.logs.transports) {
57
- if (out.transport && !ALLOWED_TRANSPORTS.includes(out.transport)) {
57
+ if (out.transport && ! ALLOWED_TRANSPORTS.includes(out.transport)) {
58
58
  global.kuzzle.log.error(`Failed to initialize logger transport "${out.transport}": unsupported transport. Skipped.`);
59
59
  }
60
60
  else {
61
- this.isActive = this.isActive || !out.silent;
61
+ this.isActive = this.isActive || ! out.silent;
62
62
  }
63
63
  }
64
64
 
65
- if (!this.isActive) {
65
+ if (! this.isActive) {
66
66
  return;
67
67
  }
68
68
 
@@ -78,7 +78,7 @@ class AccessLogger {
78
78
  }
79
79
 
80
80
  log (connection, request, extra) {
81
- if (!this.isActive) {
81
+ if (! this.isActive) {
82
82
  return;
83
83
  }
84
84
 
@@ -212,7 +212,7 @@ class AccessLoggerWorker {
212
212
  }
213
213
  }
214
214
 
215
- this.logger = winston.createLogger({transports});
215
+ this.logger = winston.createLogger({ transports });
216
216
  }
217
217
 
218
218
  /**
@@ -325,7 +325,7 @@ class AccessLoggerWorker {
325
325
  }
326
326
  }
327
327
 
328
- if (!isMainThread) {
328
+ if (! isMainThread) {
329
329
  // Needed for instantiating a serialized KuzzleRequest object
330
330
  global.kuzzle = { id: workerData.kuzzleId };
331
331
 
@@ -36,7 +36,7 @@ class ClientConnection {
36
36
  this.protocol = protocol;
37
37
  this.headers = {};
38
38
 
39
- if (!Array.isArray(ips)) {
39
+ if (! Array.isArray(ips)) {
40
40
  throw new TypeError(`Expected ips to be an Array, got ${typeof ips}`);
41
41
  }
42
42
  this.ips = ips;
@@ -99,7 +99,7 @@ class EntryPoint {
99
99
  async startListening () {
100
100
  // We need to verify the port ourselves, to make sure Node.js won't open
101
101
  // a named pipe if the provided port number is a string
102
- if (!Number.isInteger(this.config.port)) {
102
+ if (! Number.isInteger(this.config.port)) {
103
103
  throw networkError.get('invalid_port', this.config.port);
104
104
  }
105
105
 
@@ -140,7 +140,7 @@ class EntryPoint {
140
140
 
141
141
  const client = this._clients.get(connectionId);
142
142
 
143
- if (!client || !client.protocol) {
143
+ if (! client || ! client.protocol) {
144
144
  return;
145
145
  }
146
146
 
@@ -160,7 +160,7 @@ class EntryPoint {
160
160
 
161
161
  const client = this._clients.get(connectionId);
162
162
 
163
- if (!client || !client.protocol) {
163
+ if (! client || ! client.protocol) {
164
164
  return;
165
165
  }
166
166
 
@@ -248,7 +248,7 @@ class EntryPoint {
248
248
  global.kuzzle.funnel.execute(request, (error, result) => {
249
249
  const _res = result || request;
250
250
 
251
- if (error && !_res.error) {
251
+ if (error && ! _res.error) {
252
252
  _res.setError(error);
253
253
  }
254
254
 
@@ -327,7 +327,7 @@ class EntryPoint {
327
327
 
328
328
  const client = this._clients.get(data.connectionId);
329
329
 
330
- if (!client || !client.protocol) {
330
+ if (! client || ! client.protocol) {
331
331
  return;
332
332
  }
333
333
 
@@ -142,7 +142,7 @@ class Router {
142
142
  route (message, cb) {
143
143
  debug('Routing HTTP message: %a', message);
144
144
 
145
- if (!has(this.routes, message.method)) {
145
+ if (! has(this.routes, message.method)) {
146
146
  this.routeUnhandledHttpMethod(message, cb);
147
147
  return;
148
148
  }
@@ -165,8 +165,8 @@ class Router {
165
165
  }
166
166
  catch (err) {
167
167
  let request;
168
- if (!routeHandler || !routeHandler._request) {
169
- request = new Request({requestId: message.requestId}, {});
168
+ if (! routeHandler || ! routeHandler._request) {
169
+ request = new Request({ requestId: message.requestId }, {});
170
170
  // Set Headers if not present
171
171
  request.response.setHeaders(this.defaultHeaders, true);
172
172
 
@@ -190,7 +190,7 @@ class Router {
190
190
  * @param {HttpMessage} message
191
191
  * @param {function} cb
192
192
  */
193
- routeUnhandledHttpMethod(message, cb) {
193
+ routeUnhandledHttpMethod (message, cb) {
194
194
  const
195
195
  requestContext = global.kuzzle.router.connections.get(message.connection.id),
196
196
  request = new Request(
@@ -253,7 +253,7 @@ function applyACAOHeader (message, request) {
253
253
  function attach (path, handler, target) {
254
254
  const sanitized = path[path.length - 1] === '/' ? path.slice(0, -1) : path;
255
255
 
256
- if (!attachParts(sanitized.split('/'), handler, target)) {
256
+ if (! attachParts(sanitized.split('/'), handler, target)) {
257
257
  throw kerror.get('duplicate_url', sanitized);
258
258
  }
259
259
  }