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
|
@@ -90,9 +90,13 @@ class KuzzleRequest {
|
|
|
90
90
|
// @deprecated - Backward compatibility with the RequestInput.headers
|
|
91
91
|
// property
|
|
92
92
|
this[_input].headers = this[_context].connection.misc.headers;
|
|
93
|
-
|
|
93
|
+
// Through a local: `assertString` answers `string | null` and the ternary
|
|
94
|
+
// is what proves it non-null here, which the declaration of `id` cannot
|
|
95
|
+
// see. `?? uuid.v4()` keeps the falsy-requestId path exactly as it was.
|
|
96
|
+
const requestId = data.requestId
|
|
94
97
|
? assert.assertString("requestId", data.requestId)
|
|
95
|
-
:
|
|
98
|
+
: null;
|
|
99
|
+
this.id = requestId ?? uuid.v4();
|
|
96
100
|
this[_timestamp] = data.timestamp || Date.now();
|
|
97
101
|
// handling provided options
|
|
98
102
|
if (options !== undefined && options !== null) {
|
|
@@ -118,9 +122,10 @@ class KuzzleRequest {
|
|
|
118
122
|
}
|
|
119
123
|
else {
|
|
120
124
|
const error = new errors_1.KuzzleError(options.error.message, options.error.status || 500);
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
125
|
+
// `Object.assign` rather than an indexed write: a KuzzleError has no
|
|
126
|
+
// index signature, and these are arbitrary extra properties carried
|
|
127
|
+
// over from a plain object.
|
|
128
|
+
Object.assign(error, Object.fromEntries(Object.entries(options.error).filter(([key]) => key !== "message" && key !== "status")));
|
|
124
129
|
this.setError(error);
|
|
125
130
|
}
|
|
126
131
|
}
|
|
@@ -142,6 +147,15 @@ class KuzzleRequest {
|
|
|
142
147
|
get deprecations() {
|
|
143
148
|
return this[_deprecations];
|
|
144
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* The setter `RequestResponse.deprecations` has always assigned through to
|
|
152
|
+
* here, and there was no setter to assign to: in a module — which is strict
|
|
153
|
+
* mode — writing to an accessor-only property throws a TypeError. Nothing in
|
|
154
|
+
* the tree exercised it, so the throw was never seen.
|
|
155
|
+
*/
|
|
156
|
+
set deprecations(deprecations) {
|
|
157
|
+
this[_deprecations] = deprecations;
|
|
158
|
+
}
|
|
145
159
|
/**
|
|
146
160
|
* Request timestamp (in Epoch-micro)
|
|
147
161
|
*/
|
|
@@ -211,7 +225,7 @@ class KuzzleRequest {
|
|
|
211
225
|
/**
|
|
212
226
|
* Sets the request result and status
|
|
213
227
|
*
|
|
214
|
-
* @deprecated Use request.response.configure
|
|
228
|
+
* @deprecated Use `request.response.configure({ result, status, headers, format })`
|
|
215
229
|
*
|
|
216
230
|
* @param result Request result. Will be converted to JSON unless `raw` option is set to `true`
|
|
217
231
|
* @param options Additional options
|
|
@@ -220,13 +234,7 @@ class KuzzleRequest {
|
|
|
220
234
|
* - `raw` (boolean): instead of a Kuzzle response, forward the result directly (default: false)
|
|
221
235
|
*/
|
|
222
236
|
setResult(result, options = {}) {
|
|
223
|
-
|
|
224
|
-
throw new errors_1.InternalError("cannot set an error as a request's response");
|
|
225
|
-
}
|
|
226
|
-
if (this.context.connection.protocol !== "http" &&
|
|
227
|
-
result instanceof types_1.HttpStream) {
|
|
228
|
-
throw kerror.get("api", "assert", "forbidden_stream");
|
|
229
|
-
}
|
|
237
|
+
this.assertResultAllowed(result);
|
|
230
238
|
this.status = options.status || 200;
|
|
231
239
|
if (options.headers) {
|
|
232
240
|
this.response.configure({
|
|
@@ -238,6 +246,29 @@ class KuzzleRequest {
|
|
|
238
246
|
}
|
|
239
247
|
this[_result] = result;
|
|
240
248
|
}
|
|
249
|
+
/**
|
|
250
|
+
* Sets the result and nothing else, after the checks every result goes
|
|
251
|
+
* through. What `response.configure({ result })` calls; plugins use that.
|
|
252
|
+
*
|
|
253
|
+
* @internal
|
|
254
|
+
*/
|
|
255
|
+
assignResult(result) {
|
|
256
|
+
this.assertResultAllowed(result);
|
|
257
|
+
this[_result] = result;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* @throws {InternalError} if the result is an Error
|
|
261
|
+
* @throws {api.assert.forbidden_stream} for an HttpStream outside HTTP
|
|
262
|
+
*/
|
|
263
|
+
assertResultAllowed(result) {
|
|
264
|
+
if (result instanceof Error) {
|
|
265
|
+
throw new errors_1.InternalError("cannot set an error as a request's response");
|
|
266
|
+
}
|
|
267
|
+
if (this.context.connection.protocol !== "http" &&
|
|
268
|
+
result instanceof types_1.HttpStream) {
|
|
269
|
+
throw kerror.get("api", "assert", "forbidden_stream");
|
|
270
|
+
}
|
|
271
|
+
}
|
|
241
272
|
/**
|
|
242
273
|
* Add a deprecation for a used component, this can be action/controller/parameters...
|
|
243
274
|
*
|
|
@@ -295,6 +326,10 @@ class KuzzleRequest {
|
|
|
295
326
|
*
|
|
296
327
|
* This can be used to match Koncorde filter rather than the Request object
|
|
297
328
|
* because it has properties defined with invisible unicode characters.
|
|
329
|
+
*
|
|
330
|
+
* The `!`s are not claims: each of these may be `null`, as on the request
|
|
331
|
+
* itself. The copy is typed as v2.56.0 typed it, non-nullable, because
|
|
332
|
+
* nullable members broke code compiled against that.
|
|
298
333
|
*/
|
|
299
334
|
pojo() {
|
|
300
335
|
return {
|
|
@@ -326,12 +361,19 @@ class KuzzleRequest {
|
|
|
326
361
|
}
|
|
327
362
|
/**
|
|
328
363
|
* Return the requested controller
|
|
364
|
+
*
|
|
365
|
+
* `null` on a request built without one. Declared `string` all the same,
|
|
366
|
+
* as v2.56.0 declared it: a `string | null` return broke code compiled
|
|
367
|
+
* against it. `input.controller` is the nullable form.
|
|
329
368
|
*/
|
|
330
369
|
getController() {
|
|
331
370
|
return this[_input].controller;
|
|
332
371
|
}
|
|
333
372
|
/**
|
|
334
373
|
* Returns the requested controller's action
|
|
374
|
+
*
|
|
375
|
+
* `null` and declared `string` as {@link getController} is;
|
|
376
|
+
* `input.action` is the nullable form.
|
|
335
377
|
*/
|
|
336
378
|
getAction() {
|
|
337
379
|
return this[_input].action;
|
|
@@ -538,13 +580,15 @@ class KuzzleRequest {
|
|
|
538
580
|
return this._getArray(this.input.args, name, name, def, true);
|
|
539
581
|
}
|
|
540
582
|
/**
|
|
541
|
-
*
|
|
542
|
-
*
|
|
543
|
-
*
|
|
544
|
-
*
|
|
545
|
-
* If the request argument is a String instead of an array, it will be JSON parsed
|
|
546
|
-
* and returned if it is a valid JSON array, otherwise it will return the string splitted on `,`.
|
|
583
|
+
* Gets a parameter from a request arguments as an array, also accepting a
|
|
584
|
+
* **comma-separated string** — the form the API documents for `ids` on
|
|
585
|
+
* `document:mGet`, `document:mExists` and `security:mGetUsers`, and the only
|
|
586
|
+
* form it documents for `server:healthCheck`'s `services`.
|
|
547
587
|
*
|
|
588
|
+
* An array is returned as is. A string is, over HTTP only, first parsed as a
|
|
589
|
+
* JSON array — the one way to pass an element that contains a comma — and
|
|
590
|
+
* otherwise split on `,`, on every protocol. Unlike `getArray`, a single
|
|
591
|
+
* query-string value (`?ids=a`) is therefore a one-element array.
|
|
548
592
|
*
|
|
549
593
|
* @param name parameter name
|
|
550
594
|
* @param def default value to return if the parameter is not set
|
|
@@ -553,7 +597,7 @@ class KuzzleRequest {
|
|
|
553
597
|
* value provided
|
|
554
598
|
* @throws {api.assert.invalid_type} If the fetched parameter is not an array or a string
|
|
555
599
|
*/
|
|
556
|
-
|
|
600
|
+
getArrayOrCsv(name, def = undefined) {
|
|
557
601
|
const value = (0, lodash_1.get)(this.input.args, name, def);
|
|
558
602
|
if (value === undefined) {
|
|
559
603
|
throw assertionError.get("missing_argument", name);
|
|
@@ -573,12 +617,20 @@ class KuzzleRequest {
|
|
|
573
617
|
return parsedValue;
|
|
574
618
|
}
|
|
575
619
|
}
|
|
576
|
-
catch
|
|
620
|
+
catch {
|
|
577
621
|
// Do nothing, let the code continue
|
|
578
622
|
}
|
|
579
623
|
}
|
|
580
624
|
return value.split(",");
|
|
581
625
|
}
|
|
626
|
+
/**
|
|
627
|
+
* @deprecated Use {@link getArrayOrCsv}, which it is an alias of: same
|
|
628
|
+
* behaviour, named after what it does. Kept because `KuzzleRequest` is part
|
|
629
|
+
* of the public plugin API.
|
|
630
|
+
*/
|
|
631
|
+
getArrayLegacy(name, def = undefined) {
|
|
632
|
+
return this.getArrayOrCsv(name, def);
|
|
633
|
+
}
|
|
582
634
|
/**
|
|
583
635
|
* Gets a parameter from a request arguments and checks that it is an object
|
|
584
636
|
*
|
|
@@ -639,6 +691,11 @@ class KuzzleRequest {
|
|
|
639
691
|
}
|
|
640
692
|
/**
|
|
641
693
|
* Returns the index specified in the request
|
|
694
|
+
*
|
|
695
|
+
* With `{ required: false }` and no index, this returns `null`. It is
|
|
696
|
+
* declared `string` all the same: that is what v2.56.0 declared, and a
|
|
697
|
+
* `string | null` overload broke code compiled against it — so Kuzzle's own
|
|
698
|
+
* callers of the optional form annotate the result `string | null`.
|
|
642
699
|
*/
|
|
643
700
|
getIndex({ required = true } = {}) {
|
|
644
701
|
const index = this.input.args.index;
|
|
@@ -647,6 +704,9 @@ class KuzzleRequest {
|
|
|
647
704
|
}
|
|
648
705
|
/**
|
|
649
706
|
* Returns the collection specified in the request
|
|
707
|
+
*
|
|
708
|
+
* `null` under the same conditions as {@link getIndex}, and declared
|
|
709
|
+
* `string` for the same reason.
|
|
650
710
|
*/
|
|
651
711
|
getCollection({ required = true } = {}) {
|
|
652
712
|
const collection = this.input.args.collection;
|
|
@@ -692,6 +752,8 @@ class KuzzleRequest {
|
|
|
692
752
|
* - `ifMissing`: method behavior if the ID is missing (default: 'error')
|
|
693
753
|
* - `generator`: function used to generate an ID (default: 'uuid.v4')
|
|
694
754
|
*
|
|
755
|
+
* With `ifMissing: 'ignore'` and no ID, this returns `null`. It is declared
|
|
756
|
+
* `string` all the same, for the reason given on {@link getIndex}.
|
|
695
757
|
*/
|
|
696
758
|
getId(options = { generator: uuid.v4, ifMissing: "error" }) {
|
|
697
759
|
const id = this.input.args._id;
|
|
@@ -721,6 +783,9 @@ class KuzzleRequest {
|
|
|
721
783
|
}
|
|
722
784
|
/**
|
|
723
785
|
* Returns the current user
|
|
786
|
+
*
|
|
787
|
+
* `null` when the request carries none. Declared `User`, as v2.56.0
|
|
788
|
+
* declared it; `context.user` is the nullable form.
|
|
724
789
|
*/
|
|
725
790
|
getUser() {
|
|
726
791
|
if (this.context?.user) {
|
|
@@ -928,7 +993,7 @@ class KuzzleRequest {
|
|
|
928
993
|
return parsedValue;
|
|
929
994
|
}
|
|
930
995
|
}
|
|
931
|
-
catch
|
|
996
|
+
catch {
|
|
932
997
|
// Do nothing, let the error be thrown below
|
|
933
998
|
}
|
|
934
999
|
}
|
|
@@ -965,7 +1030,7 @@ class KuzzleRequest {
|
|
|
965
1030
|
return parsedValue;
|
|
966
1031
|
}
|
|
967
1032
|
}
|
|
968
|
-
catch
|
|
1033
|
+
catch {
|
|
969
1034
|
// Do nothing, let the error be thrown below
|
|
970
1035
|
}
|
|
971
1036
|
}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import { JSONObject } from "
|
|
2
|
-
import { Token } from "../../model/security/token";
|
|
3
|
-
import { User } from "../../model/security/user";
|
|
1
|
+
import type { JSONObject } from "../../types/JSONObject";
|
|
2
|
+
import type { Token } from "../../model/security/token";
|
|
3
|
+
import type { User } from "../../model/security/user";
|
|
4
|
+
declare const _token = "token\u200B";
|
|
5
|
+
declare const _user = "user\u200B";
|
|
6
|
+
declare const _connection = "connection\u200B";
|
|
7
|
+
declare const _c_id = "id\u200B";
|
|
8
|
+
declare const _c_protocol = "protocol\u200B";
|
|
9
|
+
declare const _c_ips = "ips\u200B";
|
|
10
|
+
declare const _c_misc = "misc\u200B";
|
|
4
11
|
export type ContextMisc = {
|
|
5
12
|
/**
|
|
6
13
|
* HTTP url
|
|
@@ -25,16 +32,20 @@ export type ContextMisc = {
|
|
|
25
32
|
* Information about the connection at the origin of the request.
|
|
26
33
|
*/
|
|
27
34
|
export declare class Connection {
|
|
35
|
+
[_c_id]: string | null;
|
|
36
|
+
[_c_protocol]: string | null;
|
|
37
|
+
[_c_ips]: string[];
|
|
38
|
+
[_c_misc]: ContextMisc;
|
|
28
39
|
constructor(connection: any);
|
|
29
40
|
/**
|
|
30
41
|
* Unique identifier of the user connection
|
|
31
42
|
*/
|
|
32
|
-
set id(str: string);
|
|
43
|
+
set id(str: string | null);
|
|
33
44
|
get id(): string | null;
|
|
34
45
|
/**
|
|
35
46
|
* Network protocol name
|
|
36
47
|
*/
|
|
37
|
-
set protocol(str: string);
|
|
48
|
+
set protocol(str: string | null);
|
|
38
49
|
get protocol(): string | null;
|
|
39
50
|
/**
|
|
40
51
|
* Chain of IP addresses, starting from the client
|
|
@@ -57,6 +68,9 @@ export declare class Connection {
|
|
|
57
68
|
* and origin (connection, protocol).
|
|
58
69
|
*/
|
|
59
70
|
export declare class RequestContext {
|
|
71
|
+
[_token]: Token | null;
|
|
72
|
+
[_user]: User | null;
|
|
73
|
+
[_connection]: Connection;
|
|
60
74
|
constructor(options?: any);
|
|
61
75
|
/**
|
|
62
76
|
* Serializes the RequestContext object
|
|
@@ -88,3 +102,4 @@ export declare class RequestContext {
|
|
|
88
102
|
get user(): User | null;
|
|
89
103
|
set user(obj: User | null);
|
|
90
104
|
}
|
|
105
|
+
export {};
|
|
@@ -68,12 +68,22 @@ class Connection {
|
|
|
68
68
|
if (typeof connection !== "object" || connection === null) {
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
// Assigned by name rather than through a dynamic index, and straight to the
|
|
72
|
+
// backing fields: the value read out of an arbitrary object is `unknown`,
|
|
73
|
+
// and asserting it here is the same single check the matching setter would
|
|
74
|
+
// have run.
|
|
75
|
+
for (const [prop, value] of Object.entries(connection)) {
|
|
76
|
+
if (prop === "id") {
|
|
77
|
+
this[_c_id] = assert.assertString("connection.id", value);
|
|
78
|
+
}
|
|
79
|
+
else if (prop === "protocol") {
|
|
80
|
+
this[_c_protocol] = assert.assertString("connection.protocol", value);
|
|
81
|
+
}
|
|
82
|
+
else if (prop === "ips") {
|
|
83
|
+
this[_c_ips] = assert.assertArray("connection.ips", value, "string");
|
|
74
84
|
}
|
|
75
85
|
else {
|
|
76
|
-
this.misc[prop] =
|
|
86
|
+
this.misc[prop] = value;
|
|
77
87
|
}
|
|
78
88
|
}
|
|
79
89
|
}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import { JSONObject } from "
|
|
1
|
+
import type { JSONObject } from "../../types/JSONObject";
|
|
2
|
+
declare const _jwt = "jwt\u200B";
|
|
3
|
+
declare const _volatile = "volatile\u200B";
|
|
4
|
+
declare const _body = "body\u200B";
|
|
5
|
+
declare const _headers = "headers\u200B";
|
|
6
|
+
declare const _controller = "controller\u200B";
|
|
7
|
+
declare const _action = "action\u200B";
|
|
8
|
+
declare const _triggerEvents = "triggerEvents\u200B";
|
|
2
9
|
/**
|
|
3
10
|
* @deprecated
|
|
4
11
|
*/
|
|
@@ -69,6 +76,13 @@ export declare class RequestInput {
|
|
|
69
76
|
* }
|
|
70
77
|
*/
|
|
71
78
|
resource: RequestResource;
|
|
79
|
+
[_jwt]: string | null;
|
|
80
|
+
[_volatile]: JSONObject | null;
|
|
81
|
+
[_body]: JSONObject | null;
|
|
82
|
+
[_headers]: JSONObject | null;
|
|
83
|
+
[_controller]: string | null;
|
|
84
|
+
[_action]: string | null;
|
|
85
|
+
[_triggerEvents]: boolean | undefined;
|
|
72
86
|
/**
|
|
73
87
|
* Builds a Kuzzle normalized request input object
|
|
74
88
|
*
|
|
@@ -76,8 +90,11 @@ export declare class RequestInput {
|
|
|
76
90
|
* format as the one used, for instance, for the Websocket protocol
|
|
77
91
|
*
|
|
78
92
|
* Any undefined option is set to null
|
|
93
|
+
*
|
|
94
|
+
* @param data - a non-null object; anything else throws. Declared
|
|
95
|
+
* `unknown`, as v2.56.0's `any` accepted anything.
|
|
79
96
|
*/
|
|
80
|
-
constructor(data:
|
|
97
|
+
constructor(data: unknown);
|
|
81
98
|
/**
|
|
82
99
|
* Authentication token.
|
|
83
100
|
* @example
|
|
@@ -96,7 +113,7 @@ export declare class RequestInput {
|
|
|
96
113
|
* }
|
|
97
114
|
*/
|
|
98
115
|
get jwt(): string | null;
|
|
99
|
-
set jwt(str: string);
|
|
116
|
+
set jwt(str: string | null);
|
|
100
117
|
/**
|
|
101
118
|
* API controller name.
|
|
102
119
|
* @example
|
|
@@ -156,14 +173,27 @@ export declare class RequestInput {
|
|
|
156
173
|
* }
|
|
157
174
|
*/
|
|
158
175
|
get body(): JSONObject | null;
|
|
159
|
-
|
|
176
|
+
/**
|
|
177
|
+
* `null` is accepted, and was already the only way to *clear* a body:
|
|
178
|
+
* `assertArrayOrObject` answers `null` for both `null` and `undefined`, the
|
|
179
|
+
* constructor initialises the field to `null`, and the getter above declares
|
|
180
|
+
* it. The parameter type excluded the one value the implementation handles
|
|
181
|
+
* first — the same asymmetry `headers` documents just below.
|
|
182
|
+
*/
|
|
183
|
+
set body(obj: JSONObject | Array<any> | null);
|
|
160
184
|
/**
|
|
161
185
|
* Request headers (Http only).
|
|
162
186
|
*
|
|
163
187
|
* @deprecated Use RequestContext.connection.misc.headers instead
|
|
164
188
|
*/
|
|
165
189
|
get headers(): JSONObject | null;
|
|
166
|
-
|
|
190
|
+
/**
|
|
191
|
+
* `undefined` is accepted because `KuzzleRequest`'s constructor assigns
|
|
192
|
+
* `context.connection.misc.headers`, which a connection without headers does
|
|
193
|
+
* not have. `assertObject` answers null for it, which is what the getter has
|
|
194
|
+
* always reported.
|
|
195
|
+
*/
|
|
196
|
+
set headers(obj: JSONObject | undefined);
|
|
167
197
|
/**
|
|
168
198
|
* Volatile object.
|
|
169
199
|
* @example
|
|
@@ -182,5 +212,6 @@ export declare class RequestInput {
|
|
|
182
212
|
* }
|
|
183
213
|
*/
|
|
184
214
|
get volatile(): JSONObject | null;
|
|
185
|
-
set volatile(obj: JSONObject);
|
|
215
|
+
set volatile(obj: JSONObject | null);
|
|
186
216
|
}
|
|
217
|
+
export {};
|
|
@@ -110,14 +110,6 @@ exports.RequestResource = RequestResource;
|
|
|
110
110
|
* "_id", "index", "collection", "refresh", "onExistingUser", "foobar", etc.
|
|
111
111
|
*/
|
|
112
112
|
class RequestInput {
|
|
113
|
-
/**
|
|
114
|
-
* Builds a Kuzzle normalized request input object
|
|
115
|
-
*
|
|
116
|
-
* The 'data' object accepts a request content using the same
|
|
117
|
-
* format as the one used, for instance, for the Websocket protocol
|
|
118
|
-
*
|
|
119
|
-
* Any undefined option is set to null
|
|
120
|
-
*/
|
|
121
113
|
constructor(data) {
|
|
122
114
|
if (!data || typeof data !== "object" || Array.isArray(data)) {
|
|
123
115
|
throw new internalError_1.InternalError("Input request data must be a non-null object");
|
|
@@ -127,7 +119,11 @@ class RequestInput {
|
|
|
127
119
|
this[_body] = null;
|
|
128
120
|
this[_controller] = null;
|
|
129
121
|
this[_action] = null;
|
|
130
|
-
|
|
122
|
+
// `undefined`, not `null`: the setter already normalises "not asked for"
|
|
123
|
+
// to undefined, and the getter has always declared `boolean | undefined`.
|
|
124
|
+
// The only reader is a truthiness test in funnel.ts, so this is the same
|
|
125
|
+
// value said honestly.
|
|
126
|
+
this[_triggerEvents] = undefined;
|
|
131
127
|
// default value to null for former "resources" to avoid breaking
|
|
132
128
|
this.args = {};
|
|
133
129
|
this.resource = new RequestResource(this.args);
|
|
@@ -171,6 +167,9 @@ class RequestInput {
|
|
|
171
167
|
get jwt() {
|
|
172
168
|
return this[_jwt];
|
|
173
169
|
}
|
|
170
|
+
// `| null` for the same reason as `body` below: `assertString` answers
|
|
171
|
+
// `null` for `null` and `undefined` in its first branch, and the getter
|
|
172
|
+
// above declares it. See docs/adr-001/steps/14-test-program-strict.md (M5).
|
|
174
173
|
set jwt(str) {
|
|
175
174
|
this[_jwt] = assert.assertString("jwt", str);
|
|
176
175
|
}
|
|
@@ -253,6 +252,13 @@ class RequestInput {
|
|
|
253
252
|
get body() {
|
|
254
253
|
return this[_body];
|
|
255
254
|
}
|
|
255
|
+
/**
|
|
256
|
+
* `null` is accepted, and was already the only way to *clear* a body:
|
|
257
|
+
* `assertArrayOrObject` answers `null` for both `null` and `undefined`, the
|
|
258
|
+
* constructor initialises the field to `null`, and the getter above declares
|
|
259
|
+
* it. The parameter type excluded the one value the implementation handles
|
|
260
|
+
* first — the same asymmetry `headers` documents just below.
|
|
261
|
+
*/
|
|
256
262
|
set body(obj) {
|
|
257
263
|
this[_body] = assert.assertArrayOrObject("body", obj);
|
|
258
264
|
}
|
|
@@ -264,6 +270,12 @@ class RequestInput {
|
|
|
264
270
|
get headers() {
|
|
265
271
|
return this[_headers];
|
|
266
272
|
}
|
|
273
|
+
/**
|
|
274
|
+
* `undefined` is accepted because `KuzzleRequest`'s constructor assigns
|
|
275
|
+
* `context.connection.misc.headers`, which a connection without headers does
|
|
276
|
+
* not have. `assertObject` answers null for it, which is what the getter has
|
|
277
|
+
* always reported.
|
|
278
|
+
*/
|
|
267
279
|
set headers(obj) {
|
|
268
280
|
this[_headers] = assert.assertObject("headers", obj);
|
|
269
281
|
}
|
|
@@ -287,6 +299,7 @@ class RequestInput {
|
|
|
287
299
|
get volatile() {
|
|
288
300
|
return this[_volatile];
|
|
289
301
|
}
|
|
302
|
+
// `| null`, as `assertObject` and the getter above both allow.
|
|
290
303
|
set volatile(obj) {
|
|
291
304
|
this[_volatile] = assert.assertObject("volatile", obj);
|
|
292
305
|
}
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
import { JSONObject } from "
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { JSONObject } from "../../types/JSONObject";
|
|
2
|
+
import type { KuzzleRequest } from "./kuzzleRequest";
|
|
3
|
+
import type { Deprecation } from "../../types";
|
|
4
|
+
import type { KuzzleError } from "../../kerror/errors/kuzzleError";
|
|
5
|
+
declare const _request = "request\u200B";
|
|
6
|
+
declare const _headers = "headers\u200B";
|
|
7
|
+
declare const _userHeaders = "userHeaders\u200B";
|
|
4
8
|
export declare class Headers {
|
|
5
9
|
headers: JSONObject;
|
|
6
10
|
private namesMap;
|
|
7
|
-
|
|
11
|
+
proxy: any;
|
|
8
12
|
constructor();
|
|
9
13
|
/**
|
|
10
14
|
* Gets a header value
|
|
11
15
|
*
|
|
12
16
|
* @param name Header name. Could be a string (case-insensitive) or a symbol
|
|
13
17
|
*/
|
|
14
|
-
getHeader(name: any): string |
|
|
18
|
+
getHeader(name: any): string | undefined;
|
|
15
19
|
removeHeader(name: string): boolean;
|
|
16
20
|
setHeader(name: string, value: string): boolean;
|
|
17
21
|
}
|
|
@@ -23,7 +27,14 @@ export declare class RequestResponse {
|
|
|
23
27
|
* If sets to true, "result" content will not be wrapped in a Kuzzle response
|
|
24
28
|
*/
|
|
25
29
|
raw: boolean;
|
|
26
|
-
|
|
30
|
+
[_request]: KuzzleRequest;
|
|
31
|
+
[_headers]: Headers;
|
|
32
|
+
[_userHeaders]: Set<string>;
|
|
33
|
+
/**
|
|
34
|
+
* @param request - the request this is the response of. Declared
|
|
35
|
+
* `unknown`, as v2.56.0's `any` accepted anything.
|
|
36
|
+
*/
|
|
37
|
+
constructor(request: unknown);
|
|
27
38
|
/**
|
|
28
39
|
* Get the parent request deprecations
|
|
29
40
|
*/
|
|
@@ -32,7 +43,7 @@ export declare class RequestResponse {
|
|
|
32
43
|
* Set the parent request deprecations
|
|
33
44
|
* @param {Object[]} deprecations
|
|
34
45
|
*/
|
|
35
|
-
set deprecations(deprecations: Array<Deprecation> |
|
|
46
|
+
set deprecations(deprecations: Array<Deprecation> | undefined);
|
|
36
47
|
/**
|
|
37
48
|
* Get the parent request status
|
|
38
49
|
* @returns {number}
|
|
@@ -43,7 +54,12 @@ export declare class RequestResponse {
|
|
|
43
54
|
* Request error
|
|
44
55
|
*/
|
|
45
56
|
get error(): KuzzleError | null;
|
|
46
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Narrower than the getter on purpose: `setError` throws an InternalError on
|
|
59
|
+
* anything that is not an Error, so assigning null here has never cleared the
|
|
60
|
+
* error — `KuzzleRequest.clearError()` is what does that.
|
|
61
|
+
*/
|
|
62
|
+
set error(e: KuzzleError);
|
|
47
63
|
/**
|
|
48
64
|
* Request external ID
|
|
49
65
|
*/
|
|
@@ -85,28 +101,47 @@ export declare class RequestResponse {
|
|
|
85
101
|
* Configure the response
|
|
86
102
|
*
|
|
87
103
|
* @param [options]
|
|
104
|
+
* @param [options.result] - Response result. Set only when the key is
|
|
105
|
+
* present, so `{ result: null }` clears it; the status is left to the
|
|
106
|
+
* `status` option, unlike the `result` setter, which resets it to 200
|
|
88
107
|
* @param [options.headers] - Additional protocol headers
|
|
89
|
-
* @param [options.status
|
|
108
|
+
* @param [options.status] - HTTP status code. When absent, a pending 102
|
|
109
|
+
* becomes 200 and any other status is kept
|
|
90
110
|
* @param [options.format] - Response format, standard or raw
|
|
91
111
|
*
|
|
112
|
+
* @throws {InternalError} if the result is an Error
|
|
113
|
+
* @throws {api.assert.forbidden_stream} if the result is an HttpStream and
|
|
114
|
+
* the protocol is not HTTP
|
|
115
|
+
*
|
|
92
116
|
* @returns void
|
|
93
117
|
*/
|
|
94
118
|
configure(options?: {
|
|
95
119
|
headers?: JSONObject;
|
|
96
120
|
status?: number;
|
|
97
121
|
format?: "standard" | "raw";
|
|
122
|
+
result?: unknown;
|
|
98
123
|
}): void;
|
|
99
124
|
/**
|
|
100
125
|
* Gets a header value (case-insensitive)
|
|
126
|
+
*
|
|
127
|
+
* A missing header gives `undefined`, as it always has. The declared
|
|
128
|
+
* `string | null` is v2.56.0's, which code compiled against it assigns to
|
|
129
|
+
* a `string | null` — so test a result with `== null`, which covers both.
|
|
101
130
|
*/
|
|
102
131
|
getHeader(name: string): string | null;
|
|
103
132
|
/**
|
|
104
133
|
* Deletes a header (case-insensitive)
|
|
134
|
+
*
|
|
135
|
+
* Answers `true`. Declared `any`, as v2.56.0 declared it: a `boolean`
|
|
136
|
+
* breaks code compiled against that, e.g. `return` of it from a function
|
|
137
|
+
* declared `void`.
|
|
105
138
|
*/
|
|
106
139
|
removeHeader(name: string): any;
|
|
107
140
|
/**
|
|
108
141
|
* Sets a new array. Behaves the same as Node.js' HTTP response.setHeader
|
|
109
142
|
* method (@see https://nodejs.org/api/http.html#http_response_setheader_name_value)
|
|
143
|
+
*
|
|
144
|
+
* Answers `true`, declared `any` for the reason given on `removeHeader`.
|
|
110
145
|
*/
|
|
111
146
|
setHeader(name: string, value: string): any;
|
|
112
147
|
/**
|
|
@@ -118,3 +153,4 @@ export declare class RequestResponse {
|
|
|
118
153
|
*/
|
|
119
154
|
toJSON(): JSONObject;
|
|
120
155
|
}
|
|
156
|
+
export {};
|