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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OpenApiDocumentDeleteByQueryComponent = exports.OpenApiDocumentDeleteByQuery = exports.OpenApiDocumentDeleteComponent = exports.OpenApiDocumentDelete = exports.OpenApiDocumentScrollComponent = exports.OpenApiDocumentScroll = exports.OpenApiDocumentUpdateComponent = exports.OpenApiDocumentUpdate = exports.OpenApiDocumentExistsComponent = exports.OpenApiDocumentExists = exports.OpenApiDocumentReplaceComponent = exports.OpenApiDocumentReplace = exports.OpenApiDocumentGetComponent = exports.OpenApiDocumentGet = exports.OpenApiDocumentCreateOrReplaceComponent = exports.OpenApiDocumentCreateOrReplace = exports.OpenApiDocumentCreateComponent = exports.OpenApiDocumentCreate = exports.OpenApiDocumentCountComponent = exports.OpenApiDocumentCount = void 0;
|
|
4
|
-
const readYamlFile_1 = require("
|
|
3
|
+
exports.OpenApiDocumentValidateComponent = exports.OpenApiDocumentValidate = exports.OpenApiDocumentDeleteByQueryComponent = exports.OpenApiDocumentDeleteByQuery = exports.OpenApiDocumentDeleteComponent = exports.OpenApiDocumentDelete = exports.OpenApiDocumentScrollComponent = exports.OpenApiDocumentScroll = exports.OpenApiDocumentUpdateComponent = exports.OpenApiDocumentUpdate = exports.OpenApiDocumentExistsComponent = exports.OpenApiDocumentExists = exports.OpenApiDocumentReplaceComponent = exports.OpenApiDocumentReplace = exports.OpenApiDocumentGetComponent = exports.OpenApiDocumentGet = exports.OpenApiDocumentCreateOrReplaceComponent = exports.OpenApiDocumentCreateOrReplace = exports.OpenApiDocumentCreateComponent = exports.OpenApiDocumentCreate = exports.OpenApiDocumentCountComponent = exports.OpenApiDocumentCount = void 0;
|
|
4
|
+
const readYamlFile_1 = require("../../../../util/readYamlFile");
|
|
5
5
|
// reading the description of the Count action in the controller document.
|
|
6
6
|
// The yaml objects are then stored in the variables below
|
|
7
7
|
const countObject = (0, readYamlFile_1.readYamlFile)(__dirname + '/count.yaml');
|
|
@@ -52,4 +52,9 @@ exports.OpenApiDocumentDeleteComponent = deleteObject.components.schemas;
|
|
|
52
52
|
const deleteByQueryObject = (0, readYamlFile_1.readYamlFile)(__dirname + '/deleteByQuery.yaml');
|
|
53
53
|
exports.OpenApiDocumentDeleteByQuery = deleteByQueryObject.DocumentDeleteByQuery;
|
|
54
54
|
exports.OpenApiDocumentDeleteByQueryComponent = deleteByQueryObject.components.schemas;
|
|
55
|
+
// reading the description of the Validate action in the controller document.
|
|
56
|
+
// The yaml objects are then stored in the variables below
|
|
57
|
+
const validateObject = (0, readYamlFile_1.readYamlFile)(__dirname + '/validate.yaml');
|
|
58
|
+
exports.OpenApiDocumentValidate = validateObject.DocumentValidate;
|
|
59
|
+
exports.OpenApiDocumentValidateComponent = validateObject.components.schemas;
|
|
55
60
|
//# sourceMappingURL=index.js.map
|
|
@@ -35,12 +35,12 @@ DocumentReplace:
|
|
|
35
35
|
description: "Replaces the content of an existing document."
|
|
36
36
|
required: true
|
|
37
37
|
schema:
|
|
38
|
-
$ref: "#/components/
|
|
38
|
+
$ref: "#/components/document/DocumentReplaceRequest"
|
|
39
39
|
responses:
|
|
40
40
|
200:
|
|
41
41
|
description: "Replaces the content of an existing document."
|
|
42
42
|
schema:
|
|
43
|
-
$ref: "#/components/
|
|
43
|
+
$ref: "#/components/document/DocumentReplaceResponse"
|
|
44
44
|
|
|
45
45
|
components:
|
|
46
46
|
schemas:
|
|
@@ -47,12 +47,12 @@ DocumentUpdate:
|
|
|
47
47
|
description: "Updates a document content."
|
|
48
48
|
required: true
|
|
49
49
|
schema:
|
|
50
|
-
$ref: "#/components/
|
|
50
|
+
$ref: "#/components/document/DocumentUpdateRequest"
|
|
51
51
|
responses:
|
|
52
52
|
200:
|
|
53
53
|
description: "Updates a document content."
|
|
54
54
|
schema:
|
|
55
|
-
$ref: "#/components/
|
|
55
|
+
$ref: "#/components/document/DocumentUpdateResponse"
|
|
56
56
|
|
|
57
57
|
components:
|
|
58
58
|
schemas:
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
DocumentValidate:
|
|
2
|
+
summary: "Validates data against existing validation rules."
|
|
3
|
+
tags:
|
|
4
|
+
- document
|
|
5
|
+
parameters:
|
|
6
|
+
- in: path
|
|
7
|
+
name: index
|
|
8
|
+
schema:
|
|
9
|
+
type: string
|
|
10
|
+
- in: path
|
|
11
|
+
name: collection
|
|
12
|
+
schema:
|
|
13
|
+
type: string
|
|
14
|
+
- in: body
|
|
15
|
+
name: "body"
|
|
16
|
+
description: "Document content to check."
|
|
17
|
+
required: true
|
|
18
|
+
schema:
|
|
19
|
+
$ref: "#/components/document/DocumentValidateRequest"
|
|
20
|
+
responses:
|
|
21
|
+
200:
|
|
22
|
+
description: "Returns the document validation status."
|
|
23
|
+
schema:
|
|
24
|
+
$ref: "#/components/document/DocumentValidateResponse"
|
|
25
|
+
|
|
26
|
+
components:
|
|
27
|
+
schemas:
|
|
28
|
+
DocumentValidateRequest:
|
|
29
|
+
allOf:
|
|
30
|
+
- type: "object"
|
|
31
|
+
description: "document content"
|
|
32
|
+
|
|
33
|
+
DocumentValidateResponse:
|
|
34
|
+
allOf:
|
|
35
|
+
- $ref: "#/components/ResponsePayload"
|
|
36
|
+
- type: "object"
|
|
37
|
+
properties:
|
|
38
|
+
result:
|
|
39
|
+
type: "object"
|
|
40
|
+
properties:
|
|
41
|
+
valid:
|
|
42
|
+
type: "boolean"
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.OpenApiPayloadsDefinitions = void 0;
|
|
14
|
+
const readYamlFile_1 = require("../../../util/readYamlFile");
|
|
15
|
+
__exportStar(require("./document"), exports);
|
|
16
|
+
// Document definitions (reusable object for KuzzleRequest and KuzzleResponse)
|
|
17
|
+
exports.OpenApiPayloadsDefinitions = (0, readYamlFile_1.readYamlFile)(__dirname + '/payloads.yaml').definitions;
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
File without changes
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export declare const OpenApiPayloadsDefinitions: any;
|
|
1
|
+
export * from './OpenApiManager';
|
package/lib/api/openapi/index.js
CHANGED
|
@@ -10,9 +10,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports
|
|
14
|
-
const readYamlFile_1 = require("../../util/readYamlFile");
|
|
15
|
-
__exportStar(require("./document"), exports);
|
|
16
|
-
// Document definitions (reusable object for KuzzleRequest and KuzzleResponse)
|
|
17
|
-
exports.OpenApiPayloadsDefinitions = (0, readYamlFile_1.readYamlFile)(__dirname + '/payloads.yaml').definitions;
|
|
13
|
+
__exportStar(require("./OpenApiManager"), exports);
|
|
18
14
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,133 @@
|
|
|
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 inflector_1 = require("../../util/inflector");
|
|
29
|
+
const routeUrlMatch = /:([^/]*)/g;
|
|
30
|
+
/**
|
|
31
|
+
* Generate basic openApi Controller
|
|
32
|
+
*/
|
|
33
|
+
function generateController(route, definition) {
|
|
34
|
+
if (route.controller === undefined) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (!lodash_1.default.some(definition.tags, { name: route.controller })) {
|
|
38
|
+
const capitalizedController = inflector_1.Inflector.pascalCase(route.controller);
|
|
39
|
+
definition.tags.push({
|
|
40
|
+
description: `${capitalizedController} Controller`,
|
|
41
|
+
name: route.controller
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
if (route.openapi.tags === undefined) {
|
|
45
|
+
route.openapi.tags = [];
|
|
46
|
+
}
|
|
47
|
+
if (!route.openapi.tags.includes(route.controller)) {
|
|
48
|
+
route.openapi.tags.push(route.controller);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Generate basic openApi Summary
|
|
53
|
+
*/
|
|
54
|
+
function generateSummary(route) {
|
|
55
|
+
if (route.openapi.description === undefined) {
|
|
56
|
+
route.openapi.description = `Controller: ${route.controller}.`;
|
|
57
|
+
}
|
|
58
|
+
if (route.openapi.summary === undefined) {
|
|
59
|
+
route.openapi.summary = `Action: ${route.action}.`;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Generate basic openApi Parameters
|
|
64
|
+
*/
|
|
65
|
+
function generateParameters(route) {
|
|
66
|
+
if (route.openapi.parameters === undefined) {
|
|
67
|
+
route.openapi.parameters = [];
|
|
68
|
+
let m = routeUrlMatch.exec(route.path);
|
|
69
|
+
while (m !== null) {
|
|
70
|
+
routeUrlMatch.lastIndex++;
|
|
71
|
+
route.openapi.parameters.push({
|
|
72
|
+
in: 'path',
|
|
73
|
+
name: m[1],
|
|
74
|
+
required: true,
|
|
75
|
+
schema: { type: 'string' }
|
|
76
|
+
});
|
|
77
|
+
m = routeUrlMatch.exec(route.path);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (route.openapi.parameters.length === 0) {
|
|
81
|
+
route.openapi.parameters = undefined;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Generate basic openApi Response
|
|
86
|
+
*/
|
|
87
|
+
function generateResponse(route) {
|
|
88
|
+
if (route.openapi.responses === undefined) {
|
|
89
|
+
route.openapi.responses = {
|
|
90
|
+
'200': {
|
|
91
|
+
description: 'OK'
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Generates JSON OpenApi object
|
|
98
|
+
*
|
|
99
|
+
* @returns {object} openApi object
|
|
100
|
+
*/
|
|
101
|
+
function generateOpenApi(routes, definition) {
|
|
102
|
+
for (const route of routes) {
|
|
103
|
+
// Make sure route verbs are lowercase
|
|
104
|
+
if (route.verb !== undefined) {
|
|
105
|
+
route.verb = route.verb.toLowerCase();
|
|
106
|
+
}
|
|
107
|
+
// Set :param notation to {param}
|
|
108
|
+
route.formattedPath = route.path.replace(routeUrlMatch, '{$1}');
|
|
109
|
+
if (definition.paths[route.formattedPath] === undefined) {
|
|
110
|
+
definition.paths[route.formattedPath] = {};
|
|
111
|
+
}
|
|
112
|
+
if (definition.paths[route.formattedPath][route.verb] !== undefined) {
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
// If custom specification, return as it is
|
|
116
|
+
if (route.openapi) {
|
|
117
|
+
generateController(route, definition);
|
|
118
|
+
definition.paths[route.formattedPath][route.verb] = route.openapi;
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
if (route.openapi === undefined) {
|
|
122
|
+
route.openapi = {};
|
|
123
|
+
}
|
|
124
|
+
generateController(route, definition);
|
|
125
|
+
generateSummary(route);
|
|
126
|
+
generateParameters(route);
|
|
127
|
+
generateResponse(route);
|
|
128
|
+
definition.paths[route.formattedPath][route.verb] = route.openapi;
|
|
129
|
+
}
|
|
130
|
+
return definition;
|
|
131
|
+
}
|
|
132
|
+
exports.generateOpenApi = generateOpenApi;
|
|
133
|
+
//# sourceMappingURL=openApiGenerator.js.map
|
|
@@ -50,6 +50,7 @@ const requestResponse_1 = require("./requestResponse");
|
|
|
50
50
|
const requestContext_1 = require("./requestContext");
|
|
51
51
|
const errors_1 = require("../../kerror/errors");
|
|
52
52
|
const kerror_1 = __importDefault(require("../../kerror"));
|
|
53
|
+
const types_1 = require("../../types");
|
|
53
54
|
const assert = __importStar(require("../../util/assertType"));
|
|
54
55
|
const safeObject_1 = require("../../util/safeObject");
|
|
55
56
|
const lodash_1 = require("lodash");
|
|
@@ -217,6 +218,9 @@ class KuzzleRequest {
|
|
|
217
218
|
if (result instanceof Error) {
|
|
218
219
|
throw new errors_1.InternalError('cannot set an error as a request\'s response');
|
|
219
220
|
}
|
|
221
|
+
if (this.context.connection.protocol !== 'http' && result instanceof types_1.HttpStream) {
|
|
222
|
+
throw kerror_1.default.get('api', 'assert', 'forbidden_stream');
|
|
223
|
+
}
|
|
220
224
|
this.status = options.status || 200;
|
|
221
225
|
if (options.headers) {
|
|
222
226
|
this.response.setHeaders(options.headers);
|
package/lib/cluster/node.js
CHANGED
|
@@ -110,10 +110,10 @@ function getIP ({ family = 'IPv4', interface: netInterface, ip } = {}) {
|
|
|
110
110
|
debug('Found interfaces %o', interfaces);
|
|
111
111
|
|
|
112
112
|
interfaces = interfaces.filter(n => {
|
|
113
|
-
return !n.internal
|
|
114
|
-
&& !isInternalIP(n.address)
|
|
113
|
+
return ! n.internal
|
|
114
|
+
&& ! isInternalIP(n.address)
|
|
115
115
|
&& n.family === family
|
|
116
|
-
&& (!ip || mustBePrivate === isPrivateIP(n.address));
|
|
116
|
+
&& (! ip || mustBePrivate === isPrivateIP(n.address));
|
|
117
117
|
});
|
|
118
118
|
|
|
119
119
|
debug('Filtered interfaces %o', interfaces);
|
|
@@ -123,7 +123,7 @@ function getIP ({ family = 'IPv4', interface: netInterface, ip } = {}) {
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
// take the first IP from the list if no interface has been defined
|
|
126
|
-
if (!netInterface) {
|
|
126
|
+
if (! netInterface) {
|
|
127
127
|
return interfaces[0].address;
|
|
128
128
|
}
|
|
129
129
|
|
|
@@ -298,7 +298,7 @@ class ClusterNode {
|
|
|
298
298
|
async evictNode (nodeId, { broadcast = false, reason = '' }) {
|
|
299
299
|
const subscriber = this.remoteNodes.get(nodeId);
|
|
300
300
|
|
|
301
|
-
if (!subscriber) {
|
|
301
|
+
if (! subscriber) {
|
|
302
302
|
return;
|
|
303
303
|
}
|
|
304
304
|
|
|
@@ -358,7 +358,7 @@ class ClusterNode {
|
|
|
358
358
|
return split.every((id, index) => id === topology[index]);
|
|
359
359
|
});
|
|
360
360
|
|
|
361
|
-
if (!found) {
|
|
361
|
+
if (! found) {
|
|
362
362
|
splits.push(topology);
|
|
363
363
|
}
|
|
364
364
|
}
|
|
@@ -415,13 +415,13 @@ class ClusterNode {
|
|
|
415
415
|
|
|
416
416
|
for (let i = 0; i < isolatedNodes.length; i++) {
|
|
417
417
|
const idCard = idCards.find(card => card.id === isolatedNodes[i]);
|
|
418
|
-
if (!youngestNode || idCard.birthdate > youngestNode.birthdate) {
|
|
418
|
+
if (! youngestNode || idCard.birthdate > youngestNode.birthdate) {
|
|
419
419
|
youngestNode = idCard;
|
|
420
420
|
}
|
|
421
421
|
}
|
|
422
422
|
|
|
423
423
|
if (isIsolated) {
|
|
424
|
-
for (let i = 0; !candidates && i < eligibleSplits.length; i++) {
|
|
424
|
+
for (let i = 0; ! candidates && i < eligibleSplits.length; i++) {
|
|
425
425
|
if (eligibleSplits[i].includes(youngestNode.id)) {
|
|
426
426
|
candidates = _.intersection(eligibleSplits[i], isolatedNodes);
|
|
427
427
|
}
|
|
@@ -621,7 +621,7 @@ class ClusterNode {
|
|
|
621
621
|
async getStatus () {
|
|
622
622
|
const status = {
|
|
623
623
|
activeNodes: 0,
|
|
624
|
-
activity: this.activity.map(({address, date, event, id, reason}) => ({
|
|
624
|
+
activity: this.activity.map(({ address, date, event, id, reason }) => ({
|
|
625
625
|
address,
|
|
626
626
|
date,
|
|
627
627
|
event: event === nodeActivityEnum.ADDED ? 'joined' : 'evicted',
|
package/lib/cluster/publisher.js
CHANGED
|
@@ -667,7 +667,7 @@ class ClusterSubscriber {
|
|
|
667
667
|
* @return {boolean} false: the message must be discarded, true otherwise
|
|
668
668
|
*/
|
|
669
669
|
async validateMessage (message) {
|
|
670
|
-
if (!has(message, 'messageId')) {
|
|
670
|
+
if (! has(message, 'messageId')) {
|
|
671
671
|
global.kuzzle.log.warn(`Invalid message received from node ${this.remoteNodeId}. Evicting it.`);
|
|
672
672
|
|
|
673
673
|
await this.evictNode({
|
|
@@ -44,7 +44,7 @@ class IDCardRenewer {
|
|
|
44
44
|
* which could be enough to make the ID Card expire.
|
|
45
45
|
*/
|
|
46
46
|
await this.renewIDCard();
|
|
47
|
-
if (!this.disposed) {
|
|
47
|
+
if (! this.disposed) {
|
|
48
48
|
this.refreshTimer = setInterval(
|
|
49
49
|
this.renewIDCard.bind(this),
|
|
50
50
|
this.refreshDelay);
|
|
@@ -110,7 +110,7 @@ class IDCardRenewer {
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
if (!isMainThread) {
|
|
113
|
+
if (! isMainThread) {
|
|
114
114
|
const idCardRenewer = new IDCardRenewer();
|
|
115
115
|
|
|
116
116
|
parentPort.on('message', async message => {
|
package/lib/config/index.js
CHANGED
|
@@ -80,7 +80,7 @@ function loadConfig () {
|
|
|
80
80
|
*/
|
|
81
81
|
function unstringify (cfg) {
|
|
82
82
|
Object.keys(cfg)
|
|
83
|
-
.filter(k =>
|
|
83
|
+
.filter(k => ! /version$/i.test(k) && (typeof cfg[k] === 'string' || cfg[k] instanceof Object))
|
|
84
84
|
.forEach(k => {
|
|
85
85
|
if (typeof cfg[k] === 'string') {
|
|
86
86
|
if (cfg[k] === 'true') {
|
|
@@ -138,7 +138,7 @@ function checkLimitsConfig (cfg) {
|
|
|
138
138
|
'subscriptionDocumentTTL'
|
|
139
139
|
];
|
|
140
140
|
|
|
141
|
-
if (!isPlainObject(cfg.limits)) {
|
|
141
|
+
if (! isPlainObject(cfg.limits)) {
|
|
142
142
|
throw kerror.get('invalid_type', 'limits', 'object');
|
|
143
143
|
}
|
|
144
144
|
|
|
@@ -148,7 +148,7 @@ function checkLimitsConfig (cfg) {
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
if ( cfg.limits[opt] < 0
|
|
151
|
-
|| cfg.limits[opt] === 0 && !canBeZero.includes(opt)
|
|
151
|
+
|| cfg.limits[opt] === 0 && ! canBeZero.includes(opt)
|
|
152
152
|
) {
|
|
153
153
|
const allowed = `>= ${canBeZero.includes(opt) ? '0' : '1'}`;
|
|
154
154
|
throw kerror.get('out_of_range', `limits.${opt}`, allowed);
|
|
@@ -221,9 +221,9 @@ function checkClusterOptions (config) {
|
|
|
221
221
|
if (`${cfg.ip}`.length === 0 || cfg.ip === 'null') {
|
|
222
222
|
cfg.ip = null;
|
|
223
223
|
}
|
|
224
|
-
assert(!cfg.ip || ['private', 'public'].includes(cfg.ip), '[CONFIG] kuzzlerc.cluster.ip: invalid value (accepted values: public, private)');
|
|
224
|
+
assert(! cfg.ip || ['private', 'public'].includes(cfg.ip), '[CONFIG] kuzzlerc.cluster.ip: invalid value (accepted values: public, private)');
|
|
225
225
|
|
|
226
|
-
assert(!cfg.interface || typeof cfg.interface === 'string', '[CONFIG] kuzzlerc.cluster.interface: value must be either null, or a string');
|
|
226
|
+
assert(! cfg.interface || typeof cfg.interface === 'string', '[CONFIG] kuzzlerc.cluster.interface: value must be either null, or a string');
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
function preprocessHttpOptions (config) {
|
|
@@ -251,7 +251,7 @@ function preprocessHttpOptions (config) {
|
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
253
|
|
|
254
|
-
function preprocessProtocolsOptions(config) {
|
|
254
|
+
function preprocessProtocolsOptions (config) {
|
|
255
255
|
const protocols = config.server.protocols;
|
|
256
256
|
|
|
257
257
|
config.internal.notifiableProtocols = [];
|
|
@@ -31,30 +31,30 @@ HTTP Response Mockup to emulate response objects for Passport Authentication
|
|
|
31
31
|
* @class PassportResponse
|
|
32
32
|
*/
|
|
33
33
|
class PassportResponse {
|
|
34
|
-
constructor() {
|
|
34
|
+
constructor () {
|
|
35
35
|
this.headers = {};
|
|
36
36
|
this.statusCode = 200;
|
|
37
37
|
this.onEndListener = null;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
setHeader(field, value) {
|
|
40
|
+
setHeader (field, value) {
|
|
41
41
|
this.headers[field] = value;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
end(statusCode) {
|
|
44
|
+
end (statusCode) {
|
|
45
45
|
if (statusCode) {
|
|
46
46
|
this.statusCode = statusCode;
|
|
47
47
|
}
|
|
48
|
-
if(typeof this.onEndListener === 'function') {
|
|
48
|
+
if (typeof this.onEndListener === 'function') {
|
|
49
49
|
this.onEndListener();
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
getHeader(key) {
|
|
53
|
+
getHeader (key) {
|
|
54
54
|
return this.headers[key];
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
addEndListener(listener) {
|
|
57
|
+
addEndListener (listener) {
|
|
58
58
|
this.onEndListener = listener;
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -32,7 +32,7 @@ const PassportResponse = require('./passportResponse');
|
|
|
32
32
|
* @class PassportWrapper
|
|
33
33
|
*/
|
|
34
34
|
class PassportWrapper {
|
|
35
|
-
constructor() {
|
|
35
|
+
constructor () {
|
|
36
36
|
this.options = {};
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -41,7 +41,7 @@ class PassportWrapper {
|
|
|
41
41
|
* @param strategyName
|
|
42
42
|
* @returns {Promise.<*>}
|
|
43
43
|
*/
|
|
44
|
-
authenticate(request, strategyName) {
|
|
44
|
+
authenticate (request, strategyName) {
|
|
45
45
|
const response = new PassportResponse();
|
|
46
46
|
|
|
47
47
|
return new Bluebird((resolve, reject) => {
|
|
@@ -67,7 +67,7 @@ class PassportWrapper {
|
|
|
67
67
|
err.message));
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
else if (!user) {
|
|
70
|
+
else if (! user) {
|
|
71
71
|
reject(
|
|
72
72
|
kerror.get('plugin', 'strategy', 'missing_user', info.message));
|
|
73
73
|
}
|
|
@@ -103,7 +103,7 @@ class PassportWrapper {
|
|
|
103
103
|
* @param {object} strategy - instantiated strategy object
|
|
104
104
|
* @param {object} opts - options to provide to authenticate with the strategy
|
|
105
105
|
*/
|
|
106
|
-
use(name, strategy, opts = {}) {
|
|
106
|
+
use (name, strategy, opts = {}) {
|
|
107
107
|
passport.use(name, strategy);
|
|
108
108
|
this.options[name] = opts;
|
|
109
109
|
}
|
|
@@ -113,7 +113,7 @@ class PassportWrapper {
|
|
|
113
113
|
*
|
|
114
114
|
* @param {string} name - name of the strategy to unregister
|
|
115
115
|
*/
|
|
116
|
-
unuse(name) {
|
|
116
|
+
unuse (name) {
|
|
117
117
|
passport.unuse(name);
|
|
118
118
|
delete this.options[name];
|
|
119
119
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EmbeddedSDK } from '../shared/sdk/embeddedSdk';
|
|
2
2
|
import { JSONObject } from '../../../index';
|
|
3
|
-
import { BackendCluster, BackendConfig, BackendController, BackendHook, BackendImport, BackendPipe, BackendPlugin, BackendStorage, BackendVault, InternalLogger } from './index';
|
|
3
|
+
import { BackendCluster, BackendConfig, BackendController, BackendHook, BackendImport, BackendPipe, BackendPlugin, BackendStorage, BackendVault, BackendOpenApi, InternalLogger } from './index';
|
|
4
4
|
export declare class Backend {
|
|
5
5
|
private _kuzzle;
|
|
6
6
|
private _name;
|
|
@@ -113,6 +113,10 @@ export declare class Backend {
|
|
|
113
113
|
* @method userMappings - Import user mappings
|
|
114
114
|
*/
|
|
115
115
|
import: BackendImport;
|
|
116
|
+
/**
|
|
117
|
+
* OpenApi manager
|
|
118
|
+
*/
|
|
119
|
+
openApi: BackendOpenApi;
|
|
116
120
|
/**
|
|
117
121
|
* @deprecated
|
|
118
122
|
*
|
|
@@ -127,6 +127,13 @@ class Backend {
|
|
|
127
127
|
this.started = true;
|
|
128
128
|
},
|
|
129
129
|
];
|
|
130
|
+
try {
|
|
131
|
+
const info = JSON.parse(fs_1.default.readFileSync('./package.json', 'utf8'));
|
|
132
|
+
this.version = info.version;
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
// Silent if no version can be found
|
|
136
|
+
}
|
|
130
137
|
global.app = this;
|
|
131
138
|
this.pipe = new index_1.BackendPipe(this);
|
|
132
139
|
this.hook = new index_1.BackendHook(this);
|
|
@@ -138,14 +145,8 @@ class Backend {
|
|
|
138
145
|
this.import = new index_1.BackendImport(this);
|
|
139
146
|
this.log = new index_1.InternalLogger(this);
|
|
140
147
|
this.cluster = new index_1.BackendCluster();
|
|
148
|
+
this.openApi = new index_1.BackendOpenApi(this);
|
|
141
149
|
this.kerror = kerror_1.default;
|
|
142
|
-
try {
|
|
143
|
-
const info = JSON.parse(fs_1.default.readFileSync('./package.json', 'utf8'));
|
|
144
|
-
this.version = info.version;
|
|
145
|
-
}
|
|
146
|
-
catch (error) {
|
|
147
|
-
// Silent if no version can be found
|
|
148
|
-
}
|
|
149
150
|
try {
|
|
150
151
|
this.commit = this._readCommit();
|
|
151
152
|
}
|
|
@@ -171,6 +172,7 @@ class Backend {
|
|
|
171
172
|
const application = new this.PluginObject(this._instanceProxy, { application: true, name: this.name });
|
|
172
173
|
application.version = this.version;
|
|
173
174
|
application.commit = this.commit;
|
|
175
|
+
application.openApi = this.openApi.definition;
|
|
174
176
|
const options = {
|
|
175
177
|
import: this._import,
|
|
176
178
|
installations: this._installationsWaitingList,
|
|
@@ -224,7 +226,9 @@ class Backend {
|
|
|
224
226
|
/**
|
|
225
227
|
* Application Name
|
|
226
228
|
*/
|
|
227
|
-
get name() {
|
|
229
|
+
get name() {
|
|
230
|
+
return this._name;
|
|
231
|
+
}
|
|
228
232
|
/**
|
|
229
233
|
* EmbeddedSDK instance
|
|
230
234
|
*/
|
|
@@ -2,13 +2,15 @@ import { ApplicationManager, Backend } from './index';
|
|
|
2
2
|
import { KuzzleConfiguration } from '../../types/config/KuzzleConfiguration';
|
|
3
3
|
export declare class BackendConfig extends ApplicationManager {
|
|
4
4
|
/**
|
|
5
|
-
* Configuration content
|
|
5
|
+
* Configuration content.
|
|
6
6
|
*/
|
|
7
7
|
content: KuzzleConfiguration;
|
|
8
8
|
constructor(application: Backend);
|
|
9
9
|
/**
|
|
10
10
|
* Sets a configuration value
|
|
11
11
|
*
|
|
12
|
+
* @deprecated use app.config.content instead
|
|
13
|
+
*
|
|
12
14
|
* @param path - Path to the configuration key (lodash style)
|
|
13
15
|
* @param value - Value for the configuration key
|
|
14
16
|
*/
|
|
@@ -16,6 +18,8 @@ export declare class BackendConfig extends ApplicationManager {
|
|
|
16
18
|
/**
|
|
17
19
|
* Merges a configuration object into the current configuration
|
|
18
20
|
*
|
|
21
|
+
* @deprecated use app.config.content instead
|
|
22
|
+
*
|
|
19
23
|
* @param config - Configuration object to merge
|
|
20
24
|
*/
|
|
21
25
|
merge(config: KuzzleConfiguration): void;
|
|
@@ -37,6 +37,8 @@ class BackendConfig extends index_1.ApplicationManager {
|
|
|
37
37
|
/**
|
|
38
38
|
* Sets a configuration value
|
|
39
39
|
*
|
|
40
|
+
* @deprecated use app.config.content instead
|
|
41
|
+
*
|
|
40
42
|
* @param path - Path to the configuration key (lodash style)
|
|
41
43
|
* @param value - Value for the configuration key
|
|
42
44
|
*/
|
|
@@ -49,6 +51,8 @@ class BackendConfig extends index_1.ApplicationManager {
|
|
|
49
51
|
/**
|
|
50
52
|
* Merges a configuration object into the current configuration
|
|
51
53
|
*
|
|
54
|
+
* @deprecated use app.config.content instead
|
|
55
|
+
*
|
|
52
56
|
* @param config - Configuration object to merge
|
|
53
57
|
*/
|
|
54
58
|
merge(config) {
|