kuzzle 2.19.2 → 2.19.3
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 +94 -80
- package/lib/api/controllers/authController.js +239 -212
- package/lib/api/controllers/baseController.js +89 -51
- package/lib/api/controllers/bulkController.js +62 -49
- package/lib/api/controllers/clusterController.js +6 -8
- package/lib/api/controllers/collectionController.js +140 -129
- package/lib/api/controllers/debugController.d.ts +2 -2
- package/lib/api/controllers/debugController.js +33 -31
- package/lib/api/controllers/documentController.js +365 -274
- package/lib/api/controllers/index.js +13 -13
- package/lib/api/controllers/indexController.js +46 -50
- package/lib/api/controllers/memoryStorageController.js +410 -360
- package/lib/api/controllers/realtimeController.js +37 -36
- package/lib/api/controllers/securityController.js +553 -412
- package/lib/api/controllers/serverController.js +111 -104
- package/lib/api/documentExtractor.js +75 -68
- package/lib/api/funnel.js +411 -312
- package/lib/api/httpRoutes.js +1493 -324
- package/lib/api/openapi/OpenApiManager.d.ts +1 -1
- package/lib/api/openapi/OpenApiManager.js +22 -22
- package/lib/api/openapi/components/document/count.yaml +1 -1
- package/lib/api/openapi/components/document/create.yaml +2 -2
- package/lib/api/openapi/components/document/delete.yaml +1 -1
- package/lib/api/openapi/components/document/deleteByQuery.yaml +1 -1
- package/lib/api/openapi/components/document/exists.yaml +1 -1
- package/lib/api/openapi/components/document/get.yaml +2 -2
- package/lib/api/openapi/components/document/index.js +12 -12
- package/lib/api/openapi/components/document/replace.yaml +1 -1
- package/lib/api/openapi/components/document/scroll.yaml +1 -1
- package/lib/api/openapi/components/document/validate.yaml +1 -1
- package/lib/api/openapi/components/index.d.ts +2 -2
- package/lib/api/openapi/components/index.js +1 -1
- package/lib/api/openapi/components/security/index.js +1 -1
- package/lib/api/openapi/components/security/upsertUser.yaml +2 -3
- package/lib/api/openapi/index.d.ts +1 -1
- package/lib/api/openapi/openApiGenerator.d.ts +1 -1
- package/lib/api/openapi/openApiGenerator.js +7 -7
- package/lib/api/rateLimiter.js +12 -13
- package/lib/api/request/index.d.ts +4 -4
- package/lib/api/request/kuzzleRequest.d.ts +9 -9
- package/lib/api/request/kuzzleRequest.js +89 -87
- package/lib/api/request/requestContext.d.ts +2 -2
- package/lib/api/request/requestContext.js +17 -17
- package/lib/api/request/requestInput.d.ts +1 -1
- package/lib/api/request/requestInput.js +19 -19
- package/lib/api/request/requestResponse.d.ts +4 -4
- package/lib/api/request/requestResponse.js +31 -33
- package/lib/cluster/command.js +48 -44
- package/lib/cluster/idCardHandler.d.ts +1 -1
- package/lib/cluster/idCardHandler.js +15 -15
- package/lib/cluster/index.js +2 -2
- package/lib/cluster/node.js +301 -269
- package/lib/cluster/publisher.js +45 -46
- package/lib/cluster/state.d.ts +5 -5
- package/lib/cluster/state.js +8 -8
- package/lib/cluster/subscriber.js +163 -113
- package/lib/cluster/workers/IDCardRenewer.js +33 -32
- package/lib/config/default.config.d.ts +1 -1
- package/lib/config/default.config.js +212 -171
- package/lib/config/documentEventAliases.js +6 -6
- package/lib/config/index.js +161 -98
- package/lib/config/sdkCompatibility.json +8 -8
- package/lib/core/auth/formatProcessing.js +7 -7
- package/lib/core/auth/passportResponse.js +7 -7
- package/lib/core/auth/passportWrapper.js +34 -30
- package/lib/core/auth/tokenManager.d.ts +2 -2
- package/lib/core/auth/tokenManager.js +11 -10
- package/lib/core/backend/applicationManager.d.ts +1 -1
- package/lib/core/backend/applicationManager.js +2 -2
- package/lib/core/backend/backend.d.ts +3 -3
- package/lib/core/backend/backend.js +34 -31
- package/lib/core/backend/backendCluster.d.ts +2 -2
- package/lib/core/backend/backendCluster.js +5 -5
- package/lib/core/backend/backendConfig.d.ts +2 -2
- package/lib/core/backend/backendConfig.js +3 -3
- package/lib/core/backend/backendController.d.ts +2 -2
- package/lib/core/backend/backendController.js +9 -10
- package/lib/core/backend/backendErrors.d.ts +3 -3
- package/lib/core/backend/backendErrors.js +2 -1
- package/lib/core/backend/backendHook.d.ts +2 -2
- package/lib/core/backend/backendHook.js +5 -5
- package/lib/core/backend/backendImport.d.ts +3 -3
- package/lib/core/backend/backendImport.js +23 -23
- package/lib/core/backend/backendOpenApi.d.ts +2 -2
- package/lib/core/backend/backendOpenApi.js +16 -16
- package/lib/core/backend/backendPipe.d.ts +2 -2
- package/lib/core/backend/backendPipe.js +6 -6
- package/lib/core/backend/backendPlugin.d.ts +4 -4
- package/lib/core/backend/backendPlugin.js +14 -14
- package/lib/core/backend/backendStorage.d.ts +2 -2
- package/lib/core/backend/backendStorage.js +1 -2
- package/lib/core/backend/backendVault.d.ts +2 -2
- package/lib/core/backend/backendVault.js +3 -3
- package/lib/core/backend/index.d.ts +14 -14
- package/lib/core/backend/internalLogger.d.ts +1 -1
- package/lib/core/backend/internalLogger.js +5 -5
- package/lib/core/cache/cacheDbEnum.js +4 -4
- package/lib/core/cache/cacheEngine.js +79 -85
- package/lib/core/network/accessLogger.js +126 -120
- package/lib/core/network/clientConnection.js +5 -5
- package/lib/core/network/context.js +8 -8
- package/lib/core/network/entryPoint.js +100 -85
- package/lib/core/network/httpRouter/index.js +63 -60
- package/lib/core/network/httpRouter/routeHandler.js +18 -19
- package/lib/core/network/httpRouter/routePart.js +23 -19
- package/lib/core/network/protocolManifest.js +3 -3
- package/lib/core/network/protocols/httpMessage.js +8 -10
- package/lib/core/network/protocols/httpwsProtocol.js +305 -250
- package/lib/core/network/protocols/internalProtocol.js +27 -24
- package/lib/core/network/protocols/mqttProtocol.js +106 -96
- package/lib/core/network/protocols/protocol.js +20 -17
- package/lib/core/network/router.js +56 -46
- package/lib/core/plugin/plugin.js +151 -120
- package/lib/core/plugin/pluginContext.d.ts +7 -7
- package/lib/core/plugin/pluginContext.js +48 -44
- package/lib/core/plugin/pluginManifest.js +13 -12
- package/lib/core/plugin/pluginRepository.js +26 -27
- package/lib/core/plugin/pluginsManager.js +425 -304
- package/lib/core/plugin/privilegedContext.js +3 -3
- package/lib/core/realtime/actionEnum.js +1 -1
- package/lib/core/realtime/channel.d.ts +1 -1
- package/lib/core/realtime/channel.js +22 -22
- package/lib/core/realtime/connectionRooms.d.ts +1 -1
- package/lib/core/realtime/hotelClerk.d.ts +2 -2
- package/lib/core/realtime/hotelClerk.js +53 -50
- package/lib/core/realtime/index.js +5 -5
- package/lib/core/realtime/notification/document.js +25 -25
- package/lib/core/realtime/notification/index.js +4 -4
- package/lib/core/realtime/notification/server.js +3 -3
- package/lib/core/realtime/notification/user.js +4 -4
- package/lib/core/realtime/notifier.js +113 -75
- package/lib/core/realtime/room.d.ts +1 -1
- package/lib/core/realtime/subscription.d.ts +1 -1
- package/lib/core/realtime/subscription.js +1 -1
- package/lib/core/security/index.js +8 -8
- package/lib/core/security/profileRepository.d.ts +6 -6
- package/lib/core/security/profileRepository.js +48 -45
- package/lib/core/security/roleRepository.js +127 -115
- package/lib/core/security/securityLoader.js +70 -63
- package/lib/core/security/tokenRepository.js +132 -118
- package/lib/core/security/userRepository.js +104 -88
- package/lib/core/shared/KoncordeWrapper.d.ts +1 -1
- package/lib/core/shared/KoncordeWrapper.js +3 -1
- package/lib/core/shared/abstractManifest.js +22 -23
- package/lib/core/shared/repository.js +69 -67
- package/lib/core/shared/sdk/embeddedSdk.d.ts +2 -2
- package/lib/core/shared/sdk/embeddedSdk.js +36 -32
- package/lib/core/shared/sdk/funnelProtocol.d.ts +1 -1
- package/lib/core/shared/sdk/funnelProtocol.js +11 -11
- package/lib/core/shared/sdk/impersonatedSdk.js +19 -18
- package/lib/core/shared/store.js +127 -32
- package/lib/core/statistics/index.js +2 -2
- package/lib/core/statistics/statistics.js +99 -85
- package/lib/core/storage/clientAdapter.js +219 -136
- package/lib/core/storage/indexCache.js +3 -3
- package/lib/core/storage/storageEngine.js +10 -13
- package/lib/core/storage/storeScopeEnum.js +3 -3
- package/lib/core/validation/baseType.js +12 -10
- package/lib/core/validation/index.js +2 -2
- package/lib/core/validation/types/anything.js +4 -4
- package/lib/core/validation/types/boolean.js +7 -7
- package/lib/core/validation/types/date.js +165 -131
- package/lib/core/validation/types/email.js +18 -21
- package/lib/core/validation/types/enum.js +34 -21
- package/lib/core/validation/types/geoPoint.js +7 -7
- package/lib/core/validation/types/geoShape.js +148 -125
- package/lib/core/validation/types/integer.js +9 -9
- package/lib/core/validation/types/ipAddress.js +17 -19
- package/lib/core/validation/types/numeric.js +36 -29
- package/lib/core/validation/types/object.js +19 -19
- package/lib/core/validation/types/string.js +36 -29
- package/lib/core/validation/types/url.js +17 -19
- package/lib/core/validation/validation.js +422 -378
- package/lib/kerror/codes/1-services.json +7 -1
- package/lib/kerror/codes/4-plugin.json +2 -2
- package/lib/kerror/codes/index.js +85 -63
- package/lib/kerror/errors/badRequestError.d.ts +1 -1
- package/lib/kerror/errors/externalServiceError.d.ts +1 -1
- package/lib/kerror/errors/forbiddenError.d.ts +1 -1
- package/lib/kerror/errors/gatewayTimeoutError.d.ts +1 -1
- package/lib/kerror/errors/index.d.ts +15 -15
- package/lib/kerror/errors/internalError.d.ts +1 -1
- package/lib/kerror/errors/kuzzleError.d.ts +1 -1
- package/lib/kerror/errors/multipleErrorsError.d.ts +1 -1
- package/lib/kerror/errors/multipleErrorsError.js +1 -1
- package/lib/kerror/errors/notFoundError.d.ts +1 -1
- package/lib/kerror/errors/partialError.d.ts +1 -1
- package/lib/kerror/errors/partialError.js +1 -1
- package/lib/kerror/errors/pluginImplementationError.d.ts +1 -1
- package/lib/kerror/errors/pluginImplementationError.js +2 -1
- package/lib/kerror/errors/preconditionError.d.ts +1 -1
- package/lib/kerror/errors/serviceUnavailableError.d.ts +1 -1
- package/lib/kerror/errors/sizeLimitError.d.ts +1 -1
- package/lib/kerror/errors/tooManyRequestsError.d.ts +1 -1
- package/lib/kerror/errors/unauthorizedError.d.ts +1 -1
- package/lib/kerror/index.d.ts +3 -3
- package/lib/kerror/index.js +17 -16
- package/lib/kuzzle/dumpGenerator.js +130 -114
- package/lib/kuzzle/event/kuzzleEventEmitter.js +96 -70
- package/lib/kuzzle/event/pipeRunner.js +25 -24
- package/lib/kuzzle/event/waterfall.js +13 -15
- package/lib/kuzzle/index.js +2 -2
- package/lib/kuzzle/internalIndexHandler.js +80 -59
- package/lib/kuzzle/kuzzle.js +99 -99
- package/lib/kuzzle/kuzzleStateEnum.js +1 -1
- package/lib/kuzzle/log.js +23 -18
- package/lib/kuzzle/vault.js +34 -19
- package/lib/model/security/profile.d.ts +3 -3
- package/lib/model/security/profile.js +38 -37
- package/lib/model/security/rights.js +5 -5
- package/lib/model/security/role.d.ts +3 -3
- package/lib/model/security/role.js +25 -26
- package/lib/model/security/token.d.ts +1 -1
- package/lib/model/security/token.js +4 -4
- package/lib/model/security/user.d.ts +2 -2
- package/lib/model/security/user.js +9 -9
- package/lib/model/storage/apiKey.js +43 -33
- package/lib/model/storage/baseModel.js +49 -45
- package/lib/service/cache/redis.js +60 -55
- package/lib/service/service.js +17 -17
- package/lib/service/storage/elasticsearch.js +839 -755
- package/lib/service/storage/esWrapper.js +103 -86
- package/lib/service/storage/queryTranslator.js +52 -59
- package/lib/types/Controller.d.ts +3 -3
- package/lib/types/ControllerDefinition.d.ts +3 -3
- package/lib/types/DebugModule.d.ts +2 -2
- package/lib/types/DebugModule.js +1 -1
- package/lib/types/Global.d.ts +1 -1
- package/lib/types/HttpStream.d.ts +2 -1
- package/lib/types/HttpStream.js +7 -5
- package/lib/types/Kuzzle.d.ts +1 -1
- package/lib/types/KuzzleDocument.d.ts +1 -1
- package/lib/types/OpenApiDefinition.d.ts +1 -1
- package/lib/types/PasswordPolicy.d.ts +1 -1
- package/lib/types/Plugin.d.ts +6 -6
- package/lib/types/Plugin.js +2 -2
- package/lib/types/Policy.d.ts +1 -1
- package/lib/types/RequestPayload.d.ts +1 -1
- package/lib/types/ResponsePayload.d.ts +1 -1
- package/lib/types/Token.d.ts +1 -1
- package/lib/types/User.d.ts +1 -1
- package/lib/types/config/DumpConfiguration.d.ts +8 -8
- package/lib/types/config/HttpConfiguration.d.ts +1 -1
- package/lib/types/config/KuzzleConfiguration.d.ts +1 -1
- package/lib/types/config/LimitsConfiguration.d.ts +8 -8
- package/lib/types/config/PluginsConfiguration.d.ts +4 -4
- package/lib/types/config/SecurityConfiguration.d.ts +62 -62
- package/lib/types/config/ServerConfiguration.d.ts +55 -55
- package/lib/types/config/ServicesConfiguration.d.ts +2 -2
- package/lib/types/config/internalCache/InternalCacheRedisConfiguration.d.ts +10 -10
- package/lib/types/config/publicCache/PublicCacheRedisConfiguration.d.ts +3 -3
- package/lib/types/config/storageEngine/StorageEngineElasticsearchConfiguration.d.ts +194 -110
- package/lib/types/errors/ErrorDefinition.d.ts +1 -1
- package/lib/types/errors/ErrorDomains.d.ts +1 -1
- package/lib/types/index.d.ts +38 -38
- package/lib/types/realtime/RealtimeScope.d.ts +1 -1
- package/lib/types/realtime/RealtimeUsers.d.ts +1 -1
- package/lib/util/assertType.js +13 -11
- package/lib/util/async.d.ts +1 -0
- package/lib/util/async.js +61 -0
- package/lib/util/asyncStore.js +19 -21
- package/lib/util/bufferedPassThrough.d.ts +2 -2
- package/lib/util/bufferedPassThrough.js +4 -4
- package/lib/util/bytes.js +9 -13
- package/lib/util/crypto.js +1 -1
- package/lib/util/debug.js +5 -5
- package/lib/util/deprecate.js +24 -21
- package/lib/util/didYouMean.js +7 -7
- package/lib/util/dump-collection.d.ts +2 -2
- package/lib/util/dump-collection.js +26 -26
- package/lib/util/esRequest.d.ts +1 -0
- package/lib/util/esRequest.js +62 -0
- package/lib/util/extractFields.js +24 -25
- package/lib/util/inflector.js +5 -5
- package/lib/util/koncordeCompat.d.ts +2 -2
- package/lib/util/koncordeCompat.js +5 -5
- package/lib/util/memoize.js +3 -5
- package/lib/util/mutex.d.ts +19 -1
- package/lib/util/mutex.js +39 -12
- package/lib/util/name-generator.js +1331 -1331
- package/lib/util/promback.js +8 -10
- package/lib/util/readYamlFile.d.ts +1 -1
- package/lib/util/readYamlFile.js +1 -1
- package/lib/util/requestAssertions.js +34 -34
- package/lib/util/safeObject.js +5 -5
- package/lib/util/stackTrace.js +20 -22
- package/lib/util/wildcard.js +15 -15
- package/package.json +6 -6
- package/npm-shrinkwrap.json +0 -19422
package/lib/util/asyncStore.js
CHANGED
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
* limitations under the License.
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
"use strict";
|
|
23
23
|
|
|
24
|
-
const assert = require(
|
|
25
|
-
const { AsyncLocalStorage } = require(
|
|
24
|
+
const assert = require("assert");
|
|
25
|
+
const { AsyncLocalStorage } = require("async_hooks");
|
|
26
26
|
|
|
27
27
|
class AsyncStore {
|
|
28
|
-
constructor
|
|
28
|
+
constructor() {
|
|
29
29
|
this._asyncLocalStorage = new AsyncLocalStorage();
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -34,7 +34,7 @@ class AsyncStore {
|
|
|
34
34
|
*
|
|
35
35
|
* @param {Function} callback
|
|
36
36
|
*/
|
|
37
|
-
run
|
|
37
|
+
run(callback) {
|
|
38
38
|
this._asyncLocalStorage.run(new Map(), callback);
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -42,7 +42,7 @@ class AsyncStore {
|
|
|
42
42
|
* Returns true if an async store exists
|
|
43
43
|
* for the current asynchronous context
|
|
44
44
|
*/
|
|
45
|
-
exists
|
|
45
|
+
exists() {
|
|
46
46
|
return Boolean(this._asyncLocalStorage.getStore());
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -52,7 +52,7 @@ class AsyncStore {
|
|
|
52
52
|
* @param {String} key
|
|
53
53
|
* @param {any} value
|
|
54
54
|
*/
|
|
55
|
-
set
|
|
55
|
+
set(key, value) {
|
|
56
56
|
return this._getStore().set(key, value);
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -63,7 +63,7 @@ class AsyncStore {
|
|
|
63
63
|
*
|
|
64
64
|
* @returns {any} value
|
|
65
65
|
*/
|
|
66
|
-
get
|
|
66
|
+
get(key) {
|
|
67
67
|
return this._getStore().get(key);
|
|
68
68
|
}
|
|
69
69
|
|
|
@@ -74,41 +74,39 @@ class AsyncStore {
|
|
|
74
74
|
*
|
|
75
75
|
* @returns {Boolean}
|
|
76
76
|
*/
|
|
77
|
-
has
|
|
77
|
+
has(key) {
|
|
78
78
|
return this._getStore().has(key);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
_getStore
|
|
81
|
+
_getStore() {
|
|
82
82
|
const store = this._asyncLocalStorage.getStore();
|
|
83
83
|
|
|
84
|
-
assert(Boolean(store),
|
|
84
|
+
assert(Boolean(store), "Associated AsyncStore is not set");
|
|
85
85
|
|
|
86
86
|
return store;
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
|
|
91
90
|
class AsyncStoreStub {
|
|
92
|
-
constructor
|
|
91
|
+
constructor() {}
|
|
93
92
|
|
|
94
|
-
run
|
|
93
|
+
run(callback) {
|
|
95
94
|
callback();
|
|
96
95
|
}
|
|
97
96
|
|
|
98
|
-
exists
|
|
97
|
+
exists() {
|
|
99
98
|
return false;
|
|
100
99
|
}
|
|
101
100
|
|
|
102
|
-
set
|
|
101
|
+
set() {}
|
|
103
102
|
|
|
104
|
-
get
|
|
103
|
+
get() {}
|
|
105
104
|
|
|
106
|
-
has
|
|
105
|
+
has() {}
|
|
107
106
|
}
|
|
108
107
|
|
|
109
|
-
if (process.version >=
|
|
108
|
+
if (process.version >= "v12.18.1") {
|
|
110
109
|
module.exports = AsyncStore;
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
110
|
+
} else {
|
|
113
111
|
module.exports = AsyncStoreStub;
|
|
114
112
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import stream from
|
|
3
|
-
declare type Encoding = BufferEncoding |
|
|
2
|
+
import stream from "stream";
|
|
3
|
+
declare type Encoding = BufferEncoding | "buffer";
|
|
4
4
|
declare type ChunkData = Buffer | string;
|
|
5
5
|
declare type Chunk = {
|
|
6
6
|
chunk: ChunkData;
|
|
@@ -50,7 +50,7 @@ class BufferedPassThrough extends stream_1.default.Duplex {
|
|
|
50
50
|
* @returns How many bytes have been copied / written to the internal buffer.
|
|
51
51
|
*/
|
|
52
52
|
writeToBuffer(data, start, end, encoding) {
|
|
53
|
-
if (encoding ===
|
|
53
|
+
if (encoding === "buffer") {
|
|
54
54
|
return data.copy(this.buffer, this.offset, start, end);
|
|
55
55
|
}
|
|
56
56
|
if (start === 0 && end === data.length) {
|
|
@@ -80,8 +80,8 @@ class BufferedPassThrough extends stream_1.default.Duplex {
|
|
|
80
80
|
chunkOffset += this.writeToBuffer(chunk, chunkOffset, chunkOffset + remainingBufferSize, encoding);
|
|
81
81
|
// Sends the whole buffer to the stream since it is full
|
|
82
82
|
if (!this.push(this.buffer)) {
|
|
83
|
-
await new Promise(res => {
|
|
84
|
-
this.once(
|
|
83
|
+
await new Promise((res) => {
|
|
84
|
+
this.once("_drained", res);
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
87
|
this.offset = 0; // Reset the offset
|
|
@@ -125,7 +125,7 @@ class BufferedPassThrough extends stream_1.default.Duplex {
|
|
|
125
125
|
*/
|
|
126
126
|
_read() {
|
|
127
127
|
// Emits an internal _drained event when the internal buffer is drained.
|
|
128
|
-
this.emit(
|
|
128
|
+
this.emit("_drained");
|
|
129
129
|
}
|
|
130
130
|
/**
|
|
131
131
|
* @override from stream.Duplex
|
package/lib/util/bytes.js
CHANGED
|
@@ -1,30 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
function bytes
|
|
4
|
-
if (typeof input ===
|
|
3
|
+
function bytes(input) {
|
|
4
|
+
if (typeof input === "number") {
|
|
5
5
|
return input;
|
|
6
|
-
}
|
|
7
|
-
else if (typeof input !== 'string') {
|
|
6
|
+
} else if (typeof input !== "string") {
|
|
8
7
|
return null;
|
|
9
8
|
}
|
|
10
9
|
|
|
11
10
|
let unit = 1;
|
|
12
|
-
if (input.toLowerCase().includes(
|
|
11
|
+
if (input.toLowerCase().includes("kb")) {
|
|
13
12
|
unit = 1024;
|
|
14
|
-
}
|
|
15
|
-
else if (input.toLowerCase().includes('mb')) {
|
|
13
|
+
} else if (input.toLowerCase().includes("mb")) {
|
|
16
14
|
unit = 1024 ** 2;
|
|
17
|
-
}
|
|
18
|
-
else if (input.toLowerCase().includes('gb')) {
|
|
15
|
+
} else if (input.toLowerCase().includes("gb")) {
|
|
19
16
|
unit = 1024 ** 3;
|
|
20
|
-
}
|
|
21
|
-
else if (input.toLowerCase().includes('tb')) {
|
|
17
|
+
} else if (input.toLowerCase().includes("tb")) {
|
|
22
18
|
unit = 1024 ** 4;
|
|
23
19
|
}
|
|
24
20
|
|
|
25
21
|
const match = input.match(/\d+/);
|
|
26
22
|
|
|
27
|
-
if (!
|
|
23
|
+
if (!match) {
|
|
28
24
|
return null;
|
|
29
25
|
}
|
|
30
26
|
|
package/lib/util/crypto.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.sha256 = void 0;
|
|
7
7
|
const crypto_1 = __importDefault(require("crypto"));
|
|
8
8
|
function sha256(string) {
|
|
9
|
-
return crypto_1.default.createHash(
|
|
9
|
+
return crypto_1.default.createHash("sha256").update(string).digest("hex");
|
|
10
10
|
}
|
|
11
11
|
exports.sha256 = sha256;
|
|
12
12
|
//# sourceMappingURL=crypto.js.map
|
package/lib/util/debug.js
CHANGED
|
@@ -19,19 +19,19 @@
|
|
|
19
19
|
* limitations under the License.
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
"use strict";
|
|
23
23
|
|
|
24
|
-
const debug = require(
|
|
25
|
-
const util = require(
|
|
24
|
+
const debug = require("debug");
|
|
25
|
+
const util = require("util");
|
|
26
26
|
|
|
27
|
-
debug.formatters.a = value => {
|
|
27
|
+
debug.formatters.a = (value) => {
|
|
28
28
|
const inspectOpts = debug.inspectOpts;
|
|
29
29
|
|
|
30
30
|
if (inspectOpts.expand) {
|
|
31
31
|
return `\n${util.inspect(value, inspectOpts)}`;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
return util.inspect(value, inspectOpts).replace(/\s*\n\s*/g,
|
|
34
|
+
return util.inspect(value, inspectOpts).replace(/\s*\n\s*/g, " ");
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
module.exports = debug;
|
package/lib/util/deprecate.js
CHANGED
|
@@ -19,45 +19,48 @@
|
|
|
19
19
|
* limitations under the License.
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
"use strict";
|
|
23
23
|
|
|
24
24
|
const deprecationWarning = (logger, ...args) => {
|
|
25
|
-
if (global.NODE_ENV ===
|
|
26
|
-
logger.warn(
|
|
25
|
+
if (global.NODE_ENV === "development") {
|
|
26
|
+
logger.warn("DEPRECATION WARNING");
|
|
27
27
|
logger.warn(...args);
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
const warnIfDeprecated = (logger, deprecations, member) => {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
.find(deprecated => deprecated === member),
|
|
32
|
+
const deprecatedProperty = Object.keys(deprecations).find(
|
|
33
|
+
(deprecated) => deprecated === member
|
|
34
|
+
),
|
|
36
35
|
alternative = deprecations[deprecatedProperty];
|
|
37
36
|
|
|
38
|
-
if (!
|
|
37
|
+
if (!deprecatedProperty) {
|
|
39
38
|
return;
|
|
40
39
|
}
|
|
41
40
|
|
|
42
|
-
if (alternative && typeof alternative.message ===
|
|
41
|
+
if (alternative && typeof alternative.message === "string") {
|
|
43
42
|
deprecationWarning(logger, alternative.message);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
} else if (typeof alternative === "string") {
|
|
44
|
+
deprecationWarning(
|
|
45
|
+
logger,
|
|
46
|
+
`Use of '${deprecatedProperty}' property is deprecated. Please, use '${alternative}' instead.`
|
|
47
|
+
);
|
|
48
|
+
} else {
|
|
49
|
+
deprecationWarning(
|
|
50
|
+
logger,
|
|
51
|
+
`Use of '${deprecatedProperty}' property is deprecated.`
|
|
52
|
+
);
|
|
50
53
|
}
|
|
51
54
|
};
|
|
52
55
|
|
|
53
56
|
const deprecateProperties = (logger, target, deprecations = {}) => {
|
|
54
|
-
if (global.NODE_ENV !==
|
|
57
|
+
if (global.NODE_ENV !== "development") {
|
|
55
58
|
return target;
|
|
56
59
|
}
|
|
57
60
|
|
|
58
61
|
return new Proxy(target, {
|
|
59
|
-
get
|
|
60
|
-
if (key ===
|
|
62
|
+
get(object, key, ...rest) {
|
|
63
|
+
if (key === "__isProxy") {
|
|
61
64
|
return true;
|
|
62
65
|
}
|
|
63
66
|
|
|
@@ -66,14 +69,14 @@ const deprecateProperties = (logger, target, deprecations = {}) => {
|
|
|
66
69
|
return Reflect.get(object, key, ...rest);
|
|
67
70
|
},
|
|
68
71
|
|
|
69
|
-
set
|
|
72
|
+
set(object, key, ...rest) {
|
|
70
73
|
warnIfDeprecated(logger, deprecations, key);
|
|
71
74
|
|
|
72
75
|
return Reflect.set(object, key, ...rest);
|
|
73
|
-
}
|
|
76
|
+
},
|
|
74
77
|
});
|
|
75
78
|
};
|
|
76
79
|
|
|
77
80
|
module.exports = {
|
|
78
|
-
deprecateProperties
|
|
81
|
+
deprecateProperties,
|
|
79
82
|
};
|
package/lib/util/didYouMean.js
CHANGED
|
@@ -19,19 +19,19 @@
|
|
|
19
19
|
* limitations under the License.
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
"use strict";
|
|
23
23
|
|
|
24
|
-
const didYouMean = require(
|
|
24
|
+
const didYouMean = require("didyoumean");
|
|
25
25
|
|
|
26
|
-
function printDidYouMean
|
|
27
|
-
if (global.NODE_ENV !==
|
|
28
|
-
return
|
|
26
|
+
function printDidYouMean(...args) {
|
|
27
|
+
if (global.NODE_ENV !== "development") {
|
|
28
|
+
return "";
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
const result = didYouMean(...args);
|
|
32
32
|
|
|
33
|
-
if (!
|
|
34
|
-
return
|
|
33
|
+
if (!result) {
|
|
34
|
+
return "";
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
return ` Did you mean "${result}"?`;
|
|
@@ -62,8 +62,8 @@ function flattenStep(output, object, prev = null) {
|
|
|
62
62
|
for (let i = 0; i < keys.length; i++) {
|
|
63
63
|
const key = keys[i];
|
|
64
64
|
const value = object[key];
|
|
65
|
-
const newKey = prev ? prev +
|
|
66
|
-
if (Object.prototype.toString.call(value) ===
|
|
65
|
+
const newKey = prev ? prev + "." + key : key;
|
|
66
|
+
if (Object.prototype.toString.call(value) === "[object Object]") {
|
|
67
67
|
flattenStep(output, value, newKey);
|
|
68
68
|
continue;
|
|
69
69
|
}
|
|
@@ -101,7 +101,7 @@ exports.extractMappingFields = extractMappingFields;
|
|
|
101
101
|
* @see https://lodash.com/docs/4.17.15#values
|
|
102
102
|
*/
|
|
103
103
|
function pickValues(object, fields) {
|
|
104
|
-
return fields.map(f => formatValueForCSV((0, get_1.default)(object, f)));
|
|
104
|
+
return fields.map((f) => formatValueForCSV((0, get_1.default)(object, f)));
|
|
105
105
|
}
|
|
106
106
|
exports.pickValues = pickValues;
|
|
107
107
|
/**
|
|
@@ -113,15 +113,15 @@ exports.pickValues = pickValues;
|
|
|
113
113
|
*/
|
|
114
114
|
function formatValueForCSV(value) {
|
|
115
115
|
if ((0, isObject_1.default)(value)) {
|
|
116
|
-
return
|
|
116
|
+
return "[OBJECT]";
|
|
117
117
|
}
|
|
118
118
|
return value;
|
|
119
119
|
}
|
|
120
120
|
class AbstractDumper {
|
|
121
121
|
constructor(index, collection, query = {}, writeStream, options = {
|
|
122
122
|
fieldsName: {},
|
|
123
|
-
scroll:
|
|
124
|
-
separator:
|
|
123
|
+
scroll: "5s",
|
|
124
|
+
separator: ",",
|
|
125
125
|
size: 10,
|
|
126
126
|
}) {
|
|
127
127
|
this.index = index;
|
|
@@ -130,7 +130,7 @@ class AbstractDumper {
|
|
|
130
130
|
this.writeStream = writeStream;
|
|
131
131
|
this.options = options;
|
|
132
132
|
if (!writeStream) {
|
|
133
|
-
throw kerror.get(
|
|
133
|
+
throw kerror.get("api", "assert", "missing_argument", "writeStream");
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
/**
|
|
@@ -154,7 +154,7 @@ class AbstractDumper {
|
|
|
154
154
|
return null;
|
|
155
155
|
}
|
|
156
156
|
try {
|
|
157
|
-
return await global.kuzzle.ask(
|
|
157
|
+
return await global.kuzzle.ask("core:storage:public:document:scroll", scrollId, { scrollTTL: this.options.scroll });
|
|
158
158
|
}
|
|
159
159
|
catch {
|
|
160
160
|
return null;
|
|
@@ -167,13 +167,13 @@ class AbstractDumper {
|
|
|
167
167
|
* @returns a promise resolving when the dump is finished.
|
|
168
168
|
*/
|
|
169
169
|
async dump() {
|
|
170
|
-
const waitWrite = new Promise((resolve, reject) => this.writeStream ? this.writeStream.on(
|
|
171
|
-
this.writeStream.on(
|
|
170
|
+
const waitWrite = new Promise((resolve, reject) => this.writeStream ? this.writeStream.on("finish", resolve) : reject());
|
|
171
|
+
this.writeStream.on("error", (error) => {
|
|
172
172
|
throw error;
|
|
173
173
|
});
|
|
174
174
|
await this.setup();
|
|
175
175
|
await this.writeHeader();
|
|
176
|
-
let results = await global.kuzzle.ask(
|
|
176
|
+
let results = await global.kuzzle.ask("core:storage:public:document:search", this.index, this.collection, this.query, {
|
|
177
177
|
lang: this.options.lang,
|
|
178
178
|
scroll: this.options.scroll,
|
|
179
179
|
size: this.options.size,
|
|
@@ -182,7 +182,7 @@ class AbstractDumper {
|
|
|
182
182
|
for (const hit of results.hits) {
|
|
183
183
|
await this.onResult({
|
|
184
184
|
_id: hit._id,
|
|
185
|
-
_source: hit._source
|
|
185
|
+
_source: hit._source,
|
|
186
186
|
});
|
|
187
187
|
}
|
|
188
188
|
} while ((results = await this.scroll(results.scrollId)));
|
|
@@ -197,7 +197,7 @@ class JSONLDumper extends AbstractDumper {
|
|
|
197
197
|
this.ndjsonStream = ndjson_1.default.stringify();
|
|
198
198
|
}
|
|
199
199
|
async setup() {
|
|
200
|
-
this.ndjsonStream.on(
|
|
200
|
+
this.ndjsonStream.on("data", (line) => {
|
|
201
201
|
this.writeStream.write(line);
|
|
202
202
|
});
|
|
203
203
|
}
|
|
@@ -205,16 +205,16 @@ class JSONLDumper extends AbstractDumper {
|
|
|
205
205
|
await this.writeLine({
|
|
206
206
|
collection: this.collection,
|
|
207
207
|
index: this.index,
|
|
208
|
-
type:
|
|
208
|
+
type: "collection",
|
|
209
209
|
});
|
|
210
210
|
}
|
|
211
211
|
writeLine(content) {
|
|
212
|
-
return new Promise(resolve => {
|
|
212
|
+
return new Promise((resolve) => {
|
|
213
213
|
if (this.ndjsonStream.write(content)) {
|
|
214
214
|
resolve();
|
|
215
215
|
}
|
|
216
216
|
else {
|
|
217
|
-
this.ndjsonStream.once(
|
|
217
|
+
this.ndjsonStream.once("drain", resolve);
|
|
218
218
|
}
|
|
219
219
|
});
|
|
220
220
|
}
|
|
@@ -225,7 +225,7 @@ class JSONLDumper extends AbstractDumper {
|
|
|
225
225
|
});
|
|
226
226
|
}
|
|
227
227
|
get fileExtension() {
|
|
228
|
-
return
|
|
228
|
+
return "jsonl";
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
231
|
class CSVDumper extends AbstractDumper {
|
|
@@ -234,36 +234,36 @@ class CSVDumper extends AbstractDumper {
|
|
|
234
234
|
this.fields = fields;
|
|
235
235
|
}
|
|
236
236
|
get fileExtension() {
|
|
237
|
-
return
|
|
237
|
+
return "csv";
|
|
238
238
|
}
|
|
239
239
|
async setup() {
|
|
240
240
|
if (!this.fields.length) {
|
|
241
241
|
// If no field has been selected, then all fields are selected.
|
|
242
|
-
const mappings = await global.kuzzle.ask(
|
|
242
|
+
const mappings = await global.kuzzle.ask("core:storage:public:mappings:get", this.index, this.collection);
|
|
243
243
|
if (!mappings.properties) {
|
|
244
244
|
return;
|
|
245
245
|
}
|
|
246
246
|
this.fields = Object.keys(flattenObject(extractMappingFields(mappings.properties)));
|
|
247
247
|
}
|
|
248
|
-
else if (this.fields.includes(
|
|
248
|
+
else if (this.fields.includes("_id")) {
|
|
249
249
|
// Delete '_id' from the selected fields, since IDs are
|
|
250
250
|
// _always_ exported.
|
|
251
|
-
this.fields.splice(this.fields.indexOf(
|
|
251
|
+
this.fields.splice(this.fields.indexOf("_id"), 1);
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
254
|
writeHeader() {
|
|
255
|
-
const mappedFieldsName = [
|
|
255
|
+
const mappedFieldsName = ["_id", ...this.fields].map((field) => {
|
|
256
256
|
return this.options.fieldsName[field] || field;
|
|
257
257
|
});
|
|
258
258
|
return this.writeLine(mappedFieldsName.join(this.options.separator));
|
|
259
259
|
}
|
|
260
260
|
writeLine(content) {
|
|
261
|
-
return new Promise(resolve => {
|
|
261
|
+
return new Promise((resolve) => {
|
|
262
262
|
if (this.writeStream.write(`${content}\n`)) {
|
|
263
263
|
resolve();
|
|
264
264
|
}
|
|
265
265
|
else {
|
|
266
|
-
this.writeStream.once(
|
|
266
|
+
this.writeStream.once("drain", resolve);
|
|
267
267
|
}
|
|
268
268
|
});
|
|
269
269
|
}
|
|
@@ -272,11 +272,11 @@ class CSVDumper extends AbstractDumper {
|
|
|
272
272
|
return this.writeLine(values.join(this.options.separator));
|
|
273
273
|
}
|
|
274
274
|
}
|
|
275
|
-
function dumpCollectionDocuments(index, collection, query = {}, format =
|
|
275
|
+
function dumpCollectionDocuments(index, collection, query = {}, format = "jsonl", fields = [], options = {}) {
|
|
276
276
|
let dumper;
|
|
277
277
|
const writableStream = new bufferedPassThrough_1.BufferedPassThrough({ highWaterMark: 16384 });
|
|
278
278
|
switch (format.toLowerCase()) {
|
|
279
|
-
case
|
|
279
|
+
case "csv":
|
|
280
280
|
dumper = new CSVDumper(index, collection, query, writableStream, options, fields);
|
|
281
281
|
dumper.dump();
|
|
282
282
|
break;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getESIndexDynamicSettings(requestSettings: object): object;
|
|
@@ -0,0 +1,62 @@
|
|
|
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.getESIndexDynamicSettings = void 0;
|
|
27
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
28
|
+
// Dynamic index settings specified in the elasticsearch documentation :
|
|
29
|
+
// https://www.elastic.co/guide/en/elasticsearch/reference/7.5/index-modules.html#index-modules-settings
|
|
30
|
+
const dynamicESSettings = [
|
|
31
|
+
"number_of_replicas",
|
|
32
|
+
"search",
|
|
33
|
+
"search.idle.after",
|
|
34
|
+
"refresh_interval",
|
|
35
|
+
"max_result_window",
|
|
36
|
+
"max_inner_result_window",
|
|
37
|
+
"max_rescore_window",
|
|
38
|
+
"max_docvalue_fields_search",
|
|
39
|
+
"max_script_fields",
|
|
40
|
+
"max_ngram_diff",
|
|
41
|
+
"max_shingle_diff",
|
|
42
|
+
"blocks",
|
|
43
|
+
"blocks.read_only",
|
|
44
|
+
"blocks.read_only_allow_delete",
|
|
45
|
+
"blocks.read",
|
|
46
|
+
"blocks.write",
|
|
47
|
+
"blocks.metadata",
|
|
48
|
+
"max_refresh_listeners",
|
|
49
|
+
"highlight.max_analyzed_offset",
|
|
50
|
+
"max_terms_count",
|
|
51
|
+
"max_regex_length",
|
|
52
|
+
"routing.allocation.enable",
|
|
53
|
+
"routing.rebalance.enable",
|
|
54
|
+
"gc_deletes",
|
|
55
|
+
"default_pipeline",
|
|
56
|
+
"final_pipeline",
|
|
57
|
+
];
|
|
58
|
+
function getESIndexDynamicSettings(requestSettings) {
|
|
59
|
+
return lodash_1.default.pick(requestSettings, dynamicESSettings);
|
|
60
|
+
}
|
|
61
|
+
exports.getESIndexDynamicSettings = getESIndexDynamicSettings;
|
|
62
|
+
//# sourceMappingURL=esRequest.js.map
|
|
@@ -19,29 +19,28 @@
|
|
|
19
19
|
* limitations under the License.
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
"use strict";
|
|
23
23
|
|
|
24
|
-
const { isPlainObject } = require(
|
|
24
|
+
const { isPlainObject } = require("./safeObject");
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
* Extract nested fields of an object in a flat array.
|
|
28
|
-
* Example: { field : { 1: "nested", 2: "nested" } } => [ 'field.1', 'field.2' ]
|
|
29
|
-
*
|
|
30
|
-
* @param {Object} document - Document to extract fields from
|
|
31
|
-
* @param {Object} options - alsoExtractValues (false), fieldsToIgnore ( [ ] )
|
|
32
|
-
*
|
|
33
|
-
* @returns { Array<String> | Array<{ key: String, value: any }> }
|
|
34
|
-
*/
|
|
35
|
-
function extractFields
|
|
36
|
-
|
|
37
|
-
alsoExtractValues = false,
|
|
38
|
-
} = {}
|
|
39
|
-
|
|
40
|
-
extractedFields = []
|
|
41
|
-
} = {}) {
|
|
27
|
+
* Extract nested fields of an object in a flat array.
|
|
28
|
+
* Example: { field : { 1: "nested", 2: "nested" } } => [ 'field.1', 'field.2' ]
|
|
29
|
+
*
|
|
30
|
+
* @param {Object} document - Document to extract fields from
|
|
31
|
+
* @param {Object} options - alsoExtractValues (false), fieldsToIgnore ( [ ] )
|
|
32
|
+
*
|
|
33
|
+
* @returns { Array<String> | Array<{ key: String, value: any }> }
|
|
34
|
+
*/
|
|
35
|
+
function extractFields(
|
|
36
|
+
document,
|
|
37
|
+
{ fieldsToIgnore = [], alsoExtractValues = false } = {},
|
|
38
|
+
{ path = null, extractedFields = [] } = {}
|
|
39
|
+
) {
|
|
42
40
|
for (const [key, value] of Object.entries(document)) {
|
|
43
|
-
if (
|
|
44
|
-
|
|
41
|
+
if (
|
|
42
|
+
fieldsToIgnore.length &&
|
|
43
|
+
fieldsToIgnore.find((keyToIgnore) => keyToIgnore === key)
|
|
45
44
|
) {
|
|
46
45
|
continue;
|
|
47
46
|
}
|
|
@@ -49,14 +48,14 @@ function extractFields (document, {
|
|
|
49
48
|
const currentPath = path ? `${path}.${key}` : key;
|
|
50
49
|
|
|
51
50
|
if (isPlainObject(value)) {
|
|
52
|
-
extractFields(
|
|
51
|
+
extractFields(
|
|
52
|
+
value,
|
|
53
53
|
{ alsoExtractValues, fieldsToIgnore },
|
|
54
|
-
{ extractedFields, path: currentPath }
|
|
55
|
-
|
|
56
|
-
else if (alsoExtractValues) {
|
|
54
|
+
{ extractedFields, path: currentPath }
|
|
55
|
+
);
|
|
56
|
+
} else if (alsoExtractValues) {
|
|
57
57
|
extractedFields.push({ key: currentPath, value });
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
58
|
+
} else {
|
|
60
59
|
extractedFields.push(currentPath);
|
|
61
60
|
}
|
|
62
61
|
}
|