kuzzle 2.16.11 → 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.
- package/lib/api/controllers/adminController.js +3 -3
- package/lib/api/controllers/authController.js +11 -11
- package/lib/api/controllers/baseController.js +60 -3
- package/lib/api/controllers/clusterController.js +1 -1
- package/lib/api/controllers/collectionController.js +7 -5
- package/lib/api/controllers/documentController.js +130 -17
- package/lib/api/controllers/indexController.js +1 -1
- package/lib/api/controllers/memoryStorageController.js +39 -38
- package/lib/api/controllers/realtimeController.js +1 -1
- package/lib/api/controllers/securityController.js +49 -49
- package/lib/api/controllers/serverController.js +73 -27
- package/lib/api/documentExtractor.js +3 -3
- package/lib/api/funnel.js +40 -21
- package/lib/api/httpRoutes.js +9 -4
- package/lib/api/openapi/OpenApiManager.d.ts +11 -0
- package/lib/api/openapi/OpenApiManager.js +96 -0
- package/lib/api/openapi/{document → components/document}/count.yaml +2 -2
- package/lib/api/openapi/{document → components/document}/create.yaml +2 -2
- package/lib/api/openapi/{document → components/document}/createOrReplace.yaml +2 -2
- package/lib/api/openapi/{document → components/document}/delete.yaml +1 -1
- package/lib/api/openapi/{document → components/document}/deleteByQuery.yaml +2 -2
- package/lib/api/openapi/{document → components/document}/exists.yaml +1 -1
- package/lib/api/openapi/{document → components/document}/get.yaml +1 -1
- package/lib/api/openapi/{document → components/document}/index.d.ts +2 -0
- package/lib/api/openapi/{document → components/document}/index.js +7 -2
- package/lib/api/openapi/{document → components/document}/replace.yaml +2 -2
- package/lib/api/openapi/{document → components/document}/scroll.yaml +1 -1
- package/lib/api/openapi/{document → components/document}/update.yaml +2 -2
- package/lib/api/openapi/components/document/validate.yaml +42 -0
- package/lib/api/openapi/components/index.d.ts +2 -0
- package/lib/api/openapi/components/index.js +18 -0
- package/lib/api/openapi/{payloads.yaml → components/payloads.yaml} +0 -0
- package/lib/api/openapi/index.d.ts +1 -2
- package/lib/api/openapi/index.js +1 -5
- package/lib/api/openapi/openApiGenerator.d.ts +7 -0
- package/lib/api/openapi/openApiGenerator.js +133 -0
- package/lib/api/request/kuzzleRequest.js +4 -0
- package/lib/cluster/node.js +9 -9
- package/lib/cluster/publisher.js +1 -1
- package/lib/cluster/subscriber.js +1 -1
- package/lib/cluster/workers/IDCardRenewer.js +2 -2
- package/lib/config/default.config.js +1 -0
- package/lib/config/index.js +6 -6
- package/lib/core/auth/passportResponse.js +6 -6
- package/lib/core/auth/passportWrapper.js +5 -5
- package/lib/core/backend/backend.d.ts +5 -1
- package/lib/core/backend/backend.js +12 -8
- package/lib/core/backend/backendConfig.d.ts +5 -1
- package/lib/core/backend/backendConfig.js +4 -0
- package/lib/core/backend/backendOpenApi.d.ts +9 -0
- package/lib/core/backend/backendOpenApi.js +69 -0
- package/lib/core/backend/index.d.ts +1 -0
- package/lib/core/backend/index.js +1 -0
- package/lib/core/network/accessLogger.js +6 -6
- package/lib/core/network/clientConnection.js +1 -1
- package/lib/core/network/entryPoint.js +5 -5
- package/lib/core/network/httpRouter/index.js +5 -5
- package/lib/core/network/httpRouter/routeHandler.js +3 -3
- package/lib/core/network/httpRouter/routePart.js +5 -5
- package/lib/core/network/protocolManifest.js +1 -1
- package/lib/core/network/protocols/httpMessage.js +2 -2
- package/lib/core/network/protocols/httpwsProtocol.js +205 -48
- package/lib/core/network/protocols/mqttProtocol.js +3 -3
- package/lib/core/network/protocols/protocol.js +3 -3
- package/lib/core/network/router.js +7 -6
- package/lib/core/plugin/plugin.js +38 -64
- package/lib/core/plugin/pluginManifest.js +3 -3
- package/lib/core/plugin/pluginRepository.js +5 -5
- package/lib/core/plugin/pluginsManager.js +29 -28
- package/lib/core/realtime/notification/server.js +1 -1
- package/lib/core/realtime/notification/user.js +1 -1
- package/lib/core/realtime/notifier.js +5 -5
- package/lib/core/security/index.js +1 -1
- package/lib/core/security/profileRepository.d.ts +176 -0
- package/lib/core/security/profileRepository.js +426 -443
- package/lib/core/security/roleRepository.js +16 -16
- package/lib/core/security/securityLoader.js +2 -2
- package/lib/core/security/tokenRepository.js +11 -11
- package/lib/core/security/userRepository.js +8 -8
- package/lib/core/shared/abstractManifest.js +4 -4
- package/lib/core/shared/repository.js +5 -5
- package/lib/core/shared/sdk/funnelProtocol.js +1 -1
- package/lib/core/shared/sdk/impersonatedSdk.js +1 -1
- package/lib/core/shared/store.js +30 -23
- package/lib/core/statistics/statistics.js +17 -17
- package/lib/core/storage/clientAdapter.js +45 -10
- package/lib/core/validation/baseType.js +5 -5
- package/lib/core/validation/types/anything.js +1 -1
- package/lib/core/validation/types/boolean.js +2 -2
- package/lib/core/validation/types/date.js +9 -9
- package/lib/core/validation/types/email.js +5 -5
- package/lib/core/validation/types/enum.js +6 -6
- package/lib/core/validation/types/geoPoint.js +2 -2
- package/lib/core/validation/types/geoShape.js +28 -25
- package/lib/core/validation/types/integer.js +4 -4
- package/lib/core/validation/types/ipAddress.js +7 -6
- package/lib/core/validation/types/numeric.js +4 -4
- package/lib/core/validation/types/object.js +5 -5
- package/lib/core/validation/types/string.js +5 -5
- package/lib/core/validation/types/url.js +7 -6
- package/lib/core/validation/validation.js +95 -84
- package/lib/kerror/codes/1-services.json +12 -0
- package/lib/kerror/codes/2-api.json +12 -0
- package/lib/kerror/codes/3-network.json +12 -0
- package/lib/kerror/codes/4-plugin.json +6 -0
- package/lib/kerror/codes/index.js +11 -11
- package/lib/kerror/index.js +1 -1
- package/lib/kuzzle/dumpGenerator.js +3 -3
- package/lib/kuzzle/event/kuzzleEventEmitter.js +4 -4
- package/lib/kuzzle/event/pipeRunner.js +1 -1
- package/lib/kuzzle/event/waterfall.js +6 -6
- package/lib/kuzzle/kuzzle.js +36 -5
- package/lib/kuzzle/log.js +3 -3
- package/lib/kuzzle/vault.js +3 -3
- package/lib/model/security/profile.d.ts +54 -0
- package/lib/model/security/profile.js +174 -233
- package/lib/model/security/rights.js +1 -1
- package/lib/model/security/role.d.ts +40 -0
- package/lib/model/security/role.js +159 -191
- package/lib/model/security/user.d.ts +29 -0
- package/lib/model/security/user.js +84 -52
- package/lib/model/storage/apiKey.js +2 -2
- package/lib/model/storage/baseModel.js +3 -3
- package/lib/service/cache/redis.js +7 -7
- package/lib/service/storage/elasticsearch.js +152 -90
- package/lib/service/storage/esWrapper.js +2 -3
- package/lib/types/ControllerDefinition.d.ts +3 -3
- package/lib/types/ControllerRights.d.ts +22 -0
- package/lib/types/ControllerRights.js +23 -0
- package/lib/types/HttpStream.d.ts +32 -0
- package/lib/types/HttpStream.js +70 -0
- package/lib/types/OpenApiDefinition.d.ts +43 -0
- package/lib/types/{config/StorageService/StorageServiceElasticsearchConfiguration.js → OpenApiDefinition.js} +1 -1
- package/lib/types/Policy.d.ts +25 -0
- package/lib/types/{InternalLogger.js → Policy.js} +2 -2
- package/lib/types/PolicyRestrictions.d.ts +21 -0
- package/lib/types/PolicyRestrictions.js +23 -0
- package/lib/types/Target.d.ts +15 -0
- package/lib/types/Target.js +23 -0
- package/lib/types/config/KuzzleConfiguration.d.ts +4 -0
- package/lib/types/config/ServicesConfiguration.d.ts +2 -2
- package/lib/types/config/{StorageService/StorageServiceElasticsearchConfiguration.d.ts → storageEngine/StorageEngineElasticsearchConfiguration.d.ts} +10 -3
- package/lib/types/config/storageEngine/StorageEngineElasticsearchConfiguration.js +3 -0
- package/lib/types/index.d.ts +7 -1
- package/lib/types/index.js +7 -1
- package/lib/util/array.d.ts +11 -0
- package/lib/util/array.js +57 -0
- package/lib/util/assertType.js +6 -6
- package/lib/util/bufferedPassThrough.d.ts +76 -0
- package/lib/util/bufferedPassThrough.js +161 -0
- package/lib/util/deprecate.js +7 -5
- package/lib/util/didYouMean.js +1 -1
- package/lib/util/dump-collection.d.ts +3 -0
- package/lib/util/dump-collection.js +265 -0
- package/lib/util/extractFields.js +2 -2
- package/lib/util/inflector.d.ts +8 -0
- package/lib/util/inflector.js +16 -0
- package/lib/util/requestAssertions.js +7 -7
- package/lib/util/wildcard.js +55 -0
- package/package-lock.json +538 -78
- package/package.json +5 -3
- package/lib/api/openApiGenerator.d.ts +0 -7
- package/lib/api/openApiGenerator.js +0 -197
- 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.
|
|
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"
|
|
@@ -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,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
|
-
};
|