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.
Files changed (408) hide show
  1. package/dist/bin/copy-binaries.js +71 -4
  2. package/dist/bin/start-kuzzle-server +191 -97
  3. package/dist/index.d.ts +31 -1
  4. package/dist/index.js +45 -2
  5. package/dist/lib/api/controllers/adminController.d.ts +4 -3
  6. package/dist/lib/api/controllers/adminController.js +1 -2
  7. package/dist/lib/api/controllers/authController.d.ts +37 -16
  8. package/dist/lib/api/controllers/authController.js +88 -39
  9. package/dist/lib/api/controllers/baseController.d.ts +10 -5
  10. package/dist/lib/api/controllers/baseController.js +36 -15
  11. package/dist/lib/api/controllers/bulkController.d.ts +11 -7
  12. package/dist/lib/api/controllers/bulkController.js +28 -5
  13. package/dist/lib/api/controllers/clusterController.d.ts +2 -2
  14. package/dist/lib/api/controllers/clusterController.js +3 -3
  15. package/dist/lib/api/controllers/collectionController.d.ts +57 -21
  16. package/dist/lib/api/controllers/collectionController.js +40 -11
  17. package/dist/lib/api/controllers/debugController.d.ts +1 -1
  18. package/dist/lib/api/controllers/documentController.d.ts +137 -28
  19. package/dist/lib/api/controllers/documentController.js +156 -125
  20. package/dist/lib/api/controllers/index.d.ts +27 -12
  21. package/dist/lib/api/controllers/index.js +28 -13
  22. package/dist/lib/api/controllers/indexController.d.ts +17 -10
  23. package/dist/lib/api/controllers/indexController.js +13 -11
  24. package/dist/lib/api/controllers/memoryStorageController.d.ts +2 -5
  25. package/dist/lib/api/controllers/memoryStorageController.js +199 -127
  26. package/dist/lib/api/controllers/realtimeController.d.ts +19 -9
  27. package/dist/lib/api/controllers/realtimeController.js +8 -4
  28. package/dist/lib/api/controllers/securityController.d.ts +42 -29
  29. package/dist/lib/api/controllers/securityController.js +35 -19
  30. package/dist/lib/api/controllers/serverController.d.ts +114 -19
  31. package/dist/lib/api/controllers/serverController.js +69 -29
  32. package/dist/lib/api/documentExtractor.d.ts +9 -7
  33. package/dist/lib/api/documentExtractor.js +105 -41
  34. package/dist/lib/api/funnel.d.ts +131 -29
  35. package/dist/lib/api/funnel.js +436 -225
  36. package/dist/lib/api/httpRoutes.d.ts +16 -11
  37. package/dist/lib/api/httpRoutes.js +272 -2
  38. package/dist/lib/api/openapi/OpenApiManager.d.ts +1 -1
  39. package/dist/lib/api/openapi/openApiGenerator.d.ts +1 -1
  40. package/dist/lib/api/rateLimiter.d.ts +15 -5
  41. package/dist/lib/api/rateLimiter.js +42 -14
  42. package/dist/lib/api/request/kuzzleRequest.d.ts +83 -12
  43. package/dist/lib/api/request/kuzzleRequest.js +88 -23
  44. package/dist/lib/api/request/requestContext.d.ts +20 -5
  45. package/dist/lib/api/request/requestContext.js +14 -4
  46. package/dist/lib/api/request/requestInput.d.ts +37 -6
  47. package/dist/lib/api/request/requestInput.js +22 -9
  48. package/dist/lib/api/request/requestResponse.d.ts +45 -9
  49. package/dist/lib/api/request/requestResponse.js +34 -3
  50. package/dist/lib/cluster/command.d.ts +131 -37
  51. package/dist/lib/cluster/command.js +243 -71
  52. package/dist/lib/cluster/idCardHandler.d.ts +18 -5
  53. package/dist/lib/cluster/idCardHandler.js +52 -19
  54. package/dist/lib/cluster/index.d.ts +8 -2
  55. package/dist/lib/cluster/index.js +6 -2
  56. package/dist/lib/cluster/node.d.ts +127 -49
  57. package/dist/lib/cluster/node.js +412 -179
  58. package/dist/lib/cluster/protobuf/command.proto +18 -0
  59. package/dist/lib/cluster/protobuf/commandMessages.d.ts +104 -0
  60. package/dist/lib/cluster/protobuf/commandMessages.js +30 -0
  61. package/dist/lib/cluster/protobuf/syncMessages.d.ts +184 -0
  62. package/dist/lib/cluster/protobuf/syncMessages.js +23 -0
  63. package/dist/lib/cluster/publisher.d.ts +118 -78
  64. package/dist/lib/cluster/publisher.js +174 -72
  65. package/dist/lib/cluster/state.d.ts +15 -9
  66. package/dist/lib/cluster/state.js +12 -8
  67. package/dist/lib/cluster/subscriber.d.ts +185 -131
  68. package/dist/lib/cluster/subscriber.js +357 -95
  69. package/dist/lib/cluster/workers/IDCardRenewer.d.ts +39 -8
  70. package/dist/lib/cluster/workers/IDCardRenewer.js +88 -23
  71. package/dist/lib/config/default.config.d.ts +2 -2
  72. package/dist/lib/config/default.config.js +10 -3
  73. package/dist/lib/config/documentEventAliases.d.ts +1 -1
  74. package/dist/lib/config/index.d.ts +2 -5
  75. package/dist/lib/config/index.js +30 -17
  76. package/dist/lib/core/auth/formatProcessing.d.ts +3 -3
  77. package/dist/lib/core/auth/passportResponse.d.ts +1 -1
  78. package/dist/lib/core/auth/passportWrapper.d.ts +1 -1
  79. package/dist/lib/core/auth/passportWrapper.js +14 -13
  80. package/dist/lib/core/auth/tokenManager.d.ts +24 -3
  81. package/dist/lib/core/auth/tokenManager.js +47 -19
  82. package/dist/lib/core/backend/applicationManager.d.ts +2 -2
  83. package/dist/lib/core/backend/backend.d.ts +16 -5
  84. package/dist/lib/core/backend/backend.js +14 -6
  85. package/dist/lib/core/backend/backendCluster.d.ts +1 -1
  86. package/dist/lib/core/backend/backendConfig.d.ts +17 -5
  87. package/dist/lib/core/backend/backendConfig.js +1 -0
  88. package/dist/lib/core/backend/backendController.d.ts +1 -1
  89. package/dist/lib/core/backend/backendController.js +8 -1
  90. package/dist/lib/core/backend/backendErrors.d.ts +15 -8
  91. package/dist/lib/core/backend/backendErrors.js +5 -0
  92. package/dist/lib/core/backend/backendHook.d.ts +1 -1
  93. package/dist/lib/core/backend/backendImport.d.ts +1 -1
  94. package/dist/lib/core/backend/backendOpenApi.d.ts +3 -2
  95. package/dist/lib/core/backend/backendPipe.d.ts +1 -1
  96. package/dist/lib/core/backend/backendPipe.js +9 -1
  97. package/dist/lib/core/backend/backendPlugin.d.ts +2 -2
  98. package/dist/lib/core/backend/backendSubscription.d.ts +2 -2
  99. package/dist/lib/core/backend/backendVault.d.ts +1 -1
  100. package/dist/lib/core/backend/backendVault.js +8 -1
  101. package/dist/lib/core/cache/cacheEngine.d.ts +7 -4
  102. package/dist/lib/core/cache/cacheEngine.js +25 -8
  103. package/dist/lib/core/debug/kuzzleDebugger.d.ts +2 -1
  104. package/dist/lib/core/debug/kuzzleDebugger.js +31 -17
  105. package/dist/lib/core/network/accessLogger.d.ts +33 -18
  106. package/dist/lib/core/network/accessLogger.js +135 -73
  107. package/dist/lib/core/network/clientConnection.d.ts +13 -11
  108. package/dist/lib/core/network/clientConnection.js +33 -9
  109. package/dist/lib/core/network/context.d.ts +17 -22
  110. package/dist/lib/core/network/context.js +43 -26
  111. package/dist/lib/core/network/entryPoint.d.ts +38 -16
  112. package/dist/lib/core/network/entryPoint.js +119 -48
  113. package/dist/lib/core/network/httpRouter/index.d.ts +20 -50
  114. package/dist/lib/core/network/httpRouter/index.js +61 -75
  115. package/dist/lib/core/network/httpRouter/routeHandler.d.ts +17 -32
  116. package/dist/lib/core/network/httpRouter/routeHandler.js +26 -36
  117. package/dist/lib/core/network/httpRouter/routePart.d.ts +9 -18
  118. package/dist/lib/core/network/httpRouter/routePart.js +61 -43
  119. package/dist/lib/core/network/httpRouter/routeTypes.d.ts +3 -0
  120. package/dist/lib/core/network/httpRouter/routeTypes.js +23 -0
  121. package/dist/lib/core/network/networkEntryPoint.d.ts +20 -0
  122. package/dist/lib/core/network/networkEntryPoint.js +23 -0
  123. package/dist/lib/core/network/protocolManifest.d.ts +5 -4
  124. package/dist/lib/core/network/protocolManifest.js +6 -3
  125. package/dist/lib/core/network/protocols/httpMessage.d.ts +25 -18
  126. package/dist/lib/core/network/protocols/httpMessage.js +14 -11
  127. package/dist/lib/core/network/protocols/httpwsProtocol.d.ts +84 -93
  128. package/dist/lib/core/network/protocols/httpwsProtocol.js +284 -129
  129. package/dist/lib/core/network/protocols/internalProtocol.d.ts +26 -15
  130. package/dist/lib/core/network/protocols/internalProtocol.js +17 -16
  131. package/dist/lib/core/network/protocols/mqttProtocol.d.ts +56 -32
  132. package/dist/lib/core/network/protocols/mqttProtocol.js +91 -44
  133. package/dist/lib/core/network/protocols/protocol.d.ts +85 -21
  134. package/dist/lib/core/network/protocols/protocol.js +83 -27
  135. package/dist/lib/core/network/router.d.ts +13 -22
  136. package/dist/lib/core/network/router.js +59 -46
  137. package/dist/lib/core/plugin/plugin.d.ts +57 -51
  138. package/dist/lib/core/plugin/plugin.js +218 -103
  139. package/dist/lib/core/plugin/pluginContext.d.ts +54 -11
  140. package/dist/lib/core/plugin/pluginContext.js +99 -58
  141. package/dist/lib/core/plugin/pluginManifest.d.ts +6 -2
  142. package/dist/lib/core/plugin/pluginManifest.js +18 -11
  143. package/dist/lib/core/plugin/pluginRepository.d.ts +35 -44
  144. package/dist/lib/core/plugin/pluginRepository.js +35 -50
  145. package/dist/lib/core/plugin/pluginsManager.d.ts +128 -46
  146. package/dist/lib/core/plugin/pluginsManager.js +468 -231
  147. package/dist/lib/core/plugin/privilegedContext.d.ts +4 -9
  148. package/dist/lib/core/plugin/privilegedContext.js +5 -10
  149. package/dist/lib/core/realtime/actionEnum.d.ts +12 -21
  150. package/dist/lib/core/realtime/actionEnum.js +6 -7
  151. package/dist/lib/core/realtime/channel.d.ts +11 -5
  152. package/dist/lib/core/realtime/channel.js +17 -2
  153. package/dist/lib/core/realtime/connectionRooms.d.ts +2 -2
  154. package/dist/lib/core/realtime/hotelClerk.d.ts +12 -6
  155. package/dist/lib/core/realtime/hotelClerk.js +29 -11
  156. package/dist/lib/core/realtime/index.d.ts +8 -3
  157. package/dist/lib/core/realtime/index.js +12 -5
  158. package/dist/lib/core/realtime/notification/document.d.ts +54 -25
  159. package/dist/lib/core/realtime/notification/document.js +10 -13
  160. package/dist/lib/core/realtime/notification/index.d.ts +9 -3
  161. package/dist/lib/core/realtime/notification/index.js +10 -4
  162. package/dist/lib/core/realtime/notification/server.d.ts +7 -10
  163. package/dist/lib/core/realtime/notification/server.js +4 -7
  164. package/dist/lib/core/realtime/notification/user.d.ts +45 -21
  165. package/dist/lib/core/realtime/notification/user.js +8 -9
  166. package/dist/lib/core/realtime/notifier.d.ts +52 -40
  167. package/dist/lib/core/realtime/notifier.js +60 -25
  168. package/dist/lib/core/realtime/room.d.ts +1 -1
  169. package/dist/lib/core/realtime/subscription.d.ts +11 -6
  170. package/dist/lib/core/realtime/subscription.js +5 -1
  171. package/dist/lib/core/security/index.d.ts +14 -6
  172. package/dist/lib/core/security/index.js +27 -13
  173. package/dist/lib/core/security/profileRepository.d.ts +24 -19
  174. package/dist/lib/core/security/profileRepository.js +23 -10
  175. package/dist/lib/core/security/roleRepository.d.ts +60 -23
  176. package/dist/lib/core/security/roleRepository.js +122 -53
  177. package/dist/lib/core/security/securityLoader.d.ts +33 -18
  178. package/dist/lib/core/security/securityLoader.js +43 -16
  179. package/dist/lib/core/security/tokenRepository.d.ts +21 -7
  180. package/dist/lib/core/security/tokenRepository.js +50 -23
  181. package/dist/lib/core/security/userRepository.d.ts +44 -21
  182. package/dist/lib/core/security/userRepository.js +59 -19
  183. package/dist/lib/core/shared/KoncordeWrapper.d.ts +1 -1
  184. package/dist/lib/core/shared/ObjectRepository.d.ts +80 -18
  185. package/dist/lib/core/shared/ObjectRepository.js +57 -29
  186. package/dist/lib/core/shared/abstractManifest.d.ts +21 -8
  187. package/dist/lib/core/shared/abstractManifest.js +57 -17
  188. package/dist/lib/core/shared/sdk/embeddedSdk.d.ts +3 -1
  189. package/dist/lib/core/shared/sdk/embeddedSdk.js +8 -7
  190. package/dist/lib/core/shared/sdk/funnelProtocol.d.ts +2 -1
  191. package/dist/lib/core/shared/sdk/funnelProtocol.js +12 -3
  192. package/dist/lib/core/shared/sdk/impersonatedSdk.d.ts +11 -5
  193. package/dist/lib/core/shared/sdk/impersonatedSdk.js +22 -9
  194. package/dist/lib/core/shared/store.d.ts +45 -29
  195. package/dist/lib/core/shared/store.js +48 -27
  196. package/dist/lib/core/statistics/statistics.d.ts +1 -1
  197. package/dist/lib/core/storage/clientAdapter.d.ts +39 -21
  198. package/dist/lib/core/storage/clientAdapter.js +88 -48
  199. package/dist/lib/core/storage/indexCache.d.ts +8 -0
  200. package/dist/lib/core/storage/indexCache.js +16 -7
  201. package/dist/lib/core/storage/storageEngine.d.ts +7 -6
  202. package/dist/lib/core/storage/storageEngine.js +11 -8
  203. package/dist/lib/core/validation/baseType.d.ts +22 -22
  204. package/dist/lib/core/validation/baseType.js +11 -26
  205. package/dist/lib/core/validation/specification.d.ts +148 -0
  206. package/dist/lib/core/validation/specification.js +34 -0
  207. package/dist/lib/core/validation/typeOptions.d.ts +62 -0
  208. package/dist/lib/core/validation/typeOptions.js +23 -0
  209. package/dist/lib/core/validation/types/anything.d.ts +3 -6
  210. package/dist/lib/core/validation/types/anything.js +7 -7
  211. package/dist/lib/core/validation/types/boolean.d.ts +5 -12
  212. package/dist/lib/core/validation/types/boolean.js +7 -12
  213. package/dist/lib/core/validation/types/date.d.ts +19 -11
  214. package/dist/lib/core/validation/types/date.js +212 -161
  215. package/dist/lib/core/validation/types/email.d.ts +7 -11
  216. package/dist/lib/core/validation/types/email.js +13 -17
  217. package/dist/lib/core/validation/types/enum.d.ts +7 -11
  218. package/dist/lib/core/validation/types/enum.js +39 -20
  219. package/dist/lib/core/validation/types/geoPoint.d.ts +5 -13
  220. package/dist/lib/core/validation/types/geoPoint.js +10 -15
  221. package/dist/lib/core/validation/types/geoShape.d.ts +22 -21
  222. package/dist/lib/core/validation/types/geoShape.js +113 -129
  223. package/dist/lib/core/validation/types/geoShapeUtils.d.ts +15 -0
  224. package/dist/lib/core/validation/types/geoShapeUtils.js +75 -0
  225. package/dist/lib/core/validation/types/integer.d.ts +7 -5
  226. package/dist/lib/core/validation/types/integer.js +7 -13
  227. package/dist/lib/core/validation/types/ipAddress.d.ts +7 -11
  228. package/dist/lib/core/validation/types/ipAddress.js +13 -17
  229. package/dist/lib/core/validation/types/numeric.d.ts +7 -11
  230. package/dist/lib/core/validation/types/numeric.js +22 -29
  231. package/dist/lib/core/validation/types/object.d.ts +8 -15
  232. package/dist/lib/core/validation/types/object.js +12 -21
  233. package/dist/lib/core/validation/types/string.d.ts +7 -11
  234. package/dist/lib/core/validation/types/string.js +22 -29
  235. package/dist/lib/core/validation/types/url.d.ts +7 -11
  236. package/dist/lib/core/validation/types/url.js +14 -18
  237. package/dist/lib/core/validation/validation.d.ts +119 -80
  238. package/dist/lib/core/validation/validation.js +470 -412
  239. package/dist/lib/core/validation/validationUtils.d.ts +31 -0
  240. package/dist/lib/core/validation/validationUtils.js +190 -0
  241. package/dist/lib/kerror/codes/4-plugin.json +0 -12
  242. package/dist/lib/kerror/codes/index.d.ts +12 -2
  243. package/dist/lib/kerror/codes/index.js +5 -4
  244. package/dist/lib/kerror/errors/badRequestError.d.ts +1 -1
  245. package/dist/lib/kerror/errors/badRequestError.js +1 -1
  246. package/dist/lib/kerror/errors/externalServiceError.d.ts +1 -1
  247. package/dist/lib/kerror/errors/externalServiceError.js +1 -1
  248. package/dist/lib/kerror/errors/forbiddenError.d.ts +1 -1
  249. package/dist/lib/kerror/errors/forbiddenError.js +1 -1
  250. package/dist/lib/kerror/errors/gatewayTimeoutError.d.ts +1 -1
  251. package/dist/lib/kerror/errors/gatewayTimeoutError.js +1 -1
  252. package/dist/lib/kerror/errors/internalError.d.ts +1 -1
  253. package/dist/lib/kerror/errors/internalError.js +1 -1
  254. package/dist/lib/kerror/errors/kuzzleError.d.ts +32 -3
  255. package/dist/lib/kerror/errors/kuzzleError.js +21 -7
  256. package/dist/lib/kerror/errors/multipleErrorsError.d.ts +2 -2
  257. package/dist/lib/kerror/errors/multipleErrorsError.js +2 -2
  258. package/dist/lib/kerror/errors/notFoundError.d.ts +1 -1
  259. package/dist/lib/kerror/errors/notFoundError.js +1 -1
  260. package/dist/lib/kerror/errors/partialError.d.ts +8 -2
  261. package/dist/lib/kerror/errors/partialError.js +22 -9
  262. package/dist/lib/kerror/errors/pluginImplementationError.d.ts +9 -1
  263. package/dist/lib/kerror/errors/pluginImplementationError.js +9 -3
  264. package/dist/lib/kerror/errors/preconditionError.d.ts +1 -1
  265. package/dist/lib/kerror/errors/preconditionError.js +1 -1
  266. package/dist/lib/kerror/errors/serviceUnavailableError.d.ts +1 -1
  267. package/dist/lib/kerror/errors/serviceUnavailableError.js +1 -1
  268. package/dist/lib/kerror/errors/sizeLimitError.d.ts +1 -1
  269. package/dist/lib/kerror/errors/sizeLimitError.js +1 -1
  270. package/dist/lib/kerror/errors/tooManyRequestsError.d.ts +1 -1
  271. package/dist/lib/kerror/errors/tooManyRequestsError.js +1 -1
  272. package/dist/lib/kerror/errors/unauthorizedError.d.ts +1 -1
  273. package/dist/lib/kerror/errors/unauthorizedError.js +1 -1
  274. package/dist/lib/kerror/index.d.ts +19 -13
  275. package/dist/lib/kerror/index.js +60 -19
  276. package/dist/lib/kuzzle/Logger.d.ts +2 -2
  277. package/dist/lib/kuzzle/dumpGenerator.d.ts +12 -8
  278. package/dist/lib/kuzzle/dumpGenerator.js +130 -62
  279. package/dist/lib/kuzzle/event/KuzzleEventEmitter.d.ts +18 -9
  280. package/dist/lib/kuzzle/event/KuzzleEventEmitter.js +45 -18
  281. package/dist/lib/kuzzle/event/pipeRunner.d.ts +37 -16
  282. package/dist/lib/kuzzle/event/pipeRunner.js +73 -26
  283. package/dist/lib/kuzzle/event/waterfall.d.ts +11 -1
  284. package/dist/lib/kuzzle/event/waterfall.js +38 -13
  285. package/dist/lib/kuzzle/internalIndexHandler.d.ts +11 -174
  286. package/dist/lib/kuzzle/internalIndexHandler.js +58 -29
  287. package/dist/lib/kuzzle/kuzzle.d.ts +25 -10
  288. package/dist/lib/kuzzle/kuzzle.js +74 -17
  289. package/dist/lib/kuzzle/kuzzleStateEnum.d.ts +16 -12
  290. package/dist/lib/kuzzle/kuzzleStateEnum.js +5 -7
  291. package/dist/lib/kuzzle/vault.d.ts +5 -1
  292. package/dist/lib/kuzzle/vault.js +29 -17
  293. package/dist/lib/model/security/profile.d.ts +34 -5
  294. package/dist/lib/model/security/profile.js +6 -5
  295. package/dist/lib/model/security/rights.d.ts +12 -4
  296. package/dist/lib/model/security/rights.js +7 -6
  297. package/dist/lib/model/security/role.d.ts +8 -4
  298. package/dist/lib/model/security/role.js +12 -6
  299. package/dist/lib/model/security/token.d.ts +8 -0
  300. package/dist/lib/model/security/user.d.ts +8 -2
  301. package/dist/lib/model/security/user.js +7 -4
  302. package/dist/lib/model/storage/apiKey.d.ts +55 -26
  303. package/dist/lib/model/storage/apiKey.js +97 -24
  304. package/dist/lib/model/storage/baseModel.d.ts +77 -66
  305. package/dist/lib/model/storage/baseModel.js +21 -34
  306. package/dist/lib/service/cache/redis.d.ts +53 -36
  307. package/dist/lib/service/cache/redis.js +148 -71
  308. package/dist/lib/service/service.d.ts +14 -19
  309. package/dist/lib/service/service.js +41 -22
  310. package/dist/lib/service/storage/7/elasticsearch.d.ts +136 -93
  311. package/dist/lib/service/storage/7/elasticsearch.js +218 -165
  312. package/dist/lib/service/storage/7/esWrapper.d.ts +30 -13
  313. package/dist/lib/service/storage/7/esWrapper.js +58 -37
  314. package/dist/lib/service/storage/8/elasticsearch.d.ts +153 -119
  315. package/dist/lib/service/storage/8/elasticsearch.js +286 -213
  316. package/dist/lib/service/storage/8/esWrapper.d.ts +30 -13
  317. package/dist/lib/service/storage/8/esWrapper.js +59 -38
  318. package/dist/lib/service/storage/commons/queryTranslator.d.ts +3 -3
  319. package/dist/lib/service/storage/commons/queryTranslator.js +71 -35
  320. package/dist/lib/types/ApiRoute.d.ts +12 -0
  321. package/dist/lib/types/ApiRoute.js +23 -0
  322. package/dist/lib/types/ClientConnection.d.ts +1 -1
  323. package/dist/lib/types/EventHandler.d.ts +10 -0
  324. package/dist/lib/types/Global.d.ts +8 -3
  325. package/dist/lib/types/HttpMessage.d.ts +2 -2
  326. package/dist/lib/types/HttpStream.d.ts +1 -1
  327. package/dist/lib/types/HttpStream.js +3 -1
  328. package/dist/lib/types/JSONObject.d.ts +9 -0
  329. package/dist/lib/types/JSONObject.js +23 -0
  330. package/dist/lib/types/Kuzzle.d.ts +5 -3
  331. package/dist/lib/types/KuzzleDocument.d.ts +1 -1
  332. package/dist/lib/types/KuzzleWebSocket.d.ts +24 -0
  333. package/dist/lib/types/KuzzleWebSocket.js +23 -0
  334. package/dist/lib/types/OpenApiDefinition.d.ts +1 -1
  335. package/dist/lib/types/Plugin.d.ts +33 -8
  336. package/dist/lib/types/PluginInstance.d.ts +67 -0
  337. package/dist/lib/types/PluginInstance.js +23 -0
  338. package/dist/lib/types/Policy.d.ts +1 -1
  339. package/dist/lib/types/Target.d.ts +8 -0
  340. package/dist/lib/types/Token.d.ts +14 -2
  341. package/dist/lib/types/config/HttpConfiguration.d.ts +5 -0
  342. package/dist/lib/types/config/KuzzleConfiguration.d.ts +102 -1
  343. package/dist/lib/types/config/PluginsConfiguration.d.ts +3 -2
  344. package/dist/lib/types/config/SecurityConfiguration.d.ts +6 -2
  345. package/dist/lib/types/config/ServerConfiguration.d.ts +2 -2
  346. package/dist/lib/types/config/ServicesConfiguration.d.ts +1 -1
  347. package/dist/lib/types/config/cache/BaseCacheRedisConfiguration.d.ts +131 -0
  348. package/dist/lib/types/config/cache/BaseCacheRedisConfiguration.js +3 -0
  349. package/dist/lib/types/config/internalCache/InternalCacheRedisConfiguration.d.ts +2 -106
  350. package/dist/lib/types/config/publicCache/PublicCacheRedisConfiguration.d.ts +2 -26
  351. package/dist/lib/types/config/storageEngine/StorageEngineElasticsearchConfiguration.d.ts +3 -0
  352. package/dist/lib/types/controllers/Controller.d.ts +12 -3
  353. package/dist/lib/types/controllers/ControllerDefinition.d.ts +2 -2
  354. package/dist/lib/types/controllers/{adminControlller.type.js → adminController.type.js} +1 -1
  355. package/dist/lib/types/controllers/authController.type.d.ts +2 -2
  356. package/dist/lib/types/core/auth/formatProcessing.type.d.ts +7 -1
  357. package/dist/lib/types/errors/ErrorDomains.d.ts +1 -1
  358. package/dist/lib/types/events/EventGenericDocument.d.ts +10 -9
  359. package/dist/lib/types/events/EventProtocol.d.ts +4 -4
  360. package/dist/lib/types/index.d.ts +7 -0
  361. package/dist/lib/types/index.js +7 -0
  362. package/dist/lib/types/shared/StoreCollectionsDefinition.d.ts +1 -1
  363. package/dist/lib/types/storage/7/Elasticsearch.d.ts +62 -13
  364. package/dist/lib/types/storage/8/Elasticsearch.d.ts +62 -13
  365. package/dist/lib/util/Inflector.d.ts +4 -1
  366. package/dist/lib/util/Inflector.js +0 -3
  367. package/dist/lib/util/assertType.d.ts +24 -27
  368. package/dist/lib/util/assertType.js +28 -39
  369. package/dist/lib/util/async.js +19 -6
  370. package/dist/lib/util/asyncStore.js +1 -1
  371. package/dist/lib/util/bufferedPassThrough.d.ts +9 -0
  372. package/dist/lib/util/bufferedPassThrough.js +27 -13
  373. package/dist/lib/util/bytes.d.ts +1 -1
  374. package/dist/lib/util/bytes.js +6 -2
  375. package/dist/lib/util/debug.d.ts +3 -1
  376. package/dist/lib/util/debug.js +42 -10
  377. package/dist/lib/util/deprecate.d.ts +9 -1
  378. package/dist/lib/util/deprecate.js +10 -6
  379. package/dist/lib/util/didYouMean.d.ts +2 -1
  380. package/dist/lib/util/didYouMean.js +8 -4
  381. package/dist/lib/util/distributedLock.d.ts +56 -0
  382. package/dist/lib/util/distributedLock.js +166 -0
  383. package/dist/lib/util/dump-collection.d.ts +1 -1
  384. package/dist/lib/util/dump-collection.js +4 -5
  385. package/dist/lib/util/extractFields.d.ts +15 -11
  386. package/dist/lib/util/extractFields.js +8 -9
  387. package/dist/lib/util/koncordeCompat.d.ts +2 -2
  388. package/dist/lib/util/koncordeCompat.js +33 -0
  389. package/dist/lib/util/memoize.d.ts +7 -6
  390. package/dist/lib/util/memoize.js +3 -3
  391. package/dist/lib/util/mutex.d.ts +22 -2
  392. package/dist/lib/util/mutex.js +39 -1
  393. package/dist/lib/util/name-generator.js +14 -2
  394. package/dist/lib/util/promback.d.ts +20 -11
  395. package/dist/lib/util/promback.js +14 -7
  396. package/dist/lib/util/requestAssertions.d.ts +30 -10
  397. package/dist/lib/util/requestAssertions.js +125 -121
  398. package/dist/lib/util/safeObject.d.ts +3 -3
  399. package/dist/lib/util/safeObject.js +7 -3
  400. package/dist/lib/util/stackTrace.d.ts +13 -5
  401. package/dist/lib/util/stackTrace.js +17 -12
  402. package/dist/lib/util/thrown.d.ts +13 -0
  403. package/dist/lib/util/thrown.js +46 -0
  404. package/dist/package.json +26 -19
  405. package/package.json +26 -19
  406. package/dist/lib/util/wildcard.d.ts +0 -1
  407. package/dist/lib/util/wildcard.js +0 -46
  408. /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
- this.id = data.requestId
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
- : uuid.v4();
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
- for (const prop of Object.keys(options.error).filter((key) => key !== "message" && key !== "status")) {
122
- error[prop] = options.error[prop];
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 instead
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
- if (result instanceof Error) {
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
- * @deprecated do not use, Use getArray instead
542
- *
543
- * Gets a parameter from a request arguments and checks that it is an array
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
- getArrayLegacy(name, def = undefined) {
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 (e) {
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 (e) {
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 (e) {
1033
+ catch {
969
1034
  // Do nothing, let the error be thrown below
970
1035
  }
971
1036
  }
@@ -1,6 +1,13 @@
1
- import { JSONObject } from "kuzzle-sdk";
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
- for (const prop of Object.keys(connection)) {
72
- if (["id", "protocol", "ips"].includes(prop)) {
73
- this[prop] = connection[prop];
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] = connection[prop];
86
+ this.misc[prop] = value;
77
87
  }
78
88
  }
79
89
  }
@@ -1,4 +1,11 @@
1
- import { JSONObject } from "kuzzle-sdk";
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: any);
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
- set body(obj: JSONObject | Array<any>);
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
- set headers(obj: JSONObject);
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
- this[_triggerEvents] = null;
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 "kuzzle-sdk";
2
- import { Deprecation } from "../../types";
3
- import { KuzzleError } from "../../kerror/errors/kuzzleError";
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
- private proxy;
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 | void;
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
- constructor(request: any);
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> | void);
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
- set error(e: KuzzleError | null);
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=200] - HTTP status code
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 {};