@webiny/api-core 0.0.0-unstable.7be00a75a9 → 0.0.0-unstable.7c2def32a7

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 (499) hide show
  1. package/ApiCoreFeature.d.ts +2 -2
  2. package/ApiCoreFeature.js +35 -5
  3. package/ApiCoreFeature.js.map +1 -1
  4. package/exports/api/security/api-key.d.ts +1 -0
  5. package/exports/api/security/api-key.js +1 -0
  6. package/exports/api/tasks.d.ts +1 -0
  7. package/exports/api/tasks.js +1 -1
  8. package/exports/api.d.ts +2 -1
  9. package/exports/api.js +2 -1
  10. package/features/ai/Ai.d.ts +5 -1
  11. package/features/ai/Ai.js +72 -29
  12. package/features/ai/Ai.js.map +1 -1
  13. package/features/ai/AiModelRegistry.d.ts +14 -0
  14. package/features/ai/AiModelRegistry.js +39 -0
  15. package/features/ai/AiModelRegistry.js.map +1 -0
  16. package/features/ai/AiSdkToolHandlerResolver.d.ts +11 -0
  17. package/features/ai/AiSdkToolHandlerResolver.js +19 -0
  18. package/features/ai/AiSdkToolHandlerResolver.js.map +1 -0
  19. package/features/ai/AiSdkTools.d.ts +4 -3
  20. package/features/ai/AiSdkTools.js +11 -9
  21. package/features/ai/AiSdkTools.js.map +1 -1
  22. package/features/ai/AnthropicSdkFactory.js +18 -34
  23. package/features/ai/AnthropicSdkFactory.js.map +1 -1
  24. package/features/ai/DEVELOPERS.md +183 -0
  25. package/features/ai/GoogleSdkFactory.d.ts +10 -0
  26. package/features/ai/GoogleSdkFactory.js +65 -0
  27. package/features/ai/GoogleSdkFactory.js.map +1 -0
  28. package/features/ai/OpenAiSdkFactory.js +42 -150
  29. package/features/ai/OpenAiSdkFactory.js.map +1 -1
  30. package/features/ai/OpenRouterSdkFactory.d.ts +10 -0
  31. package/features/ai/OpenRouterSdkFactory.js +112 -0
  32. package/features/ai/OpenRouterSdkFactory.js.map +1 -0
  33. package/features/ai/RemoteAiModelCatalog.d.ts +13 -0
  34. package/features/ai/RemoteAiModelCatalog.js +74 -0
  35. package/features/ai/RemoteAiModelCatalog.js.map +1 -0
  36. package/features/ai/TextExtractor/DefaultTextExtractor.d.ts +9 -0
  37. package/features/ai/TextExtractor/DefaultTextExtractor.js +28 -0
  38. package/features/ai/TextExtractor/DefaultTextExtractor.js.map +1 -0
  39. package/features/ai/TextExtractor/abstractions.d.ts +12 -0
  40. package/features/ai/TextExtractor/abstractions.js +5 -0
  41. package/features/ai/TextExtractor/abstractions.js.map +1 -0
  42. package/features/ai/TextExtractor/index.d.ts +3 -0
  43. package/features/ai/TextExtractor/index.js +2 -0
  44. package/features/ai/TextExtractor/parsers/docxParser.d.ts +1 -0
  45. package/features/ai/TextExtractor/parsers/docxParser.js +111 -0
  46. package/features/ai/TextExtractor/parsers/docxParser.js.map +1 -0
  47. package/features/ai/abstractions.d.ts +102 -7
  48. package/features/ai/abstractions.js +6 -2
  49. package/features/ai/abstractions.js.map +1 -1
  50. package/features/ai/events.d.ts +59 -0
  51. package/features/ai/events.js +41 -0
  52. package/features/ai/events.js.map +1 -0
  53. package/features/ai/feature.js +16 -0
  54. package/features/ai/feature.js.map +1 -1
  55. package/features/ai/index.d.ts +6 -2
  56. package/features/ai/index.js +4 -1
  57. package/features/ai/toolPipeline/AiOutputToolRegistry.d.ts +11 -0
  58. package/features/ai/toolPipeline/AiOutputToolRegistry.js +31 -0
  59. package/features/ai/toolPipeline/AiOutputToolRegistry.js.map +1 -0
  60. package/features/ai/toolPipeline/AiToolPipelineRunner.d.ts +10 -0
  61. package/features/ai/toolPipeline/AiToolPipelineRunner.js +36 -0
  62. package/features/ai/toolPipeline/AiToolPipelineRunner.js.map +1 -0
  63. package/features/ai/toolPipeline/abstractions.d.ts +23 -0
  64. package/features/ai/toolPipeline/abstractions.js +7 -0
  65. package/features/ai/toolPipeline/abstractions.js.map +1 -0
  66. package/features/ai/toolPipeline/index.d.ts +2 -0
  67. package/features/ai/toolPipeline/index.js +1 -0
  68. package/features/dateFormatter/DefaultDateFormatter.d.ts +15 -0
  69. package/features/dateFormatter/DefaultDateFormatter.js +20 -0
  70. package/features/dateFormatter/DefaultDateFormatter.js.map +1 -0
  71. package/features/dateFormatter/abstractions.d.ts +13 -0
  72. package/features/dateFormatter/abstractions.js +5 -0
  73. package/features/dateFormatter/abstractions.js.map +1 -0
  74. package/features/dateFormatter/feature.d.ts +4 -0
  75. package/features/dateFormatter/feature.js +11 -0
  76. package/features/dateFormatter/feature.js.map +1 -0
  77. package/features/dateFormatter/index.d.ts +3 -0
  78. package/features/dateFormatter/index.js +2 -0
  79. package/features/debugger/Debugger.d.ts +30 -0
  80. package/features/debugger/Debugger.js +142 -0
  81. package/features/debugger/Debugger.js.map +1 -0
  82. package/features/debugger/DebuggerRouteDecorator.d.ts +45 -0
  83. package/features/debugger/DebuggerRouteDecorator.js +107 -0
  84. package/features/debugger/DebuggerRouteDecorator.js.map +1 -0
  85. package/features/debugger/GraphQLDebuggerTransport.d.ts +28 -0
  86. package/features/debugger/GraphQLDebuggerTransport.js +45 -0
  87. package/features/debugger/GraphQLDebuggerTransport.js.map +1 -0
  88. package/features/debugger/__tests__/matchNamespace.test.d.ts +1 -0
  89. package/features/debugger/__tests__/matchNamespace.test.js +68 -0
  90. package/features/debugger/__tests__/matchNamespace.test.js.map +1 -0
  91. package/features/debugger/__tests__/serialize.test.d.ts +1 -0
  92. package/features/debugger/__tests__/serialize.test.js +220 -0
  93. package/features/debugger/__tests__/serialize.test.js.map +1 -0
  94. package/features/debugger/abstractions.d.ts +100 -0
  95. package/features/debugger/abstractions.js +6 -0
  96. package/features/debugger/abstractions.js.map +1 -0
  97. package/features/debugger/feature.d.ts +5 -0
  98. package/features/debugger/feature.js +15 -0
  99. package/features/debugger/feature.js.map +1 -0
  100. package/features/debugger/index.d.ts +12 -0
  101. package/features/debugger/index.js +7 -0
  102. package/features/debugger/limits.d.ts +18 -0
  103. package/features/debugger/limits.js +11 -0
  104. package/features/debugger/limits.js.map +1 -0
  105. package/features/debugger/matchNamespace.d.ts +14 -0
  106. package/features/debugger/matchNamespace.js +35 -0
  107. package/features/debugger/matchNamespace.js.map +1 -0
  108. package/features/debugger/parseNamespaceHeader.d.ts +7 -0
  109. package/features/debugger/parseNamespaceHeader.js +16 -0
  110. package/features/debugger/parseNamespaceHeader.js.map +1 -0
  111. package/features/debugger/permissions.d.ts +14 -0
  112. package/features/debugger/permissions.js +8 -0
  113. package/features/debugger/permissions.js.map +1 -0
  114. package/features/debugger/permissionsSchema.d.ts +17 -0
  115. package/features/debugger/permissionsSchema.js +18 -0
  116. package/features/debugger/permissionsSchema.js.map +1 -0
  117. package/features/debugger/serialize.d.ts +11 -0
  118. package/features/debugger/serialize.js +121 -0
  119. package/features/debugger/serialize.js.map +1 -0
  120. package/features/encryption/EncryptionKeyCacheFeature.d.ts +8 -0
  121. package/features/encryption/EncryptionKeyCacheFeature.js +11 -0
  122. package/features/encryption/EncryptionKeyCacheFeature.js.map +1 -0
  123. package/features/encryption/EncryptionService.d.ts +2 -1
  124. package/features/encryption/EncryptionService.js +11 -4
  125. package/features/encryption/EncryptionService.js.map +1 -1
  126. package/features/encryption/MemoryEncryptionKeyCache.d.ts +13 -0
  127. package/features/encryption/MemoryEncryptionKeyCache.js +26 -0
  128. package/features/encryption/MemoryEncryptionKeyCache.js.map +1 -0
  129. package/features/encryption/abstractions.d.ts +11 -0
  130. package/features/encryption/abstractions.js +2 -1
  131. package/features/encryption/abstractions.js.map +1 -1
  132. package/features/encryption/index.d.ts +1 -0
  133. package/features/encryption/index.js +1 -0
  134. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.d.ts +13 -0
  135. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js +62 -0
  136. package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js.map +1 -0
  137. package/features/hashing/ScryptHasher.d.ts +11 -0
  138. package/features/hashing/ScryptHasher.js +74 -0
  139. package/features/hashing/ScryptHasher.js.map +1 -0
  140. package/features/hashing/abstractions.d.ts +18 -0
  141. package/features/hashing/abstractions.js +5 -0
  142. package/features/hashing/abstractions.js.map +1 -0
  143. package/features/hashing/feature.d.ts +4 -0
  144. package/features/hashing/feature.js +11 -0
  145. package/features/hashing/feature.js.map +1 -0
  146. package/features/hashing/index.d.ts +2 -0
  147. package/features/hashing/index.js +1 -0
  148. package/features/httpClient/HttpClient.d.ts +7 -0
  149. package/features/httpClient/HttpClient.js +72 -0
  150. package/features/httpClient/HttpClient.js.map +1 -0
  151. package/features/httpClient/HttpRequestError.d.ts +10 -0
  152. package/features/httpClient/HttpRequestError.js +13 -0
  153. package/features/httpClient/HttpRequestError.js.map +1 -0
  154. package/features/httpClient/HttpStatusError.d.ts +12 -0
  155. package/features/httpClient/HttpStatusError.js +12 -0
  156. package/features/httpClient/HttpStatusError.js.map +1 -0
  157. package/features/httpClient/abstractions.d.ts +32 -0
  158. package/features/httpClient/abstractions.js +5 -0
  159. package/features/httpClient/abstractions.js.map +1 -0
  160. package/features/httpClient/feature.d.ts +4 -0
  161. package/features/httpClient/feature.js +11 -0
  162. package/features/httpClient/feature.js.map +1 -0
  163. package/features/httpClient/index.d.ts +3 -0
  164. package/features/httpClient/index.js +3 -0
  165. package/features/keyValueStore/GlobalKeyValueStore.d.ts +9 -3
  166. package/features/keyValueStore/GlobalKeyValueStore.js +12 -2
  167. package/features/keyValueStore/GlobalKeyValueStore.js.map +1 -1
  168. package/features/keyValueStore/KeyValueStore.d.ts +6 -2
  169. package/features/keyValueStore/KeyValueStore.js +13 -3
  170. package/features/keyValueStore/KeyValueStore.js.map +1 -1
  171. package/features/keyValueStore/KeyValueStoreRepository.d.ts +8 -2
  172. package/features/keyValueStore/KeyValueStoreRepository.js +82 -4
  173. package/features/keyValueStore/KeyValueStoreRepository.js.map +1 -1
  174. package/features/keyValueStore/abstractions.d.ts +132 -14
  175. package/features/keyValueStore/abstractions.js.map +1 -1
  176. package/features/keyValueStore/errors.d.ts +29 -0
  177. package/features/keyValueStore/errors.js +49 -1
  178. package/features/keyValueStore/errors.js.map +1 -1
  179. package/features/keyValueStore/index.d.ts +4 -1
  180. package/features/keyValueStore/index.js +1 -1
  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/RawAuthToken.d.ts +14 -0
  205. package/features/requestContext/RawAuthToken.js +19 -0
  206. package/features/requestContext/RawAuthToken.js.map +1 -0
  207. package/features/requestContext/RawTenantId.d.ts +14 -0
  208. package/features/requestContext/RawTenantId.js +19 -0
  209. package/features/requestContext/RawTenantId.js.map +1 -0
  210. package/features/requestContext/RequestIdentityLoader.d.ts +19 -0
  211. package/features/requestContext/RequestIdentityLoader.js +26 -0
  212. package/features/requestContext/RequestIdentityLoader.js.map +1 -0
  213. package/features/requestContext/RequestTenantLoader.d.ts +18 -0
  214. package/features/requestContext/RequestTenantLoader.js +52 -0
  215. package/features/requestContext/RequestTenantLoader.js.map +1 -0
  216. package/features/requestContext/abstractions.d.ts +75 -0
  217. package/features/requestContext/abstractions.js +9 -0
  218. package/features/requestContext/abstractions.js.map +1 -0
  219. package/features/requestContext/extractAssumePermissions.d.ts +14 -0
  220. package/features/requestContext/extractAssumePermissions.js +32 -0
  221. package/features/requestContext/extractAssumePermissions.js.map +1 -0
  222. package/features/requestContext/feature.d.ts +12 -0
  223. package/features/requestContext/feature.js +19 -0
  224. package/features/requestContext/feature.js.map +1 -0
  225. package/features/requestContext/index.d.ts +4 -0
  226. package/features/requestContext/index.js +3 -0
  227. package/features/security/IdentityContext/IdentityContext.d.ts +3 -3
  228. package/features/security/IdentityContext/IdentityContext.js +6 -6
  229. package/features/security/IdentityContext/IdentityContext.js.map +1 -1
  230. package/features/security/apiKeys/ApiKeyAuthenticator.d.ts +14 -0
  231. package/features/security/apiKeys/ApiKeyAuthenticator.js +36 -0
  232. package/features/security/apiKeys/ApiKeyAuthenticator.js.map +1 -0
  233. package/features/security/apiKeys/ApiKeyAuthorizer.d.ts +10 -0
  234. package/features/security/apiKeys/ApiKeyAuthorizer.js +15 -0
  235. package/features/security/apiKeys/ApiKeyAuthorizer.js.map +1 -0
  236. package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js +11 -6
  237. package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js.map +1 -1
  238. package/features/security/apiKeys/GetApiKey/GetApiKeyUseCase.d.ts +1 -1
  239. package/features/security/apiKeys/GetApiKey/GetApiKeyUseCase.js.map +1 -1
  240. package/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.d.ts +1 -3
  241. package/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.js.map +1 -1
  242. package/features/security/apiKeys/GetApiKeyBySlug/abstractions.d.ts +1 -1
  243. package/features/security/apiKeys/GetApiKeyBySlug/abstractions.js.map +1 -1
  244. package/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.d.ts +1 -3
  245. package/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.js.map +1 -1
  246. package/features/security/apiKeys/GetApiKeyByToken/abstractions.d.ts +1 -1
  247. package/features/security/apiKeys/GetApiKeyByToken/abstractions.js.map +1 -1
  248. package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js +9 -3
  249. package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js.map +1 -1
  250. package/features/security/apiKeys/feature.js +11 -2
  251. package/features/security/apiKeys/feature.js.map +1 -1
  252. package/features/security/apiKeys/shared/ApiKeyProvider.d.ts +3 -5
  253. package/features/security/apiKeys/shared/ApiKeyProvider.js +6 -21
  254. package/features/security/apiKeys/shared/ApiKeyProvider.js.map +1 -1
  255. package/features/security/apiKeys/shared/ApiKeysRepository.d.ts +1 -0
  256. package/features/security/apiKeys/shared/ApiKeysRepository.js +19 -4
  257. package/features/security/apiKeys/shared/ApiKeysRepository.js.map +1 -1
  258. package/features/security/apiKeys/shared/generateToken.d.ts +1 -1
  259. package/features/security/apiKeys/shared/generateToken.js.map +1 -1
  260. package/features/security/apiKeys/shared/schemas.d.ts +2 -2
  261. package/features/security/apiKeys/shared/schemas.js +2 -2
  262. package/features/security/apiKeys/shared/schemas.js.map +1 -1
  263. package/features/security/apiKeys/shared/types.d.ts +1 -1
  264. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.d.ts +30 -0
  265. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js +60 -0
  266. package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js.map +1 -0
  267. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.d.ts +4 -4
  268. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js +5 -5
  269. package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js.map +1 -1
  270. package/features/security/authorization/GroupsTeamsAuthorizer/feature.js +2 -0
  271. package/features/security/authorization/GroupsTeamsAuthorizer/feature.js.map +1 -1
  272. package/features/security/roles/CreateRole/CreateRoleUseCase.js +11 -6
  273. package/features/security/roles/CreateRole/CreateRoleUseCase.js.map +1 -1
  274. package/features/security/roles/CreateRole/schema.d.ts +1 -1
  275. package/features/security/roles/CreateRole/schema.js +1 -1
  276. package/features/security/roles/CreateRole/schema.js.map +1 -1
  277. package/features/security/roles/Installer/RolesInstaller.js +1 -0
  278. package/features/security/roles/Installer/RolesInstaller.js.map +1 -1
  279. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js +9 -3
  280. package/features/security/roles/UpdateRole/UpdateRoleUseCase.js.map +1 -1
  281. package/features/security/roles/UpdateRole/schema.d.ts +1 -1
  282. package/features/security/roles/UpdateRole/schema.js +1 -1
  283. package/features/security/roles/UpdateRole/schema.js.map +1 -1
  284. package/features/security/shared/description.d.ts +4 -0
  285. package/features/security/shared/description.js +7 -0
  286. package/features/security/shared/description.js.map +1 -0
  287. package/features/security/shared/index.d.ts +1 -0
  288. package/features/security/shared/index.js +1 -0
  289. package/features/security/teams/CreateTeam/CreateTeamUseCase.d.ts +3 -1
  290. package/features/security/teams/CreateTeam/CreateTeamUseCase.js +20 -8
  291. package/features/security/teams/CreateTeam/CreateTeamUseCase.js.map +1 -1
  292. package/features/security/teams/CreateTeam/schema.d.ts +1 -1
  293. package/features/security/teams/CreateTeam/schema.js +1 -1
  294. package/features/security/teams/CreateTeam/schema.js.map +1 -1
  295. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.d.ts +3 -1
  296. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js +20 -5
  297. package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js.map +1 -1
  298. package/features/security/teams/UpdateTeam/schema.d.ts +1 -1
  299. package/features/security/teams/UpdateTeam/schema.js +1 -1
  300. package/features/security/teams/UpdateTeam/schema.js.map +1 -1
  301. package/features/security/teams/shared/resolveRoleIdentifiers.d.ts +17 -0
  302. package/features/security/teams/shared/resolveRoleIdentifiers.js +32 -0
  303. package/features/security/teams/shared/resolveRoleIdentifiers.js.map +1 -0
  304. package/features/security/utils/getPermissionsFromRoles.d.ts +1 -1
  305. package/features/serviceDiscovery/ServiceDiscovery.d.ts +17 -0
  306. package/features/serviceDiscovery/ServiceDiscovery.js +22 -0
  307. package/features/serviceDiscovery/ServiceDiscovery.js.map +1 -0
  308. package/features/serviceDiscovery/__tests__/ServiceDiscovery.test.d.ts +1 -0
  309. package/features/serviceDiscovery/__tests__/ServiceDiscovery.test.js +111 -0
  310. package/features/serviceDiscovery/__tests__/ServiceDiscovery.test.js.map +1 -0
  311. package/features/serviceDiscovery/index.d.ts +3 -0
  312. package/features/serviceDiscovery/index.js +1 -0
  313. package/features/slugify/DefaultSlugify.d.ts +8 -0
  314. package/features/slugify/DefaultSlugify.js +20 -0
  315. package/features/slugify/DefaultSlugify.js.map +1 -0
  316. package/features/slugify/abstractions.d.ts +12 -0
  317. package/features/slugify/abstractions.js +5 -0
  318. package/features/slugify/abstractions.js.map +1 -0
  319. package/features/slugify/feature.d.ts +4 -0
  320. package/features/slugify/feature.js +11 -0
  321. package/features/slugify/feature.js.map +1 -0
  322. package/features/slugify/index.d.ts +3 -0
  323. package/features/slugify/index.js +2 -0
  324. package/features/storageOperations/abstractions.d.ts +21 -0
  325. package/features/storageOperations/abstractions.js +10 -0
  326. package/features/storageOperations/abstractions.js.map +1 -0
  327. package/features/stringFormatter/DefaultStringFormatter.d.ts +17 -0
  328. package/features/stringFormatter/DefaultStringFormatter.js +19 -0
  329. package/features/stringFormatter/DefaultStringFormatter.js.map +1 -0
  330. package/features/stringFormatter/abstractions.d.ts +11 -0
  331. package/features/stringFormatter/abstractions.js +5 -0
  332. package/features/stringFormatter/abstractions.js.map +1 -0
  333. package/features/stringFormatter/feature.d.ts +4 -0
  334. package/features/stringFormatter/feature.js +13 -0
  335. package/features/stringFormatter/feature.js.map +1 -0
  336. package/features/stringFormatter/index.d.ts +3 -0
  337. package/features/stringFormatter/index.js +2 -0
  338. package/features/task/TaskDefinition/abstractions.d.ts +69 -4
  339. package/features/task/TaskDefinition/abstractions.js +2 -1
  340. package/features/task/TaskDefinition/abstractions.js.map +1 -1
  341. package/features/tenancy/CreateTenant/CreateTenantUseCase.d.ts +1 -1
  342. package/features/tenancy/InstallTenant/InstallTenantUseCase.d.ts +1 -1
  343. package/features/tenancy/TenantContext/TenantContext.d.ts +1 -0
  344. package/features/tenancy/TenantContext/TenantContext.js +13 -8
  345. package/features/tenancy/TenantContext/TenantContext.js.map +1 -1
  346. package/features/tenancy/UpdateTenant/UpdateTenantUseCase.d.ts +2 -2
  347. package/features/users/CreateUser/decorators/CreateUserWithWcpIncrement.d.ts +1 -1
  348. package/features/wcp/WcpContext/WcpContext.d.ts +16 -5
  349. package/features/wcp/WcpContext/WcpContext.js +41 -2
  350. package/features/wcp/WcpContext/WcpContext.js.map +1 -1
  351. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.d.ts +15 -60
  352. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js +81 -25
  353. package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js.map +1 -1
  354. package/features/wcp/WcpContext/feature.d.ts +1 -2
  355. package/features/wcp/WcpContext/feature.js +2 -2
  356. package/features/wcp/WcpContext/feature.js.map +1 -1
  357. package/features/wcp/WcpContext/index.d.ts +0 -1
  358. package/features/wcp/WcpContext/types.d.ts +0 -4
  359. package/features/wcp/WcpFeature.d.ts +1 -1
  360. package/features/wcp/WcpFeature.js +7 -2
  361. package/features/wcp/WcpFeature.js.map +1 -1
  362. package/features/wcp/WcpLicenseLoader.d.ts +25 -0
  363. package/features/wcp/WcpLicenseLoader.js +58 -0
  364. package/features/wcp/WcpLicenseLoader.js.map +1 -0
  365. package/features/wcp/WcpLicenseProvider.d.ts +21 -0
  366. package/features/wcp/WcpLicenseProvider.js +14 -0
  367. package/features/wcp/WcpLicenseProvider.js.map +1 -0
  368. package/features/wcp/resolveWcpProjectEnvironment.d.ts +9 -0
  369. package/features/wcp/resolveWcpProjectEnvironment.js +23 -0
  370. package/features/wcp/resolveWcpProjectEnvironment.js.map +1 -0
  371. package/graphql/ApiCoreSchemaFactory.d.ts +16 -0
  372. package/graphql/ApiCoreSchemaFactory.js +58 -0
  373. package/graphql/ApiCoreSchemaFactory.js.map +1 -0
  374. package/graphql/featureFlags/FeatureFlagsSchemaFactory.d.ts +10 -0
  375. package/graphql/featureFlags/FeatureFlagsSchemaFactory.js +53 -0
  376. package/graphql/featureFlags/FeatureFlagsSchemaFactory.js.map +1 -0
  377. package/graphql/security/NotAuthorizedResponse.d.ts +1 -1
  378. package/graphql/security/NotAuthorizedResponse.js +1 -1
  379. package/graphql/security/NotAuthorizedResponse.js.map +1 -1
  380. package/graphql/security/SecuritySchemaFactory.d.ts +15 -0
  381. package/graphql/security/SecuritySchemaFactory.js +27 -0
  382. package/graphql/security/SecuritySchemaFactory.js.map +1 -0
  383. package/graphql/security/addApiKeySchema.d.ts +2 -0
  384. package/graphql/security/{apiKey.gql.js → addApiKeySchema.js} +45 -27
  385. package/graphql/security/addApiKeySchema.js.map +1 -0
  386. package/graphql/security/addIdentitySchema.d.ts +2 -0
  387. package/graphql/security/{identity.gql.js → addIdentitySchema.js} +52 -35
  388. package/graphql/security/addIdentitySchema.js.map +1 -0
  389. package/graphql/security/addRoleSchema.d.ts +2 -0
  390. package/graphql/security/addRoleSchema.js +137 -0
  391. package/graphql/security/addRoleSchema.js.map +1 -0
  392. package/graphql/security/addSecurityBaseSchema.d.ts +2 -0
  393. package/graphql/security/{base.gql.js → addSecurityBaseSchema.js} +14 -16
  394. package/graphql/security/addSecurityBaseSchema.js.map +1 -0
  395. package/graphql/security/addTeamSchema.d.ts +2 -0
  396. package/graphql/security/addTeamSchema.js +157 -0
  397. package/graphql/security/addTeamSchema.js.map +1 -0
  398. package/graphql/system/SystemSchemaFactory.d.ts +10 -0
  399. package/graphql/system/SystemSchemaFactory.js +70 -0
  400. package/graphql/system/SystemSchemaFactory.js.map +1 -0
  401. package/graphql/users/UsersSchemaFactory.d.ts +10 -0
  402. package/graphql/users/UsersSchemaFactory.js +195 -0
  403. package/graphql/users/UsersSchemaFactory.js.map +1 -0
  404. package/graphql/wcp/WcpSchemaFactory.d.ts +10 -0
  405. package/graphql/wcp/{graphql.js → WcpSchemaFactory.js} +32 -18
  406. package/graphql/wcp/WcpSchemaFactory.js.map +1 -0
  407. package/idp/JwksCache.d.ts +14 -3
  408. package/idp/JwksCache.js +97 -17
  409. package/idp/JwksCache.js.map +1 -1
  410. package/idp/JwksStoreFeature.d.ts +8 -0
  411. package/idp/JwksStoreFeature.js +11 -0
  412. package/idp/JwksStoreFeature.js.map +1 -0
  413. package/idp/MemoryJwksStore.d.ts +14 -0
  414. package/idp/MemoryJwksStore.js +21 -0
  415. package/idp/MemoryJwksStore.js.map +1 -0
  416. package/idp/OidcJwtIdentityProvider.js +5 -1
  417. package/idp/OidcJwtIdentityProvider.js.map +1 -1
  418. package/idp/abstractions.d.ts +24 -0
  419. package/idp/abstractions.js +2 -1
  420. package/idp/abstractions.js.map +1 -1
  421. package/idp/feature.js +1 -2
  422. package/idp/feature.js.map +1 -1
  423. package/idp/index.d.ts +1 -0
  424. package/idp/index.js +1 -0
  425. package/index.d.ts +3 -1
  426. package/index.js +3 -1
  427. package/package.json +23 -24
  428. package/testing/environment.d.ts +14 -0
  429. package/testing/environment.js +18 -0
  430. package/testing/environment.js.map +1 -0
  431. package/types/core.d.ts +17 -5
  432. package/types/security.d.ts +1 -7
  433. package/types/tenancy.d.ts +0 -17
  434. package/types/users.d.ts +0 -13
  435. package/createApiCore.d.ts +0 -7
  436. package/createApiCore.js +0 -22
  437. package/createApiCore.js.map +0 -1
  438. package/graphql/security/apiKey.gql.d.ts +0 -4
  439. package/graphql/security/apiKey.gql.js.map +0 -1
  440. package/graphql/security/base.gql.d.ts +0 -4
  441. package/graphql/security/base.gql.js.map +0 -1
  442. package/graphql/security/identity.gql.d.ts +0 -4
  443. package/graphql/security/identity.gql.js.map +0 -1
  444. package/graphql/security/index.d.ts +0 -1
  445. package/graphql/security/index.js +0 -15
  446. package/graphql/security/index.js.map +0 -1
  447. package/graphql/security/role.gql.d.ts +0 -4
  448. package/graphql/security/role.gql.js +0 -106
  449. package/graphql/security/role.gql.js.map +0 -1
  450. package/graphql/security/team.gql.d.ts +0 -4
  451. package/graphql/security/team.gql.js +0 -119
  452. package/graphql/security/team.gql.js.map +0 -1
  453. package/graphql/system/createSystemGraphQL.d.ts +0 -2
  454. package/graphql/system/createSystemGraphQL.js +0 -54
  455. package/graphql/system/createSystemGraphQL.js.map +0 -1
  456. package/graphql/users/user.gql.d.ts +0 -3
  457. package/graphql/users/user.gql.js +0 -167
  458. package/graphql/users/user.gql.js.map +0 -1
  459. package/graphql/wcp/graphql.d.ts +0 -2
  460. package/graphql/wcp/graphql.js.map +0 -1
  461. package/legacy/security/LegacyContext.d.ts +0 -36
  462. package/legacy/security/LegacyContext.js +0 -152
  463. package/legacy/security/LegacyContext.js.map +0 -1
  464. package/legacy/security/createSecurityContext.d.ts +0 -3
  465. package/legacy/security/createSecurityContext.js +0 -10
  466. package/legacy/security/createSecurityContext.js.map +0 -1
  467. package/legacy/security/plugins/apiKeyAuthentication.d.ts +0 -7
  468. package/legacy/security/plugins/apiKeyAuthentication.js +0 -20
  469. package/legacy/security/plugins/apiKeyAuthentication.js.map +0 -1
  470. package/legacy/security/plugins/apiKeyAuthorization.d.ts +0 -6
  471. package/legacy/security/plugins/apiKeyAuthorization.js +0 -13
  472. package/legacy/security/plugins/apiKeyAuthorization.js.map +0 -1
  473. package/legacy/security/plugins/authenticateUsingCookie.d.ts +0 -5
  474. package/legacy/security/plugins/authenticateUsingCookie.js +0 -23
  475. package/legacy/security/plugins/authenticateUsingCookie.js.map +0 -1
  476. package/legacy/security/plugins/authenticateUsingHttpHeader.d.ts +0 -5
  477. package/legacy/security/plugins/authenticateUsingHttpHeader.js +0 -20
  478. package/legacy/security/plugins/authenticateUsingHttpHeader.js.map +0 -1
  479. package/legacy/security/plugins/secureHeaders.d.ts +0 -1
  480. package/legacy/security/plugins/secureHeaders.js +0 -30
  481. package/legacy/security/plugins/secureHeaders.js.map +0 -1
  482. package/legacy/tenancy/LegacyContext.d.ts +0 -15
  483. package/legacy/tenancy/LegacyContext.js +0 -57
  484. package/legacy/tenancy/LegacyContext.js.map +0 -1
  485. package/legacy/tenancy/createTenancyContext.d.ts +0 -3
  486. package/legacy/tenancy/createTenancyContext.js +0 -31
  487. package/legacy/tenancy/createTenancyContext.js.map +0 -1
  488. package/legacy/users/LegacyContext.d.ts +0 -13
  489. package/legacy/users/LegacyContext.js +0 -55
  490. package/legacy/users/LegacyContext.js.map +0 -1
  491. package/legacy/users/createAdminUsersContext.d.ts +0 -3
  492. package/legacy/users/createAdminUsersContext.js +0 -12
  493. package/legacy/users/createAdminUsersContext.js.map +0 -1
  494. package/legacy/wcp/LegacyWcpContext.d.ts +0 -33
  495. package/legacy/wcp/LegacyWcpContext.js +0 -84
  496. package/legacy/wcp/LegacyWcpContext.js.map +0 -1
  497. package/legacy/wcp/context.d.ts +0 -5
  498. package/legacy/wcp/context.js +0 -46
  499. package/legacy/wcp/context.js.map +0 -1
@@ -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,
@@ -1 +1 @@
1
- {"version":3,"file":"features/keyValueStore/KeyValueStoreRepository.js","sources":["../../../src/features/keyValueStore/KeyValueStoreRepository.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport {\n KeyValueStorageOperations,\n KeyValueStoreRepository as RepositoryAbstraction,\n type IKeyValueStoreSetOptions\n} from \"./abstractions.js\";\nimport { KeyNotFoundError, KeyValueStorageError } from \"./errors.js\";\n\n/**\n * KeyValueStoreRepository implementation.\n *\n * This repository passes key and scope separately to storage operations.\n * The storage layer is responsible for handling scope-based partitioning.\n */\nclass KeyValueStoreRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(private storageOperations: KeyValueStorageOperations.Interface) {}\n\n async get<T = unknown>(\n key: string,\n scope: string\n ): Promise<Result<T, RepositoryAbstraction.Error>> {\n try {\n const record = await this.storageOperations.get(key, scope);\n\n if (!record) {\n return Result.fail(new KeyNotFoundError(key));\n }\n\n return Result.ok(record.value as T);\n } catch (error) {\n return Result.fail(new KeyValueStorageError(error as Error));\n }\n }\n\n async set(\n key: string,\n value: any,\n scope: string,\n options?: IKeyValueStoreSetOptions\n ): Promise<Result<void, RepositoryAbstraction.Error>> {\n try {\n await this.storageOperations.set(key, value, scope, options);\n return Result.ok();\n } catch (error) {\n return Result.fail(new KeyValueStorageError(error as Error));\n }\n }\n\n async delete(key: string, scope: string): Promise<Result<void, RepositoryAbstraction.Error>> {\n try {\n await this.storageOperations.delete(key, scope);\n return Result.ok();\n } catch (error) {\n return Result.fail(new KeyValueStorageError(error as Error));\n }\n }\n}\n\nexport const KeyValueStoreRepository = createImplementation({\n abstraction: RepositoryAbstraction,\n implementation: KeyValueStoreRepositoryImpl,\n dependencies: [KeyValueStorageOperations]\n});\n"],"names":["KeyValueStoreRepositoryImpl","storageOperations","key","scope","record","Result","KeyNotFoundError","error","KeyValueStorageError","value","options","KeyValueStoreRepository","createImplementation","RepositoryAbstraction","KeyValueStorageOperations"],"mappings":";;;AAeA,MAAMA;IACF,YAAoBC,iBAAsD,CAAE;aAAxDA,iBAAiB,GAAjBA;IAAyD;IAE7E,MAAM,IACFC,GAAW,EACXC,KAAa,EACkC;QAC/C,IAAI;YACA,MAAMC,SAAS,MAAM,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAACF,KAAKC;YAErD,IAAI,CAACC,QACD,OAAOC,OAAO,IAAI,CAAC,IAAIC,iBAAiBJ;YAG5C,OAAOG,OAAO,EAAE,CAACD,OAAO,KAAK;QACjC,EAAE,OAAOG,OAAO;YACZ,OAAOF,OAAO,IAAI,CAAC,IAAIG,qBAAqBD;QAChD;IACJ;IAEA,MAAM,IACFL,GAAW,EACXO,KAAU,EACVN,KAAa,EACbO,OAAkC,EACgB;QAClD,IAAI;YACA,MAAM,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAACR,KAAKO,OAAON,OAAOO;YACpD,OAAOL,OAAO,EAAE;QACpB,EAAE,OAAOE,OAAO;YACZ,OAAOF,OAAO,IAAI,CAAC,IAAIG,qBAAqBD;QAChD;IACJ;IAEA,MAAM,OAAOL,GAAW,EAAEC,KAAa,EAAsD;QACzF,IAAI;YACA,MAAM,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAACD,KAAKC;YACzC,OAAOE,OAAO,EAAE;QACpB,EAAE,OAAOE,OAAO;YACZ,OAAOF,OAAO,IAAI,CAAC,IAAIG,qBAAqBD;QAChD;IACJ;AACJ;AAEO,MAAMI,kDAA0BC,qBAAqB;IACxD,aAAaC;IACb,gBAAgBb;IAChB,cAAc;QAACc;KAA0B;AAC7C"}
1
+ {"version":3,"file":"features/keyValueStore/KeyValueStoreRepository.js","sources":["../../../src/features/keyValueStore/KeyValueStoreRepository.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { KeyValueStorageOperations } from \"./abstractions.js\";\nimport { KeyValueStoreRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport type { IKeyValueListParams } from \"./abstractions.js\";\nimport type { IKeyValueListResult } from \"./abstractions.js\";\nimport type { IKeyValueRecord } from \"./abstractions.js\";\nimport type { IKeyValueStoreSetOptions } from \"./abstractions.js\";\nimport type { IKeyValueDeleteOptions } from \"./abstractions.js\";\nimport { KeyNotFoundError } from \"./errors.js\";\nimport { KeyValueStorageError } from \"./errors.js\";\nimport { KeyValueInvalidCursorError } from \"./errors.js\";\nimport { KeyValueInvalidCollectionError } from \"./errors.js\";\nimport { KeyValueKeyTooLongError } from \"./errors.js\";\nimport { KeyValueConditionFailedError } from \"./errors.js\";\nimport { KeyValueInvalidConditionError } from \"./errors.js\";\n\nconst DEFAULT_LIST_LIMIT = 100;\nconst MAX_LIST_LIMIT = 1000;\n\nconst resolveLimit = (limit: number | undefined): number => {\n if (!limit || !Number.isFinite(limit)) {\n return DEFAULT_LIST_LIMIT;\n }\n const whole = Math.floor(limit);\n const atLeastOne = Math.max(whole, 1);\n return Math.min(atLeastOne, MAX_LIST_LIMIT);\n};\n\ninterface ICursor {\n collection: string;\n reverse: boolean;\n after: string;\n}\n\n/*\n * The cursor carries the key the previous page stopped at, with the collection and direction it was\n * read in, so it cannot quietly continue a different listing. Encoded so callers treat it as opaque\n * and do not build one by hand, which leaves room to change what it carries.\n */\nconst encodeCursor = (cursor: ICursor): string => {\n const json = JSON.stringify(cursor);\n return Buffer.from(json).toString(\"base64url\");\n};\n\nconst decodeCursor = (cursor: string): ICursor | undefined => {\n try {\n const json = Buffer.from(cursor, \"base64url\").toString(\"utf8\");\n const parsed = JSON.parse(json);\n if (\n typeof parsed?.collection !== \"string\" ||\n typeof parsed.reverse !== \"boolean\" ||\n typeof parsed.after !== \"string\"\n ) {\n return undefined;\n }\n return parsed;\n } catch {\n return undefined;\n }\n};\n\nconst isComparable = (value: unknown): boolean => {\n const type = typeof value;\n return type === \"string\" || type === \"number\" || type === \"boolean\";\n};\n\n/*\n * The types already allow one of `exists` or `equals`, of the right kind. This holds callers the\n * types do not reach, such as plain JavaScript, to the same: a condition the stores would read\n * differently, or not at all, must not become an unconditional write.\n */\nconst isValidCondition = (condition: unknown, allowNotExists: boolean): boolean => {\n if (typeof condition !== \"object\" || condition === null) {\n return false;\n }\n const { exists, equals } = condition as { exists?: unknown; equals?: unknown };\n if (exists !== undefined && equals !== undefined) {\n return false;\n }\n if (exists !== undefined) {\n return exists === true || (exists === false && allowNotExists);\n }\n return isComparable(equals);\n};\n\n/*\n * Both limits come from DynamoDB, where a collection member's key goes into a GSI sort key (1024\n * bytes at most) and the collection name into a GSI partition key (2048 bytes, shared with the\n * scope). Checked here rather than in the DynamoDB layer so every store rejects the same writes.\n */\nconst MAX_COLLECTION_BYTES = 1000;\nconst MAX_COLLECTION_KEY_BYTES = 1000;\n\nconst isValidCollection = (collection: unknown): collection is string => {\n return (\n typeof collection === \"string\" &&\n collection.length > 0 &&\n Buffer.byteLength(collection, \"utf8\") <= MAX_COLLECTION_BYTES\n );\n};\n\n/**\n * KeyValueStoreRepository implementation.\n *\n * This repository passes key and scope separately to storage operations.\n * The storage layer is responsible for handling scope-based partitioning.\n */\nclass KeyValueStoreRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(private storageOperations: KeyValueStorageOperations.Interface) {}\n\n async get<T = unknown>(\n key: string,\n scope: string\n ): Promise<Result<T, RepositoryAbstraction.Error>> {\n try {\n const record = await this.storageOperations.get(key, scope);\n\n if (!record) {\n return Result.fail(new KeyNotFoundError(key));\n }\n\n return Result.ok(record.value as T);\n } catch (error) {\n return Result.fail(new KeyValueStorageError(error as Error));\n }\n }\n\n async set(\n key: string,\n value: any,\n scope: string,\n options?: IKeyValueStoreSetOptions\n ): Promise<Result<void, RepositoryAbstraction.Error>> {\n if (options?.condition !== undefined && !isValidCondition(options.condition, true)) {\n return Result.fail(new KeyValueInvalidConditionError());\n }\n if (options?.collection !== undefined) {\n if (!isValidCollection(options.collection)) {\n return Result.fail(new KeyValueInvalidCollectionError(MAX_COLLECTION_BYTES));\n }\n if (Buffer.byteLength(key, \"utf8\") > MAX_COLLECTION_KEY_BYTES) {\n return Result.fail(new KeyValueKeyTooLongError(key, MAX_COLLECTION_KEY_BYTES));\n }\n }\n\n try {\n const written = await this.storageOperations.set(key, value, scope, options);\n if (!written) {\n return Result.fail(new KeyValueConditionFailedError(key));\n }\n return Result.ok();\n } catch (error) {\n return Result.fail(new KeyValueStorageError(error as Error));\n }\n }\n\n async delete(\n key: string,\n scope: string,\n options?: IKeyValueDeleteOptions\n ): Promise<Result<void, RepositoryAbstraction.Error>> {\n if (options?.condition !== undefined && !isValidCondition(options.condition, false)) {\n return Result.fail(new KeyValueInvalidConditionError());\n }\n try {\n const deleted = await this.storageOperations.delete(key, scope, options);\n if (!deleted) {\n return Result.fail(new KeyValueConditionFailedError(key));\n }\n return Result.ok();\n } catch (error) {\n return Result.fail(new KeyValueStorageError(error as Error));\n }\n }\n\n async list<T = unknown>(\n scope: string,\n params: IKeyValueListParams\n ): Promise<Result<IKeyValueListResult<T>, RepositoryAbstraction.Error>> {\n const { collection, cursor } = params;\n if (!isValidCollection(collection)) {\n return Result.fail(new KeyValueInvalidCollectionError(MAX_COLLECTION_BYTES));\n }\n\n let reverse = params.reverse ?? false;\n let after: string | undefined;\n if (cursor) {\n const decoded = decodeCursor(cursor);\n if (!decoded || decoded.collection !== collection) {\n return Result.fail(new KeyValueInvalidCursorError(cursor));\n }\n reverse = decoded.reverse;\n after = decoded.after;\n }\n\n const limit = resolveLimit(params.limit);\n\n try {\n const { items, lastKey } = await this.storageOperations.list({\n collection,\n scope,\n limit,\n reverse,\n after\n });\n\n let nextCursor: string | null = null;\n if (lastKey !== null) {\n nextCursor = encodeCursor({ collection, reverse, after: lastKey });\n }\n\n return Result.ok({\n items: items as IKeyValueRecord<T>[],\n cursor: nextCursor\n });\n } catch (error) {\n return Result.fail(new KeyValueStorageError(error as Error));\n }\n }\n}\n\nexport const KeyValueStoreRepository = createImplementation({\n abstraction: RepositoryAbstraction,\n implementation: KeyValueStoreRepositoryImpl,\n dependencies: [KeyValueStorageOperations]\n});\n"],"names":["DEFAULT_LIST_LIMIT","MAX_LIST_LIMIT","resolveLimit","limit","Number","whole","Math","atLeastOne","encodeCursor","cursor","json","JSON","Buffer","decodeCursor","parsed","isComparable","value","type","isValidCondition","condition","allowNotExists","exists","equals","undefined","MAX_COLLECTION_BYTES","MAX_COLLECTION_KEY_BYTES","isValidCollection","collection","KeyValueStoreRepositoryImpl","storageOperations","key","scope","record","Result","KeyNotFoundError","error","KeyValueStorageError","options","KeyValueInvalidConditionError","KeyValueInvalidCollectionError","KeyValueKeyTooLongError","written","KeyValueConditionFailedError","deleted","params","reverse","after","decoded","KeyValueInvalidCursorError","items","lastKey","nextCursor","KeyValueStoreRepository","createImplementation","RepositoryAbstraction","KeyValueStorageOperations"],"mappings":";;;AAiBA,MAAMA,qBAAqB;AAC3B,MAAMC,iBAAiB;AAEvB,MAAMC,eAAe,CAACC;IAClB,IAAI,CAACA,SAAS,CAACC,OAAO,QAAQ,CAACD,QAC3B,OAAOH;IAEX,MAAMK,QAAQC,KAAK,KAAK,CAACH;IACzB,MAAMI,aAAaD,KAAK,GAAG,CAACD,OAAO;IACnC,OAAOC,KAAK,GAAG,CAACC,YAAYN;AAChC;AAaA,MAAMO,eAAe,CAACC;IAClB,MAAMC,OAAOC,KAAK,SAAS,CAACF;IAC5B,OAAOG,OAAO,IAAI,CAACF,MAAM,QAAQ,CAAC;AACtC;AAEA,MAAMG,eAAe,CAACJ;IAClB,IAAI;QACA,MAAMC,OAAOE,OAAO,IAAI,CAACH,QAAQ,aAAa,QAAQ,CAAC;QACvD,MAAMK,SAASH,KAAK,KAAK,CAACD;QAC1B,IACI,AAA8B,YAA9B,OAAOI,QAAQ,cACf,AAA0B,aAA1B,OAAOA,OAAO,OAAO,IACrB,AAAwB,YAAxB,OAAOA,OAAO,KAAK,EAEnB;QAEJ,OAAOA;IACX,EAAE,OAAM;QACJ;IACJ;AACJ;AAEA,MAAMC,eAAe,CAACC;IAClB,MAAMC,OAAO,OAAOD;IACpB,OAAOC,AAAS,aAATA,QAAqBA,AAAS,aAATA,QAAqBA,AAAS,cAATA;AACrD;AAOA,MAAMC,mBAAmB,CAACC,WAAoBC;IAC1C,IAAI,AAAqB,YAArB,OAAOD,aAA0BA,AAAc,SAAdA,WACjC,OAAO;IAEX,MAAM,EAAEE,MAAM,EAAEC,MAAM,EAAE,GAAGH;IAC3B,IAAIE,AAAWE,WAAXF,UAAwBC,AAAWC,WAAXD,QACxB,OAAO;IAEX,IAAID,AAAWE,WAAXF,QACA,OAAOA,AAAW,SAAXA,UAAoBA,AAAW,UAAXA,UAAoBD;IAEnD,OAAOL,aAAaO;AACxB;AAOA,MAAME,uBAAuB;AAC7B,MAAMC,2BAA2B;AAEjC,MAAMC,oBAAoB,CAACC,aAEnB,AAAsB,YAAtB,OAAOA,cACPA,WAAW,MAAM,GAAG,KACpBf,OAAO,UAAU,CAACe,YAAY,WAAWH;AAUjD,MAAMI;IACF,YAAoBC,iBAAsD,CAAE;aAAxDA,iBAAiB,GAAjBA;IAAyD;IAE7E,MAAM,IACFC,GAAW,EACXC,KAAa,EACkC;QAC/C,IAAI;YACA,MAAMC,SAAS,MAAM,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAACF,KAAKC;YAErD,IAAI,CAACC,QACD,OAAOC,OAAO,IAAI,CAAC,IAAIC,iBAAiBJ;YAG5C,OAAOG,OAAO,EAAE,CAACD,OAAO,KAAK;QACjC,EAAE,OAAOG,OAAO;YACZ,OAAOF,OAAO,IAAI,CAAC,IAAIG,qBAAqBD;QAChD;IACJ;IAEA,MAAM,IACFL,GAAW,EACXd,KAAU,EACVe,KAAa,EACbM,OAAkC,EACgB;QAClD,IAAIA,SAAS,cAAcd,UAAa,CAACL,iBAAiBmB,QAAQ,SAAS,EAAE,OACzE,OAAOJ,OAAO,IAAI,CAAC,IAAIK;QAE3B,IAAID,SAAS,eAAed,QAAW;YACnC,IAAI,CAACG,kBAAkBW,QAAQ,UAAU,GACrC,OAAOJ,OAAO,IAAI,CAAC,IAAIM,+BAA+Bf;YAE1D,IAAIZ,OAAO,UAAU,CAACkB,KAAK,UAAUL,0BACjC,OAAOQ,OAAO,IAAI,CAAC,IAAIO,wBAAwBV,KAAKL;QAE5D;QAEA,IAAI;YACA,MAAMgB,UAAU,MAAM,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAACX,KAAKd,OAAOe,OAAOM;YACpE,IAAI,CAACI,SACD,OAAOR,OAAO,IAAI,CAAC,IAAIS,6BAA6BZ;YAExD,OAAOG,OAAO,EAAE;QACpB,EAAE,OAAOE,OAAO;YACZ,OAAOF,OAAO,IAAI,CAAC,IAAIG,qBAAqBD;QAChD;IACJ;IAEA,MAAM,OACFL,GAAW,EACXC,KAAa,EACbM,OAAgC,EACkB;QAClD,IAAIA,SAAS,cAAcd,UAAa,CAACL,iBAAiBmB,QAAQ,SAAS,EAAE,QACzE,OAAOJ,OAAO,IAAI,CAAC,IAAIK;QAE3B,IAAI;YACA,MAAMK,UAAU,MAAM,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAACb,KAAKC,OAAOM;YAChE,IAAI,CAACM,SACD,OAAOV,OAAO,IAAI,CAAC,IAAIS,6BAA6BZ;YAExD,OAAOG,OAAO,EAAE;QACpB,EAAE,OAAOE,OAAO;YACZ,OAAOF,OAAO,IAAI,CAAC,IAAIG,qBAAqBD;QAChD;IACJ;IAEA,MAAM,KACFJ,KAAa,EACba,MAA2B,EACyC;QACpE,MAAM,EAAEjB,UAAU,EAAElB,MAAM,EAAE,GAAGmC;QAC/B,IAAI,CAAClB,kBAAkBC,aACnB,OAAOM,OAAO,IAAI,CAAC,IAAIM,+BAA+Bf;QAG1D,IAAIqB,UAAUD,OAAO,OAAO,IAAI;QAChC,IAAIE;QACJ,IAAIrC,QAAQ;YACR,MAAMsC,UAAUlC,aAAaJ;YAC7B,IAAI,CAACsC,WAAWA,QAAQ,UAAU,KAAKpB,YACnC,OAAOM,OAAO,IAAI,CAAC,IAAIe,2BAA2BvC;YAEtDoC,UAAUE,QAAQ,OAAO;YACzBD,QAAQC,QAAQ,KAAK;QACzB;QAEA,MAAM5C,QAAQD,aAAa0C,OAAO,KAAK;QAEvC,IAAI;YACA,MAAM,EAAEK,KAAK,EAAEC,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC;gBACzDvB;gBACAI;gBACA5B;gBACA0C;gBACAC;YACJ;YAEA,IAAIK,aAA4B;YAChC,IAAID,AAAY,SAAZA,SACAC,aAAa3C,aAAa;gBAAEmB;gBAAYkB;gBAAS,OAAOK;YAAQ;YAGpE,OAAOjB,OAAO,EAAE,CAAC;gBACb,OAAOgB;gBACP,QAAQE;YACZ;QACJ,EAAE,OAAOhB,OAAO;YACZ,OAAOF,OAAO,IAAI,CAAC,IAAIG,qBAAqBD;QAChD;IACJ;AACJ;AAEO,MAAMiB,kDAA0BC,qBAAqB;IACxD,aAAaC;IACb,gBAAgB1B;IAChB,cAAc;QAAC2B;KAA0B;AAC7C"}