@webiny/api-core 6.6.0-alpha.0 → 6.6.0-alpha.10

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 (391) hide show
  1. package/ApiCoreFeature.js +12 -2
  2. package/ApiCoreFeature.js.map +1 -1
  3. package/exports/api/security/api-key.d.ts +1 -0
  4. package/exports/api/security/api-key.js +1 -0
  5. package/exports/api/tasks.d.ts +1 -0
  6. package/exports/api/tasks.js +1 -1
  7. package/exports/api.d.ts +1 -1
  8. package/exports/api.js +1 -1
  9. package/features/ai/Ai.d.ts +5 -1
  10. package/features/ai/Ai.js +72 -29
  11. package/features/ai/Ai.js.map +1 -1
  12. package/features/ai/AiModelRegistry.d.ts +14 -0
  13. package/features/ai/AiModelRegistry.js +39 -0
  14. package/features/ai/AiModelRegistry.js.map +1 -0
  15. package/features/ai/AiSdkToolHandlerResolver.d.ts +11 -0
  16. package/features/ai/AiSdkToolHandlerResolver.js +19 -0
  17. package/features/ai/AiSdkToolHandlerResolver.js.map +1 -0
  18. package/features/ai/AiSdkTools.d.ts +4 -3
  19. package/features/ai/AiSdkTools.js +11 -9
  20. package/features/ai/AiSdkTools.js.map +1 -1
  21. package/features/ai/AnthropicSdkFactory.js +24 -4
  22. package/features/ai/AnthropicSdkFactory.js.map +1 -1
  23. package/features/ai/DEVELOPERS.md +183 -0
  24. package/features/ai/GoogleSdkFactory.d.ts +10 -0
  25. package/features/ai/GoogleSdkFactory.js +65 -0
  26. package/features/ai/GoogleSdkFactory.js.map +1 -0
  27. package/features/ai/OpenAiSdkFactory.js +67 -11
  28. package/features/ai/OpenAiSdkFactory.js.map +1 -1
  29. package/features/ai/OpenRouterSdkFactory.d.ts +10 -0
  30. package/features/ai/OpenRouterSdkFactory.js +112 -0
  31. package/features/ai/OpenRouterSdkFactory.js.map +1 -0
  32. package/features/ai/RemoteAiModelCatalog.d.ts +13 -0
  33. package/features/ai/RemoteAiModelCatalog.js +74 -0
  34. package/features/ai/RemoteAiModelCatalog.js.map +1 -0
  35. package/features/ai/TextExtractor/DefaultTextExtractor.d.ts +9 -0
  36. package/features/ai/TextExtractor/DefaultTextExtractor.js +28 -0
  37. package/features/ai/TextExtractor/DefaultTextExtractor.js.map +1 -0
  38. package/features/ai/TextExtractor/abstractions.d.ts +12 -0
  39. package/features/ai/TextExtractor/abstractions.js +5 -0
  40. package/features/ai/TextExtractor/abstractions.js.map +1 -0
  41. package/features/ai/TextExtractor/index.d.ts +3 -0
  42. package/features/ai/TextExtractor/index.js +2 -0
  43. package/features/ai/TextExtractor/parsers/docxParser.d.ts +1 -0
  44. package/features/ai/TextExtractor/parsers/docxParser.js +111 -0
  45. package/features/ai/TextExtractor/parsers/docxParser.js.map +1 -0
  46. package/features/ai/abstractions.d.ts +102 -7
  47. package/features/ai/abstractions.js +6 -2
  48. package/features/ai/abstractions.js.map +1 -1
  49. package/features/ai/events.d.ts +59 -0
  50. package/features/ai/events.js +41 -0
  51. package/features/ai/events.js.map +1 -0
  52. package/features/ai/feature.js +12 -0
  53. package/features/ai/feature.js.map +1 -1
  54. package/features/ai/index.d.ts +5 -3
  55. package/features/ai/index.js +3 -1
  56. package/features/dateFormatter/DefaultDateFormatter.d.ts +15 -0
  57. package/features/dateFormatter/DefaultDateFormatter.js +20 -0
  58. package/features/dateFormatter/DefaultDateFormatter.js.map +1 -0
  59. package/features/dateFormatter/abstractions.d.ts +13 -0
  60. package/features/dateFormatter/abstractions.js +5 -0
  61. package/features/dateFormatter/abstractions.js.map +1 -0
  62. package/features/dateFormatter/feature.d.ts +4 -0
  63. package/features/dateFormatter/feature.js +11 -0
  64. package/features/dateFormatter/feature.js.map +1 -0
  65. package/features/dateFormatter/index.d.ts +3 -0
  66. package/features/dateFormatter/index.js +2 -0
  67. package/features/debugger/Debugger.d.ts +30 -0
  68. package/features/debugger/Debugger.js +142 -0
  69. package/features/debugger/Debugger.js.map +1 -0
  70. package/features/debugger/DebuggerRouteDecorator.d.ts +45 -0
  71. package/features/debugger/DebuggerRouteDecorator.js +102 -0
  72. package/features/debugger/DebuggerRouteDecorator.js.map +1 -0
  73. package/features/debugger/GraphQLDebuggerTransport.d.ts +28 -0
  74. package/features/debugger/GraphQLDebuggerTransport.js +45 -0
  75. package/features/debugger/GraphQLDebuggerTransport.js.map +1 -0
  76. package/features/debugger/__tests__/matchNamespace.test.d.ts +1 -0
  77. package/features/debugger/__tests__/matchNamespace.test.js +68 -0
  78. package/features/debugger/__tests__/matchNamespace.test.js.map +1 -0
  79. package/features/debugger/__tests__/serialize.test.d.ts +1 -0
  80. package/features/debugger/__tests__/serialize.test.js +220 -0
  81. package/features/debugger/__tests__/serialize.test.js.map +1 -0
  82. package/features/debugger/abstractions.d.ts +100 -0
  83. package/features/debugger/abstractions.js +6 -0
  84. package/features/debugger/abstractions.js.map +1 -0
  85. package/features/debugger/feature.d.ts +5 -0
  86. package/features/debugger/feature.js +15 -0
  87. package/features/debugger/feature.js.map +1 -0
  88. package/features/debugger/index.d.ts +12 -0
  89. package/features/debugger/index.js +7 -0
  90. package/features/debugger/limits.d.ts +18 -0
  91. package/features/debugger/limits.js +11 -0
  92. package/features/debugger/limits.js.map +1 -0
  93. package/features/debugger/matchNamespace.d.ts +14 -0
  94. package/features/debugger/matchNamespace.js +35 -0
  95. package/features/debugger/matchNamespace.js.map +1 -0
  96. package/features/debugger/parseNamespaceHeader.d.ts +7 -0
  97. package/features/debugger/parseNamespaceHeader.js +16 -0
  98. package/features/debugger/parseNamespaceHeader.js.map +1 -0
  99. package/features/debugger/permissions.d.ts +14 -0
  100. package/features/debugger/permissions.js +8 -0
  101. package/features/debugger/permissions.js.map +1 -0
  102. package/features/debugger/permissionsSchema.d.ts +17 -0
  103. package/features/debugger/permissionsSchema.js +18 -0
  104. package/features/debugger/permissionsSchema.js.map +1 -0
  105. package/features/debugger/serialize.d.ts +11 -0
  106. package/features/debugger/serialize.js +121 -0
  107. package/features/debugger/serialize.js.map +1 -0
  108. package/features/encryption/BuildParamsEncryptionConfig.d.ts +13 -0
  109. package/features/encryption/BuildParamsEncryptionConfig.js +19 -0
  110. package/features/encryption/BuildParamsEncryptionConfig.js.map +1 -0
  111. package/features/encryption/EncryptionKeyCacheFeature.d.ts +8 -0
  112. package/features/encryption/EncryptionKeyCacheFeature.js +11 -0
  113. package/features/encryption/EncryptionKeyCacheFeature.js.map +1 -0
  114. package/features/encryption/EncryptionService.d.ts +3 -2
  115. package/features/encryption/EncryptionService.js +15 -13
  116. package/features/encryption/EncryptionService.js.map +1 -1
  117. package/features/encryption/MemoryEncryptionKeyCache.d.ts +13 -0
  118. package/features/encryption/MemoryEncryptionKeyCache.js +26 -0
  119. package/features/encryption/MemoryEncryptionKeyCache.js.map +1 -0
  120. package/features/encryption/abstractions.d.ts +26 -0
  121. package/features/encryption/abstractions.js +3 -1
  122. package/features/encryption/abstractions.js.map +1 -1
  123. package/features/encryption/feature.js +2 -0
  124. package/features/encryption/feature.js.map +1 -1
  125. package/features/encryption/index.d.ts +3 -0
  126. package/features/encryption/index.js +3 -1
  127. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.d.ts +13 -0
  128. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js +61 -0
  129. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js.map +1 -0
  130. package/features/hashing/BuildParamsHashingConfig.d.ts +11 -0
  131. package/features/hashing/BuildParamsHashingConfig.js +18 -0
  132. package/features/hashing/BuildParamsHashingConfig.js.map +1 -0
  133. package/features/hashing/ScryptHasher.d.ts +2 -2
  134. package/features/hashing/ScryptHasher.js +6 -8
  135. package/features/hashing/ScryptHasher.js.map +1 -1
  136. package/features/hashing/abstractions.d.ts +15 -0
  137. package/features/hashing/abstractions.js +2 -1
  138. package/features/hashing/abstractions.js.map +1 -1
  139. package/features/hashing/feature.js +2 -0
  140. package/features/hashing/feature.js.map +1 -1
  141. package/features/hashing/index.d.ts +1 -0
  142. package/features/hashing/index.js +1 -1
  143. package/features/httpClient/HttpClient.d.ts +7 -0
  144. package/features/httpClient/HttpClient.js +72 -0
  145. package/features/httpClient/HttpClient.js.map +1 -0
  146. package/features/httpClient/HttpRequestError.d.ts +10 -0
  147. package/features/httpClient/HttpRequestError.js +13 -0
  148. package/features/httpClient/HttpRequestError.js.map +1 -0
  149. package/features/httpClient/HttpStatusError.d.ts +12 -0
  150. package/features/httpClient/HttpStatusError.js +12 -0
  151. package/features/httpClient/HttpStatusError.js.map +1 -0
  152. package/features/httpClient/abstractions.d.ts +32 -0
  153. package/features/httpClient/abstractions.js +5 -0
  154. package/features/httpClient/abstractions.js.map +1 -0
  155. package/features/httpClient/feature.d.ts +4 -0
  156. package/features/httpClient/feature.js +11 -0
  157. package/features/httpClient/feature.js.map +1 -0
  158. package/features/httpClient/index.d.ts +3 -0
  159. package/features/httpClient/index.js +3 -0
  160. package/features/keyValueStore/GlobalKeyValueStore.d.ts +9 -3
  161. package/features/keyValueStore/GlobalKeyValueStore.js +12 -2
  162. package/features/keyValueStore/GlobalKeyValueStore.js.map +1 -1
  163. package/features/keyValueStore/KeyValueStore.d.ts +6 -2
  164. package/features/keyValueStore/KeyValueStore.js +13 -3
  165. package/features/keyValueStore/KeyValueStore.js.map +1 -1
  166. package/features/keyValueStore/KeyValueStoreRepository.d.ts +8 -2
  167. package/features/keyValueStore/KeyValueStoreRepository.js +82 -4
  168. package/features/keyValueStore/KeyValueStoreRepository.js.map +1 -1
  169. package/features/keyValueStore/abstractions.d.ts +132 -14
  170. package/features/keyValueStore/abstractions.js.map +1 -1
  171. package/features/keyValueStore/errors.d.ts +29 -0
  172. package/features/keyValueStore/errors.js +49 -1
  173. package/features/keyValueStore/errors.js.map +1 -1
  174. package/features/keyValueStore/index.d.ts +4 -1
  175. package/features/keyValueStore/index.js +1 -1
  176. package/features/logger/NullLogger.d.ts +10 -0
  177. package/features/logger/NullLogger.js +12 -0
  178. package/features/logger/NullLogger.js.map +1 -0
  179. package/features/logger/index.d.ts +1 -0
  180. package/features/logger/index.js +1 -0
  181. package/features/publicUrls/NullPublicUrls.d.ts +11 -0
  182. package/features/publicUrls/NullPublicUrls.js +17 -0
  183. package/features/publicUrls/NullPublicUrls.js.map +1 -0
  184. package/features/publicUrls/PublicUrl.d.ts +24 -0
  185. package/features/publicUrls/PublicUrl.js +43 -0
  186. package/features/publicUrls/PublicUrl.js.map +1 -0
  187. package/features/publicUrls/__tests__/PublicUrl.test.d.ts +1 -0
  188. package/features/publicUrls/__tests__/PublicUrl.test.js +38 -0
  189. package/features/publicUrls/__tests__/PublicUrl.test.js.map +1 -0
  190. package/features/publicUrls/__tests__/PublicUrls.test.d.ts +1 -0
  191. package/features/publicUrls/__tests__/PublicUrls.test.js +14 -0
  192. package/features/publicUrls/__tests__/PublicUrls.test.js.map +1 -0
  193. package/features/publicUrls/abstractions.d.ts +27 -0
  194. package/features/publicUrls/abstractions.js +5 -0
  195. package/features/publicUrls/abstractions.js.map +1 -0
  196. package/features/publicUrls/feature.d.ts +8 -0
  197. package/features/publicUrls/feature.js +11 -0
  198. package/features/publicUrls/feature.js.map +1 -0
  199. package/features/publicUrls/index.d.ts +3 -0
  200. package/features/publicUrls/index.js +3 -0
  201. package/features/requestContext/RawAssumePermissions.d.ts +14 -0
  202. package/features/requestContext/RawAssumePermissions.js +19 -0
  203. package/features/requestContext/RawAssumePermissions.js.map +1 -0
  204. package/features/requestContext/abstractions.d.ts +22 -0
  205. package/features/requestContext/abstractions.js +2 -1
  206. package/features/requestContext/abstractions.js.map +1 -1
  207. package/features/requestContext/extractAssumePermissions.d.ts +14 -0
  208. package/features/requestContext/extractAssumePermissions.js +32 -0
  209. package/features/requestContext/extractAssumePermissions.js.map +1 -0
  210. package/features/requestContext/feature.d.ts +2 -1
  211. package/features/requestContext/feature.js +2 -0
  212. package/features/requestContext/feature.js.map +1 -1
  213. package/features/requestContext/index.d.ts +3 -1
  214. package/features/requestContext/index.js +2 -1
  215. package/features/security/IdentityContext/IdentityContext.d.ts +8 -4
  216. package/features/security/IdentityContext/IdentityContext.js +28 -11
  217. package/features/security/IdentityContext/IdentityContext.js.map +1 -1
  218. package/features/security/IdentityContext/abstractions.d.ts +6 -1
  219. package/features/security/IdentityContext/abstractions.js.map +1 -1
  220. package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js +11 -6
  221. package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js.map +1 -1
  222. package/features/security/apiKeys/GetApiKey/GetApiKeyUseCase.d.ts +1 -1
  223. package/features/security/apiKeys/GetApiKey/GetApiKeyUseCase.js.map +1 -1
  224. package/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.d.ts +1 -3
  225. package/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.js.map +1 -1
  226. package/features/security/apiKeys/GetApiKeyBySlug/abstractions.d.ts +1 -1
  227. package/features/security/apiKeys/GetApiKeyBySlug/abstractions.js.map +1 -1
  228. package/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.d.ts +1 -3
  229. package/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.js.map +1 -1
  230. package/features/security/apiKeys/GetApiKeyByToken/abstractions.d.ts +1 -1
  231. package/features/security/apiKeys/GetApiKeyByToken/abstractions.js.map +1 -1
  232. package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js +9 -3
  233. package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js.map +1 -1
  234. package/features/security/apiKeys/feature.js +7 -2
  235. package/features/security/apiKeys/feature.js.map +1 -1
  236. package/features/security/apiKeys/shared/ApiKeyProvider.d.ts +3 -5
  237. package/features/security/apiKeys/shared/ApiKeyProvider.js +6 -21
  238. package/features/security/apiKeys/shared/ApiKeyProvider.js.map +1 -1
  239. package/features/security/apiKeys/shared/ApiKeysRepository.d.ts +1 -0
  240. package/features/security/apiKeys/shared/ApiKeysRepository.js +19 -4
  241. package/features/security/apiKeys/shared/ApiKeysRepository.js.map +1 -1
  242. package/features/security/apiKeys/shared/generateToken.d.ts +1 -1
  243. package/features/security/apiKeys/shared/generateToken.js.map +1 -1
  244. package/features/security/apiKeys/shared/schemas.d.ts +2 -2
  245. package/features/security/apiKeys/shared/schemas.js +2 -2
  246. package/features/security/apiKeys/shared/schemas.js.map +1 -1
  247. package/features/security/apiKeys/shared/types.d.ts +1 -1
  248. package/features/security/authorization/AuthorizationContext/AuthorizationContext.d.ts +13 -3
  249. package/features/security/authorization/AuthorizationContext/AuthorizationContext.js +35 -22
  250. package/features/security/authorization/AuthorizationContext/AuthorizationContext.js.map +1 -1
  251. package/features/security/authorization/AuthorizationContext/abstractions.d.ts +2 -0
  252. package/features/security/authorization/AuthorizationContext/abstractions.js.map +1 -1
  253. package/features/security/authorization/AuthorizationContext/feature.js +6 -1
  254. package/features/security/authorization/AuthorizationContext/feature.js.map +1 -1
  255. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.d.ts +30 -0
  256. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js +60 -0
  257. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js.map +1 -0
  258. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.d.ts +3 -3
  259. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js +5 -5
  260. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js.map +1 -1
  261. package/features/security/authorization/GroupsTeamsAuthorizer/feature.js +2 -0
  262. package/features/security/authorization/GroupsTeamsAuthorizer/feature.js.map +1 -1
  263. package/features/security/roles/CreateRole/CreateRoleUseCase.js +11 -6
  264. package/features/security/roles/CreateRole/CreateRoleUseCase.js.map +1 -1
  265. package/features/security/roles/CreateRole/schema.d.ts +1 -1
  266. package/features/security/roles/CreateRole/schema.js +1 -1
  267. package/features/security/roles/CreateRole/schema.js.map +1 -1
  268. package/features/security/roles/Installer/RolesInstaller.js +1 -0
  269. package/features/security/roles/Installer/RolesInstaller.js.map +1 -1
  270. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js +9 -3
  271. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js.map +1 -1
  272. package/features/security/roles/UpdateRole/schema.d.ts +1 -1
  273. package/features/security/roles/UpdateRole/schema.js +1 -1
  274. package/features/security/roles/UpdateRole/schema.js.map +1 -1
  275. package/features/security/shared/description.d.ts +4 -0
  276. package/features/security/shared/description.js +7 -0
  277. package/features/security/shared/description.js.map +1 -0
  278. package/features/security/shared/index.d.ts +1 -0
  279. package/features/security/shared/index.js +1 -0
  280. package/features/security/teams/CreateTeam/CreateTeamUseCase.d.ts +3 -1
  281. package/features/security/teams/CreateTeam/CreateTeamUseCase.js +20 -8
  282. package/features/security/teams/CreateTeam/CreateTeamUseCase.js.map +1 -1
  283. package/features/security/teams/CreateTeam/schema.d.ts +1 -1
  284. package/features/security/teams/CreateTeam/schema.js +1 -1
  285. package/features/security/teams/CreateTeam/schema.js.map +1 -1
  286. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.d.ts +3 -1
  287. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js +20 -5
  288. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js.map +1 -1
  289. package/features/security/teams/UpdateTeam/schema.d.ts +1 -1
  290. package/features/security/teams/UpdateTeam/schema.js +1 -1
  291. package/features/security/teams/UpdateTeam/schema.js.map +1 -1
  292. package/features/security/teams/shared/resolveRoleIdentifiers.d.ts +17 -0
  293. package/features/security/teams/shared/resolveRoleIdentifiers.js +32 -0
  294. package/features/security/teams/shared/resolveRoleIdentifiers.js.map +1 -0
  295. package/features/slugify/DefaultSlugify.d.ts +8 -0
  296. package/features/slugify/DefaultSlugify.js +20 -0
  297. package/features/slugify/DefaultSlugify.js.map +1 -0
  298. package/features/slugify/abstractions.d.ts +12 -0
  299. package/features/slugify/abstractions.js +5 -0
  300. package/features/slugify/abstractions.js.map +1 -0
  301. package/features/{logger → slugify}/feature.d.ts +1 -1
  302. package/features/slugify/feature.js +11 -0
  303. package/features/slugify/feature.js.map +1 -0
  304. package/features/slugify/index.d.ts +3 -0
  305. package/features/slugify/index.js +2 -0
  306. package/features/stringFormatter/DefaultStringFormatter.d.ts +17 -0
  307. package/features/stringFormatter/DefaultStringFormatter.js +19 -0
  308. package/features/stringFormatter/DefaultStringFormatter.js.map +1 -0
  309. package/features/stringFormatter/abstractions.d.ts +11 -0
  310. package/features/stringFormatter/abstractions.js +5 -0
  311. package/features/stringFormatter/abstractions.js.map +1 -0
  312. package/features/stringFormatter/feature.d.ts +4 -0
  313. package/features/stringFormatter/feature.js +13 -0
  314. package/features/stringFormatter/feature.js.map +1 -0
  315. package/features/stringFormatter/index.d.ts +3 -0
  316. package/features/stringFormatter/index.js +2 -0
  317. package/features/task/TaskDefinition/abstractions.d.ts +69 -4
  318. package/features/task/TaskDefinition/abstractions.js +2 -1
  319. package/features/task/TaskDefinition/abstractions.js.map +1 -1
  320. package/features/tenancy/TenantContext/TenantContext.d.ts +5 -1
  321. package/features/tenancy/TenantContext/TenantContext.js +31 -23
  322. package/features/tenancy/TenantContext/TenantContext.js.map +1 -1
  323. package/features/users/shared/loaders.js.map +1 -1
  324. package/features/users/shared/types.d.ts +9 -7
  325. package/features/wcp/WcpContext/WcpContext.d.ts +11 -0
  326. package/features/wcp/WcpContext/WcpContext.js +33 -0
  327. package/features/wcp/WcpContext/WcpContext.js.map +1 -1
  328. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.d.ts +14 -60
  329. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js +77 -25
  330. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js.map +1 -1
  331. package/features/wcp/WcpFeature.js +2 -0
  332. package/features/wcp/WcpFeature.js.map +1 -1
  333. package/features/wcp/WcpLicenseLoader.d.ts +25 -0
  334. package/features/wcp/WcpLicenseLoader.js +58 -0
  335. package/features/wcp/WcpLicenseLoader.js.map +1 -0
  336. package/features/wcp/WcpLicenseProvider.d.ts +6 -14
  337. package/features/wcp/WcpLicenseProvider.js +3 -7
  338. package/features/wcp/WcpLicenseProvider.js.map +1 -1
  339. package/features/wcp/resolveWcpProjectEnvironment.d.ts +9 -0
  340. package/features/wcp/resolveWcpProjectEnvironment.js +23 -0
  341. package/features/wcp/resolveWcpProjectEnvironment.js.map +1 -0
  342. package/graphql/ApiCoreSchemaFactory.d.ts +1 -0
  343. package/graphql/ApiCoreSchemaFactory.js +7 -1
  344. package/graphql/ApiCoreSchemaFactory.js.map +1 -1
  345. package/graphql/featureFlags/FeatureFlagsSchemaFactory.d.ts +10 -0
  346. package/graphql/featureFlags/FeatureFlagsSchemaFactory.js +53 -0
  347. package/graphql/featureFlags/FeatureFlagsSchemaFactory.js.map +1 -0
  348. package/graphql/security/SecuritySchemaFactory.d.ts +1 -0
  349. package/graphql/security/SecuritySchemaFactory.js +4 -0
  350. package/graphql/security/SecuritySchemaFactory.js.map +1 -1
  351. package/graphql/system/SystemSchemaFactory.d.ts +1 -0
  352. package/graphql/system/SystemSchemaFactory.js +4 -0
  353. package/graphql/system/SystemSchemaFactory.js.map +1 -1
  354. package/graphql/users/UsersSchemaFactory.d.ts +1 -0
  355. package/graphql/users/UsersSchemaFactory.js +4 -0
  356. package/graphql/users/UsersSchemaFactory.js.map +1 -1
  357. package/graphql/wcp/WcpSchemaFactory.d.ts +1 -0
  358. package/graphql/wcp/WcpSchemaFactory.js +6 -0
  359. package/graphql/wcp/WcpSchemaFactory.js.map +1 -1
  360. package/idp/JwksCache.d.ts +14 -3
  361. package/idp/JwksCache.js +97 -17
  362. package/idp/JwksCache.js.map +1 -1
  363. package/idp/JwksStoreFeature.d.ts +8 -0
  364. package/idp/JwksStoreFeature.js +11 -0
  365. package/idp/JwksStoreFeature.js.map +1 -0
  366. package/idp/MemoryJwksStore.d.ts +14 -0
  367. package/idp/MemoryJwksStore.js +21 -0
  368. package/idp/MemoryJwksStore.js.map +1 -0
  369. package/idp/OidcJwtIdentityProvider.js +5 -1
  370. package/idp/OidcJwtIdentityProvider.js.map +1 -1
  371. package/idp/abstractions.d.ts +24 -0
  372. package/idp/abstractions.js +2 -1
  373. package/idp/abstractions.js.map +1 -1
  374. package/idp/feature.js +1 -2
  375. package/idp/feature.js.map +1 -1
  376. package/idp/index.d.ts +1 -0
  377. package/idp/index.js +1 -0
  378. package/package.json +22 -22
  379. package/testing/environment.d.ts +14 -0
  380. package/testing/environment.js +18 -0
  381. package/testing/environment.js.map +1 -0
  382. package/types/security.d.ts +1 -1
  383. package/types/users.d.ts +2 -3
  384. package/features/logger/LoggerService.d.ts +0 -14
  385. package/features/logger/LoggerService.js +0 -48
  386. package/features/logger/LoggerService.js.map +0 -1
  387. package/features/logger/feature.js +0 -11
  388. package/features/logger/feature.js.map +0 -1
  389. package/features/wcp/loadWcpLicense.d.ts +0 -2
  390. package/features/wcp/loadWcpLicense.js +0 -51
  391. package/features/wcp/loadWcpLicense.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"features/hashing/ScryptHasher.js","sources":["../../../src/features/hashing/ScryptHasher.ts"],"sourcesContent":["import { randomBytes, scrypt as scryptCb, timingSafeEqual } from \"node:crypto\";\nimport type { ScryptOptions } from \"node:crypto\";\nimport { createImplementation } from \"@webiny/feature/api\";\nimport { Hasher as HasherAbstraction } from \"./abstractions.js\";\nimport type { IHasher } from \"./abstractions.js\";\nimport { BuildParams } from \"../buildParams/abstractions.js\";\n\n// `promisify(scryptCb)` resolves to the no-options overload, so we wrap by hand\n// to keep the cost parameters (N, r, p).\nconst scrypt = (\n value: string,\n salt: Buffer,\n keylen: number,\n options: ScryptOptions\n): Promise<Buffer> =>\n new Promise((resolve, reject) => {\n scryptCb(value, salt, keylen, options, (err, derivedKey) => {\n if (err) {\n reject(err);\n } else {\n resolve(derivedKey);\n }\n });\n });\n\n/**\n * Default hasher, built on Node's `crypto.scrypt` — no native dependency, so it runs anywhere Node\n * runs.\n *\n * Configuration (from `webiny.config.tsx` via `<Infra.Hashing>` → BuildParams):\n * - `HashingPepper` — an optional server-side secret folded into every hash. Unlike the per-value\n * salt (stored alongside the hash), the pepper is NOT stored, so a stolen database alone cannot\n * be brute-forced without also holding the pepper. Changing it invalidates existing hashes (same\n * trade-off as rotating the encryption passphrase). Omitted → no pepper, salt only.\n * - `HashingCost` — optional override of the scrypt cost parameter N. Defaults to 16384.\n *\n * The stored value is self-describing (`scrypt$N$r$p$salt$hash`), so switching to Argon2id later is\n * a matter of registering a different `Hasher` — old scrypt hashes keep verifying.\n */\nconst PREFIX = \"scrypt\";\nconst KEYLEN = 64;\nconst SALT_BYTES = 16;\n\ninterface ScryptCost {\n N: number;\n r: number;\n p: number;\n}\n\nconst DEFAULT_COST: ScryptCost = { N: 16384, r: 8, p: 1 };\n\nexport class ScryptHasher implements IHasher {\n private readonly cost: ScryptCost;\n private readonly pepper: string;\n\n constructor(buildParams: BuildParams.Interface) {\n this.pepper = buildParams.get<string>(\"HashingPepper\") ?? \"\";\n const costN = buildParams.get<number | string>(\"HashingCost\");\n this.cost = costN ? { ...DEFAULT_COST, N: Number(costN) } : DEFAULT_COST;\n }\n\n async hash(value: string): Promise<string> {\n const { N, r, p } = this.cost;\n const salt = randomBytes(SALT_BYTES);\n const derived = (await scrypt(this.withPepper(value), salt, KEYLEN, { N, r, p })) as Buffer;\n\n return [PREFIX, N, r, p, salt.toString(\"base64\"), derived.toString(\"base64\")].join(\"$\");\n }\n\n async verify(value: string, storedHash: string): Promise<boolean> {\n const parts = storedHash.split(\"$\");\n if (parts.length !== 6 || parts[0] !== PREFIX) {\n return false;\n }\n\n const [, nRaw, rRaw, pRaw, saltB64, hashB64] = parts;\n const N = Number(nRaw);\n const r = Number(rRaw);\n const p = Number(pRaw);\n const salt = Buffer.from(saltB64, \"base64\");\n const expected = Buffer.from(hashB64, \"base64\");\n\n const derived = (await scrypt(this.withPepper(value), salt, expected.length, {\n N,\n r,\n p\n })) as Buffer;\n\n // Lengths always match here, so timingSafeEqual is safe to call directly.\n return timingSafeEqual(derived, expected);\n }\n\n private withPepper(value: string): string {\n return this.pepper ? `${value}${this.pepper}` : value;\n }\n}\n\nexport const Hasher = createImplementation({\n abstraction: HasherAbstraction,\n implementation: ScryptHasher,\n dependencies: [BuildParams]\n});\n"],"names":["scrypt","value","salt","keylen","options","Promise","resolve","reject","scryptCb","err","derivedKey","PREFIX","KEYLEN","SALT_BYTES","DEFAULT_COST","ScryptHasher","buildParams","costN","Number","N","r","p","randomBytes","derived","storedHash","parts","nRaw","rRaw","pRaw","saltB64","hashB64","Buffer","expected","timingSafeEqual","Hasher","createImplementation","HasherAbstraction","BuildParams"],"mappings":";;;;AASA,MAAMA,sBAAS,CACXC,OACAC,MACAC,QACAC,UAEA,IAAIC,QAAQ,CAACC,SAASC;QAClBC,OAASP,OAAOC,MAAMC,QAAQC,SAAS,CAACK,KAAKC;YACzC,IAAID,KACAF,OAAOE;iBAEPH,QAAQI;QAEhB;IACJ;AAgBJ,MAAMC,SAAS;AACf,MAAMC,SAAS;AACf,MAAMC,aAAa;AAQnB,MAAMC,eAA2B;IAAE,GAAG;IAAO,GAAG;IAAG,GAAG;AAAE;AAEjD,MAAMC;IAIT,YAAYC,WAAkC,CAAE;QAC5C,IAAI,CAAC,MAAM,GAAGA,YAAY,GAAG,CAAS,oBAAoB;QAC1D,MAAMC,QAAQD,YAAY,GAAG,CAAkB;QAC/C,IAAI,CAAC,IAAI,GAAGC,QAAQ;YAAE,GAAGH,YAAY;YAAE,GAAGI,OAAOD;QAAO,IAAIH;IAChE;IAEA,MAAM,KAAKb,KAAa,EAAmB;QACvC,MAAM,EAAEkB,CAAC,EAAEC,CAAC,EAAEC,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI;QAC7B,MAAMnB,OAAOoB,YAAYT;QACzB,MAAMU,UAAW,MAAMvB,oBAAO,IAAI,CAAC,UAAU,CAACC,QAAQC,MAAMU,QAAQ;YAAEO;YAAGC;YAAGC;QAAE;QAE9E,OAAO;YAACV;YAAQQ;YAAGC;YAAGC;YAAGnB,KAAK,QAAQ,CAAC;YAAWqB,QAAQ,QAAQ,CAAC;SAAU,CAAC,IAAI,CAAC;IACvF;IAEA,MAAM,OAAOtB,KAAa,EAAEuB,UAAkB,EAAoB;QAC9D,MAAMC,QAAQD,WAAW,KAAK,CAAC;QAC/B,IAAIC,AAAiB,MAAjBA,MAAM,MAAM,IAAUA,KAAK,CAAC,EAAE,KAAKd,QACnC,OAAO;QAGX,MAAM,GAAGe,MAAMC,MAAMC,MAAMC,SAASC,QAAQ,GAAGL;QAC/C,MAAMN,IAAID,OAAOQ;QACjB,MAAMN,IAAIF,OAAOS;QACjB,MAAMN,IAAIH,OAAOU;QACjB,MAAM1B,OAAO6B,OAAO,IAAI,CAACF,SAAS;QAClC,MAAMG,WAAWD,OAAO,IAAI,CAACD,SAAS;QAEtC,MAAMP,UAAW,MAAMvB,oBAAO,IAAI,CAAC,UAAU,CAACC,QAAQC,MAAM8B,SAAS,MAAM,EAAE;YACzEb;YACAC;YACAC;QACJ;QAGA,OAAOY,gBAAgBV,SAASS;IACpC;IAEQ,WAAW/B,KAAa,EAAU;QACtC,OAAO,IAAI,CAAC,MAAM,GAAG,GAAGA,QAAQ,IAAI,CAAC,MAAM,EAAE,GAAGA;IACpD;AACJ;AAEO,MAAMiC,sBAASC,qBAAqB;IACvC,aAAaC;IACb,gBAAgBrB;IAChB,cAAc;QAACsB;KAAY;AAC/B"}
1
+ {"version":3,"file":"features/hashing/ScryptHasher.js","sources":["../../../src/features/hashing/ScryptHasher.ts"],"sourcesContent":["import { randomBytes, scrypt as scryptCb, timingSafeEqual } from \"node:crypto\";\nimport type { ScryptOptions } from \"node:crypto\";\nimport { createImplementation } from \"@webiny/feature/api\";\nimport { Hasher as HasherAbstraction } from \"./abstractions.js\";\nimport type { IHasher } from \"./abstractions.js\";\nimport { HashingConfig } from \"./abstractions.js\";\n\n// `promisify(scryptCb)` resolves to the no-options overload, so we wrap by hand\n// to keep the cost parameters (N, r, p).\nconst scrypt = (\n value: string,\n salt: Buffer,\n keylen: number,\n options: ScryptOptions\n): Promise<Buffer> =>\n new Promise((resolve, reject) => {\n scryptCb(value, salt, keylen, options, (err, derivedKey) => {\n if (err) {\n reject(err);\n } else {\n resolve(derivedKey);\n }\n });\n });\n\n/**\n * Default hasher, built on Node's `crypto.scrypt` — no native dependency, so it runs anywhere Node\n * runs.\n *\n * Configuration (from `webiny.config.tsx` via `<Infra.Hashing>` → BuildParams):\n * - `HashingPepper` — an optional server-side secret folded into every hash. Unlike the per-value\n * salt (stored alongside the hash), the pepper is NOT stored, so a stolen database alone cannot\n * be brute-forced without also holding the pepper. Changing it invalidates existing hashes (same\n * trade-off as rotating the encryption passphrase). Omitted → no pepper, salt only.\n * - `HashingCost` — optional override of the scrypt cost parameter N. Defaults to 16384.\n *\n * The stored value is self-describing (`scrypt$N$r$p$salt$hash`), so switching to Argon2id later is\n * a matter of registering a different `Hasher` — old scrypt hashes keep verifying.\n */\nconst PREFIX = \"scrypt\";\nconst KEYLEN = 64;\nconst SALT_BYTES = 16;\n\ninterface ScryptCost {\n N: number;\n r: number;\n p: number;\n}\n\nconst DEFAULT_COST: ScryptCost = { N: 16384, r: 8, p: 1 };\n\nexport class ScryptHasher implements IHasher {\n private readonly cost: ScryptCost;\n private readonly pepper: string;\n\n constructor(config: HashingConfig.Interface) {\n this.pepper = config.pepper;\n this.cost = config.costN ? { ...DEFAULT_COST, N: config.costN } : DEFAULT_COST;\n }\n\n async hash(value: string): Promise<string> {\n const { N, r, p } = this.cost;\n const salt = randomBytes(SALT_BYTES);\n const derived = (await scrypt(this.withPepper(value), salt, KEYLEN, { N, r, p })) as Buffer;\n\n return [PREFIX, N, r, p, salt.toString(\"base64\"), derived.toString(\"base64\")].join(\"$\");\n }\n\n async verify(value: string, storedHash: string): Promise<boolean> {\n const parts = storedHash.split(\"$\");\n if (parts.length !== 6 || parts[0] !== PREFIX) {\n return false;\n }\n\n const [, nRaw, rRaw, pRaw, saltB64, hashB64] = parts;\n const N = Number(nRaw);\n const r = Number(rRaw);\n const p = Number(pRaw);\n const salt = Buffer.from(saltB64, \"base64\");\n const expected = Buffer.from(hashB64, \"base64\");\n\n const derived = (await scrypt(this.withPepper(value), salt, expected.length, {\n N,\n r,\n p\n })) as Buffer;\n\n // Lengths always match here, so timingSafeEqual is safe to call directly.\n return timingSafeEqual(derived, expected);\n }\n\n private withPepper(value: string): string {\n return this.pepper ? `${value}${this.pepper}` : value;\n }\n}\n\nexport const Hasher = createImplementation({\n abstraction: HasherAbstraction,\n implementation: ScryptHasher,\n dependencies: [HashingConfig]\n});\n"],"names":["scrypt","value","salt","keylen","options","Promise","resolve","reject","scryptCb","err","derivedKey","PREFIX","KEYLEN","SALT_BYTES","DEFAULT_COST","ScryptHasher","config","N","r","p","randomBytes","derived","storedHash","parts","nRaw","rRaw","pRaw","saltB64","hashB64","Number","Buffer","expected","timingSafeEqual","Hasher","createImplementation","HasherAbstraction","HashingConfig"],"mappings":";;;AASA,MAAMA,sBAAS,CACXC,OACAC,MACAC,QACAC,UAEA,IAAIC,QAAQ,CAACC,SAASC;QAClBC,OAASP,OAAOC,MAAMC,QAAQC,SAAS,CAACK,KAAKC;YACzC,IAAID,KACAF,OAAOE;iBAEPH,QAAQI;QAEhB;IACJ;AAgBJ,MAAMC,SAAS;AACf,MAAMC,SAAS;AACf,MAAMC,aAAa;AAQnB,MAAMC,eAA2B;IAAE,GAAG;IAAO,GAAG;IAAG,GAAG;AAAE;AAEjD,MAAMC;IAIT,YAAYC,MAA+B,CAAE;QACzC,IAAI,CAAC,MAAM,GAAGA,OAAO,MAAM;QAC3B,IAAI,CAAC,IAAI,GAAGA,OAAO,KAAK,GAAG;YAAE,GAAGF,YAAY;YAAE,GAAGE,OAAO,KAAK;QAAC,IAAIF;IACtE;IAEA,MAAM,KAAKb,KAAa,EAAmB;QACvC,MAAM,EAAEgB,CAAC,EAAEC,CAAC,EAAEC,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI;QAC7B,MAAMjB,OAAOkB,YAAYP;QACzB,MAAMQ,UAAW,MAAMrB,oBAAO,IAAI,CAAC,UAAU,CAACC,QAAQC,MAAMU,QAAQ;YAAEK;YAAGC;YAAGC;QAAE;QAE9E,OAAO;YAACR;YAAQM;YAAGC;YAAGC;YAAGjB,KAAK,QAAQ,CAAC;YAAWmB,QAAQ,QAAQ,CAAC;SAAU,CAAC,IAAI,CAAC;IACvF;IAEA,MAAM,OAAOpB,KAAa,EAAEqB,UAAkB,EAAoB;QAC9D,MAAMC,QAAQD,WAAW,KAAK,CAAC;QAC/B,IAAIC,AAAiB,MAAjBA,MAAM,MAAM,IAAUA,KAAK,CAAC,EAAE,KAAKZ,QACnC,OAAO;QAGX,MAAM,GAAGa,MAAMC,MAAMC,MAAMC,SAASC,QAAQ,GAAGL;QAC/C,MAAMN,IAAIY,OAAOL;QACjB,MAAMN,IAAIW,OAAOJ;QACjB,MAAMN,IAAIU,OAAOH;QACjB,MAAMxB,OAAO4B,OAAO,IAAI,CAACH,SAAS;QAClC,MAAMI,WAAWD,OAAO,IAAI,CAACF,SAAS;QAEtC,MAAMP,UAAW,MAAMrB,oBAAO,IAAI,CAAC,UAAU,CAACC,QAAQC,MAAM6B,SAAS,MAAM,EAAE;YACzEd;YACAC;YACAC;QACJ;QAGA,OAAOa,gBAAgBX,SAASU;IACpC;IAEQ,WAAW9B,KAAa,EAAU;QACtC,OAAO,IAAI,CAAC,MAAM,GAAG,GAAGA,QAAQ,IAAI,CAAC,MAAM,EAAE,GAAGA;IACpD;AACJ;AAEO,MAAMgC,sBAASC,qBAAqB;IACvC,aAAaC;IACb,gBAAgBpB;IAChB,cAAc;QAACqB;KAAc;AACjC"}
@@ -16,3 +16,18 @@ export declare const Hasher: import("@webiny/di").Abstraction<IHasher>;
16
16
  export declare namespace Hasher {
17
17
  type Interface = IHasher;
18
18
  }
19
+ export interface IHashingConfig {
20
+ /** Server-side secret folded into every hash. Empty when none is configured. */
21
+ readonly pepper: string;
22
+ /** scrypt cost parameter N. `null` uses the default. */
23
+ readonly costN: number | null;
24
+ }
25
+ /**
26
+ * Where `Hasher` gets its pepper and cost. The default reads the `HashingPepper` and `HashingCost`
27
+ * build params (`<Infra.Crypto.Hashing>`). A hosting type can replace it, e.g. to read the pepper
28
+ * from env at startup.
29
+ */
30
+ export declare const HashingConfig: import("@webiny/di").Abstraction<IHashingConfig>;
31
+ export declare namespace HashingConfig {
32
+ type Interface = IHashingConfig;
33
+ }
@@ -1,5 +1,6 @@
1
1
  import { createAbstraction } from "@webiny/feature/api";
2
2
  const Hasher = createAbstraction("Hasher");
3
- export { Hasher };
3
+ const HashingConfig = createAbstraction("HashingConfig");
4
+ export { Hasher, HashingConfig };
4
5
 
5
6
  //# sourceMappingURL=abstractions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"features/hashing/abstractions.js","sources":["../../../src/features/hashing/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\n\nexport interface IHasher {\n hash(value: string): Promise<string>;\n /** Constant-time compare of `value` against a previously produced hash string. */\n verify(value: string, storedHash: string): Promise<boolean>;\n}\n\n/**\n * Hashes and verifies secret values (passwords, API-key secrets, tokens, …) with a slow, salted\n * KDF — built for the \"store a hash, later verify a presented value\" pattern.\n *\n * NOT a general-purpose digest: output is salted and non-deterministic, so this is the wrong tool\n * for checksums / cache keys / dedup (use a fast deterministic digest util for those). Swap the\n * implementation to change algorithms (e.g. Argon2id); stored hashes are self-describing, so old\n * hashes keep verifying after a swap.\n */\nexport const Hasher = createAbstraction<IHasher>(\"Hasher\");\n\nexport namespace Hasher {\n export type Interface = IHasher;\n}\n"],"names":["Hasher","createAbstraction"],"mappings":";AAiBO,MAAMA,SAASC,kBAA2B"}
1
+ {"version":3,"file":"features/hashing/abstractions.js","sources":["../../../src/features/hashing/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\n\nexport interface IHasher {\n hash(value: string): Promise<string>;\n /** Constant-time compare of `value` against a previously produced hash string. */\n verify(value: string, storedHash: string): Promise<boolean>;\n}\n\n/**\n * Hashes and verifies secret values (passwords, API-key secrets, tokens, …) with a slow, salted\n * KDF — built for the \"store a hash, later verify a presented value\" pattern.\n *\n * NOT a general-purpose digest: output is salted and non-deterministic, so this is the wrong tool\n * for checksums / cache keys / dedup (use a fast deterministic digest util for those). Swap the\n * implementation to change algorithms (e.g. Argon2id); stored hashes are self-describing, so old\n * hashes keep verifying after a swap.\n */\nexport const Hasher = createAbstraction<IHasher>(\"Hasher\");\n\nexport namespace Hasher {\n export type Interface = IHasher;\n}\n\nexport interface IHashingConfig {\n /** Server-side secret folded into every hash. Empty when none is configured. */\n readonly pepper: string;\n /** scrypt cost parameter N. `null` uses the default. */\n readonly costN: number | null;\n}\n\n/**\n * Where `Hasher` gets its pepper and cost. The default reads the `HashingPepper` and `HashingCost`\n * build params (`<Infra.Crypto.Hashing>`). A hosting type can replace it, e.g. to read the pepper\n * from env at startup.\n */\nexport const HashingConfig = createAbstraction<IHashingConfig>(\"HashingConfig\");\n\nexport namespace HashingConfig {\n export type Interface = IHashingConfig;\n}\n"],"names":["Hasher","createAbstraction","HashingConfig"],"mappings":";AAiBO,MAAMA,SAASC,kBAA2B;AAkB1C,MAAMC,gBAAgBD,kBAAkC"}
@@ -1,8 +1,10 @@
1
1
  import { createFeature } from "@webiny/feature/api";
2
2
  import { Hasher } from "./ScryptHasher.js";
3
+ import { BuildParamsHashingConfig } from "./BuildParamsHashingConfig.js";
3
4
  const HasherFeature = createFeature({
4
5
  name: "HasherFeature",
5
6
  register (container) {
7
+ container.register(BuildParamsHashingConfig);
6
8
  container.register(Hasher);
7
9
  }
8
10
  });
@@ -1 +1 @@
1
- {"version":3,"file":"features/hashing/feature.js","sources":["../../../src/features/hashing/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { Hasher } from \"./ScryptHasher.js\";\n\nexport const HasherFeature = createFeature({\n name: \"HasherFeature\",\n register(container) {\n container.register(Hasher);\n }\n});\n"],"names":["HasherFeature","createFeature","container","Hasher"],"mappings":";;AAGO,MAAMA,gBAAgBC,cAAc;IACvC,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
1
+ {"version":3,"file":"features/hashing/feature.js","sources":["../../../src/features/hashing/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { Hasher } from \"./ScryptHasher.js\";\nimport { BuildParamsHashingConfig } from \"./BuildParamsHashingConfig.js\";\n\nexport const HasherFeature = createFeature({\n name: \"HasherFeature\",\n register(container) {\n container.register(BuildParamsHashingConfig);\n container.register(Hasher);\n }\n});\n"],"names":["HasherFeature","createFeature","container","BuildParamsHashingConfig","Hasher"],"mappings":";;;AAIO,MAAMA,gBAAgBC,cAAc;IACvC,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE;IACvB;AACJ"}
@@ -1,2 +1,3 @@
1
1
  export { Hasher } from "./abstractions.js";
2
+ export { HashingConfig } from "./abstractions.js";
2
3
  export type { IHasher } from "./abstractions.js";
@@ -1 +1 @@
1
- export { Hasher } from "./abstractions.js";
1
+ export { Hasher, HashingConfig } from "./abstractions.js";
@@ -0,0 +1,7 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { HttpClient as HttpClientAbstraction } from "./abstractions.js";
3
+ declare class HttpClientImpl implements HttpClientAbstraction.Interface {
4
+ requestJson(request: HttpClientAbstraction.Request): Promise<Result<unknown, HttpClientAbstraction.Error>>;
5
+ }
6
+ export declare const HttpClient: import("@webiny/di").Implementation<typeof HttpClientImpl>;
7
+ export {};
@@ -0,0 +1,72 @@
1
+ import { Result, createImplementation } from "@webiny/feature/api";
2
+ import { HttpClient } from "./abstractions.js";
3
+ import { HttpRequestError } from "./HttpRequestError.js";
4
+ import { HttpStatusError } from "./HttpStatusError.js";
5
+ const DEFAULT_TIMEOUT_MS = 10000;
6
+ function createRequestInit(request) {
7
+ const timeoutMs = request.timeoutMs ?? DEFAULT_TIMEOUT_MS;
8
+ const headers = new Headers(request.headers);
9
+ const init = {
10
+ method: request.method ?? "GET",
11
+ headers,
12
+ signal: AbortSignal.timeout(timeoutMs)
13
+ };
14
+ if (void 0 !== request.body) {
15
+ if (!headers.has("content-type")) headers.set("content-type", "application/json");
16
+ init.body = JSON.stringify(request.body);
17
+ }
18
+ return init;
19
+ }
20
+ function isTimeout(error) {
21
+ return error instanceof Error && "TimeoutError" === error.name;
22
+ }
23
+ function parseJson(text) {
24
+ if ("" === text) return Result.ok(void 0);
25
+ try {
26
+ const value = JSON.parse(text);
27
+ return Result.ok(value);
28
+ } catch (error) {
29
+ return Result.fail(error);
30
+ }
31
+ }
32
+ class HttpClientImpl {
33
+ async requestJson(request) {
34
+ const { url } = request;
35
+ const init = createRequestInit(request);
36
+ let response;
37
+ let text;
38
+ try {
39
+ response = await fetch(url, init);
40
+ text = await response.text();
41
+ } catch (error) {
42
+ const reason = isTimeout(error) ? "timeout" : "network";
43
+ return Result.fail(new HttpRequestError({
44
+ url,
45
+ reason
46
+ }, error));
47
+ }
48
+ const body = parseJson(text);
49
+ if (!response.ok) {
50
+ const statusError = new HttpStatusError({
51
+ url,
52
+ status: response.status,
53
+ statusText: response.statusText,
54
+ body: body.isOk() ? body.value : void 0
55
+ });
56
+ return Result.fail(statusError);
57
+ }
58
+ if (body.isFail()) return Result.fail(new HttpRequestError({
59
+ url,
60
+ reason: "invalidJson"
61
+ }, body.error));
62
+ return Result.ok(body.value);
63
+ }
64
+ }
65
+ const HttpClient_HttpClient = createImplementation({
66
+ abstraction: HttpClient,
67
+ implementation: HttpClientImpl,
68
+ dependencies: []
69
+ });
70
+ export { HttpClient_HttpClient as HttpClient };
71
+
72
+ //# sourceMappingURL=HttpClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/httpClient/HttpClient.js","sources":["../../../src/features/httpClient/HttpClient.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { HttpClient as HttpClientAbstraction } from \"./abstractions.js\";\nimport { HttpRequestError } from \"./HttpRequestError.js\";\nimport { HttpStatusError } from \"./HttpStatusError.js\";\n\nconst DEFAULT_TIMEOUT_MS = 10_000;\n\nfunction createRequestInit(request: HttpClientAbstraction.Request): RequestInit {\n const timeoutMs = request.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n const headers = new Headers(request.headers);\n const init: RequestInit = {\n method: request.method ?? \"GET\",\n headers,\n signal: AbortSignal.timeout(timeoutMs)\n };\n\n if (request.body !== undefined) {\n if (!headers.has(\"content-type\")) {\n headers.set(\"content-type\", \"application/json\");\n }\n init.body = JSON.stringify(request.body);\n }\n\n return init;\n}\n\nfunction isTimeout(error: unknown): boolean {\n return error instanceof Error && error.name === \"TimeoutError\";\n}\n\n// An empty body parses to `undefined`, so a 204 is not an invalid response.\nfunction parseJson(text: string): Result<unknown, unknown> {\n if (text === \"\") {\n return Result.ok(undefined);\n }\n try {\n const value: unknown = JSON.parse(text);\n return Result.ok(value);\n } catch (error) {\n return Result.fail(error);\n }\n}\n\nclass HttpClientImpl implements HttpClientAbstraction.Interface {\n async requestJson(\n request: HttpClientAbstraction.Request\n ): Promise<Result<unknown, HttpClientAbstraction.Error>> {\n const { url } = request;\n const init = createRequestInit(request);\n\n let response: Response;\n let text: string;\n try {\n response = await fetch(url, init);\n text = await response.text();\n } catch (error) {\n const reason = isTimeout(error) ? \"timeout\" : \"network\";\n return Result.fail(new HttpRequestError({ url, reason }, error));\n }\n\n const body = parseJson(text);\n\n if (!response.ok) {\n const statusError = new HttpStatusError({\n url,\n status: response.status,\n statusText: response.statusText,\n body: body.isOk() ? body.value : undefined\n });\n return Result.fail(statusError);\n }\n\n if (body.isFail()) {\n return Result.fail(new HttpRequestError({ url, reason: \"invalidJson\" }, body.error));\n }\n\n return Result.ok(body.value);\n }\n}\n\nexport const HttpClient = createImplementation({\n abstraction: HttpClientAbstraction,\n implementation: HttpClientImpl,\n dependencies: []\n});\n"],"names":["DEFAULT_TIMEOUT_MS","createRequestInit","request","timeoutMs","headers","Headers","init","AbortSignal","undefined","JSON","isTimeout","error","Error","parseJson","text","Result","value","HttpClientImpl","url","response","fetch","reason","HttpRequestError","body","statusError","HttpStatusError","HttpClient","createImplementation","HttpClientAbstraction"],"mappings":";;;;AAMA,MAAMA,qBAAqB;AAE3B,SAASC,kBAAkBC,OAAsC;IAC7D,MAAMC,YAAYD,QAAQ,SAAS,IAAIF;IACvC,MAAMI,UAAU,IAAIC,QAAQH,QAAQ,OAAO;IAC3C,MAAMI,OAAoB;QACtB,QAAQJ,QAAQ,MAAM,IAAI;QAC1BE;QACA,QAAQG,YAAY,OAAO,CAACJ;IAChC;IAEA,IAAID,AAAiBM,WAAjBN,QAAQ,IAAI,EAAgB;QAC5B,IAAI,CAACE,QAAQ,GAAG,CAAC,iBACbA,QAAQ,GAAG,CAAC,gBAAgB;QAEhCE,KAAK,IAAI,GAAGG,KAAK,SAAS,CAACP,QAAQ,IAAI;IAC3C;IAEA,OAAOI;AACX;AAEA,SAASI,UAAUC,KAAc;IAC7B,OAAOA,iBAAiBC,SAASD,AAAe,mBAAfA,MAAM,IAAI;AAC/C;AAGA,SAASE,UAAUC,IAAY;IAC3B,IAAIA,AAAS,OAATA,MACA,OAAOC,OAAO,EAAE,CAACP;IAErB,IAAI;QACA,MAAMQ,QAAiBP,KAAK,KAAK,CAACK;QAClC,OAAOC,OAAO,EAAE,CAACC;IACrB,EAAE,OAAOL,OAAO;QACZ,OAAOI,OAAO,IAAI,CAACJ;IACvB;AACJ;AAEA,MAAMM;IACF,MAAM,YACFf,OAAsC,EACe;QACrD,MAAM,EAAEgB,GAAG,EAAE,GAAGhB;QAChB,MAAMI,OAAOL,kBAAkBC;QAE/B,IAAIiB;QACJ,IAAIL;QACJ,IAAI;YACAK,WAAW,MAAMC,MAAMF,KAAKZ;YAC5BQ,OAAO,MAAMK,SAAS,IAAI;QAC9B,EAAE,OAAOR,OAAO;YACZ,MAAMU,SAASX,UAAUC,SAAS,YAAY;YAC9C,OAAOI,OAAO,IAAI,CAAC,IAAIO,iBAAiB;gBAAEJ;gBAAKG;YAAO,GAAGV;QAC7D;QAEA,MAAMY,OAAOV,UAAUC;QAEvB,IAAI,CAACK,SAAS,EAAE,EAAE;YACd,MAAMK,cAAc,IAAIC,gBAAgB;gBACpCP;gBACA,QAAQC,SAAS,MAAM;gBACvB,YAAYA,SAAS,UAAU;gBAC/B,MAAMI,KAAK,IAAI,KAAKA,KAAK,KAAK,GAAGf;YACrC;YACA,OAAOO,OAAO,IAAI,CAACS;QACvB;QAEA,IAAID,KAAK,MAAM,IACX,OAAOR,OAAO,IAAI,CAAC,IAAIO,iBAAiB;YAAEJ;YAAK,QAAQ;QAAc,GAAGK,KAAK,KAAK;QAGtF,OAAOR,OAAO,EAAE,CAACQ,KAAK,KAAK;IAC/B;AACJ;AAEO,MAAMG,wBAAaC,qBAAqB;IAC3C,aAAaC;IACb,gBAAgBX;IAChB,cAAc,EAAE;AACpB"}
@@ -0,0 +1,10 @@
1
+ import { BaseError } from "@webiny/feature/api";
2
+ export interface HttpRequestErrorData {
3
+ url: string;
4
+ reason: "network" | "timeout" | "invalidJson";
5
+ }
6
+ /** The request didn't produce a usable response: it failed, timed out, or the body wasn't JSON. */
7
+ export declare class HttpRequestError extends BaseError<HttpRequestErrorData> {
8
+ readonly code: "HttpClient/Request";
9
+ constructor(data: HttpRequestErrorData, cause: unknown);
10
+ }
@@ -0,0 +1,13 @@
1
+ import { BaseError } from "@webiny/feature/api";
2
+ class HttpRequestError extends BaseError {
3
+ constructor(data, cause){
4
+ super({
5
+ message: `Request to "${data.url}" failed (${data.reason}).`,
6
+ data
7
+ }), this.code = "HttpClient/Request";
8
+ this.cause = cause;
9
+ }
10
+ }
11
+ export { HttpRequestError };
12
+
13
+ //# sourceMappingURL=HttpRequestError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/httpClient/HttpRequestError.js","sources":["../../../src/features/httpClient/HttpRequestError.ts"],"sourcesContent":["import { BaseError } from \"@webiny/feature/api\";\n\nexport interface HttpRequestErrorData {\n url: string;\n reason: \"network\" | \"timeout\" | \"invalidJson\";\n}\n\n/** The request didn't produce a usable response: it failed, timed out, or the body wasn't JSON. */\nexport class HttpRequestError extends BaseError<HttpRequestErrorData> {\n override readonly code = \"HttpClient/Request\" as const;\n\n constructor(data: HttpRequestErrorData, cause: unknown) {\n super({\n message: `Request to \"${data.url}\" failed (${data.reason}).`,\n data\n });\n this.cause = cause;\n }\n}\n"],"names":["HttpRequestError","BaseError","data","cause"],"mappings":";AAQO,MAAMA,yBAAyBC;IAGlC,YAAYC,IAA0B,EAAEC,KAAc,CAAE;QACpD,KAAK,CAAC;YACF,SAAS,CAAC,YAAY,EAAED,KAAK,GAAG,CAAC,UAAU,EAAEA,KAAK,MAAM,CAAC,EAAE,CAAC;YAC5DA;QACJ,SANc,IAAI,GAAG;QAOrB,IAAI,CAAC,KAAK,GAAGC;IACjB;AACJ"}
@@ -0,0 +1,12 @@
1
+ import { BaseError } from "@webiny/feature/api";
2
+ export interface HttpStatusErrorData {
3
+ url: string;
4
+ status: number;
5
+ statusText: string;
6
+ body: unknown;
7
+ }
8
+ /** The server answered with a non-2xx status. */
9
+ export declare class HttpStatusError extends BaseError<HttpStatusErrorData> {
10
+ readonly code: "HttpClient/Status";
11
+ constructor(data: HttpStatusErrorData);
12
+ }
@@ -0,0 +1,12 @@
1
+ import { BaseError } from "@webiny/feature/api";
2
+ class HttpStatusError extends BaseError {
3
+ constructor(data){
4
+ super({
5
+ message: `Request to "${data.url}" failed with status ${data.status}.`,
6
+ data
7
+ }), this.code = "HttpClient/Status";
8
+ }
9
+ }
10
+ export { HttpStatusError };
11
+
12
+ //# sourceMappingURL=HttpStatusError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/httpClient/HttpStatusError.js","sources":["../../../src/features/httpClient/HttpStatusError.ts"],"sourcesContent":["import { BaseError } from \"@webiny/feature/api\";\n\nexport interface HttpStatusErrorData {\n url: string;\n status: number;\n statusText: string;\n body: unknown; // the parsed JSON body, or `undefined` when there was none\n}\n\n/** The server answered with a non-2xx status. */\nexport class HttpStatusError extends BaseError<HttpStatusErrorData> {\n override readonly code = \"HttpClient/Status\" as const;\n\n constructor(data: HttpStatusErrorData) {\n super({\n message: `Request to \"${data.url}\" failed with status ${data.status}.`,\n data\n });\n }\n}\n"],"names":["HttpStatusError","BaseError","data"],"mappings":";AAUO,MAAMA,wBAAwBC;IAGjC,YAAYC,IAAyB,CAAE;QACnC,KAAK,CAAC;YACF,SAAS,CAAC,YAAY,EAAEA,KAAK,GAAG,CAAC,qBAAqB,EAAEA,KAAK,MAAM,CAAC,CAAC,CAAC;YACtEA;QACJ,SANc,IAAI,GAAG;IAOzB;AACJ"}
@@ -0,0 +1,32 @@
1
+ import type { Result } from "@webiny/feature/api";
2
+ import type { HttpRequestError } from "./HttpRequestError.js";
3
+ import type { HttpStatusError } from "./HttpStatusError.js";
4
+ export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
5
+ export interface IHttpClientRequest {
6
+ url: string;
7
+ method?: HttpMethod;
8
+ headers?: Record<string, string>;
9
+ body?: unknown;
10
+ timeoutMs?: number;
11
+ }
12
+ export interface IHttpClientErrors {
13
+ request: HttpRequestError;
14
+ status: HttpStatusError;
15
+ }
16
+ type HttpClientError = IHttpClientErrors[keyof IHttpClientErrors];
17
+ export interface IHttpClient {
18
+ /**
19
+ * Sends a request and parses the response body as JSON. The body is `unknown` on purpose:
20
+ * validate it before use.
21
+ */
22
+ requestJson(request: IHttpClientRequest): Promise<Result<unknown, HttpClientError>>;
23
+ }
24
+ /** Outbound HTTP requests with a timeout, a status check and JSON parsing. */
25
+ export declare const HttpClient: import("@webiny/di").Abstraction<IHttpClient>;
26
+ export declare namespace HttpClient {
27
+ type Interface = IHttpClient;
28
+ type Request = IHttpClientRequest;
29
+ type Method = HttpMethod;
30
+ type Error = HttpClientError;
31
+ }
32
+ export {};
@@ -0,0 +1,5 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const HttpClient = createAbstraction("HttpClient");
3
+ export { HttpClient };
4
+
5
+ //# sourceMappingURL=abstractions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/httpClient/abstractions.js","sources":["../../../src/features/httpClient/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { Result } from \"@webiny/feature/api\";\nimport type { HttpRequestError } from \"./HttpRequestError.js\";\nimport type { HttpStatusError } from \"./HttpStatusError.js\";\n\nexport type HttpMethod = \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n\nexport interface IHttpClientRequest {\n url: string;\n method?: HttpMethod; // defaults to \"GET\"\n headers?: Record<string, string>;\n body?: unknown; // sent as JSON\n timeoutMs?: number; // defaults to 10 seconds\n}\n\nexport interface IHttpClientErrors {\n request: HttpRequestError;\n status: HttpStatusError;\n}\n\ntype HttpClientError = IHttpClientErrors[keyof IHttpClientErrors];\n\nexport interface IHttpClient {\n /**\n * Sends a request and parses the response body as JSON. The body is `unknown` on purpose:\n * validate it before use.\n */\n requestJson(request: IHttpClientRequest): Promise<Result<unknown, HttpClientError>>;\n}\n\n/** Outbound HTTP requests with a timeout, a status check and JSON parsing. */\nexport const HttpClient = createAbstraction<IHttpClient>(\"HttpClient\");\n\nexport namespace HttpClient {\n export type Interface = IHttpClient;\n export type Request = IHttpClientRequest;\n export type Method = HttpMethod;\n export type Error = HttpClientError;\n}\n"],"names":["HttpClient","createAbstraction"],"mappings":";AA+BO,MAAMA,aAAaC,kBAA+B"}
@@ -0,0 +1,4 @@
1
+ export declare const HttpClientFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -0,0 +1,11 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { HttpClient } from "./HttpClient.js";
3
+ const HttpClientFeature = createFeature({
4
+ name: "HttpClientFeature",
5
+ register (container) {
6
+ container.register(HttpClient).inSingletonScope();
7
+ }
8
+ });
9
+ export { HttpClientFeature };
10
+
11
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/httpClient/feature.js","sources":["../../../src/features/httpClient/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { HttpClient } from \"./HttpClient.js\";\n\nexport const HttpClientFeature = createFeature({\n name: \"HttpClientFeature\",\n register(container) {\n container.register(HttpClient).inSingletonScope();\n }\n});\n"],"names":["HttpClientFeature","createFeature","container","HttpClient"],"mappings":";;AAGO,MAAMA,oBAAoBC,cAAc;IAC3C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC,YAAY,gBAAgB;IACnD;AACJ"}
@@ -0,0 +1,3 @@
1
+ export { HttpClient } from "./abstractions.js";
2
+ export { HttpRequestError } from "./HttpRequestError.js";
3
+ export { HttpStatusError } from "./HttpStatusError.js";
@@ -0,0 +1,3 @@
1
+ export { HttpClient } from "./abstractions.js";
2
+ export { HttpRequestError } from "./HttpRequestError.js";
3
+ export { HttpStatusError } from "./HttpStatusError.js";
@@ -1,12 +1,18 @@
1
1
  import { Result } from "@webiny/feature/api";
2
- import { KeyValueStoreRepository, GlobalKeyValueStore as ServiceAbstraction, IGlobalKeyValueStoreOptions } from "./abstractions.js";
2
+ import { KeyValueStoreRepository } from "./abstractions.js";
3
+ import { GlobalKeyValueStore as ServiceAbstraction } from "./abstractions.js";
4
+ import type { IGlobalKeyValueStoreOptions } from "./abstractions.js";
5
+ import type { IGlobalKeyValueSetOptions } from "./abstractions.js";
6
+ import type { IGlobalKeyValueListParams } from "./abstractions.js";
7
+ import type { IGlobalKeyValueDeleteOptions } from "./abstractions.js";
3
8
  declare class GlobalKeyValueStoreImpl implements ServiceAbstraction.Interface {
4
9
  private repository;
5
10
  constructor(repository: KeyValueStoreRepository.Interface);
6
11
  private getScope;
7
12
  get<T = unknown>(key: string, options?: IGlobalKeyValueStoreOptions): Promise<Result<T, ServiceAbstraction.Error>>;
8
- set(key: string, value: any, options?: IGlobalKeyValueStoreOptions): Promise<Result<void, ServiceAbstraction.Error>>;
9
- delete(key: string, options?: IGlobalKeyValueStoreOptions): Promise<Result<void, ServiceAbstraction.Error>>;
13
+ set(key: string, value: any, options?: IGlobalKeyValueSetOptions): Promise<Result<void, ServiceAbstraction.Error>>;
14
+ delete(key: string, options?: IGlobalKeyValueDeleteOptions): Promise<Result<void, ServiceAbstraction.Error>>;
15
+ list<T = unknown>(params: IGlobalKeyValueListParams): Promise<Result<ServiceAbstraction.ListResult<T>, ServiceAbstraction.Error>>;
10
16
  }
11
17
  export declare const GlobalKeyValueStore: import("@webiny/di").Implementation<typeof GlobalKeyValueStoreImpl>;
12
18
  export {};
@@ -15,12 +15,22 @@ class GlobalKeyValueStoreImpl {
15
15
  async set(key, value, options) {
16
16
  const scope = this.getScope(options);
17
17
  return this.repository.set(key, value, scope, {
18
- expiresAt: options?.expiresAt
18
+ expiresAt: options?.expiresAt,
19
+ collection: options?.collection,
20
+ condition: options?.condition
19
21
  });
20
22
  }
21
23
  async delete(key, options) {
22
24
  const scope = this.getScope(options);
23
- return this.repository.delete(key, scope);
25
+ return this.repository.delete(key, scope, {
26
+ condition: options?.condition
27
+ });
28
+ }
29
+ async list(params) {
30
+ const { scope, ...listParams } = params;
31
+ return this.repository.list(this.getScope({
32
+ scope
33
+ }), listParams);
24
34
  }
25
35
  }
26
36
  const GlobalKeyValueStore_GlobalKeyValueStore = createImplementation({
@@ -1 +1 @@
1
- {"version":3,"file":"features/keyValueStore/GlobalKeyValueStore.js","sources":["../../../src/features/keyValueStore/GlobalKeyValueStore.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport {\n KeyValueStoreRepository,\n GlobalKeyValueStore as ServiceAbstraction,\n IGlobalKeyValueStoreOptions\n} from \"./abstractions.js\";\n\nconst DEFAULT_SCOPE = \"global\";\n\nclass GlobalKeyValueStoreImpl implements ServiceAbstraction.Interface {\n constructor(private repository: KeyValueStoreRepository.Interface) {}\n\n private getScope(options?: IGlobalKeyValueStoreOptions): string {\n return options?.scope || DEFAULT_SCOPE;\n }\n\n async get<T = unknown>(\n key: string,\n options?: IGlobalKeyValueStoreOptions\n ): Promise<Result<T, ServiceAbstraction.Error>> {\n const scope = this.getScope(options);\n return this.repository.get<T>(key, scope);\n }\n\n async set(\n key: string,\n value: any,\n options?: IGlobalKeyValueStoreOptions\n ): Promise<Result<void, ServiceAbstraction.Error>> {\n const scope = this.getScope(options);\n return this.repository.set(key, value, scope, {\n expiresAt: options?.expiresAt\n });\n }\n\n async delete(\n key: string,\n options?: IGlobalKeyValueStoreOptions\n ): Promise<Result<void, ServiceAbstraction.Error>> {\n const scope = this.getScope(options);\n return this.repository.delete(key, scope);\n }\n}\n\nexport const GlobalKeyValueStore = createImplementation({\n abstraction: ServiceAbstraction,\n implementation: GlobalKeyValueStoreImpl,\n dependencies: [KeyValueStoreRepository]\n});\n"],"names":["DEFAULT_SCOPE","GlobalKeyValueStoreImpl","repository","options","key","scope","value","GlobalKeyValueStore","createImplementation","ServiceAbstraction","KeyValueStoreRepository"],"mappings":";;AAQA,MAAMA,gBAAgB;AAEtB,MAAMC;IACF,YAAoBC,UAA6C,CAAE;aAA/CA,UAAU,GAAVA;IAAgD;IAE5D,SAASC,OAAqC,EAAU;QAC5D,OAAOA,SAAS,SAASH;IAC7B;IAEA,MAAM,IACFI,GAAW,EACXD,OAAqC,EACO;QAC5C,MAAME,QAAQ,IAAI,CAAC,QAAQ,CAACF;QAC5B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAIC,KAAKC;IACvC;IAEA,MAAM,IACFD,GAAW,EACXE,KAAU,EACVH,OAAqC,EACU;QAC/C,MAAME,QAAQ,IAAI,CAAC,QAAQ,CAACF;QAC5B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAACC,KAAKE,OAAOD,OAAO;YAC1C,WAAWF,SAAS;QACxB;IACJ;IAEA,MAAM,OACFC,GAAW,EACXD,OAAqC,EACU;QAC/C,MAAME,QAAQ,IAAI,CAAC,QAAQ,CAACF;QAC5B,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAACC,KAAKC;IACvC;AACJ;AAEO,MAAME,0CAAsBC,qBAAqB;IACpD,aAAaC;IACb,gBAAgBR;IAChB,cAAc;QAACS;KAAwB;AAC3C"}
1
+ {"version":3,"file":"features/keyValueStore/GlobalKeyValueStore.js","sources":["../../../src/features/keyValueStore/GlobalKeyValueStore.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { KeyValueStoreRepository } from \"./abstractions.js\";\nimport { GlobalKeyValueStore as ServiceAbstraction } from \"./abstractions.js\";\nimport type { IGlobalKeyValueStoreOptions } from \"./abstractions.js\";\nimport type { IGlobalKeyValueSetOptions } from \"./abstractions.js\";\nimport type { IGlobalKeyValueListParams } from \"./abstractions.js\";\nimport type { IGlobalKeyValueDeleteOptions } from \"./abstractions.js\";\n\nconst DEFAULT_SCOPE = \"global\";\n\nclass GlobalKeyValueStoreImpl implements ServiceAbstraction.Interface {\n constructor(private repository: KeyValueStoreRepository.Interface) {}\n\n private getScope(options?: { scope?: string }): string {\n return options?.scope || DEFAULT_SCOPE;\n }\n\n async get<T = unknown>(\n key: string,\n options?: IGlobalKeyValueStoreOptions\n ): Promise<Result<T, ServiceAbstraction.Error>> {\n const scope = this.getScope(options);\n return this.repository.get<T>(key, scope);\n }\n\n async set(\n key: string,\n value: any,\n options?: IGlobalKeyValueSetOptions\n ): Promise<Result<void, ServiceAbstraction.Error>> {\n const scope = this.getScope(options);\n return this.repository.set(key, value, scope, {\n expiresAt: options?.expiresAt,\n collection: options?.collection,\n condition: options?.condition\n });\n }\n\n async delete(\n key: string,\n options?: IGlobalKeyValueDeleteOptions\n ): Promise<Result<void, ServiceAbstraction.Error>> {\n const scope = this.getScope(options);\n return this.repository.delete(key, scope, { condition: options?.condition });\n }\n\n async list<T = unknown>(\n params: IGlobalKeyValueListParams\n ): Promise<Result<ServiceAbstraction.ListResult<T>, ServiceAbstraction.Error>> {\n const { scope, ...listParams } = params;\n return this.repository.list<T>(this.getScope({ scope }), listParams);\n }\n}\n\nexport const GlobalKeyValueStore = createImplementation({\n abstraction: ServiceAbstraction,\n implementation: GlobalKeyValueStoreImpl,\n dependencies: [KeyValueStoreRepository]\n});\n"],"names":["DEFAULT_SCOPE","GlobalKeyValueStoreImpl","repository","options","key","scope","value","params","listParams","GlobalKeyValueStore","createImplementation","ServiceAbstraction","KeyValueStoreRepository"],"mappings":";;AASA,MAAMA,gBAAgB;AAEtB,MAAMC;IACF,YAAoBC,UAA6C,CAAE;aAA/CA,UAAU,GAAVA;IAAgD;IAE5D,SAASC,OAA4B,EAAU;QACnD,OAAOA,SAAS,SAASH;IAC7B;IAEA,MAAM,IACFI,GAAW,EACXD,OAAqC,EACO;QAC5C,MAAME,QAAQ,IAAI,CAAC,QAAQ,CAACF;QAC5B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAIC,KAAKC;IACvC;IAEA,MAAM,IACFD,GAAW,EACXE,KAAU,EACVH,OAAmC,EACY;QAC/C,MAAME,QAAQ,IAAI,CAAC,QAAQ,CAACF;QAC5B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAACC,KAAKE,OAAOD,OAAO;YAC1C,WAAWF,SAAS;YACpB,YAAYA,SAAS;YACrB,WAAWA,SAAS;QACxB;IACJ;IAEA,MAAM,OACFC,GAAW,EACXD,OAAsC,EACS;QAC/C,MAAME,QAAQ,IAAI,CAAC,QAAQ,CAACF;QAC5B,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAACC,KAAKC,OAAO;YAAE,WAAWF,SAAS;QAAU;IAC9E;IAEA,MAAM,KACFI,MAAiC,EAC0C;QAC3E,MAAM,EAAEF,KAAK,EAAE,GAAGG,YAAY,GAAGD;QACjC,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAI,IAAI,CAAC,QAAQ,CAAC;YAAEF;QAAM,IAAIG;IAC7D;AACJ;AAEO,MAAMC,0CAAsBC,qBAAqB;IACpD,aAAaC;IACb,gBAAgBV;IAChB,cAAc;QAACW;KAAwB;AAC3C"}
@@ -1,14 +1,18 @@
1
1
  import { Result } from "@webiny/feature/api";
2
2
  import { KeyValueStore as ServiceAbstraction } from "./abstractions.js";
3
3
  import { GlobalKeyValueStore } from "./abstractions.js";
4
+ import type { IKeyValueSetOptions } from "./abstractions.js";
5
+ import type { IKeyValueDeleteOptions } from "./abstractions.js";
6
+ import type { IKeyValueListParams } from "./abstractions.js";
4
7
  import { TenantContext } from "../../features/tenancy/TenantContext/index.js";
5
8
  declare class KeyValueStoreImpl implements ServiceAbstraction.Interface {
6
9
  private tenantContext;
7
10
  private globalStore;
8
11
  constructor(tenantContext: TenantContext.Interface, globalStore: GlobalKeyValueStore.Interface);
9
12
  get<T = unknown>(key: string): Promise<Result<T, ServiceAbstraction.Error>>;
10
- set(key: string, value: any): Promise<Result<void, ServiceAbstraction.Error>>;
11
- delete(key: string): Promise<Result<void, ServiceAbstraction.Error>>;
13
+ set(key: string, value: any, options?: IKeyValueSetOptions): Promise<Result<void, ServiceAbstraction.Error>>;
14
+ delete(key: string, options?: IKeyValueDeleteOptions): Promise<Result<void, ServiceAbstraction.Error>>;
15
+ list<T = unknown>(params: IKeyValueListParams): Promise<Result<ServiceAbstraction.ListResult<T>, ServiceAbstraction.Error>>;
12
16
  }
13
17
  export declare const KeyValueStore: typeof KeyValueStoreImpl & {
14
18
  __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IKeyValueStore>;
@@ -11,15 +11,25 @@ class KeyValueStoreImpl {
11
11
  scope: tenant.id
12
12
  });
13
13
  }
14
- async set(key, value) {
14
+ async set(key, value, options) {
15
15
  const tenant = this.tenantContext.getTenant();
16
16
  return this.globalStore.set(key, value, {
17
- scope: tenant.id
17
+ scope: tenant.id,
18
+ collection: options?.collection,
19
+ condition: options?.condition
18
20
  });
19
21
  }
20
- async delete(key) {
22
+ async delete(key, options) {
21
23
  const tenant = this.tenantContext.getTenant();
22
24
  return this.globalStore.delete(key, {
25
+ scope: tenant.id,
26
+ condition: options?.condition
27
+ });
28
+ }
29
+ async list(params) {
30
+ const tenant = this.tenantContext.getTenant();
31
+ return this.globalStore.list({
32
+ ...params,
23
33
  scope: tenant.id
24
34
  });
25
35
  }
@@ -1 +1 @@
1
- {"version":3,"file":"features/keyValueStore/KeyValueStore.js","sources":["../../../src/features/keyValueStore/KeyValueStore.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { KeyValueStore as ServiceAbstraction } from \"./abstractions.js\";\nimport { GlobalKeyValueStore } from \"./abstractions.js\";\nimport { TenantContext } from \"~/features/tenancy/TenantContext/index.js\";\n\nclass KeyValueStoreImpl implements ServiceAbstraction.Interface {\n constructor(\n private tenantContext: TenantContext.Interface,\n private globalStore: GlobalKeyValueStore.Interface\n ) {}\n\n async get<T = unknown>(key: string): Promise<Result<T, ServiceAbstraction.Error>> {\n const tenant = this.tenantContext.getTenant();\n return this.globalStore.get<T>(key, { scope: tenant.id });\n }\n\n async set(key: string, value: any): Promise<Result<void, ServiceAbstraction.Error>> {\n const tenant = this.tenantContext.getTenant();\n return this.globalStore.set(key, value, { scope: tenant.id });\n }\n\n async delete(key: string): Promise<Result<void, ServiceAbstraction.Error>> {\n const tenant = this.tenantContext.getTenant();\n return this.globalStore.delete(key, { scope: tenant.id });\n }\n}\n\nexport const KeyValueStore = ServiceAbstraction.createImplementation({\n implementation: KeyValueStoreImpl,\n dependencies: [TenantContext, GlobalKeyValueStore]\n});\n"],"names":["KeyValueStoreImpl","tenantContext","globalStore","key","tenant","value","KeyValueStore","ServiceAbstraction","TenantContext","GlobalKeyValueStore"],"mappings":";;AAKA,MAAMA;IACF,YACYC,aAAsC,EACtCC,WAA0C,CACpD;aAFUD,aAAa,GAAbA;aACAC,WAAW,GAAXA;IACT;IAEH,MAAM,IAAiBC,GAAW,EAAgD;QAC9E,MAAMC,SAAS,IAAI,CAAC,aAAa,CAAC,SAAS;QAC3C,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAID,KAAK;YAAE,OAAOC,OAAO,EAAE;QAAC;IAC3D;IAEA,MAAM,IAAID,GAAW,EAAEE,KAAU,EAAmD;QAChF,MAAMD,SAAS,IAAI,CAAC,aAAa,CAAC,SAAS;QAC3C,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAACD,KAAKE,OAAO;YAAE,OAAOD,OAAO,EAAE;QAAC;IAC/D;IAEA,MAAM,OAAOD,GAAW,EAAmD;QACvE,MAAMC,SAAS,IAAI,CAAC,aAAa,CAAC,SAAS;QAC3C,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAACD,KAAK;YAAE,OAAOC,OAAO,EAAE;QAAC;IAC3D;AACJ;AAEO,MAAME,8BAAgBC,cAAAA,oBAAuC,CAAC;IACjE,gBAAgBP;IAChB,cAAc;QAACQ;QAAeC;KAAoB;AACtD"}
1
+ {"version":3,"file":"features/keyValueStore/KeyValueStore.js","sources":["../../../src/features/keyValueStore/KeyValueStore.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { KeyValueStore as ServiceAbstraction } from \"./abstractions.js\";\nimport { GlobalKeyValueStore } from \"./abstractions.js\";\nimport type { IKeyValueSetOptions } from \"./abstractions.js\";\nimport type { IKeyValueDeleteOptions } from \"./abstractions.js\";\nimport type { IKeyValueListParams } from \"./abstractions.js\";\nimport { TenantContext } from \"~/features/tenancy/TenantContext/index.js\";\n\nclass KeyValueStoreImpl implements ServiceAbstraction.Interface {\n constructor(\n private tenantContext: TenantContext.Interface,\n private globalStore: GlobalKeyValueStore.Interface\n ) {}\n\n async get<T = unknown>(key: string): Promise<Result<T, ServiceAbstraction.Error>> {\n const tenant = this.tenantContext.getTenant();\n return this.globalStore.get<T>(key, { scope: tenant.id });\n }\n\n async set(\n key: string,\n value: any,\n options?: IKeyValueSetOptions\n ): Promise<Result<void, ServiceAbstraction.Error>> {\n const tenant = this.tenantContext.getTenant();\n return this.globalStore.set(key, value, {\n scope: tenant.id,\n collection: options?.collection,\n condition: options?.condition\n });\n }\n\n async delete(\n key: string,\n options?: IKeyValueDeleteOptions\n ): Promise<Result<void, ServiceAbstraction.Error>> {\n const tenant = this.tenantContext.getTenant();\n return this.globalStore.delete(key, { scope: tenant.id, condition: options?.condition });\n }\n\n async list<T = unknown>(\n params: IKeyValueListParams\n ): Promise<Result<ServiceAbstraction.ListResult<T>, ServiceAbstraction.Error>> {\n const tenant = this.tenantContext.getTenant();\n return this.globalStore.list<T>({ ...params, scope: tenant.id });\n }\n}\n\nexport const KeyValueStore = ServiceAbstraction.createImplementation({\n implementation: KeyValueStoreImpl,\n dependencies: [TenantContext, GlobalKeyValueStore]\n});\n"],"names":["KeyValueStoreImpl","tenantContext","globalStore","key","tenant","value","options","params","KeyValueStore","ServiceAbstraction","TenantContext","GlobalKeyValueStore"],"mappings":";;AAQA,MAAMA;IACF,YACYC,aAAsC,EACtCC,WAA0C,CACpD;aAFUD,aAAa,GAAbA;aACAC,WAAW,GAAXA;IACT;IAEH,MAAM,IAAiBC,GAAW,EAAgD;QAC9E,MAAMC,SAAS,IAAI,CAAC,aAAa,CAAC,SAAS;QAC3C,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAID,KAAK;YAAE,OAAOC,OAAO,EAAE;QAAC;IAC3D;IAEA,MAAM,IACFD,GAAW,EACXE,KAAU,EACVC,OAA6B,EACkB;QAC/C,MAAMF,SAAS,IAAI,CAAC,aAAa,CAAC,SAAS;QAC3C,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAACD,KAAKE,OAAO;YACpC,OAAOD,OAAO,EAAE;YAChB,YAAYE,SAAS;YACrB,WAAWA,SAAS;QACxB;IACJ;IAEA,MAAM,OACFH,GAAW,EACXG,OAAgC,EACe;QAC/C,MAAMF,SAAS,IAAI,CAAC,aAAa,CAAC,SAAS;QAC3C,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAACD,KAAK;YAAE,OAAOC,OAAO,EAAE;YAAE,WAAWE,SAAS;QAAU;IAC1F;IAEA,MAAM,KACFC,MAA2B,EACgD;QAC3E,MAAMH,SAAS,IAAI,CAAC,aAAa,CAAC,SAAS;QAC3C,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAI;YAAE,GAAGG,MAAM;YAAE,OAAOH,OAAO,EAAE;QAAC;IAClE;AACJ;AAEO,MAAMI,8BAAgBC,cAAAA,oBAAuC,CAAC;IACjE,gBAAgBT;IAChB,cAAc;QAACU;QAAeC;KAAoB;AACtD"}
@@ -1,5 +1,10 @@
1
1
  import { Result } from "@webiny/feature/api";
2
- import { KeyValueStorageOperations, KeyValueStoreRepository as RepositoryAbstraction, type IKeyValueStoreSetOptions } from "./abstractions.js";
2
+ import { KeyValueStorageOperations } from "./abstractions.js";
3
+ import { KeyValueStoreRepository as RepositoryAbstraction } from "./abstractions.js";
4
+ import type { IKeyValueListParams } from "./abstractions.js";
5
+ import type { IKeyValueListResult } from "./abstractions.js";
6
+ import type { IKeyValueStoreSetOptions } from "./abstractions.js";
7
+ import type { IKeyValueDeleteOptions } from "./abstractions.js";
3
8
  /**
4
9
  * KeyValueStoreRepository implementation.
5
10
  *
@@ -11,7 +16,8 @@ declare class KeyValueStoreRepositoryImpl implements RepositoryAbstraction.Inter
11
16
  constructor(storageOperations: KeyValueStorageOperations.Interface);
12
17
  get<T = unknown>(key: string, scope: string): Promise<Result<T, RepositoryAbstraction.Error>>;
13
18
  set(key: string, value: any, scope: string, options?: IKeyValueStoreSetOptions): Promise<Result<void, RepositoryAbstraction.Error>>;
14
- delete(key: string, scope: string): Promise<Result<void, RepositoryAbstraction.Error>>;
19
+ delete(key: string, scope: string, options?: IKeyValueDeleteOptions): Promise<Result<void, RepositoryAbstraction.Error>>;
20
+ list<T = unknown>(scope: string, params: IKeyValueListParams): Promise<Result<IKeyValueListResult<T>, RepositoryAbstraction.Error>>;
15
21
  }
16
22
  export declare const KeyValueStoreRepository: import("@webiny/di").Implementation<typeof KeyValueStoreRepositoryImpl>;
17
23
  export {};
@@ -1,6 +1,42 @@
1
1
  import { Result, createImplementation } from "@webiny/feature/api";
2
2
  import { KeyValueStorageOperations, KeyValueStoreRepository } from "./abstractions.js";
3
- import { KeyNotFoundError, KeyValueStorageError } from "./errors.js";
3
+ import { KeyNotFoundError, KeyValueConditionFailedError, KeyValueInvalidCollectionError, KeyValueInvalidConditionError, KeyValueInvalidCursorError, KeyValueKeyTooLongError, KeyValueStorageError } from "./errors.js";
4
+ const DEFAULT_LIST_LIMIT = 100;
5
+ const MAX_LIST_LIMIT = 1000;
6
+ const resolveLimit = (limit)=>{
7
+ if (!limit || !Number.isFinite(limit)) return DEFAULT_LIST_LIMIT;
8
+ const whole = Math.floor(limit);
9
+ const atLeastOne = Math.max(whole, 1);
10
+ return Math.min(atLeastOne, MAX_LIST_LIMIT);
11
+ };
12
+ const encodeCursor = (cursor)=>{
13
+ const json = JSON.stringify(cursor);
14
+ return Buffer.from(json).toString("base64url");
15
+ };
16
+ const decodeCursor = (cursor)=>{
17
+ try {
18
+ const json = Buffer.from(cursor, "base64url").toString("utf8");
19
+ const parsed = JSON.parse(json);
20
+ if ("string" != typeof parsed?.collection || "boolean" != typeof parsed.reverse || "string" != typeof parsed.after) return;
21
+ return parsed;
22
+ } catch {
23
+ return;
24
+ }
25
+ };
26
+ const isComparable = (value)=>{
27
+ const type = typeof value;
28
+ return "string" === type || "number" === type || "boolean" === type;
29
+ };
30
+ const isValidCondition = (condition, allowNotExists)=>{
31
+ if ("object" != typeof condition || null === condition) return false;
32
+ const { exists, equals } = condition;
33
+ if (void 0 !== exists && void 0 !== equals) return false;
34
+ if (void 0 !== exists) return true === exists || false === exists && allowNotExists;
35
+ return isComparable(equals);
36
+ };
37
+ const MAX_COLLECTION_BYTES = 1000;
38
+ const MAX_COLLECTION_KEY_BYTES = 1000;
39
+ const isValidCollection = (collection)=>"string" == typeof collection && collection.length > 0 && Buffer.byteLength(collection, "utf8") <= MAX_COLLECTION_BYTES;
4
40
  class KeyValueStoreRepositoryImpl {
5
41
  constructor(storageOperations){
6
42
  this.storageOperations = storageOperations;
@@ -15,21 +51,63 @@ class KeyValueStoreRepositoryImpl {
15
51
  }
16
52
  }
17
53
  async set(key, value, scope, options) {
54
+ if (options?.condition !== void 0 && !isValidCondition(options.condition, true)) return Result.fail(new KeyValueInvalidConditionError());
55
+ if (options?.collection !== void 0) {
56
+ if (!isValidCollection(options.collection)) return Result.fail(new KeyValueInvalidCollectionError(MAX_COLLECTION_BYTES));
57
+ if (Buffer.byteLength(key, "utf8") > MAX_COLLECTION_KEY_BYTES) return Result.fail(new KeyValueKeyTooLongError(key, MAX_COLLECTION_KEY_BYTES));
58
+ }
18
59
  try {
19
- await this.storageOperations.set(key, value, scope, options);
60
+ const written = await this.storageOperations.set(key, value, scope, options);
61
+ if (!written) return Result.fail(new KeyValueConditionFailedError(key));
20
62
  return Result.ok();
21
63
  } catch (error) {
22
64
  return Result.fail(new KeyValueStorageError(error));
23
65
  }
24
66
  }
25
- async delete(key, scope) {
67
+ async delete(key, scope, options) {
68
+ if (options?.condition !== void 0 && !isValidCondition(options.condition, false)) return Result.fail(new KeyValueInvalidConditionError());
26
69
  try {
27
- await this.storageOperations.delete(key, scope);
70
+ const deleted = await this.storageOperations.delete(key, scope, options);
71
+ if (!deleted) return Result.fail(new KeyValueConditionFailedError(key));
28
72
  return Result.ok();
29
73
  } catch (error) {
30
74
  return Result.fail(new KeyValueStorageError(error));
31
75
  }
32
76
  }
77
+ async list(scope, params) {
78
+ const { collection, cursor } = params;
79
+ if (!isValidCollection(collection)) return Result.fail(new KeyValueInvalidCollectionError(MAX_COLLECTION_BYTES));
80
+ let reverse = params.reverse ?? false;
81
+ let after;
82
+ if (cursor) {
83
+ const decoded = decodeCursor(cursor);
84
+ if (!decoded || decoded.collection !== collection) return Result.fail(new KeyValueInvalidCursorError(cursor));
85
+ reverse = decoded.reverse;
86
+ after = decoded.after;
87
+ }
88
+ const limit = resolveLimit(params.limit);
89
+ try {
90
+ const { items, lastKey } = await this.storageOperations.list({
91
+ collection,
92
+ scope,
93
+ limit,
94
+ reverse,
95
+ after
96
+ });
97
+ let nextCursor = null;
98
+ if (null !== lastKey) nextCursor = encodeCursor({
99
+ collection,
100
+ reverse,
101
+ after: lastKey
102
+ });
103
+ return Result.ok({
104
+ items: items,
105
+ cursor: nextCursor
106
+ });
107
+ } catch (error) {
108
+ return Result.fail(new KeyValueStorageError(error));
109
+ }
110
+ }
33
111
  }
34
112
  const KeyValueStoreRepository_KeyValueStoreRepository = createImplementation({
35
113
  abstraction: KeyValueStoreRepository,