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
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.16.11",
4
+ "version": "2.17.2",
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"
@@ -34,7 +34,8 @@
34
34
  "test:lint:js": "eslint --max-warnings=0 ./lib ./test ./features-legacy ./bin ./features ./doc/build-error-codes.js ./plugins/available/functional-test-plugin",
35
35
  "test:lint:js:fix": "eslint --max-warnings=0 --fix ./lib ./test ./features-legacy ./bin ./features ./doc/build-error-codes.js",
36
36
  "doc-error-codes": "node -r ts-node/register doc/build-error-codes",
37
- "docker:install": "docker-compose run kuzzle_node_1 npm install"
37
+ "docker:install": "docker-compose run kuzzle_node_1 npm install",
38
+ "docker:test:unit": "docker-compose run kuzzle_node_1 npm run test:unit"
38
39
  },
39
40
  "directories": {
40
41
  "lib": "lib"
@@ -51,6 +52,7 @@
51
52
  "didyoumean": "^1.2.2",
52
53
  "dumpme": "^1.0.3",
53
54
  "eventemitter3": "^4.0.7",
55
+ "express": "^4.17.2",
54
56
  "inquirer": "^8.2.0",
55
57
  "ioredis": "^4.28.3",
56
58
  "js-yaml": "^4.1.0",
@@ -68,8 +70,8 @@
68
70
  "ms": "^2.1.3",
69
71
  "murmurhash-native": "^3.5.0",
70
72
  "nanoid": "^3.2.0",
73
+ "ndjson": "^2.0.0",
71
74
  "node-segfault-handler": "^1.0.4",
72
- "openapi-enforcer": "^1.16.1",
73
75
  "passport": "^0.5.2",
74
76
  "protobufjs": "~6.11.2",
75
77
  "rc": "1.2.8",
@@ -1,7 +0,0 @@
1
- import { JSONObject } from '../../index';
2
- /**
3
- * Generates JSON OpenApi object
4
- *
5
- * @returns {object} openApi object
6
- */
7
- export declare function generateOpenApi(): JSONObject;
@@ -1,197 +0,0 @@
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 __importDefault = (this && this.__importDefault) || function (mod) {
23
- return (mod && mod.__esModule) ? mod : { "default": mod };
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.generateOpenApi = void 0;
27
- const lodash_1 = __importDefault(require("lodash"));
28
- const package_json_1 = require("../../package.json");
29
- const openapi_1 = require("./openapi");
30
- const inflector_1 = require("../util/inflector");
31
- const routeUrlMatch = /:([^/]*)/g;
32
- /**
33
- * Generate basic openApi Controller
34
- */
35
- function generateController(route, response) {
36
- if (route.controller !== undefined) {
37
- if (!lodash_1.default.some(response.tags, { name: route.controller })) {
38
- const capitalizedController = inflector_1.Inflector.upFirst(route.controller);
39
- response.tags.push({ description: `${capitalizedController} Controller`, name: route.controller });
40
- }
41
- if (route.openapi.tags === undefined) {
42
- route.openapi.tags = [];
43
- }
44
- if (!route.openapi.tags.includes(route.controller)) {
45
- route.openapi.tags.push(route.controller);
46
- }
47
- }
48
- }
49
- /**
50
- * Generate basic openApi Summary
51
- */
52
- function generateSummary(route) {
53
- if (route.openapi.description === undefined) {
54
- route.openapi.description = `Controller: ${route.controller}.`;
55
- }
56
- if (route.openapi.summary === undefined) {
57
- route.openapi.summary = `Action: ${route.action}.`;
58
- }
59
- }
60
- /**
61
- * Generate basic openApi Parameters
62
- */
63
- function generateParameters(route) {
64
- if (route.openapi.parameters === undefined) {
65
- route.openapi.parameters = [];
66
- let m = routeUrlMatch.exec(route.path);
67
- while (m !== null) {
68
- routeUrlMatch.lastIndex++;
69
- route.openapi.parameters.push({
70
- in: 'path',
71
- name: m[1],
72
- required: true,
73
- schema: { type: 'string' }
74
- });
75
- m = routeUrlMatch.exec(route.path);
76
- }
77
- }
78
- if (route.openapi.parameters.length === 0) {
79
- route.openapi.parameters = undefined;
80
- }
81
- }
82
- /**
83
- * Generate basic openApi Response
84
- */
85
- function generateResponse(route) {
86
- if (route.openapi.responses === undefined) {
87
- route.openapi.responses = {
88
- '200': {
89
- description: 'OK'
90
- }
91
- };
92
- }
93
- }
94
- /**
95
- * Generates JSON OpenApi object
96
- *
97
- * @returns {object} openApi object
98
- */
99
- function generateOpenApi() {
100
- const routes = [];
101
- global.kuzzle.config.http.routes.forEach(route => routes.push({ ...route }));
102
- global.kuzzle.pluginsManager.routes.forEach(route => routes.push({ ...route }));
103
- /* eslint-disable sort-keys */
104
- const response = {
105
- swagger: '2.0',
106
- info: {
107
- title: 'Kuzzle API',
108
- description: 'Kuzzle HTTP API definition',
109
- contact: {
110
- name: 'Kuzzle team',
111
- url: 'https://kuzzle.io',
112
- email: 'support@kuzzle.io',
113
- discord: 'http://join.discord.kuzzle.io'
114
- },
115
- license: {
116
- name: 'Apache 2',
117
- url: 'http://opensource.org/licenses/apache2.0'
118
- },
119
- version: package_json_1.version
120
- },
121
- externalDocs: {
122
- description: 'Kuzzle API Documentation',
123
- url: 'https://docs.kuzzle.io/core/2/api/'
124
- },
125
- servers: [
126
- {
127
- url: 'https://{baseUrl}:{port}',
128
- description: 'Kuzzle Base Url',
129
- variables: {
130
- baseUrl: {
131
- default: 'localhost'
132
- },
133
- port: {
134
- default: '7512'
135
- }
136
- }
137
- }
138
- ],
139
- tags: [
140
- {
141
- name: 'document',
142
- description: 'document controller'
143
- }
144
- ],
145
- schemes: [
146
- 'https',
147
- 'http'
148
- ],
149
- paths: {},
150
- components: {
151
- ...openapi_1.OpenApiPayloadsDefinitions,
152
- schemas: {
153
- ...openapi_1.OpenApiDocumentCountComponent,
154
- ...openapi_1.OpenApiDocumentDeleteByQueryComponent,
155
- ...openapi_1.OpenApiDocumentDeleteComponent,
156
- ...openapi_1.OpenApiDocumentScrollComponent,
157
- ...openapi_1.OpenApiDocumentExistsComponent,
158
- ...openapi_1.OpenApiDocumentUpdateComponent,
159
- ...openapi_1.OpenApiDocumentReplaceComponent,
160
- ...openapi_1.OpenApiDocumentGetComponent,
161
- ...openapi_1.OpenApiDocumentCreateOrReplaceComponent,
162
- ...openapi_1.OpenApiDocumentCreateComponent,
163
- }
164
- }
165
- };
166
- /* eslint-enable sort-keys */
167
- for (const route of routes) {
168
- // Make sure route verbs are lowercase
169
- if (route.verb !== undefined) {
170
- route.verb = route.verb.toLowerCase();
171
- }
172
- // Set :param notation to {param}
173
- route.formattedPath = route.path.replace(routeUrlMatch, '{$1}');
174
- if (response.paths[route.formattedPath] === undefined) {
175
- response.paths[route.formattedPath] = {};
176
- }
177
- if (response.paths[route.formattedPath][route.verb] !== undefined) {
178
- continue;
179
- }
180
- // If custom specification, return as it is
181
- if (route.openapi) {
182
- response.paths[route.formattedPath][route.verb] = route.openapi;
183
- continue;
184
- }
185
- if (route.openapi === undefined) {
186
- route.openapi = {};
187
- }
188
- generateController(route, response);
189
- generateSummary(route);
190
- generateParameters(route);
191
- generateResponse(route);
192
- response.paths[route.formattedPath][route.verb] = route.openapi;
193
- }
194
- return response;
195
- }
196
- exports.generateOpenApi = generateOpenApi;
197
- //# sourceMappingURL=openApiGenerator.js.map
@@ -1,25 +0,0 @@
1
- /**
2
- * Internal logger.
3
- */
4
- export declare type InternalLogger = {
5
- /**
6
- * Logs a debug message
7
- */
8
- debug: (message: any) => void;
9
- /**
10
- * Logs an error message
11
- */
12
- error: (message: any) => void;
13
- /**
14
- * Logs an info message
15
- */
16
- info: (message: any) => void;
17
- /**
18
- * Logs a verbose message
19
- */
20
- verbose: (message: any) => void;
21
- /**
22
- * Logs a warn message
23
- */
24
- warn: (message: any) => void;
25
- };