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,39 +1,54 @@
|
|
|
1
|
-
import { StoreCollectionsDefinition } from "../../types";
|
|
2
|
-
import { storeScopeEnum } from "../storage/storeScopeEnum";
|
|
1
|
+
import type { StoreCollectionsDefinition } from "../../types";
|
|
2
|
+
import type { storeScopeEnum } from "../storage/storeScopeEnum";
|
|
3
|
+
type StoreAskMethod = (...args: any[]) => Promise<any>;
|
|
3
4
|
/**
|
|
4
5
|
* Wrapper around the document store.
|
|
5
6
|
* Once instantiated, this class can only access the index passed in the
|
|
6
7
|
* constructor
|
|
7
8
|
*/
|
|
8
9
|
export declare class Store {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Every member below up to `updateMapping` is written by the constructor
|
|
12
|
+
* through `Reflect.set` over `INDEXED_ASK_SUFFIXES`, which no annotation
|
|
13
|
+
* makes visible to the compiler — hence the definite-assignment assertions.
|
|
14
|
+
* Adding a name here without adding it there yields `undefined is not a
|
|
15
|
+
* function` at the first call, which is what the shared suffix map exists to
|
|
16
|
+
* make unlikely.
|
|
17
|
+
*/
|
|
18
|
+
count: StoreAskMethod;
|
|
19
|
+
create: StoreAskMethod;
|
|
20
|
+
createCollection: StoreAskMethod;
|
|
21
|
+
createOrReplace: StoreAskMethod;
|
|
22
|
+
delete: StoreAskMethod;
|
|
23
|
+
deleteByQuery: StoreAskMethod;
|
|
24
|
+
deleteCollection: StoreAskMethod;
|
|
25
|
+
deleteFields: StoreAskMethod;
|
|
26
|
+
deleteIndex: StoreAskMethod;
|
|
27
|
+
exists: StoreAskMethod;
|
|
28
|
+
get: StoreAskMethod;
|
|
29
|
+
getMapping: StoreAskMethod;
|
|
30
|
+
getSettings: StoreAskMethod;
|
|
31
|
+
mExecute: StoreAskMethod;
|
|
32
|
+
mGet: StoreAskMethod;
|
|
33
|
+
refreshCollection: StoreAskMethod;
|
|
34
|
+
replace: StoreAskMethod;
|
|
35
|
+
search: StoreAskMethod;
|
|
36
|
+
truncateCollection: StoreAskMethod;
|
|
37
|
+
update: StoreAskMethod;
|
|
38
|
+
updateByQuery: StoreAskMethod;
|
|
39
|
+
updateCollection: StoreAskMethod;
|
|
40
|
+
updateMapping: StoreAskMethod;
|
|
41
|
+
multiSearch: StoreAskMethod;
|
|
42
|
+
scroll: StoreAskMethod;
|
|
34
43
|
index: string;
|
|
35
44
|
scope: storeScopeEnum;
|
|
36
|
-
|
|
45
|
+
/**
|
|
46
|
+
* `protected`, and not `readonly`: `InternalIndexHandler` has always
|
|
47
|
+
* replaced it with a child logger of its own in its constructor. The
|
|
48
|
+
* JavaScript could do that through a `private` declaration; saying so is
|
|
49
|
+
* what lets the subclass compile.
|
|
50
|
+
*/
|
|
51
|
+
protected logger: import("../../kuzzle/Logger").Logger;
|
|
37
52
|
constructor(index: string, scope: storeScopeEnum);
|
|
38
53
|
/**
|
|
39
54
|
* Initialize the index, and creates provided collections
|
|
@@ -47,6 +62,7 @@ export declare class Store {
|
|
|
47
62
|
* @returns {Promise}
|
|
48
63
|
*/
|
|
49
64
|
createCollections(collections: StoreCollectionsDefinition, { indexCacheOnly }?: {
|
|
50
|
-
indexCacheOnly?: boolean;
|
|
65
|
+
indexCacheOnly?: boolean | undefined;
|
|
51
66
|
}): Promise<any>;
|
|
52
67
|
}
|
|
68
|
+
export {};
|
|
@@ -48,6 +48,41 @@ const kerror = __importStar(require("../../kerror"));
|
|
|
48
48
|
const async_1 = require("../../util/async");
|
|
49
49
|
const esRequest_1 = require("../../util/esRequest");
|
|
50
50
|
const mutex_1 = require("../../util/mutex");
|
|
51
|
+
/**
|
|
52
|
+
* The store methods that are nothing but an ask on a
|
|
53
|
+
* `core:storage:<scope>:<suffix>` event taking the index as its first
|
|
54
|
+
* argument, mapped to that suffix.
|
|
55
|
+
*
|
|
56
|
+
* The constructor's loop is driven by this map, so the 23 `core:storage:` event
|
|
57
|
+
* strings are written once rather than once per method. `multiSearch` and
|
|
58
|
+
* `scroll` are deliberately absent: they are the two that do not take the
|
|
59
|
+
* index, and the constructor assigns them by hand.
|
|
60
|
+
*/
|
|
61
|
+
const INDEXED_ASK_SUFFIXES = {
|
|
62
|
+
count: "document:count",
|
|
63
|
+
create: "document:create",
|
|
64
|
+
createCollection: "collection:create",
|
|
65
|
+
createOrReplace: "document:createOrReplace",
|
|
66
|
+
delete: "document:delete",
|
|
67
|
+
deleteByQuery: "document:deleteByQuery",
|
|
68
|
+
deleteCollection: "collection:delete",
|
|
69
|
+
deleteFields: "document:deleteFields",
|
|
70
|
+
deleteIndex: "index:delete",
|
|
71
|
+
exists: "document:exist",
|
|
72
|
+
get: "document:get",
|
|
73
|
+
getMapping: "mappings:get",
|
|
74
|
+
getSettings: "collection:settings:get",
|
|
75
|
+
mExecute: "document:mExecute",
|
|
76
|
+
mGet: "document:mGet",
|
|
77
|
+
refreshCollection: "collection:refresh",
|
|
78
|
+
replace: "document:replace",
|
|
79
|
+
search: "document:search",
|
|
80
|
+
truncateCollection: "collection:truncate",
|
|
81
|
+
update: "document:update",
|
|
82
|
+
updateByQuery: "document:updateByQuery",
|
|
83
|
+
updateCollection: "collection:update",
|
|
84
|
+
updateMapping: "mappings:update",
|
|
85
|
+
};
|
|
51
86
|
/**
|
|
52
87
|
* Wrapper around the document store.
|
|
53
88
|
* Once instantiated, this class can only access the index passed in the
|
|
@@ -55,36 +90,22 @@ const mutex_1 = require("../../util/mutex");
|
|
|
55
90
|
*/
|
|
56
91
|
class Store {
|
|
57
92
|
constructor(index, scope) {
|
|
93
|
+
/**
|
|
94
|
+
* `protected`, and not `readonly`: `InternalIndexHandler` has always
|
|
95
|
+
* replaced it with a child logger of its own in its constructor. The
|
|
96
|
+
* JavaScript could do that through a `private` declaration; saying so is
|
|
97
|
+
* what lets the subclass compile.
|
|
98
|
+
*/
|
|
58
99
|
this.logger = global.kuzzle.log.child("core:shared:store");
|
|
59
100
|
this.index = index;
|
|
60
101
|
this.scope = scope;
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
deleteCollection: `core:storage:${scope}:collection:delete`,
|
|
69
|
-
deleteFields: `core:storage:${scope}:document:deleteFields`,
|
|
70
|
-
deleteIndex: `core:storage:${scope}:index:delete`,
|
|
71
|
-
exists: `core:storage:${scope}:document:exist`,
|
|
72
|
-
get: `core:storage:${scope}:document:get`,
|
|
73
|
-
getMapping: `core:storage:${scope}:mappings:get`,
|
|
74
|
-
getSettings: `core:storage:${scope}:collection:settings:get`,
|
|
75
|
-
mExecute: `core:storage:${scope}:document:mExecute`,
|
|
76
|
-
mGet: `core:storage:${scope}:document:mGet`,
|
|
77
|
-
refreshCollection: `core:storage:${scope}:collection:refresh`,
|
|
78
|
-
replace: `core:storage:${scope}:document:replace`,
|
|
79
|
-
search: `core:storage:${scope}:document:search`,
|
|
80
|
-
truncateCollection: `core:storage:${scope}:collection:truncate`,
|
|
81
|
-
update: `core:storage:${scope}:document:update`,
|
|
82
|
-
updateByQuery: `core:storage:${scope}:document:updateByQuery`,
|
|
83
|
-
updateCollection: `core:storage:${scope}:collection:update`,
|
|
84
|
-
updateMapping: `core:storage:${scope}:mappings:update`,
|
|
85
|
-
};
|
|
86
|
-
for (const [method, event] of Object.entries(methodsMapping)) {
|
|
87
|
-
this[method] = (...args) => global.kuzzle.ask(event, this.index, ...args);
|
|
102
|
+
for (const [method, suffix] of Object.entries(INDEXED_ASK_SUFFIXES)) {
|
|
103
|
+
const event = `core:storage:${scope}:${suffix}`;
|
|
104
|
+
// `method` is a runtime key over the mapping above, so a plain
|
|
105
|
+
// `this[method] = ...` cannot be typed without an index signature that
|
|
106
|
+
// would swallow every real member — the trade-off TD-28 settled with
|
|
107
|
+
// `Reflect.set` in `memoryStorageController` and `baseController`.
|
|
108
|
+
Reflect.set(this, method, (...args) => global.kuzzle.ask(event, this.index, ...args));
|
|
88
109
|
}
|
|
89
110
|
// the scroll and multiSearch method are special: they doesn't need an index parameter
|
|
90
111
|
// we keep them for ease of use
|
|
@@ -1,29 +1,43 @@
|
|
|
1
|
-
|
|
1
|
+
import type { JSONObject } from "../../types/JSONObject";
|
|
2
|
+
import { Elasticsearch } from "../../service/storage/Elasticsearch";
|
|
3
|
+
import { IndexCache } from "./indexCache";
|
|
4
|
+
import type { storeScopeEnum } from "./storeScopeEnum";
|
|
5
|
+
import "../../types/Global";
|
|
6
|
+
/** Where `createIndex` / `createCollection` / `loadMappings` write, and whether
|
|
7
|
+
* the change is broadcast to the rest of the cluster. */
|
|
8
|
+
interface WriteScopeOptions {
|
|
9
|
+
indexCacheOnly?: boolean;
|
|
10
|
+
propagate?: boolean;
|
|
11
|
+
}
|
|
12
|
+
interface LoadMappingsOptions extends WriteScopeOptions {
|
|
13
|
+
rawMappings?: boolean;
|
|
14
|
+
refresh?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** `{ index: { collection: payload } }`, as the fixtures and mappings
|
|
17
|
+
* import payloads are shaped. */
|
|
18
|
+
type ImportPayload = Record<string, Record<string, JSONObject>>;
|
|
2
19
|
/**
|
|
3
20
|
* Storage client adapter to perform validation on index/collection existence
|
|
4
21
|
* and to maintain the index/collection cache.
|
|
5
22
|
*/
|
|
6
23
|
declare class ClientAdapter {
|
|
24
|
+
es: Elasticsearch;
|
|
7
25
|
/**
|
|
8
|
-
*
|
|
26
|
+
* The version-specific ES service (ES7 or ES8). Its type is whatever
|
|
27
|
+
* `Elasticsearch` exposes — which is `any` today, and is tracked there as
|
|
28
|
+
* TD-13; referencing it rather than re-writing `any` keeps that one hole
|
|
29
|
+
* counted once, at its source.
|
|
9
30
|
*/
|
|
10
|
-
|
|
11
|
-
es: Elasticsearch;
|
|
12
|
-
client: any;
|
|
31
|
+
client: Elasticsearch["client"];
|
|
13
32
|
scope: storeScopeEnum;
|
|
14
33
|
cache: IndexCache;
|
|
34
|
+
constructor(scope: storeScopeEnum);
|
|
15
35
|
init(): Promise<void>;
|
|
16
|
-
createIndex(index:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
indexCacheOnly?: boolean;
|
|
22
|
-
propagate?: boolean;
|
|
23
|
-
}): Promise<void>;
|
|
24
|
-
deleteIndex(index: any): Promise<void>;
|
|
25
|
-
deleteIndexes(indexes: any): Promise<any>;
|
|
26
|
-
deleteCollection(index: any, collection: any): Promise<void>;
|
|
36
|
+
createIndex(index: string, { indexCacheOnly, propagate }?: WriteScopeOptions): Promise<void>;
|
|
37
|
+
createCollection(index: string, collection: string, opts: JSONObject, { indexCacheOnly, propagate }?: WriteScopeOptions): Promise<void>;
|
|
38
|
+
deleteIndex(index: string): Promise<void>;
|
|
39
|
+
deleteIndexes(indexes: string[]): Promise<string[]>;
|
|
40
|
+
deleteCollection(index: string, collection: string): Promise<void>;
|
|
27
41
|
/**
|
|
28
42
|
* Populates the index cache with existing index/collection.
|
|
29
43
|
* Also checks for duplicated index names.
|
|
@@ -44,9 +58,9 @@ declare class ClientAdapter {
|
|
|
44
58
|
* @param {String} fixturesId
|
|
45
59
|
* @returns {Promise}
|
|
46
60
|
*/
|
|
47
|
-
loadFixtures(fixtures?:
|
|
61
|
+
loadFixtures(fixtures?: ImportPayload, { refresh }?: {
|
|
48
62
|
refresh?: string;
|
|
49
|
-
}): Promise<
|
|
63
|
+
}): Promise<void>;
|
|
50
64
|
/**
|
|
51
65
|
* Load database mappings into Kuzzle
|
|
52
66
|
*
|
|
@@ -56,7 +70,11 @@ declare class ClientAdapter {
|
|
|
56
70
|
* - indexCacheOnly (false): only update the cache, don't update the database
|
|
57
71
|
* @returns {Promise}
|
|
58
72
|
*/
|
|
59
|
-
loadMappings(fixtures?:
|
|
73
|
+
loadMappings(fixtures?: ImportPayload, options?: LoadMappingsOptions): Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Creates one index/collection pair from an import payload. Extracted from
|
|
76
|
+
* `loadMappings` verbatim.
|
|
77
|
+
*/
|
|
78
|
+
private _loadCollectionMappings;
|
|
60
79
|
}
|
|
61
|
-
|
|
62
|
-
import { IndexCache } from "./indexCache";
|
|
80
|
+
export = ClientAdapter;
|
|
@@ -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,26 +19,54 @@
|
|
|
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
|
-
|
|
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 Elasticsearch_1 = require("../../service/storage/Elasticsearch");
|
|
46
|
+
const indexCache_1 = require("./indexCache");
|
|
47
|
+
const safeObject_1 = require("../../util/safeObject");
|
|
48
|
+
const kerror = __importStar(require("../../kerror"));
|
|
49
|
+
const mutex_1 = require("../../util/mutex"); // NOSONAR: see loadMappings
|
|
50
|
+
require("../../types/Global");
|
|
27
51
|
const servicesError = kerror.wrap("services", "storage");
|
|
52
|
+
/** Hoisted out of the signature: an object literal as a default parameter is
|
|
53
|
+
* re-allocated on every call, and this one is only ever read. */
|
|
54
|
+
const DEFAULT_LOAD_MAPPINGS_OPTIONS = Object.freeze({
|
|
55
|
+
indexCacheOnly: false,
|
|
56
|
+
propagate: true,
|
|
57
|
+
rawMappings: false,
|
|
58
|
+
refresh: false,
|
|
59
|
+
});
|
|
28
60
|
/**
|
|
29
61
|
* Storage client adapter to perform validation on index/collection existence
|
|
30
62
|
* and to maintain the index/collection cache.
|
|
31
63
|
*/
|
|
32
64
|
class ClientAdapter {
|
|
33
|
-
/**
|
|
34
|
-
* @param {storeScopeEnum} scope
|
|
35
|
-
*/
|
|
36
65
|
constructor(scope) {
|
|
37
|
-
this.es = new Elasticsearch(global.kuzzle.config.services.storageEngine, scope);
|
|
66
|
+
this.es = new Elasticsearch_1.Elasticsearch(global.kuzzle.config.services.storageEngine, scope);
|
|
38
67
|
this.client = this.es.client;
|
|
39
68
|
this.scope = scope;
|
|
40
|
-
this.cache = new IndexCache();
|
|
69
|
+
this.cache = new indexCache_1.IndexCache();
|
|
41
70
|
}
|
|
42
71
|
async init() {
|
|
43
72
|
await this.es.init();
|
|
@@ -136,6 +165,8 @@ class ClientAdapter {
|
|
|
136
165
|
if (global.kuzzle.config.services.storageEngine.generateMissingAliases) {
|
|
137
166
|
await this.client.generateMissingAliases();
|
|
138
167
|
}
|
|
168
|
+
// `client` is untyped (see the field's comment), so the schema shape is
|
|
169
|
+
// stated here: index name -> its collection names.
|
|
139
170
|
const schema = await this.client.getSchema();
|
|
140
171
|
for (const [index, collections] of Object.entries(schema)) {
|
|
141
172
|
this.cache.addIndex(index);
|
|
@@ -682,14 +713,17 @@ class ClientAdapter {
|
|
|
682
713
|
* @returns {Promise}
|
|
683
714
|
*/
|
|
684
715
|
async loadFixtures(fixtures = {}, { refresh = "wait_for" } = {}) {
|
|
685
|
-
if (!isPlainObject(fixtures)) {
|
|
716
|
+
if (!(0, safeObject_1.isPlainObject)(fixtures)) {
|
|
686
717
|
throw kerror.get("api", "assert", "invalid_argument", fixtures, "object");
|
|
687
718
|
}
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
719
|
+
// `Object.entries`, not `keys` + three indexed reads: the value comes back
|
|
720
|
+
// with the key and there is nothing left for `noUncheckedIndexedAccess` to
|
|
721
|
+
// object to.
|
|
722
|
+
for (const [index, collections] of Object.entries(fixtures)) {
|
|
723
|
+
if (!(0, safeObject_1.isPlainObject)(collections)) {
|
|
724
|
+
throw kerror.get("api", "assert", "invalid_argument", collections, "object");
|
|
691
725
|
}
|
|
692
|
-
for (const [collection, payload] of Object.entries(
|
|
726
|
+
for (const [collection, payload] of Object.entries(collections)) {
|
|
693
727
|
this.cache.assertCollectionExists(index, collection);
|
|
694
728
|
const { errors } = await this.client.import(index, collection, payload, { refresh });
|
|
695
729
|
if (errors.length > 0) {
|
|
@@ -707,43 +741,22 @@ class ClientAdapter {
|
|
|
707
741
|
* - indexCacheOnly (false): only update the cache, don't update the database
|
|
708
742
|
* @returns {Promise}
|
|
709
743
|
*/
|
|
710
|
-
async loadMappings(fixtures = {}, options = {
|
|
711
|
-
|
|
712
|
-
propagate: true,
|
|
713
|
-
rawMappings: false,
|
|
714
|
-
refresh: false,
|
|
715
|
-
}) {
|
|
716
|
-
if (!isPlainObject(fixtures)) {
|
|
744
|
+
async loadMappings(fixtures = {}, options = DEFAULT_LOAD_MAPPINGS_OPTIONS) {
|
|
745
|
+
if (!(0, safeObject_1.isPlainObject)(fixtures)) {
|
|
717
746
|
throw kerror.get("api", "assert", "invalid_argument", fixtures, "object");
|
|
718
747
|
}
|
|
719
|
-
|
|
748
|
+
// NOSONAR: `Mutex` is deprecated in favour of `withLock`, but the two use
|
|
749
|
+
// incompatible acquisition/TTL formats and must not contend on the same
|
|
750
|
+
// key — swapping it is a behaviour change, deferred to #2894.
|
|
751
|
+
const mutex = new mutex_1.Mutex("loadMappings", { timeout: -1, ttl: 60000 }); // NOSONAR
|
|
720
752
|
await mutex.lock();
|
|
721
753
|
try {
|
|
722
|
-
for (const index of Object.
|
|
723
|
-
if (!isPlainObject(
|
|
724
|
-
throw kerror.get("api", "assert", "invalid_argument",
|
|
754
|
+
for (const [index, collections] of Object.entries(fixtures)) {
|
|
755
|
+
if (!(0, safeObject_1.isPlainObject)(collections)) {
|
|
756
|
+
throw kerror.get("api", "assert", "invalid_argument", collections, "object");
|
|
725
757
|
}
|
|
726
|
-
for (const [collection, mappings] of Object.entries(
|
|
727
|
-
|
|
728
|
-
await this.createIndex(index, {
|
|
729
|
-
indexCacheOnly: options.indexCacheOnly,
|
|
730
|
-
propagate: options.propagate,
|
|
731
|
-
});
|
|
732
|
-
}
|
|
733
|
-
catch (error) {
|
|
734
|
-
// @cluster: ignore if the index already exists to prevent race
|
|
735
|
-
// conditions with index cache propagation
|
|
736
|
-
if (error.id !== "services.storage.index_already_exists") {
|
|
737
|
-
throw error;
|
|
738
|
-
}
|
|
739
|
-
}
|
|
740
|
-
await this.createCollection(index, collection, options.rawMappings ? { mappings } : mappings, {
|
|
741
|
-
indexCacheOnly: options.indexCacheOnly,
|
|
742
|
-
propagate: options.propagate,
|
|
743
|
-
});
|
|
744
|
-
if (options.refresh && !options.indexCacheOnly) {
|
|
745
|
-
await this.client.refreshCollection(index, collection);
|
|
746
|
-
}
|
|
758
|
+
for (const [collection, mappings] of Object.entries(collections)) {
|
|
759
|
+
await this._loadCollectionMappings(index, collection, mappings, options);
|
|
747
760
|
}
|
|
748
761
|
}
|
|
749
762
|
}
|
|
@@ -751,6 +764,33 @@ class ClientAdapter {
|
|
|
751
764
|
await mutex.unlock();
|
|
752
765
|
}
|
|
753
766
|
}
|
|
767
|
+
/**
|
|
768
|
+
* Creates one index/collection pair from an import payload. Extracted from
|
|
769
|
+
* `loadMappings` verbatim.
|
|
770
|
+
*/
|
|
771
|
+
async _loadCollectionMappings(index, collection, mappings, options) {
|
|
772
|
+
try {
|
|
773
|
+
await this.createIndex(index, {
|
|
774
|
+
indexCacheOnly: options.indexCacheOnly,
|
|
775
|
+
propagate: options.propagate,
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
catch (error) {
|
|
779
|
+
// @cluster: ignore if the index already exists to prevent race
|
|
780
|
+
// conditions with index cache propagation
|
|
781
|
+
if (error.id !==
|
|
782
|
+
"services.storage.index_already_exists") {
|
|
783
|
+
throw error;
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
await this.createCollection(index, collection, options.rawMappings ? { mappings } : mappings, {
|
|
787
|
+
indexCacheOnly: options.indexCacheOnly,
|
|
788
|
+
propagate: options.propagate,
|
|
789
|
+
});
|
|
790
|
+
if (options.refresh && !options.indexCacheOnly) {
|
|
791
|
+
await this.client.refreshCollection(index, collection);
|
|
792
|
+
}
|
|
793
|
+
}
|
|
754
794
|
}
|
|
755
795
|
module.exports = ClientAdapter;
|
|
756
796
|
//# sourceMappingURL=clientAdapter.js.map
|
|
@@ -48,6 +48,14 @@ export declare class IndexCache {
|
|
|
48
48
|
* @throws If the index does not exist
|
|
49
49
|
*/
|
|
50
50
|
assertIndexExists(index: string): void;
|
|
51
|
+
/**
|
|
52
|
+
* Answers an index's collections, or throws if the index is not cached.
|
|
53
|
+
*
|
|
54
|
+
* One lookup for both questions: `has()` followed by `get()` left every
|
|
55
|
+
* caller holding an invariant the Map had already been asked about, one line
|
|
56
|
+
* away from the answer.
|
|
57
|
+
*/
|
|
58
|
+
private getCollections;
|
|
51
59
|
/**
|
|
52
60
|
* Assert that the provided index and collection exist
|
|
53
61
|
*/
|
|
@@ -73,8 +73,7 @@ class IndexCache {
|
|
|
73
73
|
*/
|
|
74
74
|
addCollection(index, collection) {
|
|
75
75
|
this.addIndex(index);
|
|
76
|
-
|
|
77
|
-
collections.add(collection);
|
|
76
|
+
this.getCollections(index).add(collection);
|
|
78
77
|
}
|
|
79
78
|
/**
|
|
80
79
|
* Check an index existence
|
|
@@ -104,8 +103,7 @@ class IndexCache {
|
|
|
104
103
|
* @throws If the provided index does not exist
|
|
105
104
|
*/
|
|
106
105
|
listCollections(index) {
|
|
107
|
-
this.
|
|
108
|
-
return Array.from(this.indexes.get(index));
|
|
106
|
+
return Array.from(this.getCollections(index));
|
|
109
107
|
}
|
|
110
108
|
/**
|
|
111
109
|
* Remove an index from the cache
|
|
@@ -128,16 +126,27 @@ class IndexCache {
|
|
|
128
126
|
* @throws If the index does not exist
|
|
129
127
|
*/
|
|
130
128
|
assertIndexExists(index) {
|
|
131
|
-
|
|
129
|
+
this.getCollections(index);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Answers an index's collections, or throws if the index is not cached.
|
|
133
|
+
*
|
|
134
|
+
* One lookup for both questions: `has()` followed by `get()` left every
|
|
135
|
+
* caller holding an invariant the Map had already been asked about, one line
|
|
136
|
+
* away from the answer.
|
|
137
|
+
*/
|
|
138
|
+
getCollections(index) {
|
|
139
|
+
const collections = this.indexes.get(index);
|
|
140
|
+
if (collections === undefined) {
|
|
132
141
|
throw storageError.get("unknown_index", index);
|
|
133
142
|
}
|
|
143
|
+
return collections;
|
|
134
144
|
}
|
|
135
145
|
/**
|
|
136
146
|
* Assert that the provided index and collection exist
|
|
137
147
|
*/
|
|
138
148
|
assertCollectionExists(index, collection) {
|
|
139
|
-
this.
|
|
140
|
-
if (!this.indexes.get(index).has(collection)) {
|
|
149
|
+
if (!this.getCollections(index).has(collection)) {
|
|
141
150
|
throw storageError.get("unknown_collection", index, collection);
|
|
142
151
|
}
|
|
143
152
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import ClientAdapter from "./clientAdapter";
|
|
2
|
+
import type { Logger } from "../../kuzzle/Logger";
|
|
3
|
+
import "../../types/Global";
|
|
2
4
|
declare class StorageEngine {
|
|
3
5
|
public: ClientAdapter;
|
|
4
6
|
private: ClientAdapter;
|
|
5
|
-
logger:
|
|
7
|
+
logger: Logger;
|
|
8
|
+
constructor();
|
|
6
9
|
/**
|
|
7
10
|
* Initialize storage clients and perform integrity checks
|
|
8
|
-
*
|
|
9
|
-
* @returns {Promise}
|
|
10
11
|
*/
|
|
11
|
-
init(): Promise<
|
|
12
|
+
init(): Promise<void>;
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
+
export = StorageEngine;
|
|
@@ -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,23 +19,25 @@
|
|
|
18
19
|
* See the License for the specific language governing permissions and
|
|
19
20
|
* limitations under the License.
|
|
20
21
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
22
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
+
};
|
|
25
|
+
const kerror_1 = require("../../kerror");
|
|
26
|
+
const clientAdapter_1 = __importDefault(require("./clientAdapter"));
|
|
27
|
+
const storeScopeEnum_1 = require("./storeScopeEnum");
|
|
28
|
+
require("../../types/Global");
|
|
29
|
+
const kerror = (0, kerror_1.wrap)("services", "storage");
|
|
25
30
|
class StorageEngine {
|
|
26
31
|
constructor() {
|
|
27
32
|
// Storage client for public indexes only
|
|
28
|
-
this.public = new
|
|
33
|
+
this.public = new clientAdapter_1.default(storeScopeEnum_1.storeScopeEnum.PUBLIC);
|
|
29
34
|
// Storage client for private indexes only
|
|
30
|
-
this.private = new
|
|
35
|
+
this.private = new clientAdapter_1.default(storeScopeEnum_1.storeScopeEnum.PRIVATE);
|
|
31
36
|
this.logger = global.kuzzle.log.child("core:storage:storageEngine");
|
|
32
37
|
this.logger.info(`[ℹ] Elasticsearch configuration is set to major version : ${global.kuzzle.config.services.storageEngine.majorVersion}`);
|
|
33
38
|
}
|
|
34
39
|
/**
|
|
35
40
|
* Initialize storage clients and perform integrity checks
|
|
36
|
-
*
|
|
37
|
-
* @returns {Promise}
|
|
38
41
|
*/
|
|
39
42
|
async init() {
|
|
40
43
|
await Promise.all([this.public.init(), this.private.init()]);
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
|
|
1
|
+
import type { TypeOptions } from "./typeOptions";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Base class of every validation type, and the contract `Validation.addType`
|
|
4
|
+
* checks a plugin-provided type against.
|
|
5
|
+
*
|
|
6
|
+
* @typeParam TOptions - the `typeOptions` shape this type accepts, once
|
|
7
|
+
* `validateFieldSpecification` has run
|
|
8
|
+
* @typeParam TSpecification - the `typeOptions` shape a user writes, which
|
|
9
|
+
* `validateFieldSpecification` checks and normalises into `TOptions`; the
|
|
10
|
+
* same shape unless the type converts something
|
|
4
11
|
*/
|
|
5
|
-
declare class BaseType {
|
|
12
|
+
declare class BaseType<TOptions extends TypeOptions = TypeOptions, TSpecification extends TypeOptions = TOptions> {
|
|
13
|
+
/** Name under which the type is registered */
|
|
14
|
+
typeName: string;
|
|
15
|
+
/** Whether fields of that type may declare children */
|
|
16
|
+
allowChildren: boolean;
|
|
17
|
+
/** `typeOptions` properties the type recognizes */
|
|
18
|
+
allowedTypeOptions: string[];
|
|
6
19
|
/**
|
|
7
20
|
* Validate a document against a registered field type validator
|
|
8
|
-
*
|
|
9
|
-
* @param {TypeOptions} typeOptions
|
|
10
|
-
* @param {*} fieldValue
|
|
11
|
-
* @param {string[]} errorMessages
|
|
12
|
-
* @returns {boolean}
|
|
13
21
|
*/
|
|
14
|
-
validate(): boolean;
|
|
22
|
+
validate(typeOptions?: TOptions, fieldValue?: unknown, errorMessages?: string[]): boolean;
|
|
15
23
|
/**
|
|
16
24
|
* Validate a field specification itself
|
|
17
25
|
*
|
|
18
|
-
* @param {TypeOptions} typeOptions
|
|
19
|
-
* @returns {TypeOptions}
|
|
20
26
|
* @throws {KuzzleError}
|
|
21
27
|
*/
|
|
22
|
-
validateFieldSpecification(opts:
|
|
28
|
+
validateFieldSpecification(opts: TSpecification): TOptions;
|
|
23
29
|
/**
|
|
24
|
-
*
|
|
25
|
-
* @param {string[]} allowedProperties
|
|
26
|
-
* @returns {boolean}
|
|
30
|
+
* Narrows `object` to a plain object holding none but the allowed properties.
|
|
27
31
|
*/
|
|
28
|
-
checkAllowedProperties(object:
|
|
29
|
-
|
|
30
|
-
* @param {StructuredFieldSpecification} fieldSpec
|
|
31
|
-
* @param {boolean} parentStrictness
|
|
32
|
-
* @returns {boolean}
|
|
33
|
-
*/
|
|
34
|
-
getStrictness(fieldSpec: StructuredFieldSpecification, parentStrictness: boolean): boolean;
|
|
32
|
+
checkAllowedProperties(object: unknown, allowedProperties: string[]): object is Record<string, unknown>;
|
|
33
|
+
getStrictness(fieldSpec: TOptions, parentStrictness: boolean): boolean;
|
|
35
34
|
}
|
|
35
|
+
export = BaseType;
|