kuzzle 2.56.0 → 2.57.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/copy-binaries.js +71 -4
- package/dist/bin/start-kuzzle-server +191 -97
- package/dist/index.d.ts +31 -1
- package/dist/index.js +45 -2
- package/dist/lib/api/controllers/adminController.d.ts +4 -3
- package/dist/lib/api/controllers/adminController.js +1 -2
- package/dist/lib/api/controllers/authController.d.ts +37 -16
- package/dist/lib/api/controllers/authController.js +88 -39
- package/dist/lib/api/controllers/baseController.d.ts +10 -5
- package/dist/lib/api/controllers/baseController.js +36 -15
- package/dist/lib/api/controllers/bulkController.d.ts +11 -7
- package/dist/lib/api/controllers/bulkController.js +28 -5
- package/dist/lib/api/controllers/clusterController.d.ts +2 -2
- package/dist/lib/api/controllers/clusterController.js +3 -3
- package/dist/lib/api/controllers/collectionController.d.ts +57 -21
- package/dist/lib/api/controllers/collectionController.js +40 -11
- package/dist/lib/api/controllers/debugController.d.ts +1 -1
- package/dist/lib/api/controllers/documentController.d.ts +137 -28
- package/dist/lib/api/controllers/documentController.js +156 -125
- package/dist/lib/api/controllers/index.d.ts +27 -12
- package/dist/lib/api/controllers/index.js +28 -13
- package/dist/lib/api/controllers/indexController.d.ts +17 -10
- package/dist/lib/api/controllers/indexController.js +13 -11
- package/dist/lib/api/controllers/memoryStorageController.d.ts +2 -5
- package/dist/lib/api/controllers/memoryStorageController.js +199 -127
- package/dist/lib/api/controllers/realtimeController.d.ts +19 -9
- package/dist/lib/api/controllers/realtimeController.js +8 -4
- package/dist/lib/api/controllers/securityController.d.ts +42 -29
- package/dist/lib/api/controllers/securityController.js +35 -19
- package/dist/lib/api/controllers/serverController.d.ts +114 -19
- package/dist/lib/api/controllers/serverController.js +69 -29
- package/dist/lib/api/documentExtractor.d.ts +9 -7
- package/dist/lib/api/documentExtractor.js +105 -41
- package/dist/lib/api/funnel.d.ts +131 -29
- package/dist/lib/api/funnel.js +436 -225
- package/dist/lib/api/httpRoutes.d.ts +16 -11
- package/dist/lib/api/httpRoutes.js +272 -2
- package/dist/lib/api/openapi/OpenApiManager.d.ts +1 -1
- package/dist/lib/api/openapi/openApiGenerator.d.ts +1 -1
- package/dist/lib/api/rateLimiter.d.ts +15 -5
- package/dist/lib/api/rateLimiter.js +42 -14
- package/dist/lib/api/request/kuzzleRequest.d.ts +83 -12
- package/dist/lib/api/request/kuzzleRequest.js +88 -23
- package/dist/lib/api/request/requestContext.d.ts +20 -5
- package/dist/lib/api/request/requestContext.js +14 -4
- package/dist/lib/api/request/requestInput.d.ts +37 -6
- package/dist/lib/api/request/requestInput.js +22 -9
- package/dist/lib/api/request/requestResponse.d.ts +45 -9
- package/dist/lib/api/request/requestResponse.js +34 -3
- package/dist/lib/cluster/command.d.ts +131 -37
- package/dist/lib/cluster/command.js +243 -71
- package/dist/lib/cluster/idCardHandler.d.ts +18 -5
- package/dist/lib/cluster/idCardHandler.js +52 -19
- package/dist/lib/cluster/index.d.ts +8 -2
- package/dist/lib/cluster/index.js +6 -2
- package/dist/lib/cluster/node.d.ts +127 -49
- package/dist/lib/cluster/node.js +412 -179
- package/dist/lib/cluster/protobuf/command.proto +18 -0
- package/dist/lib/cluster/protobuf/commandMessages.d.ts +104 -0
- package/dist/lib/cluster/protobuf/commandMessages.js +30 -0
- package/dist/lib/cluster/protobuf/syncMessages.d.ts +184 -0
- package/dist/lib/cluster/protobuf/syncMessages.js +23 -0
- package/dist/lib/cluster/publisher.d.ts +118 -78
- package/dist/lib/cluster/publisher.js +174 -72
- package/dist/lib/cluster/state.d.ts +15 -9
- package/dist/lib/cluster/state.js +12 -8
- package/dist/lib/cluster/subscriber.d.ts +185 -131
- package/dist/lib/cluster/subscriber.js +357 -95
- package/dist/lib/cluster/workers/IDCardRenewer.d.ts +39 -8
- package/dist/lib/cluster/workers/IDCardRenewer.js +88 -23
- package/dist/lib/config/default.config.d.ts +2 -2
- package/dist/lib/config/default.config.js +10 -3
- package/dist/lib/config/documentEventAliases.d.ts +1 -1
- package/dist/lib/config/index.d.ts +2 -5
- package/dist/lib/config/index.js +30 -17
- package/dist/lib/core/auth/formatProcessing.d.ts +3 -3
- package/dist/lib/core/auth/passportResponse.d.ts +1 -1
- package/dist/lib/core/auth/passportWrapper.d.ts +1 -1
- package/dist/lib/core/auth/passportWrapper.js +14 -13
- package/dist/lib/core/auth/tokenManager.d.ts +24 -3
- package/dist/lib/core/auth/tokenManager.js +47 -19
- package/dist/lib/core/backend/applicationManager.d.ts +2 -2
- package/dist/lib/core/backend/backend.d.ts +16 -5
- package/dist/lib/core/backend/backend.js +14 -6
- package/dist/lib/core/backend/backendCluster.d.ts +1 -1
- package/dist/lib/core/backend/backendConfig.d.ts +17 -5
- package/dist/lib/core/backend/backendConfig.js +1 -0
- package/dist/lib/core/backend/backendController.d.ts +1 -1
- package/dist/lib/core/backend/backendController.js +8 -1
- package/dist/lib/core/backend/backendErrors.d.ts +15 -8
- package/dist/lib/core/backend/backendErrors.js +5 -0
- package/dist/lib/core/backend/backendHook.d.ts +1 -1
- package/dist/lib/core/backend/backendImport.d.ts +1 -1
- package/dist/lib/core/backend/backendOpenApi.d.ts +3 -2
- package/dist/lib/core/backend/backendPipe.d.ts +1 -1
- package/dist/lib/core/backend/backendPipe.js +9 -1
- package/dist/lib/core/backend/backendPlugin.d.ts +2 -2
- package/dist/lib/core/backend/backendSubscription.d.ts +2 -2
- package/dist/lib/core/backend/backendVault.d.ts +1 -1
- package/dist/lib/core/backend/backendVault.js +8 -1
- package/dist/lib/core/cache/cacheEngine.d.ts +7 -4
- package/dist/lib/core/cache/cacheEngine.js +25 -8
- package/dist/lib/core/debug/kuzzleDebugger.d.ts +2 -1
- package/dist/lib/core/debug/kuzzleDebugger.js +31 -17
- package/dist/lib/core/network/accessLogger.d.ts +33 -18
- package/dist/lib/core/network/accessLogger.js +135 -73
- package/dist/lib/core/network/clientConnection.d.ts +13 -11
- package/dist/lib/core/network/clientConnection.js +33 -9
- package/dist/lib/core/network/context.d.ts +17 -22
- package/dist/lib/core/network/context.js +43 -26
- package/dist/lib/core/network/entryPoint.d.ts +38 -16
- package/dist/lib/core/network/entryPoint.js +119 -48
- package/dist/lib/core/network/httpRouter/index.d.ts +20 -50
- package/dist/lib/core/network/httpRouter/index.js +61 -75
- package/dist/lib/core/network/httpRouter/routeHandler.d.ts +17 -32
- package/dist/lib/core/network/httpRouter/routeHandler.js +26 -36
- package/dist/lib/core/network/httpRouter/routePart.d.ts +9 -18
- package/dist/lib/core/network/httpRouter/routePart.js +61 -43
- package/dist/lib/core/network/httpRouter/routeTypes.d.ts +3 -0
- package/dist/lib/core/network/httpRouter/routeTypes.js +23 -0
- package/dist/lib/core/network/networkEntryPoint.d.ts +20 -0
- package/dist/lib/core/network/networkEntryPoint.js +23 -0
- package/dist/lib/core/network/protocolManifest.d.ts +5 -4
- package/dist/lib/core/network/protocolManifest.js +6 -3
- package/dist/lib/core/network/protocols/httpMessage.d.ts +25 -18
- package/dist/lib/core/network/protocols/httpMessage.js +14 -11
- package/dist/lib/core/network/protocols/httpwsProtocol.d.ts +84 -93
- package/dist/lib/core/network/protocols/httpwsProtocol.js +284 -129
- package/dist/lib/core/network/protocols/internalProtocol.d.ts +26 -15
- package/dist/lib/core/network/protocols/internalProtocol.js +17 -16
- package/dist/lib/core/network/protocols/mqttProtocol.d.ts +56 -32
- package/dist/lib/core/network/protocols/mqttProtocol.js +91 -44
- package/dist/lib/core/network/protocols/protocol.d.ts +85 -21
- package/dist/lib/core/network/protocols/protocol.js +83 -27
- package/dist/lib/core/network/router.d.ts +13 -22
- package/dist/lib/core/network/router.js +59 -46
- package/dist/lib/core/plugin/plugin.d.ts +57 -51
- package/dist/lib/core/plugin/plugin.js +218 -103
- package/dist/lib/core/plugin/pluginContext.d.ts +54 -11
- package/dist/lib/core/plugin/pluginContext.js +99 -58
- package/dist/lib/core/plugin/pluginManifest.d.ts +6 -2
- package/dist/lib/core/plugin/pluginManifest.js +18 -11
- package/dist/lib/core/plugin/pluginRepository.d.ts +35 -44
- package/dist/lib/core/plugin/pluginRepository.js +35 -50
- package/dist/lib/core/plugin/pluginsManager.d.ts +128 -46
- package/dist/lib/core/plugin/pluginsManager.js +468 -231
- package/dist/lib/core/plugin/privilegedContext.d.ts +4 -9
- package/dist/lib/core/plugin/privilegedContext.js +5 -10
- package/dist/lib/core/realtime/actionEnum.d.ts +12 -21
- package/dist/lib/core/realtime/actionEnum.js +6 -7
- package/dist/lib/core/realtime/channel.d.ts +11 -5
- package/dist/lib/core/realtime/channel.js +17 -2
- package/dist/lib/core/realtime/connectionRooms.d.ts +2 -2
- package/dist/lib/core/realtime/hotelClerk.d.ts +12 -6
- package/dist/lib/core/realtime/hotelClerk.js +29 -11
- package/dist/lib/core/realtime/index.d.ts +8 -3
- package/dist/lib/core/realtime/index.js +12 -5
- package/dist/lib/core/realtime/notification/document.d.ts +54 -25
- package/dist/lib/core/realtime/notification/document.js +10 -13
- package/dist/lib/core/realtime/notification/index.d.ts +9 -3
- package/dist/lib/core/realtime/notification/index.js +10 -4
- package/dist/lib/core/realtime/notification/server.d.ts +7 -10
- package/dist/lib/core/realtime/notification/server.js +4 -7
- package/dist/lib/core/realtime/notification/user.d.ts +45 -21
- package/dist/lib/core/realtime/notification/user.js +8 -9
- package/dist/lib/core/realtime/notifier.d.ts +52 -40
- package/dist/lib/core/realtime/notifier.js +60 -25
- package/dist/lib/core/realtime/room.d.ts +1 -1
- package/dist/lib/core/realtime/subscription.d.ts +11 -6
- package/dist/lib/core/realtime/subscription.js +5 -1
- package/dist/lib/core/security/index.d.ts +14 -6
- package/dist/lib/core/security/index.js +27 -13
- package/dist/lib/core/security/profileRepository.d.ts +24 -19
- package/dist/lib/core/security/profileRepository.js +23 -10
- package/dist/lib/core/security/roleRepository.d.ts +60 -23
- package/dist/lib/core/security/roleRepository.js +122 -53
- package/dist/lib/core/security/securityLoader.d.ts +33 -18
- package/dist/lib/core/security/securityLoader.js +43 -16
- package/dist/lib/core/security/tokenRepository.d.ts +21 -7
- package/dist/lib/core/security/tokenRepository.js +50 -23
- package/dist/lib/core/security/userRepository.d.ts +44 -21
- package/dist/lib/core/security/userRepository.js +59 -19
- package/dist/lib/core/shared/KoncordeWrapper.d.ts +1 -1
- package/dist/lib/core/shared/ObjectRepository.d.ts +80 -18
- package/dist/lib/core/shared/ObjectRepository.js +57 -29
- package/dist/lib/core/shared/abstractManifest.d.ts +21 -8
- package/dist/lib/core/shared/abstractManifest.js +57 -17
- package/dist/lib/core/shared/sdk/embeddedSdk.d.ts +3 -1
- package/dist/lib/core/shared/sdk/embeddedSdk.js +8 -7
- package/dist/lib/core/shared/sdk/funnelProtocol.d.ts +2 -1
- package/dist/lib/core/shared/sdk/funnelProtocol.js +12 -3
- package/dist/lib/core/shared/sdk/impersonatedSdk.d.ts +11 -5
- package/dist/lib/core/shared/sdk/impersonatedSdk.js +22 -9
- package/dist/lib/core/shared/store.d.ts +45 -29
- package/dist/lib/core/shared/store.js +48 -27
- package/dist/lib/core/statistics/statistics.d.ts +1 -1
- package/dist/lib/core/storage/clientAdapter.d.ts +39 -21
- package/dist/lib/core/storage/clientAdapter.js +88 -48
- package/dist/lib/core/storage/indexCache.d.ts +8 -0
- package/dist/lib/core/storage/indexCache.js +16 -7
- package/dist/lib/core/storage/storageEngine.d.ts +7 -6
- package/dist/lib/core/storage/storageEngine.js +11 -8
- package/dist/lib/core/validation/baseType.d.ts +22 -22
- package/dist/lib/core/validation/baseType.js +11 -26
- package/dist/lib/core/validation/specification.d.ts +148 -0
- package/dist/lib/core/validation/specification.js +34 -0
- package/dist/lib/core/validation/typeOptions.d.ts +62 -0
- package/dist/lib/core/validation/typeOptions.js +23 -0
- package/dist/lib/core/validation/types/anything.d.ts +3 -6
- package/dist/lib/core/validation/types/anything.js +7 -7
- package/dist/lib/core/validation/types/boolean.d.ts +5 -12
- package/dist/lib/core/validation/types/boolean.js +7 -12
- package/dist/lib/core/validation/types/date.d.ts +19 -11
- package/dist/lib/core/validation/types/date.js +212 -161
- package/dist/lib/core/validation/types/email.d.ts +7 -11
- package/dist/lib/core/validation/types/email.js +13 -17
- package/dist/lib/core/validation/types/enum.d.ts +7 -11
- package/dist/lib/core/validation/types/enum.js +39 -20
- package/dist/lib/core/validation/types/geoPoint.d.ts +5 -13
- package/dist/lib/core/validation/types/geoPoint.js +10 -15
- package/dist/lib/core/validation/types/geoShape.d.ts +22 -21
- package/dist/lib/core/validation/types/geoShape.js +113 -129
- package/dist/lib/core/validation/types/geoShapeUtils.d.ts +15 -0
- package/dist/lib/core/validation/types/geoShapeUtils.js +75 -0
- package/dist/lib/core/validation/types/integer.d.ts +7 -5
- package/dist/lib/core/validation/types/integer.js +7 -13
- package/dist/lib/core/validation/types/ipAddress.d.ts +7 -11
- package/dist/lib/core/validation/types/ipAddress.js +13 -17
- package/dist/lib/core/validation/types/numeric.d.ts +7 -11
- package/dist/lib/core/validation/types/numeric.js +22 -29
- package/dist/lib/core/validation/types/object.d.ts +8 -15
- package/dist/lib/core/validation/types/object.js +12 -21
- package/dist/lib/core/validation/types/string.d.ts +7 -11
- package/dist/lib/core/validation/types/string.js +22 -29
- package/dist/lib/core/validation/types/url.d.ts +7 -11
- package/dist/lib/core/validation/types/url.js +14 -18
- package/dist/lib/core/validation/validation.d.ts +119 -80
- package/dist/lib/core/validation/validation.js +470 -412
- package/dist/lib/core/validation/validationUtils.d.ts +31 -0
- package/dist/lib/core/validation/validationUtils.js +190 -0
- package/dist/lib/kerror/codes/4-plugin.json +0 -12
- package/dist/lib/kerror/codes/index.d.ts +12 -2
- package/dist/lib/kerror/codes/index.js +5 -4
- package/dist/lib/kerror/errors/badRequestError.d.ts +1 -1
- package/dist/lib/kerror/errors/badRequestError.js +1 -1
- package/dist/lib/kerror/errors/externalServiceError.d.ts +1 -1
- package/dist/lib/kerror/errors/externalServiceError.js +1 -1
- package/dist/lib/kerror/errors/forbiddenError.d.ts +1 -1
- package/dist/lib/kerror/errors/forbiddenError.js +1 -1
- package/dist/lib/kerror/errors/gatewayTimeoutError.d.ts +1 -1
- package/dist/lib/kerror/errors/gatewayTimeoutError.js +1 -1
- package/dist/lib/kerror/errors/internalError.d.ts +1 -1
- package/dist/lib/kerror/errors/internalError.js +1 -1
- package/dist/lib/kerror/errors/kuzzleError.d.ts +32 -3
- package/dist/lib/kerror/errors/kuzzleError.js +21 -7
- package/dist/lib/kerror/errors/multipleErrorsError.d.ts +2 -2
- package/dist/lib/kerror/errors/multipleErrorsError.js +2 -2
- package/dist/lib/kerror/errors/notFoundError.d.ts +1 -1
- package/dist/lib/kerror/errors/notFoundError.js +1 -1
- package/dist/lib/kerror/errors/partialError.d.ts +8 -2
- package/dist/lib/kerror/errors/partialError.js +22 -9
- package/dist/lib/kerror/errors/pluginImplementationError.d.ts +9 -1
- package/dist/lib/kerror/errors/pluginImplementationError.js +9 -3
- package/dist/lib/kerror/errors/preconditionError.d.ts +1 -1
- package/dist/lib/kerror/errors/preconditionError.js +1 -1
- package/dist/lib/kerror/errors/serviceUnavailableError.d.ts +1 -1
- package/dist/lib/kerror/errors/serviceUnavailableError.js +1 -1
- package/dist/lib/kerror/errors/sizeLimitError.d.ts +1 -1
- package/dist/lib/kerror/errors/sizeLimitError.js +1 -1
- package/dist/lib/kerror/errors/tooManyRequestsError.d.ts +1 -1
- package/dist/lib/kerror/errors/tooManyRequestsError.js +1 -1
- package/dist/lib/kerror/errors/unauthorizedError.d.ts +1 -1
- package/dist/lib/kerror/errors/unauthorizedError.js +1 -1
- package/dist/lib/kerror/index.d.ts +19 -13
- package/dist/lib/kerror/index.js +60 -19
- package/dist/lib/kuzzle/Logger.d.ts +2 -2
- package/dist/lib/kuzzle/dumpGenerator.d.ts +12 -8
- package/dist/lib/kuzzle/dumpGenerator.js +130 -62
- package/dist/lib/kuzzle/event/KuzzleEventEmitter.d.ts +18 -9
- package/dist/lib/kuzzle/event/KuzzleEventEmitter.js +45 -18
- package/dist/lib/kuzzle/event/pipeRunner.d.ts +37 -16
- package/dist/lib/kuzzle/event/pipeRunner.js +73 -26
- package/dist/lib/kuzzle/event/waterfall.d.ts +11 -1
- package/dist/lib/kuzzle/event/waterfall.js +38 -13
- package/dist/lib/kuzzle/internalIndexHandler.d.ts +11 -174
- package/dist/lib/kuzzle/internalIndexHandler.js +58 -29
- package/dist/lib/kuzzle/kuzzle.d.ts +25 -10
- package/dist/lib/kuzzle/kuzzle.js +74 -17
- package/dist/lib/kuzzle/kuzzleStateEnum.d.ts +16 -12
- package/dist/lib/kuzzle/kuzzleStateEnum.js +5 -7
- package/dist/lib/kuzzle/vault.d.ts +5 -1
- package/dist/lib/kuzzle/vault.js +29 -17
- package/dist/lib/model/security/profile.d.ts +34 -5
- package/dist/lib/model/security/profile.js +6 -5
- package/dist/lib/model/security/rights.d.ts +12 -4
- package/dist/lib/model/security/rights.js +7 -6
- package/dist/lib/model/security/role.d.ts +8 -4
- package/dist/lib/model/security/role.js +12 -6
- package/dist/lib/model/security/token.d.ts +8 -0
- package/dist/lib/model/security/user.d.ts +8 -2
- package/dist/lib/model/security/user.js +7 -4
- package/dist/lib/model/storage/apiKey.d.ts +55 -26
- package/dist/lib/model/storage/apiKey.js +97 -24
- package/dist/lib/model/storage/baseModel.d.ts +77 -66
- package/dist/lib/model/storage/baseModel.js +21 -34
- package/dist/lib/service/cache/redis.d.ts +53 -36
- package/dist/lib/service/cache/redis.js +148 -71
- package/dist/lib/service/service.d.ts +14 -19
- package/dist/lib/service/service.js +41 -22
- package/dist/lib/service/storage/7/elasticsearch.d.ts +136 -93
- package/dist/lib/service/storage/7/elasticsearch.js +218 -165
- package/dist/lib/service/storage/7/esWrapper.d.ts +30 -13
- package/dist/lib/service/storage/7/esWrapper.js +58 -37
- package/dist/lib/service/storage/8/elasticsearch.d.ts +153 -119
- package/dist/lib/service/storage/8/elasticsearch.js +286 -213
- package/dist/lib/service/storage/8/esWrapper.d.ts +30 -13
- package/dist/lib/service/storage/8/esWrapper.js +59 -38
- package/dist/lib/service/storage/commons/queryTranslator.d.ts +3 -3
- package/dist/lib/service/storage/commons/queryTranslator.js +71 -35
- package/dist/lib/types/ApiRoute.d.ts +12 -0
- package/dist/lib/types/ApiRoute.js +23 -0
- package/dist/lib/types/ClientConnection.d.ts +1 -1
- package/dist/lib/types/EventHandler.d.ts +10 -0
- package/dist/lib/types/Global.d.ts +8 -3
- package/dist/lib/types/HttpMessage.d.ts +2 -2
- package/dist/lib/types/HttpStream.d.ts +1 -1
- package/dist/lib/types/HttpStream.js +3 -1
- package/dist/lib/types/JSONObject.d.ts +9 -0
- package/dist/lib/types/JSONObject.js +23 -0
- package/dist/lib/types/Kuzzle.d.ts +5 -3
- package/dist/lib/types/KuzzleDocument.d.ts +1 -1
- package/dist/lib/types/KuzzleWebSocket.d.ts +24 -0
- package/dist/lib/types/KuzzleWebSocket.js +23 -0
- package/dist/lib/types/OpenApiDefinition.d.ts +1 -1
- package/dist/lib/types/Plugin.d.ts +33 -8
- package/dist/lib/types/PluginInstance.d.ts +67 -0
- package/dist/lib/types/PluginInstance.js +23 -0
- package/dist/lib/types/Policy.d.ts +1 -1
- package/dist/lib/types/Target.d.ts +8 -0
- package/dist/lib/types/Token.d.ts +14 -2
- package/dist/lib/types/config/HttpConfiguration.d.ts +5 -0
- package/dist/lib/types/config/KuzzleConfiguration.d.ts +102 -1
- package/dist/lib/types/config/PluginsConfiguration.d.ts +3 -2
- package/dist/lib/types/config/SecurityConfiguration.d.ts +6 -2
- package/dist/lib/types/config/ServerConfiguration.d.ts +2 -2
- package/dist/lib/types/config/ServicesConfiguration.d.ts +1 -1
- package/dist/lib/types/config/cache/BaseCacheRedisConfiguration.d.ts +131 -0
- package/dist/lib/types/config/cache/BaseCacheRedisConfiguration.js +3 -0
- package/dist/lib/types/config/internalCache/InternalCacheRedisConfiguration.d.ts +2 -106
- package/dist/lib/types/config/publicCache/PublicCacheRedisConfiguration.d.ts +2 -26
- package/dist/lib/types/config/storageEngine/StorageEngineElasticsearchConfiguration.d.ts +3 -0
- package/dist/lib/types/controllers/Controller.d.ts +12 -3
- package/dist/lib/types/controllers/ControllerDefinition.d.ts +2 -2
- package/dist/lib/types/controllers/{adminControlller.type.js → adminController.type.js} +1 -1
- package/dist/lib/types/controllers/authController.type.d.ts +2 -2
- package/dist/lib/types/core/auth/formatProcessing.type.d.ts +7 -1
- package/dist/lib/types/errors/ErrorDomains.d.ts +1 -1
- package/dist/lib/types/events/EventGenericDocument.d.ts +10 -9
- package/dist/lib/types/events/EventProtocol.d.ts +4 -4
- package/dist/lib/types/index.d.ts +7 -0
- package/dist/lib/types/index.js +7 -0
- package/dist/lib/types/shared/StoreCollectionsDefinition.d.ts +1 -1
- package/dist/lib/types/storage/7/Elasticsearch.d.ts +62 -13
- package/dist/lib/types/storage/8/Elasticsearch.d.ts +62 -13
- package/dist/lib/util/Inflector.d.ts +4 -1
- package/dist/lib/util/Inflector.js +0 -3
- package/dist/lib/util/assertType.d.ts +24 -27
- package/dist/lib/util/assertType.js +28 -39
- package/dist/lib/util/async.js +19 -6
- package/dist/lib/util/asyncStore.js +1 -1
- package/dist/lib/util/bufferedPassThrough.d.ts +9 -0
- package/dist/lib/util/bufferedPassThrough.js +27 -13
- package/dist/lib/util/bytes.d.ts +1 -1
- package/dist/lib/util/bytes.js +6 -2
- package/dist/lib/util/debug.d.ts +3 -1
- package/dist/lib/util/debug.js +42 -10
- package/dist/lib/util/deprecate.d.ts +9 -1
- package/dist/lib/util/deprecate.js +10 -6
- package/dist/lib/util/didYouMean.d.ts +2 -1
- package/dist/lib/util/didYouMean.js +8 -4
- package/dist/lib/util/distributedLock.d.ts +56 -0
- package/dist/lib/util/distributedLock.js +166 -0
- package/dist/lib/util/dump-collection.d.ts +1 -1
- package/dist/lib/util/dump-collection.js +4 -5
- package/dist/lib/util/extractFields.d.ts +15 -11
- package/dist/lib/util/extractFields.js +8 -9
- package/dist/lib/util/koncordeCompat.d.ts +2 -2
- package/dist/lib/util/koncordeCompat.js +33 -0
- package/dist/lib/util/memoize.d.ts +7 -6
- package/dist/lib/util/memoize.js +3 -3
- package/dist/lib/util/mutex.d.ts +22 -2
- package/dist/lib/util/mutex.js +39 -1
- package/dist/lib/util/name-generator.js +14 -2
- package/dist/lib/util/promback.d.ts +20 -11
- package/dist/lib/util/promback.js +14 -7
- package/dist/lib/util/requestAssertions.d.ts +30 -10
- package/dist/lib/util/requestAssertions.js +125 -121
- package/dist/lib/util/safeObject.d.ts +3 -3
- package/dist/lib/util/safeObject.js +7 -3
- package/dist/lib/util/stackTrace.d.ts +13 -5
- package/dist/lib/util/stackTrace.js +17 -12
- package/dist/lib/util/thrown.d.ts +13 -0
- package/dist/lib/util/thrown.js +46 -0
- package/dist/package.json +26 -19
- package/package.json +26 -19
- package/dist/lib/util/wildcard.d.ts +0 -1
- package/dist/lib/util/wildcard.js +0 -46
- /package/dist/lib/types/controllers/{adminControlller.type.d.ts → adminController.type.d.ts} +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/*
|
|
2
3
|
* Kuzzle, a backend software, self-hostable and ready to use
|
|
3
4
|
* to power modern apps
|
|
@@ -18,18 +19,40 @@
|
|
|
18
19
|
* See the License for the specific language governing permissions and
|
|
19
20
|
* limitations under the License.
|
|
20
21
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
25
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
26
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
27
|
+
}
|
|
28
|
+
Object.defineProperty(o, k2, desc);
|
|
29
|
+
}) : (function(o, m, k, k2) {
|
|
30
|
+
if (k2 === undefined) k2 = k;
|
|
31
|
+
o[k2] = m[k];
|
|
32
|
+
}));
|
|
33
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
34
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
35
|
+
}) : function(o, v) {
|
|
36
|
+
o["default"] = v;
|
|
37
|
+
});
|
|
38
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
39
|
+
if (mod && mod.__esModule) return mod;
|
|
40
|
+
var result = {};
|
|
41
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
42
|
+
__setModuleDefault(result, mod);
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
const kerror_1 = require("../../kerror");
|
|
46
|
+
const request_1 = require("../request");
|
|
47
|
+
const baseController_1 = require("./baseController");
|
|
48
|
+
const kassert = __importStar(require("../../util/requestAssertions"));
|
|
49
|
+
const safeObject_1 = require("../../util/safeObject");
|
|
50
|
+
const kerror = (0, kerror_1.wrap)("api", "assert");
|
|
51
|
+
// Stays a mutable top-level binding: the Mocha spec rewires it through
|
|
52
|
+
// `__get__("mapping")` / `__set__({ mapping })` on the compiled CJS, which a
|
|
53
|
+
// `const` would make impossible (assignment to a constant).
|
|
28
54
|
let mapping;
|
|
29
|
-
|
|
30
|
-
* @class MemoryStorageController
|
|
31
|
-
*/
|
|
32
|
-
class MemoryStorageController extends NativeController {
|
|
55
|
+
class MemoryStorageController extends baseController_1.NativeController {
|
|
33
56
|
constructor() {
|
|
34
57
|
super();
|
|
35
58
|
initMapping();
|
|
@@ -43,13 +66,18 @@ class MemoryStorageController extends NativeController {
|
|
|
43
66
|
}
|
|
44
67
|
return async (request) => global.kuzzle.ask("core:cache:public:execute", command, ...extractArgumentsFromRequest(command, request));
|
|
45
68
|
};
|
|
69
|
+
// Every Redis command in the table becomes an action method on the
|
|
70
|
+
// instance, installed here and looked up by name by the funnel. `command`
|
|
71
|
+
// is a runtime-built key, so a plain `this[command] = …` cannot be typed
|
|
72
|
+
// without opening the whole class to an index signature (TD-28, #2704);
|
|
73
|
+
// `Reflect.set` is the property-write counterpart already used for the
|
|
74
|
+
// same reason in `core/shared/sdk/impersonatedSdk`.
|
|
46
75
|
for (const command of Object.keys(mapping)) {
|
|
47
76
|
this._actions.add(command);
|
|
48
|
-
this
|
|
77
|
+
Reflect.set(this, command, buildCommandFn(command));
|
|
49
78
|
}
|
|
50
79
|
}
|
|
51
80
|
}
|
|
52
|
-
module.exports = MemoryStorageController;
|
|
53
81
|
const scanMatchProperty = {
|
|
54
82
|
skip: true,
|
|
55
83
|
merge: true,
|
|
@@ -70,6 +98,15 @@ const scanCountProperty = {
|
|
|
70
98
|
return ["COUNT", val];
|
|
71
99
|
},
|
|
72
100
|
};
|
|
101
|
+
/**
|
|
102
|
+
* The table entry for a command this module handles itself: one that takes no
|
|
103
|
+
* argument at all, or one an `extractArgumentsFromRequestFor*` function reads.
|
|
104
|
+
*
|
|
105
|
+
* Named rather than a bare `null` in the literal: with the table inferred
|
|
106
|
+
* through `satisfies`, `noImplicitAny` reads a lone `null` property as `any`
|
|
107
|
+
* — ten of them, which is what the implicit-any ratchet counts.
|
|
108
|
+
*/
|
|
109
|
+
const NO_MAPPING = null;
|
|
73
110
|
const zrangebyscoreOptionsProperty = {
|
|
74
111
|
skip: true,
|
|
75
112
|
merge: true,
|
|
@@ -83,7 +120,13 @@ const zrangebyscoreLimitProperty = {
|
|
|
83
120
|
path: ["args", "limit"],
|
|
84
121
|
};
|
|
85
122
|
function initMapping() {
|
|
86
|
-
|
|
123
|
+
// `satisfies`, not an annotation: the table is checked against
|
|
124
|
+
// `RedisCommandMapping` — which is what contextually types the `map`
|
|
125
|
+
// closures below — while keeping its literal type, so the aliases at the
|
|
126
|
+
// bottom read entries the compiler knows are there. Annotated, every
|
|
127
|
+
// `mapping.mget` was `CommandArguments | undefined` and sixteen aliases
|
|
128
|
+
// could not be assigned from one.
|
|
129
|
+
const table = {
|
|
87
130
|
append: {
|
|
88
131
|
key: ["resource", "_id"],
|
|
89
132
|
value: ["body", "value"],
|
|
@@ -104,7 +147,7 @@ function initMapping() {
|
|
|
104
147
|
start: { skip: true, path: ["args", "start"] },
|
|
105
148
|
end: { skip: true, path: ["args", "end"] },
|
|
106
149
|
},
|
|
107
|
-
dbsize:
|
|
150
|
+
dbsize: NO_MAPPING,
|
|
108
151
|
decrby: {
|
|
109
152
|
key: ["resource", "_id"],
|
|
110
153
|
value: ["body", "value"],
|
|
@@ -120,7 +163,7 @@ function initMapping() {
|
|
|
120
163
|
key: ["resource", "_id"],
|
|
121
164
|
timestamp: ["body", "timestamp"],
|
|
122
165
|
},
|
|
123
|
-
flushdb:
|
|
166
|
+
flushdb: NO_MAPPING,
|
|
124
167
|
geoadd: {
|
|
125
168
|
key: { path: ["resource", "_id"] },
|
|
126
169
|
points: {
|
|
@@ -128,10 +171,12 @@ function initMapping() {
|
|
|
128
171
|
const result = [];
|
|
129
172
|
kassert.assertBodyHasAttribute(request, "points");
|
|
130
173
|
kassert.assertBodyAttributeType(request, "points", "array");
|
|
131
|
-
|
|
174
|
+
// The assert above is what makes the array shape safe to assume.
|
|
175
|
+
const points = val;
|
|
176
|
+
if (points.length === 0) {
|
|
132
177
|
throw kerror.get("empty_argument", "points");
|
|
133
178
|
}
|
|
134
|
-
|
|
179
|
+
points.forEach((v) => {
|
|
135
180
|
if (typeof v !== "object" || !v.lon || !v.lat || !v.name) {
|
|
136
181
|
throw kerror.get("invalid_argument", "points", "<array of geopoints>");
|
|
137
182
|
}
|
|
@@ -331,13 +376,13 @@ function initMapping() {
|
|
|
331
376
|
key: ["resource", "_id"],
|
|
332
377
|
sources: { skip: true, merge: true, path: ["body", "sources"] },
|
|
333
378
|
},
|
|
334
|
-
ping:
|
|
379
|
+
ping: NO_MAPPING,
|
|
335
380
|
psetex: {
|
|
336
381
|
key: ["resource", "_id"],
|
|
337
382
|
milliseconds: ["body", "milliseconds"],
|
|
338
383
|
value: ["body", "value"],
|
|
339
384
|
},
|
|
340
|
-
randomkey:
|
|
385
|
+
randomkey: NO_MAPPING,
|
|
341
386
|
rename: {
|
|
342
387
|
key: ["resource", "_id"],
|
|
343
388
|
newkey: ["body", "newkey"],
|
|
@@ -372,7 +417,7 @@ function initMapping() {
|
|
|
372
417
|
key: ["resource", "_id"],
|
|
373
418
|
keys: { merge: true, path: ["body", "keys"] },
|
|
374
419
|
},
|
|
375
|
-
set:
|
|
420
|
+
set: NO_MAPPING, // handled by extractArgumentsFromRequestForSet
|
|
376
421
|
setex: {
|
|
377
422
|
key: ["resource", "_id"],
|
|
378
423
|
seconds: ["body", "seconds"],
|
|
@@ -395,7 +440,7 @@ function initMapping() {
|
|
|
395
440
|
destination: ["body", "destination"],
|
|
396
441
|
member: ["body", "member"],
|
|
397
442
|
},
|
|
398
|
-
sort:
|
|
443
|
+
sort: NO_MAPPING, // handled by extractArgumentsFromRequestForSort
|
|
399
444
|
spop: {
|
|
400
445
|
key: ["resource", "_id"],
|
|
401
446
|
count: { skip: true, path: ["body", "count"] },
|
|
@@ -425,11 +470,11 @@ function initMapping() {
|
|
|
425
470
|
destination: ["body", "destination"],
|
|
426
471
|
keys: { merge: true, path: ["body", "keys"] },
|
|
427
472
|
},
|
|
428
|
-
time:
|
|
473
|
+
time: NO_MAPPING,
|
|
429
474
|
touch: {
|
|
430
475
|
keys: { merge: true, path: ["body", "keys"] },
|
|
431
476
|
},
|
|
432
|
-
zadd:
|
|
477
|
+
zadd: NO_MAPPING, // handled by extractArgumentsFromRequestForZAdd
|
|
433
478
|
zcount: {
|
|
434
479
|
key: ["resource", "_id"],
|
|
435
480
|
min: ["args", "min"],
|
|
@@ -440,7 +485,7 @@ function initMapping() {
|
|
|
440
485
|
value: ["body", "value"],
|
|
441
486
|
member: ["body", "member"],
|
|
442
487
|
},
|
|
443
|
-
zinterstore:
|
|
488
|
+
zinterstore: NO_MAPPING, // handled by extractArgumentsFromRequestForZInterstore
|
|
444
489
|
zlexcount: {
|
|
445
490
|
key: ["resource", "_id"],
|
|
446
491
|
min: ["args", "min"],
|
|
@@ -516,8 +561,9 @@ function initMapping() {
|
|
|
516
561
|
key: ["resource", "_id"],
|
|
517
562
|
member: ["args", "member"],
|
|
518
563
|
},
|
|
519
|
-
zunionstore:
|
|
564
|
+
zunionstore: NO_MAPPING, // handled by extractArgumentsFromRequestForZInterstore
|
|
520
565
|
};
|
|
566
|
+
mapping = table;
|
|
521
567
|
// unique argument key
|
|
522
568
|
mapping.decr =
|
|
523
569
|
mapping.get =
|
|
@@ -546,82 +592,92 @@ function initMapping() {
|
|
|
546
592
|
key: ["resource", "_id"],
|
|
547
593
|
value: ["body", "value"],
|
|
548
594
|
};
|
|
549
|
-
mapping.pfcount = mapping.sinter =
|
|
550
|
-
mapping.incrby = mapping.incrbyfloat =
|
|
551
|
-
mapping.geopos =
|
|
552
|
-
mapping.hget =
|
|
553
|
-
mapping.hsetnx =
|
|
554
|
-
mapping.msetnx =
|
|
555
|
-
mapping.rpush =
|
|
556
|
-
mapping.hincrbyfloat =
|
|
557
|
-
mapping.zrevrange =
|
|
558
|
-
mapping.zscore = mapping.zrank =
|
|
559
|
-
mapping.hscan = mapping.zscan =
|
|
560
|
-
mapping.exists =
|
|
595
|
+
mapping.pfcount = mapping.sinter = table.mget;
|
|
596
|
+
mapping.incrby = mapping.incrbyfloat = table.decrby;
|
|
597
|
+
mapping.geopos = table.geohash;
|
|
598
|
+
mapping.hget = table.hexists;
|
|
599
|
+
mapping.hsetnx = table.hset;
|
|
600
|
+
mapping.msetnx = table.mset;
|
|
601
|
+
mapping.rpush = table.lpush;
|
|
602
|
+
mapping.hincrbyfloat = table.hincrby;
|
|
603
|
+
mapping.zrevrange = table.zrange;
|
|
604
|
+
mapping.zscore = mapping.zrank = table.zrevrank;
|
|
605
|
+
mapping.hscan = mapping.zscan = table.sscan;
|
|
606
|
+
mapping.exists = table.mget;
|
|
561
607
|
}
|
|
562
608
|
/**
|
|
563
609
|
* @param {string} command
|
|
564
610
|
* @param {Request} request
|
|
565
611
|
* @returns {*}
|
|
566
612
|
*/
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
613
|
+
/**
|
|
614
|
+
* Commands whose arguments a dedicated function reads, because the table
|
|
615
|
+
* cannot describe them. The six `if`s this replaces were the bulk of
|
|
616
|
+
* `extractArgumentsFromRequest`'s cognitive complexity.
|
|
617
|
+
*/
|
|
618
|
+
const SPECIAL_EXTRACTORS = {
|
|
619
|
+
mexecute: (request) => extractArgumentsFromRequestForMExecute(request),
|
|
620
|
+
set: (request) => extractArgumentsFromRequestForSet(request),
|
|
621
|
+
sort: (request) => extractArgumentsFromRequestForSort(request),
|
|
622
|
+
zadd: (request) => extractArgumentsFromRequestForZAdd(request),
|
|
623
|
+
zinterstore: (request) => extractArgumentsFromRequestForZInterstore(request),
|
|
624
|
+
zunionstore: (request) => extractArgumentsFromRequestForZInterstore(request),
|
|
625
|
+
};
|
|
626
|
+
/**
|
|
627
|
+
* Reads one of a command's arguments out of the request and appends it to the
|
|
628
|
+
* argument list.
|
|
629
|
+
*/
|
|
630
|
+
function appendArgument(args, key, data, request) {
|
|
631
|
+
const path = Array.isArray(data) ? data : data.path;
|
|
632
|
+
const toMerge = !Array.isArray(data) && data.merge === true;
|
|
633
|
+
const map = !Array.isArray(data) && data.map;
|
|
634
|
+
const skip = !Array.isArray(data) && data.skip === true;
|
|
635
|
+
let value = path.reduce((previousValue, currentValue) => {
|
|
636
|
+
// Indexing `undefined` throws, as it did before: no path in the table
|
|
637
|
+
// is deeper than the two levels the request always has.
|
|
638
|
+
const next = previousValue[currentValue];
|
|
639
|
+
return next ?? undefined;
|
|
640
|
+
}, request.input);
|
|
641
|
+
if (value === undefined) {
|
|
642
|
+
if (skip) {
|
|
643
|
+
return;
|
|
644
|
+
}
|
|
645
|
+
throw kerror.get("missing_argument", key);
|
|
572
646
|
}
|
|
573
|
-
if (
|
|
574
|
-
|
|
647
|
+
if (map) {
|
|
648
|
+
value = map(value, request);
|
|
575
649
|
}
|
|
576
|
-
if (
|
|
577
|
-
return
|
|
650
|
+
if (value === undefined) {
|
|
651
|
+
return;
|
|
578
652
|
}
|
|
579
|
-
if (
|
|
580
|
-
|
|
653
|
+
if (toMerge && Array.isArray(value)) {
|
|
654
|
+
for (const item of value) {
|
|
655
|
+
args.push(item);
|
|
656
|
+
}
|
|
581
657
|
}
|
|
582
|
-
|
|
583
|
-
|
|
658
|
+
else {
|
|
659
|
+
args.push(value);
|
|
584
660
|
}
|
|
585
|
-
|
|
586
|
-
|
|
661
|
+
}
|
|
662
|
+
function extractArgumentsFromRequest(command, request) {
|
|
663
|
+
const special = SPECIAL_EXTRACTORS[command];
|
|
664
|
+
if (special) {
|
|
665
|
+
return special(request);
|
|
587
666
|
}
|
|
588
|
-
|
|
667
|
+
const commandArguments = mapping[command];
|
|
668
|
+
// One lookup, and the `null` entries — the commands that take no argument —
|
|
669
|
+
// are the same answer as an unknown command. The table was read twice, the
|
|
670
|
+
// second time without the guard the first had just applied.
|
|
671
|
+
if (!commandArguments) {
|
|
589
672
|
return [];
|
|
590
673
|
}
|
|
591
674
|
if (!request.input.body) {
|
|
592
675
|
request.input.body = {};
|
|
593
676
|
}
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
const map = !Array.isArray(data) && data.map;
|
|
599
|
-
const skip = !Array.isArray(data) && data.skip === true;
|
|
600
|
-
let value = path.reduce((previousValue, currentValue, currentIndex, array) => {
|
|
601
|
-
if (previousValue[array[currentIndex]] !== undefined &&
|
|
602
|
-
previousValue[array[currentIndex]] !== null) {
|
|
603
|
-
return previousValue[array[currentIndex]];
|
|
604
|
-
}
|
|
605
|
-
return undefined;
|
|
606
|
-
}, request.input);
|
|
607
|
-
if (value === undefined) {
|
|
608
|
-
if (skip) {
|
|
609
|
-
return;
|
|
610
|
-
}
|
|
611
|
-
throw kerror.get("missing_argument", key);
|
|
612
|
-
}
|
|
613
|
-
if (map) {
|
|
614
|
-
value = data.map(value, request);
|
|
615
|
-
}
|
|
616
|
-
if (value !== undefined) {
|
|
617
|
-
if (toMerge && Array.isArray(value)) {
|
|
618
|
-
args = args.concat(value);
|
|
619
|
-
}
|
|
620
|
-
else {
|
|
621
|
-
args.push(value);
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
});
|
|
677
|
+
const args = [];
|
|
678
|
+
for (const [key, data] of Object.entries(commandArguments)) {
|
|
679
|
+
appendArgument(args, key, data, request);
|
|
680
|
+
}
|
|
625
681
|
return args;
|
|
626
682
|
}
|
|
627
683
|
/**
|
|
@@ -632,7 +688,7 @@ function extractArgumentsFromRequestForSet(request) {
|
|
|
632
688
|
const args = [request.input.args._id];
|
|
633
689
|
kassert.assertHasId(request);
|
|
634
690
|
kassert.assertHasBody(request);
|
|
635
|
-
if (["undefined", "boolean", "object"].
|
|
691
|
+
if (["undefined", "boolean", "object"].includes(typeof request.input.body.value)) {
|
|
636
692
|
throw kerror.get("invalid_type", "value", "string, number");
|
|
637
693
|
}
|
|
638
694
|
if (request.input.body.nx && request.input.body.xx) {
|
|
@@ -663,36 +719,36 @@ function extractArgumentsFromRequestForSet(request) {
|
|
|
663
719
|
function extractArgumentsFromRequestForSort(request) {
|
|
664
720
|
const args = [request.input.args._id];
|
|
665
721
|
kassert.assertHasId(request);
|
|
666
|
-
if (request.input.body) {
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
}
|
|
677
|
-
if (request.input.body.by !== undefined) {
|
|
678
|
-
args.push("BY", request.input.body.by);
|
|
679
|
-
}
|
|
680
|
-
if (request.input.body.limit !== undefined) {
|
|
681
|
-
kassert.assertBodyAttributeType(request, "limit", "array");
|
|
682
|
-
assertInt(request, "limit.offset", request.input.body.limit[0]);
|
|
683
|
-
assertInt(request, "limit.count", request.input.body.limit[1]);
|
|
684
|
-
args.push("LIMIT", request.input.body.limit[0], request.input.body.limit[1]);
|
|
685
|
-
}
|
|
686
|
-
if (request.input.body.get !== undefined) {
|
|
687
|
-
kassert.assertBodyAttributeType(request, "get", "array");
|
|
688
|
-
request.input.body.get.forEach((pattern) => {
|
|
689
|
-
args.push("GET");
|
|
690
|
-
args.push(pattern);
|
|
691
|
-
});
|
|
692
|
-
}
|
|
693
|
-
if (request.input.body.store !== undefined) {
|
|
694
|
-
args.push("STORE", request.input.body.store);
|
|
722
|
+
if (!request.input.body) {
|
|
723
|
+
return args;
|
|
724
|
+
}
|
|
725
|
+
if (request.input.body.alpha) {
|
|
726
|
+
args.push("ALPHA");
|
|
727
|
+
}
|
|
728
|
+
if (request.input.body.direction !== undefined) {
|
|
729
|
+
const direction = request.input.body.direction.toUpperCase();
|
|
730
|
+
if (!["ASC", "DESC"].includes(direction)) {
|
|
731
|
+
throw kerror.get("invalid_argument", "direction", '"ASC", "DESC"');
|
|
695
732
|
}
|
|
733
|
+
args.push(direction);
|
|
734
|
+
}
|
|
735
|
+
if (request.input.body.by !== undefined) {
|
|
736
|
+
args.push("BY", request.input.body.by);
|
|
737
|
+
}
|
|
738
|
+
if (request.input.body.limit !== undefined) {
|
|
739
|
+
kassert.assertBodyAttributeType(request, "limit", "array");
|
|
740
|
+
assertInt(request, "limit.offset", request.input.body.limit[0]);
|
|
741
|
+
assertInt(request, "limit.count", request.input.body.limit[1]);
|
|
742
|
+
args.push("LIMIT", request.input.body.limit[0], request.input.body.limit[1]);
|
|
743
|
+
}
|
|
744
|
+
if (request.input.body.get !== undefined) {
|
|
745
|
+
kassert.assertBodyAttributeType(request, "get", "array");
|
|
746
|
+
request.input.body.get.forEach((pattern) => {
|
|
747
|
+
args.push("GET", pattern);
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
if (request.input.body.store !== undefined) {
|
|
751
|
+
args.push("STORE", request.input.body.store);
|
|
696
752
|
}
|
|
697
753
|
return args;
|
|
698
754
|
}
|
|
@@ -706,22 +762,22 @@ function extractArgumentsFromRequestForMExecute(request) {
|
|
|
706
762
|
kassert.assertBodyAttributeType(request, "actions", "array");
|
|
707
763
|
const actions = request.input.body.actions;
|
|
708
764
|
return actions.map((command) => {
|
|
709
|
-
if (!has(command, "action")) {
|
|
765
|
+
if (!(0, safeObject_1.has)(command, "action")) {
|
|
710
766
|
throw kerror.get("missing_argument", "action");
|
|
711
767
|
}
|
|
712
|
-
if (!has(command, "args")) {
|
|
768
|
+
if (!(0, safeObject_1.has)(command, "args")) {
|
|
713
769
|
throw kerror.get("missing_argument", "args");
|
|
714
770
|
}
|
|
715
|
-
if (!isPlainObject(command.args)) {
|
|
771
|
+
if (!(0, safeObject_1.isPlainObject)(command.args)) {
|
|
716
772
|
throw kerror.get("invalid_type", "args", "object");
|
|
717
773
|
}
|
|
718
774
|
if (command.action === "mexecute") {
|
|
719
775
|
throw kerror.get("forbidden_argument", "mexecute");
|
|
720
776
|
}
|
|
721
|
-
if (!has(mapping, command.action)) {
|
|
777
|
+
if (!(0, safeObject_1.has)(mapping, command.action)) {
|
|
722
778
|
throw kerror.get("forbidden_argument", command.action);
|
|
723
779
|
}
|
|
724
|
-
const subRequest = new Request(command.args);
|
|
780
|
+
const subRequest = new request_1.Request(command.args);
|
|
725
781
|
const extractedArguments = extractArgumentsFromRequest(command.action, subRequest);
|
|
726
782
|
return [command.action, ...extractedArguments];
|
|
727
783
|
});
|
|
@@ -758,15 +814,14 @@ function extractArgumentsFromRequestForZAdd(request) {
|
|
|
758
814
|
throw kerror.get("too_many_arguments", "elements");
|
|
759
815
|
}
|
|
760
816
|
request.input.body.elements.forEach((element, index) => {
|
|
761
|
-
if (!isPlainObject(element)) {
|
|
817
|
+
if (!(0, safeObject_1.isPlainObject)(element)) {
|
|
762
818
|
throw kerror.get("invalid_argument", "elements", "<array of objects>");
|
|
763
819
|
}
|
|
764
820
|
if (!element.member) {
|
|
765
821
|
throw kerror.get("missing_argument", `elements[${index}].member`);
|
|
766
822
|
}
|
|
767
823
|
assertFloat(request, "score", element.score);
|
|
768
|
-
args.push(element.score);
|
|
769
|
-
args.push(element.member);
|
|
824
|
+
args.push(element.score, element.member);
|
|
770
825
|
});
|
|
771
826
|
return args;
|
|
772
827
|
}
|
|
@@ -795,7 +850,7 @@ function extractArgumentsFromRequestForZInterstore(request) {
|
|
|
795
850
|
if (request.input.body.aggregate) {
|
|
796
851
|
kassert.assertBodyAttributeType(request, "aggregate", "string");
|
|
797
852
|
const aggregate = request.input.body.aggregate.toUpperCase();
|
|
798
|
-
if (["SUM", "MIN", "MAX"].
|
|
853
|
+
if (!["SUM", "MIN", "MAX"].includes(aggregate)) {
|
|
799
854
|
throw kerror.get("invalid_argument", "aggregate", '"SUM", "MIN" or "MAX"');
|
|
800
855
|
}
|
|
801
856
|
args.push("AGGREGATE", aggregate);
|
|
@@ -813,7 +868,8 @@ function extractArgumentsFromRequestForZInterstore(request) {
|
|
|
813
868
|
*/
|
|
814
869
|
function assertFloat(request, name, value) {
|
|
815
870
|
// Number.parseXxx computes the 1st member of an array if one is provided
|
|
816
|
-
if (Array.isArray(value) ||
|
|
871
|
+
if (Array.isArray(value) ||
|
|
872
|
+
Number.isNaN(Number.parseFloat(scalarToString(value)))) {
|
|
817
873
|
throw kerror.get("invalid_type", name, "number");
|
|
818
874
|
}
|
|
819
875
|
}
|
|
@@ -828,10 +884,23 @@ function assertFloat(request, name, value) {
|
|
|
828
884
|
*/
|
|
829
885
|
function assertInt(request, name, value) {
|
|
830
886
|
// Number.parseXxx computes the 1st member of an array if one is provided
|
|
831
|
-
if (Array.isArray(value) ||
|
|
887
|
+
if (Array.isArray(value) ||
|
|
888
|
+
Number.isNaN(Number.parseInt(scalarToString(value)))) {
|
|
832
889
|
throw kerror.get("invalid_type", name, "integer");
|
|
833
890
|
}
|
|
834
891
|
}
|
|
892
|
+
/**
|
|
893
|
+
* The string `Number.parse*` would have coerced its argument to. Anything that
|
|
894
|
+
* is not a scalar parses to NaN either way, so returning "" for it preserves
|
|
895
|
+
* the behaviour without stringifying an object.
|
|
896
|
+
*/
|
|
897
|
+
function scalarToString(value) {
|
|
898
|
+
return typeof value === "string" ||
|
|
899
|
+
typeof value === "number" ||
|
|
900
|
+
typeof value === "boolean"
|
|
901
|
+
? String(value)
|
|
902
|
+
: "";
|
|
903
|
+
}
|
|
835
904
|
/**
|
|
836
905
|
* Deal with arguments being either an array or a string: return the array
|
|
837
906
|
* intact if it's the former, and convert it to an array if it's a string
|
|
@@ -839,6 +908,8 @@ function assertInt(request, name, value) {
|
|
|
839
908
|
* @returns {Array}
|
|
840
909
|
*/
|
|
841
910
|
function toArray(arg) {
|
|
911
|
+
// Anything that is neither a string nor an array used to be handed to Redis
|
|
912
|
+
// unchanged, and still is — the command itself rejects it.
|
|
842
913
|
return typeof arg === "string" ? arg.split(",") : arg;
|
|
843
914
|
}
|
|
844
915
|
/**
|
|
@@ -848,7 +919,7 @@ function toArray(arg) {
|
|
|
848
919
|
*/
|
|
849
920
|
function sanitizeArrayArgument(arg) {
|
|
850
921
|
const result = toArray(arg);
|
|
851
|
-
return result.map((v) =>
|
|
922
|
+
return result.map((v) => typeof v === "string" ? v.toUpperCase() : v);
|
|
852
923
|
}
|
|
853
924
|
/**
|
|
854
925
|
* Parse a LIMIT argument and throws if not a valid LIMIT parameter
|
|
@@ -864,4 +935,5 @@ function processLimit(arg) {
|
|
|
864
935
|
}
|
|
865
936
|
return result;
|
|
866
937
|
}
|
|
938
|
+
module.exports = MemoryStorageController;
|
|
867
939
|
//# sourceMappingURL=memoryStorageController.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { NativeController } from "./baseController";
|
|
2
|
+
import type { KuzzleRequest } from "../request";
|
|
2
3
|
/**
|
|
3
4
|
* @class RealtimeController
|
|
4
5
|
*/
|
|
@@ -8,40 +9,49 @@ declare class RealtimeController extends NativeController {
|
|
|
8
9
|
* @param {Request} request
|
|
9
10
|
* @returns {Promise<Object>}
|
|
10
11
|
*/
|
|
11
|
-
subscribe(request:
|
|
12
|
+
subscribe(request: KuzzleRequest): Promise<any>;
|
|
12
13
|
/**
|
|
13
14
|
* @param {Request} request
|
|
14
15
|
* @returns {Promise<Object>}
|
|
15
16
|
*/
|
|
16
|
-
join(request:
|
|
17
|
+
join(request: KuzzleRequest): Promise<any>;
|
|
17
18
|
/**
|
|
18
19
|
* @param {Request} request
|
|
19
20
|
* @returns {Promise<String>}
|
|
20
21
|
*/
|
|
21
|
-
unsubscribe(request:
|
|
22
|
+
unsubscribe(request: KuzzleRequest): Promise<{
|
|
23
|
+
roomId: string;
|
|
24
|
+
}>;
|
|
22
25
|
/**
|
|
23
26
|
* @param {Request} request
|
|
24
27
|
* @returns {Promise<Object>}
|
|
25
28
|
*/
|
|
26
|
-
count(request:
|
|
29
|
+
count(request: KuzzleRequest): Promise<{
|
|
30
|
+
count: any;
|
|
31
|
+
}>;
|
|
27
32
|
/**
|
|
28
33
|
* @param {Request} request
|
|
29
34
|
* @returns {Promise.<Object>}
|
|
30
35
|
*/
|
|
31
|
-
list(request:
|
|
36
|
+
list(request: KuzzleRequest): Promise<any>;
|
|
32
37
|
/**
|
|
33
38
|
* Publish a realtime message
|
|
34
39
|
*
|
|
35
40
|
* @param {Request} request
|
|
36
41
|
* @returns {Promise<Object>}
|
|
37
42
|
*/
|
|
38
|
-
publish(request:
|
|
43
|
+
publish(request: KuzzleRequest): Promise<{
|
|
44
|
+
published: boolean;
|
|
45
|
+
}>;
|
|
39
46
|
/**
|
|
40
47
|
* Validate a document against collection validation specifications.
|
|
41
48
|
*
|
|
42
49
|
* @param {Request} request
|
|
43
50
|
* @returns {Promise<Object>}
|
|
44
51
|
*/
|
|
45
|
-
validate(request:
|
|
52
|
+
validate(request: KuzzleRequest): Promise<{
|
|
53
|
+
errorMessages: import("../../core/validation/specification").VerboseErrorMessages;
|
|
54
|
+
valid: boolean;
|
|
55
|
+
}>;
|
|
46
56
|
}
|
|
47
|
-
|
|
57
|
+
export = RealtimeController;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/*
|
|
2
3
|
* Kuzzle, a backend software, self-hostable and ready to use
|
|
3
4
|
* to power modern apps
|
|
@@ -18,12 +19,11 @@
|
|
|
18
19
|
* See the License for the specific language governing permissions and
|
|
19
20
|
* limitations under the License.
|
|
20
21
|
*/
|
|
21
|
-
|
|
22
|
-
const { NativeController } = require("./baseController");
|
|
22
|
+
const baseController_1 = require("./baseController");
|
|
23
23
|
/**
|
|
24
24
|
* @class RealtimeController
|
|
25
25
|
*/
|
|
26
|
-
class RealtimeController extends NativeController {
|
|
26
|
+
class RealtimeController extends baseController_1.NativeController {
|
|
27
27
|
constructor() {
|
|
28
28
|
super([
|
|
29
29
|
"count",
|
|
@@ -107,7 +107,11 @@ class RealtimeController extends NativeController {
|
|
|
107
107
|
request.getBody();
|
|
108
108
|
request.getIndexAndCollection();
|
|
109
109
|
const newRequest = await global.kuzzle.validation.validate(request, false);
|
|
110
|
-
|
|
110
|
+
// `getBody` rather than `input.body`: the body is nullable on the request
|
|
111
|
+
// and this line has always required it. The assertion is the same one
|
|
112
|
+
// `request.getBody()` made above, on the same object — `validate` answers
|
|
113
|
+
// the request it was handed.
|
|
114
|
+
newRequest.getBody()._kuzzle_info = {
|
|
111
115
|
author: request.getKuid(),
|
|
112
116
|
createdAt: Date.now(),
|
|
113
117
|
};
|