kuzzle 2.16.8 → 2.17.0

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 (167) hide show
  1. package/README.md +11 -0
  2. package/lib/api/controllers/adminController.js +7 -6
  3. package/lib/api/controllers/authController.js +11 -11
  4. package/lib/api/controllers/baseController.js +60 -3
  5. package/lib/api/controllers/clusterController.js +1 -1
  6. package/lib/api/controllers/collectionController.js +7 -5
  7. package/lib/api/controllers/documentController.js +130 -17
  8. package/lib/api/controllers/indexController.js +1 -1
  9. package/lib/api/controllers/memoryStorageController.js +39 -38
  10. package/lib/api/controllers/realtimeController.js +1 -1
  11. package/lib/api/controllers/securityController.js +49 -49
  12. package/lib/api/controllers/serverController.js +73 -27
  13. package/lib/api/documentExtractor.js +3 -3
  14. package/lib/api/funnel.js +40 -21
  15. package/lib/api/httpRoutes.js +9 -4
  16. package/lib/api/openapi/OpenApiManager.d.ts +11 -0
  17. package/lib/api/openapi/OpenApiManager.js +96 -0
  18. package/lib/api/openapi/{document → components/document}/count.yaml +2 -2
  19. package/lib/api/openapi/{document → components/document}/create.yaml +2 -2
  20. package/lib/api/openapi/{document → components/document}/createOrReplace.yaml +2 -2
  21. package/lib/api/openapi/{document → components/document}/delete.yaml +1 -1
  22. package/lib/api/openapi/{document → components/document}/deleteByQuery.yaml +2 -2
  23. package/lib/api/openapi/{document → components/document}/exists.yaml +1 -1
  24. package/lib/api/openapi/{document → components/document}/get.yaml +1 -1
  25. package/lib/api/openapi/{document → components/document}/index.d.ts +2 -0
  26. package/lib/api/openapi/{document → components/document}/index.js +7 -2
  27. package/lib/api/openapi/{document → components/document}/replace.yaml +2 -2
  28. package/lib/api/openapi/{document → components/document}/scroll.yaml +1 -1
  29. package/lib/api/openapi/{document → components/document}/update.yaml +2 -2
  30. package/lib/api/openapi/components/document/validate.yaml +42 -0
  31. package/lib/api/openapi/components/index.d.ts +2 -0
  32. package/lib/api/openapi/components/index.js +18 -0
  33. package/lib/api/openapi/{payloads.yaml → components/payloads.yaml} +0 -0
  34. package/lib/api/openapi/index.d.ts +1 -2
  35. package/lib/api/openapi/index.js +1 -5
  36. package/lib/api/openapi/openApiGenerator.d.ts +7 -0
  37. package/lib/api/openapi/openApiGenerator.js +133 -0
  38. package/lib/api/request/kuzzleRequest.d.ts +11 -11
  39. package/lib/api/request/kuzzleRequest.js +38 -48
  40. package/lib/cluster/node.js +9 -9
  41. package/lib/cluster/publisher.js +1 -1
  42. package/lib/cluster/subscriber.js +1 -1
  43. package/lib/cluster/workers/IDCardRenewer.js +13 -4
  44. package/lib/config/default.config.js +1 -0
  45. package/lib/config/index.js +6 -6
  46. package/lib/core/auth/passportResponse.js +6 -6
  47. package/lib/core/auth/passportWrapper.js +5 -5
  48. package/lib/core/backend/backend.d.ts +5 -1
  49. package/lib/core/backend/backend.js +12 -8
  50. package/lib/core/backend/backendConfig.d.ts +5 -1
  51. package/lib/core/backend/backendConfig.js +4 -0
  52. package/lib/core/backend/backendOpenApi.d.ts +9 -0
  53. package/lib/core/backend/backendOpenApi.js +69 -0
  54. package/lib/core/backend/index.d.ts +1 -0
  55. package/lib/core/backend/index.js +1 -0
  56. package/lib/core/network/accessLogger.js +6 -6
  57. package/lib/core/network/clientConnection.js +1 -1
  58. package/lib/core/network/entryPoint.js +5 -5
  59. package/lib/core/network/httpRouter/index.js +5 -5
  60. package/lib/core/network/httpRouter/routeHandler.js +3 -3
  61. package/lib/core/network/httpRouter/routePart.js +5 -5
  62. package/lib/core/network/protocolManifest.js +1 -1
  63. package/lib/core/network/protocols/httpMessage.js +2 -2
  64. package/lib/core/network/protocols/httpwsProtocol.js +207 -46
  65. package/lib/core/network/protocols/mqttProtocol.js +3 -3
  66. package/lib/core/network/protocols/protocol.js +3 -3
  67. package/lib/core/network/router.js +7 -6
  68. package/lib/core/plugin/plugin.js +38 -64
  69. package/lib/core/plugin/pluginContext.d.ts +10 -1
  70. package/lib/core/plugin/pluginContext.js +2 -0
  71. package/lib/core/plugin/pluginManifest.js +3 -3
  72. package/lib/core/plugin/pluginRepository.js +5 -5
  73. package/lib/core/plugin/pluginsManager.js +29 -28
  74. package/lib/core/realtime/notification/server.js +1 -1
  75. package/lib/core/realtime/notification/user.js +1 -1
  76. package/lib/core/realtime/notifier.js +5 -5
  77. package/lib/core/security/index.js +1 -1
  78. package/lib/core/security/profileRepository.d.ts +176 -0
  79. package/lib/core/security/profileRepository.js +426 -443
  80. package/lib/core/security/roleRepository.js +16 -16
  81. package/lib/core/security/securityLoader.js +3 -3
  82. package/lib/core/security/tokenRepository.js +18 -21
  83. package/lib/core/security/userRepository.js +8 -8
  84. package/lib/core/shared/abstractManifest.js +4 -4
  85. package/lib/core/shared/repository.js +6 -6
  86. package/lib/core/shared/sdk/funnelProtocol.js +1 -1
  87. package/lib/core/shared/sdk/impersonatedSdk.js +1 -1
  88. package/lib/core/shared/store.js +30 -23
  89. package/lib/core/statistics/statistics.js +17 -17
  90. package/lib/core/storage/clientAdapter.js +45 -10
  91. package/lib/core/validation/baseType.js +5 -5
  92. package/lib/core/validation/types/anything.js +1 -1
  93. package/lib/core/validation/types/boolean.js +2 -2
  94. package/lib/core/validation/types/date.js +9 -9
  95. package/lib/core/validation/types/email.js +5 -5
  96. package/lib/core/validation/types/enum.js +6 -6
  97. package/lib/core/validation/types/geoPoint.js +2 -2
  98. package/lib/core/validation/types/geoShape.js +28 -25
  99. package/lib/core/validation/types/integer.js +4 -4
  100. package/lib/core/validation/types/ipAddress.js +7 -6
  101. package/lib/core/validation/types/numeric.js +4 -4
  102. package/lib/core/validation/types/object.js +5 -5
  103. package/lib/core/validation/types/string.js +5 -5
  104. package/lib/core/validation/types/url.js +7 -6
  105. package/lib/core/validation/validation.js +95 -84
  106. package/lib/kerror/codes/1-services.json +12 -0
  107. package/lib/kerror/codes/2-api.json +12 -0
  108. package/lib/kerror/codes/3-network.json +12 -0
  109. package/lib/kerror/codes/4-plugin.json +6 -0
  110. package/lib/kerror/codes/index.js +11 -11
  111. package/lib/kerror/index.js +1 -1
  112. package/lib/kuzzle/dumpGenerator.js +3 -3
  113. package/lib/kuzzle/event/kuzzleEventEmitter.js +4 -4
  114. package/lib/kuzzle/event/pipeRunner.js +1 -1
  115. package/lib/kuzzle/event/waterfall.js +6 -6
  116. package/lib/kuzzle/kuzzle.js +36 -5
  117. package/lib/kuzzle/log.js +3 -3
  118. package/lib/kuzzle/vault.js +3 -3
  119. package/lib/model/security/profile.d.ts +54 -0
  120. package/lib/model/security/profile.js +174 -233
  121. package/lib/model/security/rights.js +1 -1
  122. package/lib/model/security/role.d.ts +40 -0
  123. package/lib/model/security/role.js +159 -191
  124. package/lib/model/security/user.d.ts +29 -0
  125. package/lib/model/security/user.js +84 -52
  126. package/lib/model/storage/apiKey.js +2 -2
  127. package/lib/model/storage/baseModel.js +3 -3
  128. package/lib/service/cache/redis.js +7 -7
  129. package/lib/service/storage/elasticsearch.js +152 -90
  130. package/lib/service/storage/esWrapper.js +2 -3
  131. package/lib/types/ControllerDefinition.d.ts +3 -3
  132. package/lib/types/ControllerRights.d.ts +22 -0
  133. package/lib/types/ControllerRights.js +23 -0
  134. package/lib/types/HttpStream.d.ts +32 -0
  135. package/lib/types/HttpStream.js +70 -0
  136. package/lib/types/OpenApiDefinition.d.ts +43 -0
  137. package/lib/types/{config/StorageService/StorageServiceElasticsearchConfiguration.js → OpenApiDefinition.js} +1 -1
  138. package/lib/types/Policy.d.ts +25 -0
  139. package/lib/types/Policy.js +23 -0
  140. package/lib/types/PolicyRestrictions.d.ts +21 -0
  141. package/lib/types/PolicyRestrictions.js +23 -0
  142. package/lib/types/Target.d.ts +15 -0
  143. package/lib/types/Target.js +23 -0
  144. package/lib/types/config/KuzzleConfiguration.d.ts +4 -0
  145. package/lib/types/config/ServicesConfiguration.d.ts +2 -2
  146. package/lib/types/config/{StorageService/StorageServiceElasticsearchConfiguration.d.ts → storageEngine/StorageEngineElasticsearchConfiguration.d.ts} +10 -3
  147. package/lib/types/config/storageEngine/StorageEngineElasticsearchConfiguration.js +3 -0
  148. package/lib/types/index.d.ts +7 -1
  149. package/lib/types/index.js +7 -1
  150. package/lib/util/array.d.ts +11 -0
  151. package/lib/util/array.js +57 -0
  152. package/lib/util/assertType.js +6 -6
  153. package/lib/util/bufferedPassThrough.d.ts +76 -0
  154. package/lib/util/bufferedPassThrough.js +161 -0
  155. package/lib/util/deprecate.js +7 -5
  156. package/lib/util/didYouMean.js +1 -1
  157. package/lib/util/dump-collection.d.ts +3 -0
  158. package/lib/util/dump-collection.js +265 -0
  159. package/lib/util/extractFields.js +2 -2
  160. package/lib/util/inflector.d.ts +8 -0
  161. package/lib/util/inflector.js +16 -0
  162. package/lib/util/requestAssertions.js +7 -7
  163. package/lib/util/wildcard.js +55 -0
  164. package/package-lock.json +881 -431
  165. package/package.json +23 -20
  166. package/lib/api/openApiGenerator.d.ts +0 -7
  167. package/lib/api/openApiGenerator.js +0 -197
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.8",
4
+ "version": "2.17.0",
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"
@@ -33,7 +33,9 @@
33
33
  "test:lint:ts:fix": "eslint --max-warnings=0 --fix ./lib --ext .ts --config .eslintc-ts.json",
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
- "doc-error-codes": "node -r ts-node/register doc/build-error-codes"
36
+ "doc-error-codes": "node -r ts-node/register doc/build-error-codes",
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"
37
39
  },
38
40
  "directories": {
39
41
  "lib": "lib"
@@ -50,26 +52,27 @@
50
52
  "didyoumean": "^1.2.2",
51
53
  "dumpme": "^1.0.3",
52
54
  "eventemitter3": "^4.0.7",
55
+ "express": "^4.17.2",
53
56
  "inquirer": "^8.2.0",
54
- "ioredis": "^4.28.2",
57
+ "ioredis": "^4.28.3",
55
58
  "js-yaml": "^4.1.0",
56
59
  "json-stable-stringify": "^1.0.1",
57
60
  "json2yaml": "^1.1.0",
58
61
  "jsonwebtoken": "^8.5.1",
59
62
  "koncorde": "^4.0.2",
60
- "kuzzle-plugin-auth-passport-local": "^6.3.4",
63
+ "kuzzle-plugin-auth-passport-local": "^6.3.6",
61
64
  "kuzzle-plugin-logger": "^3.0.3",
62
- "kuzzle-sdk": "7.7.6",
65
+ "kuzzle-sdk": "7.8.2",
63
66
  "kuzzle-vault": "^2.0.4",
64
67
  "lodash": "4.17.21",
65
68
  "long": "^5.2.0",
66
69
  "moment": "^2.29.1",
67
70
  "ms": "^2.1.3",
68
71
  "murmurhash-native": "^3.5.0",
69
- "nanoid": "^3.1.30",
72
+ "nanoid": "^3.2.0",
73
+ "ndjson": "^2.0.0",
70
74
  "node-segfault-handler": "^1.0.4",
71
- "openapi-enforcer": "^1.16.1",
72
- "passport": "^0.5.0",
75
+ "passport": "^0.5.2",
73
76
  "protobufjs": "~6.11.2",
74
77
  "rc": "1.2.8",
75
78
  "semver": "^7.3.5",
@@ -77,11 +80,11 @@
77
80
  "uWebSockets.js": "https://github.com/uNetworking/uWebSockets.js/archive/refs/tags/v20.0.0.tar.gz",
78
81
  "uuid": "^8.3.2",
79
82
  "validator": "^13.7.0",
80
- "winston": "^3.3.3",
81
- "winston-elasticsearch": "0.16.0",
83
+ "winston": "^3.4.0",
84
+ "winston-elasticsearch": "0.16.1",
82
85
  "winston-syslog": "^2.4.4",
83
- "winston-transport": "^4.4.0",
84
- "yargs": "^17.3.0",
86
+ "winston-transport": "^4.4.2",
87
+ "yargs": "^17.3.1",
85
88
  "zeromq": "^6.0.0-beta.6"
86
89
  },
87
90
  "repository": {
@@ -90,17 +93,17 @@
90
93
  },
91
94
  "devDependencies": {
92
95
  "@types/lodash": "^4.14.178",
93
- "@typescript-eslint/eslint-plugin": "^5.6.0",
94
- "@typescript-eslint/parser": "^5.6.0",
95
- "async": "^3.2.2",
96
- "chokidar": "^3.5.2",
96
+ "@typescript-eslint/eslint-plugin": "^5.10.0",
97
+ "@typescript-eslint/parser": "^5.10.0",
98
+ "async": "^3.2.3",
99
+ "chokidar": "^3.5.3",
97
100
  "codecov": "^3.8.3",
98
101
  "cucumber": "^6.0.5",
99
102
  "ergol": "^1.0.1",
100
- "eslint": "^8.4.1",
101
- "mocha": "^9.1.3",
103
+ "eslint": "^8.7.0",
104
+ "mocha": "^9.2.0",
102
105
  "mock-require": "^3.0.3",
103
- "mqtt": "^4.2.8",
106
+ "mqtt": "^4.3.4",
104
107
  "nyc": "^15.1.0",
105
108
  "request": "^2.88.2",
106
109
  "request-promise": "^4.2.6",
@@ -110,7 +113,7 @@
110
113
  "sinon": "^12.0.1",
111
114
  "strip-json-comments": "https://github.com/sindresorhus/strip-json-comments/archive/refs/tags/v3.1.1.tar.gz",
112
115
  "ts-node": "^10.4.0",
113
- "typescript": "^4.5.3",
116
+ "typescript": "^4.5.5",
114
117
  "yaml": "^1.10.2"
115
118
  },
116
119
  "engines": {
@@ -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